/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.0.3 (2019-03-19) */ !function(n,v){"use strict";var y=function(){return(y=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 Xt.objOf(Tn(a,function(n){return n.fold(function(n,e,t,r){return Yt.field(n,t,r)},function(n,e){return Yt.state(n)})}))}}},ar=function(t,i){var u=function(n,e){return(o=or(t),{extract:function(t,r,n){var e=Tn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return qt(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return Xt.arrOf(o)}}).extract(n,b,e);var o};return{extract:function(t,r,o){var n=C(o),e=u(t,n);return Pt(e,function(n){var e=Tn(n,function(n){return nr.field(n,n,ht(),i)});return ur(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return Xt.setOf(t,i)}}},cr=h(or(jt)),fr=nr.state,sr=nr.field,lr=function(t,e,r,o,i){return Et(o,i).fold(function(){return n=o,e=i,Zt(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+Qt(n)});var n,e},function(n){return ur(n).extract(t.concat(["branch: "+i]),e,r)})},dr=function(o,i){return{extract:function(e,t,r){return Et(r,o).fold(function(){return n=o,Zt(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return lr(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+C(i)},toDsl:function(){return Xt.choiceOf(o,i)}}},mr=or(jt),gr=function(e){return or(function(n){return e(n).fold(Lt,jt)})},pr=function(e,n){return ar(function(n){return Nt(e(n))},n)},vr=function(n,e,t){return Ht((r=n,o=b,i=t,u=e.extract([r],o,i),$t(u,function(n){return{input:i,errors:n}})));var r,o,i,u},hr=function(n){return n.fold(function(n){throw new Error(yr(n))},b)},br=function(n,e,t){return hr(vr(n,e,t))},yr=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+Qt(n.input);var e,t},xr=function(n,e){return dr(n,e)},wr=h(mr),Sr=(It=yn,Bt="function",or(function(n){var e=typeof n;return It(n)?jt(n):Lt("Expected type: "+Bt+" but got: "+e)})),Or=function(n){return sr(n,n,ht(),cr())},Tr=function(n,e){return sr(n,n,ht(),e)},kr=function(n,e){return sr(n,n,ht(),ur(e))},Er=function(n){return sr(n,n,bt(),cr())},Cr=function(n,e){return sr(n,n,bt(),ur(e))},Dr=function(n,e){return sr(n,n,bt(),ir(e))},Mr=function(n,e){return sr(n,n,vt(e),cr())},Ar=function(n,e,t){return sr(n,n,vt(e),t)},Ir=function(n,e){return fr(n,e)},Br=function(n,e){return Ue(n.element(),e.event().target())},Rr=function(n){if(!At(n,"can")&&!At(n,"abort")&&!At(n,"run"))throw new Error("EventHandler defined by: "+Jt(n,null,2)+" does not have can, abort, or run!");return br("Extracting event.handler",ir([Mr("can",h(!0)),Mr("abort",h(!1)),Mr("run",x)]),n)},Fr=function(t){var e,r,o,i,n=(e=t,r=function(n){return n.can},function(){for(var t=[],n=0;n"}),wr()),Bc=Ir("schema",function(){return[Er("preprocess")]}),Rc=Mr("defaults",h({})),Fc=Mr("overrides",h({})),Vc=ur([Dc,Mc,Ac,Ic,Rc,Fc]),Nc=ur([Dc,Mc,Ac,Ic,Rc,Fc]),Hc=ur([Dc,Bc,Ac,Or("unit"),Ic,Rc,Fc]),jc=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},zc=function(t,r){return function(n){var e=br("Converting part type",r,n);return t(e)}},Lc=zc(Cc.required,Vc),Pc=zc(Cc.optional,Nc),Uc=zc(Cc.group,Hc),Gc=h("entirety"),$c=function(n,e,t,r){return mt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},Wc=function(o,n){var i={};return kn(n,function(n){var e;(e=n,e.fold(E.some,E.none,E.some,E.some)).each(function(t){var r=_c(o,t.pname);i[t.name]=function(n){var e=br("Part: "+t.name+" in "+o,ur(t.schema),n);return y({},r,{config:n,validated:e})}})}),i},_c=function(n,e){return{uiType:Tc(),owner:n,name:e}},qc=function(n,e,t){return r=e,i={},o={},kn(t,function(n){n.fold(function(r){i[r.pname]=Sc(!0,function(n,e,t){return r.factory.sketch($c(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=h(n.factory.sketch($c(r,n,e[Gc()]),e))},function(r){i[r.pname]=Sc(!1,function(n,e,t){return r.factory.sketch($c(n,r,e,t))})},function(o){i[o.pname]=Oc(!0,function(e,n,t){var r=e[o.name];return Tn(r,function(n){return o.factory.sketch(mt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:h(i),externals:h(o)};var r,i,o},Xc=function(n,e,t){return wc(E.some(n),e,e.components,t)},Yc=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOption()},Kc=function(n,e,t){return Yc(n,e,t).getOrDie("Could not find part: "+t)},Jc=function(e,n){var t=Tn(n,jc);return Dt(Tn(t,function(n){return{key:n,value:e+"-"+n}}))},Qc=function(e){return sr("partUids","partUids",xt(function(n){return Jc(n.uid,e)}),wr())},Zc=Ec("alloy-premade"),nf=function(n){return Ct(Zc,n)},ef=function(r){return n=function(n){for(var e=[],t=1;t')},function(n){return xf(''+n+"")})},Tf=function(n,e,t,r){return hf.sketch({dom:Of(n,r),action:e,buttonBehaviours:mt(so([bf.config({})]),t)})},kf={forToolbar:Tf,forToolbarCommand:function(n,e){return Tf(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=Sf(t);return Tf(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=Sf(e);return Tf(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:Of},Ef=Yn.detect().deviceType.isTouch(),Cf=Pc({schema:[Or("dom")],name:"label"}),Df=function(n){return Pc({name:n+"-edge",overrides:function(r){return r.model.manager.edgeActions[n].fold(function(){return{}},function(t){var n=Gr([_r(F(),t,[r])]),e=Gr([_r(H(),t,[r]),_r(j(),function(n,e){e.mouseIsDown.get()&&t(n,e)},[r])]);return{events:Ef?n:e}})}})},Mf=Df("top-left"),Af=Df("top"),If=Df("top-right"),Bf=Df("right"),Rf=Df("bottom-right"),Ff=Df("bottom"),Vf=Df("bottom-left"),Nf=[Cf,Df("left"),Bf,Af,Ff,Mf,If,Vf,Rf,Lc({name:"thumb",defaults:h({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Gr([Xr(F(),n,"spectrum"),Xr(V(),n,"spectrum"),Xr(N(),n,"spectrum"),Xr(H(),n,"spectrum"),Xr(j(),n,"spectrum"),Xr(z(),n,"spectrum")])}}}),Lc({schema:[Ir("mouseIsDown",function(){return Fo(!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)})},n=Gr([Wr(F(),o),Wr(V(),o)]),e=Gr([Wr(H(),o),Wr(j(),function(n,e){t.mouseIsDown.get()&&o(n,e)})]);return{behaviours:so(Ef?[]:[lc.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)}}),zi.config({})]),events:Ef?n:e}}})],Hf=function(n,e,t){e.store.manager.onLoad(n,e,t)},jf=function(n,e,t){e.store.manager.onUnload(n,e,t)},zf=/* */Object.freeze({onLoad:Hf,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}}),Lf=/* */Object.freeze({events:function(t,r){var n=t.resetOnDom?[Kr(function(n,e){Hf(n,t,r)}),Jr(function(n,e){jf(n,t,r)})]:[ro(t,r,Hf)];return Gr(n)}}),Pf=function(){var n=Fo(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()}}})},Uf=function(){var i=Fo({}),u=Fo({});return fo({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return Et(i.get(),n).orThunk(function(){return Et(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};kn(n,function(e){r[e.value]=e,Et(e,"meta").each(function(n){Et(n,"text").each(function(n){o[n]=e})})}),i.set(y({},e,r)),u.set(y({},t,o))},clear:function(){i.set({}),u.set({})}})},Gf=/* */Object.freeze({memory:Pf,dataset:Uf,manual:function(){return fo({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),$f=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},Wf=[Er("initialValue"),Or("getFallbackEntry"),Or("getDataKey"),Or("setValue"),di("manager",{setValue:$f,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){$f(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:Uf})],_f=[Or("getValue"),Mr("setValue",x),Er("initialValue"),di("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:x,state:co.init})],qf=[Er("initialValue"),di("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:Pf})],Xf=[Ar("store",{mode:"memory"},xr("mode",{memory:qf,manual:_f,dataset:Wf})),ci("onSetValue"),Mr("resetOnDom",!1)],Yf=mo({fields:Xf,name:"representing",active:Lf,apis:zf,extra:{setValueFrom:function(n,e){var t=Yf.getValue(e);Yf.setValue(n,t)}},state:Gf}),Kf=function(t,r){return{left:h(t),top:h(r),translate:function(n,e){return Kf(t+n,r+e)}}},Jf=Kf,Qf=Yn.detect().deviceType.isTouch(),Zf=h("slider.change.value"),ns=function(n){var e=n.event().raw();if(Qf){var t=e;return t.touches!==undefined&&1===t.touches.length?E.some(t.touches[0]).map(function(n){return Jf(n.clientX,n.clientY)}):E.none()}var r=e;return r.clientX!==undefined?E.some(r).map(function(n){return Jf(n.clientX,n.clientY)}):E.none()},es=function(n,e,t,r){return n'),components:[Dl.parts()["left-edge"](wf('
')),Dl.parts().spectrum({dom:xf('
'),components:[wf('
')],behaviours:so([Mi.config({toggleClass:Fi.resolve("thumb-active")})])}),Dl.parts()["right-edge"](wf('
')),Dl.parts().thumb({dom:xf('
'),behaviours:so([Mi.config({toggleClass:Fi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Ui(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Mi.on(e)},onDragEnd:function(n,e){Mi.off(e)},onInit:function(n,e,t,r){var o=i(r.x());Ui(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:so([Ii(Dl.refresh)])}))];var o,i},Il=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 Ml(n,"color-levels",function(){return Al(e)},r)},Bl=ir([Or("getInitialValue"),Or("onChange"),Or("category"),Or("sizes")]),Rl=function(n){var i=br("SizeSlider",Bl,n);return Dl.sketch({dom:{tag:"div",classes:[Fi.resolve("slider-"+i.category+"-size-container"),Fi.resolve("slider"),Fi.resolve("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r'),components:[wf('
')]}),Dl.parts().thumb({dom:xf('
'),behaviours:so([Mi.config({toggleClass:Fi.resolve("thumb-active")})])})]})},Fl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Vl=function(n){var e,t,r=n.selection.getStart(),o=be.fromDom(r),i=be.fromDom(n.getBody()),u=(e=function(n){return Ue(i,n)},(Te(t=o)?E.some(t):$e(t)).map(function(n){return Lr(n,function(n){return _i(n,"font-size").isSome()},e).bind(function(n){return _i(n,"font-size")}).getOrThunk(function(){return $i(n,"font-size")})}).getOr(""));return Mn(Fl,function(n){return u===n}).getOr("medium")},Nl={candidates:h(Fl),get:function(n){var e,t=Vl(n);return(e=t,An(Fl,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,E.from(Fl[e])).each(function(n){var e,t;t=n,Vl(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},Hl=Nl.candidates(),jl=function(n){return[wf(''),(e=n,Rl({onChange:e.onChange,sizes:Hl,category:"font",getInitialValue:e.getInitialValue})),wf('')];var e},zl=function(n){var e=function t(n){return n.uid!==undefined}(n)&&At(n,"uid")?n.uid:ff("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(E.none,E.some)},asSpec:function(){return y({},n,{uid:e})}}};function Ll(n,e){return Ul(v.document.createElement("canvas"),n,e)}function Pl(n){return n.getContext("2d")}function Ul(n,e,t){return n.width=e,n.height=t,n}var Gl={create:Ll,clone:function Nh(n){var e;return Pl(e=Ll(n.width,n.height)).drawImage(n,0,0),e},resize:Ul,get2dContext:Pl,get3dContext:function Hh(n){var e=null;try{e=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},$l={getWidth:function jh(n){return n.naturalWidth||n.width},getHeight:function zh(n){return n.naturalHeight||n.height}},Wl=window.Promise?window.Promise:function(){var n=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=[],f(n,r(o,this),r(u,this))},e=n.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){v.setTimeout(n,1)};function r(n,e){return function(){n.apply(e,arguments)}}var t=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};function i(r){var o=this;null!==this._state?e(function(){var n=o._state?r.onFulfilled:r.onRejected;if(null!==n){var e;try{e=n(o._value)}catch(t){return void r.reject(t)}r.resolve(e)}else(o._state?r.resolve:r.reject)(o._value)}):this._deferreds.push(r)}function o(n){try{if(n===this)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var e=n.then;if("function"==typeof e)return void f(r(e,n),r(o,this),r(u,this))}this._state=!0,this._value=n,a.call(this)}catch(t){u.call(this,t)}}function u(n){this._state=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferreds.length;n'),action:function(n){var e=t.get(n);Yf.setValue(e,"")}}));return{name:n,spec:bd.sketch({dom:xf('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:so([Mi.config({toggleClass:Fi.resolve("input-container-empty")}),hd.config({find:function(n){return E.some(t.get(n))}}),gd("input-clearing",[Wr(G(),function(n){var e=t.get(n);(0"},$d=function(o,n,e){return{uid:o.uid,dom:o.dom,components:n,behaviours:gc(o.formBehaviours,[Yf.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),A(e.partUids,function(n,e){return h(t.getByUid(n))}));return A(r,function(n,e){return n().bind(function(n){var e,t=hd.getCurrent(n);return e="missing current",t.fold(function(){return ft.error(e)},ft.value)}).map(Yf.getValue)})},setValue:function(t,n){M(n,function(e,n){Yc(t,o,n).each(function(n){hd.getCurrent(n).each(function(n){Yf.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return Yc(n,o,e).bind(hd.getCurrent)}}}},Wd=(ef(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=Gd(n),o=e,{uiType:Tc(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=Tn(r,function(n){return Lc({name:n,pname:Gd(n)})});return lf("form",Ud,o,$d,t)}),_d=function(){var e=Fo(E.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(E.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(E.some(n))},run:function(n){e.get().each(n)}}},qd=function(){var e=Fo(E.none());return{clear:function(){e.set(E.none())},set:function(n){e.set(E.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},Xd=function(n){return{xValue:n,points:[]}},Yd=function(n,e){if(e===n.xValue)return n;var t=0'),action:function(n){me(n,r,{direction:e})},buttonBehaviours:so([Pd.config({disableClass:Fi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=tu(n.element(),"."+Fi.resolve("serialised-dialog-screen"));iu(n.element(),"."+Fi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[bd.sketch({dom:xf('
'),components:Tn(u.fields,function(n,e){return e<=u.maxFieldIndex?bd.sketch({dom:xf('
'),components:[o(-1,"previous",0'),behaviours:so([Mu.config({highlightClass:Fi.resolve("dot-active"),itemClass:Fi.resolve("dot-item")})]),components:Fn(u.fields,function(n,e){return e<=u.maxFieldIndex?[wf('
')]:[]})});return{dom:xf('
'),components:[c.asSpec(),f.asSpec()],behaviours:so([lc.config({mode:"special",focusIn:function(n){var e=c.get(n);lc.focusIn(e)}}),gd("serializer-wrapper-events",[Wr(F(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(Xd(t.raw().touches[0].clientX))}),Wr(V(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(Yd(n,t.raw().touches[0].clientX))})}),Wr(N(),function(r){u.state.dialogSwipeState.on(function(n){var e=c.get(r),t=-1*Kd(n);i(e,t)})})])])}},Qd=X(function(t,r){return[{label:"the link group",items:[Jd({fields:[Dd("url","Type or paste URL"),Dd("text","Link text"),Dd("title","Link title"),Dd("target","Link target"),(n="link",{name:n,spec:yd.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return E.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return E.some(sd.getInfo(r))},onExecute:function(n){var e=Yf.getValue(n);sd.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),Zd=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],nm=Gr([(Zl=Jn(),nd=function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(Ue(t=o,n.element())&&!Ue(t,r)&&(v.console.warn(Jn()+" did not get interpreted by the desired target. \nOriginator: "+qo(o)+"\nTarget: "+qo(i)+"\nCheck the "+Jn()+" event handlers"),1))},{key:Zl,value:Rr({can:nd})})]),em=/* */Object.freeze({events:nm}),tm=b,rm=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+qo(e().element())+" is not in context.")}};return{debugInfo:h("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:h(!1)}},om=rm(),im=function(n,o){var i={};return M(n,function(n,r){M(n,function(n,e){var t=kt(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},um=function(n,e){return t=l.apply(undefined,[n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:h(r)};var t,r},am=function(n){return n.cHandler},cm=function(n,e){return{name:h(n),handler:h(e)}},fm=function(n,e,t){var r,o,i=y({},t,(r=n,o={},kn(e,function(n){o[n.name()]=n.handlers(r)}),o));return im(i,cm)},sm=function(n){var e,i=yn(e=n)?{can:h(!0),abort:h(!1),run:e}:e;return function(n,e){for(var t=[],r=2;r "):r[0].name();return Ct(o,{handler:e,purpose:h(t)})})});return Mt(e,{})},mm=function(n){return vr("custom.definition",ur([sr("dom","dom",ht(),ur([Or("tag"),Mr("styles",{}),Mr("classes",[]),Mr("attributes",{}),Er("value"),Er("innerHtml")])),Or("components"),Or("uid"),Mr("events",{}),Mr("apis",{}),sr("eventOrder","eventOrder",(e={"alloy.execute":["disabling","alloy.base.behaviour","toggling","typeaheadevents"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing","item-events","tooltipping"],mousedown:["focusing","alloy.base.behaviour","item-type-events"],mouseover:["item-type-events","tooltipping"]},pt.mergeWithThunk(h(e))),wr()),Er("domModification")]),n);var e},gm=function(e,n){kn(n,function(n){Eo(e,n)})},pm=function(e,n){kn(n,function(n){Do(e,n)})},vm=function(n,e){return t=n,o=Tn(r=e,function(n){return Cr(n.name(),[Or("config"),Mr("state",co)])}),i=vr("component.behaviours",ur(o),t.behaviours).fold(function(n){throw new Error(yr(n)+"\nComplete spec:\n"+Jt(t,null,2))},function(n){return n}),{list:r,data:A(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},hm=function(n){var e,t,r,o=(e=n,t=kt("behaviours",{})(e),r=En(C(t),function(n){return t[n]!==undefined}),Tn(r,function(n){return t[n].me}));return vm(n,o)},bm=function(n,e,t){var r,o,i,u=y({},(r=n).dom,{uid:r.uid,domChildren:Tn(r.components,function(n){return n.element()})}),a=n.domModification.fold(function(){return to({})},to),c={"alloy.base.modification":a},f=0");r[t[0]]=Ct(t[1],n),r[t[1]]=Ct(t[0],n)}),r},createBistate:function(n,e,t){return Dt([{key:n,value:Ct(e,t)},{key:e,value:Ct(n,t)}])},createTristate:function(n,e,t,r){return Dt([{key:n,value:Dt([{key:e,value:r},{key:t,value:r}])},{key:e,value:Dt([{key:n,value:r},{key:t,value:r}])},{key:t,value:Dt([{key:n,value:r},{key:e,value:r}])}])}}}),ag=Fi.resolve("scrollable"),cg={register:function(n){Eo(n,ag)},deregister:function(n){Do(n,ag)},scrollable:h(ag)},fg=function(n){return Et(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?[Fi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Fi.resolve("format-matches"),selected:t},itemBehaviours:so(o?[]:[Ai(n,function(n,e){(e?Mi.on:Mi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},lg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[hf.sketch({dom:{tag:"div",classes:[Fi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Fi.resolve("styles-collapse-icon")]}},Sm(n)]:[Sm(n)],action:function(n){if(r){var e=t().get(n);Jm.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Fi.resolve("styles-menu-items-container")]},components:[Pm.parts().items({})],behaviours:so([gd("adhoc-scrollable-menu",[Kr(function(n,e){Ui(n.element(),"overflow-y","auto"),Ui(n.element(),"-webkit-overflow-scrolling","touch"),cg.register(n.element())}),Jr(function(n){qi(n.element(),"overflow-y"),qi(n.element(),"-webkit-overflow-scrolling"),cg.deregister(n.element())})])])}],items:e,menuBehaviours:so([ug.config({initialState:"after",routes:ug.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},dg=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return a},n=lg("Styles",[].concat(Tn(o.items,function(n){return sg(fg(n),n.title,n.isSelected(),n.getPreview(),At(o.expansions,fg(n)))})),i,!1),e=A(o.menus,function(n,e){var t=Tn(n,function(n){return sg(fg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",At(o.expansions,fg(n)))});return lg(e,t,i,!0)}),t=mt(e,Ct("styles",n)),{tmenu:Jm.tieredData("styles",t,o.expansions)}),a=zl(Jm.sketch({dom:{tag:"div",classes:[Fi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=Yf.getValue(e);return r.handle(e,t.value),E.none()},onEscape:function(){return E.none()},onOpenMenu:function(n,e){var t=cs(n.element());as(e.element(),t),ug.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=cs(n.element()),o=ou(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();as(t.element(),r),ug.progressTo(i,"before"),ug.jumpTo(t,"after"),ug.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=ou(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();ug.progressTo(o,"after"),ug.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Fi.resolve("styles-background-menu"),menu:Fi.resolve("styles-menu"),selectedMenu:Fi.resolve("styles-selected-menu"),item:Fi.resolve("styles-item"),selectedItem:Fi.resolve("styles-selected-item")}}));return a.asSpec()},mg=function(n){return At(n,"items")?(i=mt((st([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),e=o=n,t=["items"],r={},M(e,function(n,e){Sn(t,e)||(r[e]=n)}),r),{menu:!0}),u=gg(o.items),{item:i,menus:mt(u.menus,Ct(o.title,u.items)),expansions:mt(u.expansions,Ct(o.title,o.title))}):{item:n,menus:{},expansions:{}};var e,t,r,o,i,u},gg=function(n){return Cn(n,function(n,e){var t=mg(e);return{menus:mt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:mt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},pg={expand:gg},vg=function(u,n){var a=function(n){return function(){return u.formatter.match(n)}},c=function(n){return function(){return u.formatter.getCssText(n)}},e=Et(n,"style_formats").getOr(Zd),f=function(n){return Tn(n,function(n){if(At(n,"items")){var e=f(n.items);return mt(mt(n,{isSelected:h(!1),getPreview:h("")}),{items:e})}return At(n,"format")?mt(i=n,{isSelected:a(i.format),getPreview:c(i.format)}):(r=Ec((t=n).title),o=mt(t,{format:r,isSelected:a(r),getPreview:c(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return f(e)},hg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return Fn(n,function(n){return n.items===undefined?!At(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===jg?[]:[Dg(be.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Mi.off)}),Dg(i,"select",n),Dg(r.doc(),"selectionchange",n)]);return{destroy:function(){kn(a,function(n){n.unbind()})}}},Lg=function(n,e){var t=parseInt(yo(n,e),10);return isNaN(t)?0:t},Pg=function qh(t,r){var o=function(n){return t(n)?E.from(n.dom().nodeValue):E.none()},n=Yn.detect().browser,e=n.isIE()&&10===n.version.major?function(n){try{return o(n)}catch(e){return E.none()}}:o;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}}}(ke,"text"),Ug=function(n){return Pg.getOption(n)},Gg=st([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),$g={before:Gg.before,on:Gg.on,after:Gg.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(b,b,b)}},Wg=st([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),_g=Me("start","soffset","finish","foffset"),qg=Wg.relative,Xg=Wg.exact,Yg=function(n,e,t,r){var o,i,u,a,c,f=(i=e,u=t,a=r,(c=Ge(o=n).dom().createRange()).setStart(o.dom(),i),c.setEnd(u.dom(),a),c),s=Ue(n,t)&&e===r;return f.collapsed&&!s},Kg=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},Jg=function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},Qg=function(n){return{left:h(n.left),top:h(n.top),right:h(n.right),bottom:h(n.bottom),width:h(n.width),height:h(n.height)}},Zg=st([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),np=function(n,e,t){return e(be.fromDom(t.startContainer),t.startOffset,be.fromDom(t.endContainer),t.endOffset)},ep=function(n,e){var o,t,r,i=(o=n,e.match({domRange:function(n){return{ltr:h(n),rtl:E.none}},relative:function(n,e){return{ltr:X(function(){return Kg(o,n,e)}),rtl:X(function(){return E.some(Kg(o,e,n))})}},exact:function(n,e,t,r){return{ltr:X(function(){return Jg(o,n,e,t,r)}),rtl:X(function(){return E.some(Jg(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return Zg.rtl(be.fromDom(n.endContainer),n.endOffset,be.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return np(0,Zg.ltr,r)}):np(0,Zg.ltr,r)},tp=(document.caretPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=Se(n);return"input"===t?$g.after(n):Sn(["br","img"],t)?0===e?$g.before(n):$g.after(n):$g.on(n,e)}),rp=function(n,e,t,r,o){var i,u,a=Jg(n,e,t,r,o);i=n,u=a,E.from(i.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},op=function(n,e,t,r,o){var i,u,a,c,l,f=(i=r,u=o,a=tp(e,t),c=tp(i,u),qg(a,c));ep(l=n,f).match({ltr:function(n,e,t,r){rp(l,n,e,t,r)},rtl:function(n,e,t,r){var o,i,u,a,c,f=l.getSelection();if(f.setBaseAndExtent)f.setBaseAndExtent(n.dom(),e,t.dom(),r);else if(f.extend)try{i=n,u=e,a=t,c=r,(o=f).collapse(i.dom(),u),o.extend(a.dom(),c)}catch(s){rp(l,t,r,n,e)}else rp(l,t,r,n,e)}})},ip=function(n){var e=be.fromDom(n.anchorNode),t=be.fromDom(n.focusNode);return Yg(e,n.anchorOffset,t,n.focusOffset)?E.some(_g(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)})}),gp(e,n.innerHeight)});return gp(e,n.innerHeight),{toEditing:function(){dp(u)},destroy:function(){t.unbind()}}},bp=function(n){return E.some(be.fromDom(n.dom().contentWindow.document.body))},yp=function(n){return E.some(be.fromDom(n.dom().contentWindow.document))},xp=function(n){return E.from(n.dom().contentWindow)},wp=function(n){return xp(n).bind(up)},Sp=function(n){return n.getFrame()},Op=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=Sp(e);return function(){return t(n)}})()}},Tp=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return Dg(e,r,n)}})},kp=function(n){return{left:h(n.left),top:h(n.top),right:h(n.right),bottom:h(n.bottom),width:h(n.width),height:h(n.height)}},Ep={getBody:Op("getBody",bp),getDoc:Op("getDoc",yp),getWin:Op("getWin",xp),getSelection:Op("getSelection",wp),getFrame:Sp,getActiveApi:function(a){var c=Sp(a);return bp(c).bind(function(u){return yp(c).bind(function(i){return xp(c).map(function(o){var n=be.fromDom(i.dom().documentElement),e=a.getCursorBox.getOrThunk(function(){return function(){return(n=o,up(n).map(function(n){return Xg(n.start(),n.soffset(),n.finish(),n.foffset())})).bind(function(n){return ap(o,n).orThunk(function(){return up(o).filter(function(n){return Ue(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0