/** * 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.4 (2019-04-23) */ !function(v){"use strict";var y=function(){return(y=Object.assign||function(n){for(var e,t=1,r=arguments.length;tc[0]&&n[1] "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return Jt.objOf(Tn(c,function(n){return n.fold(function(n,e,t,r){return Qt.field(n,t,r)},function(n,e){return Qt.state(n)})}))}}},sr=function(t,i){var u=function(n,e){return(o=cr(t),{extract:function(t,r,n){var e=Tn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return Kt(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return Jt.arrOf(o)}}).extract(n,w,e);var o};return{extract:function(t,r,o){var n=I(o),e=u(t,n);return $t(e,function(n){var e=Tn(n,function(n){return rr.field(n,n,xt(),i)});return fr(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return Jt.setOf(t,i)}}},lr=b(cr(Lt)),dr=rr.state,mr=rr.field,gr=function(t,e,r,o,i){return Mt(o,i).fold(function(){return n=o,e=i,tr(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+er(n)});var n,e},function(n){return fr(n).extract(t.concat(["branch: "+i]),e,r)})},pr=function(o,i){return{extract:function(e,t,r){return Mt(r,o).fold(function(){return n=o,tr(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return gr(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+I(i)},toDsl:function(){return Jt.choiceOf(o,i)}}},vr=cr(Lt),hr=function(e){return cr(function(n){return e(n).fold(Gt,Lt)})},br=function(e,n){return sr(function(n){return zt(e(n))},n)},yr=function(n,e,t){return Pt((r=n,o=w,i=t,u=e.extract([r],o,i),qt(u,function(n){return{input:i,errors:n}})));var r,o,i,u},xr=function(n){return n.fold(function(n){throw new Error(Sr(n))},w)},wr=function(n,e,t){return xr(yr(n,e,t))},Sr=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+er(n.input);var e,t},Or=function(n,e){return pr(n,e)},Tr=b(vr),kr=(Ft=yn,Vt="function",cr(function(n){var e=typeof n;return Ft(n)?Lt(n):Gt("Expected type: "+Vt+" but got: "+e)})),Er=function(n){return mr(n,n,xt(),lr())},Cr=function(n,e){return mr(n,n,xt(),e)},Dr=function(n,e){return mr(n,n,xt(),fr(e))},Mr=function(n){return mr(n,n,wt(),lr())},Ir=function(n,e){return mr(n,n,wt(),e)},Ar=function(n,e){return Ir(n,fr(e))},Br=function(n,e){return Ir(n,ar(e))},Rr=function(n,e){return mr(n,n,yt(e),lr())},Fr=function(n,e,t){return mr(n,n,yt(e),t)},Vr=function(n,e){return dr(n,e)},Nr=function(n,e){return We(n.element(),e.event().target())},jr=function(n){if(!Rt(n,"can")&&!Rt(n,"abort")&&!Rt(n,"run"))throw new Error("EventHandler defined by: "+nr(n,null,2)+" does not have can, abort, or run!");return wr("Extracting event.handler",ar([Rr("can",b(!0)),Rr("abort",b(!1)),Rr("run",x)]),n)},Hr=function(t){var e,r,o,i,n=(e=t,r=function(n){return n.can},function(){for(var t=[],n=0;n"}),Tr()),$a=Vr("schema",function(){return[Mr("preprocess")]}),Wa=Rr("defaults",b({})),_a=Rr("overrides",b({})),qa=fr([Pa,La,Ua,Ga,Wa,_a]),Xa=fr([Pa,La,Ua,Ga,Wa,_a]),Ya=fr([Pa,$a,Ua,Er("unit"),Ga,Wa,_a]),Ka=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},Ja=function(t,r){return function(n){var e=wr("Converting part type",r,n);return t(e)}},Qa=Ja(za.required,qa),Za=Ja(za.optional,Xa),nf=Ja(za.group,Ya),ef=b("entirety"),tf=function(n,e,t,r){return vt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},rf=function(o,n){var i={};return kn(n,function(n){var e;(e=n,e.fold(M.some,M.none,M.some,M.some)).each(function(t){var r=of(o,t.pname);i[t.name]=function(n){var e=wr("Part: "+t.name+" in "+o,fr(t.schema),n);return y({},r,{config:n,validated:e})}})}),i},of=function(n,e){return{uiType:Na(),owner:n,name:e}},uf=function(n,e,t){return{uiType:Na(),owner:n,name:e,config:t,validated:{}}},cf=function(n){return Vn(n,function(n){return n.fold(M.none,M.some,M.none,M.none).map(function(n){return Dr(n.name,n.schema.concat([Oi(ef())]))}).toArray()})},af=function(n){return Tn(n,Ka)},ff=function(n,e,t){return r=e,i={},o={},kn(t,function(n){n.fold(function(r){i[r.pname]=Fa(!0,function(n,e,t){return r.factory.sketch(tf(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=b(n.factory.sketch(tf(r,n,e[ef()]),e))},function(r){i[r.pname]=Fa(!1,function(n,e,t){return r.factory.sketch(tf(n,r,e,t))})},function(o){i[o.pname]=Va(!0,function(e,n,t){var r=e[o.name];return Tn(r,function(n){return o.factory.sketch(vt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:b(i),externals:b(o)};var r,i,o},sf=function(n,e,t){return Ra(M.some(n),e,e.components,t)},lf=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOption()},df=function(n,e,t){return lf(n,e,t).getOrDie("Could not find part: "+t)},mf=function(n,e){var t=n.getSystem();return R(e.partUids,function(n,e){return b(t.getByUid(n))})},gf=function(e,n){var t=af(n);return At(Tn(t,function(n){return{key:n,value:e+"-"+n}}))},pf=function(e){return mr("partUids","partUids",Ot(function(n){return gf(n.uid,e)}),Tr())},vf=Ha("alloy-premade"),hf=function(n){return It(vf,n)},bf=function(n){return Mt(n,vf)},yf=function(r){return n=function(n){for(var e=[],t=1;t')},function(n){return jf(''+n+"")})},Lf=function(n,e,t,r){return Ff.sketch({dom:Pf(n,r),action:e,buttonBehaviours:vt(vo([Vf.config({})]),t)})},Uf={forToolbar:Lf,forToolbarCommand:function(n,e){return Lf(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=zf(t);return Lf(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=zf(e);return Lf(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:Pf},Gf=Jn.detect().deviceType.isTouch(),$f=Za({schema:[Er("dom")],name:"label"}),Wf=function(n){return Za({name:n+"-edge",overrides:function(r){return r.model.manager.edgeActions[n].fold(function(){return{}},function(t){var n=Wr([Yr(j(),t,[r])]),e=Wr([Yr(P(),t,[r]),Yr(L(),function(n,e){e.mouseIsDown.get()&&t(n,e)},[r])]);return{events:Gf?n:e}})}})},_f=Wf("top-left"),qf=Wf("top"),Xf=Wf("top-right"),Yf=Wf("right"),Kf=Wf("bottom-right"),Jf=Wf("bottom"),Qf=Wf("bottom-left"),Zf=[$f,Wf("left"),Yf,qf,Jf,_f,Xf,Qf,Kf,Qa({name:"thumb",defaults:b({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Wr([Qr(j(),n,"spectrum"),Qr(H(),n,"spectrum"),Qr(z(),n,"spectrum"),Qr(P(),n,"spectrum"),Qr(L(),n,"spectrum"),Qr(U(),n,"spectrum")])}}}),Qa({schema:[Vr("mouseIsDown",function(){return Po(!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=Wr([Xr(j(),o),Xr(H(),o)]),e=Wr([Xr(P(),o),Xr(L(),function(n,e){t.mouseIsDown.get()&&o(n,e)})]);return{behaviours:vo(Gf?[]:[Oa.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)}}),Xi.config({})]),events:Gf?n:e}}})],ns=function(n,e,t){e.store.manager.onLoad(n,e,t)},es=function(n,e,t){e.store.manager.onUnload(n,e,t)},ts=/* */Object.freeze({onLoad:ns,onUnload:es,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}}),rs=/* */Object.freeze({events:function(t,r){var n=t.resetOnDom?[to(function(n,e){ns(n,t,r)}),ro(function(n,e){es(n,t,r)})]:[fo(t,r,ns)];return Wr(n)}}),os=function(){var n=Po(null);return po({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()}}})},is=function(){var i=Po({}),u=Po({});return po({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return Mt(i.get(),n).orThunk(function(){return Mt(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};kn(n,function(e){r[e.value]=e,Mt(e,"meta").each(function(n){Mt(n,"text").each(function(n){o[n]=e})})}),i.set(y({},e,r)),u.set(y({},t,o))},clear:function(){i.set({}),u.set({})}})},us=/* */Object.freeze({memory:os,dataset:is,manual:function(){return po({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),cs=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},as=[Mr("initialValue"),Er("getFallbackEntry"),Er("getDataKey"),Er("setValue"),Si("manager",{setValue:cs,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){cs(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:is})],fs=[Er("getValue"),Rr("setValue",x),Mr("initialValue"),Si("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:go.init})],ss=[Mr("initialValue"),Si("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:os})],ls=[Fr("store",{mode:"memory"},Or("mode",{memory:ss,manual:fs,dataset:as})),bi("onSetValue"),Rr("resetOnDom",!1)],ds=bo({fields:ls,name:"representing",active:rs,apis:ts,extra:{setValueFrom:function(n,e){var t=ds.getValue(e);ds.setValue(n,t)}},state:us}),ms=function(t,r){return{left:b(t),top:b(r),translate:function(n,e){return ms(t+n,r+e)}}},gs=ms,ps=Jn.detect().deviceType.isTouch(),vs=b("slider.change.value"),hs=function(n){var e=n.event().raw();if(ps){var t=e;return t.touches!==undefined&&1===t.touches.length?M.some(t.touches[0]).map(function(n){return gs(n.clientX,n.clientY)}):M.none()}var r=e;return r.clientX!==undefined?M.some(r).map(function(n){return gs(n.clientX,n.clientY)}):M.none()},bs=function(n,e,t,r){return n'),components:[Wl.parts()["left-edge"](Hf('
')),Wl.parts().spectrum({dom:jf('
'),components:[Hf('
')],behaviours:vo([Hi.config({toggleClass:Gi.resolve("thumb-active")})])}),Wl.parts()["right-edge"](Hf('
')),Wl.parts().thumb({dom:jf('
'),behaviours:vo([Hi.config({toggleClass:Gi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Qi(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Hi.on(e)},onDragEnd:function(n,e){Hi.off(e)},onInit:function(n,e,t,r){var o=i(r.x());Qi(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:vo([Pi(Wl.refresh)])}))];var o,i},Xl=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 _l(n,"color-levels",function(){return ql(e)},r)},Yl=ar([Er("getInitialValue"),Er("onChange"),Er("category"),Er("sizes")]),Kl=function(n){var i=wr("SizeSlider",Yl,n);return Wl.sketch({dom:{tag:"div",classes:[Gi.resolve("slider-"+i.category+"-size-container"),Gi.resolve("slider"),Gi.resolve("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r'),components:[Hf('
')]}),Wl.parts().thumb({dom:jf('
'),behaviours:vo([Hi.config({toggleClass:Gi.resolve("thumb-active")})])})]})},Jl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Ql=function(n){var e,t,r=n.selection.getStart(),o=xe.fromDom(r),i=xe.fromDom(n.getBody()),u=(e=function(n){return We(i,n)},(Ce(t=o)?M.some(t):qe(t)).map(function(n){return Ur(n,function(n){return tu(n,"font-size").isSome()},e).bind(function(n){return tu(n,"font-size")}).getOrThunk(function(){return nu(n,"font-size")})}).getOr(""));return In(Jl,function(n){return u===n}).getOr("medium")},Zl={candidates:b(Jl),get:function(n){var e,t=Ql(n);return(e=t,An(Jl,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,M.from(Jl[e])).each(function(n){var e,t;t=n,Ql(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},nd=Zl.candidates(),ed=function(n){return[Hf(''),(e=n,Kl({onChange:e.onChange,sizes:nd,category:"font",getInitialValue:e.getInitialValue})),Hf('')];var e},td=function(n){var e=function t(n){return n.uid!==undefined}(n)&&Rt(n,"uid")?n.uid:Ef("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(M.none,M.some)},asSpec:function(){return y({},n,{uid:e})}}};function rd(n,e){return id(v.document.createElement("canvas"),n,e)}function od(n){return n.getContext("2d")}function id(n,e,t){return n.width=e,n.height=t,n}var ud={create:rd,clone:function gb(n){var e;return od(e=rd(n.width,n.height)).drawImage(n,0,0),e},resize:id,get2dContext:od,get3dContext:function pb(n){var e=null;try{e=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},cd={getWidth:function vb(n){return n.naturalWidth||n.width},getHeight:function hb(n){return n.naturalHeight||n.height}},ad=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,c.call(this)}catch(t){u.call(this,t)}}function u(n){this._state=!1,this._value=n,c.call(this)}function c(){for(var n=0,e=this._deferreds.length;n'),action:function(n){var e=t.get(n);ds.setValue(e,"")}}));return{name:n,spec:Rd.sketch({dom:jf('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:vo([Hi.config({toggleClass:Gi.resolve("input-container-empty")}),Bd.config({find:function(n){return M.some(t.get(n))}}),Md("input-clearing",[Xr(_(),function(n){var e=t.get(n);(0"},cm=function(r,n,e){return{uid:r.uid,dom:r.dom,components:n,behaviours:Ea(r.formBehaviours,[ds.config({store:{mode:"manual",getValue:function(n){var e=mf(n,r);return R(e,function(n,e){return n().bind(function(n){var e,t=Bd.getCurrent(n);return e="missing current",t.fold(function(){return dt.error(e)},dt.value)}).map(ds.getValue)})},setValue:function(t,n){B(n,function(e,n){lf(t,r,n).each(function(n){Bd.getCurrent(n).each(function(n){ds.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return lf(n,r,e).bind(Bd.getCurrent)}}}},am=(yf(function(n,e,t){return n.getField(e,t)}),function(n){var t,e=(t=[],{field:function(n,e){return t.push(n),uf("form",um(n),e)},record:function(){return t}}),r=n(e),o=e.record(),i=Tn(o,function(n){return Qa({name:n,pname:um(n)})});return Df("form",im,i,cm,r)}),fm=function(){var e=Po(M.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(M.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(M.some(n))},run:function(n){e.get().each(n)}}},sm=function(){var e=Po(M.none());return{clear:function(){e.set(M.none())},set:function(n){e.set(M.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},lm=function(n){return{xValue:n,points:[]}},dm=function(n,e){if(e===n.xValue)return n;var t=0'),action:function(n){pe(n,r,{direction:e})},buttonBehaviours:vo([om.config({disableClass:Gi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=pu(n.element(),"."+Gi.resolve("serialised-dialog-screen"));bu(n.element(),"."+Gi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[Rd.sketch({dom:jf('
'),components:Tn(u.fields,function(n,e){return e<=u.maxFieldIndex?Rd.sketch({dom:jf('
'),components:[o(-1,"previous",0'),behaviours:vo([Gu.config({highlightClass:Gi.resolve("dot-active"),itemClass:Gi.resolve("dot-item")})]),components:Vn(u.fields,function(n,e){return e<=u.maxFieldIndex?[Hf('
')]:[]})});return{dom:jf('
'),components:[a.asSpec(),f.asSpec()],behaviours:vo([Oa.config({mode:"special",focusIn:function(n){var e=a.get(n);Oa.focusIn(e)}}),Md("serializer-wrapper-events",[Xr(j(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(lm(t.raw().touches[0].clientX))}),Xr(H(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(dm(n,t.raw().touches[0].clientX))})}),Xr(z(),function(r){u.state.dialogSwipeState.on(function(n){var e=a.get(r),t=-1*mm(n);i(e,t)})})])])}},pm=J(function(t,r){return[{label:"the link group",items:[gm({fields:[$d("url","Type or paste URL"),$d("text","Link text"),$d("title","Link title"),$d("target","Link target"),(n="link",{name:n,spec:Fd.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return M.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return M.some(kd.getInfo(r))},onExecute:function(n){var e=ds.getValue(n);kd.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),vm=[{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"}]}],hm=Wr([qr(Zn(),function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(We(t=o,n.element())&&!We(t,r)&&(v.console.warn(Zn()+" did not get interpreted by the desired target. \nOriginator: "+Zo(o)+"\nTarget: "+Zo(i)+"\nCheck the "+Zn()+" event handlers"),1))})]),bm=/* */Object.freeze({events:hm}),ym=w,xm=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+Zo(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)}},wm=xm(),Sm=function(n,o){var i={};return B(n,function(n,r){B(n,function(n,e){var t=Dt(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},Om=function(n,e){return t=l.apply(undefined,[n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:b(r)};var t,r},Tm=function(n){return n.cHandler},km=function(n,e){return{name:b(n),handler:b(e)}},Em=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 Sm(i,km)},Cm=function(n){var e,i=yn(e=n)?{can:b(!0),abort:b(!1),run:e}:e;return function(n,e){for(var t=[],r=2;r "):r[0].name();return It(o,{handler:e,purpose:b(t)})})});return Bt(e,{})},Im=function(n){return yr("custom.definition",fr([mr("dom","dom",xt(),fr([Er("tag"),Rr("styles",{}),Rr("classes",[]),Rr("attributes",{}),Mr("value"),Mr("innerHtml")])),Er("components"),Er("uid"),Rr("events",{}),Rr("apis",{}),mr("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"]},bt.mergeWithThunk(b(e))),Tr()),Mr("domModification")]),n);var e},Am=function(e,n){kn(n,function(n){Ro(e,n)})},Bm=function(e,n){kn(n,function(n){Fo(e,n)})},Rm=function(n,e){return t=n,o=Tn(r=e,function(n){return Ar(n.name(),[Er("config"),Rr("state",go)])}),i=yr("component.behaviours",fr(o),t.behaviours).fold(function(n){throw new Error(Sr(n)+"\nComplete spec:\n"+nr(t,null,2))},function(n){return n}),{list:r,data:R(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},Fm=function(n){var e,t,r,o=(e=n,t=Dt("behaviours",{})(e),r=Cn(I(t),function(n){return t[n]!==undefined}),Tn(r,function(n){return t[n].me}));return Rm(n,o)},Vm=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()})}),c=n.domModification.fold(function(){return ao({})},ao),a={"alloy.base.modification":c},f=0");r[t[0]]=It(t[1],n),r[t[1]]=It(t[0],n)}),r},createBistate:function(n,e,t){return At([{key:n,value:It(e,t)},{key:e,value:It(n,t)}])},createTristate:function(n,e,t,r){return At([{key:n,value:At([{key:e,value:r},{key:t,value:r}])},{key:e,value:At([{key:n,value:r},{key:t,value:r}])},{key:t,value:At([{key:n,value:r},{key:e,value:r}])}])}}}),Tg=Gi.resolve("scrollable"),kg={register:function(n){Ro(n,Tg)},deregister:function(n){Fo(n,Tg)},scrollable:b(Tg)},Eg=function(n){return Mt(n,"format").getOr(n.title)},Cg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Gi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Gi.resolve("format-matches"),selected:t},itemBehaviours:vo(o?[]:[zi(n,function(n,e){(e?Hi.on:Hi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},Dg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Ff.sketch({dom:{tag:"div",classes:[Gi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Gi.resolve("styles-collapse-icon")]}},zm(n)]:[zm(n)],action:function(n){if(r){var e=t().get(n);gg.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Gi.resolve("styles-menu-items-container")]},components:[og.parts().items({})],behaviours:vo([Md("adhoc-scrollable-menu",[to(function(n,e){Qi(n.element(),"overflow-y","auto"),Qi(n.element(),"-webkit-overflow-scrolling","touch"),kg.register(n.element())}),ro(function(n){ru(n.element(),"overflow-y"),ru(n.element(),"-webkit-overflow-scrolling"),kg.deregister(n.element())})])])}],items:e,menuBehaviours:vo([Og.config({initialState:"after",routes:Og.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},Mg=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return c},n=Dg("Styles",[].concat(Tn(o.items,function(n){return Cg(Eg(n),n.title,n.isSelected(),n.getPreview(),Rt(o.expansions,Eg(n)))})),i,!1),e=R(o.menus,function(n,e){var t=Tn(n,function(n){return Cg(Eg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Rt(o.expansions,Eg(n)))});return Dg(e,t,i,!0)}),t=vt(e,It("styles",n)),{tmenu:gg.tieredData("styles",t,o.expansions)}),c=td(gg.sketch({dom:{tag:"div",classes:[Gi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=ds.getValue(e);return r.handle(e,t.value),M.none()},onEscape:function(){return M.none()},onOpenMenu:function(n,e){var t=ks(n.element());Ts(e.element(),t),Og.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=ks(n.element()),o=hu(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Ts(t.element(),r),Og.progressTo(i,"before"),Og.jumpTo(t,"after"),Og.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=hu(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();Og.progressTo(o,"after"),Og.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Gi.resolve("styles-background-menu"),menu:Gi.resolve("styles-menu"),selectedMenu:Gi.resolve("styles-selected-menu"),item:Gi.resolve("styles-item"),selectedItem:Gi.resolve("styles-selected-item")}}));return c.asSpec()},Ig=function(n){return Rt(n,"items")?(i=vt((mt([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),e=o=n,t=["items"],r={},B(e,function(n,e){Sn(t,e)||(r[e]=n)}),r),{menu:!0}),u=Ag(o.items),{item:i,menus:vt(u.menus,It(o.title,u.items)),expansions:vt(u.expansions,It(o.title,o.title))}):{item:n,menus:{},expansions:{}};var e,t,r,o,i,u},Ag=function(n){return Dn(n,function(n,e){var t=Ig(e);return{menus:vt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:vt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Bg={expand:Ag},Rg=function(u,n){var c=function(n){return function(){return u.formatter.match(n)}},a=function(n){return function(){return u.formatter.getCssText(n)}},e=Mt(n,"style_formats").getOr(vm),f=function(n){return Tn(n,function(n){if(Rt(n,"items")){var e=f(n.items);return vt(vt(n,{isSelected:b(!1),getPreview:b("")}),{items:e})}return Rt(n,"format")?vt(i=n,{isSelected:c(i.format),getPreview:a(i.format)}):(r=Ha((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(e)},Fg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return Vn(n,function(n){return n.items===undefined?!Rt(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===ep?[]:[Wg(xe.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Hi.off)}),Wg(i,"select",n),Wg(r.doc(),"selectionchange",n)]);return{destroy:function(){kn(c,function(n){n.unbind()})}}},rp=function(n,e){var t=parseInt(ko(n,e),10);return isNaN(t)?0:t},op=function kb(t,r){var o=function(n){return t(n)?M.from(n.dom().nodeValue):M.none()},n=Jn.detect().browser,e=n.isIE()&&10===n.version.major?function(n){try{return o(n)}catch(e){return M.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}}}(De,"text"),ip=function(n){return op.getOption(n)},up=mt([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),cp={before:up.before,on:up.on,after:up.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(w,w,w)}},ap=mt([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),fp=Be("start","soffset","finish","foffset"),sp=ap.relative,lp=ap.exact,dp=function(n,e,t,r){var o,i,u,c,a,f=(i=e,u=t,c=r,(a=_e(o=n).dom().createRange()).setStart(o.dom(),i),a.setEnd(u.dom(),c),a),s=We(n,t)&&e===r;return f.collapsed&&!s},mp=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},gp=function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},pp=function(n){return{left:b(n.left),top:b(n.top),right:b(n.right),bottom:b(n.bottom),width:b(n.width),height:b(n.height)}},vp=mt([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),hp=function(n,e,t){return e(xe.fromDom(t.startContainer),t.startOffset,xe.fromDom(t.endContainer),t.endOffset)},bp=function(n,e){var o,t,r,i=(o=n,e.match({domRange:function(n){return{ltr:b(n),rtl:M.none}},relative:function(n,e){return{ltr:J(function(){return mp(o,n,e)}),rtl:J(function(){return M.some(mp(o,e,n))})}},exact:function(n,e,t,r){return{ltr:J(function(){return gp(o,n,e,t,r)}),rtl:J(function(){return M.some(gp(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return vp.rtl(xe.fromDom(n.endContainer),n.endOffset,xe.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return hp(0,vp.ltr,r)}):hp(0,vp.ltr,r)},yp=(document.caretPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=Te(n);return"input"===t?cp.after(n):Sn(["br","img"],t)?0===e?cp.before(n):cp.after(n):cp.on(n,e)}),xp=function(n,e,t,r,o){var i,u,c=gp(n,e,t,r,o);i=n,u=c,M.from(i.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},wp=function(n,e,t,r,o){var i,u,c,a,l,f=(i=r,u=o,c=yp(e,t),a=yp(i,u),sp(c,a));bp(l=n,f).match({ltr:function(n,e,t,r){xp(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){xp(l,t,r,n,e)}else xp(l,t,r,n,e)}})},Sp=function(n){var e=xe.fromDom(n.anchorNode),t=xe.fromDom(n.focusNode);return dp(e,n.anchorOffset,t,n.focusOffset)?M.some(fp(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)})}),Ap(e,n.innerHeight)});return Ap(e,n.innerHeight),{toEditing:function(){Mp(u)},destroy:function(){t.unbind()}}},Vp=function(n){return M.some(xe.fromDom(n.dom().contentWindow.document.body))},Np=function(n){return M.some(xe.fromDom(n.dom().contentWindow.document))},jp=function(n){return M.from(n.dom().contentWindow)},Hp=function(n){return jp(n).bind(Op)},zp=function(n){return n.getFrame()},Pp=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=zp(e);return function(){return t(n)}})()}},Lp=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return Wg(e,r,n)}})},Up=function(n){return{left:b(n.left),top:b(n.top),right:b(n.right),bottom:b(n.bottom),width:b(n.width),height:b(n.height)}},Gp={getBody:Pp("getBody",Vp),getDoc:Pp("getDoc",Np),getWin:Pp("getWin",jp),getSelection:Pp("getSelection",Hp),getFrame:zp,getActiveApi:function(c){var a=zp(c);return Vp(a).bind(function(u){return Np(a).bind(function(i){return jp(a).map(function(o){var n=xe.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return(n=o,Op(n).map(function(n){return lp(n.start(),n.soffset(),n.finish(),n.foffset())})).bind(function(n){return Tp(o,n).orThunk(function(){return Op(o).filter(function(n){return We(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0