/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.0.5 (2019-05-09) */ !function(x){"use strict";var tt=function(){for(var t=[],n=0;na[0]&&t[1] "+o.toString()},function(t,n){return"state("+t+")"})}).join("\n")+"}"},toDsl:function(){return _o.objOf(_(a,function(t){return t.fold(function(t,n,e,o){return Mo.field(t,e,o)},function(t,n){return Mo.state(t)})}))}}},Wo=function(r){return{extract:function(e,o,t){var n=_(t,function(t,n){return r.extract(e.concat(["["+n+"]"]),o,t)});return Do(n)},toString:function(){return"array("+r.toString()+")"},toDsl:function(){return _o.arrOf(r)}}},Go=function(a,c){return{extract:function(e,o,r){var t,n,i=Z(r),u=(t=e,n=i,Wo(Lo(a)).extract(t,d,n));return Co(u,function(t){var n=_(t,function(t){return Ho.field(t,t,lo(),c)});return Uo(n).extract(e,o,r)})},toString:function(){return"setOf("+c.toString()+")"},toDsl:function(){return _o.setOf(a,c)}}},Xo=nt(Lo(wo)),Yo=p(Wo,Uo),qo=Ho.state,Ko=Ho.field,Jo=function(e,n,o,r,i){return Et(r,i).fold(function(){return t=r,n=i,Ro(e,function(){return'The chosen schema: "'+n+'" did not exist in branches: '+Vo(t)});var t,n},function(t){return Uo(t).extract(e.concat(["branch: "+i]),n,o)})},$o=function(r,i){return{extract:function(n,e,o){return Et(o,r).fold(function(){return t=r,Ro(n,function(){return'Choice schema did not contain choice key: "'+t+'"'});var t},function(t){return Jo(n,e,o,i,t)})},toString:function(){return"chooseOn("+r+"). Possible values: "+Z(i)},toDsl:function(){return _o.choiceOf(r,i)}}},Qo=Lo(wo),Zo=function(t){return Yo(t)},tr=function(){return Wo(Qo)},nr=function(n){return Lo(function(t){return n(t).fold(ko,wo)})},er=function(n,t){return Go(function(t){return yo(n(t))},t)},or=function(t,n,e,o){var r=n.extract([t],e,o);return To(r,function(t){return{input:o,errors:t}})},rr=function(t,n,e){return xo(or(t,n,d,e))},ir=function(t){return t.fold(function(t){throw new Error(ar(t))},d)},ur=function(t,n,e){return ir(rr(t,n,e))},ar=function(t){return"Errors: \n"+(n=t.errors,e=10 ")+")\n"+t.getErrorInfo()}))+"\n\nInput object: "+Vo(t.input);var n,e},cr=function(t,n){return $o(t,n)},sr=nt(Qo),fr=function(e,o){return Lo(function(t){var n=typeof t;return e(t)?wo(t):ko("Expected type: "+o+" but got: "+n)})},lr=fr(D,"number"),dr=fr(k,"string"),mr=fr(O,"boolean"),gr=fr(E,"function"),pr=function(n){return nr(function(t){return T(n,t)?vt.value(t):vt.error('Unsupported value: "'+t+'", choose one of "'+n.join(", ")+'".')})},hr=function(t){return Ko(t,t,lo(),Xo())},vr=function(t,n){return Ko(t,t,lo(),n)},br=function(t){return vr(t,dr)},yr=function(t,n){return Ko(t,t,lo(),pr(n))},xr=function(t){return vr(t,gr)},wr=function(t,n){return Ko(t,t,lo(),Uo(n))},Sr=function(t,n){return Ko(t,t,lo(),Yo(n))},kr=function(t,n){return Ko(t,t,lo(),Wo(n))},Cr=function(t){return Ko(t,t,mo(),Xo())},Or=function(t,n){return Ko(t,t,mo(),n)},Er=function(t){return Or(t,lr)},Tr=function(t){return Or(t,dr)},Br=function(t){return Or(t,gr)},Ar=function(t,n){return Or(t,Uo(n))},Dr=function(t,n){return Ko(t,t,fo(n),Xo())},_r=function(t,n,e){return Ko(t,t,fo(n),e)},Mr=function(t,n){return _r(t,n,lr)},Fr=function(t,n){return _r(t,n,dr)},Ir=function(t,n,e){return _r(t,n,pr(e))},Vr=function(t,n){return _r(t,n,mr)},Rr=function(t,n){return _r(t,n,gr)},Hr=function(t,n,e){return _r(t,n,Uo(e))},Nr=function(t,n){return qo(t,n)},Pr=function(t,n){return he(t.element(),n.event().target())},zr=function(t){if(!Dt(t,"can")&&!Dt(t,"abort")&&!Dt(t,"run"))throw new Error("EventHandler defined by: "+Io(t,null,2)+" does not have can, abort, or run!");return ur("Extracting event.handler",jo([Dr("can",nt(!0)),Dr("abort",nt(!1)),Dr("run",tt)]),t)},Lr=function(e){var n,o,r,i,t=(n=e,o=function(t){return t.can},function(){for(var e=[],t=0;t "):o[0].name();return Tt(r,{handler:n,purpose:nt(e)})})});return At(n,{})},Ki=function(t){return rr("custom.definition",Uo([Ko("dom","dom",lo(),Uo([hr("tag"),Dr("styles",{}),Dr("classes",[]),Dr("attributes",{}),Cr("value"),Cr("innerHtml")])),hr("components"),hr("uid"),Dr("events",{}),Dr("apis",{}),Ko("eventOrder","eventOrder",(n={"alloy.execute":["disabling","alloy.base.behaviour","toggling","typeaheadevents"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing","item-events","tooltipping"],mousedown:["focusing","alloy.base.behaviour","item-type-events"],mouseover:["item-type-events","tooltipping"]},so.mergeWithThunk(nt(n))),sr()),Cr("domModification")]),t);var n},Ji=function(t,n){var e=Le(t,n);return e===undefined||""===e?[]:e.split(" ")},$i=function(t){return t.dom().classList!==undefined},Qi=function(t){return Ji(t,"class")},Zi=function(t,n){return r=n,i=Ji(e=t,o="class").concat([r]),ze(e,o,i.join(" ")),!0;var e,o,r,i},tu=function(t,n){return r=n,0<(i=V(Ji(e=t,o="class"),function(t){return t!==r})).length?ze(e,o,i.join(" ")):Ue(e,o),!1;var e,o,r,i},nu=function(t,n){$i(t)?t.dom().classList.add(n):Zi(t,n)},eu=function(t,n){var e;$i(t)?t.dom().classList.remove(n):tu(t,n),0===($i(e=t)?e.dom().classList:Qi(e)).length&&Ue(e,"class")},ou=function(t,n){return $i(t)&&t.dom().classList.contains(n)},ru=function(n,t){M(t,function(t){nu(n,t)})},iu=function(n,t){M(t,function(t){eu(n,t)})},uu=function(t){return t.style!==undefined},au=function(t,n,e){if(!k(e))throw x.console.error("Invalid call to CSS.set. Property ",n,":: Value ",e,":: Element ",t),new Error("CSS value must be a string: "+e);uu(t)&&t.style.setProperty(n,e)},cu=function(t,n){uu(t)&&t.style.removeProperty(n)},su=function(t,n,e){var o=t.dom();au(o,n,e)},fu=function(t,n){var e=t.dom();rt(n,function(t,n){au(e,n,t)})},lu=function(t,n){var e=t.dom();rt(n,function(t,n){t.fold(function(){cu(e,n)},function(t){au(e,n,t)})})},du=function(t,n){var e=t.dom(),o=x.window.getComputedStyle(e).getPropertyValue(n),r=""!==o||Jr(t)?o:mu(e,n);return null===r?undefined:r},mu=function(t,n){return uu(t)?t.style.getPropertyValue(n):""},gu=function(t,n){var e=t.dom(),o=mu(e,n);return et.from(o).filter(function(t){return 0"}),sr()),hf=Nr("schema",function(){return[Cr("preprocess")]}),vf=Dr("defaults",nt({})),yf=Dr("overrides",nt({})),xf=Uo([lf,mf,gf,pf,vf,yf]),wf=Uo([lf,mf,gf,vf,yf]),Sf=Uo([lf,mf,gf,pf,vf,yf]),kf=Uo([lf,hf,gf,hr("unit"),pf,vf,yf]),Cf=function(t){return t.fold(et.some,et.none,et.some,et.some)},Of=function(t){var n=function(t){return t.name};return t.fold(n,n,n,n)},Ef=function(e,o){return function(t){var n=ur("Converting part type",o,t);return e(n)}},Tf=Ef(ff.required,xf),Bf=Ef(ff.external,wf),Af=Ef(ff.optional,Sf),Df=Ef(ff.group,kf),_f=nt("entirety"),Mf=/* */Object.freeze({required:Tf,external:Bf,optional:Af,group:Df,asNamedPart:Cf,name:Of,asCommon:function(t){return t.fold(d,d,d,d)},original:_f}),Ff=function(t,n,e,o){return wt(n.defaults(t,e,o),e,{uid:t.partUids[n.name]},n.overrides(t,e,o))},If=function(r,t){var n={};return M(t,function(t){Cf(t).each(function(e){var o=Vf(r,e.pname);n[e.name]=function(t){var n=ur("Part: "+e.name+" in "+r,Uo(e.schema),t);return io({},o,{config:t,validated:n})}})}),n},Vf=function(t,n){return{uiType:sf(),owner:t,name:n}},Rf=function(t,n,e){return{uiType:sf(),owner:t,name:n,config:e,validated:{}}},Hf=function(t){return j(t,function(t){return t.fold(et.none,et.some,et.none,et.none).map(function(t){return wr(t.name,t.schema.concat([Ku(_f())]))}).toArray()})},Nf=function(t){return _(t,Of)},Pf=function(t,n,e){return o=n,i={},r={},M(e,function(t){t.fold(function(o){i[o.pname]=uf(!0,function(t,n,e){return o.factory.sketch(Ff(t,o,n,e))})},function(t){var n=o.parts[t.name];r[t.name]=nt(t.factory.sketch(Ff(o,t,n[_f()]),n))},function(o){i[o.pname]=uf(!1,function(t,n,e){return o.factory.sketch(Ff(t,o,n,e))})},function(r){i[r.pname]=cf(!0,function(n,t,e){var o=n[r.name];return _(o,function(t){return r.factory.sketch(wt(r.defaults(n,t,e),t,r.overrides(n,t)))})})})}),{internals:nt(i),externals:nt(r)};var o,i,r},zf=function(t,n,e){return rf(et.some(t),n,n.components,e)},Lf=function(t,n,e){var o=n.partUids[e];return t.getSystem().getByUid(o).toOption()},jf=function(t,n,e){return Lf(t,n,e).getOrDie("Could not find part: "+e)},Uf=function(t,n,e){var o={},r=n.partUids,i=t.getSystem();return M(e,function(t){o[t]=i.getByUid(r[t])}),it(o,nt)},Wf=function(t,n){var e=t.getSystem();return it(n.partUids,function(t,n){return nt(e.getByUid(t))})},Gf=function(t){return Z(t.partUids)},Xf=function(t,n,e){var o={},r=n.partUids,i=t.getSystem();return M(e,function(t){o[t]=i.getByUid(r[t]).getOrDie()}),it(o,nt)},Yf=function(n,t){var e=Nf(t);return Bt(_(e,function(t){return{key:t,value:n+"-"+t}}))},qf=function(n){return Ko("partUids","partUids",po(function(t){return Yf(t.uid,n)}),sr())},Kf=/* */Object.freeze({generate:If,generateOne:Rf,schemas:Hf,names:Nf,substitutes:Pf,components:zf,defaultUids:Yf,defaultUidsSchema:qf,getAllParts:Wf,getAllPartNames:Gf,getPart:Lf,getPartOrDie:jf,getParts:Uf,getPartsOrDie:Xf}),Jf=function(t,n,e,o,r){var i,u,a=(u=r,(0<(i=o).length?[wr("parts",i)]:[]).concat([hr("uid"),Dr("dom",{}),Dr("components",[]),Ku("originalSpec"),Dr("debug.sketcher",{})]).concat(u));return ur(t+" [SpecSchema]",jo(a.concat(n)),e)},$f=function(t,n,e,o,r){var i=Qf(r),u=Hf(e),a=qf(e),c=Jf(t,n,i,u,[a]),s=Pf(0,c,e);return o(c,zf(t,c,s.internals()),i,s.externals())},Qf=function(t){return t.hasOwnProperty("uid")?t:io({},t,{uid:Bi("uid")})};function Zf(t){return t.uid!==undefined}var tl,nl,el=jo([hr("name"),hr("factory"),hr("configFields"),Dr("apis",{}),Dr("extraApis",{})]),ol=jo([hr("name"),hr("factory"),hr("configFields"),hr("partFields"),Dr("apis",{}),Dr("extraApis",{})]),rl=function(t){var i=ur("Sketcher for "+t.name,el,t),n=it(i.apis,Hi),e=it(i.extraApis,function(t,n){return Fi(t,n)});return io({name:nt(i.name),partFields:nt([]),configFields:nt(i.configFields),sketch:function(t){return n=i.name,e=i.configFields,o=i.factory,r=Qf(t),o(Jf(n,e,r,[],[]),r);var n,e,o,r}},n,e)},il=function(t){var n=ur("Sketcher for "+t.name,ol,t),e=If(n.name,n.partFields),o=it(n.apis,Hi),r=it(n.extraApis,function(t,n){return Fi(t,n)});return io({name:nt(n.name),partFields:nt(n.partFields),configFields:nt(n.configFields),sketch:function(t){return $f(n.name,n.configFields,n.partFields,n.factory,t)},parts:nt(e)},o,r)},ul=function(t){return"input"===Fe(t)&&"radio"!==Le(t,"type")||"textarea"===Fe(t)},al=/* */Object.freeze({getCurrent:function(t,n,e){return n.find(t)}}),cl=[hr("find")],sl=ra({fields:cl,name:"composing",apis:al}),fl=function(t,n,e,o){var r=t+n;return o=t.minChars&&t.matches.getOr(Vg)(e.range,a,e.text)});return{lookupData:Ig.all(_(t,function(n){return n.fetch(e.text,n.maxResults).then(function(t){return{items:t,columns:n.columns,onAction:n.onAction}})})),triggerChar:e.triggerChar,range:e.range}})},Hg=Uo([Nr("type",function(){return"autocompleteitem"}),Nr("active",function(){return!1}),Nr("disabled",function(){return!1}),Dr("meta",{}),br("value"),Tr("text"),Tr("icon")]),Ng=Uo([br("type"),br("ch"),Mr("minChars",1),Dr("columns",1),Mr("maxResults",10),Br("matches"),xr("fetch"),xr("onAction")]),Pg=function(t){var n,e,o=t.ui.registry.getAll().popups,r=it(o,function(t){return(n=t,rr("Autocompleter",Ng,n)).fold(function(t){throw new Error(ar(t))},function(t){return t});var n}),i=(n=at(r,function(t){return t.ch}),e={},M(n,function(t){e[t]={}}),Z(e)),u=st(r);return{dataset:r,triggerChars:i,lookupByChar:function(n){return V(u,function(t){return t.ch===n})}}},zg=[Vr("disabled",!1),Tr("text"),Tr("shortcut"),Ko("value","value",go(function(){return oo("menuitem-value")}),sr()),Dr("meta",{})],Lg=Uo([br("type"),Rr("onSetup",function(){return tt}),Rr("onAction",tt),Tr("icon")].concat(zg)),jg=Uo([br("type"),xr("getSubmenuItems"),Rr("onSetup",function(){return tt}),Tr("icon")].concat(zg)),Ug=Uo([br("type"),Vr("active",!1),Rr("onSetup",function(){return tt}),xr("onAction")].concat(zg)),Wg=Uo([br("type"),Vr("active",!1),Tr("icon")].concat(zg)),Gg=Uo([br("type"),Tr("text")]),Xg=Uo([br("type"),yr("fancytype",["inserttable","colorswatch"]),Rr("onAction",tt)]),Yg=function(t,o,n){var r=Gc(t.element(),"."+n);if(0o}).getOr(r.length);return et.some({numColumns:e,numRows:Math.ceil(r.length/e)})}return et.none()},qg=function(t,n){return ea([og(t,n)])},Kg=function(t){return qg(oo("unnamed-events"),t)},Jg=[hr("lazySink"),hr("tooltipDom"),Dr("exclusive",!0),Dr("tooltipComponents",[]),Dr("delay",300),Ir("mode","normal",["normal","follow-highlight"]),Dr("anchor",function(t){return{anchor:"hotspot",hotspot:t,layouts:{onLtr:nt([wc,xc,hc,bc,vc,yc]),onRtl:nt([wc,xc,hc,bc,vc,yc])}}}),Wu("onHide"),Wu("onShow")],$g=/* */Object.freeze({init:function(){var e=_t(et.none()),n=_t(et.none()),o=function(){e.get().each(function(t){x.clearTimeout(t)})},t=nt("not-implemented");return Pi({getTooltip:function(){return n.get()},isShowing:function(){return n.get().isSome()},setTooltip:function(t){n.set(et.some(t))},clearTooltip:function(){n.set(et.none())},clearTimer:o,resetTimer:function(t,n){o(),e.set(et.some(x.setTimeout(function(){t()},n)))},readState:t})}}),Qg=oo("tooltip.exclusive"),Zg=oo("tooltip.show"),tp=oo("tooltip.hide"),np=function(t,n,e){t.getSystem().broadcastOn([Qg],{})},ep=/* */Object.freeze({hideAllExclusive:np,setComponents:function(t,n,e,o){e.getTooltip().each(function(t){t.getSystem().isConnected()&&xm.set(t,o)})}}),op=ra({fields:Jg,name:"tooltipping",active:/* */Object.freeze({events:function(o,r){var e=function(n){r.getTooltip().each(function(t){Ds(t),o.onHide(n,t),r.clearTooltip()}),r.clearTimer()};return oi(L([[ai(Zg,function(t){r.resetTimer(function(){!function(n){if(!r.isShowing()){np(n);var t=o.lazySink(n).getOrDie(),e=n.getSystem().build({dom:o.tooltipDom,components:o.tooltipComponents,events:oi("normal"===o.mode?[ai(Wt(),function(t){jr(n,Zg)}),ai(jt(),function(t){jr(n,tp)})]:[]),behaviours:ea([xm.config({})])});r.setTooltip(e),Ts(t,e),o.onShow(n,e),Cs.position(t,o.anchor(n),e)}}(t)},o.delay)}),ai(tp,function(t){r.resetTimer(function(){e(t)},o.delay)}),ai(Mn(),function(t,n){T(n.channels(),Qg)&&e(t)}),vi(function(t){e(t)})],"normal"===o.mode?[ai(Gt(),function(t){jr(t,Zg)}),ai(Dn(),function(t){jr(t,tp)}),ai(Wt(),function(t){jr(t,Zg)}),ai(jt(),function(t){jr(t,tp)})]:[ai(Jn(),function(t,n){jr(t,Zg)}),ai($n(),function(t){jr(t,tp)})]]))}}),state:$g,apis:ep}),rp=function(t){var n,e,o,r=Zn.fromHtml(t),i=we(r),u=(e=(n=r).dom().attributes!==undefined?n.dom().attributes:[],U(e,function(t,n){var e;return"class"===n.name?t:io({},t,((e={})[n.name]=n.value,e))},{})),a=(o=r,Array.prototype.slice.call(o.dom().classList,0)),c=0===i.length?{}:{innerHtml:_e(r)};return io({tag:Fe(r),classes:a,attributes:u},c)},ip=tinymce.util.Tools.resolve("tinymce.util.I18n"),up="tox-menu-nav__js",ap="tox-collection__item",cp="tox-swatch",sp={normal:up,color:cp},fp="tox-collection__item--enabled",lp="tox-collection__item-icon",dp="tox-collection__item-label",mp="tox-collection__item--active",gp=function(t){return Et(sp,t).getOr(up)},pp=tinymce.util.Tools.resolve("tinymce.Env"),hp=function(t){var e=pp.mac?{alt:"⌥",ctrl:"⌃",shift:"⇧",meta:"⌘",access:"⌃⌥"}:{meta:"Ctrl",access:"Shift+Alt"},n=t.split("+"),o=_(n,function(t){var n=t.toLowerCase().trim();return lt(e,n)?e[n]:t});return pp.mac?o.join(""):o.join("+")},vp=function(t){return{dom:{tag:"div",classes:[lp],innerHtml:t}}},bp=function(t){return{dom:{tag:"div",classes:[dp]},components:[Eu(ip.translate(t))]}},yp=function(t,n){return{dom:{tag:"div",classes:[dp]},components:[{dom:{tag:t.tag,attributes:{style:t.styleAttr}},components:[Eu(ip.translate(n))]}]}},xp=function(t){return{dom:{tag:"div",classes:["tox-collection__item-accessory"],innerHtml:hp(t)}}},wp=function(t){return{dom:{tag:"div",classes:[lp,"tox-collection__item-checkmark"],innerHtml:kg("checkmark",t)}}},Sp=["list-num-default","list-num-lower-alpha","list-num-lower-greek","list-num-lower-roman","list-num-upper-alpha","list-num-upper-roman"],kp=["list-bull-circle","list-bull-default","list-bull-square"],Cp=function(t,r,n,i){void 0===i&&(i=et.none());var e,o,u,a,c,s,f,l,d,m,g,p,h,v=ip.isRtl()&&t.iconContent.exists(function(t){return T(kp,t)}),b=(e=t.iconContent,e.map(function(t){return ip.isRtl()&&T(Sp,t)?t+"-rtl":t})).map(function(t){return n=t,e=r.icons,o=i,et.from(e()[n]).or(o).getOrThunk(function(){return Sg(e)});var n,e,o}),y=et.from(t.meta).fold(function(){return bp},function(t){return lt(t,"style")?w(yp,t.style):bp});return"color"===t.presets?(l=t.ariaLabel,d=t.value,m=r,{dom:(g=cp,p=b.getOr(""),h=l.map(function(t){return' title="'+m.translate(t)+'"'}).getOr(""),rp("custom"===d?'":"remove"===d?'
"+p+"
":'
")),optComponents:[]}):(o=t,u=b,a=y,c=v,s=n?o.checkMark.orThunk(function(){return u.or(et.some("")).map(vp)}):et.none(),f=o.ariaLabel.map(function(t){return{attributes:{title:ip.translate(t)}}}).getOr({}),{dom:St({tag:"div",classes:[up,ap].concat(c?["tox-collection__item-icon-rtl"]:[])},f),optComponents:[s,o.textContent.map(a),o.shortcutContent.map(xp),o.caret]})},Op=["input","button","textarea"],Ep=function(t,n,e){n.disabled&&Mp(t,n,e)},Tp=function(t){return T(Op,Fe(t.element()))},Bp=function(t){ze(t.element(),"disabled","disabled")},Ap=function(t){Ue(t.element(),"disabled")},Dp=function(t){ze(t.element(),"aria-disabled","true")},_p=function(t){ze(t.element(),"aria-disabled","false")},Mp=function(n,t,e){t.disableClass.each(function(t){nu(n.element(),t)}),(Tp(n)?Bp:Dp)(n)},Fp=function(n,t,e){t.disableClass.each(function(t){eu(n.element(),t)}),(Tp(n)?Ap:_p)(n)},Ip=function(t){return Tp(t)?je(t.element(),"disabled"):"true"===Le(t.element(),"aria-disabled")},Vp=/* */Object.freeze({enable:Fp,disable:Mp,isDisabled:Ip,onLoad:Ep,set:function(t,n,e,o){(o?Mp:Fp)(t,n,e)}}),Rp=/* */Object.freeze({exhibit:function(t,n,e){return Li({classes:n.disabled?n.disableClass.map(q).getOr([]):[]})},events:function(t,n){return oi([ri(Fn(),function(t,n){return Ip(t)}),$u(t,n,Ep)])}}),Hp=[Dr("disabled",!1),Cr("disableClass")],Np=ra({fields:Hp,name:"disabling",active:Rp,apis:Vp}),Pp=function(t){return Np.config({disabled:t,disableClass:"tox-collection__item--state-disabled"})},zp=function(t){return Np.config({disabled:t})},Lp=function(t){return Np.config({disabled:t,disableClass:"tox-tbtn--disabled"})},jp=function(t,n){var e=t.getApi(n);return function(t){t(e)}},Up=function(e,o){return hi(function(t){jp(e,t)(function(t){var n=e.onSetup(t);null!==n&&n!==undefined&&o.set(n)})})},Wp=function(n,e){return vi(function(t){return jp(n,t)(e.get())})};(Ag=Bg||(Bg={}))[Ag.CLOSE_ON_EXECUTE=0]="CLOSE_ON_EXECUTE",Ag[Ag.BUBBLE_TO_SANDBOX=1]="BUBBLE_TO_SANDBOX";var Gp,Xp,Yp=Bg,qp={"alloy.execute":["disabling","alloy.base.behaviour","toggling","item-events"]},Kp=function(t){return j(t,function(t){return t.toArray()})},Jp=function(t,n,e){var o,r,i=_t(tt);return{type:"item",dom:n.dom,components:Kp(n.optComponents),data:t.data,eventOrder:qp,hasSubmenu:t.triggersSubmenu,itemBehaviours:ea([og("item-events",[(o=t,r=e,yi(function(t,n){jp(o,t)(o.onAction),o.triggersSubmenu||r!==Yp.CLOSE_ON_EXECUTE||(jr(t,Nn()),n.stop())})),Up(t,i),Wp(t,i)]),Pp(t.disabled),xm.config({})].concat(t.itemBehaviours))}},$p=function(t){return{value:t.value,meta:St({text:t.text.getOr("")},t.meta)}},Qp=nt(If("item-widget",ug())),Zp=oo("cell-over"),th=oo("cell-execute"),nh=function(n,e,t){var o,r=function(t){return Ur(t,th,{row:n,col:e})};return Au({dom:{tag:"div",attributes:(o={role:"button"},o["aria-labelledby"]=t,o)},behaviours:ea([og("insert-table-picker-cell",[ai(Wt(),Nm.focus),ai(Fn(),r),ai(Rn(),r)]),Jm.config({toggleClass:"tox-insert-table-picker__selected",toggleOnExecute:!1}),Nm.config({onFocus:function(t){return Ur(t,Zp,{row:n,col:e})}})])})},eh=function(t){return{value:nt(t)}},oh=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,rh=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,ih=function(t){return oh.test(t)||rh.test(t)},uh=function(t){var n,e=(n=t.value().replace(oh,function(t,n,e,o){return n+n+e+e+o+o}),{value:nt(n)}),o=rh.exec(e.value());return null===o?["FFFFFF","FF","FF","FF"]:o},ah=function(t){var n=t.toString(16);return 1===n.length?"0"+n:n},ch=function(t){var n=ah(t.red())+ah(t.green())+ah(t.blue());return eh(n)},sh=Math.min,fh=Math.max,lh=Math.round,dh=/^rgb\((\d+),\s*(\d+),\s*(\d+)\)/,mh=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d?(?:\.\d+)?)\)/,gh=function(t,n,e,o){return{red:nt(t),green:nt(n),blue:nt(e),alpha:nt(o)}},ph=function(t){var n=parseInt(t,10);return n.toString()===t&&0<=n&&n<=255},hh=function(t){var n,e,o,r=(t.hue()||0)%360,i=t.saturation()/100,u=t.value()/100;if(i=fh(0,sh(i,1)),u=fh(0,sh(u,1)),0===i)return n=e=o=lh(255*u),gh(n,e,o,1);var a=r/60,c=u*i,s=c*(1-Math.abs(a%2-1)),f=u-c;switch(Math.floor(a)){case 0:n=c,e=s,o=0;break;case 1:n=s,e=c,o=0;break;case 2:n=0,e=c,o=s;break;case 3:n=0,e=s,o=c;break;case 4:n=s,e=0,o=c;break;case 5:n=c,e=0,o=s;break;default:n=e=o=0}return n=lh(255*(n+f)),e=lh(255*(e+f)),o=lh(255*(o+f)),gh(n,e,o,1)},vh=function(t){var n=uh(t),e=parseInt(n[1],16),o=parseInt(n[2],16),r=parseInt(n[3],16);return gh(e,o,r,1)},bh=function(t,n,e,o){var r=parseInt(t,10),i=parseInt(n,10),u=parseInt(e,10),a=parseFloat(o);return gh(r,i,u,a)},yh=function(t){return"rgba("+t.red()+","+t.green()+","+t.blue()+","+t.alpha()+")"},xh=nt(gh(255,0,0,1)),wh=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),Sh="tinymce-custom-colors",kh="choiceitem",Ch=[{type:kh,text:"Turquoise",value:"#18BC9B"},{type:kh,text:"Green",value:"#2FCC71"},{type:kh,text:"Blue",value:"#3598DB"},{type:kh,text:"Purple",value:"#9B59B6"},{type:kh,text:"Navy Blue",value:"#34495E"},{type:kh,text:"Dark Turquoise",value:"#18A085"},{type:kh,text:"Dark Green",value:"#27AE60"},{type:kh,text:"Medium Blue",value:"#2880B9"},{type:kh,text:"Medium Purple",value:"#8E44AD"},{type:kh,text:"Midnight Blue",value:"#2B3E50"},{type:kh,text:"Yellow",value:"#F1C40F"},{type:kh,text:"Orange",value:"#E67E23"},{type:kh,text:"Red",value:"#E74C3C"},{type:kh,text:"Light Gray",value:"#ECF0F1"},{type:kh,text:"Gray",value:"#95A5A6"},{type:kh,text:"Dark Yellow",value:"#F29D12"},{type:kh,text:"Dark Orange",value:"#D35400"},{type:kh,text:"Dark Red",value:"#C0392B"},{type:kh,text:"Medium Gray",value:"#BDC3C7"},{type:kh,text:"Dark Gray",value:"#7E8C8D"},{type:kh,text:"Black",value:"#000000"},{type:kh,text:"White",value:"#ffffff"}],Oh=function QD(n){void 0===n&&(n=10);var t,e=wh.getItem(Sh),o=k(e)?JSON.parse(e):[],r=n-(t=o).length<0?t.slice(0,n):t,i=function(t){r.splice(t,1)};return{add:function(t){b(r,t).each(i),r.unshift(t),r.length>n&&r.pop(),wh.setItem(Sh,JSON.stringify(r))},state:function(){return r.slice(0)}}}(10),Eh=function(t){var n,e=[];for(n=0;n=r.minChars){var o=sl.getCurrent(e).bind(function(t){return Sl.getHighlighted(t).map(Fm.getValue)});r.previewing.set(!0),Eb(r,u(t),t,e,i,function(t){sl.getCurrent(e).each(function(t){o.fold(function(){r.model.selectsOver&&Sl.highlightFirst(t)},function(n){Sl.highlightBy(t,function(t){return Fm.getValue(t).value===n.value}),Sl.getHighlighted(t).orThunk(function(){return Sl.highlightFirst(t),et.none()})})})},qv.HighlightFirst).get(tt)}},cancelEvent:Pn()}),pm.config({mode:"special",onDown:function(t,n){return e(t,n,Sl.highlightFirst),et.some(!0)},onEscape:function(t){var n=mb.getCoupled(t,"sandbox");return Us.isOpen(n)?(Us.close(n),et.some(!0)):et.none()},onUp:function(t,n){return e(t,n,Sl.highlightLast),et.some(!0)},onEnter:function(n){var t=mb.getCoupled(n,"sandbox"),e=Us.isOpen(t);if(e&&!r.previewing.get())return sl.getCurrent(t).bind(function(t){return Sl.getHighlighted(t)}).map(function(t){return Ur(n,Pb(),{item:t}),!0});var o=Fm.getValue(n);return jr(n,Pn()),r.onExecute(t,n,o),e&&Us.close(t),et.some(!0)}}),Jm.config({toggleClass:r.markers.openClass,aria:{mode:"expanded"}}),mb.config({others:{sandbox:function(t){return _b(r,t,{onOpen:function(){return Jm.on(t)},onClose:function(){return Jm.off(t)}})}}}),og("typeaheadevents",[yi(function(t){var n=tt;Bb(r,u(t),t,i,n,qv.HighlightFirst).get(tt)}),ai(Pb(),function(t,n){var e=mb.getCoupled(t,"sandbox");Mb(r.model,t,n.event().item()),jr(t,Pn()),r.onItemExecute(t,e,n.event().item(),Fm.getValue(t)),Us.close(e),Ib(t)})].concat(r.dismissOnBlur?[ai(Dn(),function(t){var n=mb.getCoupled(t,"sandbox");Rl(n.element()).isNone()&&Us.close(n)})]:[]))];return{uid:r.uid,dom:Nb(wt(r,{inputAttributes:{role:"combobox","aria-autocomplete":"list","aria-haspopup":"true"}})),behaviours:io({},o,$s(r.typeaheadBehaviours,a)),eventOrder:r.eventOrder}}}),Wb=function(t,n,e){var o=Xb(t,n,e);return fb.sketch(o)},Gb=function(t,n){return Wb(t,n,[])},Xb=function(t,n,e){return{dom:Yb(e),components:t.toArray().concat([n])}},Yb=function(t){return{tag:"div",classes:["tox-form__group"].concat(t)}},qb=function(t,n){return fb.parts().label({dom:{tag:"label",classes:["tox-label"],innerHtml:n.translate(t)}})},Kb=function(t){return"separator"===t.type},Jb={type:"separator"},$b=function(t,e){var n=U(t,function(t,n){return k(n)?""===n?t:"|"===n?0"},pw=function(o,t,n){return{uid:o.uid,dom:o.dom,components:t,behaviours:$s(o.formBehaviours,[Fm.config({store:{mode:"manual",getValue:function(t){var n=Wf(t,o);return it(n,function(t,n){return t().bind(function(t){var n,e=sl.getCurrent(t);return n="missing current",e.fold(function(){return vt.error(n)},vt.value)}).map(Fm.getValue)})},setValue:function(e,t){rt(t,function(n,t){Lf(e,o,t).each(function(t){sl.getCurrent(t).each(function(t){Fm.setValue(t,n)})})})}}})]),apis:{getField:function(t,n){return Lf(t,o,n).bind(sl.getCurrent)}}}},hw={getField:Hi(function(t,n,e){return t.getField(n,e)}),sketch:function(t){var e,n=(e=[],{field:function(t,n){return e.push(t),Rf("form",gw(t),n)},record:function(){return e}}),o=t(n),r=n.record(),i=_(r,function(t){return Tf({name:t,pname:gw(t)})});return $f("form",mw,i,pw,o)}},vw=oo("valid-input"),bw=oo("invalid-input"),yw=oo("validating-input"),xw="colorcustom.rgb.",ww=function(d,m,g,p){var h=function(t,n,e,o,r){var i,u,a=d(xw+"range"),c=[fb.parts().label({dom:{tag:"label",innerHtml:e,attributes:{"aria-label":o}}}),fb.parts().field({data:r,factory:ny,inputAttributes:io({type:"text"},"hex"===n?{"aria-live":"polite"}:{}),inputClasses:[m("textfield")],inputBehaviours:ea([(i=n,u=t,ly.config({invalidClass:m("invalid"),notify:{onValidate:function(t){Ur(t,yw,{type:i})},onValid:function(t){Ur(t,vw,{type:i,value:Fm.getValue(t)})},onInvalid:function(t){Ur(t,bw,{type:i,value:Fm.getValue(t)})}},validator:{validate:function(t){var n=Fm.getValue(t),e=u(n)?vt.value(!0):vt.error(d("aria.input.invalid"));return Sb.pure(e)},validateOnLoad:!1}})),gy.config({})]),onSetValue:function(t){ly.isInvalid(t)&&ly.run(t).get(tt)}})],s="hex"!==n?[fb.parts()["aria-descriptor"]({text:a})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:c.concat(s)}},v=function(t,n){var e=n.red(),o=n.green(),r=n.blue();Fm.setValue(t,{red:e,green:o,blue:r})},b=wg({dom:{tag:"div",classes:[m("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),y=function(t,n){b.getOpt(t).each(function(t){su(t.element(),"background-color","#"+n.value())})};return rl({factory:function(){var e={red:nt(_t(et.some(255))),green:nt(_t(et.some(255))),blue:nt(_t(et.some(255))),hex:nt(_t(et.some("ffffff")))},o=function(t){return e[t]().get()},i=function(t,n){e[t]().set(n)},r=function(t){var n=t.red(),e=t.green(),o=t.blue();i("red",et.some(n)),i("green",et.some(e)),i("blue",et.some(o))},n=function(t,n){var e=n.event();"hex"!==e.type()?i(e.type(),et.none()):p(t)},u=function(r,t,n){var e=parseInt(n,10);i(t,et.some(e)),o("red").bind(function(e){return o("green").bind(function(n){return o("blue").map(function(t){return gh(e,n,t,1)})})}).each(function(t){var n,e,o=(n=r,e=ch(t),hw.getField(n,"hex").each(function(t){Nm.isFocused(t)||Fm.setValue(n,{hex:e.value()})}),e);y(r,o)})},a=function(t,n){var e=n.event();"hex"===e.type()?function(t,n){g(t);var e=eh(n);i("hex",et.some(n));var o=vh(e);v(t,o),r(o),Ur(t,Cy(),{hex:e}),y(t,e)}(t,e.value()):u(t,e.type(),e.value())},t=function(t){return{label:d(xw+t+".label"),description:d(xw+t+".description")}},c=t("red"),s=t("green"),f=t("blue"),l=t("hex");return wt(hw.sketch(function(t){return{dom:{tag:"form",classes:[m("rgb-form")],attributes:{"aria-label":d("aria.color.picker")}},components:[t.field("red",fb.sketch(h(ph,"red",c.label,c.description,255))),t.field("green",fb.sketch(h(ph,"green",s.label,s.description,255))),t.field("blue",fb.sketch(h(ph,"blue",f.label,f.description,255))),t.field("hex",fb.sketch(h(ih,"hex",l.label,l.description,"ffffff"))),b.asSpec()],formBehaviours:ea([ly.config({invalidClass:m("form-invalid")}),og("rgb-form-events",[ai(vw,a),ai(bw,n),ai(yw,n)])])}}),{apis:{updateHex:function(t,n){var e,o;Fm.setValue(t,{hex:n.value()}),e=t,o=vh(n),v(e,o),r(o),y(t,n)}}})},name:"RgbForm",configFields:[],apis:{updateHex:function(t,n,e){t.updateHex(n,e)}},extraApis:{}})},Sw=function(t,o){var r=lw.parts().spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[o("sv-palette-spectrum")]}}),i=lw.parts().thumb({dom:{tag:"div",attributes:{role:"presentation"},classes:[o("sv-palette-thumb")],innerHtml:"'}}),u=function(t,n){var e=t.width,o=t.height,r=t.getContext("2d");if(null!==r){r.fillStyle=n,r.fillRect(0,0,e,o);var i=r.createLinearGradient(0,0,e,0);i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=i,r.fillRect(0,0,e,o);var u=r.createLinearGradient(0,0,0,o);u.addColorStop(0,"rgba(0,0,0,0)"),u.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=u,r.fillRect(0,0,e,o)}};return rl({factory:function(t){var n=nt({x:nt(0),y:nt(0)}),e=ea([sl.config({find:et.some}),Nm.config({})]);return lw.sketch({dom:{tag:"div",attributes:{role:"presentation"},classes:[o("sv-palette")]},model:{mode:"xy",getInitialValue:n},rounded:!1,components:[r,i],onChange:function(t,n,e){Ur(t,Ey(),{value:e})},onInit:function(t,n,e,o){u(e.element().dom(),yh(xh()))},sliderBehaviours:e})},name:"SaturationBrightnessPalette",configFields:[],apis:{setRgba:function(t,n,e){var o,r;o=e,r=n.components()[0].element().dom(),u(r,yh(o))}},extraApis:{}})},kw=function(c,s){return rl({name:"ColourPicker",configFields:[hr("dom"),Dr("onValidHex",tt),Dr("onInvalidHex",tt)],factory:function(t){var a,v,e=ww(c,s,t.onValidHex,t.onInvalidHex),o=Sw(c,s),b={paletteRgba:nt(_t(xh()))},n=wg(o.sketch({})),r=wg(e.sketch({})),i=function(t,e){n.getOpt(t).each(function(t){var n=vh(e);b.paletteRgba().set(n),o.setRgba(t,n)})},u=function(t,n){r.getOpt(t).each(function(t){e.updateHex(t,n)})},y=function(n,e,t){M(t,function(t){t(n,e)})};return{uid:t.uid,dom:t.dom,components:[n.asSpec(),dw(c,s),r.asSpec()],behaviours:ea([og("colour-picker-events",[ai(Ey(),(v=[u],function(t,n){var e,o,r,i,u,a,c,s,f,l=n.event().value(),d=b.paletteRgba().get(),m=(i=r=0,u=(e=d).red()/255,a=e.green()/255,c=e.blue()/255,s=Math.min(u,Math.min(a,c)),f=Math.max(u,Math.max(a,c)),s===f?ky(0,0,100*(i=s)):(r=60*((r=u===s?3:c===s?1:5)-(u===s?a-c:c===s?u-a:c-u)/(f-s)),o=(f-s)/f,i=f,ky(Math.round(r),Math.round(100*o),Math.round(100*i)))),g=ky(m.hue(),l.x(),100-l.y()),p=hh(g),h=ch(p);y(t,h,v)})),ai(Oy(),(a=[i,u],function(t,n){var e,o,r,i=n.event().value(),u=(e=i.y(),o=ky((100-e)/100*360,100,100),r=hh(o),ch(r));y(t,u,a)}))]),sl.config({find:function(t){return r.getOpt(t)}}),pm.config({mode:"acyclic"})])}}})},Cw=function(){return sl.config({find:et.some})},Ow=function(t){return sl.config({find:t.getOpt})},Ew=function(t){return sl.config({find:function(n){return ke(n.element(),t).bind(function(t){return n.getSystem().getByDom(t).toOption()})}})},Tw={"colorcustom.rgb.red.label":"R","colorcustom.rgb.red.description":"Red component","colorcustom.rgb.green.label":"G","colorcustom.rgb.green.description":"Green component","colorcustom.rgb.blue.label":"B","colorcustom.rgb.blue.description":"Blue component","colorcustom.rgb.hex.label":"#","colorcustom.rgb.hex.description":"Hex color code","colorcustom.rgb.range":"Range 0 to 255","colorcustom.sb.saturation":"Saturation","colorcustom.sb.brightness":"Brightness","colorcustom.sb.picker":"Saturation and Brightness Picker","colorcustom.sb.palette":"Saturation and Brightness Palette","colorcustom.sb.instructions":"Use arrow keys to select saturation and brightness, on x and y axes","colorcustom.hue.hue":"Hue","colorcustom.hue.slider":"Hue Slider","colorcustom.hue.palette":"Hue Palette","colorcustom.hue.instructions":"Use arrow keys to select a hue","aria.color.picker":"Color Picker","aria.input.invalid":"Invalid input"},Bw=function(t){return Tw[t]},Aw=Uo([Dr("preprocess",d),Dr("postprocess",d)]),Dw=function(t,n,e){return Fm.config(wt({store:{mode:"manual",getValue:n,setValue:e}},t.map(function(t){return{store:{initialValue:t}}}).getOr({})))},_w=function(t,n,e){return Dw(t,function(t){return n(t.element())},function(t,n){return e(t.element(),n)})},Mw=function(r,t){var i=ur("RepresentingConfigs.memento processors",Aw,t);return Fm.config({store:{mode:"manual",getValue:function(t){var n=r.get(t),e=Fm.getValue(n);return i.postprocess(e)},setValue:function(t,n){var e=i.preprocess(n),o=r.get(t);Fm.setValue(o,e)}}})},Fw=Dw,Iw=function(t){return _w(t,_e,Me)},Vw=function(t){return Fm.config({store:{mode:"memory",initialValue:t}})},Rw=function(r,n){var e=function(t,n){n.stop()},o=function(t){return function(n,e){M(t,function(t){t(n,e)})}},i=function(t,n){if(!Np.isDisabled(t)){var e=n.event().raw();a(t,e.dataTransfer.files)}},u=function(t,n){var e=n.event().raw().target.files;a(t,e)},a=function(t,n){var e,o;Fm.setValue(t,(e=n,o=new RegExp("("+".jpg,.jpeg,.png,.gif".split(/\s*,\s*/).join("|")+")$","i"),V(Q(e),function(t){return o.test(t.name)}))),Ur(t,Zv,{name:r.name})},c=wg({dom:{tag:"input",attributes:{type:"file",accept:"image/*"},styles:{display:"none"}},behaviours:ea([og("input-file-events",[mi(Rn())])])}),t=r.label.map(function(t){return qb(t,n)}),s=fb.parts().field({factory:{sketch:function(t){return{uid:t.uid,dom:{tag:"div",classes:["tox-dropzone-container"]},behaviours:ea([Vw([]),Cw(),Np.config({}),Jm.config({toggleClass:"dragenter",toggleOnExecute:!1}),og("dropzone-events",[ai("dragenter",o([e,Jm.toggle])),ai("dragleave",o([e,Jm.toggle])),ai("dragover",e),ai("drop",o([e,i])),ai(Jt(),u)])]),components:[{dom:{tag:"div",classes:["tox-dropzone"],styles:{}},components:[{dom:{tag:"p",innerHtml:n.translate("Drop an image here")}},xg.sketch({dom:{tag:"button",innerHtml:n.translate("Browse for an image"),styles:{position:"relative"},classes:["tox-button","tox-button--secondary"]},components:[c.asSpec()],action:function(t){c.get(t).element().dom().click()},buttonBehaviours:ea([gy.config({})])})]}]}}}});return Wb(t,s,["tox-form__group--stretched"])},Hw=oo("alloy-fake-before-tabstop"),Nw=oo("alloy-fake-after-tabstop"),Pw=function(t){return{dom:{tag:"div",styles:{width:"1px",height:"1px",outline:"none"},attributes:{tabindex:"0"},classes:t},behaviours:ea([Nm.config({ignore:!0}),gy.config({})])}},zw=function(t,n){Ur(t,Yt(),{raw:{which:9,shiftKey:n}})},Lw=function(t){return Sv(t,["."+Hw,"."+Nw].join(","),nt(!1))},jw=function(t,n){var e=n.element();ou(e,Hw)?zw(t,!0):ou(e,Nw)&&zw(t,!1)},Uw=function(t){return{dom:{tag:"div",classes:["tox-navobj"]},components:[Pw([Hw]),t,Pw([Nw])],behaviours:ea([Ew(1)])}},Ww=!(Tn.detect().browser.isIE()||Tn.detect().browser.isEdge()),Gw=function(t,n){var o,r,e=Ww&&t.sandboxed,i=io({},t.label.map(function(t){return{title:t}}).getOr({}),e?{sandbox:"allow-scripts allow-same-origin"}:{}),u=(o=e,r=_t(""),{getValue:function(t){return r.get()},setValue:function(t,n){if(o)ze(t.element(),"src","data:text/html;charset=utf-8,"+encodeURIComponent(n));else{ze(t.element(),"src","javascript:''");var e=t.element().dom().contentWindow.document;e.open(),e.write(n),e.close()}r.set(n)}}),a=t.label.map(function(t){return qb(t,n)}),c=fb.parts().field({factory:{sketch:function(t){return Uw({uid:t.uid,dom:{tag:"iframe",attributes:i},behaviours:ea([gy.config({}),Nm.config({}),Fw(et.none(),u.getValue,u.setValue)])})}}});return Wb(a,c,["tox-form__group--stretched"])};function Xw(t,n){return Kw(x.document.createElement("canvas"),t,n)}function Yw(t){var n=Xw(t.width,t.height);return qw(n).drawImage(t,0,0),n}function qw(t){return t.getContext("2d")}function Kw(t,n,e){return t.width=n,t.height=e,t}var Jw={atob:function(t){return ue.getOrDie("atob")(t)},requestAnimationFrame:function(t){ue.getOrDie("requestAnimationFrame")(t)}};function $w(t){return t.naturalWidth||t.width}function Qw(t){return t.naturalHeight||t.height}var Zw=window.Promise?window.Promise:function(){var i=function(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],f(t,o(r,this),o(a,this))},t=i.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(t){x.setTimeout(t,1)};function o(t,n){return function(){return t.apply(n,arguments)}}var e=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function u(o){var r=this;null!==this._state?t(function(){var t=r._state?o.onFulfilled:o.onRejected;if(null!==t){var n;try{n=t(r._value)}catch(e){return void o.reject(e)}o.resolve(n)}else(r._state?o.resolve:o.reject)(r._value)}):this._deferreds.push(o)}function r(t){try{if(t===this)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void f(o(n,t),o(r,this),o(a,this))}this._state=!0,this._value=t,c.call(this)}catch(e){a.call(this,e)}}function a(t){this._state=!1,this._value=t,c.call(this)}function c(){for(var t=0,n=this._deferreds;t").css({position:"absolute",top:0,left:0,width:o.width,height:o.height,zIndex:2147483647,opacity:1e-4,cursor:e}).appendTo(d.body),ok(d).on("mousemove touchmove",c).on("mouseup touchend",a),r.start(t)},c=function(t){if(ck(t),t.button!==u)return a(t);t.deltaX=t.screenX-f,t.deltaY=t.screenY-l,t.preventDefault(),r.drag(t)},a=function(t){ck(t),ok(d).off("mousemove touchmove",c).off("mouseup touchend",a),i.remove(),r.stop&&r.stop(t)},this.destroy=function(){ok(m).off()},ok(m).on("mousedown touchstart",n)}var fk,lk,dk,mk=0,gk=function(n){var f=wg({dom:{tag:"div",classes:["tox-image-tools__image-bg"],attributes:{role:"presentation"}}}),l=_t(1),d=_t(et.none()),m=_t({x:0,y:0,w:1,h:1}),c=_t({x:0,y:0,w:1,h:1}),s=function(t,s){g.getOpt(t).each(function(t){var e=l.get(),o=xa(t.element()),r=ka(t.element()),i=s.dom().naturalWidth*e,u=s.dom().naturalHeight*e,a=Math.max(0,o/2-i/2),c=Math.max(0,r/2-u/2),n={left:a.toString()+"px",top:c.toString()+"px",width:i.toString()+"px",height:u.toString()+"px",position:"absolute"};fu(s,n),f.getOpt(t).each(function(t){fu(t.element(),n)}),d.get().each(function(t){var n=m.get();t.setRect({x:n.x*e+a,y:n.y*e+c,w:n.w*e,h:n.h*e}),t.setClampRect({x:a,y:c,w:i,h:u}),t.setViewPortRect({x:0,y:0,w:o,h:r})})})},e=function(t,n){var e,a=Zn.fromTag("img");return ze(a,"src",n),(e=a.dom(),new Ig(function(t){var n=function(){e.removeEventListener("load",n),t(e)};e.complete?t(e):e.addEventListener("load",n)})).then(function(){return g.getOpt(t).map(function(t){var n=Tu({element:a});xm.replaceAt(t,1,et.some(n));var e=c.get(),o={x:0,y:0,w:a.dom().naturalWidth,h:a.dom().naturalHeight};c.set(o);var r,u,i=rk.inflate(o,-20,-20);return m.set(i),e.w===o.w&&e.h===o.h||(r=t,u=a,g.getOpt(r).each(function(t){var n=xa(t.element()),e=ka(t.element()),o=u.dom().naturalWidth,r=u.dom().naturalHeight,i=Math.min(n/o,e/r);1<=i?l.set(1):l.set(i)})),s(t,a),a})})},t=Lv.sketch({dom:{tag:"div",classes:["tox-image-tools__image"]},components:[f.asSpec(),{dom:{tag:"img",attributes:{src:n}}},{dom:{tag:"div"},behaviours:ea([og("image-panel-crop-events",[hi(function(t){g.getOpt(t).each(function(t){var n=function S(s,e,f,o,r){var l,u,n,i,a="tox-",c="tox-crid-"+mk++;function d(t,n){return{x:n.x-t.x,y:n.y-t.y,w:n.w,h:n.h}}function m(t,n,e,o){var r,i,u,a,c;r=n.x,i=n.y,u=n.w,a=n.h,r+=e*t.deltaX,i+=o*t.deltaY,(u+=e*t.deltaW)<20&&(u=20),(a+=o*t.deltaH)<20&&(a=20),c=s=rk.clamp({x:r,y:i,w:u,h:a},f,"move"===t.name),c=d(f,c),l.fire("updateRect",{rect:c}),h(c)}function g(n){function t(t,n){n.h<0&&(n.h=0),n.w<0&&(n.w=0),ok("#"+c+"-"+t,o).css({left:n.x,top:n.y,width:n.w,height:n.h})}uk.each(u,function(t){ok("#"+c+"-"+t.name,o).css({left:n.w*t.xMul+n.x,top:n.h*t.yMul+n.y})}),t("top",{x:e.x,y:e.y,w:e.w,h:n.y-e.y}),t("right",{x:n.x+n.w,y:n.y,w:e.w-n.x-n.w+e.x,h:n.h}),t("bottom",{x:e.x,y:n.y+n.h,w:e.w,h:e.h-n.y-n.h+e.y}),t("left",{x:e.x,y:n.y,w:n.x-e.x,h:n.h}),t("move",n)}function p(t){g(s=t)}function h(t){p(function e(t,n){return{x:n.x+t.x,y:n.y+t.y,w:n.w,h:n.h}}(f,t))}return u=[{name:"move",xMul:0,yMul:0,deltaX:1,deltaY:1,deltaW:0,deltaH:0,label:"Crop Mask"},{name:"nw",xMul:0,yMul:0,deltaX:1,deltaY:1,deltaW:-1,deltaH:-1,label:"Top Left Crop Handle"},{name:"ne",xMul:1,yMul:0,deltaX:0,deltaY:1,deltaW:1,deltaH:-1,label:"Top Right Crop Handle"},{name:"sw",xMul:0,yMul:1,deltaX:1,deltaY:0,deltaW:-1,deltaH:1,label:"Bottom Left Crop Handle"},{name:"se",xMul:1,yMul:1,deltaX:0,deltaY:0,deltaW:1,deltaH:1,label:"Bottom Right Crop Handle"}],i=["top","right","bottom","left"],function v(){ok('
').appendTo(o),uk.each(i,function(t){ok("#"+c,o).append(''),components:[],behaviours:ea([VO.config({channel:aD,initialData:t,updateState:function(t,n){var r=_(n.buttons,function(t){var n,e,o=wg((e=i,LS(n=t,n.type,e)));return{name:t.name,align:t.align,memento:o}});return et.some({lookupByName:function(t,n){return e=t,o=n,H(r,function(t){return t.name===o}).bind(function(t){return t.memento.getOpt(e)});var e,o},footerButtons:r})},renderComponents:mD})])}},pD=function(t,n){return KB.parts().footer(gD(t,n))},hD=function(n,e){if(n.getRoot().getSystem().isConnected()){var o=sl.getCurrent(n.getFormWrapper()).getOr(n.getFormWrapper());return hw.getField(o,e).fold(function(){var t=n.getFooter();return VO.getState(t).get().bind(function(t){return t.lookupByName(o,e)})},function(t){return et.some(t)})}return et.none()},vD=function(c,o){var t=function(t){var n=c.getRoot();n.getSystem().isConnected()&&t(n)},s={getData:function(){var t=c.getRoot(),n=t.getSystem().isConnected()?c.getFormWrapper():t;return Fm.getValue(n)},setData:function(a){t(function(t){var n,e,o=s.getData(),r=St(o,a),i=(n=r,e=c.getRoot(),VO.getState(e).get().map(function(t){return ir(rr("data",t.dataValidator,n))}).getOr(n)),u=c.getFormWrapper();Fm.setValue(u,i)})},disable:function(t){hD(c,t).each(Np.disable)},enable:function(t){hD(c,t).each(Np.enable)},focus:function(t){hD(c,t).each(Nm.focus)},block:function(n){if(!k(n))throw new Error("The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument");t(function(t){Ur(t,rb,{message:n})})},unblock:function(){t(function(t){jr(t,ib)})},showTab:function(e){t(function(t){var n=c.getBody();VO.getState(n).get().exists(function(t){return t.isTabPanel()})&&sl.getCurrent(n).each(function(t){ZA.showTab(t,e)})})},redial:function(e){t(function(t){var n=o(e);t.getSystem().broadcastOn([rD],n),t.getSystem().broadcastOn([iD],n.internalDialog),t.getSystem().broadcastOn([uD],n.internalDialog),t.getSystem().broadcastOn([aD],n.internalDialog),s.setData(n.initialData)})},close:function(){t(function(t){jr(t,tb)})}};return s},bD=function(t){return xg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":t.translate("Close"),title:t.translate("Close")}},components:[{dom:{tag:"div",classes:["tox-icon"],innerHtml:''}}],action:function(t){jr(t,nb)}})},yD=function(t,n,e){var o=function(t){return[Eu(e.translate(t.title))]};return{dom:{tag:"div",classes:["tox-dialog__title"],attributes:io({},n.map(function(t){return{id:t}}).getOr({}))},components:o(t),behaviours:ea([VO.config({channel:iD,renderComponents:o})])}},xD=function(t,n){return e={title:n.shared.providers.translate(t),draggable:!0},o=n.shared.providers,r=KB.parts().title(yD(e,et.none(),o)),i=KB.parts().draghandle({dom:rp('
')}),u=KB.parts().close(bD(o)),a=[r].concat(e.draggable?[i]:[]).concat([u]),Lv.sketch({dom:rp('
'),components:a});var e,o,r,i,u,a},wD=function(t,n){return{onClose:function(){return n.closeWindow()},onBlock:function(e){KB.setBusy(t(),function(t,n){return{dom:{tag:"div",classes:["tox-dialog__busy-spinner"],attributes:{"aria-label":e.message()},styles:{left:"0px",right:"0px",bottom:"0px",top:"0px",position:"absolute"}},behaviours:n,components:[{dom:rp('
')}]}})},onUnblock:function(){KB.setIdle(t())}}},SD=function(t,n,e,o){var r;return Au(KB.sketch({lazySink:o.shared.getSink,onEscape:function(t){return jr(t,nb),et.some(!0)},useTabstopAt:function(t){return!Lw(t)&&("button"!==Fe(t)||"disabled"!==Le(t,"disabled"))},modalBehaviours:ea([VO.config({channel:rD,updateState:function(t,n){return et.some(n)},initialData:n}),Vw({}),Nm.config({}),og("execute-on-form",e.concat([pi(Gt(),function(t,n){pm.focusIn(t)})])),og("scroll-lock",[hi(function(){nu($r(),"tox-dialog__disable-scroll")}),vi(function(){eu($r(),"tox-dialog__disable-scroll")})])].concat(t.extraBehaviours)),eventOrder:(r={},r[Fn()]=["execute-on-form"],r[Mn()]=["reflecting","receiving"],r[Un()]=["scroll-lock","reflecting","messages","execute-on-form","alloy.base.behaviour"],r[Wn()]=["alloy.base.behaviour","execute-on-form","messages","reflecting","scroll-lock"],r),dom:{tag:"div",classes:["tox-dialog"].concat(t.extraClasses),styles:io({position:"relative"},t.extraStyles)},components:[t.header,t.body].concat(t.footer.toArray()),dragBlockClass:"tox-dialog-wrap",parts:{blocker:{dom:rp('
'),components:[{dom:{tag:"div",classes:["tox-dialog-wrap__backdrop"]}}]}}}))},kD=function(t,n,e){var o,r,i,u=xD(t.internalDialog.title,e),a=(o={body:t.internalDialog.body},r=e,i=sD(o,et.none(),r,!1),KB.parts().body(i)),c=pD({buttons:t.internalDialog.buttons},e.shared.providers),s=dD(function(){return m},wD(function(){return d},n)),f="normal"!==t.internalDialog.size?"large"===t.internalDialog.size?["tox-dialog--width-lg"]:["tox-dialog--width-md"]:[],l={header:u,body:a,footer:et.some(c),extraClasses:f,extraBehaviours:[],extraStyles:{}},d=SD(l,t,s,e),m=vD({getRoot:function(){return d},getBody:function(){return KB.getBody(d)},getFooter:function(){return KB.getFooter(d)},getFormWrapper:function(){var t=KB.getBody(d);return sl.getCurrent(t).getOr(t)}},n.redial);return{dialog:d,instanceApi:m}},CD=tinymce.util.Tools.resolve("tinymce.util.URI"),OD=["insertContent","setContent","execCommand","close","block","unblock"],ED=function(t){return C(t)&&-1!==OD.indexOf(t.mceAction)},TD=function(o,t,r,n){var e,i,u,a,c=xD(o.title,n),s=(i={dom:{tag:"div",classes:["tox-dialog__content-js"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-iframe"]},components:[Uw({dom:{tag:"iframe",attributes:{src:o.url}},behaviours:ea([gy.config({}),Nm.config({})])})]}],behaviours:ea([pm.config({mode:"acyclic",useTabstopAt:S(Lw)})])},KB.parts().body(i)),f=o.buttons.bind(function(t){return 0===t.length?et.none():et.some(pD({buttons:t},n.shared.providers))}),l=lD(function(){return y},wD(function(){return b},t)),d=io({},o.height.fold(function(){return{}},function(t){return{height:t+"px","max-height":t+"px"}}),o.width.fold(function(){return{}},function(t){return{width:t+"px","max-width":t+"px"}})),m=o.width.isNone()&&o.height.isNone()?["tox-dialog--width-lg"]:[],g=new CD(o.url,{base_uri:new CD(x.window.location.href)}),p=g.protocol+"://"+g.host+(g.port?":"+g.port:""),h=_t(et.none()),v=[og("messages",[hi(function(){var t=xv(Zn.fromDom(x.window),"message",function(t){if(g.isSameOrigin(new CD(t.raw().origin))){var n=t.raw().data;ED(n)?function(t,n,e){switch(e.mceAction){case"insertContent":t.insertContent(e.content);break;case"setContent":t.setContent(e.content);break;case"execCommand":var o=!!O(e.ui)&&e.ui;t.execCommand(e.cmd,o,e.value);break;case"close":n.close();break;case"block":n.block(e.message);break;case"unblock":n.unblock()}}(r,y,n):!ED(e=n)&&C(e)&<(e,"mceAction")&&o.onMessage(y,n)}var e});h.set(et.some(t))}),vi(function(){h.get().each(function(t){return t.unbind()})})]),fa.config({channels:(e={},e[cD]={onReceive:function(t,n){Fu(t.element(),"iframe").each(function(t){t.dom().contentWindow.postMessage(n,p)})}},e)})],b=SD({header:c,body:s,footer:f,extraClasses:m,extraBehaviours:v,extraStyles:d},o,l,n),y=(u=b,a=function(t){u.getSystem().isConnected()&&t(u)},{block:function(n){if(!k(n))throw new Error("The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument");a(function(t){Ur(t,rb,{message:n})})},unblock:function(){a(function(t){jr(t,ib)})},close:function(){a(function(t){jr(t,tb)})},sendMessage:function(n){a(function(t){t.getSystem().broadcastOn([cD],n)})}});return{dialog:b,instanceApi:y}},BD=function(t,n,e,o){var r,i,u,a,c,s,f,l,d,m,g,p=oo("dialog-label"),h=oo("dialog-content"),v=wg((u={title:t.internalDialog.title,draggable:!0},a=p,c=e.shared.providers,Lv.sketch({dom:rp('
'),components:[yD(u,et.some(a),c),bD(c)],containerBehaviours:ea([SB.config({mode:"mouse",blockerClass:"blocker",getTarget:function(t){return Iu(t,'[role="dialog"]').getOrDie()},snaps:{getSnapPoints:function(){return[]},leftAttr:"data-drag-left",topAttr:"data-drag-top"}})])}))),b=wg((s={body:t.internalDialog.body},f=h,l=e,d=o,sD(s,et.some(f),l,d))),y=wg((m={buttons:t.internalDialog.buttons},g=e.shared.providers,gD(m,g))),x=dD(function(){return S},{onBlock:function(){},onUnblock:function(){},onClose:function(){return n.closeWindow()}}),w=Au({dom:{tag:"div",classes:["tox-dialog"],attributes:(r={role:"dialog"},r["aria-labelledby"]=p,r["aria-describedby"]=""+h,r)},eventOrder:(i={},i[Mn()]=[VO.name(),fa.name()],i[Fn()]=["execute-on-form"],i[Un()]=["reflecting","execute-on-form"],i),behaviours:ea([pm.config({mode:"cyclic",onEscape:function(t){return jr(t,tb),et.some(!0)},useTabstopAt:function(t){return!Lw(t)&&("button"!==Fe(t)||"disabled"!==Le(t,"disabled"))}}),VO.config({channel:rD,updateState:function(t,n){return et.some(n)},initialData:t}),og("execute-on-form",x),Vw({})]),components:[v.asSpec(),b.asSpec(),y.asSpec()]}),S=vD({getRoot:function(){return w},getFooter:function(){return y.get(w)},getBody:function(){return b.get(w)},getFormWrapper:function(){var t=b.get(w);return sl.getCurrent(t).getOr(t)}},n.redial);return{dialog:w,instanceApi:S}},AD=function(t,n){return KB.parts().close(xg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":n.translate("Close")}},action:t,buttonBehaviours:ea([gy.config({})])}))},DD=function(){return KB.parts().title({dom:{tag:"div",classes:["tox-dialog__title"],innerHtml:"",styles:{display:"none"}}})},_D=function(t,n){return KB.parts().body({dom:{tag:"div",classes:["tox-dialog__body","todo-tox-fit"]},components:[{dom:rp("

"+n.translate(t)+"

")}]})},MD=function(t){return KB.parts().footer({dom:{tag:"div",classes:["tox-dialog__footer"]},components:t})},FD=function(t,n){return[Lv.sketch({dom:{tag:"div",classes:["tox-dialog__footer-start"]},components:t}),Lv.sketch({dom:{tag:"div",classes:["tox-dialog__footer-end"]},components:n})]},ID=function(e){return KB.sketch({lazySink:e.lazySink,onEscape:function(){return e.onCancel(),et.some(!0)},dom:{tag:"div",classes:["tox-dialog"].concat(e.extraClasses)},components:[{dom:{tag:"div",classes:["tox-dialog__header"]},components:[e.partSpecs.title,e.partSpecs.close]},e.partSpecs.body,e.partSpecs.footer],parts:{blocker:{dom:rp('
'),components:[{dom:{tag:"div",classes:["tox-dialog-wrap__backdrop"]}}]}},modalBehaviours:ea([og("basic-dialog-events",[ai(nb,function(t,n){e.onCancel()}),ai(ob,function(t,n){e.onSubmit()})])])})},VD=function(s){var u,a,e=(u=s.backstage.shared,{open:function(t,n){var e=function(){KB.hide(r),n()},o=wg(LS({name:"close-alert",text:"OK",primary:!0,icon:et.none()},"cancel",u.providers)),r=Au(ID({lazySink:function(){return u.getSink()},partSpecs:{title:DD(),close:AD(function(){e()},u.providers),body:_D(t,u.providers),footer:MD(FD([],[o.asSpec()]))},onCancel:function(){return e()},onSubmit:tt,extraClasses:["tox-alert-dialog"]}));KB.show(r);var i=o.get(r);Nm.focus(i)}}),o=(a=s.backstage.shared,{open:function(t,n){var e=function(t){KB.hide(i),n(t)},o=wg(LS({name:"yes",text:"Yes",primary:!0,icon:et.none()},"submit",a.providers)),r=LS({name:"no",text:"No",primary:!0,icon:et.none()},"cancel",a.providers),i=Au(ID({lazySink:function(){return a.getSink()},partSpecs:{title:DD(),close:AD(function(){e(!1)},a.providers),body:_D(t,a.providers),footer:MD(FD([],[r,o.asSpec()]))},onCancel:function(){return e(!1)},onSubmit:function(){return e(!0)},extraClasses:["tox-confirm-dialog"]}));KB.show(i);var u=o.get(i);Nm.focus(u)}}),r=function(t,e){return LA.openUrl(function(t){var n=TD(t,{closeWindow:function(){KB.hide(n.dialog),e(n.instanceApi)}},s.editor,s.backstage);return KB.show(n.dialog),n.instanceApi},t)},i=function(t,i){return LA.open(function(t,n,e){var o=n,r=kD({dataValidator:e,initialData:o,internalDialog:t},{redial:LA.redial,closeWindow:function(){KB.hide(r.dialog),i(r.instanceApi)}},s.backstage);return KB.show(r.dialog),r.instanceApi.setData(o),r.instanceApi},t)},c=function(t,u,a,c){return LA.open(function(t,n,e){var o=ir(rr("data",e,n)),r=BD({dataValidator:e,initialData:o,internalDialog:t},{redial:LA.redial,closeWindow:function(){bg.hide(i),a(r.instanceApi)}},s.backstage,c),i=Au(bg.sketch({lazySink:s.backstage.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:{},inlineBehaviours:ea([og("window-manager-inline-events",[ai(Gn(),function(t,n){jr(r.dialog,nb)})])])}));return bg.showAt(i,u,Du(r.dialog)),r.instanceApi.setData(o),pm.focusIn(r.dialog),r.instanceApi},t)};return{open:function(t,n,e){return n!==undefined&&"toolbar"===n.inline?c(t,s.backstage.shared.anchors.toolbar(),e,n.ariaAttrs):n!==undefined&&"cursor"===n.inline?c(t,s.backstage.shared.anchors.cursor(),e,n.ariaAttrs):i(t,e)},openUrl:function(t,n){return r(t,n)},alert:function(t,n){e.open(t,function(){n()})},close:function(t){t.close()},confirm:function(t,n){o.open(t,function(t){n(t)})}}};ro.add("silver",function(t){var n=IB(t),e=n.mothership,o=n.uiMothership,r=n.backstage,i=n.renderUI,u=n.getUi;WB(t,r),to(oo("silver-demo"),e),to(oo("silver-ui-demo"),o),pv(t,r.shared);var a=VD({editor:t,backstage:r});return{renderUI:i,getWindowManagerImpl:nt(a),getNotificationManagerImpl:function(){return Tg(t,{backstage:r},o)},ui:u()}}),function a_(){}}(window);