"use strict";function string2array(a){return a.split(",").map(Function.prototype.call,String.prototype.trim)}function pasteHtmlAtCaret(a){var b,c;if(window.getSelection){if(b=window.getSelection(),b.getRangeAt&&b.rangeCount){c=b.getRangeAt(0),c.deleteContents();var d=document.createElement("div");d.innerHTML=a;for(var e,f,g=document.createDocumentFragment();e=d.firstChild;)f=g.appendChild(e);c.insertNode(g),f&&(c=c.cloneRange(),c.setStartAfter(f),c.collapse(!0),b.removeAllRanges(),b.addRange(c))}}else document.selection&&"Control"!=document.selection.type&&document.selection.createRange().pasteHTML(a)}var VERSION="3.0.16";angular.module("ngWig",["ngwig-app-templates"]),angular.ngWig={version:VERSION},angular.module("ngWig").component("ngWig",{bindings:{content:"=ngModel",options:"",onPaste:"&",buttons:"@",beforeExecCommand:"&",afterExecCommand:"&",placeholder:"@?"},require:{ngModelController:"ngModel"},templateUrl:"ng-wig/views/ng-wig.html",controller:["$scope","$element","$q","$attrs","$window","$document","ngWigToolbar",function(a,b,c,d,e,f,g){var h=this,i=angular.element(b[0].querySelector("#ng-wig-editable"));this.required="required"in d,this.isSourceModeAllowed="sourceModeAllowed"in d,this.editMode=!1,d.$observe("disabled",function(a){h.disabled=a,i.attr("contenteditable",!a)}),this.isEditorActive=function(){return i[0]===f[0].activeElement},this.toggleEditMode=function(){h.editMode=!h.editMode,e.getSelection().removeAllRanges&&e.getSelection().removeAllRanges()},this.execCommand=function(a,b){if(h.editMode)return!1;if(f[0].queryCommandSupported&&!f[0].queryCommandSupported(a))throw'The command "'+a+'" is not supported';if("createlink"!==a&&"insertImage"!==a||(b=e.prompt("Please enter the URL","http://"))){h.beforeExecCommand({command:a,options:b});var c=f[0].getSelection().toString();"createlink"===a&&""===c?f[0].execCommand("insertHtml",!1,''+b+""):f[0].execCommand(a,!1,b),h.afterExecCommand({command:a,options:b}),i.length&&i[0].focus()}},this.$onInit=function(){h.toolbarButtons=g.getToolbarButtons(h.buttons&&string2array(h.buttons));var b=Boolean(h.placeholder);h.ngModelController.$render=function(){return h.ngModelController.$viewValue?i.html(h.ngModelController.$viewValue):b?i.empty():i.html("
")},i.bind("blur keyup change focus click",function(){!b||i.html().length&&"