From 6578b37825a6b9aa938242733b836c8336c8373d Mon Sep 17 00:00:00 2001 From: Anthony Blackshaw Date: Fri, 1 Apr 2016 17:54:33 +0100 Subject: [PATCH] Updated ContentEdit dependancy with support for behaviours (ContentEdit 1.1.0) --- build/content-tools.js | 65 +++++++++++++++++++++---------- build/content-tools.min.js | 12 +++--- external/scripts/content-edit.js | 66 ++++++++++++++++++++++---------- 3 files changed, 97 insertions(+), 46 deletions(-) diff --git a/build/content-tools.js b/build/content-tools.js index fe17502b..5b451496 100644 --- a/build/content-tools.js +++ b/build/content-tools.js @@ -2173,7 +2173,7 @@ if (allowed === void 0) { return this._behaviours[behaviour]; } - return this._behaviours[name] = allowed; + return this._behaviours[behaviour] = allowed; }; Element.prototype.createDraggingDOMElement = function() { @@ -2199,6 +2199,9 @@ Element.prototype.drop = function(element, placement) { var root; + if (!this.can('drop')) { + return; + } root = ContentEdit.Root.get(); if (element) { element._removeCSSClass('ce-element--drop'); @@ -4036,6 +4039,7 @@ function ListItem(attributes) { ListItem.__super__.constructor.call(this, 'li', attributes); + this._behaviours['indent'] = true; } ListItem.prototype.cssTypeName = function() { @@ -4078,6 +4082,9 @@ ListItem.prototype.indent = function() { var sibling; + if (!this.can('indent')) { + return; + } if (this.parent().children.indexOf(this) === 0) { return; } @@ -4110,6 +4117,9 @@ ListItem.prototype.unindent = function() { var child, grandParent, i, itemIndex, list, parent, parentIndex, selection, sibling, siblings, text, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1; + if (!this.can('indent')) { + return; + } parent = this.parent(); grandParent = parent.parent(); siblings = parent.children.slice(parent.children.indexOf(this) + 1, parent.children.length); @@ -4266,6 +4276,13 @@ return ContentEdit.Element.prototype.blur.call(this); }; + ListItemText.prototype.can = function(behaviour, allowed) { + if (allowed) { + throw new Error('Cannot set behaviour for ListItemText'); + } + return this.parent().can(behaviour); + }; + ListItemText.prototype.html = function(indent) { var content; if (indent == null) { @@ -4831,6 +4848,13 @@ return ContentEdit.Element.prototype.blur.call(this); }; + TableCellText.prototype.can = function(behaviour, allowed) { + if (allowed) { + throw new Error('Cannot set behaviour for ListItemText'); + } + return this.parent().can(behaviour); + }; + TableCellText.prototype.html = function(indent) { var content; if (indent == null) { @@ -4875,33 +4899,35 @@ ev.preventDefault(); cell = this.parent(); row = cell.parent(); + if (!(row.isEmpty() && row.can('remove'))) { + return; + } if (this.content.length() === 0 && row.children.indexOf(cell) === 0) { - if (row.isEmpty() && this.can('remove')) { - previous = this.previousContent(); - if (previous) { - previous.focus(); - selection = new ContentSelect.Range(previous.content.length(), previous.content.length()); - selection.select(previous.domElement()); - } - return row.parent().detach(row); + previous = this.previousContent(); + if (previous) { + previous.focus(); + selection = new ContentSelect.Range(previous.content.length(), previous.content.length()); + selection.select(previous.domElement()); } + return row.parent().detach(row); } }; TableCellText.prototype._keyDelete = function(ev) { var lastChild, nextElement, row, selection; row = this.parent().parent(); - if (row.isEmpty() && this.can('remove')) { - ev.preventDefault(); - lastChild = row.children[row.children.length - 1]; - nextElement = lastChild.tableCellText().nextContent(); - if (nextElement) { - nextElement.focus(); - selection = new ContentSelect.Range(0, 0); - selection.select(nextElement.domElement()); - } - return row.parent().detach(row); + if (!(row.isEmpty() && row.can('remove'))) { + return; + } + ev.preventDefault(); + lastChild = row.children[row.children.length - 1]; + nextElement = lastChild.tableCellText().nextContent(); + if (nextElement) { + nextElement.focus(); + selection = new ContentSelect.Range(0, 0); + selection.select(nextElement.domElement()); } + return row.parent().detach(row); }; TableCellText.prototype._keyDown = function(ev) { @@ -5013,7 +5039,6 @@ })(ContentEdit.Text); }).call(this); - (function() { var AttributeUI, CropMarksUI, StyleUI, _EditorApp, __hasProp = {}.hasOwnProperty, diff --git a/build/content-tools.min.js b/build/content-tools.min.js index 742f1435..3b75852c 100644 --- a/build/content-tools.min.js +++ b/build/content-tools.min.js @@ -1,7 +1,7 @@ /*! ContentTools v1.2.1 by Anthony Blackshaw (https://github.com/anthonyjb) */ -(function(){window.FSM={},FSM.Machine=function(){function a(a){this.context=a,this._stateTransitions={},this._stateTransitionsAny={},this._defaultTransition=null,this._initialState=null,this._currentState=null}return a.prototype.addTransition=function(a,b,c,d){return c||(c=b),this._stateTransitions[[a,b]]=[c,d]},a.prototype.addTransitions=function(a,b,c,d){var e,f,g,h;for(c||(c=b),h=[],f=0,g=a.length;g>f;f++)e=a[f],h.push(this.addTransition(e,b,c,d));return h},a.prototype.addTransitionAny=function(a,b,c){return b||(b=a),this._stateTransitionsAny[a]=[b,c]},a.prototype.setDefaultTransition=function(a,b){return this._defaultTransition=[a,b]},a.prototype.getTransition=function(a,b){if(this._stateTransitions[[a,b]])return this._stateTransitions[[a,b]];if(this._stateTransitionsAny[b])return this._stateTransitionsAny[b];if(this._defaultTransition)return this._defaultTransition;throw new Error("Transition is undefined: ("+a+", "+b+")")},a.prototype.getCurrentState=function(){return this._currentState},a.prototype.setInitialState=function(a){return this._initialState=a,this._currentState?void 0:this.reset()},a.prototype.reset=function(){return this._currentState=this._initialState},a.prototype.process=function(a){var b;return b=this.getTransition(a,this._currentState),b[1]&&b[1].call(this.context||(this.context=this),a),this._currentState=b[0]},a}()}).call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=[].slice,A=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};window.HTMLString={},HTMLString.String=function(){function a(a,b){null==b&&(b=!1),this._preserveWhitespace=b,a?(null===HTMLString.String._parser&&(HTMLString.String._parser=new y),this.characters=HTMLString.String._parser.parse(a,this._preserveWhitespace).characters):this.characters=[]}return a._parser=null,a.prototype.isWhitespace=function(){var a,b,c,d;for(d=this.characters,b=0,c=d.length;c>b;b++)if(a=d[b],!a.isWhitespace())return!1;return!0},a.prototype.length=function(){return this.characters.length},a.prototype.preserveWhitespace=function(){return this._preserveWhitespace},a.prototype.capitalize=function(){var a,b;return b=this.copy(),b.length()&&(a=b.characters[0]._c.toUpperCase(),b.characters[0]._c=a),b},a.prototype.charAt=function(a){return this.characters[a].copy()},a.prototype.concat=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(g=2<=arguments.length?z.call(arguments,0,i=arguments.length-1):(i=0,[]),c=arguments[i++],"undefined"!=typeof c&&"boolean"!=typeof c&&(g.push(c),c=!0),e=this.copy(),j=0,m=g.length;m>j;j++)if(f=g[j],0!==f.length){if(h=f,"string"==typeof f&&(h=new HTMLString.String(f,this._preserveWhitespace)),c&&e.length())for(b=e.charAt(e.length()-1),d=b.tags(),b.isTag()&&d.shift(),"string"!=typeof f&&(h=h.copy()),p=h.characters,k=0,n=p.length;n>k;k++)a=p[k],a.addTags.apply(a,d);for(q=h.characters,l=0,o=q.length;o>l;l++)a=q[l],e.characters.push(a)}return e},a.prototype.contains=function(a){var b,c,d,e,f,g,h;if("string"==typeof a)return this.text().indexOf(a)>-1;for(d=0;d<=this.length()-a.length();){for(c=!0,h=a.characters,e=f=0,g=h.length;g>f;e=++f)if(b=h[e],!b.eq(this.characters[e+d])){c=!1;break}if(c)return!0;d++}return!1},a.prototype.endsWith=function(a){var b,c,d,e,f,g;if("string"==typeof a)return""===a||this.text().slice(-a.length)===a;for(c=this.characters.slice().reverse(),g=a.characters.slice().reverse(),d=e=0,f=g.length;f>e;d=++e)if(b=g[d],!b.eq(c[d]))return!1;return!0},a.prototype.format=function(){var a,b,c,d,e,f,g;for(b=arguments[0],f=arguments[1],e=3<=arguments.length?z.call(arguments,2):[],0>f&&(f=this.length()+f+1),0>b&&(b=this.length()+b),d=this.copy(),c=g=b;f>=b?f>g:g>f;c=f>=b?++g:--g)a=d.characters[c],a.addTags.apply(a,e);return d},a.prototype.hasTags=function(){var a,b,c,d,e,f,g,h;for(d=2<=arguments.length?z.call(arguments,0,e=arguments.length-1):(e=0,[]),c=arguments[e++],"undefined"!=typeof c&&"boolean"!=typeof c&&(d.push(c),c=!1),b=!1,h=this.characters,f=0,g=h.length;g>f;f++)if(a=h[f],a.hasTags.apply(a,d))b=!0;else if(c)return!1;return b},a.prototype.html=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;for(e="",h=[],f=[],c=[],t=this.characters,j=0,n=t.length;n>j;j++){for(a=t[j],c=[],u=h.slice().reverse(),k=0,o=u.length;o>k;k++)if(g=u[k],c.push(g),!a.hasTags(g)){for(l=0,p=c.length;p>l;l++)b=c[l],e+=b.tail(),h.pop(),f.pop();c=[]}for(v=a._tags,m=0,q=v.length;q>m;m++)i=v[m],-1===f.indexOf(i.head())&&(i.selfClosing()||(d=i.head(),e+=d,h.push(i),f.push(d)));a._tags.length>0&&a._tags[0].selfClosing()&&(e+=a._tags[0].head()),e+=a.c()}for(w=h.reverse(),s=0,r=w.length;r>s;s++)i=w[s],e+=i.tail();return e},a.prototype.indexOf=function(a,b){var c,d,e,f,g,h;if(null==b&&(b=0),0>b&&(b=0),"string"==typeof a)return this.text().indexOf(a,b);for(;b<=this.length()-a.length();){for(d=!0,h=a.characters,e=f=0,g=h.length;g>f;e=++f)if(c=h[e],!c.eq(this.characters[e+b])){d=!1;break}if(d)return b;b++}return-1},a.prototype.insert=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;if(null==c&&(c=!0),e=this.slice(0,a),j=this.slice(a),0>a&&(a=this.length()+a),h=b,"string"==typeof b&&(h=new HTMLString.String(b,this._preserveWhitespace)),c&&a>0)for(f=this.charAt(a-1),g=f.tags(),f.isTag()&&g.shift(),"string"!=typeof b&&(h=h.copy()),q=h.characters,k=0,n=q.length;n>k;k++)d=q[k],d.addTags.apply(d,g);for(i=e,r=h.characters,l=0,o=r.length;o>l;l++)d=r[l],i.characters.push(d);for(s=j.characters,m=0,p=s.length;p>m;m++)d=s[m],i.characters.push(d);return i},a.prototype.lastIndexOf=function(a,b){var c,d,e,f,g,h,i,j,k;if(null==b&&(b=0),0>b&&(b=0),d=this.characters.slice(b).reverse(),b=0,"string"==typeof a){if(!this.contains(a))return-1;for(a=a.split("").reverse();b<=d.length-a.length;){for(e=!0,g=0,f=h=0,j=a.length;j>h;f=++h)if(c=a[f],d[f+b].isTag()&&(g+=1),c!==d[g+f+b].c()){e=!1;break}if(e)return b;b++}return-1}for(a=a.characters.slice().reverse();b<=d.length-a.length;){for(e=!0,f=i=0,k=a.length;k>i;f=++i)if(c=a[f],!c.eq(d[f+b])){e=!1;break}if(e)return b;b++}return-1},a.prototype.optimize=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J;for(i=[],g=[],e=null,D=this.characters.slice().reverse(),p=0,t=D.length;t>p;p++){for(a=D[p],a._runLengthMap={},a._runLengthMapSize=0,c=[],E=i.slice().reverse(),q=0,u=E.length;u>q;q++)if(h=E[q],c.push(h),!a.hasTags(h)){for(r=0,v=c.length;v>r;r++)b=c[r],i.pop(),g.pop();c=[]}for(F=a._tags,s=0,w=F.length;w>s;s++)o=F[s],-1===g.indexOf(o.head())&&(o.selfClosing()||(i.push(o),g.push(o.head())));for(A=0,x=i.length;x>A;A++)o=i[A],d=o.head(),e?(a._runLengthMap[d]||(a._runLengthMap[d]=[o,0]),m=0,e._runLengthMap[d]&&(m=e._runLengthMap[d][1]),a._runLengthMap[d][1]=m+1):a._runLengthMap[d]=[o,1];e=a}for(k=function(a,b){return b[1]-a[1]},G=this.characters,J=[],B=0,y=G.length;y>B;B++)if(a=G[B],f=a._tags.length,!(f>0&&a._tags[0].selfClosing()&&3>f||2>f)){l=[],H=a._runLengthMap;for(o in H)j=H[o],l.push(j);for(l.sort(k),I=a._tags.slice(),C=0,z=I.length;z>C;C++)o=I[C],o.selfClosing()||a.removeTags(o);J.push(a.addTags.apply(a,function(){var a,b,c;for(c=[],b=0,a=l.length;a>b;b++)n=l[b],c.push(n[0]);return c}()))}return J},a.prototype.slice=function(a,b){var c,d;return d=new HTMLString.String("",this._preserveWhitespace),d.characters=function(){var d,e,f,g;for(f=this.characters.slice(a,b),g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(c.copy());return g}.call(this),d},a.prototype.split=function(a,b){var c,d,e,f,g,h,i,j;for(null==a&&(a=""),null==b&&(b=0),g=0,c=0,f=[0];;){if(b>0&&c>b)break;if(e=this.indexOf(a,g),-1===e||e===this.length()-1)break;f.push(e),g=e+1}for(f.push(this.length()),h=[],d=i=0,j=f.length-2;j>=0?j>=i:i>=j;d=j>=0?++i:--i)h.push(this.slice(f[d],f[d+1]));return h},a.prototype.startsWith=function(a){var b,c,d,e,f;if("string"==typeof a)return this.text().slice(0,a.length)===a;for(f=a.characters,c=d=0,e=f.length;e>d;c=++d)if(b=f[c],!b.eq(this.characters[c]))return!1;return!0},a.prototype.substr=function(a,b){return 0>=b?new HTMLString.String("",this._preserveWhitespace):(0>a&&(a=this.length()+a),void 0===b&&(b=this.length()-a),this.slice(a,a+b))},a.prototype.substring=function(a,b){return void 0===b&&(b=this.length()),this.slice(a,b)},a.prototype.text=function(){var a,b,c,d,e;for(b="",e=this.characters,c=0,d=e.length;d>c;c++)a=e[c],a.isTag()?a.isTag("br")&&(b+="\n"):b+=(" "!==a.c(),a.c());return this.constructor.decode(b)},a.prototype.toLowerCase=function(){var a,b,c,d,e;for(b=this.copy(),e=b.characters,c=0,d=e.length;d>c;c++)a=e[c],1===a._c.length&&(a._c=a._c.toLowerCase());return b},a.prototype.toUpperCase=function(){var a,b,c,d,e;for(b=this.copy(),e=b.characters,c=0,d=e.length;d>c;c++)a=e[c],1===a._c.length&&(a._c=a._c.toUpperCase());return b},a.prototype.trim=function(){var a,b,c,d,e,f,g,h,i,j;for(i=this.characters,b=e=0,g=i.length;g>e&&(a=i[b],a.isWhitespace());b=++e);for(j=this.characters.slice().reverse(),d=f=0,h=j.length;h>f&&(a=j[d],a.isWhitespace());d=++f);return d=this.length()-d-1,c=new HTMLString.String("",this._preserveWhitespace),c.characters=function(){var c,e,f,g;for(f=this.characters.slice(b,+d+1||9e9),g=[],c=0,e=f.length;e>c;c++)a=f[c],g.push(a.copy());return g}.call(this),c},a.prototype.trimLeft=function(){var a,b,c,d,e,f,g;for(d=this.length()-1,g=this.characters,b=e=0,f=g.length;f>e&&(a=g[b],a.isWhitespace());b=++e);return c=new HTMLString.String("",this._preserveWhitespace),c.characters=function(){var c,e,f,g;for(f=this.characters.slice(b,+d+1||9e9),g=[],c=0,e=f.length;e>c;c++)a=f[c],g.push(a.copy());return g}.call(this),c},a.prototype.trimRight=function(){var a,b,c,d,e,f,g;for(b=0,g=this.characters.slice().reverse(),d=e=0,f=g.length;f>e&&(a=g[d],a.isWhitespace());d=++e);return d=this.length()-d-1,c=new HTMLString.String("",this._preserveWhitespace),c.characters=function(){var c,e,f,g;for(f=this.characters.slice(b,+d+1||9e9),g=[],c=0,e=f.length;e>c;c++)a=f[c],g.push(a.copy());return g}.call(this),c},a.prototype.unformat=function(){var a,b,c,d,e,f,g;for(b=arguments[0],f=arguments[1],e=3<=arguments.length?z.call(arguments,2):[],0>f&&(f=this.length()+f+1),0>b&&(b=this.length()+b),d=this.copy(),c=g=b;f>=b?f>g:g>f;c=f>=b?++g:--g)a=d.characters[c],a.removeTags.apply(a,e);return d},a.prototype.copy=function(){var a,b;return b=new HTMLString.String("",this._preserveWhitespace),b.characters=function(){var b,c,d,e;for(d=this.characters,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.copy());return e}.call(this),b},a.encode=function(a){var b;return b=document.createElement("textarea"),b.textContent=a,b.innerHTML},a.decode=function(a){var b;return b=document.createElement("textarea"),b.innerHTML=a,b.textContent},a}(),a="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-_$".split(""),b=a.concat("1234567890".split("")),h=b.concat([":"]),q=b.concat(["#"]),t=b.concat([":"]),n=1,p=2,s=3,r=4,o=5,w=6,u=7,x=8,v=9,j=10,g=11,i=12,c=13,m=14,k=15,l=16,e=17,f=18,d=19,y=function(){function y(){this.fsm=new FSM.Machine(this),this.fsm.setInitialState(n),this.fsm.addTransitionAny(n,null,function(a){return this._pushChar(a)}),this.fsm.addTransition("<",n,s),this.fsm.addTransition("&",n,p),this.fsm.addTransitions(q,p,null,function(a){return this.entity+=a}),this.fsm.addTransition(";",p,n,function(){return this._pushChar("&"+this.entity+";"),this.entity=""}),this.fsm.addTransitions([" ","\n"],s),this.fsm.addTransitions(a,s,r,function(){return this._back()}),this.fsm.addTransition("/",s,o),this.fsm.addTransitions([" ","\n"],r),this.fsm.addTransitions(a,r,w,function(){return this._back()}),this.fsm.addTransitions([" ","\n"],o),this.fsm.addTransitions(a,o,u,function(){return this._back()}),this.fsm.addTransitions(t,w,null,function(a){return this.tagName+=a}),this.fsm.addTransitions([" ","\n"],w,j),this.fsm.addTransition("/",w,x,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",w,n,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],x),this.fsm.addTransition(">",x,n,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],j),this.fsm.addTransition("/",j,x,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",j,n,function(){return this._pushTag()}),this.fsm.addTransitions(a,j,g,function(){return this._back()}),this.fsm.addTransitions(t,u,null,function(a){return this.tagName+=a}),this.fsm.addTransitions([" ","\n"],u,v),this.fsm.addTransition(">",u,n,function(){return this._popTag()}),this.fsm.addTransitions([" ","\n"],v),this.fsm.addTransition(">",v,n,function(){return this._popTag()}),this.fsm.addTransitions(h,g,null,function(a){return this.attributeName+=a}),this.fsm.addTransitions([" ","\n"],g,i),this.fsm.addTransition("=",g,c),this.fsm.addTransitions([" ","\n"],i),this.fsm.addTransition("=",i,c),this.fsm.addTransitions(">",g,j,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitionAny(i,j,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitions([" ","\n"],c),this.fsm.addTransition("'",c,m),this.fsm.addTransition('"',c,k),this.fsm.addTransitions(b.concat(["&"],c,l,function(){return this._back()})),this.fsm.addTransition(" ",l,j,function(){return this._pushAttribute()}),this.fsm.addTransitions(["/",">"],l,j,function(){return this._back(),this._pushAttribute()}),this.fsm.addTransition("&",l,e),this.fsm.addTransitionAny(l,null,function(a){return this.attributeValue+=a}),this.fsm.addTransition("'",m,j,function(){return this._pushAttribute()}),this.fsm.addTransition("&",m,f),this.fsm.addTransitionAny(m,null,function(a){return this.attributeValue+=a}),this.fsm.addTransition('"',k,j,function(){return this._pushAttribute()}),this.fsm.addTransition("&",k,d),this.fsm.addTransitionAny(k,null,function(a){return this.attributeValue+=a}),this.fsm.addTransitions(q,e,null,function(a){return this.entity+=a}),this.fsm.addTransitions(q,f,function(a){return this.entity+=a}),this.fsm.addTransitions(q,d,null,function(a){return this.entity+=a}),this.fsm.addTransition(";",e,l,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",f,m,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",d,k,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""})}return y.prototype._back=function(){return this.head--},y.prototype._pushAttribute=function(){return this.attributes[this.attributeName]=this.attributeValue,this.attributeName="",this.attributeValue=""},y.prototype._pushChar=function(a){var b,c;return b=new HTMLString.Character(a,this.tags),this._preserveWhitespace?void this.string.characters.push(b):!this.string.length()||b.isTag()||b.isEntity()||!b.isWhitespace()||(c=this.string.characters[this.string.length()-1],!c.isWhitespace()||c.isTag()||c.isEntity())?this.string.characters.push(b):void 0},y.prototype._pushTag=function(){var a,b;return a=new HTMLString.Tag(this.tagName,this.attributes),this.tags.push(a),a.selfClosing()&&(this._pushChar(""),this.tags.pop(),!this.selfClosed&&(b=this.tagName,A.call(HTMLString.Tag.SELF_CLOSING,b)>=0)&&this.fsm.reset()),this.tagName="",this.selfClosed=!1,this.attributes={}},y.prototype._popTag=function(){for(var a,b;;)if(b=this.tags.pop(),this.string.length()&&(a=this.string.characters[this.string.length()-1],a.isTag()||a.isEntity()||!a.isWhitespace()||a.removeTags(b)),b.name()===this.tagName.toLowerCase())break;return this.tagName=""},y.prototype.parse=function(a,b){var c,d;for(this._preserveWhitespace=b,this.reset(),a=this.preprocess(a),this.fsm.parser=this;this.head> "+d)}this.head++}return this.string},y.prototype.preprocess=function(a){return a=a.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),a=a.replace(//g,""),this._preserveWhitespace||(a=a.replace(/\s+/g," ")),a},y.prototype.reset=function(){return this.fsm.reset(),this.head=0,this.string=new HTMLString.String,this.entity="",this.tags=[],this.tagName="",this.selfClosing=!1,this.attributes={},this.attributeName="",this.attributeValue=""},y}(),HTMLString.Tag=function(){function a(a,b){var c,d;this._name=a.toLowerCase(),this._selfClosing=HTMLString.Tag.SELF_CLOSING[this._name]===!0,this._head=null,this._attributes={};for(c in b)d=b[c],this._attributes[c]=d}return a.SELF_CLOSING={area:!0,base:!0,br:!0,hr:!0,img:!0,input:!0,"link meta":!0,wbr:!0},a.prototype.head=function(){var a,b,c,d;if(!this._head){a=[],d=this._attributes;for(b in d)c=d[b],a.push(c?""+b+'="'+c+'"':""+b);a.sort(),a.unshift(this._name),this._head="<"+a.join(" ")+">"}return this._head},a.prototype.name=function(){return this._name},a.prototype.selfClosing=function(){return this._selfClosing},a.prototype.tail=function(){return this._selfClosing?"":""},a.prototype.attr=function(a,b){return void 0===b?this._attributes[a]:(this._attributes[a]=b,this._head=null)},a.prototype.removeAttr=function(a){return void 0!==this._attributes[a]?delete this._attributes[a]:void 0},a.prototype.copy=function(){return new HTMLString.Tag(this._name,this._attributes)},a}(),HTMLString.Character=function(){function a(a,b){this._c=a,a.length>1&&(this._c=a.toLowerCase()),this._tags=[],this.addTags.apply(this,b)}return a.prototype.c=function(){return this._c},a.prototype.isEntity=function(){return this._c.length>1},a.prototype.isTag=function(a){return 0!==this._tags.length&&this._tags[0].selfClosing()?a&&this._tags[0].name()!==a?!1:!0:!1},a.prototype.isWhitespace=function(){var a;return" "===(a=this._c)||"\n"===a||" "===a||this.isTag("br")},a.prototype.tags=function(){var a;return function(){var b,c,d,e;for(d=this._tags,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.copy());return e}.call(this)},a.prototype.addTags=function(){var a,b,c,d,e;for(b=1<=arguments.length?z.call(arguments,0):[],e=[],c=0,d=b.length;d>c;c++)a=b[c],a.selfClosing()?this.isTag()||this._tags.unshift(a.copy()):e.push(this._tags.push(a.copy()));return e},a.prototype.eq=function(a){var b,c,d,e,f,g,h,i;if(this.c()!==a.c())return!1;if(this._tags.length!==a._tags.length)return!1;for(c={},h=this._tags,d=0,f=h.length;f>d;d++)b=h[d],c[b.head()]=!0;for(i=a._tags,e=0,g=i.length;g>e;e++)if(b=i[e],!c[b.head()])return!1;return!0},a.prototype.hasTags=function(){var a,b,c,d,e,f,g,h,i;for(d=1<=arguments.length?z.call(arguments,0):[],c={},b={},i=this._tags,e=0,g=i.length;g>e;e++)a=i[e],c[a.name()]=!0,b[a.head()]=!0;for(f=0,h=d.length;h>f;f++)if(a=d[f],"string"==typeof a){if(void 0===c[a])return!1}else if(void 0===b[a.head()])return!1;return!0},a.prototype.removeTags=function(){var a,b,c,d,e,f,g;if(e=1<=arguments.length?z.call(arguments,0):[],0===e.length)return void(this._tags=[]);for(b={},a={},f=0,g=e.length;g>f;f++)d=e[f],"string"==typeof d?b[d]=d:a[d.head()]=d;return c=[],this._tags=this._tags.filter(function(c){return a[c.head()]||b[c.name()]?void 0:c})},a.prototype.copy=function(){var a;return new HTMLString.Character(this._c,function(){var b,c,d,e;for(d=this._tags,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.copy());return e}.call(this))},a}()}.call(this),function(){var a,b,c,d,e,f=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};window.ContentSelect={},ContentSelect.Range=function(){function f(a,b){this.set(a,b)}return f.prototype.isCollapsed=function(){return this._from===this._to},f.prototype.span=function(){return this._to-this._from},f.prototype.collapse=function(){return this._to=this._from},f.prototype.eq=function(a){return this.get()[0]===a.get()[0]&&this.get()[1]===a.get()[1]},f.prototype.get=function(){return[this._from,this._to]},f.prototype.select=function(a){var b,d,e,f,g,h,i,j,k;return ContentSelect.Range.unselectAll(),b=document.createRange(),j=c(a,this._from),g=j[0],i=j[1],k=c(a,this._to),d=k[0],f=k[1],h=g.length||0,e=d.length||0,b.setStart(g,Math.min(i,h)),b.setEnd(d,Math.min(f,e)),window.getSelection().addRange(b)},f.prototype.set=function(a,b){return a=Math.max(0,a),b=Math.max(0,b),this._from=Math.min(a,b),this._to=Math.max(a,b)},f.prepareElement=function(b){var c,d,e,f,g,h;for(e=b.querySelectorAll(a.join(", ")),h=[],c=f=0,g=e.length;g>f;c=++f)d=e[c],d.parentNode.insertBefore(document.createTextNode(""),d),h.push(ca;a++)h=d[a],e.push(h);return e}();g.length>0;)switch(d=g.shift(),d.nodeType){case Node.TEXT_NODE:if(d.textContent.length>=e)return[d,e];e-=d.textContent.length;break;case Node.ELEMENT_NODE:if(i=d.nodeName.toLowerCase(),f.call(a,i)>=0){if(0===e)return[d,0];e=Math.max(0,e-1)}else d.childNodes&&Array.prototype.unshift.apply(g,function(){var a,b,c,e;for(c=d.childNodes,e=[],a=0,b=c.length;b>a;a++)h=c[a],e.push(h);return e}())}return[d,e]},e=function(b,c){var d,e,g,h,i,j;if(0===b.childNodes.length)return 0;for(g=0,d=function(){var a,c,d,f;for(d=b.childNodes,f=[],a=0,c=d.length;c>a;a++)e=d[a],f.push(e);return f}();d.length>0;){if(h=d.shift(),h===c)return i=h.nodeName.toLowerCase(),f.call(a,i)>=0?g+1:g;switch(h.nodeType){case Node.TEXT_NODE:g+=h.textContent.length;break;case Node.ELEMENT_NODE:j=h.nodeName.toLowerCase(),f.call(a,j)>=0?g+=1:h.childNodes&&Array.prototype.unshift.apply(d,function(){var a,b,c,d;for(c=h.childNodes,d=[],a=0,b=c.length;b>a;a++)e=c[a],d.push(e);return d}())}}return g},d=function(b,c){var d,e,g,h,i,j,k,l,m,n,o,p,q,r;if(e=b.childNodes,m=c.cloneRange(),m.collapse(!0),i=c.cloneRange(),i.collapse(!1),k=m.startContainer,l=m.startOffset,g=i.endContainer,h=i.endOffset,!m.comparePoint)return[k,l,g,h];if(k===b)for(k=e[e.length-1],l=k.textContent.length,j=n=0,p=e.length;p>n;j=++n)if(d=e[j],1===m.comparePoint(d,0)){0===j?(k=d,l=0):(k=e[j-1],l=d.textContent.length),r=k.nodeName.toLowerCase,f.call(a,r)>=0&&(l=1);break}if(c.collapsed)return[k,l,k,l];if(g===b)for(g=e[e.length-1],h=g.textContent.length,j=o=0,q=e.length;q>o;j=++o)d=e[j],1===i.comparePoint(d,0)&&(g=0===j?d:e[j-1],h=d.textContent.length+1);return[k,l,g,h]}}.call(this),function(){var a,b,c,d=[].slice,e=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},f={}.hasOwnProperty,g=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},h=function(a,b){return function(){return a.apply(b,arguments)}};window.ContentEdit={ALIGNMENT_CLASS_NAMES:{left:"align-left",right:"align-right"},DEFAULT_MAX_ELEMENT_WIDTH:800,DEFAULT_MIN_ELEMENT_WIDTH:80,DRAG_HOLD_DURATION:500,DROP_EDGE_SIZE:50,HELPER_CHAR_LIMIT:250,INDENT:" ",LANGUAGE:"en",PREFER_LINE_BREAKS:!1,RESIZE_CORNER_SIZE:15,_translations:{},_:function(a){var b;return b=ContentEdit.LANGUAGE,ContentEdit._translations[b]&&ContentEdit._translations[b][a]?ContentEdit._translations[b][a]:a},addTranslations:function(a,b){return ContentEdit._translations[a]=b},addCSSClass:function(a,b){var c,d,e;return a.classList?void a.classList.add(b):(d=a.getAttribute("class"),d?(e=function(){var a,b,e,f;for(e=d.split(" "),f=[],a=0,b=e.length;b>a;a++)c=e[a],f.push(c);return f}(),-1===e.indexOf(b)?a.setAttribute("class",""+d+" "+b):void 0):a.setAttribute("class",b))},attributesToString:function(a){var b,c,d,e,f,g;if(!a)return"";for(d=function(){var b;b=[];for(c in a)b.push(c);return b}(),d.sort(),b=[],f=0,g=d.length;g>f;f++)c=d[f],e=a[c],""===e?b.push(c):(e=HTMLString.String.encode(e),e=e.replace(/"/g,"""),b.push(""+c+'="'+e+'"'));return b.join(" ")},removeCSSClass:function(a,b){var c,d,e,f;return a.classList?(a.classList.remove(b),void(0===a.classList.length&&a.removeAttribute("class"))):(d=a.getAttribute("class"),d&&(f=function(){var a,b,e,f;for(e=d.split(" "),f=[],a=0,b=e.length;b>a;a++)c=e[a],f.push(c);return f}(),e=f.indexOf(b),e>-1)?(f.splice(e,1),f.length?a.setAttribute("class",f.join(" ")):a.removeAttribute("class")):void 0)}},b=function(){function a(){this._tagNames={}}return a.prototype.register=function(){var a,b,c,e,f,g;for(a=arguments[0],c=2<=arguments.length?d.call(arguments,1):[],g=[],e=0,f=c.length;f>e;e++)b=c[e],g.push(this._tagNames[b.toLowerCase()]=a);return g},a.prototype.match=function(a){return this._tagNames[a.toLowerCase()]?this._tagNames[a.toLowerCase()]:ContentEdit.Static},a}(),ContentEdit.TagNames=function(){function a(){}var c;return c=null,a.get=function(){return null!=c?c:c=new b},a}(),ContentEdit.Node=function(){function a(){this._bindings={},this._parent=null,this._modified=null}return a.prototype.lastModified=function(){return this._modified},a.prototype.parent=function(){return this._parent},a.prototype.parents=function(){var a,b;for(b=[],a=this._parent;a;)b.push(a),a=a._parent;return b},a.prototype.type=function(){return"Node"},a.prototype.html=function(a){throw null==a&&(a=""),new Error("`html` not implemented")},a.prototype.bind=function(a,b){return void 0===this._bindings[a]&&(this._bindings[a]=[]),this._bindings[a].push(b),b},a.prototype.trigger=function(){var a,b,c,e,f,g,h;if(c=arguments[0],a=2<=arguments.length?d.call(arguments,1):[],this._bindings[c]){for(g=this._bindings[c],h=[],e=0,f=g.length;f>e;e++)b=g[e],b&&h.push(b.call.apply(b,[this].concat(d.call(a))));return h}},a.prototype.unbind=function(a,b){var c,d,e,f,g,h;if(!a)return void(this._bindings={});if(!b)return void(this._bindings[a]=void 0);if(this._bindings[a]){for(g=this._bindings[a],h=[],c=e=0,f=g.length;f>e;c=++e)d=g[c],h.push(d===b?this._bindings[a].splice(c,1):void 0);return h}},a.prototype.commit=function(){return this._modified=null,ContentEdit.Root.get().trigger("commit",this)},a.prototype.taint=function(){var a,b,c,d,e,f;for(a=Date.now(),this._modified=a,f=this.parents(),d=0,e=f.length;e>d;d++)b=f[d],b._modified=a;return c=ContentEdit.Root.get(),c._modified=a,c.trigger("taint",this)},a.prototype.closest=function(a){var b;for(b=this.parent();b&&!a(b);)b=b.parent?b.parent():null;return b},a.prototype.next=function(){var a,b,c,d,e,f;if(this.children&&this.children.length>0)return this.children[0];for(f=[this].concat(this.parents()),d=0,e=f.length;e>d;d++){if(c=f[d],!c.parent())return null;if(a=c.parent().children,b=a.indexOf(c),b=0||(this.prototype[b]=c);return this},a.fromDOMElement=function(){throw new Error("`fromDOMElement` not implemented")},a}(),ContentEdit.NodeCollection=function(a){function b(){b.__super__.constructor.call(this),this.children=[]}return g(b,a),b.prototype.descendants=function(){var a,b,c;for(a=[],c=this.children.slice();c.length>0;)b=c.shift(),a.push(b),b.children&&b.children.length>0&&(c=b.children.slice().concat(c));return a},b.prototype.isMounted=function(){return!1},b.prototype.type=function(){return"NodeCollection"},b.prototype.attach=function(a,b){return a.parent()&&a.parent().detach(a),a._parent=this,void 0!==b?this.children.splice(b,0,a):this.children.push(a),a.mount&&this.isMounted()&&a.mount(),this.taint(),ContentEdit.Root.get().trigger("attach",this,a)},b.prototype.commit=function(){var a,b,c,d;for(d=this.descendants(),b=0,c=d.length;c>b;b++)a=d[b],a._modified=null;return this._modified=null,ContentEdit.Root.get().trigger("commit",this)},b.prototype.detach=function(a){var b;return b=this.children.indexOf(a),-1!==b?(a.unmount&&this.isMounted()&&a.isMounted()&&a.unmount(),this.children.splice(b,1),a._parent=null,this.taint(),ContentEdit.Root.get().trigger("detach",this,a)):void 0},b}(ContentEdit.Node),ContentEdit.Element=function(a){function b(a,c){b.__super__.constructor.call(this),this._tagName=a.toLowerCase(),this._attributes=c?c:{},this._domElement=null,this._behaviours={drag:!0,drop:!0,merge:!0,remove:!0,resize:!0,spawn:!0}}return g(b,a),b.prototype.attributes=function(){var a,b,c,d;a={},d=this._attributes;for(b in d)c=d[b],a[b]=c;return a},b.prototype.cssTypeName=function(){return"element"},b.prototype.domElement=function(){return this._domElement},b.prototype.isFocused=function(){return ContentEdit.Root.get().focused()===this},b.prototype.isMounted=function(){return null!==this._domElement},b.prototype.type=function(){return"Element"},b.prototype.typeName=function(){return"Element"},b.prototype.addCSSClass=function(a){var b;return b=!1,this.hasCSSClass(a)||(b=!0,this.attr("class")?this.attr("class",""+this.attr("class")+" "+a):this.attr("class",a)),this._addCSSClass(a),b?this.taint():void 0},b.prototype.attr=function(a,b){return a=a.toLowerCase(),void 0===b?this._attributes[a]:(this._attributes[a]=b,this.isMounted()&&"class"!==a.toLowerCase()&&this._domElement.setAttribute(a,b),this.taint())},b.prototype.blur=function(){var a;return a=ContentEdit.Root.get(),this.isFocused()?(this._removeCSSClass("ce-element--focused"),a._focused=null,a.trigger("blur",this)):void 0},b.prototype.can=function(a,b){return void 0===b?this._behaviours[a]:this._behaviours[name]=b},b.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=document.createElement("div"),a.setAttribute("class","ce-drag-helper ce-drag-helper--type-"+this.cssTypeName()),a.setAttribute("data-ce-type",ContentEdit._(this.typeName())),a},b.prototype.drag=function(a,b){var c;if(this.isMounted()&&this.can("drag"))return c=ContentEdit.Root.get(),c.startDragging(this,a,b),c.trigger("drag",this)},b.prototype.drop=function(a,b){var c;if(c=ContentEdit.Root.get(),a){if(a._removeCSSClass("ce-element--drop"),a._removeCSSClass("ce-element--drop-"+b[0]),a._removeCSSClass("ce-element--drop-"+b[1]),this.constructor.droppers[a.type()])return this.constructor.droppers[a.type()](this,a,b),void c.trigger("drop",this,a,b);if(a.constructor.droppers[this.type()])return a.constructor.droppers[this.type()](this,a,b),void c.trigger("drop",this,a,b)}return c.trigger("drop",this,null,null)},b.prototype.focus=function(a){var b;return b=ContentEdit.Root.get(),this.isFocused()?void 0:(b.focused()&&b.focused().blur(),this._addCSSClass("ce-element--focused"),b._focused=this,this.isMounted()&&!a&&this.domElement().focus(),b.trigger("focus",this))},b.prototype.hasCSSClass=function(a){var b,c;return this.attr("class")&&(c=function(){var a,c,d,e;for(d=this.attr("class").split(" "),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),c.indexOf(a)>-1)?!0:!1 -},b.prototype.merge=function(a){return this.can("merge")&&this.can("remove")?this.constructor.mergers[a.type()]?this.constructor.mergers[a.type()](a,this):a.constructor.mergers[this.type()]?a.constructor.mergers[this.type()](a,this):void 0:!1},b.prototype.mount=function(){var a;return this._domElement||(this._domElement=document.createElement(this.tagName())),a=this.nextSibling(),a?this.parent().domElement().insertBefore(this._domElement,a.domElement()):this.parent().domElement().appendChild(this._domElement),this._addDOMEventListeners(),this._addCSSClass("ce-element"),this._addCSSClass("ce-element--type-"+this.cssTypeName()),this.isFocused()&&this._addCSSClass("ce-element--focused"),ContentEdit.Root.get().trigger("mount",this)},b.prototype.removeAttr=function(a){return a=a.toLowerCase(),this._attributes[a]?(delete this._attributes[a],this.isMounted()&&"class"!==a.toLowerCase()&&this._domElement.removeAttribute(a),this.taint()):void 0},b.prototype.removeCSSClass=function(a){var b,c,d;if(this.hasCSSClass(a))return d=function(){var a,c,d,e;for(d=this.attr("class").split(" "),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),c=d.indexOf(a),c>-1&&d.splice(c,1),d.length?this.attr("class",d.join(" ")):this.removeAttr("class"),this._removeCSSClass(a),this.taint()},b.prototype.tagName=function(a){return void 0===a?this._tagName:(this._tagName=a.toLowerCase(),this.isMounted()&&(this.unmount(),this.mount()),this.taint())},b.prototype.unmount=function(){return this._removeDOMEventListeners(),this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,ContentEdit.Root.get().trigger("unmount",this)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("focus",function(){return function(a){return a.preventDefault()}}(this)),this._domElement.addEventListener("dragstart",function(){return function(a){return a.preventDefault()}}(this)),this._domElement.addEventListener("keydown",function(a){return function(b){return a._onKeyDown(b)}}(this)),this._domElement.addEventListener("keyup",function(a){return function(b){return a._onKeyUp(b)}}(this)),this._domElement.addEventListener("mousedown",function(a){return function(b){return 0===b.button?a._onMouseDown(b):void 0}}(this)),this._domElement.addEventListener("mousemove",function(a){return function(b){return a._onMouseMove(b)}}(this)),this._domElement.addEventListener("mouseover",function(a){return function(b){return a._onMouseOver(b)}}(this)),this._domElement.addEventListener("mouseout",function(a){return function(b){return a._onMouseOut(b)}}(this)),this._domElement.addEventListener("mouseup",function(a){return function(b){return 0===b.button?a._onMouseUp(b):void 0}}(this)),this._domElement.addEventListener("paste",function(a){return function(b){return a._onPaste(b)}}(this)),this._domElement.addEventListener("dragover",function(){return function(a){return a.preventDefault()}}(this)),this._domElement.addEventListener("drop",function(a){return function(b){return a._onNativeDrop(b)}}(this))},b.prototype._onKeyDown=function(){},b.prototype._onKeyUp=function(){},b.prototype._onMouseDown=function(){return this.focus?this.focus(!0):void 0},b.prototype._onMouseMove=function(a){return this._onOver(a)},b.prototype._onMouseOver=function(a){return this._onOver(a)},b.prototype._onMouseOut=function(){var a,b;return this._removeCSSClass("ce-element--over"),b=ContentEdit.Root.get(),a=b.dragging(),a?(this._removeCSSClass("ce-element--drop"),this._removeCSSClass("ce-element--drop-above"),this._removeCSSClass("ce-element--drop-below"),this._removeCSSClass("ce-element--drop-center"),this._removeCSSClass("ce-element--drop-left"),this._removeCSSClass("ce-element--drop-right"),b._dropTarget=null):void 0},b.prototype._onMouseUp=function(){},b.prototype._onNativeDrop=function(a){return a.preventDefault(),a.stopPropagation(),ContentEdit.Root.get().trigger("native-drop",this,a)},b.prototype._onPaste=function(a){return a.preventDefault(),a.stopPropagation(),ContentEdit.Root.get().trigger("paste",this,a)},b.prototype._onOver=function(){var a,b;return this._addCSSClass("ce-element--over"),b=ContentEdit.Root.get(),a=b.dragging(),a&&a!==this&&!b._dropTarget&&this.can("drop")&&(this.constructor.droppers[a.type()]||a.constructor.droppers[this.type()])?(this._addCSSClass("ce-element--drop"),b._dropTarget=this):void 0},b.prototype._removeDOMEventListeners=function(){},b.prototype._addCSSClass=function(a){return this.isMounted()?ContentEdit.addCSSClass(this._domElement,a):void 0},b.prototype._attributesToString=function(){return Object.getOwnPropertyNames(this._attributes).length>0?" "+ContentEdit.attributesToString(this._attributes):""},b.prototype._removeCSSClass=function(a){return this.isMounted()?ContentEdit.removeCSSClass(this._domElement,a):void 0},b.droppers={},b.mergers={},b.placements=["above","below"],b.getDOMElementAttributes=function(a){var b,c,d,e,f;if(!a.hasAttributes())return{};for(c={},f=a.attributes,d=0,e=f.length;e>d;d++)b=f[d],c[b.name.toLowerCase()]=b.value;return c},b._dropVert=function(a,b,c){var d;return a.parent().detach(a),d=b.parent().children.indexOf(b),"below"===c[0]&&(d+=1),b.parent().attach(a,d)},b._dropBoth=function(a,b,c){var d,e,f,g,h,i,j,k;if(a.parent().detach(a),h=b.parent().children.indexOf(b),"below"===c[0]&&"center"===c[1]&&(h+=1),e=ContentEdit.ALIGNMENT_CLASS_NAMES.left,f=ContentEdit.ALIGNMENT_CLASS_NAMES.right,a.a){if(a._removeCSSClass(e),a._removeCSSClass(f),a.a["class"]){for(d=[],k=a.a["class"].split(" "),i=0,j=k.length;j>i;i++)g=k[i],g!==e&&g!==f&&d.push(g);d.length?a.a["class"]=d.join(" "):delete a.a["class"]}}else a.removeCSSClass(e),a.removeCSSClass(f);return"left"===c[1]&&(a.a?(a.a["class"]?a.a["class"]+=" "+e:a.a["class"]=e,a._addCSSClass(e)):a.addCSSClass(e)),"right"===c[1]&&(a.a?(a.a["class"]?a.a["class"]+=" "+f:a.a["class"]=f,a._addCSSClass(f)):a.addCSSClass(f)),b.parent().attach(a,h)},b}(ContentEdit.Node),ContentEdit.ElementCollection=function(a){function b(a,c){b.__super__.constructor.call(this,a,c),ContentEdit.NodeCollection.prototype.constructor.call(this)}return g(b,a),b.extend(ContentEdit.NodeCollection),b.prototype.cssTypeName=function(){return"element-collection"},b.prototype.isMounted=function(){return null!==this._domElement},b.prototype.type=function(){return"ElementCollection"},b.prototype.createDraggingDOMElement=function(){var a,c;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),c=this._domElement.textContent,c.length>ContentEdit.HELPER_CHAR_LIMIT&&(c=c.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a.innerHTML=c,a},b.prototype.detach=function(a){return ContentEdit.NodeCollection.prototype.detach.call(this,a),0===this.children.length&&this.parent()?this.parent().detach(this):void 0},b.prototype.html=function(a){var b,c;return null==a&&(a=""),c=function(){var c,d,e,f;for(e=this.children,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b.html(a+ContentEdit.INDENT));return f}.call(this),""+a+"<"+this.tagName()+this._attributesToString()+">\n"+(""+c.join("\n")+"\n")+(""+a+"")},b.prototype.mount=function(){var a,c,d,e,f,g,h,i;this._domElement=document.createElement(this._tagName),g=this._attributes;for(c in g)d=g[c],this._domElement.setAttribute(c,d);for(b.__super__.mount.call(this),h=this.children,i=[],e=0,f=h.length;f>e;e++)a=h[e],i.push(a.mount());return i},b.prototype.unmount=function(){var a,c,d,e;for(e=this.children,c=0,d=e.length;d>c;c++)a=e[c],a.unmount();return b.__super__.unmount.call(this)},b.prototype.blur=void 0,b.prototype.focus=void 0,b}(ContentEdit.Element),ContentEdit.ResizableElement=function(a){function b(a,c){b.__super__.constructor.call(this,a,c),this._domSizeInfoElement=null,this._aspectRatio=1}return g(b,a),b.prototype.aspectRatio=function(){return this._aspectRatio},b.prototype.maxSize=function(){var a;return a=parseInt(this.attr("data-ce-max-width")||0),a||(a=ContentEdit.DEFAULT_MAX_ELEMENT_WIDTH),a=Math.max(a,this.size()[0]),[a,a*this.aspectRatio()]},b.prototype.minSize=function(){var a;return a=parseInt(this.attr("data-ce-min-width")||0),a||(a=ContentEdit.DEFAULT_MIN_ELEMENT_WIDTH),a=Math.min(a,this.size()[0]),[a,a*this.aspectRatio()]},b.prototype.type=function(){return"ResizableElement"},b.prototype.mount=function(){return b.__super__.mount.call(this),this._domElement.setAttribute("data-ce-size",this._getSizeInfo())},b.prototype.resize=function(a,b,c){return this.isMounted()&&this.can("resize")?ContentEdit.Root.get().startResizing(this,a,b,c,!0):void 0},b.prototype.size=function(a){var b,c,d,e;return a?(a[0]=parseInt(a[0]),a[1]=parseInt(a[1]),d=this.minSize(),a[0]=Math.max(a[0],d[0]),a[1]=Math.max(a[1],d[1]),c=this.maxSize(),a[0]=Math.min(a[0],c[0]),a[1]=Math.min(a[1],c[1]),this.attr("width",parseInt(a[0])),this.attr("height",parseInt(a[1])),this.isMounted()?(this._domElement.style.width=""+a[0]+"px",this._domElement.style.height=""+a[1]+"px",this._domElement.setAttribute("data-ce-size",this._getSizeInfo())):void 0):(e=parseInt(this.attr("width")||1),b=parseInt(this.attr("height")||1),[e,b])},b.prototype._onMouseDown=function(a){var c;return b.__super__._onMouseDown.call(this,a),c=this._getResizeCorner(a.clientX,a.clientY),c?this.resize(c,a.clientX,a.clientY):(clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(b){return function(){return b.drag(a.pageX,a.pageY)}}(this),150))},b.prototype._onMouseMove=function(a){var c;return b.__super__._onMouseMove.call(this),this.can("resize")?(this._removeCSSClass("ce-element--resize-top-left"),this._removeCSSClass("ce-element--resize-top-right"),this._removeCSSClass("ce-element--resize-bottom-left"),this._removeCSSClass("ce-element--resize-bottom-right"),c=this._getResizeCorner(a.clientX,a.clientY),c?this._addCSSClass("ce-element--resize-"+c[0]+"-"+c[1]):void 0):void 0},b.prototype._onMouseOut=function(){return b.__super__._onMouseOut.call(this),this._removeCSSClass("ce-element--resize-top-left"),this._removeCSSClass("ce-element--resize-top-right"),this._removeCSSClass("ce-element--resize-bottom-left"),this._removeCSSClass("ce-element--resize-bottom-right")},b.prototype._onMouseUp=function(){return b.__super__._onMouseUp.call(this),this._dragTimeout?clearTimeout(this._dragTimeout):void 0},b.prototype._getResizeCorner=function(a,b){var c,d,e,f,g;return e=this._domElement.getBoundingClientRect(),g=[a-e.left,b-e.top],a=g[0],b=g[1],f=this.size(),d=ContentEdit.RESIZE_CORNER_SIZE,d=Math.min(d,Math.max(parseInt(f[0]/4),1)),d=Math.min(d,Math.max(parseInt(f[1]/4),1)),c=null,d>a?d>b?c=["top","left"]:b>e.height-d&&(c=["bottom","left"]):a>e.width-d&&(d>b?c=["top","right"]:b>e.height-d&&(c=["bottom","right"])),c},b.prototype._getSizeInfo=function(){var a;return a=this.size(),"w "+a[0]+" × h "+a[1]},b}(ContentEdit.Element),ContentEdit.Region=function(a){function b(a){var c,d,e,f,g,h,i,j;for(b.__super__.constructor.call(this),this._domElement=a,h=ContentEdit.TagNames.get(),e=function(){var a,b,d,e;for(d=this._domElement.childNodes,e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(c);return e}.call(this),i=0,j=e.length;j>i;i++)d=e[i],1===d.nodeType&&(f=h.match(d.getAttribute("data-ce-tag")?d.getAttribute("data-ce-tag"):d.tagName),g=f.fromDOMElement(d),this._domElement.removeChild(d),g&&this.attach(g),ContentEdit.Root.get().trigger("ready",this))}return g(b,a),b.prototype.domElement=function(){return this._domElement},b.prototype.isMounted=function(){return!0},b.prototype.type=function(){return"Region"},b.prototype.html=function(a){var b;return null==a&&(a=""),function(){var c,d,e,f;for(e=this.children,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b.html(a));return f}.call(this).join("\n").trim()},b}(ContentEdit.NodeCollection),a=function(a){function b(){this._onStopResizing=h(this._onStopResizing,this),this._onResize=h(this._onResize,this),this._onStopDragging=h(this._onStopDragging,this),this._onDrag=h(this._onDrag,this),b.__super__.constructor.call(this),this._focused=null,this._dragging=null,this._dropTarget=null,this._draggingDOMElement=null,this._resizing=null,this._resizingInit=null}return g(b,a),b.prototype.dragging=function(){return this._dragging},b.prototype.dropTarget=function(){return this._dropTarget},b.prototype.focused=function(){return this._focused},b.prototype.resizing=function(){return this._resizing},b.prototype.type=function(){return"Root"},b.prototype.cancelDragging=function(){return this._dragging?(document.body.removeChild(this._draggingDOMElement),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._dragging._removeCSSClass("ce-element--dragging"),this._dragging=null,this._dropTarget=null,ContentEdit.removeCSSClass(document.body,"ce--dragging")):void 0},b.prototype.startDragging=function(a,b,c){return this._dragging?void 0:(this._dragging=a,this._dragging._addCSSClass("ce-element--dragging"),this._draggingDOMElement=this._dragging.createDraggingDOMElement(),document.body.appendChild(this._draggingDOMElement),this._draggingDOMElement.style.left=""+b+"px",this._draggingDOMElement.style.top=""+c+"px",document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging"))},b.prototype._getDropPlacement=function(a,b){var c,d,e,f;return this._dropTarget?(d=this._dropTarget.domElement().getBoundingClientRect(),f=[a-d.left,b-d.top],a=f[0],b=f[1],c="center",ad.width-ContentEdit.DROP_EDGE_SIZE&&(c="right"),e="above",b>d.height/2&&(e="below"),[e,c]):null},b.prototype._onDrag=function(a){var b,c,d;return ContentSelect.Range.unselectAll(),this._draggingDOMElement.style.left=""+a.pageX+"px",this._draggingDOMElement.style.top=""+a.pageY+"px",this._dropTarget&&(b=this._getDropPlacement(a.clientX,a.clientY),this._dropTarget._removeCSSClass("ce-element--drop-above"),this._dropTarget._removeCSSClass("ce-element--drop-below"),this._dropTarget._removeCSSClass("ce-element--drop-center"),this._dropTarget._removeCSSClass("ce-element--drop-left"),this._dropTarget._removeCSSClass("ce-element--drop-right"),c=b[0],e.call(this._dragging.constructor.placements,c)>=0&&this._dropTarget._addCSSClass("ce-element--drop-"+b[0]),d=b[1],e.call(this._dragging.constructor.placements,d)>=0)?this._dropTarget._addCSSClass("ce-element--drop-"+b[1]):void 0},b.prototype._onStopDragging=function(a){var b;return b=this._getDropPlacement(a.clientX,a.clientY),this._dragging.drop(this._dropTarget,b),this.cancelDragging()},b.prototype.startResizing=function(a,b,c,d,e){var f,g;if(!this._resizing)return this._resizing=a,this._resizingInit={corner:b,fixed:e,origin:[c,d],size:a.size()},this._resizing._addCSSClass("ce-element--resizing"),g=this._resizing.parent().domElement(),f=document.createElement("div"),f.setAttribute("class","ce-measure"),g.appendChild(f),this._resizingParentWidth=f.getBoundingClientRect().width,g.removeChild(f),document.addEventListener("mousemove",this._onResize),document.addEventListener("mouseup",this._onStopResizing),ContentEdit.addCSSClass(document.body,"ce--resizing")},b.prototype._onResize=function(a){var b,c,d,e;return ContentSelect.Range.unselectAll(),d=this._resizingInit.origin[0]-a.clientX,"right"===this._resizingInit.corner[1]&&(d=-d),c=this._resizingInit.size[0]+d,c=Math.min(c,this._resizingParentWidth),this._resizingInit.fixed?b=c*this._resizing.aspectRatio():(e=this._resizingInit.origin[1]-a.clientY,"bottom"===this._resizingInit.corner[0]&&(e=-e),b=this._resizingInit.size[1]+e),this._resizing.size([c,b])},b.prototype._onStopResizing=function(){return document.removeEventListener("mousemove",this._onResize),document.removeEventListener("mouseup",this._onStopResizing),this._resizing._removeCSSClass("ce-element--resizing"),this._resizing=null,this._resizingInit=null,this._resizingParentWidth=null,ContentEdit.removeCSSClass(document.body,"ce--resizing")},b}(ContentEdit.Node),ContentEdit.Root=function(){function b(){}var c;return c=null,b.get=function(){return null!=c?c:c=new a},b}(),ContentEdit.Static=function(a){function b(a,c,d){b.__super__.constructor.call(this,a,c),this._content=d}return g(b,a),b.prototype.cssTypeName=function(){return"static"},b.prototype.type=function(){return"Static"},b.prototype.typeName=function(){return"Static"},b.prototype.createDraggingDOMElement=function(){var a,c;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),c=this._domElement.textContent,c.length>ContentEdit.HELPER_CHAR_LIMIT&&(c=c.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a.innerHTML=c,a},b.prototype.html=function(a){return null==a&&(a=""),HTMLString.Tag.SELF_CLOSING[this._tagName]?""+a+"<"+this._tagName+this._attributesToString()+">":""+a+"<"+this._tagName+this._attributesToString()+">"+this._content+(""+a+"")},b.prototype.mount=function(){var a,c,d;this._domElement=document.createElement(this._tagName),d=this._attributes;for(a in d)c=d[a],this._domElement.setAttribute(a,c);return this._domElement.innerHTML=this._content,b.__super__.mount.call(this)},b.prototype.blur=void 0,b.prototype.focus=void 0,b.prototype._onMouseDown=function(a){return b.__super__._onMouseDown.call(this,a),void 0!==this.attr("data-ce-moveable")?(clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(b){return function(){return b.drag(a.pageX,a.pageY)}}(this),150)):void 0},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.prototype._onMouseUp=function(a){return b.__super__._onMouseUp.call(this,a),this._dragTimeout?clearTimeout(this._dragTimeout):void 0},b.droppers={Static:ContentEdit.Element._dropVert},b.fromDOMElement=function(a){return new this(a.tagName,this.getDOMElementAttributes(a),a.innerHTML)},b}(ContentEdit.Element),ContentEdit.TagNames.get().register(ContentEdit.Static,"static"),ContentEdit.Text=function(a){function b(a,c,d){b.__super__.constructor.call(this,a,c),this.content=d instanceof HTMLString.String?d:new HTMLString.String(d).trim()}return g(b,a),b.prototype.cssTypeName=function(){return"text"},b.prototype.type=function(){return"Text"},b.prototype.typeName=function(){return"Text"},b.prototype.blur=function(){var a;if(this.isMounted()&&this._syncContent(),this.content.isWhitespace()&&this.can("remove"))this.parent()&&this.parent().detach(this);else if(this.isMounted()){try{this._domElement.blur()}catch(c){a=c}this._domElement.removeAttribute("contenteditable")}return b.__super__.blur.call(this)},b.prototype.createDraggingDOMElement=function(){var a,c;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),c=HTMLString.String.encode(this._domElement.textContent),c.length>ContentEdit.HELPER_CHAR_LIMIT&&(c=c.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a.innerHTML=c,a},b.prototype.drag=function(a,c){return this.storeState(),this._domElement.removeAttribute("contenteditable"),b.__super__.drag.call(this,a,c)},b.prototype.drop=function(a,c){return b.__super__.drop.call(this,a,c),this.restoreState()},b.prototype.focus=function(a){return this.isMounted()&&this._domElement.setAttribute("contenteditable",""),b.__super__.focus.call(this,a)},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCached\n"+(""+a+ContentEdit.INDENT+this._cached+"\n")+(""+a+"")},b.prototype.mount=function(){var a,c,d;this._domElement=document.createElement(this._tagName),d=this._attributes;for(a in d)c=d[a],this._domElement.setAttribute(a,c);return this.updateInnerHTML(),b.__super__.mount.call(this)},b.prototype.restoreState=function(){return this._savedSelection?this.isMounted()&&this.isFocused()?(this._domElement.setAttribute("contenteditable",""),this._addCSSClass("ce-element--focused"),document.activeElement!==this.domElement()&&this.domElement().focus(),this._savedSelection.select(this._domElement),this._savedSelection=void 0):void(this._savedSelection=void 0):void 0},b.prototype.selection=function(a){return void 0===a?this.isMounted()?ContentSelect.Range.query(this._domElement):new ContentSelect.Range(0,0):a.select(this._domElement)},b.prototype.storeState=function(){return this.isMounted()&&this.isFocused()?this._savedSelection=ContentSelect.Range.query(this._domElement):void 0},b.prototype.updateInnerHTML=function(){return this._domElement.innerHTML=this.content.html(),ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},b.prototype._onKeyDown=function(a){switch(a.keyCode){case 40:return this._keyDown(a);case 37:return this._keyLeft(a);case 39:return this._keyRight(a);case 38:return this._keyUp(a);case 9:return this._keyTab(a);case 8:return this._keyBack(a);case 46:return this._keyDelete(a);case 13:return this._keyReturn(a)}},b.prototype._onKeyUp=function(a){return b.__super__._onKeyUp.call(this,a),this._syncContent()},b.prototype._onMouseDown=function(a){return b.__super__._onMouseDown.call(this,a),clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(b){return function(){return b.drag(a.pageX,a.pageY)}}(this),ContentEdit.DRAG_HOLD_DURATION),0===this.content.length()&&ContentEdit.Root.get().focused()===this?(a.preventDefault(),document.activeElement!==this._domElement&&this._domElement.focus(),new ContentSelect.Range(0,0).select(this._domElement)):void 0},b.prototype._onMouseMove=function(a){return this._dragTimeout&&clearTimeout(this._dragTimeout),b.__super__._onMouseMove.call(this,a)},b.prototype._onMouseOut=function(a){return this._dragTimeout&&clearTimeout(this._dragTimeout),b.__super__._onMouseOut.call(this,a)},b.prototype._onMouseUp=function(a){return this._dragTimeout&&clearTimeout(this._dragTimeout),b.__super__._onMouseUp.call(this,a)},b.prototype._keyBack=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),0===c.get()[0]&&c.isCollapsed()?(a.preventDefault(),b=this.previousContent(),this._syncContent(),b?b.merge(this):void 0):void 0},b.prototype._keyDelete=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),this._atEnd(c)&&c.isCollapsed()?(a.preventDefault(),b=this.nextContent(),b?this.merge(b):void 0):void 0},b.prototype._keyDown=function(a){return this._keyRight(a)},b.prototype._keyLeft=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),0===c.get()[0]&&c.isCollapsed()?(a.preventDefault(),b=this.previousContent(),b?(b.focus(),c=new ContentSelect.Range(b.content.length(),b.content.length()),c.select(b.domElement())):ContentEdit.Root.get().trigger("previous-region",this.closest(function(a){return"Region"===a.type()}))):void 0},b.prototype._keyReturn=function(a){var b,c,d,e,f,g;if(a.preventDefault(),!this.content.isWhitespace()){if(ContentSelect.Range.query(this._domElement),e=ContentSelect.Range.query(this._domElement),g=this.content.substring(0,e.get()[0]),f=this.content.substring(e.get()[1]),a.shiftKey^ContentEdit.PREFER_LINE_BREAKS)return c=e.get()[0],d="
",this.content.length()===c&&(this.content.characters[c-1].isTag("br")||(d="

")),this.content=this.content.insert(c,new HTMLString.String(d,!0),!0),this.updateInnerHTML(),c+=1,e=new ContentSelect.Range(c,c),void e.select(this.domElement());if(this.can("spawn"))return this.content=g.trim(),this.updateInnerHTML(),b=new this.constructor("p",{},f.trim()),this.parent().attach(b,this.parent().children.indexOf(this)+1),g.length()?(b.focus(),e=new ContentSelect.Range(0,0),e.select(b.domElement())):(e=new ContentSelect.Range(0,g.length()),e.select(this._domElement)),this.taint()}},b.prototype._keyRight=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),this._atEnd(c)&&c.isCollapsed()?(a.preventDefault(),b=this.nextContent(),b?(b.focus(),c=new ContentSelect.Range(0,0),c.select(b.domElement())):ContentEdit.Root.get().trigger("next-region",this.closest(function(a){return"Region"===a.type()}))):void 0},b.prototype._keyTab=function(a){return a.preventDefault()},b.prototype._keyUp=function(a){return this._keyLeft(a)},b.prototype._atEnd=function(a){var b;return b=a.get()[0]===this.content.length(),a.get()[0]===this.content.length()-1&&this.content.characters[this.content.characters.length-1].isTag("br")&&(b=!0),b},b.prototype._flagIfEmpty=function(){return 0===this.content.length()?this._addCSSClass("ce-element--empty"):this._removeCSSClass("ce-element--empty")},b.prototype._syncContent=function(){var a,b;return b=this.content.html(),this.content=new HTMLString.String(this._domElement.innerHTML,this.content.preserveWhitespace()),a=this.content.html(),b!==a&&this.taint(),this._flagIfEmpty()},b.droppers={Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert},b.mergers={Text:function(a,b){var c;return c=b.content.length(),a.content.length()&&(b.content=b.content.concat(a.content)),b.isMounted()&&b.updateInnerHTML(),b.focus(),new ContentSelect.Range(c,c).select(b._domElement),a.parent()&&a.parent().detach(a),b.taint()}},b.fromDOMElement=function(a){return new this(a.tagName,this.getDOMElementAttributes(a),a.innerHTML.replace(/^\s+|\s+$/g,""))},b}(ContentEdit.Element),ContentEdit.TagNames.get().register(ContentEdit.Text,"address","blockquote","h1","h2","h3","h4","h5","h6","p"),ContentEdit.PreText=function(a){function b(a,b,c){this.content=c instanceof HTMLString.String?c:new HTMLString.String(c,!0),ContentEdit.Element.call(this,a,b)}return g(b,a),b.prototype.cssTypeName=function(){return"pre-text"},b.prototype.type=function(){return"PreText"},b.prototype.typeName=function(){return"Preformatted"},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCached"+(""+this._cached+"")},b.prototype.updateInnerHTML=function(){var a;return a=this.content.html(),a+="​",this._domElement.innerHTML=a,ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},b.prototype._onKeyUp=function(){var a,b,c;return c=this.content.html(),a=this._domElement.innerHTML,this.content=new HTMLString.String(a,this.content.preserveWhitespace()),b=this.content.html(),c!==b&&this.taint(),this._flagIfEmpty()},b.prototype._keyReturn=function(a){var b,c,d,e;return a.preventDefault(),c=ContentSelect.Range.query(this._domElement),b=c.get()[0]+1,0===c.get()[0]&&c.isCollapsed()?this.content=new HTMLString.String("\n",!0).concat(this.content):this._atEnd(c)&&c.isCollapsed()?this.content=this.content.concat(new HTMLString.String("\n",!0)):0===c.get()[0]&&c.get()[1]===this.content.length()?(this.content=new HTMLString.String("\n",!0),b=0):(e=this.content.substring(0,c.get()[0]),d=this.content.substring(c.get()[1]),this.content=e.concat(new HTMLString.String("\n",!0),d)),this.updateInnerHTML(),c.set(b,b),c.select(this._domElement),this.taint()},b.droppers={PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert},b.mergers={},b.fromDOMElement=function(a){return new this(a.tagName,this.getDOMElementAttributes(a),a.innerHTML)},b}(ContentEdit.Text),ContentEdit.TagNames.get().register(ContentEdit.PreText,"pre"),ContentEdit.Image=function(a){function b(a,c){var d;b.__super__.constructor.call(this,"img",a),this.a=c?c:null,d=this.size(),this._aspectRatio=d[1]/d[0]}return g(b,a),b.prototype.cssTypeName=function(){return"image"},b.prototype.type=function(){return"Image"},b.prototype.typeName=function(){return"Image"},b.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),a.style.backgroundImage="url("+this._attributes.src+")",a},b.prototype.html=function(a){var b,c;return null==a&&(a=""),c=""+a+"",this.a?(b=ContentEdit.attributesToString(this.a),b=""+b+' data-ce-tag="img"',""+a+"\n"+(""+ContentEdit.INDENT+c+"\n")+(""+a+"")):c},b.prototype.mount=function(){var a,c;return this._domElement=document.createElement("div"),a="",this.a&&this.a["class"]&&(a+=" "+this.a["class"]),this._attributes["class"]&&(a+=" "+this._attributes["class"]),this._domElement.setAttribute("class",a),c=this._attributes.style?this._attributes.style:"",c+="background-image:url("+this._attributes.src+");",this._attributes.width&&(c+="width:"+this._attributes.width+"px;"),this._attributes.height&&(c+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",c),b.__super__.mount.call(this)},b.droppers={Image:ContentEdit.Element._dropBoth,PreText:ContentEdit.Element._dropBoth,Static:ContentEdit.Element._dropBoth,Text:ContentEdit.Element._dropBoth},b.placements=["above","below","left","right","center"],b.fromDOMElement=function(a){var b,c,d,e,f,g,h;if(b=null,"a"===a.tagName.toLowerCase()){for(b=this.getDOMElementAttributes(a),f=function(){var b,c,e,f;for(e=a.childNodes,f=[],b=0,c=e.length;c>b;b++)d=e[b],f.push(d);return f}(),g=0,h=f.length;h>g;g++)if(e=f[g],1===e.nodeType&&"img"===e.tagName.toLowerCase()){a=e;break}"a"===a.tagName.toLowerCase()&&(a=document.createElement("img"))}return c=this.getDOMElementAttributes(a),void 0===c.width&&(c.width=void 0===c.height?a.naturalWidth:a.clientWidth),void 0===c.height&&(c.height=void 0===c.width?a.naturalHeight:a.clientHeight),new this(c,b)},b}(ContentEdit.ResizableElement),ContentEdit.TagNames.get().register(ContentEdit.Image,"img"),ContentEdit.Video=function(a){function b(a,c,d){var e;null==d&&(d=[]),b.__super__.constructor.call(this,a,c),this.sources=d,e=this.size(),this._aspectRatio=e[1]/e[0]}return g(b,a),b.prototype.cssTypeName=function(){return"video"},b.prototype.type=function(){return"Video"},b.prototype.typeName=function(){return"Video"},b.prototype._title=function(){var a;return a="",this.attr("src")?a=this.attr("src"):this.sources.length&&(a=this.sources[0].src),a||(a="No video source set"),a.length>ContentEdit.HELPER_CHAR_LIMIT&&(a=text.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a},b.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),a.innerHTML=this._title(),a},b.prototype.html=function(a){var b,c,d,e,f,g;if(null==a&&(a=""),"video"===this.tagName()){for(d=[],g=this.sources,e=0,f=g.length;f>e;e++)c=g[e],b=ContentEdit.attributesToString(c),d.push(""+a+ContentEdit.INDENT+"");return""+a+"\n"+d.join("\n")+("\n"+a+"")}return""+a+"<"+this._tagName+this._attributesToString()+">"+("")},b.prototype.mount=function(){var a;return this._domElement=document.createElement("div"),this.a&&this.a["class"]?this._domElement.setAttribute("class",this.a["class"]):this._attributes["class"]&&this._domElement.setAttribute("class",this._attributes["class"]),a=this._attributes.style?this._attributes.style:"",this._attributes.width&&(a+="width:"+this._attributes.width+"px;"),this._attributes.height&&(a+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",a),this._domElement.setAttribute("data-ce-title",this._title()),b.__super__.mount.call(this)},b.droppers={Image:ContentEdit.Element._dropBoth,PreText:ContentEdit.Element._dropBoth,Static:ContentEdit.Element._dropBoth,Text:ContentEdit.Element._dropBoth,Video:ContentEdit.Element._dropBoth},b.placements=["above","below","left","right","center"],b.fromDOMElement=function(a){var b,c,d,e,f,g;for(d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),e=[],f=0,g=d.length;g>f;f++)c=d[f],1===c.nodeType&&"source"===c.tagName.toLowerCase()&&e.push(this.getDOMElementAttributes(c));return new this(a.tagName,this.getDOMElementAttributes(a),e)},b}(ContentEdit.ResizableElement),ContentEdit.TagNames.get().register(ContentEdit.Video,"iframe","video"),ContentEdit.List=function(a){function b(a,c){b.__super__.constructor.call(this,a,c) -}return g(b,a),b.prototype.cssTypeName=function(){return"list"},b.prototype.type=function(){return"List"},b.prototype.typeName=function(){return"List"},b.prototype._onMouseOver=function(a){return"ListItem"!==this.parent().type()?(b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")):void 0},b.droppers={Image:ContentEdit.Element._dropBoth,List:ContentEdit.Element._dropVert,PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert,Video:ContentEdit.Element._dropBoth},b.fromDOMElement=function(a){var b,c,d,e,f,g;for(e=new this(a.tagName,this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),f=0,g=d.length;g>f;f++)c=d[f],1===c.nodeType&&"li"===c.tagName.toLowerCase()&&e.attach(ContentEdit.ListItem.fromDOMElement(c));return 0===e.children.length?null:e},b}(ContentEdit.ElementCollection),ContentEdit.TagNames.get().register(ContentEdit.List,"ol","ul"),ContentEdit.ListItem=function(a){function b(a){b.__super__.constructor.call(this,"li",a)}return g(b,a),b.prototype.cssTypeName=function(){return"list-item"},b.prototype.list=function(){return 2===this.children.length?this.children[1]:null},b.prototype.listItemText=function(){return this.children.length>0?this.children[0]:null},b.prototype.type=function(){return"ListItem"},b.prototype.html=function(a){var b;return null==a&&(a=""),b=[""+a+""],this.listItemText()&&b.push(this.listItemText().html(a+ContentEdit.INDENT)),this.list()&&b.push(this.list().html(a+ContentEdit.INDENT)),b.push(""+a+""),b.join("\n")},b.prototype.indent=function(){var a;if(0!==this.parent().children.indexOf(this))return a=this.previousSibling(),a.list()||a.attach(new ContentEdit.List(a.parent().tagName())),this.listItemText().storeState(),this.parent().detach(this),a.list().attach(this),this.listItemText().restoreState()},b.prototype.remove=function(){var a,b,c,d,e,f;if(this.parent()){if(c=this.parent().children.indexOf(this),this.list())for(f=this.list().children.slice(),b=d=0,e=f.length;e>d;b=++d)a=f[b],a.parent().detach(a),this.parent().attach(a,b+c);return this.parent().detach(this)}},b.prototype.unindent=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(f=this.parent(),b=f.parent(),j=f.children.slice(f.children.indexOf(this)+1,f.children.length),"ListItem"===b.type()){for(this.listItemText().storeState(),f.detach(this),b.parent().attach(this,b.parent().children.indexOf(b)+1),j.length&&!this.list()&&this.attach(new ContentEdit.List(f.tagName())),l=0,p=j.length;p>l;l++)i=j[l],i.parent().detach(i),this.list().attach(i);return this.listItemText().restoreState()}if(k=new ContentEdit.Text("p",this.attr("class")?{"class":this.attr("class")}:{},this.listItemText().content),h=null,this.listItemText().isFocused()&&(h=ContentSelect.Range.query(this.listItemText().domElement())),g=b.children.indexOf(f),d=f.children.indexOf(this),0===d){if(e=null,1===f.children.length?(this.list()&&(e=new ContentEdit.List(f.tagName())),b.detach(f)):f.detach(this),b.attach(k,g),e&&b.attach(e,g+1),this.list())for(t=this.list().children.slice(),c=m=0,q=t.length;q>m;c=++m)a=t[c],a.parent().detach(a),e?e.attach(a):f.attach(a,c)}else if(d===f.children.length-1)f.detach(this),b.attach(k,g+1),this.list()&&b.attach(this.list(),g+2);else{if(f.detach(this),b.attach(k,g+1),e=new ContentEdit.List(f.tagName()),b.attach(e,g+2),this.list())for(u=this.list().children.slice(),n=0,r=u.length;r>n;n++)a=u[n],a.parent().detach(a),e.attach(a);for(o=0,s=j.length;s>o;o++)i=j[o],i.parent().detach(i),e.attach(i)}return h?(k.focus(),h.select(k.domElement())):void 0},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.prototype._addDOMEventListeners=function(){},b.prototype._removeDOMEventListners=function(){},b.fromDOMElement=function(a){var b,c,d,e,f,g,h,i,j,k;for(f=new this(this.getDOMElementAttributes(a)),c="",d=null,j=a.childNodes,h=0,i=j.length;i>h;h++)b=j[h],1===b.nodeType?"ul"===(k=b.tagName.toLowerCase())||"li"===k?d||(d=b):c+=b.outerHTML:c+=HTMLString.String.encode(b.textContent);return c=c.replace(/^\s+|\s+$/g,""),g=new ContentEdit.ListItemText(c),f.attach(g),d&&(e=ContentEdit.List.fromDOMElement(d),f.attach(e)),f},b}(ContentEdit.ElementCollection),ContentEdit.ListItemText=function(a){function b(a){b.__super__.constructor.call(this,"div",{},a)}return g(b,a),b.prototype.cssTypeName=function(){return"list-item-text"},b.prototype.type=function(){return"ListItemText"},b.prototype.typeName=function(){return"List item"},b.prototype.blur=function(){return this.content.isWhitespace()&&this.can("remove")?this.parent().remove():this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),ContentEdit.Element.prototype.blur.call(this)},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCachedc;c++)if(b=e[c],b.tagName()===a)return b;return null},b.droppers={Image:ContentEdit.Element._dropBoth,List:ContentEdit.Element._dropVert,PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Table:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert,Video:ContentEdit.Element._dropBoth},b.fromDOMElement=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(h=new this(this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),e=[],j=0,l=d.length;l>j;j++)if(c=d[j],1===c.nodeType&&(i=c.tagName.toLowerCase(),!h._getChild(i)))switch(i){case"tbody":case"tfoot":case"thead":g=ContentEdit.TableSection.fromDOMElement(c),h.attach(g);break;case"tr":e.push(ContentEdit.TableRow.fromDOMElement(c))}if(e.length>0)for(h._getChild("tbody")||h.attach(new ContentEdit.TableSection("tbody")),k=0,m=e.length;m>k;k++)f=e[k],h.tbody().attach(f);return 0===h.children.length?null:h},b}(ContentEdit.ElementCollection),ContentEdit.TagNames.get().register(ContentEdit.Table,"table"),ContentEdit.TableSection=function(a){function b(a,c){b.__super__.constructor.call(this,a,c)}return g(b,a),b.prototype.cssTypeName=function(){return"table-section"},b.prototype.type=function(){return"TableSection"},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.fromDOMElement=function(a){var b,c,d,e,f,g;for(e=new this(a.tagName,this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),f=0,g=d.length;g>f;f++)c=d[f],1===c.nodeType&&"tr"===c.tagName.toLowerCase()&&e.attach(ContentEdit.TableRow.fromDOMElement(c));return e},b}(ContentEdit.ElementCollection),ContentEdit.TableRow=function(a){function b(a){b.__super__.constructor.call(this,"tr",a)}return g(b,a),b.prototype.cssTypeName=function(){return"table-row"},b.prototype.isEmpty=function(){var a,b,c,d,e;for(e=this.children,c=0,d=e.length;d>c;c++)if(a=e[c],b=a.tableCellText(),b&&b.content.length()>0)return!1;return!0},b.prototype.type=function(){return"TableRow"},b.prototype.typeName=function(){return"Table row"},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.droppers={TableRow:ContentEdit.Element._dropVert},b.fromDOMElement=function(a){var b,c,d,e,f,g,h;for(e=new this(this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),g=0,h=d.length;h>g;g++)c=d[g],1===c.nodeType&&(f=c.tagName.toLowerCase(),("td"===f||"th"===f)&&e.attach(ContentEdit.TableCell.fromDOMElement(c)));return e},b}(ContentEdit.ElementCollection),ContentEdit.TableCell=function(a){function b(a,c){b.__super__.constructor.call(this,a,c)}return g(b,a),b.prototype.cssTypeName=function(){return"table-cell"},b.prototype.tableCellText=function(){return this.children.length>0?this.children[0]:null},b.prototype.type=function(){return"TableCell"},b.prototype.html=function(a){var b;return null==a&&(a=""),b=[""+a+"<"+this.tagName()+this._attributesToString()+">"],this.tableCellText()&&b.push(this.tableCellText().html(a+ContentEdit.INDENT)),b.push(""+a+""),b.join("\n")},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.prototype._addDOMEventListeners=function(){},b.prototype._removeDOMEventListners=function(){},b.fromDOMElement=function(a){var b,c;return b=new this(a.tagName,this.getDOMElementAttributes(a)),c=new ContentEdit.TableCellText(a.innerHTML.replace(/^\s+|\s+$/g,"")),b.attach(c),b},b}(ContentEdit.ElementCollection),ContentEdit.TableCellText=function(a){function b(a){b.__super__.constructor.call(this,"div",{},a)}return g(b,a),b.prototype.cssTypeName=function(){return"table-cell-text"},b.prototype.type=function(){return"TableCellText"},b.prototype._isInFirstRow=function(){var a,b,c,d;return a=this.parent(),b=a.parent(),c=b.parent(),d=c.parent(),c!==d.firstSection()?!1:b===c.children[0]},b.prototype._isInLastRow=function(){var a,b,c,d;return a=this.parent(),b=a.parent(),c=b.parent(),d=c.parent(),c!==d.lastSection()?!1:b===c.children[c.children.length-1]},b.prototype._isLastInSection=function(){var a,b,c;return a=this.parent(),b=a.parent(),c=b.parent(),b!==c.children[c.children.length-1]?!1:a===b.children[b.children.length-1]},b.prototype.blur=function(){return this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),ContentEdit.Element.prototype.blur.call(this)},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCachedi;i++)c=k[i],e=new ContentEdit.TableCell(c.tagName(),c._attributes),f=new ContentEdit.TableCellText(""),e.attach(f),g.attach(e);return h=this.closest(function(a){return"TableSection"===a.type()}),h.attach(g),g.children[0].tableCellText().focus()}return this.nextContent().focus()}},b.prototype._keyUp=function(a){var b,c,d,e,f,g;return g=ContentSelect.Range.query(this._domElement),0===g.get()[0]&&g.isCollapsed()?(a.preventDefault(),b=this.parent(),this._isInFirstRow()?(f=b.parent(),d=f.children[0].previousContent(),d?d.focus():ContentEdit.Root.get().trigger("previous-region",this.closest(function(a){return"Region"===a}))):(e=b.parent().previousWithTest(function(a){return"TableRow"===a.type()}),c=b.parent().children.indexOf(b),c=Math.min(c,e.children.length),e.children[c].tableCellText().focus())):void 0},b.droppers={},b.mergers={},b}(ContentEdit.Text)}.call(this),function(){var a,b,c,d,e={}.hasOwnProperty,f=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g=function(a,b){return function(){return a.apply(b,arguments)}},h=[].slice;window.ContentTools={Tools:{},CANCEL_MESSAGE:"Your changes have not been saved, do you really want to lose them?".trim(),DEFAULT_TOOLS:[["bold","italic","link","align-left","align-center","align-right"],["heading","subheading","paragraph","unordered-list","ordered-list","table","indent","unindent","line-break"],["image","video","preformatted"],["undo","redo","remove"]],DEFAULT_VIDEO_HEIGHT:300,DEFAULT_VIDEO_WIDTH:400,HIGHLIGHT_HOLD_DURATION:2e3,INSPECTOR_IGNORED_ELEMENTS:["ListItemText","Region","TableCellText"],IMAGE_UPLOADER:null,MIN_CROP:10,RESTRICTED_ATTRIBUTES:{"*":["style"],img:["height","src","width","data-ce-max-width","data-ce-min-width"],iframe:["height","width"]},getEmbedVideoURL:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;for(b={"www.youtube.com":"youtube","youtu.be":"youtube","vimeo.com":"vimeo","player.vimeo.com":"vimeo"},k=document.createElement("a"),k.href=a,g=k.hostname.toLowerCase(),l=k.pathname,null!==l&&"/"!==l.substr(0,1)&&(l="/"+l),i={},j=k.search.slice(1),p=j.split("&"),n=0,o=p.length;o>n;n++)e=p[n],e=e.split("="),e[0]&&(i[e[0]]=e[1]);switch(b[g]){case"youtube":if("/watch"===l.toLowerCase()){if(!i.v)return null;c=i.v,delete i.v}else{if(f=l.match(/\/([A-Za-z0-9_-]+)$/i),!f)return null;c=f[1]}return a="https://www.youtube.com/embed/"+c,h=function(){var a;a=[];for(d in i)m=i[d],a.push(""+d+"="+m);return a}().join("&"),h&&(a+="?"+h),a;case"vimeo":return(f=l.match(/\/(\w+\/\w+\/){0,1}(\d+)/i))?(a="https://player.vimeo.com/video/"+f[2],h=function(){var a;a=[];for(d in i)m=i[d],a.push(""+d+"="+m);return a}().join("&"),h&&(a+="?"+h),a):null}return null},getRestrictedAtributes:function(a){var b;return b=[],ContentTools.RESTRICTED_ATTRIBUTES[a]&&(b=b.concat(ContentTools.RESTRICTED_ATTRIBUTES[a])),ContentTools.RESTRICTED_ATTRIBUTES["*"]&&(b=b.concat(ContentTools.RESTRICTED_ATTRIBUTES["*"])),b}},ContentTools.ComponentUI=function(){function a(){this._eventBinderDOM=document.createElement("div"),this._bindings={},this._parent=null,this._children=[],this._domElement=null}return a.prototype.children=function(){return this._children.slice()},a.prototype.domElement=function(){return this._domElement},a.prototype.isMounted=function(){return null!==this._domElement},a.prototype.parent=function(){return this._parent},a.prototype.attach=function(a,b){return a.parent()&&a.parent().detach(a),a._parent=this,void 0!==b?this._children.splice(b,0,a):this._children.push(a)},a.prototype.addCSSClass=function(a){return this.isMounted()?ContentEdit.addCSSClass(this._domElement,a):void 0},a.prototype.detatch=function(a){var b;return b=this._children.indexOf(a),-1!==b?this._children.splice(b,1):void 0},a.prototype.mount=function(){},a.prototype.removeCSSClass=function(a){return this.isMounted()?ContentEdit.removeCSSClass(this._domElement,a):void 0},a.prototype.unmount=function(){return this.isMounted()?(this._removeDOMEventListeners(),this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null):void 0},a.prototype.addEventListener=function(a,b){void 0===this._bindings[a]&&(this._bindings[a]=[]),this._bindings[a].push(b)},a.prototype.createEvent=function(a,b){return new ContentTools.Event(a,b)},a.prototype.dispatchEvent=function(a){var b,c,d,e;if(!this._bindings[a.name()])return!a.defaultPrevented();for(e=this._bindings[a.name()],c=0,d=e.length;d>c&&(b=e[c],!a.propagationStopped());c++)b&&b.call(this,a);return!a.defaultPrevented()},a.prototype.removeEventListener=function(a,b){var c,d,e,f,g,h;if(!a)return void(this._bindings={});if(!b)return void(this._bindings[a]=void 0);if(this._bindings[a]){for(g=this._bindings[a],h=[],c=e=0,f=g.length;f>e;c=++e)d=g[c],h.push(d===b?this._bindings[a].splice(c,1):void 0);return h}},a.prototype._addDOMEventListeners=function(){},a.prototype._removeDOMEventListeners=function(){},a.createDiv=function(a,b,c){var d,e,f;if(d=document.createElement("div"),a&&a.length>0&&d.setAttribute("class",a.join(" ")),b)for(e in b)f=b[e],d.setAttribute(e,f);return c&&(d.innerHTML=c),d},a}(),ContentTools.WidgetUI=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),b.prototype.attach=function(a,c){return b.__super__.attach.call(this,a,c),this.isMounted()?void 0:a.mount()},b.prototype.detatch=function(a){return b.__super__.detatch.call(this,a),this.isMounted()?a.unmount():void 0},b.prototype.show=function(){var a;return this.isMounted()||this.mount(),a=function(a){return function(){return a.addCSSClass("ct-widget--active")}}(this),setTimeout(a,100)},b.prototype.hide=function(){var a;return this.removeCSSClass("ct-widget--active"),a=function(b){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(b._domElement).opacity)<.01?b.unmount():setTimeout(a,250):void b.unmount()}}(this),this.isMounted()?setTimeout(a,250):void 0},b}(ContentTools.ComponentUI),ContentTools.AnchoredComponentUI=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),b.prototype.mount=function(a,b){return null==b&&(b=null),a.insertBefore(this._domElement,b),this._addDOMEventListeners()},b}(ContentTools.ComponentUI),ContentTools.Event=function(){function a(a,b){this._name=a,this._detail=b,this._timeStamp=Date.now(),this._defaultPrevented=!1,this._propagationStopped=!1}return a.prototype.defaultPrevented=function(){return this._defaultPrevented},a.prototype.detail=function(){return this._detail},a.prototype.name=function(){return this._name},a.prototype.propagationStopped=function(){return this._propagationStopped},a.prototype.timeStamp=function(){return this._timeStamp},a.prototype.preventDefault=function(){return this._defaultPrevented=!0},a.prototype.stopImmediatePropagation=function(){return this._propagationStopped=!0},a}(),ContentTools.FlashUI=function(a){function b(a){b.__super__.constructor.call(this),this.mount(a)}return f(b,a),b.prototype.mount=function(a){var c;return this._domElement=this.constructor.createDiv(["ct-flash","ct-flash--active","ct-flash--"+a,"ct-widget","ct-widget--active"]),b.__super__.mount.call(this,ContentTools.EditorApp.get().domElement()),c=function(a){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(a._domElement).opacity)<.01?a.unmount():setTimeout(c,250):void a.unmount()}}(this),setTimeout(c,250)},b}(ContentTools.AnchoredComponentUI),ContentTools.IgnitionUI=function(a){function b(){b.__super__.constructor.call(this),this._revertToState="ready",this._state="ready"}return f(b,a),b.prototype.busy=function(a){if(this.dispatchEvent(this.createEvent("busy",{busy:a}))){if(a===("busy"===this._state))return;return a?(this._revertToState=this._state,this.state("busy")):this.state(this._revertToState)}},b.prototype.cancel=function(){return this.dispatchEvent(this.createEvent("cancel"))?this.state("ready"):void 0},b.prototype.confirm=function(){return this.dispatchEvent(this.createEvent("confirm"))?this.state("ready"):void 0},b.prototype.edit=function(){return this.dispatchEvent(this.createEvent("edit"))?this.state("editing"):void 0},b.prototype.mount=function(){return b.__super__.mount.call(this),this._domElement=this.constructor.createDiv(["ct-widget","ct-ignition","ct-ignition--ready"]),this.parent().domElement().appendChild(this._domElement),this._domEdit=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--edit"]),this._domElement.appendChild(this._domEdit),this._domConfirm=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--confirm"]),this._domElement.appendChild(this._domConfirm),this._domCancel=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--cancel"]),this._domElement.appendChild(this._domCancel),this._domBusy=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--busy"]),this._domElement.appendChild(this._domBusy),this._addDOMEventListeners()},b.prototype.state=function(a){if(void 0===a)return this._state;if(this._state!==a&&this.dispatchEvent(this.createEvent("statechange",{state:a})))return this._state=a,this.removeCSSClass("ct-ignition--busy"),this.removeCSSClass("ct-ignition--editing"),this.removeCSSClass("ct-ignition--ready"),"busy"===this._state?this.addCSSClass("ct-ignition--busy"):"editing"===this._state?this.addCSSClass("ct-ignition--editing"):"ready"===this._state?this.addCSSClass("ct-ignition--ready"):void 0},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domEdit=null,this._domConfirm=null,this._domCancel=null},b.prototype._addDOMEventListeners=function(){return this._domEdit.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.edit()}}(this)),this._domConfirm.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.confirm()}}(this)),this._domCancel.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.cancel()}}(this))},b}(ContentTools.WidgetUI),ContentTools.InspectorUI=function(a){function b(){b.__super__.constructor.call(this),this._tagUIs=[]}return f(b,a),b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-inspector"]),this.parent().domElement().appendChild(this._domElement),this._domTags=this.constructor.createDiv(["ct-inspector__tags","ct-tags"]),this._domElement.appendChild(this._domTags),this._addDOMEventListeners(),this._handleFocusChange=function(a){return function(){return a.updateTags()}}(this),ContentEdit.Root.get().bind("blur",this._handleFocusChange),ContentEdit.Root.get().bind("focus",this._handleFocusChange),ContentEdit.Root.get().bind("mount",this._handleFocusChange)},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domTags=null,ContentEdit.Root.get().unbind("blur",this._handleFocusChange),ContentEdit.Root.get().unbind("focus",this._handleFocusChange),ContentEdit.Root.get().unbind("mount",this._handleFocusChange)},b.prototype.updateTags=function(){var a,b,c,d,e,f,g,h,i;for(a=ContentEdit.Root.get().focused(),h=this._tagUIs,d=0,f=h.length;f>d;d++)c=h[d],c.unmount();if(this._tagUIs=[],a){for(b=a.parents(),b.reverse(),b.push(a),i=[],e=0,g=b.length;g>e;e++)a=b[e],-1===ContentTools.INSPECTOR_IGNORED_ELEMENTS.indexOf(a.type())&&(c=new ContentTools.TagUI(a),this._tagUIs.push(c),i.push(c.mount(this._domTags)));return i}},b}(ContentTools.WidgetUI),ContentTools.TagUI=function(a){function b(a){this.element=a,this._onMouseDown=g(this._onMouseDown,this),b.__super__.constructor.call(this)}return f(b,a),b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-tag"]),this._domElement.textContent=this.element.tagName(),b.__super__.mount.call(this,a,c)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown)},b.prototype._onMouseDown=function(a){var b,c,d;return a.preventDefault(),this.element.storeState&&this.element.storeState(),b=ContentTools.EditorApp.get(),d=new ContentTools.ModalUI,c=new ContentTools.PropertiesDialog(this.element),c.addEventListener("cancel",function(a){return function(){return d.hide(),c.hide(),a.element.restoreState?a.element.restoreState():void 0}}(this)),c.addEventListener("save",function(a){return function(b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;j=b.detail(),f=j.changedAttributes,n=j.changedStyles,l=j.innerHTML;for(m in f)if(o=f[m],"class"===m){for(null===o&&(o=""),h={},t=o.split(" "),p=0,r=t.length;r>p;p++)g=t[p],g=g.trim(),g&&(h[g]=!0,a.element.hasCSSClass(g)||a.element.addCSSClass(g));for(u=a.element.attr("class").split(" "),q=0,s=u.length;s>q;q++)g=u[q],g=g.trim(),void 0===h[g]&&a.element.removeCSSClass(g)}else null===o?a.element.removeAttr(m):a.element.attr(m,o);for(i in n)e=n[i],e?a.element.addCSSClass(i):a.element.removeCSSClass(i);return null!==l&&l!==c.getElementInnerHTML()&&(k=a.element,k.content||(k=k.children[0]),k.content=new HTMLString.String(l,k.content.preserveWhitespace()),k.updateInnerHTML(),k.taint(),k.selection(new ContentSelect.Range(0,0)),k.storeState()),d.hide(),c.hide(),a.element.restoreState?a.element.restoreState():void 0}}(this)),b.attach(d),b.attach(c),d.show(),c.show()},b}(ContentTools.AnchoredComponentUI),ContentTools.ModalUI=function(a){function b(a,c){b.__super__.constructor.call(this),this._transparent=a,this._allowScrolling=c}return f(b,a),b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-modal"]),this.parent().domElement().appendChild(this._domElement),this._transparent&&this.addCSSClass("ct-modal--transparent"),this._allowScrolling||ContentEdit.addCSSClass(document.body,"ct--no-scroll"),this._addDOMEventListeners()},b.prototype.unmount=function(){return this._allowScrolling||ContentEdit.removeCSSClass(document.body,"ct--no-scroll"),b.__super__.unmount.call(this)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("click",function(a){return function(){return a.dispatchEvent(a.createEvent("click"))}}(this))},b}(ContentTools.WidgetUI),ContentTools.ToolboxUI=function(a){function b(a){this._onStopDragging=g(this._onStopDragging,this),this._onStartDragging=g(this._onStartDragging,this),this._onDrag=g(this._onDrag,this),b.__super__.constructor.call(this),this._tools=a,this._dragging=!1,this._draggingOffset=null,this._domGrip=null,this._toolUIs={}}return f(b,a),b.prototype.isDragging=function(){return this._dragging},b.prototype.hide=function(){return this._removeDOMEventListeners(),b.__super__.hide.call(this)},b.prototype.mount=function(){var a,b,c;return this._domElement=this.constructor.createDiv(["ct-widget","ct-toolbox"]),this.parent().domElement().appendChild(this._domElement),this._domGrip=this.constructor.createDiv(["ct-toolbox__grip","ct-grip"]),this._domElement.appendChild(this._domGrip),this._domGrip.appendChild(this.constructor.createDiv(["ct-grip__bump"])),this._domGrip.appendChild(this.constructor.createDiv(["ct-grip__bump"])),this._domGrip.appendChild(this.constructor.createDiv(["ct-grip__bump"])),this._domToolGroups=this.constructor.createDiv(["ct-tool-groups"]),this._domElement.appendChild(this._domToolGroups),this.tools(this._tools),c=window.localStorage.getItem("ct-toolbox-position"),c&&/^\d+,\d+$/.test(c)&&(b=function(){var b,d,e,f;for(e=c.split(","),f=[],b=0,d=e.length;d>b;b++)a=e[b],f.push(parseInt(a));return f}(),this._domElement.style.left=""+b[0]+"px",this._domElement.style.top=""+b[1]+"px",this._contain()),this._addDOMEventListeners()},b.prototype.tools=function(a){var b,c,d,e,f,g,h,i,j,k,l;if(void 0===a)return this._tools; -if(this._tools=a,this.isMounted()){j=this._toolUIs;for(f in j)g=j[f],g.unmount();for(this._toolUIs={};this._domToolGroups.lastChild;)this._domToolGroups.removeChild(this._domToolGroups.lastChild);for(k=this._tools,l=[],c=h=0,i=k.length;i>h;c=++h)e=k[c],b=this.constructor.createDiv(["ct-tool-group"]),this._domToolGroups.appendChild(b),l.push(function(){var a,c,g;for(g=[],a=0,c=e.length;c>a;a++)f=e[a],d=ContentTools.ToolShelf.fetch(f),this._toolUIs[f]=new ContentTools.ToolUI(d),this._toolUIs[f].mount(b),this._toolUIs[f].disabled(!0),g.push(this._toolUIs[f].addEventListener("applied",function(a){return function(){return a.updateTools()}}(this)));return g}.call(this));return l}},b.prototype.updateTools=function(){var a,b,c,d,e,f;a=ContentEdit.Root.get().focused(),c=null,a&&a.selection&&(c=a.selection()),e=this._toolUIs,f=[];for(b in e)d=e[b],f.push(d.update(a,c));return f},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domGrip=null},b.prototype._addDOMEventListeners=function(){return this._domGrip.addEventListener("mousedown",this._onStartDragging),this._handleResize=function(a){return function(){var b;return a._resizeTimeout&&clearTimeout(a._resizeTimeout),b=function(){return a._contain()},a._resizeTimeout=setTimeout(b,250)}}(this),window.addEventListener("resize",this._handleResize),this._updateTools=function(a){return function(){var b,c,d,e,f,g,h,i;if(b=ContentTools.EditorApp.get(),g=!1,c=ContentEdit.Root.get().focused(),e=null,c===a._lastUpdateElement?c&&c.selection&&(e=c.selection(),a._lastUpdateSelection?e.eq(a._lastUpdateSelection)||(g=!0):g=!0):g=!0,b.history&&(a._lastUpdateHistoryLength!==b.history.length()&&(g=!0),a._lastUpdateHistoryLength=b.history.length(),a._lastUpdateHistoryIndex!==b.history.index()&&(g=!0),a._lastUpdateHistoryIndex=b.history.index()),a._lastUpdateElement=c,a._lastUpdateSelection=e,g){h=a._toolUIs,i=[];for(d in h)f=h[d],i.push(f.update(c,e));return i}}}(this),this._updateToolsTimeout=setInterval(this._updateTools,100),this._handleKeyDown=function(){return function(a){var b,c,d,e,f;switch(46===a.keyCode&&(b=ContentEdit.Root.get().focused(),b&&!b.content&&ContentTools.Tools.Remove.apply(b,null,function(){})),f=navigator.appVersion,c="linux",-1!==f.indexOf("Mac")?c="mac":-1!==f.indexOf("Win")&&(c="windows"),d=!1,e=!1,c){case"linux":90===a.keyCode&&a.ctrlKey&&(d=a.shiftKey,e=!d);break;case"mac":90===a.keyCode&&a.metaKey&&(d=a.shiftKey,e=!d);break;case"windows":89===a.keyCode&&a.ctrlKey&&(d=!0),90===a.keyCode&&a.ctrlKey&&(e=!0)}return e&&ContentTools.Tools.Undo.canApply(null,null)&&ContentTools.Tools.Undo.apply(null,null,function(){}),d&&ContentTools.Tools.Redo.canApply(null,null)?ContentTools.Tools.Redo.apply(null,null,function(){}):void 0}}(this),window.addEventListener("keydown",this._handleKeyDown)},b.prototype._contain=function(){var a;if(this.isMounted())return a=this._domElement.getBoundingClientRect(),a.left+a.width>window.innerWidth&&(this._domElement.style.left=""+(window.innerWidth-a.width)+"px"),a.top+a.height>window.innerHeight&&(this._domElement.style.top=""+(window.innerHeight-a.height)+"px"),a.left<0&&(this._domElement.style.left="0px"),a.top<0&&(this._domElement.style.top="0px"),a=this._domElement.getBoundingClientRect(),window.localStorage.setItem("ct-toolbox-position",""+a.left+","+a.top)},b.prototype._removeDOMEventListeners=function(){return this.isMounted()&&this._domGrip.removeEventListener("mousedown",this._onStartDragging),window.removeEventListener("keydown",this._handleKeyDown),window.removeEventListener("resize",this._handleResize),window.removeEventListener("resize",this._handleResize),clearInterval(this._updateToolsTimeout)},b.prototype._onDrag=function(a){return ContentSelect.Range.unselectAll(),this._domElement.style.left=""+(a.clientX-this._draggingOffset.x)+"px",this._domElement.style.top=""+(a.clientY-this._draggingOffset.y)+"px"},b.prototype._onStartDragging=function(a){var b;return a.preventDefault(),this.isDragging()?void 0:(this._dragging=!0,this.addCSSClass("ct-toolbox--dragging"),b=this._domElement.getBoundingClientRect(),this._draggingOffset={x:a.clientX-b.left,y:a.clientY-b.top},document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging"))},b.prototype._onStopDragging=function(){return this.isDragging()?(this._contain(),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._draggingOffset=null,this._dragging=!1,this.removeCSSClass("ct-toolbox--dragging"),ContentEdit.removeCSSClass(document.body,"ce--dragging")):void 0},b}(ContentTools.WidgetUI),ContentTools.ToolUI=function(a){function b(a){this._onMouseUp=g(this._onMouseUp,this),this._onMouseLeave=g(this._onMouseLeave,this),this._onMouseDown=g(this._onMouseDown,this),this._addDOMEventListeners=g(this._addDOMEventListeners,this),b.__super__.constructor.call(this),this.tool=a,this._mouseDown=!1,this._disabled=!1}return f(b,a),b.prototype.apply=function(a,b){var c,d;if(this.tool.canApply(a,b))return d={element:a,selection:b},c=function(a){return function(b){return b?a.dispatchEvent(a.createEvent("applied",d)):void 0}}(this),this.dispatchEvent(this.createEvent("apply",d))?this.tool.apply(a,b,c):void 0},b.prototype.disabled=function(a){if(void 0===a)return this._disabled;if(this._disabled!==a)return this._disabled=a,a?(this._mouseDown=!1,this.addCSSClass("ct-tool--disabled"),this.removeCSSClass("ct-tool--applied")):this.removeCSSClass("ct-tool--disabled")},b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-tool","ct-tool--"+this.tool.icon]),this._domElement.setAttribute("data-tooltip",ContentEdit._(this.tool.label)),b.__super__.mount.call(this,a,c)},b.prototype.update=function(a,b){return(!this.tool.requiresElement||a&&a.isMounted())&&this.tool.canApply(a,b)?(this.disabled(!1),this.tool.isApplied(a,b)?this.addCSSClass("ct-tool--applied"):this.removeCSSClass("ct-tool--applied")):void this.disabled(!0)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown),this._domElement.addEventListener("mouseleave",this._onMouseLeave),this._domElement.addEventListener("mouseup",this._onMouseUp)},b.prototype._onMouseDown=function(a){return a.preventDefault(),this.disabled()?void 0:(this._mouseDown=!0,this.addCSSClass("ct-tool--down"))},b.prototype._onMouseLeave=function(){return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},b.prototype._onMouseUp=function(){var a,b;if(this._mouseDown){if(a=ContentEdit.Root.get().focused(),this.tool.requiresElement&&(!a||!a.isMounted()))return;b=null,a&&a.selection&&(b=a.selection()),this.apply(a,b)}return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},b}(ContentTools.AnchoredComponentUI),ContentTools.AnchoredDialogUI=function(a){function b(){b.__super__.constructor.call(this),this._position=[0,0]}return f(b,a),b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-anchored-dialog"]),this.parent().domElement().appendChild(this._domElement),this._domElement.style.top=""+this._position[1]+"px",this._domElement.style.left=""+this._position[0]+"px"},b.prototype.position=function(a){return void 0===a?this._position.slice():(this._position=a.slice(),this.isMounted()?(this._domElement.style.top=""+this._position[1]+"px",this._domElement.style.left=""+this._position[0]+"px"):void 0)},b}(ContentTools.WidgetUI),ContentTools.DialogUI=function(a){function b(a){null==a&&(a=""),b.__super__.constructor.call(this),this._busy=!1,this._caption=a}return f(b,a),b.prototype.busy=function(a){if(void 0===a)return this._busy;if(this._busy!==a&&(this._busy=a,this.isMounted()))return this._busy?ContentEdit.addCSSClass(this._domElement,"ct-dialog--busy"):ContentEdit.removeCSSClass(this._domElement,"ct-dialog--busy")},b.prototype.caption=function(a){return void 0===a?this._caption:(this._caption=a,this._domCaption.textContent=ContentEdit._(a))},b.prototype.mount=function(){var a,b,c;return a=["ct-widget","ct-dialog"],this._busy&&a.push("ct-dialog--busy"),this._domElement=this.constructor.createDiv(a),this.parent().domElement().appendChild(this._domElement),c=this.constructor.createDiv(["ct-dialog__header"]),this._domElement.appendChild(c),this._domCaption=this.constructor.createDiv(["ct-dialog__caption"]),c.appendChild(this._domCaption),this.caption(this._caption),this._domClose=this.constructor.createDiv(["ct-dialog__close"]),c.appendChild(this._domClose),b=this.constructor.createDiv(["ct-dialog__body"]),this._domElement.appendChild(b),this._domView=this.constructor.createDiv(["ct-dialog__view"]),b.appendChild(this._domView),this._domControls=this.constructor.createDiv(["ct-dialog__controls"]),b.appendChild(this._domControls),this._domBusy=this.constructor.createDiv(["ct-dialog__busy"]),this._domElement.appendChild(this._domBusy)},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domBusy=null,this._domCaption=null,this._domClose=null,this._domControls=null,this._domView=null},b.prototype._addDOMEventListeners=function(){return this._handleEscape=function(a){return function(b){return a._busy?void 0:27===b.keyCode?a.dispatchEvent(a.createEvent("cancel")):void 0}}(this),document.addEventListener("keyup",this._handleEscape),this._domClose.addEventListener("click",function(a){return function(b){return b.preventDefault(),a._busy?void 0:a.dispatchEvent(a.createEvent("cancel"))}}(this))},b.prototype._removeDOMEventListeners=function(){return document.removeEventListener("keyup",this._handleEscape)},b}(ContentTools.WidgetUI),ContentTools.ImageDialog=function(a){function c(){c.__super__.constructor.call(this,"Insert image"),this._cropMarks=null,this._imageURL=null,this._imageSize=null,this._progress=0,this._state="empty",ContentTools.IMAGE_UPLOADER&&ContentTools.IMAGE_UPLOADER(this)}return f(c,a),c.prototype.cropRegion=function(){return this._cropMarks?this._cropMarks.region():[0,0,1,1]},c.prototype.addCropMarks=function(){return this._cropMarks?void 0:(this._cropMarks=new b(this._imageSize),this._cropMarks.mount(this._domView),ContentEdit.addCSSClass(this._domCrop,"ct-control--active"))},c.prototype.clear=function(){return this._domImage&&(this._domImage.parentNode.removeChild(this._domImage),this._domImage=null),this._imageURL=null,this._imageSize=null,this.state("empty")},c.prototype.mount=function(){var a,b,d;return c.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-image-dialog"),ContentEdit.addCSSClass(this._domElement,"ct-image-dialog--empty"),ContentEdit.addCSSClass(this._domView,"ct-image-dialog__view"),d=this.constructor.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(d),this._domRotateCCW=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--rotate-ccw"]),this._domRotateCCW.setAttribute("data-tooltip",ContentEdit._("Rotate")+" -90°"),d.appendChild(this._domRotateCCW),this._domRotateCW=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--rotate-cw"]),this._domRotateCW.setAttribute("data-tooltip",ContentEdit._("Rotate")+" 90°"),d.appendChild(this._domRotateCW),this._domCrop=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--crop"]),this._domCrop.setAttribute("data-tooltip",ContentEdit._("Crop marks")),d.appendChild(this._domCrop),b=this.constructor.createDiv(["ct-progress-bar"]),d.appendChild(b),this._domProgress=this.constructor.createDiv(["ct-progress-bar__progress"]),b.appendChild(this._domProgress),a=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(a),this._domUpload=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--upload"]),this._domUpload.textContent=ContentEdit._("Upload"),a.appendChild(this._domUpload),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-image-dialog__file-upload"),this._domInput.setAttribute("name","file"),this._domInput.setAttribute("type","file"),this._domInput.setAttribute("accept","image/*"),this._domUpload.appendChild(this._domInput),this._domInsert=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--insert"]),this._domInsert.textContent=ContentEdit._("Insert"),a.appendChild(this._domInsert),this._domCancelUpload=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--cancel"]),this._domCancelUpload.textContent=ContentEdit._("Cancel"),a.appendChild(this._domCancelUpload),this._domClear=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--clear"]),this._domClear.textContent=ContentEdit._("Clear"),a.appendChild(this._domClear),this._addDOMEventListeners(),this.dispatchEvent(this.createEvent("imageuploader.mount"))},c.prototype.populate=function(a,b){return this._imageURL=a,this._imageSize=b,this._domImage||(this._domImage=this.constructor.createDiv(["ct-image-dialog__image"]),this._domView.appendChild(this._domImage)),this._domImage.style["background-image"]="url("+a+")",this.state("populated")},c.prototype.progress=function(a){return void 0===a?this._progress:(this._progress=a,this.isMounted()?this._domProgress.style.width=""+this._progress+"%":void 0)},c.prototype.removeCropMarks=function(){return this._cropMarks?(this._cropMarks.unmount(),this._cropMarks=null,ContentEdit.removeCSSClass(this._domCrop,"ct-control--active")):void 0},c.prototype.save=function(a,b,c){return this.dispatchEvent(this.createEvent("save",{imageURL:a,imageSize:b,imageAttrs:c}))},c.prototype.state=function(a){var b;if(void 0===a)return this._state;if(this._state!==a&&(b=this._state,this._state=a,this.isMounted()))return ContentEdit.addCSSClass(this._domElement,"ct-image-dialog--"+this._state),ContentEdit.removeCSSClass(this._domElement,"ct-image-dialog--"+b)},c.prototype.unmount=function(){return c.__super__.unmount.call(this),this._domCancelUpload=null,this._domClear=null,this._domCrop=null,this._domInput=null,this._domInsert=null,this._domProgress=null,this._domRotateCCW=null,this._domRotateCW=null,this._domUpload=null,this.dispatchEvent(this.createEvent("imageuploader.unmount"))},c.prototype._addDOMEventListeners=function(){return c.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("change",function(a){return function(b){var c;return c=b.target.files[0],b.target.value="",b.target.value&&(b.target.type="text",b.target.type="file"),a.dispatchEvent(a.createEvent("imageuploader.fileready",{file:c}))}}(this)),this._domCancelUpload.addEventListener("click",function(a){return function(){return a.dispatchEvent(a.createEvent("imageuploader.cancelupload"))}}(this)),this._domClear.addEventListener("click",function(a){return function(){return a.removeCropMarks(),a.dispatchEvent(a.createEvent("imageuploader.clear"))}}(this)),this._domRotateCCW.addEventListener("click",function(a){return function(){return a.removeCropMarks(),a.dispatchEvent(a.createEvent("imageuploader.rotateccw"))}}(this)),this._domRotateCW.addEventListener("click",function(a){return function(){return a.removeCropMarks(),a.dispatchEvent(a.createEvent("imageuploader.rotatecw"))}}(this)),this._domCrop.addEventListener("click",function(a){return function(){return a._cropMarks?a.removeCropMarks():a.addCropMarks()}}(this)),this._domInsert.addEventListener("click",function(a){return function(){return a.dispatchEvent(a.createEvent("imageuploader.save"))}}(this))},c}(ContentTools.DialogUI),b=function(a){function b(a){b.__super__.constructor.call(this),this._bounds=null,this._dragging=null,this._draggingOrigin=null,this._imageSize=a}return f(b,a),b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-crop-marks"]),this._domClipper=this.constructor.createDiv(["ct-crop-marks__clipper"]),this._domElement.appendChild(this._domClipper),this._domRulers=[this.constructor.createDiv(["ct-crop-marks__ruler","ct-crop-marks__ruler--top-left"]),this.constructor.createDiv(["ct-crop-marks__ruler","ct-crop-marks__ruler--bottom-right"])],this._domClipper.appendChild(this._domRulers[0]),this._domClipper.appendChild(this._domRulers[1]),this._domHandles=[this.constructor.createDiv(["ct-crop-marks__handle","ct-crop-marks__handle--top-left"]),this.constructor.createDiv(["ct-crop-marks__handle","ct-crop-marks__handle--bottom-right"])],this._domElement.appendChild(this._domHandles[0]),this._domElement.appendChild(this._domHandles[1]),b.__super__.mount.call(this,a,c),this._fit(a)},b.prototype.region=function(){return[parseFloat(this._domHandles[0].style.top)/this._bounds[1],parseFloat(this._domHandles[0].style.left)/this._bounds[0],parseFloat(this._domHandles[1].style.top)/this._bounds[1],parseFloat(this._domHandles[1].style.left)/this._bounds[0]]},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domClipper=null,this._domHandles=null,this._domRulers=null},b.prototype._addDOMEventListeners=function(){return b.__super__._addDOMEventListeners.call(this),this._domHandles[0].addEventListener("mousedown",function(a){return function(b){return 0===b.button?a._startDrag(0,b.clientY,b.clientX):void 0}}(this)),this._domHandles[1].addEventListener("mousedown",function(a){return function(b){return 0===b.button?a._startDrag(1,b.clientY,b.clientX):void 0}}(this))},b.prototype._drag=function(a,b){var c,d,e,f,g;if(null!==this._dragging)return ContentSelect.Range.unselectAll(),f=a-this._draggingOrigin[1],e=b-this._draggingOrigin[0],c=this._bounds[1],b=0,a=0,g=this._bounds[0],d=Math.min(Math.min(ContentTools.MIN_CROP,c),g),0===this._dragging?(c=parseInt(this._domHandles[1].style.top)-d,g=parseInt(this._domHandles[1].style.left)-d):(b=parseInt(this._domHandles[0].style.left)+d,a=parseInt(this._domHandles[0].style.top)+d),f=Math.min(Math.max(a,f),c),e=Math.min(Math.max(b,e),g),this._domHandles[this._dragging].style.top=""+f+"px",this._domHandles[this._dragging].style.left=""+e+"px",this._domRulers[this._dragging].style.top=""+f+"px",this._domRulers[this._dragging].style.left=""+e+"px"},b.prototype._fit=function(a){var b,c,d,e,f,g,h,i;return f=a.getBoundingClientRect(),i=f.width/this._imageSize[0],c=f.height/this._imageSize[1],e=Math.min(i,c),h=e*this._imageSize[0],b=e*this._imageSize[1],d=(f.width-h)/2,g=(f.height-b)/2,this._domElement.style.width=""+h+"px",this._domElement.style.height=""+b+"px",this._domElement.style.top=""+g+"px",this._domElement.style.left=""+d+"px",this._domHandles[0].style.top="0px",this._domHandles[0].style.left="0px",this._domHandles[1].style.top=""+b+"px",this._domHandles[1].style.left=""+h+"px",this._domRulers[0].style.top="0px",this._domRulers[0].style.left="0px",this._domRulers[1].style.top=""+b+"px",this._domRulers[1].style.left=""+h+"px",this._bounds=[h,b]},b.prototype._startDrag=function(a,b,c){var d;return d=this._domHandles[a],this._dragging=a,this._draggingOrigin=[c-parseInt(d.style.left),b-parseInt(d.style.top)],this._onMouseMove=function(a){return function(b){return a._drag(b.clientY,b.clientX)}}(this),document.addEventListener("mousemove",this._onMouseMove),this._onMouseUp=function(a){return function(){return a._stopDrag()}}(this),document.addEventListener("mouseup",this._onMouseUp)},b.prototype._stopDrag=function(){return document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._dragging=null,this._draggingOrigin=null},b}(ContentTools.AnchoredComponentUI),ContentTools.LinkDialog=function(a){function b(a,c){null==a&&(a=""),null==c&&(c=""),b.__super__.constructor.call(this),this._href=a,this._target=c}var c;return f(b,a),c="_blank",b.prototype.mount=function(){return b.__super__.mount.call(this),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-anchored-dialog__input"),this._domInput.setAttribute("name","href"),this._domInput.setAttribute("placeholder",ContentEdit._("Enter a link")+"..."),this._domInput.setAttribute("type","text"),this._domInput.setAttribute("value",this._href),this._domElement.appendChild(this._domInput),this._domTargetButton=this.constructor.createDiv(["ct-anchored-dialog__target-button"]),this._domElement.appendChild(this._domTargetButton),this._target===c&&ContentEdit.addCSSClass(this._domTargetButton,"ct-anchored-dialog__target-button--active"),this._domButton=this.constructor.createDiv(["ct-anchored-dialog__button"]),this._domElement.appendChild(this._domButton),this._addDOMEventListeners()},b.prototype.save=function(){var a;return this.isMounted()?(a={href:this._domInput.value.trim(),target:this._target?this._target:void 0},this.dispatchEvent(this.createEvent("save",a))):void this.dispatchEvent(this.createEvent("save"))},b.prototype.show=function(){return b.__super__.show.call(this),this._domInput.focus(),this._href?this._domInput.select():void 0},b.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),b.__super__.unmount.call(this),this._domButton=null,this._domInput=null},b.prototype._addDOMEventListeners=function(){return this._domInput.addEventListener("keypress",function(a){return function(b){return 13===b.keyCode?a.save():void 0}}(this)),this._domTargetButton.addEventListener("click",function(a){return function(b){return b.preventDefault(),a._target===c?(a._target="",ContentEdit.removeCSSClass(a._domTargetButton,"ct-anchored-dialog__target-button--active")):(a._target=c,ContentEdit.addCSSClass(a._domTargetButton,"ct-anchored-dialog__target-button--active"))}}(this)),this._domButton.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.save()}}(this))},b}(ContentTools.AnchoredDialogUI),ContentTools.PropertiesDialog=function(b){function d(a){var b;this.element=a,d.__super__.constructor.call(this,"Properties"),this._attributeUIs=[],this._focusedAttributeUI=null,this._styleUIs=[],this._supportsCoding=this.element.content,("ListItem"===(b=this.element.type())||"TableCell"===b)&&(this._supportsCoding=!0)}return f(d,b),d.prototype.caption=function(a){return void 0===a?this._caption:(this._caption=a,this._domCaption.textContent=ContentEdit._(a)+(": "+this.element.tagName()))},d.prototype.changedAttributes=function(){var a,b,c,d,e,f,g,h,i,j;for(b={},c={},i=this._attributeUIs,g=0,h=i.length;h>g;g++)a=i[g],d=a.name(),f=a.value(),""!==d&&(b[d.toLowerCase()]=!0,this.element.attr(d)!==f&&(c[d]=f));e=ContentTools.getRestrictedAtributes(this.element.tagName()),j=this.element.attributes();for(d in j)f=j[d],e&&-1!==e.indexOf(d.toLowerCase())||void 0===b[d]&&(c[d]=null);return c},d.prototype.changedStyles=function(){var a,b,c,d,e,f;for(c={},f=this._styleUIs,d=0,e=f.length;e>d;d++)b=f[d],a=b.style.cssClass(),this.element.hasCSSClass(a)!==b.applied()&&(c[a]=b.applied());return c},d.prototype.getElementInnerHTML=function(){return this._supportsCoding?this.element.content?this.element.content.html():this.element.children[0].content.html():null},d.prototype.mount=function(){var a,b,e,f,g,h,i,j,k,l,m,n,o,p,q;for(d.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog"),ContentEdit.addCSSClass(this._domView,"ct-properties-dialog__view"),this._domStyles=this.constructor.createDiv(["ct-properties-dialog__styles"]),this._domStyles.setAttribute("data-ct-empty",ContentEdit._("No styles available for this tag")),this._domView.appendChild(this._domStyles),q=ContentTools.StylePalette.styles(this.element.tagName()),m=0,o=q.length;o>m;m++)j=q[m],k=new c(j,this.element.hasCSSClass(j.cssClass())),this._styleUIs.push(k),k.mount(this._domStyles);this._domAttributes=this.constructor.createDiv(["ct-properties-dialog__attributes"]),this._domView.appendChild(this._domAttributes),i=ContentTools.getRestrictedAtributes(this.element.tagName()),b=this.element.attributes(),a=[];for(h in b)l=b[h],i&&-1!==i.indexOf(h.toLowerCase())||a.push(h);for(a.sort(),n=0,p=a.length;p>n;n++)h=a[n],l=b[h],this._addAttributeUI(h,l);return this._addAttributeUI("",""),this._domCode=this.constructor.createDiv(["ct-properties-dialog__code"]),this._domView.appendChild(this._domCode),this._domInnerHTML=document.createElement("textarea"),this._domInnerHTML.setAttribute("class","ct-properties-dialog__inner-html"),this._domInnerHTML.setAttribute("name","code"),this._domInnerHTML.value=this.getElementInnerHTML(),this._domCode.appendChild(this._domInnerHTML),f=this.constructor.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(f),this._domStylesTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--styles"]),this._domStylesTab.setAttribute("data-tooltip",ContentEdit._("Styles")),f.appendChild(this._domStylesTab),this._domAttributesTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--attributes"]),this._domAttributesTab.setAttribute("data-tooltip",ContentEdit._("Attributes")),f.appendChild(this._domAttributesTab),this._domCodeTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--code"]),this._domCodeTab.setAttribute("data-tooltip",ContentEdit._("Code")),f.appendChild(this._domCodeTab),this._supportsCoding||ContentEdit.addCSSClass(this._domCodeTab,"ct-control--muted"),this._domRemoveAttribute=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--remove","ct-control--muted"]),this._domRemoveAttribute.setAttribute("data-tooltip",ContentEdit._("Remove")),f.appendChild(this._domRemoveAttribute),e=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(e),this._domApply=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent=ContentEdit._("Apply"),e.appendChild(this._domApply),g=window.localStorage.getItem("ct-properties-dialog-tab"),"attributes"===g?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--attributes"),ContentEdit.addCSSClass(this._domAttributesTab,"ct-control--active")):"code"===g&&this._supportsCoding?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--code"),ContentEdit.addCSSClass(this._domCodeTab,"ct-control--active")):(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--styles"),ContentEdit.addCSSClass(this._domStylesTab,"ct-control--active")),this._addDOMEventListeners()},d.prototype.save=function(){var a,b;return b=null,this._supportsCoding&&(b=this._domInnerHTML.value),a={changedAttributes:this.changedAttributes(),changedStyles:this.changedStyles(),innerHTML:b},this.dispatchEvent(this.createEvent("save",a))},d.prototype._addAttributeUI=function(b,c){var d,e;return e=this,d=new a(b,c),this._attributeUIs.push(d),d.addEventListener("blur",function(){var a,b,c;return e._focusedAttributeUI=null,ContentEdit.addCSSClass(e._domRemoveAttribute,"ct-control--muted"),a=e._attributeUIs.indexOf(this),c=e._attributeUIs.length,""===this.name()&&c-1>a&&(this.unmount(),e._attributeUIs.splice(a,1)),b=e._attributeUIs[c-1],b&&b.name()&&b.value()?e._addAttributeUI("",""):void 0}),d.addEventListener("focus",function(){return e._focusedAttributeUI=this,ContentEdit.removeCSSClass(e._domRemoveAttribute,"ct-control--muted")}),d.addEventListener("namechange",function(){var a,c,d,f,g,h,i;for(a=e.element,b=this.name().toLowerCase(),d=ContentTools.getRestrictedAtributes(a.tagName()),f=!0,d&&-1!==d.indexOf(b)&&(f=!1),i=e._attributeUIs,g=0,h=i.length;h>g;g++)c=i[g],""!==b&&c!==this&&c.name().toLowerCase()===b&&(f=!1);return this.valid(f),f?ContentEdit.removeCSSClass(e._domApply,"ct-control--muted"):ContentEdit.addCSSClass(e._domApply,"ct-control--muted")}),d.mount(this._domAttributes),d},d.prototype._addDOMEventListeners=function(){var a,b;return d.__super__._addDOMEventListeners.call(this),a=function(a){return function(b){var c,d,e,f,g,h;for(f=["attributes","code","styles"],g=0,h=f.length;h>g;g++)d=f[g],d!==b&&(e=d.charAt(0).toUpperCase()+d.slice(1),ContentEdit.removeCSSClass(a._domElement,"ct-properties-dialog--"+d),ContentEdit.removeCSSClass(a["_dom"+e+"Tab"],"ct-control--active"));return c=b.charAt(0).toUpperCase()+b.slice(1),ContentEdit.addCSSClass(a._domElement,"ct-properties-dialog--"+b),ContentEdit.addCSSClass(a["_dom"+c+"Tab"],"ct-control--active"),window.localStorage.setItem("ct-properties-dialog-tab",b)}}(this),this._domStylesTab.addEventListener("mousedown",function(){return function(){return a("styles")}}(this)),this._domAttributesTab.addEventListener("mousedown",function(){return function(){return a("attributes")}}(this)),this._supportsCoding&&this._domCodeTab.addEventListener("mousedown",function(){return function(){return a("code")}}(this)),this._domRemoveAttribute.addEventListener("mousedown",function(a){return function(b){var c,d;return b.preventDefault(),a._focusedAttributeUI&&(c=a._attributeUIs.indexOf(a._focusedAttributeUI),d=c===a._attributeUIs.length-1,a._focusedAttributeUI.unmount(),a._attributeUIs.splice(c,1),d)?a._addAttributeUI("",""):void 0}}(this)),b=function(a){return function(){var b;try{return b=new HTMLString.String(a._domInnerHTML.value),ContentEdit.removeCSSClass(a._domInnerHTML,"ct-properties-dialog__inner-html--invalid"),ContentEdit.removeCSSClass(a._domApply,"ct-control--muted")}catch(c){return ContentEdit.addCSSClass(a._domInnerHTML,"ct-properties-dialog__inner-html--invalid"),ContentEdit.addCSSClass(a._domApply,"ct-control--muted")}}}(this),this._domInnerHTML.addEventListener("input",b),this._domInnerHTML.addEventListener("propertychange",b),this._domApply.addEventListener("click",function(a){return function(b){var c;return b.preventDefault(),c=a._domApply.getAttribute("class"),-1===c.indexOf("ct-control--muted")?a.save():void 0}}(this))},d}(ContentTools.DialogUI),c=function(a){function b(a,c){this.style=a,b.__super__.constructor.call(this),this._applied=c}return f(b,a),b.prototype.applied=function(a){if(void 0===a)return this._applied;if(this._applied!==a)return this._applied=a,this._applied?ContentEdit.addCSSClass(this._domElement,"ct-section--applied"):ContentEdit.removeCSSClass(this._domElement,"ct-section--applied")},b.prototype.mount=function(a,c){var d;return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-section"]),this._applied&&ContentEdit.addCSSClass(this._domElement,"ct-section--applied"),d=this.constructor.createDiv(["ct-section__label"]),d.textContent=this.style.name(),this._domElement.appendChild(d),this._domElement.appendChild(this.constructor.createDiv(["ct-section__switch"])),b.__super__.mount.call(this,a,c)},b.prototype._addDOMEventListeners=function(){var a;return a=function(a){return function(b){return b.preventDefault(),a.applied(a.applied()?!1:!0)}}(this),this._domElement.addEventListener("click",a)},b}(ContentTools.AnchoredComponentUI),a=function(a){function b(a,c){b.__super__.constructor.call(this),this._initialName=a,this._initialValue=c}return f(b,a),b.prototype.name=function(){return this._domName.value.trim()},b.prototype.value=function(){return this._domValue.value.trim()},b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-attribute"]),this._domName=document.createElement("input"),this._domName.setAttribute("class","ct-attribute__name"),this._domName.setAttribute("name","name"),this._domName.setAttribute("placeholder",ContentEdit._("Name")),this._domName.setAttribute("type","text"),this._domName.setAttribute("value",this._initialName),this._domElement.appendChild(this._domName),this._domValue=document.createElement("input"),this._domValue.setAttribute("class","ct-attribute__value"),this._domValue.setAttribute("name","value"),this._domValue.setAttribute("placeholder",ContentEdit._("Value")),this._domValue.setAttribute("type","text"),this._domValue.setAttribute("value",this._initialValue),this._domElement.appendChild(this._domValue),b.__super__.mount.call(this,a,c)},b.prototype.valid=function(a){return a?ContentEdit.removeCSSClass(this._domName,"ct-attribute__name--invalid"):ContentEdit.addCSSClass(this._domName,"ct-attribute__name--invalid") -},b.prototype._addDOMEventListeners=function(){return this._domName.addEventListener("blur",function(a){return function(){var b,c,d;return b=a.name(),c=a._domElement.nextSibling,a.dispatchEvent(a.createEvent("blur")),""===b&&c?(d=c.querySelector(".ct-attribute__name"),d.focus()):void 0}}(this)),this._domName.addEventListener("focus",function(a){return function(){return a.dispatchEvent(a.createEvent("focus"))}}(this)),this._domName.addEventListener("input",function(a){return function(){return a.dispatchEvent(a.createEvent("namechange"))}}(this)),this._domName.addEventListener("keydown",function(a){return function(b){return 13===b.keyCode?a._domValue.focus():void 0}}(this)),this._domValue.addEventListener("blur",function(a){return function(){return a.dispatchEvent(a.createEvent("blur"))}}(this)),this._domValue.addEventListener("focus",function(a){return function(){return a.dispatchEvent(a.createEvent("focus"))}}(this)),this._domValue.addEventListener("keydown",function(a){return function(b){var c,d;if(13===b.keyCode||9===b.keyCode&&!b.shiftKey)return b.preventDefault(),c=a._domElement.nextSibling,c||(a._domValue.blur(),c=a._domElement.nextSibling),c?(d=c.querySelector(".ct-attribute__name"),d.focus()):void 0}}(this))},b}(ContentTools.AnchoredComponentUI),ContentTools.TableDialog=function(a){function b(a){this.table=a,this.table?b.__super__.constructor.call(this,"Update table"):b.__super__.constructor.call(this,"Insert table")}return f(b,a),b.prototype.mount=function(){var a,c,d,e,f,g,h;return b.__super__.mount.call(this),a={columns:3,foot:!1,head:!0},this.table&&(a={columns:this.table.firstSection().children[0].children.length,foot:this.table.tfoot(),head:this.table.thead()}),ContentEdit.addCSSClass(this._domElement,"ct-table-dialog"),ContentEdit.addCSSClass(this._domView,"ct-table-dialog__view"),h=["ct-section"],a.head&&h.push("ct-section--applied"),this._domHeadSection=this.constructor.createDiv(h),this._domView.appendChild(this._domHeadSection),f=this.constructor.createDiv(["ct-section__label"]),f.textContent=ContentEdit._("Table head"),this._domHeadSection.appendChild(f),this._domHeadSwitch=this.constructor.createDiv(["ct-section__switch"]),this._domHeadSection.appendChild(this._domHeadSwitch),this._domBodySection=this.constructor.createDiv(["ct-section","ct-section--applied","ct-section--contains-input"]),this._domView.appendChild(this._domBodySection),c=this.constructor.createDiv(["ct-section__label"]),c.textContent=ContentEdit._("Table body (columns)"),this._domBodySection.appendChild(c),this._domBodyInput=document.createElement("input"),this._domBodyInput.setAttribute("class","ct-section__input"),this._domBodyInput.setAttribute("maxlength","2"),this._domBodyInput.setAttribute("name","columns"),this._domBodyInput.setAttribute("type","text"),this._domBodyInput.setAttribute("value",a.columns),this._domBodySection.appendChild(this._domBodyInput),g=["ct-section"],a.foot&&g.push("ct-section--applied"),this._domFootSection=this.constructor.createDiv(g),this._domView.appendChild(this._domFootSection),e=this.constructor.createDiv(["ct-section__label"]),e.textContent=ContentEdit._("Table foot"),this._domFootSection.appendChild(e),this._domFootSwitch=this.constructor.createDiv(["ct-section__switch"]),this._domFootSection.appendChild(this._domFootSwitch),d=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(d),this._domApply=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent="Apply",d.appendChild(this._domApply),this._addDOMEventListeners()},b.prototype.save=function(){var a,b,c;return b=this._domFootSection.getAttribute("class"),c=this._domHeadSection.getAttribute("class"),a={columns:parseInt(this._domBodyInput.value),foot:b.indexOf("ct-section--applied")>-1,head:c.indexOf("ct-section--applied")>-1},this.dispatchEvent(this.createEvent("save",a))},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domBodyInput=null,this._domBodySection=null,this._domApply=null,this._domHeadSection=null,this._domHeadSwitch=null,this._domFootSection=null,this._domFootSwitch=null},b.prototype._addDOMEventListeners=function(){var a;return b.__super__._addDOMEventListeners.call(this),a=function(a){return a.preventDefault(),this.getAttribute("class").indexOf("ct-section--applied")>-1?ContentEdit.removeCSSClass(this,"ct-section--applied"):ContentEdit.addCSSClass(this,"ct-section--applied")},this._domHeadSection.addEventListener("click",a),this._domFootSection.addEventListener("click",a),this._domBodySection.addEventListener("click",function(a){return function(){return a._domBodyInput.focus()}}(this)),this._domBodyInput.addEventListener("input",function(a){return function(b){var c;return c=/^[1-9]\d{0,1}$/.test(b.target.value),c?(ContentEdit.removeCSSClass(a._domBodyInput,"ct-section__input--invalid"),ContentEdit.removeCSSClass(a._domApply,"ct-control--muted")):(ContentEdit.addCSSClass(a._domBodyInput,"ct-section__input--invalid"),ContentEdit.addCSSClass(a._domApply,"ct-control--muted"))}}(this)),this._domApply.addEventListener("click",function(a){return function(b){var c;return b.preventDefault(),c=a._domApply.getAttribute("class"),-1===c.indexOf("ct-control--muted")?a.save():void 0}}(this))},b}(ContentTools.DialogUI),ContentTools.VideoDialog=function(a){function b(){b.__super__.constructor.call(this,"Insert video")}return f(b,a),b.prototype.clearPreview=function(){return this._domPreview?(this._domPreview.parentNode.removeChild(this._domPreview),this._domPreview=void 0):void 0},b.prototype.mount=function(){var a;return b.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-video-dialog"),ContentEdit.addCSSClass(this._domView,"ct-video-dialog__preview"),a=this.constructor.createDiv(["ct-control-group"]),this._domControls.appendChild(a),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-video-dialog__input"),this._domInput.setAttribute("name","url"),this._domInput.setAttribute("placeholder",ContentEdit._("Paste YouTube or Vimeo URL")+"..."),this._domInput.setAttribute("type","text"),a.appendChild(this._domInput),this._domButton=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--insert","ct-control--muted"]),this._domButton.textContent=ContentEdit._("Insert"),a.appendChild(this._domButton),this._addDOMEventListeners()},b.prototype.preview=function(a){return this.clearPreview(),this._domPreview=document.createElement("iframe"),this._domPreview.setAttribute("frameborder","0"),this._domPreview.setAttribute("height","100%"),this._domPreview.setAttribute("src",a),this._domPreview.setAttribute("width","100%"),this._domView.appendChild(this._domPreview)},b.prototype.save=function(){var a,b;return b=this._domInput.value.trim(),a=ContentTools.getEmbedVideoURL(b),this.dispatchEvent(a?this.createEvent("save",{url:a}):this.createEvent("save",{url:b}))},b.prototype.show=function(){return b.__super__.show.call(this),this._domInput.focus()},b.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),b.__super__.unmount.call(this),this._domButton=null,this._domInput=null,this._domPreview=null},b.prototype._addDOMEventListeners=function(){return b.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("input",function(a){return function(b){var c;return b.target.value?ContentEdit.removeCSSClass(a._domButton,"ct-control--muted"):ContentEdit.addCSSClass(a._domButton,"ct-control--muted"),a._updatePreviewTimeout&&clearTimeout(a._updatePreviewTimeout),c=function(){var b,c;return c=a._domInput.value.trim(),b=ContentTools.getEmbedVideoURL(c),b?a.preview(b):a.clearPreview()},a._updatePreviewTimeout=setTimeout(c,500)}}(this)),this._domInput.addEventListener("keypress",function(a){return function(b){return 13===b.keyCode?a.save():void 0}}(this)),this._domButton.addEventListener("click",function(a){return function(b){var c;return b.preventDefault(),c=a._domButton.getAttribute("class"),-1===c.indexOf("ct-control--muted")?a.save():void 0}}(this))},b}(ContentTools.DialogUI),d=function(a){function b(){b.__super__.constructor.call(this),this.history=null,this._state="dormant",this._regions=null,this._orderedRegions=null,this._rootLastModified=null,this._regionsLastModified={},this._ignition=null,this._inspector=null,this._toolbox=null}return f(b,a),b.prototype.ctrlDown=function(){return this._ctrlDown},b.prototype.domRegions=function(){return this._domRegions},b.prototype.getState=function(){return this._state},b.prototype.ignition=function(){return this._ignition},b.prototype.inspector=function(){return this._inspector},b.prototype.isDormant=function(){return"dormant"===this._state},b.prototype.isReady=function(){return"ready"===this._state},b.prototype.isEditing=function(){return"editing"===this._state},b.prototype.orderedRegions=function(){var a;return function(){var b,c,d,e;for(d=this._orderedRegions,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this._regions[a]);return e}.call(this)},b.prototype.regions=function(){return this._regions},b.prototype.shiftDown=function(){return this._shiftDown},b.prototype.toolbox=function(){return this._toolbox},b.prototype.busy=function(a){return this._ignition.busy(a)},b.prototype.init=function(a,b){return null==b&&(b="id"),this._namingProp=b,this._domRegions=a.length>0&&a[0].nodeType===Node.ELEMENT_NODE?a:document.querySelectorAll(a),0!==this._domRegions.length?(this.mount(),this._ignition=new ContentTools.IgnitionUI,this.attach(this._ignition),this._domRegions.length&&(this._ignition.show(),this._ignition.addEventListener("edit",function(a){return function(b){return b.preventDefault(),a.start(),a._ignition.state("editing")}}(this)),this._ignition.addEventListener("confirm",function(a){return function(b){return b.preventDefault(),a._ignition.state("ready"),a.stop(!0)}}(this)),this._ignition.addEventListener("cancel",function(a){return function(b){return b.preventDefault(),a.stop(!1),a._ignition.state(a.isEditing()?"editing":"ready")}}(this))),this._toolbox=new ContentTools.ToolboxUI(ContentTools.DEFAULT_TOOLS),this.attach(this._toolbox),this._inspector=new ContentTools.InspectorUI,this.attach(this._inspector),this._state="ready",ContentEdit.Root.get().bind("detach",function(a){return function(){return a._preventEmptyRegions()}}(this)),ContentEdit.Root.get().bind("paste",function(a){return function(b,c){return a.paste(b,c.clipboardData)}}(this)),ContentEdit.Root.get().bind("next-region",function(a){return function(b){var c,d,e,f,g,h,i;if(f=a.orderedRegions(),e=f.indexOf(b),!(e>=f.length-1)){for(b=f[e+1],d=null,i=b.descendants(),g=0,h=i.length;h>g;g++)if(c=i[g],void 0!==c.content){d=c;break}return d?(d.focus(),void d.selection(new ContentSelect.Range(0,0))):ContentEdit.Root.get().trigger("next-region",b)}}}(this)),ContentEdit.Root.get().bind("previous-region",function(a){return function(b){var c,d,e,f,g,h,i,j;if(h=a.orderedRegions(),f=h.indexOf(b),!(0>=f)){for(b=h[f-1],e=null,d=b.descendants(),d.reverse(),i=0,j=d.length;j>i;i++)if(c=d[i],void 0!==c.content){e=c;break}return e?(g=e.content.length(),e.focus(),void e.selection(new ContentSelect.Range(g,g))):ContentEdit.Root.get().trigger("previous-region",b)}}}(this))):void 0},b.prototype.destroy=function(){return this.unmount()},b.prototype.highlightRegions=function(a){var b,c,d,e,f;for(e=this._domRegions,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(a?ContentEdit.addCSSClass(b,"ct--highlight"):ContentEdit.removeCSSClass(b,"ct--highlight"));return f},b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-app"]),document.body.insertBefore(this._domElement,null),this._addDOMEventListeners()},b.prototype.paste=function(a,b){var c,d,e,f,g,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;if(d=b.getData("text/plain"),q=d.split("\n"),q=q.filter(function(a){return""!==a.trim()})){if(f=HTMLString.String.encode,w=a.type(),(q.length>1||!a.content)&&"PreText"!==w){for("ListItemText"===w?(k=a.parent(),j=a.parent().parent(),i=j.children.indexOf(k)+1):(k=a,"Region"!==k.parent().type()&&(k=a.closest(function(a){return"Region"===a.parent().type()})),j=k.parent(),i=j.children.indexOf(k)+1),g=x=0,y=q.length;y>x;g=++x)o=q[g],o=f(o),"ListItemText"===w?(l=new ContentEdit.ListItem,m=new ContentEdit.ListItemText(o),l.attach(m),n=m):(l=new ContentEdit.Text("p",{},o),n=l),j.attach(l,i+g);return p=n.content.length(),n.focus(),n.selection(new ContentSelect.Range(p,p))}return d=f(d),d=new HTMLString.String(d,"PreText"===w),s=a.selection(),e=s.get()[0]+d.length(),v=a.content.substring(0,s.get()[0]),u=a.content.substring(s.get()[1]),r=a.content.substring(s.get()[0],s.get()[1]),r.length()&&(c=r.characters[0],t=c.tags(),c.isTag()&&t.shift(),t.length>=1&&(d=d.format.apply(d,[0,d.length()].concat(h.call(t))))),a.content=v.concat(d),a.content=a.content.concat(u,!1),a.updateInnerHTML(),a.taint(),s.set(e,e),a.selection(s)}},b.prototype.unmount=function(){return this.isMounted()?(this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,this._removeDOMEventListeners(),this._ignition=null,this._inspector=null,this._toolbox=null):void 0},b.prototype.revert=function(){var a;if(this.dispatchEvent(this.createEvent("revert")))return a=ContentEdit._("Your changes have not been saved, do you really want to lose them?"),ContentEdit.Root.get().lastModified()>this._rootLastModified&&!window.confirm(a)?!1:(this.revertToSnapshot(this.history.goTo(0),!1),!0)},b.prototype.revertToSnapshot=function(a,b){var c,d,e,f,g,h,i,j;null==b&&(b=!0),i=this._regions;for(e in i)f=i[e],f.domElement().innerHTML=a.regions[e];if(b){for(ContentEdit.Root.get().focused()&&ContentEdit.Root.get().focused().blur(),this._regions={},j=this._domRegions,d=g=0,h=j.length;h>g;d=++g)c=j[d],e=c.getAttribute(this._namingProp),e||(e=d),this._regions[e]=new ContentEdit.Region(c);return this.history.replaceRegions(this._regions),this.history.restoreSelection(a),this._inspector.updateTags()}},b.prototype.save=function(a){var b,c,d,e,f,g,h;if(this.dispatchEvent(this.createEvent("save",{passive:a}))){if(g=ContentEdit.Root.get(),g.lastModified()===this._rootLastModified&&a)return void this.dispatchEvent(this.createEvent("saved",{regions:{},passive:a}));d={},h=this._regions;for(e in h)f=h[e],c=f.html(),1===f.children.length&&(b=f.children[0],b.content&&!b.content.html()&&(c="")),a||(f.domElement().innerHTML=c),f.lastModified()!==this._regionsLastModified[e]&&(d[e]=c,this._regionsLastModified[e]=f.lastModified());return this.dispatchEvent(this.createEvent("saved",{regions:d,passive:a}))}},b.prototype.setRegionOrder=function(a){return this._orderedRegions=a.slice()},b.prototype.start=function(){var a,b,c,d,e,f;if(this.dispatchEvent(this.createEvent("start"))){for(this.busy(!0),this._regions={},this._orderedRegions=[],f=this._domRegions,b=d=0,e=f.length;e>d;b=++d)a=f[b],c=a.getAttribute(this._namingProp),c||(c=b),this._regions[c]=new ContentEdit.Region(a),this._orderedRegions.push(c),this._regionsLastModified[c]=this._regions[c].lastModified();return this._preventEmptyRegions(),this._rootLastModified=ContentEdit.Root.get().lastModified(),this.history=new ContentTools.History(this._regions),this.history.watch(),this._state="editing",this._toolbox.show(),this._inspector.show(),this.busy(!1)}},b.prototype.stop=function(a){var b;if(this.dispatchEvent(this.createEvent("stop",{save:a}))){if(b=ContentEdit.Root.get().focused(),b&&b.isMounted()&&void 0!==b._syncContent&&b._syncContent(),a)this.save();else if(!this.revert())return;ContentEdit.Root.get().focused()&&ContentEdit.Root.get().focused().blur(),this.history.stopWatching(),this.history=null,this._toolbox.hide(),this._inspector.hide(),this._regions={},this._state="ready"}},b.prototype._addDOMEventListeners=function(){return this._handleHighlightOn=function(a){return function(b){var c;if(17===(c=b.keyCode)||224===c)return void(a._ctrlDown=!0);if(16===b.keyCode){if(a._highlightTimeout)return;return a._shiftDown=!0,a._highlightTimeout=setTimeout(function(){return a.highlightRegions(!0)},ContentTools.HIGHLIGHT_HOLD_DURATION)}}}(this),this._handleHighlightOff=function(a){return function(b){var c;return 17===(c=b.keyCode)||224===c?void(a._ctrlDown=!1):16===b.keyCode?(a._shiftDown=!1,a._highlightTimeout&&(clearTimeout(a._highlightTimeout),a._highlightTimeout=null),a.highlightRegions(!1)):void 0}}(this),document.addEventListener("keydown",this._handleHighlightOn),document.addEventListener("keyup",this._handleHighlightOff),window.onbeforeunload=function(a){return function(){return"editing"===a._state?ContentEdit._(ContentTools.CANCEL_MESSAGE):void 0}}(this),window.addEventListener("unload",function(a){return function(){return a.destroy()}}(this))},b.prototype._preventEmptyRegions=function(){var a,b,c,d,e,f,g,h,i,j,k;i=this._regions,k=[];for(d in i){for(f=i[d],c=f.lastModified(),b=!1,j=f.children,g=0,h=j.length;h>g;g++)if(a=j[g],"Static"!==a.type()){b=!0;break}b||(e=new ContentEdit.Text("p",{},""),f.attach(e),k.push(f._modified=c))}return k},b.prototype._removeDOMEventListeners=function(){return document.removeEventListener("keydown",this._handleHighlightOn),document.removeEventListener("keyup",this._handleHighlightOff)},b}(ContentTools.ComponentUI),ContentTools.EditorApp=function(){function a(){}var b;return b=null,a.get=function(){var a;return a=ContentTools.EditorApp.getCls(),null!=b?b:b=new a},a.getCls=function(){return d},a}(),ContentTools.History=function(){function a(a){this._lastSnapshotTaken=null,this._regions={},this.replaceRegions(a),this._snapshotIndex=-1,this._snapshots=[],this._store()}return a.prototype.canRedo=function(){return this._snapshotIndex0},a.prototype.index=function(){return this._snapshotIndex},a.prototype.length=function(){return this._snapshots.length},a.prototype.snapshot=function(){return this._snapshots[this._snapshotIndex]},a.prototype.goTo=function(a){return this._snapshotIndex=Math.min(this._snapshots.length-1,Math.max(0,a)),this.snapshot()},a.prototype.redo=function(){return this.goTo(this._snapshotIndex+1)},a.prototype.replaceRegions=function(a){var b,c,d;this._regions={},d=[];for(b in a)c=a[b],d.push(this._regions[b]=c);return d},a.prototype.restoreSelection=function(a){var b,c;if(a.selected)return c=this._regions[a.selected.region],b=c.descendants()[a.selected.element],b.focus(),b.selection&&a.selected.selection?b.selection(a.selected.selection):void 0},a.prototype.stopWatching=function(){return this._watchInterval&&clearInterval(this._watchInterval),this._delayedStoreTimeout?clearTimeout(this._delayedStoreTimeout):void 0},a.prototype.undo=function(){return this.goTo(this._snapshotIndex-1)},a.prototype.watch=function(){var a;return this._lastSnapshotTaken=Date.now(),a=function(a){return function(){var b,c;if(c=ContentEdit.Root.get().lastModified(),null!==c&&c>a._lastSnapshotTaken){if(a._delayedStoreRequested===c)return;return a._delayedStoreTimeout&&clearTimeout(a._delayedStoreTimeout),b=function(){return a._lastSnapshotTaken=c,a._store()},a._delayedStoreRequested=c,a._delayedStoreTimeout=setTimeout(b,500)}}}(this),this._watchInterval=setInterval(a,50)},a.prototype._store=function(){var a,b,c,d,e,f,g;e={regions:{},selected:null},f=this._regions;for(b in f)d=f[b],e.regions[b]=d.html();if(a=ContentEdit.Root.get().focused()){if(e.selected={},d=a.closest(function(a){return"Region"===a.type()}),!d)return;g=this._regions;for(b in g)if(c=g[b],d===c){e.selected.region=b;break}e.selected.element=d.descendants().indexOf(a),a.selection&&(e.selected.selection=a.selection())}return this._snapshotIndexi;i++)if(d=n[i],d.hasTags("a"))for(o=d.tags(),j=0,l=o.length;l>j;j++)if(g=o[j],"a"===g.name())return g.attr(a);return""},b.canApply=function(a,b){var c;return"Image"===a.type()?!0:a.content&&b&&(!b.isCollapsed()||(c=a.content.characters[b.get()[0]],c&&c.hasTags("a")))?!0:!1},b.isApplied=function(a,c){return"Image"===a.type()?a.a:b.__super__.constructor.isApplied.call(this,a,c)},b.apply=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;if(f=!1,"Image"===a.type())n=a.domElement().getBoundingClientRect();else{if(b.isCollapsed()){for(g=a.content.characters,p=b.get(0)[0],j=p;p>0&&g[p-1].hasTags("a");)p-=1;for(;ji;i++)if(e=d[i],a.hasCSSClass(e)){a.removeCSSClass(e),a.a["class"]=e;break}}else{for(h=[],a.a["class"]&&(h=a.a["class"].split(" ")),j=0,n=d.length;n>j;j++)if(e=d[j],h.indexOf(e)>-1){a.addCSSClass(e);break}a.a=null}a.unmount(),a.mount()}else a.content=a.content.unformat(k,q,"a"),g.href&&(c=new HTMLString.Tag("a",g),a.content=a.content.format(k,q,c),a.content.optimize()),a.updateInnerHTML();return a.taint(),m.dispatchEvent(m.createEvent("click"))}),e.attach(m),e.attach(h),m.show(),h.show()},b}(ContentTools.Tools.Bold),ContentTools.Tools.Heading=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"heading"),b.label="Heading",b.icon="heading",b.tagName="h1",b.canApply=function(a){return void 0!==a.content&&-1!==["Text","PreText"].indexOf(a.type())},b.isApplied=function(a){return a.content?-1===["Text","PreText"].indexOf(a.type())?!1:a.tagName()===this.tagName:!1},b.apply=function(a,b,c){var d,e,f,g;return a.storeState(),"PreText"===a.type()?(d=a.content.html().replace(/ /g," "),g=new ContentEdit.Text(this.tagName,{},d),f=a.parent(),e=f.children.indexOf(a),f.detach(a),f.attach(g,e),a.blur(),g.focus(),g.selection(b)):(a.tagName(a.tagName()===this.tagName?"p":this.tagName),a.restoreState()),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.Subheading=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"subheading"),b.label="Subheading",b.icon="subheading",b.tagName="h2",b}(ContentTools.Tools.Heading),ContentTools.Tools.Paragraph=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"paragraph"),b.label="Paragraph",b.icon="paragraph",b.tagName="p",b.canApply=function(a){return void 0!==a},b.apply=function(a,c,d){var e,f,g,h;return e=ContentTools.EditorApp.get(),f=e.ctrlDown(),ContentTools.Tools.Heading.canApply(a)&&!f?b.__super__.constructor.apply.call(this,a,c,d):("Region"!==a.parent().type()&&(a=a.closest(function(a){return"Region"===a.parent().type()})),h=a.parent(),g=new ContentEdit.Text("p"),h.attach(g,h.children.indexOf(a)+1),g.focus(),d(!0))},b}(ContentTools.Tools.Heading),ContentTools.Tools.Preformatted=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"preformatted"),b.label="Preformatted",b.icon="preformatted",b.tagName="pre",b.apply=function(a,b,c){var d,e,f,g;return"PreText"===a.type()?void ContentTools.Tools.Paragraph.apply(a,b,c):(g=a.content.text(),f=new ContentEdit.PreText("pre",{},HTMLString.String.encode(g)),e=a.parent(),d=e.children.indexOf(a),e.detach(a),e.attach(f,d),a.blur(),f.focus(),f.selection(b),c(!0))},b}(ContentTools.Tools.Heading),ContentTools.Tools.AlignLeft=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"align-left"),b.label="Align left",b.icon="align-left",b.className="text-left",b.canApply=function(a){return void 0!==a.content},b.isApplied=function(a){var b;return this.canApply(a)?(("ListItemText"===(b=a.type())||"TableCellText"===b)&&(a=a.parent()),a.hasCSSClass(this.className)):!1},b.apply=function(a,b,c){var d,e,f,g,h;for(("ListItemText"===(h=a.type())||"TableCellText"===h)&&(a=a.parent()),d=[ContentTools.Tools.AlignLeft.className,ContentTools.Tools.AlignCenter.className,ContentTools.Tools.AlignRight.className],f=0,g=d.length;g>f;f++)if(e=d[f],a.hasCSSClass(e)&&(a.removeCSSClass(e),e===this.className))return c(!0);return a.addCSSClass(this.className),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.AlignCenter=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"align-center"),b.label="Align center",b.icon="align-center",b.className="text-center",b}(ContentTools.Tools.AlignLeft),ContentTools.Tools.AlignRight=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"align-right"),b.label="Align right",b.icon="align-right",b.className="text-right",b}(ContentTools.Tools.AlignLeft),ContentTools.Tools.UnorderedList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"unordered-list"),b.label="Bullet list",b.icon="unordered-list",b.listTag="ul",b.canApply=function(a){var b;return void 0!==a.content&&("Region"===(b=a.parent().type())||"ListItem"===b)},b.apply=function(a,b,c){var d,e,f,g,h;return"ListItem"===a.parent().type()?(a.storeState(),e=a.closest(function(a){return"List"===a.type()}),e.tagName(this.listTag),a.restoreState()):(g=new ContentEdit.ListItemText(a.content.copy()),f=new ContentEdit.ListItem,f.attach(g),e=new ContentEdit.List(this.listTag,{}),e.attach(f),h=a.parent(),d=h.children.indexOf(a),h.detach(a),h.attach(e,d),g.focus(),g.selection(b)),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.OrderedList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"ordered-list"),b.label="Numbers list",b.icon="ordered-list",b.listTag="ol",b}(ContentTools.Tools.UnorderedList),ContentTools.Tools.Table=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"table"),b.label="Table",b.icon="table",b.canApply=function(a){return void 0!==a},b.apply=function(a,b,c){var d,e,f,g;return a.storeState&&a.storeState(),d=ContentTools.EditorApp.get(),f=new ContentTools.ModalUI,g=a.closest(function(a){return a&&"Table"===a.type()}),e=new ContentTools.TableDialog(g),e.addEventListener("cancel",function(){return function(){return f.hide(),e.hide(),a.restoreState&&a.restoreState(),c(!1)}}(this)),e.addEventListener("save",function(b){return function(d){var h,i,j,k,l;return k=d.detail(),i=!0,g?(b._updateTable(k,g),i=a.closest(function(a){return a&&"Table"===a.type()})):(g=b._createTable(k),l=b._insertAt(a),j=l[0],h=l[1],j.parent().attach(g,h),i=!1),i?a.restoreState():g.firstSection().children[0].children[0].children[0].focus(),f.hide(),e.hide(),c(!0)}}(this)),d.attach(f),d.attach(e),f.show(),e.show()},b._adjustColumns=function(a,b){var c,d,e,f,g,h,i,j,k,l,m;for(l=a.children,m=[],j=0,k=l.length;k>j;j++)i=l[j],d=i.children[0].tagName(),f=i.children.length,g=b-f,m.push(0>g?function(){var a,b;for(b=[],h=a=g;0>=g?0>a:a>0;h=0>=g?++a:--a)c=i.children[i.children.length-1],b.push(i.detach(c));return b}():g>0?function(){var a,b;for(b=[],h=a=0;g>=0?g>a:a>g;h=g>=0?++a:--a)c=new ContentEdit.TableCell(d),i.attach(c),e=new ContentEdit.TableCellText(""),b.push(c.attach(e));return b}():void 0);return m},b._createTable=function(a){var b,c,d,e;return e=new ContentEdit.Table,a.head&&(d=this._createTableSection("thead","th",a.columns),e.attach(d)),b=this._createTableSection("tbody","td",a.columns),e.attach(b),a.foot&&(c=this._createTableSection("tfoot","td",a.columns),e.attach(c)),e},b._createTableSection=function(a,b,c){var d,e,f,g,h,i;for(h=new ContentEdit.TableSection(a),g=new ContentEdit.TableRow,h.attach(g),f=i=0;c>=0?c>i:i>c;f=c>=0?++i:--i)d=new ContentEdit.TableCell(b),g.attach(d),e=new ContentEdit.TableCellText(""),d.attach(e);return h},b._updateTable=function(a,b){var c,d,e,f,g,h,i;if(!a.head&&b.thead()&&b.detach(b.thead()),!a.foot&&b.tfoot()&&b.detach(b.tfoot()),c=b.firstSection().children[0].children.length,a.columns!==c)for(i=b.children,g=0,h=i.length;h>g;g++)f=i[g],this._adjustColumns(f,a.columns);return a.head&&!b.thead()&&(e=this._createTableSection("thead","th",a.columns),b.attach(e)),a.foot&&!b.tfoot()?(d=this._createTableSection("tfoot","td",a.columns),b.attach(d)):void 0},b}(ContentTools.Tool),ContentTools.Tools.Indent=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"indent"),b.label="Indent",b.icon="indent",b.canApply=function(a){return"ListItem"===a.parent().type()&&a.parent().parent().children.indexOf(a.parent())>0 -},b.apply=function(a,b,c){return a.parent().indent(),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.Unindent=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"unindent"),b.label="Unindent",b.icon="unindent",b.canApply=function(a){return"ListItem"===a.parent().type()},b.apply=function(a,b,c){return a.parent().unindent(),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.LineBreak=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"line-break"),b.label="Line break",b.icon="line-break",b.canApply=function(a){return a.content},b.apply=function(a,b,c){var d,e,f,g;return e=b.get()[0]+1,g=a.content.substring(0,b.get()[0]),f=a.content.substring(b.get()[1]),d=new HTMLString.String("
",a.content.preserveWhitespace()),a.content=g.concat(d,f),a.updateInnerHTML(),a.taint(),b.set(e,e),a.selection(b),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.Image=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"image"),b.label="Image",b.icon="image",b.canApply=function(){return!0},b.apply=function(a,b,c){var d,e,f;return a.storeState&&a.storeState(),d=ContentTools.EditorApp.get(),f=new ContentTools.ModalUI,e=new ContentTools.ImageDialog,e.addEventListener("cancel",function(){return function(){return f.hide(),e.hide(),a.restoreState&&a.restoreState(),c(!1)}}(this)),e.addEventListener("save",function(b){return function(d){var g,h,i,j,k,l,m,n;return g=d.detail(),k=g.imageURL,j=g.imageSize,i=g.imageAttrs,i||(i={}),i.height=j[1],i.src=k,i.width=j[0],h=new ContentEdit.Image(i),n=b._insertAt(a),m=n[0],l=n[1],m.parent().attach(h,l),h.focus(),f.hide(),e.hide(),c(!0)}}(this)),d.attach(f),d.attach(e),f.show(),e.show()},b}(ContentTools.Tool),ContentTools.Tools.Video=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"video"),b.label="Video",b.icon="video",b.canApply=function(){return!0},b.apply=function(a,b,c){var d,e,f;return a.storeState&&a.storeState(),d=ContentTools.EditorApp.get(),f=new ContentTools.ModalUI,e=new ContentTools.VideoDialog,e.addEventListener("cancel",function(){return function(){return f.hide(),e.hide(),a.restoreState&&a.restoreState(),c(!1)}}(this)),e.addEventListener("save",function(b){return function(d){var g,h,i,j,k;return i=d.detail().url,i?(j=new ContentEdit.Video("iframe",{frameborder:0,height:ContentTools.DEFAULT_VIDEO_HEIGHT,src:i,width:ContentTools.DEFAULT_VIDEO_WIDTH}),k=b._insertAt(a),h=k[0],g=k[1],h.parent().attach(j,g),j.focus()):a.restoreState&&a.restoreState(),f.hide(),e.hide(),c(""!==i)}}(this)),d.attach(f),d.attach(e),f.show(),e.show()},b}(ContentTools.Tool),ContentTools.Tools.Undo=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"undo"),b.label="Undo",b.icon="undo",b.requiresElement=!1,b.canApply=function(){var a;return a=ContentTools.EditorApp.get(),a.history&&a.history.canUndo()},b.apply=function(){var a,b;return a=ContentTools.EditorApp.get(),a.history.stopWatching(),b=a.history.undo(),a.revertToSnapshot(b),a.history.watch()},b}(ContentTools.Tool),ContentTools.Tools.Redo=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"redo"),b.label="Redo",b.icon="redo",b.requiresElement=!1,b.canApply=function(){var a;return a=ContentTools.EditorApp.get(),a.history&&a.history.canRedo()},b.apply=function(){var a,b;return a=ContentTools.EditorApp.get(),a.history.stopWatching(),b=a.history.redo(),a.revertToSnapshot(b),a.history.watch()},b}(ContentTools.Tool),ContentTools.Tools.Remove=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"remove"),b.label="Remove",b.icon="remove",b.canApply=function(){return!0},b.apply=function(a,b,c){var d,e,f,g;if(d=ContentTools.EditorApp.get(),a.blur(),a.nextContent()?a.nextContent().focus():a.previousContent()&&a.previousContent().focus(),!a.isMounted())return void c(!0);switch(a.type()){case"ListItemText":d.ctrlDown()?(e=a.closest(function(a){return"Region"===a.parent().type()}),e.parent().detach(e)):a.parent().parent().detach(a.parent());break;case"TableCellText":d.ctrlDown()?(g=a.closest(function(a){return"Table"===a.type()}),g.parent().detach(g)):(f=a.parent().parent(),f.parent().detach(f));break;default:a.parent().detach(a)}return c(!0)},b}(ContentTools.Tool)}.call(this); \ No newline at end of file +(function(){window.FSM={},FSM.Machine=function(){function a(a){this.context=a,this._stateTransitions={},this._stateTransitionsAny={},this._defaultTransition=null,this._initialState=null,this._currentState=null}return a.prototype.addTransition=function(a,b,c,d){return c||(c=b),this._stateTransitions[[a,b]]=[c,d]},a.prototype.addTransitions=function(a,b,c,d){var e,f,g,h;for(c||(c=b),h=[],f=0,g=a.length;g>f;f++)e=a[f],h.push(this.addTransition(e,b,c,d));return h},a.prototype.addTransitionAny=function(a,b,c){return b||(b=a),this._stateTransitionsAny[a]=[b,c]},a.prototype.setDefaultTransition=function(a,b){return this._defaultTransition=[a,b]},a.prototype.getTransition=function(a,b){if(this._stateTransitions[[a,b]])return this._stateTransitions[[a,b]];if(this._stateTransitionsAny[b])return this._stateTransitionsAny[b];if(this._defaultTransition)return this._defaultTransition;throw new Error("Transition is undefined: ("+a+", "+b+")")},a.prototype.getCurrentState=function(){return this._currentState},a.prototype.setInitialState=function(a){return this._initialState=a,this._currentState?void 0:this.reset()},a.prototype.reset=function(){return this._currentState=this._initialState},a.prototype.process=function(a){var b;return b=this.getTransition(a,this._currentState),b[1]&&b[1].call(this.context||(this.context=this),a),this._currentState=b[0]},a}()}).call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=[].slice,A=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};window.HTMLString={},HTMLString.String=function(){function a(a,b){null==b&&(b=!1),this._preserveWhitespace=b,a?(null===HTMLString.String._parser&&(HTMLString.String._parser=new y),this.characters=HTMLString.String._parser.parse(a,this._preserveWhitespace).characters):this.characters=[]}return a._parser=null,a.prototype.isWhitespace=function(){var a,b,c,d;for(d=this.characters,b=0,c=d.length;c>b;b++)if(a=d[b],!a.isWhitespace())return!1;return!0},a.prototype.length=function(){return this.characters.length},a.prototype.preserveWhitespace=function(){return this._preserveWhitespace},a.prototype.capitalize=function(){var a,b;return b=this.copy(),b.length()&&(a=b.characters[0]._c.toUpperCase(),b.characters[0]._c=a),b},a.prototype.charAt=function(a){return this.characters[a].copy()},a.prototype.concat=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(g=2<=arguments.length?z.call(arguments,0,i=arguments.length-1):(i=0,[]),c=arguments[i++],"undefined"!=typeof c&&"boolean"!=typeof c&&(g.push(c),c=!0),e=this.copy(),j=0,m=g.length;m>j;j++)if(f=g[j],0!==f.length){if(h=f,"string"==typeof f&&(h=new HTMLString.String(f,this._preserveWhitespace)),c&&e.length())for(b=e.charAt(e.length()-1),d=b.tags(),b.isTag()&&d.shift(),"string"!=typeof f&&(h=h.copy()),p=h.characters,k=0,n=p.length;n>k;k++)a=p[k],a.addTags.apply(a,d);for(q=h.characters,l=0,o=q.length;o>l;l++)a=q[l],e.characters.push(a)}return e},a.prototype.contains=function(a){var b,c,d,e,f,g,h;if("string"==typeof a)return this.text().indexOf(a)>-1;for(d=0;d<=this.length()-a.length();){for(c=!0,h=a.characters,e=f=0,g=h.length;g>f;e=++f)if(b=h[e],!b.eq(this.characters[e+d])){c=!1;break}if(c)return!0;d++}return!1},a.prototype.endsWith=function(a){var b,c,d,e,f,g;if("string"==typeof a)return""===a||this.text().slice(-a.length)===a;for(c=this.characters.slice().reverse(),g=a.characters.slice().reverse(),d=e=0,f=g.length;f>e;d=++e)if(b=g[d],!b.eq(c[d]))return!1;return!0},a.prototype.format=function(){var a,b,c,d,e,f,g;for(b=arguments[0],f=arguments[1],e=3<=arguments.length?z.call(arguments,2):[],0>f&&(f=this.length()+f+1),0>b&&(b=this.length()+b),d=this.copy(),c=g=b;f>=b?f>g:g>f;c=f>=b?++g:--g)a=d.characters[c],a.addTags.apply(a,e);return d},a.prototype.hasTags=function(){var a,b,c,d,e,f,g,h;for(d=2<=arguments.length?z.call(arguments,0,e=arguments.length-1):(e=0,[]),c=arguments[e++],"undefined"!=typeof c&&"boolean"!=typeof c&&(d.push(c),c=!1),b=!1,h=this.characters,f=0,g=h.length;g>f;f++)if(a=h[f],a.hasTags.apply(a,d))b=!0;else if(c)return!1;return b},a.prototype.html=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;for(e="",h=[],f=[],c=[],t=this.characters,j=0,n=t.length;n>j;j++){for(a=t[j],c=[],u=h.slice().reverse(),k=0,o=u.length;o>k;k++)if(g=u[k],c.push(g),!a.hasTags(g)){for(l=0,p=c.length;p>l;l++)b=c[l],e+=b.tail(),h.pop(),f.pop();c=[]}for(v=a._tags,m=0,q=v.length;q>m;m++)i=v[m],-1===f.indexOf(i.head())&&(i.selfClosing()||(d=i.head(),e+=d,h.push(i),f.push(d)));a._tags.length>0&&a._tags[0].selfClosing()&&(e+=a._tags[0].head()),e+=a.c()}for(w=h.reverse(),s=0,r=w.length;r>s;s++)i=w[s],e+=i.tail();return e},a.prototype.indexOf=function(a,b){var c,d,e,f,g,h;if(null==b&&(b=0),0>b&&(b=0),"string"==typeof a)return this.text().indexOf(a,b);for(;b<=this.length()-a.length();){for(d=!0,h=a.characters,e=f=0,g=h.length;g>f;e=++f)if(c=h[e],!c.eq(this.characters[e+b])){d=!1;break}if(d)return b;b++}return-1},a.prototype.insert=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;if(null==c&&(c=!0),e=this.slice(0,a),j=this.slice(a),0>a&&(a=this.length()+a),h=b,"string"==typeof b&&(h=new HTMLString.String(b,this._preserveWhitespace)),c&&a>0)for(f=this.charAt(a-1),g=f.tags(),f.isTag()&&g.shift(),"string"!=typeof b&&(h=h.copy()),q=h.characters,k=0,n=q.length;n>k;k++)d=q[k],d.addTags.apply(d,g);for(i=e,r=h.characters,l=0,o=r.length;o>l;l++)d=r[l],i.characters.push(d);for(s=j.characters,m=0,p=s.length;p>m;m++)d=s[m],i.characters.push(d);return i},a.prototype.lastIndexOf=function(a,b){var c,d,e,f,g,h,i,j,k;if(null==b&&(b=0),0>b&&(b=0),d=this.characters.slice(b).reverse(),b=0,"string"==typeof a){if(!this.contains(a))return-1;for(a=a.split("").reverse();b<=d.length-a.length;){for(e=!0,g=0,f=h=0,j=a.length;j>h;f=++h)if(c=a[f],d[f+b].isTag()&&(g+=1),c!==d[g+f+b].c()){e=!1;break}if(e)return b;b++}return-1}for(a=a.characters.slice().reverse();b<=d.length-a.length;){for(e=!0,f=i=0,k=a.length;k>i;f=++i)if(c=a[f],!c.eq(d[f+b])){e=!1;break}if(e)return b;b++}return-1},a.prototype.optimize=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J;for(i=[],g=[],e=null,D=this.characters.slice().reverse(),p=0,t=D.length;t>p;p++){for(a=D[p],a._runLengthMap={},a._runLengthMapSize=0,c=[],E=i.slice().reverse(),q=0,u=E.length;u>q;q++)if(h=E[q],c.push(h),!a.hasTags(h)){for(r=0,v=c.length;v>r;r++)b=c[r],i.pop(),g.pop();c=[]}for(F=a._tags,s=0,w=F.length;w>s;s++)o=F[s],-1===g.indexOf(o.head())&&(o.selfClosing()||(i.push(o),g.push(o.head())));for(A=0,x=i.length;x>A;A++)o=i[A],d=o.head(),e?(a._runLengthMap[d]||(a._runLengthMap[d]=[o,0]),m=0,e._runLengthMap[d]&&(m=e._runLengthMap[d][1]),a._runLengthMap[d][1]=m+1):a._runLengthMap[d]=[o,1];e=a}for(k=function(a,b){return b[1]-a[1]},G=this.characters,J=[],B=0,y=G.length;y>B;B++)if(a=G[B],f=a._tags.length,!(f>0&&a._tags[0].selfClosing()&&3>f||2>f)){l=[],H=a._runLengthMap;for(o in H)j=H[o],l.push(j);for(l.sort(k),I=a._tags.slice(),C=0,z=I.length;z>C;C++)o=I[C],o.selfClosing()||a.removeTags(o);J.push(a.addTags.apply(a,function(){var a,b,c;for(c=[],b=0,a=l.length;a>b;b++)n=l[b],c.push(n[0]);return c}()))}return J},a.prototype.slice=function(a,b){var c,d;return d=new HTMLString.String("",this._preserveWhitespace),d.characters=function(){var d,e,f,g;for(f=this.characters.slice(a,b),g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(c.copy());return g}.call(this),d},a.prototype.split=function(a,b){var c,d,e,f,g,h,i,j;for(null==a&&(a=""),null==b&&(b=0),g=0,c=0,f=[0];;){if(b>0&&c>b)break;if(e=this.indexOf(a,g),-1===e||e===this.length()-1)break;f.push(e),g=e+1}for(f.push(this.length()),h=[],d=i=0,j=f.length-2;j>=0?j>=i:i>=j;d=j>=0?++i:--i)h.push(this.slice(f[d],f[d+1]));return h},a.prototype.startsWith=function(a){var b,c,d,e,f;if("string"==typeof a)return this.text().slice(0,a.length)===a;for(f=a.characters,c=d=0,e=f.length;e>d;c=++d)if(b=f[c],!b.eq(this.characters[c]))return!1;return!0},a.prototype.substr=function(a,b){return 0>=b?new HTMLString.String("",this._preserveWhitespace):(0>a&&(a=this.length()+a),void 0===b&&(b=this.length()-a),this.slice(a,a+b))},a.prototype.substring=function(a,b){return void 0===b&&(b=this.length()),this.slice(a,b)},a.prototype.text=function(){var a,b,c,d,e;for(b="",e=this.characters,c=0,d=e.length;d>c;c++)a=e[c],a.isTag()?a.isTag("br")&&(b+="\n"):b+=(" "!==a.c(),a.c());return this.constructor.decode(b)},a.prototype.toLowerCase=function(){var a,b,c,d,e;for(b=this.copy(),e=b.characters,c=0,d=e.length;d>c;c++)a=e[c],1===a._c.length&&(a._c=a._c.toLowerCase());return b},a.prototype.toUpperCase=function(){var a,b,c,d,e;for(b=this.copy(),e=b.characters,c=0,d=e.length;d>c;c++)a=e[c],1===a._c.length&&(a._c=a._c.toUpperCase());return b},a.prototype.trim=function(){var a,b,c,d,e,f,g,h,i,j;for(i=this.characters,b=e=0,g=i.length;g>e&&(a=i[b],a.isWhitespace());b=++e);for(j=this.characters.slice().reverse(),d=f=0,h=j.length;h>f&&(a=j[d],a.isWhitespace());d=++f);return d=this.length()-d-1,c=new HTMLString.String("",this._preserveWhitespace),c.characters=function(){var c,e,f,g;for(f=this.characters.slice(b,+d+1||9e9),g=[],c=0,e=f.length;e>c;c++)a=f[c],g.push(a.copy());return g}.call(this),c},a.prototype.trimLeft=function(){var a,b,c,d,e,f,g;for(d=this.length()-1,g=this.characters,b=e=0,f=g.length;f>e&&(a=g[b],a.isWhitespace());b=++e);return c=new HTMLString.String("",this._preserveWhitespace),c.characters=function(){var c,e,f,g;for(f=this.characters.slice(b,+d+1||9e9),g=[],c=0,e=f.length;e>c;c++)a=f[c],g.push(a.copy());return g}.call(this),c},a.prototype.trimRight=function(){var a,b,c,d,e,f,g;for(b=0,g=this.characters.slice().reverse(),d=e=0,f=g.length;f>e&&(a=g[d],a.isWhitespace());d=++e);return d=this.length()-d-1,c=new HTMLString.String("",this._preserveWhitespace),c.characters=function(){var c,e,f,g;for(f=this.characters.slice(b,+d+1||9e9),g=[],c=0,e=f.length;e>c;c++)a=f[c],g.push(a.copy());return g}.call(this),c},a.prototype.unformat=function(){var a,b,c,d,e,f,g;for(b=arguments[0],f=arguments[1],e=3<=arguments.length?z.call(arguments,2):[],0>f&&(f=this.length()+f+1),0>b&&(b=this.length()+b),d=this.copy(),c=g=b;f>=b?f>g:g>f;c=f>=b?++g:--g)a=d.characters[c],a.removeTags.apply(a,e);return d},a.prototype.copy=function(){var a,b;return b=new HTMLString.String("",this._preserveWhitespace),b.characters=function(){var b,c,d,e;for(d=this.characters,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.copy());return e}.call(this),b},a.encode=function(a){var b;return b=document.createElement("textarea"),b.textContent=a,b.innerHTML},a.decode=function(a){var b;return b=document.createElement("textarea"),b.innerHTML=a,b.textContent},a}(),a="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-_$".split(""),b=a.concat("1234567890".split("")),h=b.concat([":"]),q=b.concat(["#"]),t=b.concat([":"]),n=1,p=2,s=3,r=4,o=5,w=6,u=7,x=8,v=9,j=10,g=11,i=12,c=13,m=14,k=15,l=16,e=17,f=18,d=19,y=function(){function y(){this.fsm=new FSM.Machine(this),this.fsm.setInitialState(n),this.fsm.addTransitionAny(n,null,function(a){return this._pushChar(a)}),this.fsm.addTransition("<",n,s),this.fsm.addTransition("&",n,p),this.fsm.addTransitions(q,p,null,function(a){return this.entity+=a}),this.fsm.addTransition(";",p,n,function(){return this._pushChar("&"+this.entity+";"),this.entity=""}),this.fsm.addTransitions([" ","\n"],s),this.fsm.addTransitions(a,s,r,function(){return this._back()}),this.fsm.addTransition("/",s,o),this.fsm.addTransitions([" ","\n"],r),this.fsm.addTransitions(a,r,w,function(){return this._back()}),this.fsm.addTransitions([" ","\n"],o),this.fsm.addTransitions(a,o,u,function(){return this._back()}),this.fsm.addTransitions(t,w,null,function(a){return this.tagName+=a}),this.fsm.addTransitions([" ","\n"],w,j),this.fsm.addTransition("/",w,x,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",w,n,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],x),this.fsm.addTransition(">",x,n,function(){return this._pushTag()}),this.fsm.addTransitions([" ","\n"],j),this.fsm.addTransition("/",j,x,function(){return this.selfClosing=!0}),this.fsm.addTransition(">",j,n,function(){return this._pushTag()}),this.fsm.addTransitions(a,j,g,function(){return this._back()}),this.fsm.addTransitions(t,u,null,function(a){return this.tagName+=a}),this.fsm.addTransitions([" ","\n"],u,v),this.fsm.addTransition(">",u,n,function(){return this._popTag()}),this.fsm.addTransitions([" ","\n"],v),this.fsm.addTransition(">",v,n,function(){return this._popTag()}),this.fsm.addTransitions(h,g,null,function(a){return this.attributeName+=a}),this.fsm.addTransitions([" ","\n"],g,i),this.fsm.addTransition("=",g,c),this.fsm.addTransitions([" ","\n"],i),this.fsm.addTransition("=",i,c),this.fsm.addTransitions(">",g,j,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitionAny(i,j,function(){return this._pushAttribute(),this._back()}),this.fsm.addTransitions([" ","\n"],c),this.fsm.addTransition("'",c,m),this.fsm.addTransition('"',c,k),this.fsm.addTransitions(b.concat(["&"],c,l,function(){return this._back()})),this.fsm.addTransition(" ",l,j,function(){return this._pushAttribute()}),this.fsm.addTransitions(["/",">"],l,j,function(){return this._back(),this._pushAttribute()}),this.fsm.addTransition("&",l,e),this.fsm.addTransitionAny(l,null,function(a){return this.attributeValue+=a}),this.fsm.addTransition("'",m,j,function(){return this._pushAttribute()}),this.fsm.addTransition("&",m,f),this.fsm.addTransitionAny(m,null,function(a){return this.attributeValue+=a}),this.fsm.addTransition('"',k,j,function(){return this._pushAttribute()}),this.fsm.addTransition("&",k,d),this.fsm.addTransitionAny(k,null,function(a){return this.attributeValue+=a}),this.fsm.addTransitions(q,e,null,function(a){return this.entity+=a}),this.fsm.addTransitions(q,f,function(a){return this.entity+=a}),this.fsm.addTransitions(q,d,null,function(a){return this.entity+=a}),this.fsm.addTransition(";",e,l,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",f,m,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""}),this.fsm.addTransition(";",d,k,function(){return this.attributeValue+="&"+this.entity+";",this.entity=""})}return y.prototype._back=function(){return this.head--},y.prototype._pushAttribute=function(){return this.attributes[this.attributeName]=this.attributeValue,this.attributeName="",this.attributeValue=""},y.prototype._pushChar=function(a){var b,c;return b=new HTMLString.Character(a,this.tags),this._preserveWhitespace?void this.string.characters.push(b):!this.string.length()||b.isTag()||b.isEntity()||!b.isWhitespace()||(c=this.string.characters[this.string.length()-1],!c.isWhitespace()||c.isTag()||c.isEntity())?this.string.characters.push(b):void 0},y.prototype._pushTag=function(){var a,b;return a=new HTMLString.Tag(this.tagName,this.attributes),this.tags.push(a),a.selfClosing()&&(this._pushChar(""),this.tags.pop(),!this.selfClosed&&(b=this.tagName,A.call(HTMLString.Tag.SELF_CLOSING,b)>=0)&&this.fsm.reset()),this.tagName="",this.selfClosed=!1,this.attributes={}},y.prototype._popTag=function(){for(var a,b;;)if(b=this.tags.pop(),this.string.length()&&(a=this.string.characters[this.string.length()-1],a.isTag()||a.isEntity()||!a.isWhitespace()||a.removeTags(b)),b.name()===this.tagName.toLowerCase())break;return this.tagName=""},y.prototype.parse=function(a,b){var c,d;for(this._preserveWhitespace=b,this.reset(),a=this.preprocess(a),this.fsm.parser=this;this.head> "+d)}this.head++}return this.string},y.prototype.preprocess=function(a){return a=a.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),a=a.replace(//g,""),this._preserveWhitespace||(a=a.replace(/\s+/g," ")),a},y.prototype.reset=function(){return this.fsm.reset(),this.head=0,this.string=new HTMLString.String,this.entity="",this.tags=[],this.tagName="",this.selfClosing=!1,this.attributes={},this.attributeName="",this.attributeValue=""},y}(),HTMLString.Tag=function(){function a(a,b){var c,d;this._name=a.toLowerCase(),this._selfClosing=HTMLString.Tag.SELF_CLOSING[this._name]===!0,this._head=null,this._attributes={};for(c in b)d=b[c],this._attributes[c]=d}return a.SELF_CLOSING={area:!0,base:!0,br:!0,hr:!0,img:!0,input:!0,"link meta":!0,wbr:!0},a.prototype.head=function(){var a,b,c,d;if(!this._head){a=[],d=this._attributes;for(b in d)c=d[b],a.push(c?""+b+'="'+c+'"':""+b);a.sort(),a.unshift(this._name),this._head="<"+a.join(" ")+">"}return this._head},a.prototype.name=function(){return this._name},a.prototype.selfClosing=function(){return this._selfClosing},a.prototype.tail=function(){return this._selfClosing?"":""},a.prototype.attr=function(a,b){return void 0===b?this._attributes[a]:(this._attributes[a]=b,this._head=null)},a.prototype.removeAttr=function(a){return void 0!==this._attributes[a]?delete this._attributes[a]:void 0},a.prototype.copy=function(){return new HTMLString.Tag(this._name,this._attributes)},a}(),HTMLString.Character=function(){function a(a,b){this._c=a,a.length>1&&(this._c=a.toLowerCase()),this._tags=[],this.addTags.apply(this,b)}return a.prototype.c=function(){return this._c},a.prototype.isEntity=function(){return this._c.length>1},a.prototype.isTag=function(a){return 0!==this._tags.length&&this._tags[0].selfClosing()?a&&this._tags[0].name()!==a?!1:!0:!1},a.prototype.isWhitespace=function(){var a;return" "===(a=this._c)||"\n"===a||" "===a||this.isTag("br")},a.prototype.tags=function(){var a;return function(){var b,c,d,e;for(d=this._tags,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.copy());return e}.call(this)},a.prototype.addTags=function(){var a,b,c,d,e;for(b=1<=arguments.length?z.call(arguments,0):[],e=[],c=0,d=b.length;d>c;c++)a=b[c],a.selfClosing()?this.isTag()||this._tags.unshift(a.copy()):e.push(this._tags.push(a.copy()));return e},a.prototype.eq=function(a){var b,c,d,e,f,g,h,i;if(this.c()!==a.c())return!1;if(this._tags.length!==a._tags.length)return!1;for(c={},h=this._tags,d=0,f=h.length;f>d;d++)b=h[d],c[b.head()]=!0;for(i=a._tags,e=0,g=i.length;g>e;e++)if(b=i[e],!c[b.head()])return!1;return!0},a.prototype.hasTags=function(){var a,b,c,d,e,f,g,h,i;for(d=1<=arguments.length?z.call(arguments,0):[],c={},b={},i=this._tags,e=0,g=i.length;g>e;e++)a=i[e],c[a.name()]=!0,b[a.head()]=!0;for(f=0,h=d.length;h>f;f++)if(a=d[f],"string"==typeof a){if(void 0===c[a])return!1}else if(void 0===b[a.head()])return!1;return!0},a.prototype.removeTags=function(){var a,b,c,d,e,f,g;if(e=1<=arguments.length?z.call(arguments,0):[],0===e.length)return void(this._tags=[]);for(b={},a={},f=0,g=e.length;g>f;f++)d=e[f],"string"==typeof d?b[d]=d:a[d.head()]=d;return c=[],this._tags=this._tags.filter(function(c){return a[c.head()]||b[c.name()]?void 0:c})},a.prototype.copy=function(){var a;return new HTMLString.Character(this._c,function(){var b,c,d,e;for(d=this._tags,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.copy());return e}.call(this))},a}()}.call(this),function(){var a,b,c,d,e,f=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};window.ContentSelect={},ContentSelect.Range=function(){function f(a,b){this.set(a,b)}return f.prototype.isCollapsed=function(){return this._from===this._to},f.prototype.span=function(){return this._to-this._from},f.prototype.collapse=function(){return this._to=this._from},f.prototype.eq=function(a){return this.get()[0]===a.get()[0]&&this.get()[1]===a.get()[1]},f.prototype.get=function(){return[this._from,this._to]},f.prototype.select=function(a){var b,d,e,f,g,h,i,j,k;return ContentSelect.Range.unselectAll(),b=document.createRange(),j=c(a,this._from),g=j[0],i=j[1],k=c(a,this._to),d=k[0],f=k[1],h=g.length||0,e=d.length||0,b.setStart(g,Math.min(i,h)),b.setEnd(d,Math.min(f,e)),window.getSelection().addRange(b)},f.prototype.set=function(a,b){return a=Math.max(0,a),b=Math.max(0,b),this._from=Math.min(a,b),this._to=Math.max(a,b)},f.prepareElement=function(b){var c,d,e,f,g,h;for(e=b.querySelectorAll(a.join(", ")),h=[],c=f=0,g=e.length;g>f;c=++f)d=e[c],d.parentNode.insertBefore(document.createTextNode(""),d),h.push(ca;a++)h=d[a],e.push(h);return e}();g.length>0;)switch(d=g.shift(),d.nodeType){case Node.TEXT_NODE:if(d.textContent.length>=e)return[d,e];e-=d.textContent.length;break;case Node.ELEMENT_NODE:if(i=d.nodeName.toLowerCase(),f.call(a,i)>=0){if(0===e)return[d,0];e=Math.max(0,e-1)}else d.childNodes&&Array.prototype.unshift.apply(g,function(){var a,b,c,e;for(c=d.childNodes,e=[],a=0,b=c.length;b>a;a++)h=c[a],e.push(h);return e}())}return[d,e]},e=function(b,c){var d,e,g,h,i,j;if(0===b.childNodes.length)return 0;for(g=0,d=function(){var a,c,d,f;for(d=b.childNodes,f=[],a=0,c=d.length;c>a;a++)e=d[a],f.push(e);return f}();d.length>0;){if(h=d.shift(),h===c)return i=h.nodeName.toLowerCase(),f.call(a,i)>=0?g+1:g;switch(h.nodeType){case Node.TEXT_NODE:g+=h.textContent.length;break;case Node.ELEMENT_NODE:j=h.nodeName.toLowerCase(),f.call(a,j)>=0?g+=1:h.childNodes&&Array.prototype.unshift.apply(d,function(){var a,b,c,d;for(c=h.childNodes,d=[],a=0,b=c.length;b>a;a++)e=c[a],d.push(e);return d}())}}return g},d=function(b,c){var d,e,g,h,i,j,k,l,m,n,o,p,q,r;if(e=b.childNodes,m=c.cloneRange(),m.collapse(!0),i=c.cloneRange(),i.collapse(!1),k=m.startContainer,l=m.startOffset,g=i.endContainer,h=i.endOffset,!m.comparePoint)return[k,l,g,h];if(k===b)for(k=e[e.length-1],l=k.textContent.length,j=n=0,p=e.length;p>n;j=++n)if(d=e[j],1===m.comparePoint(d,0)){0===j?(k=d,l=0):(k=e[j-1],l=d.textContent.length),r=k.nodeName.toLowerCase,f.call(a,r)>=0&&(l=1);break}if(c.collapsed)return[k,l,k,l];if(g===b)for(g=e[e.length-1],h=g.textContent.length,j=o=0,q=e.length;q>o;j=++o)d=e[j],1===i.comparePoint(d,0)&&(g=0===j?d:e[j-1],h=d.textContent.length+1);return[k,l,g,h]}}.call(this),function(){var a,b,c,d=[].slice,e=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},f={}.hasOwnProperty,g=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},h=function(a,b){return function(){return a.apply(b,arguments)}};window.ContentEdit={ALIGNMENT_CLASS_NAMES:{left:"align-left",right:"align-right"},DEFAULT_MAX_ELEMENT_WIDTH:800,DEFAULT_MIN_ELEMENT_WIDTH:80,DRAG_HOLD_DURATION:500,DROP_EDGE_SIZE:50,HELPER_CHAR_LIMIT:250,INDENT:" ",LANGUAGE:"en",PREFER_LINE_BREAKS:!1,RESIZE_CORNER_SIZE:15,_translations:{},_:function(a){var b;return b=ContentEdit.LANGUAGE,ContentEdit._translations[b]&&ContentEdit._translations[b][a]?ContentEdit._translations[b][a]:a},addTranslations:function(a,b){return ContentEdit._translations[a]=b},addCSSClass:function(a,b){var c,d,e;return a.classList?void a.classList.add(b):(d=a.getAttribute("class"),d?(e=function(){var a,b,e,f;for(e=d.split(" "),f=[],a=0,b=e.length;b>a;a++)c=e[a],f.push(c);return f}(),-1===e.indexOf(b)?a.setAttribute("class",""+d+" "+b):void 0):a.setAttribute("class",b))},attributesToString:function(a){var b,c,d,e,f,g;if(!a)return"";for(d=function(){var b;b=[];for(c in a)b.push(c);return b}(),d.sort(),b=[],f=0,g=d.length;g>f;f++)c=d[f],e=a[c],""===e?b.push(c):(e=HTMLString.String.encode(e),e=e.replace(/"/g,"""),b.push(""+c+'="'+e+'"'));return b.join(" ")},removeCSSClass:function(a,b){var c,d,e,f;return a.classList?(a.classList.remove(b),void(0===a.classList.length&&a.removeAttribute("class"))):(d=a.getAttribute("class"),d&&(f=function(){var a,b,e,f;for(e=d.split(" "),f=[],a=0,b=e.length;b>a;a++)c=e[a],f.push(c);return f}(),e=f.indexOf(b),e>-1)?(f.splice(e,1),f.length?a.setAttribute("class",f.join(" ")):a.removeAttribute("class")):void 0)}},b=function(){function a(){this._tagNames={}}return a.prototype.register=function(){var a,b,c,e,f,g;for(a=arguments[0],c=2<=arguments.length?d.call(arguments,1):[],g=[],e=0,f=c.length;f>e;e++)b=c[e],g.push(this._tagNames[b.toLowerCase()]=a);return g},a.prototype.match=function(a){return this._tagNames[a.toLowerCase()]?this._tagNames[a.toLowerCase()]:ContentEdit.Static},a}(),ContentEdit.TagNames=function(){function a(){}var c;return c=null,a.get=function(){return null!=c?c:c=new b},a}(),ContentEdit.Node=function(){function a(){this._bindings={},this._parent=null,this._modified=null}return a.prototype.lastModified=function(){return this._modified},a.prototype.parent=function(){return this._parent},a.prototype.parents=function(){var a,b;for(b=[],a=this._parent;a;)b.push(a),a=a._parent;return b},a.prototype.type=function(){return"Node"},a.prototype.html=function(a){throw null==a&&(a=""),new Error("`html` not implemented")},a.prototype.bind=function(a,b){return void 0===this._bindings[a]&&(this._bindings[a]=[]),this._bindings[a].push(b),b},a.prototype.trigger=function(){var a,b,c,e,f,g,h;if(c=arguments[0],a=2<=arguments.length?d.call(arguments,1):[],this._bindings[c]){for(g=this._bindings[c],h=[],e=0,f=g.length;f>e;e++)b=g[e],b&&h.push(b.call.apply(b,[this].concat(d.call(a))));return h}},a.prototype.unbind=function(a,b){var c,d,e,f,g,h;if(!a)return void(this._bindings={});if(!b)return void(this._bindings[a]=void 0);if(this._bindings[a]){for(g=this._bindings[a],h=[],c=e=0,f=g.length;f>e;c=++e)d=g[c],h.push(d===b?this._bindings[a].splice(c,1):void 0);return h}},a.prototype.commit=function(){return this._modified=null,ContentEdit.Root.get().trigger("commit",this)},a.prototype.taint=function(){var a,b,c,d,e,f;for(a=Date.now(),this._modified=a,f=this.parents(),d=0,e=f.length;e>d;d++)b=f[d],b._modified=a;return c=ContentEdit.Root.get(),c._modified=a,c.trigger("taint",this)},a.prototype.closest=function(a){var b;for(b=this.parent();b&&!a(b);)b=b.parent?b.parent():null;return b},a.prototype.next=function(){var a,b,c,d,e,f;if(this.children&&this.children.length>0)return this.children[0];for(f=[this].concat(this.parents()),d=0,e=f.length;e>d;d++){if(c=f[d],!c.parent())return null;if(a=c.parent().children,b=a.indexOf(c),b=0||(this.prototype[b]=c);return this},a.fromDOMElement=function(){throw new Error("`fromDOMElement` not implemented")},a}(),ContentEdit.NodeCollection=function(a){function b(){b.__super__.constructor.call(this),this.children=[]}return g(b,a),b.prototype.descendants=function(){var a,b,c;for(a=[],c=this.children.slice();c.length>0;)b=c.shift(),a.push(b),b.children&&b.children.length>0&&(c=b.children.slice().concat(c));return a},b.prototype.isMounted=function(){return!1},b.prototype.type=function(){return"NodeCollection"},b.prototype.attach=function(a,b){return a.parent()&&a.parent().detach(a),a._parent=this,void 0!==b?this.children.splice(b,0,a):this.children.push(a),a.mount&&this.isMounted()&&a.mount(),this.taint(),ContentEdit.Root.get().trigger("attach",this,a)},b.prototype.commit=function(){var a,b,c,d;for(d=this.descendants(),b=0,c=d.length;c>b;b++)a=d[b],a._modified=null;return this._modified=null,ContentEdit.Root.get().trigger("commit",this)},b.prototype.detach=function(a){var b;return b=this.children.indexOf(a),-1!==b?(a.unmount&&this.isMounted()&&a.isMounted()&&a.unmount(),this.children.splice(b,1),a._parent=null,this.taint(),ContentEdit.Root.get().trigger("detach",this,a)):void 0},b}(ContentEdit.Node),ContentEdit.Element=function(a){function b(a,c){b.__super__.constructor.call(this),this._tagName=a.toLowerCase(),this._attributes=c?c:{},this._domElement=null,this._behaviours={drag:!0,drop:!0,merge:!0,remove:!0,resize:!0,spawn:!0}}return g(b,a),b.prototype.attributes=function(){var a,b,c,d;a={},d=this._attributes;for(b in d)c=d[b],a[b]=c;return a},b.prototype.cssTypeName=function(){return"element"},b.prototype.domElement=function(){return this._domElement},b.prototype.isFocused=function(){return ContentEdit.Root.get().focused()===this},b.prototype.isMounted=function(){return null!==this._domElement},b.prototype.type=function(){return"Element"},b.prototype.typeName=function(){return"Element"},b.prototype.addCSSClass=function(a){var b;return b=!1,this.hasCSSClass(a)||(b=!0,this.attr("class")?this.attr("class",""+this.attr("class")+" "+a):this.attr("class",a)),this._addCSSClass(a),b?this.taint():void 0},b.prototype.attr=function(a,b){return a=a.toLowerCase(),void 0===b?this._attributes[a]:(this._attributes[a]=b,this.isMounted()&&"class"!==a.toLowerCase()&&this._domElement.setAttribute(a,b),this.taint())},b.prototype.blur=function(){var a;return a=ContentEdit.Root.get(),this.isFocused()?(this._removeCSSClass("ce-element--focused"),a._focused=null,a.trigger("blur",this)):void 0},b.prototype.can=function(a,b){return void 0===b?this._behaviours[a]:this._behaviours[a]=b},b.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=document.createElement("div"),a.setAttribute("class","ce-drag-helper ce-drag-helper--type-"+this.cssTypeName()),a.setAttribute("data-ce-type",ContentEdit._(this.typeName())),a},b.prototype.drag=function(a,b){var c;if(this.isMounted()&&this.can("drag"))return c=ContentEdit.Root.get(),c.startDragging(this,a,b),c.trigger("drag",this)},b.prototype.drop=function(a,b){var c;if(this.can("drop")){if(c=ContentEdit.Root.get(),a){if(a._removeCSSClass("ce-element--drop"),a._removeCSSClass("ce-element--drop-"+b[0]),a._removeCSSClass("ce-element--drop-"+b[1]),this.constructor.droppers[a.type()])return this.constructor.droppers[a.type()](this,a,b),void c.trigger("drop",this,a,b);if(a.constructor.droppers[this.type()])return a.constructor.droppers[this.type()](this,a,b),void c.trigger("drop",this,a,b)}return c.trigger("drop",this,null,null)}},b.prototype.focus=function(a){var b;return b=ContentEdit.Root.get(),this.isFocused()?void 0:(b.focused()&&b.focused().blur(),this._addCSSClass("ce-element--focused"),b._focused=this,this.isMounted()&&!a&&this.domElement().focus(),b.trigger("focus",this))},b.prototype.hasCSSClass=function(a){var b,c;return this.attr("class")&&(c=function(){var a,c,d,e;for(d=this.attr("class").split(" "),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b); +return e}.call(this),c.indexOf(a)>-1)?!0:!1},b.prototype.merge=function(a){return this.can("merge")&&this.can("remove")?this.constructor.mergers[a.type()]?this.constructor.mergers[a.type()](a,this):a.constructor.mergers[this.type()]?a.constructor.mergers[this.type()](a,this):void 0:!1},b.prototype.mount=function(){var a;return this._domElement||(this._domElement=document.createElement(this.tagName())),a=this.nextSibling(),a?this.parent().domElement().insertBefore(this._domElement,a.domElement()):this.parent().domElement().appendChild(this._domElement),this._addDOMEventListeners(),this._addCSSClass("ce-element"),this._addCSSClass("ce-element--type-"+this.cssTypeName()),this.isFocused()&&this._addCSSClass("ce-element--focused"),ContentEdit.Root.get().trigger("mount",this)},b.prototype.removeAttr=function(a){return a=a.toLowerCase(),this._attributes[a]?(delete this._attributes[a],this.isMounted()&&"class"!==a.toLowerCase()&&this._domElement.removeAttribute(a),this.taint()):void 0},b.prototype.removeCSSClass=function(a){var b,c,d;if(this.hasCSSClass(a))return d=function(){var a,c,d,e;for(d=this.attr("class").split(" "),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),c=d.indexOf(a),c>-1&&d.splice(c,1),d.length?this.attr("class",d.join(" ")):this.removeAttr("class"),this._removeCSSClass(a),this.taint()},b.prototype.tagName=function(a){return void 0===a?this._tagName:(this._tagName=a.toLowerCase(),this.isMounted()&&(this.unmount(),this.mount()),this.taint())},b.prototype.unmount=function(){return this._removeDOMEventListeners(),this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,ContentEdit.Root.get().trigger("unmount",this)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("focus",function(){return function(a){return a.preventDefault()}}(this)),this._domElement.addEventListener("dragstart",function(){return function(a){return a.preventDefault()}}(this)),this._domElement.addEventListener("keydown",function(a){return function(b){return a._onKeyDown(b)}}(this)),this._domElement.addEventListener("keyup",function(a){return function(b){return a._onKeyUp(b)}}(this)),this._domElement.addEventListener("mousedown",function(a){return function(b){return 0===b.button?a._onMouseDown(b):void 0}}(this)),this._domElement.addEventListener("mousemove",function(a){return function(b){return a._onMouseMove(b)}}(this)),this._domElement.addEventListener("mouseover",function(a){return function(b){return a._onMouseOver(b)}}(this)),this._domElement.addEventListener("mouseout",function(a){return function(b){return a._onMouseOut(b)}}(this)),this._domElement.addEventListener("mouseup",function(a){return function(b){return 0===b.button?a._onMouseUp(b):void 0}}(this)),this._domElement.addEventListener("paste",function(a){return function(b){return a._onPaste(b)}}(this)),this._domElement.addEventListener("dragover",function(){return function(a){return a.preventDefault()}}(this)),this._domElement.addEventListener("drop",function(a){return function(b){return a._onNativeDrop(b)}}(this))},b.prototype._onKeyDown=function(){},b.prototype._onKeyUp=function(){},b.prototype._onMouseDown=function(){return this.focus?this.focus(!0):void 0},b.prototype._onMouseMove=function(a){return this._onOver(a)},b.prototype._onMouseOver=function(a){return this._onOver(a)},b.prototype._onMouseOut=function(){var a,b;return this._removeCSSClass("ce-element--over"),b=ContentEdit.Root.get(),a=b.dragging(),a?(this._removeCSSClass("ce-element--drop"),this._removeCSSClass("ce-element--drop-above"),this._removeCSSClass("ce-element--drop-below"),this._removeCSSClass("ce-element--drop-center"),this._removeCSSClass("ce-element--drop-left"),this._removeCSSClass("ce-element--drop-right"),b._dropTarget=null):void 0},b.prototype._onMouseUp=function(){},b.prototype._onNativeDrop=function(a){return a.preventDefault(),a.stopPropagation(),ContentEdit.Root.get().trigger("native-drop",this,a)},b.prototype._onPaste=function(a){return a.preventDefault(),a.stopPropagation(),ContentEdit.Root.get().trigger("paste",this,a)},b.prototype._onOver=function(){var a,b;return this._addCSSClass("ce-element--over"),b=ContentEdit.Root.get(),a=b.dragging(),a&&a!==this&&!b._dropTarget&&this.can("drop")&&(this.constructor.droppers[a.type()]||a.constructor.droppers[this.type()])?(this._addCSSClass("ce-element--drop"),b._dropTarget=this):void 0},b.prototype._removeDOMEventListeners=function(){},b.prototype._addCSSClass=function(a){return this.isMounted()?ContentEdit.addCSSClass(this._domElement,a):void 0},b.prototype._attributesToString=function(){return Object.getOwnPropertyNames(this._attributes).length>0?" "+ContentEdit.attributesToString(this._attributes):""},b.prototype._removeCSSClass=function(a){return this.isMounted()?ContentEdit.removeCSSClass(this._domElement,a):void 0},b.droppers={},b.mergers={},b.placements=["above","below"],b.getDOMElementAttributes=function(a){var b,c,d,e,f;if(!a.hasAttributes())return{};for(c={},f=a.attributes,d=0,e=f.length;e>d;d++)b=f[d],c[b.name.toLowerCase()]=b.value;return c},b._dropVert=function(a,b,c){var d;return a.parent().detach(a),d=b.parent().children.indexOf(b),"below"===c[0]&&(d+=1),b.parent().attach(a,d)},b._dropBoth=function(a,b,c){var d,e,f,g,h,i,j,k;if(a.parent().detach(a),h=b.parent().children.indexOf(b),"below"===c[0]&&"center"===c[1]&&(h+=1),e=ContentEdit.ALIGNMENT_CLASS_NAMES.left,f=ContentEdit.ALIGNMENT_CLASS_NAMES.right,a.a){if(a._removeCSSClass(e),a._removeCSSClass(f),a.a["class"]){for(d=[],k=a.a["class"].split(" "),i=0,j=k.length;j>i;i++)g=k[i],g!==e&&g!==f&&d.push(g);d.length?a.a["class"]=d.join(" "):delete a.a["class"]}}else a.removeCSSClass(e),a.removeCSSClass(f);return"left"===c[1]&&(a.a?(a.a["class"]?a.a["class"]+=" "+e:a.a["class"]=e,a._addCSSClass(e)):a.addCSSClass(e)),"right"===c[1]&&(a.a?(a.a["class"]?a.a["class"]+=" "+f:a.a["class"]=f,a._addCSSClass(f)):a.addCSSClass(f)),b.parent().attach(a,h)},b}(ContentEdit.Node),ContentEdit.ElementCollection=function(a){function b(a,c){b.__super__.constructor.call(this,a,c),ContentEdit.NodeCollection.prototype.constructor.call(this)}return g(b,a),b.extend(ContentEdit.NodeCollection),b.prototype.cssTypeName=function(){return"element-collection"},b.prototype.isMounted=function(){return null!==this._domElement},b.prototype.type=function(){return"ElementCollection"},b.prototype.createDraggingDOMElement=function(){var a,c;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),c=this._domElement.textContent,c.length>ContentEdit.HELPER_CHAR_LIMIT&&(c=c.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a.innerHTML=c,a},b.prototype.detach=function(a){return ContentEdit.NodeCollection.prototype.detach.call(this,a),0===this.children.length&&this.parent()?this.parent().detach(this):void 0},b.prototype.html=function(a){var b,c;return null==a&&(a=""),c=function(){var c,d,e,f;for(e=this.children,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b.html(a+ContentEdit.INDENT));return f}.call(this),""+a+"<"+this.tagName()+this._attributesToString()+">\n"+(""+c.join("\n")+"\n")+(""+a+"")},b.prototype.mount=function(){var a,c,d,e,f,g,h,i;this._domElement=document.createElement(this._tagName),g=this._attributes;for(c in g)d=g[c],this._domElement.setAttribute(c,d);for(b.__super__.mount.call(this),h=this.children,i=[],e=0,f=h.length;f>e;e++)a=h[e],i.push(a.mount());return i},b.prototype.unmount=function(){var a,c,d,e;for(e=this.children,c=0,d=e.length;d>c;c++)a=e[c],a.unmount();return b.__super__.unmount.call(this)},b.prototype.blur=void 0,b.prototype.focus=void 0,b}(ContentEdit.Element),ContentEdit.ResizableElement=function(a){function b(a,c){b.__super__.constructor.call(this,a,c),this._domSizeInfoElement=null,this._aspectRatio=1}return g(b,a),b.prototype.aspectRatio=function(){return this._aspectRatio},b.prototype.maxSize=function(){var a;return a=parseInt(this.attr("data-ce-max-width")||0),a||(a=ContentEdit.DEFAULT_MAX_ELEMENT_WIDTH),a=Math.max(a,this.size()[0]),[a,a*this.aspectRatio()]},b.prototype.minSize=function(){var a;return a=parseInt(this.attr("data-ce-min-width")||0),a||(a=ContentEdit.DEFAULT_MIN_ELEMENT_WIDTH),a=Math.min(a,this.size()[0]),[a,a*this.aspectRatio()]},b.prototype.type=function(){return"ResizableElement"},b.prototype.mount=function(){return b.__super__.mount.call(this),this._domElement.setAttribute("data-ce-size",this._getSizeInfo())},b.prototype.resize=function(a,b,c){return this.isMounted()&&this.can("resize")?ContentEdit.Root.get().startResizing(this,a,b,c,!0):void 0},b.prototype.size=function(a){var b,c,d,e;return a?(a[0]=parseInt(a[0]),a[1]=parseInt(a[1]),d=this.minSize(),a[0]=Math.max(a[0],d[0]),a[1]=Math.max(a[1],d[1]),c=this.maxSize(),a[0]=Math.min(a[0],c[0]),a[1]=Math.min(a[1],c[1]),this.attr("width",parseInt(a[0])),this.attr("height",parseInt(a[1])),this.isMounted()?(this._domElement.style.width=""+a[0]+"px",this._domElement.style.height=""+a[1]+"px",this._domElement.setAttribute("data-ce-size",this._getSizeInfo())):void 0):(e=parseInt(this.attr("width")||1),b=parseInt(this.attr("height")||1),[e,b])},b.prototype._onMouseDown=function(a){var c;return b.__super__._onMouseDown.call(this,a),c=this._getResizeCorner(a.clientX,a.clientY),c?this.resize(c,a.clientX,a.clientY):(clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(b){return function(){return b.drag(a.pageX,a.pageY)}}(this),150))},b.prototype._onMouseMove=function(a){var c;return b.__super__._onMouseMove.call(this),this.can("resize")?(this._removeCSSClass("ce-element--resize-top-left"),this._removeCSSClass("ce-element--resize-top-right"),this._removeCSSClass("ce-element--resize-bottom-left"),this._removeCSSClass("ce-element--resize-bottom-right"),c=this._getResizeCorner(a.clientX,a.clientY),c?this._addCSSClass("ce-element--resize-"+c[0]+"-"+c[1]):void 0):void 0},b.prototype._onMouseOut=function(){return b.__super__._onMouseOut.call(this),this._removeCSSClass("ce-element--resize-top-left"),this._removeCSSClass("ce-element--resize-top-right"),this._removeCSSClass("ce-element--resize-bottom-left"),this._removeCSSClass("ce-element--resize-bottom-right")},b.prototype._onMouseUp=function(){return b.__super__._onMouseUp.call(this),this._dragTimeout?clearTimeout(this._dragTimeout):void 0},b.prototype._getResizeCorner=function(a,b){var c,d,e,f,g;return e=this._domElement.getBoundingClientRect(),g=[a-e.left,b-e.top],a=g[0],b=g[1],f=this.size(),d=ContentEdit.RESIZE_CORNER_SIZE,d=Math.min(d,Math.max(parseInt(f[0]/4),1)),d=Math.min(d,Math.max(parseInt(f[1]/4),1)),c=null,d>a?d>b?c=["top","left"]:b>e.height-d&&(c=["bottom","left"]):a>e.width-d&&(d>b?c=["top","right"]:b>e.height-d&&(c=["bottom","right"])),c},b.prototype._getSizeInfo=function(){var a;return a=this.size(),"w "+a[0]+" × h "+a[1]},b}(ContentEdit.Element),ContentEdit.Region=function(a){function b(a){var c,d,e,f,g,h,i,j;for(b.__super__.constructor.call(this),this._domElement=a,h=ContentEdit.TagNames.get(),e=function(){var a,b,d,e;for(d=this._domElement.childNodes,e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(c);return e}.call(this),i=0,j=e.length;j>i;i++)d=e[i],1===d.nodeType&&(f=h.match(d.getAttribute("data-ce-tag")?d.getAttribute("data-ce-tag"):d.tagName),g=f.fromDOMElement(d),this._domElement.removeChild(d),g&&this.attach(g),ContentEdit.Root.get().trigger("ready",this))}return g(b,a),b.prototype.domElement=function(){return this._domElement},b.prototype.isMounted=function(){return!0},b.prototype.type=function(){return"Region"},b.prototype.html=function(a){var b;return null==a&&(a=""),function(){var c,d,e,f;for(e=this.children,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b.html(a));return f}.call(this).join("\n").trim()},b}(ContentEdit.NodeCollection),a=function(a){function b(){this._onStopResizing=h(this._onStopResizing,this),this._onResize=h(this._onResize,this),this._onStopDragging=h(this._onStopDragging,this),this._onDrag=h(this._onDrag,this),b.__super__.constructor.call(this),this._focused=null,this._dragging=null,this._dropTarget=null,this._draggingDOMElement=null,this._resizing=null,this._resizingInit=null}return g(b,a),b.prototype.dragging=function(){return this._dragging},b.prototype.dropTarget=function(){return this._dropTarget},b.prototype.focused=function(){return this._focused},b.prototype.resizing=function(){return this._resizing},b.prototype.type=function(){return"Root"},b.prototype.cancelDragging=function(){return this._dragging?(document.body.removeChild(this._draggingDOMElement),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._dragging._removeCSSClass("ce-element--dragging"),this._dragging=null,this._dropTarget=null,ContentEdit.removeCSSClass(document.body,"ce--dragging")):void 0},b.prototype.startDragging=function(a,b,c){return this._dragging?void 0:(this._dragging=a,this._dragging._addCSSClass("ce-element--dragging"),this._draggingDOMElement=this._dragging.createDraggingDOMElement(),document.body.appendChild(this._draggingDOMElement),this._draggingDOMElement.style.left=""+b+"px",this._draggingDOMElement.style.top=""+c+"px",document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging"))},b.prototype._getDropPlacement=function(a,b){var c,d,e,f;return this._dropTarget?(d=this._dropTarget.domElement().getBoundingClientRect(),f=[a-d.left,b-d.top],a=f[0],b=f[1],c="center",ad.width-ContentEdit.DROP_EDGE_SIZE&&(c="right"),e="above",b>d.height/2&&(e="below"),[e,c]):null},b.prototype._onDrag=function(a){var b,c,d;return ContentSelect.Range.unselectAll(),this._draggingDOMElement.style.left=""+a.pageX+"px",this._draggingDOMElement.style.top=""+a.pageY+"px",this._dropTarget&&(b=this._getDropPlacement(a.clientX,a.clientY),this._dropTarget._removeCSSClass("ce-element--drop-above"),this._dropTarget._removeCSSClass("ce-element--drop-below"),this._dropTarget._removeCSSClass("ce-element--drop-center"),this._dropTarget._removeCSSClass("ce-element--drop-left"),this._dropTarget._removeCSSClass("ce-element--drop-right"),c=b[0],e.call(this._dragging.constructor.placements,c)>=0&&this._dropTarget._addCSSClass("ce-element--drop-"+b[0]),d=b[1],e.call(this._dragging.constructor.placements,d)>=0)?this._dropTarget._addCSSClass("ce-element--drop-"+b[1]):void 0},b.prototype._onStopDragging=function(a){var b;return b=this._getDropPlacement(a.clientX,a.clientY),this._dragging.drop(this._dropTarget,b),this.cancelDragging()},b.prototype.startResizing=function(a,b,c,d,e){var f,g;if(!this._resizing)return this._resizing=a,this._resizingInit={corner:b,fixed:e,origin:[c,d],size:a.size()},this._resizing._addCSSClass("ce-element--resizing"),g=this._resizing.parent().domElement(),f=document.createElement("div"),f.setAttribute("class","ce-measure"),g.appendChild(f),this._resizingParentWidth=f.getBoundingClientRect().width,g.removeChild(f),document.addEventListener("mousemove",this._onResize),document.addEventListener("mouseup",this._onStopResizing),ContentEdit.addCSSClass(document.body,"ce--resizing")},b.prototype._onResize=function(a){var b,c,d,e;return ContentSelect.Range.unselectAll(),d=this._resizingInit.origin[0]-a.clientX,"right"===this._resizingInit.corner[1]&&(d=-d),c=this._resizingInit.size[0]+d,c=Math.min(c,this._resizingParentWidth),this._resizingInit.fixed?b=c*this._resizing.aspectRatio():(e=this._resizingInit.origin[1]-a.clientY,"bottom"===this._resizingInit.corner[0]&&(e=-e),b=this._resizingInit.size[1]+e),this._resizing.size([c,b])},b.prototype._onStopResizing=function(){return document.removeEventListener("mousemove",this._onResize),document.removeEventListener("mouseup",this._onStopResizing),this._resizing._removeCSSClass("ce-element--resizing"),this._resizing=null,this._resizingInit=null,this._resizingParentWidth=null,ContentEdit.removeCSSClass(document.body,"ce--resizing")},b}(ContentEdit.Node),ContentEdit.Root=function(){function b(){}var c;return c=null,b.get=function(){return null!=c?c:c=new a},b}(),ContentEdit.Static=function(a){function b(a,c,d){b.__super__.constructor.call(this,a,c),this._content=d}return g(b,a),b.prototype.cssTypeName=function(){return"static"},b.prototype.type=function(){return"Static"},b.prototype.typeName=function(){return"Static"},b.prototype.createDraggingDOMElement=function(){var a,c;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),c=this._domElement.textContent,c.length>ContentEdit.HELPER_CHAR_LIMIT&&(c=c.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a.innerHTML=c,a},b.prototype.html=function(a){return null==a&&(a=""),HTMLString.Tag.SELF_CLOSING[this._tagName]?""+a+"<"+this._tagName+this._attributesToString()+">":""+a+"<"+this._tagName+this._attributesToString()+">"+this._content+(""+a+"")},b.prototype.mount=function(){var a,c,d;this._domElement=document.createElement(this._tagName),d=this._attributes;for(a in d)c=d[a],this._domElement.setAttribute(a,c);return this._domElement.innerHTML=this._content,b.__super__.mount.call(this)},b.prototype.blur=void 0,b.prototype.focus=void 0,b.prototype._onMouseDown=function(a){return b.__super__._onMouseDown.call(this,a),void 0!==this.attr("data-ce-moveable")?(clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(b){return function(){return b.drag(a.pageX,a.pageY)}}(this),150)):void 0},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.prototype._onMouseUp=function(a){return b.__super__._onMouseUp.call(this,a),this._dragTimeout?clearTimeout(this._dragTimeout):void 0},b.droppers={Static:ContentEdit.Element._dropVert},b.fromDOMElement=function(a){return new this(a.tagName,this.getDOMElementAttributes(a),a.innerHTML)},b}(ContentEdit.Element),ContentEdit.TagNames.get().register(ContentEdit.Static,"static"),ContentEdit.Text=function(a){function b(a,c,d){b.__super__.constructor.call(this,a,c),this.content=d instanceof HTMLString.String?d:new HTMLString.String(d).trim()}return g(b,a),b.prototype.cssTypeName=function(){return"text"},b.prototype.type=function(){return"Text"},b.prototype.typeName=function(){return"Text"},b.prototype.blur=function(){var a;if(this.isMounted()&&this._syncContent(),this.content.isWhitespace()&&this.can("remove"))this.parent()&&this.parent().detach(this);else if(this.isMounted()){try{this._domElement.blur()}catch(c){a=c}this._domElement.removeAttribute("contenteditable")}return b.__super__.blur.call(this)},b.prototype.createDraggingDOMElement=function(){var a,c;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),c=HTMLString.String.encode(this._domElement.textContent),c.length>ContentEdit.HELPER_CHAR_LIMIT&&(c=c.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a.innerHTML=c,a},b.prototype.drag=function(a,c){return this.storeState(),this._domElement.removeAttribute("contenteditable"),b.__super__.drag.call(this,a,c)},b.prototype.drop=function(a,c){return b.__super__.drop.call(this,a,c),this.restoreState()},b.prototype.focus=function(a){return this.isMounted()&&this._domElement.setAttribute("contenteditable",""),b.__super__.focus.call(this,a)},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCached\n"+(""+a+ContentEdit.INDENT+this._cached+"\n")+(""+a+"")},b.prototype.mount=function(){var a,c,d;this._domElement=document.createElement(this._tagName),d=this._attributes;for(a in d)c=d[a],this._domElement.setAttribute(a,c);return this.updateInnerHTML(),b.__super__.mount.call(this)},b.prototype.restoreState=function(){return this._savedSelection?this.isMounted()&&this.isFocused()?(this._domElement.setAttribute("contenteditable",""),this._addCSSClass("ce-element--focused"),document.activeElement!==this.domElement()&&this.domElement().focus(),this._savedSelection.select(this._domElement),this._savedSelection=void 0):void(this._savedSelection=void 0):void 0},b.prototype.selection=function(a){return void 0===a?this.isMounted()?ContentSelect.Range.query(this._domElement):new ContentSelect.Range(0,0):a.select(this._domElement)},b.prototype.storeState=function(){return this.isMounted()&&this.isFocused()?this._savedSelection=ContentSelect.Range.query(this._domElement):void 0},b.prototype.updateInnerHTML=function(){return this._domElement.innerHTML=this.content.html(),ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},b.prototype._onKeyDown=function(a){switch(a.keyCode){case 40:return this._keyDown(a);case 37:return this._keyLeft(a);case 39:return this._keyRight(a);case 38:return this._keyUp(a);case 9:return this._keyTab(a);case 8:return this._keyBack(a);case 46:return this._keyDelete(a);case 13:return this._keyReturn(a)}},b.prototype._onKeyUp=function(a){return b.__super__._onKeyUp.call(this,a),this._syncContent()},b.prototype._onMouseDown=function(a){return b.__super__._onMouseDown.call(this,a),clearTimeout(this._dragTimeout),this._dragTimeout=setTimeout(function(b){return function(){return b.drag(a.pageX,a.pageY)}}(this),ContentEdit.DRAG_HOLD_DURATION),0===this.content.length()&&ContentEdit.Root.get().focused()===this?(a.preventDefault(),document.activeElement!==this._domElement&&this._domElement.focus(),new ContentSelect.Range(0,0).select(this._domElement)):void 0},b.prototype._onMouseMove=function(a){return this._dragTimeout&&clearTimeout(this._dragTimeout),b.__super__._onMouseMove.call(this,a)},b.prototype._onMouseOut=function(a){return this._dragTimeout&&clearTimeout(this._dragTimeout),b.__super__._onMouseOut.call(this,a)},b.prototype._onMouseUp=function(a){return this._dragTimeout&&clearTimeout(this._dragTimeout),b.__super__._onMouseUp.call(this,a)},b.prototype._keyBack=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),0===c.get()[0]&&c.isCollapsed()?(a.preventDefault(),b=this.previousContent(),this._syncContent(),b?b.merge(this):void 0):void 0},b.prototype._keyDelete=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),this._atEnd(c)&&c.isCollapsed()?(a.preventDefault(),b=this.nextContent(),b?this.merge(b):void 0):void 0},b.prototype._keyDown=function(a){return this._keyRight(a)},b.prototype._keyLeft=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),0===c.get()[0]&&c.isCollapsed()?(a.preventDefault(),b=this.previousContent(),b?(b.focus(),c=new ContentSelect.Range(b.content.length(),b.content.length()),c.select(b.domElement())):ContentEdit.Root.get().trigger("previous-region",this.closest(function(a){return"Region"===a.type()}))):void 0},b.prototype._keyReturn=function(a){var b,c,d,e,f,g;if(a.preventDefault(),!this.content.isWhitespace()){if(ContentSelect.Range.query(this._domElement),e=ContentSelect.Range.query(this._domElement),g=this.content.substring(0,e.get()[0]),f=this.content.substring(e.get()[1]),a.shiftKey^ContentEdit.PREFER_LINE_BREAKS)return c=e.get()[0],d="
",this.content.length()===c&&(this.content.characters[c-1].isTag("br")||(d="

")),this.content=this.content.insert(c,new HTMLString.String(d,!0),!0),this.updateInnerHTML(),c+=1,e=new ContentSelect.Range(c,c),void e.select(this.domElement());if(this.can("spawn"))return this.content=g.trim(),this.updateInnerHTML(),b=new this.constructor("p",{},f.trim()),this.parent().attach(b,this.parent().children.indexOf(this)+1),g.length()?(b.focus(),e=new ContentSelect.Range(0,0),e.select(b.domElement())):(e=new ContentSelect.Range(0,g.length()),e.select(this._domElement)),this.taint()}},b.prototype._keyRight=function(a){var b,c;return c=ContentSelect.Range.query(this._domElement),this._atEnd(c)&&c.isCollapsed()?(a.preventDefault(),b=this.nextContent(),b?(b.focus(),c=new ContentSelect.Range(0,0),c.select(b.domElement())):ContentEdit.Root.get().trigger("next-region",this.closest(function(a){return"Region"===a.type()}))):void 0},b.prototype._keyTab=function(a){return a.preventDefault()},b.prototype._keyUp=function(a){return this._keyLeft(a)},b.prototype._atEnd=function(a){var b;return b=a.get()[0]===this.content.length(),a.get()[0]===this.content.length()-1&&this.content.characters[this.content.characters.length-1].isTag("br")&&(b=!0),b},b.prototype._flagIfEmpty=function(){return 0===this.content.length()?this._addCSSClass("ce-element--empty"):this._removeCSSClass("ce-element--empty")},b.prototype._syncContent=function(){var a,b;return b=this.content.html(),this.content=new HTMLString.String(this._domElement.innerHTML,this.content.preserveWhitespace()),a=this.content.html(),b!==a&&this.taint(),this._flagIfEmpty()},b.droppers={Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert},b.mergers={Text:function(a,b){var c;return c=b.content.length(),a.content.length()&&(b.content=b.content.concat(a.content)),b.isMounted()&&b.updateInnerHTML(),b.focus(),new ContentSelect.Range(c,c).select(b._domElement),a.parent()&&a.parent().detach(a),b.taint()}},b.fromDOMElement=function(a){return new this(a.tagName,this.getDOMElementAttributes(a),a.innerHTML.replace(/^\s+|\s+$/g,""))},b}(ContentEdit.Element),ContentEdit.TagNames.get().register(ContentEdit.Text,"address","blockquote","h1","h2","h3","h4","h5","h6","p"),ContentEdit.PreText=function(a){function b(a,b,c){this.content=c instanceof HTMLString.String?c:new HTMLString.String(c,!0),ContentEdit.Element.call(this,a,b)}return g(b,a),b.prototype.cssTypeName=function(){return"pre-text"},b.prototype.type=function(){return"PreText"},b.prototype.typeName=function(){return"Preformatted"},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCached"+(""+this._cached+"")},b.prototype.updateInnerHTML=function(){var a;return a=this.content.html(),a+="​",this._domElement.innerHTML=a,ContentSelect.Range.prepareElement(this._domElement),this._flagIfEmpty()},b.prototype._onKeyUp=function(){var a,b,c;return c=this.content.html(),a=this._domElement.innerHTML,this.content=new HTMLString.String(a,this.content.preserveWhitespace()),b=this.content.html(),c!==b&&this.taint(),this._flagIfEmpty()},b.prototype._keyReturn=function(a){var b,c,d,e;return a.preventDefault(),c=ContentSelect.Range.query(this._domElement),b=c.get()[0]+1,0===c.get()[0]&&c.isCollapsed()?this.content=new HTMLString.String("\n",!0).concat(this.content):this._atEnd(c)&&c.isCollapsed()?this.content=this.content.concat(new HTMLString.String("\n",!0)):0===c.get()[0]&&c.get()[1]===this.content.length()?(this.content=new HTMLString.String("\n",!0),b=0):(e=this.content.substring(0,c.get()[0]),d=this.content.substring(c.get()[1]),this.content=e.concat(new HTMLString.String("\n",!0),d)),this.updateInnerHTML(),c.set(b,b),c.select(this._domElement),this.taint()},b.droppers={PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert},b.mergers={},b.fromDOMElement=function(a){return new this(a.tagName,this.getDOMElementAttributes(a),a.innerHTML)},b}(ContentEdit.Text),ContentEdit.TagNames.get().register(ContentEdit.PreText,"pre"),ContentEdit.Image=function(a){function b(a,c){var d;b.__super__.constructor.call(this,"img",a),this.a=c?c:null,d=this.size(),this._aspectRatio=d[1]/d[0]}return g(b,a),b.prototype.cssTypeName=function(){return"image"},b.prototype.type=function(){return"Image"},b.prototype.typeName=function(){return"Image"},b.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),a.style.backgroundImage="url("+this._attributes.src+")",a},b.prototype.html=function(a){var b,c;return null==a&&(a=""),c=""+a+"",this.a?(b=ContentEdit.attributesToString(this.a),b=""+b+' data-ce-tag="img"',""+a+"\n"+(""+ContentEdit.INDENT+c+"\n")+(""+a+"")):c},b.prototype.mount=function(){var a,c;return this._domElement=document.createElement("div"),a="",this.a&&this.a["class"]&&(a+=" "+this.a["class"]),this._attributes["class"]&&(a+=" "+this._attributes["class"]),this._domElement.setAttribute("class",a),c=this._attributes.style?this._attributes.style:"",c+="background-image:url("+this._attributes.src+");",this._attributes.width&&(c+="width:"+this._attributes.width+"px;"),this._attributes.height&&(c+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",c),b.__super__.mount.call(this)},b.droppers={Image:ContentEdit.Element._dropBoth,PreText:ContentEdit.Element._dropBoth,Static:ContentEdit.Element._dropBoth,Text:ContentEdit.Element._dropBoth},b.placements=["above","below","left","right","center"],b.fromDOMElement=function(a){var b,c,d,e,f,g,h;if(b=null,"a"===a.tagName.toLowerCase()){for(b=this.getDOMElementAttributes(a),f=function(){var b,c,e,f;for(e=a.childNodes,f=[],b=0,c=e.length;c>b;b++)d=e[b],f.push(d);return f}(),g=0,h=f.length;h>g;g++)if(e=f[g],1===e.nodeType&&"img"===e.tagName.toLowerCase()){a=e;break}"a"===a.tagName.toLowerCase()&&(a=document.createElement("img"))}return c=this.getDOMElementAttributes(a),void 0===c.width&&(c.width=void 0===c.height?a.naturalWidth:a.clientWidth),void 0===c.height&&(c.height=void 0===c.width?a.naturalHeight:a.clientHeight),new this(c,b)},b}(ContentEdit.ResizableElement),ContentEdit.TagNames.get().register(ContentEdit.Image,"img"),ContentEdit.Video=function(a){function b(a,c,d){var e;null==d&&(d=[]),b.__super__.constructor.call(this,a,c),this.sources=d,e=this.size(),this._aspectRatio=e[1]/e[0]}return g(b,a),b.prototype.cssTypeName=function(){return"video"},b.prototype.type=function(){return"Video"},b.prototype.typeName=function(){return"Video"},b.prototype._title=function(){var a;return a="",this.attr("src")?a=this.attr("src"):this.sources.length&&(a=this.sources[0].src),a||(a="No video source set"),a.length>ContentEdit.HELPER_CHAR_LIMIT&&(a=text.substr(0,ContentEdit.HELPER_CHAR_LIMIT)),a},b.prototype.createDraggingDOMElement=function(){var a;if(this.isMounted())return a=b.__super__.createDraggingDOMElement.call(this),a.innerHTML=this._title(),a},b.prototype.html=function(a){var b,c,d,e,f,g;if(null==a&&(a=""),"video"===this.tagName()){for(d=[],g=this.sources,e=0,f=g.length;f>e;e++)c=g[e],b=ContentEdit.attributesToString(c),d.push(""+a+ContentEdit.INDENT+"");return""+a+"\n"+d.join("\n")+("\n"+a+"")}return""+a+"<"+this._tagName+this._attributesToString()+">"+("")},b.prototype.mount=function(){var a;return this._domElement=document.createElement("div"),this.a&&this.a["class"]?this._domElement.setAttribute("class",this.a["class"]):this._attributes["class"]&&this._domElement.setAttribute("class",this._attributes["class"]),a=this._attributes.style?this._attributes.style:"",this._attributes.width&&(a+="width:"+this._attributes.width+"px;"),this._attributes.height&&(a+="height:"+this._attributes.height+"px;"),this._domElement.setAttribute("style",a),this._domElement.setAttribute("data-ce-title",this._title()),b.__super__.mount.call(this)},b.droppers={Image:ContentEdit.Element._dropBoth,PreText:ContentEdit.Element._dropBoth,Static:ContentEdit.Element._dropBoth,Text:ContentEdit.Element._dropBoth,Video:ContentEdit.Element._dropBoth},b.placements=["above","below","left","right","center"],b.fromDOMElement=function(a){var b,c,d,e,f,g;for(d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),e=[],f=0,g=d.length;g>f;f++)c=d[f],1===c.nodeType&&"source"===c.tagName.toLowerCase()&&e.push(this.getDOMElementAttributes(c));return new this(a.tagName,this.getDOMElementAttributes(a),e)},b}(ContentEdit.ResizableElement),ContentEdit.TagNames.get().register(ContentEdit.Video,"iframe","video"),ContentEdit.List=function(a){function b(a,c){b.__super__.constructor.call(this,a,c) +}return g(b,a),b.prototype.cssTypeName=function(){return"list"},b.prototype.type=function(){return"List"},b.prototype.typeName=function(){return"List"},b.prototype._onMouseOver=function(a){return"ListItem"!==this.parent().type()?(b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")):void 0},b.droppers={Image:ContentEdit.Element._dropBoth,List:ContentEdit.Element._dropVert,PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert,Video:ContentEdit.Element._dropBoth},b.fromDOMElement=function(a){var b,c,d,e,f,g;for(e=new this(a.tagName,this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),f=0,g=d.length;g>f;f++)c=d[f],1===c.nodeType&&"li"===c.tagName.toLowerCase()&&e.attach(ContentEdit.ListItem.fromDOMElement(c));return 0===e.children.length?null:e},b}(ContentEdit.ElementCollection),ContentEdit.TagNames.get().register(ContentEdit.List,"ol","ul"),ContentEdit.ListItem=function(a){function b(a){b.__super__.constructor.call(this,"li",a),this._behaviours.indent=!0}return g(b,a),b.prototype.cssTypeName=function(){return"list-item"},b.prototype.list=function(){return 2===this.children.length?this.children[1]:null},b.prototype.listItemText=function(){return this.children.length>0?this.children[0]:null},b.prototype.type=function(){return"ListItem"},b.prototype.html=function(a){var b;return null==a&&(a=""),b=[""+a+""],this.listItemText()&&b.push(this.listItemText().html(a+ContentEdit.INDENT)),this.list()&&b.push(this.list().html(a+ContentEdit.INDENT)),b.push(""+a+""),b.join("\n")},b.prototype.indent=function(){var a;if(this.can("indent")&&0!==this.parent().children.indexOf(this))return a=this.previousSibling(),a.list()||a.attach(new ContentEdit.List(a.parent().tagName())),this.listItemText().storeState(),this.parent().detach(this),a.list().attach(this),this.listItemText().restoreState()},b.prototype.remove=function(){var a,b,c,d,e,f;if(this.parent()){if(c=this.parent().children.indexOf(this),this.list())for(f=this.list().children.slice(),b=d=0,e=f.length;e>d;b=++d)a=f[b],a.parent().detach(a),this.parent().attach(a,b+c);return this.parent().detach(this)}},b.prototype.unindent=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(this.can("indent")){if(f=this.parent(),b=f.parent(),j=f.children.slice(f.children.indexOf(this)+1,f.children.length),"ListItem"===b.type()){for(this.listItemText().storeState(),f.detach(this),b.parent().attach(this,b.parent().children.indexOf(b)+1),j.length&&!this.list()&&this.attach(new ContentEdit.List(f.tagName())),l=0,p=j.length;p>l;l++)i=j[l],i.parent().detach(i),this.list().attach(i);return this.listItemText().restoreState()}if(k=new ContentEdit.Text("p",this.attr("class")?{"class":this.attr("class")}:{},this.listItemText().content),h=null,this.listItemText().isFocused()&&(h=ContentSelect.Range.query(this.listItemText().domElement())),g=b.children.indexOf(f),d=f.children.indexOf(this),0===d){if(e=null,1===f.children.length?(this.list()&&(e=new ContentEdit.List(f.tagName())),b.detach(f)):f.detach(this),b.attach(k,g),e&&b.attach(e,g+1),this.list())for(t=this.list().children.slice(),c=m=0,q=t.length;q>m;c=++m)a=t[c],a.parent().detach(a),e?e.attach(a):f.attach(a,c)}else if(d===f.children.length-1)f.detach(this),b.attach(k,g+1),this.list()&&b.attach(this.list(),g+2);else{if(f.detach(this),b.attach(k,g+1),e=new ContentEdit.List(f.tagName()),b.attach(e,g+2),this.list())for(u=this.list().children.slice(),n=0,r=u.length;r>n;n++)a=u[n],a.parent().detach(a),e.attach(a);for(o=0,s=j.length;s>o;o++)i=j[o],i.parent().detach(i),e.attach(i)}return h?(k.focus(),h.select(k.domElement())):void 0}},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.prototype._addDOMEventListeners=function(){},b.prototype._removeDOMEventListners=function(){},b.fromDOMElement=function(a){var b,c,d,e,f,g,h,i,j,k;for(f=new this(this.getDOMElementAttributes(a)),c="",d=null,j=a.childNodes,h=0,i=j.length;i>h;h++)b=j[h],1===b.nodeType?"ul"===(k=b.tagName.toLowerCase())||"li"===k?d||(d=b):c+=b.outerHTML:c+=HTMLString.String.encode(b.textContent);return c=c.replace(/^\s+|\s+$/g,""),g=new ContentEdit.ListItemText(c),f.attach(g),d&&(e=ContentEdit.List.fromDOMElement(d),f.attach(e)),f},b}(ContentEdit.ElementCollection),ContentEdit.ListItemText=function(a){function b(a){b.__super__.constructor.call(this,"div",{},a)}return g(b,a),b.prototype.cssTypeName=function(){return"list-item-text"},b.prototype.type=function(){return"ListItemText"},b.prototype.typeName=function(){return"List item"},b.prototype.blur=function(){return this.content.isWhitespace()&&this.can("remove")?this.parent().remove():this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),ContentEdit.Element.prototype.blur.call(this)},b.prototype.can=function(a,b){if(b)throw new Error("Cannot set behaviour for ListItemText");return this.parent().can(a)},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCachedc;c++)if(b=e[c],b.tagName()===a)return b;return null},b.droppers={Image:ContentEdit.Element._dropBoth,List:ContentEdit.Element._dropVert,PreText:ContentEdit.Element._dropVert,Static:ContentEdit.Element._dropVert,Table:ContentEdit.Element._dropVert,Text:ContentEdit.Element._dropVert,Video:ContentEdit.Element._dropBoth},b.fromDOMElement=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(h=new this(this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),e=[],j=0,l=d.length;l>j;j++)if(c=d[j],1===c.nodeType&&(i=c.tagName.toLowerCase(),!h._getChild(i)))switch(i){case"tbody":case"tfoot":case"thead":g=ContentEdit.TableSection.fromDOMElement(c),h.attach(g);break;case"tr":e.push(ContentEdit.TableRow.fromDOMElement(c))}if(e.length>0)for(h._getChild("tbody")||h.attach(new ContentEdit.TableSection("tbody")),k=0,m=e.length;m>k;k++)f=e[k],h.tbody().attach(f);return 0===h.children.length?null:h},b}(ContentEdit.ElementCollection),ContentEdit.TagNames.get().register(ContentEdit.Table,"table"),ContentEdit.TableSection=function(a){function b(a,c){b.__super__.constructor.call(this,a,c)}return g(b,a),b.prototype.cssTypeName=function(){return"table-section"},b.prototype.type=function(){return"TableSection"},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.fromDOMElement=function(a){var b,c,d,e,f,g;for(e=new this(a.tagName,this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),f=0,g=d.length;g>f;f++)c=d[f],1===c.nodeType&&"tr"===c.tagName.toLowerCase()&&e.attach(ContentEdit.TableRow.fromDOMElement(c));return e},b}(ContentEdit.ElementCollection),ContentEdit.TableRow=function(a){function b(a){b.__super__.constructor.call(this,"tr",a)}return g(b,a),b.prototype.cssTypeName=function(){return"table-row"},b.prototype.isEmpty=function(){var a,b,c,d,e;for(e=this.children,c=0,d=e.length;d>c;c++)if(a=e[c],b=a.tableCellText(),b&&b.content.length()>0)return!1;return!0},b.prototype.type=function(){return"TableRow"},b.prototype.typeName=function(){return"Table row"},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.droppers={TableRow:ContentEdit.Element._dropVert},b.fromDOMElement=function(a){var b,c,d,e,f,g,h;for(e=new this(this.getDOMElementAttributes(a)),d=function(){var c,d,e,f;for(e=a.childNodes,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b);return f}(),g=0,h=d.length;h>g;g++)c=d[g],1===c.nodeType&&(f=c.tagName.toLowerCase(),("td"===f||"th"===f)&&e.attach(ContentEdit.TableCell.fromDOMElement(c)));return e},b}(ContentEdit.ElementCollection),ContentEdit.TableCell=function(a){function b(a,c){b.__super__.constructor.call(this,a,c)}return g(b,a),b.prototype.cssTypeName=function(){return"table-cell"},b.prototype.tableCellText=function(){return this.children.length>0?this.children[0]:null},b.prototype.type=function(){return"TableCell"},b.prototype.html=function(a){var b;return null==a&&(a=""),b=[""+a+"<"+this.tagName()+this._attributesToString()+">"],this.tableCellText()&&b.push(this.tableCellText().html(a+ContentEdit.INDENT)),b.push(""+a+""),b.join("\n")},b.prototype._onMouseOver=function(a){return b.__super__._onMouseOver.call(this,a),this._removeCSSClass("ce-element--over")},b.prototype._addDOMEventListeners=function(){},b.prototype._removeDOMEventListners=function(){},b.fromDOMElement=function(a){var b,c;return b=new this(a.tagName,this.getDOMElementAttributes(a)),c=new ContentEdit.TableCellText(a.innerHTML.replace(/^\s+|\s+$/g,"")),b.attach(c),b},b}(ContentEdit.ElementCollection),ContentEdit.TableCellText=function(a){function b(a){b.__super__.constructor.call(this,"div",{},a)}return g(b,a),b.prototype.cssTypeName=function(){return"table-cell-text"},b.prototype.type=function(){return"TableCellText"},b.prototype._isInFirstRow=function(){var a,b,c,d;return a=this.parent(),b=a.parent(),c=b.parent(),d=c.parent(),c!==d.firstSection()?!1:b===c.children[0]},b.prototype._isInLastRow=function(){var a,b,c,d;return a=this.parent(),b=a.parent(),c=b.parent(),d=c.parent(),c!==d.lastSection()?!1:b===c.children[c.children.length-1]},b.prototype._isLastInSection=function(){var a,b,c;return a=this.parent(),b=a.parent(),c=b.parent(),b!==c.children[c.children.length-1]?!1:a===b.children[b.children.length-1]},b.prototype.blur=function(){return this.isMounted()&&(this._domElement.blur(),this._domElement.removeAttribute("contenteditable")),ContentEdit.Element.prototype.blur.call(this)},b.prototype.can=function(a,b){if(b)throw new Error("Cannot set behaviour for ListItemText");return this.parent().can(a)},b.prototype.html=function(a){var b;return null==a&&(a=""),(!this._lastCached||this._lastCachedi;i++)c=k[i],e=new ContentEdit.TableCell(c.tagName(),c._attributes),f=new ContentEdit.TableCellText(""),e.attach(f),g.attach(e);return h=this.closest(function(a){return"TableSection"===a.type()}),h.attach(g),g.children[0].tableCellText().focus()}return this.nextContent().focus()}},b.prototype._keyUp=function(a){var b,c,d,e,f,g;return g=ContentSelect.Range.query(this._domElement),0===g.get()[0]&&g.isCollapsed()?(a.preventDefault(),b=this.parent(),this._isInFirstRow()?(f=b.parent(),d=f.children[0].previousContent(),d?d.focus():ContentEdit.Root.get().trigger("previous-region",this.closest(function(a){return"Region"===a}))):(e=b.parent().previousWithTest(function(a){return"TableRow"===a.type()}),c=b.parent().children.indexOf(b),c=Math.min(c,e.children.length),e.children[c].tableCellText().focus())):void 0},b.droppers={},b.mergers={},b}(ContentEdit.Text)}.call(this),function(){var a,b,c,d,e={}.hasOwnProperty,f=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},g=function(a,b){return function(){return a.apply(b,arguments)}},h=[].slice;window.ContentTools={Tools:{},CANCEL_MESSAGE:"Your changes have not been saved, do you really want to lose them?".trim(),DEFAULT_TOOLS:[["bold","italic","link","align-left","align-center","align-right"],["heading","subheading","paragraph","unordered-list","ordered-list","table","indent","unindent","line-break"],["image","video","preformatted"],["undo","redo","remove"]],DEFAULT_VIDEO_HEIGHT:300,DEFAULT_VIDEO_WIDTH:400,HIGHLIGHT_HOLD_DURATION:2e3,INSPECTOR_IGNORED_ELEMENTS:["ListItemText","Region","TableCellText"],IMAGE_UPLOADER:null,MIN_CROP:10,RESTRICTED_ATTRIBUTES:{"*":["style"],img:["height","src","width","data-ce-max-width","data-ce-min-width"],iframe:["height","width"]},getEmbedVideoURL:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;for(b={"www.youtube.com":"youtube","youtu.be":"youtube","vimeo.com":"vimeo","player.vimeo.com":"vimeo"},k=document.createElement("a"),k.href=a,g=k.hostname.toLowerCase(),l=k.pathname,null!==l&&"/"!==l.substr(0,1)&&(l="/"+l),i={},j=k.search.slice(1),p=j.split("&"),n=0,o=p.length;o>n;n++)e=p[n],e=e.split("="),e[0]&&(i[e[0]]=e[1]);switch(b[g]){case"youtube":if("/watch"===l.toLowerCase()){if(!i.v)return null;c=i.v,delete i.v}else{if(f=l.match(/\/([A-Za-z0-9_-]+)$/i),!f)return null;c=f[1]}return a="https://www.youtube.com/embed/"+c,h=function(){var a;a=[];for(d in i)m=i[d],a.push(""+d+"="+m);return a}().join("&"),h&&(a+="?"+h),a;case"vimeo":return(f=l.match(/\/(\w+\/\w+\/){0,1}(\d+)/i))?(a="https://player.vimeo.com/video/"+f[2],h=function(){var a;a=[];for(d in i)m=i[d],a.push(""+d+"="+m);return a}().join("&"),h&&(a+="?"+h),a):null}return null},getRestrictedAtributes:function(a){var b;return b=[],ContentTools.RESTRICTED_ATTRIBUTES[a]&&(b=b.concat(ContentTools.RESTRICTED_ATTRIBUTES[a])),ContentTools.RESTRICTED_ATTRIBUTES["*"]&&(b=b.concat(ContentTools.RESTRICTED_ATTRIBUTES["*"])),b}},ContentTools.ComponentUI=function(){function a(){this._eventBinderDOM=document.createElement("div"),this._bindings={},this._parent=null,this._children=[],this._domElement=null}return a.prototype.children=function(){return this._children.slice()},a.prototype.domElement=function(){return this._domElement},a.prototype.isMounted=function(){return null!==this._domElement},a.prototype.parent=function(){return this._parent},a.prototype.attach=function(a,b){return a.parent()&&a.parent().detach(a),a._parent=this,void 0!==b?this._children.splice(b,0,a):this._children.push(a)},a.prototype.addCSSClass=function(a){return this.isMounted()?ContentEdit.addCSSClass(this._domElement,a):void 0},a.prototype.detatch=function(a){var b;return b=this._children.indexOf(a),-1!==b?this._children.splice(b,1):void 0},a.prototype.mount=function(){},a.prototype.removeCSSClass=function(a){return this.isMounted()?ContentEdit.removeCSSClass(this._domElement,a):void 0},a.prototype.unmount=function(){return this.isMounted()?(this._removeDOMEventListeners(),this._domElement.parentNode&&this._domElement.parentNode.removeChild(this._domElement),this._domElement=null):void 0},a.prototype.addEventListener=function(a,b){void 0===this._bindings[a]&&(this._bindings[a]=[]),this._bindings[a].push(b)},a.prototype.createEvent=function(a,b){return new ContentTools.Event(a,b)},a.prototype.dispatchEvent=function(a){var b,c,d,e;if(!this._bindings[a.name()])return!a.defaultPrevented();for(e=this._bindings[a.name()],c=0,d=e.length;d>c&&(b=e[c],!a.propagationStopped());c++)b&&b.call(this,a);return!a.defaultPrevented()},a.prototype.removeEventListener=function(a,b){var c,d,e,f,g,h;if(!a)return void(this._bindings={});if(!b)return void(this._bindings[a]=void 0);if(this._bindings[a]){for(g=this._bindings[a],h=[],c=e=0,f=g.length;f>e;c=++e)d=g[c],h.push(d===b?this._bindings[a].splice(c,1):void 0);return h}},a.prototype._addDOMEventListeners=function(){},a.prototype._removeDOMEventListeners=function(){},a.createDiv=function(a,b,c){var d,e,f;if(d=document.createElement("div"),a&&a.length>0&&d.setAttribute("class",a.join(" ")),b)for(e in b)f=b[e],d.setAttribute(e,f);return c&&(d.innerHTML=c),d},a}(),ContentTools.WidgetUI=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),b.prototype.attach=function(a,c){return b.__super__.attach.call(this,a,c),this.isMounted()?void 0:a.mount()},b.prototype.detatch=function(a){return b.__super__.detatch.call(this,a),this.isMounted()?a.unmount():void 0},b.prototype.show=function(){var a;return this.isMounted()||this.mount(),a=function(a){return function(){return a.addCSSClass("ct-widget--active")}}(this),setTimeout(a,100)},b.prototype.hide=function(){var a;return this.removeCSSClass("ct-widget--active"),a=function(b){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(b._domElement).opacity)<.01?b.unmount():setTimeout(a,250):void b.unmount()}}(this),this.isMounted()?setTimeout(a,250):void 0},b}(ContentTools.ComponentUI),ContentTools.AnchoredComponentUI=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),b.prototype.mount=function(a,b){return null==b&&(b=null),a.insertBefore(this._domElement,b),this._addDOMEventListeners()},b}(ContentTools.ComponentUI),ContentTools.Event=function(){function a(a,b){this._name=a,this._detail=b,this._timeStamp=Date.now(),this._defaultPrevented=!1,this._propagationStopped=!1}return a.prototype.defaultPrevented=function(){return this._defaultPrevented},a.prototype.detail=function(){return this._detail},a.prototype.name=function(){return this._name},a.prototype.propagationStopped=function(){return this._propagationStopped},a.prototype.timeStamp=function(){return this._timeStamp},a.prototype.preventDefault=function(){return this._defaultPrevented=!0},a.prototype.stopImmediatePropagation=function(){return this._propagationStopped=!0},a}(),ContentTools.FlashUI=function(a){function b(a){b.__super__.constructor.call(this),this.mount(a)}return f(b,a),b.prototype.mount=function(a){var c;return this._domElement=this.constructor.createDiv(["ct-flash","ct-flash--active","ct-flash--"+a,"ct-widget","ct-widget--active"]),b.__super__.mount.call(this,ContentTools.EditorApp.get().domElement()),c=function(a){return function(){return window.getComputedStyle?parseFloat(window.getComputedStyle(a._domElement).opacity)<.01?a.unmount():setTimeout(c,250):void a.unmount()}}(this),setTimeout(c,250)},b}(ContentTools.AnchoredComponentUI),ContentTools.IgnitionUI=function(a){function b(){b.__super__.constructor.call(this),this._revertToState="ready",this._state="ready"}return f(b,a),b.prototype.busy=function(a){if(this.dispatchEvent(this.createEvent("busy",{busy:a}))){if(a===("busy"===this._state))return;return a?(this._revertToState=this._state,this.state("busy")):this.state(this._revertToState)}},b.prototype.cancel=function(){return this.dispatchEvent(this.createEvent("cancel"))?this.state("ready"):void 0},b.prototype.confirm=function(){return this.dispatchEvent(this.createEvent("confirm"))?this.state("ready"):void 0},b.prototype.edit=function(){return this.dispatchEvent(this.createEvent("edit"))?this.state("editing"):void 0},b.prototype.mount=function(){return b.__super__.mount.call(this),this._domElement=this.constructor.createDiv(["ct-widget","ct-ignition","ct-ignition--ready"]),this.parent().domElement().appendChild(this._domElement),this._domEdit=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--edit"]),this._domElement.appendChild(this._domEdit),this._domConfirm=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--confirm"]),this._domElement.appendChild(this._domConfirm),this._domCancel=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--cancel"]),this._domElement.appendChild(this._domCancel),this._domBusy=this.constructor.createDiv(["ct-ignition__button","ct-ignition__button--busy"]),this._domElement.appendChild(this._domBusy),this._addDOMEventListeners()},b.prototype.state=function(a){if(void 0===a)return this._state;if(this._state!==a&&this.dispatchEvent(this.createEvent("statechange",{state:a})))return this._state=a,this.removeCSSClass("ct-ignition--busy"),this.removeCSSClass("ct-ignition--editing"),this.removeCSSClass("ct-ignition--ready"),"busy"===this._state?this.addCSSClass("ct-ignition--busy"):"editing"===this._state?this.addCSSClass("ct-ignition--editing"):"ready"===this._state?this.addCSSClass("ct-ignition--ready"):void 0},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domEdit=null,this._domConfirm=null,this._domCancel=null},b.prototype._addDOMEventListeners=function(){return this._domEdit.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.edit()}}(this)),this._domConfirm.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.confirm()}}(this)),this._domCancel.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.cancel()}}(this))},b}(ContentTools.WidgetUI),ContentTools.InspectorUI=function(a){function b(){b.__super__.constructor.call(this),this._tagUIs=[]}return f(b,a),b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-inspector"]),this.parent().domElement().appendChild(this._domElement),this._domTags=this.constructor.createDiv(["ct-inspector__tags","ct-tags"]),this._domElement.appendChild(this._domTags),this._addDOMEventListeners(),this._handleFocusChange=function(a){return function(){return a.updateTags()}}(this),ContentEdit.Root.get().bind("blur",this._handleFocusChange),ContentEdit.Root.get().bind("focus",this._handleFocusChange),ContentEdit.Root.get().bind("mount",this._handleFocusChange)},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domTags=null,ContentEdit.Root.get().unbind("blur",this._handleFocusChange),ContentEdit.Root.get().unbind("focus",this._handleFocusChange),ContentEdit.Root.get().unbind("mount",this._handleFocusChange)},b.prototype.updateTags=function(){var a,b,c,d,e,f,g,h,i;for(a=ContentEdit.Root.get().focused(),h=this._tagUIs,d=0,f=h.length;f>d;d++)c=h[d],c.unmount();if(this._tagUIs=[],a){for(b=a.parents(),b.reverse(),b.push(a),i=[],e=0,g=b.length;g>e;e++)a=b[e],-1===ContentTools.INSPECTOR_IGNORED_ELEMENTS.indexOf(a.type())&&(c=new ContentTools.TagUI(a),this._tagUIs.push(c),i.push(c.mount(this._domTags)));return i}},b}(ContentTools.WidgetUI),ContentTools.TagUI=function(a){function b(a){this.element=a,this._onMouseDown=g(this._onMouseDown,this),b.__super__.constructor.call(this)}return f(b,a),b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-tag"]),this._domElement.textContent=this.element.tagName(),b.__super__.mount.call(this,a,c)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown)},b.prototype._onMouseDown=function(a){var b,c,d;return a.preventDefault(),this.element.storeState&&this.element.storeState(),b=ContentTools.EditorApp.get(),d=new ContentTools.ModalUI,c=new ContentTools.PropertiesDialog(this.element),c.addEventListener("cancel",function(a){return function(){return d.hide(),c.hide(),a.element.restoreState?a.element.restoreState():void 0}}(this)),c.addEventListener("save",function(a){return function(b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;j=b.detail(),f=j.changedAttributes,n=j.changedStyles,l=j.innerHTML;for(m in f)if(o=f[m],"class"===m){for(null===o&&(o=""),h={},t=o.split(" "),p=0,r=t.length;r>p;p++)g=t[p],g=g.trim(),g&&(h[g]=!0,a.element.hasCSSClass(g)||a.element.addCSSClass(g));for(u=a.element.attr("class").split(" "),q=0,s=u.length;s>q;q++)g=u[q],g=g.trim(),void 0===h[g]&&a.element.removeCSSClass(g)}else null===o?a.element.removeAttr(m):a.element.attr(m,o);for(i in n)e=n[i],e?a.element.addCSSClass(i):a.element.removeCSSClass(i);return null!==l&&l!==c.getElementInnerHTML()&&(k=a.element,k.content||(k=k.children[0]),k.content=new HTMLString.String(l,k.content.preserveWhitespace()),k.updateInnerHTML(),k.taint(),k.selection(new ContentSelect.Range(0,0)),k.storeState()),d.hide(),c.hide(),a.element.restoreState?a.element.restoreState():void 0}}(this)),b.attach(d),b.attach(c),d.show(),c.show()},b}(ContentTools.AnchoredComponentUI),ContentTools.ModalUI=function(a){function b(a,c){b.__super__.constructor.call(this),this._transparent=a,this._allowScrolling=c}return f(b,a),b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-modal"]),this.parent().domElement().appendChild(this._domElement),this._transparent&&this.addCSSClass("ct-modal--transparent"),this._allowScrolling||ContentEdit.addCSSClass(document.body,"ct--no-scroll"),this._addDOMEventListeners()},b.prototype.unmount=function(){return this._allowScrolling||ContentEdit.removeCSSClass(document.body,"ct--no-scroll"),b.__super__.unmount.call(this)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("click",function(a){return function(){return a.dispatchEvent(a.createEvent("click"))}}(this))},b}(ContentTools.WidgetUI),ContentTools.ToolboxUI=function(a){function b(a){this._onStopDragging=g(this._onStopDragging,this),this._onStartDragging=g(this._onStartDragging,this),this._onDrag=g(this._onDrag,this),b.__super__.constructor.call(this),this._tools=a,this._dragging=!1,this._draggingOffset=null,this._domGrip=null,this._toolUIs={}}return f(b,a),b.prototype.isDragging=function(){return this._dragging},b.prototype.hide=function(){return this._removeDOMEventListeners(),b.__super__.hide.call(this)},b.prototype.mount=function(){var a,b,c;return this._domElement=this.constructor.createDiv(["ct-widget","ct-toolbox"]),this.parent().domElement().appendChild(this._domElement),this._domGrip=this.constructor.createDiv(["ct-toolbox__grip","ct-grip"]),this._domElement.appendChild(this._domGrip),this._domGrip.appendChild(this.constructor.createDiv(["ct-grip__bump"])),this._domGrip.appendChild(this.constructor.createDiv(["ct-grip__bump"])),this._domGrip.appendChild(this.constructor.createDiv(["ct-grip__bump"])),this._domToolGroups=this.constructor.createDiv(["ct-tool-groups"]),this._domElement.appendChild(this._domToolGroups),this.tools(this._tools),c=window.localStorage.getItem("ct-toolbox-position"),c&&/^\d+,\d+$/.test(c)&&(b=function(){var b,d,e,f; +for(e=c.split(","),f=[],b=0,d=e.length;d>b;b++)a=e[b],f.push(parseInt(a));return f}(),this._domElement.style.left=""+b[0]+"px",this._domElement.style.top=""+b[1]+"px",this._contain()),this._addDOMEventListeners()},b.prototype.tools=function(a){var b,c,d,e,f,g,h,i,j,k,l;if(void 0===a)return this._tools;if(this._tools=a,this.isMounted()){j=this._toolUIs;for(f in j)g=j[f],g.unmount();for(this._toolUIs={};this._domToolGroups.lastChild;)this._domToolGroups.removeChild(this._domToolGroups.lastChild);for(k=this._tools,l=[],c=h=0,i=k.length;i>h;c=++h)e=k[c],b=this.constructor.createDiv(["ct-tool-group"]),this._domToolGroups.appendChild(b),l.push(function(){var a,c,g;for(g=[],a=0,c=e.length;c>a;a++)f=e[a],d=ContentTools.ToolShelf.fetch(f),this._toolUIs[f]=new ContentTools.ToolUI(d),this._toolUIs[f].mount(b),this._toolUIs[f].disabled(!0),g.push(this._toolUIs[f].addEventListener("applied",function(a){return function(){return a.updateTools()}}(this)));return g}.call(this));return l}},b.prototype.updateTools=function(){var a,b,c,d,e,f;a=ContentEdit.Root.get().focused(),c=null,a&&a.selection&&(c=a.selection()),e=this._toolUIs,f=[];for(b in e)d=e[b],f.push(d.update(a,c));return f},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domGrip=null},b.prototype._addDOMEventListeners=function(){return this._domGrip.addEventListener("mousedown",this._onStartDragging),this._handleResize=function(a){return function(){var b;return a._resizeTimeout&&clearTimeout(a._resizeTimeout),b=function(){return a._contain()},a._resizeTimeout=setTimeout(b,250)}}(this),window.addEventListener("resize",this._handleResize),this._updateTools=function(a){return function(){var b,c,d,e,f,g,h,i;if(b=ContentTools.EditorApp.get(),g=!1,c=ContentEdit.Root.get().focused(),e=null,c===a._lastUpdateElement?c&&c.selection&&(e=c.selection(),a._lastUpdateSelection?e.eq(a._lastUpdateSelection)||(g=!0):g=!0):g=!0,b.history&&(a._lastUpdateHistoryLength!==b.history.length()&&(g=!0),a._lastUpdateHistoryLength=b.history.length(),a._lastUpdateHistoryIndex!==b.history.index()&&(g=!0),a._lastUpdateHistoryIndex=b.history.index()),a._lastUpdateElement=c,a._lastUpdateSelection=e,g){h=a._toolUIs,i=[];for(d in h)f=h[d],i.push(f.update(c,e));return i}}}(this),this._updateToolsTimeout=setInterval(this._updateTools,100),this._handleKeyDown=function(){return function(a){var b,c,d,e,f;switch(46===a.keyCode&&(b=ContentEdit.Root.get().focused(),b&&!b.content&&ContentTools.Tools.Remove.apply(b,null,function(){})),f=navigator.appVersion,c="linux",-1!==f.indexOf("Mac")?c="mac":-1!==f.indexOf("Win")&&(c="windows"),d=!1,e=!1,c){case"linux":90===a.keyCode&&a.ctrlKey&&(d=a.shiftKey,e=!d);break;case"mac":90===a.keyCode&&a.metaKey&&(d=a.shiftKey,e=!d);break;case"windows":89===a.keyCode&&a.ctrlKey&&(d=!0),90===a.keyCode&&a.ctrlKey&&(e=!0)}return e&&ContentTools.Tools.Undo.canApply(null,null)&&ContentTools.Tools.Undo.apply(null,null,function(){}),d&&ContentTools.Tools.Redo.canApply(null,null)?ContentTools.Tools.Redo.apply(null,null,function(){}):void 0}}(this),window.addEventListener("keydown",this._handleKeyDown)},b.prototype._contain=function(){var a;if(this.isMounted())return a=this._domElement.getBoundingClientRect(),a.left+a.width>window.innerWidth&&(this._domElement.style.left=""+(window.innerWidth-a.width)+"px"),a.top+a.height>window.innerHeight&&(this._domElement.style.top=""+(window.innerHeight-a.height)+"px"),a.left<0&&(this._domElement.style.left="0px"),a.top<0&&(this._domElement.style.top="0px"),a=this._domElement.getBoundingClientRect(),window.localStorage.setItem("ct-toolbox-position",""+a.left+","+a.top)},b.prototype._removeDOMEventListeners=function(){return this.isMounted()&&this._domGrip.removeEventListener("mousedown",this._onStartDragging),window.removeEventListener("keydown",this._handleKeyDown),window.removeEventListener("resize",this._handleResize),window.removeEventListener("resize",this._handleResize),clearInterval(this._updateToolsTimeout)},b.prototype._onDrag=function(a){return ContentSelect.Range.unselectAll(),this._domElement.style.left=""+(a.clientX-this._draggingOffset.x)+"px",this._domElement.style.top=""+(a.clientY-this._draggingOffset.y)+"px"},b.prototype._onStartDragging=function(a){var b;return a.preventDefault(),this.isDragging()?void 0:(this._dragging=!0,this.addCSSClass("ct-toolbox--dragging"),b=this._domElement.getBoundingClientRect(),this._draggingOffset={x:a.clientX-b.left,y:a.clientY-b.top},document.addEventListener("mousemove",this._onDrag),document.addEventListener("mouseup",this._onStopDragging),ContentEdit.addCSSClass(document.body,"ce--dragging"))},b.prototype._onStopDragging=function(){return this.isDragging()?(this._contain(),document.removeEventListener("mousemove",this._onDrag),document.removeEventListener("mouseup",this._onStopDragging),this._draggingOffset=null,this._dragging=!1,this.removeCSSClass("ct-toolbox--dragging"),ContentEdit.removeCSSClass(document.body,"ce--dragging")):void 0},b}(ContentTools.WidgetUI),ContentTools.ToolUI=function(a){function b(a){this._onMouseUp=g(this._onMouseUp,this),this._onMouseLeave=g(this._onMouseLeave,this),this._onMouseDown=g(this._onMouseDown,this),this._addDOMEventListeners=g(this._addDOMEventListeners,this),b.__super__.constructor.call(this),this.tool=a,this._mouseDown=!1,this._disabled=!1}return f(b,a),b.prototype.apply=function(a,b){var c,d;if(this.tool.canApply(a,b))return d={element:a,selection:b},c=function(a){return function(b){return b?a.dispatchEvent(a.createEvent("applied",d)):void 0}}(this),this.dispatchEvent(this.createEvent("apply",d))?this.tool.apply(a,b,c):void 0},b.prototype.disabled=function(a){if(void 0===a)return this._disabled;if(this._disabled!==a)return this._disabled=a,a?(this._mouseDown=!1,this.addCSSClass("ct-tool--disabled"),this.removeCSSClass("ct-tool--applied")):this.removeCSSClass("ct-tool--disabled")},b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-tool","ct-tool--"+this.tool.icon]),this._domElement.setAttribute("data-tooltip",ContentEdit._(this.tool.label)),b.__super__.mount.call(this,a,c)},b.prototype.update=function(a,b){return(!this.tool.requiresElement||a&&a.isMounted())&&this.tool.canApply(a,b)?(this.disabled(!1),this.tool.isApplied(a,b)?this.addCSSClass("ct-tool--applied"):this.removeCSSClass("ct-tool--applied")):void this.disabled(!0)},b.prototype._addDOMEventListeners=function(){return this._domElement.addEventListener("mousedown",this._onMouseDown),this._domElement.addEventListener("mouseleave",this._onMouseLeave),this._domElement.addEventListener("mouseup",this._onMouseUp)},b.prototype._onMouseDown=function(a){return a.preventDefault(),this.disabled()?void 0:(this._mouseDown=!0,this.addCSSClass("ct-tool--down"))},b.prototype._onMouseLeave=function(){return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},b.prototype._onMouseUp=function(){var a,b;if(this._mouseDown){if(a=ContentEdit.Root.get().focused(),this.tool.requiresElement&&(!a||!a.isMounted()))return;b=null,a&&a.selection&&(b=a.selection()),this.apply(a,b)}return this._mouseDown=!1,this.removeCSSClass("ct-tool--down")},b}(ContentTools.AnchoredComponentUI),ContentTools.AnchoredDialogUI=function(a){function b(){b.__super__.constructor.call(this),this._position=[0,0]}return f(b,a),b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-widget","ct-anchored-dialog"]),this.parent().domElement().appendChild(this._domElement),this._domElement.style.top=""+this._position[1]+"px",this._domElement.style.left=""+this._position[0]+"px"},b.prototype.position=function(a){return void 0===a?this._position.slice():(this._position=a.slice(),this.isMounted()?(this._domElement.style.top=""+this._position[1]+"px",this._domElement.style.left=""+this._position[0]+"px"):void 0)},b}(ContentTools.WidgetUI),ContentTools.DialogUI=function(a){function b(a){null==a&&(a=""),b.__super__.constructor.call(this),this._busy=!1,this._caption=a}return f(b,a),b.prototype.busy=function(a){if(void 0===a)return this._busy;if(this._busy!==a&&(this._busy=a,this.isMounted()))return this._busy?ContentEdit.addCSSClass(this._domElement,"ct-dialog--busy"):ContentEdit.removeCSSClass(this._domElement,"ct-dialog--busy")},b.prototype.caption=function(a){return void 0===a?this._caption:(this._caption=a,this._domCaption.textContent=ContentEdit._(a))},b.prototype.mount=function(){var a,b,c;return a=["ct-widget","ct-dialog"],this._busy&&a.push("ct-dialog--busy"),this._domElement=this.constructor.createDiv(a),this.parent().domElement().appendChild(this._domElement),c=this.constructor.createDiv(["ct-dialog__header"]),this._domElement.appendChild(c),this._domCaption=this.constructor.createDiv(["ct-dialog__caption"]),c.appendChild(this._domCaption),this.caption(this._caption),this._domClose=this.constructor.createDiv(["ct-dialog__close"]),c.appendChild(this._domClose),b=this.constructor.createDiv(["ct-dialog__body"]),this._domElement.appendChild(b),this._domView=this.constructor.createDiv(["ct-dialog__view"]),b.appendChild(this._domView),this._domControls=this.constructor.createDiv(["ct-dialog__controls"]),b.appendChild(this._domControls),this._domBusy=this.constructor.createDiv(["ct-dialog__busy"]),this._domElement.appendChild(this._domBusy)},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domBusy=null,this._domCaption=null,this._domClose=null,this._domControls=null,this._domView=null},b.prototype._addDOMEventListeners=function(){return this._handleEscape=function(a){return function(b){return a._busy?void 0:27===b.keyCode?a.dispatchEvent(a.createEvent("cancel")):void 0}}(this),document.addEventListener("keyup",this._handleEscape),this._domClose.addEventListener("click",function(a){return function(b){return b.preventDefault(),a._busy?void 0:a.dispatchEvent(a.createEvent("cancel"))}}(this))},b.prototype._removeDOMEventListeners=function(){return document.removeEventListener("keyup",this._handleEscape)},b}(ContentTools.WidgetUI),ContentTools.ImageDialog=function(a){function c(){c.__super__.constructor.call(this,"Insert image"),this._cropMarks=null,this._imageURL=null,this._imageSize=null,this._progress=0,this._state="empty",ContentTools.IMAGE_UPLOADER&&ContentTools.IMAGE_UPLOADER(this)}return f(c,a),c.prototype.cropRegion=function(){return this._cropMarks?this._cropMarks.region():[0,0,1,1]},c.prototype.addCropMarks=function(){return this._cropMarks?void 0:(this._cropMarks=new b(this._imageSize),this._cropMarks.mount(this._domView),ContentEdit.addCSSClass(this._domCrop,"ct-control--active"))},c.prototype.clear=function(){return this._domImage&&(this._domImage.parentNode.removeChild(this._domImage),this._domImage=null),this._imageURL=null,this._imageSize=null,this.state("empty")},c.prototype.mount=function(){var a,b,d;return c.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-image-dialog"),ContentEdit.addCSSClass(this._domElement,"ct-image-dialog--empty"),ContentEdit.addCSSClass(this._domView,"ct-image-dialog__view"),d=this.constructor.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(d),this._domRotateCCW=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--rotate-ccw"]),this._domRotateCCW.setAttribute("data-tooltip",ContentEdit._("Rotate")+" -90°"),d.appendChild(this._domRotateCCW),this._domRotateCW=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--rotate-cw"]),this._domRotateCW.setAttribute("data-tooltip",ContentEdit._("Rotate")+" 90°"),d.appendChild(this._domRotateCW),this._domCrop=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--crop"]),this._domCrop.setAttribute("data-tooltip",ContentEdit._("Crop marks")),d.appendChild(this._domCrop),b=this.constructor.createDiv(["ct-progress-bar"]),d.appendChild(b),this._domProgress=this.constructor.createDiv(["ct-progress-bar__progress"]),b.appendChild(this._domProgress),a=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(a),this._domUpload=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--upload"]),this._domUpload.textContent=ContentEdit._("Upload"),a.appendChild(this._domUpload),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-image-dialog__file-upload"),this._domInput.setAttribute("name","file"),this._domInput.setAttribute("type","file"),this._domInput.setAttribute("accept","image/*"),this._domUpload.appendChild(this._domInput),this._domInsert=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--insert"]),this._domInsert.textContent=ContentEdit._("Insert"),a.appendChild(this._domInsert),this._domCancelUpload=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--cancel"]),this._domCancelUpload.textContent=ContentEdit._("Cancel"),a.appendChild(this._domCancelUpload),this._domClear=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--clear"]),this._domClear.textContent=ContentEdit._("Clear"),a.appendChild(this._domClear),this._addDOMEventListeners(),this.dispatchEvent(this.createEvent("imageuploader.mount"))},c.prototype.populate=function(a,b){return this._imageURL=a,this._imageSize=b,this._domImage||(this._domImage=this.constructor.createDiv(["ct-image-dialog__image"]),this._domView.appendChild(this._domImage)),this._domImage.style["background-image"]="url("+a+")",this.state("populated")},c.prototype.progress=function(a){return void 0===a?this._progress:(this._progress=a,this.isMounted()?this._domProgress.style.width=""+this._progress+"%":void 0)},c.prototype.removeCropMarks=function(){return this._cropMarks?(this._cropMarks.unmount(),this._cropMarks=null,ContentEdit.removeCSSClass(this._domCrop,"ct-control--active")):void 0},c.prototype.save=function(a,b,c){return this.dispatchEvent(this.createEvent("save",{imageURL:a,imageSize:b,imageAttrs:c}))},c.prototype.state=function(a){var b;if(void 0===a)return this._state;if(this._state!==a&&(b=this._state,this._state=a,this.isMounted()))return ContentEdit.addCSSClass(this._domElement,"ct-image-dialog--"+this._state),ContentEdit.removeCSSClass(this._domElement,"ct-image-dialog--"+b)},c.prototype.unmount=function(){return c.__super__.unmount.call(this),this._domCancelUpload=null,this._domClear=null,this._domCrop=null,this._domInput=null,this._domInsert=null,this._domProgress=null,this._domRotateCCW=null,this._domRotateCW=null,this._domUpload=null,this.dispatchEvent(this.createEvent("imageuploader.unmount"))},c.prototype._addDOMEventListeners=function(){return c.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("change",function(a){return function(b){var c;return c=b.target.files[0],b.target.value="",b.target.value&&(b.target.type="text",b.target.type="file"),a.dispatchEvent(a.createEvent("imageuploader.fileready",{file:c}))}}(this)),this._domCancelUpload.addEventListener("click",function(a){return function(){return a.dispatchEvent(a.createEvent("imageuploader.cancelupload"))}}(this)),this._domClear.addEventListener("click",function(a){return function(){return a.removeCropMarks(),a.dispatchEvent(a.createEvent("imageuploader.clear"))}}(this)),this._domRotateCCW.addEventListener("click",function(a){return function(){return a.removeCropMarks(),a.dispatchEvent(a.createEvent("imageuploader.rotateccw"))}}(this)),this._domRotateCW.addEventListener("click",function(a){return function(){return a.removeCropMarks(),a.dispatchEvent(a.createEvent("imageuploader.rotatecw"))}}(this)),this._domCrop.addEventListener("click",function(a){return function(){return a._cropMarks?a.removeCropMarks():a.addCropMarks()}}(this)),this._domInsert.addEventListener("click",function(a){return function(){return a.dispatchEvent(a.createEvent("imageuploader.save"))}}(this))},c}(ContentTools.DialogUI),b=function(a){function b(a){b.__super__.constructor.call(this),this._bounds=null,this._dragging=null,this._draggingOrigin=null,this._imageSize=a}return f(b,a),b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-crop-marks"]),this._domClipper=this.constructor.createDiv(["ct-crop-marks__clipper"]),this._domElement.appendChild(this._domClipper),this._domRulers=[this.constructor.createDiv(["ct-crop-marks__ruler","ct-crop-marks__ruler--top-left"]),this.constructor.createDiv(["ct-crop-marks__ruler","ct-crop-marks__ruler--bottom-right"])],this._domClipper.appendChild(this._domRulers[0]),this._domClipper.appendChild(this._domRulers[1]),this._domHandles=[this.constructor.createDiv(["ct-crop-marks__handle","ct-crop-marks__handle--top-left"]),this.constructor.createDiv(["ct-crop-marks__handle","ct-crop-marks__handle--bottom-right"])],this._domElement.appendChild(this._domHandles[0]),this._domElement.appendChild(this._domHandles[1]),b.__super__.mount.call(this,a,c),this._fit(a)},b.prototype.region=function(){return[parseFloat(this._domHandles[0].style.top)/this._bounds[1],parseFloat(this._domHandles[0].style.left)/this._bounds[0],parseFloat(this._domHandles[1].style.top)/this._bounds[1],parseFloat(this._domHandles[1].style.left)/this._bounds[0]]},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domClipper=null,this._domHandles=null,this._domRulers=null},b.prototype._addDOMEventListeners=function(){return b.__super__._addDOMEventListeners.call(this),this._domHandles[0].addEventListener("mousedown",function(a){return function(b){return 0===b.button?a._startDrag(0,b.clientY,b.clientX):void 0}}(this)),this._domHandles[1].addEventListener("mousedown",function(a){return function(b){return 0===b.button?a._startDrag(1,b.clientY,b.clientX):void 0}}(this))},b.prototype._drag=function(a,b){var c,d,e,f,g;if(null!==this._dragging)return ContentSelect.Range.unselectAll(),f=a-this._draggingOrigin[1],e=b-this._draggingOrigin[0],c=this._bounds[1],b=0,a=0,g=this._bounds[0],d=Math.min(Math.min(ContentTools.MIN_CROP,c),g),0===this._dragging?(c=parseInt(this._domHandles[1].style.top)-d,g=parseInt(this._domHandles[1].style.left)-d):(b=parseInt(this._domHandles[0].style.left)+d,a=parseInt(this._domHandles[0].style.top)+d),f=Math.min(Math.max(a,f),c),e=Math.min(Math.max(b,e),g),this._domHandles[this._dragging].style.top=""+f+"px",this._domHandles[this._dragging].style.left=""+e+"px",this._domRulers[this._dragging].style.top=""+f+"px",this._domRulers[this._dragging].style.left=""+e+"px"},b.prototype._fit=function(a){var b,c,d,e,f,g,h,i;return f=a.getBoundingClientRect(),i=f.width/this._imageSize[0],c=f.height/this._imageSize[1],e=Math.min(i,c),h=e*this._imageSize[0],b=e*this._imageSize[1],d=(f.width-h)/2,g=(f.height-b)/2,this._domElement.style.width=""+h+"px",this._domElement.style.height=""+b+"px",this._domElement.style.top=""+g+"px",this._domElement.style.left=""+d+"px",this._domHandles[0].style.top="0px",this._domHandles[0].style.left="0px",this._domHandles[1].style.top=""+b+"px",this._domHandles[1].style.left=""+h+"px",this._domRulers[0].style.top="0px",this._domRulers[0].style.left="0px",this._domRulers[1].style.top=""+b+"px",this._domRulers[1].style.left=""+h+"px",this._bounds=[h,b]},b.prototype._startDrag=function(a,b,c){var d;return d=this._domHandles[a],this._dragging=a,this._draggingOrigin=[c-parseInt(d.style.left),b-parseInt(d.style.top)],this._onMouseMove=function(a){return function(b){return a._drag(b.clientY,b.clientX)}}(this),document.addEventListener("mousemove",this._onMouseMove),this._onMouseUp=function(a){return function(){return a._stopDrag()}}(this),document.addEventListener("mouseup",this._onMouseUp)},b.prototype._stopDrag=function(){return document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._dragging=null,this._draggingOrigin=null},b}(ContentTools.AnchoredComponentUI),ContentTools.LinkDialog=function(a){function b(a,c){null==a&&(a=""),null==c&&(c=""),b.__super__.constructor.call(this),this._href=a,this._target=c}var c;return f(b,a),c="_blank",b.prototype.mount=function(){return b.__super__.mount.call(this),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-anchored-dialog__input"),this._domInput.setAttribute("name","href"),this._domInput.setAttribute("placeholder",ContentEdit._("Enter a link")+"..."),this._domInput.setAttribute("type","text"),this._domInput.setAttribute("value",this._href),this._domElement.appendChild(this._domInput),this._domTargetButton=this.constructor.createDiv(["ct-anchored-dialog__target-button"]),this._domElement.appendChild(this._domTargetButton),this._target===c&&ContentEdit.addCSSClass(this._domTargetButton,"ct-anchored-dialog__target-button--active"),this._domButton=this.constructor.createDiv(["ct-anchored-dialog__button"]),this._domElement.appendChild(this._domButton),this._addDOMEventListeners()},b.prototype.save=function(){var a;return this.isMounted()?(a={href:this._domInput.value.trim(),target:this._target?this._target:void 0},this.dispatchEvent(this.createEvent("save",a))):void this.dispatchEvent(this.createEvent("save"))},b.prototype.show=function(){return b.__super__.show.call(this),this._domInput.focus(),this._href?this._domInput.select():void 0},b.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),b.__super__.unmount.call(this),this._domButton=null,this._domInput=null},b.prototype._addDOMEventListeners=function(){return this._domInput.addEventListener("keypress",function(a){return function(b){return 13===b.keyCode?a.save():void 0}}(this)),this._domTargetButton.addEventListener("click",function(a){return function(b){return b.preventDefault(),a._target===c?(a._target="",ContentEdit.removeCSSClass(a._domTargetButton,"ct-anchored-dialog__target-button--active")):(a._target=c,ContentEdit.addCSSClass(a._domTargetButton,"ct-anchored-dialog__target-button--active"))}}(this)),this._domButton.addEventListener("click",function(a){return function(b){return b.preventDefault(),a.save()}}(this))},b}(ContentTools.AnchoredDialogUI),ContentTools.PropertiesDialog=function(b){function d(a){var b;this.element=a,d.__super__.constructor.call(this,"Properties"),this._attributeUIs=[],this._focusedAttributeUI=null,this._styleUIs=[],this._supportsCoding=this.element.content,("ListItem"===(b=this.element.type())||"TableCell"===b)&&(this._supportsCoding=!0)}return f(d,b),d.prototype.caption=function(a){return void 0===a?this._caption:(this._caption=a,this._domCaption.textContent=ContentEdit._(a)+(": "+this.element.tagName()))},d.prototype.changedAttributes=function(){var a,b,c,d,e,f,g,h,i,j;for(b={},c={},i=this._attributeUIs,g=0,h=i.length;h>g;g++)a=i[g],d=a.name(),f=a.value(),""!==d&&(b[d.toLowerCase()]=!0,this.element.attr(d)!==f&&(c[d]=f));e=ContentTools.getRestrictedAtributes(this.element.tagName()),j=this.element.attributes();for(d in j)f=j[d],e&&-1!==e.indexOf(d.toLowerCase())||void 0===b[d]&&(c[d]=null);return c},d.prototype.changedStyles=function(){var a,b,c,d,e,f;for(c={},f=this._styleUIs,d=0,e=f.length;e>d;d++)b=f[d],a=b.style.cssClass(),this.element.hasCSSClass(a)!==b.applied()&&(c[a]=b.applied());return c},d.prototype.getElementInnerHTML=function(){return this._supportsCoding?this.element.content?this.element.content.html():this.element.children[0].content.html():null},d.prototype.mount=function(){var a,b,e,f,g,h,i,j,k,l,m,n,o,p,q;for(d.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog"),ContentEdit.addCSSClass(this._domView,"ct-properties-dialog__view"),this._domStyles=this.constructor.createDiv(["ct-properties-dialog__styles"]),this._domStyles.setAttribute("data-ct-empty",ContentEdit._("No styles available for this tag")),this._domView.appendChild(this._domStyles),q=ContentTools.StylePalette.styles(this.element.tagName()),m=0,o=q.length;o>m;m++)j=q[m],k=new c(j,this.element.hasCSSClass(j.cssClass())),this._styleUIs.push(k),k.mount(this._domStyles);this._domAttributes=this.constructor.createDiv(["ct-properties-dialog__attributes"]),this._domView.appendChild(this._domAttributes),i=ContentTools.getRestrictedAtributes(this.element.tagName()),b=this.element.attributes(),a=[];for(h in b)l=b[h],i&&-1!==i.indexOf(h.toLowerCase())||a.push(h);for(a.sort(),n=0,p=a.length;p>n;n++)h=a[n],l=b[h],this._addAttributeUI(h,l);return this._addAttributeUI("",""),this._domCode=this.constructor.createDiv(["ct-properties-dialog__code"]),this._domView.appendChild(this._domCode),this._domInnerHTML=document.createElement("textarea"),this._domInnerHTML.setAttribute("class","ct-properties-dialog__inner-html"),this._domInnerHTML.setAttribute("name","code"),this._domInnerHTML.value=this.getElementInnerHTML(),this._domCode.appendChild(this._domInnerHTML),f=this.constructor.createDiv(["ct-control-group","ct-control-group--left"]),this._domControls.appendChild(f),this._domStylesTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--styles"]),this._domStylesTab.setAttribute("data-tooltip",ContentEdit._("Styles")),f.appendChild(this._domStylesTab),this._domAttributesTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--attributes"]),this._domAttributesTab.setAttribute("data-tooltip",ContentEdit._("Attributes")),f.appendChild(this._domAttributesTab),this._domCodeTab=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--code"]),this._domCodeTab.setAttribute("data-tooltip",ContentEdit._("Code")),f.appendChild(this._domCodeTab),this._supportsCoding||ContentEdit.addCSSClass(this._domCodeTab,"ct-control--muted"),this._domRemoveAttribute=this.constructor.createDiv(["ct-control","ct-control--icon","ct-control--remove","ct-control--muted"]),this._domRemoveAttribute.setAttribute("data-tooltip",ContentEdit._("Remove")),f.appendChild(this._domRemoveAttribute),e=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(e),this._domApply=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent=ContentEdit._("Apply"),e.appendChild(this._domApply),g=window.localStorage.getItem("ct-properties-dialog-tab"),"attributes"===g?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--attributes"),ContentEdit.addCSSClass(this._domAttributesTab,"ct-control--active")):"code"===g&&this._supportsCoding?(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--code"),ContentEdit.addCSSClass(this._domCodeTab,"ct-control--active")):(ContentEdit.addCSSClass(this._domElement,"ct-properties-dialog--styles"),ContentEdit.addCSSClass(this._domStylesTab,"ct-control--active")),this._addDOMEventListeners()},d.prototype.save=function(){var a,b;return b=null,this._supportsCoding&&(b=this._domInnerHTML.value),a={changedAttributes:this.changedAttributes(),changedStyles:this.changedStyles(),innerHTML:b},this.dispatchEvent(this.createEvent("save",a))},d.prototype._addAttributeUI=function(b,c){var d,e;return e=this,d=new a(b,c),this._attributeUIs.push(d),d.addEventListener("blur",function(){var a,b,c;return e._focusedAttributeUI=null,ContentEdit.addCSSClass(e._domRemoveAttribute,"ct-control--muted"),a=e._attributeUIs.indexOf(this),c=e._attributeUIs.length,""===this.name()&&c-1>a&&(this.unmount(),e._attributeUIs.splice(a,1)),b=e._attributeUIs[c-1],b&&b.name()&&b.value()?e._addAttributeUI("",""):void 0}),d.addEventListener("focus",function(){return e._focusedAttributeUI=this,ContentEdit.removeCSSClass(e._domRemoveAttribute,"ct-control--muted")}),d.addEventListener("namechange",function(){var a,c,d,f,g,h,i;for(a=e.element,b=this.name().toLowerCase(),d=ContentTools.getRestrictedAtributes(a.tagName()),f=!0,d&&-1!==d.indexOf(b)&&(f=!1),i=e._attributeUIs,g=0,h=i.length;h>g;g++)c=i[g],""!==b&&c!==this&&c.name().toLowerCase()===b&&(f=!1);return this.valid(f),f?ContentEdit.removeCSSClass(e._domApply,"ct-control--muted"):ContentEdit.addCSSClass(e._domApply,"ct-control--muted")}),d.mount(this._domAttributes),d},d.prototype._addDOMEventListeners=function(){var a,b;return d.__super__._addDOMEventListeners.call(this),a=function(a){return function(b){var c,d,e,f,g,h;for(f=["attributes","code","styles"],g=0,h=f.length;h>g;g++)d=f[g],d!==b&&(e=d.charAt(0).toUpperCase()+d.slice(1),ContentEdit.removeCSSClass(a._domElement,"ct-properties-dialog--"+d),ContentEdit.removeCSSClass(a["_dom"+e+"Tab"],"ct-control--active"));return c=b.charAt(0).toUpperCase()+b.slice(1),ContentEdit.addCSSClass(a._domElement,"ct-properties-dialog--"+b),ContentEdit.addCSSClass(a["_dom"+c+"Tab"],"ct-control--active"),window.localStorage.setItem("ct-properties-dialog-tab",b)}}(this),this._domStylesTab.addEventListener("mousedown",function(){return function(){return a("styles")}}(this)),this._domAttributesTab.addEventListener("mousedown",function(){return function(){return a("attributes")}}(this)),this._supportsCoding&&this._domCodeTab.addEventListener("mousedown",function(){return function(){return a("code")}}(this)),this._domRemoveAttribute.addEventListener("mousedown",function(a){return function(b){var c,d;return b.preventDefault(),a._focusedAttributeUI&&(c=a._attributeUIs.indexOf(a._focusedAttributeUI),d=c===a._attributeUIs.length-1,a._focusedAttributeUI.unmount(),a._attributeUIs.splice(c,1),d)?a._addAttributeUI("",""):void 0}}(this)),b=function(a){return function(){var b;try{return b=new HTMLString.String(a._domInnerHTML.value),ContentEdit.removeCSSClass(a._domInnerHTML,"ct-properties-dialog__inner-html--invalid"),ContentEdit.removeCSSClass(a._domApply,"ct-control--muted")}catch(c){return ContentEdit.addCSSClass(a._domInnerHTML,"ct-properties-dialog__inner-html--invalid"),ContentEdit.addCSSClass(a._domApply,"ct-control--muted")}}}(this),this._domInnerHTML.addEventListener("input",b),this._domInnerHTML.addEventListener("propertychange",b),this._domApply.addEventListener("click",function(a){return function(b){var c;return b.preventDefault(),c=a._domApply.getAttribute("class"),-1===c.indexOf("ct-control--muted")?a.save():void 0}}(this))},d}(ContentTools.DialogUI),c=function(a){function b(a,c){this.style=a,b.__super__.constructor.call(this),this._applied=c}return f(b,a),b.prototype.applied=function(a){if(void 0===a)return this._applied;if(this._applied!==a)return this._applied=a,this._applied?ContentEdit.addCSSClass(this._domElement,"ct-section--applied"):ContentEdit.removeCSSClass(this._domElement,"ct-section--applied")},b.prototype.mount=function(a,c){var d;return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-section"]),this._applied&&ContentEdit.addCSSClass(this._domElement,"ct-section--applied"),d=this.constructor.createDiv(["ct-section__label"]),d.textContent=this.style.name(),this._domElement.appendChild(d),this._domElement.appendChild(this.constructor.createDiv(["ct-section__switch"])),b.__super__.mount.call(this,a,c)},b.prototype._addDOMEventListeners=function(){var a;return a=function(a){return function(b){return b.preventDefault(),a.applied(a.applied()?!1:!0)}}(this),this._domElement.addEventListener("click",a)},b}(ContentTools.AnchoredComponentUI),a=function(a){function b(a,c){b.__super__.constructor.call(this),this._initialName=a,this._initialValue=c}return f(b,a),b.prototype.name=function(){return this._domName.value.trim()},b.prototype.value=function(){return this._domValue.value.trim()},b.prototype.mount=function(a,c){return null==c&&(c=null),this._domElement=this.constructor.createDiv(["ct-attribute"]),this._domName=document.createElement("input"),this._domName.setAttribute("class","ct-attribute__name"),this._domName.setAttribute("name","name"),this._domName.setAttribute("placeholder",ContentEdit._("Name")),this._domName.setAttribute("type","text"),this._domName.setAttribute("value",this._initialName),this._domElement.appendChild(this._domName),this._domValue=document.createElement("input"),this._domValue.setAttribute("class","ct-attribute__value"),this._domValue.setAttribute("name","value"),this._domValue.setAttribute("placeholder",ContentEdit._("Value")),this._domValue.setAttribute("type","text"),this._domValue.setAttribute("value",this._initialValue),this._domElement.appendChild(this._domValue),b.__super__.mount.call(this,a,c) +},b.prototype.valid=function(a){return a?ContentEdit.removeCSSClass(this._domName,"ct-attribute__name--invalid"):ContentEdit.addCSSClass(this._domName,"ct-attribute__name--invalid")},b.prototype._addDOMEventListeners=function(){return this._domName.addEventListener("blur",function(a){return function(){var b,c,d;return b=a.name(),c=a._domElement.nextSibling,a.dispatchEvent(a.createEvent("blur")),""===b&&c?(d=c.querySelector(".ct-attribute__name"),d.focus()):void 0}}(this)),this._domName.addEventListener("focus",function(a){return function(){return a.dispatchEvent(a.createEvent("focus"))}}(this)),this._domName.addEventListener("input",function(a){return function(){return a.dispatchEvent(a.createEvent("namechange"))}}(this)),this._domName.addEventListener("keydown",function(a){return function(b){return 13===b.keyCode?a._domValue.focus():void 0}}(this)),this._domValue.addEventListener("blur",function(a){return function(){return a.dispatchEvent(a.createEvent("blur"))}}(this)),this._domValue.addEventListener("focus",function(a){return function(){return a.dispatchEvent(a.createEvent("focus"))}}(this)),this._domValue.addEventListener("keydown",function(a){return function(b){var c,d;if(13===b.keyCode||9===b.keyCode&&!b.shiftKey)return b.preventDefault(),c=a._domElement.nextSibling,c||(a._domValue.blur(),c=a._domElement.nextSibling),c?(d=c.querySelector(".ct-attribute__name"),d.focus()):void 0}}(this))},b}(ContentTools.AnchoredComponentUI),ContentTools.TableDialog=function(a){function b(a){this.table=a,this.table?b.__super__.constructor.call(this,"Update table"):b.__super__.constructor.call(this,"Insert table")}return f(b,a),b.prototype.mount=function(){var a,c,d,e,f,g,h;return b.__super__.mount.call(this),a={columns:3,foot:!1,head:!0},this.table&&(a={columns:this.table.firstSection().children[0].children.length,foot:this.table.tfoot(),head:this.table.thead()}),ContentEdit.addCSSClass(this._domElement,"ct-table-dialog"),ContentEdit.addCSSClass(this._domView,"ct-table-dialog__view"),h=["ct-section"],a.head&&h.push("ct-section--applied"),this._domHeadSection=this.constructor.createDiv(h),this._domView.appendChild(this._domHeadSection),f=this.constructor.createDiv(["ct-section__label"]),f.textContent=ContentEdit._("Table head"),this._domHeadSection.appendChild(f),this._domHeadSwitch=this.constructor.createDiv(["ct-section__switch"]),this._domHeadSection.appendChild(this._domHeadSwitch),this._domBodySection=this.constructor.createDiv(["ct-section","ct-section--applied","ct-section--contains-input"]),this._domView.appendChild(this._domBodySection),c=this.constructor.createDiv(["ct-section__label"]),c.textContent=ContentEdit._("Table body (columns)"),this._domBodySection.appendChild(c),this._domBodyInput=document.createElement("input"),this._domBodyInput.setAttribute("class","ct-section__input"),this._domBodyInput.setAttribute("maxlength","2"),this._domBodyInput.setAttribute("name","columns"),this._domBodyInput.setAttribute("type","text"),this._domBodyInput.setAttribute("value",a.columns),this._domBodySection.appendChild(this._domBodyInput),g=["ct-section"],a.foot&&g.push("ct-section--applied"),this._domFootSection=this.constructor.createDiv(g),this._domView.appendChild(this._domFootSection),e=this.constructor.createDiv(["ct-section__label"]),e.textContent=ContentEdit._("Table foot"),this._domFootSection.appendChild(e),this._domFootSwitch=this.constructor.createDiv(["ct-section__switch"]),this._domFootSection.appendChild(this._domFootSwitch),d=this.constructor.createDiv(["ct-control-group","ct-control-group--right"]),this._domControls.appendChild(d),this._domApply=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--apply"]),this._domApply.textContent="Apply",d.appendChild(this._domApply),this._addDOMEventListeners()},b.prototype.save=function(){var a,b,c;return b=this._domFootSection.getAttribute("class"),c=this._domHeadSection.getAttribute("class"),a={columns:parseInt(this._domBodyInput.value),foot:b.indexOf("ct-section--applied")>-1,head:c.indexOf("ct-section--applied")>-1},this.dispatchEvent(this.createEvent("save",a))},b.prototype.unmount=function(){return b.__super__.unmount.call(this),this._domBodyInput=null,this._domBodySection=null,this._domApply=null,this._domHeadSection=null,this._domHeadSwitch=null,this._domFootSection=null,this._domFootSwitch=null},b.prototype._addDOMEventListeners=function(){var a;return b.__super__._addDOMEventListeners.call(this),a=function(a){return a.preventDefault(),this.getAttribute("class").indexOf("ct-section--applied")>-1?ContentEdit.removeCSSClass(this,"ct-section--applied"):ContentEdit.addCSSClass(this,"ct-section--applied")},this._domHeadSection.addEventListener("click",a),this._domFootSection.addEventListener("click",a),this._domBodySection.addEventListener("click",function(a){return function(){return a._domBodyInput.focus()}}(this)),this._domBodyInput.addEventListener("input",function(a){return function(b){var c;return c=/^[1-9]\d{0,1}$/.test(b.target.value),c?(ContentEdit.removeCSSClass(a._domBodyInput,"ct-section__input--invalid"),ContentEdit.removeCSSClass(a._domApply,"ct-control--muted")):(ContentEdit.addCSSClass(a._domBodyInput,"ct-section__input--invalid"),ContentEdit.addCSSClass(a._domApply,"ct-control--muted"))}}(this)),this._domApply.addEventListener("click",function(a){return function(b){var c;return b.preventDefault(),c=a._domApply.getAttribute("class"),-1===c.indexOf("ct-control--muted")?a.save():void 0}}(this))},b}(ContentTools.DialogUI),ContentTools.VideoDialog=function(a){function b(){b.__super__.constructor.call(this,"Insert video")}return f(b,a),b.prototype.clearPreview=function(){return this._domPreview?(this._domPreview.parentNode.removeChild(this._domPreview),this._domPreview=void 0):void 0},b.prototype.mount=function(){var a;return b.__super__.mount.call(this),ContentEdit.addCSSClass(this._domElement,"ct-video-dialog"),ContentEdit.addCSSClass(this._domView,"ct-video-dialog__preview"),a=this.constructor.createDiv(["ct-control-group"]),this._domControls.appendChild(a),this._domInput=document.createElement("input"),this._domInput.setAttribute("class","ct-video-dialog__input"),this._domInput.setAttribute("name","url"),this._domInput.setAttribute("placeholder",ContentEdit._("Paste YouTube or Vimeo URL")+"..."),this._domInput.setAttribute("type","text"),a.appendChild(this._domInput),this._domButton=this.constructor.createDiv(["ct-control","ct-control--text","ct-control--insert","ct-control--muted"]),this._domButton.textContent=ContentEdit._("Insert"),a.appendChild(this._domButton),this._addDOMEventListeners()},b.prototype.preview=function(a){return this.clearPreview(),this._domPreview=document.createElement("iframe"),this._domPreview.setAttribute("frameborder","0"),this._domPreview.setAttribute("height","100%"),this._domPreview.setAttribute("src",a),this._domPreview.setAttribute("width","100%"),this._domView.appendChild(this._domPreview)},b.prototype.save=function(){var a,b;return b=this._domInput.value.trim(),a=ContentTools.getEmbedVideoURL(b),this.dispatchEvent(a?this.createEvent("save",{url:a}):this.createEvent("save",{url:b}))},b.prototype.show=function(){return b.__super__.show.call(this),this._domInput.focus()},b.prototype.unmount=function(){return this.isMounted()&&this._domInput.blur(),b.__super__.unmount.call(this),this._domButton=null,this._domInput=null,this._domPreview=null},b.prototype._addDOMEventListeners=function(){return b.__super__._addDOMEventListeners.call(this),this._domInput.addEventListener("input",function(a){return function(b){var c;return b.target.value?ContentEdit.removeCSSClass(a._domButton,"ct-control--muted"):ContentEdit.addCSSClass(a._domButton,"ct-control--muted"),a._updatePreviewTimeout&&clearTimeout(a._updatePreviewTimeout),c=function(){var b,c;return c=a._domInput.value.trim(),b=ContentTools.getEmbedVideoURL(c),b?a.preview(b):a.clearPreview()},a._updatePreviewTimeout=setTimeout(c,500)}}(this)),this._domInput.addEventListener("keypress",function(a){return function(b){return 13===b.keyCode?a.save():void 0}}(this)),this._domButton.addEventListener("click",function(a){return function(b){var c;return b.preventDefault(),c=a._domButton.getAttribute("class"),-1===c.indexOf("ct-control--muted")?a.save():void 0}}(this))},b}(ContentTools.DialogUI),d=function(a){function b(){b.__super__.constructor.call(this),this.history=null,this._state="dormant",this._regions=null,this._orderedRegions=null,this._rootLastModified=null,this._regionsLastModified={},this._ignition=null,this._inspector=null,this._toolbox=null}return f(b,a),b.prototype.ctrlDown=function(){return this._ctrlDown},b.prototype.domRegions=function(){return this._domRegions},b.prototype.getState=function(){return this._state},b.prototype.ignition=function(){return this._ignition},b.prototype.inspector=function(){return this._inspector},b.prototype.isDormant=function(){return"dormant"===this._state},b.prototype.isReady=function(){return"ready"===this._state},b.prototype.isEditing=function(){return"editing"===this._state},b.prototype.orderedRegions=function(){var a;return function(){var b,c,d,e;for(d=this._orderedRegions,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this._regions[a]);return e}.call(this)},b.prototype.regions=function(){return this._regions},b.prototype.shiftDown=function(){return this._shiftDown},b.prototype.toolbox=function(){return this._toolbox},b.prototype.busy=function(a){return this._ignition.busy(a)},b.prototype.init=function(a,b){return null==b&&(b="id"),this._namingProp=b,this._domRegions=a.length>0&&a[0].nodeType===Node.ELEMENT_NODE?a:document.querySelectorAll(a),0!==this._domRegions.length?(this.mount(),this._ignition=new ContentTools.IgnitionUI,this.attach(this._ignition),this._domRegions.length&&(this._ignition.show(),this._ignition.addEventListener("edit",function(a){return function(b){return b.preventDefault(),a.start(),a._ignition.state("editing")}}(this)),this._ignition.addEventListener("confirm",function(a){return function(b){return b.preventDefault(),a._ignition.state("ready"),a.stop(!0)}}(this)),this._ignition.addEventListener("cancel",function(a){return function(b){return b.preventDefault(),a.stop(!1),a._ignition.state(a.isEditing()?"editing":"ready")}}(this))),this._toolbox=new ContentTools.ToolboxUI(ContentTools.DEFAULT_TOOLS),this.attach(this._toolbox),this._inspector=new ContentTools.InspectorUI,this.attach(this._inspector),this._state="ready",ContentEdit.Root.get().bind("detach",function(a){return function(){return a._preventEmptyRegions()}}(this)),ContentEdit.Root.get().bind("paste",function(a){return function(b,c){return a.paste(b,c.clipboardData)}}(this)),ContentEdit.Root.get().bind("next-region",function(a){return function(b){var c,d,e,f,g,h,i;if(f=a.orderedRegions(),e=f.indexOf(b),!(e>=f.length-1)){for(b=f[e+1],d=null,i=b.descendants(),g=0,h=i.length;h>g;g++)if(c=i[g],void 0!==c.content){d=c;break}return d?(d.focus(),void d.selection(new ContentSelect.Range(0,0))):ContentEdit.Root.get().trigger("next-region",b)}}}(this)),ContentEdit.Root.get().bind("previous-region",function(a){return function(b){var c,d,e,f,g,h,i,j;if(h=a.orderedRegions(),f=h.indexOf(b),!(0>=f)){for(b=h[f-1],e=null,d=b.descendants(),d.reverse(),i=0,j=d.length;j>i;i++)if(c=d[i],void 0!==c.content){e=c;break}return e?(g=e.content.length(),e.focus(),void e.selection(new ContentSelect.Range(g,g))):ContentEdit.Root.get().trigger("previous-region",b)}}}(this))):void 0},b.prototype.destroy=function(){return this.unmount()},b.prototype.highlightRegions=function(a){var b,c,d,e,f;for(e=this._domRegions,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(a?ContentEdit.addCSSClass(b,"ct--highlight"):ContentEdit.removeCSSClass(b,"ct--highlight"));return f},b.prototype.mount=function(){return this._domElement=this.constructor.createDiv(["ct-app"]),document.body.insertBefore(this._domElement,null),this._addDOMEventListeners()},b.prototype.paste=function(a,b){var c,d,e,f,g,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;if(d=b.getData("text/plain"),q=d.split("\n"),q=q.filter(function(a){return""!==a.trim()})){if(f=HTMLString.String.encode,w=a.type(),(q.length>1||!a.content)&&"PreText"!==w){for("ListItemText"===w?(k=a.parent(),j=a.parent().parent(),i=j.children.indexOf(k)+1):(k=a,"Region"!==k.parent().type()&&(k=a.closest(function(a){return"Region"===a.parent().type()})),j=k.parent(),i=j.children.indexOf(k)+1),g=x=0,y=q.length;y>x;g=++x)o=q[g],o=f(o),"ListItemText"===w?(l=new ContentEdit.ListItem,m=new ContentEdit.ListItemText(o),l.attach(m),n=m):(l=new ContentEdit.Text("p",{},o),n=l),j.attach(l,i+g);return p=n.content.length(),n.focus(),n.selection(new ContentSelect.Range(p,p))}return d=f(d),d=new HTMLString.String(d,"PreText"===w),s=a.selection(),e=s.get()[0]+d.length(),v=a.content.substring(0,s.get()[0]),u=a.content.substring(s.get()[1]),r=a.content.substring(s.get()[0],s.get()[1]),r.length()&&(c=r.characters[0],t=c.tags(),c.isTag()&&t.shift(),t.length>=1&&(d=d.format.apply(d,[0,d.length()].concat(h.call(t))))),a.content=v.concat(d),a.content=a.content.concat(u,!1),a.updateInnerHTML(),a.taint(),s.set(e,e),a.selection(s)}},b.prototype.unmount=function(){return this.isMounted()?(this._domElement.parentNode.removeChild(this._domElement),this._domElement=null,this._removeDOMEventListeners(),this._ignition=null,this._inspector=null,this._toolbox=null):void 0},b.prototype.revert=function(){var a;if(this.dispatchEvent(this.createEvent("revert")))return a=ContentEdit._("Your changes have not been saved, do you really want to lose them?"),ContentEdit.Root.get().lastModified()>this._rootLastModified&&!window.confirm(a)?!1:(this.revertToSnapshot(this.history.goTo(0),!1),!0)},b.prototype.revertToSnapshot=function(a,b){var c,d,e,f,g,h,i,j;null==b&&(b=!0),i=this._regions;for(e in i)f=i[e],f.domElement().innerHTML=a.regions[e];if(b){for(ContentEdit.Root.get().focused()&&ContentEdit.Root.get().focused().blur(),this._regions={},j=this._domRegions,d=g=0,h=j.length;h>g;d=++g)c=j[d],e=c.getAttribute(this._namingProp),e||(e=d),this._regions[e]=new ContentEdit.Region(c);return this.history.replaceRegions(this._regions),this.history.restoreSelection(a),this._inspector.updateTags()}},b.prototype.save=function(a){var b,c,d,e,f,g,h;if(this.dispatchEvent(this.createEvent("save",{passive:a}))){if(g=ContentEdit.Root.get(),g.lastModified()===this._rootLastModified&&a)return void this.dispatchEvent(this.createEvent("saved",{regions:{},passive:a}));d={},h=this._regions;for(e in h)f=h[e],c=f.html(),1===f.children.length&&(b=f.children[0],b.content&&!b.content.html()&&(c="")),a||(f.domElement().innerHTML=c),f.lastModified()!==this._regionsLastModified[e]&&(d[e]=c,this._regionsLastModified[e]=f.lastModified());return this.dispatchEvent(this.createEvent("saved",{regions:d,passive:a}))}},b.prototype.setRegionOrder=function(a){return this._orderedRegions=a.slice()},b.prototype.start=function(){var a,b,c,d,e,f;if(this.dispatchEvent(this.createEvent("start"))){for(this.busy(!0),this._regions={},this._orderedRegions=[],f=this._domRegions,b=d=0,e=f.length;e>d;b=++d)a=f[b],c=a.getAttribute(this._namingProp),c||(c=b),this._regions[c]=new ContentEdit.Region(a),this._orderedRegions.push(c),this._regionsLastModified[c]=this._regions[c].lastModified();return this._preventEmptyRegions(),this._rootLastModified=ContentEdit.Root.get().lastModified(),this.history=new ContentTools.History(this._regions),this.history.watch(),this._state="editing",this._toolbox.show(),this._inspector.show(),this.busy(!1)}},b.prototype.stop=function(a){var b;if(this.dispatchEvent(this.createEvent("stop",{save:a}))){if(b=ContentEdit.Root.get().focused(),b&&b.isMounted()&&void 0!==b._syncContent&&b._syncContent(),a)this.save();else if(!this.revert())return;ContentEdit.Root.get().focused()&&ContentEdit.Root.get().focused().blur(),this.history.stopWatching(),this.history=null,this._toolbox.hide(),this._inspector.hide(),this._regions={},this._state="ready"}},b.prototype._addDOMEventListeners=function(){return this._handleHighlightOn=function(a){return function(b){var c;if(17===(c=b.keyCode)||224===c)return void(a._ctrlDown=!0);if(16===b.keyCode){if(a._highlightTimeout)return;return a._shiftDown=!0,a._highlightTimeout=setTimeout(function(){return a.highlightRegions(!0)},ContentTools.HIGHLIGHT_HOLD_DURATION)}}}(this),this._handleHighlightOff=function(a){return function(b){var c;return 17===(c=b.keyCode)||224===c?void(a._ctrlDown=!1):16===b.keyCode?(a._shiftDown=!1,a._highlightTimeout&&(clearTimeout(a._highlightTimeout),a._highlightTimeout=null),a.highlightRegions(!1)):void 0}}(this),document.addEventListener("keydown",this._handleHighlightOn),document.addEventListener("keyup",this._handleHighlightOff),window.onbeforeunload=function(a){return function(){return"editing"===a._state?ContentEdit._(ContentTools.CANCEL_MESSAGE):void 0}}(this),window.addEventListener("unload",function(a){return function(){return a.destroy()}}(this))},b.prototype._preventEmptyRegions=function(){var a,b,c,d,e,f,g,h,i,j,k;i=this._regions,k=[];for(d in i){for(f=i[d],c=f.lastModified(),b=!1,j=f.children,g=0,h=j.length;h>g;g++)if(a=j[g],"Static"!==a.type()){b=!0;break}b||(e=new ContentEdit.Text("p",{},""),f.attach(e),k.push(f._modified=c))}return k},b.prototype._removeDOMEventListeners=function(){return document.removeEventListener("keydown",this._handleHighlightOn),document.removeEventListener("keyup",this._handleHighlightOff)},b}(ContentTools.ComponentUI),ContentTools.EditorApp=function(){function a(){}var b;return b=null,a.get=function(){var a;return a=ContentTools.EditorApp.getCls(),null!=b?b:b=new a},a.getCls=function(){return d},a}(),ContentTools.History=function(){function a(a){this._lastSnapshotTaken=null,this._regions={},this.replaceRegions(a),this._snapshotIndex=-1,this._snapshots=[],this._store()}return a.prototype.canRedo=function(){return this._snapshotIndex0},a.prototype.index=function(){return this._snapshotIndex},a.prototype.length=function(){return this._snapshots.length},a.prototype.snapshot=function(){return this._snapshots[this._snapshotIndex]},a.prototype.goTo=function(a){return this._snapshotIndex=Math.min(this._snapshots.length-1,Math.max(0,a)),this.snapshot()},a.prototype.redo=function(){return this.goTo(this._snapshotIndex+1)},a.prototype.replaceRegions=function(a){var b,c,d;this._regions={},d=[];for(b in a)c=a[b],d.push(this._regions[b]=c);return d},a.prototype.restoreSelection=function(a){var b,c;if(a.selected)return c=this._regions[a.selected.region],b=c.descendants()[a.selected.element],b.focus(),b.selection&&a.selected.selection?b.selection(a.selected.selection):void 0},a.prototype.stopWatching=function(){return this._watchInterval&&clearInterval(this._watchInterval),this._delayedStoreTimeout?clearTimeout(this._delayedStoreTimeout):void 0},a.prototype.undo=function(){return this.goTo(this._snapshotIndex-1)},a.prototype.watch=function(){var a;return this._lastSnapshotTaken=Date.now(),a=function(a){return function(){var b,c;if(c=ContentEdit.Root.get().lastModified(),null!==c&&c>a._lastSnapshotTaken){if(a._delayedStoreRequested===c)return;return a._delayedStoreTimeout&&clearTimeout(a._delayedStoreTimeout),b=function(){return a._lastSnapshotTaken=c,a._store()},a._delayedStoreRequested=c,a._delayedStoreTimeout=setTimeout(b,500)}}}(this),this._watchInterval=setInterval(a,50)},a.prototype._store=function(){var a,b,c,d,e,f,g;e={regions:{},selected:null},f=this._regions;for(b in f)d=f[b],e.regions[b]=d.html();if(a=ContentEdit.Root.get().focused()){if(e.selected={},d=a.closest(function(a){return"Region"===a.type()}),!d)return;g=this._regions;for(b in g)if(c=g[b],d===c){e.selected.region=b;break}e.selected.element=d.descendants().indexOf(a),a.selection&&(e.selected.selection=a.selection())}return this._snapshotIndexi;i++)if(d=n[i],d.hasTags("a"))for(o=d.tags(),j=0,l=o.length;l>j;j++)if(g=o[j],"a"===g.name())return g.attr(a);return""},b.canApply=function(a,b){var c;return"Image"===a.type()?!0:a.content&&b&&(!b.isCollapsed()||(c=a.content.characters[b.get()[0]],c&&c.hasTags("a")))?!0:!1},b.isApplied=function(a,c){return"Image"===a.type()?a.a:b.__super__.constructor.isApplied.call(this,a,c)},b.apply=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;if(f=!1,"Image"===a.type())n=a.domElement().getBoundingClientRect();else{if(b.isCollapsed()){for(g=a.content.characters,p=b.get(0)[0],j=p;p>0&&g[p-1].hasTags("a");)p-=1;for(;ji;i++)if(e=d[i],a.hasCSSClass(e)){a.removeCSSClass(e),a.a["class"]=e;break}}else{for(h=[],a.a["class"]&&(h=a.a["class"].split(" ")),j=0,n=d.length;n>j;j++)if(e=d[j],h.indexOf(e)>-1){a.addCSSClass(e);break}a.a=null}a.unmount(),a.mount()}else a.content=a.content.unformat(k,q,"a"),g.href&&(c=new HTMLString.Tag("a",g),a.content=a.content.format(k,q,c),a.content.optimize()),a.updateInnerHTML();return a.taint(),m.dispatchEvent(m.createEvent("click"))}),e.attach(m),e.attach(h),m.show(),h.show()},b}(ContentTools.Tools.Bold),ContentTools.Tools.Heading=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"heading"),b.label="Heading",b.icon="heading",b.tagName="h1",b.canApply=function(a){return void 0!==a.content&&-1!==["Text","PreText"].indexOf(a.type())},b.isApplied=function(a){return a.content?-1===["Text","PreText"].indexOf(a.type())?!1:a.tagName()===this.tagName:!1},b.apply=function(a,b,c){var d,e,f,g;return a.storeState(),"PreText"===a.type()?(d=a.content.html().replace(/ /g," "),g=new ContentEdit.Text(this.tagName,{},d),f=a.parent(),e=f.children.indexOf(a),f.detach(a),f.attach(g,e),a.blur(),g.focus(),g.selection(b)):(a.tagName(a.tagName()===this.tagName?"p":this.tagName),a.restoreState()),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.Subheading=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"subheading"),b.label="Subheading",b.icon="subheading",b.tagName="h2",b}(ContentTools.Tools.Heading),ContentTools.Tools.Paragraph=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"paragraph"),b.label="Paragraph",b.icon="paragraph",b.tagName="p",b.canApply=function(a){return void 0!==a},b.apply=function(a,c,d){var e,f,g,h;return e=ContentTools.EditorApp.get(),f=e.ctrlDown(),ContentTools.Tools.Heading.canApply(a)&&!f?b.__super__.constructor.apply.call(this,a,c,d):("Region"!==a.parent().type()&&(a=a.closest(function(a){return"Region"===a.parent().type()})),h=a.parent(),g=new ContentEdit.Text("p"),h.attach(g,h.children.indexOf(a)+1),g.focus(),d(!0))},b}(ContentTools.Tools.Heading),ContentTools.Tools.Preformatted=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"preformatted"),b.label="Preformatted",b.icon="preformatted",b.tagName="pre",b.apply=function(a,b,c){var d,e,f,g;return"PreText"===a.type()?void ContentTools.Tools.Paragraph.apply(a,b,c):(g=a.content.text(),f=new ContentEdit.PreText("pre",{},HTMLString.String.encode(g)),e=a.parent(),d=e.children.indexOf(a),e.detach(a),e.attach(f,d),a.blur(),f.focus(),f.selection(b),c(!0))},b}(ContentTools.Tools.Heading),ContentTools.Tools.AlignLeft=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"align-left"),b.label="Align left",b.icon="align-left",b.className="text-left",b.canApply=function(a){return void 0!==a.content},b.isApplied=function(a){var b;return this.canApply(a)?(("ListItemText"===(b=a.type())||"TableCellText"===b)&&(a=a.parent()),a.hasCSSClass(this.className)):!1},b.apply=function(a,b,c){var d,e,f,g,h;for(("ListItemText"===(h=a.type())||"TableCellText"===h)&&(a=a.parent()),d=[ContentTools.Tools.AlignLeft.className,ContentTools.Tools.AlignCenter.className,ContentTools.Tools.AlignRight.className],f=0,g=d.length;g>f;f++)if(e=d[f],a.hasCSSClass(e)&&(a.removeCSSClass(e),e===this.className))return c(!0);return a.addCSSClass(this.className),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.AlignCenter=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"align-center"),b.label="Align center",b.icon="align-center",b.className="text-center",b}(ContentTools.Tools.AlignLeft),ContentTools.Tools.AlignRight=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"align-right"),b.label="Align right",b.icon="align-right",b.className="text-right",b}(ContentTools.Tools.AlignLeft),ContentTools.Tools.UnorderedList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"unordered-list"),b.label="Bullet list",b.icon="unordered-list",b.listTag="ul",b.canApply=function(a){var b;return void 0!==a.content&&("Region"===(b=a.parent().type())||"ListItem"===b)},b.apply=function(a,b,c){var d,e,f,g,h;return"ListItem"===a.parent().type()?(a.storeState(),e=a.closest(function(a){return"List"===a.type()}),e.tagName(this.listTag),a.restoreState()):(g=new ContentEdit.ListItemText(a.content.copy()),f=new ContentEdit.ListItem,f.attach(g),e=new ContentEdit.List(this.listTag,{}),e.attach(f),h=a.parent(),d=h.children.indexOf(a),h.detach(a),h.attach(e,d),g.focus(),g.selection(b)),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.OrderedList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"ordered-list"),b.label="Numbers list",b.icon="ordered-list",b.listTag="ol",b}(ContentTools.Tools.UnorderedList),ContentTools.Tools.Table=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"table"),b.label="Table",b.icon="table",b.canApply=function(a){return void 0!==a},b.apply=function(a,b,c){var d,e,f,g;return a.storeState&&a.storeState(),d=ContentTools.EditorApp.get(),f=new ContentTools.ModalUI,g=a.closest(function(a){return a&&"Table"===a.type()}),e=new ContentTools.TableDialog(g),e.addEventListener("cancel",function(){return function(){return f.hide(),e.hide(),a.restoreState&&a.restoreState(),c(!1)}}(this)),e.addEventListener("save",function(b){return function(d){var h,i,j,k,l;return k=d.detail(),i=!0,g?(b._updateTable(k,g),i=a.closest(function(a){return a&&"Table"===a.type()})):(g=b._createTable(k),l=b._insertAt(a),j=l[0],h=l[1],j.parent().attach(g,h),i=!1),i?a.restoreState():g.firstSection().children[0].children[0].children[0].focus(),f.hide(),e.hide(),c(!0)}}(this)),d.attach(f),d.attach(e),f.show(),e.show()},b._adjustColumns=function(a,b){var c,d,e,f,g,h,i,j,k,l,m;for(l=a.children,m=[],j=0,k=l.length;k>j;j++)i=l[j],d=i.children[0].tagName(),f=i.children.length,g=b-f,m.push(0>g?function(){var a,b;for(b=[],h=a=g;0>=g?0>a:a>0;h=0>=g?++a:--a)c=i.children[i.children.length-1],b.push(i.detach(c));return b}():g>0?function(){var a,b;for(b=[],h=a=0;g>=0?g>a:a>g;h=g>=0?++a:--a)c=new ContentEdit.TableCell(d),i.attach(c),e=new ContentEdit.TableCellText(""),b.push(c.attach(e));return b}():void 0);return m},b._createTable=function(a){var b,c,d,e;return e=new ContentEdit.Table,a.head&&(d=this._createTableSection("thead","th",a.columns),e.attach(d)),b=this._createTableSection("tbody","td",a.columns),e.attach(b),a.foot&&(c=this._createTableSection("tfoot","td",a.columns),e.attach(c)),e},b._createTableSection=function(a,b,c){var d,e,f,g,h,i;for(h=new ContentEdit.TableSection(a),g=new ContentEdit.TableRow,h.attach(g),f=i=0;c>=0?c>i:i>c;f=c>=0?++i:--i)d=new ContentEdit.TableCell(b),g.attach(d),e=new ContentEdit.TableCellText(""),d.attach(e);return h},b._updateTable=function(a,b){var c,d,e,f,g,h,i;if(!a.head&&b.thead()&&b.detach(b.thead()),!a.foot&&b.tfoot()&&b.detach(b.tfoot()),c=b.firstSection().children[0].children.length,a.columns!==c)for(i=b.children,g=0,h=i.length;h>g;g++)f=i[g],this._adjustColumns(f,a.columns);return a.head&&!b.thead()&&(e=this._createTableSection("thead","th",a.columns),b.attach(e)),a.foot&&!b.tfoot()?(d=this._createTableSection("tfoot","td",a.columns),b.attach(d)):void 0},b}(ContentTools.Tool),ContentTools.Tools.Indent=function(a){function b(){return b.__super__.constructor.apply(this,arguments) +}return f(b,a),ContentTools.ToolShelf.stow(b,"indent"),b.label="Indent",b.icon="indent",b.canApply=function(a){return"ListItem"===a.parent().type()&&a.parent().parent().children.indexOf(a.parent())>0},b.apply=function(a,b,c){return a.parent().indent(),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.Unindent=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"unindent"),b.label="Unindent",b.icon="unindent",b.canApply=function(a){return"ListItem"===a.parent().type()},b.apply=function(a,b,c){return a.parent().unindent(),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.LineBreak=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"line-break"),b.label="Line break",b.icon="line-break",b.canApply=function(a){return a.content},b.apply=function(a,b,c){var d,e,f,g;return e=b.get()[0]+1,g=a.content.substring(0,b.get()[0]),f=a.content.substring(b.get()[1]),d=new HTMLString.String("
",a.content.preserveWhitespace()),a.content=g.concat(d,f),a.updateInnerHTML(),a.taint(),b.set(e,e),a.selection(b),c(!0)},b}(ContentTools.Tool),ContentTools.Tools.Image=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"image"),b.label="Image",b.icon="image",b.canApply=function(){return!0},b.apply=function(a,b,c){var d,e,f;return a.storeState&&a.storeState(),d=ContentTools.EditorApp.get(),f=new ContentTools.ModalUI,e=new ContentTools.ImageDialog,e.addEventListener("cancel",function(){return function(){return f.hide(),e.hide(),a.restoreState&&a.restoreState(),c(!1)}}(this)),e.addEventListener("save",function(b){return function(d){var g,h,i,j,k,l,m,n;return g=d.detail(),k=g.imageURL,j=g.imageSize,i=g.imageAttrs,i||(i={}),i.height=j[1],i.src=k,i.width=j[0],h=new ContentEdit.Image(i),n=b._insertAt(a),m=n[0],l=n[1],m.parent().attach(h,l),h.focus(),f.hide(),e.hide(),c(!0)}}(this)),d.attach(f),d.attach(e),f.show(),e.show()},b}(ContentTools.Tool),ContentTools.Tools.Video=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"video"),b.label="Video",b.icon="video",b.canApply=function(){return!0},b.apply=function(a,b,c){var d,e,f;return a.storeState&&a.storeState(),d=ContentTools.EditorApp.get(),f=new ContentTools.ModalUI,e=new ContentTools.VideoDialog,e.addEventListener("cancel",function(){return function(){return f.hide(),e.hide(),a.restoreState&&a.restoreState(),c(!1)}}(this)),e.addEventListener("save",function(b){return function(d){var g,h,i,j,k;return i=d.detail().url,i?(j=new ContentEdit.Video("iframe",{frameborder:0,height:ContentTools.DEFAULT_VIDEO_HEIGHT,src:i,width:ContentTools.DEFAULT_VIDEO_WIDTH}),k=b._insertAt(a),h=k[0],g=k[1],h.parent().attach(j,g),j.focus()):a.restoreState&&a.restoreState(),f.hide(),e.hide(),c(""!==i)}}(this)),d.attach(f),d.attach(e),f.show(),e.show()},b}(ContentTools.Tool),ContentTools.Tools.Undo=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"undo"),b.label="Undo",b.icon="undo",b.requiresElement=!1,b.canApply=function(){var a;return a=ContentTools.EditorApp.get(),a.history&&a.history.canUndo()},b.apply=function(){var a,b;return a=ContentTools.EditorApp.get(),a.history.stopWatching(),b=a.history.undo(),a.revertToSnapshot(b),a.history.watch()},b}(ContentTools.Tool),ContentTools.Tools.Redo=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"redo"),b.label="Redo",b.icon="redo",b.requiresElement=!1,b.canApply=function(){var a;return a=ContentTools.EditorApp.get(),a.history&&a.history.canRedo()},b.apply=function(){var a,b;return a=ContentTools.EditorApp.get(),a.history.stopWatching(),b=a.history.redo(),a.revertToSnapshot(b),a.history.watch()},b}(ContentTools.Tool),ContentTools.Tools.Remove=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return f(b,a),ContentTools.ToolShelf.stow(b,"remove"),b.label="Remove",b.icon="remove",b.canApply=function(){return!0},b.apply=function(a,b,c){var d,e,f,g;if(d=ContentTools.EditorApp.get(),a.blur(),a.nextContent()?a.nextContent().focus():a.previousContent()&&a.previousContent().focus(),!a.isMounted())return void c(!0);switch(a.type()){case"ListItemText":d.ctrlDown()?(e=a.closest(function(a){return"Region"===a.parent().type()}),e.parent().detach(e)):a.parent().parent().detach(a.parent());break;case"TableCellText":d.ctrlDown()?(g=a.closest(function(a){return"Table"===a.type()}),g.parent().detach(g)):(f=a.parent().parent(),f.parent().detach(f));break;default:a.parent().detach(a)}return c(!0)},b}(ContentTools.Tool)}.call(this); \ No newline at end of file diff --git a/external/scripts/content-edit.js b/external/scripts/content-edit.js index 99ab8e80..fc5cb32a 100644 --- a/external/scripts/content-edit.js +++ b/external/scripts/content-edit.js @@ -2173,7 +2173,7 @@ if (allowed === void 0) { return this._behaviours[behaviour]; } - return this._behaviours[name] = allowed; + return this._behaviours[behaviour] = allowed; }; Element.prototype.createDraggingDOMElement = function() { @@ -2199,6 +2199,9 @@ Element.prototype.drop = function(element, placement) { var root; + if (!this.can('drop')) { + return; + } root = ContentEdit.Root.get(); if (element) { element._removeCSSClass('ce-element--drop'); @@ -4036,6 +4039,7 @@ function ListItem(attributes) { ListItem.__super__.constructor.call(this, 'li', attributes); + this._behaviours['indent'] = true; } ListItem.prototype.cssTypeName = function() { @@ -4078,6 +4082,9 @@ ListItem.prototype.indent = function() { var sibling; + if (!this.can('indent')) { + return; + } if (this.parent().children.indexOf(this) === 0) { return; } @@ -4110,6 +4117,9 @@ ListItem.prototype.unindent = function() { var child, grandParent, i, itemIndex, list, parent, parentIndex, selection, sibling, siblings, text, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1; + if (!this.can('indent')) { + return; + } parent = this.parent(); grandParent = parent.parent(); siblings = parent.children.slice(parent.children.indexOf(this) + 1, parent.children.length); @@ -4266,6 +4276,13 @@ return ContentEdit.Element.prototype.blur.call(this); }; + ListItemText.prototype.can = function(behaviour, allowed) { + if (allowed) { + throw new Error('Cannot set behaviour for ListItemText'); + } + return this.parent().can(behaviour); + }; + ListItemText.prototype.html = function(indent) { var content; if (indent == null) { @@ -4831,6 +4848,13 @@ return ContentEdit.Element.prototype.blur.call(this); }; + TableCellText.prototype.can = function(behaviour, allowed) { + if (allowed) { + throw new Error('Cannot set behaviour for ListItemText'); + } + return this.parent().can(behaviour); + }; + TableCellText.prototype.html = function(indent) { var content; if (indent == null) { @@ -4875,33 +4899,35 @@ ev.preventDefault(); cell = this.parent(); row = cell.parent(); + if (!(row.isEmpty() && row.can('remove'))) { + return; + } if (this.content.length() === 0 && row.children.indexOf(cell) === 0) { - if (row.isEmpty() && this.can('remove')) { - previous = this.previousContent(); - if (previous) { - previous.focus(); - selection = new ContentSelect.Range(previous.content.length(), previous.content.length()); - selection.select(previous.domElement()); - } - return row.parent().detach(row); + previous = this.previousContent(); + if (previous) { + previous.focus(); + selection = new ContentSelect.Range(previous.content.length(), previous.content.length()); + selection.select(previous.domElement()); } + return row.parent().detach(row); } }; TableCellText.prototype._keyDelete = function(ev) { var lastChild, nextElement, row, selection; row = this.parent().parent(); - if (row.isEmpty() && this.can('remove')) { - ev.preventDefault(); - lastChild = row.children[row.children.length - 1]; - nextElement = lastChild.tableCellText().nextContent(); - if (nextElement) { - nextElement.focus(); - selection = new ContentSelect.Range(0, 0); - selection.select(nextElement.domElement()); - } - return row.parent().detach(row); + if (!(row.isEmpty() && row.can('remove'))) { + return; + } + ev.preventDefault(); + lastChild = row.children[row.children.length - 1]; + nextElement = lastChild.tableCellText().nextContent(); + if (nextElement) { + nextElement.focus(); + selection = new ContentSelect.Range(0, 0); + selection.select(nextElement.domElement()); } + return row.parent().detach(row); }; TableCellText.prototype._keyDown = function(ev) { @@ -5012,4 +5038,4 @@ })(ContentEdit.Text); -}).call(this); +}).call(this); \ No newline at end of file