/** * 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.1.0 (2019-10-17) */ !function(d){"use strict";var x=function(){return(x=Object.assign||function(n){for(var e,t=1,r=arguments.length;t "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return wr.objOf(ke(r,function(n){return n.fold(function(n,e,t,r){return Sr.field(n,t,r)},function(n,e){return Sr.state(n)})}))}}},kr=v(_t(dr)),Er=Tr.state,Cr=Tr.field,Dr=_t(dr),Mr=function(n){return"Errors: \n"+function(n){var e=10 ")+")\n"+n.getErrorInfo()})}(n.errors)+"\n\nInput object: "+At(n.input)},Ir=v(Dr),Rr=(ar=xe,fr="function",_t(function(n){var e=typeof n;return ar(n)?dr(n):gr("Expected type: "+fr+" but got: "+e)}));function Fr(n,e,t,r,o){return n(t,r)?An.some(t):xe(o)&&o(t)?An.none():e(t,r,o)}function Ar(n,e,t){for(var r=n.dom(),o=xe(t)?t:v(!1);r.parentNode;){r=r.parentNode;var i=Je.fromDom(r);if(e(i))return An.some(i);if(o(i))break}return An.none()}function Br(n,e,t){return Fr(function(n,e){return e(n)},Ar,n,e,t)}function Vr(n,o){var i=function(n){for(var e=0;e"}),Ir()),Ya=or("schema",function(){return[Qt("preprocess")]}),Ka=tr("defaults",v({})),Ja=tr("overrides",v({})),Qa=Or([$a,Wa,Xa,qa,Ka,Ja]),Za=Or([$a,Wa,Xa,qa,Ka,Ja]),nf=Or([$a,Ya,Xa,Yt("unit"),qa,Ka,Ja]),ef=bc(Ua.required,Qa),tf=bc(Ua.optional,Za),rf=bc(Ua.group,nf),of=v("entirety"),uf=function(n,e){return{uiType:La(),owner:n,name:e}},cf=vc("alloy-premade"),af=v("alloy-id-"),ff=v("data-alloy-id"),sf=af(),lf=ff(),df=function(n,e){Object.defineProperty(n.dom(),lf,{value:e,writable:!0})},mf=function(n){var e=et(n)?n.dom()[lf]:null;return An.from(e)},gf=function(n){return n.hasOwnProperty("uid")?n:x(x({},n),{uid:Ic("uid")})};function pf(n){var e=Xt("Sketcher for "+n.name,Ps,n),t=S(e.apis,Mc),r=S(e.extraApis,function(n,e){return Gr(n,e)});return x(x({name:v(e.name),partFields:v([]),configFields:v(e.configFields),sketch:function(n){return function(n,e,t,r){var o=gf(r);return t(Rc(n,e,o,[],[]),o)}(e.name,e.configFields,e.factory,n)}},t),r)}function hf(n){var e=Xt("Sketcher for "+n.name,Hs,n),t=wc(e.name,e.partFields),r=S(e.apis,Mc),o=S(e.extraApis,function(n,e){return Gr(n,e)});return x(x({name:v(e.name),partFields:v(e.partFields),configFields:v(e.configFields),sketch:function(n){return Fc(e.name,e.configFields,e.partFields,e.factory,n)},parts:v(t)},r),o)}function vf(n){var e=Je.fromHtml(n),t=at(e),r=function(n){var e=n.dom().attributes!==undefined?n.dom().attributes:[];return I(e,function(n,e){var t;return"class"===e.name?n:x(x({},n),((t={})[e.name]=e.value,t))},{})}(e),o=function(n){return Array.prototype.slice.call(n.dom().classList,0)}(e),i=0===t.length?{}:{innerHtml:po(e)};return x({tag:q(e),classes:o,attributes:r},i)}function yf(n){return{dom:Gs(n)}}function bf(n){return Bo([Fi.config({toggleClass:ji.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Ai(n,function(n,e){(e?Fi.on:Fi.off)(n)})])}function xf(n,e){var t=e.ui.registry.getAll().icons;return An.from(t[n]).fold(function(){return Gs('')},function(n){return Gs(''+n+"")})}function wf(n){return tf({name:n+"-edge",overrides:function(r){return r.model.manager.edgeActions[n].fold(function(){return{}},function(t){var n=Nr([Pr(Pn(),t,[r])]),e=Nr([Pr(Ln(),t,[r]),Pr(Gn(),function(n,e){e.mouseIsDown.get()&&t(n,e)},[r])]);return{events:Ws?n:e}})}})}function Sf(n,e,t){e.store.manager.onLoad(n,e,t)}function Tf(n,e,t){e.store.manager.onUnload(n,e,t)}function Of(){var n=Zn(null);return Ao({set:n.set,get:n.get,isNotSet:function(){return null===n.get()},clear:function(){n.set(null)},readState:function(){return{mode:"memory",value:n.get()}}})}function kf(){var i=Zn({}),u=Zn({});return Ao({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return Dt(i.get(),n).orThunk(function(){return Dt(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};C(n,function(e){r[e.value]=e,Dt(e,"meta").each(function(n){Dt(n,"text").each(function(n){o[n]=e})})}),i.set(x(x({},e),r)),u.set(x(x({},t),o))},clear:function(){i.set({}),u.set({})}})}function Ef(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)}function Cf(n,e){sl.set(n,e)}function Df(n){return sl.get(n)}function Mf(n){var e=n.event().raw();if(ml){var t=e;return t.touches!==undefined&&1===t.touches.length?An.some(t.touches[0]).map(function(n){return dl(n.clientX,n.clientY)}):An.none()}var r=e;return r.clientX!==undefined?An.some(r).map(function(n){return dl(n.clientX,n.clientY)}):An.none()}function If(n){return n.model.minX}function Rf(n){return n.model.minY}function Ff(n){return n.model.minX-1}function Af(n){return n.model.minY-1}function Bf(n){return n.model.maxX}function Vf(n){return n.model.maxY}function Nf(n){return n.model.maxX+1}function jf(n){return n.model.maxY+1}function _f(n,e,t){return e(n)-t(n)}function Pf(n){return _f(n,Bf,If)}function Hf(n){return _f(n,Vf,Rf)}function zf(n){return Pf(n)/2}function Lf(n){return Hf(n)/2}function Gf(n){return n.stepSize}function Uf(n){return n.snapToGrid}function $f(n){return n.snapStart}function Wf(n){return n.rounded}function Xf(n,e){return n[e+"-edge"]!==undefined}function qf(n){return Xf(n,"left")}function Yf(n){return Xf(n,"right")}function Kf(n){return Xf(n,"top")}function Jf(n){return Xf(n,"bottom")}function Qf(n){return n.model.value.get()}function Zf(n){return{x:v(n)}}function ns(n){return{y:v(n)}}function es(n,e){return{x:v(n),y:v(e)}}function ts(n,e){U(n,gl(),{value:e})}function rs(n,e,t,r){return n'),components:[jl.parts()["left-edge"](yf('
')),jl.parts().spectrum({dom:Gs('
'),components:[yf('
')],behaviours:Bo([Fi.config({toggleClass:ji.resolve("thumb-active")})])}),jl.parts()["right-edge"](yf('
')),jl.parts().thumb({dom:Gs('
'),behaviours:Bo([Fi.config({toggleClass:ji.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Li(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Fi.on(e)},onDragEnd:function(n,e){Fi.off(e)},onInit:function(n,e,t,r){var o=i(r.x());Li(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:Bo([Bi(jl.refresh)])})}(n)]}function Bs(n){var e=n.selection.getStart(),t=Je.fromDom(e),r=Je.fromDom(n.getBody()),o=function(e,n){return(et(n)?An.some(n):fn(n).filter(et)).map(function(n){return Br(n,function(n){return mi(n,"font-size").isSome()},e).bind(function(n){return mi(n,"font-size")}).getOrThunk(function(){return di(n,"font-size")})}).getOr("")}(function(n){return cn(r,n)},t);return R(zl,function(n){return o===n}).getOr("medium")}function Vs(n){return[yf(''),function(n){return Hl({onChange:n.onChange,sizes:Gl,category:"font",getInitialValue:n.getInitialValue})}(n),yf('')]}function Ns(n){var e=function t(n){return n.uid!==undefined}(n)&&Mn(n,"uid")?n.uid:Ic("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).toOption()},asSpec:function(){return x(x({},n),{uid:e})}}}var js,_s,Ps=Pt([Yt("name"),Yt("factory"),Yt("configFields"),tr("apis",{}),tr("extraApis",{})]),Hs=Pt([Yt("name"),Yt("factory"),Yt("configFields"),Yt("partFields"),tr("apis",{}),tr("extraApis",{})]),zs=pf({name:"Button",factory:function(n){function t(e){return Dt(n.dom,"attributes").bind(function(n){return Dt(n,e)})}var e=function(n){function e(n,e){e.stop(),$(n)}var t=L().deviceType.isTouch()?[_r(He(),e)]:[_r(Kn(),e),_r(Ln(),function(n,e){e.cut()})];return Nr(A([n.map(function(t){return _r(_e(),function(n,e){t(n),e.stop()})}).toArray(),t]))}(n.action),r=n.dom.tag;return{uid:n.uid,dom:n.dom,components:n.components,events:e,behaviours:Na(n.buttonBehaviours,[zi.config({}),Ba.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:function(){if("button"!==r)return{role:t("role").getOr("button")};var n=t("type").getOr("button"),e=t("role").map(function(n){return{role:n}}).getOr({});return x({type:n},e)}()},eventOrder:n.eventOrder}},configFields:[tr("uid",undefined),Yt("dom"),tr("components",[]),Va("buttonBehaviours",[zi,Ba]),Qt("action"),Qt("role"),tr("eventOrder",{})]}),Ls=qr({fields:[],name:"unselecting",active:/* */Object.freeze({events:function(n){return Nr([jr(Qn(),v(!0))])},exhibit:function(n,e){return Ur({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})}})}),Gs=function(n){var e=function(n,r){return n.replace(/\$\{([^{}]*)\}/g,function(n,e){var t=r[e];return function(n){var e=typeof n;return"string"==e||"number"==e}(t)?t.toString():n})}(n,{prefix:ji.prefix()});return vf(e)},Us=function(n,e,t,r){return zs.sketch({dom:xf(n,r),action:e,buttonBehaviours:xt(Bo([Ls.config({})]),t)})},$s={forToolbar:Us,forToolbarCommand:function(n,e){return Us(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=bf(t);return Us(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=bf(e);return Us(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:xf},Ws=L().deviceType.isTouch(),Xs=tf({schema:[Yt("dom")],name:"label"}),qs=wf("top-left"),Ys=wf("top"),Ks=wf("top-right"),Js=wf("right"),Qs=wf("bottom-right"),Zs=wf("bottom"),nl=wf("bottom-left"),el=[Xs,wf("left"),Js,Ys,Zs,qs,Ks,nl,Qs,ef({name:"thumb",defaults:v({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Nr([zr(Pn(),n,"spectrum"),zr(Hn(),n,"spectrum"),zr(zn(),n,"spectrum"),zr(Ln(),n,"spectrum"),zr(Gn(),n,"spectrum"),zr(Un(),n,"spectrum")])}}}),ef({schema:[or("mouseIsDown",function(){return Zn(!1)})],name:"spectrum",overrides:function(t){function r(e,n){return o.getValueFromEvent(n).map(function(n){return o.setValueFrom(e,t,n)})}var o=t.model.manager,n=Nr([_r(Pn(),r),_r(Hn(),r)]),e=Nr([_r(Ln(),r),_r(Gn(),function(n,e){t.mouseIsDown.get()&&r(n,e)})]);return{behaviours:Bo(Ws?[]:[Ba.config({mode:"special",onLeft:function(n){return o.onLeft(n,t)},onRight:function(n){return o.onRight(n,t)},onUp:function(n){return o.onUp(n,t)},onDown:function(n){return o.onDown(n,t)}}),zi.config({})]),events:Ws?n:e}}})],tl=/* */Object.freeze({onLoad:Sf,onUnload:Tf,setValue:function(n,e,t,r){e.store.manager.setValue(n,e,t,r)},getValue:function(n,e,t){return e.store.manager.getValue(n,e,t)},getState:function(n,e,t){return t}}),rl=/* */Object.freeze({events:function(t,r){var n=t.resetOnDom?[Eo(function(n,e){Sf(n,t,r)}),Co(function(n,e){Tf(n,t,r)})]:[$r(t,r,Sf)];return Nr(n)}}),ol=/* */Object.freeze({memory:Of,dataset:kf,manual:function(){return Ao({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),il=[Qt("initialValue"),Yt("getFallbackEntry"),Yt("getDataKey"),Yt("setValue"),ni("manager",{setValue:Ef,getValue:function(n,e,t){var r=e.store,o=r.getDataKey(n);return t.lookup(o).fold(function(){return r.getFallbackEntry(o)},function(n){return n})},onLoad:function(e,t,r){t.store.initialValue.each(function(n){Ef(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:kf})],ul=[Yt("getValue"),tr("setValue",w),Qt("initialValue"),ni("manager",{setValue:function(n,e,t,r){e.store.setValue(n,r),e.onSetValue(n,r)},getValue:function(n,e,t){return e.store.getValue(n)},onLoad:function(e,t,n){t.store.initialValue.each(function(n){t.store.setValue(e,n)})},onUnload:w,state:Fo.init})],cl=[Qt("initialValue"),ni("manager",{setValue:function(n,e,t,r){t.set(r),e.onSetValue(n,r)},getValue:function(n,e,t){return t.get()},onLoad:function(n,e,t){e.store.initialValue.each(function(n){t.isNotSet()&&t.set(n)})},onUnload:function(n,e,t){t.clear()},state:Of})],al=[rr("store",{mode:"memory"},qt("mode",{memory:cl,manual:ul,dataset:il})),Ko("onSetValue"),tr("resetOnDom",!1)],fl=qr({fields:al,name:"representing",active:rl,apis:tl,extra:{setValueFrom:function(n,e){var t=fl.getValue(e);fl.setValue(n,t)}},state:ol}),sl=Ui("width",function(n){return n.dom().offsetWidth}),ll=function(t,r){return{left:v(t),top:v(r),translate:function(n,e){return ll(t+n,r+e)}}},dl=ll,ml=L().deviceType.isTouch(),gl=v("slider.change.value"),pl="left",hl=Ss(-1),vl=Ss(1),yl=An.none,bl=An.none,xl={"top-left":An.none(),top:An.none(),"top-right":An.none(),right:An.some(function(n,e){ts(n,Zf(Nf(e)))}),"bottom-right":An.none(),bottom:An.none(),"bottom-left":An.none(),left:An.some(function(n,e){ts(n,Zf(Ff(e)))})},wl=/* */Object.freeze({setValueFrom:function(n,e,t){var r=ws(n,e,t),o=xs(r);return bs(n,o),r},setToMin:function(n,e){var t=If(e);bs(n,xs(t))},setToMax:function(n,e){var t=Bf(e);bs(n,xs(t))},findValueOfOffset:ws,getValueFromEvent:function(n){return Mf(n).map(function(n){return n.left()})},findPositionOfValue:Ts,setPositionFromValue:function(n,e,t,r){var o=Qf(t),i=Ts(n,r.getSpectrum(n),o.x(),r.getLeftEdge(n),r.getRightEdge(n),t),u=Df(e.element())/2;Li(e.element(),"left",i-u+"px")},onLeft:hl,onRight:vl,onUp:yl,onDown:bl,edgeActions:xl}),Sl=An.none,Tl=An.none,Ol=Cs(-1),kl=Cs(1),El={"top-left":An.none(),top:An.some(function(n,e){ts(n,ns(Af(e)))}),"top-right":An.none(),right:An.none(),"bottom-right":An.none(),bottom:An.some(function(n,e){ts(n,ns(jf(e)))}),"bottom-left":An.none(),left:An.none()},Cl=/* */Object.freeze({setValueFrom:function(n,e,t){var r=Es(n,e,t),o=ks(r);return Os(n,o),r},setToMin:function(n,e){var t=Rf(e);Os(n,ks(t))},setToMax:function(n,e){var t=Vf(e);Os(n,ks(t))},findValueOfOffset:Es,getValueFromEvent:function(n){return Mf(n).map(function(n){return n.top()})},findPositionOfValue:Ds,setPositionFromValue:function(n,e,t,r){var o=Qf(t),i=Ds(n,r.getSpectrum(n),o.y(),r.getTopEdge(n),r.getBottomEdge(n),t),u=$i(e.element())/2;Li(e.element(),"top",i-u+"px")},onLeft:Sl,onRight:Tl,onUp:Ol,onDown:kl,edgeActions:El}),Dl=Rs(-1,!1),Ml=Rs(1,!1),Il=Rs(-1,!0),Rl=Rs(1,!0),Fl={"top-left":An.some(function(n,e){ts(n,es(Ff(e),Af(e)))}),top:An.some(function(n,e){ts(n,es(zf(e),Af(e)))}),"top-right":An.some(function(n,e){ts(n,es(Nf(e),Af(e)))}),right:An.some(function(n,e){ts(n,es(Nf(e),Lf(e)))}),"bottom-right":An.some(function(n,e){ts(n,es(Nf(e),jf(e)))}),bottom:An.some(function(n,e){ts(n,es(zf(e),jf(e)))}),"bottom-left":An.some(function(n,e){ts(n,es(Ff(e),jf(e)))}),left:An.some(function(n,e){ts(n,es(Ff(e),Lf(e)))})},Al=/* */Object.freeze({setValueFrom:function(n,e,t){var r=ws(n,e,t.left()),o=Es(n,e,t.top()),i=Is(r,o);return Ms(n,i),i},setToMin:function(n,e){var t=If(e),r=Rf(e);Ms(n,Is(t,r))},setToMax:function(n,e){var t=Bf(e),r=Vf(e);Ms(n,Is(t,r))},getValueFromEvent:function(n){return Mf(n)},setPositionFromValue:function(n,e,t,r){var o=Qf(t),i=Ts(n,r.getSpectrum(n),o.x(),r.getLeftEdge(n),r.getRightEdge(n),t),u=Ds(n,r.getSpectrum(n),o.y(),r.getTopEdge(n),r.getBottomEdge(n),t),c=Df(e.element())/2,a=$i(e.element())/2;Li(e.element(),"left",i-c+"px"),Li(e.element(),"top",u-a+"px")},onLeft:Dl,onRight:Ml,onUp:Il,onDown:Rl,edgeActions:Fl}),Bl=L().deviceType.isTouch(),Vl=[tr("stepSize",1),tr("onChange",w),tr("onChoose",w),tr("onInit",w),tr("onDragStart",w),tr("onDragEnd",w),tr("snapToGrid",!1),tr("rounded",!0),Qt("snapStart"),Kt("model",qt("mode",{x:[tr("minX",0),tr("maxX",100),or("value",function(n){return Zn(n.mode.minX)}),Yt("getInitialValue"),ni("manager",wl)],y:[tr("minY",0),tr("maxY",100),or("value",function(n){return Zn(n.mode.minY)}),Yt("getInitialValue"),ni("manager",Cl)],xy:[tr("minX",0),tr("maxX",100),tr("minY",0),tr("maxY",100),or("value",function(n){return Zn({x:v(n.mode.minX),y:v(n.mode.minY)})}),Yt("getInitialValue"),ni("manager",Al)]})),dc("sliderBehaviours",[Ba,fl])].concat(Bl?[]:[or("mouseIsDown",function(){return Zn(!1)})]),Nl=L().deviceType.isTouch(),jl=hf({name:"Slider",configFields:Vl,partFields:el,factory:function(i,n,e,t){function u(n){return kc(n,i,"thumb")}function c(n){return kc(n,i,"spectrum")}function r(n){return Oc(n,i,"left-edge")}function o(n){return Oc(n,i,"right-edge")}function a(n){return Oc(n,i,"top-edge")}function f(n){return Oc(n,i,"bottom-edge")}function s(n,e){m.setPositionFromValue(n,e,i,{getLeftEdge:r,getRightEdge:o,getTopEdge:a,getBottomEdge:f,getSpectrum:c})}function l(n,e){d.value.set(e);var t=u(n);return s(n,t),i.onChange(n,t,e),An.some(!0)}var d=i.model,m=d.manager,g=[_r(Pn(),function(n,e){i.onDragStart(n,u(n))}),_r(zn(),function(n,e){i.onDragEnd(n,u(n))})],p=[_r(Ln(),function(n,e){e.stop(),i.onDragStart(n,u(n)),i.mouseIsDown.set(!0)}),_r(Un(),function(n,e){i.onDragEnd(n,u(n))})],h=Nl?g:p;return{uid:i.uid,dom:i.dom,components:n,behaviours:gc(i.sliderBehaviours,A([Nl?[]:[Ba.config({mode:"special",focusIn:function(n){return Oc(n,i,"spectrum").map(Ba.focusIn).map(v(!0))}})],[fl.config({store:{mode:"manual",getValue:function(n){return d.value.get()}}}),Ei.config({channels:{"mouse.released":{onReceive:function(t,n){function e(){Oc(t,i,"thumb").each(function(n){var e=d.value.get();i.onChoose(t,n,e)})}if(Nl)e();else{var r=i.mouseIsDown.get();i.mouseIsDown.set(!1),r&&e()}}}}})]])),events:Nr([_r(gl(),function(n,e){l(n,e.event().value())}),Eo(function(n,e){var t=d.getInitialValue();d.value.set(t);var r=u(n);s(n,r);var o=c(n);i.onInit(n,r,o,d.value.get())})].concat(h)),apis:{resetToMin:function(n){m.setToMin(n,i)},resetToMax:function(n){m.setToMax(n,i)},changeValue:l,refresh:s},domModification:{styles:{position:"relative"}}}},apis:{resetToMin:function(n,e){n.resetToMin(e)},resetToMax:function(n,e){n.resetToMax(e)},refresh:function(n,e){n.refresh(e)}}}),_l=function(n,r){var e={onChange:function(n,e,t){r.undoManager.transact(function(){r.formatter.apply("forecolor",{value:t}),r.nodeChanged()})},getInitialValue:function(){return-1}};return Fs(n,"color-levels",function(){return As(e)},r)},Pl=Pt([Yt("getInitialValue"),Yt("onChange"),Yt("category"),Yt("sizes")]),Hl=function(n){var o=Xt("SizeSlider",Pl,n);return jl.sketch({dom:{tag:"div",classes:[ji.resolve("slider-"+o.category+"-size-container"),ji.resolve("slider"),ji.resolve("slider-size-container")]},onChange:function(n,e,t){var r=t.x();!function(n){return 0<=n&&n'),components:[yf('
')]}),jl.parts().thumb({dom:Gs('
'),behaviours:Bo([Fi.config({toggleClass:ji.resolve("thumb-active")})])})]})},zl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Ll={candidates:v(zl),get:function(n){return function(e){return F(zl,function(n){return n===e})}(Bs(n)).getOr(2)},apply:function(e,n){(function(n){return An.from(zl[n])})(n).each(function(n){!function(n,e){Bs(n)!==e&&n.execCommand("fontSize",!1,e)}(e,n)})}},Gl=Ll.candidates(),Ul=window.Promise?window.Promise:(js=$l.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){d.setTimeout(n,1)},_s=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)},$l.prototype["catch"]=function(n){return this.then(null,n)},$l.prototype.then=function(t,r){var o=this;return new $l(function(n,e){Xl.call(o,new Jl(t,r,n,e))})},$l.all=function(){for(var n=[],e=0;e'),action:function(n){var e=t.get(n);fl.setValue(e,"")}}));return{name:n,spec:gm.sketch({dom:Gs('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:Bo([Fi.config({toggleClass:ji.resolve("input-container-empty")}),mm.config({find:function(n){return An.some(t.get(n))}}),sm("input-clearing",[_r(qn(),function(n){var e=t.get(n);(0"}function xd(){function e(){t.get().each(function(n){n.destroy()})}var t=Zn(An.none());return{clear:function(){e(),t.set(An.none())},isSet:function(){return t.get().isSome()},set:function(n){e(),t.set(An.some(n))},run:function(n){t.get().each(n)}}}function wd(){var e=Zn(An.none());return{clear:function(){e.set(An.none())},set:function(n){e.set(An.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}}function Sd(n){function r(e,n,t){return zs.sketch({dom:Gs(''),action:function(n){U(n,u,{direction:e})},buttonBehaviours:Bo([Cm.config({disableClass:ji.resolve("toolbar-navigation-disabled"),disabled:!t})])})}function o(n,o){var i=qi(n.element(),"."+ji.resolve("serialised-dialog-screen"));Ji(n.element(),"."+ji.resolve("serialised-dialog-chain")).each(function(r){0<=c.state.currentScreen.get()+o&&c.state.currentScreen.get()+o'),components:[gm.sketch({dom:Gs('
'),components:ke(c.fields,function(n,e){return e<=c.maxFieldIndex?gm.sketch({dom:Gs('
'),components:[r(-1,"previous",0'),behaviours:Bo([Eu.config({highlightClass:ji.resolve("dot-active"),itemClass:ji.resolve("dot-item")})]),components:B(c.fields,function(n,e){return e<=c.maxFieldIndex?[yf('
')]:[]})});return{dom:Gs('
'),components:[a.asSpec(),f.asSpec()],behaviours:Bo([Ba.config({mode:"special",focusIn:function(n){var e=a.get(n);Ba.focusIn(e)}}),sm("serializer-wrapper-events",[_r(Pn(),function(n,e){var t=e.event();c.state.dialogSwipeState.set(Rm(t.raw().touches[0].clientX))}),_r(Hn(),function(n,e){var t=e.event();c.state.dialogSwipeState.on(function(n){e.event().prevent(),c.state.dialogSwipeState.set(Fm(n,t.raw().touches[0].clientX))})}),_r(zn(),function(r){c.state.dialogSwipeState.on(function(n){var e=a.get(r),t=-1*Am(n);o(e,t)})})])])}}function Td(e){function n(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+bo(e().element())+" is not in context.")}}return{debugInfo:v("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),build:n("build"),addToWorld:n("addToWorld"),removeFromWorld:n("removeFromWorld"),addToGui:n("addToGui"),removeFromGui:n("removeFromGui"),getByUid:n("getByUid"),getByDom:n("getByDom"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),isConnected:v(!1)}}function Od(n,o){var i={};return Nn(n,function(n,r){Nn(n,function(n,e){var t=kn(e,[])(i);i[e]=t.concat([o(r,n)])})}),i}function kd(n){return n.cHandler}function Ed(n,e){return{name:v(n),handler:v(e)}}function Cd(n,e,t){var r=x(x({},t),function(n,e){var t={};return C(n,function(n){t[n.name()]=n.handlers(e)}),t}(e,n));return Od(r,Ed)}function Dd(n){var i=function(n){return xe(n)?{can:v(!0),abort:v(!1),run:n}:n}(n);return function(n,e){for(var t=[],r=2;r "):r[0].name();return En(o,function(n,e){return{handler:n,purpose:v(e)}}(e,t))})});return Dn(e,{})},Lm=function(n){var e=Xt("external.component",Pt([Yt("element"),Qt("uid")]),n),t=Zn(Td());e.uid.each(function(n){df(e.element,n)});var r={getSystem:t.get,config:An.none,hasConfigured:v(!1),connect:function(n){t.set(n)},disconnect:function(){t.set(Td(function(){return r}))},getApis:function(){return{}},element:v(e.element),spec:v(n),readState:v("No state"),syncComponents:w,components:v([]),events:v({})};return Dc(r)},Gm=Ic,Um=function(e){return function(n){return Dt(n,cf)}(e).fold(function(){var n=e.hasOwnProperty("uid")?e:x({uid:Gm("")},e);return _d(n).getOrDie()},function(n){return n})},$m=Dc,Wm="alloy.item-hover",Xm="alloy.item-focus",qm=v(Wm),Ym=v(Xm),Km=[Yt("data"),Yt("components"),Yt("dom"),tr("hasSubmenu",!1),Qt("toggling"),Va("itemBehaviours",[Fi,zi,Ba,fl]),tr("ignoreFocus",!1),tr("domModification",{}),ni("builder",function(n){return{dom:n.dom,domModification:x(x({},n.domModification),{attributes:x(x(x({role:n.toggling.isSome()?"menuitemcheckbox":"menuitem"},n.domModification.attributes),{"aria-haspopup":n.hasSubmenu}),n.hasSubmenu?{"aria-expanded":!1}:{})}),behaviours:Na(n.itemBehaviours,[n.toggling.fold(Fi.revoke,function(n){return Fi.config(x({aria:{mode:"checked"}},n))}),zi.config({ignore:n.ignoreFocus,stopMousedown:n.ignoreFocus,onFocus:function(n){zd(n)}}),Ba.config({mode:"execution"}),fl.config({store:{mode:"memory",initialValue:n.data}}),sm("item-type-events",[_r(ze(),$),Lr(Ln()),_r($n(),Hd),_r(Pe(),zi.focus)])]),components:n.components,eventOrder:n.eventOrder}}),tr("eventOrder",{})],Jm=[Yt("dom"),Yt("components"),ni("builder",function(n){return{dom:n.dom,components:n.components,events:Nr([function(n){return _r(n,function(n,e){e.stop()})}(Pe())])}})],Qm=v([ef({name:"widget",overrides:function(e){return{behaviours:Bo([fl.config({store:{mode:"manual",getValue:function(n){return e.data},setValue:function(){}}})])}}})]),Zm=[Yt("uid"),Yt("data"),Yt("components"),Yt("dom"),tr("autofocus",!1),tr("ignoreFocus",!1),Va("widgetBehaviours",[fl,zi,Ba]),tr("domModification",{}),Cc(Qm()),ni("builder",function(t){function r(n){return Oc(n,t,"widget").map(function(n){return Ba.focusIn(n),n})}function n(n,e){return Mu(e.event().target())||t.autofocus&&e.setSource(n.element()),An.none()}var e=Sc(0,t,Qm()),o=Tc("item-widget",t,e.internals());return{dom:t.dom,components:o,domModification:t.domModification,events:Nr([Mo(function(n,e){r(n).each(function(n){e.stop()})}),_r($n(),Hd),_r(Pe(),function(n,e){t.autofocus?r(n):zi.focus(n)})]),behaviours:Na(t.widgetBehaviours,[fl.config({store:{mode:"memory",initialValue:t.data}}),zi.config({ignore:t.ignoreFocus,onFocus:function(n){zd(n)}}),Ba.config({mode:"special",focusIn:t.autofocus?function(n){r(n)}:jo(),onLeft:n,onRight:n,onEscape:function(n,e){return zi.isFocused(n)||t.autofocus?(t.autofocus&&e.setSource(n.element()),An.none()):(zi.focus(n),An.some(!0))}})])}})],ng=qt("type",{widget:Zm,item:Km,separator:Jm}),eg=v([rf({factory:{sketch:function(n){var e=Xt("menu.spec item",ng,n);return e.builder(e)}},name:"items",unit:"item",defaults:function(n,e){return e.hasOwnProperty("uid")?e:x(x({},e),{uid:Ic("item")})},overrides:function(n,e){return{type:e.type,ignoreFocus:n.fakeFocus,domModification:{classes:[n.markers.item]}}}})]),tg=v([Yt("value"),Yt("items"),Yt("dom"),Yt("components"),tr("eventOrder",{}),dc("menuBehaviours",[Eu,fl,mm,Ba]),rr("movement",{mode:"menu",moveOnTab:!0},qt("mode",{grid:[Oi(),ni("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers.item,initSize:{numColumns:e.initSize.numColumns,numRows:e.initSize.numRows},focusManager:n.focusManager}})],matrix:[ni("config",function(n,e){return{mode:"matrix",selectors:{row:e.rowSelector,cell:"."+n.markers.item},focusManager:n.focusManager}}),Yt("rowSelector")],menu:[tr("moveOnTab",!0),ni("config",function(n,e){return{mode:"menu",selector:"."+n.markers.item,moveOnTab:e.moveOnTab,focusManager:n.focusManager}})]})),Kt("markers",Si()),tr("fakeFocus",!1),tr("focusManager",gu()),Ko("onHighlight")]),rg=v("alloy.menu-focus"),og=hf({name:"Menu",configFields:tg(),partFields:eg(),factory:function(n,e,t,r){return{uid:n.uid,dom:n.dom,markers:n.markers,behaviours:gc(n.menuBehaviours,[Eu.config({highlightClass:n.markers.selectedItem,itemClass:n.markers.item,onHighlight:n.onHighlight}),fl.config({store:{mode:"memory",initialValue:n.value}}),mm.config({find:An.some}),Ba.config(n.movement.config(n,n.movement))]),events:Nr([_r(Ym(),function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){Eu.highlight(e,n),t.stop(),U(e,rg(),{menu:e,item:n})})}),_r(qm(),function(n,e){var t=e.event().item();Eu.highlight(n,t)})]),components:e,eventOrder:n.eventOrder,domModification:{attributes:{role:"menu"}}}}}),ig=function(n,e){return n.components()},ug=qr({fields:[],name:"replacing",apis:/* */Object.freeze({append:function(n,e,t,r){Ld(n,0,ft,r)},prepend:function(n,e,t,r){Ld(n,0,mn,r)},remove:Gd,replaceAt:Ud,replaceBy:function(e,n,t,r,o){var i=ig(e);return F(i,r).bind(function(n){return Ud(e,0,0,n,o)})},set:function(e,n,t,r){!function(n,t){var r=an(t),e=mo(r).bind(function(e){function n(n){return cn(e,n)}return n(t)?An.some(t):Vr(t,n)}),o=n(t);e.each(function(e){mo(r).filter(function(n){return cn(n,e)}).fold(function(){so(e)},w)})}(function(){var n=ke(r,e.getSystem().build);vn(e,n)},e.element())},contents:ig})}),cg=function(t,r,o,n){return Dt(o,n).bind(function(n){return Dt(t,n).bind(function(n){var e=cg(t,r,o,n);return An.some([n].concat(e))})}).getOr([])},ag=function(n){return"prepared"===n.type?An.some(n.menu):An.none()},fg={init:function(){function o(t){return function(n,e){for(var t=Bn(n),r=0,o=t.length;r");r[t[0]]=En(t[1],n),r[t[1]]=En(t[0],n)}),r},createBistate:function(n,e,t){return Cn([{key:n,value:En(e,t)},{key:e,value:En(n,t)}])},createTristate:function(n,e,t,r){return Cn([{key:n,value:Cn([{key:e,value:r},{key:t,value:r}])},{key:e,value:Cn([{key:n,value:r},{key:t,value:r}])},{key:t,value:Cn([{key:n,value:r},{key:e,value:r}])}])}}}),yg=ji.resolve("scrollable"),bg={register:function(n){io(n,yg)},deregister:function(n){co(n,yg)},scrollable:v(yg)},xg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[ji.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:ji.resolve("format-matches"),selected:t},itemBehaviours:Bo(o?[]:[Ai(n,function(n,e){(e?Fi.on:Fi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},wg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[zs.sketch({dom:{tag:"div",classes:[ji.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[ji.resolve("styles-collapse-icon")]}},Pd(n)]:[Pd(n)],action:function(n){if(r){var e=t().get(n);lg.collapseMenu(e)}}}),{dom:{tag:"div",classes:[ji.resolve("styles-menu-items-container")]},components:[og.parts().items({})],behaviours:Bo([sm("adhoc-scrollable-menu",[Eo(function(n,e){Li(n.element(),"overflow-y","auto"),Li(n.element(),"-webkit-overflow-scrolling","touch"),bg.register(n.element())}),Co(function(n){gi(n.element(),"overflow-y"),gi(n.element(),"-webkit-overflow-scrolling"),bg.deregister(n.element())})])])}],items:e,menuBehaviours:Bo([vg.config({initialState:"after",routes:vg.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},Sg=function(r){var n=function(r,o){var n=wg("Styles",[].concat(ke(r.items,function(n){return xg(Yd(n),n.title,n.isSelected(),n.getPreview(),Mn(r.expansions,Yd(n)))})),o,!1),e=S(r.menus,function(n,e){var t=ke(n,function(n){return xg(Yd(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Mn(r.expansions,Yd(n)))});return wg(e,t,o,!0)}),t=xt(e,En("styles",n));return{tmenu:lg.tieredData("styles",t,r.expansions)}}(r.formats,function(){return e}),e=Ns(lg.sketch({dom:{tag:"div",classes:[ji.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=fl.getValue(e);return r.handle(e,t.value),An.none()},onEscape:function(){return An.none()},onOpenMenu:function(n,e){var t=Df(n.element());Cf(e.element(),t),vg.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Df(n.element()),o=Ki(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Cf(t.element(),r),vg.progressTo(i,"before"),vg.jumpTo(t,"after"),vg.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=Ki(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();vg.progressTo(o,"after"),vg.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:n.tmenu,markers:{backgroundMenu:ji.resolve("styles-background-menu"),menu:ji.resolve("styles-menu"),selectedMenu:ji.resolve("styles-selected-menu"),item:ji.resolve("styles-item"),selectedItem:ji.resolve("styles-selected-item")}}));return e.asSpec()},Tg=function(n){return M(n,function(n,e){var t=Kd(e);return{menus:xt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:xt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Og={expand:Tg},kg=function(r,n){function o(n){return function(){return r.formatter.match(n)}}function i(n){return function(){return r.formatter.getCssText(n)}}var e=Dt(n,"style_formats").getOr(Vm),t=function(n){return ke(n,function(n){if(Mn(n,"items")){var e=t(n.items);return xt(function(n){return xt(n,{isSelected:v(!1),getPreview:v("")})}(n),{items:e})}return Mn(n,"format")?function(n){return xt(n,{isSelected:o(n.format),getPreview:i(n.format)})}(n):function(n){var e=vc(n.title),t=xt(n,{format:e,isSelected:o(e),getPreview:i(e)});return r.formatter.register(e,t),t}(n)})};return t(e)},Eg=function(t,n,r){var e=function(e,n){var t=function(n){return B(n,function(n){return n.items===undefined?!Mn(n,"format")||e.formatter.canApply(n.format)?[n]:[]:0e.innerHeight||n.bottom()>e.innerHeight?n.bottom()-e.innerHeight+50:0;0!=t&&e.scrollTo(e.pageXOffset,e.pageYOffset+t)})})].concat(!0==Hg?[]:[em(Je.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Fi.off)}),em(u,"select",n),em(r.doc(),"selectionchange",n)]);return{destroy:function(){C(c,function(n){n.unbind()})}}},Lg=function(n,e){var t=parseInt(Qr(n,e),10);return isNaN(t)?0:t};function Gg(n){return Mp.getOption(n)}function Ug(n){return function(n){return Gg(n).filter(function(n){return 0!==n.trim().length||-1=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function Jg(t,r,n,e,o){function i(n){var e=t.dom().createRange();return e.setStart(r.dom(),n),e.collapse(!0),e}var u=function(n){return Mp.get(n)}(r).length,c=function(n,e,t,r,o){if(0===o)return 0;if(e===r)return o-1;for(var i=r,u=1;un.innerHeight||e.bottom()>n.innerHeight?Math.min(t,e.bottom()-n.innerHeight+50):0}(r,n,t);0!==e&&r.scrollTo(r.pageXOffset,r.pageYOffset+e)})}),pp(e,n.innerHeight)});pp(e,n.innerHeight);return{toEditing:function(){Hp(r)},destroy:function(){t.unbind()}}},Gp={getBody:Tp("getBody",yp),getDoc:Tp("getDoc",bp),getWin:Tp("getWin",xp),getSelection:Tp("getSelection",wp),getFrame:Sp,getActiveApi:function(c){var a=Sp(c);return yp(a).bind(function(u){return bp(a).bind(function(i){return xp(a).map(function(o){var n=Je.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return function(n){return sp(n).map(function(n){return Vp.exact(n.start(),n.soffset(),n.finish(),n.foffset())})}(o).bind(function(n){return lp(o,n).orThunk(function(){return function(n){return sp(n).filter(function(n){return cn(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0