theme.min.js 170KB

1
  1. !function(){"use strict";var n,e,t,o,r,i,u,a=function(n){return function(){return n}},O={noop:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e]},noarg:function(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t()}},compose:function(t,o){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(o.apply(null,arguments))}},constant:a,identity:function(n){return n},tripleEquals:function(n,e){return n===e},curry:function(i){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];for(var u=new Array(arguments.length-1),t=1;t<arguments.length;t++)u[t-1]=arguments[t];return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=new Array(arguments.length),o=0;o<t.length;o++)t[o]=arguments[o];var r=u.concat(t);return i.apply(null,r)}},not:function(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return!t.apply(null,arguments)}},die:function(n){return function(){throw new Error(n)}},apply:function(n){return n()},call:function(n){n()},never:a(!1),always:a(!0)},c=function(e){return function(n){return function(n){if(null===n)return"null";var e=typeof n;return"object"===e&&Array.prototype.isPrototypeOf(n)?"array":"object"===e&&String.prototype.isPrototypeOf(n)?"string":e}(n)===e}},E={isString:c("string"),isObject:c("object"),isArray:c("array"),isNull:c("null"),isBoolean:c("boolean"),isUndefined:c("undefined"),isFunction:c("function"),isNumber:c("number")},s=function(u){return function(){for(var n=new Array(arguments.length),e=0;e<n.length;e++)n[e]=arguments[e];if(0===n.length)throw new Error("Can't merge zero objects");for(var t={},o=0;o<n.length;o++){var r=n[o];for(var i in r)r.hasOwnProperty(i)&&(t[i]=u(t[i],r[i]))}return t}},f=s(function(n,e){return E.isObject(n)&&E.isObject(e)?f(n,e):e}),l=s(function(n,e){return e}),D={deepMerge:f,merge:l},d=O.never,m=O.always,g=function(){return p},p=(o={fold:function(n,e){return n()},is:d,isSome:d,isNone:m,getOr:t=function(n){return n},getOrThunk:e=function(n){return n()},getOrDie:function(n){throw new Error(n||"error: getOrDie called on none.")},or:t,orThunk:e,map:g,ap:g,each:function(){},bind:g,flatten:g,exists:d,forall:m,filter:g,equals:n=function(n){return n.isNone()},equals_:n,toArray:function(){return[]},toString:O.constant("none()")},Object.freeze&&Object.freeze(o),o),v=function(t){var n=function(){return t},e=function(){return r},o=function(n){return n(t)},r={fold:function(n,e){return e(t)},is:function(n){return t===n},isSome:m,isNone:d,getOr:n,getOrThunk:n,getOrDie:n,or:e,orThunk:e,map:function(n){return v(n(t))},ap:function(n){return n.fold(g,function(n){return v(n(t))})},each:function(n){n(t)},bind:o,flatten:n,exists:o,forall:o,filter:function(n){return n(t)?r:p},equals:function(n){return n.is(t)},equals_:function(n,e){return n.fold(d,function(n){return e(t,n)})},toArray:function(){return[t]},toString:function(){return"some("+t+")"}};return r},y={some:v,none:g,from:function(n){return null===n||n===undefined?p:v(n)}},h=(r=Object.keys)===undefined?function(n){var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(t);return e}:r,b=function(n,e){for(var t=h(n),o=0,r=t.length;o<r;o++){var i=t[o];e(n[i],i,n)}},w=function(o,r){var i={};return b(o,function(n,e){var t=r(n,e,o);i[t.k]=t.v}),i},x=function(n,t){var o=[];return b(n,function(n,e){o.push(t(n,e))}),o},S=function(n){return x(n,function(n){return n})},M={bifilter:function(n,t){var o={},r={};return b(n,function(n,e){(t(n,e)?o:r)[e]=n}),{t:o,f:r}},each:b,map:function(n,o){return w(n,function(n,e,t){return{k:e,v:o(n,e,t)}})},mapToArray:x,tupleMap:w,find:function(n,e){for(var t=h(n),o=0,r=t.length;o<r;o++){var i=t[o],u=n[i];if(e(u,i,n))return y.some(u)}return y.none()},keys:h,values:S,size:function(n){return S(n).length}},T=(O.constant("contextmenu"),O.constant("touchstart")),k=O.constant("touchmove"),C=O.constant("touchend"),A=(O.constant("gesturestart"),O.constant("mousedown")),B=O.constant("mousemove"),R=(O.constant("mouseout"),O.constant("mouseup")),I=O.constant("mouseover"),F=(O.constant("focusin"),O.constant("keydown")),N=O.constant("input"),V=O.constant("change"),H=(O.constant("focus"),O.constant("click")),j=O.constant("transitionend"),z=O.constant("selectstart"),L=function(n){var e,t=!1;return function(){return t||(t=!0,e=n.apply(null,arguments)),e}},P=function(n,e){var t=function(n,e){for(var t=0;t<n.length;t++){var o=n[t];if(o.test(e))return o}return undefined}(n,e);if(!t)return{major:0,minor:0};var o=function(n){return Number(e.replace(t,"$"+n))};return U(o(1),o(2))},W=function(){return U(0,0)},U=function(n,e){return{major:n,minor:e}},G={nu:U,detect:function(n,e){var t=String(e).toLowerCase();return 0===n.length?W():P(n,t)},unknown:W},$="Firefox",q=function(n,e){return function(){return e===n}},_=function(n){var e=n.current;return{current:e,version:n.version,isEdge:q("Edge",e),isChrome:q("Chrome",e),isIE:q("IE",e),isOpera:q("Opera",e),isFirefox:q($,e),isSafari:q("Safari",e)}},K={unknown:function(){return _({current:undefined,version:G.unknown()})},nu:_,edge:O.constant("Edge"),chrome:O.constant("Chrome"),ie:O.constant("IE"),opera:O.constant("Opera"),firefox:O.constant($),safari:O.constant("Safari")},X="Windows",Y="Android",J="Solaris",Q="FreeBSD",Z=function(n,e){return function(){return e===n}},nn=function(n){var e=n.current;return{current:e,version:n.version,isWindows:Z(X,e),isiOS:Z("iOS",e),isAndroid:Z(Y,e),isOSX:Z("OSX",e),isLinux:Z("Linux",e),isSolaris:Z(J,e),isFreeBSD:Z(Q,e)}},en={unknown:function(){return nn({current:undefined,version:G.unknown()})},nu:nn,windows:O.constant(X),ios:O.constant("iOS"),android:O.constant(Y),linux:O.constant("Linux"),osx:O.constant("OSX"),solaris:O.constant(J),freebsd:O.constant(Q)},tn=(i=Array.prototype.indexOf)===undefined?function(n,e){return fn(n,e)}:function(n,e){return i.call(n,e)},on=function(n,e){return-1<tn(n,e)},rn=function(n,e){for(var t=n.length,o=new Array(t),r=0;r<t;r++){var i=n[r];o[r]=e(i,r,n)}return o},un=function(n,e){for(var t=0,o=n.length;t<o;t++)e(n[t],t,n)},an=function(n,e){for(var t=n.length-1;0<=t;t--)e(n[t],t,n)},cn=function(n,e){for(var t=[],o=0,r=n.length;o<r;o++){var i=n[o];e(i,o,n)&&t.push(i)}return t},sn=function(n,e){for(var t=0,o=n.length;t<o;t++)if(e(n[t],t,n))return y.some(t);return y.none()},fn=function(n,e){for(var t=0,o=n.length;t<o;++t)if(n[t]===e)return t;return-1},ln=Array.prototype.push,dn=function(n){for(var e=[],t=0,o=n.length;t<o;++t){if(!Array.prototype.isPrototypeOf(n[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+n);ln.apply(e,n[t])}return e},mn=function(n,e){for(var t=0,o=n.length;t<o;++t)if(!0!==e(n[t],t,n))return!1;return!0},gn=Array.prototype.slice,pn=E.isFunction(Array.from)?Array.from:function(n){return gn.call(n)},vn={map:rn,each:un,eachr:an,partition:function(n,e){for(var t=[],o=[],r=0,i=n.length;r<i;r++){var u=n[r];(e(u,r,n)?t:o).push(u)}return{pass:t,fail:o}},filter:cn,groupBy:function(n,e){if(0===n.length)return[];for(var t=e(n[0]),o=[],r=[],i=0,u=n.length;i<u;i++){var a=n[i],c=e(a);c!==t&&(o.push(r),r=[]),t=c,r.push(a)}return 0!==r.length&&o.push(r),o},indexOf:function(n,e){var t=tn(n,e);return-1===t?y.none():y.some(t)},foldr:function(n,e,t){return an(n,function(n){t=e(t,n)}),t},foldl:function(n,e,t){return un(n,function(n){t=e(t,n)}),t},find:function(n,e){for(var t=0,o=n.length;t<o;t++){var r=n[t];if(e(r,t,n))return y.some(r)}return y.none()},findIndex:sn,flatten:dn,bind:function(n,e){var t=rn(n,e);return dn(t)},forall:mn,exists:function(n,e){return sn(n,e).isSome()},contains:on,equal:function(n,t){return n.length===t.length&&mn(n,function(n,e){return n===t[e]})},reverse:function(n){var e=gn.call(n,0);return e.reverse(),e},chunk:function(n,e){for(var t=[],o=0;o<n.length;o+=e){var r=n.slice(o,o+e);t.push(r)}return t},difference:function(n,e){return cn(n,function(n){return!on(e,n)})},mapToObject:function(n,e){for(var t={},o=0,r=n.length;o<r;o++){var i=n[o];t[String(i)]=e(i,o)}return t},pure:function(n){return[n]},sort:function(n,e){var t=gn.call(n,0);return t.sort(e),t},range:function(n,e){for(var t=[],o=0;o<n;o++)t.push(e(o));return t},head:function(n){return 0===n.length?y.none():y.some(n[0])},last:function(n){return 0===n.length?y.none():y.some(n[n.length-1])},from:pn},hn=function(n,e){var t=String(e).toLowerCase();return vn.find(n,function(n){return n.search(t)})},bn=function(n,t){return hn(n,t).map(function(n){var e=G.detect(n.versionRegexes,t);return{current:n.name,version:e}})},yn=function(n,t){return hn(n,t).map(function(n){var e=G.detect(n.versionRegexes,t);return{current:n.name,version:e}})},wn=function(n,r){return n.replace(/\${([^{}]*)}/g,function(n,e){var t,o=r[e];return"string"==(t=typeof o)||"number"===t?o:n})},xn=function(n,e){return-1!==n.indexOf(e)},Sn=function(n){return n.replace(/^\s+|\s+$/g,"")},Tn=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,kn=function(e){return function(n){return xn(n,e)}},Cn=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(n){return xn(n,"edge/")&&xn(n,"chrome")&&xn(n,"safari")&&xn(n,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Tn],search:function(n){return xn(n,"chrome")&&!xn(n,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(n){return xn(n,"msie")||xn(n,"trident")}},{name:"Opera",versionRegexes:[Tn,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:kn("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:kn("firefox")},{name:"Safari",versionRegexes:[Tn,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(n){return(xn(n,"safari")||xn(n,"mobile/"))&&xn(n,"applewebkit")}}],On=[{name:"Windows",search:kn("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(n){return xn(n,"iphone")||xn(n,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:kn("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:kn("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:kn("linux"),versionRegexes:[]},{name:"Solaris",search:kn("sunos"),versionRegexes:[]},{name:"FreeBSD",search:kn("freebsd"),versionRegexes:[]}],En={browsers:O.constant(Cn),oses:O.constant(On)},Dn=function(n){var e,t,o,r,i,u,a,c,s,f,l,d=En.browsers(),m=En.oses(),g=bn(d,n).fold(K.unknown,K.nu),p=yn(m,n).fold(en.unknown,en.nu);return{browser:g,os:p,deviceType:(t=g,o=n,r=(e=p).isiOS()&&!0===/ipad/i.test(o),i=e.isiOS()&&!r,u=e.isAndroid()&&3===e.version.major,a=e.isAndroid()&&4===e.version.major,c=r||u||a&&!0===/mobile/i.test(o),s=e.isiOS()||e.isAndroid(),f=s&&!c,l=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),{isiPad:O.constant(r),isiPhone:O.constant(i),isTablet:O.constant(c),isPhone:O.constant(f),isTouch:O.constant(s),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:O.constant(l)})}},Mn={detect:L(function(){var n=navigator.userAgent;return Dn(n)})},An={tap:O.constant("alloy.tap")},Bn=O.constant("alloy.focus"),Rn=O.constant("alloy.blur.post"),In=O.constant("alloy.receive"),Fn=O.constant("alloy.execute"),Nn=O.constant("alloy.focus.item"),Vn=An.tap,Hn=Mn.detect().deviceType.isTouch()?An.tap:H,jn=O.constant("alloy.longpress"),zn=(O.constant("alloy.sandbox.close"),O.constant("alloy.system.init")),Ln=O.constant("alloy.system.scroll"),Pn=O.constant("alloy.system.attached"),Wn=O.constant("alloy.system.detached"),Un=(O.constant("alloy.change.tab"),O.constant("alloy.dismiss.tab"),function(n,e){_n(n,n.element(),e,{})}),Gn=function(n,e,t){_n(n,n.element(),e,t)},$n=function(n){Un(n,Fn())},qn=function(n,e,t){_n(n,e,t,{})},_n=function(n,e,t,o){var r=D.deepMerge({target:e},o);n.getSystem().triggerEvent(t,e,M.map(r,O.constant))},Kn=function(n){if(null===n||n===undefined)throw new Error("Node cannot be null or undefined");return{dom:O.constant(n)}},Xn={fromHtml:function(n,e){var t=(e||document).createElement("div");if(t.innerHTML=n,!t.hasChildNodes()||1<t.childNodes.length)throw console.error("HTML does not have a single root node",n),"HTML must have a single root node";return Kn(t.childNodes[0])},fromTag:function(n,e){var t=(e||document).createElement(n);return Kn(t)},fromText:function(n,e){var t=(e||document).createTextNode(n);return Kn(t)},fromDom:Kn,fromPoint:function(n,e,t){return y.from(n.dom().elementFromPoint(e,t)).map(Kn)}},Yn=8,Jn=9,Qn=1,Zn=3,ne=function(n){return n.dom().nodeName.toLowerCase()},ee=function(n){return n.dom().nodeType},te=function(e){return function(n){return ee(n)===e}},oe=te(Qn),re=te(Zn),ie=te(Jn),ue={name:ne,type:ee,value:function(n){return n.dom().nodeValue},isElement:oe,isText:re,isDocument:ie,isComment:function(n){return ee(n)===Yn||"#comment"===ne(n)}},ae=L(function(){return ce(Xn.fromDom(document))}),ce=function(n){var e=n.dom().body;if(null===e||e===undefined)throw"Body is not available yet";return Xn.fromDom(e)},se={body:ae,getBody:ce,inBody:function(n){var e=ue.isText(n)?n.dom().parentNode:n.dom();return e!==undefined&&null!==e&&e.ownerDocument.body.contains(e)}},fe=function(n){return n.slice(0).sort()},le={sort:fe,reqMessage:function(n,e){throw new Error("All required keys ("+fe(n).join(", ")+") were not specified. Specified keys were: "+fe(e).join(", ")+".")},unsuppMessage:function(n){throw new Error("Unsupported keys for object: "+fe(n).join(", "))},validateStrArr:function(e,n){if(!E.isArray(n))throw new Error("The "+e+" fields must be an array. Was: "+n+".");vn.each(n,function(n){if(!E.isString(n))throw new Error("The value "+n+" in the "+e+" fields was not a string.")})},invalidTypeMessage:function(n,e){throw new Error("All values need to be of type: "+e+". Keys ("+fe(n).join(", ")+") were not.")},checkDupes:function(n){var t=fe(n);vn.find(t,function(n,e){return e<t.length-1&&n===t[e+1]}).each(function(n){throw new Error("The field: "+n+" occurs more than once in the combined fields: ["+t.join(", ")+"].")})}},de={immutable:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(e.length!==t.length)throw new Error('Wrong number of arguments to struct. Expected "['+e.length+']", got '+t.length+" arguments");var o={};return vn.each(e,function(n,e){o[n]=O.constant(t[e])}),o}},immutableBag:function(r,i){var u=r.concat(i);if(0===u.length)throw new Error("You must specify at least one required or optional field.");return le.validateStrArr("required",r),le.validateStrArr("optional",i),le.checkDupes(u),function(e){var t=M.keys(e);vn.forall(r,function(n){return vn.contains(t,n)})||le.reqMessage(r,t);var n=vn.filter(t,function(n){return!vn.contains(u,n)});0<n.length&&le.unsuppMessage(n);var o={};return vn.each(r,function(n){o[n]=O.constant(e[n])}),vn.each(i,function(n){o[n]=O.constant(Object.prototype.hasOwnProperty.call(e,n)?y.some(e[n]):y.none())}),o}}},me=function(n,e){for(var t=[],o=function(n){return t.push(n),e(n)},r=e(n);(r=r.bind(o)).isSome(););return t},ge="undefined"!=typeof window?window:Function("return this;")(),pe=function(n,e){for(var t=e!==undefined&&null!==e?e:ge,o=0;o<n.length&&t!==undefined&&null!==t;++o)t=t[n[o]];return t},ve=function(n,e){var t=n.split(".");return pe(t,e)},he={getOrDie:function(n,e){var t=ve(n,e);if(t===undefined||null===t)throw n+" not available on this browser";return t}},be=Qn,ye=Jn,we=function(n){return n.nodeType!==be&&n.nodeType!==ye||0===n.childElementCount},xe={all:function(n,e){var t=e===undefined?document:e.dom();return we(t)?[]:vn.map(t.querySelectorAll(n),Xn.fromDom)},is:function(n,e){var t=n.dom();if(t.nodeType!==be)return!1;if(t.matches!==undefined)return t.matches(e);if(t.msMatchesSelector!==undefined)return t.msMatchesSelector(e);if(t.webkitMatchesSelector!==undefined)return t.webkitMatchesSelector(e);if(t.mozMatchesSelector!==undefined)return t.mozMatchesSelector(e);throw new Error("Browser lacks native selectors")},one:function(n,e){var t=e===undefined?document:e.dom();return we(t)?y.none():y.from(t.querySelector(n)).map(Xn.fromDom)}},Se=function(n,e){return n.dom()===e.dom()},Te=(Mn.detect().browser.isIE(),Se),ke=function(n){return Xn.fromDom(n.dom().ownerDocument)},Ce=function(n){var e=n.dom();return y.from(e.parentNode).map(Xn.fromDom)},Oe=function(n){var e=n.dom();return y.from(e.previousSibling).map(Xn.fromDom)},Ee=function(n){var e=n.dom();return y.from(e.nextSibling).map(Xn.fromDom)},De=function(n){var e=n.dom();return vn.map(e.childNodes,Xn.fromDom)},Me=function(n,e){var t=n.dom().childNodes;return y.from(t[e]).map(Xn.fromDom)},Ae=de.immutable("element","offset"),Be={owner:ke,defaultView:function(n){var e=n.dom().ownerDocument.defaultView;return Xn.fromDom(e)},documentElement:function(n){var e=ke(n);return Xn.fromDom(e.dom().documentElement)},parent:Ce,findIndex:function(t){return Ce(t).bind(function(n){var e=De(n);return vn.findIndex(e,function(n){return Te(t,n)})})},parents:function(n,e){for(var t=E.isFunction(e)?e:O.constant(!1),o=n.dom(),r=[];null!==o.parentNode&&o.parentNode!==undefined;){var i=o.parentNode,u=Xn.fromDom(i);if(r.push(u),!0===t(u))break;o=i}return r},siblings:function(e){return Ce(e).map(De).map(function(n){return vn.filter(n,function(n){return!Te(e,n)})}).getOr([])},prevSibling:Oe,offsetParent:function(n){var e=n.dom();return y.from(e.offsetParent).map(Xn.fromDom)},prevSiblings:function(n){return vn.reverse(me(n,Oe))},nextSibling:Ee,nextSiblings:function(n){return me(n,Ee)},children:De,child:Me,firstChild:function(n){return Me(n,0)},lastChild:function(n){return Me(n,n.dom().childNodes.length-1)},childNodesCount:function(n){return n.dom().childNodes.length},hasChildNodes:function(n){return n.dom().hasChildNodes()},leaf:function(n,e){var t=De(n);return 0<t.length&&e<t.length?Ae(t[e],0):Ae(n,e)}},Re=function(e,t){Be.parent(e).each(function(n){n.dom().insertBefore(t.dom(),e.dom())})},Ie=function(n,e){n.dom().appendChild(e.dom())},Fe={before:Re,after:function(n,e){Be.nextSibling(n).fold(function(){Be.parent(n).each(function(n){Ie(n,e)})},function(n){Re(n,e)})},prepend:function(e,t){Be.firstChild(e).fold(function(){Ie(e,t)},function(n){e.dom().insertBefore(t.dom(),n.dom())})},append:Ie,appendAt:function(n,e,t){Be.child(n,t).fold(function(){Ie(n,e)},function(n){Re(n,e)})},wrap:function(n,e){Re(n,e),Ie(e,n)}},Ne={before:function(e,n){vn.each(n,function(n){Fe.before(e,n)})},after:function(o,r){vn.each(r,function(n,e){var t=0===e?o:r[e-1];Fe.after(t,n)})},prepend:function(e,n){vn.each(n.slice().reverse(),function(n){Fe.prepend(e,n)})},append:function(e,n){vn.each(n,function(n){Fe.append(e,n)})}},Ve=function(n){var e=n.dom();null!==e.parentNode&&e.parentNode.removeChild(e)},He={empty:function(n){n.dom().textContent="",vn.each(Be.children(n),function(n){Ve(n)})},remove:Ve,unwrap:function(n){var e=Be.children(n);0<e.length&&Ne.before(n,e),Ve(n)}},je=function(n){Un(n,Wn());var e=n.components();vn.each(e,je)},ze=function(n){var e=n.components();vn.each(e,ze),Un(n,Pn())},Le=function(n,e){Pe(n,e,Fe.append)},Pe=function(n,e,t){n.getSystem().addToWorld(e),t(n.element(),e.element()),se.inBody(n.element())&&ze(e),n.syncComponents()},We=function(n){je(n),He.remove(n.element()),n.getSystem().removeFromWorld(n)},Ue=function(e){var n=Be.parent(e.element()).bind(function(n){return e.getSystem().getByDom(n).fold(y.none,y.some)});We(e),n.each(function(n){n.syncComponents()})},Ge=function(t){return{is:function(n){return t===n},isValue:O.always,isError:O.never,getOr:O.constant(t),getOrThunk:O.constant(t),getOrDie:O.constant(t),or:function(n){return Ge(t)},orThunk:function(n){return Ge(t)},fold:function(n,e){return e(t)},map:function(n){return Ge(n(t))},each:function(n){n(t)},bind:function(n){return n(t)},exists:function(n){return n(t)},forall:function(n){return n(t)},toOption:function(){return y.some(t)}}},$e=function(t){return{is:O.never,isValue:O.never,isError:O.always,getOr:O.identity,getOrThunk:function(n){return n()},getOrDie:function(){return O.die(String(t))()},or:function(n){return n},orThunk:function(n){return n()},fold:function(n,e){return n(t)},map:function(n){return $e(t)},each:O.noop,bind:function(n){return $e(t)},exists:O.never,forall:O.always,toOption:y.none}},qe={value:Ge,error:$e},_e=function(u){if(!E.isArray(u))throw new Error("cases must be an array");if(0===u.length)throw new Error("there must be at least one case");var a=[],t={};return vn.each(u,function(n,o){var e=M.keys(n);if(1!==e.length)throw new Error("one and only one name per case");var r=e[0],i=n[r];if(t[r]!==undefined)throw new Error("duplicate key detected:"+r);if("cata"===r)throw new Error("cannot have a case named cata (sorry)");if(!E.isArray(i))throw new Error("case arguments must be an array");a.push(r),t[r]=function(){var n=arguments.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+r+". Expected "+i.length+" ("+i+"), got "+n);for(var t=new Array(n),e=0;e<t.length;e++)t[e]=arguments[e];return{fold:function(){if(arguments.length!==u.length)throw new Error("Wrong number of arguments to fold. Expected "+u.length+", got "+arguments.length);return arguments[o].apply(null,t)},match:function(n){var e=M.keys(n);if(a.length!==e.length)throw new Error("Wrong number of arguments to match. Expected: "+a.join(",")+"\nActual: "+e.join(","));if(!vn.forall(a,function(n){return vn.contains(e,n)}))throw new Error("Not all branches were specified when using match. Specified: "+e.join(", ")+"\nRequired: "+a.join(", "));return n[r].apply(null,t)},log:function(n){console.log(n,{constructors:a,constructor:r,params:t})}}}}),t},Ke=_e([{strict:[]},{defaultedThunk:["fallbackThunk"]},{asOption:[]},{asDefaultedOptionThunk:["fallbackThunk"]},{mergeWithThunk:["baseThunk"]}]),Xe=function(n){return Ke.defaultedThunk(O.constant(n))},Ye=Ke.strict,Je=Ke.asOption,Qe=Ke.defaultedThunk,Ze=(Ke.asDefaultedOptionThunk,Ke.mergeWithThunk),nt=(_e([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),function(n){var e=[],t=[];return vn.each(n,function(n){n.fold(function(n){e.push(n)},function(n){t.push(n)})}),{errors:e,values:t}}),et=function(n){return O.compose(qe.error,vn.flatten)(n)},tt=function(n,e){var t,o,r=nt(n);return 0<r.errors.length?et(r.errors):(t=r.values,o=e,qe.value(D.deepMerge.apply(undefined,[o].concat(t))))},ot=function(n){var e=nt(n);return 0<e.errors.length?et(e.errors):qe.value(e.values)},rt=function(e){return function(n){return n.hasOwnProperty(e)?y.from(n[e]):y.none()}},it=function(n,e){return rt(e)(n)},ut=function(n,e){var t={};return t[n]=e,t},at=function(n,e){return t=n,o=e,r={},vn.each(o,function(n){t[n]!==undefined&&t.hasOwnProperty(n)&&(r[n]=t[n])}),r;var t,o,r},ct=function(n,e){return t=n,o=e,r={},M.each(t,function(n,e){vn.contains(o,e)||(r[e]=n)}),r;var t,o,r},st=function(n){return rt(n)},ft=function(n,e){return t=n,o=e,function(n){return rt(t)(n).getOr(o)};var t,o},lt=function(n,e){return it(n,e)},dt=function(n,e){return ut(n,e)},mt=function(n){return e=n,t={},vn.each(e,function(n){t[n.key]=n.value}),t;var e,t},gt=function(n,e){return tt(n,e)},pt=function(n,e){return o=e,(t=n).hasOwnProperty(o)&&t[o]!==undefined&&null!==t[o];var t,o},vt=_e([{setOf:["validator","valueType"]},{arrOf:["valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key","branches"]},{thunk:["description"]},{func:["args","outputSchema"]}]),ht=_e([{field:["name","presence","type"]},{state:["name"]}]),bt=function(){return he.getOrDie("JSON")},yt=function(n,e,t){return bt().stringify(n,e,t)},wt=function(n){return E.isObject(n)&&100<M.keys(n).length?" removed due to size":yt(n,null,2)},xt=function(n,e){return qe.error([{path:n,getErrorInfo:e}])},St=_e([{field:["key","okey","presence","prop"]},{state:["okey","instantiator"]}]),Tt=function(t,o,r){return it(o,r).fold(function(){return n=r,e=o,xt(t,function(){return'Could not find valid *strict* value for "'+n+'" in '+wt(e)});var n,e},qe.value)},kt=function(n,e,t){var o=it(n,e).fold(function(){return t(n)},O.identity);return qe.value(o)},Ct=function(r,a,n,c){return n.fold(function(i,e,n,t){var o=function(n){return t.extract(r.concat([i]),c,n).map(function(n){return ut(e,c(n))})},u=function(n){return n.fold(function(){var n=ut(e,c(y.none()));return qe.value(n)},function(n){return t.extract(r.concat([i]),c,n).map(function(n){return ut(e,c(y.some(n)))})})};return n.fold(function(){return Tt(r,a,i).bind(o)},function(n){return kt(a,i,n).bind(o)},function(){return(n=a,e=i,qe.value(it(n,e))).bind(u);var n,e},function(n){return(e=a,t=i,o=n,r=it(e,t).map(function(n){return!0===n?o(e):n}),qe.value(r)).bind(u);var e,t,o,r},function(n){var e=n(a);return kt(a,i,O.constant({})).map(function(n){return D.deepMerge(e,n)}).bind(o)})},function(n,e){var t=e(a);return qe.value(ut(n,c(t)))})},Ot=function(o){return{extract:function(t,n,e){return o(e,n).fold(function(n){return e=n,xt(t,function(){return e});var e},qe.value)},toString:function(){return"val"},toDsl:function(){return vt.itemOf(o)}}},Et=function(n){var c=Dt(n),s=vn.foldr(n,function(e,n){return n.fold(function(n){return D.deepMerge(e,dt(n,!0))},O.constant(e))},{});return{extract:function(n,e,t){var o,r,i,u=E.isBoolean(t)?[]:(o=t,r=M.keys(o),vn.filter(r,function(n){return pt(o,n)})),a=vn.filter(u,function(n){return!pt(s,n)});return 0===a.length?c.extract(n,e,t):(i=a,xt(n,function(){return"There are unsupported fields: ["+i.join(", ")+"] specified"}))},toString:c.toString,toDsl:c.toDsl}},Dt=function(c){return{extract:function(n,e,t){return o=n,r=t,i=c,u=e,a=vn.map(i,function(n){return Ct(o,r,n,u)}),tt(a,{});var o,r,i,u,a},toString:function(){return"obj{\n"+vn.map(c,function(n){return n.fold(function(n,e,t,o){return n+" -> "+o.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return vt.objOf(vn.map(c,function(n){return n.fold(function(n,e,t,o){return ht.field(n,t,o)},function(n,e){return ht.state(n)})}))}}},Mt=function(r){return{extract:function(t,o,n){var e=vn.map(n,function(n,e){return r.extract(t.concat(["["+e+"]"]),o,n)});return ot(e)},toString:function(){return"array("+r.toString()+")"},toDsl:function(){return vt.arrOf(r)}}},At=function(u,a){return{extract:function(t,o,r){var n,e,i=M.keys(r);return(n=t,e=i,Mt(Ot(u)).extract(n,O.identity,e)).bind(function(n){var e=vn.map(n,function(n){return St.field(n,n,Ye(),a)});return Dt(e).extract(t,o,r)})},toString:function(){return"setOf("+a.toString()+")"},toDsl:function(){return vt.setOf(u,a)}}},Bt=O.constant(Ot(qe.value)),Rt=(O.compose(Mt,Dt),St.state),It=St.field,Ft=function(n){return It(n,n,Ye(),Bt())},Nt=function(n,e){return It(n,n,Ye(),e)},Vt=function(n){return It(n,n,Ye(),Ot(function(n){return E.isFunction(n)?qe.value(n):qe.error("Not a function")}))},Ht=function(n,e){return It(n,n,Ye(),Dt(e))},jt=function(n){return It(n,n,Je(),Bt())},zt=function(n,e){return It(n,n,Je(),Dt(e))},Lt=function(n,e){return It(n,n,Je(),Et(e))},Pt=function(n,e){return It(n,n,Xe(e),Bt())},Wt=function(n,e,t){return It(n,n,Xe(e),t)},Ut=function(n,e){return Rt(n,e)},Gt=function(t,e,o,r,i){return lt(r,i).fold(function(){return n=r,e=i,xt(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+wt(n)});var n,e},function(n){return Dt(n).extract(t.concat(["branch: "+i]),e,o)})},$t=function(r,i){return{extract:function(e,t,o){return lt(o,r).fold(function(){return n=r,xt(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return Gt(e,t,o,i,n)})},toString:function(){return"chooseOn("+r+"). Possible values: "+M.keys(i)},toDsl:function(){return vt.choiceOf(r,i)}}},qt=Ot(qe.value),_t=function(n,e,t,o){return e.extract([n],t,o).fold(function(n){return qe.error({input:o,errors:n})},qe.value)},Kt=function(n,e,t){return _t(n,e,O.constant,t)},Xt=function(n){return n.fold(function(n){throw new Error(Qt(n))},O.identity)},Yt=function(n,e,t){return Xt((o=t,_t(n,e,O.identity,o)));var o},Jt=function(n,e,t){return Xt(Kt(n,e,t))},Qt=function(n){return"Errors: \n"+(e=n.errors,t=10<e.length?e.slice(0,10).concat([{path:[],getErrorInfo:function(){return"... (only showing first ten failures)"}}]):e,vn.map(t,function(n){return"Failed path: ("+n.path.join(" > ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+wt(n.input);var e,t},Zt=function(n,e){return $t(n,e)},no=O.constant(qt),eo=function(n){if(!pt(n,"can")&&!pt(n,"abort")&&!pt(n,"run"))throw new Error("EventHandler defined by: "+yt(n,null,2)+" does not have can, abort, or run!");return Yt("Extracting event.handler",Et([Pt("can",O.constant(!0)),Pt("abort",O.constant(!1)),Pt("run",O.noop)]),n)},to=function(n){var e,o,r,i,t=(e=n,o=function(n){return n.can},function(){var t=Array.prototype.slice.call(arguments,0);return vn.foldl(e,function(n,e){return n&&o(e).apply(undefined,t)},!0)}),u=(r=n,i=function(n){return n.abort},function(){var t=Array.prototype.slice.call(arguments,0);return vn.foldl(r,function(n,e){return n||i(e).apply(undefined,t)},!1)});return eo({can:t,abort:u,run:function(){var e=Array.prototype.slice.call(arguments,0);vn.each(n,function(n){n.run.apply(undefined,e)})}})},oo=mt,ro=function(n,e){return{key:n,value:eo({abort:e})}},io=function(n,e){return{key:n,value:eo({run:e})}},uo=function(n,e,t){return{key:n,value:eo({run:function(n){e.apply(undefined,[n].concat(t))}})}},ao=function(n){return function(o){return{key:n,value:eo({run:function(n,e){var t;t=e,Te(n.element(),t.event().target())&&o(n,e)}})}}},co=function(n,e,t){var u,o,r=e.partUids()[t];return o=r,io(u=n,function(n,i){n.getSystem().getByUid(o).each(function(n){var e,t,o,r;t=(e=n).element(),o=u,r=i,e.getSystem().triggerEvent(o,t,r.event())})})},so=function(n){return io(n,function(n,e){e.cut()})},fo=ao(Pn()),lo=ao(Wn()),mo=ao(zn()),go=(u=Fn(),function(n){return io(u,n)}),po=function(n,e){return n},vo=de.immutableBag(["tag"],["classes","attributes","styles","value","innerHtml","domChildren","defChildren"]),ho=function(n){return{tag:n.tag(),classes:n.classes().getOr([]),attributes:n.attributes().getOr({}),styles:n.styles().getOr({}),value:n.value().getOr("<none>"),innerHtml:n.innerHtml().getOr("<none>"),defChildren:n.defChildren().getOr("<none>"),domChildren:n.domChildren().fold(function(){return"<none>"},function(n){return 0===n.length?"0 children, but still specified":String(n.length)})}},bo=de.immutableBag([],["classes","attributes","styles","value","innerHtml","defChildren","domChildren"]),yo=function(e,n,t){return n.fold(function(){return t.fold(function(){return{}},function(n){return dt(e,n)})},function(n){return t.fold(function(){return dt(e,n)},function(n){return dt(e,n)})})},wo=function(t,o,r){return mo(function(n,e){r(n,t,o)})},xo=function(n,e,t,o,r,i){var u,a,c=n,s=zt(e,[(u="config",a=n,It(u,u,Je(),a))]);return To(c,s,e,t,o,r,i)},So=function(n){return{key:n,value:undefined}},To=function(t,n,o,r,e,i,u){var a=function(n){return pt(n,o)?n[o]():y.none()},c=M.map(e,function(n,e){return r=o,i=n,u=e,function(t){var o=arguments;return t.config({name:O.constant(r)}).fold(function(){throw new Error("We could not find any behaviour configuration for: "+r+". Using API: "+u)},function(n){var e=Array.prototype.slice.call(o,1);return i.apply(undefined,[t,n.config,n.state].concat(e))})};var r,i,u}),s=M.map(i,function(n,e){return po(n)}),f=D.deepMerge(s,c,{revoke:O.curry(So,o),config:function(n){var e=Jt(o+"-config",t,n);return{key:o,value:{config:e,me:f,configAsRaw:L(function(){return Yt(o+"-config",t,n)}),initialConfig:n,state:u}}},schema:function(){return n},exhibit:function(n,t){return a(n).bind(function(e){return lt(r,"exhibit").map(function(n){return n(t,e.config,e.state)})}).getOr(bo({}))},name:function(){return o},handlers:function(n){return a(n).bind(function(e){return lt(r,"events").map(function(n){return n(e.config,e.state)})}).getOr({})}});return f},ko=function(n,e){return Co(n,e,{validate:E.isFunction,label:"function"})},Co=function(o,r,i){if(0===r.length)throw new Error("You must specify at least one required field.");return le.validateStrArr("required",r),le.checkDupes(r),function(e){var t=M.keys(e);vn.forall(r,function(n){return vn.contains(t,n)})||le.reqMessage(r,t),o(r,t);var n=vn.filter(r,function(n){return!i.validate(e[n],n)});return 0<n.length&&le.invalidTypeMessage(n,i.label),e}},Oo=O.noop,Eo={exactly:O.curry(ko,function(e,n){var t=vn.filter(n,function(n){return!vn.contains(e,n)});0<t.length&&le.unsuppMessage(t)}),ensure:O.curry(ko,Oo),ensureWith:O.curry(Co,Oo)},Do=Eo.ensure(["readState"]),Mo=function(){return Do({readState:function(){return"No State required"}})},Ao=Object.freeze({init:Mo}),Bo=function(n){return mt(n)},Ro=Et([Ft("fields"),Ft("name"),Pt("active",{}),Pt("apis",{}),Pt("extra",{}),Pt("state",Ao)]),Io=function(n){var e,t,o,r,i,u,a,c,s=Yt("Creating behaviour: "+n.name,Ro,n);return e=s.fields,t=s.name,o=s.active,r=s.apis,i=s.extra,u=s.state,a=Et(e),c=zt(t,[Lt("config",e)]),To(a,c,t,o,r,i,u)},Fo=Et([Ft("branchKey"),Ft("branches"),Ft("name"),Pt("active",{}),Pt("apis",{}),Pt("extra",{}),Pt("state",Ao)]),No=(O.constant(undefined),O.constant({}),O.constant({}),O.constant({}),O.constant(Ao));function Vo(n,e,t){var o=t||!1,r=function(){e(),o=!0},i=function(){n(),o=!1};return{on:r,off:i,toggle:function(){(o?i:r)()},isOn:function(){return o}}}var Ho=function(n,e,t){if(!(E.isString(t)||E.isBoolean(t)||E.isNumber(t)))throw console.error("Invalid call to Attr.set. Key ",e,":: Value ",t,":: Element ",n),new Error("Attribute value was not simple");n.setAttribute(e,t+"")},jo=function(n,e,t){Ho(n.dom(),e,t)},zo=function(n,e){var t=n.dom().getAttribute(e);return null===t?undefined:t},Lo=function(n,e){var t=n.dom();return!(!t||!t.hasAttribute)&&t.hasAttribute(e)},Po={clone:function(n){return vn.foldl(n.dom().attributes,function(n,e){return n[e.name]=e.value,n},{})},set:jo,setAll:function(n,e){var t=n.dom();M.each(e,function(n,e){Ho(t,e,n)})},get:zo,has:Lo,remove:function(n,e){n.dom().removeAttribute(e)},hasNone:function(n){var e=n.dom().attributes;return e===undefined||null===e||0===e.length},transfer:function(r,i,n){ue.isElement(r)&&ue.isElement(i)&&vn.each(n,function(n){var e,t,o;t=i,Lo(e=r,o=n)&&!Lo(t,o)&&jo(t,o,zo(e,o))})}},Wo=function(n,e){var t=Po.get(n,e);return t===undefined||""===t?[]:t.split(" ")},Uo=Wo,Go=function(n,e,t){var o=Wo(n,e).concat([t]);Po.set(n,e,o.join(" "))},$o=function(n,e,t){var o=vn.filter(Wo(n,e),function(n){return n!==t});0<o.length?Po.set(n,e,o.join(" ")):Po.remove(n,e)},qo=function(n){return Uo(n,"class")},_o=function(n,e){return Go(n,"class",e)},Ko=function(n,e){return $o(n,"class",e)},Xo=qo,Yo=_o,Jo=Ko,Qo=function(n,e){vn.contains(qo(n),e)?Ko(n,e):_o(n,e)},Zo=function(n){return n.dom().classList!==undefined},nr=function(n,e){return Zo(n)&&n.dom().classList.contains(e)},er={add:function(n,e){Zo(n)?n.dom().classList.add(e):Yo(n,e)},remove:function(n,e){var t;Zo(n)?n.dom().classList.remove(e):Jo(n,e),0===(Zo(t=n)?t.dom().classList:Xo(t)).length&&Po.remove(t,"class")},toggle:function(n,e){return Zo(n)?n.dom().classList.toggle(e):Qo(n,e)},toggler:function(n,e){var t=Zo(n),o=n.dom().classList;return Vo(function(){t?o.remove(e):Jo(n,e)},function(){t?o.add(e):Yo(n,e)},nr(n,e))},has:nr},tr=function(n,e,t){er.remove(n,t),er.add(n,e)},or=Object.freeze({toAlpha:function(n,e,t){tr(n.element(),e.alpha(),e.omega())},toOmega:function(n,e,t){tr(n.element(),e.omega(),e.alpha())},isAlpha:function(n,e,t){return er.has(n.element(),e.alpha())},isOmega:function(n,e,t){return er.has(n.element(),e.omega())},clear:function(n,e,t){er.remove(n.element(),e.alpha()),er.remove(n.element(),e.omega())}}),rr=[Ft("alpha"),Ft("omega")],ir=Io({fields:rr,name:"swapping",apis:or}),ur=function(n){var e=n,t=function(){return e};return{get:t,set:function(n){e=n},clone:function(){return ur(t())}}};function ar(n,e,t,o,r){return n(t,o)?y.some(t):E.isFunction(r)&&r(t)?y.none():e(t,o,r)}var cr=function(n,e,t){for(var o=n.dom(),r=E.isFunction(t)?t:O.constant(!1);o.parentNode;){o=o.parentNode;var i=Xn.fromDom(o);if(e(i))return y.some(i);if(r(i))break}return y.none()},sr=function(n,e){return vn.find(n.dom().childNodes,O.compose(e,Xn.fromDom)).map(Xn.fromDom)},fr=function(n,o){var r=function(n){for(var e=0;e<n.childNodes.length;e++){if(o(Xn.fromDom(n.childNodes[e])))return y.some(Xn.fromDom(n.childNodes[e]));var t=r(n.childNodes[e]);if(t.isSome())return t}return y.none()};return r(n.dom())},lr={first:function(n){return fr(se.body(),n)},ancestor:cr,closest:function(n,e,t){return ar(function(n){return e(n)},cr,n,e,t)},sibling:function(e,t){var n=e.dom();return n.parentNode?sr(Xn.fromDom(n.parentNode),function(n){return!Te(e,n)&&t(n)}):y.none()},child:sr,descendant:fr},dr=function(n){n.dom().focus()},mr=function(n){var e=n!==undefined?n.dom():document;return y.from(e.activeElement).map(Xn.fromDom)},gr=function(n){var e=Be.owner(n).dom();return n.dom()===e.activeElement},pr=dr,vr=function(n){n.dom().blur()},hr=mr,br=function(e){return mr(Be.owner(e)).filter(function(n){return e.dom().contains(n.dom())})},yr=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),wr=tinymce.util.Tools.resolve("tinymce.ThemeManager"),xr=function(n){var e=document.createElement("a");e.target="_blank",e.href=n.href,e.rel="noreferrer noopener";var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),document.body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)},Sr={formatChanged:O.constant("formatChanged"),orientationChanged:O.constant("orientationChanged"),dropupDismissed:O.constant("dropupDismissed")},Tr=function(n,e){var t=(e||document).createElement("div");return t.innerHTML=n,Be.children(Xn.fromDom(t))},kr=function(n){return n.dom().innerHTML},Cr=kr,Or=function(n,e){var t=Be.owner(n).dom(),o=Xn.fromDom(t.createDocumentFragment()),r=Tr(e,t);Ne.append(o,r),He.empty(n),Fe.append(n,o)},Er=function(n){var e=Xn.fromTag("div"),t=Xn.fromDom(n.dom().cloneNode(!0));return Fe.append(e,t),kr(e)},Dr=function(n,e){return Xn.fromDom(n.dom().cloneNode(e))},Mr=function(n){return Dr(n,!1)},Ar=function(n){return e=Mr(n),Er(e);var e},Br=Object.freeze({events:function(a){return oo([io(In(),function(r,i){var n,e,u=a.channels(),t=M.keys(u),o=(n=t,(e=i).universal()?n:vn.filter(n,function(n){return vn.contains(e.channels(),n)}));vn.each(o,function(n){var e=u[n](),t=e.schema(),o=Jt("channel["+n+"] data\nReceiver: "+Ar(r.element()),t,i.data());e.onReceive()(r,o)})})])}}),Rr=function(n){for(var e=[],t=function(n){e.push(n)},o=0;o<n.length;o++)n[o].each(t);return e},Ir=function(n,e){for(var t=0;t<n.length;t++){var o=e(n[t],t);if(o.isSome())return o}return y.none()},Fr="unknown",Nr=[],Vr=["alloy/data/Fields","alloy/debugging/Debugging"],Hr={logEventCut:O.noop,logEventStopped:O.noop,logNoParent:O.noop,logEventNoHandlers:O.noop,logEventResponse:O.noop,write:O.noop},jr=function(n,e,t){var o,r="*"===Nr||vn.contains(Nr,n)?(o=[],{logEventCut:function(n,e,t){o.push({outcome:"cut",target:e,purpose:t})},logEventStopped:function(n,e,t){o.push({outcome:"stopped",target:e,purpose:t})},logNoParent:function(n,e,t){o.push({outcome:"no-parent",target:e,purpose:t})},logEventNoHandlers:function(n,e){o.push({outcome:"no-handlers-left",target:e})},logEventResponse:function(n,e,t){o.push({outcome:"response",purpose:t,target:e})},write:function(){vn.contains(["mousemove","mouseover","mouseout",zn()],n)||console.log(n,{event:n,target:e.dom(),sequence:vn.map(o,function(n){return vn.contains(["cut","stopped","response"],n.outcome)?"{"+n.purpose+"} "+n.outcome+" at ("+Ar(n.target)+")":n.outcome})})}}):Hr,i=t(r);return r.write(),i},zr=(O.constant(Hr),O.constant(!0),O.constant([Ft("menu"),Ft("selectedMenu")])),Lr=O.constant([Ft("item"),Ft("selectedItem")]),Pr=(O.constant(Et(Lr().concat(zr()))),O.constant(Et(Lr()))),Wr=Ht("initSize",[Ft("numColumns"),Ft("numRows")]),Ur=function(n,e,t){var o;return function(){var n=new Error;if(n.stack!==undefined){var e=n.stack.split("\n");vn.find(e,function(e){return 0<e.indexOf("alloy")&&!vn.exists(Vr,function(n){return-1<e.indexOf(n)})}).getOr(Fr)}}(),It(e,e,t,(o=function(n){return qe.value(function(){return n.apply(undefined,arguments)})},Ot(function(n){return o(n)})))},Gr=function(n){return Ur(0,n,Xe(O.noop))},$r=function(n){return Ur(0,n,Xe(y.none))},qr=function(n){return Ur(0,n,Ye())},_r=function(n){return Ur(0,n,Ye())},Kr=function(n,e){return Ut(n,O.constant(e))},Xr=function(n){return Ut(n,O.identity)},Yr=O.constant(Wr),Jr=[Nt("channels",At(qe.value,Et([qr("onReceive"),Pt("schema",no())])))],Qr=Io({fields:Jr,name:"receiving",active:Br}),Zr=function(n,e){var t=oi(n,e),o=e.aria();o.update()(n,o,t)},ni=function(n,e,t){er.toggle(n.element(),e.toggleClass()),Zr(n,e)},ei=function(n,e,t){er.add(n.element(),e.toggleClass()),Zr(n,e)},ti=function(n,e,t){er.remove(n.element(),e.toggleClass()),Zr(n,e)},oi=function(n,e){return er.has(n.element(),e.toggleClass())},ri=function(n,e,t){(e.selected()?ei:ti)(n,e,t)},ii=Object.freeze({onLoad:ri,toggle:ni,isOn:oi,on:ei,off:ti}),ui=Object.freeze({exhibit:function(n,e,t){return bo({})},events:function(n,e){var t,o,r,i=(t=n,o=e,r=ni,go(function(n){r(n,t,o)})),u=wo(n,e,ri);return oo(vn.flatten([n.toggleOnExecute()?[i]:[],[u]]))}}),ai=function(n,e,t){Po.set(n.element(),"aria-expanded",t)},ci=[Pt("selected",!1),Ft("toggleClass"),Pt("toggleOnExecute",!0),Wt("aria",{mode:"none"},Zt("mode",{pressed:[Pt("syncWithExpanded",!1),Kr("update",function(n,e,t){Po.set(n.element(),"aria-pressed",t),e.syncWithExpanded()&&ai(n,e,t)})],checked:[Kr("update",function(n,e,t){Po.set(n.element(),"aria-checked",t)})],expanded:[Kr("update",ai)],selected:[Kr("update",function(n,e,t){Po.set(n.element(),"aria-selected",t)})],none:[Kr("update",O.noop)]}))],si=Io({fields:ci,name:"toggling",active:ui,apis:ii}),fi=function(t,o){return Qr.config({channels:dt(Sr.formatChanged(),{onReceive:function(n,e){e.command===t&&o(n,e.state)}})})},li=function(n){return Qr.config({channels:dt(Sr.orientationChanged(),{onReceive:n})})},di=function(n,e){return{key:n,value:{onReceive:e}}},mi="tinymce-mobile",gi={resolve:function(n){return mi+"-"+n},prefix:O.constant(mi)},pi=function(n,e){e.ignore()||(pr(n.element()),e.onFocus()(n))},vi=Object.freeze({focus:pi,blur:function(n,e){e.ignore()||vr(n.element())},isFocused:function(n){return gr(n.element())}}),hi=Object.freeze({exhibit:function(n,e){return e.ignore()?bo({}):bo({attributes:{tabindex:"-1"}})},events:function(t){return oo([io(Bn(),function(n,e){pi(n,t),e.stop()})])}}),bi=[Gr("onFocus"),Pt("ignore",!1)],yi=Io({fields:bi,name:"focusing",active:hi,apis:vi}),wi={isSupported:function(n){return n.style!==undefined}},xi=function(n,e,t){if(!E.isString(t))throw console.error("Invalid call to CSS.set. Property ",e,":: Value ",t,":: Element ",n),new Error("CSS value must be a string: "+t);wi.isSupported(n)&&n.style.setProperty(e,t)},Si=function(n,e){wi.isSupported(n)&&n.style.removeProperty(e)},Ti=function(n,e,t){var o=n.dom();xi(o,e,t)},ki=function(n,e){return wi.isSupported(n)?n.style.getPropertyValue(e):""},Ci=function(n,e){var t=n.dom(),o=ki(t,e);return y.from(o).filter(function(n){return 0<n.length})},Oi={copy:function(n,e){var t=n.dom(),o=e.dom();wi.isSupported(t)&&wi.isSupported(o)&&(o.style.cssText=t.style.cssText)},set:Ti,preserve:function(n,e){var t=Po.get(n,"style"),o=e(n);return(t===undefined?Po.remove:Po.set)(n,"style",t),o},setAll:function(n,e){var t=n.dom();M.each(e,function(n,e){xi(t,e,n)})},setOptions:function(n,e){var t=n.dom();M.each(e,function(n,e){n.fold(function(){Si(t,e)},function(n){xi(t,e,n)})})},remove:function(n,e){var t=n.dom();Si(t,e),Po.has(n,"style")&&""===Sn(Po.get(n,"style"))&&Po.remove(n,"style")},get:function(n,e){var t=n.dom(),o=window.getComputedStyle(t).getPropertyValue(e),r=""!==o||se.inBody(n)?o:ki(t,e);return null===r?undefined:r},getRaw:Ci,getAllRaw:function(n){var e={},t=n.dom();if(wi.isSupported(t))for(var o=0;o<t.style.length;o++){var r=t.style.item(o);e[r]=t.style[r]}return e},isValidValue:function(n,e,t){var o=Xn.fromTag(n);return Ti(o,e,t),Ci(o,e).isSome()},reflow:function(n){return n.dom().offsetWidth},transfer:function(o,r,n){ue.isElement(o)&&ue.isElement(r)&&vn.each(n,function(n){var e,t;e=r,Ci(o,t=n).each(function(n){Ci(e,t).isNone()&&Ti(e,t,n)})})}};function Ei(o,r){var n=function(n){var e=r(n);if(e<=0||null===e){var t=Oi.get(n,o);return parseFloat(t)||0}return e},i=function(r,n){return vn.foldl(n,function(n,e){var t=Oi.get(r,e),o=t===undefined?0:parseInt(t,10);return isNaN(o)?n:n+o},0)};return{set:function(n,e){if(!E.isNumber(e)&&!e.match(/^[0-9]+$/))throw o+".set accepts only positive integer values. Value was "+e;var t=n.dom();wi.isSupported(t)&&(t.style[o]=e+"px")},get:n,getOuter:n,aggregate:i,max:function(n,e,t){var o=i(n,t);return o<e?e-o:0}}}var Di,Mi,Ai=Ei("height",function(n){return se.inBody(n)?n.dom().getBoundingClientRect().height:n.dom().offsetHeight}),Bi=function(n){return Ai.get(n)},Ri=function(n,e,t){return vn.filter(Be.parents(n,t),e)},Ii=function(n,e){return vn.filter(Be.siblings(n),e)},Fi=function(n){return xe.all(n)},Ni=function(n,e,t){return Ri(n,function(n){return xe.is(n,e)},t)},Vi=function(n,e){return Ii(n,function(n){return xe.is(n,e)})},Hi=function(n,e){return xe.all(e,n)},ji=function(n,e,t){return lr.ancestor(n,function(n){return xe.is(n,e)},t)},zi=function(n){return xe.one(n)},Li=ji,Pi=function(n,e){return xe.one(e,n)},Wi=function(n,e,t){return ar(xe.is,ji,n,e,t)},Ui={BACKSPACE:O.constant([8]),TAB:O.constant([9]),ENTER:O.constant([13]),SHIFT:O.constant([16]),CTRL:O.constant([17]),ALT:O.constant([18]),CAPSLOCK:O.constant([20]),ESCAPE:O.constant([27]),SPACE:O.constant([32]),PAGEUP:O.constant([33]),PAGEDOWN:O.constant([34]),END:O.constant([35]),HOME:O.constant([36]),LEFT:O.constant([37]),UP:O.constant([38]),RIGHT:O.constant([39]),DOWN:O.constant([40]),INSERT:O.constant([45]),DEL:O.constant([46]),META:O.constant([91,93,224]),F10:O.constant([121])},Gi=function(n,e,t){var o=vn.reverse(n.slice(0,e)),r=vn.reverse(n.slice(e+1));return vn.find(o.concat(r),t)},$i=function(n,e,t){var o=vn.reverse(n.slice(0,e));return vn.find(o,t)},qi=function(n,e,t){var o=n.slice(0,e),r=n.slice(e+1);return vn.find(r.concat(o),t)},_i=function(n,e,t){var o=n.slice(e+1);return vn.find(o,t)},Ki=function(e){return function(n){return vn.contains(e,n.raw().which)}},Xi=function(n){return function(e){return vn.forall(n,function(n){return n(e)})}},Yi=function(n){return!0===n.raw().shiftKey},Ji=function(n){return!0===n.raw().ctrlKey},Qi=(O.not(Ji),O.not(Yi)),Zi=function(n,e){return{matches:n,classification:e}},nu=function(n,e,t,o){var r=n+e;return o<r?t:r<t?o:r},eu=function(n,e,t){return n<=e?e:t<=n?t:n},tu=function(e,t,n){var o=Hi(e.element(),"."+t.highlightClass());vn.each(o,function(n){er.remove(n,t.highlightClass()),e.getSystem().getByDom(n).each(function(n){t.onDehighlight()(e,n)})})},ou=function(n,e,t,o){var r=ru(n,e,t,o);tu(n,e),er.add(o.element(),e.highlightClass()),r||e.onHighlight()(n,o)},ru=function(n,e,t,o){return er.has(o.element(),e.highlightClass())},iu=function(n,e,t,o){var r=Hi(n.element(),"."+e.itemClass());return y.from(r[o]).fold(function(){return qe.error("No element found with index "+o)},n.getSystem().getByDom)},uu=function(n,e,t){return Pi(n.element(),"."+e.itemClass()).bind(n.getSystem().getByDom)},au=function(n,e,t){var o=Hi(n.element(),"."+e.itemClass());return(0<o.length?y.some(o[o.length-1]):y.none()).bind(n.getSystem().getByDom)},cu=function(t,e,n,o){var r=Hi(t.element(),"."+e.itemClass());return vn.findIndex(r,function(n){return er.has(n,e.highlightClass())}).bind(function(n){var e=nu(n,o,0,r.length-1);return t.getSystem().getByDom(r[e])})},su=Object.freeze({dehighlightAll:tu,dehighlight:function(n,e,t,o){var r=ru(n,e,t,o);er.remove(o.element(),e.highlightClass()),r&&e.onDehighlight()(n,o)},highlight:ou,highlightFirst:function(e,t,o){uu(e,t,o).each(function(n){ou(e,t,o,n)})},highlightLast:function(e,t,o){au(e,t,o).each(function(n){ou(e,t,o,n)})},highlightAt:function(e,t,o,n){iu(e,t,o,n).fold(function(n){throw new Error(n)},function(n){ou(e,t,o,n)})},highlightBy:function(e,t,o,n){var r=Hi(e.element(),"."+t.itemClass()),i=Rr(vn.map(r,function(n){return e.getSystem().getByDom(n).toOption()}));vn.find(i,n).each(function(n){ou(e,t,o,n)})},isHighlighted:ru,getHighlighted:function(n,e,t){return Pi(n.element(),"."+e.highlightClass()).bind(n.getSystem().getByDom)},getFirst:uu,getLast:au,getPrevious:function(n,e,t){return cu(n,e,0,-1)},getNext:function(n,e,t){return cu(n,e,0,1)}}),fu=[Ft("highlightClass"),Ft("itemClass"),Gr("onHighlight"),Gr("onDehighlight")],lu=Io({fields:fu,name:"highlighting",apis:su}),du=function(){return{get:function(n){return br(n.element())},set:function(n,e){n.getSystem().triggerFocus(e,n.element())}}},mu=function(n,e,a,t,o,i){var u=function(e,t,o,r){var n,i,u=a(e,t,o,r);return(n=u,i=t.event(),vn.find(n,function(n){return n.matches(i)}).map(function(n){return n.classification})).bind(function(n){return n(e,t,o,r)})},r={schema:function(){return n.concat([Pt("focusManager",du()),Kr("handler",r),Kr("state",e)])},processKey:u,toEvents:function(o,r){var n=t(o,r),e=oo(i.map(function(t){return io(Bn(),function(n,e){t(n,o,r,e),e.stop()})}).toArray().concat([io(F(),function(n,e){u(n,e,o,r).each(function(n){e.stop()})})]));return D.deepMerge(n,e)},toApis:o};return r},gu=function(n){var e=[jt("onEscape"),jt("onEnter"),Pt("selector",'[data-alloy-tabstop="true"]'),Pt("firstTabstop",0),Pt("useTabstopAt",O.constant(!0)),jt("visibilitySelector")].concat([n]),a=function(n,e){var t=n.visibilitySelector().bind(function(n){return Wi(e,n)}).getOr(e);return 0<Bi(t)},c=function(e,n,t,o,r){return r(n,t,function(n){return a(e=o,t=n)&&e.useTabstopAt()(t);var e,t}).fold(function(){return o.cyclic()?y.some(!0):y.none()},function(n){return o.focusManager().set(e,n),y.some(!0)})},i=function(e,n,t,o){var r,i,u=Hi(e.element(),t.selector());return(r=e,i=t,i.focusManager().get(r).bind(function(n){return Wi(n,i.selector())})).bind(function(n){return vn.findIndex(u,O.curry(Te,n)).bind(function(n){return c(e,u,n,t,o)})})},t=O.constant([Zi(Xi([Yi,Ki(Ui.TAB())]),function(n,e,t,o){var r=t.cyclic()?Gi:$i;return i(n,0,t,r)}),Zi(Ki(Ui.TAB()),function(n,e,t,o){var r=t.cyclic()?qi:_i;return i(n,0,t,r)}),Zi(Ki(Ui.ESCAPE()),function(e,t,n,o){return n.onEscape().bind(function(n){return n(e,t)})}),Zi(Xi([Qi,Ki(Ui.ENTER())]),function(e,t,n,o){return n.onEnter().bind(function(n){return n(e,t)})})]),o=O.constant({}),r=O.constant({});return mu(e,Mo,t,o,r,y.some(function(e,t,n){var o,r,i,u;(o=e,r=t,i=Hi(o.element(),r.selector()),u=vn.filter(i,function(n){return a(r,n)}),y.from(u[r.firstTabstop()])).each(function(n){t.focusManager().set(e,n)})}))},pu=gu(Ut("cyclic",O.constant(!1))),vu=gu(Ut("cyclic",O.constant(!0))),hu=function(n){return"input"===ue.name(n)&&"radio"!==Po.get(n,"type")||"textarea"===ue.name(n)},bu=function(n,e,t){return hu(t)&&Ki(Ui.SPACE())(e.event())?y.none():(qn(n,t,Fn()),y.some(!0))},yu=[Pt("execute",bu),Pt("useSpace",!1),Pt("useEnter",!0),Pt("useControlEnter",!1),Pt("useDown",!1)],wu=function(n,e,t,o){return t.execute()(n,e,n.element())},xu=O.constant({}),Su=O.constant({}),Tu=mu(yu,Mo,function(n,e,t,o){var r=t.useSpace()&&!hu(n.element())?Ui.SPACE():[],i=t.useEnter()?Ui.ENTER():[],u=t.useDown()?Ui.DOWN():[],a=r.concat(i).concat(u);return[Zi(Ki(a),wu)].concat(t.useControlEnter()?[Zi(Xi([Ji,Ki(Ui.ENTER())]),wu)]:[])},xu,Su,y.none()),ku=function(n){var t=ur(y.none());return Do({readState:O.constant({}),setGridSize:function(n,e){t.set(y.some({numRows:O.constant(n),numColumns:O.constant(e)}))},getNumRows:function(){return t.get().map(function(n){return n.numRows()})},getNumColumns:function(){return t.get().map(function(n){return n.numColumns()})}})},Cu=Object.freeze({flatgrid:ku,init:function(n){return n.state()(n)}}),Ou=function(n){return"rtl"===Oi.get(n,"direction")?"rtl":"ltr"},Eu=function(e,t){return function(n){return"rtl"===Ou(n)?t:e}},Du=function(i){return function(n,e,t,o){var r=i(n.element());return Ru(r,n,e,t,o)}},Mu=function(n,e){var t=Eu(n,e);return Du(t)},Au=function(n,e){var t=Eu(e,n);return Du(t)},Bu=function(r){return function(n,e,t,o){return Ru(r,n,e,t,o)}},Ru=function(e,t,n,o,r){return o.focusManager().get(t).bind(function(n){return e(t.element(),n,o,r)}).map(function(n){return o.focusManager().set(t,n),!0})},Iu=Bu,Fu=Bu,Nu=Bu,Vu=function(n){var e,t=n.dom();return!((e=t).offsetWidth<=0&&e.offsetHeight<=0)},Hu=de.immutableBag(["index","candidates"],[]),ju=function(n,e,t){return zu(n,e,t,Vu)},zu=function(n,e,t,o){var r,i,u=O.curry(Te,e),a=Hi(n,t),c=vn.filter(a,Vu);return r=c,i=u,vn.findIndex(r,i).map(function(n){return Hu({index:n,candidates:r})})},Lu=function(n,e){return vn.findIndex(n,function(n){return Te(e,n)})},Pu=function(t,n,o,e){return e(Math.floor(n/o),n%o).bind(function(n){var e=n.row()*o+n.column();return 0<=e&&e<t.length?y.some(t[e]):y.none()})},Wu=function(r,n,i,u,a){return Pu(r,n,u,function(n,e){var t=n===i-1?r.length-n*u:u,o=nu(e,a,0,t-1);return y.some({row:O.constant(n),column:O.constant(o)})})},Uu=function(i,n,u,a,c){return Pu(i,n,a,function(n,e){var t=nu(n,c,0,u-1),o=t===u-1?i.length-t*a:a,r=eu(e,0,o-1);return y.some({row:O.constant(t),column:O.constant(r)})})},Gu=[Ft("selector"),Pt("execute",bu),$r("onEscape"),Pt("captureTab",!1),Yr()],$u=function(r){return function(n,e,t,o){return ju(n,e,t.selector()).bind(function(n){return r(n.candidates(),n.index(),o.getNumRows().getOr(t.initSize().numRows()),o.getNumColumns().getOr(t.initSize().numColumns()))})}},qu=function(n,e,t,o){return t.captureTab()?y.some(!0):y.none()},_u=$u(function(n,e,t,o){return Wu(n,e,t,o,-1)}),Ku=$u(function(n,e,t,o){return Wu(n,e,t,o,1)}),Xu=$u(function(n,e,t,o){return Uu(n,e,t,o,-1)}),Yu=$u(function(n,e,t,o){return Uu(n,e,t,o,1)}),Ju=O.constant([Zi(Ki(Ui.LEFT()),Mu(_u,Ku)),Zi(Ki(Ui.RIGHT()),Au(_u,Ku)),Zi(Ki(Ui.UP()),Iu(Xu)),Zi(Ki(Ui.DOWN()),Fu(Yu)),Zi(Xi([Yi,Ki(Ui.TAB())]),qu),Zi(Xi([Qi,Ki(Ui.TAB())]),qu),Zi(Ki(Ui.ESCAPE()),function(n,e,t,o){return t.onEscape()(n,e)}),Zi(Ki(Ui.SPACE().concat(Ui.ENTER())),function(e,t,o,n){return(r=e,i=o,i.focusManager().get(r).bind(function(n){return Wi(n,i.selector())})).bind(function(n){return o.execute()(e,t,n)});var r,i})]),Qu=O.constant({}),Zu=mu(Gu,ku,Ju,Qu,{},y.some(function(e,t,n){Pi(e.element(),t.selector()).each(function(n){t.focusManager().set(e,n)})})),na=function(n,e,t,r){return ju(n,t,e).bind(function(n){var e=n.index(),t=n.candidates(),o=nu(e,r,0,t.length-1);return y.from(t[o])})},ea=[Ft("selector"),Pt("getInitial",y.none),Pt("execute",bu),Pt("executeOnMove",!1)],ta=function(e,t,o){return(n=e,r=o,r.focusManager().get(n).bind(function(n){return Wi(n,r.selector())})).bind(function(n){return o.execute()(e,t,n)});var n,r},oa=function(n,e,t){return na(n,t.selector(),e,-1)},ra=function(n,e,t){return na(n,t.selector(),e,1)},ia=function(o){return function(n,e,t){return o(n,e,t).bind(function(){return t.executeOnMove()?ta(n,e,t):y.some(!0)})}},ua=O.constant({}),aa=O.constant({}),ca=mu(ea,Mo,function(n){return[Zi(Ki(Ui.LEFT().concat(Ui.UP())),ia(Mu(oa,ra))),Zi(Ki(Ui.RIGHT().concat(Ui.DOWN())),ia(Au(oa,ra))),Zi(Ki(Ui.ENTER()),ta),Zi(Ki(Ui.SPACE()),ta)]},ua,aa,y.some(function(e,t){t.getInitial()(e).or(Pi(e.element(),t.selector())).each(function(n){t.focusManager().set(e,n)})})),sa=de.immutableBag(["rowIndex","columnIndex","cell"],[]),fa=function(n,e,t){return y.from(n[e]).bind(function(n){return y.from(n[t]).map(function(n){return sa({rowIndex:e,columnIndex:t,cell:n})})})},la=function(n,e,t,o){var r=n[e].length,i=nu(t,o,0,r-1);return fa(n,e,i)},da=function(n,e,t,o){var r=nu(t,o,0,n.length-1),i=n[r].length,u=eu(e,0,i-1);return fa(n,r,u)},ma=function(n,e,t,o){var r=n[e].length,i=eu(t+o,0,r-1);return fa(n,e,i)},ga=function(n,e,t,o){var r=eu(t+o,0,n.length-1),i=n[r].length,u=eu(e,0,i-1);return fa(n,r,u)},pa=[Ht("selectors",[Ft("row"),Ft("cell")]),Pt("cycles",!0),Pt("previousSelector",y.none),Pt("execute",bu)],va=function(n,e){return function(t,o,u){var a=u.cycles()?n:e;return Wi(o,u.selectors().row()).bind(function(n){var e=Hi(n,u.selectors().cell());return Lu(e,o).bind(function(r){var i=Hi(t,u.selectors().row());return Lu(i,n).bind(function(n){var e,t,o=(e=i,t=u,vn.map(e,function(n){return Hi(n,t.selectors().cell())}));return a(o,n,r).map(function(n){return n.cell()})})})})}},ha=va(function(n,e,t){return la(n,e,t,-1)},function(n,e,t){return ma(n,e,t,-1)}),ba=va(function(n,e,t){return la(n,e,t,1)},function(n,e,t){return ma(n,e,t,1)}),ya=va(function(n,e,t){return da(n,t,e,-1)},function(n,e,t){return ga(n,t,e,-1)}),wa=va(function(n,e,t){return da(n,t,e,1)},function(n,e,t){return ga(n,t,e,1)}),xa=O.constant([Zi(Ki(Ui.LEFT()),Mu(ha,ba)),Zi(Ki(Ui.RIGHT()),Au(ha,ba)),Zi(Ki(Ui.UP()),Iu(ya)),Zi(Ki(Ui.DOWN()),Fu(wa)),Zi(Ki(Ui.SPACE().concat(Ui.ENTER())),function(e,t,o){return br(e.element()).bind(function(n){return o.execute()(e,t,n)})})]),Sa=O.constant({}),Ta=O.constant({}),ka=mu(pa,Mo,xa,Sa,Ta,y.some(function(e,t){t.previousSelector()(e).orThunk(function(){var n=t.selectors();return Pi(e.element(),n.cell())}).each(function(n){t.focusManager().set(e,n)})})),Ca=[Ft("selector"),Pt("execute",bu),Pt("moveOnTab",!1)],Oa=function(e,t,o){return o.focusManager().get(e).bind(function(n){return o.execute()(e,t,n)})},Ea=function(n,e,t){return na(n,t.selector(),e,-1)},Da=function(n,e,t){return na(n,t.selector(),e,1)},Ma=O.constant([Zi(Ki(Ui.UP()),Nu(Ea)),Zi(Ki(Ui.DOWN()),Nu(Da)),Zi(Xi([Yi,Ki(Ui.TAB())]),function(n,e,t){return t.moveOnTab()?Nu(Ea)(n,e,t):y.none()}),Zi(Xi([Qi,Ki(Ui.TAB())]),function(n,e,t){return t.moveOnTab()?Nu(Da)(n,e,t):y.none()}),Zi(Ki(Ui.ENTER()),Oa),Zi(Ki(Ui.SPACE()),Oa)]),Aa=O.constant({}),Ba=O.constant({}),Ra=mu(Ca,Mo,Ma,Aa,Ba,y.some(function(e,t,n){Pi(e.element(),t.selector()).each(function(n){t.focusManager().set(e,n)})})),Ia=[$r("onSpace"),$r("onEnter"),$r("onShiftEnter"),$r("onLeft"),$r("onRight"),$r("onTab"),$r("onShiftTab"),$r("onUp"),$r("onDown"),$r("onEscape"),jt("focusIn")],Fa=O.constant({}),Na=O.constant({}),Va=mu(Ia,Mo,function(n,e,t){return[Zi(Ki(Ui.SPACE()),t.onSpace()),Zi(Xi([Qi,Ki(Ui.ENTER())]),t.onEnter()),Zi(Xi([Yi,Ki(Ui.ENTER())]),t.onShiftEnter()),Zi(Xi([Yi,Ki(Ui.TAB())]),t.onShiftTab()),Zi(Xi([Qi,Ki(Ui.TAB())]),t.onTab()),Zi(Ki(Ui.UP()),t.onUp()),Zi(Ki(Ui.DOWN()),t.onDown()),Zi(Ki(Ui.LEFT()),t.onLeft()),Zi(Ki(Ui.RIGHT()),t.onRight()),Zi(Ki(Ui.SPACE()),t.onSpace()),Zi(Ki(Ui.ESCAPE()),t.onEscape())]},Fa,Na,y.some(function(e,t){return t.focusIn().bind(function(n){return n(e,t)})})),Ha={acyclic:pu.schema(),cyclic:vu.schema(),flow:ca.schema(),flatgrid:Zu.schema(),matrix:ka.schema(),execution:Tu.schema(),menu:Ra.schema(),special:Va.schema()},ja=(Mi=Yt("Creating behaviour: "+(Di={branchKey:"mode",branches:Ha,name:"keying",active:{events:function(n,e){return n.handler().toEvents(n,e)}},apis:{focusIn:function(n){n.getSystem().triggerFocus(n.element(),n.element())},setGridSize:function(n,e,t,o,r){pt(t,"setGridSize")?t.setGridSize(o,r):console.error("Layout does not support setGridSize")}},state:Cu}).name,Fo,Di),xo(Zt(Mi.branchKey,Mi.branches),Mi.name,Mi.active,Mi.apis,Mi.extra,Mi.state)),za=function(o,n){return e=o,t={},r=vn.map(n,function(n){return e=n.name(),t="Cannot configure "+n.name()+" for "+o,It(e,e,Je(),Ot(function(n){return qe.error("The field: "+e+" is forbidden. "+t)}));var e,t}).concat([Ut("dump",O.identity)]),It(e,e,Xe(t),Dt(r));var e,t,r},La=function(n){return n.dump()},Pa="placeholder",Wa=_e([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),Ua=function(n,e,t,o){return t.uiType===Pa?(i=t,u=o,(r=n).exists(function(n){return n!==i.owner})?Wa.single(!0,O.constant(i)):lt(u,i.name).fold(function(){throw new Error("Unknown placeholder component: "+i.name+"\nKnown: ["+M.keys(u)+"]\nNamespace: "+r.getOr("none")+"\nSpec: "+yt(i,null,2))},function(n){return n.replace()})):Wa.single(!1,O.constant(t));var r,i,u},Ga=function(i,u,a,c){return Ua(i,0,a,c).fold(function(n,e){var t=e(u,a.config,a.validated),o=lt(t,"components").getOr([]),r=vn.bind(o,function(n){return Ga(i,u,n,c)});return[D.deepMerge(t,{components:r})]},function(n,e){return e(u,a.config,a.validated)})},$a=function(e,t,n,o){var r,i,u,a,c=M.map(o,function(n,e){return t=e,o=n,r=!1,{name:O.constant(t),required:function(){return o.fold(function(n,e){return n},function(n,e){return n})},used:function(){return r},replace:function(){if(!0===r)throw new Error("Trying to use the same placeholder more than once: "+t);return r=!0,o}};var t,o,r}),s=(r=e,i=t,u=n,a=c,vn.bind(u,function(n){return Ga(r,i,n,a)}));return M.each(c,function(n){if(!1===n.used()&&n.required())throw new Error("Placeholder: "+n.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+yt(t.components(),null,2))}),s},qa=Wa.single,_a=Wa.multiple,Ka=O.constant(Pa),Xa=0,Ya=function(n){var e=(new Date).getTime();return n+"_"+Math.floor(1e9*Math.random())+ ++Xa+String(e)},Ja=_e([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),Qa=Pt("factory",{sketch:O.identity}),Za=Pt("schema",[]),nc=Ft("name"),ec=It("pname","pname",Qe(function(n){return"<alloy."+Ya(n.name)+">"}),no()),tc=Pt("defaults",O.constant({})),oc=Pt("overrides",O.constant({})),rc=Dt([Qa,Za,nc,ec,tc,oc]),ic=Dt([Qa,Za,nc,tc,oc]),uc=Dt([Qa,Za,nc,ec,tc,oc]),ac=Dt([Qa,Za,nc,Ft("unit"),ec,tc,oc]),cc=function(n){var e=function(n){return n.name()};return n.fold(e,e,e,e)},sc=function(t,o){return function(n){var e=Jt("Converting part type",o,n);return t(e)}},fc=sc(Ja.required,rc),lc=(sc(Ja.external,ic),sc(Ja.optional,uc)),dc=sc(Ja.group,ac),mc=O.constant("entirety"),gc=function(n,e,t,o){var r=t;return D.deepMerge(e.defaults()(n,t,o),t,{uid:n.partUids()[e.name()]},e.overrides()(n,t,o),{"debug.sketcher":dt("part-"+e.name(),r)})},pc=function(r,n){var i={};return vn.each(n,function(n){var e;(e=n,e.fold(y.some,y.none,y.some,y.some)).each(function(t){var o=vc(r,t.pname());i[t.name()]=function(n){var e=Yt("Part: "+t.name()+" in "+r,Dt(t.schema()),n);return D.deepMerge(o,{config:n,validated:e})}})}),i},vc=function(n,e){return{uiType:Ka(),owner:n,name:e}},hc=function(n,e,t){return o=e,r=t,i={},u={},vn.each(r,function(n){n.fold(function(o){i[o.pname()]=qa(!0,function(n,e,t){return o.factory().sketch(gc(n,o,e,t))})},function(n){var e=o.parts()[n.name()]();u[n.name()]=O.constant(gc(o,n,e[mc()]()))},function(o){i[o.pname()]=qa(!1,function(n,e,t){return o.factory().sketch(gc(n,o,e,t))})},function(r){i[r.pname()]=_a(!0,function(e,n,t){var o=e[r.name()]();return vn.map(o,function(n){return r.factory().sketch(D.deepMerge(r.defaults()(e,n),n,r.overrides()(e,n)))})})})}),{internals:O.constant(i),externals:O.constant(u)};var o,r,i,u},bc=function(n,e,t){return $a(y.some(n),e,e.components(),t)},yc=function(n,e,t){var o=e.partUids()[t];return n.getSystem().getByUid(o).toOption()},wc=function(n,e,t){return yc(n,e,t).getOrDie("Could not find part: "+t)},xc=function(e,n){var t,o=(t=n,vn.map(t,cc));return mt(vn.map(o,function(n){return{key:n,value:e+"-"+n}}))},Sc=function(e){return It("partUids","partUids",Ze(function(n){return xc(n.uid,e)}),no())},Tc=Ya("alloy-premade"),kc=Ya("api"),Cc=function(n){return dt(Tc,n)},Oc=function(o){return function(n){var e=Array.prototype.slice.call(arguments,0),t=n.config(kc);return o.apply(undefined,[t].concat(e))}},Ec=O.constant(kc),Dc=O.constant("alloy-id-"),Mc=O.constant("data-alloy-id"),Ac=Dc(),Bc=Mc(),Rc=function(n,e){var t=Ya(Ac+n);return Po.set(e,Bc,t),t},Ic=function(n){var e=ue.isElement(n)?Po.get(n,Bc):null;return y.from(e)},Fc=function(n){return Ya(n)},Nc=(O.constant(Bc),function(n,e,t,o,r){var i,u,a=(u=r,(0<(i=o).length?[Ht("parts",i)]:[]).concat([Ft("uid"),Pt("dom",{}),Pt("components",[]),Xr("originalSpec"),Pt("debug.sketcher",{})]).concat(u));return Jt(n+" [SpecSchema]",Et(a.concat(e)),t)}),Vc=function(n,e,t,o,r){var i,u=Hc(r),a=(i=t,vn.bind(i,function(n){return n.fold(y.none,y.some,y.none,y.none).map(function(n){return Ht(n.name(),n.schema().concat([Xr(mc())]))}).toArray()})),c=Sc(t),s=Nc(n,e,u,a,[c]),f=hc(0,s,t),l=bc(n,s,f.internals());return D.deepMerge(o(s,l,u,f.externals()),{"debug.sketcher":dt(n,r)})},Hc=function(n){return D.deepMerge({uid:Fc("uid")},n)},jc=Et([Ft("name"),Ft("factory"),Ft("configFields"),Pt("apis",{}),Pt("extraApis",{})]),zc=Et([Ft("name"),Ft("factory"),Ft("configFields"),Ft("partFields"),Pt("apis",{}),Pt("extraApis",{})]),Lc=function(n){var a=Yt("Sketcher for "+n.name,jc,n),e=M.map(a.apis,Oc),t=M.map(a.extraApis,function(n,e){return po(n)});return D.deepMerge({name:O.constant(a.name),partFields:O.constant([]),configFields:O.constant(a.configFields),sketch:function(n){return e=a.name,t=a.configFields,o=a.factory,i=Hc(r=n),u=Nc(e,t,i,[],[]),D.deepMerge(o(u,i),{"debug.sketcher":dt(e,r)});var e,t,o,r,i,u}},e,t)},Pc=function(n){var e=Yt("Sketcher for "+n.name,zc,n),t=pc(e.name,e.partFields),o=M.map(e.apis,Oc),r=M.map(e.extraApis,function(n,e){return po(n)});return D.deepMerge({name:O.constant(e.name),partFields:O.constant(e.partFields),configFields:O.constant(e.configFields),sketch:function(n){return Vc(e.name,e.configFields,e.partFields,e.factory,n)},parts:O.constant(t)},o,r)},Wc=Lc({name:"Button",factory:function(n,e){var t,o,r,i=(t=n.action(),o=function(n,e){e.stop(),$n(n)},r=Mn.detect().deviceType.isTouch()?[io(Vn(),o)]:[io(H(),o),io(A(),function(n,e){e.cut()})],oo(vn.flatten([t.map(function(t){return io(Fn(),function(n,e){t(n),e.stop()})}).toArray(),r]))),u=lt(n.dom(),"attributes").bind(st("type")),a=lt(n.dom(),"tag");return{uid:n.uid(),dom:n.dom(),components:n.components(),events:i,behaviours:D.deepMerge(Bo([yi.config({}),ja.config({mode:"execution",useSpace:!0,useEnter:!0})]),La(n.buttonBehaviours())),domModification:{attributes:D.deepMerge(u.fold(function(){return a.is("button")?{type:"button"}:{}},function(n){return{}}),{role:n.role().getOr("button")})},eventOrder:n.eventOrder()}},configFields:[Pt("uid",undefined),Ft("dom"),Pt("components",[]),za("buttonBehaviours",[yi,ja]),jt("action"),jt("role"),Pt("eventOrder",{})]}),Uc=Object.freeze({events:function(n){return oo([ro(z(),O.constant(!0))])},exhibit:function(n,e){return bo({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})}}),Gc=Io({fields:[],name:"unselecting",active:Uc}),$c=function(n){var e,t,o,r=Xn.fromHtml(n),i=Be.children(r),u=(t=(e=r).dom().attributes!==undefined?e.dom().attributes:[],vn.foldl(t,function(n,e){return"class"===e.name?n:D.deepMerge(n,dt(e.name,e.value))},{})),a=(o=r,Array.prototype.slice.call(o.dom().classList,0)),c=0===i.length?{}:{innerHtml:Cr(r)};return D.deepMerge({tag:ue.name(r),classes:a,attributes:u},c)},qc=function(n){var e=wn(n,{prefix:gi.prefix()});return $c(e)},_c=function(n){return{dom:qc(n)}},Kc=function(n){return Bo([si.config({toggleClass:gi.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),fi(n,function(n,e){(e?si.on:si.off)(n)})])},Xc=function(n,e,t){return Wc.sketch({dom:qc('<span class="${prefix}-toolbar-button ${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:e,buttonBehaviours:D.deepMerge(Bo([Gc.config({})]),t)})},Yc={forToolbar:Xc,forToolbarCommand:function(n,e){return Xc(e,function(){n.execCommand(e)},{})},forToolbarStateAction:function(n,e,t,o){var r=Kc(t);return Xc(e,o,r)},forToolbarStateCommand:function(n,e){var t=Kc(e);return Xc(e,function(){n.execCommand(e)},t)}},Jc=function(n,e,t){return Math.max(e,Math.min(t,n))},Qc=function(n,e,t,o,r,i,u){var a=t-e;if(o<n.left)return e-1;if(o>n.right)return t+1;var c,s,f,l,d=Math.min(n.right,Math.max(o,n.left))-n.left,m=Jc(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=r,u.fold(function(){var n=c-s,e=Math.round(n/l)*l;return Jc(s+e,s-1,f+1)},function(n){var e=(c-n)%l,t=Math.round(e/l),o=Math.floor((c-n)/l),r=Math.floor((f-n)/l),i=n+Math.min(r,o+t)*l;return Math.max(n,i)})):g},Zc="slider.change.value",ns=Mn.detect().deviceType.isTouch(),es=function(n){var e;return(e=n.event().raw(),ns&&e.touches!==undefined&&1===e.touches.length?y.some(e.touches[0]):ns&&e.touches!==undefined?y.none():ns||e.clientX===undefined?y.none():y.some(e)).map(function(n){return n.clientX})},ts=function(n,e){Gn(n,Zc,{value:e})},os=function(i,u,a,n){return es(n).map(function(n){var e,t,o,r;return e=i,o=n,r=Qc(a,(t=u).min(),t.max(),o,t.stepSize(),t.snapToGrid(),t.snapStart()),ts(e,r),n})},rs=function(n,e){var t,o,r,i,u=(t=e.value().get(),o=e.min(),r=e.max(),i=e.stepSize(),t<o?t:r<t?r:t===o?o-1:Math.max(o,t-i));ts(n,u)},is=function(n,e){var t,o,r,i,u=(t=e.value().get(),o=e.min(),r=e.max(),i=e.stepSize(),r<t?t:t<o?o:t===r?r+1:Math.min(r,t+i));ts(n,u)},us=O.constant(Zc),as=Mn.detect().deviceType.isTouch(),cs=function(n,o){return lc({name:n+"-edge",overrides:function(n){var e=oo([uo(T(),o,[n])]),t=oo([uo(A(),o,[n]),uo(B(),function(n,e){e.mouseIsDown().get()&&o(n,e)},[n])]);return{events:as?e:t}}})},ss=[cs("left",function(n,e){ts(n,e.min()-1)}),cs("right",function(n,e){ts(n,e.max()+1)}),fc({name:"thumb",defaults:O.constant({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:oo([co(T(),n,"spectrum"),co(k(),n,"spectrum"),co(C(),n,"spectrum")])}}}),fc({schema:[Ut("mouseIsDown",function(){return ur(!1)})],name:"spectrum",overrides:function(o){var t=function(n,e){var t=n.element().dom().getBoundingClientRect();os(n,o,t,e)},n=oo([io(T(),t),io(k(),t)]),e=oo([io(A(),t),io(B(),function(n,e){o.mouseIsDown().get()&&t(n,e)})]);return{behaviours:Bo(as?[]:[ja.config({mode:"special",onLeft:function(n){return rs(n,o),y.some(!0)},onRight:function(n){return is(n,o),y.some(!0)}}),yi.config({})]),events:as?n:e}}})],fs=function(n,e,t){e.store().manager().onLoad(n,e,t)},ls=function(n,e,t){e.store().manager().onUnload(n,e,t)},ds=Object.freeze({onLoad:fs,onUnload:ls,setValue:function(n,e,t,o){e.store().manager().setValue(n,e,t,o)},getValue:function(n,e,t){return e.store().manager().getValue(n,e,t)}}),ms=Object.freeze({events:function(t,o){var n=t.resetOnDom()?[fo(function(n,e){fs(n,t,o)}),lo(function(n,e){ls(n,t,o)})]:[wo(t,o,fs)];return oo(n)}}),gs=function(){var n=ur(null);return Do({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()}}})},ps=function(){var n=ur({});return Do({readState:function(){return{mode:"dataset",dataset:n.get()}},set:n.set,get:n.get})},vs=Object.freeze({memory:gs,dataset:ps,manual:function(){return Do({readState:function(){}})},init:function(n){return n.store().manager().state(n)}}),hs=function(n,e,t,o){e.store().getDataKey(),t.set({}),e.store().setData()(n,o),e.onSetValue()(n,o)},bs=[jt("initialValue"),Ft("getFallbackEntry"),Ft("getDataKey"),Ft("setData"),Kr("manager",{setValue:hs,getValue:function(n,e,t){var o=e.store().getDataKey()(n),r=t.get();return lt(r,o).fold(function(){return e.store().getFallbackEntry()(o)},function(n){return n})},onLoad:function(e,t,o){t.store().initialValue().each(function(n){hs(e,t,o,n)})},onUnload:function(n,e,t){t.set({})},state:ps})],ys=[Ft("getValue"),Pt("setValue",O.noop),jt("initialValue"),Kr("manager",{setValue:function(n,e,t,o){e.store().setValue()(n,o),e.onSetValue()(n,o)},getValue:function(n,e,t){return e.store().getValue()(n)},onLoad:function(e,t,n){t.store().initialValue().each(function(n){t.store().setValue()(e,n)})},onUnload:O.noop,state:Mo})],ws=[jt("initialValue"),Kr("manager",{setValue:function(n,e,t,o){t.set(o),e.onSetValue()(n,o)},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:gs})],xs=[Wt("store",{mode:"memory"},Zt("mode",{memory:ws,manual:ys,dataset:bs})),Gr("onSetValue"),Pt("resetOnDom",!1)],Ss=Io({fields:xs,name:"representing",active:ms,apis:ds,extra:{setValueFrom:function(n,e){var t=Ss.getValue(e);Ss.setValue(n,t)}},state:vs}),Ts=Mn.detect().deviceType.isTouch(),ks=[Ft("min"),Ft("max"),Pt("stepSize",1),Pt("onChange",O.noop),Pt("onInit",O.noop),Pt("onDragStart",O.noop),Pt("onDragEnd",O.noop),Pt("snapToGrid",!1),jt("snapStart"),Ft("getInitialValue"),za("sliderBehaviours",[ja,Ss]),Ut("value",function(n){return ur(n.min)})].concat(Ts?[]:[Ut("mouseIsDown",function(){return ur(!1)})]),Cs=Ei("width",function(n){return n.dom().offsetWidth}),Os=function(n,e){Cs.set(n,e)},Es=function(n){return Cs.get(n)},Ds=Mn.detect().deviceType.isTouch(),Ms=Pc({name:"Slider",configFields:ks,partFields:ss,factory:function(c,n,e,t){var s=c.max()-c.min(),f=function(n){var e=n.element().dom().getBoundingClientRect();return(e.left+e.right)/2},r=function(n){return wc(n,c,"thumb")},i=function(n){var e,t,o,r,i=wc(n,c,"spectrum").element().dom().getBoundingClientRect(),u=n.element().dom().getBoundingClientRect(),a=(e=n,t=i,(r=(o=c).value().get())<o.min()?yc(e,o,"left-edge").fold(function(){return 0},function(n){return f(n)-t.left}):r>o.max()?yc(e,o,"right-edge").fold(function(){return t.width},function(n){return f(n)-t.left}):(o.value().get()-o.min())/s*t.width);return i.left-u.left+a},u=function(n){var e=i(n),t=r(n),o=Es(t.element())/2;Oi.set(t.element(),"left",e-o+"px")},o=function(n,e){var t=c.value().get(),o=r(n);return t!==e||Oi.getRaw(o.element(),"left").isNone()?(c.value().set(e),u(n),c.onChange()(n,o,e),y.some(!0)):y.none()},a=Ds?[io(T(),function(n,e){c.onDragStart()(n,r(n))}),io(C(),function(n,e){c.onDragEnd()(n,r(n))})]:[io(A(),function(n,e){e.stop(),c.onDragStart()(n,r(n)),c.mouseIsDown().set(!0)}),io(R(),function(n,e){c.onDragEnd()(n,r(n)),c.mouseIsDown().set(!1)})];return{uid:c.uid(),dom:c.dom(),components:n,behaviours:D.deepMerge(Bo(vn.flatten([Ds?[]:[ja.config({mode:"special",focusIn:function(n){return yc(n,c,"spectrum").map(ja.focusIn).map(O.constant(!0))}})],[Ss.config({store:{mode:"manual",getValue:function(n){return c.value().get()}}})]])),La(c.sliderBehaviours())),events:oo([io(us(),function(n,e){o(n,e.event().value())}),fo(function(n,e){c.value().set(c.getInitialValue()());var t=r(n);u(n),c.onInit()(n,t,c.value().get())})].concat(a)),apis:{resetToMin:function(n){o(n,c.min())},resetToMax:function(n){o(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)}}}),As=function(e,t,o){return Yc.forToolbar(t,function(){var n=o();e.setContextToolbar([{label:t+" group",items:n}])},{})},Bs=function(n){return[(r=n,i=function(n){return n<0?"black":360<n?"white":"hsl("+n+", 100%, 50%)"},Ms.sketch({dom:qc('<div class="${prefix}-slider ${prefix}-hue-slider-container"></div>'),components:[Ms.parts()["left-edge"](_c('<div class="${prefix}-hue-slider-black"></div>')),Ms.parts().spectrum({dom:qc('<div class="${prefix}-slider-gradient-container"></div>'),components:[_c('<div class="${prefix}-slider-gradient"></div>')],behaviours:Bo([si.config({toggleClass:gi.resolve("thumb-active")})])}),Ms.parts()["right-edge"](_c('<div class="${prefix}-hue-slider-white"></div>')),Ms.parts().thumb({dom:qc('<div class="${prefix}-slider-thumb"></div>'),behaviours:Bo([si.config({toggleClass:gi.resolve("thumb-active")})])})],onChange:function(n,e,t){var o=i(t);Oi.set(e.element(),"background-color",o),r.onChange(n,e,o)},onDragStart:function(n,e){si.on(e)},onDragEnd:function(n,e){si.off(e)},onInit:function(n,e,t){var o=i(t);Oi.set(e.element(),"background-color",o)},stepSize:10,min:0,max:360,getInitialValue:r.getInitialValue,sliderBehaviours:Bo([li(Ms.refresh)])}))];var r,i},Rs=function(n,o){var e={onChange:function(n,e,t){o.undoManager.transact(function(){o.formatter.apply("forecolor",{value:t}),o.nodeChanged()})},getInitialValue:function(){return-1}};return As(n,"color",function(){return Bs(e)})},Is=Et([Ft("getInitialValue"),Ft("onChange"),Ft("category"),Ft("sizes")]),Fs=function(n){var r=Yt("SizeSlider",Is,n);return Ms.sketch({dom:{tag:"div",classes:[gi.resolve("slider-"+r.category+"-size-container"),gi.resolve("slider"),gi.resolve("slider-size-container")]},onChange:function(n,e,t){var o;0<=(o=t)&&o<r.sizes.length&&r.onChange(t)},onDragStart:function(n,e){si.on(e)},onDragEnd:function(n,e){si.off(e)},min:0,max:r.sizes.length-1,stepSize:1,getInitialValue:r.getInitialValue,snapToGrid:!0,sliderBehaviours:Bo([li(Ms.refresh)]),components:[Ms.parts().spectrum({dom:qc('<div class="${prefix}-slider-size-container"></div>'),components:[_c('<div class="${prefix}-slider-size-line"></div>')]}),Ms.parts().thumb({dom:qc('<div class="${prefix}-slider-thumb"></div>'),behaviours:Bo([si.config({toggleClass:gi.resolve("thumb-active")})])})]})},Ns=function(n,e,t){for(var o=n.dom(),r=E.isFunction(t)?t:O.constant(!1);o.parentNode;){o=o.parentNode;var i=Xn.fromDom(o),u=e(i);if(u.isSome())return u;if(r(i))break}return y.none()},Vs=function(n,e,t){return e(n).orThunk(function(){return t(n)?y.none():Ns(n,e,t)})},Hs=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],js=function(n){var e,t,o=n.selection.getStart(),r=Xn.fromDom(o),i=Xn.fromDom(n.getBody()),u=(e=function(n){return Te(i,n)},t=r,(ue.isElement(t)?y.some(t):Be.parent(t)).map(function(n){return Vs(n,function(n){return Oi.getRaw(n,"font-size")},e).getOrThunk(function(){return Oi.get(n,"font-size")})}).getOr(""));return vn.find(Hs,function(n){return u===n}).getOr("medium")},zs={candidates:O.constant(Hs),get:function(n){var e,t=js(n);return(e=t,vn.findIndex(Hs,function(n){return n===e})).getOr(2)},apply:function(o,n){var e;(e=n,y.from(Hs[e])).each(function(n){var e,t;t=n,js(e=o)!==t&&e.execCommand("fontSize",!1,t)})}},Ls=zs.candidates(),Ps=function(n){return[_c('<span class="${prefix}-toolbar-button ${prefix}-icon-small-font ${prefix}-icon"></span>'),(e=n,Fs({onChange:e.onChange,sizes:Ls,category:"font",getInitialValue:e.getInitialValue})),_c('<span class="${prefix}-toolbar-button ${prefix}-icon-large-font ${prefix}-icon"></span>')];var e},Ws=function(n){var e=n.uid!==undefined&&pt(n,"uid")?n.uid:Fc("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(y.none,y.some)},asSpec:function(){return D.deepMerge(n,{uid:e})}}};function Us(n,e){return $s(document.createElement("canvas"),n,e)}function Gs(n){return n.getContext("2d")}function $s(n,e,t){return n.width=e,n.height=t,n}var qs={create:Us,clone:function(n){var e;return Gs(e=Us(n.width,n.height)).drawImage(n,0,0),e},resize:$s,get2dContext:Gs,get3dContext:function(n){var e=null;try{e=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},_s={getWidth:function(n){return n.naturalWidth||n.width},getHeight:function(n){return n.naturalHeight||n.height}},Ks=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,o(r,this),o(u,this))},e=n.immediateFn||"function"==typeof setImmediate&&setImmediate||function(n){setTimeout(n,1)};function o(n,e){return function(){n.apply(e,arguments)}}var t=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};function i(o){var r=this;null!==this._state?e(function(){var n=r._state?o.onFulfilled:o.onRejected;if(null!==n){var e;try{e=n(r._value)}catch(t){return void o.reject(t)}o.resolve(e)}else(r._state?o.resolve:o.reject)(r._value)}):this._deferreds.push(o)}function r(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(o(e,n),o(r,this),o(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<e;n++)i.call(this,this._deferreds[n]);this._deferreds=null}function c(n,e,t,o){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof e?e:null,this.resolve=t,this.reject=o}function s(n,e,t){var o=!1;try{n(function(n){o||(o=!0,e(n))},function(n){o||(o=!0,t(n))})}catch(r){if(o)return;o=!0,t(r)}}return n.prototype["catch"]=function(n){return this.then(null,n)},n.prototype.then=function(t,o){var r=this;return new n(function(n,e){i.call(r,new c(t,o,n,e))})},n.all=function(){var c=Array.prototype.slice.call(1===arguments.length&&t(arguments[0])?arguments[0]:arguments);return new n(function(r,i){if(0===c.length)return r([]);var u=c.length;function a(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if("function"==typeof t)return void t.call(n,function(n){a(e,n)},i)}c[e]=n,0==--u&&r(c)}catch(o){i(o)}}for(var n=0;n<c.length;n++)a(n,c[n])})},n.resolve=function(e){return e&&"object"==typeof e&&e.constructor===n?e:new n(function(n){n(e)})},n.reject=function(t){return new n(function(n,e){e(t)})},n.race=function(r){return new n(function(n,e){for(var t=0,o=r.length;t<o;t++)r[t].then(n,e)})},n}();function Xs(){return new(he.getOrDie("FileReader"))}var Ys={atob:function(n){return he.getOrDie("atob")(n)},requestAnimationFrame:function(n){he.getOrDie("requestAnimationFrame")(n)}};function Js(a){return new Ks(function(n,e){var t=URL.createObjectURL(a),o=new Image,r=function(){o.removeEventListener("load",i),o.removeEventListener("error",u)};function i(){r(),n(o)}function u(){r(),e("Unable to load data of type "+a.type+": "+t)}o.addEventListener("load",i),o.addEventListener("error",u),o.src=t,o.complete&&i()})}function Qs(o){return new Ks(function(n,t){var e=new XMLHttpRequest;e.open("GET",o,!0),e.responseType="blob",e.onload=function(){200==this.status&&n(this.response)},e.onerror=function(){var n,e=this;t(0===this.status?((n=new Error("No access to download image")).code=18,n.name="SecurityError",n):new Error("Error "+e.status+" downloading image"))},e.send()})}function Zs(n){var e=n.split(","),t=/data:([^;]+)/.exec(e[0]);if(!t)return y.none();for(var o,r,i,u=t[1],a=e[1],c=Ys.atob(a),s=c.length,f=Math.ceil(s/1024),l=new Array(f),d=0;d<f;++d){for(var m=1024*d,g=Math.min(m+1024,s),p=new Array(g-m),v=m,h=0;v<g;++h,++v)p[h]=c[v].charCodeAt(0);l[d]=(o=p,new(he.getOrDie("Uint8Array"))(o))}return y.some((r=l,i={type:u},new(he.getOrDie("Blob"))(r,i)))}function nf(t){return new Ks(function(n,e){Zs(t).fold(function(){e("uri is not base64: "+t)},n)})}function ef(t){return new Ks(function(n){var e=new Xs;e.onloadend=function(){n(e.result)},e.readAsDataURL(t)})}var tf,of,rf,uf,af,cf,sf,ff,lf={blobToImage:Js,imageToBlob:function(n){var e=n.src;return 0===e.indexOf("data:")?nf(e):Qs(e)},blobToArrayBuffer:function(t){return new Ks(function(n){var e=new Xs;e.onloadend=function(){n(e.result)},e.readAsArrayBuffer(t)})},blobToDataUri:ef,blobToBase64:function(n){return ef(n).then(function(n){return n.split(",")[1]})},dataUriToBlobSync:Zs,canvasToBlob:function(n,t,o){return t=t||"image/png",HTMLCanvasElement.prototype.toBlob?new Ks(function(e){n.toBlob(function(n){e(n)},t,o)}):nf(n.toDataURL(t,o))},canvasToDataURL:function(n,e,t){return e=e||"image/png",n.then(function(n){return n.toDataURL(e,t)})},blobToCanvas:function(n){return Js(n).then(function(n){var e,t;return e=n,URL.revokeObjectURL(e.src),t=qs.create(_s.getWidth(n),_s.getHeight(n)),qs.get2dContext(t).drawImage(n,0,0),t})},uriToBlob:function(n){return 0===n.indexOf("blob:")?Qs(n):0===n.indexOf("data:")?nf(n):null}},df=function(n){return lf.blobToBase64(n)},mf=function(u){var e=Ws({dom:{tag:"input",attributes:{accept:"image/*",type:"file",title:""},styles:{visibility:"hidden",position:"absolute"}},events:oo([so(H()),io(V(),function(n,e){var t,o,r;(t=e,o=t.event(),r=o.raw().target.files||o.raw().dataTransfer.files,y.from(r[0])).each(function(n){var r,i;r=u,df(i=n).then(function(o){r.undoManager.transact(function(){var n=r.editorUpload.blobCache,e=n.create(Ya("mceu"),i,o);n.add(e);var t=r.dom.createHTML("img",{src:e.blobUri()});r.insertContent(t)})})})})])});return Wc.sketch({dom:qc('<span class="${prefix}-toolbar-button ${prefix}-icon-image ${prefix}-icon"></span>'),components:[e.asSpec()],action:function(n){e.get(n).element().dom().click()}})},gf=function(n){return n.dom().textContent},pf=function(n,e){n.dom().textContent=e},vf=function(n){return 0<n.length},hf=function(n){return n===undefined||null===n?"":n},bf=function(e,t,n){return n.text.filter(vf).fold(function(){return Po.get(n=e,"href")===gf(n)?y.some(t):y.none();var n},y.some)},yf=function(n){var e=Xn.fromDom(n.selection.getStart());return Wi(e,"a")},wf={getInfo:function(n){return yf(n).fold(function(){return{url:"",text:n.selection.getContent({format:"text"}),title:"",target:"",link:y.none()}},function(n){return t=gf(e=n),o=Po.get(e,"href"),r=Po.get(e,"title"),i=Po.get(e,"target"),{url:hf(o),text:t!==o?hf(t):"",title:hf(r),target:hf(i),link:y.some(e)};var e,t,o,r,i})},applyInfo:function(r,i){i.url.filter(vf).fold(function(){var e;e=r,i.link.bind(O.identity).each(function(n){e.execCommand("unlink")})},function(t){var n,e,o=(n=i,(e={}).href=t,n.title.filter(vf).each(function(n){e.title=n}),n.target.filter(vf).each(function(n){e.target=n}),e);i.link.bind(O.identity).fold(function(){var n=i.text.filter(vf).getOr(t);r.insertContent(r.dom.createHTML("a",o,r.dom.encode(n)))},function(e){var n=bf(e,t,i);Po.setAll(e,o),n.each(function(n){pf(e,n)})})})},query:yf},xf=Mn.detect(),Sf=function(n,e){var t=e.selection.getRng();n(),e.selection.setRng(t)},Tf=function(n,e){(xf.os.isAndroid()?Sf:O.apply)(e,n)},kf=function(n,e){var t,o;return{key:n,value:{config:{},me:(t=n,o=oo(e),Io({fields:[Ft("enabled")],name:t,active:{events:O.constant(o)}})),configAsRaw:O.constant({}),initialConfig:{},state:No()}}},Cf=Object.freeze({getCurrent:function(n,e,t){return e.find()(n)}}),Of=[Ft("find")],Ef=Io({fields:Of,name:"composing",apis:Cf}),Df=Lc({name:"Container",factory:function(n,e){return{uid:n.uid(),dom:D.deepMerge({tag:"div",attributes:{role:"presentation"}},n.dom()),components:n.components(),behaviours:La(n.containerBehaviours()),events:n.events(),domModification:n.domModification(),eventOrder:n.eventOrder()}},configFields:[Pt("components",[]),za("containerBehaviours",[]),Pt("events",{}),Pt("domModification",{}),Pt("eventOrder",{})]}),Mf=Lc({name:"DataField",factory:function(t,n){return{uid:t.uid(),dom:t.dom(),behaviours:D.deepMerge(Bo([Ss.config({store:{mode:"memory",initialValue:t.getInitialValue()()}}),Ef.config({find:y.some})]),La(t.dataBehaviours())),events:oo([fo(function(n,e){Ss.setValue(n,t.getInitialValue()())})])}},configFields:[Ft("uid"),Ft("dom"),Ft("getInitialValue"),za("dataBehaviours",[Ss,Ef])]}),Af=function(n,e){if(e===undefined)throw new Error("Value.set was undefined");n.dom().value=e},Bf=function(n){return n.dom().value},Rf=O.constant([jt("data"),Pt("inputAttributes",{}),Pt("inputStyles",{}),Pt("type","input"),Pt("tag","input"),Pt("inputClasses",[]),Gr("onSetValue"),Pt("styles",{}),jt("placeholder"),Pt("eventOrder",{}),za("inputBehaviours",[Ss,yi]),Pt("selectOnFocus",!0)]),If=Lc({name:"Input",configFields:Rf(),factory:function(n,e){return{uid:n.uid(),dom:(o=n,{tag:o.tag(),attributes:D.deepMerge(mt([{key:"type",value:o.type()}].concat(o.placeholder().map(function(n){return{key:"placeholder",value:n}}).toArray())),o.inputAttributes()),styles:o.inputStyles(),classes:o.inputClasses()}),components:[],behaviours:(t=n,D.deepMerge(Bo([Ss.config({store:{mode:"manual",initialValue:t.data().getOr(undefined),getValue:function(n){return Bf(n.element())},setValue:function(n,e){Bf(n.element())!==e&&Af(n.element(),e)}},onSetValue:t.onSetValue()}),yi.config({onFocus:!1===t.selectOnFocus()?O.noop:function(n){var e=n.element(),t=Bf(e);e.dom().setSelectionRange(0,t.length)}})]),La(t.inputBehaviours()))),eventOrder:n.eventOrder()};var t,o}}),Ff=Object.freeze({exhibit:function(n,e){return bo({attributes:mt([{key:e.tabAttr(),value:"true"}])})}}),Nf=[Pt("tabAttr","data-alloy-tabstop")],Vf=Io({fields:Nf,name:"tabstopping",active:Ff}),Hf=function(n,e){var t=Ws(If.sketch({placeholder:e,onSetValue:function(n,e){Un(n,N())},inputBehaviours:Bo([Ef.config({find:y.some}),Vf.config({}),ja.config({mode:"execution"})]),selectOnFocus:!1})),o=Ws(Wc.sketch({dom:qc('<button class="${prefix}-input-container-x ${prefix}-icon-cancel-circle ${prefix}-icon"></button>'),action:function(n){var e=t.get(n);Ss.setValue(e,"")}}));return{name:n,spec:Df.sketch({dom:qc('<div class="${prefix}-input-container"></div>'),components:[t.asSpec(),o.asSpec()],containerBehaviours:Bo([si.config({toggleClass:gi.resolve("input-container-empty")}),Ef.config({find:function(n){return y.some(t.get(n))}}),kf("input-clearing",[io(N(),function(n){var e=t.get(n);(0<Ss.getValue(e).length?si.off:si.on)(n)})])])})}},jf=["input","button","textarea"],zf=function(n,e,t){e.disabled()&&$f(n,e,t)},Lf=function(n){return vn.contains(jf,ue.name(n.element()))},Pf=function(n){Po.set(n.element(),"disabled","disabled")},Wf=function(n){Po.remove(n.element(),"disabled")},Uf=function(n){Po.set(n.element(),"aria-disabled","true")},Gf=function(n){Po.set(n.element(),"aria-disabled","false")},$f=function(e,n,t){n.disableClass().each(function(n){er.add(e.element(),n)}),(Lf(e)?Pf:Uf)(e)},qf=function(n){return Lf(n)?Po.has(n.element(),"disabled"):"true"===Po.get(n.element(),"aria-disabled")},_f=Object.freeze({enable:function(e,n,t){n.disableClass().each(function(n){er.remove(e.element(),n)}),(Lf(e)?Wf:Gf)(e)},disable:$f,isDisabled:qf,onLoad:zf}),Kf=Object.freeze({exhibit:function(n,e,t){return bo({classes:e.disabled()?e.disableClass().map(vn.pure).getOr([]):[]})},events:function(n,e){return oo([ro(Fn(),function(n,e){return qf(n)}),wo(n,e,zf)])}}),Xf=[Pt("disabled",!1),jt("disableClass")],Yf=Io({fields:Xf,name:"disabling",active:Kf,apis:_f}),Jf=[za("formBehaviours",[Ss])],Qf=function(n){return"<alloy.field."+n+">"},Zf=function(r,n,e){return D.deepMerge({"debug.sketcher":{Form:e},uid:r.uid(),dom:r.dom(),components:n,behaviours:D.deepMerge(Bo([Ss.config({store:{mode:"manual",getValue:function(n){var e,t,o=(e=r,t=n.getSystem(),M.map(e.partUids(),function(n,e){return O.constant(t.getByUid(n))}));return M.map(o,function(n,e){return n().bind(Ef.getCurrent).map(Ss.getValue)})},setValue:function(t,n){M.each(n,function(e,n){yc(t,r,n).each(function(n){Ef.getCurrent(n).each(function(n){Ss.setValue(n,e)})})})}}})]),La(r.formBehaviours())),apis:{getField:function(n,e){return yc(n,r,e).bind(Ef.getCurrent)}}})},nl=(Oc(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",o=Qf(n),r=e,{uiType:Ka(),owner:t,name:o,config:r,validated:{}};var t,o,r},record:function(){return i}}),t=n(e),o=e.record(),r=vn.map(o,function(n){return fc({name:n,pname:Qf(n)})});return Vc("form",Jf,r,Zf,t)}),el=function(n){var e=ur(y.none()),t=function(){e.get().each(n)};return{clear:function(){t(),e.set(y.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(y.some(n))}}},tl={destroyable:function(){return el(function(n){n.destroy()})},unbindable:function(){return el(function(n){n.unbind()})},api:function(){var e=ur(y.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(y.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(y.some(n))},run:function(n){e.get().each(n)}}},value:function(){var e=ur(y.none());return{clear:function(){e.set(y.none())},set:function(n){e.set(y.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}}},ol=function(n){return{xValue:n,points:[]}},rl=function(n,e){if(e===n.xValue)return n;var t=0<e-n.xValue?1:-1,o={direction:t,xValue:e};return{xValue:e,points:(0===n.points.length?[]:n.points[n.points.length-1].direction===t?n.points.slice(0,n.points.length-1):n.points).concat([o])}},il=function(n){if(0===n.points.length)return 0;var e=n.points[0].direction,t=n.points[n.points.length-1].direction;return-1===e&&-1===t?-1:1===e&&1===t?1:0},ul=function(n){var o="navigateEvent",e=Dt([Ft("fields"),Pt("maxFieldIndex",n.fields.length-1),Ft("onExecute"),Ft("getInitialValue"),Ut("state",function(){return{dialogSwipeState:tl.value(),currentScreen:ur(0)}})]),u=Yt("SerialisedDialog",e,n),r=function(e,n,t){return Wc.sketch({dom:qc('<span class="${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:function(n){Gn(n,o,{direction:e})},buttonBehaviours:Bo([Yf.config({disableClass:gi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,r){var i=Hi(n.element(),"."+gi.resolve("serialised-dialog-screen"));Pi(n.element(),"."+gi.resolve("serialised-dialog-chain")).each(function(o){0<=u.state.currentScreen.get()+r&&u.state.currentScreen.get()+r<i.length&&(Oi.getRaw(o,"left").each(function(n){var e=parseInt(n,10),t=Es(i[0]);Oi.set(o,"left",e-r*t+"px")}),u.state.currentScreen.set(u.state.currentScreen.get()+r))})},a=function(o){var n=Hi(o.element(),"input");y.from(n[u.state.currentScreen.get()]).each(function(n){o.getSystem().getByDom(n).each(function(n){var e,t;e=o,t=n.element(),e.getSystem().triggerFocus(t,e.element())})});var e=s.get(o);lu.highlightAt(e,u.state.currentScreen.get())},c=Ws(nl(function(t){return{dom:qc('<div class="${prefix}-serialised-dialog"></div>'),components:[Df.sketch({dom:qc('<div class="${prefix}-serialised-dialog-chain" style="left: 0px; position: absolute;"></div>'),components:vn.map(u.fields,function(n,e){return e<=u.maxFieldIndex?Df.sketch({dom:qc('<div class="${prefix}-serialised-dialog-screen"></div>'),components:vn.flatten([[r(-1,"previous",0<e)],[t.field(n.name,n.spec)],[r(1,"next",e<u.maxFieldIndex)]])}):t.field(n.name,n.spec)})})],formBehaviours:Bo([li(function(n,e){var t;t=e,Pi(n.element(),"."+gi.resolve("serialised-dialog-chain")).each(function(n){Oi.set(n,"left",-u.state.currentScreen.get()*t.width+"px")})}),ja.config({mode:"special",focusIn:function(n){a(n)},onTab:function(n){return i(n,1),y.some(!0)},onShiftTab:function(n){return i(n,-1),y.some(!0)}}),kf("form-events",[fo(function(e,n){u.state.currentScreen.set(0),u.state.dialogSwipeState.clear();var t=s.get(e);lu.highlightFirst(t),u.getInitialValue(e).each(function(n){Ss.setValue(e,n)})}),go(u.onExecute),io(j(),function(n,e){"left"===e.event().raw().propertyName&&a(n)}),io(o,function(n,e){var t=e.event().direction();i(n,t)})])])}})),s=Ws({dom:qc('<div class="${prefix}-dot-container"></div>'),behaviours:Bo([lu.config({highlightClass:gi.resolve("dot-active"),itemClass:gi.resolve("dot-item")})]),components:vn.bind(u.fields,function(n,e){return e<=u.maxFieldIndex?[_c('<div class="${prefix}-dot-item ${prefix}-icon-full-dot ${prefix}-icon"></div>')]:[]})});return{dom:qc('<div class="${prefix}-serializer-wrapper"></div>'),components:[c.asSpec(),s.asSpec()],behaviours:Bo([ja.config({mode:"special",focusIn:function(n){var e=c.get(n);ja.focusIn(e)}}),kf("serializer-wrapper-events",[io(T(),function(n,e){u.state.dialogSwipeState.set(ol(e.event().raw().touches[0].clientX))}),io(k(),function(n,e){u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(rl(n,e.event().raw().touches[0].clientX))})}),io(C(),function(o){u.state.dialogSwipeState.on(function(n){var e=c.get(o),t=-1*il(n);i(e,t)})})])])}},al=L(function(t,o){return[{label:"the link group",items:[ul({fields:[Hf("url","Type or paste URL"),Hf("text","Link text"),Hf("title","Link title"),Hf("target","Link target"),(n="link",{name:n,spec:Mf.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return y.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return y.some(wf.getInfo(o))},onExecute:function(n){var e=Ss.getValue(n);wf.applyInfo(o,e),t.restoreToolbar(),o.focus()}})]}];var n}),cl=[{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"}]}],sl={events:oo([(tf=Bn(),of=function(n,e){var t,o,r=e.event().originator(),i=e.event().target();return o=i,!(Te(t=r,n.element())&&!Te(t,o)&&(console.warn(Bn()+" did not get interpreted by the desired target. \nOriginator: "+Ar(r)+"\nTarget: "+Ar(i)+"\nCheck the "+Bn()+" event handlers"),1))},{key:tf,value:eo({can:of})})])},fl=O.identity,ll=Eo.exactly(["debugInfo","triggerFocus","triggerEvent","triggerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","build","getByUid","getByDom","broadcast","broadcastOn"]),dl=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+Ar(e().element())+" is not in context.")}};return ll({debugInfo:O.constant("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")})},ml=function(e,n){var t=vn.map(n,function(n){return It(n.name(),n.name(),Je(),Dt([Ft("config"),Pt("state",Ao)]))}),o=Kt("component.behaviours",Dt(t),e.behaviours).fold(function(n){throw new Error(Qt(n)+"\nComplete spec:\n"+yt(e,null,2))},O.identity);return{list:n,data:M.map(o,function(n){var e=n();return O.constant(e.map(function(n){return{config:n.config(),state:n.state().init(n.config())}}))})}},gl=function(n){return n.list},pl=function(n){return n.data},vl=function(n,r){var i={};return M.each(n,function(n,o){M.each(n,function(n,e){var t=ft(e,[])(i);i[e]=t.concat([r(o,n)])})}),i},hl=function(n,e){return{name:O.constant(n),modification:e}},bl=function(n,e,t){return 1<n.length?qe.error('Multiple behaviours have tried to change DOM "'+e+'". The guilty behaviours are: '+yt(vn.map(n,function(n){return n.name()}))+". At this stage, this is not supported. Future releases might provide strategies for resolving this."):0===n.length?qe.value({}):qe.value(n[0].modification().fold(function(){return{}},function(n){return dt(e,n)}))},yl=function(u,a){return vn.foldl(u,function(n,e){var t=e.modification().getOr({});return n.bind(function(i){var n=M.mapToArray(t,function(n,e){return i[e]!==undefined?(t=a,o=e,r=u,qe.error("Mulitple behaviours have tried to change the _"+o+'_ "'+t+'". The guilty behaviours are: '+yt(vn.bind(r,function(n){return n.modification().getOr({})[o]!==undefined?[n.name()]:[]}),null,2)+". This is not currently supported.")):qe.value(dt(e,n));var t,o,r});return gt(n,i)})},qe.value({})).map(function(n){return dt(a,n)})},wl={classes:function(n,e){var t=vn.bind(n,function(n){return n.modification().getOr([])});return qe.value(dt(e,t))},attributes:yl,styles:yl,domChildren:bl,defChildren:bl,innerHtml:bl,value:bl},xl=function(u,a,n,c){var e=n.slice(0);try{var t=e.sort(function(n,e){var t=n[a](),o=e[a](),r=c.indexOf(t),i=c.indexOf(o);if(-1===r)throw new Error("The ordering for "+u+" does not have an entry for "+t+".\nOrder specified: "+yt(c,null,2));if(-1===i)throw new Error("The ordering for "+u+" does not have an entry for "+o+".\nOrder specified: "+yt(c,null,2));return r<i?-1:i<r?1:0});return qe.value(t)}catch(o){return qe.error([o])}},Sl=function(n,e){return{handler:O.curry.apply(undefined,[n.handler].concat(e)),purpose:n.purpose}},Tl=function(n){return n.handler},kl=function(n,e){return{name:O.constant(n),handler:O.constant(e)}},Cl=function(n,e,t){var o,r,i,u=D.deepMerge(t,(o=e,r=n,i={},vn.each(o,function(n){i[n.name()]=n.handlers(r)}),i));return vl(u,kl)},Ol=function(n){var e,o=(e=n,E.isFunction(e)?{can:O.constant(!0),abort:O.constant(!1),run:e}:e);return function(n,e){var t=Array.prototype.slice.call(arguments,0);o.abort.apply(undefined,t)?e.stop():o.can.apply(undefined,t)&&o.run.apply(undefined,t)}},El=function(n,e,t){var o,r,i=e[t];return i?xl("Event: "+t,"name",n,i).map(function(n){var e=vn.map(n,function(n){return n.handler()});return to(e)}):(o=t,r=n,qe.error(["The event ("+o+') has more than one behaviour that listens to it.\nWhen this occurs, you must specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that can trigger it are: '+yt(vn.map(r,function(n){return n.name()}),null,2)]))},Dl=function(n,u){var e=M.mapToArray(n,function(r,i){return(1===r.length?qe.value(r[0].handler()):El(r,u,i)).map(function(n){var e,t=Ol(n),o=1<r.length?vn.filter(u,function(e){return vn.contains(r,function(n){return n.name()===e})}).join(" > "):r[0].name();return dt(i,(e=o,{handler:t,purpose:O.constant(e)}))})});return gt(e,{})},Ml=function(n){return Kt("custom.definition",Et([It("dom","dom",Ye(),Et([Ft("tag"),Pt("styles",{}),Pt("classes",[]),Pt("attributes",{}),jt("value"),jt("innerHtml")])),Ft("components"),Ft("uid"),Pt("events",{}),Pt("apis",O.constant({})),It("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"]},Ke.mergeWithThunk(O.constant(e))),no()),jt("domModification"),Xr("originalSpec"),Pt("debug.sketcher","unknown")]),n);var e},Al=function(n){var e,t={tag:n.dom().tag(),classes:n.dom().classes(),attributes:D.deepMerge((e=n,dt(Mc(),e.uid())),n.dom().attributes()),styles:n.dom().styles(),domChildren:vn.map(n.components(),function(n){return n.element()})};return vo(D.deepMerge(t,n.dom().innerHtml().map(function(n){return dt("innerHtml",n)}).getOr({}),n.dom().value().map(function(n){return dt("value",n)}).getOr({})))},Bl={add:function(e,n){vn.each(n,function(n){er.add(e,n)})},remove:function(e,n){vn.each(n,function(n){er.remove(e,n)})},toggle:function(e,n){vn.each(n,function(n){er.toggle(e,n)})},hasAll:function(e,n){return vn.forall(n,function(n){return er.has(e,n)})},hasAny:function(e,n){return vn.exists(n,function(n){return er.has(e,n)})},get:function(n){return Zo(n)?function(n){for(var e=n.dom().classList,t=new Array(e.length),o=0;o<e.length;o++)t[o]=e.item(o);return t}(n):Xo(n)}},Rl=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=ho(e),yt(n,null,2)));return e.domChildren().fold(function(){var n=e.defChildren().getOr([]);return vn.map(n,Fl)},function(n){return n});var n},Il=function(n){var e=Xn.fromTag(n.tag());Po.setAll(e,n.attributes().getOr({})),Bl.add(e,n.classes().getOr([])),Oi.setAll(e,n.styles().getOr({})),Or(e,n.innerHtml().getOr(""));var t=Rl(n);return Ne.append(e,t),n.value().each(function(n){Af(e,n)}),e},Fl=function(n){var e=vo(n);return Il(e)},Nl=function(n){var e,t,o,r=(t=lt(e=n,"behaviours").getOr({}),o=vn.filter(M.keys(t),function(n){return t[n]!==undefined}),vn.map(o,function(n){return e.behaviours[n].me}));return ml(n,r)},Vl=Eo.exactly(["getSystem","config","hasConfigured","spec","connect","disconnect","element","syncComponents","readState","components","events"]),Hl=function(t){var n,e,o,r,i,u,a,c,s,f,l=function(){return C},d=ur(dl(l)),m=Xt(Ml(D.deepMerge(t,{behaviours:undefined}))),g=Nl(t),p=gl(g),v=pl(g),h=Al(m),b={"alloy.base.modification":(n=m,n.domModification().fold(function(){return bo({})},bo))},y=function(e,n,t,o){var r=D.deepMerge({},n);vn.each(t,function(n){r[n.name()]=n.exhibit(e,o)});var i=vl(r,hl),u=M.map(i,function(n,e){return vn.bind(n,function(e){return e.modification().fold(function(){return[]},function(n){return[e]})})}),a=M.mapToArray(u,function(e,t){return lt(wl,t).fold(function(){return qe.error("Unknown field type: "+t)},function(n){return n(e,t)})});return gt(a,{}).map(bo)}(v,b,p,h).getOrDie(),w=(e=h,o=y,r=D.deepMerge({tag:e.tag(),classes:o.classes().getOr([]).concat(e.classes().getOr([])),attributes:D.merge(e.attributes().getOr({}),o.attributes().getOr({})),styles:D.merge(e.styles().getOr({}),o.styles().getOr({}))},o.innerHtml().or(e.innerHtml()).map(function(n){return dt("innerHtml",n)}).getOr({}),yo("domChildren",o.domChildren(),e.domChildren()),yo("defChildren",o.defChildren(),e.defChildren()),o.value().or(e.value()).map(function(n){return dt("value",n)}).getOr({})),vo(r)),x=Il(w),S={"alloy.base.behaviour":(i=m,i.events())},T=(u=v,a=m.eventOrder(),c=p,s=S,f=Cl(u,c,s),Dl(f,a)).getOrDie(),k=ur(m.components()),C=Vl({getSystem:d.get,config:function(n){if(n===Ec())return m.apis();var e=v;return(E.isFunction(e[n.name()])?e[n.name()]:function(){throw new Error("Could not find "+n.name()+" in "+yt(t,null,2))})()},hasConfigured:function(n){return E.isFunction(v[n.name()])},spec:O.constant(t),readState:function(n){return v[n]().map(function(n){return n.state.readState()}).getOr("not enabled")},connect:function(n){d.set(n)},disconnect:function(){d.set(dl(l))},element:O.constant(x),syncComponents:function(){var n=Be.children(x),e=vn.bind(n,function(n){return d.get().getByDom(n).fold(function(){return[]},function(n){return[n]})});k.set(e)},components:k.get,events:O.constant(T)});return C},jl=function(n){var e,t,o=fl(n),r=(e=o,t=ft("components",[])(e),vn.map(t,Pl)),i=D.deepMerge(sl,o,dt("components",r));return qe.value(Hl(i))},zl=function(n){var e=Xn.fromText(n);return Ll({element:e})},Ll=function(n){var t=Jt("external.component",Et([Ft("element"),jt("uid")]),n),e=ur(dl());t.uid().each(function(n){var e;e=t.element(),Po.set(e,Bc,n)});var o=Vl({getSystem:e.get,config:y.none,hasConfigured:O.constant(!1),connect:function(n){e.set(n)},disconnect:function(){e.set(dl(function(){return o}))},element:O.constant(t.element()),spec:O.constant(n),readState:O.constant("No state"),syncComponents:O.noop,components:O.constant([]),events:O.constant({})});return Cc(o)},Pl=function(e){return(n=e,lt(n,Tc)).fold(function(){var n=D.deepMerge({uid:Fc("")},e);return jl(n).getOrDie()},function(n){return n});var n},Wl=Cc,Ul="alloy.item-hover",Gl="alloy.item-focus",$l=function(n){(br(n.element()).isNone()||yi.isFocused(n))&&(yi.isFocused(n)||yi.focus(n),Gn(n,Ul,{item:n}))},ql=function(n){Gn(n,Gl,{item:n})},_l=O.constant(Ul),Kl=O.constant(Gl),Xl=[Ft("data"),Ft("components"),Ft("dom"),jt("toggling"),Pt("itemBehaviours",{}),Pt("ignoreFocus",!1),Pt("domModification",{}),Kr("builder",function(n){return{dom:D.deepMerge(n.dom(),{attributes:{role:n.toggling().isSome()?"menuitemcheckbox":"menuitem"}}),behaviours:D.deepMerge(Bo([n.toggling().fold(si.revoke,function(n){return si.config(D.deepMerge({aria:{mode:"checked"}},n))}),yi.config({ignore:n.ignoreFocus(),onFocus:function(n){ql(n)}}),ja.config({mode:"execution"}),Ss.config({store:{mode:"memory",initialValue:n.data()}})]),n.itemBehaviours()),events:oo([(e=Hn(),o=$n,io(e,function(e,t){e.getSystem().getByDom(t.event().target()).each(function(n){o(e,n,t)})})),so(A()),io(I(),$l),io(Nn(),yi.focus)]),components:n.components(),domModification:n.domModification()};var e,o})],Yl=[Ft("dom"),Ft("components"),Kr("builder",function(n){return{dom:n.dom(),components:n.components(),events:oo([(e=Nn(),io(e,function(n,e){e.stop()}))])};var e})],Jl=O.constant("item-widget"),Ql=O.constant([fc({name:"widget",overrides:function(e){return{behaviours:Bo([Ss.config({store:{mode:"manual",getValue:function(n){return e.data()},setValue:function(){}}})])}}})]),Zl=[Ft("uid"),Ft("data"),Ft("components"),Ft("dom"),Pt("autofocus",!1),Pt("domModification",{}),Sc(Ql()),Kr("builder",function(t){var n=hc(Jl(),t,Ql()),e=bc(Jl(),t,n.internals()),o=function(n){return yc(n,t,"widget").map(function(n){return ja.focusIn(n),n})},r=function(n,e){return hu(e.event().target())||t.autofocus()&&e.setSource(n.element()),y.none()};return D.deepMerge({dom:t.dom(),components:e,domModification:t.domModification(),events:oo([go(function(n,e){o(n).each(function(n){e.stop()})}),io(I(),$l),io(Nn(),function(n,e){t.autofocus()?o(n):yi.focus(n)})]),behaviours:Bo([Ss.config({store:{mode:"memory",initialValue:t.data()}}),yi.config({onFocus:function(n){ql(n)}}),ja.config({mode:"special",onLeft:r,onRight:r,onEscape:function(n,e){return yi.isFocused(n)||t.autofocus()?(t.autofocus()&&e.setSource(n.element()),y.none()):(yi.focus(n),y.some(!0))}})])})})],nd=Zt("type",{widget:Zl,item:Xl,separator:Yl}),ed=O.constant([dc({factory:{sketch:function(n){var e=Jt("menu.spec item",nd,n);return e.builder()(e)}},name:"items",unit:"item",defaults:function(n,e){var t=Fc("");return D.deepMerge({uid:t},e)},overrides:function(n,e){return{type:e.type,ignoreFocus:n.fakeFocus(),domModification:{classes:[n.markers().item()]}}}})]),td=O.constant([Ft("value"),Ft("items"),Ft("dom"),Ft("components"),Pt("eventOrder",{}),za("menuBehaviours",[lu,Ss,Ef,ja]),Wt("movement",{mode:"menu",moveOnTab:!0},Zt("mode",{grid:[Yr(),Kr("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers().item(),initSize:{numColumns:e.initSize().numColumns(),numRows:e.initSize().numRows()},focusManager:n.focusManager()}})],menu:[Pt("moveOnTab",!0),Kr("config",function(n,e){return{mode:"menu",selector:"."+n.markers().item(),moveOnTab:e.moveOnTab(),focusManager:n.focusManager()}})]})),Nt("markers",Pr()),Pt("fakeFocus",!1),Pt("focusManager",du()),Gr("onHighlight")]),od=(O.constant("menu"),O.constant("alloy.menu-focus")),rd=Pc({name:"Menu",configFields:td(),partFields:ed(),factory:function(n,e,t,o){return D.deepMerge({dom:D.deepMerge(n.dom(),{attributes:{role:"menu"}}),uid:n.uid(),behaviours:D.deepMerge(Bo([lu.config({highlightClass:n.markers().selectedItem(),itemClass:n.markers().item(),onHighlight:n.onHighlight()}),Ss.config({store:{mode:"memory",initialValue:n.value()}}),Ef.config({find:O.identity}),ja.config(n.movement().config()(n,n.movement()))]),La(n.menuBehaviours())),events:oo([io(Kl(),function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){lu.highlight(e,n),t.stop(),Gn(e,od(),{menu:e,item:n})})}),io(_l(),function(n,e){var t=e.event().item();lu.highlight(n,t)})]),components:e,eventOrder:n.eventOrder()})}}),id=function(n,e,t,o){var r=n.getSystem().build(o);Pe(n,r,t)},ud=function(n,e){return n.components()},ad=Object.freeze({append:function(n,e,t,o){id(n,0,Fe.append,o)},prepend:function(n,e,t,o){id(n,0,Fe.prepend,o)},remove:function(n,e,t,o){var r=ud(n,e);vn.find(r,function(n){return Te(o.element(),n.element())}).each(Ue)},set:function(e,n,t,o){var r,i,u,a,c,s;i=(r=e).components(),vn.each(i,We),He.empty(r.element()),r.syncComponents(),u=function(){var n=vn.map(o,e.getSystem().build);vn.each(n,function(n){Le(e,n)})},a=e.element(),c=Be.owner(a),s=hr(c).bind(function(e){var n=function(n){return Te(e,n)};return n(a)?y.some(a):lr.descendant(a,n)}),u(a),s.each(function(e){hr(c).filter(function(n){return Te(n,e)}).orThunk(function(){pr(e)})})},contents:ud}),cd=Io({fields:[],name:"replacing",apis:ad}),sd=function(t,o,r,n){return lt(r,n).bind(function(n){return lt(t,n).bind(function(n){var e=sd(t,o,r,n);return y.some([n].concat(e))})}).getOr([])},fd=function(n,e){var t={};M.each(n,function(n,e){vn.each(n,function(n){t[n]=e})});var o,r=e,i=(o=e,M.tupleMap(o,function(n,e){return{k:n,v:e}})),u=M.map(i,function(n,e){return[e].concat(sd(t,r,i,e))});return M.map(t,function(n){return lt(u,n).getOr([n])})},ld=O.constant("collapse-item"),dd=Lc({name:"TieredMenu",configFields:[_r("onExecute"),_r("onEscape"),qr("onOpenMenu"),qr("onOpenSubmenu"),Gr("onCollapseMenu"),Pt("openImmediately",!0),Ht("data",[Ft("primary"),Ft("menus"),Ft("expansions")]),Pt("fakeFocus",!1),Gr("onHighlight"),Gr("onHover"),Ht("markers",[Ft("backgroundMenu")].concat(zr()).concat(Lr())),Ft("dom"),Pt("navigateOnHover",!0),Pt("stayInDom",!1),za("tmenuBehaviours",[ja,lu,Ef,cd]),Pt("eventOrder",{})],apis:{collapseMenu:function(n,e){n.collapseMenu(e)}},factory:function(u,r){var a,c,s,f,l,n,i=function(o,n){return M.map(n,function(n,e){var t=rd.sketch(D.deepMerge(n,{value:e,items:n.items,markers:at(r.markers,["item","selectedItem"]),fakeFocus:u.fakeFocus(),onHighlight:u.onHighlight(),focusManager:u.fakeFocus()?{get:function(n){return lu.getHighlighted(n).map(function(n){return n.element()})},set:function(e,n){e.getSystem().getByDom(n).fold(O.noop,function(n){lu.highlight(e,n)})}}:du()}));return o.getSystem().build(t)})},d=(a=ur({}),c=ur({}),s=ur({}),f=ur(y.none()),l=ur(O.constant([])),{setContents:function(n,e,t,o){f.set(y.some(n)),a.set(t),c.set(e),l.set(o);var r=o(e),i=fd(r,t);s.set(i)},expand:function(t){return lt(a.get(),t).map(function(n){var e=lt(s.get(),t).getOr([]);return[n].concat(e)})},refresh:function(n){return lt(s.get(),n)},collapse:function(n){return lt(s.get(),n).bind(function(n){return 1<n.length?y.some(n.slice(1)):y.none()})},lookupMenu:n=function(n){return lt(c.get(),n)},otherMenus:function(n){var e=l.get()(c.get());return vn.difference(M.keys(e),n)},getPrimary:function(){return f.get().bind(n)},getMenus:function(){return c.get()},clear:function(){a.set({}),c.set({}),s.set({}),f.set(y.none())},isClear:function(){return f.get().isNone()}}),m=function(n){return Ss.getValue(n).value},g=function(n,e){return M.map(u.data().menus(),function(n,e){return vn.bind(n.items,function(n){return"separator"===n.type?[]:[n.data.value]})})},p=function(e,n){lu.highlight(e,n),lu.getHighlighted(n).orThunk(function(){return lu.getFirst(n)}).each(function(n){qn(e,n.element(),Nn())})},v=function(n,e){return Rr(vn.map(e,n.lookupMenu))},h=function(o,r,i){return y.from(i[0]).bind(r.lookupMenu).map(function(n){var e=v(r,i.slice(1));vn.each(e,function(n){er.add(n.element(),u.markers().backgroundMenu())}),se.inBody(n.element())||cd.append(o,Wl(n)),Bl.remove(n.element(),[u.markers().backgroundMenu()]),p(o,n);var t=v(r,r.otherMenus(i));return vn.each(t,function(n){Bl.remove(n.element(),[u.markers().backgroundMenu()]),u.stayInDom()||cd.remove(o,n)}),n})},b=function(e,t){var n=m(t);return d.expand(n).bind(function(n){return y.from(n[0]).bind(d.lookupMenu).each(function(n){se.inBody(n.element())||cd.append(e,Wl(n)),u.onOpenSubmenu()(e,t,n),lu.highlightFirst(n)}),h(e,d,n)})},o=function(e,t){var n=m(t);return d.collapse(n).bind(function(n){return h(e,d,n).map(function(n){return u.onCollapseMenu()(e,t,n),n})})},e=function(t){return function(e,n){return Wi(n.getSource(),"."+u.markers().item()).bind(function(n){return e.getSystem().getByDom(n).bind(function(n){return t(e,n)})})}},t=oo([io(od(),function(n,e){var t=e.event().menu();lu.highlight(n,t)}),go(function(e,n){var t=n.event().target();return e.getSystem().getByDom(t).bind(function(n){return 0===m(n).indexOf("collapse-item")?o(e,n):b(e,n).orThunk(function(){return u.onExecute()(e,n)})})}),fo(function(e,n){var t,o;(t=e,o=i(t,u.data().menus()),d.setContents(u.data().primary(),o,u.data().expansions(),function(n){return g(t,n)}),d.getPrimary()).each(function(n){cd.append(e,Wl(n)),u.openImmediately()&&(p(e,n),u.onOpenMenu()(e,n))})})].concat(u.navigateOnHover()?[io(_l(),function(n,e){var t,o,r=e.event().item();t=n,o=m(r),d.refresh(o).bind(function(n){return h(t,d,n)}),b(n,r),u.onHover()(n,r)})]:[]));return{uid:u.uid(),dom:u.dom(),behaviours:D.deepMerge(Bo([ja.config({mode:"special",onRight:e(function(n,e){return hu(e.element())?y.none():b(n,e)}),onLeft:e(function(n,e){return hu(e.element())?y.none():o(n,e)}),onEscape:e(function(n,e){return o(n,e).orThunk(function(){return u.onEscape()(n,e)})}),focusIn:function(e,n){d.getPrimary().each(function(n){qn(e,n.element(),Nn())})}}),lu.config({highlightClass:u.markers().selectedMenu(),itemClass:u.markers().menu()}),Ef.config({find:function(n){return lu.getHighlighted(n)}}),cd.config({})]),La(u.tmenuBehaviours())),eventOrder:u.eventOrder(),apis:{collapseMenu:function(e){lu.getHighlighted(e).each(function(n){lu.getHighlighted(n).each(function(n){o(e,n)})})}},events:t}},extraApis:{tieredData:function(n,e,t){return{primary:n,menus:e,expansions:t}},singleData:function(n,e){return{primary:n,menus:dt(n,e),expansions:{}}},collapseItem:function(n){return{value:Ya(ld()),text:n}}}}),md=function(n,e,t,o){return lt(e.routes(),o.start()).map(O.apply).bind(function(n){return lt(n,o.destination()).map(O.apply)})},gd=function(n,e,t,o){return md(0,e,0,o).bind(function(e){return e.transition().map(function(n){return{transition:O.constant(n),route:O.constant(e)}})})},pd=function(t,o,n){var e,r,i;(e=t,r=o,i=n,vd(e,r,i).bind(function(n){return gd(e,r,i,n)})).each(function(n){var e=n.transition();er.remove(t.element(),e.transitionClass()),Po.remove(t.element(),o.destinationAttr())})},vd=function(n,e,t){var o=n.element();return Po.has(o,e.destinationAttr())?y.some({start:O.constant(Po.get(n.element(),e.stateAttr())),destination:O.constant(Po.get(n.element(),e.destinationAttr()))}):y.none()},hd=function(n,e,t,o){pd(n,e,t),Po.has(n.element(),e.stateAttr())&&Po.get(n.element(),e.stateAttr())!==o&&e.onFinish()(n,o),Po.set(n.element(),e.stateAttr(),o)},bd=Object.freeze({findRoute:md,disableTransition:pd,getCurrentRoute:vd,jumpTo:hd,progressTo:function(t,o,r,i){var n,e;e=o,Po.has((n=t).element(),e.destinationAttr())&&(Po.set(n.element(),e.stateAttr(),Po.get(n.element(),e.destinationAttr())),Po.remove(n.element(),e.destinationAttr()));var u,a,c,s=(u=t,a=o,c=i,{start:O.constant(Po.get(u.element(),a.stateAttr())),destination:O.constant(c)});gd(t,o,r,s).fold(function(){hd(t,o,r,i)},function(n){pd(t,o,r);var e=n.transition();er.add(t.element(),e.transitionClass()),Po.set(t.element(),o.destinationAttr(),i)})},getState:function(n,e,t){var o=n.element();return Po.has(o,e.stateAttr())?y.some(Po.get(o,e.stateAttr())):y.none()}}),yd=Object.freeze({events:function(r,i){return oo([io(j(),function(t,n){var o=n.event().raw();vd(t,r,i).each(function(e){md(0,r,0,e).each(function(n){n.transition().each(function(n){o.propertyName===n.property()&&(hd(t,r,i,e.destination()),r.onTransition()(t,e))})})})}),fo(function(n,e){hd(n,r,i,r.initialState())})])}}),wd=[Pt("destinationAttr","data-transitioning-destination"),Pt("stateAttr","data-transitioning-state"),Ft("initialState"),Gr("onTransition"),Gr("onFinish"),Nt("routes",At(qe.value,At(qe.value,Et([Lt("transition",[Ft("property"),Ft("transitionClass")])]))))],xd=Io({fields:wd,name:"transitioning",active:yd,apis:bd,extra:{createRoutes:function(n){var o={};return M.each(n,function(n,e){var t=e.split("<->");o[t[0]]=dt(t[1],n),o[t[1]]=dt(t[0],n)}),o},createBistate:function(n,e,t){return mt([{key:n,value:dt(e,t)},{key:e,value:dt(n,t)}])},createTristate:function(n,e,t,o){return mt([{key:n,value:mt([{key:e,value:o},{key:t,value:o}])},{key:e,value:mt([{key:n,value:o},{key:t,value:o}])},{key:t,value:mt([{key:n,value:o},{key:e,value:o}])}])}}}),Sd=gi.resolve("scrollable"),Td={register:function(n){er.add(n,Sd)},deregister:function(n){er.remove(n,Sd)},scrollable:O.constant(Sd)},kd=function(n){return lt(n,"format").getOr(n.title)},Cd=function(n,e,t,o,r){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:r?[gi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:gi.resolve("format-matches"),selected:t},itemBehaviours:Bo(r?[]:[fi(n,function(n,e){(e?si.on:si.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:o},innerHtml:e}}]}},Od=function(n,e,t,o){return{value:n,dom:{tag:"div"},components:[Wc.sketch({dom:{tag:"div",classes:[gi.resolve("styles-collapser")]},components:o?[{dom:{tag:"span",classes:[gi.resolve("styles-collapse-icon")]}},zl(n)]:[zl(n)],action:function(n){if(o){var e=t().get(n);dd.collapseMenu(e)}}}),{dom:{tag:"div",classes:[gi.resolve("styles-menu-items-container")]},components:[rd.parts().items({})],behaviours:Bo([kf("adhoc-scrollable-menu",[fo(function(n,e){Oi.set(n.element(),"overflow-y","auto"),Oi.set(n.element(),"-webkit-overflow-scrolling","touch"),Td.register(n.element())}),lo(function(n){Oi.remove(n.element(),"overflow-y"),Oi.remove(n.element(),"-webkit-overflow-scrolling"),Td.deregister(n.element())})])])}],items:e,menuBehaviours:Bo([xd.config({initialState:"after",routes:xd.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},Ed=function(o){var r,i,n,e,t,u=(r=o.formats,i=function(){return a},n=Od("Styles",[].concat(vn.map(r.items,function(n){return Cd(kd(n),n.title,n.isSelected(),n.getPreview(),pt(r.expansions,kd(n)))})),i,!1),e=M.map(r.menus,function(n,e){var t=vn.map(n,function(n){return Cd(kd(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",pt(r.expansions,kd(n)))});return Od(e,t,i,!0)}),t=D.deepMerge(e,dt("styles",n)),{tmenu:dd.tieredData("styles",t,r.expansions)}),a=Ws(dd.sketch({dom:{tag:"div",classes:[gi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=Ss.getValue(e);o.handle(e,t.value)},onEscape:function(){},onOpenMenu:function(n,e){var t=Es(n.element());Os(e.element(),t),xd.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var o=Es(n.element()),r=Li(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(r).getOrDie();Os(t.element(),o),xd.progressTo(i,"before"),xd.jumpTo(t,"after"),xd.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var o=Li(e.element(),'[role="menu"]').getOrDie("hacky"),r=n.getSystem().getByDom(o).getOrDie();xd.progressTo(r,"after"),xd.progressTo(t,"current")},navigateOnHover:!1,openImmediately:!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 a.asSpec()},Dd=function(n){return pt(n,"items")?(e=n,t=D.deepMerge(ct(e,["items"]),{menu:!0}),o=Md(e.items),{item:t,menus:D.deepMerge(o.menus,dt(e.title,o.items)),expansions:D.deepMerge(o.expansions,dt(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,o},Md=function(n){return vn.foldr(n,function(n,e){var t=Dd(e);return{menus:D.deepMerge(n.menus,t.menus),items:[t.item].concat(n.items),expansions:D.deepMerge(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Ad={expand:Md},Bd=function(a,n){var c=function(n){return function(){return a.formatter.match(n)}},s=function(n){return function(){return a.formatter.getCssText(n)}},e=lt(n,"style_formats").getOr(cl),f=function(n){return vn.map(n,function(n){if(pt(n,"items")){var e=f(n.items);return D.deepMerge((u=n,D.deepMerge(u,{isSelected:O.constant(!1),getPreview:O.constant("")})),{items:e})}return pt(n,"format")?(i=n,D.deepMerge(i,{isSelected:c(i.format),getPreview:s(i.format)})):(o=Ya((t=n).title),r=D.deepMerge(t,{format:o,isSelected:c(o),getPreview:s(o)}),a.formatter.register(o,r),r);var t,o,r,i,u})};return f(e)},Rd=function(t,n,o){var e,r,i,u=(e=t,i=(r=function(n){return vn.bind(n,function(n){return n.items!==undefined?0<r(n.items).length?[n]:[]:!pt(n,"format")||e.formatter.canApply(n.format)?[n]:[]})})(n),Ad.expand(i));return Ed({formats:u,handle:function(n,e){t.undoManager.transact(function(){si.isOn(n)?t.formatter.remove(e):t.formatter.apply(e)}),o()}})},Id=["undo","bold","italic","link","image","bullist","styleselect"],Fd=function(n){var e=n.replace(/\|/g," ").trim();return 0<e.length?e.split(/\s+/):[]},Nd=function(n){return vn.bind(n,function(n){return E.isArray(n)?Nd(n):Fd(n)})},Vd=function(n){var e=n.toolbar!==undefined?n.toolbar:Id;return E.isArray(e)?Nd(e):Fd(e)},Hd=function(o,r){var n=function(n){return function(){return Yc.forToolbarCommand(r,n)}},e=function(n){return function(){return Yc.forToolbarStateCommand(r,n)}},t=function(n,e,t){return function(){return Yc.forToolbarStateAction(r,n,e,t)}},i=n("undo"),u=n("redo"),a=e("bold"),c=e("italic"),s=e("underline"),f=n("removeformat"),l=t("unlink","link",function(){r.execCommand("unlink",null,!1)}),d=t("unordered-list","ul",function(){r.execCommand("InsertUnorderedList",null,!1)}),m=t("ordered-list","ol",function(){r.execCommand("InsertOrderedList",null,!1)}),g=Bd(r,r.settings),p=function(){return Rd(r,g,function(){r.fire("scrollIntoView")})},v=function(n,e){return{isSupported:function(){return n.forall(function(n){return pt(r.buttons,n)})},sketch:e}};return{undo:v(y.none(),i),redo:v(y.none(),u),bold:v(y.none(),a),italic:v(y.none(),c),underline:v(y.none(),s),removeformat:v(y.none(),f),link:v(y.none(),function(){return e=o,t=r,Yc.forToolbarStateAction(t,"link","link",function(){var n=al(e,t);e.setContextToolbar(n),Tf(t,function(){e.focusToolbar()}),wf.query(t).each(function(n){t.selection.select(n.dom())})});var e,t}),unlink:v(y.none(),l),image:v(y.none(),function(){return mf(r)}),bullist:v(y.some("bullist"),d),numlist:v(y.some("numlist"),m),fontsizeselect:v(y.none(),function(){return e=r,n={onChange:function(n){zs.apply(e,n)},getInitialValue:function(){return zs.get(e)}},As(o,"font-size",function(){return Ps(n)});var e,n}),forecolor:v(y.none(),function(){return Rs(o,r)}),styleselect:v(y.none(),function(){return Yc.forToolbar("style-formats",function(n){r.fire("toReading"),o.dropup().appear(p,si.on,n)},Bo([si.config({toggleClass:gi.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Qr.config({channels:mt([di(Sr.orientationChanged(),si.off),di(Sr.dropupDismissed(),si.off)])})]))})}},jd=function(n,t){var e=Vd(n),o={};return vn.bind(e,function(n){var e=!pt(o,n)&&pt(t,n)&&t[n].isSupported()?[t[n].sketch()]:[];return o[n]=!0,e})},zd=function(m,g){return function(n){if(m(n)){var e,t,o,r,i,u,a,c=Xn.fromDom(n.target),s=function(){n.stopPropagation()},f=function(){n.preventDefault()},l=O.compose(f,s),d=(e=c,t=n.clientX,o=n.clientY,r=s,i=f,u=l,a=n,{target:O.constant(e),x:O.constant(t),y:O.constant(o),stop:r,prevent:i,kill:u,raw:O.constant(a)});g(d)}}},Ld=function(n,e,t,o,r){var i=zd(t,o);return n.dom().addEventListener(e,i,r),{unbind:O.curry(Pd,n,e,i,r)}},Pd=function(n,e,t,o){n.dom().removeEventListener(e,t,o)},Wd=function(n,e,t,o){return Ld(n,e,t,o,!1)},Ud=function(n,e,t,o){return Ld(n,e,t,o,!0)},Gd=O.constant(!0),$d={bind:function(n,e,t){return Wd(n,e,Gd,t)},capture:function(n,e,t){return Ud(n,e,Gd,t)}},qd=function(n){var e=n.matchMedia("(orientation: portrait)").matches;return{isPortrait:O.constant(e)}},_d=qd,Kd=function(o,e){var n=Xn.fromDom(o),r=null,t=$d.bind(n,"orientationchange",function(){clearInterval(r);var n=qd(o);e.onChange(n),i(function(){e.onReady(n)})}),i=function(n){clearInterval(r);var e=o.innerHeight,t=0;r=setInterval(function(){e!==o.innerHeight?(clearInterval(r),n(y.some(o.innerHeight))):20<t&&(clearInterval(r),n(y.none())),t++},50)};return{onAdjustment:i,destroy:function(){t.unbind()}}},Xd=function(n){var e=Mn.detect().os.isiOS(),t=qd(n).isPortrait();return e&&!t?n.screen.height:n.screen.width},Yd=function(n){return n.raw().touches===undefined||1!==n.raw().touches.length?y.none():y.some(n.raw().touches[0])},Jd=function(t){var o,r,i,u=ur(y.none()),a=(o=function(n){u.set(y.none()),t.triggerEvent(jn(),n)},r=400,i=null,{cancel:function(){null!==i&&(clearTimeout(i),i=null)},schedule:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=arguments;i=setTimeout(function(){o.apply(null,t),i=null},r)}}),c=mt([{key:T(),value:function(t){return Yd(t).each(function(n){a.cancel();var e={x:O.constant(n.clientX),y:O.constant(n.clientY),target:t.target};a.schedule(t),u.set(y.some(e))}),y.none()}},{key:k(),value:function(n){return a.cancel(),Yd(n).each(function(i){u.get().each(function(n){var e,t,o,r;e=i,t=n,o=Math.abs(e.clientX-t.x()),r=Math.abs(e.clientY-t.y()),(5<o||5<r)&&u.set(y.none())})}),y.none()}},{key:C(),value:function(e){return a.cancel(),u.get().filter(function(n){return Te(n.target(),e.target())}).map(function(n){return t.triggerEvent(Vn(),e)})}}]);return{fireIfReady:function(e,n){return lt(c,n).bind(function(n){return n(e)})}}},Qd=function(t){var e=Jd({triggerEvent:function(n,e){t.onTapContent(e)}});return{fireTouchstart:function(n){e.fireIfReady(n,"touchstart")},onTouchend:function(){return $d.bind(t.body(),"touchend",function(n){e.fireIfReady(n,"touchend")})},onTouchmove:function(){return $d.bind(t.body(),"touchmove",function(n){e.fireIfReady(n,"touchmove")})}}},Zd=6<=Mn.detect().os.version.major,nm=function(o,e,t){var r=Qd(o),i=Be.owner(e),u=function(n){return!Te(n.start(),n.finish())||n.soffset()!==n.foffset()},n=function(){var n=o.doc().dom().hasFocus()&&o.getSelection().exists(u);t.getByDom(e).each(!0===(n||hr(i).filter(function(n){return"input"===ue.name(n)}).exists(function(n){return n.dom().selectionStart!==n.dom().selectionEnd}))?si.on:si.off)},a=[$d.bind(o.body(),"touchstart",function(n){o.onTouchContent(),r.fireTouchstart(n)}),r.onTouchmove(),r.onTouchend(),$d.bind(e,"touchstart",function(n){o.onTouchToolstrip()}),o.onToReading(function(){vr(o.body())}),o.onToEditing(O.noop),o.onScrollToCursor(function(n){n.preventDefault(),o.getCursorBox().each(function(n){var e=o.win(),t=n.top()>e.innerHeight||n.bottom()>e.innerHeight?n.bottom()-e.innerHeight+50:0;0!==t&&e.scrollTo(e.pageXOffset,e.pageYOffset+t)})})].concat(!0===Zd?[]:[$d.bind(Xn.fromDom(o.win()),"blur",function(){t.getByDom(e).each(si.off)}),$d.bind(i,"select",n),$d.bind(o.doc(),"selectionchange",n)]);return{destroy:function(){vn.each(a,function(n){n.unbind()})}}},em=function(n,e){var t=parseInt(Po.get(n,e),10);return isNaN(t)?0:t},tm=(rf=ue.isText,uf="text",af=function(n){return rf(n)?y.from(n.dom().nodeValue):y.none()},cf=Mn.detect().browser,{get:function(n){if(!rf(n))throw new Error("Can only get "+uf+" value of a "+uf+" node");return sf(n).getOr("")},getOption:sf=cf.isIE()&&10===cf.version.major?function(n){try{return af(n)}catch(e){return y.none()}}:af,set:function(n,e){if(!rf(n))throw new Error("Can only set raw "+uf+" value of a "+uf+" node");n.dom().nodeValue=e}}),om=function(n){return tm.getOption(n)},rm=function(n){return"img"===ue.name(n)?1:om(n).fold(function(){return Be.children(n).length},function(n){return n.length})},im=rm,um=_e([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),am={before:um.before,on:um.on,after:um.after,cata:function(n,e,t,o){return n.fold(e,t,o)},getStart:function(n){return n.fold(O.identity,O.identity,O.identity)}},cm=_e([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),sm=de.immutable("start","soffset","finish","foffset"),fm={domRange:cm.domRange,relative:cm.relative,exact:cm.exact,exactFromRange:function(n){return cm.exact(n.start(),n.soffset(),n.finish(),n.foffset())},range:sm,getWin:function(n){var e=n.match({domRange:function(n){return Xn.fromDom(n.startContainer)},relative:function(n,e){return am.getStart(n)},exact:function(n,e,t,o){return n}});return Be.defaultView(e)}},lm=function(n,e,t,o){var r=Be.owner(n).dom().createRange();return r.setStart(n.dom(),e),r.setEnd(t.dom(),o),r},dm=function(n,e,t,o){var r=lm(n,e,t,o),i=Te(n,t)&&e===o;return r.collapsed&&!i},mm=function(n,e){n.selectNodeContents(e.dom())},gm=function(n){n.deleteContents()},pm=function(n){return{left:O.constant(n.left),top:O.constant(n.top),right:O.constant(n.right),bottom:O.constant(n.bottom),width:O.constant(n.width),height:O.constant(n.height)}},vm={create:function(n){return n.document.createRange()},replaceWith:function(n,e){gm(n),n.insertNode(e.dom())},selectNodeContents:function(n,e){var t=n.document.createRange();return mm(t,e),t},selectNodeContentsUsing:mm,relativeToNative:function(n,e,t){var o,r,i=n.document.createRange();return o=i,e.fold(function(n){o.setStartBefore(n.dom())},function(n,e){o.setStart(n.dom(),e)},function(n){o.setStartAfter(n.dom())}),r=i,t.fold(function(n){r.setEndBefore(n.dom())},function(n,e){r.setEnd(n.dom(),e)},function(n){r.setEndAfter(n.dom())}),i},exactToNative:function(n,e,t,o,r){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(o.dom(),r),i},deleteContents:gm,cloneFragment:function(n){var e=n.cloneContents();return Xn.fromDom(e)},getFirstRect:function(n){var e=n.getClientRects(),t=0<e.length?e[0]:n.getBoundingClientRect();return 0<t.width||0<t.height?y.some(t).map(pm):y.none()},getBounds:function(n){var e=n.getBoundingClientRect();return 0<e.width||0<e.height?y.some(e).map(pm):y.none()},isWithin:function(n,e){return e.compareBoundaryPoints(n.END_TO_START,n)<1&&-1<e.compareBoundaryPoints(n.START_TO_END,n)},toString:function(n){return n.toString()}},hm=_e([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),bm=function(n,e,t){return e(Xn.fromDom(t.startContainer),t.startOffset,Xn.fromDom(t.endContainer),t.endOffset)},ym=function(n,e){var r,t,o,i=(r=n,e.match({domRange:function(n){return{ltr:O.constant(n),rtl:y.none}},relative:function(n,e){return{ltr:L(function(){return vm.relativeToNative(r,n,e)}),rtl:L(function(){return y.some(vm.relativeToNative(r,e,n))})}},exact:function(n,e,t,o){return{ltr:L(function(){return vm.exactToNative(r,n,e,t,o)}),rtl:L(function(){return y.some(vm.exactToNative(r,t,o,n,e))})}}}));return(o=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return hm.rtl(Xn.fromDom(n.endContainer),n.endOffset,Xn.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return bm(0,hm.ltr,o)}):bm(0,hm.ltr,o)},wm=(hm.ltr,hm.rtl,ym),xm=function(i,n){return ym(i,n).match({ltr:function(n,e,t,o){var r=i.document.createRange();return r.setStart(n.dom(),e),r.setEnd(t.dom(),o),r},rtl:function(n,e,t,o){var r=i.document.createRange();return r.setStart(t.dom(),o),r.setEnd(n.dom(),e),r}})},Sm=(document.caretPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=ue.name(n);return"input"===t?am.after(n):vn.contains(["br","img"],t)?0===e?am.before(n):am.after(n):am.on(n,e)}),Tm=function(n,e,t,o){var r=Sm(n,e),i=Sm(t,o);return fm.relative(r,i)},km=Tm,Cm=function(n,e){y.from(n.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(e)})},Om=function(n,e,t,o,r){var i=vm.exactToNative(n,e,t,o,r);Cm(n,i)},Em=function(i,n){return wm(i,n).match({ltr:function(n,e,t,o){Om(i,n,e,t,o)},rtl:function(n,e,t,o){var r=i.getSelection();r.setBaseAndExtent?r.setBaseAndExtent(n.dom(),e,t.dom(),o):r.extend?(r.collapse(n.dom(),e),r.extend(t.dom(),o)):Om(i,t,o,n,e)}})},Dm=function(n){var e=Xn.fromDom(n.anchorNode),t=Xn.fromDom(n.focusNode);return dm(e,n.anchorOffset,t,n.focusOffset)?y.some(fm.range(Xn.fromDom(n.anchorNode),n.anchorOffset,Xn.fromDom(n.focusNode),n.focusOffset)):function(n){if(0<n.rangeCount){var e=n.getRangeAt(0),t=n.getRangeAt(n.rangeCount-1);return y.some(fm.range(Xn.fromDom(e.startContainer),e.startOffset,Xn.fromDom(t.endContainer),t.endOffset))}return y.none()}(n)},Mm=function(n){var e=n.getSelection();return 0<e.rangeCount?Dm(e):y.none()},Am=function(n,e,t,o,r){var i=km(e,t,o,r);Em(n,i)},Bm=Mm,Rm=function(n){return Mm(n).map(function(n){return fm.exact(n.start(),n.soffset(),n.finish(),n.foffset())})},Im=function(n){n.getSelection().removeAllRanges()},Fm=function(n,e){var t=xm(n,e);return vm.getFirstRect(t)},Nm=function(n){return{left:n.left,top:n.top,right:n.right,bottom:n.bottom,width:O.constant(2),height:n.height}},Vm=function(n){return{left:O.constant(n.left),top:O.constant(n.top),right:O.constant(n.right),bottom:O.constant(n.bottom),width:O.constant(n.width),height:O.constant(n.height)}},Hm={getRectangles:function(n){var e=n.getSelection();return e!==undefined&&0<e.rangeCount?function(t){if(t.collapsed){var o=Xn.fromDom(t.startContainer);return Be.parent(o).bind(function(n){var e=fm.exact(o,t.startOffset,n,im(n));return Fm(t.startContainer.ownerDocument.defaultView,e).map(Nm).map(vn.pure)}).getOr([])}return vn.map(t.getClientRects(),Vm)}(e.getRangeAt(0)):[]}},jm=function(n){n.focus();var e=Xn.fromDom(n.document.body);(hr().exists(function(n){return vn.contains(["input","textarea"],ue.name(n))})?function(n){setTimeout(function(){n()},0)}:O.apply)(function(){hr().each(vr),pr(e)})},zm="data-"+gi.resolve("last-outer-height"),Lm=function(n,e){Po.set(n,zm,e)},Pm=function(n){return{top:O.constant(n.top()),bottom:O.constant(n.top()+n.height())}},Wm=function(n,e){var t=em(e,zm),o=n.innerHeight;return o<t?y.some(t-o):y.none()},Um=function(n,u){var e=Xn.fromDom(u.document.body),t=$d.bind(Xn.fromDom(n),"resize",function(){Wm(n,e).each(function(i){var n,e;(n=u,e=Hm.getRectangles(n),0<e.length?y.some(e[0]).map(Pm):y.none()).each(function(n){var e,t,o,r=(e=u,o=i,(t=n).top()>e.innerHeight||t.bottom()>e.innerHeight?Math.min(o,t.bottom()-e.innerHeight+50):0);0!==r&&u.scrollTo(u.pageXOffset,u.pageYOffset+r)})}),Lm(e,n.innerHeight)});return Lm(e,n.innerHeight),{toEditing:function(){jm(u)},destroy:function(){t.unbind()}}},Gm=function(n){return y.some(Xn.fromDom(n.dom().contentWindow.document.body))},$m=function(n){return y.some(Xn.fromDom(n.dom().contentWindow.document))},qm=function(n){return y.from(n.dom().contentWindow)},_m=function(n){return qm(n).bind(Bm)},Km=function(n){return n.getFrame()},Xm=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=Km(e);return function(){return t(n)}})()}},Ym=function(n,e,t,o){return n[t].getOrThunk(function(){return function(n){return $d.bind(e,o,n)}})},Jm=function(n){return{left:O.constant(n.left),top:O.constant(n.top),right:O.constant(n.right),bottom:O.constant(n.bottom),width:O.constant(n.width),height:O.constant(n.height)}},Qm={getBody:Xm("getBody",Gm),getDoc:Xm("getDoc",$m),getWin:Xm("getWin",qm),getSelection:Xm("getSelection",_m),getFrame:Km,getActiveApi:function(a){var c=Km(a);return Gm(c).bind(function(u){return $m(c).bind(function(i){return qm(c).map(function(r){var n=Xn.fromDom(i.dom().documentElement),e=a.getCursorBox.getOrThunk(function(){return function(){return Rm(r).bind(function(n){return Fm(r,n).orThunk(function(){return Bm(r).filter(function(n){return Te(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0<e.width||0<e.height?y.some(e).map(Jm):y.none()})})})}}),t=a.setSelection.getOrThunk(function(){return function(n,e,t,o){Am(r,n,e,t,o)}}),o=a.clearSelection.getOrThunk(function(){return function(){Im(r)}});return{body:O.constant(u),doc:O.constant(i),win:O.constant(r),html:O.constant(n),getSelection:O.curry(_m,c),setSelection:t,clearSelection:o,frame:O.constant(c),onKeyup:Ym(a,i,"onKeyup","keyup"),onNodeChanged:Ym(a,i,"onNodeChanged","selectionchange"),onDomChanged:a.onDomChanged,onScrollToCursor:a.onScrollToCursor,onScrollToElement:a.onScrollToElement,onToReading:a.onToReading,onToEditing:a.onToEditing,onToolbarScrollStart:a.onToolbarScrollStart,onTouchContent:a.onTouchContent,onTapContent:a.onTapContent,onTouchToolstrip:a.onTouchToolstrip,getCursorBox:e}})})})}},Zm="data-ephox-mobile-fullscreen-style",ng="position:absolute!important;",eg="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;",tg=Mn.detect().os.isAndroid(),og=function(n,e){var t,o,r=function(o){return function(n){var e=Po.get(n,"style"),t=e===undefined?"no-styles":e.trim();t!==o&&(Po.set(n,Zm,t),Po.set(n,"style",o))}},i=Ni(n,"*"),u=vn.bind(i,function(n){return Vi(n,"*")}),a=(t=e,(o=Oi.get(t,"background-color"))!==undefined&&""!==o?"background-color:"+o+"!important":"background-color:rgb(255,255,255)!important;");vn.each(u,r("display:none!important;")),vn.each(i,r(ng+eg+a)),r((!0===tg?"":ng)+eg+a)(n)},rg=function(){var n=Fi("["+Zm+"]");vn.each(n,function(n){var e=Po.get(n,Zm);"no-styles"!==e?Po.set(n,"style",e):Po.remove(n,"style"),Po.remove(n,Zm)})},ig=function(){var e=zi("head").getOrDie(),n=zi('meta[name="viewport"]').getOrThunk(function(){var n=Xn.fromTag("meta");return Po.set(n,"name","viewport"),Fe.append(e,n),n}),t=Po.get(n,"content");return{maximize:function(){Po.set(n,"content","width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0")},restore:function(){t!==undefined&&null!==t&&0<t.length?Po.set(n,"content",t):Po.set(n,"content","user-scalable=yes")}}},ug=function(e,n){var t=ig(),o=tl.api(),r=tl.api();return{enter:function(){n.hide(),er.add(e.container,gi.resolve("fullscreen-maximized")),er.add(e.container,gi.resolve("android-maximized")),t.maximize(),er.add(e.body,gi.resolve("android-scroll-reload")),o.set(Um(e.win,Qm.getWin(e.editor).getOrDie("no"))),Qm.getActiveApi(e.editor).each(function(n){og(e.container,n.body()),r.set(nm(n,e.toolstrip,e.alloy))})},exit:function(){t.restore(),n.show(),er.remove(e.container,gi.resolve("fullscreen-maximized")),er.remove(e.container,gi.resolve("android-maximized")),rg(),er.remove(e.body,gi.resolve("android-scroll-reload")),r.clear(),o.clear()}}},ag=function(e,t){var o=null;return{cancel:function(){null!==o&&(clearTimeout(o),o=null)},throttle:function(){var n=arguments;null===o&&(o=setTimeout(function(){e.apply(null,n),n=o=null},t))}}},cg=function(e,t){var o=null;return{cancel:function(){null!==o&&(clearTimeout(o),o=null)},throttle:function(){var n=arguments;null!==o&&clearTimeout(o),o=setTimeout(function(){e.apply(null,n),n=o=null},t)}}},sg=function(n,e){var t=Ws(Df.sketch({dom:qc('<div aria-hidden="true" class="${prefix}-mask-tap-icon"></div>'),containerBehaviours:Bo([si.config({toggleClass:gi.resolve("mask-tap-icon-selected"),toggleOnExecute:!1})])})),o=ag(n,200);return Df.sketch({dom:qc('<div class="${prefix}-disabled-mask"></div>'),components:[Df.sketch({dom:qc('<div class="${prefix}-content-container"></div>'),components:[Wc.sketch({dom:qc('<div class="${prefix}-content-tap-section"></div>'),components:[t.asSpec()],action:function(n){o.throttle()},buttonBehaviours:Bo([si.config({toggleClass:gi.resolve("mask-tap-icon-selected")})])})]})]})},fg=Dt([Ht("editor",[Ft("getFrame"),jt("getBody"),jt("getDoc"),jt("getWin"),jt("getSelection"),jt("setSelection"),jt("clearSelection"),jt("cursorSaver"),jt("onKeyup"),jt("onNodeChanged"),jt("getCursorBox"),Ft("onDomChanged"),Pt("onTouchContent",O.noop),Pt("onTapContent",O.noop),Pt("onTouchToolstrip",O.noop),Pt("onScrollToCursor",O.constant({unbind:O.noop})),Pt("onScrollToElement",O.constant({unbind:O.noop})),Pt("onToEditing",O.constant({unbind:O.noop})),Pt("onToReading",O.constant({unbind:O.noop})),Pt("onToolbarScrollStart",O.identity)]),Ft("socket"),Ft("toolstrip"),Ft("dropup"),Ft("toolbar"),Ft("container"),Ft("alloy"),Ut("win",function(n){return Be.owner(n.socket).dom().defaultView}),Ut("body",function(n){return Xn.fromDom(n.socket.dom().ownerDocument.body)}),Pt("translate",O.identity),Pt("setReadOnly",O.noop),Pt("readOnlyOnInit",O.constant(!0))]),lg={produce:function(n){var e=Yt("Getting AndroidWebapp schema",fg,n);Oi.set(e.toolstrip,"width","100%");var t=Pl(sg(function(){e.setReadOnly(!0),r.enter()},e.translate));e.alloy.add(t);var o={show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}};Fe.append(e.container,t.element());var r=ug(e,o);return{setReadOnly:e.setReadOnly,refreshStructure:O.noop,enter:r.enter,exit:r.exit,destroy:O.noop}}},dg=O.constant([Pt("shell",!0),za("toolbarBehaviours",[cd])]),mg=O.constant([lc({name:"groups",overrides:function(n){return{behaviours:Bo([cd.config({})])}}})]),gg=(O.constant("Toolbar"),Pc({name:"Toolbar",configFields:dg(),partFields:mg(),factory:function(e,n,t,o){var r=function(n){return e.shell()?y.some(n):yc(n,e,"groups")},i=e.shell()?{behaviours:[cd.config({})],components:[]}:{behaviours:[],components:n};return{uid:e.uid(),dom:e.dom(),components:i.components,behaviours:D.deepMerge(Bo(i.behaviours),La(e.toolbarBehaviours())),apis:{setGroups:function(n,e){r(n).fold(function(){throw console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")},function(n){cd.set(n,e)})}},domModification:{attributes:{role:"group"}}}},apis:{setGroups:function(n,e,t){n.setGroups(e,t)}}})),pg=O.constant([Ft("items"),(ff=["itemClass"],Ht("markers",vn.map(ff,Ft))),za("tgroupBehaviours",[ja])]),vg=O.constant([dc({name:"items",unit:"item",overrides:function(n){return{domModification:{classes:[n.markers().itemClass()]}}}})]),hg=(O.constant("ToolbarGroup"),Pc({name:"ToolbarGroup",configFields:pg(),partFields:vg(),factory:function(n,e,t,o){return D.deepMerge({dom:{attributes:{role:"toolbar"}}},{uid:n.uid(),dom:n.dom(),components:e,behaviours:D.deepMerge(Bo([ja.config({mode:"flow",selector:"."+n.markers().itemClass()})]),La(n.tgroupBehaviours())),"debug.sketcher":t["debug.sketcher"]})}})),bg="data-"+gi.resolve("horizontal-scroll"),yg=function(n){return 0<n.dom().scrollTop||function(n){n.dom().scrollTop=1;var e=0!==n.dom().scrollTop;return n.dom().scrollTop=0,e}(n)},wg=function(n){return 0<n.dom().scrollLeft||function(n){n.dom().scrollLeft=1;var e=0!==n.dom().scrollLeft;return n.dom().scrollLeft=0,e}(n)},xg=function(n){return"true"===Po.get(n,bg)?wg:yg},Sg={exclusive:function(n,e){return $d.bind(n,"touchmove",function(n){Wi(n.target(),e).filter(xg).fold(function(){n.raw().preventDefault()},O.noop)})},markAsHorizontal:function(n){Po.set(n,bg,"true")}};function Tg(){var e=function(n){var e=!0===n.scrollable?"${prefix}-toolbar-scrollable-group":"";return{dom:qc('<div aria-label="'+n.label+'" class="${prefix}-toolbar-group '+e+'"></div>'),tgroupBehaviours:Bo([kf("adhoc-scrollable-toolbar",!0===n.scrollable?[mo(function(n,e){Oi.set(n.element(),"overflow-x","auto"),Sg.markAsHorizontal(n.element()),Td.register(n.element())})]:[])]),components:[Df.sketch({components:[hg.parts().items({})]})],markers:{itemClass:gi.resolve("toolbar-group-item")},items:n.items}},t=Pl(gg.sketch({dom:qc('<div class="${prefix}-toolbar"></div>'),components:[gg.parts().groups({})],toolbarBehaviours:Bo([si.config({toggleClass:gi.resolve("context-toolbar"),toggleOnExecute:!1,aria:{mode:"none"}}),ja.config({mode:"cyclic"})]),shell:!0})),n=Pl(Df.sketch({dom:{classes:[gi.resolve("toolstrip")]},components:[Wl(t)],containerBehaviours:Bo([si.config({toggleClass:gi.resolve("android-selection-context-toolbar"),toggleOnExecute:!1})])})),o=function(){gg.setGroups(t,r.get()),si.off(t)},r=ur([]);return{wrapper:O.constant(n),toolbar:O.constant(t),createGroups:function(n){return vn.map(n,O.compose(hg.sketch,e))},setGroups:function(n){r.set(n),o()},setContextToolbar:function(n){si.on(t),gg.setGroups(t,n)},restoreToolbar:function(){si.isOn(t)&&o()},refresh:function(){},focus:function(){ja.focusIn(t)}}}var kg=function(n,e){cd.append(n,Wl(e))},Cg=function(n,e){cd.remove(n,e)},Og={makeEditSwitch:function(n){return Pl(Wc.sketch({dom:qc('<div class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),action:function(){n.run(function(n){n.setReadOnly(!1)})}}))},makeSocket:function(){return Pl(Df.sketch({dom:qc('<div class="${prefix}-editor-socket"></div>'),components:[],containerBehaviours:Bo([cd.config({})])}))},updateMode:function(n,e,t,o){(!0===t?ir.toAlpha:ir.toOmega)(o),(t?kg:Cg)(n,e)}},Eg=function(e,n){return n.getAnimationRoot().fold(function(){return e.element()},function(n){return n(e)})},Dg=function(n){return n.dimension().property()},Mg=function(n,e){return n.dimension().getDimension()(e)},Ag=function(n,e){var t=Eg(n,e);Bl.remove(t,[e.shrinkingClass(),e.growingClass()])},Bg=function(n,e){er.remove(n.element(),e.openClass()),er.add(n.element(),e.closedClass()),Oi.set(n.element(),Dg(e),"0px"),Oi.reflow(n.element())},Rg=function(n,e){er.remove(n.element(),e.closedClass()),er.add(n.element(),e.openClass()),Oi.remove(n.element(),Dg(e))},Ig=function(n,e,t){t.setCollapsed(),Oi.set(n.element(),Dg(e),Mg(e,n.element())),Oi.reflow(n.element());var o=Eg(n,e);er.add(o,e.shrinkingClass()),Bg(n,e),e.onStartShrink()(n)},Fg=function(n,e,t){var o=function(n,e){Rg(n,e);var t=Mg(e,n.element());return Bg(n,e),t}(n,e),r=Eg(n,e);er.add(r,e.growingClass()),Rg(n,e),Oi.set(n.element(),Dg(e),o),t.setExpanded(),e.onStartGrow()(n)},Ng=function(n,e,t){var o=Eg(n,e);return!0===er.has(o,e.growingClass())},Vg=function(n,e,t){var o=Eg(n,e);return!0===er.has(o,e.shrinkingClass())},Hg=Object.freeze({grow:function(n,e,t){t.isExpanded()||Fg(n,e,t)},shrink:function(n,e,t){t.isExpanded()&&Ig(n,e,t)},immediateShrink:function(n,e,t){var o,r;t.isExpanded()&&(o=n,r=e,t.setCollapsed(),Oi.set(o.element(),Dg(r),Mg(r,o.element())),Oi.reflow(o.element()),Ag(o,r),Bg(o,r),r.onStartShrink()(o),r.onShrunk()(o))},hasGrown:function(n,e,t){return t.isExpanded()},hasShrunk:function(n,e,t){return t.isCollapsed()},isGrowing:Ng,isShrinking:Vg,isTransitioning:function(n,e,t){return!0===Ng(n,e)||!0===Vg(n,e)},toggleGrow:function(n,e,t){(t.isExpanded()?Ig:Fg)(n,e,t)},disableTransitions:Ag}),jg=Object.freeze({exhibit:function(n,e){var t=e.expanded();return bo(t?{classes:[e.openClass()],styles:{}}:{classes:[e.closedClass()],styles:dt(e.dimension().property(),"0px")})},events:function(t,o){return oo([io(j(),function(n,e){e.event().raw().propertyName===t.dimension().property()&&(Ag(n,t),o.isExpanded()&&Oi.remove(n.element(),t.dimension().property()),(o.isExpanded()?t.onGrown():t.onShrunk())(n,e))})])}}),zg=[Ft("closedClass"),Ft("openClass"),Ft("shrinkingClass"),Ft("growingClass"),jt("getAnimationRoot"),Gr("onShrunk"),Gr("onStartShrink"),Gr("onGrown"),Gr("onStartGrow"),Pt("expanded",!1),Nt("dimension",Zt("property",{width:[Kr("property","width"),Kr("getDimension",function(n){return Es(n)+"px"})],height:[Kr("property","height"),Kr("getDimension",function(n){return Bi(n)+"px"})]}))],Lg=Object.freeze({init:function(n){var e=ur(n.expanded());return Do({isExpanded:function(){return!0===e.get()},isCollapsed:function(){return!1===e.get()},setCollapsed:O.curry(e.set,!1),setExpanded:O.curry(e.set,!0),readState:function(){return"expanded: "+e.get()}})}}),Pg=Io({fields:zg,name:"sliding",active:jg,apis:Hg,state:Lg}),Wg=function(e,t){var o=Pl(Df.sketch({dom:{tag:"div",classes:gi.resolve("dropup")},components:[],containerBehaviours:Bo([cd.config({}),Pg.config({closedClass:gi.resolve("dropup-closed"),openClass:gi.resolve("dropup-open"),shrinkingClass:gi.resolve("dropup-shrinking"),growingClass:gi.resolve("dropup-growing"),dimension:{property:"height"},onShrunk:function(n){e(),t(),cd.set(n,[])},onGrown:function(n){e(),t()}}),li(function(n,e){r(O.noop)})])})),r=function(n){window.requestAnimationFrame(function(){n(),Pg.shrink(o)})};return{appear:function(n,e,t){!0===Pg.hasShrunk(o)&&!1===Pg.isTransitioning(o)&&window.requestAnimationFrame(function(){e(t),cd.set(o,[n()]),Pg.grow(o)})},disappear:r,component:O.constant(o),element:o.element}},Ug=Mn.detect().browser.isFirefox(),Gg=Et([Vt("triggerEvent"),Vt("broadcastEvent"),Pt("stopBackspace",!0)]),$g=function(e,n){var t,o,r,i,u=Yt("Getting GUI events settings",Gg,n),a=Mn.detect().deviceType.isTouch()?["touchstart","touchmove","touchend","gesturestart"]:["mousedown","mouseup","mouseover","mousemove","mouseout","click"],c=Jd(u),s=vn.map(a.concat(["selectstart","input","contextmenu","change","transitionend","dragstart","dragover","drop"]),function(n){return $d.bind(e,n,function(e){c.fireIfReady(e,n).each(function(n){n&&e.kill()}),u.triggerEvent(n,e)&&e.kill()})}),f=$d.bind(e,"keydown",function(n){var e;u.triggerEvent("keydown",n)?n.kill():!0!==u.stopBackspace||(e=n).raw().which!==Ui.BACKSPACE()[0]||vn.contains(["input","textarea"],ue.name(e.target()))||n.prevent()}),l=(t=e,o=function(n){u.triggerEvent("focusin",n)&&n.kill()},Ug?$d.capture(t,"focus",o):$d.bind(t,"focusin",o)),d=(r=e,i=function(n){u.triggerEvent("focusout",n)&&n.kill(),setTimeout(function(){u.triggerEvent(Rn(),n)},0)},Ug?$d.capture(r,"blur",i):$d.bind(r,"focusout",i)),m=Be.defaultView(e),g=$d.bind(m,"scroll",function(n){u.broadcastEvent(Ln(),n)&&n.kill()});return{unbind:function(){vn.each(s,function(n){n.unbind()}),f.unbind(),l.unbind(),d.unbind(),g.unbind()}}},qg=function(n,e){var t=lt(n,"target").map(function(n){return n()}).getOr(e);return ur(t)},_g=_e([{stopped:[]},{resume:["element"]},{complete:[]}]),Kg=function(n,o,e,t,r,i){var u,a,c,s,f=n(o,t),l=(u=e,a=r,c=ur(!1),s=ur(!1),{stop:function(){c.set(!0)},cut:function(){s.set(!0)},isStopped:c.get,isCut:s.get,event:O.constant(u),setSource:a.set,getSource:a.get});return f.fold(function(){return i.logEventNoHandlers(o,t),_g.complete()},function(e){var t=e.descHandler();return Tl(t)(l),l.isStopped()?(i.logEventStopped(o,e.element(),t.purpose()),_g.stopped()):l.isCut()?(i.logEventCut(o,e.element(),t.purpose()),_g.complete()):Be.parent(e.element()).fold(function(){return i.logNoParent(o,e.element(),t.purpose()),_g.complete()},function(n){return i.logEventResponse(o,e.element(),t.purpose()),_g.resume(n)})})},Xg=function(e,t,o,n,r,i){return Kg(e,t,o,n,r,i).fold(function(){return!0},function(n){return Xg(e,t,o,n,r,i)},function(){return!1})},Yg=function(n,e,t){var o,r,i=(o=e,r=ur(!1),{stop:function(){r.set(!0)},cut:O.noop,isStopped:r.get,isCut:O.constant(!1),event:O.constant(o),setTarget:O.die("Cannot set target of a broadcasted event"),getTarget:O.die("Cannot get target of a broadcasted event")});return vn.each(n,function(n){var e=n.descHandler();Tl(e)(i)}),i.isStopped()},Jg=function(n,e,t,o,r){var i=qg(t,o);return Xg(n,e,t,o,i,r)},Qg=function(n,e,t){return lr.closest(n,function(n){return e(n).isSome()},t).bind(e)},Zg=de.immutable("element","descHandler"),np=function(n,e){return{id:O.constant(n),descHandler:O.constant(e)}};function ep(){var i={};return{registerId:function(o,r,n){M.each(n,function(n,e){var t=i[e]!==undefined?i[e]:{};t[r]=Sl(n,o),i[e]=t})},unregisterId:function(t){M.each(i,function(n,e){n.hasOwnProperty(t)&&delete n[t]})},filterByType:function(n){return lt(i,n).map(function(n){return M.mapToArray(n,function(n,e){return np(e,n)})}).getOr([])},find:function(n,e,t){var r=st(e)(i);return Qg(t,function(n){return t=r,Ic(o=n).fold(function(){return y.none()},function(n){var e=st(n);return t.bind(e).map(function(n){return Zg(o,n)})});var t,o},n)}}}function tp(){var i=ep(),u={},a=function(n){Ic(n.element()).each(function(n){u[n]=undefined,i.unregisterId(n)})};return{find:function(n,e,t){return i.find(n,e,t)},filter:function(n){return i.filterByType(n)},register:function(n){var e,t,o=(t=(e=n).element(),Ic(t).fold(function(){return Rc("uid-",e.element())},function(n){return n}));pt(u,o)&&function(n,e){var t=u[e];if(t!==n)throw new Error('The tagId "'+e+'" is already used by: '+Ar(t.element())+"\nCannot use it for: "+Ar(n.element())+"\nThe conflicting element is"+(se.inBody(t.element())?" ":" not ")+"already in the DOM");a(n)}(n,o);var r=[n];i.registerId(r,o,n.events()),u[o]=n},unregister:a,getById:function(n){return st(n)(u)}}}var op=function(t){var o=function(e){return Be.parent(t.element()).fold(function(){return!0},function(n){return Te(e,n)})},r=tp(),s=function(n,e){return r.find(o,n,e)},n=$g(t.element(),{triggerEvent:function(u,a){return jr(u,a.target(),function(n){return e=s,t=u,r=n,i=(o=a).target(),Jg(e,t,o,i,r);var e,t,o,r,i})},broadcastEvent:function(n,e){var t=r.filter(n);return Yg(t,e)}}),i=ll({debugInfo:O.constant("real"),triggerEvent:function(e,t,o){jr(e,t,function(n){Jg(s,e,o,t,n)})},triggerFocus:function(a,c){Ic(a).fold(function(){pr(a)},function(n){jr(Bn(),a,function(n){var e,t,o,r,i,u;e=s,t=Bn(),o={originator:O.constant(c),target:O.constant(a)},i=n,u=qg(o,r=a),Kg(e,t,o,r,u,i)})})},triggerEscape:function(n,e){i.triggerEvent("keydown",n.element(),e.event())},getByUid:function(n){return m(n)},getByDom:function(n){return g(n)},build:Pl,addToGui:function(n){a(n)},removeFromGui:function(n){c(n)},addToWorld:function(n){e(n)},removeFromWorld:function(n){u(n)},broadcast:function(n){l(n)},broadcastOn:function(n,e){d(n,e)}}),e=function(n){n.connect(i),ue.isText(n.element())||(r.register(n),vn.each(n.components(),e),i.triggerEvent(zn(),n.element(),{target:O.constant(n.element())}))},u=function(n){ue.isText(n.element())||(vn.each(n.components(),u),r.unregister(n)),n.disconnect()},a=function(n){Le(t,n)},c=function(n){Ue(n)},f=function(t){var n=r.filter(In());vn.each(n,function(n){var e=n.descHandler();Tl(e)(t)})},l=function(n){f({universal:O.constant(!0),data:O.constant(n)})},d=function(n,e){f({universal:O.constant(!1),channels:O.constant(n),data:O.constant(e)})},m=function(n){return r.getById(n).fold(function(){return qe.error(new Error('Could not find component with uid: "'+n+'" in system.'))},qe.value)},g=function(n){var e=Ic(n).getOr("not found");return m(e)};return e(t),{root:O.constant(t),element:t.element,destroy:function(){n.unbind(),He.remove(t.element())},add:a,remove:c,getByUid:m,getByDom:g,addToWorld:e,removeFromWorld:u,broadcast:l,broadcastOn:d}},rp=O.constant(gi.resolve("readonly-mode")),ip=O.constant(gi.resolve("edit-mode"));function up(n){var e=Pl(Df.sketch({dom:{classes:[gi.resolve("outer-container")].concat(n.classes)},containerBehaviours:Bo([ir.config({alpha:rp(),omega:ip()})])}));return op(e)}var ap=function(n,e){var t=Xn.fromTag("input");Oi.setAll(t,{opacity:"0",position:"absolute",top:"-1000px",left:"-1000px"}),Fe.append(n,t),pr(t),e(t),He.remove(t)},cp=function(n){var e=n.getSelection();if(0<e.rangeCount){var t=e.getRangeAt(0),o=n.document.createRange();o.setStart(t.startContainer,t.startOffset),o.setEnd(t.endContainer,t.endOffset),e.removeAllRanges(),e.addRange(o)}},sp={resume:function(n,e){hr().each(function(n){Te(n,e)||vr(n)}),n.focus(),pr(Xn.fromDom(n.document.body)),cp(n)}},fp={stubborn:function(n,e,t,o){var r=function(){sp.resume(e,o)},i=$d.bind(t,"keydown",function(n){vn.contains(["input","textarea"],ue.name(n.target()))||r()});return{toReading:function(){ap(n,vr)},toEditing:r,onToolbarTouch:function(){},destroy:function(){i.unbind()}}},timid:function(n,e,t,o){var r=function(){vr(o)};return{toReading:function(){r()},toEditing:function(){sp.resume(e,o)},onToolbarTouch:function(){r()},destroy:O.noop}}},lp=function(t,o,r,i,n){var u=function(){o.run(function(n){n.refreshSelection()})},e=function(n,e){var t=n-i.dom().scrollTop;o.run(function(n){n.scrollIntoView(t,t+e)})},a=function(){o.run(function(n){n.clearSelection()})},c=function(){t.getCursorBox().each(function(n){e(n.top(),n.height())}),o.run(function(n){n.syncHeight()})},s=Qd(t),f=cg(c,300),l=[t.onKeyup(function(){a(),f.throttle()}),t.onNodeChanged(u),t.onDomChanged(f.throttle),t.onDomChanged(u),t.onScrollToCursor(function(n){n.preventDefault(),f.throttle()}),t.onScrollToElement(function(n){n.element(),e(o,i)}),t.onToEditing(function(){o.run(function(n){n.toEditing()})}),t.onToReading(function(){o.run(function(n){n.toReading()})}),$d.bind(t.doc(),"touchend",function(n){Te(t.html(),n.target())||Te(t.body(),n.target())}),$d.bind(r,"transitionend",function(n){var e;"height"===n.raw().propertyName&&(e=Bi(r),o.run(function(n){n.setViewportOffset(e)}),u(),c())}),$d.capture(r,"touchstart",function(n){var e;o.run(function(n){n.highlightSelection()}),e=n,o.run(function(n){n.onToolbarTouch(e)}),t.onTouchToolstrip()}),$d.bind(t.body(),"touchstart",function(n){a(),t.onTouchContent(),s.fireTouchstart(n)}),s.onTouchmove(),s.onTouchend(),$d.bind(t.body(),"click",function(n){n.kill()}),$d.bind(r,"touchmove",function(){t.onToolbarScrollStart()})];return{destroy:function(){vn.each(l,function(n){n.unbind()})}}},dp=function(n){var t=y.none(),e=[],o=function(n){r()?u(n):e.push(n)},r=function(){return t.isSome()},i=function(n){vn.each(n,u)},u=function(e){t.each(function(n){setTimeout(function(){e(n)},0)})};return n(function(n){t=y.some(n),i(e),e=[]}),{get:o,map:function(t){return dp(function(e){o(function(n){e(t(n))})})},isReady:r}},mp={nu:dp,pure:function(e){return dp(function(n){n(e)})}},gp=function(t){return function(){var n=Array.prototype.slice.call(arguments),e=this;setTimeout(function(){t.apply(e,n)},0)}},pp=function(e){var n=function(n){e(gp(n))};return{map:function(o){return pp(function(t){n(function(n){var e=o(n);t(e)})})},bind:function(t){return pp(function(e){n(function(n){t(n).get(e)})})},anonBind:function(t){return pp(function(e){n(function(n){t.get(e)})})},toLazy:function(){return mp.nu(n)},get:n}},vp={nu:pp,pure:function(e){return pp(function(n){n(e)})}},hp=function(n,e,t){return Math.abs(n-e)<=t?y.none():n<e?y.some(n+t):y.some(n-t)},bp=function(){var s=null;return{animate:function(o,r,n,i,e,t){var u=!1,a=function(n){u=!0,e(n)};clearInterval(s);var c=function(n){clearInterval(s),a(n)};s=setInterval(function(){var t=o();hp(t,r,n).fold(function(){clearInterval(s),a(r)},function(n){if(i(n,c),!u){var e=o();(e!==n||Math.abs(e-r)>Math.abs(t-r))&&(clearInterval(s),a(r))}})},t)}}},yp=function(e,t){return Ir([{width:320,height:480,keyboard:{portrait:300,landscape:240}},{width:320,height:568,keyboard:{portrait:300,landscape:240}},{width:375,height:667,keyboard:{portrait:305,landscape:240}},{width:414,height:736,keyboard:{portrait:320,landscape:240}},{width:768,height:1024,keyboard:{portrait:320,landscape:400}},{width:1024,height:1366,keyboard:{portrait:380,landscape:460}}],function(n){return e<=n.width&&t<=n.height?y.some(n.keyboard):y.none()}).getOr({portrait:t/5,landscape:e/4})},wp=function(n){var e,t=_d(n).isPortrait(),o=yp((e=n).screen.width,e.screen.height),r=t?o.portrait:o.landscape;return(t?n.screen.height:n.screen.width)-n.innerHeight>r?0:r},xp=function(n,e){var t=Be.owner(n).dom().defaultView;return Bi(n)+Bi(e)-wp(t)},Sp=xp,Tp=function(n,e,t){var o=xp(e,t),r=Bi(e)+Bi(t)-o;Oi.set(n,"padding-bottom",r+"px")},kp=_e([{fixed:["element","property","offsetY"]},{scroller:["element","offsetY"]}]),Cp="data-"+gi.resolve("position-y-fixed"),Op="data-"+gi.resolve("y-property"),Ep="data-"+gi.resolve("scrolling"),Dp="data-"+gi.resolve("last-window-height"),Mp=function(n){return em(n,Cp)},Ap=function(n,e){var t=Po.get(n,Op);return kp.fixed(n,t,e)},Bp=function(n,e){return kp.scroller(n,e)},Rp=function(n){var e=Mp(n);return("true"===Po.get(n,Ep)?Bp:Ap)(n,e)},Ip=function(n,e,t){var o=Be.owner(n).dom().defaultView.innerHeight;return Po.set(n,Dp,o+"px"),o-e-t},Fp=function(n){var e=Hi(n,"["+Cp+"]");return vn.map(e,Rp)},Np=function(o,r,i,u){var n,e,t,a,c,s,f,l,d=Be.owner(o).dom().defaultView,m=(l=Po.get(f=i,"style"),Oi.setAll(f,{position:"absolute",top:"0px"}),Po.set(f,Cp,"0px"),Po.set(f,Op,"top"),{restore:function(){Po.set(f,"style",l||""),Po.remove(f,Cp),Po.remove(f,Op)}}),g=Bi(i),p=Bi(u),v=Ip(o,g,p),h=(t=g,a=v,s=Po.get(c=o,"style"),Td.register(c),Oi.setAll(c,{position:"absolute",height:a+"px",width:"100%",top:t+"px"}),Po.set(c,Cp,t+"px"),Po.set(c,Ep,"true"),Po.set(c,Op,"top"),{restore:function(){Td.deregister(c),Po.set(c,"style",s||""),Po.remove(c,Cp),Po.remove(c,Ep),Po.remove(c,Op)}}),b=(e=Po.get(n=u,"style"),Oi.setAll(n,{position:"absolute",bottom:"0px"}),Po.set(n,Cp,"0px"),Po.set(n,Op,"bottom"),{restore:function(){Po.set(n,"style",e||""),Po.remove(n,Cp),Po.remove(n,Op)}}),y=!0,w=function(){var n=d.innerHeight;return em(o,Dp)<n},x=function(){if(y){var n=Bi(i),e=Bi(u),t=Ip(o,n,e);Po.set(o,Cp,n+"px"),Oi.set(o,"height",t+"px"),Oi.set(u,"bottom",-(n+t+e)+"px"),Tp(r,o,u)}};return Tp(r,o,u),{setViewportOffset:function(n){Po.set(o,Cp,n+"px"),x()},isExpanding:w,isShrinking:O.not(w),refresh:x,restore:function(){y=!1,m.restore(),h.restore(),b.restore()}}},Vp=Mp,Hp=bp(),jp="data-"+gi.resolve("last-scroll-top"),zp=function(n){var e=Oi.getRaw(n,"top").getOr(0);return parseInt(e,10)},Lp=function(n){return parseInt(n.dom().scrollTop,10)},Pp=function(n,e){var t=e+Vp(n)+"px";Oi.set(n,"top",t)},Wp=function(t,o,r){return vp.nu(function(n){var e=O.curry(Lp,t);Hp.animate(e,o,15,function(n){t.dom().scrollTop=n,Oi.set(t,"top",zp(t)+15+"px")},function(){t.dom().scrollTop=o,Oi.set(t,"top",r+"px"),n(o)},10)})},Up=function(r,i){return vp.nu(function(n){var e=O.curry(Lp,r);Po.set(r,jp,e());var t=Math.abs(i-e()),o=Math.ceil(t/10);Hp.animate(e,i,o,function(n,e){em(r,jp)!==r.dom().scrollTop?e(r.dom().scrollTop):(r.dom().scrollTop=n,Po.set(r,jp,n))},function(){r.dom().scrollTop=i,Po.set(r,jp,i),n(i)},10)})},Gp=function(i,u){return vp.nu(function(n){var e=O.curry(zp,i),t=function(n){Oi.set(i,"top",n+"px")},o=Math.abs(u-e()),r=Math.ceil(o/10);Hp.animate(e,u,r,t,function(){t(u),n(u)},10)})},$p=function(e,t,o){var r=Be.owner(e).dom().defaultView;return vp.nu(function(n){Pp(e,o),Pp(t,o),r.scrollTo(0,o),n(o)})},qp=function(n,e,t,o,r){var i=Sp(e,t),u=O.curry(cp,n);i<o||i<r?Up(e,e.dom().scrollTop-i+r).get(u):o<0&&Up(e,e.dom().scrollTop+o).get(u)},_p=function(u,n){return n(function(o){var r=[],i=0;0===u.length?o([]):vn.each(u,function(n,e){var t;n.get((t=e,function(n){r[t]=n,++i>=u.length&&o(r)}))})})},Kp=function(n){return _p(n,vp.nu)},Xp=Kp,Yp=function(n,c){return n.fold(function(n,e,t){return o=n,r=e,u=c+(i=t),Oi.set(o,r,u+"px"),vp.pure(i);var o,r,i,u},function(n,e){return t=n,r=c+(o=e),i=Oi.getRaw(t,"top").getOr(o),u=r-parseInt(i,10),a=t.dom().scrollTop+u,Wp(t,a,r);var t,o,r,i,u,a})},Jp=function(n,e){var t=Fp(n),o=vn.map(t,function(n){return Yp(n,e)});return Xp(o)},Qp=function(e,t,n,o,r,i){var u,a,c=(u=function(n){return $p(e,t,n)},a=ur(mp.pure({})),{start:function(e){var n=mp.nu(function(n){return u(e).get(n)});a.set(n)},idle:function(n){a.get().get(function(){n()})}}),s=cg(function(){c.idle(function(){Jp(n,o.pageYOffset).get(function(){var n;(n=Hm.getRectangles(i),y.from(n[0]).bind(function(n){var e=n.top()-t.dom().scrollTop;return e>o.innerHeight+5||e<-5?y.some({top:O.constant(e),bottom:O.constant(e+n.height())}):y.none()})).each(function(n){t.dom().scrollTop=t.dom().scrollTop+n.top()}),c.start(0),r.refresh()})})},1e3),f=$d.bind(Xn.fromDom(o),"scroll",function(){o.pageYOffset<0||s.throttle()});return Jp(n,o.pageYOffset).get(O.identity),{unbind:f.unbind}},Zp=function(n){var t=n.cWin(),e=n.ceBody(),o=n.socket(),r=n.toolstrip(),i=n.toolbar(),u=n.contentElement(),a=n.keyboardType(),c=n.outerWindow(),s=n.dropup(),f=Np(o,e,r,s),l=a(n.outerBody(),t,se.body(),u,r,i),d=Kd(c,{onChange:O.noop,onReady:f.refresh});d.onAdjustment(function(){f.refresh()});var m=$d.bind(Xn.fromDom(c),"resize",function(){f.isExpanding()&&f.refresh()}),g=Qp(r,o,n.outerBody(),c,f,t),p=function(t,e){var n=t.document,o=Xn.fromTag("div");er.add(o,gi.resolve("unfocused-selections")),Fe.append(Xn.fromDom(n.documentElement),o);var r=$d.bind(o,"touchstart",function(n){n.prevent(),sp.resume(t,e),u()}),i=function(n){var e=Xn.fromTag("span");return Bl.add(e,[gi.resolve("layer-editor"),gi.resolve("unfocused-selection")]),Oi.setAll(e,{left:n.left()+"px",top:n.top()+"px",width:n.width()+"px",height:n.height()+"px"}),e},u=function(){He.empty(o)};return{update:function(){u();var n=Hm.getRectangles(t),e=vn.map(n,i);Ne.append(o,e)},isActive:function(){return 0<Be.children(o).length},destroy:function(){r.unbind(),He.remove(o)},clear:u}}(t,u),v=function(){p.clear()};return{toEditing:function(){l.toEditing(),v()},toReading:function(){l.toReading()},onToolbarTouch:function(n){l.onToolbarTouch(n)},refreshSelection:function(){p.isActive()&&p.update()},clearSelection:v,highlightSelection:function(){p.update()},scrollIntoView:function(n,e){qp(t,o,s,n,e)},updateToolbarPadding:O.noop,setViewportOffset:function(n){f.setViewportOffset(n),Gp(o,n).get(O.identity)},syncHeight:function(){Oi.set(u,"height",u.dom().contentWindow.document.body.scrollHeight+"px")},refreshStructure:f.refresh,destroy:function(){f.restore(),d.destroy(),g.unbind(),m.unbind(),l.destroy(),p.destroy(),ap(se.body(),vr)}}},nv=function(o,n){var r=ig(),i=tl.value(),u=tl.value(),a=tl.api(),c=tl.api();return{enter:function(){n.hide();var t=Xn.fromDom(document);Qm.getActiveApi(o.editor).each(function(n){i.set({socketHeight:Oi.getRaw(o.socket,"height"),iframeHeight:Oi.getRaw(n.frame(),"height"),outerScroll:document.body.scrollTop}),u.set({exclusives:Sg.exclusive(t,"."+Td.scrollable())}),er.add(o.container,gi.resolve("fullscreen-maximized")),og(o.container,n.body()),r.maximize(),Oi.set(o.socket,"overflow","scroll"),Oi.set(o.socket,"-webkit-overflow-scrolling","touch"),pr(n.body());var e=de.immutableBag(["cWin","ceBody","socket","toolstrip","toolbar","dropup","contentElement","cursor","keyboardType","isScrolling","outerWindow","outerBody"],[]);a.set(Zp(e({cWin:n.win(),ceBody:n.body(),socket:o.socket,toolstrip:o.toolstrip,toolbar:o.toolbar,dropup:o.dropup.element(),contentElement:n.frame(),cursor:O.noop,outerBody:o.body,outerWindow:o.win,keyboardType:fp.stubborn,isScrolling:function(){return u.get().exists(function(n){return n.socket.isScrolling()})}}))),a.run(function(n){n.syncHeight()}),c.set(lp(n,a,o.toolstrip,o.socket,o.dropup))})},refreshStructure:function(){a.run(function(n){n.refreshStructure()})},exit:function(){r.restore(),c.clear(),a.clear(),n.show(),i.on(function(n){n.socketHeight.each(function(n){Oi.set(o.socket,"height",n)}),n.iframeHeight.each(function(n){Oi.set(o.editor.getFrame(),"height",n)}),document.body.scrollTop=n.scrollTop}),i.clear(),u.on(function(n){n.exclusives.unbind()}),u.clear(),er.remove(o.container,gi.resolve("fullscreen-maximized")),rg(),Td.deregister(o.toolbar),Oi.remove(o.socket,"overflow"),Oi.remove(o.socket,"-webkit-overflow-scrolling"),vr(o.editor.getFrame()),Qm.getActiveApi(o.editor).each(function(n){n.clearSelection()})}}},ev={produce:function(n){var e=Yt("Getting IosWebapp schema",fg,n);Oi.set(e.toolstrip,"width","100%"),Oi.set(e.container,"position","relative");var t=Pl(sg(function(){e.setReadOnly(e.readOnlyOnInit()),o.enter()},e.translate));e.alloy.add(t);var o=nv(e,{show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}});return{setReadOnly:e.setReadOnly,refreshStructure:o.refreshStructure,enter:o.enter,exit:o.exit,destroy:O.noop}}},tv=tinymce.util.Tools.resolve("tinymce.EditorManager"),ov=function(n){var e=lt(n.settings,"skin_url").fold(function(){return tv.baseURL+"/skins/lightgray"},function(n){return n});return{content:e+"/content.mobile.min.css",ui:e+"/skin.mobile.min.css"}},rv=function(n,e,t){n.system().broadcastOn([Sr.formatChanged()],{command:e,state:t})},iv=function(o,n){var e=M.keys(n.formatter.get());vn.each(e,function(e){n.formatter.formatChanged(e,function(n){rv(o,e,n)})}),vn.each(["ul","ol"],function(t){n.selection.selectorChanged(t,function(n,e){rv(o,t,n)})})},uv=(O.constant(["x-small","small","medium","large","x-large"]),function(n){var e=function(){n._skinLoaded=!0,n.fire("SkinLoaded")};return function(){n.initialized?e():n.on("init",e)}}),av=O.constant("toReading"),cv=O.constant("toEditing");wr.add("mobile",function(C){return{getNotificationManagerImpl:function(){return{open:O.identity,close:O.noop,reposition:O.noop,getArgs:O.identity}},renderUI:function(n){var e=ov(C);0==(!1===C.settings.skin)?(C.contentCSS.push(e.content),yr.DOM.styleSheetLoader.load(e.ui,uv(C))):uv(C)();var t,o,r,i,u,a,c,s,f,l,d,m,g,p,v=function(){C.fire("scrollIntoView")},h=Xn.fromTag("div"),b=Mn.detect().os.isAndroid()?(s=v,f=up({classes:[gi.resolve("android-container")]}),l=Tg(),d=tl.api(),m=Og.makeEditSwitch(d),g=Og.makeSocket(),p=Wg(O.noop,s),f.add(l.wrapper()),f.add(g),f.add(p.component()),{system:O.constant(f),element:f.element,init:function(n){d.set(lg.produce(n))},exit:function(){d.run(function(n){n.exit(),cd.remove(g,m)})},setToolbarGroups:function(n){var e=l.createGroups(n);l.setGroups(e)},setContextToolbar:function(n){var e=l.createGroups(n);l.setContextToolbar(e)},focusToolbar:function(){l.focus()},restoreToolbar:function(){l.restoreToolbar()},updateMode:function(n){Og.updateMode(g,m,n,f.root())},socket:O.constant(g),dropup:O.constant(p)}):(t=v,o=up({classes:[gi.resolve("ios-container")]}),r=Tg(),i=tl.api(),u=Og.makeEditSwitch(i),a=Og.makeSocket(),c=Wg(function(){i.run(function(n){n.refreshStructure()})},t),o.add(r.wrapper()),o.add(a),o.add(c.component()),{system:O.constant(o),element:o.element,init:function(n){i.set(ev.produce(n))},exit:function(){i.run(function(n){cd.remove(a,u),n.exit()})},setToolbarGroups:function(n){var e=r.createGroups(n);r.setGroups(e)},setContextToolbar:function(n){var e=r.createGroups(n);r.setContextToolbar(e)},focusToolbar:function(){r.focus()},restoreToolbar:function(){r.restoreToolbar()},updateMode:function(n){Og.updateMode(a,u,n,o.root())},socket:O.constant(a),dropup:O.constant(c)}),y=Xn.fromDom(n.targetNode);Fe.after(y,h),function(n,e){Fe.append(n,e.element());var t=Be.children(e.element());vn.each(t,function(n){e.getByDom(n).each(ze)})}(h,b.system());var w=n.targetNode.ownerDocument.defaultView,x=Kd(w,{onChange:function(){b.system().broadcastOn([Sr.orientationChanged()],{width:Xd(w)})},onReady:O.noop}),S=function(n,e,t,o){!1===o&&C.selection.collapse();var r=T(n,e,t);b.setToolbarGroups(!0===o?r.readOnly:r.main),C.setMode(!0===o?"readonly":"design"),C.fire(!0===o?av():cv()),b.updateMode(o)},T=function(n,e,t){var o=n.get(),r={readOnly:o.backToMask.concat(e.get()),main:o.backToMask.concat(t.get())};return r},k=function(n,e){return C.on(n,e),{unbind:function(){C.off(n)}}};return C.on("init",function(){b.init({editor:{getFrame:function(){return Xn.fromDom(C.contentAreaContainer.querySelector("iframe"))},onDomChanged:function(){return{unbind:O.noop}},onToReading:function(n){return k(av(),n)},onToEditing:function(n){return k(cv(),n)},onScrollToCursor:function(e){return C.on("scrollIntoView",function(n){e(n)}),{unbind:function(){C.off("scrollIntoView"),x.destroy()}}},onTouchToolstrip:function(){t()},onTouchContent:function(){var n,e=Xn.fromDom(C.editorContainer.querySelector("."+gi.resolve("toolbar")));(n=e,br(n).bind(function(n){return b.system().getByDom(n).toOption()})).each($n),b.restoreToolbar(),t()},onTapContent:function(n){var e=n.target();"img"===ue.name(e)?(C.selection.select(e.dom()),n.kill()):"a"===ue.name(e)&&b.system().getByDom(Xn.fromDom(C.editorContainer)).each(function(n){ir.isAlpha(n)&&xr(e.dom())})}},container:Xn.fromDom(C.editorContainer),socket:Xn.fromDom(C.contentAreaContainer),toolstrip:Xn.fromDom(C.editorContainer.querySelector("."+gi.resolve("toolstrip"))),toolbar:Xn.fromDom(C.editorContainer.querySelector("."+gi.resolve("toolbar"))),dropup:b.dropup(),alloy:b.system(),translate:O.noop,setReadOnly:function(n){S(c,a,u,n)},readOnlyOnInit:function(){return!1}});var t=function(){b.dropup().disappear(function(){b.system().broadcastOn([Sr.dropupDismissed()],{})})},n={label:"The first group",scrollable:!1,items:[Yc.forToolbar("back",function(){C.selection.collapse(),b.exit()},{})]},e={label:"Back to read only",scrollable:!1,items:[Yc.forToolbar("readonly-back",function(){S(c,a,u,!0)},{})]},o=Hd(b,C),r=jd(C.settings,o),i={label:"The extra group",scrollable:!1,items:[]},u=ur([{label:"the action group",scrollable:!0,items:r},i]),a=ur([{label:"The read only mode group",scrollable:!0,items:[]},i]),c=ur({backToMask:[n],backToReadOnly:[e]});iv(b,C)}),{iframeContainer:b.socket().element().dom(),editorContainer:b.element().dom()}}}})}();