/** * 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.4.2 (2020-08-17) */ !function(x){"use strict";var w=function(){return(w=Object.assign||function(n){for(var e,t=1,r=arguments.length;t "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"}}},ir=function(t,i){var u=function(n,e){return o=tr(t),function(t,r,n){var e=pn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return Yt(e)}(n,y,e);var o};return{extract:function(t,r,o){var n=k(o),e=u(t,n);return Ct(e,function(n){var e=pn(n,function(n){return Qt.field(n,n,Nt(),i)});return or(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"}}},ur=O(tr(Tt)),cr=Qt.state,ar=Qt.field,fr=function(t,e,r,o,i){return I(o,i).fold(function(){return n=o,e=i,Jt(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+Kt(n)});var n,e},function(n){return n.extract(t.concat(["branch: "+i]),e,r)})},sr=function(o,i){return{extract:function(e,t,r){return I(r,o).fold(function(){return n=o,Jt(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return fr(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+k(i)}}},lr=tr(Tt),dr=function(e){return tr(function(n){return e(n).fold(Et,Tt)})},mr=function(e,n){return ir(function(n){return St(e(n))},n)},gr=function(n,e,t){return Ot((r=n,o=y,i=t,u=e.extract([r],o,i),_t(u,function(n){return{input:i,errors:n}})));var r,o,i,u},pr=function(n){return n.fold(function(n){throw new Error(vr(n))},y)},hr=function(n,e,t){return pr(gr(n,e,t))},vr=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}).join("\n"))+"\n\nInput object: "+Kt(n.input);var e,t},yr=function(n,e){return sr(n,C(e,or))},br=O(lr),xr=(gt=an,pt="function",tr(function(n){var e=typeof n;return gt(n)?Tt(n):Et("Expected type: "+pt+" but got: "+e)})),wr=function(n){return ar(n,n,Nt(),ur())},Sr=function(n,e){return ar(n,n,Nt(),e)},Or=function(n,e){return ar(n,n,Nt(),or(e))},Tr=function(n){return ar(n,n,Pt(),ur())},kr=function(n,e){return ar(n,n,Pt(),e)},Er=function(n,e){return kr(n,or(e))},Cr=function(n,e){return kr(n,rr(e))},Dr=function(n,e){return ar(n,n,jt(e),ur())},Mr=function(n,e,t){return ar(n,n,jt(e),t)},_r=function(n,e){return cr(n,e)},Ir=function(n){return an(n)?n:O(!1)},Fr=function(n,e,t){var r=e(n),o=Ir(t);return r.orThunk(function(){return o(n)?T.none():function(n,e,t){for(var r=n.dom(),o=Ir(t);r.parentNode;){r=r.parentNode;var i=ke.fromDom(r),u=e(i);if(u.isSome())return u;if(o(i))break}return T.none()}(n,e,o)})},Rr=function(n,e){return Ae(n.element(),e.event().target())},Vr=function(n){if(!R(n,"can")&&!R(n,"abort")&&!R(n,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(n,null,2)+" does not have can, abort, or run!");return hr("Extracting event.handler",rr([Dr("can",O(!0)),Dr("abort",O(!1)),Dr("run",S)]),n)},Br=function(t){var e,r,o,i,n=(r=function(n){return n.can},function(){for(var t=[],n=0;n=r.length&&t.substr(o,o+r.length)===r?n.substring(0,n.length-"/*".length):n;var e,t,r,o})},Yr=function(n,e){var t=n.toString(),r=t.indexOf(")")+1,o=t.indexOf("("),i=t.substring(o+1,r-1).split(/,\s*/);return n.toFunctionAnnotation=function(){return{name:e,parameters:qr(i)}},n},Kr=function(n){return{classes:n.classes!==undefined?n.classes:[],attributes:n.attributes!==undefined?n.attributes:{},styles:n.styles!==undefined?n.styles:{}}},Jr=function(t,r,o){return Wr(function(n,e){o(n,t,r)})},Qr=function(o,i,u){var n,e,t,r,c,a;return n=function(t){for(var n=[],e=1;e"}),br()),$a=_r("schema",function(){return[Tr("preprocess")]}),Ua=Dr("defaults",O({})),Wa=Dr("overrides",O({})),Xa=or([Ha,za,La,Ga,Ua,Wa]),qa=or([Ha,za,La,Ua,Wa]),Ya=or([Ha,za,La,Ga,Ua,Wa]),Ka=or([Ha,$a,La,wr("unit"),Ga,Ua,Wa]),Ja=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},Qa=function(t,r){return function(n){var e=hr("Converting part type",r,n);return t(e)}},Za=Qa(Pa.required,Xa),nf=(Qa(Pa.external,qa),Qa(Pa.optional,Ya)),ef=Qa(Pa.group,Ka),tf=O("entirety"),rf=function(n,e,t,r){return Vt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},of=function(o,n){var e={};return hn(n,function(n){n.fold(T.some,T.none,T.some,T.some).each(function(t){var r=uf(o,t.pname);e[t.name]=function(n){var e=hr("Part: "+t.name+" in "+o,or(t.schema),n);return w(w({},r),{config:n,validated:e})}})}),e},uf=function(n,e){return{uiType:Aa(),owner:n,name:e}},cf=function(n,e,t){return r=e,i={},o={},hn(t,function(n){n.fold(function(r){i[r.pname]=Va(!0,function(n,e,t){return r.factory.sketch(rf(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=O(n.factory.sketch(rf(r,n,e[tf()]),e))},function(r){i[r.pname]=Va(!1,function(n,e,t){return r.factory.sketch(rf(n,r,e,t))})},function(o){i[o.pname]=Ba(!0,function(e,n,t){var r=e[o.name];return pn(r,function(n){return o.factory.sketch(Vt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:O(i),externals:O(o)};var r,i,o},af=function(n,e,t){return Ra(T.some(n),e,e.components,t)},ff=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOption()},sf=function(n,e,t){return ff(n,e,t).getOrDie("Could not find part: "+t)},lf=function(e,n){var t=pn(n,Ja);return Ut(pn(t,function(n){return{key:n,value:e+"-"+n}}))},df=function(e){return ar("partUids","partUids",zt(function(n){return lf(n.uid,e)}),br())},mf=Na("alloy-premade"),gf=function(n){return $t(mf,n)},pf=function(r){return n=function(n){for(var e=[],t=1;t')},function(n){return Af(''+n+"")})},zf=function(n,e,t,r){return Rf.sketch({dom:Hf(n,r),action:e,buttonBehaviours:Vt(ro([Vf.config({})]),t)})},Lf=nf({schema:[wr("dom")],name:"label"}),Gf=function(e){return nf({name:e+"-edge",overrides:function(n){return n.model.manager.edgeActions[e].fold(function(){return{}},function(r){return{events:Ar([Pr($n(),function(n,e,t){return r(n,t)},[n]),Pr(Xn(),function(n,e,t){return r(n,t)},[n]),Pr(qn(),function(n,e,t){t.mouseIsDown.get()&&r(n,t)},[n])])}})}})},$f=Gf("top-left"),Uf=Gf("top"),Wf=Gf("top-right"),Xf=Gf("right"),qf=Gf("bottom-right"),Yf=Gf("bottom"),Kf=Gf("bottom-left"),Jf=[Lf,Gf("left"),Xf,Uf,Yf,$f,Wf,Kf,qf,Za({name:"thumb",defaults:O({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Ar([Lr($n(),n,"spectrum"),Lr(Un(),n,"spectrum"),Lr(Wn(),n,"spectrum"),Lr(Xn(),n,"spectrum"),Lr(qn(),n,"spectrum"),Lr(Yn(),n,"spectrum")])}}}),Za({schema:[_r("mouseIsDown",function(){return Do(!1)})],name:"spectrum",overrides:function(t){var r=t.model.manager,o=function(e,n){return r.getValueFromEvent(n).map(function(n){return r.setValueFrom(e,t,n)})};return{behaviours:ro([Sa.config({mode:"special",onLeft:function(n){return r.onLeft(n,t)},onRight:function(n){return r.onRight(n,t)},onUp:function(n){return r.onUp(n,t)},onDown:function(n){return r.onDown(n,t)}}),Bi.config({})]),events:Ar([Nr($n(),o),Nr(Un(),o),Nr(Xn(),o),Nr(qn(),function(n,e){t.mouseIsDown.get()&&o(n,e)})])}}})],Qf=function(n,e,t){e.store.manager.onLoad(n,e,t)},Zf=function(n,e,t){e.store.manager.onUnload(n,e,t)},ns=/* */Object.freeze({__proto__:null,onLoad:Qf,onUnload:Zf,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}}),es=/* */Object.freeze({__proto__:null,events:function(t,r){var n=t.resetOnDom?[$r(function(n,e){Qf(n,t,r)}),Ur(function(n,e){Zf(n,t,r)})]:[Jr(t,r,Qf)];return Ar(n)}}),ts=function(){var n=Do(null);return to({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()}}})},rs=function(){var i=Do({}),u=Do({});return to({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return I(i.get(),n).orThunk(function(){return I(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};hn(n,function(e){r[e.value]=e,I(e,"meta").each(function(n){I(n,"text").each(function(n){o[n]=e})})}),i.set(w(w({},e),r)),u.set(w(w({},t),o))},clear:function(){i.set({}),u.set({})}})},os=/* */Object.freeze({__proto__:null,memory:ts,dataset:rs,manual:function(){return to({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),is=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},us=[Tr("initialValue"),wr("getFallbackEntry"),wr("getDataKey"),wr("setValue"),ai("manager",{setValue:is,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){is(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:rs})],cs=[wr("getValue"),Dr("setValue",S),Tr("initialValue"),ai("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:S,state:eo.init})],as=[Tr("initialValue"),ai("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:ts})],fs=[Mr("store",{mode:"memory"},yr("mode",{memory:as,manual:cs,dataset:us})),oi("onSetValue"),Dr("resetOnDom",!1)],ss=io({fields:fs,name:"representing",active:es,apis:ns,extra:{setValueFrom:function(n,e){var t=ss.getValue(e);ss.setValue(n,t)}},state:os}),ls=Ui("width",function(n){return n.dom().offsetWidth}),ds=function(n,e){return ls.set(n,e)},ms=function(n){return ls.get(n)},gs=function(t,r){return{left:O(t),top:O(r),translate:function(n,e){return gs(t+n,r+e)}}},ps=gs,hs=O("slider.change.value"),vs=function(n){var e=n.event().raw();if(-1!==e.type.indexOf("touch")){return e.touches!==undefined&&1===e.touches.length?T.some(e.touches[0]).map(function(n){return ps(n.clientX,n.clientY)}):T.none()}return e.clientX!==undefined?T.some(e).map(function(n){return ps(n.clientX,n.clientY)}):T.none()},ys=function(n){return n.model.minX},bs=function(n){return n.model.minY},xs=function(n){return n.model.minX-1},ws=function(n){return n.model.minY-1},Ss=function(n){return n.model.maxX},Os=function(n){return n.model.maxY},Ts=function(n){return n.model.maxX+1},ks=function(n){return n.model.maxY+1},Es=function(n,e,t){return e(n)-t(n)},Cs=function(n){return Es(n,Ss,ys)},Ds=function(n){return Es(n,Os,bs)},Ms=function(n){return Cs(n)/2},_s=function(n){return Ds(n)/2},Is=function(n){return n.stepSize},Fs=function(n){return n.snapToGrid},Rs=function(n){return n.snapStart},Vs=function(n){return n.rounded},Bs=function(n,e){return n[e+"-edge"]!==undefined},As=function(n){return Bs(n,"left")},js=function(n){return Bs(n,"right")},Ns=function(n){return Bs(n,"top")},Ps=function(n){return Bs(n,"bottom")},Hs=function(n){return n.model.value.get()},zs=function(n){return{x:O(n)}},Ls=function(n){return{y:O(n)}},Gs=function(n,e){return{x:O(n),y:O(e)}},$s=function(n,e){xe(n,hs(),{value:e})},Us=function(n,e,t,r){return n'),components:[zl.parts()["left-edge"](jf('
')),zl.parts().spectrum({dom:Af('
'),components:[jf('
')],behaviours:ro([Ti.config({toggleClass:Mi("thumb-active")})])}),zl.parts()["right-edge"](jf('
')),zl.parts().thumb({dom:Af('
'),behaviours:ro([Ti.config({toggleClass:Mi("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Ni(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Ti.on(e)},onDragEnd:function(n,e){Ti.off(e)},onInit:function(n,e,t,r){var o=i(r.x());Ni(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:ro([Ei(zl.refresh)])}))];var o,i},$l=rr([wr("getInitialValue"),wr("onChange"),wr("category"),wr("sizes")]),Ul=function(n){var i=hr("SizeSlider",$l,n);return zl.sketch({dom:{tag:"div",classes:[Mi("slider-"+i.category+"-size-container"),Mi("slider"),Mi("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r'),components:[jf('
')]}),zl.parts().thumb({dom:Af('
'),behaviours:ro([Ti.config({toggleClass:Mi("thumb-active")})])})]})},Wl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Xl=function(e,n){return(De(n)?T.some(n):Ne(n).filter(De)).map(function(n){return Ji(function(n,e){return e(n)},nu,n,function(n){return Li(n,"font-size").isSome()},e).bind(function(n){return Li(n,"font-size")}).getOrThunk(function(){return Hi(n,"font-size")})}).getOr("")},ql=function(n){var e=n.selection.getStart(),t=ke.fromDom(e),r=ke.fromDom(n.getBody()),o=Xl(function(n){return Ae(r,n)},t);return xn(Wl,function(n){return o===n}).getOr("medium")},Yl=function(n){var e,t=ql(n);return e=t,wn(Wl,function(n){return n===e}).getOr(2)},Kl=function(r,n){var e;e=n,T.from(Wl[e]).each(function(n){var e,t;t=n,ql(e=r)!==t&&e.execCommand("fontSize",!1,t)})},Jl=O(Wl)(),Ql=function(n){return[jf(''),Ul({onChange:(e=n).onChange,sizes:Jl,category:"font",getInitialValue:e.getInitialValue}),jf('')];var e},Zl=function(n){var e=function t(n){return n.uid!==undefined}(n)&&R(n,"uid")?n.uid:Sf("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).toOption()},asSpec:function(){return w(w({},n),{uid:e})}}},nd=window.Promise?window.Promise:(Cf=(Ef=function(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],cd(n,ed(rd,this),ed(od,this))}).immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){x.setTimeout(n,1)},Df=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)},Ef.prototype["catch"]=function(n){return this.then(null,n)},Ef.prototype.then=function(t,r){var o=this;return new Ef(function(n,e){td.call(o,new ud(t,r,n,e))})},Ef.all=function(){for(var n=[],e=0;e'),action:function(n){var e=t.get(n);ss.setValue(e,"")}}));return{name:n,spec:Td.sketch({dom:Af('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:ro([Ti.config({toggleClass:Mi("input-container-empty")}),Od.config({find:function(n){return T.some(t.get(n))}}),xd("input-clearing",[Nr(Zn(),function(n){var e=t.get(n);(0"},Qd=function(o,n){return{uid:o.uid,dom:o.dom,components:n,behaviours:ka(o.formBehaviours,[ss.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),C(e.partUids,function(n,e){return O(t.getByUid(n))}));return C(r,function(n,o){return n().bind(function(n){var e,t,r=Od.getCurrent(n);return e=r,t=new Error("Cannot find a current component to extract the value from for form part '"+o+"': "+$o(n.element())),e.fold(function(){return mt.error(t)},mt.value)}).map(ss.getValue)})},setValue:function(t,n){E(n,function(e,n){ff(t,o,n).each(function(n){Od.getCurrent(n).each(function(n){ss.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return ff(n,o,e).bind(Od.getCurrent)}}}},Zd=(pf(function(n,e,t){return n.getField(e,t)}),function(n){var i,e=(i=[],{field:function(n,e){return i.push(n),t="form",r=Jd(n),o=e,{uiType:Aa(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=pn(r,function(n){return Za({name:n,pname:Jd(n)})});return Tf("form",Kd,o,Qd,t)}),nm=function(){var e=Do(T.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(T.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(T.some(n))},run:function(n){e.get().each(n)}}},em=function(){var e=Do(T.none());return{clear:function(){e.set(T.none())},set:function(n){e.set(T.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},tm=function(n){var r="navigateEvent",e=or([wr("fields"),Dr("maxFieldIndex",n.fields.length-1),wr("onExecute"),wr("getInitialValue"),_r("state",function(){return{dialogSwipeState:em(),currentScreen:Do(0)}})]),u=hr("SerialisedDialog",e,n),o=function(e,n,t){return Rf.sketch({dom:Af(''),action:function(n){xe(n,r,{direction:e})},buttonBehaviours:ro([Yd.config({disableClass:Mi("toolbar-navigation-disabled"),disabled:function(){return!t}})])})},i=function(n,o){var i=Ki(n.element(),"."+Mi("serialised-dialog-screen"));ru(n.element(),"."+Mi("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[Td.sketch({dom:Af('
'),components:pn(u.fields,function(n,e){return e<=u.maxFieldIndex?Td.sketch({dom:Af('
'),components:[o(-1,"previous",0'),behaviours:ro([Bu.config({highlightClass:Mi("dot-active"),itemClass:Mi("dot-item")})]),components:On(u.fields,function(n,e){return e<=u.maxFieldIndex?[jf('
')]:[]})});return{dom:Af('
'),components:[a.asSpec(),f.asSpec()],behaviours:ro([Sa.config({mode:"special",focusIn:function(n){var e=a.get(n);Sa.focusIn(e)}}),xd("serializer-wrapper-events",[Nr($n(),function(n,e){var t=e.event();u.state.dialogSwipeState.set({xValue:t.raw().touches[0].clientX,points:[]})}),Nr(Un(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(function(n,e){if(e===n.xValue)return n;var t=0 "):r[0].name();return $t(o,{handler:e,purpose:O(t)})})});return Wt(e,{})},bm=function(n){return gr("custom.definition",or([ar("dom","dom",Nt(),or([wr("tag"),Dr("styles",{}),Dr("classes",[]),Dr("attributes",{}),Tr("value"),Tr("innerHtml")])),wr("components"),wr("uid"),Dr("events",{}),Dr("apis",{}),ar("eventOrder","eventOrder",At.mergeWithThunk(O({"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"],touchstart:["focusing","alloy.base.behaviour","item-type-events"],mouseover:["item-type-events","tooltipping"],"alloy.receive":["receiving","reflecting","tooltipping"]})),br()),Tr("domModification")]),n)},xm=function(e,n){hn(n,function(n){xo(e,n)})},wm=function(e,n){hn(n,function(n){So(e,n)})},Sm=function(n,e){return t=n,o=pn(r=e,function(n){return Er(n.name(),[wr("config"),Dr("state",eo)])}),i=gr("component.behaviours",or(o),t.behaviours).fold(function(n){throw new Error(vr(n)+"\nComplete spec:\n"+JSON.stringify(t,null,2))},function(n){return n}),{list:r,data:C(i,function(n){var e=n.map(function(n){return{config:n.config,state:n.state.init(n.config)}});return function(){return e}})};var t,r,o,i},Om=function(n){var e,t,r=(e=I(n,"behaviours").getOr({}),t=vn(k(e),function(n){return e[n]!==undefined}),pn(t,function(n){return e[n].me}));return Sm(n,r)},Tm=function(n,e,t){var r,o,i,u=w(w({},(r=n).dom),{uid:r.uid,domChildren:pn(r.components,function(n){return n.element()})}),c=n.domModification.fold(function(){return Kr({})},Kr),a={"alloy.base.modification":c},f=0");r[t[0]]=$t(t[1],n),r[t[1]]=$t(t[0],n)}),r},createBistate:function(n,e,t){return Ut([{key:n,value:$t(e,t)},{key:e,value:$t(n,t)}])},createTristate:function(n,e,t,r){return Ut([{key:n,value:Ut([{key:e,value:r},{key:t,value:r}])},{key:e,value:Ut([{key:n,value:r},{key:t,value:r}])},{key:t,value:Ut([{key:n,value:r},{key:e,value:r}])}])}}}),hg=Mi("scrollable"),vg=function(n){xo(n,hg)},yg=function(n){So(n,hg)},bg=hg,xg=function(n){return I(n,"format").getOr(n.title)},wg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Mi("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Mi("format-matches"),selected:t},itemBehaviours:ro(o?[]:[ki(n,function(n,e){(e?Ti.on:Ti.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},Sg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Rf.sketch({dom:{tag:"div",classes:[Mi("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Mi("styles-collapse-icon")]}},Dm(n)]:[Dm(n)],action:function(n){if(r){var e=t().get(n);ug.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Mi("styles-menu-items-container")]},components:[qm.parts().items({})],behaviours:ro([xd("adhoc-scrollable-menu",[$r(function(n,e){Ni(n.element(),"overflow-y","auto"),Ni(n.element(),"-webkit-overflow-scrolling","touch"),vg(n.element())}),Ur(function(n){Gi(n.element(),"overflow-y"),Gi(n.element(),"-webkit-overflow-scrolling"),yg(n.element())})])])}],items:e,menuBehaviours:ro([pg.config({initialState:"after",routes:pg.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},Og=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return c},n=Sg("Styles",[].concat(pn(o.items,function(n){return wg(xg(n),n.title,n.isSelected(),n.getPreview(),R(o.expansions,xg(n)))})),i,!1),e=C(o.menus,function(n,e){var t=pn(n,function(n){return wg(xg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",R(o.expansions,xg(n)))});return Sg(e,t,i,!0)}),t=Vt(e,$t("styles",n)),{tmenu:ug.tieredData("styles",t,o.expansions)}),c=Zl(ug.sketch({dom:{tag:"div",classes:[Mi("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=ss.getValue(e);return r.handle(e,t.value),T.none()},onEscape:function(){return T.none()},onOpenMenu:function(n,e){var t=ms(n.element());ds(e.element(),t),pg.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=ms(n.element()),o=tu(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();ds(t.element(),r),pg.progressTo(i,"before"),pg.jumpTo(t,"after"),pg.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=tu(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:u.tmenu,markers:{backgroundMenu:Mi("styles-background-menu"),menu:Mi("styles-menu"),selectedMenu:Mi("styles-selected-menu"),item:Mi("styles-item"),selectedItem:Mi("styles-selected-item")}}));return c.asSpec()},Tg=function(n){return R(n,"items")?(t=Vt(Gt(e=n,["items"]),{menu:!0}),r=kg(e.items),{item:t,menus:Vt(r.menus,$t(e.title,r.items)),expansions:Vt(r.expansions,$t(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},kg=function(n){return yn(n,function(n,e){var t=Tg(e);return{menus:Vt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:Vt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Eg=function(u){var c=function(n){return function(){return u.formatter.match(n)}},a=function(n){return function(){return u.formatter.getCssText(n)}},f=function(n){return pn(n,function(n){if(R(n,"items")){var e=f(n.items);return Vt(Vt(n,{isSelected:O(!1),getPreview:O("")}),{items:e})}return R(n,"format")?Vt(i=n,{isSelected:c(i.format),getPreview:a(i.format)}):(r=Na((t=n).title),o=Vt(t,{format:r,isSelected:c(r),getPreview:a(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return f(u.getParam("style_formats",Bo,"array"))},Cg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return On(n,function(n){return n.items===undefined?!R(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?[]:[Ag(ke.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Ti.off)}),Ag(i,"select",n),Ag(r.doc(),"selectionchange",n)]);return{destroy:function(){hn(c,function(n){n.unbind()})}}},Wg=function(n,e){var t=parseInt(lo(n,e),10);return isNaN(t)?0:t};var Xg,qg,Yg=function Pv(t,r){var e=function(n){return t(n)?T.from(n.dom().nodeValue):T.none()};return{get:function(n){if(!t(n))throw new Error("Can only get "+r+" value of a "+r+" node");return e(n).getOr("")},getOption:e,set:function(n,e){if(!t(n))throw new Error("Can only set raw "+r+" value of a "+r+" node");n.dom().nodeValue=e}}}(Me,"text"),Kg=function(n){return"img"===Ee(n)?1:(e=n,Yg.getOption(e).fold(function(){return Pe(n).length},function(n){return n.length}));var e},Jg=function(n,e,t,r){return{start:O(n),soffset:O(e),finish:O(t),foffset:O(r)}},Qg=It([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Zg={before:Qg.before,on:Qg.on,after:Qg.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(y,y,y)}},np=It([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),ep={domRange:np.domRange,relative:np.relative,exact:np.exact,exactFromRange:function(n){return np.exact(n.start(),n.soffset(),n.finish(),n.foffset())},getWin:function(n){var e,t=n.match({domRange:function(n){return ke.fromDom(n.startContainer)},relative:function(n,e){return Zg.getStart(n)},exact:function(n,e,t,r){return n}});return e=t,ke.fromDom(e.dom().ownerDocument.defaultView)},range:Jg},tp=function(n,e,t){var r,o,i=n.document.createRange();return r=i,e.fold(function(n){r.setStartBefore(n.dom())},function(n,e){r.setStart(n.dom(),e)},function(n){r.setStartAfter(n.dom())}),o=i,t.fold(function(n){o.setEndBefore(n.dom())},function(n,e){o.setEnd(n.dom(),e)},function(n){o.setEndAfter(n.dom())}),i},rp=function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},op=function(n){return{left:O(n.left),top:O(n.top),right:O(n.right),bottom:O(n.bottom),width:O(n.width),height:O(n.height)}},ip=It([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),up=function(n,e,t){return e(ke.fromDom(t.startContainer),t.startOffset,ke.fromDom(t.endContainer),t.endOffset)},cp=function(n,e){var o,t,r,i=(o=n,e.match({domRange:function(n){return{ltr:O(n),rtl:T.none}},relative:function(n,e){return{ltr:V(function(){return tp(o,n,e)}),rtl:V(function(){return T.some(tp(o,e,n))})}},exact:function(n,e,t,r){return{ltr:V(function(){return rp(o,n,e,t,r)}),rtl:V(function(){return T.some(rp(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return ip.rtl(ke.fromDom(n.endContainer),n.endOffset,ke.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return up(0,ip.ltr,r)}):up(0,ip.ltr,r)},ap=(ip.ltr,ip.rtl,function(n,e){var t=Ee(n);return"input"===t?Zg.after(n):mn(["br","img"],t)?0===e?Zg.before(n):Zg.after(n):Zg.on(n,e)}),fp=function(n,e,t,r){var o,i,u,c,a,f=(i=e,u=t,c=r,(a=je(o=n).dom().createRange()).setStart(o.dom(),i),a.setEnd(u.dom(),c),a),s=Ae(n,t)&&e===r;return f.collapsed&&!s},sp=function(n,e,t,r,o){var i,u,c=rp(n,e,t,r,o);i=n,u=c,T.from(i.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},lp=function(l,n){return cp(l,n).match({ltr:function(n,e,t,r){sp(l,n,e,t,r)},rtl:function(n,e,t,r){var o,i,u,c,a,f=l.getSelection();if(f.setBaseAndExtent)f.setBaseAndExtent(n.dom(),e,t.dom(),r);else if(f.extend)try{i=n,u=e,c=t,a=r,(o=f).collapse(i.dom(),u),o.extend(c.dom(),a)}catch(s){sp(l,t,r,n,e)}else sp(l,t,r,n,e)}})},dp=function(n,e,t,r,o){var i,u,c,a,f=(i=r,u=o,c=ap(e,t),a=ap(i,u),ep.relative(c,a));lp(n,f)},mp=function(n){var e=ke.fromDom(n.anchorNode),t=ke.fromDom(n.focusNode);return fp(e,n.anchorOffset,t,n.focusOffset)?T.some(Jg(e,n.anchorOffset,t,n.focusOffset)):function(n){if(0e.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),wp(e,n.innerHeight)});wp(e,n.innerHeight);return{toEditing:function(){bp(u)},destroy:function(){t.unbind()}}},kp=function(n){return T.from(n.dom().contentWindow)},Ep=function(n){return kp(n).bind(gp)},Cp=function(n){return n.getFrame()},Dp=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return Ag(e,r,n)}})},Mp=function(n){return{left:O(n.left),top:O(n.top),right:O(n.right),bottom:O(n.bottom),width:O(n.width),height:O(n.height)}},_p=function(c){var n,a=Cp(c);return n=a,T.some(ke.fromDom(n.dom().contentWindow.document.body)).bind(function(u){return n=a,T.some(ke.fromDom(n.dom().contentWindow.document)).bind(function(i){return kp(a).map(function(o){var n=ke.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return gp(o).map(function(n){return ep.exact(n.start(),n.soffset(),n.finish(),n.foffset())}).bind(function(n){return pp(o,n).orThunk(function(){return gp(o).filter(function(n){return Ae(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0