/** * 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.6.2 (2020-12-08) */ !function(){"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")+"}"}}},br=function(t,i){var u=function(n,e){return o=hr(t),function(t,r,n){var e=N(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return fr(e)}(n,v,e);var o};return{extract:function(t,r,o){var n=Qe(o),e=u(t,n);return zt(e,function(n){var e=N(n,function(n){return dr.field(n,n,Qt(),i)});return yr(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"}}},xr=y(hr(Nt)),wr=dr.state,Sr=dr.field,Or=function(t,e,r,o,i){return it(o,i).fold(function(){return n=o,e=i,lr(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+sr(n)});var n,e},function(n){return n.extract(t.concat(["branch: "+i]),e,r)})},Tr=function(o,i){return{extract:function(e,t,r){return it(r,o).fold(function(){return n=o,lr(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return Or(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+Qe(i)}}},kr=hr(Nt),Er=function(e){return hr(function(n){return e(n).fold(Ht,Nt)})},Cr=function(e,n){return br(function(n){return At(e(n))},n)},Mr=function(n,e,t){return jt((r=n,o=v,i=t,u=e.extract([r],o,i),$t(u,function(n){return{input:i,errors:n}})));var r,o,i,u},Dr=function(n){return n.fold(function(n){throw new Error(Ir(n))},v)},_r=function(n,e,t){return Dr(Mr(n,e,t))},Ir=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}).join("\n"))+"\n\nInput object: "+sr(n.input);var e,t},Fr=function(n,e){return Tr(n,et(e,yr))},Rr=y(kr),Vr=(Mt=I,Dt="function",hr(function(n){var e=typeof n;return Mt(n)?Nt(n):Ht("Expected type: "+Dt+" but got: "+e)})),Br=function(n){return Sr(n,n,Qt(),xr())},Ar=function(n,e){return Sr(n,n,Qt(),e)},jr=function(n,e){return Sr(n,n,Qt(),yr(e))},Nr=function(n){return Sr(n,n,Zt(),xr())},Pr=function(n,e){return Sr(n,n,Zt(),e)},Hr=function(n,e){return Pr(n,yr(e))},zr=function(n,e){return Pr(n,vr(e))},Lr=function(n,e){return Sr(n,n,Jt(e),xr())},Gr=function(n,e,t){return Sr(n,n,Jt(e),t)},$r=function(n,e){return wr(n,e)},Ur=[Br("alpha"),Br("omega")],Wr=function(n){return I(n)?n:l},Xr=function(n,e,t){var r=e(n),o=Wr(t);return r.orThunk(function(){return o(n)?T.none():function(n,e,t){for(var r=n.dom,o=Wr(t);r.parentNode;){r=r.parentNode;var i=de.fromDom(r),u=e(i);if(u.isSome())return u;if(o(i))break}return T.none()}(n,e,o)})},qr=function(n,e){return ve(n.element,e.event.target)},Yr=function(n){if(!ct(n,"can")&&!ct(n,"abort")&&!ct(n,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(n,null,2)+" does not have can, abort, or run!");return _r("Extracting event.handler",vr([Lr("can",w),Lr("abort",l),Lr("run",O)]),n)},Kr=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})},so=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:fo(i)}},n},lo=function(n){return{classes:n.classes!==undefined?n.classes:[],attributes:n.attributes!==undefined?n.attributes:{},styles:n.styles!==undefined?n.styles:{}}},mo=function(t,r,o){return co(function(n,e){o(n,t,r)})},go=function(o,i,u){var n,e,t,r,c,a;return n=function(t){for(var n=[],e=1;e"}),Rr()),za=$r("schema",function(){return[Nr("preprocess")]}),La=Lr("defaults",y({})),Ga=Lr("overrides",y({})),$a=yr([ja,Na,Pa,Ha,La,Ga]),Ua=yr([ja,Na,Pa,La,Ga]),Wa=yr([ja,Na,Pa,Ha,La,Ga]),Xa=yr([ja,za,Pa,Br("unit"),Ha,La,Ga]),qa=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},Ya=function(t,r){return function(n){var e=_r("Converting part type",r,n);return t(e)}},Ka=Ya(Aa.required,$a),Ja=(Ya(Aa.external,Ua),Ya(Aa.optional,Wa)),Qa=Ya(Aa.group,Xa),Za=y("entirety"),nf=function(n,e,t,r){return qt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},ef=function(o,n){var e={};return P(n,function(n){n.fold(T.some,T.none,T.some,T.some).each(function(t){var r=tf(o,t.pname);e[t.name]=function(n){var e=_r("Part: "+t.name+" in "+o,yr(t.schema),n);return x(x({},r),{config:n,validated:e})}})}),e},tf=function(n,e){return{uiType:Ra(),owner:n,name:e}},rf=function(n,e,t){return r=e,i={},o={},P(t,function(n){n.fold(function(r){i[r.pname]=Ia(!0,function(n,e,t){return r.factory.sketch(nf(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=y(n.factory.sketch(nf(r,n,e[Za()]),e))},function(r){i[r.pname]=Ia(!1,function(n,e,t){return r.factory.sketch(nf(n,r,e,t))})},function(o){i[o.pname]=Fa(!0,function(e,n,t){var r=e[o.name];return N(r,function(n){return o.factory.sketch(qt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:y(i),externals:y(o)};var r,i,o},of=function(n,e,t){return _a(T.some(n),e,e.components,t)},uf=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOptional()},cf=function(n,e,t){return uf(n,e,t).getOrDie("Could not find part: "+t)},af=function(e,n){var t=N(n,qa);return ir(N(t,function(n){return{key:n,value:e+"-"+n}}))},ff=function(e){return Sr("partUids","partUids",er(function(n){return af(n.uid,e)}),Rr())},sf=Ba("alloy-premade"),lf=function(n){return or(sf,n)},df=function(r){return n=function(n){for(var e=[],t=1;t')},function(n){return Vf(''+n+"")})},Pf=function(n,e,t,r){return If.sketch({dom:Nf(n,r),action:e,buttonBehaviours:qt(bo([Ff.config({})]),t)})},Hf=Ja({schema:[Br("dom")],name:"label"}),zf=function(e){return Ja({name:e+"-edge",overrides:function(n){return n.model.manager.edgeActions[e].fold(function(){return{}},function(r){return{events:Jr([no(_n(),function(n,e,t){return r(n,t)},[n]),no(Rn(),function(n,e,t){return r(n,t)},[n]),no(Vn(),function(n,e,t){t.mouseIsDown.get()&&r(n,t)},[n])])}})}})},Lf=zf("top-left"),Gf=zf("top"),$f=zf("top-right"),Uf=zf("right"),Wf=zf("bottom-right"),Xf=zf("bottom"),qf=zf("bottom-left"),Yf=[Hf,zf("left"),Uf,Gf,Xf,Lf,$f,qf,Wf,Ka({name:"thumb",defaults:y({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Jr([ro(_n(),n,"spectrum"),ro(In(),n,"spectrum"),ro(Fn(),n,"spectrum"),ro(Rn(),n,"spectrum"),ro(Vn(),n,"spectrum"),ro(Bn(),n,"spectrum")])}}}),Ka({schema:[$r("mouseIsDown",function(){return ko(!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:bo([ba.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)}}),_i.config({})]),events:Jr([Zr(_n(),o),Zr(In(),o),Zr(Rn(),o),Zr(Vn(),function(n,e){t.mouseIsDown.get()&&o(n,e)})])}}})],Kf=function(n,e,t){e.store.manager.onLoad(n,e,t)},Jf=function(n,e,t){e.store.manager.onUnload(n,e,t)},Qf=/* */Object.freeze({__proto__:null,onLoad:Kf,onUnload:Jf,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}}),Zf=/* */Object.freeze({__proto__:null,events:function(t,r){var n=t.resetOnDom?[io(function(n,e){Kf(n,t,r)}),uo(function(n,e){Jf(n,t,r)})]:[mo(t,r,Kf)];return Jr(n)}}),ns=function(){var n=ko(null);return yo({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()}}})},es=function(){var i=ko({}),u=ko({});return yo({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return it(i.get(),n).orThunk(function(){return it(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};P(n,function(e){r[e.value]=e,it(e,"meta").each(function(n){it(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({})}})},ts=/* */Object.freeze({__proto__:null,memory:ns,dataset:es,manual:function(){return yo({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),rs=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},os=[Nr("initialValue"),Br("getFallbackEntry"),Br("getDataKey"),Br("setValue"),ri("manager",{setValue:rs,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){rs(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:es})],is=[Br("getValue"),Lr("setValue",O),Nr("initialValue"),ri("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:O,state:vo.init})],us=[Nr("initialValue"),ri("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:ns})],cs=[Gr("store",{mode:"memory"},Fr("mode",{memory:us,manual:is,dataset:os})),Zo("onSetValue"),Lr("resetOnDom",!1)],as=wo({fields:cs,name:"representing",active:Zf,apis:Qf,extra:{setValueFrom:function(n,e){var t=as.getValue(e);as.setValue(n,t)}},state:ts}),fs=Hi("width",function(n){return n.dom.offsetWidth}),ss=function(n,e){return fs.set(n,e)},ls=function(n){return fs.get(n)},ds=function(t,r){return{left:t,top:r,translate:function(n,e){return ds(t+n,r+e)}}},ms=ds,gs=y("slider.change.value"),ps=function(n){var e=n.event.raw;return-1===e.type.indexOf("touch")?e.clientX!==undefined?T.some(e).map(function(n){return ms(n.clientX,n.clientY)}):T.none():e.touches!==undefined&&1===e.touches.length?T.some(e.touches[0]).map(function(n){return ms(n.clientX,n.clientY)}):T.none()},hs=function(n){return n.model.minX},vs=function(n){return n.model.minY},ys=function(n){return n.model.minX-1},bs=function(n){return n.model.minY-1},xs=function(n){return n.model.maxX},ws=function(n){return n.model.maxY},Ss=function(n){return n.model.maxX+1},Os=function(n){return n.model.maxY+1},Ts=function(n,e,t){return e(n)-t(n)},ks=function(n){return Ts(n,xs,hs)},Es=function(n){return Ts(n,ws,vs)},Cs=function(n){return ks(n)/2},Ms=function(n){return Es(n)/2},Ds=function(n){return n.stepSize},_s=function(n){return n.snapToGrid},Is=function(n){return n.snapStart},Fs=function(n){return n.rounded},Rs=function(n,e){return n[e+"-edge"]!==undefined},Vs=function(n){return Rs(n,"left")},Bs=function(n){return Rs(n,"right")},As=function(n){return Rs(n,"top")},js=function(n){return Rs(n,"bottom")},Ns=function(n){return n.model.value.get()},Ps=function(n){return{x:n}},Hs=function(n){return{y:n}},zs=function(n,e){return{x:n,y:e}},Ls=function(n,e){ce(n,gs(),{value:e})},Gs=function(n,e,t,r){return n'),components:[Hl.parts["left-edge"](Bf('
')),Hl.parts.spectrum({dom:Vf('
'),components:[Bf('
')],behaviours:bo([bi.config({toggleClass:Ti("thumb-active")})])}),Hl.parts["right-edge"](Bf('
')),Hl.parts.thumb({dom:Vf('
'),behaviours:bo([bi.config({toggleClass:Ti("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Ri(e.element,"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){bi.on(e)},onDragEnd:function(n,e){bi.off(e)},onInit:function(n,e,t,r){var o=i(r.x());Ri(e.element,"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:o.getInitialValue()}}},sliderBehaviours:bo([wi(Hl.refresh)])}))];var o,i},Gl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],$l=function(e,n){return(xe(n)?T.some(n):Ee(n).filter(xe)).map(function(n){return Wi(function(n,e){return e(n)},Yi,n,function(n){return ji(n,"font-size").isSome()},e).bind(function(n){return ji(n,"font-size")}).getOrThunk(function(){return Bi(n,"font-size")})}).getOr("")},Ul=function(n){var e=n.selection.getStart(),t=de.fromDom(e),r=de.fromDom(n.getBody()),o=$l(function(n){return ve(r,n)},t);return G(Gl,function(n){return o===n}).getOr("medium")},Wl=function(n){var e,t=Ul(n);return e=t,$(Gl,function(n){return n===e}).getOr(2)},Xl=function(r,n){var e;e=n,T.from(Gl[e]).each(function(n){var e,t;t=n,Ul(e=r)!==t&&e.execCommand("fontSize",!1,t)})},ql=y(Gl),Yl=vr([Br("getInitialValue"),Br("onChange"),Br("category"),Br("sizes")]),Kl=function(n){var i=_r("SizeSlider",Yl,n);return Hl.sketch({dom:{tag:"div",classes:[Ti("slider-"+i.category+"-size-container"),Ti("slider"),Ti("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r'),components:[Bf('
')]}),Hl.parts.thumb({dom:Vf('
'),behaviours:bo([bi.config({toggleClass:Ti("thumb-active")})])})]})},Jl=ql(),Ql=function(n){return[Bf(''),Kl({onChange:(e=n).onChange,sizes:Jl,category:"font",getInitialValue:e.getInitialValue}),Bf('')];var e},Zl=function(n){var e=n.uid!==undefined&&ct(n,"uid")?n.uid:bf("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).toOptional()},asSpec:function(){return x(x({},n),{uid:e})}}},nd=window.Promise?window.Promise:(Of=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))},Tf=window,kf=Of.immediateFn||"function"==typeof Tf.setImmediate&&Tf.setImmediate||function(n){setTimeout(n,1)},Ef=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)},Of.prototype["catch"]=function(n){return this.then(null,n)},Of.prototype.then=function(t,r){var o=this;return new Of(function(n,e){td.call(o,new ud(t,r,n,e))})},Of.all=function(){for(var n=[],e=0;e'),action:function(n){var e=t.get(n);as.setValue(e,"")}}));return{name:n,spec:Td.sketch({dom:Vf('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:bo([bi.config({toggleClass:Ti("input-container-empty")}),Od.config({find:function(n){return T.some(t.get(n))}}),xd("input-clearing",[Zr(Pn(),function(n){var e=t.get(n);(0"},Qd=function(o,n){return{uid:o.uid,dom:o.dom,components:n,behaviours:Sa(o.formBehaviours,[as.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),et(e.partUids,function(n,e){return y(t.getByUid(n))}));return et(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+"': "+Ho(n.element)),e.fold(function(){return Ct.error(t)},Ct.value)}).map(as.getValue)})},setValue:function(t,n){nt(n,function(e,n){uf(t,o,n).each(function(n){Od.getCurrent(n).each(function(n){as.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return uf(n,o,e).bind(Od.getCurrent)}}}},Zd=(df(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:Ra(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=N(r,function(n){return Ka({name:n,pname:Jd(n)})});return wf("form",Kd,o,Qd,t)}),nm=function(){var e=ko(T.none()),t=function(){return e.get().each(function(n){return 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){return e.get().each(n)}}},em=function(){var e=ko(T.none());return{clear:function(){return e.set(T.none())},set:function(n){return e.set(T.some(n))},isSet:function(){return e.get().isSome()},on:function(n){return e.get().each(n)}}},tm=function(n){var r="navigateEvent",e=yr([Br("fields"),Lr("maxFieldIndex",n.fields.length-1),Br("onExecute"),Br("getInitialValue"),$r("state",function(){return{dialogSwipeState:em(),currentScreen:ko(0)}})]),u=_r("SerialisedDialog",e,n),o=function(e,n,t){return If.sketch({dom:Vf(''),action:function(n){ce(n,r,{direction:e})},buttonBehaviours:bo([Yd.config({disableClass:Ti("toolbar-navigation-disabled"),disabled:function(){return!t}})])})},i=function(n,o){var i=Ui(n.element,"."+Ti("serialised-dialog-screen"));Qi(n.element,"."+Ti("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[Td.sketch({dom:Vf('
'),components:N(u.fields,function(n,e){return e<=u.maxFieldIndex?Td.sketch({dom:Vf('
'),components:[o(-1,"previous",0'),behaviours:bo([Fu.config({highlightClass:Ti("dot-active"),itemClass:Ti("dot-item")})]),components:W(u.fields,function(n,e){return e<=u.maxFieldIndex?[Bf('
')]:[]})});return{dom:Vf('
'),components:[a.asSpec(),f.asSpec()],behaviours:bo([ba.config({mode:"special",focusIn:function(n){var e=a.get(n);ba.focusIn(e)}}),xd("serializer-wrapper-events",[Zr(_n(),function(n,e){var t=e.event;u.state.dialogSwipeState.set({xValue:t.raw.touches[0].clientX,points:[]})}),Zr(In(),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 or(o,{handler:e,purpose:t})})});return ur(e,{})},bm="alloy.base.behaviour",xm=function(n){var e,t;return Mr("custom.definition",yr([Sr("dom","dom",Qt(),yr([Br("tag"),Lr("styles",{}),Lr("classes",[]),Lr("attributes",{}),Nr("value"),Nr("innerHtml")])),Br("components"),Br("uid"),Lr("events",{}),Lr("apis",{}),Sr("eventOrder","eventOrder",((e={})[Kn()]=["disabling",bm,"toggling","typeaheadevents"],e[Wn()]=[bm,"focusing","keying"],e[ne()]=[bm,"disabling","toggling","representing"],e[Pn()]=[bm,"representing","streaming","invalidating"],e[te()]=[bm,"representing","item-events","tooltipping"],e[Rn()]=["focusing",bm,"item-type-events"],e[_n()]=["focusing",bm,"item-type-events"],e[An()]=["item-type-events","tooltipping"],e[Yn()]=["receiving","reflecting","tooltipping"],t=e,Kt.mergeWithThunk(y(t))),Rr()),Nr("domModification")]),n)},wm=function(e,n){P(n,function(n){bt(e,n)})},Sm=function(e,n){P(n,function(n){wt(e,n)})},Om=function(n,e){return t=n,o=N(r=e,function(n){return Hr(n.name(),[Br("config"),Lr("state",vo)])}),i=Mr("component.behaviours",yr(o),t.behaviours).fold(function(n){throw new Error(Ir(n)+"\nComplete spec:\n"+JSON.stringify(t,null,2))},function(n){return n}),{list:r,data:et(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},Tm=function(n){var e,t,r=(e=it(n,"behaviours").getOr({}),t=H(Qe(e),function(n){return e[n]!==undefined}),N(t,function(n){return e[n].me}));return Om(n,r)},km=function(n,e,t){var r,o,i,u=x(x({},(r=n).dom),{uid:r.uid,domChildren:N(r.components,function(n){return n.element})}),c=n.domModification.fold(function(){return lo({})},lo),a={"alloy.base.modification":c},f=0");r[t[0]]=or(t[1],n),r[t[1]]=or(t[0],n)}),r},createBistate:function(n,e,t){return ir([{key:n,value:or(e,t)},{key:e,value:or(n,t)}])},createTristate:function(n,e,t,r){return ir([{key:n,value:ir([{key:e,value:r},{key:t,value:r}])},{key:e,value:ir([{key:n,value:r},{key:t,value:r}])},{key:t,value:ir([{key:n,value:r},{key:e,value:r}])}])}}}),vg=Ti("scrollable"),yg=function(n){bt(n,vg)},bg=function(n){wt(n,vg)},xg=vg,wg=function(n){return it(n,"format").getOr(n.title)},Sg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Ti("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Ti("format-matches"),selected:t},itemBehaviours:bo(o?[]:[xi(n,function(n,e){(e?bi.on:bi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},Og=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[If.sketch({dom:{tag:"div",classes:[Ti("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Ti("styles-collapse-icon")]}},Dm(n)]:[Dm(n)],action:function(n){var e;r&&(e=t().get(n),cg.collapseMenu(e))}}),{dom:{tag:"div",classes:[Ti("styles-menu-items-container")]},components:[Ym.parts.items({})],behaviours:bo([xd("adhoc-scrollable-menu",[io(function(n,e){Ri(n.element,"overflow-y","auto"),Ri(n.element,"-webkit-overflow-scrolling","touch"),yg(n.element)}),uo(function(n){Ni(n.element,"overflow-y"),Ni(n.element,"-webkit-overflow-scrolling"),bg(n.element)})])])}],items:e,menuBehaviours:bo([hg.config({initialState:"after",routes:hg.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},Tg=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return c},n=Og("Styles",[].concat(N(o.items,function(n){return Sg(wg(n),n.title,n.isSelected(),n.getPreview(),ct(o.expansions,wg(n)))})),i,!1),e=et(o.menus,function(n,e){var t=N(n,function(n){return Sg(wg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",ct(o.expansions,wg(n)))});return Og(e,t,i,!0)}),t=qt(e,or("styles",n)),{tmenu:cg.tieredData("styles",t,o.expansions)}),c=Zl(cg.sketch({dom:{tag:"div",classes:[Ti("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=as.getValue(e);return r.handle(e,t.value),T.none()},onEscape:function(){return T.none()},onOpenMenu:function(n,e){var t=ls(n.element);ss(e.element,t),hg.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=ls(n.element),o=Ji(e.element,'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();ss(t.element,r),hg.progressTo(i,"before"),hg.jumpTo(t,"after"),hg.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=Ji(e.element,'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();hg.progressTo(o,"after"),hg.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Ti("styles-background-menu"),menu:Ti("styles-menu"),selectedMenu:Ti("styles-selected-menu"),item:Ti("styles-item"),selectedItem:Ti("styles-selected-item")}}));return c.asSpec()},kg=function(n){return ct(n,"items")?(t=qt(rr(e=n,["items"]),{menu:!0}),r=Eg(e.items),{item:t,menus:qt(r.menus,or(e.title,r.items)),expansions:qt(r.expansions,or(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},Eg=function(n){return z(n,function(n,e){var t=kg(e);return{menus:qt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:qt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Cg=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 N(n,function(n){if(ct(n,"items")){var e=f(n.items);return qt(qt(n,{isSelected:l,getPreview:y("")}),{items:e})}return ct(n,"format")?qt(i=n,{isSelected:c(i.format),getPreview:a(i.format)}):(r=Ba((t=n).title),o=qt(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",Fo,"array"))},Mg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return W(n,function(n){return n.items===undefined?!ct(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==Fp?[]:[jg(de.fromDom(r.win),"blur",function(){t.getByDom(e).each(bi.off)}),jg(i,"select",n),jg(r.doc,"selectionchange",n)]);return{destroy:function(){P(c,function(n){n.unbind()})}}},Vp=function(n,e){var t=parseInt(lt(n,e),10);return isNaN(t)?0:t},Bp=function(n){return x(x({},n),{width:2})},Ap=function(n){return{left:n.left,top:n.top,right:n.right,bottom:n.bottom,width:n.width,height:n.height}},jp=function(n){var e=n.getSelection();return e!==undefined&&0e.innerHeight||t.bottom>e.innerHeight?Math.min(r,t.bottom-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),Hp(e,n.innerHeight)});Hp(e,n.innerHeight);return{toEditing:function(){Np(u)},destroy:function(){t.unbind()}}},$p=function(t,r){var o=null;return{cancel:function(){null!==o&&(clearTimeout(o),o=null)},throttle:function(){for(var n=[],e=0;e