TimeTrex/interface/html5/framework/tinymce/themes/mobile/theme.min.js

1 line
161 KiB
JavaScript

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