!function(){"use strict";var n,e,t,r,o,i,u,a,k=function(){for(var n=[],e=0;e "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return Mt.objOf(yn(a,function(n){return n.fold(function(n,e,t,r){return It.field(n,t,r)},function(n,e){return It.state(n)})}))}}},Wt=function(t,i){var e=function(n,e){return(o=Ut(t),{extract:function(t,r,n){var e=yn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return bt(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return Mt.arrOf(o)}}).extract(n,h,e);var o};return{extract:function(t,r,o){var n=F(o);return e(t,n).bind(function(n){var e=yn(n,function(n){return Ht.field(n,n,lt(),i)});return _t(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return Mt.setOf(t,i)}}},$t=E(Ut(at.value)),Gt=Ht.state,qt=Ht.field,Yt=function(t,e,r,o,i){return kt(o,i).fold(function(){return n=o,e=i,Vt(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+Ft(n)});var n,e},function(n){return _t(n).extract(t.concat(["branch: "+i]),e,r)})},Xt=function(o,i){return{extract:function(e,t,r){return kt(r,o).fold(function(){return n=o,Vt(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return Yt(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+F(i)},toDsl:function(){return Mt.choiceOf(o,i)}}},Kt=Ut(at.value),Jt=function(n,e,t,r){return e.extract([n],t,r).fold(function(n){return at.error({input:r,errors:n})},at.value)},Qt=function(n,e,t){return Jt(n,e,E,t)},Zt=function(n){return n.fold(function(n){throw new Error(tr(n))},h)},nr=function(n,e,t){return Zt(Jt(n,e,h,t))},er=function(n,e,t){return Zt(Qt(n,e,t))},tr=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+Ft(n.input);var e,t},rr=function(n,e){return Xt(n,e)},or=E(Kt),ir=(i=w,u="function",Ut(function(n){var e=typeof n;return i(n)?at.value(n):at.error("Expected type: "+u+" but got: "+e)})),ur=function(n){return qt(n,n,lt(),$t())},ar=function(n,e){return qt(n,n,lt(),e)},cr=function(n){return ar(n,ir)},sr=function(n,e){return qt(n,n,lt(),_t(e))},fr=function(n){return qt(n,n,dt(),$t())},lr=function(n,e){return qt(n,n,dt(),_t(e))},dr=function(n,e){return qt(n,n,dt(),Pt(e))},mr=function(n,e){return qt(n,n,ft(e),$t())},gr=function(n,e,t){return qt(n,n,ft(e),t)},vr=function(n,e){return Gt(n,e)},pr=function(n){if(!Rt(n,"can")&&!Rt(n,"abort")&&!Rt(n,"run"))throw new Error("EventHandler defined by: "+Bt(n,null,2)+" does not have can, abort, or run!");return nr("Extracting event.handler",Pt([mr("can",E(!0)),mr("abort",E(!1)),mr("run",k)]),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"),innerHtml:n.innerHtml().getOr(""),defChildren:n.defChildren().fold(function(){return""},function(n){return Bt(n,null,2)}),domChildren:n.domChildren().fold(function(){return""},function(n){return 0===n.length?"0 children, but still specified":String(n.length)})}},Nr=De([],["classes","attributes","styles","value","innerHtml","defChildren","domChildren"]),Br=function(e,n,t){return n.fold(function(){return t.fold(function(){return{}},function(n){return Et(e,n)})},function(n){return t.fold(function(){return Et(e,n)},function(n){return Et(e,n)})})},Fr=function(t,r,o){return Er(function(n,e){o(n,t,r)})},Vr=function(n,e,t,r,o,i){var u,a,c=n,s=lr(e,[(u="config",a=n,qt(u,u,dt(),a))]);return jr(c,s,e,t,r,o,i)},Hr=function(o,i,u){var n,e,t,r,a,c;return n=function(t){for(var n=[],e=1;e"}),or()),Oc=mr("defaults",E({})),Cc=mr("overrides",E({})),kc=_t([wc,xc,Tc,Sc,Oc,Cc]),Ec=_t([wc,xc,Tc,Oc,Cc]),Dc=_t([wc,xc,Tc,Sc,Oc,Cc]),Ac=_t([wc,xc,Tc,ur("unit"),Sc,Oc,Cc]),Rc=function(n){var e=function(n){return n.name()};return n.fold(e,e,e,e)},Mc=function(t,r){return function(n){var e=er("Converting part type",r,n);return t(e)}},Ic=Mc(yc.required,kc),Nc=(Mc(yc.external,Ec),Mc(yc.optional,Dc)),Bc=Mc(yc.group,Ac),Fc=E("entirety"),Vc=function(n,e,t,r){var o=t;return C(e.defaults()(n,t,r),t,{uid:n.partUids()[e.name()]},e.overrides()(n,t,r),{"debug.sketcher":Et("part-"+e.name(),o)})},Hc=function(o,n){var i={};return wn(n,function(n){var e;(e=n,e.fold(B.some,B.none,B.some,B.some)).each(function(t){var r=zc(o,t.pname());i[t.name()]=function(n){var e=nr("Part: "+t.name()+" in "+o,_t(t.schema()),n);return C(r,{config:n,validated:e})}})}),i},zc=function(n,e){return{uiType:pc(),owner:n,name:e}},jc=function(n,e,t){return r=e,i={},o={},wn(t,function(n){n.fold(function(r){i[r.pname()]=gc(!0,function(n,e,t){return r.factory().sketch(Vc(n,r,e,t))})},function(n){var e=r.parts()[n.name()]();o[n.name()]=E(Vc(r,n,e[Fc()]()))},function(r){i[r.pname()]=gc(!1,function(n,e,t){return r.factory().sketch(Vc(n,r,e,t))})},function(o){i[o.pname()]=vc(!0,function(e,n,t){var r=e[o.name()]();return yn(r,function(n){return o.factory().sketch(C(o.defaults()(e,n),n,o.overrides()(e,n)))})})})}),{internals:E(i),externals:E(o)};var r,i,o},Lc=function(n,e,t){return mc(B.some(n),e,e.components(),t)},Uc=function(n,e,t){var r=e.partUids()[t];return n.getSystem().getByUid(r).toOption()},Pc=function(n,e,t){return Uc(n,e,t).getOrDie("Could not find part: "+t)},_c=function(e,n){var t=yn(n,Rc);return Dt(yn(t,function(n){return{key:n,value:e+"-"+n}}))},Wc=function(e){return qt("partUids","partUids",gt(function(n){return _c(n.uid,e)}),or())},$c=bc("alloy-premade"),Gc=bc("api"),qc=function(n){return Et($c,n)},Yc=function(o){return n=function(n){for(var e=[],t=1;t'),action:e,buttonBehaviours:C(qr([ls.config({})]),t)})},hs={forToolbar:ps,forToolbarCommand:function(n,e){return ps(e,function(){n.execCommand(e)},{})},forToolbarStateAction:function(n,e,t,r){var o=vs(t);return ps(e,r,o)},forToolbarStateCommand:function(n,e){var t=vs(e);return ps(e,function(){n.execCommand(e)},t)}},bs=function(t,r){return{left:E(t),top:E(r),translate:function(n,e){return bs(t+n,r+e)}}},ys=bs,ws=function(n,e,t){return Math.max(e,Math.min(t,n))},xs=function(n,e,t,r,o,i,u){var a=t-e;if(rn.right)return t+1;var c,s,f,l,d=Math.min(n.right,Math.max(r,n.left))-n.left,m=ws(d/n.width*a+e,e-1,t+1),g=Math.round(m);return i&&e<=m&&m<=t?(c=m,s=e,f=t,l=o,u.fold(function(){var n=c-s,e=Math.round(n/l)*l;return ws(s+e,s-1,f+1)},function(n){var e=(c-n)%l,t=Math.round(e/l),r=Math.floor((c-n)/l),o=Math.floor((f-n)/l),i=n+Math.min(o,r+t)*l;return Math.max(n,i)})):g},Ts="slider.change.value",Ss=Wn.detect().deviceType.isTouch(),Os=function(n){return function(n){var e=n.event().raw();if(Ss){var t=e;return t.touches!==undefined&&1===t.touches.length?B.some(t.touches[0]).map(function(n){return ys(n.clientX,n.clientY)}):B.none()}var r=e;return r.clientX!==undefined?B.some(r).map(function(n){return ys(n.clientX,n.clientY)}):B.none()}(n).map(function(n){return n.left()})},Cs=function(n,e){ie(n,Ts,{value:e})},ks=function(i,u,a,n){return Os(n).map(function(n){var e,t,r,o;return e=i,r=n,o=xs(a,(t=u).min(),t.max(),r,t.stepSize(),t.snapToGrid(),t.snapStart()),Cs(e,o),n})},Es=function(n,e){var t,r,o,i,u=(t=e.value().get(),r=e.min(),o=e.max(),i=e.stepSize(),tr.max()?Uc(e,r,"right-edge").fold(function(){return t.width},function(n){return f(n)-t.left}):(r.value().get()-r.min())/s*t.width);return i.left-u.left+a},u=function(n){var e=i(n),t=o(n),r=Xs(t.element())/2;_i.set(t.element(),"left",e-r+"px")},r=function(n,e){var t=c.value().get(),r=o(n);return t!==e||_i.getRaw(r.element(),"left").isNone()?(c.value().set(e),u(n),c.onChange()(n,r,e),B.some(!0)):B.none()},a=Ks?[wr(L(),function(n,e){c.onDragStart()(n,o(n))}),wr(P(),function(n,e){c.onDragEnd()(n,o(n))})]:[wr(_(),function(n,e){e.stop(),c.onDragStart()(n,o(n)),c.mouseIsDown().set(!0)}),wr($(),function(n,e){c.onDragEnd()(n,o(n)),c.mouseIsDown().set(!1)})];return{uid:c.uid(),dom:c.dom(),components:n,behaviours:C(qr(Dn([Ks?[]:[uc.config({mode:"special",focusIn:function(n){return Uc(n,c,"spectrum").map(uc.focusIn).map(E(!0))}})],[Ws.config({store:{mode:"manual",getValue:function(n){return c.value().get()}}})]])),cc(c.sliderBehaviours())),events:br([wr(Ts,function(n,e){r(n,e.event().value())}),Cr(function(n,e){c.value().set(c.getInitialValue()());var t=o(n);u(n),c.onInit()(n,t,c.value().get())})].concat(a)),apis:{resetToMin:function(n){r(n,c.min())},resetToMax:function(n){r(n,c.max())},refresh:u},domModification:{styles:{position:"relative"}}}},apis:{resetToMin:function(n,e){n.resetToMin(e)},resetToMax:function(n,e){n.resetToMax(e)},refresh:function(n,e){n.refresh(e)}}}),Qs=function(e,t,r){return hs.forToolbar(t,function(){var n=r();e.setContextToolbar([{label:t+" group",items:n}])},{})},Zs=function(n){return[(o=n,i=function(n){return n<0?"black":360'),components:[Js.parts()["left-edge"](gs('
')),Js.parts().spectrum({dom:ms('
'),components:[gs('
')],behaviours:qr([ki.config({toggleClass:Mi.resolve("thumb-active")})])}),Js.parts()["right-edge"](gs('
')),Js.parts().thumb({dom:ms('
'),behaviours:qr([ki.config({toggleClass:Mi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t);_i.set(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){ki.on(e)},onDragEnd:function(n,e){ki.off(e)},onInit:function(n,e,t){var r=i(t);_i.set(e.element(),"background-color",r)},stepSize:10,min:0,max:360,getInitialValue:o.getInitialValue,sliderBehaviours:qr([Di(Js.refresh)])}))];var o,i},nf=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 Qs(n,"color",function(){return Zs(e)})},ef=Pt([ur("getInitialValue"),ur("onChange"),ur("category"),ur("sizes")]),tf=function(n){var o=nr("SizeSlider",ef,n);return Js.sketch({dom:{tag:"div",classes:[Mi.resolve("slider-"+o.category+"-size-container"),Mi.resolve("slider"),Mi.resolve("slider-size-container")]},onChange:function(n,e,t){var r;0<=(r=t)&&r'),components:[gs('
')]}),Js.parts().thumb({dom:ms('
'),behaviours:qr([ki.config({toggleClass:Mi.resolve("thumb-active")})])})]})},rf=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],of=function(n){var e,t,r=n.selection.getStart(),o=fe.fromDom(r),i=fe.fromDom(n.getBody()),u=(e=function(n){return ze(i,n)},t=o,(be.isElement(t)?B.some(t):$e.parent(t)).map(function(n){return Do.closest(n,function(n){return _i.getRaw(n,"font-size").isSome()},e).bind(function(n){return _i.getRaw(n,"font-size")}).getOrThunk(function(){return _i.get(n,"font-size")})}).getOr(""));return On(rf,function(n){return u===n}).getOr("medium")},uf={candidates:E(rf),get:function(n){var e,t=of(n);return(e=t,Cn(rf,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,B.from(rf[e])).each(function(n){var e,t;t=n,of(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},af=uf.candidates(),cf=function(n){return[gs(''),(e=n,tf({onChange:e.onChange,sizes:af,category:"font",getInitialValue:e.getInitialValue})),gs('')];var e},sf=function(n){var e=n.uid!==undefined&&Rt(n,"uid")?n.uid:es("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(B.none,B.some)},asSpec:function(){return C(n,{uid:e})}}};function ff(n,e){return df(document.createElement("canvas"),n,e)}function lf(n){return n.getContext("2d")}function df(n,e,t){return n.width=e,n.height=t,n}var mf={create:ff,clone:function(n){var e;return lf(e=ff(n.width,n.height)).drawImage(n,0,0),e},resize:df,get2dContext:lf,get3dContext:function(n){var e=null;try{e=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},gf={getWidth:function(n){return n.naturalWidth||n.width},getHeight:function(n){return n.naturalHeight||n.height}},vf=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=[],s(n,r(o,this),r(u,this))},e=n.immediateFn||"function"==typeof setImmediate&&setImmediate||function(n){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 s(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'),components:[e.asSpec()],action:function(n){e.get(n).element().dom().click()}})},Bf=function(n){return n.dom().textContent},Ff=function(n,e){n.dom().textContent=e},Vf=function(n){return 0'),action:function(n){var e=t.get(n);Ws.setValue(e,"")}}));return{name:n,spec:Yf.sketch({dom:ms('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:qr([ki.config({toggleClass:Mi.resolve("input-container-empty")}),qf.config({find:function(n){return B.some(t.get(n))}}),Wf("input-clearing",[wr(Y(),function(n){var e=t.get(n);(0"},wl=function(o,n,e){return C({"debug.sketcher":{Form:e},uid:o.uid(),dom:o.dom(),components:n,behaviours:C(qr([Ws.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),H(e.partUids(),function(n,e){return E(t.getByUid(n))}));return H(r,function(n,e){return n().bind(qf.getCurrent).map(Ws.getValue)})},setValue:function(t,n){V(n,function(e,n){Uc(t,o,n).each(function(n){qf.getCurrent(n).each(function(n){Ws.setValue(n,e)})})})}}})]),cc(o.formBehaviours())),apis:{getField:function(n,e){return Uc(n,o,e).bind(qf.getCurrent)}}})},xl=(Yc(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=yl(n),o=e,{uiType:pc(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=yn(r,function(n){return Ic({name:n,pname:yl(n)})});return rs("form",bl,o,wl,t)}),Tl=function(){var e=So(B.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(B.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(B.some(n))},run:function(n){e.get().each(n)}}},Sl=function(){var e=So(B.none());return{clear:function(){e.set(B.none())},set:function(n){e.set(B.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},Ol=function(n){return{xValue:n,points:[]}},Cl=function(n,e){if(e===n.xValue)return n;var t=0'),action:function(n){ie(n,r,{direction:e})},buttonBehaviours:qr([hl.config({disableClass:Mi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=nu(n.element(),"."+Mi.resolve("serialised-dialog-screen"));ou(n.element(),"."+Mi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[Yf.sketch({dom:ms('
'),components:yn(u.fields,function(n,e){return e<=u.maxFieldIndex?Yf.sketch({dom:ms('
'),components:Dn([[o(-1,"previous",0'),behaviours:qr([Eu.config({highlightClass:Mi.resolve("dot-active"),itemClass:Mi.resolve("dot-item")})]),components:An(u.fields,function(n,e){return e<=u.maxFieldIndex?[gs('
')]:[]})});return{dom:ms('
'),components:[c.asSpec(),s.asSpec()],behaviours:qr([uc.config({mode:"special",focusIn:function(n){var e=c.get(n);uc.focusIn(e)}}),Wf("serializer-wrapper-events",[wr(L(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(Ol(t.touches[0].clientX))}),wr(U(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(Cl(n,t.raw().touches[0].clientX))})}),wr(P(),function(r){u.state.dialogSwipeState.on(function(n){var e=c.get(r),t=-1*kl(n);i(e,t)})})])])}},Dl=Z(function(t,r){return[{label:"the link group",items:[El({fields:[ol("url","Type or paste URL"),ol("text","Link text"),ol("title","Link title"),ol("target","Link target"),(n="link",{name:n,spec:Xf.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return B.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return B.some(Lf.getInfo(r))},onExecute:function(n){var e=Ws.getValue(n);Lf.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),Al=[{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"}]}],Rl=br([(Sf=Gn(),Of=function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(ze(t=o,n.element())&&!ze(t,r)&&(console.warn(Gn()+" did not get interpreted by the desired target. \nOriginator: "+qo(o)+"\nTarget: "+qo(i)+"\nCheck the "+Gn()+" event handlers"),1))},{key:Sf,value:pr({can:Of})})]),Ml=Object.freeze({events:Rl}),Il=h,Nl=Wr(["debugInfo","triggerFocus","triggerEvent","triggerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","build","getByUid","getByDom","broadcast","broadcastOn","isConnected"]),Bl=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 Nl({debugInfo:E("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"),isConnected:E(!1)})},Fl=function(n,o){var i={};return V(n,function(n,r){V(n,function(n,e){var t=Ct(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},Vl=function(n,e){return 1 "):r[0].name();return Et(o,{handler:e,purpose:E(t)})})});return At(e,{})},Gl=function(n){return Qt("custom.definition",Pt([qt("dom","dom",lt(),Pt([ur("tag"),mr("styles",{}),mr("classes",[]),mr("attributes",{}),fr("value"),fr("innerHtml")])),ur("components"),ur("uid"),mr("events",{}),mr("apis",E({})),qt("eventOrder","eventOrder",(e={"alloy.execute":["disabling","alloy.base.behaviour","toggling"],"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"]},st.mergeWithThunk(E(e))),or()),fr("domModification"),di("originalSpec"),mr("debug.sketcher","unknown")]),n);var e},ql=function(n){var e,t={tag:n.dom().tag(),classes:n.dom().classes(),attributes:C((e=n,Et(Jc(),e.uid())),n.dom().attributes()),styles:n.dom().styles(),domChildren:yn(n.components(),function(n){return n.element()})};return Mr(C(t,n.dom().innerHtml().map(function(n){return Et("innerHtml",n)}).getOr({}),n.dom().value().map(function(n){return Et("value",n)}).getOr({})))},Yl=function(e,n){wn(n,function(n){bo.add(e,n)})},Xl=function(e,n){wn(n,function(n){bo.remove(e,n)})},Kl=function(e){if(e.domChildren().isSome()&&e.defChildren().isSome())throw new Error("Cannot specify children and child specs! Must be one or the other.\nDef: "+(n=Ir(e),Bt(n,null,2)));return e.domChildren().fold(function(){var n=e.defChildren().getOr([]);return yn(n,Ql)},function(n){return n});var n},Jl=function(n){var e=fe.fromTag(n.tag());ro.setAll(e,n.attributes().getOr({})),Yl(e,n.classes().getOr([])),_i.setAll(e,n.styles().getOr({})),_o(e,n.innerHtml().getOr(""));var t=Kl(n);return Ke(e,t),n.value().each(function(n){Kf(e,n)}),e},Ql=function(n){var e=Mr(n);return Jl(e)},Zl=function(n,e){return t=n,o=yn(r=e,function(n){return lr(n.name(),[ur("config"),mr("state",$r)])}),i=Qt("component.behaviours",_t(o),t.behaviours).fold(function(n){throw new Error(tr(n)+"\nComplete spec:\n"+Bt(t,null,2))},function(n){return n}),{list:r,data:H(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},nd=function(n){var e,t,r=(e=kt(n,"behaviours").getOr({}),t=xn(F(e),function(n){return e[n]!==undefined}),yn(t,function(n){return e[n].me}));return Zl(n,r)},ed=Wr(["getSystem","config","hasConfigured","spec","connect","disconnect","element","syncComponents","readState","components","events"]),td=function(n,e,t){var r,o,i,u,a=ql(n),c=function(e,n,t,r){var o=C({},n);wn(t,function(n){o[n.name()]=n.exhibit(e,r)});var i=Fl(o,function(n,e){return{name:function(){return n},modification:e}}),u=H(i,function(n,e){return An(n,function(e){return e.modification().fold(function(){return[]},function(n){return[e]})})}),a=j(u,function(e,t){return kt(zl,t).fold(function(){return at.error("Unknown field type: "+t)},function(n){return n(e,t)})});return At(a,{}).map(Nr)}(t,{"alloy.base.modification":(r=n,r.domModification().fold(function(){return Nr({})},Nr))},e,a).getOrDie();return i=c,u=C({tag:(o=a).tag(),classes:i.classes().getOr([]).concat(o.classes().getOr([])),attributes:D(o.attributes().getOr({}),i.attributes().getOr({})),styles:D(o.styles().getOr({}),i.styles().getOr({}))},i.innerHtml().or(o.innerHtml()).map(function(n){return Et("innerHtml",n)}).getOr({}),Br("domChildren",i.domChildren(),o.domChildren()),Br("defChildren",i.defChildren(),o.defChildren()),i.value().or(o.value()).map(function(n){return Et("value",n)}).getOr({})),Mr(u)},rd=function(n,e,t){var r,o,i,u,a,c,s={"alloy.base.behaviour":(r=n,r.events())};return(o=t,i=n.eventOrder(),u=e,a=s,c=Pl(o,u,a),$l(c,i)).getOrDie()},od=function(n){var e,t,r,o,i,u,a,c,s,f,l,d,m,g,v=Il(n),p=(e=v,t=Ct("components",[])(e),yn(t,ad)),h=C(Ml,v,Et("components",p));return at.value((r=h,i=So(Bl(o=function(){return g})),u=Zt(Gl(C(r,{behaviours:undefined}))),a=nd(r),c=a.list,s=a.data,f=td(u,c,s),l=Jl(f),d=rd(u,c,s),m=So(u.components()),g=ed({getSystem:i.get,config:function(n){if(n===Xc())return u.apis();if(b(n))throw new Error("Invalid input: only API constant is allowed");var e=s;return(w(e[n.name()])?e[n.name()]:function(){throw new Error("Could not find "+n.name()+" in "+Bt(r,null,2))})()},hasConfigured:function(n){return w(s[n.name()])},spec:E(r),readState:function(n){return s[n]().map(function(n){return n.state.readState()}).getOr("not enabled")},connect:function(n){i.set(n)},disconnect:function(){i.set(Bl(o))},element:E(l),syncComponents:function(){var n=$e.children(l),e=An(n,function(n){return i.get().getByDom(n).fold(function(){return[]},function(n){return[n]})});m.set(e)},components:m.get,events:E(d)})))},id=function(n){var e=fe.fromText(n);return ud({element:e})},ud=function(n){var t=er("external.component",Pt([ur("element"),fr("uid")]),n),e=So(Bl());t.uid().each(function(n){var e;e=t.element(),ro.set(e,Zc,n)});var r=ed({getSystem:e.get,config:B.none,hasConfigured:E(!1),connect:function(n){e.set(n)},disconnect:function(){e.set(Bl(function(){return r}))},element:E(t.element()),spec:E(n),readState:E("No state"),syncComponents:k,components:E([]),events:E({})});return qc(r)},ad=function(e){return(n=e,kt(n,$c)).fold(function(){var n=C({uid:es("")},e);return od(n).getOrDie()},function(n){return n});var n},cd=qc,sd="alloy.item-hover",fd="alloy.item-focus",ld=function(n){(Fo(n.element()).isNone()||Vi.isFocused(n))&&(Vi.isFocused(n)||Vi.focus(n),ie(n,sd,{item:n}))},dd=function(n){ie(n,fd,{item:n})},md=E(sd),gd=E(fd),vd=[ur("data"),ur("components"),ur("dom"),fr("toggling"),mr("itemBehaviours",{}),mr("ignoreFocus",!1),mr("domModification",{}),li("builder",function(n){return{dom:C(n.dom(),{attributes:{role:n.toggling().isSome()?"menuitemcheckbox":"menuitem"}}),behaviours:C(qr([n.toggling().fold(ki.revoke,function(n){return ki.config(C({aria:{mode:"checked"}},n))}),Vi.config({ignore:n.ignoreFocus(),onFocus:function(n){dd(n)}}),uc.config({mode:"execution"}),Ws.config({store:{mode:"memory",initialValue:n.data()}})]),n.itemBehaviours()),events:br([(e=Qn(),r=ue,wr(e,function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){r(e,n,t)})})),Or(_()),wr(G(),ld),wr(Kn(),Vi.focus)]),components:n.components(),domModification:n.domModification(),eventOrder:n.eventOrder()};var e,r}),mr("eventOrder",{})],pd=[ur("dom"),ur("components"),li("builder",function(n){return{dom:n.dom(),components:n.components(),events:br([(e=Kn(),wr(e,function(n,e){e.stop()}))])};var e})],hd=E([Ic({name:"widget",overrides:function(e){return{behaviours:qr([Ws.config({store:{mode:"manual",getValue:function(n){return e.data()},setValue:function(){}}})])}}})]),bd=[ur("uid"),ur("data"),ur("components"),ur("dom"),mr("autofocus",!1),mr("domModification",{}),Wc(hd()),li("builder",function(t){var n=jc(0,t,hd()),e=Lc("item-widget",t,n.internals()),r=function(n){return Uc(n,t,"widget").map(function(n){return uc.focusIn(n),n})},o=function(n,e){return Nu(e.event().target())||t.autofocus()&&e.setSource(n.element()),B.none()};return C({dom:t.dom(),components:e,domModification:t.domModification(),events:br([Dr(function(n,e){r(n).each(function(n){e.stop()})}),wr(G(),ld),wr(Kn(),function(n,e){t.autofocus()?r(n):Vi.focus(n)})]),behaviours:qr([Ws.config({store:{mode:"memory",initialValue:t.data()}}),Vi.config({onFocus:function(n){dd(n)}}),uc.config({mode:"special",focusIn:t.autofocus()?function(n){r(n)}:Jr(),onLeft:o,onRight:o,onEscape:function(n,e){return Vi.isFocused(n)||t.autofocus()?(t.autofocus()&&e.setSource(n.element()),B.none()):(Vi.focus(n),B.some(!0))}})])})})],yd=rr("type",{widget:bd,item:vd,separator:pd}),wd=E([Bc({factory:{sketch:function(n){var e=er("menu.spec item",yd,n);return e.builder()(e)}},name:"items",unit:"item",defaults:function(n,e){var t=es("");return C({uid:t},e)},overrides:function(n,e){return{type:e.type,ignoreFocus:n.fakeFocus(),domModification:{classes:[n.markers().item()]}}}})]),xd=E([ur("value"),ur("items"),ur("dom"),ur("components"),mr("eventOrder",{}),ac("menuBehaviours",[Eu,Ws,qf,uc]),gr("movement",{mode:"menu",moveOnTab:!0},rr("mode",{grid:[mi(),li("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers().item(),initSize:{numColumns:e.initSize().numColumns(),numRows:e.initSize().numRows()},focusManager:n.focusManager()}})],menu:[mr("moveOnTab",!0),li("config",function(n,e){return{mode:"menu",selector:"."+n.markers().item(),moveOnTab:e.moveOnTab(),focusManager:n.focusManager()}})]})),ar("markers",oi()),mr("fakeFocus",!1),mr("focusManager",Du()),ai("onHighlight")]),Td=E("alloy.menu-focus"),Sd=cs({name:"Menu",configFields:xd(),partFields:wd(),factory:function(n,e,t,r){return C({dom:C(n.dom(),{attributes:{role:"menu"}}),uid:n.uid(),behaviours:C(qr([Eu.config({highlightClass:n.markers().selectedItem(),itemClass:n.markers().item(),onHighlight:n.onHighlight()}),Ws.config({store:{mode:"memory",initialValue:n.value()}}),qf.config({find:B.some}),uc.config(n.movement().config()(n,n.movement()))]),cc(n.menuBehaviours())),events:br([wr(gd(),function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){Eu.highlight(e,n),t.stop(),ie(e,Td(),{menu:e,item:n})})}),wr(md(),function(n,e){var t=e.event().item();Eu.highlight(n,t)})]),components:e,eventOrder:n.eventOrder()})}}),Od=function(n,e,t,r){var o=n.getSystem().build(r);tt(n,o,t)},Cd=function(n,e){return n.components()},kd=Object.freeze({append:function(n,e,t,r){Od(n,0,Ye.append,r)},prepend:function(n,e,t,r){Od(n,0,Ye.prepend,r)},remove:function(n,e,t,r){var o=Cd(n,e);On(o,function(n){return ze(r.element(),n.element())}).each(ot)},set:function(e,n,t,r){var o,i,u,a,c,s;i=(o=e).components(),wn(i,rt),Qe.empty(o.element()),o.syncComponents(),u=function(){var n=yn(r,e.getSystem().build);wn(n,function(n){et(e,n)})},a=e.element(),c=$e.owner(a),s=Bo(c).bind(function(e){var n=function(n){return ze(e,n)};return n(a)?B.some(a):Do.descendant(a,n)}),u(a),s.each(function(e){Bo(c).filter(function(n){return ze(n,e)}).fold(function(){Io(e)},k)})},contents:Cd}),Ed=Xr({fields:[],name:"replacing",apis:kd}),Dd=function(t,r,o,n){return kt(o,n).bind(function(n){return kt(t,n).bind(function(n){var e=Dd(t,r,o,n);return B.some([n].concat(e))})}).getOr([])},Ad=function(n,e){var t={};V(n,function(n,e){wn(n,function(n){t[n]=e})});var r=e,o=z(e,function(n,e){return{k:n,v:e}}),i=H(o,function(n,e){return[e].concat(Dd(t,r,o,e))});return H(t,function(n){return kt(i,n).getOr([n])})},Rd=function(){var i=So({}),u=So({}),a=So({}),c=So(B.none()),s=So({}),n=function(n){return kt(u.get(),n)};return{setContents:function(n,e,t,r){c.set(B.some(n)),i.set(t),u.set(e),s.set(r);var o=Ad(r,t);a.set(o)},expand:function(t){return kt(i.get(),t).map(function(n){var e=kt(a.get(),t).getOr([]);return[n].concat(e)})},refresh:function(n){return kt(a.get(),n)},collapse:function(n){return kt(a.get(),n).bind(function(n){return 1");r[t[0]]=Et(t[1],n),r[t[1]]=Et(t[0],n)}),r},createBistate:function(n,e,t){return Dt([{key:n,value:Et(e,t)},{key:e,value:Et(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}])}])}}}),Pd=Mi.resolve("scrollable"),_d={register:function(n){bo.add(n,Pd)},deregister:function(n){bo.remove(n,Pd)},scrollable:E(Pd)},Wd=function(n){return kt(n,"format").getOr(n.title)},$d=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Mi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Mi.resolve("format-matches"),selected:t},itemBehaviours:qr(o?[]:[Ei(n,function(n,e){(e?ki.on:ki.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},Gd=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[ss.sketch({dom:{tag:"div",classes:[Mi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Mi.resolve("styles-collapse-icon")]}},id(n)]:[id(n)],action:function(n){if(r){var e=t().get(n);Id.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Mi.resolve("styles-menu-items-container")]},components:[Sd.parts().items({})],behaviours:qr([Wf("adhoc-scrollable-menu",[Cr(function(n,e){_i.set(n.element(),"overflow-y","auto"),_i.set(n.element(),"-webkit-overflow-scrolling","touch"),_d.register(n.element())}),kr(function(n){_i.remove(n.element(),"overflow-y"),_i.remove(n.element(),"-webkit-overflow-scrolling"),_d.deregister(n.element())})])])}],items:e,menuBehaviours:qr([Ud.config({initialState:"after",routes:Ud.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},qd=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return a},n=Gd("Styles",[].concat(yn(o.items,function(n){return $d(Wd(n),n.title,n.isSelected(),n.getPreview(),Rt(o.expansions,Wd(n)))})),i,!1),e=H(o.menus,function(n,e){var t=yn(n,function(n){return $d(Wd(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Rt(o.expansions,Wd(n)))});return Gd(e,t,i,!0)}),t=C(e,Et("styles",n)),{tmenu:Id.tieredData("styles",t,o.expansions)}),a=sf(Id.sketch({dom:{tag:"div",classes:[Mi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=Ws.getValue(e);return r.handle(e,t.value),B.none()},onEscape:function(){return B.none()},onOpenMenu:function(n,e){var t=Xs(n.element());Ys(e.element(),t),Ud.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Xs(n.element()),o=ru(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Ys(t.element(),r),Ud.progressTo(i,"before"),Ud.jumpTo(t,"after"),Ud.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=ru(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();Ud.progressTo(o,"after"),Ud.progressTo(t,"current")},navigateOnHover:!1,openImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Mi.resolve("styles-background-menu"),menu:Mi.resolve("styles-menu"),selectedMenu:Mi.resolve("styles-selected-menu"),item:Mi.resolve("styles-item"),selectedItem:Mi.resolve("styles-selected-item")}}));return a.asSpec()},Yd=function(n){return Rt(n,"items")?(t=C(St(e=n,["items"]),{menu:!0}),r=Xd(e.items),{item:t,menus:C(r.menus,Et(e.title,r.items)),expansions:C(r.expansions,Et(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},Xd=function(n){return Tn(n,function(n,e){var t=Yd(e);return{menus:C(n.menus,t.menus),items:[t.item].concat(n.items),expansions:C(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Kd={expand:Xd},Jd=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=kt(n,"style_formats").getOr(Al),s=function(n){return yn(n,function(n){if(Rt(n,"items")){var e=s(n.items);return C(C(n,{isSelected:E(!1),getPreview:E("")}),{items:e})}return Rt(n,"format")?C(i=n,{isSelected:a(i.format),getPreview:c(i.format)}):(r=bc((t=n).title),o=C(t,{format:r,isSelected:a(r),getPreview:c(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return s(e)},Qd=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return An(n,function(n){return n.items!==undefined?0e.innerHeight||n.bottom()>e.innerHeight?n.bottom()-e.innerHeight+50:0;0!==t&&e.scrollTo(e.pageXOffset,e.pageYOffset+t)})})].concat(!0===wm?[]:[lm(fe.fromDom(r.win()),"blur",function(){t.getByDom(e).each(ki.off)}),lm(i,"select",n),lm(r.doc(),"selectionchange",n)]);return{destroy:function(){wn(a,function(n){n.unbind()})}}},Tm=function(n,e){var t=parseInt(ro.get(n,e),10);return isNaN(t)?0:t},Sm=(Cf=be.isText,kf="text",Ef=function(n){return Cf(n)?B.from(n.dom().nodeValue):B.none()},Df=Wn.detect().browser,{get:function(n){if(!Cf(n))throw new Error("Can only get "+kf+" value of a "+kf+" node");return Af(n).getOr("")},getOption:Af=Df.isIE()&&10===Df.version.major?function(n){try{return Ef(n)}catch(e){return B.none()}}:Ef,set:function(n,e){if(!Cf(n))throw new Error("Can only set raw "+kf+" value of a "+kf+" node");n.dom().nodeValue=e}}),Om=function(n){return Sm.getOption(n)},Cm=function(n){return"img"===be.name(n)?1:Om(n).fold(function(){return $e.children(n).length},function(n){return n.length})},km=Cm,Em=ct([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Dm={before:Em.before,on:Em.on,after:Em.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(h,h,h)}},Am=ct([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Rm=Te("start","soffset","finish","foffset"),Mm={domRange:Am.domRange,relative:Am.relative,exact:Am.exact,exactFromRange:function(n){return Am.exact(n.start(),n.soffset(),n.finish(),n.foffset())},range:Rm,getWin:function(n){var e=n.match({domRange:function(n){return fe.fromDom(n.startContainer)},relative:function(n,e){return Dm.getStart(n)},exact:function(n,e,t,r){return n}});return $e.defaultView(e)}},Im=function(n,e,t,r){var o=$e.owner(n).dom().createRange();return o.setStart(n.dom(),e),o.setEnd(t.dom(),r),o},Nm=function(n,e,t,r){var o=Im(n,e,t,r),i=ze(n,t)&&e===r;return o.collapsed&&!i},Bm=function(n,e){n.selectNodeContents(e.dom())},Fm=function(n){n.deleteContents()},Vm=function(n){return{left:E(n.left),top:E(n.top),right:E(n.right),bottom:E(n.bottom),width:E(n.width),height:E(n.height)}},Hm={create:function(n){return n.document.createRange()},replaceWith:function(n,e){Fm(n),n.insertNode(e.dom())},selectNodeContents:function(n,e){var t=n.document.createRange();return Bm(t,e),t},selectNodeContentsUsing:Bm,relativeToNative: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},exactToNative:function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},deleteContents:Fm,cloneFragment:function(n){var e=n.cloneContents();return fe.fromDom(e)},getFirstRect:function(n){var e=n.getClientRects(),t=0e.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),ag(e,n.innerHeight)});return ag(e,n.innerHeight),{toEditing:function(){ig(u)},destroy:function(){t.unbind()}}},lg=function(n){return B.some(fe.fromDom(n.dom().contentWindow.document.body))},dg=function(n){return B.some(fe.fromDom(n.dom().contentWindow.document))},mg=function(n){return B.from(n.dom().contentWindow)},gg=function(n){return mg(n).bind(Qm)},vg=function(n){return n.getFrame()},pg=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=vg(e);return function(){return t(n)}})()}},hg=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return lm(e,r,n)}})},bg=function(n){return{left:E(n.left),top:E(n.top),right:E(n.right),bottom:E(n.bottom),width:E(n.width),height:E(n.height)}},yg={getBody:pg("getBody",lg),getDoc:pg("getDoc",dg),getWin:pg("getWin",mg),getSelection:pg("getSelection",gg),getFrame:vg,getActiveApi:function(a){var c=vg(a);return lg(c).bind(function(u){return dg(c).bind(function(i){return mg(c).map(function(o){var n=fe.fromDom(i.dom().documentElement),e=a.getCursorBox.getOrThunk(function(){return function(){return Zm(o).bind(function(n){return eg(o,n).orThunk(function(){return Qm(o).filter(function(n){return ze(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0