agenda-libre-ruby/public/assets/tinymce/themes/mobile/theme-1b5655e2a8eaa4ed42fa4cf27355384d0aca89d4c1a80e02732d40731df2f2e8.js
2019-08-04 22:45:24 +02:00

11 lines
167 KiB
JavaScript

/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
* Version: 5.0.12 (2019-07-18)
*/
!function(v){"use strict";var y=function(){return(y=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}).apply(this,arguments)};function a(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(n);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(t[r[o]]=n[r[o]])}return t}var x=function(){},p=function(t,r){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(r.apply(null,n))}},h=function(n){return function(){return n}},b=function(n){return n};function l(r){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=o.concat(n);return r.apply(null,t)}}var n,e,t,r,o,i,u,w=function(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return!t.apply(null,n)}},c=function(n){return function(){throw new Error(n)}},f=function(n){return n()},s=h(!1),d=h(!0),m=s,g=d,S=function(){return O},O=(r={fold:function(n,e){return n()},is:m,isSome:m,isNone:g,getOr:t=function(n){return n},getOrThunk:e=function(n){return n()},getOrDie:function(n){throw new Error(n||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:t,orThunk:e,map:S,ap:S,each:function(){},bind:S,flatten:S,exists:m,forall:g,filter:S,equals:n=function(n){return n.isNone()},equals_:n,toArray:function(){return[]},toString:h("none()")},Object.freeze&&Object.freeze(r),r),T=function(t){var n=function(){return t},e=function(){return o},r=function(n){return n(t)},o={fold:function(n,e){return e(t)},is:function(n){return t===n},isSome:g,isNone:m,getOr:n,getOrThunk:n,getOrDie:n,getOrNull:n,getOrUndefined:n,or:e,orThunk:e,map:function(n){return T(n(t))},ap:function(n){return n.fold(S,function(n){return T(n(t))})},each:function(n){n(t)},bind:r,flatten:n,exists:r,forall:r,filter:function(n){return n(t)?o:O},equals:function(n){return n.is(t)},equals_:function(n,e){return n.fold(m,function(n){return e(t,n)})},toArray:function(){return[t]},toString:function(){return"some("+t+")"}};return o},k={some:T,none:S,from:function(n){return null===n||n===undefined?O:T(n)}},E=Object.keys,C=Object.hasOwnProperty,D=function(n,e){for(var t=E(n),r=0,o=t.length;r<o;r++){var i=t[r];e(n[i],i,n)}},M=function(n,r){return I(n,function(n,e,t){return{k:e,v:r(n,e,t)}})},I=function(r,o){var i={};return D(r,function(n,e){var t=o(n,e,r);i[t.k]=t.v}),i},R=function(n,t){var r=[];return D(n,function(n,e){r.push(t(n,e))}),r},B=function(n,e){return C.call(n,e)},A=h("touchstart"),F=h("touchmove"),V=h("touchend"),N=h("mousedown"),j=h("mousemove"),H=h("mouseup"),z=h("mouseover"),P=h("keydown"),L=h("keyup"),G=h("input"),$=h("change"),U=h("click"),W=h("transitionend"),_=h("selectstart"),X=function(t){var r,o=!1;return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return o||(o=!0,r=t.apply(null,n)),r}},q=function(n,e){var t=function(n,e){for(var t=0;t<n.length;t++){var r=n[t];if(r.test(e))return r}return undefined}(n,e);if(!t)return{major:0,minor:0};var r=function(n){return Number(e.replace(t,"$"+n))};return K(r(1),r(2))},Y=function(){return K(0,0)},K=function(n,e){return{major:n,minor:e}},J={nu:K,detect:function(n,e){var t=String(e).toLowerCase();return 0===n.length?Y():q(n,t)},unknown:Y},Q="Edge",Z="Chrome",nn="Opera",en="Firefox",tn="Safari",rn=function(n,e){return function(){return e===n}},on=function(n){var e=n.current;return{current:e,version:n.version,isEdge:rn(Q,e),isChrome:rn(Z,e),isIE:rn("IE",e),isOpera:rn(nn,e),isFirefox:rn(en,e),isSafari:rn(tn,e)}},un={unknown:function(){return on({current:undefined,version:J.unknown()})},nu:on,edge:h(Q),chrome:h(Z),ie:h("IE"),opera:h(nn),firefox:h(en),safari:h(tn)},cn="Windows",an="Android",fn="Solaris",sn="FreeBSD",ln=function(n,e){return function(){return e===n}},dn=function(n){var e=n.current;return{current:e,version:n.version,isWindows:ln(cn,e),isiOS:ln("iOS",e),isAndroid:ln(an,e),isOSX:ln("OSX",e),isLinux:ln("Linux",e),isSolaris:ln(fn,e),isFreeBSD:ln(sn,e)}},mn={unknown:function(){return dn({current:undefined,version:J.unknown()})},nu:dn,windows:h(cn),ios:h("iOS"),android:h(an),linux:h("Linux"),osx:h("OSX"),solaris:h(fn),freebsd:h(sn)},gn=function(e){return function(n){return function(n){if(null===n)return"null";var e=typeof n;return"object"===e&&(Array.prototype.isPrototypeOf(n)||n.constructor&&"Array"===n.constructor.name)?"array":"object"===e&&(String.prototype.isPrototypeOf(n)||n.constructor&&"String"===n.constructor.name)?"string":e}(n)===e}},pn=gn("string"),vn=gn("object"),hn=gn("array"),bn=gn("boolean"),yn=gn("function"),xn=gn("number"),wn=Array.prototype.slice,Sn=(o=Array.prototype.indexOf)===undefined?function(n,e){return Bn(n,e)}:function(n,e){return o.call(n,e)},On=function(n,e){return-1<Sn(n,e)},Tn=function(n,e){return Rn(n,e).isSome()},kn=function(n,e){for(var t=n.length,r=new Array(t),o=0;o<t;o++){var i=n[o];r[o]=e(i,o,n)}return r},En=function(n,e){for(var t=0,r=n.length;t<r;t++){e(n[t],t,n)}},Cn=function(n,e){for(var t=[],r=0,o=n.length;r<o;r++){var i=n[r];e(i,r,n)&&t.push(i)}return t},Dn=function(n,e,t){return function(n,e){for(var t=n.length-1;0<=t;t--)e(n[t],t,n)}(n,function(n){t=e(t,n)}),t},Mn=function(n,e,t){return En(n,function(n){t=e(t,n)}),t},In=function(n,e){for(var t=0,r=n.length;t<r;t++){var o=n[t];if(e(o,t,n))return k.some(o)}return k.none()},Rn=function(n,e){for(var t=0,r=n.length;t<r;t++){if(e(n[t],t,n))return k.some(t)}return k.none()},Bn=function(n,e){for(var t=0,r=n.length;t<r;++t)if(n[t]===e)return t;return-1},An=Array.prototype.push,Fn=function(n){for(var e=[],t=0,r=n.length;t<r;++t){if(!hn(n[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+n);An.apply(e,n[t])}return e},Vn=function(n,e){var t=kn(n,e);return Fn(t)},Nn=function(n,e){for(var t=0,r=n.length;t<r;++t){if(!0!==e(n[t],t,n))return!1}return!0},jn=function(n){var e=wn.call(n,0);return e.reverse(),e},Hn=function(n){return[n]},zn=(yn(Array.from)&&Array.from,function(n,e){var t=String(e).toLowerCase();return In(n,function(n){return n.search(t)})}),Pn=function(n,t){return zn(n,t).map(function(n){var e=J.detect(n.versionRegexes,t);return{current:n.name,version:e}})},Ln=function(n,t){return zn(n,t).map(function(n){var e=J.detect(n.versionRegexes,t);return{current:n.name,version:e}})},Gn=function(n,e){return-1!==n.indexOf(e)},$n=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Un=function(e){return function(n){return Gn(n,e)}},Wn=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(n){return Gn(n,"edge/")&&Gn(n,"chrome")&&Gn(n,"safari")&&Gn(n,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,$n],search:function(n){return Gn(n,"chrome")&&!Gn(n,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(n){return Gn(n,"msie")||Gn(n,"trident")}},{name:"Opera",versionRegexes:[$n,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Un("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Un("firefox")},{name:"Safari",versionRegexes:[$n,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(n){return(Gn(n,"safari")||Gn(n,"mobile/"))&&Gn(n,"applewebkit")}}],_n=[{name:"Windows",search:Un("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(n){return Gn(n,"iphone")||Gn(n,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Un("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:Un("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Un("linux"),versionRegexes:[]},{name:"Solaris",search:Un("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Un("freebsd"),versionRegexes:[]}],Xn={browsers:h(Wn),oses:h(_n)},qn=function(n){var e,t,r,o,i,u,c,a,f,s,l,d=Xn.browsers(),m=Xn.oses(),g=Pn(d,n).fold(un.unknown,un.nu),p=Ln(m,n).fold(mn.unknown,mn.nu);return{browser:g,os:p,deviceType:(t=g,r=n,o=(e=p).isiOS()&&!0===/ipad/i.test(r),i=e.isiOS()&&!o,u=e.isAndroid()&&3===e.version.major,c=e.isAndroid()&&4===e.version.major,a=o||u||c&&!0===/mobile/i.test(r),f=e.isiOS()||e.isAndroid(),s=f&&!a,l=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(r),{isiPad:h(o),isiPhone:h(i),isTablet:h(a),isPhone:h(s),isTouch:h(f),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:h(l)})}},Yn={detect:X(function(){var n=v.navigator.userAgent;return qn(n)})},Kn={tap:h("alloy.tap")},Jn=h("alloy.focus"),Qn=h("alloy.blur.post"),Zn=h("alloy.paste.post"),ne=h("alloy.receive"),ee=h("alloy.execute"),te=h("alloy.focus.item"),re=Kn.tap,oe=Yn.detect().deviceType.isTouch()?Kn.tap:U,ie=h("alloy.longpress"),ue=h("alloy.system.init"),ce=h("alloy.system.attached"),ae=h("alloy.system.detached"),fe=h("alloy.focusmanager.shifted"),se=h("alloy.highlight"),le=h("alloy.dehighlight"),de=function(n,e){ve(n,n.element(),e,{})},me=function(n,e,t){ve(n,n.element(),e,t)},ge=function(n){de(n,ee())},pe=function(n,e,t){ve(n,e,t,{})},ve=function(n,e,t,r){var o=y({target:e},r);n.getSystem().triggerEvent(t,e,M(o,h))},he=function(n){if(null===n||n===undefined)throw new Error("Node cannot be null or undefined");return{dom:h(n)}},be={fromHtml:function(n,e){var t=(e||v.document).createElement("div");if(t.innerHTML=n,!t.hasChildNodes()||1<t.childNodes.length)throw v.console.error("HTML does not have a single root node",n),new Error("HTML must have a single root node");return he(t.childNodes[0])},fromTag:function(n,e){var t=(e||v.document).createElement(n);return he(t)},fromText:function(n,e){var t=(e||v.document).createTextNode(n);return he(t)},fromDom:he,fromPoint:function(n,e,t){var r=n.dom();return k.from(r.elementFromPoint(e,t)).map(he)}},ye=(v.Node.ATTRIBUTE_NODE,v.Node.CDATA_SECTION_NODE,v.Node.COMMENT_NODE,v.Node.DOCUMENT_NODE),xe=(v.Node.DOCUMENT_TYPE_NODE,v.Node.DOCUMENT_FRAGMENT_NODE,v.Node.ELEMENT_NODE),we=v.Node.TEXT_NODE,Se=(v.Node.PROCESSING_INSTRUCTION_NODE,v.Node.ENTITY_REFERENCE_NODE,v.Node.ENTITY_NODE,v.Node.NOTATION_NODE,function(n){return n.dom().nodeName.toLowerCase()}),Oe=function(e){return function(n){return n.dom().nodeType===e}},Te=Oe(xe),ke=Oe(we),Ee=function(n){var e=ke(n)?n.dom().parentNode:n.dom();return e!==undefined&&null!==e&&e.ownerDocument.body.contains(e)},Ce=X(function(){return De(be.fromDom(v.document))}),De=function(n){var e=n.dom().body;if(null===e||e===undefined)throw new Error("Body is not available yet");return be.fromDom(e)},Me=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 r={};return En(e,function(n,e){r[n]=h(t[e])}),r}},Ie=function(n){return n.slice(0).sort()},Re=function(e,n){if(!hn(n))throw new Error("The "+e+" fields must be an array. Was: "+n+".");En(n,function(n){if(!pn(n))throw new Error("The value "+n+" in the "+e+" fields was not a string.")})},Be=function(o,i){var t,u=o.concat(i);if(0===u.length)throw new Error("You must specify at least one required or optional field.");return Re("required",o),Re("optional",i),t=Ie(u),In(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(", ")+"].")}),function(e){var t=E(e);Nn(o,function(n){return On(t,n)})||function(n,e){throw new Error("All required keys ("+Ie(n).join(", ")+") were not specified. Specified keys were: "+Ie(e).join(", ")+".")}(o,t);var n=Cn(t,function(n){return!On(u,n)});0<n.length&&function(n){throw new Error("Unsupported keys for object: "+Ie(n).join(", "))}(n);var r={};return En(o,function(n){r[n]=h(e[n])}),En(i,function(n){r[n]=h(Object.prototype.hasOwnProperty.call(e,n)?k.some(e[n]):k.none())}),r}},Ae="undefined"!=typeof v.window?v.window:Function("return this;")(),Fe=function(n,e){return function(n,e){for(var t=e!==undefined&&null!==e?e:Ae,r=0;r<n.length&&t!==undefined&&null!==t;++r)t=t[n[r]];return t}(n.split("."),e)},Ve={getOrDie:function(n,e){var t=Fe(n,e);if(t===undefined||null===t)throw new Error(n+" not available on this browser");return t}},Ne=function(){return Ve.getOrDie("Node")},je=function(n,e,t){return 0!=(n.compareDocumentPosition(e)&t)},He=function(n,e){return je(n,e,Ne().DOCUMENT_POSITION_CONTAINED_BY)},ze=xe,Pe=ye,Le=function(n,e){var t=n.dom();if(t.nodeType!==ze)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")},Ge=function(n){return n.nodeType!==ze&&n.nodeType!==Pe||0===n.childElementCount},$e=function(n,e){var t=e===undefined?v.document:e.dom();return Ge(t)?[]:kn(t.querySelectorAll(n),be.fromDom)},Ue=function(n,e){var t=e===undefined?v.document:e.dom();return Ge(t)?k.none():k.from(t.querySelector(n)).map(be.fromDom)},We=function(n,e){return n.dom()===e.dom()},_e=(Yn.detect().browser.isIE(),function(n){return be.fromDom(n.dom().ownerDocument)}),Xe=function(n){var e=n.dom();return k.from(e.parentNode).map(be.fromDom)},qe=function(n){var e=n.dom();return kn(e.childNodes,be.fromDom)},Ye=function(n,e){var t=n.dom().childNodes;return k.from(t[e]).map(be.fromDom)},Ke=(Me("element","offset"),function(e,t){Xe(e).each(function(n){n.dom().insertBefore(t.dom(),e.dom())})}),Je=function(n,e){var t;(t=n.dom(),k.from(t.nextSibling).map(be.fromDom)).fold(function(){Xe(n).each(function(n){Ze(n,e)})},function(n){Ke(n,e)})},Qe=function(e,t){Ye(e,0).fold(function(){Ze(e,t)},function(n){e.dom().insertBefore(t.dom(),n.dom())})},Ze=function(n,e){n.dom().appendChild(e.dom())},nt=function(e,n){En(n,function(n){Ze(e,n)})},et=function(n){n.dom().textContent="",En(qe(n),function(n){tt(n)})},tt=function(n){var e=n.dom();null!==e.parentNode&&e.parentNode.removeChild(e)},rt=function(n){de(n,ae());var e=n.components();En(e,rt)},ot=function(n){var e=n.components();En(e,ot),de(n,ce())},it=function(n,e){ut(n,e,Ze)},ut=function(n,e,t){n.getSystem().addToWorld(e),t(n.element(),e.element()),Ee(n.element())&&ot(e),n.syncComponents()},ct=function(n){rt(n),tt(n.element()),n.getSystem().removeFromWorld(n)},at=function(e){var n=Xe(e.element()).bind(function(n){return e.getSystem().getByDom(n).fold(k.none,k.some)});ct(e),n.each(function(n){n.syncComponents()})},ft=function(n,e,t){t(n,e.element());var r=qe(e.element());En(r,function(n){e.getByDom(n).each(ot)})},st=function(t){return{is:function(n){return t===n},isValue:d,isError:s,getOr:h(t),getOrThunk:h(t),getOrDie:h(t),or:function(n){return st(t)},orThunk:function(n){return st(t)},fold:function(n,e){return e(t)},map:function(n){return st(n(t))},mapError:function(n){return st(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 k.some(t)}}},lt=function(t){return{is:s,isValue:s,isError:d,getOr:b,getOrThunk:function(n){return n()},getOrDie:function(){return c(String(t))()},or:function(n){return n},orThunk:function(n){return n()},fold:function(n,e){return n(t)},map:function(n){return lt(t)},mapError:function(n){return lt(n(t))},each:x,bind:function(n){return lt(t)},exists:s,forall:d,toOption:k.none}},dt={value:st,error:lt,fromOption:function(n,e){return n.fold(function(){return lt(e)},st)}},mt=function(u){if(!hn(u))throw new Error("cases must be an array");if(0===u.length)throw new Error("there must be at least one case");var c=[],t={};return En(u,function(n,r){var e=E(n);if(1!==e.length)throw new Error("one and only one name per case");var o=e[0],i=n[o];if(t[o]!==undefined)throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!hn(i))throw new Error("case arguments must be an array");c.push(o),t[o]=function(){var n=arguments.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+o+". 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[r].apply(null,t)},match:function(n){var e=E(n);if(c.length!==e.length)throw new Error("Wrong number of arguments to match. Expected: "+c.join(",")+"\nActual: "+e.join(","));if(!Nn(c,function(n){return On(e,n)}))throw new Error("Not all branches were specified when using match. Specified: "+e.join(", ")+"\nRequired: "+c.join(", "));return n[o].apply(null,t)},log:function(n){v.console.log(n,{constructors:c,constructor:o,params:t})}}}}),t},gt=Object.prototype.hasOwnProperty,pt=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={},r=0;r<n.length;r++){var o=n[r];for(var i in o)gt.call(o,i)&&(t[i]=u(t[i],o[i]))}return t}},vt=pt(function(n,e){return vn(n)&&vn(e)?vt(n,e):e}),ht=pt(function(n,e){return e}),bt=mt([{strict:[]},{defaultedThunk:["fallbackThunk"]},{asOption:[]},{asDefaultedOptionThunk:["fallbackThunk"]},{mergeWithThunk:["baseThunk"]}]),yt=function(n){return bt.defaultedThunk(h(n))},xt=bt.strict,wt=bt.asOption,St=bt.defaultedThunk,Ot=bt.mergeWithThunk,Tt=function(e){return function(n){return B(n,e)?k.from(n[e]):k.none()}},kt=function(n,e){return Tt(e)(n)},Et=function(n,e){var t={};return t[n]=e,t},Ct=(mt([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),function(n,e){return t=e,r={},D(n,function(n,e){On(t,e)||(r[e]=n)}),r;var t,r}),Dt=function(n){return Tt(n)},Mt=function(n,e){return t=n,r=e,function(n){return B(n,t)?n[t]:r};var t,r},It=function(n,e){return kt(n,e)},Rt=function(n,e){return Et(n,e)},Bt=function(n){return e={},En(n,function(n){e[n.key]=n.value}),e;var e},At=function(n,e){var t,r,o,i,u,c=(t=[],r=[],En(n,function(n){n.fold(function(n){t.push(n)},function(n){r.push(n)})}),{errors:t,values:r});return 0<c.errors.length?(u=c.errors,p(dt.error,Fn)(u)):(i=e,0===(o=c.values).length?dt.value(i):dt.value(vt(i,ht.apply(undefined,o))))},Ft=function(n,e){return B(t=n,r=e)&&t[r]!==undefined&&null!==t[r];var t,r};(u=i||(i={}))[u.Error=0]="Error",u[u.Value=1]="Value";var Vt,Nt,jt=function(n,e,t){return n.stype===i.Error?e(n.serror):t(n.svalue)},Ht=function(n){return{stype:i.Value,svalue:n}},zt=function(n){return{stype:i.Error,serror:n}},Pt=function(n){return n.fold(zt,Ht)},Lt=function(n){return jt(n,dt.error,dt.value)},Gt=Ht,$t=function(n){var e=[],t=[];return En(n,function(n){jt(n,function(n){return t.push(n)},function(n){return e.push(n)})}),{values:e,errors:t}},Ut=zt,Wt=function(n,e){return n.stype===i.Value?e(n.svalue):n},_t=function(n,e){return n.stype===i.Error?e(n.serror):n},Xt=function(n,e){return n.stype===i.Value?{stype:i.Value,svalue:e(n.svalue)}:n},qt=function(n,e){return n.stype===i.Error?{stype:i.Error,serror:e(n.serror)}:n},Yt=function(n){return p(Ut,Fn)(n)},Kt=function(n,e){var t,r,o=$t(n);return 0<o.errors.length?Yt(o.errors):(t=o.values,r=e,0<t.length?Gt(vt(r,ht.apply(undefined,t))):Gt(r))},Jt=function(n){var e=$t(n);return 0<e.errors.length?Yt(e.errors):Gt(e.values)},Qt=mt([{setOf:["validator","valueType"]},{arrOf:["valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key","branches"]},{thunk:["description"]},{func:["args","outputSchema"]}]),Zt=mt([{field:["name","presence","type"]},{state:["name"]}]),nr=function(){return Ve.getOrDie("JSON")},er=function(n,e,t){return nr().stringify(n,e,t)},tr=function(n){return vn(n)&&100<E(n).length?" removed due to size":er(n,null,2)},rr=function(n,e){return Ut([{path:n,getErrorInfo:e}])},or=mt([{field:["key","okey","presence","prop"]},{state:["okey","instantiator"]}]),ir=function(t,r,o){return kt(r,o).fold(function(){return n=o,e=r,rr(t,function(){return'Could not find valid *strict* value for "'+n+'" in '+tr(e)});var n,e},Gt)},ur=function(n,e,t){var r=kt(n,e).fold(function(){return t(n)},b);return Gt(r)},cr=function(c,a,n,f){return n.fold(function(o,t,n,r){var i=function(n){var e=r.extract(c.concat([o]),f,n);return Xt(e,function(n){return Et(t,f(n))})},u=function(n){return n.fold(function(){var n=Et(t,f(k.none()));return Gt(n)},function(n){var e=r.extract(c.concat([o]),f,n);return Xt(e,function(n){return Et(t,f(k.some(n)))})})};return n.fold(function(){return Wt(ir(c,a,o),i)},function(n){return Wt(ur(a,o,n),i)},function(){return Wt(Gt(kt(a,o)),u)},function(n){return Wt((t=n,r=kt(e=a,o).map(function(n){return!0===n?t(e):n}),Gt(r)),u);var e,t,r},function(n){var e=n(a),t=Xt(ur(a,o,h({})),function(n){return vt(e,n)});return Wt(t,i)})},function(n,e){var t=e(a);return Gt(Et(n,f(t)))})},ar=function(r){return{extract:function(t,n,e){return _t(r(e,n),function(n){return e=n,rr(t,function(){return e});var e})},toString:function(){return"val"},toDsl:function(){return Qt.itemOf(r)}}},fr=function(n){var a=sr(n),f=Dn(n,function(e,n){return n.fold(function(n){return vt(e,Rt(n,!0))},h(e))},{});return{extract:function(n,e,t){var r,o,i,u=bn(t)?[]:(o=E(r=t),Cn(o,function(n){return Ft(r,n)})),c=Cn(u,function(n){return!Ft(f,n)});return 0===c.length?a.extract(n,e,t):(i=c,rr(n,function(){return"There are unsupported fields: ["+i.join(", ")+"] specified"}))},toString:a.toString,toDsl:a.toDsl}},sr=function(c){return{extract:function(n,e,t){return r=n,o=t,i=e,u=kn(c,function(n){return cr(r,o,n,i)}),Kt(u,{});var r,o,i,u},toString:function(){return"obj{\n"+kn(c,function(n){return n.fold(function(n,e,t,r){return n+" -> "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return Qt.objOf(kn(c,function(n){return n.fold(function(n,e,t,r){return Zt.field(n,t,r)},function(n,e){return Zt.state(n)})}))}}},lr=function(t,i){var u=function(n,e){return(o=ar(t),{extract:function(t,r,n){var e=kn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return Jt(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return Qt.arrOf(o)}}).extract(n,b,e);var o};return{extract:function(t,r,o){var n=E(o),e=u(t,n);return Wt(e,function(n){var e=kn(n,function(n){return or.field(n,n,xt(),i)});return sr(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return Qt.setOf(t,i)}}},dr=h(ar(Gt)),mr=or.state,gr=or.field,pr=function(t,e,r,o,i){return It(o,i).fold(function(){return n=o,e=i,rr(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+tr(n)});var n,e},function(n){return sr(n).extract(t.concat(["branch: "+i]),e,r)})},vr=function(o,i){return{extract:function(e,t,r){return It(r,o).fold(function(){return n=o,rr(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return pr(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+E(i)},toDsl:function(){return Qt.choiceOf(o,i)}}},hr=ar(Gt),br=function(e){return ar(function(n){return e(n).fold(Ut,Gt)})},yr=function(e,n){return lr(function(n){return Pt(e(n))},n)},xr=function(n,e,t){return Lt((r=n,o=b,i=t,u=e.extract([r],o,i),qt(u,function(n){return{input:i,errors:n}})));var r,o,i,u},wr=function(n){return n.fold(function(n){throw new Error(Or(n))},b)},Sr=function(n,e,t){return wr(xr(n,e,t))},Or=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,kn(t,function(n){return"Failed path: ("+n.path.join(" > ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+tr(n.input);var e,t},Tr=function(n,e){return vr(n,e)},kr=h(hr),Er=(Vt=yn,Nt="function",ar(function(n){var e=typeof n;return Vt(n)?Gt(n):Ut("Expected type: "+Nt+" but got: "+e)})),Cr=function(n){return gr(n,n,xt(),dr())},Dr=function(n,e){return gr(n,n,xt(),e)},Mr=function(n,e){return gr(n,n,xt(),sr(e))},Ir=function(n){return gr(n,n,wt(),dr())},Rr=function(n,e){return gr(n,n,wt(),e)},Br=function(n,e){return Rr(n,sr(e))},Ar=function(n,e){return Rr(n,fr(e))},Fr=function(n,e){return gr(n,n,yt(e),dr())},Vr=function(n,e,t){return gr(n,n,yt(e),t)},Nr=function(n,e){return mr(n,e)},jr=function(n,e){return We(n.element(),e.event().target())},Hr=function(n){if(!Ft(n,"can")&&!Ft(n,"abort")&&!Ft(n,"run"))throw new Error("EventHandler defined by: "+er(n,null,2)+" does not have can, abort, or run!");return Sr("Extracting event.handler",fr([Fr("can",h(!0)),Fr("abort",h(!1)),Fr("run",x)]),n)},zr=function(t){var e,r,o,i,n=(e=t,r=function(n){return n.can},function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Mn(e,function(n,e){return n&&r(e).apply(undefined,t)},!0)}),u=(o=t,i=function(n){return n.abort},function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Mn(o,function(n,e){return n||i(e).apply(undefined,t)},!1)});return Hr({can:n,abort:u,run:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];En(t,function(n){n.run.apply(undefined,e)})}})};function Pr(n,e,t,r,o){return n(t,r)?k.some(t):yn(o)&&o(t)?k.none():e(t,r,o)}var Lr,Gr,$r,Ur=function(n,e,t){for(var r=n.dom(),o=yn(t)?t:h(!1);r.parentNode;){r=r.parentNode;var i=be.fromDom(r);if(e(i))return k.some(i);if(o(i))break}return k.none()},Wr=function(n,e,t){return Pr(function(n){return e(n)},Ur,n,e,t)},_r=function(n,r){var o=function(n){for(var e=0;e<n.childNodes.length;e++){if(r(be.fromDom(n.childNodes[e])))return k.some(be.fromDom(n.childNodes[e]));var t=o(n.childNodes[e]);if(t.isSome())return t}return k.none()};return o(n.dom())},Xr=function(n,e,t){return Wr(n,function(n){return e(n).isSome()},t).bind(e)},qr=function(n){return Bt(n)},Yr=function(n,e){return{key:n,value:Hr({abort:e})}},Kr=function(n,e){return{key:n,value:Hr({run:e})}},Jr=function(n,e,t){return{key:n,value:Hr({run:function(n){e.apply(undefined,[n].concat(t))}})}},Qr=function(n){return function(t){return{key:n,value:Hr({run:function(n,e){jr(n,e)&&t(n,e)}})}}},Zr=function(n,e,t){var u,r,o=e.partUids[t];return r=o,Kr(u=n,function(n,i){n.getSystem().getByUid(r).each(function(n){var e,t,r,o;t=(e=n).element(),r=u,o=i,e.getSystem().triggerEvent(r,t,o.event())})})},no=function(n){return Kr(n,function(n,e){e.cut()})},eo=Qr(ce()),to=Qr(ae()),ro=Qr(ue()),oo=(Lr=ee(),function(n){return Kr(Lr,n)}),io=function(n){return kn(n,function(n){return r=e="/*",o=(t=n).length-e.length,""!==r&&(t.length<r.length||t.substr(o,o+r.length)!==r)?n:n.substring(0,n.length-"/*".length);var e,t,r,o})},uo=function(n,e){var t=n.toString(),r=t.indexOf(")")+1,o=t.indexOf("("),i=t.substring(o+1,r-1).split(/,\s*/);return n.toFunctionAnnotation=function(){return{name:e,parameters:io(i)}},n},co=function(n){return{classes:n.classes!==undefined?n.classes:[],attributes:n.attributes!==undefined?n.attributes:{},styles:n.styles!==undefined?n.styles:{}}},ao=function(t,r,o){return ro(function(n,e){o(n,t,r)})},fo=function(o,i,u){var n,e,t,r,c,a;return n=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=[t].concat(n);return t.config({name:h(o)}).fold(function(){throw new Error("We could not find any behaviour configuration for: "+o+". Using API: "+u)},function(n){var e=Array.prototype.slice.call(r,1);return i.apply(undefined,[t,n.config,n.state].concat(e))})},e=u,t=i.toString(),r=t.indexOf(")")+1,c=t.indexOf("("),a=t.substring(c+1,r-1).split(/,\s*/),n.toFunctionAnnotation=function(){return{name:e,parameters:io(a.slice(0,1).concat(a.slice(3)))}},n},so=function(n){return{key:n,value:undefined}},lo=function(t,n,r,o,e,i,u){var c=function(n){return Ft(n,r)?n[r]():k.none()},a=M(e,function(n,e){return fo(r,n,e)}),f=M(i,function(n,e){return uo(n,e)}),s=y({},f,a,{revoke:l(so,r),config:function(n){var e=Sr(r+"-config",t,n);return{key:r,value:{config:e,me:s,configAsRaw:X(function(){return Sr(r+"-config",t,n)}),initialConfig:n,state:u}}},schema:function(){return n},exhibit:function(n,t){return c(n).bind(function(e){return It(o,"exhibit").map(function(n){return n(t,e.config,e.state)})}).getOr(co({}))},name:function(){return r},handlers:function(n){return c(n).map(function(n){return Mt("events",function(n,e){return{}})(o)(n.config,n.state)}).getOr({})}});return s},mo={init:function(){return go({readState:function(){return"No State required"}})}},go=function(n){return n},po=function(n){return Bt(n)},vo=fr([Cr("fields"),Cr("name"),Fr("active",{}),Fr("apis",{}),Fr("state",mo),Fr("extra",{})]),ho=function(n){var e,t,r,o,i,u,c,a,f=Sr("Creating behaviour: "+n.name,vo,n);return e=f.fields,t=f.name,r=f.active,o=f.apis,i=f.extra,u=f.state,c=fr(e),a=Br(t,[Ar("config",e)]),lo(c,a,t,r,o,i,u)},bo=fr([Cr("branchKey"),Cr("branches"),Cr("name"),Fr("active",{}),Fr("apis",{}),Fr("state",mo),Fr("extra",{})]),yo=h(undefined),xo=function(n,e,t){if(!(pn(t)||bn(t)||xn(t)))throw v.console.error("Invalid call to Attr.set. Key ",e,":: Value ",t,":: Element ",n),new Error("Attribute value was not simple");n.setAttribute(e,t+"")},wo=function(n,e,t){xo(n.dom(),e,t)},So=function(n,e){var t=n.dom();D(e,function(n,e){xo(t,e,n)})},Oo=function(n,e){var t=n.dom().getAttribute(e);return null===t?undefined:t},To=function(n,e){var t=n.dom();return!(!t||!t.hasAttribute)&&t.hasAttribute(e)},ko=function(n,e){n.dom().removeAttribute(e)},Eo=function(n,e){var t=Oo(n,e);return t===undefined||""===t?[]:t.split(" ")},Co=function(n){return n.dom().classList!==undefined},Do=function(n,e){return o=e,i=Eo(t=n,r="class").concat([o]),wo(t,r,i.join(" ")),!0;var t,r,o,i},Mo=function(n,e){return o=e,0<(i=Cn(Eo(t=n,r="class"),function(n){return n!==o})).length?wo(t,r,i.join(" ")):ko(t,r),!1;var t,r,o,i},Io=function(n,e){Co(n)?n.dom().classList.add(e):Do(n,e)},Ro=function(n){0===(Co(n)?n.dom().classList:Eo(n,"class")).length&&ko(n,"class")},Bo=function(n,e){Co(n)?n.dom().classList.remove(e):Mo(n,e);Ro(n)},Ao=function(n,e){return Co(n)&&n.dom().classList.contains(e)},Fo=function(n,e,t){Bo(n,t),Io(n,e)},Vo=/* */Object.freeze({toAlpha:function(n,e,t){Fo(n.element(),e.alpha,e.omega)},toOmega:function(n,e,t){Fo(n.element(),e.omega,e.alpha)},isAlpha:function(n,e,t){return Ao(n.element(),e.alpha)},isOmega:function(n,e,t){return Ao(n.element(),e.omega)},clear:function(n,e,t){Bo(n.element(),e.alpha),Bo(n.element(),e.omega)}}),No=[Cr("alpha"),Cr("omega")],jo=ho({fields:No,name:"swapping",apis:Vo}),Ho=function(n){var e=n,t=function(){return e};return{get:t,set:function(n){e=n},clone:function(){return Ho(t())}}},zo=function(n){n.dom().focus()},Po=function(n){n.dom().blur()},Lo=function(n){var e=n!==undefined?n.dom():v.document;return k.from(e.activeElement).map(be.fromDom)},Go=function(e){return Lo(_e(e)).filter(function(n){return e.dom().contains(n.dom())})},$o=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),Uo=tinymce.util.Tools.resolve("tinymce.ThemeManager"),Wo=function(n){var e=v.document.createElement("a");e.target="_blank",e.href=n.href,e.rel="noreferrer noopener";var t=v.document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,v.window,0,0,0,0,0,!1,!1,!1,!1,0,null),v.document.body.appendChild(e),e.dispatchEvent(t),v.document.body.removeChild(e)},_o={formatChanged:h("formatChanged"),orientationChanged:h("orientationChanged"),dropupDismissed:h("dropupDismissed")},Xo=function(n){return n.dom().innerHTML},qo=function(n,e){var t,r,o=_e(n).dom(),i=be.fromDom(o.createDocumentFragment()),u=(t=e,(r=(o||v.document).createElement("div")).innerHTML=t,qe(be.fromDom(r)));nt(i,u),et(n),Ze(n,i)},Yo=function(n){return e=n,t=!1,be.fromDom(e.dom().cloneNode(t));var e,t},Ko=function(n){var e,t,r,o=Yo(n);return e=o,t=be.fromTag("div"),r=be.fromDom(e.dom().cloneNode(!0)),Ze(t,r),Xo(t)},Jo=function(n){return Ko(n)},Qo=/* */Object.freeze({events:function(c){return qr([Kr(ne(),function(o,i){var n,e,u=c.channels,t=E(u),r=(n=t,(e=i).universal()?n:Cn(n,function(n){return On(e.channels(),n)}));En(r,function(n){var e=u[n],t=e.schema,r=Sr("channel["+n+"] data\nReceiver: "+Jo(o.element()),t,i.data());e.onReceive(o,r)})})])}}),Zo=function(n){for(var e=[],t=function(n){e.push(n)},r=0;r<n.length;r++)n[r].each(t);return e},ni=function(n,e){for(var t=0;t<n.length;t++){var r=e(n[t],t);if(r.isSome())return r}return k.none()},ei="unknown";($r=Gr||(Gr={}))[$r.STOP=0]="STOP",$r[$r.NORMAL=1]="NORMAL",$r[$r.LOGGING=2]="LOGGING";var ti,ri=Ho({}),oi=function(e,n,t){var r,o,i,u;switch(It(ri.get(),e).orThunk(function(){var n=E(ri.get());return ni(n,function(n){return-1<e.indexOf(n)?k.some(ri.get()[n]):k.none()})}).getOr(Gr.NORMAL)){case Gr.NORMAL:return t(ci());case Gr.LOGGING:var c=(r=e,o=n,i=[],u=(new Date).getTime(),{logEventCut:function(n,e,t){i.push({outcome:"cut",target:e,purpose:t})},logEventStopped:function(n,e,t){i.push({outcome:"stopped",target:e,purpose:t})},logNoParent:function(n,e,t){i.push({outcome:"no-parent",target:e,purpose:t})},logEventNoHandlers:function(n,e){i.push({outcome:"no-handlers-left",target:e})},logEventResponse:function(n,e,t){i.push({outcome:"response",purpose:t,target:e})},write:function(){var n=(new Date).getTime();On(["mousemove","mouseover","mouseout",ue()],r)||v.console.log(r,{event:r,time:n-u,target:o.dom(),sequence:kn(i,function(n){return On(["cut","stopped","response"],n.outcome)?"{"+n.purpose+"} "+n.outcome+" at ("+Jo(n.target)+")":n.outcome})})}}),a=t(c);return c.write(),a;case Gr.STOP:return!0}},ii=["alloy/data/Fields","alloy/debugging/Debugging"],ui=function(n,e,t){return oi(n,e,t)},ci=h({logEventCut:x,logEventStopped:x,logNoParent:x,logEventNoHandlers:x,logEventResponse:x,write:x}),ai=h([Cr("menu"),Cr("selectedMenu")]),fi=h([Cr("item"),Cr("selectedItem")]),si=(h(sr(fi().concat(ai()))),h(sr(fi()))),li=Mr("initSize",[Cr("numColumns"),Cr("numRows")]),di=function(n,e,t){!function(){var n=new Error;if(n.stack===undefined)return;var e=n.stack.split("\n");In(e,function(e){return 0<e.indexOf("alloy")&&!Tn(ii,function(n){return-1<e.indexOf(n)})}).getOr(ei)}();return gr(e,e,t,br(function(t){return dt.value(function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(undefined,n)})}))},mi=function(n){return di(0,n,yt(x))},gi=function(n){return di(0,n,yt(k.none))},pi=function(n){return di(0,n,xt())},vi=function(n){return di(0,n,xt())},hi=function(n,e){return Nr(n,h(e))},bi=function(n){return Nr(n,b)},yi=h(li),xi=[Dr("channels",yr(dt.value,fr([pi("onReceive"),Fr("schema",kr())])))],wi=ho({fields:xi,name:"receiving",active:Qo}),Si=function(n,e,t){var r=e.aria;r.update(n,r,t.get())},Oi=function(e,n,t){n.toggleClass.each(function(n){t.get()?Io(e.element(),n):Bo(e.element(),n)})},Ti=function(n,e,t){Ci(n,e,t,!t.get())},ki=function(n,e,t){t.set(!0),Oi(n,e,t),Si(n,e,t)},Ei=function(n,e,t){t.set(!1),Oi(n,e,t),Si(n,e,t)},Ci=function(n,e,t,r){(r?ki:Ei)(n,e,t)},Di=function(n,e,t){Ci(n,e,t,e.selected)},Mi=/* */Object.freeze({onLoad:Di,toggle:Ti,isOn:function(n,e,t){return t.get()},on:ki,off:Ei,set:Ci}),Ii=/* */Object.freeze({exhibit:function(n,e,t){return co({})},events:function(n,e){var t,r,o,i=(t=n,r=e,o=Ti,oo(function(n){o(n,t,r)})),u=ao(n,e,Di);return qr(Fn([n.toggleOnExecute?[i]:[],[u]]))}}),Ri=function(n,e,t){wo(n.element(),"aria-expanded",t)},Bi=[Fr("selected",!1),Ir("toggleClass"),Fr("toggleOnExecute",!0),Vr("aria",{mode:"none"},Tr("mode",{pressed:[Fr("syncWithExpanded",!1),hi("update",function(n,e,t){wo(n.element(),"aria-pressed",t),e.syncWithExpanded&&Ri(n,e,t)})],checked:[hi("update",function(n,e,t){wo(n.element(),"aria-checked",t)})],expanded:[hi("update",Ri)],selected:[hi("update",function(n,e,t){wo(n.element(),"aria-selected",t)})],none:[hi("update",x)]}))],Ai=ho({fields:Bi,name:"toggling",active:Ii,apis:Mi,state:(ti=!1,{init:function(){var e=Ho(ti);return{get:function(){return e.get()},set:function(n){return e.set(n)},clear:function(){return e.set(ti)},readState:function(){return e.get()}}}})}),Fi=function(t,r){return wi.config({channels:Rt(_o.formatChanged(),{onReceive:function(n,e){e.command===t&&r(n,e.state)}})})},Vi=function(n){return wi.config({channels:Rt(_o.orientationChanged(),{onReceive:n})})},Ni=function(n,e){return{key:n,value:{onReceive:e}}},ji="tinymce-mobile",Hi={resolve:function(n){return ji+"-"+n},prefix:h(ji)},zi=function(n,e){e.ignore||(zo(n.element()),e.onFocus(n))},Pi=/* */Object.freeze({focus:zi,blur:function(n,e){e.ignore||Po(n.element())},isFocused:function(n){return e=n.element(),t=_e(e).dom(),e.dom()===t.activeElement;var e,t}}),Li=/* */Object.freeze({exhibit:function(n,e){var t=e.ignore?{}:{attributes:{tabindex:"-1"}};return co(t)},events:function(t){return qr([Kr(Jn(),function(n,e){zi(n,t),e.stop()})].concat(t.stopMousedown?[Kr(N(),function(n,e){e.event().prevent()})]:[]))}}),Gi=[mi("onFocus"),Fr("stopMousedown",!1),Fr("ignore",!1)],$i=ho({fields:Gi,name:"focusing",active:Li,apis:Pi}),Ui=function(n){return n.style!==undefined&&yn(n.style.getPropertyValue)},Wi=function(n,e,t){if(!pn(t))throw v.console.error("Invalid call to CSS.set. Property ",e,":: Value ",t,":: Element ",n),new Error("CSS value must be a string: "+t);Ui(n)&&n.style.setProperty(e,t)},_i=function(n,e,t){var r=n.dom();Wi(r,e,t)},Xi=function(n,e){var t=n.dom();D(e,function(n,e){Wi(t,e,n)})},qi=function(n,e){var t=n.dom(),r=v.window.getComputedStyle(t).getPropertyValue(e),o=""!==r||Ee(n)?r:Yi(t,e);return null===o?undefined:o},Yi=function(n,e){return Ui(n)?n.style.getPropertyValue(e):""},Ki=function(n,e){var t=n.dom(),r=Yi(t,e);return k.from(r).filter(function(n){return 0<n.length})},Ji=function(n,e){var t,r,o=n.dom();r=e,Ui(t=o)&&t.style.removeProperty(r),To(n,"style")&&""===Oo(n,"style").replace(/^\s+|\s+$/g,"")&&ko(n,"style")},Qi=function(n){return n.dom().offsetWidth};function Zi(r,o){var n=function(n){var e=o(n);if(e<=0||null===e){var t=qi(n,r);return parseFloat(t)||0}return e},i=function(o,n){return Mn(n,function(n,e){var t=qi(o,e),r=t===undefined?0:parseInt(t,10);return isNaN(r)?n:n+r},0)};return{set:function(n,e){if(!xn(e)&&!e.match(/^[0-9]+$/))throw new Error(r+".set accepts only positive integer values. Value was "+e);var t=n.dom();Ui(t)&&(t.style[r]=e+"px")},get:n,getOuter:n,aggregate:i,max:function(n,e,t){var r=i(n,t);return r<e?e-r:0}}}var nu,eu,tu=Zi("height",function(n){var e=n.dom();return Ee(n)?e.getBoundingClientRect().height:e.offsetHeight}),ru=function(n){return tu.get(n)},ou=function(n,e,t){return Cn(function(n,e){for(var t=yn(e)?e:h(!1),r=n.dom(),o=[];null!==r.parentNode&&r.parentNode!==undefined;){var i=r.parentNode,u=be.fromDom(i);if(o.push(u),!0===t(u))break;r=i}return o}(n,t),e)},iu=function(n,e){return Cn(Xe(t=n).map(qe).map(function(n){return Cn(n,function(n){return!We(t,n)})}).getOr([]),e);var t},uu=function(n,e){return $e(e,n)},cu=function(n){return Ue(n)},au=function(n,e,t){return Ur(n,function(n){return Le(n,e)},t)},fu=function(n,e){return Ue(e,n)},su=function(n,e,t){return Pr(Le,au,n,e,t)},lu=function(n,e,t){var r=jn(n.slice(0,e)),o=jn(n.slice(e+1));return In(r.concat(o),t)},du=function(n,e,t){var r=jn(n.slice(0,e));return In(r,t)},mu=function(n,e,t){var r=n.slice(0,e),o=n.slice(e+1);return In(o.concat(r),t)},gu=function(n,e,t){var r=n.slice(e+1);return In(r,t)},pu=function(t){return function(n){var e=n.raw();return On(t,e.which)}},vu=function(n){return function(e){return Nn(n,function(n){return n(e)})}},hu=function(n){return!0===n.raw().shiftKey},bu=function(n){return!0===n.raw().ctrlKey},yu=w(hu),xu=function(n,e){return{matches:n,classification:e}},wu=function(n,e,t,r){var o=n+e;return r<o?t:o<t?r:o},Su=function(n,e,t){return n<=e?e:t<=n?t:n},Ou=function(t,r,n,o){var e=uu(t.element(),"."+r.highlightClass);En(e,function(e){Tn(o,function(n){return n.element()===e})||(Bo(e,r.highlightClass),t.getSystem().getByDom(e).each(function(n){r.onDehighlight(t,n),de(n,le())}))})},Tu=function(n,e,t,r){Ou(n,e,0,[r]),ku(n,e,t,r)||(Io(r.element(),e.highlightClass),e.onHighlight(n,r),de(r,se()))},ku=function(n,e,t,r){return Ao(r.element(),e.highlightClass)},Eu=function(n,e,t,r){var o=uu(n.element(),"."+e.itemClass);return k.from(o[r]).fold(function(){return dt.error("No element found with index "+r)},n.getSystem().getByDom)},Cu=function(e,n,t){return fu(e.element(),"."+n.itemClass).bind(function(n){return e.getSystem().getByDom(n).toOption()})},Du=function(e,n,t){var r=uu(e.element(),"."+n.itemClass);return(0<r.length?k.some(r[r.length-1]):k.none()).bind(function(n){return e.getSystem().getByDom(n).toOption()})},Mu=function(t,e,n,r){var o=uu(t.element(),"."+e.itemClass);return Rn(o,function(n){return Ao(n,e.highlightClass)}).bind(function(n){var e=wu(n,r,0,o.length-1);return t.getSystem().getByDom(o[e]).toOption()})},Iu=function(e,n,t){var r=uu(e.element(),"."+n.itemClass);return Zo(kn(r,function(n){return e.getSystem().getByDom(n).toOption()}))},Ru=/* */Object.freeze({dehighlightAll:function(n,e,t){return Ou(n,e,0,[])},dehighlight:function(n,e,t,r){ku(n,e,t,r)&&(Bo(r.element(),e.highlightClass),e.onDehighlight(n,r),de(r,le()))},highlight:Tu,highlightFirst:function(e,t,r){Cu(e,t).each(function(n){Tu(e,t,r,n)})},highlightLast:function(e,t,r){Du(e,t).each(function(n){Tu(e,t,r,n)})},highlightAt:function(e,t,r,n){Eu(e,t,r,n).fold(function(n){throw new Error(n)},function(n){Tu(e,t,r,n)})},highlightBy:function(e,t,r,n){var o=Iu(e,t);In(o,n).each(function(n){Tu(e,t,r,n)})},isHighlighted:ku,getHighlighted:function(e,n,t){return fu(e.element(),"."+n.highlightClass).bind(function(n){return e.getSystem().getByDom(n).toOption()})},getFirst:Cu,getLast:Du,getPrevious:function(n,e,t){return Mu(n,e,0,-1)},getNext:function(n,e,t){return Mu(n,e,0,1)},getCandidates:Iu}),Bu=[Cr("highlightClass"),Cr("itemClass"),mi("onHighlight"),mi("onDehighlight")],Au=ho({fields:Bu,name:"highlighting",apis:Ru}),Fu=function(n,e,t){e.exists(function(e){return t.exists(function(n){return We(n,e)})})||me(n,fe(),{prevFocus:e,newFocus:t})},Vu=function(){var o=function(n){return Go(n.element())};return{get:o,set:function(n,e){var t=o(n);n.getSystem().triggerFocus(e,n.element());var r=o(n);Fu(n,t,r)}}};(eu=nu||(nu={})).OnFocusMode="onFocus",eu.OnEnterOrSpaceMode="onEnterOrSpace",eu.OnApiMode="onApi";var Nu,ju,Hu,zu,Pu,Lu,Gu,$u,Uu,Wu,_u=function(n,e,t,r,c){var a=function(e,t,n,r,o){var i,u,c=n(e,t,r,o);return(i=c,u=t.event(),In(i,function(n){return n.matches(u)}).map(function(n){return n.classification})).bind(function(n){return n(e,t,r,o)})},o={schema:function(){return n.concat([Fr("focusManager",Vu()),Vr("focusInside","onFocus",br(function(n){return On(["onFocus","onEnterOrSpace","onApi"],n)?dt.value(n):dt.error("Invalid value for focusInside")})),hi("handler",o),hi("state",e),hi("sendFocusIn",c)])},processKey:a,toEvents:function(i,u){var n=i.focusInside!==nu.OnFocusMode?k.none():c(i).map(function(t){return Kr(Jn(),function(n,e){t(n,i,u),e.stop()})});return qr(n.toArray().concat([Kr(P(),function(r,o){a(r,o,t,i,u).fold(function(){var e,t,n;e=r,t=o,n=pu([32].concat([13]))(t.event()),i.focusInside===nu.OnEnterOrSpaceMode&&n&&jr(e,t)&&c(i).each(function(n){n(e,i,u),t.stop()})},function(n){o.stop()})}),Kr(L(),function(n,e){a(n,e,r,i,u).each(function(n){e.stop()})})]))}};return o},Xu=function(n){var e=[Ir("onEscape"),Ir("onEnter"),Fr("selector",'[data-alloy-tabstop="true"]'),Fr("firstTabstop",0),Fr("useTabstopAt",h(!0)),Ir("visibilitySelector")].concat([n]),u=function(n,e){var t=n.visibilitySelector.bind(function(n){return su(e,n)}).getOr(e);return 0<ru(t)},t=function(e,t){var n,r,o,i;(n=e,r=t,o=uu(n.element(),r.selector),i=Cn(o,function(n){return u(r,n)}),k.from(i[r.firstTabstop])).each(function(n){t.focusManager.set(e,n)})},c=function(e,n,t,r,o){return o(n,t,function(n){return u(e=r,t=n)&&e.useTabstopAt(t);var e,t}).fold(function(){return r.cyclic?k.some(!0):k.none()},function(n){return r.focusManager.set(e,n),k.some(!0)})},i=function(e,n,t,r){var o,i,u=uu(e.element(),t.selector);return(o=e,i=t,i.focusManager.get(o).bind(function(n){return su(n,i.selector)})).bind(function(n){return Rn(u,l(We,n)).bind(function(n){return c(e,u,n,t,r)})})},r=h([xu(vu([hu,pu([9])]),function(n,e,t,r){var o=t.cyclic?lu:du;return i(n,0,t,o)}),xu(pu([9]),function(n,e,t,r){var o=t.cyclic?mu:gu;return i(n,0,t,o)}),xu(pu([27]),function(e,t,n,r){return n.onEscape.bind(function(n){return n(e,t)})}),xu(vu([yu,pu([13])]),function(e,t,n,r){return n.onEnter.bind(function(n){return n(e,t)})})]),o=h([]);return _u(e,mo.init,r,o,function(){return k.some(t)})},qu=Xu(Nr("cyclic",h(!1))),Yu=Xu(Nr("cyclic",h(!0))),Ku=function(n){return"input"===Se(n)&&"radio"!==Oo(n,"type")||"textarea"===Se(n)},Ju=function(n,e,t){return Ku(t)&&pu([32])(e.event())?k.none():(pe(n,t,ee()),k.some(!0))},Qu=function(n,e){return k.some(!0)},Zu=[Fr("execute",Ju),Fr("useSpace",!1),Fr("useEnter",!0),Fr("useControlEnter",!1),Fr("useDown",!1)],nc=function(n,e,t){return t.execute(n,e,n.element())},ec=_u(Zu,mo.init,function(n,e,t,r){var o=t.useSpace&&!Ku(n.element())?[32]:[],i=t.useEnter?[13]:[],u=t.useDown?[40]:[],c=o.concat(i).concat(u);return[xu(pu(c),nc)].concat(t.useControlEnter?[xu(vu([bu,pu([13])]),nc)]:[])},function(n,e,t,r){return t.useSpace&&!Ku(n.element())?[xu(pu([32]),Qu)]:[]},function(){return k.none()}),tc=function(n){var t=Ho(k.none());return go({readState:function(){return t.get().map(function(n){return{numRows:n.numRows(),numColumns:n.numColumns()}}).getOr({numRows:"?",numColumns:"?"})},setGridSize:function(n,e){t.set(k.some({numRows:h(n),numColumns:h(e)}))},getNumRows:function(){return t.get().map(function(n){return n.numRows()})},getNumColumns:function(){return t.get().map(function(n){return n.numColumns()})}})},rc=/* */Object.freeze({flatgrid:tc,init:function(n){return n.state(n)}}),oc=function(e,t){return function(n){return"rtl"===ic(n)?t:e}},ic=function(n){return"rtl"===qi(n,"direction")?"rtl":"ltr"},uc=function(i){return function(n,e,t,r){var o=i(n.element());return sc(o,n,e,t,r)}},cc=function(n,e){var t=oc(n,e);return uc(t)},ac=function(n,e){var t=oc(e,n);return uc(t)},fc=function(o){return function(n,e,t,r){return sc(o,n,e,t,r)}},sc=function(e,t,n,r,o){return r.focusManager.get(t).bind(function(n){return e(t.element(),n,r,o)}).map(function(n){return r.focusManager.set(t,n),!0})},lc=fc,dc=fc,mc=fc,gc=function(n){var e,t=n.dom();return!((e=t).offsetWidth<=0&&e.offsetHeight<=0)},pc=Be(["index","candidates"],[]),vc=function(n,e,t){var r,o=l(We,e),i=uu(n,t),u=Cn(i,gc);return Rn(r=u,o).map(function(n){return pc({index:n,candidates:r})})},hc=function(n,e){return Rn(n,function(n){return We(e,n)})},bc=function(t,n,r,e){return e(Math.floor(n/r),n%r).bind(function(n){var e=n.row()*r+n.column();return 0<=e&&e<t.length?k.some(t[e]):k.none()})},yc=function(o,n,i,u,c){return bc(o,n,u,function(n,e){var t=n===i-1?o.length-n*u:u,r=wu(e,c,0,t-1);return k.some({row:h(n),column:h(r)})})},xc=function(i,n,u,c,a){return bc(i,n,c,function(n,e){var t=wu(n,a,0,u-1),r=t===u-1?i.length-t*c:c,o=Su(e,0,r-1);return k.some({row:h(t),column:h(o)})})},wc=[Cr("selector"),Fr("execute",Ju),gi("onEscape"),Fr("captureTab",!1),yi()],Sc=function(e,t,n){fu(e.element(),t.selector).each(function(n){t.focusManager.set(e,n)})},Oc=function(o){return function(n,e,t,r){return vc(n,e,t.selector).bind(function(n){return o(n.candidates(),n.index(),r.getNumRows().getOr(t.initSize.numRows),r.getNumColumns().getOr(t.initSize.numColumns))})}},Tc=function(n,e,t,r){return t.captureTab?k.some(!0):k.none()},kc=Oc(function(n,e,t,r){return yc(n,e,t,r,-1)}),Ec=Oc(function(n,e,t,r){return yc(n,e,t,r,1)}),Cc=Oc(function(n,e,t,r){return xc(n,e,t,r,-1)}),Dc=Oc(function(n,e,t,r){return xc(n,e,t,r,1)}),Mc=h([xu(pu([37]),cc(kc,Ec)),xu(pu([39]),ac(kc,Ec)),xu(pu([38]),lc(Cc)),xu(pu([40]),dc(Dc)),xu(vu([hu,pu([9])]),Tc),xu(vu([yu,pu([9])]),Tc),xu(pu([27]),function(n,e,t,r){return t.onEscape(n,e)}),xu(pu([32].concat([13])),function(e,t,r,n){return(o=e,i=r,i.focusManager.get(o).bind(function(n){return su(n,i.selector)})).bind(function(n){return r.execute(e,t,n)});var o,i})]),Ic=h([xu(pu([32]),Qu)]),Rc=_u(wc,tc,Mc,Ic,function(){return k.some(Sc)}),Bc=function(n,e,t,i){var u=function(n,e,t){var r,o=wu(e,i,0,t.length-1);return o===n?k.none():(r=t[o],"button"===Se(r)&&"disabled"===Oo(r,"disabled")?u(n,o,t):k.from(t[o]))};return vc(n,t,e).bind(function(n){var e=n.index(),t=n.candidates();return u(e,e,t)})},Ac=[Cr("selector"),Fr("getInitial",k.none),Fr("execute",Ju),gi("onEscape"),Fr("executeOnMove",!1),Fr("allowVertical",!0)],Fc=function(e,t,r){return(n=e,o=r,o.focusManager.get(n).bind(function(n){return su(n,o.selector)})).bind(function(n){return r.execute(e,t,n)});var n,o},Vc=function(e,t){t.getInitial(e).orThunk(function(){return fu(e.element(),t.selector)}).each(function(n){t.focusManager.set(e,n)})},Nc=function(n,e,t){return Bc(n,t.selector,e,-1)},jc=function(n,e,t){return Bc(n,t.selector,e,1)},Hc=function(r){return function(n,e,t){return r(n,e,t).bind(function(){return t.executeOnMove?Fc(n,e,t):k.some(!0)})}},zc=function(n,e,t,r){return t.onEscape(n,e)},Pc=h([xu(pu([32]),Qu)]),Lc=_u(Ac,mo.init,function(n,e,t,r){var o=[37].concat(t.allowVertical?[38]:[]),i=[39].concat(t.allowVertical?[40]:[]);return[xu(pu(o),Hc(cc(Nc,jc))),xu(pu(i),Hc(ac(Nc,jc))),xu(pu([13]),Fc),xu(pu([32]),Fc),xu(pu([27]),zc)]},Pc,function(){return k.some(Vc)}),Gc=Be(["rowIndex","columnIndex","cell"],[]),$c=function(n,e,t){return k.from(n[e]).bind(function(n){return k.from(n[t]).map(function(n){return Gc({rowIndex:e,columnIndex:t,cell:n})})})},Uc=function(n,e,t,r){var o=n[e].length,i=wu(t,r,0,o-1);return $c(n,e,i)},Wc=function(n,e,t,r){var o=wu(t,r,0,n.length-1),i=n[o].length,u=Su(e,0,i-1);return $c(n,o,u)},_c=function(n,e,t,r){var o=n[e].length,i=Su(t+r,0,o-1);return $c(n,e,i)},Xc=function(n,e,t,r){var o=Su(t+r,0,n.length-1),i=n[o].length,u=Su(e,0,i-1);return $c(n,o,u)},qc=[Mr("selectors",[Cr("row"),Cr("cell")]),Fr("cycles",!0),Fr("previousSelector",k.none),Fr("execute",Ju)],Yc=function(e,t){t.previousSelector(e).orThunk(function(){var n=t.selectors;return fu(e.element(),n.cell)}).each(function(n){t.focusManager.set(e,n)})},Kc=function(n,e){return function(t,r,i){var u=i.cycles?n:e;return su(r,i.selectors.row).bind(function(n){var e=uu(n,i.selectors.cell);return hc(e,r).bind(function(r){var o=uu(t,i.selectors.row);return hc(o,n).bind(function(n){var e,t=(e=i,kn(o,function(n){return uu(n,e.selectors.cell)}));return u(t,n,r).map(function(n){return n.cell()})})})})}},Jc=Kc(function(n,e,t){return Uc(n,e,t,-1)},function(n,e,t){return _c(n,e,t,-1)}),Qc=Kc(function(n,e,t){return Uc(n,e,t,1)},function(n,e,t){return _c(n,e,t,1)}),Zc=Kc(function(n,e,t){return Wc(n,t,e,-1)},function(n,e,t){return Xc(n,t,e,-1)}),na=Kc(function(n,e,t){return Wc(n,t,e,1)},function(n,e,t){return Xc(n,t,e,1)}),ea=h([xu(pu([37]),cc(Jc,Qc)),xu(pu([39]),ac(Jc,Qc)),xu(pu([38]),lc(Zc)),xu(pu([40]),dc(na)),xu(pu([32].concat([13])),function(e,t,r){return Go(e.element()).bind(function(n){return r.execute(e,t,n)})})]),ta=h([xu(pu([32]),Qu)]),ra=_u(qc,mo.init,ea,ta,function(){return k.some(Yc)}),oa=[Cr("selector"),Fr("execute",Ju),Fr("moveOnTab",!1)],ia=function(e,t,r){return r.focusManager.get(e).bind(function(n){return r.execute(e,t,n)})},ua=function(e,t){fu(e.element(),t.selector).each(function(n){t.focusManager.set(e,n)})},ca=function(n,e,t){return Bc(n,t.selector,e,-1)},aa=function(n,e,t){return Bc(n,t.selector,e,1)},fa=h([xu(pu([38]),mc(ca)),xu(pu([40]),mc(aa)),xu(vu([hu,pu([9])]),function(n,e,t){return t.moveOnTab?mc(ca)(n,e,t):k.none()}),xu(vu([yu,pu([9])]),function(n,e,t){return t.moveOnTab?mc(aa)(n,e,t):k.none()}),xu(pu([13]),ia),xu(pu([32]),ia)]),sa=h([xu(pu([32]),Qu)]),la=_u(oa,mo.init,fa,sa,function(){return k.some(ua)}),da=[gi("onSpace"),gi("onEnter"),gi("onShiftEnter"),gi("onLeft"),gi("onRight"),gi("onTab"),gi("onShiftTab"),gi("onUp"),gi("onDown"),gi("onEscape"),Fr("stopSpaceKeyup",!1),Ir("focusIn")],ma=_u(da,mo.init,function(n,e,t){return[xu(pu([32]),t.onSpace),xu(vu([yu,pu([13])]),t.onEnter),xu(vu([hu,pu([13])]),t.onShiftEnter),xu(vu([hu,pu([9])]),t.onShiftTab),xu(vu([yu,pu([9])]),t.onTab),xu(pu([38]),t.onUp),xu(pu([40]),t.onDown),xu(pu([37]),t.onLeft),xu(pu([39]),t.onRight),xu(pu([32]),t.onSpace),xu(pu([27]),t.onEscape)]},function(n,e,t){return t.stopSpaceKeyup?[xu(pu([32]),Qu)]:[]},function(n){return n.focusIn}),ga=qu.schema(),pa=Yu.schema(),va=Lc.schema(),ha=Rc.schema(),ba=ra.schema(),ya=ec.schema(),xa=la.schema(),wa=ma.schema(),Sa=(Wu=Sr("Creating behaviour: "+(Nu={branchKey:"mode",branches:/* */Object.freeze({acyclic:ga,cyclic:pa,flow:va,flatgrid:ha,matrix:ba,execution:ya,menu:xa,special:wa}),name:"keying",active:{events:function(n,e){return n.handler.toEvents(n,e)}},apis:{focusIn:function(e,t,r){t.sendFocusIn(t).fold(function(){e.getSystem().triggerFocus(e.element(),e.element())},function(n){n(e,t,r)})},setGridSize:function(n,e,t,r,o){Ft(t,"setGridSize")?t.setGridSize(r,o):v.console.error("Layout does not support setGridSize")}},state:rc}).name,bo,Nu),ju=Tr(Wu.branchKey,Wu.branches),Hu=Wu.name,zu=Wu.active,Pu=Wu.apis,Lu=Wu.extra,Gu=Wu.state,Uu=Br(Hu,[Rr("config",$u=ju)]),lo($u,Uu,Hu,zu,Pu,Lu,Gu)),Oa=function(r,n){return e=r,t={},o=kn(n,function(n){return e=n.name(),t="Cannot configure "+n.name()+" for "+r,gr(e,e,wt(),ar(function(n){return Ut("The field: "+e+" is forbidden. "+t)}));var e,t}).concat([Nr("dump",b)]),Vr(e,t,sr(o));var e,t,o},Ta=function(n){return n.dump},ka=function(n,e){return y({},n.dump,po(e))},Ea=Oa,Ca=ka,Da="placeholder",Ma=mt([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),Ia=function(n,e,t,r){return t.uiType===Da?(i=t,u=r,(o=n).exists(function(n){return n!==i.owner})?Ma.single(!0,h(i)):It(u,i.name).fold(function(){throw new Error("Unknown placeholder component: "+i.name+"\nKnown: ["+E(u)+"]\nNamespace: "+o.getOr("none")+"\nSpec: "+er(i,null,2))},function(n){return n.replace()})):Ma.single(!1,h(t));var o,i,u},Ra=function(i,u,c,a){return Ia(i,0,c,a).fold(function(n,e){var t=e(u,c.config,c.validated),r=It(t,"components").getOr([]),o=Vn(r,function(n){return Ra(i,u,n,a)});return[y({},t,{components:o})]},function(n,e){var t=e(u,c.config,c.validated);return c.validated.preprocess.getOr(b)(t)})},Ba=function(e,t,n,r){var o,i,u,c=M(r,function(n,e){return r=n,o=!1,{name:h(t=e),required:function(){return r.fold(function(n,e){return n},function(n,e){return n})},used:function(){return o},replace:function(){if(!0===o)throw new Error("Trying to use the same placeholder more than once: "+t);return o=!0,r}};var t,r,o}),a=(o=e,i=t,u=c,Vn(n,function(n){return Ra(o,i,n,u)}));return D(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: "+er(t.components,null,2))}),a},Aa=Ma.single,Fa=Ma.multiple,Va=h(Da),Na=0,ja=function(n){var e=(new Date).getTime();return n+"_"+Math.floor(1e9*Math.random())+ ++Na+String(e)},Ha=mt([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),za=Fr("factory",{sketch:b}),Pa=Fr("schema",[]),La=Cr("name"),Ga=gr("pname","pname",St(function(n){return"<alloy."+ja(n.name)+">"}),kr()),$a=Nr("schema",function(){return[Ir("preprocess")]}),Ua=Fr("defaults",h({})),Wa=Fr("overrides",h({})),_a=sr([za,Pa,La,Ga,Ua,Wa]),Xa=sr([za,Pa,La,Ga,Ua,Wa]),qa=sr([za,$a,La,Cr("unit"),Ga,Ua,Wa]),Ya=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},Ka=function(t,r){return function(n){var e=Sr("Converting part type",r,n);return t(e)}},Ja=Ka(Ha.required,_a),Qa=Ka(Ha.optional,Xa),Za=Ka(Ha.group,qa),nf=h("entirety"),ef=function(n,e,t,r){return vt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},tf=function(o,n){var i={};return En(n,function(n){var e;(e=n,e.fold(k.some,k.none,k.some,k.some)).each(function(t){var r=rf(o,t.pname);i[t.name]=function(n){var e=Sr("Part: "+t.name+" in "+o,sr(t.schema),n);return y({},r,{config:n,validated:e})}})}),i},rf=function(n,e){return{uiType:Va(),owner:n,name:e}},of=function(n,e,t){return r=e,i={},o={},En(t,function(n){n.fold(function(r){i[r.pname]=Aa(!0,function(n,e,t){return r.factory.sketch(ef(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=h(n.factory.sketch(ef(r,n,e[nf()]),e))},function(r){i[r.pname]=Aa(!1,function(n,e,t){return r.factory.sketch(ef(n,r,e,t))})},function(o){i[o.pname]=Fa(!0,function(e,n,t){var r=e[o.name];return kn(r,function(n){return o.factory.sketch(vt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:h(i),externals:h(o)};var r,i,o},uf=function(n,e,t){return Ba(k.some(n),e,e.components,t)},cf=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOption()},af=function(n,e,t){return cf(n,e,t).getOrDie("Could not find part: "+t)},ff=function(e,n){var t=kn(n,Ya);return Bt(kn(t,function(n){return{key:n,value:e+"-"+n}}))},sf=function(e){return gr("partUids","partUids",Ot(function(n){return ff(n.uid,e)}),kr())},lf=ja("alloy-premade"),df=function(n){return Rt(lf,n)},mf=function(r){return n=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return r.apply(undefined,[n.getApis()].concat([n].concat(e)))},e=r.toString(),t=e.indexOf(")")+1,o=e.indexOf("("),i=e.substring(o+1,t-1).split(/,\s*/),n.toFunctionAnnotation=function(){return{name:"OVERRIDE",parameters:io(i.slice(1))}},n;var n,e,t,o,i},gf=h("alloy-id-"),pf=h("data-alloy-id"),vf=gf(),hf=pf(),bf=function(n,e){Object.defineProperty(n.dom(),hf,{value:e,writable:!0})},yf=function(n){var e=Te(n)?n.dom()[hf]:null;return k.from(e)},xf=function(n){return ja(n)},wf=function(n,e,t,r,o){var i,u,c=(u=o,(0<(i=r).length?[Mr("parts",i)]:[]).concat([Cr("uid"),Fr("dom",{}),Fr("components",[]),bi("originalSpec"),Fr("debug.sketcher",{})]).concat(u));return Sr(n+" [SpecSchema]",fr(c.concat(e)),t)},Sf=function(n,e,t,r,o){var i=Of(o),u=Vn(t,function(n){return n.fold(k.none,k.some,k.none,k.none).map(function(n){return Mr(n.name,n.schema.concat([bi(nf())]))}).toArray()}),c=sf(t),a=wf(n,e,i,u,[c]),f=of(0,a,t);return r(a,uf(n,a,f.internals()),i,f.externals())},Of=function(n){return n.hasOwnProperty("uid")?n:y({},n,{uid:xf("uid")})};var Tf=fr([Cr("name"),Cr("factory"),Cr("configFields"),Fr("apis",{}),Fr("extraApis",{})]),kf=fr([Cr("name"),Cr("factory"),Cr("configFields"),Cr("partFields"),Fr("apis",{}),Fr("extraApis",{})]),Ef=function(n){var i=Sr("Sketcher for "+n.name,Tf,n),e=M(i.apis,mf),t=M(i.extraApis,function(n,e){return uo(n,e)});return y({name:h(i.name),partFields:h([]),configFields:h(i.configFields),sketch:function(n){return e=i.name,t=i.configFields,r=i.factory,o=Of(n),r(wf(e,t,o,[],[]),o);var e,t,r,o}},e,t)},Cf=function(n){var e=Sr("Sketcher for "+n.name,kf,n),t=tf(e.name,e.partFields),r=M(e.apis,mf),o=M(e.extraApis,function(n,e){return uo(n,e)});return y({name:h(e.name),partFields:h(e.partFields),configFields:h(e.configFields),sketch:function(n){return Sf(e.name,e.configFields,e.partFields,e.factory,n)},parts:h(t)},r,o)},Df=Ef({name:"Button",factory:function(n){var e,t,r,o=(e=n.action,t=function(n,e){e.stop(),ge(n)},r=Yn.detect().deviceType.isTouch()?[Kr(re(),t)]:[Kr(U(),t),Kr(N(),function(n,e){e.cut()})],qr(Fn([e.map(function(t){return Kr(ee(),function(n,e){t(n),e.stop()})}).toArray(),r]))),i=n.dom.tag,u=function(e){return It(n.dom,"attributes").bind(function(n){return It(n,e)})};return{uid:n.uid,dom:n.dom,components:n.components,events:o,behaviours:Ca(n.buttonBehaviours,[$i.config({}),Sa.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:function(){if("button"!==i)return{role:u("role").getOr("button")};var n=u("type").getOr("button"),e=u("role").map(function(n){return{role:n}}).getOr({});return y({type:n},e)}()},eventOrder:n.eventOrder}},configFields:[Fr("uid",undefined),Cr("dom"),Fr("components",[]),Ea("buttonBehaviours",[$i,Sa]),Ir("action"),Ir("role"),Fr("eventOrder",{})]}),Mf=ho({fields:[],name:"unselecting",active:/* */Object.freeze({events:function(n){return qr([Yr(_(),h(!0))])},exhibit:function(n,e){return co({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})}})}),If=function(n){var e,t,r,o=be.fromHtml(n),i=qe(o),u=(t=(e=o).dom().attributes!==undefined?e.dom().attributes:[],Mn(t,function(n,e){var t;return"class"===e.name?n:y({},n,((t={})[e.name]=e.value,t))},{})),c=(r=o,Array.prototype.slice.call(r.dom().classList,0)),a=0===i.length?{}:{innerHtml:Xo(o)};return y({tag:Se(o),classes:c,attributes:u},a)},Rf=function(n){var e,o,t=(e=n,o={prefix:Hi.prefix()},e.replace(/\$\{([^{}]*)\}/g,function(n,e){var t,r=o[e];return"string"==(t=typeof r)||"number"===t?r.toString():n}));return If(t)},Bf=function(n){return{dom:Rf(n)}},Af=function(n){return po([Ai.config({toggleClass:Hi.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Fi(n,function(n,e){(e?Ai.on:Ai.off)(n)})])},Ff=function(n,e){var t=e.ui.registry.getAll().icons;return k.from(t[n]).fold(function(){return Rf('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item ${prefix}-icon-'+n+' ${prefix}-icon"></span>')},function(n){return Rf('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item">'+n+"</span>")})},Vf=function(n,e,t,r){return Df.sketch({dom:Ff(n,r),action:e,buttonBehaviours:vt(po([Mf.config({})]),t)})},Nf={forToolbar:Vf,forToolbarCommand:function(n,e){return Vf(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=Af(t);return Vf(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=Af(e);return Vf(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:Ff},jf=Yn.detect().deviceType.isTouch(),Hf=Qa({schema:[Cr("dom")],name:"label"}),zf=function(n){return Qa({name:n+"-edge",overrides:function(r){return r.model.manager.edgeActions[n].fold(function(){return{}},function(t){var n=qr([Jr(A(),t,[r])]),e=qr([Jr(N(),t,[r]),Jr(j(),function(n,e){e.mouseIsDown.get()&&t(n,e)},[r])]);return{events:jf?n:e}})}})},Pf=zf("top-left"),Lf=zf("top"),Gf=zf("top-right"),$f=zf("right"),Uf=zf("bottom-right"),Wf=zf("bottom"),_f=zf("bottom-left"),Xf=[Hf,zf("left"),$f,Lf,Wf,Pf,Gf,_f,Uf,Ja({name:"thumb",defaults:h({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:qr([Zr(A(),n,"spectrum"),Zr(F(),n,"spectrum"),Zr(V(),n,"spectrum"),Zr(N(),n,"spectrum"),Zr(j(),n,"spectrum"),Zr(H(),n,"spectrum")])}}}),Ja({schema:[Nr("mouseIsDown",function(){return Ho(!1)})],name:"spectrum",overrides:function(t){var r=t.model.manager,o=function(e,n){return r.getValueFromEvent(n).map(function(n){return r.setValueFrom(e,t,n)})},n=qr([Kr(A(),o),Kr(F(),o)]),e=qr([Kr(N(),o),Kr(j(),function(n,e){t.mouseIsDown.get()&&o(n,e)})]);return{behaviours:po(jf?[]:[Sa.config({mode:"special",onLeft:function(n){return r.onLeft(n,t)},onRight:function(n){return r.onRight(n,t)},onUp:function(n){return r.onUp(n,t)},onDown:function(n){return r.onDown(n,t)}}),$i.config({})]),events:jf?n:e}}})],qf=function(n,e,t){e.store.manager.onLoad(n,e,t)},Yf=function(n,e,t){e.store.manager.onUnload(n,e,t)},Kf=/* */Object.freeze({onLoad:qf,onUnload:Yf,setValue:function(n,e,t,r){e.store.manager.setValue(n,e,t,r)},getValue:function(n,e,t){return e.store.manager.getValue(n,e,t)},getState:function(n,e,t){return t}}),Jf=/* */Object.freeze({events:function(t,r){var n=t.resetOnDom?[eo(function(n,e){qf(n,t,r)}),to(function(n,e){Yf(n,t,r)})]:[ao(t,r,qf)];return qr(n)}}),Qf=function(){var n=Ho(null);return go({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()}}})},Zf=function(){var i=Ho({}),u=Ho({});return go({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return It(i.get(),n).orThunk(function(){return It(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};En(n,function(e){r[e.value]=e,It(e,"meta").each(function(n){It(n,"text").each(function(n){o[n]=e})})}),i.set(y({},e,r)),u.set(y({},t,o))},clear:function(){i.set({}),u.set({})}})},ns=/* */Object.freeze({memory:Qf,dataset:Zf,manual:function(){return go({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),es=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},ts=[Ir("initialValue"),Cr("getFallbackEntry"),Cr("getDataKey"),Cr("setValue"),hi("manager",{setValue:es,getValue:function(n,e,t){var r=e.store,o=r.getDataKey(n);return t.lookup(o).fold(function(){return r.getFallbackEntry(o)},function(n){return n})},onLoad:function(e,t,r){t.store.initialValue.each(function(n){es(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:Zf})],rs=[Cr("getValue"),Fr("setValue",x),Ir("initialValue"),hi("manager",{setValue:function(n,e,t,r){e.store.setValue(n,r),e.onSetValue(n,r)},getValue:function(n,e,t){return e.store.getValue(n)},onLoad:function(e,t,n){t.store.initialValue.each(function(n){t.store.setValue(e,n)})},onUnload:x,state:mo.init})],os=[Ir("initialValue"),hi("manager",{setValue:function(n,e,t,r){t.set(r),e.onSetValue(n,r)},getValue:function(n,e,t){return t.get()},onLoad:function(n,e,t){e.store.initialValue.each(function(n){t.isNotSet()&&t.set(n)})},onUnload:function(n,e,t){t.clear()},state:Qf})],is=[Vr("store",{mode:"memory"},Tr("mode",{memory:os,manual:rs,dataset:ts})),mi("onSetValue"),Fr("resetOnDom",!1)],us=ho({fields:is,name:"representing",active:Jf,apis:Kf,extra:{setValueFrom:function(n,e){var t=us.getValue(e);us.setValue(n,t)}},state:ns}),cs=Zi("width",function(n){return n.dom().offsetWidth}),as=function(n,e){cs.set(n,e)},fs=function(n){return cs.get(n)},ss=function(t,r){return{left:h(t),top:h(r),translate:function(n,e){return ss(t+n,r+e)}}},ls=ss,ds=Yn.detect().deviceType.isTouch(),ms=h("slider.change.value"),gs=function(n){var e=n.event().raw();if(ds){var t=e;return t.touches!==undefined&&1===t.touches.length?k.some(t.touches[0]).map(function(n){return ls(n.clientX,n.clientY)}):k.none()}var r=e;return r.clientX!==undefined?k.some(r).map(function(n){return ls(n.clientX,n.clientY)}):k.none()},ps=function(n){return n.model.minX},vs=function(n){return n.model.minY},hs=function(n){return n.model.minX-1},bs=function(n){return n.model.minY-1},ys=function(n){return n.model.maxX},xs=function(n){return n.model.maxY},ws=function(n){return n.model.maxX+1},Ss=function(n){return n.model.maxY+1},Os=function(n,e,t){return e(n)-t(n)},Ts=function(n){return Os(n,ys,ps)},ks=function(n){return Os(n,xs,vs)},Es=function(n){return Ts(n)/2},Cs=function(n){return ks(n)/2},Ds=function(n){return n.stepSize},Ms=function(n){return n.snapToGrid},Is=function(n){return n.snapStart},Rs=function(n){return n.rounded},Bs=function(n,e){return n[e+"-edge"]!==undefined},As=function(n){return Bs(n,"left")},Fs=function(n){return Bs(n,"right")},Vs=function(n){return Bs(n,"top")},Ns=function(n){return Bs(n,"bottom")},js=function(n){return n.model.value.get()},Hs=function(n){return{x:h(n)}},zs=function(n){return{y:h(n)}},Ps=function(n,e){return{x:h(n),y:h(e)}},Ls=function(n,e){me(n,ms(),{value:e})},Gs=function(n,e,t,r){return n<e?n:t<n?t:n===e?e-1:Math.max(e,n-r)},$s=function(n,e,t,r){return t<n?n:n<e?e:n===t?t+1:Math.min(t,n+r)},Us=function(n,e,t){return Math.max(e,Math.min(t,n))},Ws=function(n){var e=n.min,t=n.max,r=n.range,o=n.value,i=n.step,u=n.snap,c=n.snapStart,a=n.rounded,f=n.hasMinEdge,s=n.hasMaxEdge,l=n.minBound,d=n.maxBound,m=n.screenRange,g=f?e-1:e,p=s?t+1:t;if(o<l)return g;if(d<o)return p;var v,h,b,y,x,w,S,O=(x=o,w=l,S=d,Math.min(S,Math.max(x,w))-w),T=Us(O/m*r+e,g,p);return u&&e<=T&&T<=t?(v=T,h=e,b=t,y=i,c.fold(function(){var n=v-h,e=Math.round(n/y)*y;return Us(h+e,h-1,b+1)},function(n){var e=(v-n)%y,t=Math.round(e/y),r=Math.floor((v-n)/y),o=Math.floor((b-n)/y),i=n+Math.min(o,r+t)*y;return Math.max(n,i)})):a?Math.round(T):T},_s=function(n){var e=n.min,t=n.max,r=n.range,o=n.value,i=n.hasMinEdge,u=n.hasMaxEdge,c=n.maxBound,a=n.maxOffset,f=n.centerMinEdge,s=n.centerMaxEdge;return o<e?i?0:f:t<o?u?c:s:(o-e)/r*a},Xs="left",qs=function(n){return n.element().dom().getBoundingClientRect()},Ys=function(n,e){return n[e]},Ks=function(n){var e=qs(n);return Ys(e,Xs)},Js=function(n){var e=qs(n);return Ys(e,"right")},Qs=function(n){var e=qs(n);return Ys(e,"top")},Zs=function(n){var e=qs(n);return Ys(e,"bottom")},nl=function(n){var e=qs(n);return Ys(e,"width")},el=function(n){var e=qs(n);return Ys(e,"height")},tl=function(n,e,t){return(n+e)/2-t},rl=function(n,e){var t=qs(n),r=qs(e),o=Ys(t,Xs),i=Ys(t,"right"),u=Ys(r,Xs);return tl(o,i,u)},ol=function(n,e){var t=qs(n),r=qs(e),o=Ys(t,"top"),i=Ys(t,"bottom"),u=Ys(r,"top");return tl(o,i,u)},il=function(n,e){me(n,ms(),{value:e})},ul=function(n){return{x:h(n)}},cl=function(n,e,t){var r={min:ps(e),max:ys(e),range:Ts(e),value:t,step:Ds(e),snap:Ms(e),snapStart:Is(e),rounded:Rs(e),hasMinEdge:As(e),hasMaxEdge:Fs(e),minBound:Ks(n),maxBound:Js(n),screenRange:nl(n)};return Ws(r)},al=function(u){return function(n,e){return(t=u,r=n,o=e,i=(0<t?$s:Gs)(js(o).x(),ps(o),ys(o),Ds(o)),il(r,ul(i)),k.some(i)).map(function(){return!0});var t,r,o,i}},fl=function(n,e,t,r,o,i){var u,c,a,f,s,l,d,m,g,p=(c=i,a=t,f=r,s=o,l=nl(u=e),d=f.bind(function(n){return k.some(rl(n,u))}).getOr(0),m=s.bind(function(n){return k.some(rl(n,u))}).getOr(l),g={min:ps(c),max:ys(c),range:Ts(c),value:a,hasMinEdge:As(c),hasMaxEdge:Fs(c),minBound:Ks(u),minOffset:0,maxBound:Js(u),maxOffset:l,centerMinEdge:d,centerMaxEdge:m},_s(g));return Ks(e)-Ks(n)+p},sl=al(-1),ll=al(1),dl=k.none,ml=k.none,gl={"top-left":k.none(),top:k.none(),"top-right":k.none(),right:k.some(function(n,e){Ls(n,Hs(ws(e)))}),"bottom-right":k.none(),bottom:k.none(),"bottom-left":k.none(),left:k.some(function(n,e){Ls(n,Hs(hs(e)))})},pl=/* */Object.freeze({setValueFrom:function(n,e,t){var r=cl(n,e,t),o=ul(r);return il(n,o),r},setToMin:function(n,e){var t=ps(e);il(n,ul(t))},setToMax:function(n,e){var t=ys(e);il(n,ul(t))},findValueOfOffset:cl,getValueFromEvent:function(n){return gs(n).map(function(n){return n.left()})},findPositionOfValue:fl,setPositionFromValue:function(n,e,t,r){var o=js(t),i=fl(n,r.getSpectrum(n),o.x(),r.getLeftEdge(n),r.getRightEdge(n),t),u=fs(e.element())/2;_i(e.element(),"left",i-u+"px")},onLeft:sl,onRight:ll,onUp:dl,onDown:ml,edgeActions:gl}),vl=function(n,e){me(n,ms(),{value:e})},hl=function(n){return{y:h(n)}},bl=function(n,e,t){var r={min:vs(e),max:xs(e),range:ks(e),value:t,step:Ds(e),snap:Ms(e),snapStart:Is(e),rounded:Rs(e),hasMinEdge:Vs(e),hasMaxEdge:Ns(e),minBound:Qs(n),maxBound:Zs(n),screenRange:el(n)};return Ws(r)},yl=function(u){return function(n,e){return(t=u,r=n,o=e,i=(0<t?$s:Gs)(js(o).y(),vs(o),xs(o),Ds(o)),vl(r,hl(i)),k.some(i)).map(function(){return!0});var t,r,o,i}},xl=function(n,e,t,r,o,i){var u,c,a,f,s,l,d,m,g,p=(c=i,a=t,f=r,s=o,l=el(u=e),d=f.bind(function(n){return k.some(ol(n,u))}).getOr(0),m=s.bind(function(n){return k.some(ol(n,u))}).getOr(l),g={min:vs(c),max:xs(c),range:ks(c),value:a,hasMinEdge:Vs(c),hasMaxEdge:Ns(c),minBound:Qs(u),minOffset:0,maxBound:Zs(u),maxOffset:l,centerMinEdge:d,centerMaxEdge:m},_s(g));return Qs(e)-Qs(n)+p},wl=k.none,Sl=k.none,Ol=yl(-1),Tl=yl(1),kl={"top-left":k.none(),top:k.some(function(n,e){Ls(n,zs(bs(e)))}),"top-right":k.none(),right:k.none(),"bottom-right":k.none(),bottom:k.some(function(n,e){Ls(n,zs(Ss(e)))}),"bottom-left":k.none(),left:k.none()},El=/* */Object.freeze({setValueFrom:function(n,e,t){var r=bl(n,e,t),o=hl(r);return vl(n,o),r},setToMin:function(n,e){var t=vs(e);vl(n,hl(t))},setToMax:function(n,e){var t=xs(e);vl(n,hl(t))},findValueOfOffset:bl,getValueFromEvent:function(n){return gs(n).map(function(n){return n.top()})},findPositionOfValue:xl,setPositionFromValue:function(n,e,t,r){var o=js(t),i=xl(n,r.getSpectrum(n),o.y(),r.getTopEdge(n),r.getBottomEdge(n),t),u=ru(e.element())/2;_i(e.element(),"top",i-u+"px")},onLeft:wl,onRight:Sl,onUp:Ol,onDown:Tl,edgeActions:kl}),Cl=function(n,e){me(n,ms(),{value:e})},Dl=function(n,e){return{x:h(n),y:h(e)}},Ml=function(f,s){return function(n,e){return(t=f,r=s,o=n,i=e,u=0<t?$s:Gs,c=r?js(i).x():u(js(i).x(),ps(i),ys(i),Ds(i)),a=r?u(js(i).y(),vs(i),xs(i),Ds(i)):js(i).y(),Cl(o,Dl(c,a)),k.some(c)).map(function(){return!0});var t,r,o,i,u,c,a}},Il=Ml(-1,!1),Rl=Ml(1,!1),Bl=Ml(-1,!0),Al=Ml(1,!0),Fl={"top-left":k.some(function(n,e){Ls(n,Ps(hs(e),bs(e)))}),top:k.some(function(n,e){Ls(n,Ps(Es(e),bs(e)))}),"top-right":k.some(function(n,e){Ls(n,Ps(ws(e),bs(e)))}),right:k.some(function(n,e){Ls(n,Ps(ws(e),Cs(e)))}),"bottom-right":k.some(function(n,e){Ls(n,Ps(ws(e),Ss(e)))}),bottom:k.some(function(n,e){Ls(n,Ps(Es(e),Ss(e)))}),"bottom-left":k.some(function(n,e){Ls(n,Ps(hs(e),Ss(e)))}),left:k.some(function(n,e){Ls(n,Ps(hs(e),Cs(e)))})},Vl=/* */Object.freeze({setValueFrom:function(n,e,t){var r=cl(n,e,t.left()),o=bl(n,e,t.top()),i=Dl(r,o);return Cl(n,i),i},setToMin:function(n,e){var t=ps(e),r=vs(e);Cl(n,Dl(t,r))},setToMax:function(n,e){var t=ys(e),r=xs(e);Cl(n,Dl(t,r))},getValueFromEvent:function(n){return gs(n)},setPositionFromValue:function(n,e,t,r){var o=js(t),i=fl(n,r.getSpectrum(n),o.x(),r.getLeftEdge(n),r.getRightEdge(n),t),u=xl(n,r.getSpectrum(n),o.y(),r.getTopEdge(n),r.getBottomEdge(n),t),c=fs(e.element())/2,a=ru(e.element())/2;_i(e.element(),"left",i-c+"px"),_i(e.element(),"top",u-a+"px")},onLeft:Il,onRight:Rl,onUp:Bl,onDown:Al,edgeActions:Fl}),Nl=Yn.detect().deviceType.isTouch(),jl=[Fr("stepSize",1),Fr("onChange",x),Fr("onChoose",x),Fr("onInit",x),Fr("onDragStart",x),Fr("onDragEnd",x),Fr("snapToGrid",!1),Fr("rounded",!0),Ir("snapStart"),Dr("model",Tr("mode",{x:[Fr("minX",0),Fr("maxX",100),Nr("value",function(n){return Ho(n.mode.minX)}),Cr("getInitialValue"),hi("manager",pl)],y:[Fr("minY",0),Fr("maxY",100),Nr("value",function(n){return Ho(n.mode.minY)}),Cr("getInitialValue"),hi("manager",El)],xy:[Fr("minX",0),Fr("maxX",100),Fr("minY",0),Fr("maxY",100),Nr("value",function(n){return Ho({x:h(n.mode.minX),y:h(n.mode.minY)})}),Cr("getInitialValue"),hi("manager",Vl)]})),Oa("sliderBehaviours",[Sa,us])].concat(Nl?[]:[Nr("mouseIsDown",function(){return Ho(!1)})]),Hl=Yn.detect().deviceType.isTouch(),zl=Cf({name:"Slider",configFields:jl,partFields:Xf,factory:function(i,n,e,t){var u=function(n){return af(n,i,"thumb")},c=function(n){return af(n,i,"spectrum")},r=function(n){return cf(n,i,"left-edge")},o=function(n){return cf(n,i,"right-edge")},a=function(n){return cf(n,i,"top-edge")},f=function(n){return cf(n,i,"bottom-edge")},s=i.model,l=s.manager,d=function(n,e){l.setPositionFromValue(n,e,i,{getLeftEdge:r,getRightEdge:o,getTopEdge:a,getBottomEdge:f,getSpectrum:c})},m=function(n,e){s.value.set(e);var t=u(n);return d(n,t),i.onChange(n,t,e),k.some(!0)},g=[Kr(A(),function(n,e){i.onDragStart(n,u(n))}),Kr(V(),function(n,e){i.onDragEnd(n,u(n))})],p=[Kr(N(),function(n,e){e.stop(),i.onDragStart(n,u(n)),i.mouseIsDown.set(!0)}),Kr(H(),function(n,e){i.onDragEnd(n,u(n))})],v=Hl?g:p;return{uid:i.uid,dom:i.dom,components:n,behaviours:ka(i.sliderBehaviours,Fn([Hl?[]:[Sa.config({mode:"special",focusIn:function(n){return cf(n,i,"spectrum").map(Sa.focusIn).map(h(!0))}})],[us.config({store:{mode:"manual",getValue:function(n){return s.value.get()}}}),wi.config({channels:{"mouse.released":{onReceive:function(t,n){var e=i.mouseIsDown.get();i.mouseIsDown.set(!1),e&&cf(t,i,"thumb").each(function(n){var e=s.value.get();i.onChoose(t,n,e)})}}}})]])),events:qr([Kr(ms(),function(n,e){m(n,e.event().value())}),eo(function(n,e){var t=s.getInitialValue();s.value.set(t);var r=u(n);d(n,r);var o=c(n);i.onInit(n,r,o,s.value.get())})].concat(v)),apis:{resetToMin:function(n){l.setToMin(n,i)},resetToMax:function(n){l.setToMax(n,i)},changeValue:m,refresh:d},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)}}}),Pl=function(e,t,r,n){return Nf.forToolbar(t,function(){var n=r();e.setContextToolbar([{label:t+" group",items:n}])},{},n)},Ll=function(n){return[(o=n,i=function(n){return n<0?"black":360<n?"white":"hsl("+n+", 100%, 50%)"},zl.sketch({dom:Rf('<div class="${prefix}-slider ${prefix}-hue-slider-container"></div>'),components:[zl.parts()["left-edge"](Bf('<div class="${prefix}-hue-slider-black"></div>')),zl.parts().spectrum({dom:Rf('<div class="${prefix}-slider-gradient-container"></div>'),components:[Bf('<div class="${prefix}-slider-gradient"></div>')],behaviours:po([Ai.config({toggleClass:Hi.resolve("thumb-active")})])}),zl.parts()["right-edge"](Bf('<div class="${prefix}-hue-slider-white"></div>')),zl.parts().thumb({dom:Rf('<div class="${prefix}-slider-thumb"></div>'),behaviours:po([Ai.config({toggleClass:Hi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());_i(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Ai.on(e)},onDragEnd:function(n,e){Ai.off(e)},onInit:function(n,e,t,r){var o=i(r.x());_i(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:po([Vi(zl.refresh)])}))];var o,i},Gl=function(n,r){var e={onChange:function(n,e,t){r.undoManager.transact(function(){r.formatter.apply("forecolor",{value:t}),r.nodeChanged()})},getInitialValue:function(){return-1}};return Pl(n,"color-levels",function(){return Ll(e)},r)},$l=fr([Cr("getInitialValue"),Cr("onChange"),Cr("category"),Cr("sizes")]),Ul=function(n){var i=Sr("SizeSlider",$l,n);return zl.sketch({dom:{tag:"div",classes:[Hi.resolve("slider-"+i.category+"-size-container"),Hi.resolve("slider"),Hi.resolve("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r<i.sizes.length&&i.onChange(o)},onDragStart:function(n,e){Ai.on(e)},onDragEnd:function(n,e){Ai.off(e)},model:{mode:"x",minX:0,maxX:i.sizes.length-1,getInitialValue:function(){return{x:function(){return i.getInitialValue()}}}},stepSize:1,snapToGrid:!0,sliderBehaviours:po([Vi(zl.refresh)]),components:[zl.parts().spectrum({dom:Rf('<div class="${prefix}-slider-size-container"></div>'),components:[Bf('<div class="${prefix}-slider-size-line"></div>')]}),zl.parts().thumb({dom:Rf('<div class="${prefix}-slider-thumb"></div>'),behaviours:po([Ai.config({toggleClass:Hi.resolve("thumb-active")})])})]})},Wl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],_l=function(n){var e,t,r=n.selection.getStart(),o=be.fromDom(r),i=be.fromDom(n.getBody()),u=(e=function(n){return We(i,n)},(Te(t=o)?k.some(t):Xe(t)).map(function(n){return Wr(n,function(n){return Ki(n,"font-size").isSome()},e).bind(function(n){return Ki(n,"font-size")}).getOrThunk(function(){return qi(n,"font-size")})}).getOr(""));return In(Wl,function(n){return u===n}).getOr("medium")},Xl={candidates:h(Wl),get:function(n){var e,t=_l(n);return(e=t,Rn(Wl,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,k.from(Wl[e])).each(function(n){var e,t;t=n,_l(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},ql=Xl.candidates(),Yl=function(n){return[Bf('<span class="${prefix}-toolbar-button ${prefix}-icon-small-font ${prefix}-icon"></span>'),(e=n,Ul({onChange:e.onChange,sizes:ql,category:"font",getInitialValue:e.getInitialValue})),Bf('<span class="${prefix}-toolbar-button ${prefix}-icon-large-font ${prefix}-icon"></span>')];var e},Kl=function(n){var e=function t(n){return n.uid!==undefined}(n)&&Ft(n,"uid")?n.uid:xf("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(k.none,k.some)},asSpec:function(){return y({},n,{uid:e})}}};var Jl=window.Promise?window.Promise:function(){var i=function(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],s(n,r(o,this),r(c,this))},n=i.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){v.setTimeout(n,1)};function r(n,e){return function(){return n.apply(e,arguments)}}var t=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};function u(r){var o=this;null!==this._state?n(function(){var n=o._state?r.onFulfilled:r.onRejected;if(null!==n){var e;try{e=n(o._value)}catch(t){return void r.reject(t)}r.resolve(e)}else(o._state?r.resolve:r.reject)(o._value)}):this._deferreds.push(r)}function o(n){try{if(n===this)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var e=n.then;if("function"==typeof e)return void s(r(e,n),r(o,this),r(c,this))}this._state=!0,this._value=n,a.call(this)}catch(t){c.call(this,t)}}function c(n){this._state=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferreds;n<e.length;n++){var t=e[n];u.call(this,t)}this._deferreds=[]}function f(n,e,t,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof e?e:null,this.resolve=t,this.reject=r}function s(n,e,t){var r=!1;try{n(function(n){r||(r=!0,e(n))},function(n){r||(r=!0,t(n))})}catch(o){if(r)return;r=!0,t(o)}}return i.prototype["catch"]=function(n){return this.then(null,n)},i.prototype.then=function(t,r){var o=this;return new i(function(n,e){u.call(o,new f(t,r,n,e))})},i.all=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var a=Array.prototype.slice.call(1===n.length&&t(n[0])?n[0]:n);return new i(function(o,i){if(0===a.length)return o([]);var u=a.length;function c(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){c(e,n)},i)}a[e]=n,0==--u&&o(a)}catch(r){i(r)}}for(var n=0;n<a.length;n++)c(n,a[n])})},i.resolve=function(e){return e&&"object"==typeof e&&e.constructor===i?e:new i(function(n){n(e)})},i.reject=function(t){return new i(function(n,e){e(t)})},i.race=function(o){return new i(function(n,e){for(var t=0,r=o;t<r.length;t++)r[t].then(n,e)})},i}();function Ql(r){return new Jl(function(n){var e=function t(){return new(Ve.getOrDie("FileReader"))}();e.onloadend=function(){n(e.result)},e.readAsDataURL(r)})}var Zl,nd,ed=function(n){return function e(n){return Ql(n).then(function(n){return n.split(",")[1]})}(n)},td=function(u){var e=Kl({dom:{tag:"input",attributes:{accept:"image/*",type:"file",title:""},styles:{visibility:"hidden",position:"absolute"}},events:qr([no(U()),Kr($(),function(n,e){var t,r,o;(t=e,r=t.event(),o=r.raw().target.files||r.raw().dataTransfer.files,k.from(o[0])).each(function(n){var o,i;o=u,ed(i=n).then(function(r){o.undoManager.transact(function(){var n=o.editorUpload.blobCache,e=n.create(ja("mceu"),i,r);n.add(e);var t=o.dom.createHTML("img",{src:e.blobUri()});o.insertContent(t)})})})})])});return Df.sketch({dom:Nf.getToolbarIconButton("image",u),components:[e.asSpec()],action:function(n){e.get(n).element().dom().click()}})},rd=function(n){return n.dom().textContent},od=function(n){return 0<n.length},id=function(n){return n===undefined||null===n?"":n},ud=function(e,t,n){return n.text.toOption().filter(od).fold(function(){return Oo(n=e,"href")===rd(n)?k.some(t):k.none();var n},k.some)},cd=function(n){var e=be.fromDom(n.selection.getStart());return su(e,"a")},ad={getInfo:function(n){return cd(n).fold(function(){return{url:"",text:n.selection.getContent({format:"text"}),title:"",target:"",link:k.none()}},function(n){return t=rd(e=n),r=Oo(e,"href"),o=Oo(e,"title"),i=Oo(e,"target"),{url:id(r),text:t!==r?id(t):"",title:id(o),target:id(i),link:k.some(e)};var e,t,r,o,i})},applyInfo:function(o,i){i.url.toOption().filter(od).fold(function(){var e;e=o,i.link.bind(b).each(function(n){e.execCommand("unlink")})},function(e){var n,t,r=(n=i,(t={}).href=e,n.title.toOption().filter(od).each(function(n){t.title=n}),n.target.toOption().filter(od).each(function(n){t.target=n}),t);i.link.bind(b).fold(function(){var n=i.text.toOption().filter(od).getOr(e);o.insertContent(o.dom.createHTML("a",r,o.dom.encode(n)))},function(t){var n=ud(t,e,i);So(t,r),n.each(function(n){var e;e=n,t.dom().textContent=e})})})},query:cd},fd=Yn.detect(),sd=function(n,e){var t=e.selection.getRng();n(),e.selection.setRng(t)},ld=function(n,e){(fd.os.isAndroid()?sd:f)(e,n)},dd=function(n,e){var t,r;return{key:n,value:{config:{},me:(t=n,r=qr(e),ho({fields:[Cr("enabled")],name:t,active:{events:h(r)}})),configAsRaw:h({}),initialConfig:{},state:mo}}},md=/* */Object.freeze({getCurrent:function(n,e,t){return e.find(n)}}),gd=[Cr("find")],pd=ho({fields:gd,name:"composing",apis:md}),vd=Ef({name:"Container",factory:function(n){var e=n.dom,t=e.attributes,r=a(e,["attributes"]);return{uid:n.uid,dom:y({tag:"div",attributes:y({role:"presentation"},t)},r),components:n.components,behaviours:Ta(n.containerBehaviours),events:n.events,domModification:n.domModification,eventOrder:n.eventOrder}},configFields:[Fr("components",[]),Oa("containerBehaviours",[]),Fr("events",{}),Fr("domModification",{}),Fr("eventOrder",{})]}),hd=Ef({name:"DataField",factory:function(t){return{uid:t.uid,dom:t.dom,behaviours:Ca(t.dataBehaviours,[us.config({store:{mode:"memory",initialValue:t.getInitialValue()}}),pd.config({find:k.some})]),events:qr([eo(function(n,e){us.setValue(n,t.getInitialValue())})])}},configFields:[Cr("uid"),Cr("dom"),Cr("getInitialValue"),Ea("dataBehaviours",[us,pd])]}),bd=function(n){return n.dom().value},yd=function(n,e){if(e===undefined)throw new Error("Value.set was undefined");n.dom().value=e},xd=h([Ir("data"),Fr("inputAttributes",{}),Fr("inputStyles",{}),Fr("tag","input"),Fr("inputClasses",[]),mi("onSetValue"),Fr("styles",{}),Fr("eventOrder",{}),Oa("inputBehaviours",[us,$i]),Fr("selectOnFocus",!0)]),wd=function(n){return y({},(e=n,po([$i.config({onFocus:!1===e.selectOnFocus?x:function(n){var e=n.element(),t=bd(e);e.dom().setSelectionRange(0,t.length)}})])),ka(n.inputBehaviours,[us.config({store:{mode:"manual",initialValue:n.data.getOr(undefined),getValue:function(n){return bd(n.element())},setValue:function(n,e){bd(n.element())!==e&&yd(n.element(),e)}},onSetValue:n.onSetValue})]));var e},Sd=Ef({name:"Input",configFields:xd(),factory:function(n,e){return{uid:n.uid,dom:(t=n,{tag:t.tag,attributes:y({type:"text"},t.inputAttributes),styles:t.inputStyles,classes:t.inputClasses}),components:[],behaviours:wd(n),eventOrder:n.eventOrder};var t}}),Od=/* */Object.freeze({exhibit:function(n,e){return co({attributes:Bt([{key:e.tabAttr,value:"true"}])})}}),Td=[Fr("tabAttr","data-alloy-tabstop")],kd=ho({fields:Td,name:"tabstopping",active:Od}),Ed=tinymce.util.Tools.resolve("tinymce.util.I18n"),Cd=function(n,e){var t=Kl(Sd.sketch({inputAttributes:{placeholder:Ed.translate(e)},onSetValue:function(n,e){de(n,G())},inputBehaviours:po([pd.config({find:k.some}),kd.config({}),Sa.config({mode:"execution"})]),selectOnFocus:!1})),r=Kl(Df.sketch({dom:Rf('<button class="${prefix}-input-container-x ${prefix}-icon-cancel-circle ${prefix}-icon"></button>'),action:function(n){var e=t.get(n);us.setValue(e,"")}}));return{name:n,spec:vd.sketch({dom:Rf('<div class="${prefix}-input-container"></div>'),components:[t.asSpec(),r.asSpec()],containerBehaviours:po([Ai.config({toggleClass:Hi.resolve("input-container-empty")}),pd.config({find:function(n){return k.some(t.get(n))}}),dd("input-clearing",[Kr(G(),function(n){var e=t.get(n);(0<us.getValue(e).length?Ai.off:Ai.on)(n)})])])})}},Dd=["input","button","textarea","select"],Md=function(n,e,t){e.disabled&&Vd(n,e)},Id=function(n){return On(Dd,Se(n.element()))},Rd=function(n){wo(n.element(),"disabled","disabled")},Bd=function(n){ko(n.element(),"disabled")},Ad=function(n){wo(n.element(),"aria-disabled","true")},Fd=function(n){wo(n.element(),"aria-disabled","false")},Vd=function(e,n,t){n.disableClass.each(function(n){Io(e.element(),n)}),(Id(e)?Rd:Ad)(e),n.onDisabled(e)},Nd=function(e,n,t){n.disableClass.each(function(n){Bo(e.element(),n)}),(Id(e)?Bd:Fd)(e),n.onEnabled(e)},jd=function(n){return Id(n)?To(n.element(),"disabled"):"true"===Oo(n.element(),"aria-disabled")},Hd=/* */Object.freeze({enable:Nd,disable:Vd,isDisabled:jd,onLoad:Md,set:function(n,e,t,r){(r?Vd:Nd)(n,e,t)}}),zd=/* */Object.freeze({exhibit:function(n,e,t){return co({classes:e.disabled?e.disableClass.map(Hn).getOr([]):[]})},events:function(n,e){return qr([Yr(ee(),function(n,e){return jd(n)}),ao(n,e,Md)])}}),Pd=[Fr("disabled",!1),Ir("disableClass"),mi("onDisabled"),mi("onEnabled")],Ld=ho({fields:Pd,name:"disabling",active:zd,apis:Hd}),Gd=[Oa("formBehaviours",[us])],$d=function(n){return"<alloy.field."+n+">"},Ud=function(o,n,e){return{uid:o.uid,dom:o.dom,components:n,behaviours:ka(o.formBehaviours,[us.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),M(e.partUids,function(n,e){return h(t.getByUid(n))}));return M(r,function(n,e){return n().bind(function(n){var e,t=pd.getCurrent(n);return e="missing current",t.fold(function(){return dt.error(e)},dt.value)}).map(us.getValue)})},setValue:function(t,n){D(n,function(e,n){cf(t,o,n).each(function(n){pd.getCurrent(n).each(function(n){us.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return cf(n,o,e).bind(pd.getCurrent)}}}},Wd=(mf(function(n,e,t){return n.getField(e,t)}),function(n){var i,e=(i=[],{field:function(n,e){return i.push(n),t="form",r=$d(n),o=e,{uiType:Va(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=kn(r,function(n){return Ja({name:n,pname:$d(n)})});return Sf("form",Gd,o,Ud,t)}),_d=function(){var e=Ho(k.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(k.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(k.some(n))},run:function(n){e.get().each(n)}}},Xd=function(){var e=Ho(k.none());return{clear:function(){e.set(k.none())},set:function(n){e.set(k.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},qd=function(n){return{xValue:n,points:[]}},Yd=function(n,e){if(e===n.xValue)return n;var t=0<e-n.xValue?1:-1,r={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([r])}},Kd=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},Jd=function(n){var r="navigateEvent",e=sr([Cr("fields"),Fr("maxFieldIndex",n.fields.length-1),Cr("onExecute"),Cr("getInitialValue"),Nr("state",function(){return{dialogSwipeState:Xd(),currentScreen:Ho(0)}})]),u=Sr("SerialisedDialog",e,n),o=function(e,n,t){return Df.sketch({dom:Rf('<span class="${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:function(n){me(n,r,{direction:e})},buttonBehaviours:po([Ld.config({disableClass:Hi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=uu(n.element(),"."+Hi.resolve("serialised-dialog-screen"));fu(n.element(),"."+Hi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o<i.length&&(Ki(r,"left").each(function(n){var e=parseInt(n,10),t=fs(i[0]);_i(r,"left",e-o*t+"px")}),u.state.currentScreen.set(u.state.currentScreen.get()+o))})},c=function(r){var n=uu(r.element(),"input");k.from(n[u.state.currentScreen.get()]).each(function(n){r.getSystem().getByDom(n).each(function(n){var e,t;e=r,t=n.element(),e.getSystem().triggerFocus(t,e.element())})});var e=f.get(r);Au.highlightAt(e,u.state.currentScreen.get())},a=Kl(Wd(function(t){return{dom:Rf('<div class="${prefix}-serialised-dialog"></div>'),components:[vd.sketch({dom:Rf('<div class="${prefix}-serialised-dialog-chain" style="left: 0px; position: absolute;"></div>'),components:kn(u.fields,function(n,e){return e<=u.maxFieldIndex?vd.sketch({dom:Rf('<div class="${prefix}-serialised-dialog-screen"></div>'),components:[o(-1,"previous",0<e),t.field(n.name,n.spec),o(1,"next",e<u.maxFieldIndex)]}):t.field(n.name,n.spec)})})],formBehaviours:po([Vi(function(n,e){var t;t=e,fu(n.element(),"."+Hi.resolve("serialised-dialog-chain")).each(function(n){_i(n,"left",-u.state.currentScreen.get()*t.width+"px")})}),Sa.config({mode:"special",focusIn:function(n){c(n)},onTab:function(n){return i(n,1),k.some(!0)},onShiftTab:function(n){return i(n,-1),k.some(!0)}}),dd("form-events",[eo(function(e,n){u.state.currentScreen.set(0),u.state.dialogSwipeState.clear();var t=f.get(e);Au.highlightFirst(t),u.getInitialValue(e).each(function(n){us.setValue(e,n)})}),oo(u.onExecute),Kr(W(),function(n,e){"left"===e.event().raw().propertyName&&c(n)}),Kr(r,function(n,e){var t=e.event().direction();i(n,t)})])])}})),f=Kl({dom:Rf('<div class="${prefix}-dot-container"></div>'),behaviours:po([Au.config({highlightClass:Hi.resolve("dot-active"),itemClass:Hi.resolve("dot-item")})]),components:Vn(u.fields,function(n,e){return e<=u.maxFieldIndex?[Bf('<div class="${prefix}-dot-item ${prefix}-icon-full-dot ${prefix}-icon"></div>')]:[]})});return{dom:Rf('<div class="${prefix}-serializer-wrapper"></div>'),components:[a.asSpec(),f.asSpec()],behaviours:po([Sa.config({mode:"special",focusIn:function(n){var e=a.get(n);Sa.focusIn(e)}}),dd("serializer-wrapper-events",[Kr(A(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(qd(t.raw().touches[0].clientX))}),Kr(F(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(Yd(n,t.raw().touches[0].clientX))})}),Kr(V(),function(r){u.state.dialogSwipeState.on(function(n){var e=a.get(r),t=-1*Kd(n);i(e,t)})})])])}},Qd=X(function(t,r){return[{label:"the link group",items:[Jd({fields:[Cd("url","Type or paste URL"),Cd("text","Link text"),Cd("title","Link title"),Cd("target","Link target"),(n="link",{name:n,spec:hd.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return k.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return k.some(ad.getInfo(r))},onExecute:function(n){var e=us.getValue(n);ad.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),Zd=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],nm=qr([(Zl=Jn(),nd=function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(We(t=o,n.element())&&!We(t,r))||(v.console.warn(Jn()+" did not get interpreted by the desired target. \nOriginator: "+Jo(o)+"\nTarget: "+Jo(i)+"\nCheck the "+Jn()+" event handlers"),!1)},{key:Zl,value:Hr({can:nd})})]),em=/* */Object.freeze({events:nm}),tm=b,rm=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+Jo(e().element())+" is not in context.")}};return{debugInfo:h("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),build:n("build"),addToWorld:n("addToWorld"),removeFromWorld:n("removeFromWorld"),addToGui:n("addToGui"),removeFromGui:n("removeFromGui"),getByUid:n("getByUid"),getByDom:n("getByDom"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),isConnected:h(!1)}},om=rm(),im=function(n,o){var i={};return D(n,function(n,r){D(n,function(n,e){var t=Mt(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},um=function(n,e){return t=l.apply(undefined,[n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:h(r)};var t,r},cm=function(n){return n.cHandler},am=function(n,e){return{name:h(n),handler:h(e)}},fm=function(n,e,t){var r,o,i=y({},t,(r=n,o={},En(e,function(n){o[n.name()]=n.handlers(r)}),o));return im(i,am)},sm=function(n){var e,i=yn(e=n)?{can:h(!0),abort:h(!1),run:e}:e;return function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];var o=[n,e].concat(t);i.abort.apply(undefined,o)?e.stop():i.can.apply(undefined,o)&&i.run.apply(undefined,o)}},lm=function(n,e,t){var r,o,i=e[t];return i?function(u,c,n,a){var e=n.slice(0);try{var t=e.sort(function(n,e){var t=n[c](),r=e[c](),o=a.indexOf(t),i=a.indexOf(r);if(-1===o)throw new Error("The ordering for "+u+" does not have an entry for "+t+".\nOrder specified: "+er(a,null,2));if(-1===i)throw new Error("The ordering for "+u+" does not have an entry for "+r+".\nOrder specified: "+er(a,null,2));return o<i?-1:i<o?1:0});return dt.value(t)}catch(r){return dt.error([r])}}("Event: "+t,"name",n,i).map(function(n){var e=kn(n,function(n){return n.handler()});return zr(e)}):(r=t,o=n,dt.error(["The event ("+r+') 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: '+er(kn(o,function(n){return n.name()}),null,2)]))},dm=function(n,i){var e=R(n,function(r,o){return(1===r.length?dt.value(r[0].handler()):lm(r,i,o)).map(function(n){var e=sm(n),t=1<r.length?Cn(i,function(e){return On(r,function(n){return n.name()===e})}).join(" > "):r[0].name();return Rt(o,{handler:e,purpose:h(t)})})});return At(e,{})},mm=function(n){return xr("custom.definition",sr([gr("dom","dom",xt(),sr([Cr("tag"),Fr("styles",{}),Fr("classes",[]),Fr("attributes",{}),Ir("value"),Ir("innerHtml")])),Cr("components"),Cr("uid"),Fr("events",{}),Fr("apis",{}),gr("eventOrder","eventOrder",(e={"alloy.execute":["disabling","alloy.base.behaviour","toggling","typeaheadevents"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing","item-events","tooltipping"],mousedown:["focusing","alloy.base.behaviour","item-type-events"],mouseover:["item-type-events","tooltipping"]},bt.mergeWithThunk(h(e))),kr()),Ir("domModification")]),n);var e},gm=function(e,n){En(n,function(n){Io(e,n)})},pm=function(e,n){En(n,function(n){Bo(e,n)})},vm=function(n,e){return t=n,o=kn(r=e,function(n){return Br(n.name(),[Cr("config"),Fr("state",mo)])}),i=xr("component.behaviours",sr(o),t.behaviours).fold(function(n){throw new Error(Or(n)+"\nComplete spec:\n"+er(t,null,2))},function(n){return n}),{list:r,data:M(i,function(n){var e=n.map(function(n){return{config:n.config,state:n.state.init(n.config)}});return function(){return e}})};var t,r,o,i},hm=function(n){var e,t,r,o=(e=n,t=Mt("behaviours",{})(e),r=Cn(E(t),function(n){return t[n]!==undefined}),kn(r,function(n){return t[n].me}));return vm(n,o)},bm=function(n,e,t){var r,o,i,u=y({},(r=n).dom,{uid:r.uid,domChildren:kn(r.components,function(n){return n.element()})}),c=n.domModification.fold(function(){return co({})},co),a={"alloy.base.modification":c},f=0<e.length?function(e,n,t,r){var o=y({},n);En(t,function(n){o[n.name()]=n.exhibit(e,r)});var i=im(o,function(n,e){return{name:n,modification:e}}),u=function(n){return Dn(n,function(n,e){return y({},e.modification,n)},{})},c=Dn(i.classes,function(n,e){return e.modification.concat(n)},[]),a=u(i.attributes),f=u(i.styles);return co({classes:c,attributes:a,styles:f})}(t,a,e,u):c;return i=f,y({},o=u,{attributes:y({},o.attributes,i.attributes),styles:y({},o.styles,i.styles),classes:o.classes.concat(i.classes)})},ym=function(n,e,t){var r,o,i,u,c,a,f={"alloy.base.behaviour":(r=n,r.events)};return(o=t,i=n.eventOrder,u=e,c=f,a=fm(o,u,c),dm(a,i)).getOrDie()},xm=function(t){var n=function(){return s},r=Ho(om),e=wr(mm(t)),o=hm(t),i=o.list,u=o.data,c=function(n){var e=be.fromTag(n.tag);So(e,n.attributes),gm(e,n.classes),Xi(e,n.styles),n.innerHtml.each(function(n){return qo(e,n)});var t=n.domChildren;return nt(e,t),n.value.each(function(n){yd(e,n)}),n.uid,bf(e,n.uid),e}(bm(e,i,u)),a=ym(e,i,u),f=Ho(e.components),s={getSystem:r.get,config:function(n){var e=u;return(yn(e[n.name()])?e[n.name()]:function(){throw new Error("Could not find "+n.name()+" in "+er(t,null,2))})()},hasConfigured:function(n){return yn(u[n.name()])},spec:h(t),readState:function(n){return u[n]().map(function(n){return n.state.readState()}).getOr("not enabled")},getApis:function(){return e.apis},connect:function(n){r.set(n)},disconnect:function(){r.set(rm(n))},element:h(c),syncComponents:function(){var n=qe(c),e=Vn(n,function(n){return r.get().getByDom(n).fold(function(){return[]},function(n){return[n]})});f.set(e)},components:f.get,events:h(a)};return s},wm=function(n){var e,t,r=tm(n),o=r.events,i=a(r,["events"]),u=(e=i,t=Mt("components",[])(e),kn(t,km)),c=y({},i,{events:y({},em,o),components:u});return dt.value(xm(c))},Sm=function(n){var e=be.fromText(n);return Om({element:e})},Om=function(n){var e=Sr("external.component",fr([Cr("element"),Ir("uid")]),n),t=Ho(rm());e.uid.each(function(n){bf(e.element,n)});var r={getSystem:t.get,config:k.none,hasConfigured:h(!1),connect:function(n){t.set(n)},disconnect:function(){t.set(rm(function(){return r}))},getApis:function(){return{}},element:h(e.element),spec:h(n),readState:h("No state"),syncComponents:x,components:h([]),events:h({})};return df(r)},Tm=xf,km=function(e){return(n=e,It(n,lf)).fold(function(){var n=e.hasOwnProperty("uid")?e:y({uid:Tm("")},e);return wm(n).getOrDie()},function(n){return n});var n},Em=df,Cm="alloy.item-hover",Dm="alloy.item-focus",Mm=function(n){(Go(n.element()).isNone()||$i.isFocused(n))&&($i.isFocused(n)||$i.focus(n),me(n,Cm,{item:n}))},Im=function(n){me(n,Dm,{item:n})},Rm=h(Cm),Bm=h(Dm),Am=[Cr("data"),Cr("components"),Cr("dom"),Fr("hasSubmenu",!1),Ir("toggling"),Ea("itemBehaviours",[Ai,$i,Sa,us]),Fr("ignoreFocus",!1),Fr("domModification",{}),hi("builder",function(n){return{dom:n.dom,domModification:y({},n.domModification,{attributes:y({role:n.toggling.isSome()?"menuitemcheckbox":"menuitem"},n.domModification.attributes,{"aria-haspopup":n.hasSubmenu},n.hasSubmenu?{"aria-expanded":!1}:{})}),behaviours:Ca(n.itemBehaviours,[n.toggling.fold(Ai.revoke,function(n){return Ai.config(y({aria:{mode:"checked"}},n))}),$i.config({ignore:n.ignoreFocus,stopMousedown:n.ignoreFocus,onFocus:function(n){Im(n)}}),Sa.config({mode:"execution"}),us.config({store:{mode:"memory",initialValue:n.data}}),dd("item-type-events",[Kr(oe(),ge),no(N()),Kr(z(),Mm),Kr(te(),$i.focus)])]),components:n.components,eventOrder:n.eventOrder}}),Fr("eventOrder",{})],Fm=[Cr("dom"),Cr("components"),hi("builder",function(n){return{dom:n.dom,components:n.components,events:qr([(e=te(),Kr(e,function(n,e){e.stop()}))])};var e})],Vm=h([Ja({name:"widget",overrides:function(e){return{behaviours:po([us.config({store:{mode:"manual",getValue:function(n){return e.data},setValue:function(){}}})])}}})]),Nm=[Cr("uid"),Cr("data"),Cr("components"),Cr("dom"),Fr("autofocus",!1),Fr("ignoreFocus",!1),Ea("widgetBehaviours",[us,$i,Sa]),Fr("domModification",{}),sf(Vm()),hi("builder",function(t){var n=of(0,t,Vm()),e=uf("item-widget",t,n.internals()),r=function(n){return cf(n,t,"widget").map(function(n){return Sa.focusIn(n),n})},o=function(n,e){return Ku(e.event().target())||t.autofocus&&e.setSource(n.element()),k.none()};return{dom:t.dom,components:e,domModification:t.domModification,events:qr([oo(function(n,e){r(n).each(function(n){e.stop()})}),Kr(z(),Mm),Kr(te(),function(n,e){t.autofocus?r(n):$i.focus(n)})]),behaviours:Ca(t.widgetBehaviours,[us.config({store:{mode:"memory",initialValue:t.data}}),$i.config({ignore:t.ignoreFocus,onFocus:function(n){Im(n)}}),Sa.config({mode:"special",focusIn:t.autofocus?function(n){r(n)}:yo(),onLeft:o,onRight:o,onEscape:function(n,e){return $i.isFocused(n)||t.autofocus?(t.autofocus&&e.setSource(n.element()),k.none()):($i.focus(n),k.some(!0))}})])}})],jm=Tr("type",{widget:Nm,item:Am,separator:Fm}),Hm=h([Za({factory:{sketch:function(n){var e=Sr("menu.spec item",jm,n);return e.builder(e)}},name:"items",unit:"item",defaults:function(n,e){return e.hasOwnProperty("uid")?e:y({},e,{uid:xf("item")})},overrides:function(n,e){return{type:e.type,ignoreFocus:n.fakeFocus,domModification:{classes:[n.markers.item]}}}})]),zm=h([Cr("value"),Cr("items"),Cr("dom"),Cr("components"),Fr("eventOrder",{}),Oa("menuBehaviours",[Au,us,pd,Sa]),Vr("movement",{mode:"menu",moveOnTab:!0},Tr("mode",{grid:[yi(),hi("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers.item,initSize:{numColumns:e.initSize.numColumns,numRows:e.initSize.numRows},focusManager:n.focusManager}})],matrix:[hi("config",function(n,e){return{mode:"matrix",selectors:{row:e.rowSelector,cell:"."+n.markers.item},focusManager:n.focusManager}}),Cr("rowSelector")],menu:[Fr("moveOnTab",!0),hi("config",function(n,e){return{mode:"menu",selector:"."+n.markers.item,moveOnTab:e.moveOnTab,focusManager:n.focusManager}})]})),Dr("markers",si()),Fr("fakeFocus",!1),Fr("focusManager",Vu()),mi("onHighlight")]),Pm=h("alloy.menu-focus"),Lm=Cf({name:"Menu",configFields:zm(),partFields:Hm(),factory:function(n,e,t,r){return{uid:n.uid,dom:n.dom,markers:n.markers,behaviours:ka(n.menuBehaviours,[Au.config({highlightClass:n.markers.selectedItem,itemClass:n.markers.item,onHighlight:n.onHighlight}),us.config({store:{mode:"memory",initialValue:n.value}}),pd.config({find:k.some}),Sa.config(n.movement.config(n,n.movement))]),events:qr([Kr(Bm(),function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){Au.highlight(e,n),t.stop(),me(e,Pm(),{menu:e,item:n})})}),Kr(Rm(),function(n,e){var t=e.event().item();Au.highlight(n,t)})]),components:e,eventOrder:n.eventOrder,domModification:{attributes:{role:"menu"}}}}}),Gm=function(n,e,t,r){var o=n.getSystem().build(r);ut(n,o,t)},$m=function(n,e,t,r){var o=Um(n);In(o,function(n){return We(r.element(),n.element())}).each(at)},Um=function(n,e){return n.components()},Wm=function(e,n,t,o,r){var i=Um(e);return k.from(i[o]).map(function(n){return $m(e,0,0,n),r.each(function(n){Gm(e,0,function(n,e){var t,r;r=e,Ye(t=n,o).fold(function(){Ze(t,r)},function(n){Ke(n,r)})},n)}),n})},_m=ho({fields:[],name:"replacing",apis:/* */Object.freeze({append:function(n,e,t,r){Gm(n,0,Ze,r)},prepend:function(n,e,t,r){Gm(n,0,Qe,r)},remove:$m,replaceAt:Wm,replaceBy:function(e,n,t,r,o){var i=Um(e);return Rn(i,r).bind(function(n){return Wm(e,0,0,n,o)})},set:function(e,n,t,r){var o,i,u,c,a,f;i=(o=e).components(),En(i,ct),et(o.element()),o.syncComponents(),u=function(){var n=kn(r,e.getSystem().build);En(n,function(n){it(e,n)})},c=e.element(),a=_e(c),f=Lo(a).bind(function(e){var n=function(n){return We(e,n)};return n(c)?k.some(c):_r(c,n)}),u(c),f.each(function(e){Lo(a).filter(function(n){return We(n,e)}).fold(function(){zo(e)},x)})},contents:Um})}),Xm=function(t,r,o,n){return It(o,n).bind(function(n){return It(t,n).bind(function(n){var e=Xm(t,r,o,n);return k.some([n].concat(e))})}).getOr([])},qm=function(n,e){var t={};D(n,function(n,e){En(n,function(n){t[n]=e})});var r=e,o=I(e,function(n,e){return{k:n,v:e}}),i=M(o,function(n,e){return[e].concat(Xm(t,r,o,e))});return M(t,function(n){return It(i,n).getOr([n])})},Ym=function(){var i=Ho({}),u=Ho({}),c=Ho({}),a=Ho(k.none()),f=Ho({}),e=function(n){return It(u.get(),n)};return{setMenuBuilt:function(n,e){var t;u.set(y({},u.get(),((t={})[n]={type:"prepared",menu:e},t)))},setContents:function(n,e,t,r){a.set(k.some(n)),i.set(t),u.set(e),f.set(r);var o=qm(r,t);c.set(o)},expand:function(t){return It(i.get(),t).map(function(n){var e=It(c.get(),t).getOr([]);return[n].concat(e)})},refresh:function(n){return It(c.get(),n)},collapse:function(n){return It(c.get(),n).bind(function(n){return 1<n.length?k.some(n.slice(1)):k.none()})},lookupMenu:e,otherMenus:function(n){var e,t,r=f.get();return e=E(r),t=n,Cn(e,function(n){return!On(t,n)})},getPrimary:function(){return a.get().bind(function(n){return e(n).bind(function(n){return"prepared"===n.type?k.some(n.menu):k.none()})})},getMenus:function(){return u.get()},clear:function(){i.set({}),u.set({}),c.set({}),a.set(k.none())},isClear:function(){return a.get().isNone()}}},Km=h("collapse-item"),Jm=Ef({name:"TieredMenu",configFields:[vi("onExecute"),vi("onEscape"),pi("onOpenMenu"),pi("onOpenSubmenu"),mi("onCollapseMenu"),Fr("highlightImmediately",!0),Mr("data",[Cr("primary"),Cr("menus"),Cr("expansions")]),Fr("fakeFocus",!1),mi("onHighlight"),mi("onHover"),Mr("markers",[Cr("backgroundMenu")].concat(ai()).concat(fi())),Cr("dom"),Fr("navigateOnHover",!0),Fr("stayInDom",!1),Oa("tmenuBehaviours",[Sa,Au,pd,_m]),Fr("eventOrder",{})],apis:{collapseMenu:function(n,e){n.collapseMenu(e)},highlightPrimary:function(n,e){n.highlightPrimary(e)}},factory:function(c,n){var a,e,i=Ho(k.none()),u=function(r,o,n){return M(n,function(n,e){var t=function(){return Lm.sketch(y({dom:n.dom},n,{value:e,items:n.items,markers:c.markers,fakeFocus:c.fakeFocus,onHighlight:c.onHighlight,focusManager:c.fakeFocus?(o=function(n){return Au.getHighlighted(n).map(function(n){return n.element()})},{get:o,set:function(e,n){var t=o(e);e.getSystem().getByDom(n).fold(x,function(n){Au.highlight(e,n)});var r=o(e);Fu(e,t,r)}}):Vu()}));var o};return e===o?{type:"prepared",menu:r.getSystem().build(t())}:{type:"notbuilt",nbMenu:t}})},f=Ym(),s=function(n){return us.getValue(n).value},l=function(n){return M(c.data.menus,function(n,e){return Vn(n.items,function(n){return"separator"===n.type?[]:[n.data.value]})})},d=function(e,n){Au.highlight(e,n),Au.getHighlighted(n).orThunk(function(){return Au.getFirst(n)}).each(function(n){pe(e,n.element(),te())})},m=function(e,n){return Zo(kn(n,function(n){return e.lookupMenu(n).bind(function(n){return"prepared"===n.type?k.some(n.menu):k.none()})}))},g=function(e,n,t){var r=m(n,n.otherMenus(t));En(r,function(n){pm(n.element(),[c.markers.backgroundMenu]),c.stayInDom||_m.remove(e,n)})},p=function(n,r){var o,e=(o=n,i.get().getOrThunk(function(){var t={},n=uu(o.element(),"."+c.markers.item),e=Cn(n,function(n){return"true"===Oo(n,"aria-haspopup")});return En(e,function(n){o.getSystem().getByDom(n).each(function(n){var e=s(n);t[e]=n})}),i.set(k.some(t)),t}));D(e,function(n,e){var t=On(r,e);wo(n.element(),"aria-expanded",t)})},v=function(r,o,i){return k.from(i[0]).bind(function(n){return o.lookupMenu(n).bind(function(n){if("notbuilt"===n.type)return k.none();var e=n.menu,t=m(o,i.slice(1));return En(t,function(n){Io(n.element(),c.markers.backgroundMenu)}),Ee(e.element())||_m.append(r,Em(e)),pm(e.element(),[c.markers.backgroundMenu]),d(r,e),g(r,o,i),k.some(e)})})};(e=a||(a={}))[e.HighlightSubmenu=0]="HighlightSubmenu",e[e.HighlightParent=1]="HighlightParent";var h=function(o,i,u){void 0===u&&(u=a.HighlightSubmenu);var n=s(i);return f.expand(n).bind(function(r){return p(o,r),k.from(r[0]).bind(function(t){return f.lookupMenu(t).bind(function(n){var e=function(n,e,t){if("notbuilt"!==t.type)return t.menu;var r=n.getSystem().build(t.nbMenu());return f.setMenuBuilt(e,r),r}(o,t,n);return Ee(e.element())||_m.append(o,Em(e)),c.onOpenSubmenu(o,i,e),u===a.HighlightSubmenu?(Au.highlightFirst(e),v(o,f,r)):(Au.dehighlightAll(e),k.some(i))})})})},r=function(e,t){var n=s(t);return f.collapse(n).bind(function(n){return p(e,n),v(e,f,n).map(function(n){return c.onCollapseMenu(e,t,n),n})})},t=function(t){return function(e,n){return su(n.getSource(),"."+c.markers.item).bind(function(n){return e.getSystem().getByDom(n).toOption().bind(function(n){return t(e,n).map(function(){return!0})})})}},o=qr([Kr(Pm(),function(e,n){var t=n.event().menu();Au.highlight(e,t);var r=s(n.event().item());f.refresh(r).each(function(n){return g(e,f,n)})}),oo(function(e,n){var t=n.event().target();e.getSystem().getByDom(t).each(function(n){0===s(n).indexOf("collapse-item")&&r(e,n),h(e,n,a.HighlightSubmenu).fold(function(){c.onExecute(e,n)},function(){})})}),eo(function(e,n){var t,r,o;(t=e,r=u(t,c.data.primary,c.data.menus),o=l(),f.setContents(c.data.primary,r,c.data.expansions,o),f.getPrimary()).each(function(n){_m.append(e,Em(n)),c.onOpenMenu(e,n),c.highlightImmediately&&d(e,n)})})].concat(c.navigateOnHover?[Kr(Rm(),function(n,e){var t,r,o=e.event().item();t=n,r=s(o),f.refresh(r).bind(function(n){return p(t,n),v(t,f,n)}),h(n,o,a.HighlightParent),c.onHover(n,o)})]:[])),b={collapseMenu:function(e){Au.getHighlighted(e).each(function(n){Au.getHighlighted(n).each(function(n){r(e,n)})})},highlightPrimary:function(e){f.getPrimary().each(function(n){d(e,n)})}};return{uid:c.uid,dom:c.dom,markers:c.markers,behaviours:ka(c.tmenuBehaviours,[Sa.config({mode:"special",onRight:t(function(n,e){return Ku(e.element())?k.none():h(n,e,a.HighlightSubmenu)}),onLeft:t(function(n,e){return Ku(e.element())?k.none():r(n,e)}),onEscape:t(function(n,e){return r(n,e).orThunk(function(){return c.onEscape(n,e).map(function(){return n})})}),focusIn:function(e,n){f.getPrimary().each(function(n){pe(e,n.element(),te())})}}),Au.config({highlightClass:c.markers.selectedMenu,itemClass:c.markers.menu}),pd.config({find:function(n){return Au.getHighlighted(n)}}),_m.config({})]),eventOrder:c.eventOrder,apis:b,events:o}},extraApis:{tieredData:function(n,e,t){return{primary:n,menus:e,expansions:t}},singleData:function(n,e){return{primary:n,menus:Rt(n,e),expansions:{}}},collapseItem:function(n){return{value:ja(Km()),meta:{text:n}}}}}),Qm=function(n,e,t,r){return It(e.routes,r.start).bind(function(n){return It(n,r.destination)})},Zm=function(n,e,t,r){return Qm(0,e,0,r).bind(function(e){return e.transition.map(function(n){return{transition:n,route:e}})})},ng=function(t,r,n){var e,o,i;(e=t,o=r,i=n,eg(e,o).bind(function(n){return Zm(e,o,i,n)})).each(function(n){var e=n.transition;Bo(t.element(),e.transitionClass),ko(t.element(),r.destinationAttr)})},eg=function(n,e,t){var r=n.element();return To(r,e.destinationAttr)?k.some({start:Oo(n.element(),e.stateAttr),destination:Oo(n.element(),e.destinationAttr)}):k.none()},tg=function(n,e,t,r){ng(n,e,t),To(n.element(),e.stateAttr)&&Oo(n.element(),e.stateAttr)!==r&&e.onFinish(n,r),wo(n.element(),e.stateAttr,r)},rg=/* */Object.freeze({findRoute:Qm,disableTransition:ng,getCurrentRoute:eg,jumpTo:tg,progressTo:function(t,r,o,i){var n,e;e=r,To((n=t).element(),e.destinationAttr)&&(wo(n.element(),e.stateAttr,Oo(n.element(),e.destinationAttr)),ko(n.element(),e.destinationAttr));var u,c,a=(u=r,c=i,{start:Oo(t.element(),u.stateAttr),destination:c});Zm(t,r,o,a).fold(function(){tg(t,r,o,i)},function(n){ng(t,r,o);var e=n.transition;Io(t.element(),e.transitionClass),wo(t.element(),r.destinationAttr,i)})},getState:function(n,e,t){var r=n.element();return To(r,e.stateAttr)?k.some(Oo(r,e.stateAttr)):k.none()}}),og=/* */Object.freeze({events:function(o,i){return qr([Kr(W(),function(t,n){var r=n.event().raw();eg(t,o).each(function(e){Qm(0,o,0,e).each(function(n){n.transition.each(function(n){r.propertyName===n.property&&(tg(t,o,i,e.destination),o.onTransition(t,e))})})})}),eo(function(n,e){tg(n,o,i,o.initialState)})])}}),ig=[Fr("destinationAttr","data-transitioning-destination"),Fr("stateAttr","data-transitioning-state"),Cr("initialState"),mi("onTransition"),mi("onFinish"),Dr("routes",yr(dt.value,yr(dt.value,fr([Ar("transition",[Cr("property"),Cr("transitionClass")])]))))],ug=ho({fields:ig,name:"transitioning",active:og,apis:rg,extra:{createRoutes:function(n){var r={};return D(n,function(n,e){var t=e.split("<->");r[t[0]]=Rt(t[1],n),r[t[1]]=Rt(t[0],n)}),r},createBistate:function(n,e,t){return Bt([{key:n,value:Rt(e,t)},{key:e,value:Rt(n,t)}])},createTristate:function(n,e,t,r){return Bt([{key:n,value:Bt([{key:e,value:r},{key:t,value:r}])},{key:e,value:Bt([{key:n,value:r},{key:t,value:r}])},{key:t,value:Bt([{key:n,value:r},{key:e,value:r}])}])}}}),cg=Hi.resolve("scrollable"),ag={register:function(n){Io(n,cg)},deregister:function(n){Bo(n,cg)},scrollable:h(cg)},fg=function(n){return It(n,"format").getOr(n.title)},sg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Hi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Hi.resolve("format-matches"),selected:t},itemBehaviours:po(o?[]:[Fi(n,function(n,e){(e?Ai.on:Ai.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},lg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Df.sketch({dom:{tag:"div",classes:[Hi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Hi.resolve("styles-collapse-icon")]}},Sm(n)]:[Sm(n)],action:function(n){if(r){var e=t().get(n);Jm.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Hi.resolve("styles-menu-items-container")]},components:[Lm.parts().items({})],behaviours:po([dd("adhoc-scrollable-menu",[eo(function(n,e){_i(n.element(),"overflow-y","auto"),_i(n.element(),"-webkit-overflow-scrolling","touch"),ag.register(n.element())}),to(function(n){Ji(n.element(),"overflow-y"),Ji(n.element(),"-webkit-overflow-scrolling"),ag.deregister(n.element())})])])}],items:e,menuBehaviours:po([ug.config({initialState:"after",routes:ug.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},dg=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return c},n=lg("Styles",[].concat(kn(o.items,function(n){return sg(fg(n),n.title,n.isSelected(),n.getPreview(),Ft(o.expansions,fg(n)))})),i,!1),e=M(o.menus,function(n,e){var t=kn(n,function(n){return sg(fg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Ft(o.expansions,fg(n)))});return lg(e,t,i,!0)}),t=vt(e,Rt("styles",n)),{tmenu:Jm.tieredData("styles",t,o.expansions)}),c=Kl(Jm.sketch({dom:{tag:"div",classes:[Hi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=us.getValue(e);return r.handle(e,t.value),k.none()},onEscape:function(){return k.none()},onOpenMenu:function(n,e){var t=fs(n.element());as(e.element(),t),ug.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=fs(n.element()),o=au(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();as(t.element(),r),ug.progressTo(i,"before"),ug.jumpTo(t,"after"),ug.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=au(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();ug.progressTo(o,"after"),ug.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Hi.resolve("styles-background-menu"),menu:Hi.resolve("styles-menu"),selectedMenu:Hi.resolve("styles-selected-menu"),item:Hi.resolve("styles-item"),selectedItem:Hi.resolve("styles-selected-item")}}));return c.asSpec()},mg=function(n){return Ft(n,"items")?(t=vt(Ct(e=n,["items"]),{menu:!0}),r=gg(e.items),{item:t,menus:vt(r.menus,Rt(e.title,r.items)),expansions:vt(r.expansions,Rt(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},gg=function(n){return Dn(n,function(n,e){var t=mg(e);return{menus:vt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:vt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},pg={expand:gg},vg=function(u,n){var c=function(n){return function(){return u.formatter.match(n)}},a=function(n){return function(){return u.formatter.getCssText(n)}},e=It(n,"style_formats").getOr(Zd),f=function(n){return kn(n,function(n){if(Ft(n,"items")){var e=f(n.items);return vt(vt(n,{isSelected:h(!1),getPreview:h("")}),{items:e})}return Ft(n,"format")?vt(i=n,{isSelected:c(i.format),getPreview:a(i.format)}):(r=ja((t=n).title),o=vt(t,{format:r,isSelected:c(r),getPreview:a(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return f(e)},hg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return Vn(n,function(n){return n.items===undefined?!Ft(n,"format")||e.formatter.canApply(n.format)?[n]:[]:0<o(n.items).length?[n]:[]})})(n),pg.expand(i));return dg({formats:u,handle:function(n,e){t.undoManager.transact(function(){Ai.isOn(n)?t.formatter.remove(e):t.formatter.apply(e)}),r()}})},bg=["undo","bold","italic","link","image","bullist","styleselect"],yg=function(n){var e=n.replace(/\|/g," ").trim();return 0<e.length?e.split(/\s+/):[]},xg=function(n){return Vn(n,function(n){return hn(n)?xg(n):yg(n)})},wg=function(n){var e=n.toolbar!==undefined?n.toolbar:bg;return hn(e)?xg(e):yg(e)},Sg=function(r,o){var n=function(n){return function(){return Nf.forToolbarCommand(o,n)}},e=function(n){return function(){return Nf.forToolbarStateCommand(o,n)}},t=function(n,e,t){return function(){return Nf.forToolbarStateAction(o,n,e,t)}},i=n("undo"),u=n("redo"),c=e("bold"),a=e("italic"),f=e("underline"),s=n("removeformat"),l=t("unlink","link",function(){o.execCommand("unlink",null,!1)}),d=t("unordered-list","ul",function(){o.execCommand("InsertUnorderedList",null,!1)}),m=t("ordered-list","ol",function(){o.execCommand("InsertOrderedList",null,!1)}),g=vg(o,o.settings),p=function(){return hg(o,g,function(){o.fire("scrollIntoView")})},v=function(n,e){return{isSupported:function(){var e=o.ui.registry.getAll().buttons;return n.forall(function(n){return Ft(e,n)})},sketch:e}};return{undo:v(k.none(),i),redo:v(k.none(),u),bold:v(k.none(),c),italic:v(k.none(),a),underline:v(k.none(),f),removeformat:v(k.none(),s),link:v(k.none(),function(){return e=r,t=o,Nf.forToolbarStateAction(t,"link","link",function(){var n=Qd(e,t);e.setContextToolbar(n),ld(t,function(){e.focusToolbar()}),ad.query(t).each(function(n){t.selection.select(n.dom())})});var e,t}),unlink:v(k.none(),l),image:v(k.none(),function(){return td(o)}),bullist:v(k.some("bullist"),d),numlist:v(k.some("numlist"),m),fontsizeselect:v(k.none(),function(){return n={onChange:function(n){Xl.apply(e,n)},getInitialValue:function(){return Xl.get(e)}},Pl(r,"font-size",function(){return Yl(n)},e=o);var e,n}),forecolor:v(k.none(),function(){return Gl(r,o)}),styleselect:v(k.none(),function(){return Nf.forToolbar("style-formats",function(n){o.fire("toReading"),r.dropup().appear(p,Ai.on,n)},po([Ai.config({toggleClass:Hi.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),wi.config({channels:Bt([Ni(_o.orientationChanged(),Ai.off),Ni(_o.dropupDismissed(),Ai.off)])})]),o)})}},Og=function(n,t){var e=wg(n),r={};return Vn(e,function(n){var e=!Ft(r,n)&&Ft(t,n)&&t[n].isSupported()?[t[n].sketch()]:[];return r[n]=!0,e})},Tg=function(m,g){return function(n){if(m(n)){var e,t,r,o,i,u,c,a=be.fromDom(n.target),f=function(){n.stopPropagation()},s=function(){n.preventDefault()},l=p(s,f),d=(e=a,t=n.clientX,r=n.clientY,o=f,i=s,u=l,c=n,{target:h(e),x:h(t),y:h(r),stop:o,prevent:i,kill:u,raw:h(c)});g(d)}}},kg=function(n,e,t,r,o){var i=Tg(t,r);return n.dom().addEventListener(e,i,o),{unbind:l(Eg,n,e,i,o)}},Eg=function(n,e,t,r){n.dom().removeEventListener(e,t,r)},Cg=h(!0),Dg=function(n,e,t){return kg(n,e,Cg,t,!1)},Mg=function(n,e,t){return kg(n,e,Cg,t,!0)},Ig=tinymce.util.Tools.resolve("tinymce.util.Delay"),Rg=function(n){var e=n.matchMedia("(orientation: portrait)").matches;return{isPortrait:h(e)}},Bg=Rg,Ag=function(r,e){var n=be.fromDom(r),o=null,t=Dg(n,"orientationchange",function(){Ig.clearInterval(o);var n=Rg(r);e.onChange(n),i(function(){e.onReady(n)})}),i=function(n){Ig.clearInterval(o);var e=r.innerHeight,t=0;o=Ig.setInterval(function(){e!==r.innerHeight?(Ig.clearInterval(o),n(k.some(r.innerHeight))):20<t&&(Ig.clearInterval(o),n(k.none())),t++},50)};return{onAdjustment:i,destroy:function(){t.unbind()}}},Fg=function(n){var e=Yn.detect().os.isiOS(),t=Rg(n).isPortrait();return e&&!t?n.screen.height:n.screen.width};var Vg=function(n){var e=n.raw();return e.touches===undefined||1!==e.touches.length?k.none():k.some(e.touches[0])},Ng=function(t){var u=Ho(k.none()),r=function n(t,r){var o=null;return{cancel:function(){null!==o&&(v.clearTimeout(o),o=null)},schedule:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];o=v.setTimeout(function(){t.apply(null,n),o=null},r)}}}(function(n){u.set(k.none()),t.triggerEvent(ie(),n)},400),o=Bt([{key:A(),value:function(t){return Vg(t).each(function(n){r.cancel();var e={x:h(n.clientX),y:h(n.clientY),target:t.target};r.schedule(t),u.set(k.some(e))}),k.none()}},{key:F(),value:function(n){return r.cancel(),Vg(n).each(function(i){u.get().each(function(n){var e,t,r,o;e=i,t=n,r=Math.abs(e.clientX-t.x()),o=Math.abs(e.clientY-t.y()),(5<r||5<o)&&u.set(k.none())})}),k.none()}},{key:V(),value:function(e){r.cancel();return u.get().filter(function(n){return We(n.target(),e.target())}).map(function(n){return t.triggerEvent(re(),e)})}}]);return{fireIfReady:function(e,n){return It(o,n).bind(function(n){return n(e)})}}},jg=function(t){var e=Ng({triggerEvent:function(n,e){t.onTapContent(e)}});return{fireTouchstart:function(n){e.fireIfReady(n,"touchstart")},onTouchend:function(){return Dg(t.body(),"touchend",function(n){e.fireIfReady(n,"touchend")})},onTouchmove:function(){return Dg(t.body(),"touchmove",function(n){e.fireIfReady(n,"touchmove")})}}},Hg=6<=Yn.detect().os.version.major,zg=function(r,e,t){var o=jg(r),i=_e(e),u=function(n){return!We(n.start(),n.finish())||n.soffset()!==n.foffset()},n=function(){var n=r.doc().dom().hasFocus()&&r.getSelection().exists(u);t.getByDom(e).each(!0===(n||Lo(i).filter(function(n){return"input"===Se(n)}).exists(function(n){return n.dom().selectionStart!==n.dom().selectionEnd}))?Ai.on:Ai.off)},c=[Dg(r.body(),"touchstart",function(n){r.onTouchContent(),o.fireTouchstart(n)}),o.onTouchmove(),o.onTouchend(),Dg(e,"touchstart",function(n){r.onTouchToolstrip()}),r.onToReading(function(){Po(r.body())}),r.onToEditing(x),r.onScrollToCursor(function(n){n.preventDefault(),r.getCursorBox().each(function(n){var e=r.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===Hg?[]:[Dg(be.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Ai.off)}),Dg(i,"select",n),Dg(r.doc(),"selectionchange",n)]);return{destroy:function(){En(c,function(n){n.unbind()})}}},Pg=function(n,e){var t=parseInt(Oo(n,e),10);return isNaN(t)?0:t};var Lg,Gg=function Jh(t,r){var o=function(n){return t(n)?k.from(n.dom().nodeValue):k.none()},n=Yn.detect().browser,e=n.isIE()&&10===n.version.major?function(n){try{return o(n)}catch(e){return k.none()}}:o;return{get:function(n){if(!t(n))throw new Error("Can only get "+r+" value of a "+r+" node");return e(n).getOr("")},getOption:e,set:function(n,e){if(!t(n))throw new Error("Can only set raw "+r+" value of a "+r+" node");n.dom().nodeValue=e}}}(ke,"text"),$g=function(n){return Gg.getOption(n)},Ug=["img","br"],Wg=function(n){return $g(n).filter(function(n){return 0!==n.trim().length||-1<n.indexOf("\xa0")}).isSome()||On(Ug,Se(n))},_g={create:Me("start","soffset","finish","foffset")},Xg=mt([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),qg={before:Xg.before,on:Xg.on,after:Xg.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(b,b,b)}},Yg=mt([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Kg={domRange:Yg.domRange,relative:Yg.relative,exact:Yg.exact,exactFromRange:function(n){return Yg.exact(n.start(),n.soffset(),n.finish(),n.foffset())},getWin:function(n){var e,t=n.match({domRange:function(n){return be.fromDom(n.startContainer)},relative:function(n,e){return qg.getStart(n)},exact:function(n,e,t,r){return n}});return e=t.dom().ownerDocument.defaultView,be.fromDom(e)},range:_g.create},Jg=function(n,e,t){var r,o,i=n.document.createRange();return r=i,e.fold(function(n){r.setStartBefore(n.dom())},function(n,e){r.setStart(n.dom(),e)},function(n){r.setStartAfter(n.dom())}),o=i,t.fold(function(n){o.setEndBefore(n.dom())},function(n,e){o.setEnd(n.dom(),e)},function(n){o.setEndAfter(n.dom())}),i},Qg=function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},Zg=function(n){return{left:h(n.left),top:h(n.top),right:h(n.right),bottom:h(n.bottom),width:h(n.width),height:h(n.height)}},np=mt([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),ep=function(n,e,t){return e(be.fromDom(t.startContainer),t.startOffset,be.fromDom(t.endContainer),t.endOffset)},tp=function(n,e){var o,t,r,i=(o=n,e.match({domRange:function(n){return{ltr:h(n),rtl:k.none}},relative:function(n,e){return{ltr:X(function(){return Jg(o,n,e)}),rtl:X(function(){return k.some(Jg(o,e,n))})}},exact:function(n,e,t,r){return{ltr:X(function(){return Qg(o,n,e,t,r)}),rtl:X(function(){return k.some(Qg(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return np.rtl(be.fromDom(n.endContainer),n.endOffset,be.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return ep(0,np.ltr,r)}):ep(0,np.ltr,r)},rp=function(n,e,t){return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom},op=function(t,r,n,e,o){var i,u=function(n){var e=t.dom().createRange();return e.setStart(r.dom(),n),e.collapse(!0),e},c=(i=r,Gg.get(i)).length,a=function(n,e,t,r,o){if(0===o)return 0;if(e===r)return o-1;for(var i=r,u=1;u<o;u++){var c=n(u),a=Math.abs(e-c.left);if(t<=c.bottom){if(t<c.top||i<a)return u-1;i=a}}return 0}(function(n){return u(n).getBoundingClientRect()},n,e,o.right,c);return u(a)},ip=function(e,t,r,o){var n=e.dom().createRange();n.selectNode(t.dom());var i=n.getClientRects();return ni(i,function(n){return rp(n,r,o)?k.some(n):k.none()}).map(function(n){return op(e,t,r,o,n)})},up=function(e,n,t,r){var o=e.dom().createRange(),i=qe(n);return ni(i,function(n){return o.selectNode(n.dom()),rp(o.getBoundingClientRect(),t,r)?cp(e,n,t,r):k.none()})},cp=function(n,e,t,r){return(ke(e)?ip:up)(n,e,t,r)},ap=function(n){return _r(n,Wg)},fp=function(n){return sp(n,Wg)},sp=function(n,i){var u=function(n){for(var e=qe(n),t=e.length-1;0<=t;t--){var r=e[t];if(i(r))return k.some(r);var o=u(r);if(o.isSome())return o}return k.none()};return u(n)},lp=function(n,e){return e-n.left<n.right-e},dp=function(n,e,t){var r=n.dom().createRange();return r.selectNode(e.dom()),r.collapse(t),r},mp=function(e,n,t){var r=e.dom().createRange();r.selectNode(n.dom());var o=r.getBoundingClientRect(),i=lp(o,t);return(!0===i?ap:fp)(n).map(function(n){return dp(e,n,i)})},gp=function(n,e,t){var r=e.dom().getBoundingClientRect(),o=lp(r,t);return k.some(dp(n,e,o))},pp=function(n,e,t,r){var o=n.dom().createRange();o.selectNode(e.dom());var i=o.getBoundingClientRect();return function(n,e,t,r){var o=n.dom().createRange();o.selectNode(e.dom());var i=o.getBoundingClientRect(),u=Math.max(i.left,Math.min(i.right,t)),c=Math.max(i.top,Math.min(i.bottom,r));return cp(n,e,u,c)}(n,e,Math.max(i.left,Math.min(i.right,t)),Math.max(i.top,Math.min(i.bottom,r)))},vp=(document.caretPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=Se(n);return"input"===t?qg.after(n):On(["br","img"],t)?0===e?qg.before(n):qg.after(n):qg.on(n,e)}),hp=function(n,e,t,r){var o,i,u,c,a,f=(i=e,u=t,c=r,(a=_e(o=n).dom().createRange()).setStart(o.dom(),i),a.setEnd(u.dom(),c),a),s=We(n,t)&&e===r;return f.collapsed&&!s},bp=function(n,e,t,r,o){var i,u,c=Qg(n,e,t,r,o);i=n,u=c,k.from(i.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},yp=function(n,e,t,r,o){var i,u,c,a,l,f=(i=r,u=o,c=vp(e,t),a=vp(i,u),Kg.relative(c,a));tp(l=n,f).match({ltr:function(n,e,t,r){bp(l,n,e,t,r)},rtl:function(n,e,t,r){var o,i,u,c,a,f=l.getSelection();if(f.setBaseAndExtent)f.setBaseAndExtent(n.dom(),e,t.dom(),r);else if(f.extend)try{i=n,u=e,c=t,a=r,(o=f).collapse(i.dom(),u),o.extend(c.dom(),a)}catch(s){bp(l,t,r,n,e)}else bp(l,t,r,n,e)}})},xp=function(n){var e=be.fromDom(n.anchorNode),t=be.fromDom(n.focusNode);return hp(e,n.anchorOffset,t,n.focusOffset)?k.some(_g.create(e,n.anchorOffset,t,n.focusOffset)):function(n){if(0<n.rangeCount){var e=n.getRangeAt(0),t=n.getRangeAt(n.rangeCount-1);return k.some(_g.create(be.fromDom(e.startContainer),e.startOffset,be.fromDom(t.endContainer),t.endOffset))}return k.none()}(n)},wp=function(n){return k.from(n.getSelection()).filter(function(n){return 0<n.rangeCount}).bind(xp)},Sp=function(n,e){var i,t,r,o,u=tp(i=n,e).match({ltr:function(n,e,t,r){var o=i.document.createRange();return o.setStart(n.dom(),e),o.setEnd(t.dom(),r),o},rtl:function(n,e,t,r){var o=i.document.createRange();return o.setStart(t.dom(),r),o.setEnd(n.dom(),e),o}});return r=(t=u).getClientRects(),0<(o=0<r.length?r[0]:t.getBoundingClientRect()).width||0<o.height?k.some(o).map(Zg):k.none()},Op=function(n){return{left:n.left,top:n.top,right:n.right,bottom:n.bottom,width:h(2),height:n.height}},Tp=function(n){return{left:h(n.left),top:h(n.top),right:h(n.right),bottom:h(n.bottom),width:h(n.width),height:h(n.height)}},kp=function(r){if(r.collapsed){var o=be.fromDom(r.startContainer);return Xe(o).bind(function(n){var e,t=Kg.exact(o,r.startOffset,n,"img"===Se(e=n)?1:$g(e).fold(function(){return qe(e).length},function(n){return n.length}));return Sp(r.startContainer.ownerDocument.defaultView,t).map(Op).map(Hn)}).getOr([])}return kn(r.getClientRects(),Tp)},Ep=function(n){var e=n.getSelection();return e!==undefined&&0<e.rangeCount?kp(e.getRangeAt(0)):[]},Cp=function(n){n.focus();var e=be.fromDom(n.document.body);(Lo().exists(function(n){return On(["input","textarea"],Se(n))})?function(n){Ig.setTimeout(function(){n()},0)}:f)(function(){Lo().each(Po),zo(e)})},Dp="data-"+Hi.resolve("last-outer-height"),Mp=function(n,e){wo(n,Dp,e)},Ip=function(n){return{top:h(n.top()),bottom:h(n.top()+n.height())}},Rp=function(n,e){var t=Pg(e,Dp),r=n.innerHeight;return r<t?k.some(t-r):k.none()},Bp=function(n,u){var e=be.fromDom(u.document.body),t=Dg(be.fromDom(n),"resize",function(){Rp(n,e).each(function(i){var n,e;(n=u,e=Ep(n),0<e.length?k.some(e[0]).map(Ip):k.none()).each(function(n){var e,t,r,o=(e=u,r=i,(t=n).top()>e.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),Mp(e,n.innerHeight)});Mp(e,n.innerHeight);return{toEditing:function(){Cp(u)},destroy:function(){t.unbind()}}},Ap=function(n){return k.some(be.fromDom(n.dom().contentWindow.document.body))},Fp=function(n){return k.some(be.fromDom(n.dom().contentWindow.document))},Vp=function(n){return k.from(n.dom().contentWindow)},Np=function(n){return Vp(n).bind(wp)},jp=function(n){return n.getFrame()},Hp=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=jp(e);return function(){return t(n)}})()}},zp=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return Dg(e,r,n)}})},Pp=function(n){return{left:h(n.left),top:h(n.top),right:h(n.right),bottom:h(n.bottom),width:h(n.width),height:h(n.height)}},Lp={getBody:Hp("getBody",Ap),getDoc:Hp("getDoc",Fp),getWin:Hp("getWin",Vp),getSelection:Hp("getSelection",Np),getFrame:jp,getActiveApi:function(c){var a=jp(c);return Ap(a).bind(function(u){return Fp(a).bind(function(i){return Vp(a).map(function(o){var n=be.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return(n=o,wp(n).map(function(n){return Kg.exact(n.start(),n.soffset(),n.finish(),n.foffset())})).bind(function(n){return Sp(o,n).orThunk(function(){return wp(o).filter(function(n){return We(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0<e.width||0<e.height?k.some(e).map(Pp):k.none()})})});var n}}),t=c.setSelection.getOrThunk(function(){return function(n,e,t,r){yp(o,n,e,t,r)}}),r=c.clearSelection.getOrThunk(function(){return function(){o.getSelection().removeAllRanges()}});return{body:h(u),doc:h(i),win:h(o),html:h(n),getSelection:l(Np,a),setSelection:t,clearSelection:r,frame:h(a),onKeyup:zp(c,i,"onKeyup","keyup"),onNodeChanged:zp(c,i,"onNodeChanged","SelectionChange"),onDomChanged:c.onDomChanged,onScrollToCursor:c.onScrollToCursor,onScrollToElement:c.onScrollToElement,onToReading:c.onToReading,onToEditing:c.onToEditing,onToolbarScrollStart:c.onToolbarScrollStart,onTouchContent:c.onTouchContent,onTapContent:c.onTapContent,onTouchToolstrip:c.onTouchToolstrip,getCursorBox:e}})})})}},Gp="data-ephox-mobile-fullscreen-style",$p="position:absolute!important;",Up="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",Wp=Yn.detect().os.isAndroid(),_p=function(n,e){var t,r,o,i=function(r){return function(n){var e=Oo(n,"style"),t=e===undefined?"no-styles":e.trim();t!==r&&(wo(n,Gp,t),wo(n,"style",r))}},u=(t="*",ou(n,function(n){return Le(n,t)},r)),c=Vn(u,function(n){var e;return e="*",iu(n,function(n){return Le(n,e)})}),a=(o=qi(e,"background-color"))!==undefined&&""!==o?"background-color:"+o+"!important":"background-color:rgb(255,255,255)!important;";En(c,i("display:none!important;")),En(u,i($p+Up+a)),i((!0===Wp?"":$p)+Up+a)(n)},Xp=function(){var n=$e("["+Gp+"]");En(n,function(n){var e=Oo(n,Gp);"no-styles"!==e?wo(n,"style",e):ko(n,"style"),ko(n,Gp)})},qp=function(){var e=cu("head").getOrDie(),n=cu('meta[name="viewport"]').getOrThunk(function(){var n=be.fromTag("meta");return wo(n,"name","viewport"),Ze(e,n),n}),t=Oo(n,"content");return{maximize:function(){wo(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?wo(n,"content",t):wo(n,"content","user-scalable=yes")}}},Yp=function(e,n){var t=qp(),r=_d(),o=_d();return{enter:function(){n.hide(),Io(e.container,Hi.resolve("fullscreen-maximized")),Io(e.container,Hi.resolve("android-maximized")),t.maximize(),Io(e.body,Hi.resolve("android-scroll-reload")),r.set(Bp(e.win,Lp.getWin(e.editor).getOrDie("no"))),Lp.getActiveApi(e.editor).each(function(n){_p(e.container,n.body()),o.set(zg(n,e.toolstrip,e.alloy))})},exit:function(){t.restore(),n.show(),Bo(e.container,Hi.resolve("fullscreen-maximized")),Bo(e.container,Hi.resolve("android-maximized")),Xp(),Bo(e.body,Hi.resolve("android-scroll-reload")),o.clear(),r.clear()}}},Kp=function(t,r){var o=null;return{cancel:function(){null!==o&&(v.clearTimeout(o),o=null)},throttle:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];null!==o&&v.clearTimeout(o),o=v.setTimeout(function(){t.apply(null,n),o=null},r)}}},Jp=function(n,e){var t,r,o,i=Kl(vd.sketch({dom:Rf('<div aria-hidden="true" class="${prefix}-mask-tap-icon"></div>'),containerBehaviours:po([Ai.config({toggleClass:Hi.resolve("mask-tap-icon-selected"),toggleOnExecute:!1})])})),u=(t=n,r=200,o=null,{cancel:function(){null!==o&&(v.clearTimeout(o),o=null)},throttle:function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];null===o&&(o=v.setTimeout(function(){t.apply(null,n),o=null},r))}});return vd.sketch({dom:Rf('<div class="${prefix}-disabled-mask"></div>'),components:[vd.sketch({dom:Rf('<div class="${prefix}-content-container"></div>'),components:[Df.sketch({dom:Rf('<div class="${prefix}-content-tap-section"></div>'),components:[i.asSpec()],action:function(n){u.throttle()},buttonBehaviours:po([Ai.config({toggleClass:Hi.resolve("mask-tap-icon-selected")})])})]})]})},Qp=sr([Mr("editor",[Cr("getFrame"),Ir("getBody"),Ir("getDoc"),Ir("getWin"),Ir("getSelection"),Ir("setSelection"),Ir("clearSelection"),Ir("cursorSaver"),Ir("onKeyup"),Ir("onNodeChanged"),Ir("getCursorBox"),Cr("onDomChanged"),Fr("onTouchContent",x),Fr("onTapContent",x),Fr("onTouchToolstrip",x),Fr("onScrollToCursor",h({unbind:x})),Fr("onScrollToElement",h({unbind:x})),Fr("onToEditing",h({unbind:x})),Fr("onToReading",h({unbind:x})),Fr("onToolbarScrollStart",b)]),Cr("socket"),Cr("toolstrip"),Cr("dropup"),Cr("toolbar"),Cr("container"),Cr("alloy"),Nr("win",function(n){return _e(n.socket).dom().defaultView}),Nr("body",function(n){return be.fromDom(n.socket.dom().ownerDocument.body)}),Fr("translate",b),Fr("setReadOnly",x),Fr("readOnlyOnInit",h(!0))]),Zp=function(n){var e=Sr("Getting AndroidWebapp schema",Qp,n);_i(e.toolstrip,"width","100%");var t=km(Jp(function(){e.setReadOnly(e.readOnlyOnInit()),o.enter()},e.translate));e.alloy.add(t);var r={show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}};Ze(e.container,t.element());var o=Yp(e,r);return{setReadOnly:e.setReadOnly,refreshStructure:x,enter:o.enter,exit:o.exit,destroy:x}},nv=h([Cr("dom"),Fr("shell",!0),Oa("toolbarBehaviours",[_m])]),ev=h([Qa({name:"groups",overrides:function(n){return{behaviours:po([_m.config({})])}}})]),tv=Cf({name:"Toolbar",configFields:nv(),partFields:ev(),factory:function(e,n,t,r){var o=function(n){return e.shell?k.some(n):cf(n,e,"groups")},i=e.shell?{behaviours:[_m.config({})],components:[]}:{behaviours:[],components:n};return{uid:e.uid,dom:e.dom,components:i.components,behaviours:ka(e.toolbarBehaviours,i.behaviours),apis:{setGroups:function(n,e){o(n).fold(function(){throw v.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){_m.set(n,e)})}},domModification:{attributes:{role:"group"}}}},apis:{setGroups:function(n,e,t){n.setGroups(e,t)}}}),rv=h([Cr("items"),(Lg=["itemSelector"],Mr("markers",kn(Lg,Cr))),Oa("tgroupBehaviours",[Sa])]),ov=h([Za({name:"items",unit:"item"})]),iv=Cf({name:"ToolbarGroup",configFields:rv(),partFields:ov(),factory:function(n,e,t,r){return{uid:n.uid,dom:n.dom,components:e,behaviours:ka(n.tgroupBehaviours,[Sa.config({mode:"flow",selector:n.markers.itemSelector})]),domModification:{attributes:{role:"toolbar"}}}}}),uv="data-"+Hi.resolve("horizontal-scroll"),cv=function(n){return"true"===Oo(n,uv)?0<(t=n).dom().scrollLeft||function(n){n.dom().scrollLeft=1;var e=0!==n.dom().scrollLeft;return n.dom().scrollLeft=0,e}(t):0<(e=n).dom().scrollTop||function(n){n.dom().scrollTop=1;var e=0!==n.dom().scrollTop;return n.dom().scrollTop=0,e}(e);var e,t},av={exclusive:function(n,e){return Dg(n,"touchmove",function(n){su(n.target(),e).filter(cv).fold(function(){n.raw().preventDefault()},x)})},markAsHorizontal:function(n){wo(n,uv,"true")}};function fv(){var e=function(n){var e=!0===n.scrollable?"${prefix}-toolbar-scrollable-group":"";return{dom:Rf('<div aria-label="'+n.label+'" class="${prefix}-toolbar-group '+e+'"></div>'),tgroupBehaviours:po([dd("adhoc-scrollable-toolbar",!0===n.scrollable?[ro(function(n,e){_i(n.element(),"overflow-x","auto"),av.markAsHorizontal(n.element()),ag.register(n.element())})]:[])]),components:[vd.sketch({components:[iv.parts().items({})]})],markers:{itemSelector:"."+Hi.resolve("toolbar-group-item")},items:n.items}},t=km(tv.sketch({dom:Rf('<div class="${prefix}-toolbar"></div>'),components:[tv.parts().groups({})],toolbarBehaviours:po([Ai.config({toggleClass:Hi.resolve("context-toolbar"),toggleOnExecute:!1,aria:{mode:"none"}}),Sa.config({mode:"cyclic"})]),shell:!0})),n=km(vd.sketch({dom:{classes:[Hi.resolve("toolstrip")]},components:[Em(t)],containerBehaviours:po([Ai.config({toggleClass:Hi.resolve("android-selection-context-toolbar"),toggleOnExecute:!1})])})),r=function(){tv.setGroups(t,o.get()),Ai.off(t)},o=Ho([]);return{wrapper:h(n),toolbar:h(t),createGroups:function(n){return kn(n,p(iv.sketch,e))},setGroups:function(n){o.set(n),r()},setContextToolbar:function(n){Ai.on(t),tv.setGroups(t,n)},restoreToolbar:function(){Ai.isOn(t)&&r()},refresh:function(){},focus:function(){Sa.focusIn(t)}}}var sv,lv=function(n,e){_m.append(n,Em(e))},dv=function(n,e){_m.remove(n,e)},mv=function(n){return km(Df.sketch({dom:Rf('<div class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),action:function(){n.run(function(n){n.setReadOnly(!1)})}}))},gv=function(){return km(vd.sketch({dom:Rf('<div class="${prefix}-editor-socket"></div>'),components:[],containerBehaviours:po([_m.config({})])}))},pv=function(n,e,t,r){(!0===t?jo.toAlpha:jo.toOmega)(r),(t?lv:dv)(n,e)},vv=function(e,n){return n.getAnimationRoot.fold(function(){return e.element()},function(n){return n(e)})},hv=function(n){return n.dimension.property},bv=function(n,e){return n.dimension.getDimension(e)},yv=function(n,e){var t=vv(n,e);pm(t,[e.shrinkingClass,e.growingClass])},xv=function(n,e){Bo(n.element(),e.openClass),Io(n.element(),e.closedClass),_i(n.element(),hv(e),"0px"),Qi(n.element())},wv=function(n,e){Bo(n.element(),e.closedClass),Io(n.element(),e.openClass),Ji(n.element(),hv(e))},Sv=function(n,e,t,r){t.setCollapsed(),_i(n.element(),hv(e),bv(e,n.element())),Qi(n.element()),yv(n,e),xv(n,e),e.onStartShrink(n),e.onShrunk(n)},Ov=function(n,e,t,r){var o=r.getOrThunk(function(){return bv(e,n.element())});t.setCollapsed(),_i(n.element(),hv(e),o),Qi(n.element());var i=vv(n,e);Bo(i,e.growingClass),Io(i,e.shrinkingClass),xv(n,e),e.onStartShrink(n)},Tv=function(n,e,t){var r=bv(e,n.element());("0px"===r?Sv:Ov)(n,e,t,k.some(r))},kv=function(n,e,t){var r=vv(n,e),o=Ao(r,e.shrinkingClass),i=bv(e,n.element());wv(n,e);var u=bv(e,n.element());(o?function(){_i(n.element(),hv(e),i),Qi(n.element())}:function(){xv(n,e)})(),Bo(r,e.shrinkingClass),Io(r,e.growingClass),wv(n,e),_i(n.element(),hv(e),u),t.setExpanded(),e.onStartGrow(n)},Ev=function(n,e,t){var r=vv(n,e);return!0===Ao(r,e.growingClass)},Cv=function(n,e,t){var r=vv(n,e);return!0===Ao(r,e.shrinkingClass)},Dv=/* */Object.freeze({refresh:function(n,e,t){if(t.isExpanded()){Ji(n.element(),hv(e));var r=bv(e,n.element());_i(n.element(),hv(e),r)}},grow:function(n,e,t){t.isExpanded()||kv(n,e,t)},shrink:function(n,e,t){t.isExpanded()&&Tv(n,e,t)},immediateShrink:function(n,e,t){t.isExpanded()&&Sv(n,e,t)},hasGrown:function(n,e,t){return t.isExpanded()},hasShrunk:function(n,e,t){return t.isCollapsed()},isGrowing:Ev,isShrinking:Cv,isTransitioning:function(n,e,t){return!0===Ev(n,e)||!0===Cv(n,e)},toggleGrow:function(n,e,t){(t.isExpanded()?Tv:kv)(n,e,t)},disableTransitions:yv}),Mv=/* */Object.freeze({exhibit:function(n,e){var t=e.expanded;return co(t?{classes:[e.openClass],styles:{}}:{classes:[e.closedClass],styles:Rt(e.dimension.property,"0px")})},events:function(t,r){return qr([(n=W(),e=function(n,e){e.event().raw().propertyName===t.dimension.property&&(yv(n,t),r.isExpanded()&&Ji(n.element(),t.dimension.property),(r.isExpanded()?t.onGrown:t.onShrunk)(n))},Qr(n)(e))]);var n,e}}),Iv=[Cr("closedClass"),Cr("openClass"),Cr("shrinkingClass"),Cr("growingClass"),Ir("getAnimationRoot"),mi("onShrunk"),mi("onStartShrink"),mi("onGrown"),mi("onStartGrow"),Fr("expanded",!1),Dr("dimension",Tr("property",{width:[hi("property","width"),hi("getDimension",function(n){return fs(n)+"px"})],height:[hi("property","height"),hi("getDimension",function(n){return ru(n)+"px"})]}))],Rv=ho({fields:Iv,name:"sliding",active:Mv,apis:Dv,state:/* */Object.freeze({init:function(n){var e=Ho(n.expanded);return go({isExpanded:function(){return!0===e.get()},isCollapsed:function(){return!1===e.get()},setCollapsed:l(e.set,!1),setExpanded:l(e.set,!0),readState:function(){return"expanded: "+e.get()}})}})}),Bv=function(e,t){var r=km(vd.sketch({dom:{tag:"div",classes:[Hi.resolve("dropup")]},components:[],containerBehaviours:po([_m.config({}),Rv.config({closedClass:Hi.resolve("dropup-closed"),openClass:Hi.resolve("dropup-open"),shrinkingClass:Hi.resolve("dropup-shrinking"),growingClass:Hi.resolve("dropup-growing"),dimension:{property:"height"},onShrunk:function(n){e(),t(),_m.set(n,[])},onGrown:function(n){e(),t()}}),Vi(function(n,e){o(x)})])})),o=function(n){v.window.requestAnimationFrame(function(){n(),Rv.shrink(r)})};return{appear:function(n,e,t){!0===Rv.hasShrunk(r)&&!1===Rv.isTransitioning(r)&&v.window.requestAnimationFrame(function(){e(t),_m.set(r,[n()]),Rv.grow(r)})},disappear:o,component:h(r),element:r.element}},Av=function(n){var e,t;return 8===n.raw().which&&!On(["input","textarea"],Se(n.target()))&&(e=n.target(),!su(e,'[contenteditable="true"]',t).isSome())},Fv=Yn.detect().browser.isFirefox(),Vv=fr([(sv="triggerEvent",Dr(sv,Er)),Fr("stopBackspace",!0)]),Nv=function(e,n){var t,r,o,i,u=Sr("Getting GUI events settings",Vv,n),c=Yn.detect().deviceType.isTouch()?["touchstart","touchmove","touchend","gesturestart"]:["mousedown","mouseup","mouseover","mousemove","mouseout","click"],a=Ng(u),f=kn(c.concat(["selectstart","input","contextmenu","change","transitionend","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","keyup"]),function(n){return Dg(e,n,function(e){a.fireIfReady(e,n).each(function(n){n&&e.kill()}),u.triggerEvent(n,e)&&e.kill()})}),s=Ho(k.none()),l=Dg(e,"paste",function(e){a.fireIfReady(e,"paste").each(function(n){n&&e.kill()}),u.triggerEvent("paste",e)&&e.kill(),s.set(k.some(v.setTimeout(function(){u.triggerEvent(Zn(),e)},0)))}),d=Dg(e,"keydown",function(n){u.triggerEvent("keydown",n)?n.kill():!0===u.stopBackspace&&Av(n)&&n.prevent()}),m=(t=e,r=function(n){u.triggerEvent("focusin",n)&&n.kill()},Fv?Mg(t,"focus",r):Dg(t,"focusin",r)),g=Ho(k.none()),p=(o=e,i=function(n){u.triggerEvent("focusout",n)&&n.kill(),g.set(k.some(v.setTimeout(function(){u.triggerEvent(Qn(),n)},0)))},Fv?Mg(o,"blur",i):Dg(o,"focusout",i));return{unbind:function(){En(f,function(n){n.unbind()}),d.unbind(),m.unbind(),p.unbind(),l.unbind(),s.get().each(v.clearTimeout),g.get().each(v.clearTimeout)}}},jv=function(n,e){var t=It(n,"target").map(function(n){return n()}).getOr(e);return Ho(t)},Hv=mt([{stopped:[]},{resume:["element"]},{complete:[]}]),zv=function(n,r,e,t,o,i){var u,c,a,f,s=n(r,t),l=(u=e,c=o,a=Ho(!1),f=Ho(!1),{stop:function(){a.set(!0)},cut:function(){f.set(!0)},isStopped:a.get,isCut:f.get,event:h(u),setSource:c.set,getSource:c.get});return s.fold(function(){return i.logEventNoHandlers(r,t),Hv.complete()},function(e){var t=e.descHandler();return cm(t)(l),l.isStopped()?(i.logEventStopped(r,e.element(),t.purpose()),Hv.stopped()):l.isCut()?(i.logEventCut(r,e.element(),t.purpose()),Hv.complete()):Xe(e.element()).fold(function(){return i.logNoParent(r,e.element(),t.purpose()),Hv.complete()},function(n){return i.logEventResponse(r,e.element(),t.purpose()),Hv.resume(n)})})},Pv=function(e,t,r,n,o,i){return zv(e,t,r,n,o,i).fold(function(){return!0},function(n){return Pv(e,t,r,n,o,i)},function(){return!1})},Lv=function(n,e,t){var r,o,i=(r=e,o=Ho(!1),{stop:function(){o.set(!0)},cut:x,isStopped:o.get,isCut:h(!1),event:h(r),setSource:c("Cannot set source of a broadcasted event"),getSource:c("Cannot get source of a broadcasted event")});return En(n,function(n){var e=n.descHandler();cm(e)(i)}),i.isStopped()},Gv=function(n,e,t,r,o){var i=jv(t,r);return Pv(n,e,t,r,i,o)},$v=Me("element","descHandler"),Uv=function(n,e){return{id:h(n),descHandler:h(e)}};function Wv(){var i={};return{registerId:function(r,o,n){D(n,function(n,e){var t=i[e]!==undefined?i[e]:{};t[o]=um(n,r),i[e]=t})},unregisterId:function(t){D(i,function(n,e){n.hasOwnProperty(t)&&delete n[t]})},filterByType:function(n){return It(i,n).map(function(n){return R(n,function(n,e){return Uv(e,n)})}).getOr([])},find:function(n,e,t){var o=Dt(e)(i);return Xr(t,function(n){return t=o,yf(r=n).fold(function(){return k.none()},function(n){var e=Dt(n);return t.bind(e).map(function(n){return $v(r,n)})});var t,r},n)}}}function _v(){var r=Wv(),o={},i=function(r){var n=r.element();return yf(n).fold(function(){return n="uid-",e=r.element(),t=ja(vf+n),bf(e,t),t;var n,e,t},function(n){return n})},u=function(n){yf(n.element()).each(function(n){delete o[n],r.unregisterId(n)})};return{find:function(n,e,t){return r.find(n,e,t)},filter:function(n){return r.filterByType(n)},register:function(n){var e=i(n);Ft(o,e)&&function(n,e){var t=o[e];if(t!==n)throw new Error('The tagId "'+e+'" is already used by: '+Jo(t.element())+"\nCannot use it for: "+Jo(n.element())+"\nThe conflicting element is"+(Ee(t.element())?" ":" not ")+"already in the DOM");u(n)}(n,e);var t=[n];r.registerId(t,e,n.events()),o[e]=n},unregister:u,getById:function(n){return Dt(n)(o)}}}var Xv=function(t){var r=function(e){return Xe(t.element()).fold(function(){return!0},function(n){return We(e,n)})},o=_v(),f=function(n,e){return o.find(r,n,e)},n=Nv(t.element(),{triggerEvent:function(u,c){return ui(u,c.target(),function(n){return e=f,t=u,o=n,i=(r=c).target(),Gv(e,t,r,i,o);var e,t,r,o,i})}}),i={debugInfo:h("real"),triggerEvent:function(e,t,r){ui(e,t,function(n){Gv(f,e,r,t,n)})},triggerFocus:function(c,a){yf(c).fold(function(){zo(c)},function(n){ui(Jn(),c,function(n){var e,t,r,o,i,u;e=f,t=Jn(),r={originator:h(a),kill:x,prevent:x,target:h(c)},i=n,u=jv(r,o=c),zv(e,t,r,o,u,i)})})},triggerEscape:function(n,e){i.triggerEvent("keydown",n.element(),e.event())},getByUid:function(n){return g(n)},getByDom:function(n){return p(n)},build:km,addToGui:function(n){c(n)},removeFromGui:function(n){a(n)},addToWorld:function(n){e(n)},removeFromWorld:function(n){u(n)},broadcast:function(n){l(n)},broadcastOn:function(n,e){d(n,e)},broadcastEvent:function(n,e){m(n,e)},isConnected:h(!0)},e=function(n){n.connect(i),ke(n.element())||(o.register(n),En(n.components(),e),i.triggerEvent(ue(),n.element(),{target:h(n.element())}))},u=function(n){ke(n.element())||(En(n.components(),u),o.unregister(n)),n.disconnect()},c=function(n){it(t,n)},a=function(n){at(n)},s=function(t){var n=o.filter(ne());En(n,function(n){var e=n.descHandler();cm(e)(t)})},l=function(n){s({universal:h(!0),data:h(n)})},d=function(n,e){s({universal:h(!1),channels:h(n),data:h(e)})},m=function(n,e){var t=o.filter(n);return Lv(t,e)},g=function(n){return o.getById(n).fold(function(){return dt.error(new Error('Could not find component with uid: "'+n+'" in system.'))},dt.value)},p=function(n){var e=yf(n).getOr("not found");return g(e)};return e(t),{root:h(t),element:t.element,destroy:function(){n.unbind(),tt(t.element())},add:c,remove:a,getByUid:g,getByDom:p,addToWorld:e,removeFromWorld:u,broadcast:l,broadcastOn:d,broadcastEvent:m}},qv=h(Hi.resolve("readonly-mode")),Yv=h(Hi.resolve("edit-mode"));function Kv(n){var e=km(vd.sketch({dom:{classes:[Hi.resolve("outer-container")].concat(n.classes)},containerBehaviours:po([jo.config({alpha:qv(),omega:Yv()})])}));return Xv(e)}var Jv=function(n,e){var t=be.fromTag("input");Xi(t,{opacity:"0",position:"absolute",top:"-1000px",left:"-1000px"}),Ze(n,t),zo(t),e(t),tt(t)},Qv=function(n){var e=n.getSelection();if(0<e.rangeCount){var t=e.getRangeAt(0),r=n.document.createRange();r.setStart(t.startContainer,t.startOffset),r.setEnd(t.endContainer,t.endOffset),e.removeAllRanges(),e.addRange(r)}},Zv=function(n,e){Lo().each(function(n){We(n,e)||Po(n)}),n.focus(),zo(be.fromDom(n.document.body)),Qv(n)},nh={stubborn:function(n,e,t,r){var o=function(){Zv(e,r)},i=Dg(t,"keydown",function(n){On(["input","textarea"],Se(n.target()))||o()});return{toReading:function(){Jv(n,Po)},toEditing:o,onToolbarTouch:function(){},destroy:function(){i.unbind()}}},timid:function(n,e,t,r){var o=function(){Po(r)};return{toReading:function(){o()},toEditing:function(){Zv(e,r)},onToolbarTouch:function(){o()},destroy:x}}},eh=function(t,r,o,i,n){var u=function(){r.run(function(n){n.refreshSelection()})},e=function(n,e){var t=n-i.dom().scrollTop;r.run(function(n){n.scrollIntoView(t,t+e)})},c=function(){r.run(function(n){n.clearSelection()})},a=function(){t.getCursorBox().each(function(n){e(n.top(),n.height())}),r.run(function(n){n.syncHeight()})},f=jg(t),s=Kp(a,300),l=[t.onKeyup(function(){c(),s.throttle()}),t.onNodeChanged(u),t.onDomChanged(s.throttle),t.onDomChanged(u),t.onScrollToCursor(function(n){n.preventDefault(),s.throttle()}),t.onScrollToElement(function(n){n.element(),e(r,i)}),t.onToEditing(function(){r.run(function(n){n.toEditing()})}),t.onToReading(function(){r.run(function(n){n.toReading()})}),Dg(t.doc(),"touchend",function(n){We(t.html(),n.target())||We(t.body(),n.target())}),Dg(o,"transitionend",function(n){var e;"height"===n.raw().propertyName&&(e=ru(o),r.run(function(n){n.setViewportOffset(e)}),u(),a())}),Mg(o,"touchstart",function(n){var e;r.run(function(n){n.highlightSelection()}),e=n,r.run(function(n){n.onToolbarTouch(e)}),t.onTouchToolstrip()}),Dg(t.body(),"touchstart",function(n){c(),t.onTouchContent(),f.fireTouchstart(n)}),f.onTouchmove(),f.onTouchend(),Dg(t.body(),"click",function(n){n.kill()}),Dg(o,"touchmove",function(){t.onToolbarScrollStart()})];return{destroy:function(){En(l,function(n){n.unbind()})}}};var th=function(n){var t=k.none(),e=[],r=function(n){o()?u(n):e.push(n)},o=function(){return t.isSome()},i=function(n){En(n,u)},u=function(e){t.each(function(n){v.setTimeout(function(){e(n)},0)})};return n(function(n){t=k.some(n),i(e),e=[]}),{get:r,map:function(t){return th(function(e){r(function(n){e(t(n))})})},isReady:o}},rh={nu:th,pure:function(e){return th(function(n){n(e)})}},oh=function(e){var n=function(n){var r;e((r=n,function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=this;v.setTimeout(function(){r.apply(t,n)},0)}))},t=function(){return rh.nu(n)};return{map:function(r){return oh(function(t){n(function(n){var e=r(n);t(e)})})},bind:function(t){return oh(function(e){n(function(n){t(n).get(e)})})},anonBind:function(t){return oh(function(e){n(function(n){t.get(e)})})},toLazy:t,toCached:function(){var e=null;return oh(function(n){null===e&&(e=t()),e.get(n)})},get:n}},ih={nu:oh,pure:function(e){return oh(function(n){n(e)})}},uh=function(n,e,t){return Math.abs(n-e)<=t?k.none():n<e?k.some(n+t):k.some(n-t)},ch=function(){var f=null;return{animate:function(r,o,n,i,e,t){var u=!1,c=function(n){u=!0,e(n)};Ig.clearInterval(f);var a=function(n){Ig.clearInterval(f),c(n)};f=Ig.setInterval(function(){var t=r();uh(t,o,n).fold(function(){Ig.clearInterval(f),c(o)},function(n){if(i(n,a),!u){var e=r();(e!==n||Math.abs(e-o)>Math.abs(t-o))&&(Ig.clearInterval(f),c(o))}})},t)}}},ah=function(e,t){return ni([{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?k.some(n.keyboard):k.none()}).getOr({portrait:t/5,landscape:e/4})},fh=function(n){var e,t=Bg(n).isPortrait(),r=ah((e=n).screen.width,e.screen.height),o=t?r.portrait:r.landscape;return(t?n.screen.height:n.screen.width)-n.innerHeight>o?0:o},sh=function(n,e){var t=_e(n).dom().defaultView;return ru(n)+ru(e)-fh(t)},lh=sh,dh=function(n,e,t){var r=sh(e,t),o=ru(e)+ru(t)-r;_i(n,"padding-bottom",o+"px")},mh=mt([{fixed:["element","property","offsetY"]},{scroller:["element","offsetY"]}]),gh="data-"+Hi.resolve("position-y-fixed"),ph="data-"+Hi.resolve("y-property"),vh="data-"+Hi.resolve("scrolling"),hh="data-"+Hi.resolve("last-window-height"),bh=function(n){return Pg(n,gh)},yh=function(n,e){var t=Oo(n,ph);return mh.fixed(n,t,e)},xh=function(n,e){return mh.scroller(n,e)},wh=function(n){var e=bh(n);return("true"===Oo(n,vh)?xh:yh)(n,e)},Sh=function(n,e,t){var r=_e(n).dom().defaultView.innerHeight;return wo(n,hh,r+"px"),r-e-t},Oh=function(n){var e=uu(n,"["+gh+"]");return kn(e,wh)},Th=function(r,o,i,u){var e=_e(r).dom().defaultView,n=(y=i,x=Oo(y,"style"),Xi(y,{position:"absolute",top:"0px"}),wo(y,gh,"0px"),wo(y,ph,"top"),{restore:function(){wo(y,"style",x||""),ko(y,gh),ko(y,ph)}}),t=ru(i),c=ru(u),a=(p=t,v=Sh(r,t,c),h=r,b=Oo(h,"style"),ag.register(h),Xi(h,{position:"absolute",height:v+"px",width:"100%",top:p+"px"}),wo(h,gh,p+"px"),wo(h,vh,"true"),wo(h,ph,"top"),{restore:function(){ag.deregister(h),wo(h,"style",b||""),ko(h,gh),ko(h,vh),ko(h,ph)}}),f=(m=u,g=Oo(m,"style"),Xi(m,{position:"absolute",bottom:"0px"}),wo(m,gh,"0px"),wo(m,ph,"bottom"),{restore:function(){wo(m,"style",g||""),ko(m,gh),ko(m,ph)}}),s=!0,l=function(){var n=e.innerHeight;return Pg(r,hh)<n},d=function(){if(s){var n=ru(i),e=ru(u),t=Sh(r,n,e);wo(r,gh,n+"px"),_i(r,"height",t+"px"),dh(o,r,u)}};var m,g;var p,v,h,b;var y,x;return dh(o,r,u),{setViewportOffset:function(n){wo(r,gh,n+"px"),d()},isExpanding:l,isShrinking:w(l),refresh:d,restore:function(){s=!1,n.restore(),a.restore(),f.restore()}}},kh=bh,Eh=ch(),Ch="data-"+Hi.resolve("last-scroll-top"),Dh=function(n){var e=Ki(n,"top").getOr("0");return parseInt(e,10)},Mh=function(n){return parseInt(n.dom().scrollTop,10)},Ih=function(n,e){var t=e+kh(n)+"px";_i(n,"top",t)},Rh=function(t,r,o){return ih.nu(function(n){var e=l(Mh,t);Eh.animate(e,r,15,function(n){t.dom().scrollTop=n,_i(t,"top",Dh(t)+15+"px")},function(){t.dom().scrollTop=r,_i(t,"top",o+"px"),n(r)},10)})},Bh=function(o,i){return ih.nu(function(n){var e=l(Mh,o);wo(o,Ch,e());var t=Math.abs(i-e()),r=Math.ceil(t/10);Eh.animate(e,i,r,function(n,e){Pg(o,Ch)!==o.dom().scrollTop?e(o.dom().scrollTop):(o.dom().scrollTop=n,wo(o,Ch,n))},function(){o.dom().scrollTop=i,wo(o,Ch,i),n(i)},10)})},Ah=function(i,u){return ih.nu(function(n){var e=l(Dh,i),t=function(n){_i(i,"top",n+"px")},r=Math.abs(u-e()),o=Math.ceil(r/10);Eh.animate(e,u,o,t,function(){t(u),n(u)},10)})},Fh=function(e,t,r){var o=_e(e).dom().defaultView;return ih.nu(function(n){Ih(e,r),Ih(t,r),o.scrollTo(0,r),n(r)})};var Vh=function(n,e,t,r,o){var i=lh(e,t),u=l(Qv,n);i<r||i<o?Bh(e,e.dom().scrollTop-i+o).get(u):r<0&&Bh(e,e.dom().scrollTop+r).get(u)},Nh=function(u,n){return n(function(r){var o=[],i=0;0===u.length?r([]):En(u,function(n,e){var t;n.get((t=e,function(n){o[t]=n,++i>=u.length&&r(o)}))})})},jh=function(n,a){return n.fold(function(n,e,t){return _i(n,e,a+(r=t)+"px"),ih.pure(r);var r},function(n,e){return o=a+(r=e),i=Ki(t=n,"top").getOr(r),u=o-parseInt(i,10),c=t.dom().scrollTop+u,Rh(t,c,o);var t,r,o,i,u,c})},Hh=function(n,e){var t=Oh(n),r=kn(t,function(n){return jh(n,e)});return Nh(r,ih.nu)},zh=function(e,t,n,r,o,i){var u=function f(t){var r=Ho(rh.pure({}));return{start:function(e){var n=rh.nu(function(n){return t(e).get(n)});r.set(n)},idle:function(n){r.get().get(function(){n()})}}}(function(n){return Fh(e,t,n)}),c=Kp(function(){u.idle(function(){Hh(n,r.pageYOffset).get(function(){var n;(n=Ep(i),k.from(n[0]).bind(function(n){var e=n.top()-t.dom().scrollTop;return e>r.innerHeight+5||e<-5?k.some({top:h(e),bottom:h(e+n.height())}):k.none()})).each(function(n){t.dom().scrollTop=t.dom().scrollTop+n.top()}),u.start(0),o.refresh()})})},1e3),a=Dg(be.fromDom(r),"scroll",function(){r.pageYOffset<0||c.throttle()});return Hh(n,r.pageYOffset).get(b),{unbind:a.unbind}},Ph=function(n){var t=n.cWin(),e=n.ceBody(),r=n.socket(),o=n.toolstrip(),i=n.toolbar(),u=n.contentElement(),c=n.keyboardType(),a=n.outerWindow(),f=n.dropup(),s=Th(r,e,o,f),l=c(n.outerBody(),t,Ce(),u,o,i),d=Ag(a,{onChange:x,onReady:s.refresh});d.onAdjustment(function(){s.refresh()});var m=Dg(be.fromDom(a),"resize",function(){s.isExpanding()&&s.refresh()}),g=zh(o,r,n.outerBody(),a,s,t),p=function h(t,e){var n=t.document,r=be.fromTag("div");Io(r,Hi.resolve("unfocused-selections")),Ze(be.fromDom(n.documentElement),r);var o=Dg(r,"touchstart",function(n){n.prevent(),Zv(t,e),u()}),i=function(n){var e=be.fromTag("span");return gm(e,[Hi.resolve("layer-editor"),Hi.resolve("unfocused-selection")]),Xi(e,{left:n.left()+"px",top:n.top()+"px",width:n.width()+"px",height:n.height()+"px"}),e},u=function(){et(r)};return{update:function(){u();var n=Ep(t),e=kn(n,i);nt(r,e)},isActive:function(){return 0<qe(r).length},destroy:function(){o.unbind(),tt(r)},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){Vh(t,r,f,n,e)},updateToolbarPadding:x,setViewportOffset:function(n){s.setViewportOffset(n),Ah(r,n).get(b)},syncHeight:function(){_i(u,"height",u.dom().contentWindow.document.body.scrollHeight+"px")},refreshStructure:s.refresh,destroy:function(){s.restore(),d.destroy(),g.unbind(),m.unbind(),l.destroy(),p.destroy(),Jv(Ce(),Po)}}},Lh=function(r,n){var o=qp(),i=Xd(),u=Xd(),c=_d(),a=_d();return{enter:function(){n.hide();var t=be.fromDom(v.document);Lp.getActiveApi(r.editor).each(function(n){i.set({socketHeight:Ki(r.socket,"height"),iframeHeight:Ki(n.frame(),"height"),outerScroll:v.document.body.scrollTop}),u.set({exclusives:av.exclusive(t,"."+ag.scrollable())}),Io(r.container,Hi.resolve("fullscreen-maximized")),_p(r.container,n.body()),o.maximize(),_i(r.socket,"overflow","scroll"),_i(r.socket,"-webkit-overflow-scrolling","touch"),zo(n.body());var e=Be(["cWin","ceBody","socket","toolstrip","toolbar","dropup","contentElement","cursor","keyboardType","isScrolling","outerWindow","outerBody"],[]);c.set(Ph(e({cWin:n.win(),ceBody:n.body(),socket:r.socket,toolstrip:r.toolstrip,toolbar:r.toolbar,dropup:r.dropup.element(),contentElement:n.frame(),cursor:x,outerBody:r.body,outerWindow:r.win,keyboardType:nh.stubborn,isScrolling:function(){return u.get().exists(function(n){return n.socket.isScrolling()})}}))),c.run(function(n){n.syncHeight()}),a.set(eh(n,c,r.toolstrip,r.socket,r.dropup))})},refreshStructure:function(){c.run(function(n){n.refreshStructure()})},exit:function(){o.restore(),a.clear(),c.clear(),n.show(),i.on(function(n){n.socketHeight.each(function(n){_i(r.socket,"height",n)}),n.iframeHeight.each(function(n){_i(r.editor.getFrame(),"height",n)}),v.document.body.scrollTop=n.scrollTop}),i.clear(),u.on(function(n){n.exclusives.unbind()}),u.clear(),Bo(r.container,Hi.resolve("fullscreen-maximized")),Xp(),ag.deregister(r.toolbar),Ji(r.socket,"overflow"),Ji(r.socket,"-webkit-overflow-scrolling"),Po(r.editor.getFrame()),Lp.getActiveApi(r.editor).each(function(n){n.clearSelection()})}}},Gh=function(n){var e=Sr("Getting IosWebapp schema",Qp,n);_i(e.toolstrip,"width","100%"),_i(e.container,"position","relative");var t=km(Jp(function(){e.setReadOnly(e.readOnlyOnInit()),o.enter()},e.translate));e.alloy.add(t);var r={show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}},o=Lh(e,r);return{setReadOnly:e.setReadOnly,refreshStructure:o.refreshStructure,enter:o.enter,exit:o.exit,destroy:x}};var $h=tinymce.util.Tools.resolve("tinymce.EditorManager"),Uh=function(n){var e=It(n.settings,"skin_url").fold(function(){return $h.baseURL+"/skins/ui/oxide"},function(n){return n});return{content:e+"/content.mobile.min.css",ui:e+"/skin.mobile.min.css"}},Wh=function(n,e,t){n.system().broadcastOn([_o.formatChanged()],{command:e,state:t})},_h=function(r,n){var e=E(n.formatter.get());En(e,function(e){n.formatter.formatChanged(e,function(n){Wh(r,e,n)})}),En(["ul","ol"],function(t){n.selection.selectorChanged(t,function(n,e){Wh(r,t,n)})})},Xh=(h(["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)}}),qh=h("toReading"),Yh=h("toEditing"),Kh=function(g){return{getNotificationManagerImpl:function(){return{open:h({progressBar:{value:x},close:x,text:x}),close:x,reposition:x,getArgs:h({})}},renderUI:function(){var n=g.getElement(),e=Uh(g);0==(!1===g.settings.skin)?(g.contentCSS.push(e.content),$o.DOM.styleSheetLoader.load(e.ui,Xh(g))):Xh(g)();var t,r,o=function(){g.fire("ScrollIntoView")},f=Yn.detect().os.isAndroid()?function a(n){var e=Kv({classes:[Hi.resolve("android-container")]}),t=fv(),r=_d(),o=mv(r),i=gv(),u=Bv(x,n);return e.add(t.wrapper()),e.add(i),e.add(u.component()),{system:h(e),element:e.element,init:function(n){r.set(Zp(n))},exit:function(){r.run(function(n){n.exit(),_m.remove(i,o)})},setToolbarGroups:function(n){var e=t.createGroups(n);t.setGroups(e)},setContextToolbar:function(n){var e=t.createGroups(n);t.setContextToolbar(e)},focusToolbar:function(){t.focus()},restoreToolbar:function(){t.restoreToolbar()},updateMode:function(n){pv(i,o,n,e.root())},socket:h(i),dropup:h(u)}}(o):function m(n){var e=Kv({classes:[Hi.resolve("ios-container")]}),t=fv(),r=_d(),o=mv(r),i=gv(),u=Bv(function(){r.run(function(n){n.refreshStructure()})},n);return e.add(t.wrapper()),e.add(i),e.add(u.component()),{system:h(e),element:e.element,init:function(n){r.set(Gh(n))},exit:function(){r.run(function(n){_m.remove(i,o),n.exit()})},setToolbarGroups:function(n){var e=t.createGroups(n);t.setGroups(e)},setContextToolbar:function(n){var e=t.createGroups(n);t.setContextToolbar(e)},focusToolbar:function(){t.focus()},restoreToolbar:function(){t.restoreToolbar()},updateMode:function(n){pv(i,o,n,e.root())},socket:h(i),dropup:h(u)}}(o),i=be.fromDom(n);t=i,r=f.system(),ft(t,r,Je);var u=n.ownerDocument.defaultView,s=Ag(u,{onChange:function(){f.system().broadcastOn([_o.orientationChanged()],{width:Fg(u)})},onReady:x}),l=function(n,e,t,r){!1===r&&g.selection.collapse();var o=c(n,e,t);f.setToolbarGroups(!0===r?o.readOnly:o.main),g.setMode(!0===r?"readonly":"design"),g.fire(!0===r?qh():Yh()),f.updateMode(r)},c=function(n,e,t){var r=n.get();return{readOnly:r.backToMask.concat(e.get()),main:r.backToMask.concat(t.get())}},d=function(n,e){return g.on(n,e),{unbind:function(){g.off(n)}}};return g.on("init",function(){f.init({editor:{getFrame:function(){return be.fromDom(g.contentAreaContainer.querySelector("iframe"))},onDomChanged:function(){return{unbind:x}},onToReading:function(n){return d(qh(),n)},onToEditing:function(n){return d(Yh(),n)},onScrollToCursor:function(e){return g.on("ScrollIntoView",function(n){e(n)}),{unbind:function(){g.off("ScrollIntoView"),s.destroy()}}},onTouchToolstrip:function(){t()},onTouchContent:function(){var n,e=be.fromDom(g.editorContainer.querySelector("."+Hi.resolve("toolbar")));(n=e,Go(n).bind(function(n){return f.system().getByDom(n).toOption()})).each(ge),f.restoreToolbar(),t()},onTapContent:function(n){var e=n.target();"img"===Se(e)?(g.selection.select(e.dom()),n.kill()):"a"===Se(e)&&f.system().getByDom(be.fromDom(g.editorContainer)).each(function(n){jo.isAlpha(n)&&Wo(e.dom())})}},container:be.fromDom(g.editorContainer),socket:be.fromDom(g.contentAreaContainer),toolstrip:be.fromDom(g.editorContainer.querySelector("."+Hi.resolve("toolstrip"))),toolbar:be.fromDom(g.editorContainer.querySelector("."+Hi.resolve("toolbar"))),dropup:f.dropup(),alloy:f.system(),translate:x,setReadOnly:function(n){l(a,c,u,n)},readOnlyOnInit:function(){return!1}});var t=function(){f.dropup().disappear(function(){f.system().broadcastOn([_o.dropupDismissed()],{})})},n={label:"The first group",scrollable:!1,items:[Nf.forToolbar("back",function(){g.selection.collapse(),f.exit()},{},g)]},e={label:"Back to read only",scrollable:!1,items:[Nf.forToolbar("readonly-back",function(){l(a,c,u,!0)},{},g)]},r=Sg(f,g),o=Og(g.settings,r),i={label:"The extra group",scrollable:!1,items:[]},u=Ho([{label:"the action group",scrollable:!0,items:o},i]),c=Ho([{label:"The read only mode group",scrollable:!0,items:[]},i]),a=Ho({backToMask:[n],backToReadOnly:[e]});_h(f,g)}),g.on("remove",function(){f.exit()}),g.on("detach",function(){var e,n;e=f.system(),n=qe(e.element()),En(n,function(n){e.getByDom(n).each(rt)}),tt(e.element()),f.system().destroy()}),{iframeContainer:f.socket().element().dom(),editorContainer:f.element().dom()}}}};!function Qh(){Uo.add("mobile",Kh)}()}(window);