/** * 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.5 (2019-12-19) */ !function(l){"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 br.objOf(de(r,function(n){return n.fold(function(n,e,t,r){return xr.field(n,t,r)},function(n,e){return xr.state(n)})}))}}},Tr=b(_t(sr)),Or=wr.state,kr=wr.field,Er=_t(sr),Cr=function(n){return"Errors: \n"+function(n){var e=10 ")+")\n"+n.getErrorInfo()})}(n.errors)+"\n\nInput object: "+Ft(n.input)},Dr=b(Er),Mr=(ur=ce,cr="function",_t(function(n){var e=typeof n;return ur(n)?sr(n):dr("Expected type: "+cr+" but got: "+e)}));function Ir(n,e,t,r,o){return n(t,r)?Fn.some(t):ce(o)&&o(t)?Fn.none():e(t,r,o)}function Rr(n,e,t){for(var r=n.dom(),o=ce(t)?t:b(!1);r.parentNode;){r=r.parentNode;var i=Je.fromDom(r);if(e(i))return Fn.some(i);if(o(i))break}return Fn.none()}function Ar(n,e,t){return Ir(function(n,e){return e(n)},Rr,n,e,t)}function Fr(n,o){var i=function(n){for(var e=0;e"}),Dr()),Ka=or("schema",function(){return[Qt("preprocess")]}),Ja=tr("defaults",b({})),Qa=tr("overrides",b({})),Za=Sr([Wa,Xa,qa,Ya,Ja,Qa]),nf=Sr([Wa,Xa,qa,Ya,Ja,Qa]),ef=Sr([Wa,Ka,qa,Yt("unit"),Ya,Ja,Qa]),tf=xc($a.required,Za),rf=xc($a.optional,nf),of=xc($a.group,ef),uf=b("entirety"),cf=function(n,e){return{uiType:Ga(),owner:n,name:e}},af=yc("alloy-premade"),ff=b("alloy-id-"),sf=b("data-alloy-id"),lf=ff(),df=sf(),mf=function(n,e){Object.defineProperty(n.dom(),df,{value:e,writable:!0})},gf=function(n){var e=et(n)?n.dom()[df]:null;return Fn.from(e)},pf=function(n){return n.hasOwnProperty("uid")?n:x(x({},n),{uid:Rc("uid")})};function hf(n){var e=Xt("Sketcher for "+n.name,Hs,n),t=S(e.apis,Ic),r=S(e.extraApis,function(n,e){return Gr(n,e)});return x(x({name:b(e.name),partFields:b([]),configFields:b(e.configFields),sketch:function(n){return function(n,e,t,r){var o=pf(r);return t(Ac(n,e,o,[],[]),o)}(e.name,e.configFields,e.factory,n)}},t),r)}function vf(n){var e=Xt("Sketcher for "+n.name,zs,n),t=Sc(e.name,e.partFields),r=S(e.apis,Ic),o=S(e.extraApis,function(n,e){return Gr(n,e)});return x(x({name:b(e.name),partFields:b(e.partFields),configFields:b(e.configFields),sketch:function(n){return Fc(e.name,e.configFields,e.partFields,e.factory,n)},parts:b(t)},r),o)}function yf(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 bf(n){return{dom:Us(n)}}function xf(n){return Bo([Fi.config({toggleClass:_i.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Bi(n,function(n,e){(e?Fi.on:Fi.off)(n)})])}function wf(n,e){var t=e.ui.registry.getAll().icons;return Fn.from(t[n]).fold(function(){return Us('')},function(n){return Us(''+n+"")})}function Sf(e){return rf({name:e+"-edge",overrides:function(n){return n.model.manager.edgeActions[e].fold(function(){return{}},function(r){return{events:Nr([Pr(xe(),r,[n]),Pr(Te(),r,[n]),Pr(Oe(),function(n,e,t){t.mouseIsDown.get()&&r(n,t)},[n])])}})}})}function Tf(n,e,t){e.store.manager.onLoad(n,e,t)}function Of(n,e,t){e.store.manager.onUnload(n,e,t)}function kf(){var n=Pn(null);return Fo({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 Ef(){var i=Pn({}),u=Pn({});return Fo({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 Cf(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)}function Df(n,e){sl.set(n,e)}function Mf(n){return sl.get(n)}function If(n){var e=n.event().raw();if(function(n){return-1!==n.type.indexOf("touch")}(e)){var t=e;return t.touches!==undefined&&1===t.touches.length?Fn.some(t.touches[0]).map(function(n){return dl(n.clientX,n.clientY)}):Fn.none()}var r=e;return r.clientX!==undefined?Fn.some(r).map(function(n){return dl(n.clientX,n.clientY)}):Fn.none()}function Rf(n){return n.model.minX}function Af(n){return n.model.minY}function Ff(n){return n.model.minX-1}function Bf(n){return n.model.minY-1}function Vf(n){return n.model.maxX}function Nf(n){return n.model.maxY}function jf(n){return n.model.maxX+1}function _f(n){return n.model.maxY+1}function Pf(n,e,t){return e(n)-t(n)}function Hf(n){return Pf(n,Vf,Rf)}function zf(n){return Pf(n,Nf,Af)}function Lf(n){return Hf(n)/2}function Gf(n){return zf(n)/2}function Uf(n){return n.stepSize}function $f(n){return n.snapToGrid}function Wf(n){return n.snapStart}function Xf(n){return n.rounded}function qf(n,e){return n[e+"-edge"]!==undefined}function Yf(n){return qf(n,"left")}function Kf(n){return qf(n,"right")}function Jf(n){return qf(n,"top")}function Qf(n){return qf(n,"bottom")}function Zf(n){return n.model.value.get()}function ns(n){return{x:b(n)}}function es(n){return{y:b(n)}}function ts(n,e){return{x:b(n),y:b(e)}}function rs(n,e){U(n,ml(),{value:e})}function os(n,e,t,r){return n'),components:[Vl.parts()["left-edge"](bf('
')),Vl.parts().spectrum({dom:Us('
'),components:[bf('
')],behaviours:Bo([Fi.config({toggleClass:_i.resolve("thumb-active")})])}),Vl.parts()["right-edge"](bf('
')),Vl.parts().thumb({dom:Us('
'),behaviours:Bo([Fi.config({toggleClass:_i.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Gi(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());Gi(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:Bo([Vi(Vl.refresh)])})}(n)]}function Vs(n){var e=n.selection.getStart(),t=Je.fromDom(e),r=Je.fromDom(n.getBody()),o=function(e,n){return(et(n)?Fn.some(n):fn(n).filter(et)).map(function(n){return Ar(n,function(n){return gi(n,"font-size").isSome()},e).bind(function(n){return gi(n,"font-size")}).getOrThunk(function(){return mi(n,"font-size")})}).getOr("")}(function(n){return cn(r,n)},t);return R(Pl,function(n){return o===n}).getOr("medium")}function Ns(n){return[bf(''),function(n){return _l({onChange:n.onChange,sizes:zl,category:"font",getInitialValue:n.getInitialValue})}(n),bf('')]}function js(n){var e=function t(n){return n.uid!==undefined}(n)&&Mn(n,"uid")?n.uid:Rc("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 _s,Ps,Hs=Pt([Yt("name"),Yt("factory"),Yt("configFields"),tr("apis",{}),tr("extraApis",{})]),zs=Pt([Yt("name"),Yt("factory"),Yt("configFields"),Yt("partFields"),tr("apis",{}),tr("extraApis",{})]),Ls=hf({name:"Button",factory:function(n){function t(e){return Dt(n.dom,"attributes").bind(function(n){return Dt(n,e)})}var e=function(n){return Nr(F([n.map(function(t){return Mo(function(n,e){t(n),e.stop()})}).toArray(),ai()]))}(n.action),r=n.dom.tag;return{uid:n.uid,dom:n.dom,components:n.components,events:e,behaviours:ja(n.buttonBehaviours,[Li.config({}),Va.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",[]),Na("buttonBehaviours",[Li,Va]),Qt("action"),Qt("role"),tr("eventOrder",{})]}),Gs=qr({fields:[],name:"unselecting",active:/* */Object.freeze({events:function(n){return Nr([jr(Fe(),b(!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"}})}})}),Us=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:_i.prefix()});return yf(e)},$s=function(n,e,t,r){return Ls.sketch({dom:wf(n,r),action:e,buttonBehaviours:xt(Bo([Gs.config({})]),t)})},Ws={forToolbar:$s,forToolbarCommand:function(n,e){return $s(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=xf(t);return $s(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=xf(e);return $s(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:wf},Xs=rf({schema:[Yt("dom")],name:"label"}),qs=Sf("top-left"),Ys=Sf("top"),Ks=Sf("top-right"),Js=Sf("right"),Qs=Sf("bottom-right"),Zs=Sf("bottom"),nl=Sf("bottom-left"),el=[Xs,Sf("left"),Js,Ys,Zs,qs,Ks,nl,Qs,tf({name:"thumb",defaults:b({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Nr([zr(xe(),n,"spectrum"),zr(we(),n,"spectrum"),zr(Se(),n,"spectrum"),zr(Te(),n,"spectrum"),zr(Oe(),n,"spectrum"),zr(ke(),n,"spectrum")])}}}),tf({schema:[or("mouseIsDown",function(){return Pn(!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;return{behaviours:Bo([Va.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)}}),Li.config({})]),events:Nr([_r(xe(),r),_r(we(),r),_r(Te(),r),_r(Oe(),function(n,e){t.mouseIsDown.get()&&r(n,e)})])}}})],tl=/* */Object.freeze({onLoad:Tf,onUnload:Of,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){Tf(n,t,r)}),Co(function(n,e){Of(n,t,r)})]:[$r(t,r,Tf)];return Nr(n)}}),ol=/* */Object.freeze({memory:kf,dataset:Ef,manual:function(){return Fo({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),il=[Qt("initialValue"),Yt("getFallbackEntry"),Yt("getDataKey"),Yt("setValue"),ni("manager",{setValue:Cf,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){Cf(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:Ef})],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:Ao.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:kf})],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=$i("width",function(n){return n.dom().offsetWidth}),ll=function(t,r){return{left:b(t),top:b(r),translate:function(n,e){return ll(t+n,r+e)}}},dl=ll,ml=b("slider.change.value"),gl="left",pl=Ts(-1),hl=Ts(1),vl=Fn.none,yl=Fn.none,bl={"top-left":Fn.none(),top:Fn.none(),"top-right":Fn.none(),right:Fn.some(function(n,e){rs(n,ns(jf(e)))}),"bottom-right":Fn.none(),bottom:Fn.none(),"bottom-left":Fn.none(),left:Fn.some(function(n,e){rs(n,ns(Ff(e)))})},xl=/* */Object.freeze({setValueFrom:function(n,e,t){var r=Ss(n,e,t),o=ws(r);return xs(n,o),r},setToMin:function(n,e){var t=Rf(e);xs(n,ws(t))},setToMax:function(n,e){var t=Vf(e);xs(n,ws(t))},findValueOfOffset:Ss,getValueFromEvent:function(n){return If(n).map(function(n){return n.left()})},findPositionOfValue:Os,setPositionFromValue:function(n,e,t,r){var o=Zf(t),i=Os(n,r.getSpectrum(n),o.x(),r.getLeftEdge(n),r.getRightEdge(n),t),u=Mf(e.element())/2;Gi(e.element(),"left",i-u+"px")},onLeft:pl,onRight:hl,onUp:vl,onDown:yl,edgeActions:bl}),wl=Fn.none,Sl=Fn.none,Tl=Ds(-1),Ol=Ds(1),kl={"top-left":Fn.none(),top:Fn.some(function(n,e){rs(n,es(Bf(e)))}),"top-right":Fn.none(),right:Fn.none(),"bottom-right":Fn.none(),bottom:Fn.some(function(n,e){rs(n,es(_f(e)))}),"bottom-left":Fn.none(),left:Fn.none()},El=/* */Object.freeze({setValueFrom:function(n,e,t){var r=Cs(n,e,t),o=Es(r);return ks(n,o),r},setToMin:function(n,e){var t=Af(e);ks(n,Es(t))},setToMax:function(n,e){var t=Nf(e);ks(n,Es(t))},findValueOfOffset:Cs,getValueFromEvent:function(n){return If(n).map(function(n){return n.top()})},findPositionOfValue:Ms,setPositionFromValue:function(n,e,t,r){var o=Zf(t),i=Ms(n,r.getSpectrum(n),o.y(),r.getTopEdge(n),r.getBottomEdge(n),t),u=Wi(e.element())/2;Gi(e.element(),"top",i-u+"px")},onLeft:wl,onRight:Sl,onUp:Tl,onDown:Ol,edgeActions:kl}),Cl=As(-1,!1),Dl=As(1,!1),Ml=As(-1,!0),Il=As(1,!0),Rl={"top-left":Fn.some(function(n,e){rs(n,ts(Ff(e),Bf(e)))}),top:Fn.some(function(n,e){rs(n,ts(Lf(e),Bf(e)))}),"top-right":Fn.some(function(n,e){rs(n,ts(jf(e),Bf(e)))}),right:Fn.some(function(n,e){rs(n,ts(jf(e),Gf(e)))}),"bottom-right":Fn.some(function(n,e){rs(n,ts(jf(e),_f(e)))}),bottom:Fn.some(function(n,e){rs(n,ts(Lf(e),_f(e)))}),"bottom-left":Fn.some(function(n,e){rs(n,ts(Ff(e),_f(e)))}),left:Fn.some(function(n,e){rs(n,ts(Ff(e),Gf(e)))})},Al=/* */Object.freeze({setValueFrom:function(n,e,t){var r=Ss(n,e,t.left()),o=Cs(n,e,t.top()),i=Rs(r,o);return Is(n,i),i},setToMin:function(n,e){var t=Rf(e),r=Af(e);Is(n,Rs(t,r))},setToMax:function(n,e){var t=Vf(e),r=Nf(e);Is(n,Rs(t,r))},getValueFromEvent:function(n){return If(n)},setPositionFromValue:function(n,e,t,r){var o=Zf(t),i=Os(n,r.getSpectrum(n),o.x(),r.getLeftEdge(n),r.getRightEdge(n),t),u=Ms(n,r.getSpectrum(n),o.y(),r.getTopEdge(n),r.getBottomEdge(n),t),c=Mf(e.element())/2,a=Wi(e.element())/2;Gi(e.element(),"left",i-c+"px"),Gi(e.element(),"top",u-a+"px")},onLeft:Cl,onRight:Dl,onUp:Ml,onDown:Il,edgeActions:Rl}),Fl=[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 Pn(n.mode.minX)}),Yt("getInitialValue"),ni("manager",xl)],y:[tr("minY",0),tr("maxY",100),or("value",function(n){return Pn(n.mode.minY)}),Yt("getInitialValue"),ni("manager",El)],xy:[tr("minX",0),tr("maxX",100),tr("minY",0),tr("maxY",100),or("value",function(n){return Pn({x:b(n.mode.minX),y:b(n.mode.minY)})}),Yt("getInitialValue"),ni("manager",Al)]})),mc("sliderBehaviours",[Va,fl]),or("mouseIsDown",function(){return Pn(!1)})],Bl=b("mouse.released"),Vl=vf({name:"Slider",configFields:Fl,partFields:el,factory:function(i,n,e,t){function u(n){return Ec(n,i,"thumb")}function c(n){return Ec(n,i,"spectrum")}function r(n){return kc(n,i,"left-edge")}function o(n){return kc(n,i,"right-edge")}function a(n){return kc(n,i,"top-edge")}function f(n){return kc(n,i,"bottom-edge")}function s(n,e){v.setPositionFromValue(n,e,i,{getLeftEdge:r,getRightEdge:o,getTopEdge:a,getBottomEdge:f,getSpectrum:c})}function l(n,e){h.value.set(e);var t=u(n);return s(n,t),i.onChange(n,t,e),Fn.some(!0)}function d(t){var n=i.mouseIsDown.get();i.mouseIsDown.set(!1),n&&kc(t,i,"thumb").each(function(n){var e=h.value.get();i.onChoose(t,n,e)})}function m(n,e){e.stop(),i.mouseIsDown.set(!0),i.onDragStart(n,u(n))}function g(n,e){e.stop(),i.onDragEnd(n,u(n)),d(n)}var p,h=i.model,v=h.manager;return{uid:i.uid,dom:i.dom,components:n,behaviours:pc(i.sliderBehaviours,[Va.config({mode:"special",focusIn:function(n){return kc(n,i,"spectrum").map(Va.focusIn).map(b(!0))}}),fl.config({store:{mode:"manual",getValue:function(n){return h.value.get()}}}),Ci.config({channels:(p={},p[Bl()]={onReceive:d},p)})]),events:Nr([_r(ml(),function(n,e){l(n,e.event().value())}),Eo(function(n,e){var t=h.getInitialValue();h.value.set(t);var r=u(n);s(n,r);var o=c(n);i.onInit(n,r,o,h.value.get())}),_r(xe(),m),_r(Se(),g),_r(Te(),m),_r(ke(),g)]),apis:{resetToMin:function(n){v.setToMin(n,i)},resetToMax:function(n){v.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)}}}),Nl=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 Bs(e)},r)},jl=Pt([Yt("getInitialValue"),Yt("onChange"),Yt("category"),Yt("sizes")]),_l=function(n){var o=Xt("SizeSlider",jl,n);return Vl.sketch({dom:{tag:"div",classes:[_i.resolve("slider-"+o.category+"-size-container"),_i.resolve("slider"),_i.resolve("slider-size-container")]},onChange:function(n,e,t){var r=t.x();!function(n){return 0<=n&&n'),components:[bf('
')]}),Vl.parts().thumb({dom:Us('
'),behaviours:Bo([Fi.config({toggleClass:_i.resolve("thumb-active")})])})]})},Pl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Hl={candidates:b(Pl),get:function(n){return function(e){return A(Pl,function(n){return n===e})}(Vs(n)).getOr(2)},apply:function(e,n){(function(n){return Fn.from(Pl[n])})(n).each(function(n){!function(n,e){Vs(n)!==e&&n.execCommand("fontSize",!1,e)}(e,n)})}},zl=Hl.candidates(),Ll=window.Promise?window.Promise:(_s=Gl.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){l.setTimeout(n,1)},Ps=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)},Gl.prototype["catch"]=function(n){return this.then(null,n)},Gl.prototype.then=function(t,r){var o=this;return new Gl(function(n,e){$l.call(o,new Yl(t,r,n,e))})},Gl.all=function(){for(var n=[],e=0;e'),action:function(n){var e=t.get(n);fl.setValue(e,"")}}));return{name:n,spec:dm.sketch({dom:Us('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:Bo([Fi.config({toggleClass:_i.resolve("input-container-empty")}),lm.config({find:function(n){return Fn.some(t.get(n))}}),am("input-clearing",[_r(Me(),function(n){var e=t.get(n);(0"}function yd(){function e(){t.get().each(function(n){n.destroy()})}var t=Pn(Fn.none());return{clear:function(){e(),t.set(Fn.none())},isSet:function(){return t.get().isSome()},set:function(n){e(),t.set(Fn.some(n))},run:function(n){t.get().each(n)}}}function bd(){var e=Pn(Fn.none());return{clear:function(){e.set(Fn.none())},set:function(n){e.set(Fn.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}}function xd(n){function r(e,n,t){return Ls.sketch({dom:Us(''),action:function(n){U(n,u,{direction:e})},buttonBehaviours:Bo([km.config({disableClass:_i.resolve("toolbar-navigation-disabled"),disabled:!t})])})}function o(n,o){var i=Yi(n.element(),"."+_i.resolve("serialised-dialog-screen"));Qi(n.element(),"."+_i.resolve("serialised-dialog-chain")).each(function(r){0<=c.state.currentScreen.get()+o&&c.state.currentScreen.get()+o'),components:[dm.sketch({dom:Us('
'),components:de(c.fields,function(n,e){return e<=c.maxFieldIndex?dm.sketch({dom:Us('
'),components:[r(-1,"previous",0'),behaviours:Bo([Cu.config({highlightClass:_i.resolve("dot-active"),itemClass:_i.resolve("dot-item")})]),components:B(c.fields,function(n,e){return e<=c.maxFieldIndex?[bf('
')]:[]})});return{dom:Us('
'),components:[a.asSpec(),f.asSpec()],behaviours:Bo([Va.config({mode:"special",focusIn:function(n){var e=a.get(n);Va.focusIn(e)}}),am("serializer-wrapper-events",[_r(xe(),function(n,e){var t=e.event();c.state.dialogSwipeState.set(Mm(t.raw().touches[0].clientX))}),_r(we(),function(n,e){var t=e.event();c.state.dialogSwipeState.on(function(n){e.event().prevent(),c.state.dialogSwipeState.set(Im(n,t.raw().touches[0].clientX))})}),_r(Se(),function(r){c.state.dialogSwipeState.on(function(n){var e=a.get(r),t=-1*Rm(n);o(e,t)})})])])}}function wd(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:b("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:b(!1)}}function Sd(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 Td(n){return n.cHandler}function Od(n,e){return{name:b(n),handler:b(e)}}function kd(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 Sd(r,Od)}function Ed(n){var i=function(n){return ce(n)?{can:b(!0),abort:b(!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:b(e)}}(e,t))})});return Dn(e,{})},Hm=function(n){var e=Xt("external.component",Pt([Yt("element"),Qt("uid")]),n),t=Pn(wd());e.uid.each(function(n){mf(e.element,n)});var r={getSystem:t.get,config:Fn.none,hasConfigured:b(!1),connect:function(n){t.set(n)},disconnect:function(){t.set(wd(function(){return r}))},getApis:function(){return{}},element:b(e.element),spec:b(n),readState:b("No state"),syncComponents:w,components:b([]),events:b({})};return Mc(r)},zm=Rc,Lm=function(e){return function(n){return Dt(n,af)}(e).fold(function(){var n=e.hasOwnProperty("uid")?e:x({uid:zm("")},e);return Nd(n).getOrDie()},function(n){return n})},Gm=Mc,Um="alloy.item-hover",$m="alloy.item-focus",Wm=b(Um),Xm=b($m),qm=[Yt("data"),Yt("components"),Yt("dom"),tr("hasSubmenu",!1),Qt("toggling"),Na("itemBehaviours",[Fi,Li,Va,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:ja(n.itemBehaviours,[n.toggling.fold(Fi.revoke,function(n){return Fi.config(x({aria:{mode:"checked"}},n))}),Li.config({ignore:n.ignoreFocus,stopMousedown:n.ignoreFocus,onFocus:function(n){Pd(n)}}),Va.config({mode:"execution"}),fl.config({store:{mode:"memory",initialValue:n.data}}),am("item-type-events",function a(){for(var n=0,e=0,t=arguments.length;e");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}])}])}}}),hg=_i.resolve("scrollable"),vg={register:function(n){io(n,hg)},deregister:function(n){co(n,hg)},scrollable:b(hg)},yg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[_i.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:_i.resolve("format-matches"),selected:t},itemBehaviours:Bo(o?[]:[Bi(n,function(n,e){(e?Fi.on:Fi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},bg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Ls.sketch({dom:{tag:"div",classes:[_i.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[_i.resolve("styles-collapse-icon")]}},jd(n)]:[jd(n)],action:function(n){if(r){var e=t().get(n);fg.collapseMenu(e)}}}),{dom:{tag:"div",classes:[_i.resolve("styles-menu-items-container")]},components:[tg.parts().items({})],behaviours:Bo([am("adhoc-scrollable-menu",[Eo(function(n,e){Gi(n.element(),"overflow-y","auto"),Gi(n.element(),"-webkit-overflow-scrolling","touch"),vg.register(n.element())}),Co(function(n){pi(n.element(),"overflow-y"),pi(n.element(),"-webkit-overflow-scrolling"),vg.deregister(n.element())})])])}],items:e,menuBehaviours:Bo([pg.config({initialState:"after",routes:pg.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},xg=function(r){var n=function(r,o){var n=bg("Styles",[].concat(de(r.items,function(n){return yg(Xd(n),n.title,n.isSelected(),n.getPreview(),Mn(r.expansions,Xd(n)))})),o,!1),e=S(r.menus,function(n,e){var t=de(n,function(n){return yg(Xd(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Mn(r.expansions,Xd(n)))});return bg(e,t,o,!0)}),t=xt(e,En("styles",n));return{tmenu:fg.tieredData("styles",t,r.expansions)}}(r.formats,function(){return e}),e=js(fg.sketch({dom:{tag:"div",classes:[_i.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=fl.getValue(e);return r.handle(e,t.value),Fn.none()},onEscape:function(){return Fn.none()},onOpenMenu:function(n,e){var t=Mf(n.element());Df(e.element(),t),pg.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Mf(n.element()),o=Ji(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Df(t.element(),r),pg.progressTo(i,"before"),pg.jumpTo(t,"after"),pg.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=Ji(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();pg.progressTo(o,"after"),pg.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:n.tmenu,markers:{backgroundMenu:_i.resolve("styles-background-menu"),menu:_i.resolve("styles-menu"),selectedMenu:_i.resolve("styles-selected-menu"),item:_i.resolve("styles-item"),selectedItem:_i.resolve("styles-selected-item")}}));return e.asSpec()},wg=function(n){return M(n,function(n,e){var t=qd(e);return{menus:xt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:xt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Sg={expand:wg},Tg=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(Fm),t=function(n){return de(n,function(n){if(Mn(n,"items")){var e=t(n.items);return xt(function(n){return xt(n,{isSelected:b(!1),getPreview:b("")})}(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=yc(n.title),t=xt(n,{format:e,isSelected:o(e),getPreview:i(e)});return r.formatter.register(e,t),t}(n)})};return t(e)},Og=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==_g?[]:[Zd(Je.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Fi.off)}),Zd(u,"select",n),Zd(r.doc(),"selectionchange",n)]);return{destroy:function(){C(c,function(n){n.unbind()})}}},Hg=function(n,e){var t=parseInt(Qr(n,e),10);return isNaN(t)?0:t};function zg(n){return Cp.getOption(n)}function Lg(n){return function(n){return zg(n).filter(function(n){return 0!==n.trim().length||-1=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom}function Yg(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 Cp.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)})}),mp(e,n.innerHeight)});mp(e,n.innerHeight);return{toEditing:function(){_p(r)},destroy:function(){t.unbind()}}},zp={getBody:wp("getBody",hp),getDoc:wp("getDoc",vp),getWin:wp("getWin",yp),getSelection:wp("getSelection",bp),getFrame:xp,getActiveApi:function(c){var a=xp(c);return hp(a).bind(function(u){return vp(a).bind(function(i){return yp(a).map(function(o){var n=Je.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return function(n){return ap(n).map(function(n){return Fp.exact(n.start(),n.soffset(),n.finish(),n.foffset())})}(o).bind(function(n){return fp(o,n).orThunk(function(){return function(n){return ap(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