diff --git a/vendor/javascript/tinymce.min.js b/vendor/javascript/tinymce.min.js index 627c73a0c9..6a7a1c880d 100644 --- a/vendor/javascript/tinymce.min.js +++ b/vendor/javascript/tinymce.min.js @@ -1 +1 @@ -function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,o={exports:{}};t=o,function(){var e=function(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=typeof e;return"object"===t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t},o=function(e){return{eq:e}},n=o((function(e,t){return e===t})),r=function(e){return o((function(t,o){if(t.length!==o.length)return!1;for(var n=t.length,r=0;r{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},d=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&c(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,m=e=>t=>typeof t===e,u=e=>t=>e===t,g=(e,t)=>p(e)&&c(e,t,((e,t)=>l(e)===t)),h=d("string"),p=d("object"),f=e=>g(e,Object),v=d("array"),b=u(null),y=m("boolean"),w=u(void 0),x=e=>null==e,C=e=>!x(e),S=m("function"),k=m("number"),_=(e,t)=>{if(v(e)){for(let o=0,n=e.length;o{},T=(e,t)=>(...o)=>e(t.apply(null,o)),O=(e,t)=>o=>e(t(o)),D=e=>()=>e,A=e=>e,M=(e,t)=>e===t;function N(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const R=e=>t=>!e(t),B=e=>()=>{throw new Error(e)},L=e=>e(),H=e=>{e()},I=D(!1),P=D(!0);class F{constructor(e,t){this.tag=e,this.value=t}static some(e){return new F(!0,e)}static none(){return F.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?F.some(e(this.value)):F.none()}bind(e){return this.tag?e(this.value):F.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:F.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return C(e)?F.some(e):F.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}F.singletonNone=new F(!1);const z=Array.prototype.slice,V=Array.prototype.indexOf,Z=Array.prototype.push,U=(e,t)=>V.call(e,t),j=(e,t)=>U(e,t)>-1,W=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{for(let o=e.length-1;o>=0;o--)t(e[o],o)},K=(e,t)=>{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(G(e,((e,n)=>{o=t(o,e,n)})),o),J=(e,t,o)=>(q(e,((e,n)=>{o=t(o,e,n)})),o),Q=(e,t,o)=>{for(let n=0,r=e.length;nQ(e,t,I),te=(e,t)=>{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;ooe($(e,t)),re=(e,t)=>{for(let o=0,n=e.length;o{const t=z.call(e,0);return t.reverse(),t},ae=(e,t)=>Y(e,(e=>!j(t,e))),ie=(e,t)=>{const o={};for(let n=0,r=e.length;n{const o=z.call(e,0);return o.sort(t),o},ce=(e,t)=>t>=0&&tce(e,0),me=e=>ce(e,e.length-1),ue=S(Array.from)?Array.from:e=>z.call(e),ge=(e,t)=>{for(let o=0;o{const o=he(e);for(let n=0,r=o.length;nbe(e,((e,o)=>({k:o,v:t(e,o)}))),be=(e,t)=>{const o={};return fe(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},ye=e=>(t,o)=>{e[o]=t},we=(e,t,o,n)=>{fe(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},xe=(e,t)=>{const o={};return we(e,t,ye(o),E),o},Ce=(e,t)=>{const o=[];return fe(e,((e,n)=>{o.push(t(e,n))})),o},Se=e=>Ce(e,A),ke=(e,t)=>_e(e,t)?F.from(e[t]):F.none(),_e=(e,t)=>pe.call(e,t),Ee=(e,t)=>_e(e,t)&&void 0!==e[t]&&null!==e[t],Te=e=>{const t={};return q(e,(e=>{t[e]={}})),he(t)},Oe=e=>void 0!==e.length,De=Array.isArray,Ae=(e,t,o)=>{if(!e)return!1;if(o=o||e,Oe(e)){for(let n=0,r=e.length;n{const o=[];return Ae(e,((n,r)=>{o.push(t(n,r,e))})),o},Ne=(e,t)=>{const o=[];return Ae(e,((n,r)=>{t&&!t(n,r,e)||o.push(n)})),o},Re=(e,t,o,n)=>{let r=w(o)?e[0]:o;for(let o=0;o{for(let n=0,r=e.length;ne[e.length-1],He=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Ie=()=>Pe(0,0),Pe=(e,t)=>({major:e,minor:t}),Fe={nu:Pe,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?Ie():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return Pe(n(1),n(2))})(e,o)},unknown:Ie},ze=(e,t)=>{const o=String(t).toLowerCase();return ee(e,(e=>e.search(o)))},Ve=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Ze=(e,t)=>je(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Ue=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!w(n)||r+t.length<=n)},je=(e,t)=>Ve(e,t,0),We=(e,t)=>Ve(e,t,e.length-t.length),$e=e=>t=>t.replace(e,""),qe=$e(/^\s+|\s+$/g),Ge=$e(/^\s+/g),Ke=$e(/\s+$/g),Ye=e=>e.length>0,Xe=e=>!Ye(e),Je=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?F.none():F.some(o)},Qe=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,et=e=>t=>Ue(t,e),tt=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Ue(e,"edge/")&&Ue(e,"chrome")&&Ue(e,"safari")&&Ue(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Qe],search:e=>Ue(e,"chrome")&&!Ue(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Ue(e,"msie")||Ue(e,"trident")},{name:"Opera",versionRegexes:[Qe,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:et("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:et("firefox")},{name:"Safari",versionRegexes:[Qe,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Ue(e,"safari")||Ue(e,"mobile/"))&&Ue(e,"applewebkit")}],ot=[{name:"Windows",search:et("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Ue(e,"iphone")||Ue(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:et("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:et("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:et("linux"),versionRegexes:[]},{name:"Solaris",search:et("sunos"),versionRegexes:[]},{name:"FreeBSD",search:et("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:et("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],nt={browsers:D(tt),oses:D(ot)},rt="Edge",st="Chromium",at="Opera",it="Firefox",lt="Safari",ct=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(rt),isChromium:n(st),isIE:n("IE"),isOpera:n(at),isFirefox:n(it),isSafari:n(lt)}},dt={unknown:()=>ct({current:void 0,version:Fe.unknown()}),nu:ct,edge:D(rt),chromium:D(st),ie:D("IE"),opera:D(at),firefox:D(it),safari:D(lt)},mt="Windows",ut="Android",gt="Linux",ht="macOS",pt="Solaris",ft="FreeBSD",vt="ChromeOS",bt=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(mt),isiOS:n("iOS"),isAndroid:n(ut),isMacOS:n(ht),isLinux:n(gt),isSolaris:n(pt),isFreeBSD:n(ft),isChromeOS:n(vt)}},yt={unknown:()=>bt({current:void 0,version:Fe.unknown()}),nu:bt,windows:D(mt),ios:D("iOS"),android:D(ut),linux:D(gt),macos:D(ht),solaris:D(pt),freebsd:D(ft),chromeos:D(vt)},wt=(e,t,o)=>{const n=nt.browsers(),r=nt.oses(),s=t.bind((e=>((e,t)=>ge(t.brands,(t=>{const o=t.brand.toLowerCase();return ee(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Fe.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>ze(e,t).map((e=>{const o=Fe.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(dt.unknown,dt.nu),a=((e,t)=>ze(e,t).map((e=>{const o=Fe.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(yt.unknown,yt.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:D(r),isiPhone:D(s),isTablet:D(l),isPhone:D(c),isTouch:D(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:D(d),isDesktop:D(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},xt=e=>window.matchMedia(e).matches;let Ct=He((()=>wt(navigator.userAgent,F.from(navigator.userAgentData),xt)));const St=()=>Ct(),kt=navigator.userAgent,_t=St(),Et=_t.browser,Tt=_t.os,Ot=_t.deviceType,Dt=-1!==kt.indexOf("Windows Phone"),At={transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",documentMode:Et.isIE()?document.documentMode||7:10,cacheSuffix:null,container:null,canHaveCSP:!Et.isIE(),windowsPhone:Dt,browser:{current:Et.current,version:Et.version,isChromium:Et.isChromium,isEdge:Et.isEdge,isFirefox:Et.isFirefox,isIE:Et.isIE,isOpera:Et.isOpera,isSafari:Et.isSafari},os:{current:Tt.current,version:Tt.version,isAndroid:Tt.isAndroid,isChromeOS:Tt.isChromeOS,isFreeBSD:Tt.isFreeBSD,isiOS:Tt.isiOS,isLinux:Tt.isLinux,isMacOS:Tt.isMacOS,isSolaris:Tt.isSolaris,isWindows:Tt.isWindows},deviceType:{isDesktop:Ot.isDesktop,isiPad:Ot.isiPad,isiPhone:Ot.isiPhone,isPhone:Ot.isPhone,isTablet:Ot.isTablet,isTouch:Ot.isTouch,isWebView:Ot.isWebView}},Mt=/^\s*|\s*$/g,Nt=e=>x(e)?"":(""+e).replace(Mt,""),Rt=function(e,t,o,n){n=n||this,e&&(o&&(e=e[o]),Ae(e,((e,r)=>!1!==t.call(n,e,r,o)&&(Rt(e,t,o,n),!0))))},Bt={trim:Nt,isArray:De,is:(e,t)=>t?!("array"!==t||!De(e))||typeof e===t:void 0!==e,toArray:e=>{if(De(e))return e;{const t=[];for(let o=0,n=e.length;o{const n=h(e)?e.split(t||","):e||[];let r=n.length;for(;r--;)o[n[r]]={};return o},each:Ae,map:Me,grep:Ne,inArray:(e,t)=>{if(e)for(let o=0,n=e.length;o{for(let o=0;o{const o=e.split(".");for(let e=0,n=o.length;ev(e)?e:""===e?[]:Me(e.split(t||","),Nt),_addCacheSuffix:e=>{const t=At.cacheSuffix;return t&&(e+=(-1===e.indexOf("?")?"?":"&")+t),e}},Lt=(e,t,o=M)=>e.exists((e=>o(e,t))),Ht=(e,t,o=M)=>It(e,t,o).getOr(e.isNone()&&t.isNone()),It=(e,t,o)=>e.isSome()&&t.isSome()?F.some(o(e.getOrDie(),t.getOrDie())):F.none(),Pt=(e,t)=>e?F.some(t):F.none(),Ft="undefined"!=typeof window?window:Function("return this;")(),zt=(e,t)=>((e,t)=>{let o=null!=t?t:Ft;for(let t=0;t{const o=((e,t)=>zt(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},Zt=Object.getPrototypeOf,Ut=e=>{const t=zt("ownerDocument.defaultView",e);return p(e)&&((e=>Vt("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Zt(e).constructor.name))},jt=e=>e.dom.nodeName.toLowerCase(),Wt=e=>e.dom.nodeType,$t=e=>t=>Wt(t)===e,qt=e=>Gt(e)&&Ut(e.dom),Gt=$t(1),Kt=$t(3),Yt=$t(9),Xt=$t(11),Jt=e=>t=>Gt(t)&&jt(t)===e,Qt=(e,t,o)=>{if(!(h(o)||y(o)||k(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},eo=(e,t,o)=>{Qt(e.dom,t,o)},to=(e,t)=>{const o=e.dom;fe(t,((e,t)=>{Qt(o,t,e)}))},oo=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},no=(e,t)=>F.from(oo(e,t)),ro=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},so=(e,t)=>{e.dom.removeAttribute(t)},ao=e=>J(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),io=(e,t)=>{const o=oo(e,t);return void 0===o||""===o?[]:o.split(" ")},lo=e=>void 0!==e.dom.classList,co=e=>io(e,"class"),mo=(e,t)=>((e,t,o)=>{const n=io(e,t).concat([o]);return eo(e,t,n.join(" ")),!0})(e,"class",t),uo=(e,t)=>((e,t,o)=>{const n=Y(io(e,t),(e=>e!==o));return n.length>0?eo(e,t,n.join(" ")):so(e,t),!1})(e,"class",t),go=(e,t)=>{lo(e)?e.dom.classList.add(t):mo(e,t)},ho=e=>{0===(lo(e)?e.dom.classList:co(e)).length&&so(e,"class")},po=(e,t)=>{lo(e)?e.dom.classList.remove(t):uo(e,t),ho(e)},fo=(e,t)=>{const o=lo(e)?e.dom.classList.toggle(t):((e,t)=>j(co(e),t)?uo(e,t):mo(e,t))(e,t);return ho(e),o},vo=(e,t)=>lo(e)&&e.dom.classList.contains(t),bo=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},yo={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return bo(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return bo(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return bo(o)},fromDom:bo,fromPoint:(e,t,o)=>F.from(e.dom.elementFromPoint(t,o)).map(bo)},wo=(e,t)=>{const o=[],n=e=>(o.push(e),t(e));let r=t(e);do{r=r.bind(n)}while(r.isSome());return o},xo=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Co=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,So=(e,t)=>e.dom===t.dom,ko=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},_o=e=>yo.fromDom(e.dom.ownerDocument),Eo=e=>Yt(e)?e:_o(e),To=e=>yo.fromDom(Eo(e).dom.defaultView),Oo=e=>F.from(e.dom.parentNode).map(yo.fromDom),Do=e=>F.from(e.dom.parentElement).map(yo.fromDom),Ao=(e,t)=>{const o=S(t)?t:I;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=yo.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Mo=e=>F.from(e.dom.previousSibling).map(yo.fromDom),No=e=>F.from(e.dom.nextSibling).map(yo.fromDom),Ro=e=>se(wo(e,Mo)),Bo=e=>wo(e,No),Lo=e=>$(e.dom.childNodes,yo.fromDom),Ho=(e,t)=>{const o=e.dom.childNodes;return F.from(o[t]).map(yo.fromDom)},Io=e=>Ho(e,0),Po=e=>Ho(e,e.dom.childNodes.length-1),Fo=e=>e.dom.childNodes.length,zo=e=>Xt(e)&&C(e.dom.host),Vo=S(Element.prototype.attachShadow)&&S(Node.prototype.getRootNode),Zo=D(Vo),Uo=Vo?e=>yo.fromDom(e.dom.getRootNode()):Eo,jo=e=>zo(e)?e:(e=>{const t=e.dom.head;if(null==t)throw new Error("Head is not available yet");return yo.fromDom(t)})(Eo(e)),Wo=e=>yo.fromDom(e.dom.host),$o=e=>{if(Zo()&&C(e.target)){const t=yo.fromDom(e.target);if(Gt(t)&&qo(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return de(t)}}return F.from(e.target)},qo=e=>C(e.dom.shadowRoot),Go=e=>{const t=Kt(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=Uo(e);return zo(t)?F.some(t):F.none()})(yo.fromDom(t)).fold((()=>o.body.contains(t)),O(Go,Wo))};var Ko=(e,t,o,n,r)=>e(o,n)?F.some(o):S(r)&&r(o)?F.none():t(o,n,r);const Yo=(e,t,o)=>{let n=e.dom;const r=S(o)?o:I;for(;n.parentNode;){n=n.parentNode;const e=yo.fromDom(n);if(t(e))return F.some(e);if(r(e))break}return F.none()},Xo=(e,t,o)=>Ko(((e,t)=>t(e)),Yo,e,t,o),Jo=(e,t)=>ee(e.dom.childNodes,(e=>t(yo.fromDom(e)))).map(yo.fromDom),Qo=(e,t)=>{const o=e=>{for(let n=0;nYo(e,(e=>xo(e,t)),o),tn=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Co(o)?F.none():F.from(o.querySelector(e)).map(yo.fromDom)})(t,e),on=(e,t,o)=>Ko(((e,t)=>xo(e,t)),en,e,t,o),nn=(e,t=!1)=>{return Go(e)?e.dom.isContentEditable:(o=e,on(o,"[contenteditable]")).fold(D(t),(e=>"true"===rn(e)));var o},rn=e=>e.dom.contentEditable,sn=e=>void 0!==e.style&&S(e.style.getPropertyValue),an=(e,t,o)=>{if(!h(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);sn(e)&&e.style.setProperty(t,o)},ln=(e,t,o)=>{const n=e.dom;an(n,t,o)},cn=(e,t)=>{const o=e.dom;fe(t,((e,t)=>{an(o,t,e)}))},dn=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||Go(e)?n:mn(o,t)},mn=(e,t)=>sn(e)?e.style.getPropertyValue(t):"",un=(e,t)=>{const o=e.dom,n=mn(o,t);return F.from(n).filter((e=>e.length>0))},gn=e=>{const t={},o=e.dom;if(sn(o))for(let e=0;e{((e,t)=>{sn(e)&&e.style.removeProperty(t)})(e.dom,t),Lt(no(e,"style").map(qe),"")&&so(e,"style")},pn=(e,t)=>{Oo(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},fn=(e,t)=>{No(e).fold((()=>{Oo(e).each((e=>{bn(e,t)}))}),(e=>{pn(e,t)}))},vn=(e,t)=>{Io(e).fold((()=>{bn(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},bn=(e,t)=>{e.dom.appendChild(t.dom)},yn=(e,t)=>{pn(e,t),bn(t,e)},wn=(e,t)=>{q(t,(t=>{bn(e,t)}))},xn=e=>{e.dom.textContent="",q(Lo(e),(e=>{Cn(e)}))},Cn=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Sn=e=>{const t=Lo(e);var o,n;t.length>0&&(o=e,q(n=t,((e,t)=>{const r=0===t?o:n[t-1];fn(r,e)}))),Cn(e)},kn=e=>$(e,yo.fromDom),_n=e=>e.dom.innerHTML,En=(e,t)=>{const o=_o(e).dom,n=yo.fromDom(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Lo(yo.fromDom(o))})(t,o);wn(n,r),xn(e),bn(e,n)},Tn=(e,t)=>o=>{e(o)&&t((e=>{const t=yo.fromDom($o(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=T(n,o);return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)})(o))},On=(e,t,o,n)=>((e,t,o,n,r)=>{const s=Tn(o,n);return e.dom.addEventListener(t,s,r),{unbind:N(Dn,e,t,s,r)}})(e,t,o,n,!1),Dn=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},An=(e,t)=>({left:e,top:t,translate:(o,n)=>An(e+o,t+n)}),Mn=An,Nn=(e,t)=>void 0!==e?e:void 0!==t?t:0,Rn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?Mn(o.offsetLeft,o.offsetTop):Go(e)?(e=>{const t=e.getBoundingClientRect();return Mn(t.left,t.top)})(t):Mn(0,0)},Bn=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return Mn(o,n)},Ln=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Hn=(e,t)=>{St().browser.isSafari()&&S(e.dom.scrollIntoViewIfNeeded)?e.dom.scrollIntoViewIfNeeded(!1):e.dom.scrollIntoView(t)},In=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Pn=e=>{const t=void 0===e?window:e,o=t.document,n=Bn(yo.fromDom(o));return(e=>{const t=void 0===e?window:e;return St().browser.isFirefox()?F.none():F.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return In(n.left,n.top,o,r)}),(e=>In(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Fn=(e,t)=>{let o=[];return q(Lo(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(Fn(e,t))})),o},zn=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Co(o)?[]:$(o.querySelectorAll(e),yo.fromDom)})(t,e),Vn=(e,t,o)=>en(e,t,o).isSome();class Zn{constructor(e,t){this.node=e,this.rootNode=t,this.current=this.current.bind(this),this.next=this.next.bind(this),this.prev=this.prev.bind(this),this.prev2=this.prev2.bind(this)}current(){return this.node}next(e){return this.node=this.findSibling(this.node,"firstChild","nextSibling",e),this.node}prev(e){return this.node=this.findSibling(this.node,"lastChild","previousSibling",e),this.node}prev2(e){return this.node=this.findPreviousNode(this.node,e),this.node}findSibling(e,t,o,n){if(e){if(!n&&e[t])return e[t];if(e!==this.rootNode){let t=e[o];if(t)return t;for(let n=e.parentNode;n&&n!==this.rootNode;n=n.parentNode)if(t=n[o],t)return t}}}findPreviousNode(e,t){if(e){const o=e.previousSibling;if(this.rootNode&&o===this.rootNode)return;if(o){if(!t)for(let e=o.lastChild;e;e=e.lastChild)if(!e.lastChild)return e;return o}const n=e.parentNode;if(n&&n!==this.rootNode)return n}}}const Un=e=>t=>!!t&&t.nodeType===e,jn=e=>!!e&&!Object.getPrototypeOf(e),Wn=Un(1),$n=e=>Wn(e)&&qt(yo.fromDom(e)),qn=e=>{const t=e.toLowerCase();return e=>C(e)&&e.nodeName.toLowerCase()===t},Gn=e=>{const t=e.map((e=>e.toLowerCase()));return e=>{if(e&&e.nodeName){const o=e.nodeName.toLowerCase();return j(t,o)}return!1}},Kn=(e,t)=>{const o=t.toLowerCase().split(" ");return t=>{if(Wn(t)){const n=t.ownerDocument.defaultView;if(n)for(let r=0;rt=>Wn(t)&&t.hasAttribute(e),Xn=e=>Wn(e)&&e.hasAttribute("data-mce-bogus"),Jn=e=>Wn(e)&&"TABLE"===e.tagName,Qn=e=>t=>{if($n(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},er=Gn(["textarea","input"]),tr=Un(3),or=Un(4),nr=Un(7),rr=Un(8),sr=Un(9),ar=Un(11),ir=qn("br"),lr=qn("img"),cr=Qn("true"),dr=Qn("false"),mr=Gn(["td","th"]),ur=Gn(["td","th","caption"]),gr=Gn(["video","audio","object","embed"]),hr=qn("li"),pr=qn("details"),fr=qn("summary"),vr="\ufeff",br=" ",yr=e=>e===vr,wr=((e,t)=>{const o=t=>e(t)?F.from(t.dom.nodeValue):F.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(Kt,"text"),xr=e=>wr.get(e),Cr=e=>wr.getOption(e),Sr=e=>{let t;return o=>(t=t||ie(e,P),_e(t,jt(o)))},kr=e=>Gt(e)&&"br"===jt(e),_r=Sr(["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"]),Er=Sr(["ul","ol","dl"]),Tr=Sr(["li","dd","dt"]),Or=Sr(["thead","tbody","tfoot"]),Dr=Sr(["td","th"]),Ar=Sr(["pre","script","textarea","style"]),Mr=e=>{const t=zn(e,"br"),o=Y((e=>{const t=[];let o=e.dom;for(;o;)t.push(yo.fromDom(o)),o=o.lastChild;return t})(e).slice(-1),kr);t.length===o.length&&q(o,Cn)},Nr=()=>{const e=yo.fromTag("br");return eo(e,"data-mce-bogus","1"),e},Rr=e=>{xn(e),bn(e,Nr())},Br=vr,Lr=yr,Hr=e=>e.replace(/\uFEFF/g,""),Ir=Wn,Pr=tr,Fr=e=>(Pr(e)&&(e=e.parentNode),Ir(e)&&e.hasAttribute("data-mce-caret")),zr=e=>Pr(e)&&Lr(e.data),Vr=e=>Fr(e)||zr(e),Zr=e=>e.firstChild!==e.lastChild||!ir(e.firstChild),Ur=e=>{const t=e.container();return!!tr(t)&&(t.data.charAt(e.offset())===Br||e.isAtStart()&&zr(t.previousSibling))},jr=e=>{const t=e.container();return!!tr(t)&&(t.data.charAt(e.offset()-1)===Br||e.isAtEnd()&&zr(t.nextSibling))},Wr=e=>Pr(e)&&e.data[0]===Br,$r=e=>Pr(e)&&e.data[e.data.length-1]===Br,qr=e=>e&&e.hasAttribute("data-mce-caret")?((e=>{var t;const o=e.getElementsByTagName("br"),n=o[o.length-1];Xn(n)&&(null===(t=n.parentNode)||void 0===t||t.removeChild(n))})(e),e.removeAttribute("data-mce-caret"),e.removeAttribute("data-mce-bogus"),e.removeAttribute("style"),e.removeAttribute("data-mce-style"),e.removeAttribute("_moz_abspos"),e):null,Gr=e=>Fr(e.startContainer),Kr=cr,Yr=dr,Xr=ir,Jr=tr,Qr=Gn(["script","style","textarea"]),es=Gn(["img","input","textarea","hr","iframe","video","audio","object","embed"]),ts=Gn(["table"]),os=Vr,ns=e=>!os(e)&&(Jr(e)?!Qr(e.parentNode):es(e)||Xr(e)||ts(e)||rs(e)),rs=e=>!(e=>Wn(e)&&"true"===e.getAttribute("unselectable"))(e)&&Yr(e),ss=(e,t)=>ns(e)&&((e,t)=>{for(let o=e.parentNode;o&&o!==t;o=o.parentNode){if(rs(o))return!1;if(Kr(o))return!0}return!0})(e,t),as=/^[ \t\r\n]*$/,is=e=>as.test(e),ls=e=>{for(const t of e)if(!yr(t))return!1;return!0},cs=e=>"\n"===e||"\r"===e,ds=(e,t=4,o=!0,n=!0)=>{const r=((e,t)=>t<=0?"":new Array(t+1).join(e))(" ",t),s=e.replace(/\t/g,r),a=J(s,((e,t)=>(e=>-1!==" \f\t\v".indexOf(e))(t)||t===br?e.pcIsSpace||""===e.str&&o||e.str.length===s.length-1&&n||((e,t)=>t=0&&cs(e[t]))(s,e.str.length+1)?{pcIsSpace:!1,str:e.str+br}:{pcIsSpace:!0,str:e.str+" "}:{pcIsSpace:cs(t),str:e.str+t}),{pcIsSpace:!1,str:""});return a.str},ms=(e,t)=>tr(e)&&is(e.data)&&!((e,t)=>{const o=yo.fromDom(t),n=yo.fromDom(e);return Vn(n,"pre,code",N(So,o))})(e,t),us=(e,t)=>ns(e)&&!ms(e,t)||(e=>Wn(e)&&"A"===e.nodeName&&!e.hasAttribute("href")&&(e.hasAttribute("name")||e.hasAttribute("id")))(e)||gs(e),gs=Yn("data-mce-bookmark"),hs=Yn("data-mce-bogus"),ps=(fs="data-mce-bogus",vs="all",e=>Wn(e)&&e.getAttribute(fs)===vs);var fs,vs;const bs=e=>Do(yo.fromDom(e)).exists((e=>!nn(e))),ys=(e,t=!0)=>((e,t)=>{let o=0;if(us(e,e))return!1;{let n=e.firstChild;if(!n)return!0;const r=new Zn(n,e);do{if(t){if(ps(n)){n=r.next(!0);continue}if(hs(n)){n=r.next();continue}}if(cr(n)&&bs(n))return!1;if(ir(n))o++,n=r.next();else{if(us(n,e))return!1;n=r.next()}}while(n);return o<=1}})(e.dom,t),ws=e=>"svg"===e.toLowerCase(),xs=e=>ws(e.nodeName),Cs=e=>"svg"===(null==e?void 0:e.nodeName)?"svg":"html",Ss=["svg"],ks="data-mce-block",_s=e=>$((e=>Y(he(e),(e=>!/[A-Z]/.test(e))))(e),(e=>`${e}:`+$(Ss,(t=>`not(${t} ${e})`)).join(":"))).join(","),Es=(e,t)=>C(t.querySelector(e))?(t.setAttribute(ks,"true"),"inline-boundary"===t.getAttribute("data-mce-selected")&&t.removeAttribute("data-mce-selected"),!0):(t.removeAttribute(ks),!1),Ts=(e,t)=>{const o=_s(e.getTransparentElements()),n=_s(e.getBlockElements());return Y(t.querySelectorAll(o),(e=>Es(n,e)))},Os=(e,t)=>{var o;const n=t?"lastChild":"firstChild";for(let t=e[n];t;t=t[n])if(ys(yo.fromDom(t)))return void(null===(o=t.parentNode)||void 0===o||o.removeChild(t))},Ds=(e,t,o)=>{const n=e.getBlockElements(),r=yo.fromDom(t),s=e=>jt(e)in n,a=e=>So(e,r);q(kn(o),(t=>{Yo(t,s,a).each((o=>{const n=((e,t)=>Y(Lo(e),t))(t,(t=>s(t)&&!e.isValidChild(jt(o),jt(t))));if(n.length>0){const t=Do(o);q(n,(e=>{Yo(e,s,a).each((t=>{((e,t)=>{const o=document.createRange(),n=e.parentNode;if(n){o.setStartBefore(e),o.setEndBefore(t);const r=o.extractContents();Os(r,!0),o.setStartAfter(t),o.setEndAfter(e);const s=o.extractContents();Os(s,!1),ys(yo.fromDom(r))||n.insertBefore(r,e),ys(yo.fromDom(t))||n.insertBefore(t,e),ys(yo.fromDom(s))||n.insertBefore(s,e),n.removeChild(e)}})(t.dom,e.dom)}))})),t.each((t=>Ts(e,t.dom)))}}))}))},As=(e,t)=>{const o=Ts(e,t);Ds(e,t,o),((e,t,o)=>{q([...o,...Ls(e,t)?[t]:[]],(t=>q(zn(yo.fromDom(t),t.nodeName.toLowerCase()),(t=>{Hs(e,t.dom)&&Sn(t)}))))})(e,t,o)},Ms=(e,t)=>{if(Bs(e,t)){const o=_s(e.getBlockElements());Es(o,t)}},Ns=e=>e.hasAttribute(ks),Rs=(e,t)=>_e(e.getTransparentElements(),t),Bs=(e,t)=>Wn(t)&&Rs(e,t.nodeName),Ls=(e,t)=>Bs(e,t)&&Ns(t),Hs=(e,t)=>Bs(e,t)&&!Ns(t),Is=(e,t)=>1===t.type&&Rs(e,t.name)&&h(t.attr(ks)),Ps=St().browser,Fs=e=>ee(e,Gt),zs=(e,t)=>e.children&&j(e.children,t),Vs=(e,t,o)=>{let n=0,r=0;const s=e.ownerDocument;if(o=o||e,t){if(o===e&&t.getBoundingClientRect&&"static"===dn(yo.fromDom(e),"position")){const o=t.getBoundingClientRect();return n=o.left+(s.documentElement.scrollLeft||e.scrollLeft)-s.documentElement.clientLeft,r=o.top+(s.documentElement.scrollTop||e.scrollTop)-s.documentElement.clientTop,{x:n,y:r}}let a=t;for(;a&&a!==o&&a.nodeType&&!zs(a,o);){const e=a;n+=e.offsetLeft||0,r+=e.offsetTop||0,a=e.offsetParent}for(a=t.parentNode;a&&a!==o&&a.nodeType&&!zs(a,o);)n-=a.scrollLeft||0,r-=a.scrollTop||0,a=a.parentNode;r+=(e=>Ps.isFirefox()&&"table"===jt(e)?Fs(Lo(e)).filter((e=>"caption"===jt(e))).bind((e=>Fs(Bo(e)).map((t=>{const o=t.dom.offsetTop,n=e.dom.offsetTop,r=e.dom.offsetHeight;return o<=n?-r:0})))).getOr(0):0)(yo.fromDom(t))}return{x:n,y:r}},Zs=(e,t={})=>{let o=0;const n={},r=yo.fromDom(e),s=Eo(r),a=e=>{bn(jo(r),e)},i=e=>{const t=jo(r);tn(t,"#"+e).each(Cn)},l=e=>ke(n,e).getOrThunk((()=>({id:"mce-u"+o++,passed:[],failed:[],count:0}))),c=e=>new Promise(((o,r)=>{let i;const c=Bt._addCacheSuffix(e),d=l(c);n[c]=d,d.count++;const m=(e,t)=>{q(e,H),d.status=t,d.passed=[],d.failed=[],i&&(i.onload=null,i.onerror=null,i=null)},u=()=>m(d.passed,2),g=()=>m(d.failed,3);if(o&&d.passed.push(o),r&&d.failed.push(r),1===d.status)return;if(2===d.status)return void u();if(3===d.status)return void g();d.status=1;const h=yo.fromTag("link",s.dom);to(h,{rel:"stylesheet",type:"text/css",id:d.id}),t.contentCssCors&&eo(h,"crossOrigin","anonymous"),t.referrerPolicy&&eo(h,"referrerpolicy",t.referrerPolicy),i=h.dom,i.onload=u,i.onerror=g,a(h),eo(h,"href",c)})),d=e=>{const t=Bt._addCacheSuffix(e);ke(n,t).each((e=>{0==--e.count&&(delete n[t],i(e.id))}))};return{load:c,loadRawCss:(e,t)=>{const o=l(e);n[e]=o,o.count++;const r=yo.fromTag("style",s.dom);to(r,{rel:"stylesheet",type:"text/css",id:o.id}),r.dom.innerHTML=t,a(r)},loadAll:e=>Promise.allSettled($(e,(e=>c(e).then(D(e))))).then((e=>{const t=K(e,(e=>"fulfilled"===e.status));return t.fail.length>0?Promise.reject($(t.fail,(e=>e.reason))):$(t.pass,(e=>e.value))})),unload:d,unloadRawCss:e=>{ke(n,e).each((t=>{0==--t.count&&(delete n[e],i(t.id))}))},unloadAll:e=>{q(e,(e=>{d(e)}))},_setReferrerPolicy:e=>{t.referrerPolicy=e},_setContentCssCors:e=>{t.contentCssCors=e}}},Us=(()=>{const e=new WeakMap;return{forElement:(t,o)=>{const n=Uo(t).dom;return F.from(e.get(n)).getOrThunk((()=>{const t=Zs(n,o);return e.set(n,t),t}))}}})(),js=(e,t,o)=>C(e)&&(us(e,t)||o.isInline(e.nodeName.toLowerCase())),Ws=e=>(e=>"span"===e.nodeName.toLowerCase())(e)&&"bookmark"===e.getAttribute("data-mce-type"),$s=(e,t,o)=>tr(e)&&e.data.length>0&&((e,t,o)=>{const n=new Zn(e,t).prev(!1),r=new Zn(e,t).next(!1),s=w(n)||js(n,t,o),a=w(r)||js(r,t,o);return s&&a})(e,t,o),qs=(e,t,o,n)=>{var r;const s=n||t;if(Wn(t)&&Ws(t))return t;const a=t.childNodes;for(let t=a.length-1;t>=0;t--)qs(e,a[t],o,s);if(Wn(t)){const e=t.childNodes;1===e.length&&Ws(e[0])&&(null===(r=t.parentNode)||void 0===r||r.insertBefore(e[0],t))}return(e=>ar(e)||sr(e))(t)||us(t,s)||(e=>!!Wn(e)&&e.childNodes.length>0)(t)||$s(t,s,o)||e.remove(t),t},Gs=Bt.makeMap,Ks=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ys=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Xs=/[<>&\"\']/g,Js=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,Qs={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"},ea={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},ta={"<":"<",">":">","&":"&",""":'"',"'":"'"},oa=(e,t)=>{const o={};if(e){const n=e.split(",");t=t||10;for(let e=0;ee.replace(t?Ks:Ys,(e=>ea[e]||e)),sa=(e,t)=>e.replace(t?Ks:Ys,(e=>e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":ea[e]||"&#"+e.charCodeAt(0)+";")),aa=(e,t,o)=>{const n=o||na;return e.replace(t?Ks:Ys,(e=>ea[e]||n[e]||e))},ia={encodeRaw:ra,encodeAllRaw:e=>(""+e).replace(Xs,(e=>ea[e]||e)),encodeNumeric:sa,encodeNamed:aa,getEncodeFunc:(e,t)=>{const o=oa(t)||na,n=(e,t)=>e.replace(t?Ks:Ys,(e=>void 0!==ea[e]?ea[e]:void 0!==o[e]?o[e]:e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":"&#"+e.charCodeAt(0)+";")),r=(e,t)=>aa(e,t,o),s=Gs(e.replace(/\+/g,","));return s.named&&s.numeric?n:s.named?t?r:aa:s.numeric?sa:ra},decode:e=>e.replace(Js,((e,t)=>t?(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10))>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):Qs[t]||String.fromCharCode(t):ta[e]||na[e]||(e=>{const t=yo.fromTag("div").dom;return t.innerHTML=e,t.textContent||t.innerText||e})(e)))},la=(e,t)=>(e=Bt.trim(e))?e.split(t||" "):[],ca=e=>new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$"),da=(e,t)=>{const o=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)])?$/;return ne(la(t,","),(t=>{const n=o.exec(t);if(n){const t=n[1],o=n[2],r=n[3],s=n[4],a=n[5],i={attributes:{},attributesOrder:[]};if(e.each((e=>((e,t)=>{fe(e.attributes,((e,o)=>{t.attributes[o]=e})),t.attributesOrder.push(...e.attributesOrder)})(e,i))),"#"===t?i.paddEmpty=!0:"-"===t&&(i.removeEmpty=!0),"!"===s&&(i.removeEmptyAttrs=!0),a&&((e,t)=>{const o=/^([!\-])?(\w+[\\:]:\w+|[^=~<]+)?(?:([=~<])(.*))?$/,n=/[*?+]/,{attributes:r,attributesOrder:s}=t;q(la(e,"|"),(e=>{const a=o.exec(e);if(a){const e={},o=a[1],i=a[2].replace(/[\\:]:/g,":"),l=a[3],c=a[4];if("!"===o&&(t.attributesRequired=t.attributesRequired||[],t.attributesRequired.push(i),e.required=!0),"-"===o)return delete r[i],void s.splice(Bt.inArray(s,i),1);if(l&&("="===l?(t.attributesDefault=t.attributesDefault||[],t.attributesDefault.push({name:i,value:c}),e.defaultValue=c):"~"===l?(t.attributesForced=t.attributesForced||[],t.attributesForced.push({name:i,value:c}),e.forcedValue=c):"<"===l&&(e.validValues=Bt.makeMap(c,"?"))),n.test(i)){const o=e;t.attributePatterns=t.attributePatterns||[],o.pattern=ca(i),t.attributePatterns.push(o)}else r[i]||s.push(i),r[i]=e}}))})(a,i),r&&(i.outputName=o),"@"===o){if(!e.isNone())return[];e=F.some(i)}return[r?{name:o,element:i,aliasName:r}:{name:o,element:i}]}return[]}))},ma={},ua=Bt.makeMap,ga=Bt.each,ha=Bt.extend,pa=Bt.explode,fa=(e,t={})=>{const o=ua(e," ",ua(e.toUpperCase()," "));return ha(o,t)},va=e=>fa("td th li dt dd figcaption caption details summary",e.getTextBlockElements()),ba=(e,t)=>{if(e){const o={};return h(e)&&(e={"*":e}),ga(e,((e,n)=>{o[n]=o[n.toUpperCase()]="map"===t?ua(e,/[, ]/):pa(e,/[, ]/)})),o}},ya=(e={})=>{var t;const o={},n={};let r=[];const s={},a={},i=(t,o,n)=>{const r=e[t];if(r)return ua(r,/[, ]/,ua(r.toUpperCase(),/[, ]/));{let e=ma[t];return e||(e=fa(o,n),ma[t]=e),e}},l=null!==(t=e.schema)&&void 0!==t?t:"html5",c=(e=>{const{globalAttributes:t,phrasingContent:o,flowContent:n}=(e=>{let t,o,n;t="id accesskey class dir lang style tabindex title role",o="address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul",n="a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment","html4"!==e&&(t+=" contenteditable contextmenu draggable dropzone hidden spellcheck translate",o+=" article aside details dialog figure main header footer hgroup section nav a ins del canvas map",n+=" audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen svg"),"html5-strict"!==e&&(t+=" xml:lang",n=[n,"acronym applet basefont big font strike tt"].join(" "),o=[o,"center dir isindex noframes"].join(" "));const r=[o,n].join(" ");return{globalAttributes:t,blockContent:o,phrasingContent:n,flowContent:r}})(e),r={},s=(e,t,o)=>{r[e]={attributes:ie(t,D({})),attributesOrder:t,children:ie(o,D({}))}},a=(e,o="",n="")=>{const r=la(n),a=la(e);let i=a.length;const l=la([t,o].join(" "));for(;i--;)s(a[i],l.slice(),r)},i=(e,t)=>{const o=la(e),n=la(t);let s=o.length;for(;s--;){const e=r[o[s]];for(let t=0,o=n.length;t{a(e,"",o)})),q(la("center dir isindex noframes"),(e=>{a(e,"",n)}))),a("html","manifest","head body"),a("head","","base command link meta noscript script style title"),a("title hr noscript br"),a("base","href target"),a("link","href rel media hreflang type sizes hreflang"),a("meta","name http-equiv content charset"),a("style","media type scoped"),a("script","src async defer type charset"),a("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",n),a("dd div","",n),a("address dt caption","","html4"===e?o:n),a("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",o),a("blockquote","cite",n),a("ol","reversed start type","li"),a("ul","","li"),a("li","value",n),a("dl","","dt dd"),a("a","href target rel media hreflang type","html4"===e?o:n),a("q","cite",o),a("ins del","cite datetime",n),a("img","src sizes srcset alt usemap ismap width height"),a("iframe","src name width height",n),a("embed","src type width height"),a("object","data type typemustmatch name usemap form width height",[n,"param"].join(" ")),a("param","name value"),a("map","name",[n,"area"].join(" ")),a("area","alt coords shape href target rel media hreflang type"),a("table","border","caption colgroup thead tfoot tbody tr"+("html4"===e?" col":"")),a("colgroup","span","col"),a("col","span"),a("tbody thead tfoot","","tr"),a("tr","","td th"),a("td","colspan rowspan headers",n),a("th","colspan rowspan headers scope abbr",n),a("form","accept-charset action autocomplete enctype method name novalidate target",n),a("fieldset","disabled form name",[n,"legend"].join(" ")),a("label","form for",o),a("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),a("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"===e?n:o),a("select","disabled form multiple name required size","option optgroup"),a("optgroup","disabled label","option"),a("option","disabled label selected value"),a("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),a("menu","type label",[n,"li"].join(" ")),a("noscript","",n),"html4"!==e&&(a("wbr"),a("ruby","",[o,"rt rp"].join(" ")),a("figcaption","",n),a("mark rt rp bdi","",o),a("summary","",[o,"h1 h2 h3 h4 h5 h6"].join(" ")),a("canvas","width height",n),a("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",[n,"track source"].join(" ")),a("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",[n,"track source"].join(" ")),a("picture","","img source"),a("source","src srcset type media sizes"),a("track","kind src srclang label default"),a("datalist","",[o,"option"].join(" ")),a("article section nav aside main header footer","",n),a("hgroup","","h1 h2 h3 h4 h5 h6"),a("figure","",[n,"figcaption"].join(" ")),a("time","datetime",o),a("dialog","open",n),a("command","type label icon disabled checked radiogroup command"),a("output","for form name",o),a("progress","value max",o),a("meter","value min max low high optimum",o),a("details","open",[n,"summary"].join(" ")),a("keygen","autofocus challenge disabled form keytype name"),s("svg","id tabindex lang xml:space class style x y width height viewBox preserveAspectRatio zoomAndPan transform".split(" "),[])),"html5-strict"!==e&&(i("script","language xml:space"),i("style","xml:space"),i("object","declare classid code codebase codetype archive standby align border hspace vspace"),i("embed","align name hspace vspace"),i("param","valuetype type"),i("a","charset name rev shape coords"),i("br","clear"),i("applet","codebase archive code object alt name width height align hspace vspace"),i("img","name longdesc align border hspace vspace"),i("iframe","longdesc frameborder marginwidth marginheight scrolling align"),i("font basefont","size color face"),i("input","usemap align"),i("select"),i("textarea"),i("h1 h2 h3 h4 h5 h6 div p legend caption","align"),i("ul","type compact"),i("li","type"),i("ol dl menu dir","compact"),i("pre","width xml:space"),i("hr","align noshade size width"),i("isindex","prompt"),i("table","summary width frame rules cellspacing cellpadding align bgcolor"),i("col","width align char charoff valign"),i("colgroup","width align char charoff valign"),i("thead","align char charoff valign"),i("tr","align char charoff valign bgcolor"),i("th","axis align char charoff valign nowrap bgcolor width height"),i("form","accept"),i("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),i("tfoot","align char charoff valign"),i("tbody","align char charoff valign"),i("area","nohref"),i("body","background bgcolor text link vlink alink")),"html4"!==e&&(i("input button select textarea","autofocus"),i("input textarea","placeholder"),i("a","download"),i("link script img","crossorigin"),i("img","loading"),i("iframe","sandbox seamless allow allowfullscreen loading")),"html4"!==e&&q([r.video,r.audio],(e=>{delete e.children.audio,delete e.children.video})),q(la("a form meter progress dfn"),(e=>{r[e]&&delete r[e].children[e]})),delete r.caption.children.table,delete r.script,r})(l);!1===e.verify_html&&(e.valid_elements="*[*]");const d=ba(e.valid_styles),m=ba(e.invalid_styles,"map"),u=ba(e.valid_classes,"map"),g=i("whitespace_elements","pre script noscript style textarea video audio iframe object code"),h=i("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),p=i("void_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),f=i("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls allowfullscreen"),v="td th iframe video audio object script code",b=i("non_empty_elements",v+" pre svg",p),y=i("move_caret_before_on_enter_elements",v+" table",p),w="h1 h2 h3 h4 h5 h6",x=i("text_block_elements",w+" p div address pre form blockquote center dir fieldset header footer article section hgroup aside main nav figure"),C=i("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption details summary html body multicol listing",x),S=i("text_inline_elements","span strong b em i font s strike u var cite dfn code mark q sup sub samp"),k=i("transparent_elements","a ins del canvas map"),_=i("wrap_block_elements","pre "+w);ga("script noscript iframe noframes noembed title style textarea xmp plaintext".split(" "),(e=>{a[e]=new RegExp("]*>","gi")}));const E=e=>{const t=F.from(o["@"]),n=/[*?+]/;q(da(t,null!=e?e:""),(({name:e,element:t,aliasName:s})=>{if(s&&(o[s]=t),n.test(e)){const o=t;o.pattern=ca(e),r.push(o)}else o[e]=t}))},T=e=>{r=[],q(he(o),(e=>{delete o[e]})),E(e)},O=e=>{delete ma.text_block_elements,delete ma.block_elements,q((e=>{const t=/^(~)?(.+)$/;return ne(la(e,","),(e=>{const o=t.exec(e);if(o){const e="~"===o[1];return[{inline:e,cloneName:e?"span":"div",name:o[2]}]}return[]}))})(null!=e?e:""),(({inline:e,name:t,cloneName:r})=>{if(n[t]=n[r],s[t]=r,b[t.toUpperCase()]={},b[t]={},e||(C[t.toUpperCase()]={},C[t]={}),!o[t]){let e=o[r];e=ha({},e),delete e.removeEmptyAttrs,delete e.removeEmpty,o[t]=e}fe(n,((e,o)=>{e[r]&&(n[o]=e=ha({},n[o]),e[t]=e[r])}))}))},A=e=>{q((e=>{const t=/^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;return ne(la(e,","),(e=>{const o=t.exec(e);if(o){const e=o[1],t=e?(e=>"-"===e?"remove":"add")(e):"replace";return[{operation:t,name:o[2],validChildren:la(o[3],"|")}]}return[]}))})(null!=e?e:""),(({operation:e,name:t,validChildren:o})=>{const r="replace"===e?{"#comment":{}}:n[t];q(o,(t=>{"remove"===e?delete r[t]:r[t]={}})),n[t]=r}))},M=e=>{const t=o[e];if(t)return t;let n=r.length;for(;n--;){const t=r[n];if(t.pattern.test(e))return t}};e.valid_elements?(T(e.valid_elements),ga(c,((e,t)=>{n[t]=e.children}))):(ga(c,((e,t)=>{o[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},n[t]=e.children})),ga(la("strong/b em/i"),(e=>{const t=la(e,"/");o[t[1]].outputName=t[0]})),ga(S,((t,n)=>{o[n]&&(e.padd_empty_block_inline_children&&(o[n].paddInEmptyBlock=!0),o[n].removeEmpty=!0)})),ga(la("ol ul blockquote a table tbody"),(e=>{o[e]&&(o[e].removeEmpty=!0)})),ga(la("p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary"),(e=>{o[e]&&(o[e].paddEmpty=!0)})),ga(la("span"),(e=>{o[e].removeEmptyAttrs=!0}))),delete o.svg,O(e.custom_elements),A(e.valid_children),E(e.extended_valid_elements),A("+ol[ul|ol],+ul[ul|ol]"),ga({dd:"dl",dt:"dl",li:"ul ol",td:"tr",th:"tr",tr:"tbody thead tfoot",tbody:"table",thead:"table",tfoot:"table",legend:"fieldset",area:"map",param:"video audio object"},((e,t)=>{o[t]&&(o[t].parentsRequired=la(e))})),e.invalid_elements&&ga(pa(e.invalid_elements),(e=>{o[e]&&delete o[e]})),M("span")||E("span[!data-mce-type|*]");const N=D(d),R=D(m),B=D(u),L=D(f),H=D(C),I=D(x),P=D(S),z=D(Object.seal(p)),V=D(h),Z=D(b),U=D(y),j=D(g),W=D(k),$=D(_),G=D(Object.seal(a)),K=(e,t)=>{const o=M(e);if(o){if(!t)return!0;{if(o.attributes[t])return!0;const e=o.attributePatterns;if(e){let o=e.length;for(;o--;)if(e[o].pattern.test(t))return!0}}}return!1},Y=e=>_e(H(),e),X=e=>!je(e,"#")&&K(e)&&!Y(e),J=D(s);return{type:l,children:n,elements:o,getValidStyles:N,getValidClasses:B,getBlockElements:H,getInvalidStyles:R,getVoidElements:z,getTextBlockElements:I,getTextInlineElements:P,getBoolAttrs:L,getElementRule:M,getSelfClosingElements:V,getNonEmptyElements:Z,getMoveCaretBeforeOnEnterElements:U,getWhitespaceElements:j,getTransparentElements:W,getSpecialElements:G,isValidChild:(e,t)=>{const o=n[e.toLowerCase()];return!(!o||!o[t.toLowerCase()])},isValid:K,isBlock:Y,isInline:X,isWrapper:e=>_e($(),e)||X(e),getCustomElements:J,addValidElements:E,setValidElements:T,addCustomElements:O,addValidChildren:A}},wa=e=>Ze(e,"#").toUpperCase(),xa=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Ca=e=>(e=>({value:wa(e)}))(xa(e.red)+xa(e.green)+xa(e.blue)),Sa=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,ka=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,_a=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),Ea=(e,t,o,n)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(o,10),i=parseFloat(n);return _a(r,s,a,i)},Ta=e=>{if("transparent"===e)return F.some(_a(0,0,0,0));const t=Sa.exec(e);if(null!==t)return F.some(Ea(t[1],t[2],t[3],"1"));const o=ka.exec(e);return null!==o?F.some(Ea(o[1],o[2],o[3],o[4])):F.none()},Oa=e=>`rgba(${e.red},${e.green},${e.blue},${e.alpha})`,Da=e=>Ta(e).map(Ca).map((e=>"#"+e.value)).getOr(e),Aa=(e={},t)=>{const o=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,n=/\s*([^:]+):\s*([^;]+);?/g,r=/\s+$/,s={};let a,i;const l=vr;t&&(a=t.getValidStyles(),i=t.getInvalidStyles());const c="\\\" \\' \\; \\: ; : \ufeff".split(" ");for(let e=0;e{const a={};let i=!1;const c=e.url_converter,m=e.url_converter_scope||d,u=(e,t,o)=>{const n=a[e+"-top"+t];if(!n)return;const r=a[e+"-right"+t];if(!r)return;const s=a[e+"-bottom"+t];if(!s)return;const i=a[e+"-left"+t];if(!i)return;const l=[n,r,s,i];let c=l.length-1;for(;c--&&l[c]===l[c+1];);c>-1&&o||(a[e+t]=-1===c?l[0]:l.join(" "),delete a[e+"-top"+t],delete a[e+"-right"+t],delete a[e+"-bottom"+t],delete a[e+"-left"+t])},g=e=>{const t=a[e];if(!t)return;const o=t.indexOf(",")>-1?[t]:t.split(" ");let n=o.length;for(;n--;)if(o[n]!==o[0])return!1;return a[e]=o[0],!0},p=e=>(i=!0,s[e]),f=(e,t)=>(i&&(e=e.replace(/\uFEFF[0-9]/g,(e=>s[e]))),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e),v=e=>String.fromCharCode(parseInt(e.slice(1),16)),b=e=>e.replace(/\\[0-9a-f]+/gi,v),y=(t,o,n,r,s,a)=>{if(s=s||a)return"'"+(s=f(s)).replace(/\'/g,"\\'")+"'";if(o=f(o||n||r||""),!e.allow_script_urls){const t=o.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(t))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(t))return""}return c&&(o=c.call(m,o,"style")),"url('"+o.replace(/\'/g,"\\'")+"')"};if(t){let s;for(t=(t=t.replace(/[\u0000-\u001F]/g,"")).replace(/\\[\"\';:\uFEFF]/g,p).replace(/\"[^\"]+\"|\'[^\']+\'/g,(e=>e.replace(/[;:]/g,p)));s=n.exec(t);){n.lastIndex=s.index+s[0].length;let t=s[1].replace(r,"").toLowerCase(),c=s[2].replace(r,"");if(t&&c){if(t=b(t),c=b(c),-1!==t.indexOf(l)||-1!==t.indexOf('"'))continue;if(!e.allow_script_urls&&("behavior"===t||/expression\s*\(|\/\*|\*\//.test(c)))continue;"font-weight"===t&&"700"===c?c="bold":"color"!==t&&"background-color"!==t||(c=c.toLowerCase()),h(e.force_hex_color)&&"off"!==e.force_hex_color&&Ta(c).each((t=>{"always"!==e.force_hex_color&&1!==t.alpha||(c=Da(Oa(t)))})),c=c.replace(o,y),a[t]=i?f(c,!0):c}}u("border","",!0),u("border","-width"),u("border","-color"),u("border","-style"),u("padding",""),u("margin",""),w="border",C="border-style",S="border-color",g(x="border-width")&&g(C)&&g(S)&&(a[w]=a[x]+" "+a[C]+" "+a[S],delete a[x],delete a[C],delete a[S]),"medium none"===a.border&&delete a.border,"none"===a["border-image"]&&delete a["border-image"]}var w,x,C,S;return a},serialize:(e,t)=>{let o="";const n=(t,n)=>{const r=n[t];if(r)for(let t=0,n=r.length;t0?" ":"")+n+": "+s+";")}};return t&&a?(n("*",a),n(t,a)):fe(e,((e,n)=>{e&&((e,t)=>{if(!i||!t)return!0;let o=i["*"];return!(o&&o[e]||(o=i[t],o&&o[e]))})(n,t)&&(o+=(o.length>0?" ":"")+n+": "+e+";")})),o}};return d},Ma={keyLocation:!0,layerX:!0,layerY:!0,returnValue:!0,webkitMovementX:!0,webkitMovementY:!0,keyIdentifier:!0,mozPressure:!0},Na=e=>x(e.preventDefault)||(e=>e instanceof Event||S(e.initEvent))(e),Ra=(e,t)=>{const o=null!=t?t:{};for(const t in e)_e(Ma,t)||(o[t]=e[t]);return C(e.composedPath)&&(o.composedPath=()=>e.composedPath()),C(e.getModifierState)&&(o.getModifierState=t=>e.getModifierState(t)),C(e.getTargetRanges)&&(o.getTargetRanges=()=>e.getTargetRanges()),o},Ba=(e,t,o,n)=>{var r;const s=Ra(t,n);return s.type=e,x(s.target)&&(s.target=null!==(r=s.srcElement)&&void 0!==r?r:o),Na(t)&&(s.preventDefault=()=>{s.defaultPrevented=!0,s.isDefaultPrevented=P,S(t.preventDefault)&&t.preventDefault()},s.stopPropagation=()=>{s.cancelBubble=!0,s.isPropagationStopped=P,S(t.stopPropagation)&&t.stopPropagation()},s.stopImmediatePropagation=()=>{s.isImmediatePropagationStopped=P,s.stopPropagation()},(e=>e.isDefaultPrevented===P||e.isDefaultPrevented===I)(s)||(s.isDefaultPrevented=!0===s.defaultPrevented?P:I,s.isPropagationStopped=!0===s.cancelBubble?P:I,s.isImmediatePropagationStopped=I)),s},La=/^(?:mouse|contextmenu)|click/,Ha=(e,t,o,n)=>{e.addEventListener(t,o,n||!1)},Ia=(e,t,o,n)=>{e.removeEventListener(t,o,n||!1)},Pa=(e,t)=>{const o=Ba(e.type,e,document,t);if((e=>C(e)&&La.test(e.type))(e)&&w(e.pageX)&&!w(e.clientX)){const t=o.target.ownerDocument||document,n=t.documentElement,r=t.body,s=o;s.pageX=e.clientX+(n&&n.scrollLeft||r&&r.scrollLeft||0)-(n&&n.clientLeft||r&&r.clientLeft||0),s.pageY=e.clientY+(n&&n.scrollTop||r&&r.scrollTop||0)-(n&&n.clientTop||r&&r.clientTop||0)}return o},Fa=(e,t,o)=>{const n=e.document,r={type:"ready"};if(o.domLoaded)return void t(r);const s=()=>{Ia(e,"DOMContentLoaded",s),Ia(e,"load",s),o.domLoaded||(o.domLoaded=!0,t(r)),e=null};"complete"===n.readyState||"interactive"===n.readyState&&n.body?s():Ha(e,"DOMContentLoaded",s),o.domLoaded||Ha(e,"load",s)};class za{constructor(){this.domLoaded=!1,this.events={},this.count=1,this.expando="mce-data-"+(+new Date).toString(32),this.hasFocusIn="onfocusin"in document.documentElement,this.count=1}bind(e,t,o,n){const r=this;let s;const a=window,i=e=>{r.executeHandlers(Pa(e||a.event),l)};if(!e||tr(e)||rr(e))return o;let l;e[r.expando]?l=e[r.expando]:(l=r.count++,e[r.expando]=l,r.events[l]={}),n=n||e;const c=t.split(" ");let d=c.length;for(;d--;){let t=c[d],m=i,u=!1,g=!1;"DOMContentLoaded"===t&&(t="ready"),r.domLoaded&&"ready"===t&&"complete"===e.readyState?o.call(n,Pa({type:t})):(r.hasFocusIn||"focusin"!==t&&"focusout"!==t||(u=!0,g="focusin"===t?"focus":"blur",m=e=>{const t=Pa(e||a.event);t.type="focus"===t.type?"focusin":"focusout",r.executeHandlers(t,l)}),s=r.events[l][t],s?"ready"===t&&r.domLoaded?o(Pa({type:t})):s.push({func:o,scope:n}):(r.events[l][t]=s=[{func:o,scope:n}],s.fakeName=g,s.capture=u,s.nativeHandler=m,"ready"===t?Fa(e,m,r):Ha(e,g||t,m,u)))}return e=s=null,o}unbind(e,t,o){if(!e||tr(e)||rr(e))return this;const n=e[this.expando];if(n){let r=this.events[n];if(t){const n=t.split(" ");let s=n.length;for(;s--;){const t=n[s],a=r[t];if(a){if(o){let e=a.length;for(;e--;)if(a[e].func===o){const o=a.nativeHandler,n=a.fakeName,s=a.capture,i=a.slice(0,e).concat(a.slice(e+1));i.nativeHandler=o,i.fakeName=n,i.capture=s,r[t]=i}}o&&0!==a.length||(delete r[t],Ia(e,a.fakeName||t,a.nativeHandler,a.capture))}}}else fe(r,((t,o)=>{Ia(e,t.fakeName||o,t.nativeHandler,t.capture)})),r={};for(const e in r)if(_e(r,e))return this;delete this.events[n];try{delete e[this.expando]}catch(t){e[this.expando]=null}}return this}fire(e,t,o){return this.dispatch(e,t,o)}dispatch(e,t,o){if(!e||tr(e)||rr(e))return this;const n=Pa({type:t,target:e},o);do{const t=e[this.expando];t&&this.executeHandlers(n,t),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow}while(e&&!n.isPropagationStopped());return this}clean(e){if(!e||tr(e)||rr(e))return this;if(e[this.expando]&&this.unbind(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName){this.unbind(e);const t=e.getElementsByTagName("*");let o=t.length;for(;o--;)(e=t[o])[this.expando]&&this.unbind(e)}return this}destroy(){this.events={}}cancel(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}executeHandlers(e,t){const o=this.events[t],n=o&&o[e.type];if(n)for(let t=0,o=n.length;t{x(o)||""===o?so(e,t):eo(e,t,o)},$a=e=>e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),qa=(e,t)=>{let o=0;if(e)for(let n=e.nodeType,r=e.previousSibling;r;r=r.previousSibling){const e=r.nodeType;(!t||!tr(r)||e!==n&&r.data.length)&&(o++,n=e)}return o},Ga=(e,t)=>{const o=oo(t,"style"),n=e.serialize(e.parse(o),jt(t));Wa(t,Ua,n)},Ka=(e,t,o)=>{const n=$a(t);x(o)||""===o?hn(e,n):ln(e,n,((e,t)=>k(e)?_e(ja,t)?e+"":e+"px":e)(o,n))},Ya=(e,t={})=>{const o={},n=window,r={};let s=0;const a=Us.forElement(yo.fromDom(e),{contentCssCors:t.contentCssCors,referrerPolicy:t.referrerPolicy}),i=[],l=t.schema?t.schema:ya({}),c=Aa({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope,force_hex_color:t.force_hex_color},t.schema),d=t.ownEvents?new za:za.Event,m=l.getBlockElements(),u=t=>t&&e&&h(t)?e.getElementById(t):t,g=e=>{const t=u(e);return C(t)?yo.fromDom(t):null},p=(e,t,o="")=>{let n;const r=g(e);if(C(r)&&Gt(r)){const e=G[t];n=e&&e.get?e.get(r.dom,t):oo(r,t)}return C(n)?n:o},f=e=>{const t=u(e);return x(t)?[]:t.attributes},b=(e,o,n)=>{M(e,(e=>{if(Wn(e)){const r=yo.fromDom(e),s=""===n?null:n,a=oo(r,o),i=G[o];i&&i.set?i.set(r.dom,s,o):Wa(r,o,s),a!==s&&t.onSetAttrib&&t.onSetAttrib({attrElm:r.dom,attrName:o,attrValue:s})}}))},y=()=>t.root_element||e.body,w=(t,o)=>Vs(e.body,u(t),o),k=(e,t,o)=>{const n=u(e);var r;if(!x(n)&&($n(n)||Wn(r=n)&&"http://www.w3.org/2000/svg"===r.namespaceURI))return o?dn(yo.fromDom(n),$a(t)):("float"===(t=t.replace(/-(\D)/g,((e,t)=>t.toUpperCase())))&&(t="cssFloat"),n.style?n.style[t]:void 0)},_=e=>{const t=u(e);if(!t)return{w:0,h:0};let o=k(t,"width"),n=k(t,"height");return o&&-1!==o.indexOf("px")||(o="0"),n&&-1!==n.indexOf("px")||(n="0"),{w:parseInt(o,10)||t.offsetWidth||t.clientWidth,h:parseInt(n,10)||t.offsetHeight||t.clientHeight}},T=(e,t)=>{if(!e)return!1;const o=v(e)?e:[e];return W(o,(e=>xo(yo.fromDom(e),t)))},O=(e,t,o,n)=>{const r=[];let s=u(e);n=void 0===n;const a=o||("BODY"!==y().nodeName?y().parentNode:null);if(h(t))if("*"===t)t=Wn;else{const e=t;t=t=>T(t,e)}for(;s&&!(s===a||x(s.nodeType)||sr(s)||ar(s));){if(!t||t(s)){if(!n)return[s];r.push(s)}s=s.parentNode}return n?r:null},A=(e,t,o)=>{let n=t;if(e){h(t)&&(n=e=>T(e,t));for(let t=e[o];t;t=t[o])if(S(n)&&n(t))return t}return null},M=function(e,t,o){const n=null!=o?o:this;if(v(e)){const o=[];return Va(e,((e,r)=>{const s=u(e);s&&o.push(t.call(n,s,r))})),o}{const o=u(e);return!!o&&t.call(n,o)}},N=(e,t)=>{M(e,(e=>{fe(t,((t,o)=>{b(e,o,t)}))}))},R=(e,t)=>{M(e,(e=>{const o=yo.fromDom(e);En(o,t)}))},B=(t,o,n,r,s)=>M(t,(t=>{const a=h(o)?e.createElement(o):o;return C(n)&&N(a,n),r&&(!h(r)&&r.nodeType?a.appendChild(r):h(r)&&R(a,r)),s?a:t.appendChild(a)})),L=(t,o,n)=>B(e.createElement(t),t,o,n,!0),H=ia.encodeAllRaw,I=(e,t)=>M(e,(e=>{const o=yo.fromDom(e);return t&&q(Lo(o),(e=>{Kt(e)&&0===e.dom.length?Cn(e):pn(o,e)})),Cn(o),o.dom})),P=(e,t,o)=>{M(e,(e=>{if(Wn(e)){const n=yo.fromDom(e),r=t.split(" ");q(r,(e=>{C(o)?(o?go:po)(n,e):fo(n,e)}))}}))},F=(e,t,o)=>M(t,(n=>{var r;const s=v(t)?e.cloneNode(!0):e;return o&&Va(Za(n.childNodes),(e=>{s.appendChild(e)})),null===(r=n.parentNode)||void 0===r||r.replaceChild(s,n),n})),z=e=>{if(Wn(e)){const t="a"===e.nodeName.toLowerCase()&&!p(e,"href")&&p(e,"id");if(p(e,"name")||p(e,"data-mce-bookmark")||t)return!0}return!1},V=()=>e.createRange(),Z=(o,r,s,a)=>{if(v(o)){let e=o.length;const t=[];for(;e--;)t[e]=Z(o[e],r,s,a);return t}return!t.collect||o!==e&&o!==n||i.push([o,r,s,a]),d.bind(o,r,s,a||$)},U=(t,o,r)=>{if(v(t)){let e=t.length;const n=[];for(;e--;)n[e]=U(t[e],o,r);return n}if(i.length>0&&(t===e||t===n)){let e=i.length;for(;e--;){const[n,s,a]=i[e];t!==n||o&&o!==s||r&&r!==a||d.unbind(n,s,a)}}return d.unbind(t,o,r)},j=e=>{if(e&&$n(e)){const t=e.getAttribute("data-mce-contenteditable");return t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null}return null},$={doc:e,settings:t,win:n,files:r,stdMode:!0,boxModel:!0,styleSheetLoader:a,boundEvents:i,styles:c,schema:l,events:d,isBlock:e=>h(e)?_e(m,e):Wn(e)&&(_e(m,e.nodeName)||Ls(l,e)),root:null,clone:(e,t)=>e.cloneNode(t),getRoot:y,getViewPort:e=>{const t=Pn(e);return{x:t.x,y:t.y,w:t.width,h:t.height}},getRect:e=>{const t=u(e),o=w(t),n=_(t);return{x:o.x,y:o.y,w:n.w,h:n.h}},getSize:_,getParent:(e,t,o)=>{const n=O(e,t,o,!1);return n&&n.length>0?n[0]:null},getParents:O,get:u,getNext:(e,t)=>A(e,t,"nextSibling"),getPrev:(e,t)=>A(e,t,"previousSibling"),select:(o,n)=>{var r,s;const a=null!==(s=null!==(r=u(n))&&void 0!==r?r:t.root_element)&&void 0!==s?s:e;return S(a.querySelectorAll)?ue(a.querySelectorAll(o)):[]},is:T,add:B,create:L,createHTML:(e,t,o="")=>{let n="<"+e;for(const e in t)Ee(t,e)&&(n+=" "+e+'="'+H(t[e])+'"');return Xe(o)&&_e(l.getVoidElements(),e)?n+" />":n+">"+o+""},createFragment:t=>{const o=e.createElement("div"),n=e.createDocumentFragment();let r;for(n.appendChild(o),t&&(o.innerHTML=t);r=o.firstChild;)n.appendChild(r);return n.removeChild(o),n},remove:I,setStyle:(e,o,n)=>{M(e,(e=>{const r=yo.fromDom(e);Ka(r,o,n),t.update_styles&&Ga(c,r)}))},getStyle:k,setStyles:(e,o)=>{M(e,(e=>{const n=yo.fromDom(e);fe(o,((e,t)=>{Ka(n,t,e)})),t.update_styles&&Ga(c,n)}))},removeAllAttribs:e=>M(e,(e=>{const t=e.attributes;for(let o=t.length-1;o>=0;o--)e.removeAttributeNode(t.item(o))})),setAttrib:b,setAttribs:N,getAttrib:p,getPos:w,parseStyle:e=>c.parse(e),serializeStyle:(e,t)=>c.serialize(e,t),addStyle:t=>{if($!==Ya.DOM&&e===document){if(o[t])return;o[t]=!0}let n=e.getElementById("mceDefaultStyles");if(!n){n=e.createElement("style"),n.id="mceDefaultStyles",n.type="text/css";const t=e.head;t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(e.createTextNode(t))},loadCSS:e=>{e||(e=""),q(e.split(","),(e=>{r[e]=!0,a.load(e).catch(E)}))},addClass:(e,t)=>{P(e,t,!0)},removeClass:(e,t)=>{P(e,t,!1)},hasClass:(e,t)=>{const o=g(e),n=t.split(" ");return C(o)&&re(n,(e=>vo(o,e)))},toggleClass:P,show:e=>{M(e,(e=>hn(yo.fromDom(e),"display")))},hide:e=>{M(e,(e=>ln(yo.fromDom(e),"display","none")))},isHidden:e=>{const t=g(e);return C(t)&&Lt(un(t,"display"),"none")},uniqueId:e=>(e||"mce_")+s++,setHTML:R,getOuterHTML:e=>{const t=g(e);return C(t)?Wn(t.dom)?t.dom.outerHTML:(e=>{const t=yo.fromTag("div"),o=yo.fromDom(e.dom.cloneNode(!0));return bn(t,o),_n(t)})(t):""},setOuterHTML:(e,t)=>{M(e,(e=>{Wn(e)&&(e.outerHTML=t)}))},decode:ia.decode,encode:H,insertAfter:(e,t)=>{const o=u(t);return M(e,(e=>{const t=null==o?void 0:o.parentNode,n=null==o?void 0:o.nextSibling;return t&&(n?t.insertBefore(e,n):t.appendChild(e)),e}))},replace:F,rename:(e,t)=>{if(e.nodeName!==t.toUpperCase()){const o=L(t);return Va(f(e),(t=>{b(o,t.nodeName,p(e,t.nodeName))})),F(o,e,!0),o}return e},findCommonAncestor:(e,t)=>{let o=e;for(;o;){let e=t;for(;e&&o!==e;)e=e.parentNode;if(o===e)break;o=o.parentNode}return!o&&e.ownerDocument?e.ownerDocument.documentElement:o},run:M,getAttribs:f,isEmpty:(e,t,o)=>{let n=0;if(z(e))return!1;const r=e.firstChild;if(r){const s=new Zn(r,e),a=l?l.getWhitespaceElements():{},i=t||(l?l.getNonEmptyElements():null);let c=r;do{if(Wn(c)){const e=c.getAttribute("data-mce-bogus");if(e){c=s.next("all"===e);continue}const t=c.nodeName.toLowerCase();if(i&&i[t]){if("br"===t){n++,c=s.next();continue}return!1}if(z(c))return!1}if(rr(c))return!1;if(tr(c)&&!is(c.data)&&(!(null==o?void 0:o.includeZwsp)||!ls(c.data)))return!1;if(tr(c)&&c.parentNode&&a[c.parentNode.nodeName]&&is(c.data))return!1;c=s.next()}while(c)}return n<=1},createRng:V,nodeIndex:qa,split:(e,t,o)=>{let n,r,s=V();if(e&&t&&e.parentNode&&t.parentNode){const a=e.parentNode;return s.setStart(a,qa(e)),s.setEnd(t.parentNode,qa(t)),n=s.extractContents(),s=V(),s.setStart(t.parentNode,qa(t)+1),s.setEnd(a,qa(e)+1),r=s.extractContents(),a.insertBefore(qs($,n,l),e),o?a.insertBefore(o,e):a.insertBefore(t,e),a.insertBefore(qs($,r,l),e),I(e),o||t}},bind:Z,unbind:U,fire:(e,t,o)=>d.dispatch(e,t,o),dispatch:(e,t,o)=>d.dispatch(e,t,o),getContentEditable:j,getContentEditableParent:e=>{const t=y();let o=null;for(let n=e;n&&n!==t&&(o=j(n),null===o);n=n.parentNode);return o},isEditable:e=>{if(C(e)){const t=Wn(e)?e:e.parentElement;return C(t)&&$n(t)&&nn(yo.fromDom(t))}return!1},destroy:()=>{if(i.length>0){let e=i.length;for(;e--;){const[t,o,n]=i[e];d.unbind(t,o,n)}}fe(r,((e,t)=>{a.unload(t),delete r[t]}))},isChildOf:(e,t)=>e===t||t.contains(e),dumpRng:e=>"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},G=((e,t,o)=>{const n=t.keep_values,r={set:(e,n,r)=>{const s=yo.fromDom(e);S(t.url_converter)&&C(n)&&(n=t.url_converter.call(t.url_converter_scope||o(),String(n),r,e)),Wa(s,"data-mce-"+r,n),Wa(s,r,n)},get:(e,t)=>{const o=yo.fromDom(e);return oo(o,"data-mce-"+t)||oo(o,t)}},s={style:{set:(t,o)=>{const r=yo.fromDom(t);n&&Wa(r,Ua,o),so(r,"style"),h(o)&&cn(r,e.parse(o))},get:t=>{const o=yo.fromDom(t),n=oo(o,Ua)||oo(o,"style");return e.serialize(e.parse(n),jt(o))}}};return n&&(s.href=s.src=r),s})(c,t,D($));return $};Ya.DOM=Ya(document),Ya.nodeIndex=qa;const Xa=Ya.DOM;class Ja{constructor(e={}){this.states={},this.queue=[],this.scriptLoadedCallbacks={},this.queueLoadedCallbacks=[],this.loading=!1,this.settings=e}_setReferrerPolicy(e){this.settings.referrerPolicy=e}loadScript(e){return new Promise(((t,o)=>{const n=Xa;let r;const s=()=>{n.remove(a),r&&(r.onerror=r.onload=r=null)},a=n.uniqueId();r=document.createElement("script"),r.id=a,r.type="text/javascript",r.src=Bt._addCacheSuffix(e),this.settings.referrerPolicy&&n.setAttrib(r,"referrerpolicy",this.settings.referrerPolicy),r.onload=()=>{s(),t()},r.onerror=()=>{s(),o("Failed to load script: "+e)},(document.getElementsByTagName("head")[0]||document.body).appendChild(r)}))}isDone(e){return 2===this.states[e]}markDone(e){this.states[e]=2}add(e){const t=this;return t.queue.push(e),void 0===t.states[e]&&(t.states[e]=0),new Promise(((o,n)=>{t.scriptLoadedCallbacks[e]||(t.scriptLoadedCallbacks[e]=[]),t.scriptLoadedCallbacks[e].push({resolve:o,reject:n})}))}load(e){return this.add(e)}remove(e){delete this.states[e],delete this.scriptLoadedCallbacks[e]}loadQueue(){const e=this.queue;return this.queue=[],this.loadScripts(e)}loadScripts(e){const t=this,o=(e,o)=>{ke(t.scriptLoadedCallbacks,o).each((t=>{q(t,(t=>t[e](o)))})),delete t.scriptLoadedCallbacks[o]},n=e=>{const t=Y(e,(e=>"rejected"===e.status));return t.length>0?Promise.reject(ne(t,(({reason:e})=>v(e)?e:[e]))):Promise.resolve()},r=e=>Promise.allSettled($(e,(e=>2===t.states[e]?(o("resolve",e),Promise.resolve()):3===t.states[e]?(o("reject",e),Promise.reject(e)):(t.states[e]=1,t.loadScript(e).then((()=>{t.states[e]=2,o("resolve",e);const s=t.queue;return s.length>0?(t.queue=[],r(s).then(n)):Promise.resolve()}),(()=>(t.states[e]=3,o("reject",e),Promise.reject(e)))))))),s=e=>(t.loading=!0,r(e).then((e=>{t.loading=!1;const o=t.queueLoadedCallbacks.shift();return F.from(o).each(H),n(e)}))),a=Te(e);return t.loading?new Promise(((e,o)=>{t.queueLoadedCallbacks.push((()=>{s(a).then(e,o)}))})):s(a)}}Ja.ScriptLoader=new Ja;const Qa=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},ei={},ti=Qa("en"),oi=()=>ke(ei,ti.get()),ni={getData:()=>ve(ei,(e=>({...e}))),setCode:e=>{e&&ti.set(e)},getCode:()=>ti.get(),add:(e,t)=>{let o=ei[e];o||(ei[e]=o={});const n=$(he(t),(e=>e.toLowerCase()));fe(t,((e,r)=>{const s=r.toLowerCase();s!==r&&((e,t)=>{const o=e.indexOf(t);return-1!==o&&e.indexOf(t,o+1)>o})(n,s)?(_e(t,s)||(o[s]=e),o[r]=e):o[s]=e}))},translate:e=>{const t=oi().getOr({}),o=e=>S(e)?Object.prototype.toString.call(e):n(e)?"":""+e,n=e=>""===e||null==e,r=e=>{const n=o(e);return _e(t,n)?o(t[n]):ke(t,n.toLowerCase()).map(o).getOr(n)},s=e=>e.replace(/{context:\w+}$/,"");if(n(e))return"";if(p(a=e)&&_e(a,"raw"))return o(e.raw);var a;if((e=>v(e)&&e.length>1)(e)){const t=e.slice(1);return s(r(e[0]).replace(/\{([0-9]+)\}/g,((e,n)=>_e(t,n)?o(t[n]):e)))}return s(r(e))},isRtl:()=>oi().bind((e=>ke(e,"_dir"))).exists((e=>"rtl"===e)),hasCode:e=>_e(ei,e)},ri=()=>{const e=[],t={},o={},n=[],r=(e,t)=>{const o=Y(n,(o=>o.name===e&&o.state===t));q(o,(e=>e.resolve()))},s=e=>_e(t,e),a=(e,o)=>{const n=ni.getCode();!n||o&&-1===(","+(o||"")+",").indexOf(","+n+",")||Ja.ScriptLoader.add(t[e]+"/langs/"+n+".js")},i=(e,t="added")=>"added"===t&&(e=>_e(o,e))(e)||"loaded"===t&&s(e)?Promise.resolve():new Promise((o=>{n.push({name:e,state:t,resolve:o})}));return{items:e,urls:t,lookup:o,get:e=>{if(o[e])return o[e].instance},requireLangPack:(e,t)=>{!1!==ri.languageLoad&&(s(e)?a(e,t):i(e,"loaded").then((()=>a(e,t))))},add:(t,n)=>(e.push(n),o[t]={instance:n},r(t,"added"),n),remove:e=>{delete t[e],delete o[e]},createUrl:(e,t)=>h(t)?h(e)?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}:t,load:(e,n)=>{if(t[e])return Promise.resolve();let s=h(n)?n:n.prefix+n.resource+n.suffix;0!==s.indexOf("/")&&-1===s.indexOf("://")&&(s=ri.baseURL+"/"+s),t[e]=s.substring(0,s.lastIndexOf("/"));const a=()=>(r(e,"loaded"),Promise.resolve());return o[e]?a():Ja.ScriptLoader.add(s).then(a)},waitFor:i}};ri.languageLoad=!0,ri.baseURL="",ri.PluginManager=ri(),ri.ThemeManager=ri(),ri.ModelManager=ri();const si=e=>{const t=Qa(F.none()),o=()=>t.get().each((e=>clearInterval(e)));return{clear:()=>{o(),t.set(F.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:n=>{o(),t.set(F.some(setInterval(n,e)))}}},ai=()=>{const e=(e=>{const t=Qa(F.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(F.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(F.some(e))}}})(E);return{...e,on:t=>e.get().each(t)}},ii=(e,t)=>{let o=null;return{cancel:()=>{b(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{b(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}},li=(e,t)=>{let o=null;const n=()=>{b(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},ci=D("mce-annotation"),di=D("data-mce-annotation"),mi=D("data-mce-annotation-uid"),ui=D("data-mce-annotation-active"),gi=D("data-mce-annotation-classes"),hi=D("data-mce-annotation-attrs"),pi=e=>t=>So(t,e),fi=(e,t)=>{const o=e.selection.getRng(),n=yo.fromDom(o.startContainer),r=yo.fromDom(e.getBody()),s=t.fold((()=>"."+ci()),(e=>`[${di()}="${e}"]`)),a=Ho(n,o.startOffset).getOr(n);return on(a,s,pi(r)).bind((t=>no(t,`${mi()}`).bind((o=>no(t,`${di()}`).map((t=>{const n=bi(e,o);return{uid:o,name:t,elements:n}}))))))},vi=(e,t)=>ro(e,"data-mce-bogus")||Vn(e,'[data-mce-bogus="all"]',pi(t)),bi=(e,t)=>{const o=yo.fromDom(e.getBody()),n=zn(o,`[${mi()}="${t}"]`);return Y(n,(e=>!vi(e,o)))},yi=(e,t)=>{const o=yo.fromDom(e.getBody()),n=zn(o,`[${di()}="${t}"]`),r={};return q(n,(e=>{if(!vi(e,o)){const t=oo(e,mi()),o=ke(r,t).getOr([]);r[t]=o.concat([e])}})),r},wi=(e,t)=>{const o=Qa({}),n=()=>({listeners:[],previous:ai()}),r=(e,t)=>{s(e,(e=>(t(e),e)))},s=(e,t)=>{const r=o.get(),s=t(ke(r,e).getOrThunk(n));r[e]=s,o.set(r)},a=(t,o)=>{q(bi(e,t),(e=>{o?eo(e,ui(),"true"):so(e,ui())}))},i=li((()=>{const o=le(t.getNames());q(o,(t=>{s(t,(o=>{const n=o.previous.get();return fi(e,F.some(t)).fold((()=>{n.each((e=>{(e=>{r(e,(t=>{q(t.listeners,(t=>t(!1,e)))}))})(t),o.previous.clear(),a(e,!1)}))}),(({uid:e,name:t,elements:s})=>{Lt(n,e)||(n.each((e=>a(e,!1))),((e,t,o)=>{r(e,(n=>{q(n.listeners,(n=>n(!0,e,{uid:t,nodes:$(o,(e=>e.dom))})))}))})(t,e,s),o.previous.set(e),a(e,!0))})),{previous:o.previous,listeners:o.listeners}}))}))}),30);return e.on("remove",(()=>{i.cancel()})),e.on("NodeChange",(()=>{i.throttle()})),{addListener:(e,t)=>{s(e,(e=>({previous:e.previous,listeners:e.listeners.concat([t])})))}}};let xi=0;const Ci=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return xi++,e+"_"+o+xi+String(t)},Si=(e,t)=>yo.fromDom(e.dom.cloneNode(t)),ki=e=>Si(e,!1),_i=e=>Si(e,!0),Ei=(e,t)=>{const o=((e,t)=>{const o=yo.fromTag(t),n=ao(e);return to(o,n),o})(e,t);fn(e,o);const n=Lo(e);return wn(o,n),Cn(e),o},Ti=(e,t,o=I)=>{const n=new Zn(e,t),r=e=>{let t;do{t=n[e]()}while(t&&!tr(t)&&!o(t));return F.from(t).filter(tr)};return{current:()=>F.from(n.current()).filter(tr),next:()=>r("next"),prev:()=>r("prev"),prev2:()=>r("prev2")}},Oi=(e,t)=>{const o=t||(t=>e.isBlock(t)||ir(t)||dr(t)),n=(e,t,o,r)=>{if(tr(e)){const o=r(e,t,e.data);if(-1!==o)return F.some({container:e,offset:o})}return o().bind((e=>n(e.container,e.offset,o,r)))};return{backwards:(t,r,s,a)=>{const i=Ti(t,null!=a?a:e.getRoot(),o);return n(t,r,(()=>i.prev().map((e=>({container:e,offset:e.length})))),s).getOrNull()},forwards:(t,r,s,a)=>{const i=Ti(t,null!=a?a:e.getRoot(),o);return n(t,r,(()=>i.next().map((e=>({container:e,offset:0})))),s).getOrNull()}}},Di=Math.round,Ai=e=>e?{left:Di(e.left),top:Di(e.top),bottom:Di(e.bottom),right:Di(e.right),width:Di(e.width),height:Di(e.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0},Mi=(e,t)=>(e=Ai(e),t||(e.left=e.left+e.width),e.right=e.left,e.width=0,e),Ni=(e,t,o)=>e>=0&&e<=Math.min(t.height,o.height)/2,Ri=(e,t)=>{const o=Math.min(t.height/2,e.height/2);return e.bottom-ot.bottom)&&Ni(t.top-e.bottom,e,t)},Bi=(e,t)=>e.top>t.bottom||!(e.bottom{const n=Math.max(Math.min(t,e.left+e.width),e.left),r=Math.max(Math.min(o,e.top+e.height),e.top);return Math.sqrt((t-n)*(t-n)+(o-r)*(o-r))},Hi=e=>{const t=e.startContainer,o=e.startOffset;return t===e.endContainer&&t.hasChildNodes()&&e.endOffset===o+1?t.childNodes[o]:null},Ii=(e,t)=>{if(Wn(e)&&e.hasChildNodes()){const o=e.childNodes,n=((e,t,o)=>Math.min(Math.max(e,t),o))(t,0,o.length-1);return o[n]}return e},Pi=new RegExp("[̀-ͯ҃-҇҈-҉֑-ֽֿׁ-ׂׄ-ׇׅؐ-ًؚ-ٰٟۖ-ۜ۟-ۤۧ-۪ۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣣ-ंऺ़ु-ै्॑-ॗॢ-ॣঁ়াু-ৄ্ৗৢ-ৣਁ-ਂ਼ੁ-ੂੇ-ੈੋ-੍ੑੰ-ੱੵઁ-ં઼ુ-ૅે-ૈ્ૢ-ૣଁ଼ାିୁ-ୄ୍ୖୗୢ-ୣஂாீ்ௗఀా-ీె-ైొ-్ౕ-ౖౢ-ౣಁ಼ಿೂೆೌ-್ೕ-ೖೢ-ೣഁാു-ൄ്ൗൢ-ൣ්ාි-ුූෟัิ-ฺ็-๎ັິ-ູົ-ຼ່-ໍ༘-ཱ༹༙༵༷-ཾྀ-྄྆-྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္-်ွ-ှၘ-ၙၞ-ၠၱ-ၴႂႅ-ႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒ-ᝓᝲ-ᝳ឴-឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧ-ᤨᤲ᤹-᤻ᨗ-ᨘᨛᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼᪰-᪽᪾ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀ-ᮁᮢ-ᮥᮨ-ᮩ᮫-ᮭ᯦ᯨ-ᯩᯭᯯ-ᯱᰬ-ᰳᰶ-᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᳸-᳹᷀-᷵᷼-᷿‌-‍⃐-⃜⃝-⃠⃡⃢-⃤⃥-⃰⳯-⵿⳱ⷠ-〪ⷿ-〭〮-゙〯-゚꙯꙰-꙲ꙴ-꙽ꚞ-ꚟ꛰-꛱ꠂ꠆ꠋꠥ-ꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꧥꨩ-ꨮꨱ-ꨲꨵ-ꨶꩃꩌꩼꪰꪲ-ꪴꪷ-ꪸꪾ-꪿꫁ꫬ-ꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-゙︯-゚]"),Fi=e=>h(e)&&e.charCodeAt(0)>=768&&Pi.test(e),zi=Wn,Vi=ns,Zi=Kn("display","block table"),Ui=Kn("float","left right"),ji=((...e)=>t=>{for(let o=0;ot<0&&Wn(e)&&e.hasChildNodes()?void 0:Ii(e,t),Yi=e=>e?e.createRange():Ya.DOM.createRng(),Xi=e=>h(e)&&/[\r\n\t ]/.test(e),Ji=e=>!!e.setStart&&!!e.setEnd,Qi=e=>{const t=e.startContainer,o=e.startOffset;if(Xi(e.toString())&&Wi(t.parentNode)&&tr(t)){const e=t.data;if(Xi(e[o-1])||Xi(e[o+1]))return!0}return!1},el=e=>0===e.left&&0===e.right&&0===e.top&&0===e.bottom,tl=e=>{var t;let o;const n=e.getClientRects();return o=n.length>0?Ai(n[0]):Ai(e.getBoundingClientRect()),!Ji(e)&&qi(e)&&el(o)?(e=>{const t=e.ownerDocument,o=Yi(t),n=t.createTextNode(br),r=e.parentNode;r.insertBefore(n,e),o.setStart(n,0),o.setEnd(n,1);const s=Ai(o.getBoundingClientRect());return r.removeChild(n),s})(e):el(o)&&Ji(e)&&null!==(t=(e=>{const t=e.startContainer,o=e.endContainer,n=e.startOffset,r=e.endOffset;if(t===o&&tr(o)&&0===n&&1===r){const t=e.cloneRange();return t.setEndAfter(o),tl(t)}return null})(e))&&void 0!==t?t:o},ol=(e,t)=>{const o=Mi(e,t);return o.width=1,o.right=o.left+1,o},nl=e=>{const t=[],o=e=>{var o,n;0!==e.height&&(t.length>0&&(o=e,n=t[t.length-1],o.left===n.left&&o.top===n.top&&o.bottom===n.bottom&&o.right===n.right)||t.push(e))},n=(e,t)=>{const n=Yi(e.ownerDocument);if(t0&&(n.setStart(e,t-1),n.setEnd(e,t),Qi(n)||o(ol(tl(n),!1))),t{const n=()=>(o||(o=nl(rl(e,t))),o);return{container:D(e),offset:D(t),toRange:()=>{const o=Yi(e.ownerDocument);return o.setStart(e,t),o.setEnd(e,t),o},getClientRects:n,isVisible:()=>n().length>0,isAtStart:()=>($i(e),0===t),isAtEnd:()=>$i(e)?t>=e.data.length:t>=e.childNodes.length,isEqual:o=>o&&e===o.container()&&t===o.offset(),getNode:o=>Ki(e,o?t-1:t)}};rl.fromRangeStart=e=>rl(e.startContainer,e.startOffset),rl.fromRangeEnd=e=>rl(e.endContainer,e.endOffset),rl.after=e=>rl(e.parentNode,Gi(e)+1),rl.before=e=>rl(e.parentNode,Gi(e)),rl.isAbove=(e,t)=>It(de(t.getClientRects()),me(e.getClientRects()),Ri).getOr(!1),rl.isBelow=(e,t)=>It(me(t.getClientRects()),de(e.getClientRects()),Bi).getOr(!1),rl.isAtStart=e=>!!e&&e.isAtStart(),rl.isAtEnd=e=>!!e&&e.isAtEnd(),rl.isTextPosition=e=>!!e&&tr(e.container()),rl.isElementPosition=e=>!rl.isTextPosition(e);const sl=(e,t)=>{tr(t)&&0===t.data.length&&e.remove(t)},al=(e,t,o)=>{ar(o)?((e,t,o)=>{const n=F.from(o.firstChild),r=F.from(o.lastChild);t.insertNode(o),n.each((t=>sl(e,t.previousSibling))),r.each((t=>sl(e,t.nextSibling)))})(e,t,o):((e,t,o)=>{t.insertNode(o),sl(e,o.previousSibling),sl(e,o.nextSibling)})(e,t,o)},il=tr,ll=Xn,cl=Ya.nodeIndex,dl=e=>{const t=e.parentNode;return ll(t)?dl(t):t},ml=e=>e?Re(e.childNodes,((e,t)=>(ll(t)&&"BR"!==t.nodeName?e=e.concat(ml(t)):e.push(t),e)),[]):[],ul=e=>t=>e===t,gl=e=>(il(e)?"text()":e.nodeName.toLowerCase())+"["+(e=>{let t,o;t=ml(dl(e)),o=Be(t,ul(e),e),t=t.slice(0,o+1);const n=Re(t,((e,o,n)=>(il(o)&&il(t[n-1])&&e++,e)),0);return t=Ne(t,Gn([e.nodeName])),o=Be(t,ul(e),e),o-n})(e)+"]",hl=(e,t)=>{let o,n=[],r=t.container(),s=t.offset();if(il(r))o=((e,t)=>{let o=e;for(;(o=o.previousSibling)&&il(o);)t+=o.data.length;return t})(r,s);else{const e=r.childNodes;s>=e.length?(o="after",s=e.length-1):o="before",r=e[s]}n.push(gl(r));let a=((e,t,o)=>{const n=[];for(let r=t.parentNode;r&&r!==e&&(!o||!o(r));r=r.parentNode)n.push(r);return n})(e,r);return a=Ne(a,R(Xn)),n=n.concat(Me(a,(e=>gl(e)))),n.reverse().join("/")+","+o},pl=(e,t)=>{if(!t)return null;const o=t.split(","),n=o[0].split("/"),r=o.length>1?o[1]:"before",s=Re(n,((e,t)=>{const o=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t);return o?("text()"===o[1]&&(o[1]="#text"),((e,t,o)=>{let n=ml(e);return n=Ne(n,((e,t)=>!il(e)||!il(n[t-1]))),n=Ne(n,Gn([t])),n[o]})(e,o[1],parseInt(o[2],10))):null}),e);if(!s)return null;if(!il(s)&&s.parentNode){let e;return e="after"===r?cl(s)+1:cl(s),rl(s.parentNode,e)}return((e,t)=>{let o=e,n=0;for(;il(o);){const r=o.data.length;if(t>=n&&t<=n+r){e=o,t-=n;break}if(!il(o.nextSibling)){e=o,t=r;break}n+=r,o=o.nextSibling}return il(e)&&t>e.data.length&&(t=e.data.length),rl(e,t)})(s,parseInt(r,10))},fl=dr,vl=(e,t,o,n,r)=>{const s=r?n.startContainer:n.endContainer;let a=r?n.startOffset:n.endOffset;const i=[],l=e.getRoot();if(tr(s))i.push(o?((e,t,o)=>{let n=e(t.data.slice(0,o)).length;for(let o=t.previousSibling;o&&tr(o);o=o.previousSibling)n+=e(o.data).length;return n})(t,s,a):a);else{let t=0;const n=s.childNodes;a>=n.length&&n.length&&(t=1,a=Math.max(0,n.length-1)),i.push(e.nodeIndex(n[a],o)+t)}for(let t=s;t&&t!==l;t=t.parentNode)i.push(e.nodeIndex(t,o));return i},bl=(e,t,o)=>{let n=0;return Bt.each(e.select(t),(e=>"all"===e.getAttribute("data-mce-bogus")?void 0:e!==o&&void n++)),n},yl=(e,t)=>{let o=t?e.startContainer:e.endContainer,n=t?e.startOffset:e.endOffset;if(Wn(o)&&"TR"===o.nodeName){const r=o.childNodes;o=r[Math.min(t?n:n-1,r.length-1)],o&&(n=t?0:o.childNodes.length,t?e.setStart(o,n):e.setEnd(o,n))}},wl=e=>(yl(e,!0),yl(e,!1),e),xl=(e,t)=>{if(Wn(e)&&(e=Ii(e,t),fl(e)))return e;if(Vr(e)){tr(e)&&Fr(e)&&(e=e.parentNode);let t=e.previousSibling;if(fl(t))return t;if(t=e.nextSibling,fl(t))return t}},Cl=(e,t,o)=>{const n=o.getNode(),r=o.getRng();if("IMG"===n.nodeName||fl(n)){const e=n.nodeName;return{name:e,index:bl(o.dom,e,n)}}const s=(e=>xl(e.startContainer,e.startOffset)||xl(e.endContainer,e.endOffset))(r);if(s){const e=s.tagName;return{name:e,index:bl(o.dom,e,s)}}return((e,t,o,n)=>{const r=t.dom,s=vl(r,e,o,n,!0),a=t.isForward(),i=Gr(n)?{isFakeCaret:!0}:{};return t.isCollapsed()?{start:s,forward:a,...i}:{start:s,end:vl(r,e,o,n,!1),forward:a,...i}})(e,o,t,r)},Sl=(e,t,o)=>{const n={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return o?e.create("span",n,""):e.create("span",n)},kl=(e,t)=>{const o=e.dom;let n=e.getRng();const r=o.uniqueId(),s=e.isCollapsed(),a=e.getNode(),i=a.nodeName,l=e.isForward();if("IMG"===i)return{name:i,index:bl(o,i,a)};const c=wl(n.cloneRange());if(!s){c.collapse(!1);const e=Sl(o,r+"_end",t);al(o,c,e)}n=wl(n),n.collapse(!0);const d=Sl(o,r+"_start",t);return al(o,n,d),e.moveToBookmark({id:r,keep:!0,forward:l}),{id:r,forward:l}},_l=(e,t,o=!1)=>2===t?Cl(Hr,o,e):3===t?(e=>{const t=e.getRng();return{start:hl(e.dom.getRoot(),rl.fromRangeStart(t)),end:hl(e.dom.getRoot(),rl.fromRangeEnd(t)),forward:e.isForward()}})(e):t?(e=>({rng:e.getRng(),forward:e.isForward()}))(e):kl(e,!1),El=N(Cl,A,!0),Tl=e=>{const t=t=>t(e),o=D(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:P,isError:I,map:t=>Dl.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>F.some(e)};return r},Ol=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:I,isError:P,map:t,mapError:t=>Dl.error(t(e)),bind:t,exists:I,forall:P,getOr:A,or:A,getOrThunk:L,orThunk:L,getOrDie:B(String(e)),each:E,toOptional:F.none};return o},Dl={value:Tl,error:Ol,fromOption:(e,t)=>e.fold((()=>Ol(t)),Tl)},Al=e=>{if(!v(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return q(e,((n,r)=>{const s=he(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!v(i))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=he(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!re(t,(e=>j(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o};Al([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Ml=e=>"inline-command"===e.type||"inline-format"===e.type,Nl=e=>"block-command"===e.type||"block-format"===e.type,Rl=e=>{const t=t=>Dl.error({message:t,pattern:e}),o=(o,n,r)=>{if(void 0!==e.format){let r;if(v(e.format)){if(!re(e.format,h))return t(o+" pattern has non-string items in the `format` array");r=e.format}else{if(!h(e.format))return t(o+" pattern has non-string `format` parameter");r=[e.format]}return Dl.value(n(r))}return void 0!==e.cmd?h(e.cmd)?Dl.value(r(e.cmd,e.value)):t(o+" pattern has non-string `cmd` parameter"):t(o+" pattern is missing both `format` and `cmd` parameters")};if(!p(e))return t("Raw pattern is not an object");if(!h(e.start))return t("Raw pattern is missing `start` parameter");if(void 0!==e.end){if(!h(e.end))return t("Inline pattern has non-string `end` parameter");if(0===e.start.length&&0===e.end.length)return t("Inline pattern has empty `start` and `end` parameters");let n=e.start,r=e.end;return 0===r.length&&(r=n,n=""),o("Inline",(e=>({type:"inline-format",start:n,end:r,format:e})),((e,t)=>({type:"inline-command",start:n,end:r,cmd:e,value:t})))}return void 0!==e.replacement?h(e.replacement)?0===e.start.length?t("Replacement pattern has empty `start` parameter"):Dl.value({type:"inline-command",start:"",end:e.start,cmd:"mceInsertContent",value:e.replacement}):t("Replacement pattern has non-string `replacement` parameter"):0===e.start.length?t("Block pattern has empty `start` parameter"):o("Block",(t=>({type:"block-format",start:e.start,format:t[0]})),((t,o)=>({type:"block-command",start:e.start,cmd:t,value:o})))},Bl=e=>Y(e,Nl),Ll=e=>Y(e,Ml),Hl=e=>{const t=(e=>{const t=[],o=[];return q(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})($(e,Rl));return q(t.errors,(e=>console.error(e.message,e.pattern))),t.values},Il=St().deviceType,Pl=Il.isTouch(),Fl=Ya.DOM,zl=e=>g(e,RegExp),Vl=e=>t=>t.options.get(e),Zl=e=>h(e)||p(e),Ul=(e,t="")=>o=>{const n=h(o);if(n){if(-1!==o.indexOf("=")){const r=(e=>{const t=e.indexOf("=")>0?e.split(/[;,](?![^=;,]*(?:[;,]|$))/):e.split(",");return J(t,((e,t)=>{const o=t.split("="),n=o[0],r=o.length>1?o[1]:n;return e[qe(n)]=qe(r),e}),{})})(o);return{value:ke(r,e.id).getOr(t),valid:n}}return{value:o,valid:n}}return{valid:!1,message:"Must be a string."}},jl=Vl("iframe_attrs"),Wl=Vl("doctype"),$l=Vl("document_base_url"),ql=Vl("body_id"),Gl=Vl("body_class"),Kl=Vl("content_security_policy"),Yl=Vl("br_in_pre"),Xl=Vl("forced_root_block"),Jl=Vl("forced_root_block_attrs"),Ql=Vl("newline_behavior"),ec=Vl("br_newline_selector"),tc=Vl("no_newline_selector"),oc=Vl("keep_styles"),nc=Vl("end_container_on_empty_block"),rc=Vl("automatic_uploads"),sc=Vl("images_reuse_filename"),ac=Vl("images_replace_blob_uris"),ic=Vl("icons"),lc=Vl("icons_url"),cc=Vl("images_upload_url"),dc=Vl("images_upload_base_path"),mc=Vl("images_upload_credentials"),uc=Vl("images_upload_handler"),gc=Vl("content_css_cors"),hc=Vl("referrer_policy"),pc=Vl("language"),fc=Vl("language_url"),vc=Vl("indent_use_margin"),bc=Vl("indentation"),yc=Vl("content_css"),wc=Vl("content_style"),xc=Vl("font_css"),Cc=Vl("directionality"),Sc=Vl("inline_boundaries_selector"),kc=Vl("object_resizing"),_c=Vl("resize_img_proportional"),Ec=Vl("placeholder"),Tc=Vl("event_root"),Oc=Vl("service_message"),Dc=Vl("theme"),Ac=Vl("theme_url"),Mc=Vl("model"),Nc=Vl("model_url"),Rc=Vl("inline_boundaries"),Bc=Vl("formats"),Lc=Vl("preview_styles"),Hc=Vl("format_empty_lines"),Ic=Vl("format_noneditable_selector"),Pc=Vl("custom_ui_selector"),Fc=Vl("inline"),zc=Vl("hidden_input"),Vc=Vl("submit_patch"),Zc=Vl("add_form_submit_trigger"),Uc=Vl("add_unload_trigger"),jc=Vl("custom_undo_redo_levels"),Wc=Vl("disable_nodechange"),$c=Vl("readonly"),qc=Vl("editable_root"),Gc=Vl("content_css_cors"),Kc=Vl("plugins"),Yc=Vl("external_plugins"),Xc=Vl("block_unsupported_drop"),Jc=Vl("visual"),Qc=Vl("visual_table_class"),ed=Vl("visual_anchor_class"),td=Vl("iframe_aria_text"),od=Vl("setup"),nd=Vl("init_instance_callback"),rd=Vl("urlconverter_callback"),sd=Vl("auto_focus"),ad=Vl("browser_spellcheck"),id=Vl("protect"),ld=Vl("paste_block_drop"),cd=Vl("paste_data_images"),dd=Vl("paste_preprocess"),md=Vl("paste_postprocess"),ud=Vl("newdocument_content"),gd=Vl("paste_webkit_styles"),hd=Vl("paste_remove_styles_if_webkit"),pd=Vl("paste_merge_formats"),fd=Vl("smart_paste"),vd=Vl("paste_as_text"),bd=Vl("paste_tab_spaces"),yd=Vl("allow_html_data_urls"),wd=Vl("text_patterns"),xd=Vl("text_patterns_lookup"),Cd=Vl("noneditable_class"),Sd=Vl("editable_class"),kd=Vl("noneditable_regexp"),_d=Vl("preserve_cdata"),Ed=Vl("highlight_on_focus"),Td=Vl("xss_sanitization"),Od=Vl("init_content_sync"),Dd=e=>Bt.explode(e.options.get("images_file_types")),Ad=Vl("table_tab_navigation"),Md=Vl("details_initial_state"),Nd=Vl("details_serialized_state"),Rd=Vl("force_hex_color"),Bd=Vl("sandbox_iframes"),Ld=Wn,Hd=tr,Id=e=>{const t=e.parentNode;t&&t.removeChild(e)},Pd=e=>{const t=Hr(e);return{count:e.length-t.length,text:t}},Fd=e=>{let t;for(;-1!==(t=e.data.lastIndexOf(Br));)e.deleteData(t,1)},zd=(e,t)=>(jd(e),t),Vd=(e,t)=>{const o=t.container(),n=((e,t)=>{const o=U(e,t);return-1===o?F.none():F.some(o)})(ue(o.childNodes),e).map((e=>eHd(e)&&t.container()===e?((e,t)=>{const o=Pd(e.data.substr(0,t.offset())),n=Pd(e.data.substr(t.offset()));return(o.text+n.text).length>0?(Fd(e),rl(e,t.offset()-o.count)):t})(e,t):zd(e,t),Ud=(e,t)=>rl.isTextPosition(t)?Zd(e,t):((e,t)=>t.container()===e.parentNode?Vd(e,t):zd(e,t))(e,t),jd=e=>{Ld(e)&&Vr(e)&&(Zr(e)?e.removeAttribute("data-mce-caret"):Id(e)),Hd(e)&&(Fd(e),0===e.data.length&&Id(e))},Wd=dr,$d=gr,qd=mr,Gd=(e,t,o)=>{const n=Mi(t.getBoundingClientRect(),o);let r,s;if("BODY"===e.tagName){const t=e.ownerDocument.documentElement;r=e.scrollLeft||t.scrollLeft,s=e.scrollTop||t.scrollTop}else{const t=e.getBoundingClientRect();r=e.scrollLeft-t.left,s=e.scrollTop-t.top}n.left+=r,n.right+=r,n.top+=s,n.bottom+=s,n.width=1;let a=t.offsetWidth-t.clientWidth;return a>0&&(o&&(a*=-1),n.left+=a,n.right+=a),n},Kd=(e,t,o,n)=>{const r=ai();let s,a;const i=Xl(e),l=e.dom,c=()=>{(e=>{var t,o;const n=zn(yo.fromDom(e),"*[contentEditable=false],video,audio,embed,object");for(let e=0;e{l.remove(e.caret),r.clear()})),s&&(clearInterval(s),s=void 0)},d=()=>{s=setInterval((()=>{r.on((e=>{n()?l.toggleClass(e.caret,"mce-visual-caret-hidden"):l.addClass(e.caret,"mce-visual-caret-hidden")}))}),500)};return{show:(e,n)=>{let s;if(c(),qd(n))return null;if(!o(n))return a=((e,t)=>{var o;const n=(null!==(o=e.ownerDocument)&&void 0!==o?o:document).createTextNode(Br),r=e.parentNode;if(t){const t=e.previousSibling;if(Pr(t)){if(Vr(t))return t;if($r(t))return t.splitText(t.data.length-1)}null==r||r.insertBefore(n,e)}else{const t=e.nextSibling;if(Pr(t)){if(Vr(t))return t;if(Wr(t))return t.splitText(1),t}e.nextSibling?null==r||r.insertBefore(n,e.nextSibling):null==r||r.appendChild(n)}return n})(n,e),s=n.ownerDocument.createRange(),Xd(a.nextSibling)?(s.setStart(a,0),s.setEnd(a,0)):(s.setStart(a,1),s.setEnd(a,1)),s;{const o=((e,t,o)=>{var n;const r=(null!==(n=t.ownerDocument)&&void 0!==n?n:document).createElement(e);r.setAttribute("data-mce-caret",o?"before":"after"),r.setAttribute("data-mce-bogus","all"),r.appendChild(Nr().dom);const s=t.parentNode;return o?null==s||s.insertBefore(r,t):t.nextSibling?null==s||s.insertBefore(r,t.nextSibling):null==s||s.appendChild(r),r})(i,n,e),c=Gd(t,n,e);l.setStyle(o,"top",c.top),a=o;const m=l.create("div",{class:"mce-visual-caret","data-mce-bogus":"all"});l.setStyles(m,{...c}),l.add(t,m),r.set({caret:m,element:n,before:e}),e&&l.addClass(m,"mce-visual-caret-before"),d(),s=n.ownerDocument.createRange(),s.setStart(o,0),s.setEnd(o,0)}return s},hide:c,getCss:()=>".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}",reposition:()=>{r.on((e=>{const o=Gd(t,e.element,e.before);l.setStyles(e.caret,{...o})}))},destroy:()=>clearInterval(s)}},Yd=()=>At.browser.isFirefox(),Xd=e=>Wd(e)||$d(e),Jd=e=>(Xd(e)||Jn(e)&&Yd())&&Do(yo.fromDom(e)).exists(nn),Qd=cr,em=dr,tm=gr,om=Kn("display","block table table-cell table-caption list-item"),nm=Vr,rm=Fr,sm=Wn,am=tr,im=ns,lm=e=>e>0,cm=e=>e<0,dm=(e,t)=>{let o;for(;o=e(t);)if(!rm(o))return o;return null},mm=(e,t,o,n,r)=>{const s=new Zn(e,n),a=em(e)||rm(e);let i;if(cm(t)){if(a&&(i=dm(s.prev.bind(s),!0),o(i)))return i;for(;i=dm(s.prev.bind(s),r);)if(o(i))return i}if(lm(t)){if(a&&(i=dm(s.next.bind(s),!0),o(i)))return i;for(;i=dm(s.next.bind(s),r);)if(o(i))return i}return null},um=(e,t)=>{for(;e&&e!==t;){if(om(e))return e;e=e.parentNode}return null},gm=(e,t,o)=>um(e.container(),o)===um(t.container(),o),hm=(e,t)=>{if(!t)return F.none();const o=t.container(),n=t.offset();return sm(o)?F.from(o.childNodes[n+e]):F.none()},pm=(e,t)=>{var o;const n=(null!==(o=t.ownerDocument)&&void 0!==o?o:document).createRange();return e?(n.setStartBefore(t),n.setEndBefore(t)):(n.setStartAfter(t),n.setEndAfter(t)),n},fm=(e,t,o)=>um(t,e)===um(o,e),vm=(e,t,o)=>{const n=e?"previousSibling":"nextSibling";let r=o;for(;r&&r!==t;){let e=r[n];if(e&&nm(e)&&(e=e[n]),em(e)||tm(e)){if(fm(t,e,r))return e;break}if(im(e))break;r=r.parentNode}return null},bm=N(pm,!0),ym=N(pm,!1),wm=(e,t,o)=>{let n;const r=N(vm,!0,t),s=N(vm,!1,t),a=o.startContainer,i=o.startOffset;if(Fr(a)){const e=am(a)?a.parentNode:a,t=e.getAttribute("data-mce-caret");if("before"===t&&(n=e.nextSibling,Jd(n)))return bm(n);if("after"===t&&(n=e.previousSibling,Jd(n)))return ym(n)}if(!o.collapsed)return o;if(tr(a)){if(nm(a)){if(1===e){if(n=s(a),n)return bm(n);if(n=r(a),n)return ym(n)}if(-1===e){if(n=r(a),n)return ym(n);if(n=s(a),n)return bm(n)}return o}if($r(a)&&i>=a.data.length-1)return 1===e&&(n=s(a),n)?bm(n):o;if(Wr(a)&&i<=1)return-1===e&&(n=r(a),n)?ym(n):o;if(i===a.data.length)return n=s(a),n?bm(n):o;if(0===i)return n=r(a),n?ym(n):o}return o},xm=(e,t)=>hm(e?0:-1,t).filter(em),Cm=(e,t,o)=>{const n=wm(e,t,o);return-1===e?rl.fromRangeStart(n):rl.fromRangeEnd(n)},Sm=e=>F.from(e.getNode()).map(yo.fromDom),km=(e,t)=>{let o=t;for(;o=e(o);)if(o.isVisible())return o;return o},_m=(e,t)=>{const o=gm(e,t);return!(o||!ir(e.getNode()))||o};var Em;!function(e){e[e.Backwards=-1]="Backwards",e[e.Forwards=1]="Forwards"}(Em||(Em={}));const Tm=dr,Om=tr,Dm=Wn,Am=ir,Mm=ns,Nm=e=>es(e)||(e=>!!rs(e)&&!J(ue(e.getElementsByTagName("*")),((e,t)=>e||Kr(t)),!1))(e),Rm=ss,Bm=(e,t)=>e.hasChildNodes()&&t{if(lm(e)){if(Mm(t.previousSibling)&&!Om(t.previousSibling))return rl.before(t);if(Om(t))return rl(t,0)}if(cm(e)){if(Mm(t.nextSibling)&&!Om(t.nextSibling))return rl.after(t);if(Om(t))return rl(t,t.data.length)}return cm(e)?Am(t)?rl.before(t):rl.after(t):rl.before(t)},Hm=(e,t,o)=>{let n,r,s,a;if(!Dm(o)||!t)return null;if(t.isEqual(rl.after(o))&&o.lastChild){if(a=rl.after(o.lastChild),cm(e)&&Mm(o.lastChild)&&Dm(o.lastChild))return Am(o.lastChild)?rl.before(o.lastChild):a}else a=t;const i=a.container();let l=a.offset();if(Om(i)){if(cm(e)&&l>0)return rl(i,--l);if(lm(e)&&l0&&(r=Bm(i,l-1),Mm(r)))return!Nm(r)&&(s=mm(r,e,Rm,r),s)?Om(s)?rl(s,s.data.length):rl.after(s):Om(r)?rl(r,r.data.length):rl.before(r);if(lm(e)&&l{const o=t.nextSibling;return o&&Mm(o)?Om(o)?rl(o,0):rl.before(o):Hm(Em.Forwards,rl.after(t),e)})(o,r):!Nm(r)&&(s=mm(r,e,Rm,r),s)?Om(s)?rl(s,0):rl.before(s):Om(r)?rl(r,0):rl.after(r);n=r||a.getNode()}if(n&&(lm(e)&&a.isAtEnd()||cm(e)&&a.isAtStart())&&(n=mm(n,e,P,o,!0),Rm(n,o)))return Lm(e,n);r=n?mm(n,e,Rm,o):n;const c=Le(Y(((e,t)=>{const o=[];let n=e;for(;n&&n!==t;)o.push(n),n=n.parentNode;return o})(i,o),Tm));return!c||r&&c.contains(r)?r?Lm(e,r):null:(a=lm(e)?rl.after(c):rl.before(c),a)},Im=e=>({next:t=>Hm(Em.Forwards,t,e),prev:t=>Hm(Em.Backwards,t,e)}),Pm=e=>rl.isTextPosition(e)?0===e.offset():ns(e.getNode()),Fm=e=>{if(rl.isTextPosition(e)){const t=e.container();return e.offset()===t.data.length}return ns(e.getNode(!0))},zm=(e,t)=>!rl.isTextPosition(e)&&!rl.isTextPosition(t)&&e.getNode()===t.getNode(!0),Vm=(e,t,o)=>{return e?!zm(t,o)&&(n=t,!(!rl.isTextPosition(n)&&ir(n.getNode())))&&Fm(t)&&Pm(o):!zm(o,t)&&Pm(t)&&Fm(o);var n},Zm=(e,t,o)=>{const n=Im(t);return F.from(e?n.next(o):n.prev(o))},Um=(e,t,o)=>Zm(e,t,o).bind((n=>gm(o,n,t)&&Vm(e,o,n)?Zm(e,t,n):F.some(n))),jm=(e,t,o,n)=>Um(e,t,o).bind((o=>n(o)?jm(e,t,o,n):F.some(o))),Wm=(e,t)=>{const o=e?t.firstChild:t.lastChild;return tr(o)?F.some(rl(o,e?0:o.data.length)):o?ns(o)?F.some(e?rl.before(o):ir(n=o)?rl.before(n):rl.after(n)):((e,t,o)=>{const n=e?rl.before(o):rl.after(o);return Zm(e,t,n)})(e,t,o):F.none();var n},$m=N(Zm,!0),qm=N(Zm,!1),Gm=N(Wm,!0),Km=N(Wm,!1),Ym="_mce_caret",Xm=e=>Wn(e)&&e.id===Ym,Jm=(e,t)=>{let o=t;for(;o&&o!==e;){if(Xm(o))return o;o=o.parentNode}return null},Qm=e=>_e(e,"name"),eu=e=>Bt.isArray(e.start),tu=e=>!(!Qm(e)&&y(e.forward))||e.forward,ou=(e,t)=>(Wn(t)&&e.isBlock(t)&&!t.innerHTML&&(t.innerHTML='
'),t),nu=(e,t)=>Km(e).fold(I,(e=>(t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0))),ru=(e,t,o)=>!(!(e=>!e.hasChildNodes())(t)||!Jm(e,t)||(((e,t)=>{var o;const n=(null!==(o=e.ownerDocument)&&void 0!==o?o:document).createTextNode(Br);e.appendChild(n),t.setStart(n,0),t.setEnd(n,0)})(t,o),0)),su=(e,t,o,n)=>{const r=o[t?"start":"end"],s=e.getRoot();if(r){let e=s,o=r[0];for(let t=r.length-1;e&&t>=1;t--){const o=e.childNodes;if(ru(s,e,n))return!0;if(r[t]>o.length-1)return!!ru(s,e,n)||nu(e,n);e=o[r[t]]}tr(e)&&(o=Math.min(r[0],e.data.length)),Wn(e)&&(o=Math.min(r[0],e.childNodes.length)),t?n.setStart(e,o):n.setEnd(e,o)}return!0},au=e=>tr(e)&&e.data.length>0,iu=(e,t,o)=>{const n=e.get(o.id+"_"+t),r=null==n?void 0:n.parentNode,s=o.keep;if(n&&r){let a,i;if("start"===t?s?n.hasChildNodes()?(a=n.firstChild,i=1):au(n.nextSibling)?(a=n.nextSibling,i=0):au(n.previousSibling)?(a=n.previousSibling,i=n.previousSibling.data.length):(a=r,i=e.nodeIndex(n)+1):(a=r,i=e.nodeIndex(n)):s?n.hasChildNodes()?(a=n.firstChild,i=1):au(n.previousSibling)?(a=n.previousSibling,i=n.previousSibling.data.length):(a=r,i=e.nodeIndex(n)):(a=r,i=e.nodeIndex(n)),!s){const r=n.previousSibling,s=n.nextSibling;let l;for(Bt.each(Bt.grep(n.childNodes),(e=>{tr(e)&&(e.data=e.data.replace(/\uFEFF/g,""))}));l=e.get(o.id+"_"+t);)e.remove(l,!0);if(tr(s)&&tr(r)&&!At.browser.isOpera()){const t=r.data.length;r.appendData(s.data),e.remove(s),a=r,i=t}}return F.some(rl(a,i))}return F.none()},lu=(e,t)=>{const o=e.dom;if(t){if(eu(t))return((e,t)=>{const o=e.createRng();return su(e,!0,t,o)&&su(e,!1,t,o)?F.some({range:o,forward:tu(t)}):F.none()})(o,t);if((e=>h(e.start))(t))return((e,t)=>{const o=F.from(pl(e.getRoot(),t.start)),n=F.from(pl(e.getRoot(),t.end));return It(o,n,((o,n)=>{const r=e.createRng();return r.setStart(o.container(),o.offset()),r.setEnd(n.container(),n.offset()),{range:r,forward:tu(t)}}))})(o,t);if((e=>_e(e,"id"))(t))return((e,t)=>{const o=iu(e,"start",t),n=iu(e,"end",t);return It(o,n.or(o),((o,n)=>{const r=e.createRng();return r.setStart(ou(e,o.container()),o.offset()),r.setEnd(ou(e,n.container()),n.offset()),{range:r,forward:tu(t)}}))})(o,t);if(Qm(t))return((e,t)=>F.from(e.select(t.name)[t.index]).map((t=>{const o=e.createRng();return o.selectNode(t),{range:o,forward:!0}})))(o,t);if((e=>_e(e,"rng"))(t))return F.some({range:t.rng,forward:tu(t)})}return F.none()},cu=(e,t,o)=>_l(e,t,o),du=(e,t)=>{lu(e,t).each((({range:t,forward:o})=>{e.setRng(t,o)}))},mu=e=>Wn(e)&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type"),uu=(gu=br,e=>gu===e);var gu;const hu=e=>""!==e&&-1!==" \f\n\r\t\v".indexOf(e),pu=e=>!hu(e)&&!uu(e)&&!yr(e),fu=e=>{const t=[];if(e)for(let o=0;oY((e=>ne(e,(e=>{const t=Hi(e);return t?[yo.fromDom(t)]:[]})))(e),Dr),bu=(e,t)=>{const o=zn(t,"td[data-mce-selected],th[data-mce-selected]");return o.length>0?o:vu(e)},yu=e=>bu(fu(e.selection.getSel()),yo.fromDom(e.getBody())),wu=(e,t)=>en(e,"table",t),xu=e=>Io(e).fold(D([e]),(t=>[e].concat(xu(t)))),Cu=e=>Po(e).fold(D([e]),(t=>"br"===jt(t)?Mo(t).map((t=>[e].concat(Cu(t)))).getOr([]):[e].concat(Cu(t)))),Su=(e,t)=>It((e=>{const t=e.startContainer,o=e.startOffset;return tr(t)?0===o?F.some(yo.fromDom(t)):F.none():F.from(t.childNodes[o]).map(yo.fromDom)})(t),(e=>{const t=e.endContainer,o=e.endOffset;return tr(t)?o===t.data.length?F.some(yo.fromDom(t)):F.none():F.from(t.childNodes[o-1]).map(yo.fromDom)})(t),((t,o)=>{const n=ee(xu(e),N(So,t)),r=ee(Cu(e),N(So,o));return n.isSome()&&r.isSome()})).getOr(!1),ku=(e,t,o,n)=>{const r=o,s=new Zn(o,r),a=xe(e.schema.getMoveCaretBeforeOnEnterElements(),((e,t)=>!j(["td","th","table"],t.toLowerCase())));let i=o;do{if(tr(i)&&0!==Bt.trim(i.data).length)return void(n?t.setStart(i,0):t.setEnd(i,i.data.length));if(a[i.nodeName])return void(n?t.setStartBefore(i):"BR"===i.nodeName?t.setEndBefore(i):t.setEndAfter(i))}while(i=n?s.next():s.prev());"BODY"===r.nodeName&&(n?t.setStart(r,0):t.setEnd(r,r.childNodes.length))},_u=e=>{const t=e.selection.getSel();return C(t)&&t.rangeCount>0},Eu=(e,t)=>{const o=yu(e);o.length>0?q(o,(o=>{const n=o.dom,r=e.dom.createRng();r.setStartBefore(n),r.setEndAfter(n),t(r,!0)})):t(e.selection.getRng(),!1)},Tu=(e,t,o)=>{const n=kl(e,t);o(n),e.moveToBookmark(n)},Ou=e=>k(null==e?void 0:e.nodeType),Du=e=>Wn(e)&&!mu(e)&&!Xm(e)&&!Xn(e),Au=(e,t,o)=>{const{selection:n,dom:r}=e,s=n.getNode(),a=dr(s);Tu(n,!0,(()=>{t()})),a&&dr(s)&&r.isChildOf(s,e.getBody())?e.selection.select(s):o(n.getStart())&&Mu(r,n)},Mu=(e,t)=>{var o,n;const r=t.getRng(),{startContainer:s,startOffset:a}=r;if(!((e,t)=>{if(Du(t)&&!/^(TD|TH)$/.test(t.nodeName)){const o=e.getAttrib(t,"data-mce-selected"),n=parseInt(o,10);return!isNaN(n)&&n>0}return!1})(e,t.getNode())&&Wn(s)){const i=s.childNodes,l=e.getRoot();let c;if(a{if(e){const n=t?"nextSibling":"previousSibling";for(e=o?e:e[n];e;e=e[n])if(Wn(e)||!Lu(e))return e}},Ru=(e,t)=>!!e.getTextBlockElements()[t.nodeName.toLowerCase()]||Ls(e,t),Bu=(e,t,o)=>e.schema.isValidChild(t,o),Lu=(e,t=!1)=>{if(C(e)&&tr(e)){const o=t?e.data.replace(/ /g," "):e.data;return is(o)}return!1},Hu=(e,t)=>{const o=e.dom;return Du(t)&&"false"===o.getContentEditable(t)&&((e,t)=>{const o="[data-mce-cef-wrappable]",n=Ic(e),r=Xe(n)?o:`${o},${n}`;return xo(yo.fromDom(t),r)})(e,t)&&0===o.select('[contenteditable="true"]',t).length},Iu=(e,t)=>S(e)?e(t):(C(t)&&(e=e.replace(/%(\w+)/g,((e,o)=>t[o]||e))),e),Pu=(e,t)=>(t=t||"",e=""+((e=e||"").nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()===t.toLowerCase()),Fu=(e,t)=>{if(x(e))return null;{let o=String(e);return"color"!==t&&"backgroundColor"!==t||(o=Da(o)),"fontWeight"===t&&700===e&&(o="bold"),"fontFamily"===t&&(o=o.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),o}},zu=(e,t,o)=>{const n=e.getStyle(t,o);return Fu(n,o)},Vu=(e,t)=>{let o;return e.getParent(t,(t=>!!Wn(t)&&(o=e.getStyle(t,"text-decoration"),!!o&&"none"!==o))),o},Zu=(e,t,o)=>e.getParents(t,o,e.getRoot()),Uu=(e,t,o)=>{const n=e.formatter.get(t);return C(n)&&W(n,o)},ju=(e,t,o)=>{const n=["inline","block","selector","attributes","styles","classes"],r=e=>xe(e,((e,t)=>W(n,(e=>e===t))));return Uu(e,t,(t=>{const n=r(t);return Uu(e,o,(e=>{const t=r(e);return((e,t,o=i)=>a(o).eq(e,t))(n,t)}))}))},Wu=e=>Ee(e,"block"),$u=e=>Ee(e,"selector"),qu=e=>Ee(e,"inline"),Gu=e=>$u(e)&&!1!==e.expand&&!qu(e),Ku=e=>(e=>{const t=[];let o=e;for(;o;){if(tr(o)&&o.data!==Br||o.childNodes.length>1)return[];Wn(o)&&t.push(o),o=o.firstChild}return t})(e).length>0,Yu=e=>Xm(e.dom)&&Ku(e.dom),Xu=mu,Ju=Zu,Qu=Lu,eg=Ru,tg=(e,t)=>{let o=t;for(;o;){if(Wn(o)&&e.getContentEditable(o))return"false"===e.getContentEditable(o)?o:t;o=o.parentNode}return t},og=(e,t,o,n)=>{const r=t.data;if(e){for(let e=o;e>0;e--)if(n(r.charAt(e-1)))return e}else for(let e=o;eog(e,t,o,(e=>uu(e)||hu(e))),rg=(e,t,o)=>og(e,t,o,pu),sg=(e,t,o,n,r,s)=>{let a;const i=e.getParent(o,e.isBlock)||t,l=(t,o,n)=>{const s=Oi(e),l=r?s.backwards:s.forwards;return F.from(l(t,o,((e,t)=>Xu(e.parentNode)?-1:(a=e,n(r,e,t))),i))};return l(o,n,ng).bind((e=>s?l(e.container,e.offset+(r?-1:0),rg):F.some(e))).orThunk((()=>a?F.some({container:a,offset:r?0:a.length}):F.none()))},ag=(e,t,o,n,r)=>{const s=n[r];tr(n)&&Xe(n.data)&&s&&(n=s);const a=Ju(e,n);for(let n=0;n{var r;let s=o;const a=e.getRoot(),i=t[0];if(Wu(i)&&(s=i.wrapper?null:e.getParent(o,i.block,a)),!s){const t=null!==(r=e.getParent(o,"LI,TD,TH,SUMMARY"))&&void 0!==r?r:a;s=e.getParent(tr(o)?o.parentNode:o,(t=>t!==a&&eg(e.schema,t)),t)}if(s&&Wu(i)&&i.wrapper&&(s=Ju(e,s,"ul,ol").reverse()[0]||s),!s)for(s=o;s&&s[n]&&!e.isBlock(s[n])&&(s=s[n],!Pu(s,"br")););return s||o},lg=(e,t,o,n)=>{const r=o.parentNode;return!C(o[n])&&(!(r!==t&&!x(r)&&!e.isBlock(r))||lg(e,t,r,n))},cg=(e,t,o,n,r)=>{let s=o;const a=r?"previousSibling":"nextSibling",i=e.getRoot();if(tr(o)&&!Qu(o)&&(r?n>0:nXu(e.parentNode)||Xu(e),mg=(e,t,o,n=!1)=>{let{startContainer:r,startOffset:s,endContainer:a,endOffset:i}=t;const l=o[0];return Wn(r)&&r.hasChildNodes()&&(r=Ii(r,s),tr(r)&&(s=0)),Wn(a)&&a.hasChildNodes()&&(a=Ii(a,t.collapsed?i:i-1),tr(a)&&(i=a.data.length)),r=tg(e,r),a=tg(e,a),dg(r)&&(r=Xu(r)?r:r.parentNode,r=t.collapsed?r.previousSibling||r:r.nextSibling||r,tr(r)&&(s=t.collapsed?r.length:0)),dg(a)&&(a=Xu(a)?a:a.parentNode,a=t.collapsed?a.nextSibling||a:a.previousSibling||a,tr(a)&&(i=t.collapsed?0:a.length)),t.collapsed&&(sg(e,e.getRoot(),r,s,!0,n).each((({container:e,offset:t})=>{r=e,s=t})),sg(e,e.getRoot(),a,i,!1,n).each((({container:e,offset:t})=>{a=e,i=t}))),(qu(l)||l.block_expand)&&(qu(l)&&tr(r)&&0!==s||(r=cg(e,o,r,s,!0)),qu(l)&&tr(a)&&i!==a.data.length||(a=cg(e,o,a,i,!1))),Gu(l)&&(r=ag(e,o,t,r,"previousSibling"),a=ag(e,o,t,a,"nextSibling")),(Wu(l)||$u(l))&&(r=ig(e,o,r,"previousSibling"),a=ig(e,o,a,"nextSibling"),Wu(l)&&(e.isBlock(r)||(r=cg(e,o,r,s,!0)),e.isBlock(a)||(a=cg(e,o,a,i,!1)))),Wn(r)&&r.parentNode&&(s=e.nodeIndex(r),r=r.parentNode),Wn(a)&&a.parentNode&&(i=e.nodeIndex(a)+1,a=a.parentNode),{startContainer:r,startOffset:s,endContainer:a,endOffset:i}},ug=(e,t,o)=>{var n;const r=t.startOffset,s=Ii(t.startContainer,r),a=t.endOffset,i=Ii(t.endContainer,a-1),l=e=>{const t=e[0];tr(t)&&t===s&&r>=t.data.length&&e.splice(0,1);const o=e[e.length-1];return 0===a&&e.length>0&&o===i&&tr(o)&&e.splice(e.length-1,1),e},c=(e,t,o)=>{const n=[];for(;e&&e!==o;e=e[t])n.push(e);return n},d=(t,o)=>e.getParent(t,(e=>e.parentNode===o),o),m=(e,t,n)=>{const r=n?"nextSibling":"previousSibling";for(let s=e,a=s.parentNode;s&&s!==t;s=a){a=s.parentNode;const t=c(s===e?s:s[r],r);t.length&&(n||t.reverse(),o(l(t)))}};if(s===i)return o(l([s]));const u=null!==(n=e.findCommonAncestor(s,i))&&void 0!==n?n:e.getRoot();if(e.isChildOf(s,i))return m(s,u,!0);if(e.isChildOf(i,s))return m(i,u);const g=d(s,u)||s,h=d(i,u)||i;m(s,g,!0);const p=c(g===s?g:g.nextSibling,"nextSibling",h===i?h.nextSibling:h);p.length&&o(l(p)),m(i,h)},gg=['pre[class*=language-][contenteditable="false"]',"figure.image","div[data-ephox-embed-iri]","div.tiny-pageembed","div.mce-toc","div[data-mce-toc]"],hg=(e,t,o,n)=>Oo(t).fold((()=>"skipping"),(r=>"br"===n||(e=>Kt(e)&&xr(e)===Br)(t)?"valid":(e=>Gt(e)&&vo(e,ci()))(t)?"existing":Xm(t.dom)?"caret":W(gg,(e=>xo(t,e)))?"valid-block":Bu(e,o,n)&&Bu(e,jt(r),o)?"valid":"invalid-child")),pg=(e,t,o,n,r,s)=>{const{uid:a=t,...i}=o;go(e,ci()),eo(e,`${mi()}`,a),eo(e,`${di()}`,n);const{attributes:l={},classes:c=[]}=r(a,i);if(to(e,l),((e,t)=>{q(t,(t=>{go(e,t)}))})(e,c),s){c.length>0&&eo(e,`${gi()}`,c.join(","));const t=he(l);t.length>0&&eo(e,`${hi()}`,t.join(","))}},fg=e=>{po(e,ci()),so(e,`${mi()}`),so(e,`${di()}`),so(e,`${ui()}`);const t=no(e,`${hi()}`).map((e=>e.split(","))).getOr([]),o=no(e,`${gi()}`).map((e=>e.split(","))).getOr([]);var n;q(t,(t=>so(e,t))),n=e,q(o,(e=>{po(n,e)})),so(e,`${gi()}`),so(e,`${hi()}`)},vg=(e,t,o,n,r)=>{const s=yo.fromTag("span",e);return pg(s,t,o,n,r,!1),s},bg=(e,t,o,n,r,s)=>{const a=[],i=vg(e.getDoc(),o,s,n,r),l=ai(),c=()=>{l.clear()},d=e=>{q(e,m)},m=t=>{switch(hg(e,t,"span",jt(t))){case"invalid-child":{c();const e=Lo(t);d(e),c();break}case"valid-block":c(),pg(t,o,s,n,r,!0);break;case"valid":{const e=l.get().getOrThunk((()=>{const e=ki(i);return a.push(e),l.set(e),e}));yn(t,e);break}}};return ug(e.dom,t,(e=>{c(),(e=>{const t=$(e,yo.fromDom);d(t)})(e)})),a},yg=(e,t,o,n)=>{e.undoManager.transact((()=>{const r=e.selection,s=r.getRng(),a=yu(e).length>0,i=Ci("mce-annotation");if(s.collapsed&&!a&&((e,t)=>{const o=mg(e.dom,t,[{inline:"span"}]);t.setStart(o.startContainer,o.startOffset),t.setEnd(o.endContainer,o.endOffset),e.selection.setRng(t)})(e,s),r.getRng().collapsed&&!a){const s=vg(e.getDoc(),i,n,t,o.decorate);En(s,br),r.getRng().insertNode(s.dom),r.select(s.dom)}else Tu(r,!1,(()=>{Eu(e,(r=>{bg(e,r,i,t,o.decorate,n)}))}))}))},wg=e=>{const t=(()=>{const e={};return{register:(t,o)=>{e[t]={name:t,settings:o}},lookup:t=>ke(e,t).map((e=>e.settings)),getNames:()=>he(e)}})();((e,t)=>{const o=di(),n=e=>F.from(e.attr(o)).bind(t.lookup),r=e=>{var t,o;e.attr(mi(),null),e.attr(di(),null),e.attr(ui(),null);const n=F.from(e.attr(hi())).map((e=>e.split(","))).getOr([]),r=F.from(e.attr(gi())).map((e=>e.split(","))).getOr([]);q(n,(t=>e.attr(t,null)));const s=null!==(o=null===(t=e.attr("class"))||void 0===t?void 0:t.split(" "))&&void 0!==o?o:[],a=ae(s,[ci()].concat(r));e.attr("class",a.length>0?a.join(" "):null),e.attr(gi(),null),e.attr(hi(),null)};e.serializer.addTempAttr(ui()),e.serializer.addAttributeFilter(o,(e=>{for(const t of e)n(t).each((e=>{!1===e.persistent&&("span"===t.name?t.unwrap():r(t))}))}))})(e,t);const o=wi(e,t),n=Jt("span"),r=e=>{q(e,(e=>{n(e)?Sn(e):fg(e)}))};return{register:(e,o)=>{t.register(e,o)},annotate:(o,n)=>{t.lookup(o).each((t=>{yg(e,o,t,n)}))},annotationChanged:(e,t)=>{o.addListener(e,t)},remove:t=>{fi(e,F.some(t)).each((({elements:t})=>{const o=e.selection.getBookmark();r(t),e.selection.moveToBookmark(o)}))},removeAll:t=>{const o=e.selection.getBookmark();fe(yi(e,t),((e,t)=>{r(e)})),e.selection.moveToBookmark(o)},getAll:t=>{const o=yi(e,t);return ve(o,(e=>$(e,(e=>e.dom))))}}},xg=e=>({getBookmark:N(cu,e),moveToBookmark:N(du,e)});xg.isBookmarkNode=mu;const Cg=(e,t,o)=>!o.collapsed&&W(o.getClientRects(),(o=>((e,t,o)=>t>=e.left&&t<=e.right&&o>=e.top&&o<=e.bottom)(o,e,t))),Sg=(e,t,o)=>{e.dispatch(t,o)},kg=(e,t,o,n)=>{e.dispatch("FormatApply",{format:t,node:o,vars:n})},_g=(e,t,o,n)=>{e.dispatch("FormatRemove",{format:t,node:o,vars:n})},Eg=(e,t)=>e.dispatch("SetContent",t),Tg=(e,t)=>e.dispatch("GetContent",t),Og=(e,t)=>e.dispatch("PastePlainTextToggle",{state:t}),Dg={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,modifierPressed:e=>e.shiftKey||e.ctrlKey||e.altKey||Dg.metaKeyPressed(e),metaKeyPressed:e=>At.os.isMacOS()||At.os.isiOS()?e.metaKey:e.ctrlKey&&!e.altKey},Ag="data-mce-selected",Mg=Math.abs,Ng=Math.round,Rg={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},Bg=(e,t)=>{const o=t.dom,n=t.getDoc(),r=document,s=t.getBody();let a,i,l,c,d,m,u,g,h,p,f,v,b,y,w;const x=e=>C(e)&&(lr(e)||o.is(e,"figure.image")),S=e=>gr(e)||o.hasClass(e,"mce-preview-object"),k=e=>{const o=e.target;((e,t)=>{if((e=>"longpress"===e.type||0===e.type.indexOf("touch"))(e)){const o=e.touches[0];return x(e.target)&&!Cg(o.clientX,o.clientY,t)}return x(e.target)&&!Cg(e.clientX,e.clientY,t)})(e,t.selection.getRng())&&!e.isDefaultPrevented()&&t.selection.select(o)},_=e=>o.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?[e,e.firstElementChild]:o.is(e,"figure.image")?[e.querySelector("img")]:[e],E=e=>{const n=kc(t);return!!n&&"false"!==e.getAttribute("data-mce-resize")&&e!==t.getBody()&&(o.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?xo(yo.fromDom(e.firstElementChild),n):xo(yo.fromDom(e),n))},T=(e,n,r)=>{if(C(r)){const s=_(e);q(s,(e=>{e.style[n]||!t.schema.isValid(e.nodeName.toLowerCase(),n)?o.setStyle(e,n,r):o.setAttrib(e,n,""+r)}))}},O=(e,t,o)=>{T(e,"width",t),T(e,"height",o)},D=e=>{let n,r,d,C,k;n=e.screenX-m,r=e.screenY-u,v=n*c[2]+g,b=r*c[3]+h,v=v<5?5:v,b=b<5?5:b,d=(x(a)||S(a))&&!1!==_c(t)?!Dg.modifierPressed(e):Dg.modifierPressed(e),d&&(Mg(n)>Mg(r)?(b=Ng(v*p),v=Ng(b/p)):(v=Ng(b/p),b=Ng(v*p))),O(i,v,b),C=c.startPos.x+n,k=c.startPos.y+r,C=C>0?C:0,k=k>0?k:0,o.setStyles(l,{left:C,top:k,display:"block"}),l.innerHTML=v+" × "+b,c[2]<0&&i.clientWidth<=v&&o.setStyle(i,"left",void 0+(g-v)),c[3]<0&&i.clientHeight<=b&&o.setStyle(i,"top",void 0+(h-b)),n=s.scrollWidth-y,r=s.scrollHeight-w,n+r!==0&&o.setStyles(l,{left:C-n,top:k-r}),f||(((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(t,a,g,h,"corner-"+c.name),f=!0)},A=()=>{const e=f;f=!1,e&&(T(a,"width",v),T(a,"height",b)),o.unbind(n,"mousemove",D),o.unbind(n,"mouseup",A),r!==n&&(o.unbind(r,"mousemove",D),o.unbind(r,"mouseup",A)),o.remove(i),o.remove(l),o.remove(d),M(a),e&&(((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(t,a,v,b,"corner-"+c.name),o.setAttrib(a,"style",o.getAttrib(a,"style"))),t.nodeChanged()},M=e=>{H();const f=o.getPos(e,s),x=f.x,C=f.y,k=e.getBoundingClientRect(),T=k.width||k.right-k.left,M=k.height||k.bottom-k.top;a!==e&&(R(),a=e,v=b=0);const N=t.dispatch("ObjectSelected",{target:e});E(e)&&!N.isDefaultPrevented()?fe(Rg,((e,t)=>{const f=f=>{const v=_(a)[0];var b;m=f.screenX,u=f.screenY,g=v.clientWidth,h=v.clientHeight,p=h/g,c=e,c.name=t,c.startPos={x:T*e[0]+x,y:M*e[1]+C},y=s.scrollWidth,w=s.scrollHeight,d=o.add(s,"div",{class:"mce-resize-backdrop","data-mce-bogus":"all"}),o.setStyles(d,{position:"fixed",left:"0",top:"0",width:"100%",height:"100%"}),i=S(b=a)?o.create("img",{src:At.transparentSrc}):b.cloneNode(!0),o.addClass(i,"mce-clonedresizable"),o.setAttrib(i,"data-mce-bogus","all"),i.contentEditable="false",o.setStyles(i,{left:x,top:C,margin:0}),O(i,T,M),i.removeAttribute(Ag),s.appendChild(i),o.bind(n,"mousemove",D),o.bind(n,"mouseup",A),r!==n&&(o.bind(r,"mousemove",D),o.bind(r,"mouseup",A)),l=o.add(s,"div",{class:"mce-resize-helper","data-mce-bogus":"all"},g+" × "+h)};let v=o.get("mceResizeHandle"+t);v&&o.remove(v),v=o.add(s,"div",{id:"mceResizeHandle"+t,"data-mce-bogus":"all",class:"mce-resizehandle",unselectable:!0,style:"cursor:"+t+"-resize; margin:0; padding:0"}),o.bind(v,"mousedown",(e=>{e.stopImmediatePropagation(),e.preventDefault(),f(e)})),e.elm=v,o.setStyles(v,{left:T*e[0]+x-v.offsetWidth/2,top:M*e[1]+C-v.offsetHeight/2})})):R(!1)},N=ii(M,0),R=(e=!0)=>{N.cancel(),H(),a&&e&&a.removeAttribute(Ag),fe(Rg,((e,t)=>{const n=o.get("mceResizeHandle"+t);n&&(o.unbind(n),o.remove(n))}))},B=(e,t)=>o.isChildOf(e,t),L=n=>{if(f||t.removed||t.composing)return;const r="mousedown"===n.type?n.target:e.getNode(),a=on(yo.fromDom(r),"table,img,figure.image,hr,video,span.mce-preview-object,details").map((e=>e.dom)).filter((e=>o.isEditable(e.parentElement)||"IMG"===e.nodeName&&o.isEditable(e))).getOrUndefined(),i=C(a)?o.getAttrib(a,Ag,"1"):"1";if(q(o.select(`img[${Ag}],hr[${Ag}]`),(e=>{e.removeAttribute(Ag)})),C(a)&&B(a,s)&&t.hasFocus()){I();const t=e.getStart(!0);if(B(t,a)&&B(e.getEnd(!0),a))return o.setAttrib(a,Ag,i),void N.throttle(a)}R()},H=()=>{fe(Rg,(e=>{e.elm&&(o.unbind(e.elm),delete e.elm)}))},I=()=>{try{t.getDoc().execCommand("enableObjectResizing",!1,"false")}catch(e){}};return t.on("init",(()=>{I(),t.on("NodeChange ResizeEditor ResizeWindow ResizeContent drop",L),t.on("keyup compositionend",(e=>{a&&"TABLE"===a.nodeName&&L(e)})),t.on("hide blur",R),t.on("contextmenu longpress",k,!0)})),t.on("remove",H),{isResizable:E,showResizeRect:M,hideResizeRect:R,updateResizeRect:L,destroy:()=>{N.cancel(),a=i=d=null}}},Lg=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Hg=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Ig=Al([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Pg=(e,t,o)=>t(yo.fromDom(o.startContainer),o.startOffset,yo.fromDom(o.endContainer),o.endOffset),Fg=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:D(e),rtl:F.none}),relative:(t,o)=>({ltr:He((()=>Lg(e,t,o))),rtl:He((()=>F.some(Lg(e,o,t))))}),exact:(t,o,n,r)=>({ltr:He((()=>Hg(e,t,o,n,r))),rtl:He((()=>F.some(Hg(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>Ig.rtl(yo.fromDom(e.endContainer),e.endOffset,yo.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>Pg(0,Ig.ltr,o))):Pg(0,Ig.ltr,o)})(0,o)};Ig.ltr,Ig.rtl;const zg=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),Vg=(e,t,o)=>{var n,r;return F.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return F.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),F.some(o)}))},Zg=(e,t,o)=>{var n,r;return F.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))},Ug=document.caretPositionFromPoint?Vg:document.caretRangeFromPoint?Zg:F.none,jg=Al([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Wg={before:jg.before,on:jg.on,after:jg.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(A,A,A)},$g=Al([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),qg={domRange:$g.domRange,relative:$g.relative,exact:$g.exact,exactFromRange:e=>$g.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>yo.fromDom(e.startContainer),relative:(e,t)=>Wg.getStart(e),exact:(e,t,o,n)=>e}))(e);return To(t)},range:zg},Gg=(e,t)=>{const o=jt(e);return"input"===o?Wg.after(e):j(["br","img"],o)?0===t?Wg.before(e):Wg.after(e):Wg.on(e,t)},Kg=(e,t)=>{const o=e.fold(Wg.before,Gg,Wg.after),n=t.fold(Wg.before,Gg,Wg.after);return qg.relative(o,n)},Yg=(e,t,o,n)=>{const r=Gg(e,t),s=Gg(o,n);return qg.relative(r,s)},Xg=(e,t)=>{const o=(t||document).createDocumentFragment();return q(e,(e=>{o.appendChild(e.dom)})),yo.fromDom(o)},Jg=e=>{const t=qg.getWin(e).dom,o=(e,o,n,r)=>Hg(t,e,o,n,r),n=(e=>e.match({domRange:e=>{const t=yo.fromDom(e.startContainer),o=yo.fromDom(e.endContainer);return Yg(t,e.startOffset,o,e.endOffset)},relative:Kg,exact:Yg}))(e);return Fg(t,n).match({ltr:o,rtl:o})},Qg=(e,t,o)=>((e,t,o)=>{const n=yo.fromDom(e.document);return Ug(n,t,o).map((e=>zg(yo.fromDom(e.startContainer),e.startOffset,yo.fromDom(e.endContainer),e.endOffset)))})(e,t,o),eh=(e,t,o)=>{const n=To(yo.fromDom(o));return Qg(n.dom,e,t).map((e=>{const t=o.createRange();return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),t})).getOrUndefined()},th=(e,t)=>C(e)&&C(t)&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset,oh=(e,t,o)=>null!==((e,t,o)=>{let n=e;for(;n&&n!==t;){if(o(n))return n;n=n.parentNode}return null})(e,t,o),nh=(e,t,o)=>oh(e,t,(e=>e.nodeName===o)),rh=(e,t)=>Vr(e)&&!oh(e,t,Xm),sh=(e,t,o)=>{const n=t.parentNode;if(n){const r=new Zn(t,e.getParent(n,e.isBlock)||e.getRoot());let s;for(;s=r[o?"prev":"next"]();)if(ir(s))return!0}return!1},ah=(e,t,o,n,r)=>{const s=e.getRoot(),a=e.schema.getNonEmptyElements(),i=r.parentNode;let l,c;if(!i)return F.none();const d=e.getParent(i,e.isBlock)||s;if(n&&ir(r)&&t&&e.isEmpty(d))return F.some(rl(i,e.nodeIndex(r)));const m=new Zn(r,d);for(;c=m[n?"prev":"next"]();){if("false"===e.getContentEditableParent(c)||rh(c,s))return F.none();if(tr(c)&&c.data.length>0)return nh(c,s,"A")?F.none():F.some(rl(c,n?c.data.length:0));if(e.isBlock(c)||a[c.nodeName.toLowerCase()])return F.none();l=c}return rr(l)?F.none():o&&l?F.some(rl(l,0)):F.none()},ih=(e,t,o,n)=>{const r=e.getRoot();let s,a=!1,i=o?n.startContainer:n.endContainer,l=o?n.startOffset:n.endOffset;const c=Wn(i)&&l===i.childNodes.length,d=e.schema.getNonEmptyElements();let m=o;if(Vr(i))return F.none();if(Wn(i)&&l>i.childNodes.length-1&&(m=!1),sr(i)&&(i=r,l=0),i===r){if(m&&(s=i.childNodes[l>0?l-1:0],s)){if(Vr(s))return F.none();if(d[s.nodeName]||Jn(s))return F.none()}if(i.hasChildNodes()){if(l=Math.min(!m&&l>0?l-1:l,i.childNodes.length-1),i=i.childNodes[l],l=tr(i)&&c?i.data.length:0,!t&&i===r.lastChild&&Jn(i))return F.none();if(((e,t)=>{let o=t;for(;o&&o!==e;){if(dr(o))return!0;o=o.parentNode}return!1})(r,i)||Vr(i))return F.none();if(pr(i))return F.none();if(i.hasChildNodes()&&!Jn(i)){s=i;const t=new Zn(i,r);do{if(dr(s)||Vr(s)){a=!1;break}if(tr(s)&&s.data.length>0){l=m?0:s.data.length,i=s,a=!0;break}if(d[s.nodeName.toLowerCase()]&&!ur(s)){l=e.nodeIndex(s),i=s.parentNode,m||l++,a=!0;break}}while(s=m?t.next():t.prev())}}}return t&&(tr(i)&&0===l&&ah(e,c,t,!0,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),Wn(i)&&(s=i.childNodes[l],s||(s=i.childNodes[l-1]),!s||!ir(s)||((e,t)=>{var o;return(null===(o=e.previousSibling)||void 0===o?void 0:o.nodeName)===t})(s,"A")||sh(e,s,!1)||sh(e,s,!0)||ah(e,c,t,!0,s).each((e=>{i=e.container(),l=e.offset(),a=!0})))),m&&!t&&tr(i)&&l===i.data.length&&ah(e,c,t,!1,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),a&&i?F.some(rl(i,l)):F.none()},lh=(e,t)=>{const o=t.collapsed,n=t.cloneRange(),r=rl.fromRangeStart(t);return ih(e,o,!0,n).each((e=>{o&&rl.isAbove(r,e)||n.setStart(e.container(),e.offset())})),o||ih(e,o,!1,n).each((e=>{n.setEnd(e.container(),e.offset())})),o&&n.collapse(!0),th(t,n)?F.none():F.some(n)},ch=(e,t)=>e.splitText(t),dh=e=>{let t=e.startContainer,o=e.startOffset,n=e.endContainer,r=e.endOffset;if(t===n&&tr(t)){if(o>0&&oo){r-=o;const e=ch(n,r).previousSibling;t=n=e,r=e.data.length,o=0}else r=0}else if(tr(t)&&o>0&&o0&&r({walk:(t,o)=>ug(e,t,o),split:dh,expand:(t,o={type:"word"})=>{if("word"===o.type){const o=mg(e,t,[{inline:"span"}]),n=e.createRng();return n.setStart(o.startContainer,o.startOffset),n.setEnd(o.endContainer,o.endOffset),n}return t},normalize:t=>lh(e,t).fold(I,(e=>(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),!0)))});mh.compareRanges=th,mh.getCaretRangeFromPoint=eh,mh.getSelectedNode=Hi,mh.getNode=Ii;const uh=((e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=dn(o,e);return parseFloat(t)||0}return n},n=(e,t)=>J(t,((t,o)=>{const n=dn(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!k(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;sn(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}})("height",(e=>{const t=e.dom;return Go(e)?t.getBoundingClientRect().height:t.offsetHeight})),gh=()=>yo.fromDom(document),hh=(e,t)=>e.view(t).fold(D([]),(t=>{const o=e.owner(t),n=hh(e,o);return[t].concat(n)}));var ph=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?F.none():F.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(yo.fromDom)},owner:e=>Eo(e)});const fh=e=>{const t=gh(),o=Bn(t),n=((e,t)=>{const o=t.owner(e);return hh(t,o)})(e,ph),r=Rn(e),s=X(n,((e,t)=>{const o=Rn(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return Mn(s.left+r.left+o.left,s.top+r.top+o.top)},vh=e=>"textarea"===jt(e),bh=(e,t)=>{const o=(e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return Mn(o.offsetLeft,o.offsetTop);const s=Nn(null==n?void 0:n.pageYOffset,r.scrollTop),a=Nn(null==n?void 0:n.pageXOffset,r.scrollLeft),i=Nn(r.clientTop,o.clientTop),l=Nn(r.clientLeft,o.clientLeft);return Rn(e).translate(a-l,s-i)})(e),n=(e=>uh.get(e))(e);return{element:e,bottom:o.top+n,height:n,pos:o,cleanup:t}},yh=(e,t)=>{const o=((e,t)=>{const o=Lo(e);if(0===o.length||vh(e))return{element:e,offset:t};if(t\ufeff');return pn(o.element,n),bh(n,(()=>Cn(n)))},wh=(e,t,o,n)=>{kh(e,((r,s)=>Ch(e,t,o,n)),o)},xh=(e,t,o,n,r)=>{const s={elm:n.element.dom,alignToTop:r};((e,t)=>e.dispatch("ScrollIntoView",t).isDefaultPrevented())(e,s)||(o(e,t,Bn(t).top,n,r),((e,t)=>{e.dispatch("AfterScrollIntoView",t)})(e,s))},Ch=(e,t,o,n)=>{const r=yo.fromDom(e.getBody()),s=yo.fromDom(e.getDoc());r.dom.offsetWidth;const a=yh(yo.fromDom(o.startContainer),o.startOffset);xh(e,s,t,a,n),a.cleanup()},Sh=(e,t,o,n)=>{const r=yo.fromDom(e.getDoc());xh(e,r,o,(e=>bh(yo.fromDom(e),E))(t),n)},kh=(e,t,o)=>{const n=o.startContainer,r=o.startOffset,s=o.endContainer,a=o.endOffset;t(yo.fromDom(n),yo.fromDom(s));const i=e.dom.createRng();i.setStart(n,r),i.setEnd(s,a),e.selection.setRng(o)},_h=(e,t,o,n,r)=>{const s=t.pos;if(n)Ln(s.left,s.top,r);else{const n=s.top-o+t.height;Ln(-e.getBody().getBoundingClientRect().left,n,r)}},Eh=(e,t,o,n,r,s)=>{const a=n+o,i=r.pos.top,l=r.bottom,c=l-i>=n;ia?_h(e,r,n,c?!1!==s:!0===s,t):l>a&&!c&&_h(e,r,n,!0===s,t)},Th=(e,t,o,n,r)=>{const s=To(t).dom.innerHeight;Eh(e,t,o,s,n,r)},Oh=(e,t,o,n,r)=>{const s=To(t).dom.innerHeight;Eh(e,t,o,s,n,r);const a=fh(n.element),i=Pn(window);a.topi.bottom&&Hn(n.element,!0===r)},Dh=(e,t,o)=>wh(e,Th,t,o),Ah=(e,t,o)=>Sh(e,t,Th,o),Mh=(e,t,o)=>wh(e,Oh,t,o),Nh=(e,t,o)=>Sh(e,t,Oh,o),Rh=(e,t,o)=>{(e.inline?Dh:Mh)(e,t,o)},Bh=(e,t=!1)=>e.dom.focus({preventScroll:t}),Lh=e=>{const t=Uo(e).dom;return e.dom===t.activeElement},Hh=(e=gh())=>F.from(e.dom.activeElement).map(yo.fromDom),Ih=(e,t)=>{const o=Kt(t)?xr(t).length:Lo(t).length+1;return e>o?o:e<0?0:e},Ph=e=>qg.range(e.start,Ih(e.soffset,e.start),e.finish,Ih(e.foffset,e.finish)),Fh=(e,t)=>!jn(t.dom)&&(ko(e,t)||So(e,t)),zh=e=>t=>Fh(e,t.start)&&Fh(e,t.finish),Vh=e=>qg.range(yo.fromDom(e.startContainer),e.startOffset,yo.fromDom(e.endContainer),e.endOffset),Zh=e=>(e=>{const t=e.getSelection();return(t&&0!==t.rangeCount?F.from(t.getRangeAt(0)):F.none()).map(Vh)})(To(e).dom).filter(zh(e)),Uh=e=>{const t=document.createRange();try{return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),F.some(t)}catch(e){return F.none()}},jh=e=>{const t=(e=>e.inline||At.browser.isFirefox())(e)?Zh(yo.fromDom(e.getBody())):F.none();e.bookmark=t.isSome()?t:e.bookmark},Wh=e=>(e.bookmark?e.bookmark:F.none()).bind((t=>((e,t)=>F.from(t).filter(zh(e)).map(Ph))(yo.fromDom(e.getBody()),t))).bind(Uh),$h={isEditorUIElement:e=>{const t=e.className.toString();return-1!==t.indexOf("tox-")||-1!==t.indexOf("mce-")}},qh={setEditorTimeout:(e,t,o)=>((e,t)=>(k(t)||(t=0),setTimeout(e,t)))((()=>{e.removed||t()}),o),setEditorInterval:(e,t,o)=>{const n=((e,t)=>(k(t)||(t=0),setInterval(e,t)))((()=>{e.removed?clearInterval(n):t()}),o);return n}},Gh=e=>{const t=ii((()=>{jh(e)}),0);e.on("init",(()=>{e.inline&&((e,t)=>{const o=()=>{t.throttle()};Ya.DOM.bind(document,"mouseup",o),e.on("remove",(()=>{Ya.DOM.unbind(document,"mouseup",o)}))})(e,t),((e,t)=>{((e,t)=>{e.on("mouseup touchend",(e=>{t.throttle()}))})(e,t),e.on("keyup NodeChange AfterSetSelectionRange",(t=>{(e=>"nodechange"===e.type&&e.selectionChange)(t)||jh(e)}))})(e,t)})),e.on("remove",(()=>{t.cancel()}))};let Kh;const Yh=Ya.DOM,Xh=e=>{const t=e.classList;return void 0!==t&&(t.contains("tox-edit-area")||t.contains("tox-edit-area__iframe")||t.contains("mce-content-body"))},Jh=(e,t)=>{const o=Pc(e),n=Yh.getParent(t,(t=>(e=>Wn(e)&&$h.isEditorUIElement(e))(t)||!!o&&e.dom.is(t,o)));return null!==n},Qh=e=>{try{const t=Uo(yo.fromDom(e.getElement()));return Hh(t).fold((()=>document.body),(e=>e.dom))}catch(e){return document.body}},ep=(e,t)=>{const o=t.editor;Gh(o);const n=(e,t)=>{Ed(e)&&!0!==e.inline&&t(yo.fromDom(e.getContainer()),"tox-edit-focus")};o.on("focusin",(()=>{const t=e.focusedEditor;Xh(Qh(o))&&n(o,go),t!==o&&(t&&t.dispatch("blur",{focusedEditor:o}),e.setActive(o),e.focusedEditor=o,o.dispatch("focus",{blurredEditor:t}),o.focus(!0))})),o.on("focusout",(()=>{qh.setEditorTimeout(o,(()=>{const t=e.focusedEditor;Xh(Qh(o))&&t===o||n(o,po),Jh(o,Qh(o))||t!==o||(o.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null)}))})),Kh||(Kh=t=>{const o=e.activeEditor;o&&$o(t).each((t=>{const n=t;n.ownerDocument===document&&(n===document.body||Jh(o,n)||e.focusedEditor!==o||(o.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null))}))},Yh.bind(document,"focusin",Kh))},tp=(e,t)=>{e.focusedEditor===t.editor&&(e.focusedEditor=null),!e.activeEditor&&Kh&&(Yh.unbind(document,"focusin",Kh),Kh=null)},op=(e,t)=>(e=>e.collapsed?F.from(Ii(e.startContainer,e.startOffset)).map(yo.fromDom):F.none())(t).bind((t=>Or(t)?F.some(t):ko(e,t)?F.none():F.some(e))),np=(e,t)=>{op(yo.fromDom(e.getBody()),t).bind((e=>Gm(e.dom))).fold((()=>{e.selection.normalize()}),(t=>e.selection.setRng(t.toRange())))},rp=e=>{if(e.setActive)try{e.setActive()}catch(t){e.focus()}else e.focus()},sp=e=>{return Lh(e)||(t=e,Hh(Uo(t)).filter((e=>t.dom.contains(e.dom)))).isSome();var t},ap=e=>e.inline?(e=>{const t=e.getBody();return t&&sp(yo.fromDom(t))})(e):(e=>C(e.iframeElement)&&Lh(yo.fromDom(e.iframeElement)))(e),ip=e=>ap(e)||(e=>{const t=Uo(yo.fromDom(e.getElement()));return Hh(t).filter((t=>!Xh(t.dom)&&Jh(e,t.dom))).isSome()})(e),lp=e=>e.editorManager.setActive(e),cp=(e,t)=>{e.removed||(t?lp(e):(e=>{const t=e.selection,o=e.getBody();let n=t.getRng();e.quirks.refreshContentEditable(),C(e.bookmark)&&!ap(e)&&Wh(e).each((t=>{e.selection.setRng(t),n=t}));const r=((e,t)=>e.dom.getParent(t,(t=>"true"===e.dom.getContentEditable(t))))(e,t.getNode());if(r&&e.dom.isChildOf(r,o))return rp(r),np(e,n),void lp(e);e.inline||(At.browser.isOpera()||rp(o),e.getWin().focus()),(At.browser.isFirefox()||e.inline)&&(rp(o),np(e,n)),lp(e)})(e))},dp=(e,t)=>t.collapsed?e.isEditable(t.startContainer):e.isEditable(t.startContainer)&&e.isEditable(t.endContainer),mp=(e,t,o,n,r)=>{const s=o?t.startContainer:t.endContainer,a=o?t.startOffset:t.endOffset;return F.from(s).map(yo.fromDom).map((e=>n&&t.collapsed?e:Ho(e,r(e,a)).getOr(e))).bind((e=>Gt(e)?F.some(e):Oo(e).filter(Gt))).map((e=>e.dom)).getOr(e)},up=(e,t,o=!1)=>mp(e,t,!0,o,((e,t)=>Math.min(Fo(e),t))),gp=(e,t,o=!1)=>mp(e,t,!1,o,((e,t)=>t>0?t-1:t)),hp=(e,t)=>{const o=e;for(;e&&tr(e)&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||o},pp=(e,t)=>$(t,(t=>{const o=e.dispatch("GetSelectionRange",{range:t});return o.range!==t?o.range:t})),fp=["img","br"],vp=e=>{const t=Cr(e).filter((e=>0!==e.trim().length||e.indexOf(br)>-1)).isSome();return t||j(fp,jt(e))||(e=>qt(e)&&"false"===oo(e,"contenteditable"))(e)},bp=(e,t)=>{const o=e=>{const n=Lo(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return F.some(r);const s=o(r);if(s.isSome())return s}return F.none()};return o(e)},yp="[data-mce-autocompleter]",wp=(e,t)=>{if(xp(yo.fromDom(e.getBody())).isNone()){const n=yo.fromHtml('',e.getDoc());bn(n,yo.fromDom(t.extractContents())),t.insertNode(n.dom),Oo(n).each((e=>e.dom.normalize())),(o=n,bp(o,vp)).map((t=>{e.selection.setCursorLocation(t.dom,(e=>"img"===jt(e)?1:Cr(e).fold((()=>Lo(e).length),(e=>e.length)))(t))}))}var o},xp=e=>tn(e,yp),Cp={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},Sp=(e,t,o)=>{const n=o?"lastChild":"firstChild",r=o?"prev":"next";if(e[n])return e[n];if(e!==t){let o=e[r];if(o)return o;for(let n=e.parent;n&&n!==t;n=n.parent)if(o=n[r],o)return o}},kp=e=>{var t;const o=null!==(t=e.value)&&void 0!==t?t:"";if(!is(o))return!1;const n=e.parent;return!n||"span"===n.name&&!n.attr("style")||!/^[ ]+$/.test(o)},_p=e=>{const t="a"===e.name&&!e.attr("href")&&e.attr("id");return e.attr("name")||e.attr("id")&&!e.firstChild||e.attr("data-mce-bookmark")||t};class Ep{static create(e,t){const o=new Ep(e,Cp[e]||1);return t&&fe(t,((e,t)=>{o.attr(t,e)})),o}constructor(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}replace(e){const t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t}attr(e,t){const o=this;if(!h(e))return C(e)&&fe(e,((e,t)=>{o.attr(t,e)})),o;const n=o.attributes;if(n){if(void 0!==t){if(null===t){if(e in n.map){delete n.map[e];let t=n.length;for(;t--;)if(n[t].name===e)return n.splice(t,1),o}return o}if(e in n.map){let o=n.length;for(;o--;)if(n[o].name===e){n[o].value=t;break}}else n.push({name:e,value:t});return n.map[e]=t,o}return n.map[e]}}clone(){const e=this,t=new Ep(e.name,e.type),o=e.attributes;if(o){const e=[];e.map={};for(let t=0,n=o.length;th(e.nodeValue)&&e.nodeValue.includes(Br),Dp=e=>(0===e.length?"":`${$(e,(e=>`[${e}]`)).join(",")},`)+'[data-mce-bogus="all"]',Ap=e=>document.createTreeWalker(e,NodeFilter.SHOW_COMMENT,(e=>Op(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP)),Mp=e=>document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>{if(Op(e)){const t=e.parentNode;return t&&_e(Tp,t.nodeName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}return NodeFilter.FILTER_SKIP})),Np=e=>null!==Ap(e).nextNode(),Rp=e=>null!==Mp(e).nextNode(),Bp=(e,t)=>null!==t.querySelector(Dp(e)),Lp=(e,t)=>{q(((e,t)=>t.querySelectorAll(Dp(e)))(e,t),(t=>{const o=yo.fromDom(t);"all"===oo(o,"data-mce-bogus")?Cn(o):q(e,(e=>{ro(o,e)&&so(o,e)}))}))},Hp=e=>{let t=e.nextNode();for(;null!==t;)t.nodeValue=null,t=e.nextNode()},Ip=T(Hp,Ap),Pp=T(Hp,Mp),Fp=(e,t)=>{const o=[{condition:N(Bp,t),action:N(Lp,t)},{condition:Np,action:Ip},{condition:Rp,action:Pp}];let n=e,r=!1;return q(o,(({condition:t,action:o})=>{t(n)&&(r||(n=e.cloneNode(!0),r=!0),o(n))})),n},zp=e=>{const t=zn(e,"[data-mce-bogus]");q(t,(e=>{"all"===oo(e,"data-mce-bogus")?Cn(e):kr(e)?(pn(e,yo.fromText(vr)),Cn(e)):Sn(e)}))},Vp=e=>{const t=zn(e,"input");q(t,(e=>{so(e,"name")}))},Zp=(e,t)=>{const o=e.getDoc(),n=Uo(yo.fromDom(e.getBody())),r=yo.fromTag("div",o);eo(r,"data-mce-bogus","all"),cn(r,{position:"fixed",left:"-9999999px",top:"0"}),En(r,t.innerHTML),zp(r),Vp(r);const s=(e=>zo(e)?e:yo.fromDom(Eo(e).dom.body))(n);bn(s,r);const a=Hr(r.dom.innerText);return Cn(r),a},Up=(e,t,o)=>{let n;return n="raw"===t.format?Bt.trim(Hr(Fp(o,e.serializer.getTempAttrs()).innerHTML)):"text"===t.format?Zp(e,o):"tree"===t.format?e.serializer.serialize(o,t):((e,t)=>{const o=Xl(e),n=new RegExp(`^(<${o}[^>]*>( | |\\s| |
|)<\\/${o}>[\r\n]*|
[\r\n]*)$`);return t.replace(n,"")})(e,e.serializer.serialize(o,t)),"text"!==t.format&&!Ar(yo.fromDom(o))&&h(n)?Bt.trim(n):n},jp=Bt.makeMap,Wp=e=>{const t=[],o=(e=e||{}).indent,n=jp(e.indent_before||""),r=jp(e.indent_after||""),s=ia.getEncodeFunc(e.entity_encoding||"raw",e.entities),a="xhtml"!==e.element_format;return{start:(e,i,l)=>{if(o&&n[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}if(t.push("<",e),i)for(let e=0,o=i.length;e":" />",l&&o&&r[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}},end:e=>{let n;t.push(""),o&&r[e]&&t.length>0&&(n=t[t.length-1],n.length>0&&"\n"!==n&&t.push("\n"))},text:(e,o)=>{e.length>0&&(t[t.length]=o?e:s(e))},cdata:e=>{t.push("")},comment:e=>{t.push("\x3c!--",e,"--\x3e")},pi:(e,n)=>{n?t.push(""):t.push(""),o&&t.push("\n")},doctype:e=>{t.push("",o?"\n":"")},reset:()=>{t.length=0},getContent:()=>t.join("").replace(/\n$/,"")}},$p=(e={},t=ya())=>{const o=Wp(e);return e.validate=!("validate"in e)||e.validate,{serialize:n=>{const r=e.validate,s={3:e=>{var t;o.text(null!==(t=e.value)&&void 0!==t?t:"",e.raw)},8:e=>{var t;o.comment(null!==(t=e.value)&&void 0!==t?t:"")},7:e=>{o.pi(e.name,e.value)},10:e=>{var t;o.doctype(null!==(t=e.value)&&void 0!==t?t:"")},4:e=>{var t;o.cdata(null!==(t=e.value)&&void 0!==t?t:"")},11:e=>{let t=e;if(t=t.firstChild)do{a(t)}while(t=t.next)}};o.reset();const a=e=>{var n;const i=s[e.type];if(i)i(e);else{const s=e.name,i=s in t.getVoidElements();let l=e.attributes;if(r&&l&&l.length>1){const o=[];o.map={};const n=t.getElementRule(e.name);if(n){for(let e=0,t=n.attributesOrder.length;e{qp.add(e)}));const Gp=["font","text-decoration","text-emphasis"],Kp=(e,t)=>he(e.parseStyle(e.getAttrib(t,"style"))),Yp=(e,t)=>re(Kp(e,t),(e=>!(e=>qp.has(e))(e))),Xp=(e,t,o)=>{const n=Kp(e,t),r=Kp(e,o),s=n=>{var r,s;const a=null!==(r=e.getStyle(t,n))&&void 0!==r?r:"",i=null!==(s=e.getStyle(o,n))&&void 0!==s?s:"";return Ye(a)&&Ye(i)&&a!==i};return W(n,(e=>{const t=t=>W(t,(t=>t===e));if(!t(r)&&t(Gp)){const e=Y(r,(e=>W(Gp,(t=>je(e,t)))));return W(e,s)}return s(e)}))},Jp=(e,t,o)=>F.from(o.container()).filter(tr).exists((n=>{const r=e?0:-1;return t(n.data.charAt(o.offset()+r))})),Qp=N(Jp,!0,hu),ef=N(Jp,!1,hu),tf=e=>{const t=e.container();return tr(t)&&(0===t.data.length||Lr(t.data)&&xg.isBookmarkNode(t.parentNode))},of=(e,t)=>o=>hm(e?0:-1,o).filter(t).isSome(),nf=e=>lr(e)&&"block"===dn(yo.fromDom(e),"display"),rf=e=>dr(e)&&!(e=>Wn(e)&&"all"===e.getAttribute("data-mce-bogus"))(e),sf=of(!0,nf),af=of(!1,nf),lf=of(!0,gr),cf=of(!1,gr),df=of(!0,Jn),mf=of(!1,Jn),uf=of(!0,rf),gf=of(!1,rf),hf=(e,t)=>((e,t,o)=>ko(t,e)?Ao(e,(e=>o(e)||So(e,t))).slice(0,-1):[])(e,t,I),pf=(e,t)=>[e].concat(hf(e,t)),ff=(e,t,o)=>jm(e,t,o,tf),vf=(e,t,o)=>ee(pf(yo.fromDom(t.container()),e),(e=>t=>e.isBlock(jt(t)))(o)),bf=(e,t,o,n)=>ff(e,t.dom,o).forall((e=>vf(t,o,n).fold((()=>!gm(e,o,t.dom)),(n=>!gm(e,o,t.dom)&&ko(n,yo.fromDom(e.container())))))),yf=(e,t,o,n)=>vf(t,o,n).fold((()=>ff(e,t.dom,o).forall((e=>!gm(e,o,t.dom)))),(t=>ff(e,t.dom,o).isNone())),wf=N(yf,!1),xf=N(yf,!0),Cf=N(bf,!1),Sf=N(bf,!0),kf=e=>Sm(e).exists(kr),_f=(e,t,o,n)=>{const r=Y(pf(yo.fromDom(o.container()),t),(e=>n.isBlock(jt(e)))),s=de(r).getOr(t);return Zm(e,s.dom,o).filter(kf)},Ef=(e,t,o)=>Sm(t).exists(kr)||_f(!0,e,t,o).isSome(),Tf=(e,t,o)=>(e=>F.from(e.getNode(!0)).map(yo.fromDom))(t).exists(kr)||_f(!1,e,t,o).isSome(),Of=N(_f,!1),Df=N(_f,!0),Af=e=>rl.isTextPosition(e)&&!e.isAtStart()&&!e.isAtEnd(),Mf=(e,t,o)=>{const n=Y(pf(yo.fromDom(t.container()),e),(e=>o.isBlock(jt(e))));return de(n).getOr(e)},Nf=(e,t,o)=>Af(t)?ef(t):ef(t)||qm(Mf(e,t,o).dom,t).exists(ef),Rf=(e,t,o)=>Af(t)?Qp(t):Qp(t)||$m(Mf(e,t,o).dom,t).exists(Qp),Bf=e=>Sm(e).bind((e=>Xo(e,Gt))).exists((e=>(e=>j(["pre","pre-wrap"],e))(dn(e,"white-space")))),Lf=(e,t,o)=>((e,t)=>qm(e.dom,t).isNone())(e,t)||((e,t)=>$m(e.dom,t).isNone())(e,t)||wf(e,t,o)||xf(e,t,o)||Tf(e,t,o)||Ef(e,t,o),Hf=(e,t)=>o=>{return n=new Zn(o,e)[t](),C(n)&&dr(n)&&om(n);var n},If=(e,t,o)=>!Bf(t)&&(Lf(e,t,o)||Nf(e,t,o)||Rf(e,t,o)),Pf=(e,t,o)=>!Bf(t)&&(wf(e,t,o)||Cf(e,t,o)||Tf(e,t,o)||Nf(e,t,o)||((e,t)=>{const o=qm(e.dom,t).getOr(t),n=Hf(e.dom,"prev");return t.isAtStart()&&(n(t.container())||n(o.container()))})(e,t)),Ff=(e,t,o)=>!Bf(t)&&(xf(e,t,o)||Sf(e,t,o)||Ef(e,t,o)||Rf(e,t,o)||((e,t)=>{const o=$m(e.dom,t).getOr(t),n=Hf(e.dom,"next");return t.isAtEnd()&&(n(t.container())||n(o.container()))})(e,t)),zf=(e,t,o)=>Pf(e,t,o)||Ff(e,(e=>{const t=e.container(),o=e.offset();return tr(t)&&ouu(e.charAt(t)),Zf=(e,t)=>hu(e.charAt(t)),Uf=(e,t,o,n)=>{const r=t.data,s=rl(t,0);return o||!Vf(r,0)||zf(e,s,n)?!!(o&&Zf(r,0)&&Pf(e,s,n))&&(t.data=br+r.slice(1),!0):(t.data=" "+r.slice(1),!0)},jf=e=>{const t=e.data,o=(e=>{const t=e.split("");return $(t,((e,o)=>uu(e)&&o>0&&o{const r=t.data,s=rl(t,r.length-1);return o||!Vf(r,r.length-1)||zf(e,s,n)?!!(o&&Zf(r,r.length-1)&&Ff(e,s,n))&&(t.data=r.slice(0,-1)+br,!0):(t.data=r.slice(0,-1)+" ",!0)},$f=(e,t,o)=>{const n=t.container();if(!tr(n))return F.none();if((e=>{const t=e.container();return tr(t)&&Ue(t.data,br)})(t)){const r=Uf(e,n,!1,o)||jf(n)||Wf(e,n,!1,o);return Pt(r,t)}if(zf(e,t,o)){const r=Uf(e,n,!0,o)||Wf(e,n,!0,o);return Pt(r,t)}return F.none()},qf=(e,t,o,n)=>{if(0===o)return;const r=yo.fromDom(e),s=Yo(r,(e=>n.isBlock(jt(e)))).getOr(r),a=e.data.slice(t,t+o),i=t+o>=e.data.length&&Ff(s,rl(e,e.data.length),n),l=0===t&&Pf(s,rl(e,0),n);e.replaceData(t,o,ds(a,4,l,i))},Gf=(e,t,o)=>{const n=e.data.slice(t),r=n.length-Ge(n).length;qf(e,t,r,o)},Kf=(e,t,o)=>{const n=e.data.slice(0,t),r=n.length-Ke(n).length;qf(e,t-r,r,o)},Yf=(e,t,o,n,r=!0)=>{const s=Ke(e.data).length,a=r?e:t,i=r?t:e;return r?a.appendData(i.data):a.insertData(0,i.data),Cn(yo.fromDom(i)),n&&Gf(a,s,o),a},Xf=(e,t)=>((e,t)=>{const o=e.container(),n=e.offset();return!rl.isTextPosition(e)&&o===t.parentNode&&n>rl.before(t).offset()})(t,e)?rl(t.container(),t.offset()-1):t,Jf=e=>{return ns(e.previousSibling)?F.some((t=e.previousSibling,tr(t)?rl(t,t.data.length):rl.after(t))):e.previousSibling?Km(e.previousSibling):F.none();var t},Qf=e=>{return ns(e.nextSibling)?F.some((t=e.nextSibling,tr(t)?rl(t,0):rl.before(t))):e.nextSibling?Gm(e.nextSibling):F.none();var t},ev=(e,t)=>Jf(t).orThunk((()=>Qf(t))).orThunk((()=>((e,t)=>F.from(t.previousSibling?t.previousSibling:t.parentNode).bind((t=>qm(e,rl.before(t)))).orThunk((()=>$m(e,rl.after(t)))))(e,t))),tv=(e,t)=>Qf(t).orThunk((()=>Jf(t))).orThunk((()=>((e,t)=>$m(e,rl.after(t)).orThunk((()=>qm(e,rl.before(t)))))(e,t))),ov=(e,t,o)=>((e,t,o)=>e?tv(t,o):ev(t,o))(e,t,o).map(N(Xf,o)),nv=(e,t,o)=>{o.fold((()=>{e.focus()}),(o=>{e.selection.setRng(o.toRange(),t)}))},rv=(e,t)=>t&&_e(e.schema.getBlockElements(),jt(t)),sv=(e,t,o,n)=>{const r=Mo(e).filter(Kt),s=No(e).filter(Kt);return Cn(e),(a=r,i=s,l=t,c=(e,t,r)=>{const s=e.dom,a=t.dom,i=s.data.length;return Yf(s,a,o,n),r.container()===a?rl(s,i):r},a.isSome()&&i.isSome()&&l.isSome()?F.some(c(a.getOrDie(),i.getOrDie(),l.getOrDie())):F.none()).orThunk((()=>(n&&(r.each((e=>Kf(e.dom,e.dom.length,o))),s.each((e=>Gf(e.dom,0,o)))),t)));var a,i,l,c},av=(e,t,o,n=!0,r=!1)=>{const s=ov(t,e.getBody(),o.dom),a=Yo(o,N(rv,e),(i=e.getBody(),e=>e.dom===i));var i;const l=sv(o,s,e.schema,((e,t)=>_e(e.schema.getTextInlineElements(),jt(t)))(e,o));e.dom.isEmpty(e.getBody())?(e.setContent(""),e.selection.setCursorLocation()):a.bind((e=>((e,t)=>{if(ys(e)){const o=yo.fromHtml('
');return t?q(Lo(e),(e=>{Yu(e)||Cn(e)})):xn(e),bn(e,o),F.some(rl.before(o.dom))}return F.none()})(e,r))).fold((()=>{n&&nv(e,t,l)}),(o=>{n&&nv(e,t,F.some(o))}))},iv=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,lv=(e,t)=>xo(yo.fromDom(t),Sc(e))&&!Ls(e.schema,t)&&e.dom.isEditable(t),cv=e=>{var t;return"rtl"===Ya.DOM.getStyle(e,"direction",!0)||(e=>iv.test(e))(null!==(t=e.textContent)&&void 0!==t?t:"")},dv=(e,t,o)=>{const n=((e,t,o)=>Y(Ya.DOM.getParents(o.container(),"*",t),e))(e,t,o);return F.from(n[n.length-1])},mv=(e,t)=>{const o=t.container(),n=t.offset();return e?zr(o)?tr(o.nextSibling)?rl(o.nextSibling,0):rl.after(o):Ur(t)?rl(o,n+1):t:zr(o)?tr(o.previousSibling)?rl(o.previousSibling,o.previousSibling.data.length):rl.before(o):jr(t)?rl(o,n-1):t},uv=N(mv,!0),gv=N(mv,!1),hv=(e,t)=>{const o=e=>e.stopImmediatePropagation();e.on("beforeinput input",o,!0),e.getDoc().execCommand(t),e.off("beforeinput input",o)},pv=e=>hv(e,"Delete"),fv=e=>_r(e)||Tr(e),vv=(e,t)=>ko(e,t)?Xo(t,fv,(e=>t=>Lt(Oo(t),e,So))(e)):F.none(),bv=(e,t=!0)=>{e.dom.isEmpty(e.getBody())&&e.setContent("",{no_selection:!t})},yv=(e,t,o)=>It(Gm(o),Km(o),((n,r)=>{const s=mv(!0,n),a=mv(!1,r),i=mv(!1,t);return e?$m(o,i).exists((e=>e.isEqual(a)&&t.isEqual(s))):qm(o,i).exists((e=>e.isEqual(s)&&t.isEqual(a)))})).getOr(!0),wv=e=>{var t;return(8===Wt(t=e)||"#comment"===jt(t)?Mo(e):Po(e)).bind(wv).orThunk((()=>F.some(e)))},xv=(e,t,o,n=!0)=>{var r;t.deleteContents();const s=wv(o).getOr(o),a=yo.fromDom(null!==(r=e.dom.getParent(s.dom,e.dom.isBlock))&&void 0!==r?r:o.dom);if(a.dom===e.getBody()?bv(e,n):ys(a)&&(Rr(a),n&&e.selection.setCursorLocation(a.dom,0)),!So(o,a)){const e=Lt(Oo(a),o)?[]:Oo(i=a).map(Lo).map((e=>Y(e,(e=>!So(i,e))))).getOr([]);q(e.concat(Lo(o)),(e=>{So(e,a)||ko(e,a)||!ys(e)||Cn(e)}))}var i},Cv=(e,t)=>((e,t)=>{const o=e.dom;return o.parentNode?Jo(yo.fromDom(o.parentNode),(o=>!So(e,o)&&t(o))):F.none()})(e,t).isSome(),Sv=(e,t)=>Qo(e,t).isSome(),kv=e=>zn(e,"td,th"),_v=(e,t)=>wu(yo.fromDom(e),t),Ev=e=>(e=>It(e.startTable,e.endTable,((t,o)=>{const n=Sv(t,(e=>So(e,o))),r=Sv(o,(e=>So(e,t)));return n||r?{...e,startTable:n?F.none():e.startTable,endTable:r?F.none():e.endTable,isSameTable:!1,isMultiTable:!1}:e})).getOr(e))(e),Tv=(e,t)=>({start:e,end:t}),Ov=Al([{singleCellTable:["rng","cell"]},{fullTable:["table"]},{partialTable:["cells","outsideDetails"]},{multiTable:["startTableCells","endTableCells","betweenRng"]}]),Dv=(e,t)=>on(yo.fromDom(e),"td,th",t),Av=e=>!So(e.start,e.end),Mv=(e,t)=>wu(e.start,t).bind((o=>wu(e.end,t).bind((e=>Pt(So(o,e),o))))),Nv=e=>t=>Mv(t,e).map((e=>((e,t,o)=>({rng:e,table:t,cells:o}))(t,e,kv(e)))),Rv=(e,t,o,n)=>{if(o.collapsed||!e.forall(Av))return F.none();if(t.isSameTable){const t=e.bind(Nv(n));return F.some({start:t,end:t})}{const e=Dv(o.startContainer,n),t=Dv(o.endContainer,n),r=e.bind((e=>t=>wu(t,e).bind((e=>me(kv(e)).map((e=>Tv(t,e))))))(n)).bind(Nv(n)),s=t.bind((e=>t=>wu(t,e).bind((e=>de(kv(e)).map((e=>Tv(e,t))))))(n)).bind(Nv(n));return F.some({start:r,end:s})}},Bv=(e,t)=>te(e,(e=>So(e,t))),Lv=e=>It(Bv(e.cells,e.rng.start),Bv(e.cells,e.rng.end),((t,o)=>e.cells.slice(t,o+1))),Hv=(e,t,o)=>e.exists((e=>((e,t)=>!Av(e)&&Mv(e,t).exists((e=>{const t=e.dom.rows;return 1===t.length&&1===t[0].cells.length})))(e,o)&&Su(e.start,t))),Iv=(e,t)=>{const{startTable:o,endTable:n}=t,r=e.cloneRange();return o.each((e=>r.setStartAfter(e.dom))),n.each((e=>r.setEndBefore(e.dom))),r},Pv=(e,t)=>{const o=(e=>t=>So(e,t))(e),n=((e,t)=>{const o=Dv(e.startContainer,t),n=Dv(e.endContainer,t);return It(o,n,Tv)})(t,o),r=((e,t)=>{const o=_v(e.startContainer,t),n=_v(e.endContainer,t),r=o.isSome(),s=n.isSome(),a=It(o,n,So).getOr(!1);return Ev({startTable:o,endTable:n,isStartInTable:r,isEndInTable:s,isSameTable:a,isMultiTable:!a&&r&&s})})(t,o);return Hv(n,t,o)?n.map((e=>Ov.singleCellTable(t,e.start))):r.isMultiTable?((e,t,o,n)=>Rv(e,t,o,n).bind((({start:e,end:n})=>{const r=e.bind(Lv).getOr([]),s=n.bind(Lv).getOr([]);if(r.length>0&&s.length>0){const e=Iv(o,t);return F.some(Ov.multiTable(r,s,e))}return F.none()})))(n,r,t,o):((e,t,o,n)=>Rv(e,t,o,n).bind((({start:e,end:t})=>e.or(t))).bind((e=>{const{isSameTable:n}=t,r=Lv(e).getOr([]);if(n&&e.cells.length===r.length)return F.some(Ov.fullTable(e.table));if(r.length>0){if(n)return F.some(Ov.partialTable(r,F.none()));{const e=Iv(o,t);return F.some(Ov.partialTable(r,F.some({...t,rng:e})))}}return F.none()})))(n,r,t,o)},Fv=e=>q(e,(e=>{so(e,"contenteditable"),Rr(e)})),zv=(e,t,o,n)=>{const r=o.cloneRange();n?(r.setStart(o.startContainer,o.startOffset),r.setEndAfter(t.dom.lastChild)):(r.setStartBefore(t.dom.firstChild),r.setEnd(o.endContainer,o.endOffset)),jv(e,r,t,!1).each((e=>e()))},Vv=e=>{const t=yu(e),o=yo.fromDom(e.selection.getNode());mr(o.dom)&&ys(o)?e.selection.setCursorLocation(o.dom,0):e.selection.collapse(!0),t.length>1&&W(t,(e=>So(e,o)))&&eo(o,"data-mce-selected","1")},Zv=(e,t,o)=>F.some((()=>{const n=e.selection.getRng(),r=o.bind((({rng:o,isStartInTable:r})=>{const s=((e,t)=>F.from(e.dom.getParent(t,e.dom.isBlock)).map(yo.fromDom))(e,r?o.endContainer:o.startContainer);o.deleteContents(),((e,t,o)=>{o.each((o=>{t?Cn(o):(Rr(o),e.selection.setCursorLocation(o.dom,0))}))})(e,r,s.filter(ys));const a=r?t[0]:t[t.length-1];return zv(e,a,n,r),ys(a)?F.none():F.some(r?t.slice(1):t.slice(0,-1))})).getOr(t);Fv(r),Vv(e)})),Uv=(e,t,o,n)=>F.some((()=>{const r=e.selection.getRng(),s=t[0],a=o[o.length-1];zv(e,s,r,!0),zv(e,a,r,!1);const i=ys(s)?t:t.slice(1),l=ys(a)?o:o.slice(0,-1);Fv(i.concat(l)),n.deleteContents(),Vv(e)})),jv=(e,t,o,n=!0)=>F.some((()=>{xv(e,t,o,n)})),Wv=(e,t)=>F.some((()=>av(e,!1,t))),$v=(e,t,o,n)=>Gv(t,n).fold((()=>((e,t,o)=>Pv(t,o).bind((t=>t.fold(N(jv,e),N(Wv,e),N(Zv,e),N(Uv,e)))))(e,t,o)),(t=>((e,t)=>Kv(e,t))(e,t))),qv=(e,t)=>ee(pf(t,e),Dr),Gv=(e,t)=>ee(pf(t,e),Jt("caption")),Kv=(e,t)=>F.some((()=>{Rr(t),e.selection.setCursorLocation(t.dom,0)})),Yv=(e,t,o,n,r)=>Um(o,e.getBody(),r).fold((()=>F.some(E)),(s=>((e,t,o,n)=>Gm(e.dom).bind((r=>Km(e.dom).map((e=>t?o.isEqual(r)&&n.isEqual(e):o.isEqual(e)&&n.isEqual(r))))).getOr(!0))(n,o,r,s)?((e,t)=>Kv(e,t))(e,n):((e,t,o)=>Gv(e,yo.fromDom(o.getNode())).fold((()=>F.some(E)),(e=>Pt(!So(e,t),E))))(t,n,s))),Xv=(e,t,o,n)=>{const r=rl.fromRangeStart(e.selection.getRng());return qv(o,n).bind((n=>ys(n)?Kv(e,n):((e,t,o,n,r)=>Um(o,e.getBody(),r).bind((e=>qv(t,yo.fromDom(e.getNode())).bind((e=>So(e,n)?F.none():F.some(E))))))(e,o,t,n,r)))},Jv=(e,t)=>e?df(t):mf(t),Qv=(e,t,o)=>{const n=yo.fromDom(e.getBody());return Gv(n,o).fold((()=>Xv(e,t,n,o).orThunk((()=>Pt(((e,t)=>{const o=rl.fromRangeStart(e.selection.getRng());return Jv(t,o)||Zm(t,e.getBody(),o).exists((e=>Jv(t,e)))})(e,t),E)))),(o=>((e,t,o,n)=>{const r=rl.fromRangeStart(e.selection.getRng());return ys(n)?Kv(e,n):Yv(e,o,t,n,r)})(e,t,n,o)))},eb=(e,t)=>{const o=yo.fromDom(e.selection.getStart(!0)),n=yu(e);return e.selection.isCollapsed()&&0===n.length?Qv(e,t,o):((e,t,o)=>{const n=yo.fromDom(e.getBody()),r=e.selection.getRng();return 0!==o.length?Zv(e,o,F.none()):$v(e,n,r,t)})(e,o,n)},tb=(e,t)=>{let o=t;for(;o&&o!==e;){if(cr(o)||dr(o))return o;o=o.parentNode}return null},ob=["data-ephox-","data-mce-","data-alloy-","data-snooker-","_"],nb=Bt.each,rb=e=>{const t=e.dom,o=new Set(e.serializer.getTempAttrs()),n=e=>W(ob,(t=>je(e,t)))||o.has(e);return{compare:(e,o)=>{if(e.nodeName!==o.nodeName||e.nodeType!==o.nodeType)return!1;const r=e=>{const o={};return nb(t.getAttribs(e),(r=>{const s=r.nodeName.toLowerCase();"style"===s||n(s)||(o[s]=t.getAttrib(e,s))})),o},s=(e,t)=>{for(const o in e)if(_e(e,o)){const n=t[o];if(w(n))return!1;if(e[o]!==n)return!1;delete t[o]}for(const e in t)if(_e(t,e))return!1;return!0};if(Wn(e)&&Wn(o)){if(!s(r(e),r(o)))return!1;if(!s(t.parseStyle(t.getAttrib(e,"style")),t.parseStyle(t.getAttrib(o,"style"))))return!1}return!mu(e)&&!mu(o)},isAttributeInternal:n}},sb=e=>["h1","h2","h3","h4","h5","h6"].includes(e.name),ab=(e,t,o,n)=>{const r=o.name;for(let t=0,s=e.length;t{const o=(e,o)=>{fe(e,(e=>{const n=ue(e.nodes);q(e.filter.callbacks,(r=>{for(let t=n.length-1;t>=0;t--){const r=n[t];(o?void 0!==r.attr(e.filter.name):r.name===e.filter.name)&&!x(r.parent)||n.splice(t,1)}n.length>0&&r(n,e.filter.name,t)}))}))};o(e.nodes,!1),o(e.attributes,!0)},lb=(e,t,o,n={})=>{const r=((e,t,o)=>{const n={nodes:{},attributes:{}};return o.firstChild&&((e,t)=>{let o=e;for(;o=o.walk();)t(o)})(o,(o=>{ab(e,t,o,n)})),n})(e,t,o);ib(r,n)},cb=(e,t,o,n)=>{if((e.pad_empty_with_br||t.insert)&&o(n)){const e=new Ep("br",1);t.insert&&e.attr("data-mce-bogus","1"),n.empty().append(e)}else n.empty().append(new Ep("#text",3)).value=br},db=(e,t)=>{const o=null==e?void 0:e.firstChild;return C(o)&&o===e.lastChild&&o.name===t},mb=(e,t,o,n)=>n.isEmpty(t,o,(t=>((e,t)=>{const o=e.getElementRule(t.name);return!0===(null==o?void 0:o.paddEmpty)})(e,t))),ub=e=>{let t;for(let o=e;o;o=o.parent){const e=o.attr("contenteditable");if("false"===e)break;"true"===e&&(t=o)}return F.from(t)},gb=(e,t,o=e.parent)=>{if(t.getSpecialElements()[e.name])e.empty().remove();else{const n=e.children();for(const e of n)o&&!t.isValidChild(o.name,e.name)&&gb(e,t,o);e.unwrap()}},hb=(e,t,o,n=E)=>{const r=t.getTextBlockElements(),s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=Bt.makeMap("tr,td,th,tbody,thead,tfoot,table,summary"),l=new Set,c=e=>e!==o&&!i[e.name];for(let o=0;o1)if(pb(t,i,d))gb(i,t);else{g.reverse(),m=g[0].clone(),n(m);let e=m;for(let o=0;o0?(u=g[o].clone(),n(u),e.append(u)):u=e;for(let e=g[o].firstChild;e&&e!==g[o+1];){const t=e.next;u.append(e),e=t}e=u}mb(t,s,a,m)?d.insert(i,g[0],!0):(d.insert(m,g[0],!0),d.insert(i,m)),d=g[0],(mb(t,s,a,d)||db(d,"br"))&&d.empty().remove()}else if(i.parent){if("li"===i.name){let e=i.prev;if(e&&("ul"===e.name||"ol"===e.name)){e.append(i);continue}if(e=i.next,e&&("ul"===e.name||"ol"===e.name)&&e.firstChild){e.insert(i,e.firstChild,!0);continue}const t=new Ep("ul",1);n(t),i.wrap(t);continue}if(t.isValidChild(i.parent.name,"div")&&t.isValidChild("div",i.name)){const e=new Ep("div",1);n(e),i.wrap(e)}else gb(i,t)}}},pb=(e,t,o=t.parent)=>!(!o||(!e.children[t.name]||e.isValidChild(o.name,t.name))&&("a"!==t.name||!((e,t)=>{let o=e;for(;o;){if(o.name===t)return!0;o=o.parent}return!1})(o,"a"))&&(!(e=>"summary"===e.name)(o)||!sb(t)||(null==o?void 0:o.firstChild)===t&&(null==o?void 0:o.lastChild)===t)),fb=e=>{const t=rl.fromRangeStart(e),o=rl.fromRangeEnd(e),n=e.commonAncestorContainer;return Zm(!1,n,o).map((r=>!gm(t,o,n)&&gm(t,r,n)?((e,t,o,n)=>{const r=document.createRange();return r.setStart(e,t),r.setEnd(o,n),r})(t.container(),t.offset(),r.container(),r.offset()):e)).getOr(e)},vb=e=>e.collapsed?e:fb(e),bb=(e,t)=>e.getBlockElements()[t.name]&&(e=>C(e.firstChild)&&e.firstChild===e.lastChild)(t)&&(e=>"br"===e.name||e.value===br)(t.firstChild),yb=(e,t)=>{let o=t.firstChild,n=t.lastChild;return o&&"meta"===o.name&&(o=o.next),n&&"mce_marker"===n.attr("id")&&(n=n.prev),((e,t)=>{const o=e.getNonEmptyElements();return C(t)&&(t.isEmpty(o)||bb(e,t))})(e,n)&&(n=null==n?void 0:n.prev),!(!o||o!==n||"ul"!==o.name&&"ol"!==o.name)},wb=e=>C(null==e?void 0:e.firstChild)&&e.firstChild===e.lastChild&&(e=>e.data===br||ir(e))(e.firstChild),xb=e=>{return e.length>0&&(!(t=e[e.length-1]).firstChild||wb(t))?e.slice(0,-1):e;var t},Cb=(e,t)=>{const o=e.getParent(t,e.isBlock);return o&&"LI"===o.nodeName?o:null},Sb=(e,t)=>{const o=rl.after(e),n=Im(t).prev(o);return n?n.toRange():null},kb=(e,t,o)=>{const n=e.parentNode;return n&&Bt.each(t,(t=>{n.insertBefore(t,e)})),((e,t)=>{const o=rl.before(e),n=Im(t).next(o);return n?n.toRange():null})(e,o)},_b=(e,t,o,n)=>{const r=((e,t,o)=>{const n=t.serialize(o);return(e=>{var t,o;const n=e.firstChild,r=e.lastChild;return n&&"META"===n.nodeName&&(null===(t=n.parentNode)||void 0===t||t.removeChild(n)),r&&"mce_marker"===r.id&&(null===(o=r.parentNode)||void 0===o||o.removeChild(r)),e})(e.createFragment(n))})(t,e,n),s=Cb(t,o.startContainer),a=xb((i=r.firstChild,Y(null!==(l=null==i?void 0:i.childNodes)&&void 0!==l?l:[],(e=>"LI"===e.nodeName))));var i,l;const c=t.getRoot(),d=e=>{const n=rl.fromRangeStart(o),r=Im(t.getRoot()),a=1===e?r.prev(n):r.next(n),i=null==a?void 0:a.getNode();return!i||Cb(t,i)!==s};return s?d(1)?kb(s,a,c):d(2)?((e,t,o,n)=>(n.insertAfter(t.reverse(),e),Sb(t[0],o)))(s,a,c,t):((e,t,o,n)=>{const r=((e,t)=>{const o=t.cloneRange(),n=t.cloneRange();return o.setStartBefore(e),n.setEndAfter(e),[o.cloneContents(),n.cloneContents()]})(e,n),s=e.parentNode;return s&&(s.insertBefore(r[0],e),Bt.each(t,(t=>{s.insertBefore(t,e)})),s.insertBefore(r[1],e),s.removeChild(e)),Sb(t[t.length-1],o)})(s,a,c,o):null},Eb=["pre"],Tb=mr,Ob=(e,t,o)=>{F.from(e.getParent(t,"td,th")).map(yo.fromDom).each((e=>((e,t)=>{Po(e).each((o=>{Mo(o).each((n=>{t.isBlock(jt(e))&&kr(o)&&t.isBlock(jt(n))&&Cn(o)}))}))})(e,o)))},Db=(e,t)=>{var o,n,r;let s;const a=e.dom,i=e.selection;if(!t)return;i.scrollIntoView(t);const l=tb(e.getBody(),t);if(l&&"false"===a.getContentEditable(l))return a.remove(t),void i.select(l);let c=a.createRng();const d=t.previousSibling;if(tr(d)){c.setStart(d,null!==(n=null===(o=d.nodeValue)||void 0===o?void 0:o.length)&&void 0!==n?n:0);const e=t.nextSibling;tr(e)&&(d.appendData(e.data),null===(r=e.parentNode)||void 0===r||r.removeChild(e))}else c.setStartBefore(t),c.setEndBefore(t);const m=a.getParent(t,a.isBlock);if(a.remove(t),m&&a.isEmpty(m)){const t=Tb(m);xn(yo.fromDom(m)),c.setStart(m,0),c.setEnd(m,0),t||(e=>!!e.getAttribute("data-mce-fragment"))(m)||!(s=(t=>{let o=rl.fromRangeStart(t);return o=Im(e.getBody()).next(o),null==o?void 0:o.toRange()})(c))?a.add(m,a.create("br",t?{}:{"data-mce-bogus":"1"})):(c=s,a.remove(m))}i.setRng(c)},Ab=e=>{const t=e.dom,o=vb(e.selection.getRng());e.selection.setRng(o);const n=t.getParent(o.startContainer,Tb);((e,t,o)=>!!C(o)&&(o===e.getParent(t.endContainer,Tb)&&Su(yo.fromDom(o),t)))(t,o,n)?jv(e,o,yo.fromDom(n)):o.startContainer===o.endContainer&&o.endOffset-o.startOffset==1&&tr(o.startContainer.childNodes[o.startOffset])?o.deleteContents():e.getDoc().execCommand("Delete",!1)},Mb=(e,t,o)=>{var n,r;const s=e.selection,a=e.dom,i=e.parser,l=o.merge,c=$p({validate:!0},e.schema),d='';o.preserve_zwsp||(t=Hr(t)),-1===t.indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,d);let m=s.getRng();const u=m.startContainer,g=e.getBody();u===g&&s.isCollapsed()&&a.isBlock(g.firstChild)&&((e,t)=>C(t)&&!e.schema.getVoidElements()[t.nodeName])(e,g.firstChild)&&a.isEmpty(g.firstChild)&&(m=a.createRng(),m.setStart(g.firstChild,0),m.setEnd(g.firstChild,0),s.setRng(m)),s.isCollapsed()||Ab(e);const h=s.getNode(),p={context:h.nodeName.toLowerCase(),data:o.data,insert:!0},f=i.parse(t,p);if(!0===o.paste&&yb(e.schema,f)&&((e,t)=>!!Cb(e,t))(a,h))return m=_b(c,a,s.getRng(),f),m&&s.setRng(m),t;!0===o.paste&&((e,t,o,n)=>{var r;const s=t.firstChild,a=t.lastChild,i=s===("bookmark"===a.attr("data-mce-type")?a.prev:a),l=j(Eb,s.name);if(i&&l){const t="false"!==s.attr("contenteditable"),a=(null===(r=e.getParent(o,e.isBlock))||void 0===r?void 0:r.nodeName.toLowerCase())===s.name,i=F.from(tb(n,o)).forall(cr);return t&&a&&i}return!1})(a,f,h,e.getBody())&&(null===(n=f.firstChild)||void 0===n||n.unwrap()),(e=>{let t=e;for(;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")})(f);let v=f.lastChild;if(v&&"mce_marker"===v.attr("id")){const t=v;for(v=v.prev;v;v=v.walk(!0))if(3===v.type||!a.isBlock(v.name)){v.parent&&e.schema.isValidChild(v.parent.name,"span")&&v.parent.insert(t,v,"br"===v.name);break}}if(e._selectionOverrides.showBlockCaretContainer(h),p.invalid||((e,t,o)=>{var n;return W(o.children(),sb)&&"SUMMARY"===(null===(n=e.getParent(t,e.isBlock))||void 0===n?void 0:n.nodeName)})(a,h,f)){e.selection.setContent(d);let o,n=s.getNode();const l=e.getBody();for(sr(n)?n=o=l:o=n;o&&o!==l;)n=o,o=o.parentNode;t=n===l?l.innerHTML:a.getOuterHTML(n);const m=i.parse(t),u=(e=>{for(let t=e;t;t=t.walk())if("mce_marker"===t.attr("id"))return F.some(t);return F.none()})(m),g=u.bind(ub).getOr(m);u.each((e=>e.replace(f)));const h=f.children(),p=null!==(r=f.parent)&&void 0!==r?r:m;f.unwrap();const v=Y(h,(t=>pb(e.schema,t,p)));hb(v,e.schema,g),lb(i.getNodeFilters(),i.getAttributeFilters(),m),t=c.serialize(m),n===l?a.setHTML(l,t):a.setOuterHTML(n,t)}else t=c.serialize(f),((e,t,o)=>{var n;if("all"===o.getAttribute("data-mce-bogus"))null===(n=o.parentNode)||void 0===n||n.insertBefore(e.dom.createFragment(t),o);else{const n=o.firstChild,r=o.lastChild;!n||n===r&&"BR"===n.nodeName?e.dom.setHTML(o,t):e.selection.setContent(t,{no_events:!0})}})(e,t,h);var b;return((e,t)=>{const o=e.schema.getTextInlineElements(),n=e.dom;if(t){const t=e.getBody(),r=rb(e);Bt.each(n.select("*[data-mce-fragment]"),(e=>{if(C(o[e.nodeName.toLowerCase()])&&Yp(n,e))for(let o=e.parentElement;C(o)&&o!==t&&!Xp(n,e,o);o=o.parentElement)if(r.compare(o,e)){n.remove(e,!0);break}}))}})(e,l),Db(e,a.get("mce_marker")),b=e.getBody(),Bt.each(b.getElementsByTagName("*"),(e=>{e.removeAttribute("data-mce-fragment")})),Ob(a,s.getStart(),e.schema),((e,t,o)=>{const n=Ao(yo.fromDom(o),(e=>So(e,yo.fromDom(t))));ce(n,n.length-2).filter(Gt).fold((()=>As(e,t)),(t=>As(e,t.dom)))})(e.schema,e.getBody(),s.getStart()),t},Nb=e=>e instanceof Ep,Rb=(e,t,o)=>{e.dom.setHTML(e.getBody(),t),!0!==o&&(e=>{ap(e)&&Gm(e.getBody()).each((t=>{const o=t.getNode(),n=Jn(o)?Gm(o).getOr(t):t;e.selection.setRng(n.toRange())}))})(e)},Bb=(e,t,o)=>F.from(e.getBody()).map((n=>Nb(t)?((e,t,o,n)=>{lb(e.parser.getNodeFilters(),e.parser.getAttributeFilters(),o);const r=$p({validate:!1},e.schema).serialize(o),s=Hr(Ar(yo.fromDom(t))?r:Bt.trim(r));return Rb(e,s,n.no_selection),{content:o,html:s}})(e,n,t,o):((e,t,o,n)=>{if(0===(o=Hr(o)).length||/^\s+$/.test(o)){const r='
';"TABLE"===t.nodeName?o=""+r+"":/^(UL|OL)$/.test(t.nodeName)&&(o="
  • "+r+"
  • ");const s=Xl(e);return e.schema.isValidChild(t.nodeName.toLowerCase(),s.toLowerCase())?(o=r,o=e.dom.createHTML(s,Jl(e),o)):o||(o=r),Rb(e,o,n.no_selection),{content:o,html:o}}{"raw"!==n.format&&(o=$p({validate:!1},e.schema).serialize(e.parser.parse(o,{isRootContent:!0,insert:!0})));const r=Ar(yo.fromDom(t))?o:Bt.trim(o);return Rb(e,r,n.no_selection),{content:r,html:r}}})(e,n,t,o))).getOr({content:t,html:Nb(o.content)?"":o.content}),Lb=e=>S(e)?e:I,Hb=(e,t,o)=>{const n=t(e),r=Lb(o);return n.orThunk((()=>r(e)?F.none():((e,t,o)=>{let n=e.dom;const r=Lb(o);for(;n.parentNode;){n=n.parentNode;const e=yo.fromDom(n),o=t(e);if(o.isSome())return o;if(r(e))break}return F.none()})(e,t,r)))},Ib=Pu,Pb=(e,t,o)=>{const n=e.formatter.get(o);if(n)for(let o=0;o{const s=e.dom.getRoot();if(t===s)return!1;const a=e.dom.getParent(t,(t=>!!Pb(e,t,o)||t.parentNode===s||!!Zb(e,t,o,n,!0)));return!!Zb(e,a,o,n,r)},zb=(e,t,o)=>!(!qu(o)||!Ib(t,o.inline))||!(!Wu(o)||!Ib(t,o.block))||!!$u(o)&&Wn(t)&&e.is(t,o.selector),Vb=(e,t,o,n,r,s)=>{const a=o[n],i="attributes"===n;if(S(o.onmatch))return o.onmatch(t,o,n);if(a)if(Oe(a)){for(let o=0;o{const s=e.formatter.get(o),a=e.dom;if(s&&Wn(t))for(let o=0;o{if(n)return Fb(e,n,t,o,r);if(n=e.selection.getNode(),Fb(e,n,t,o,r))return!0;const s=e.selection.getStart();return!(s===n||!Fb(e,s,t,o,r))},jb=(e,t)=>{const o=t=>So(t,yo.fromDom(e.getBody()));return F.from(e.selection.getStart(!0)).bind((n=>Hb(yo.fromDom(n),(o=>ge(t,(t=>((t,o)=>Zb(e,t.dom,o)?F.some(o):F.none())(o,t)))),o))).getOrNull()},Wb=(e,t,o)=>J(o,((o,n)=>{const r=((e,t)=>Uu(e,t,(e=>{const t=e=>S(e)||e.length>1&&"%"===e.charAt(0);return W(["styles","attributes"],(o=>ke(e,o).exists((e=>{const o=v(e)?e:Se(e);return W(o,t)}))))})))(e,n);return e.formatter.matchNode(t,n,{},r)?o.concat([n]):o}),[]),$b=Br,qb=e=>{if(e){const t=new Zn(e,e);for(let e=t.current();e;e=t.next())if(tr(e))return e}return null},Gb=e=>{const t=yo.fromTag("span");return to(t,{id:Ym,"data-mce-bogus":"1","data-mce-type":"format-caret"}),e&&bn(t,yo.fromText($b)),t},Kb=(e,t,o)=>{const n=e.dom,r=e.selection;if(Ku(t))av(e,!1,yo.fromDom(t),o,!0);else{const e=r.getRng(),o=n.getParent(t,n.isBlock),s=e.startContainer,a=e.startOffset,i=e.endContainer,l=e.endOffset,c=(e=>{const t=qb(e);return t&&t.data.charAt(0)===$b&&t.deleteData(0,1),t})(t);n.remove(t,!0),s===c&&a>0&&e.setStart(c,a-1),i===c&&l>0&&e.setEnd(c,l-1),o&&n.isEmpty(o)&&Rr(yo.fromDom(o)),r.setRng(e)}},Yb=(e,t,o)=>{const n=e.dom,r=e.selection;if(t)Kb(e,t,o);else if(!(t=Jm(e.getBody(),r.getStart())))for(;t=n.get(Ym);)Kb(e,t,o)},Xb=(e,t)=>(e.appendChild(t),t),Jb=(e,t)=>{var o;const n=X(e,((e,t)=>Xb(e,t.cloneNode(!1))),t),r=null!==(o=n.ownerDocument)&&void 0!==o?o:document;return Xb(n,r.createTextNode($b))},Qb=(e,t,o,n)=>{const r=e.dom,s=e.selection;let a=!1;const i=e.formatter.get(t);if(!i)return;const l=s.getRng(),c=l.startContainer,d=l.startOffset;let m=c;tr(c)&&(d!==c.data.length&&(a=!0),m=m.parentNode);const u=[];let g;for(;m;){if(Zb(e,m,t,o,n)){g=m;break}m.nextSibling&&(a=!0),u.push(m),m=m.parentNode}if(g)if(a){const a=s.getBookmark();l.collapse(!0);let c=mg(r,l,i,!0);c=dh(c),e.formatter.remove(t,o,c,n),s.moveToBookmark(a)}else{const a=Jm(e.getBody(),g),i=C(a)?r.getParents(g.parentNode,P,a):[],l=Gb(!1).dom;((e,t,o)=>{var n,r;const s=e.dom,a=s.getParent(o,N(Ru,e.schema));a&&s.isEmpty(a)?null===(n=o.parentNode)||void 0===n||n.replaceChild(t,o):(Mr(yo.fromDom(o)),s.isEmpty(o)?null===(r=o.parentNode)||void 0===r||r.replaceChild(t,o):s.insertAfter(t,o))})(e,l,null!=a?a:g);const c=((e,t,o,n,r,s)=>{const a=e.formatter,i=e.dom,l=Y(he(a.get()),(e=>e!==n&&!Ue(e,"removeformat"))),c=Wb(e,o,l);if(Y(c,(t=>!ju(e,t,n))).length>0){const e=o.cloneNode(!1);return i.add(t,e),a.remove(n,r,e,s),i.remove(e),F.some(e)}return F.none()})(e,l,g,t,o,n),d=Jb([...u,...c.toArray(),...i],l);a&&Kb(e,a,C(a)),s.setCursorLocation(d,1),r.isEmpty(g)&&r.remove(g)}},ey=e=>{e.on("mouseup keydown",(t=>{var o;((e,t,o)=>{const n=e.selection,r=e.getBody();Yb(e,null,o),8!==t&&46!==t||!n.isCollapsed()||n.getStart().innerHTML!==$b||Yb(e,Jm(r,n.getStart()),!0),37!==t&&39!==t||Yb(e,Jm(r,n.getStart()),!0)})(e,t.keyCode,(o=e.selection.getRng().endContainer,tr(o)&&We(o.data,br)))}))},ty=e=>{const t=Gb(!1),o=Jb(e,t.dom);return{caretContainer:t,caretPosition:rl(o,0)}},oy=(e,t)=>{const{caretContainer:o,caretPosition:n}=ty(t);return pn(yo.fromDom(e),o),Cn(yo.fromDom(e)),n},ny=(e,t)=>{if(Xm(t.dom))return!1;const o=e.schema.getTextInlineElements();return _e(o,jt(t))&&!Xm(t.dom)&&!Xn(t.dom)},ry={},sy=Gn(["pre"]);((e,t)=>{ry[e]||(ry[e]=[]),ry[e].push(t)})("pre",(e=>{const t=e.selection.getRng();if(!t.collapsed){const t=e.selection.getSelectedBlocks(),o=Y(Y(t,sy),(e=>t=>{const o=t.previousSibling;return sy(o)&&j(e,o)})(t));q(o,(e=>{((e,t)=>{const o=yo.fromDom(t),n=Eo(o).dom;Cn(o),wn(yo.fromDom(e),[yo.fromTag("br",n),yo.fromTag("br",n),...Lo(o)])})(e.previousSibling,e)}))}}));const ay=["fontWeight","fontStyle","color","fontSize","fontFamily"],iy=e=>ee(e,(e=>qu(e)&&"span"===e.inline&&(e=>p(e.styles)&&W(he(e.styles),(e=>j(ay,e))))(e))),ly=(e,t)=>{const o=e.get(t);return v(o)?iy(o):F.none()},cy=(e,t)=>qm(t,rl.fromRangeStart(e)).isNone(),dy=(e,t)=>!1===$m(t,rl.fromRangeEnd(e)).exists((e=>!ir(e.getNode())||$m(t,e).isSome())),my=e=>t=>hr(t)&&e.isEditable(t),uy=e=>Y((e=>{const t=e.getSelectedBlocks(),o=e.getRng();if(e.isCollapsed())return[];if(1===t.length)return cy(o,t[0])&&dy(o,t[0])?t:[];{const e=de(t).filter((e=>cy(o,e))).toArray(),n=me(t).filter((e=>dy(o,e))).toArray(),r=t.slice(1,-1);return e.concat(r).concat(n)}})(e),my(e.dom)),gy=e=>Y(e.getSelectedBlocks(),my(e.dom)),hy=Bt.each,py=e=>Wn(e)&&!mu(e)&&!Xm(e)&&!Xn(e),fy=(e,t)=>{for(let o=e;o;o=o[t]){if(tr(o)&&Ye(o.data))return e;if(Wn(o)&&!mu(o))return o}return e},vy=(e,t,o)=>{const n=rb(e),r=$n(t)&&e.dom.isEditable(t),s=$n(o)&&e.dom.isEditable(o);if(r&&s){const r=fy(t,"previousSibling"),s=fy(o,"nextSibling");if(n.compare(r,s)){for(let e=r.nextSibling;e&&e!==s;){const t=e;e=e.nextSibling,r.appendChild(t)}return e.dom.remove(s),Bt.each(Bt.grep(s.childNodes),(e=>{r.appendChild(e)})),r}}return o},by=(e,t,o,n)=>{var r;if(n&&!1!==t.merge_siblings){const t=null!==(r=vy(e,Nu(n),n))&&void 0!==r?r:n;vy(e,t,Nu(t,!0))}},yy=(e,t,o)=>{hy(e.childNodes,(e=>{py(e)&&(t(e)&&o(e),e.hasChildNodes()&&yy(e,t,o))}))},wy=(e,t)=>o=>!(!o||!zu(e,o,t)),xy=(e,t,o)=>n=>{e.setStyle(n,t,o),""===n.getAttribute("style")&&n.removeAttribute("style"),((e,t)=>{"SPAN"===t.nodeName&&0===e.getAttribs(t).length&&e.remove(t,!0)})(e,n)},Cy=Al([{keep:[]},{rename:["name"]},{removed:[]}]),Sy=/^(src|href|style)$/,ky=Bt.each,_y=Pu,Ey=(e,t,o)=>e.isChildOf(t,o)&&t!==o&&!e.isBlock(o),Ty=(e,t,o)=>{let n=t[o?"startContainer":"endContainer"],r=t[o?"startOffset":"endOffset"];if(Wn(n)){const e=n.childNodes.length-1;!o&&r&&r--,n=n.childNodes[r>e?e:r]}return tr(n)&&o&&r>=n.data.length&&(n=new Zn(n,e.getBody()).next()||n),tr(n)&&!o&&0===r&&(n=new Zn(n,e.getBody()).prev()||n),n},Oy=(e,t)=>{const o=t?"firstChild":"lastChild",n=e[o];return(e=>/^(TR|TH|TD)$/.test(e.nodeName))(e)&&n?"TR"===e.nodeName&&n[o]||n:e},Dy=(e,t,o,n)=>{var r;const s=e.create(o,n);return null===(r=t.parentNode)||void 0===r||r.insertBefore(s,t),s.appendChild(t),s},Ay=(e,t,o,n,r)=>{const s=yo.fromDom(t),a=yo.fromDom(e.create(n,r)),i=o?Bo(s):Ro(s);return wn(a,i),o?(pn(s,a),vn(a,s)):(fn(s,a),bn(a,s)),a.dom},My=(e,t,o)=>{const n=t.parentNode;let r;const s=e.dom,a=Xl(e);Wu(o)&&n===s.getRoot()&&(o.list_block&&_y(t,o.list_block)||q(ue(t.childNodes),(t=>{Bu(e,a,t.nodeName.toLowerCase())?r?r.appendChild(t):(r=Dy(s,t,a),s.setAttribs(r,Jl(e))):r=null}))),(e=>$u(e)&&qu(e)&&Lt(ke(e,"mixed"),!0))(o)&&!_y(o.inline,t)||s.remove(t,!0)},Ny=(e,t,o)=>k(e)?{name:t,value:null}:{name:e,value:Iu(t,o)},Ry=(e,t)=>{""===e.getAttrib(t,"style")&&(t.removeAttribute("style"),t.removeAttribute("data-mce-style"))},By=(e,t,o,n,r)=>{let s=!1;ky(o.styles,((a,i)=>{const{name:l,value:c}=Ny(i,a,n),d=Fu(c,l);(o.remove_similar||b(c)||!Wn(r)||_y(zu(e,r,l),d))&&e.setStyle(t,l,""),s=!0})),s&&Ry(e,t)},Ly=(e,t,o,n,r)=>{const s=e.dom,a=rb(e),i=e.schema;if(qu(t)&&Rs(i,t.inline)&&Ls(i,n)&&n.parentElement===e.getBody())return My(e,n,t),Cy.removed();if(!t.ceFalseOverride&&n&&"false"===s.getContentEditableParent(n))return Cy.keep();if(n&&!zb(s,n,t)&&!((e,t)=>t.links&&"A"===e.nodeName)(n,t))return Cy.keep();const l=n,c=t.preserve_attributes;if(qu(t)&&"all"===t.remove&&v(c)){const e=Y(s.getAttribs(l),(e=>j(c,e.name.toLowerCase())));if(s.removeAllAttribs(l),q(e,(e=>s.setAttrib(l,e.name,e.value))),e.length>0)return Cy.rename("span")}if("all"!==t.remove){By(s,l,t,o,r),ky(t.attributes,((e,n)=>{const{name:a,value:i}=Ny(n,e,o);if(t.remove_similar||b(i)||!Wn(r)||_y(s.getAttrib(r,a),i)){if("class"===a){const e=s.getAttrib(l,a);if(e){let t="";if(q(e.split(/\s+/),(e=>{/mce\-\w+/.test(e)&&(t+=(t?" ":"")+e)})),t)return void s.setAttrib(l,a,t)}}if(Sy.test(a)&&l.removeAttribute("data-mce-"+a),"style"===a&&Gn(["li"])(l)&&"none"===s.getStyle(l,"list-style-type"))return l.removeAttribute(a),void s.setStyle(l,"list-style-type","none");"class"===a&&l.removeAttribute("className"),l.removeAttribute(a)}})),ky(t.classes,(e=>{e=Iu(e,o),Wn(r)&&!s.hasClass(r,e)||s.removeClass(l,e)}));const e=s.getAttribs(l);for(let t=0;tLy(e,t,o,n,n).fold(D(n),(t=>(e.dom.createFragment().appendChild(n),e.dom.rename(n,t))),D(null)),Iy=(e,t,o,n,r)=>{const s=e.formatter.get(t),a=s[0],i=e.dom,l=e.selection,c=n=>{const i=((e,t,o,n,r)=>{let s;return t.parentNode&&q(Zu(e.dom,t.parentNode).reverse(),(t=>{if(!s&&Wn(t)&&"_start"!==t.id&&"_end"!==t.id){const a=Zb(e,t,o,n,r);a&&!1!==a.split&&(s=t)}})),s})(e,n,t,o,r);return((e,t,o,n,r,s,a,i)=>{var l,c;let d,m;const u=e.dom;if(o){const g=o.parentNode;for(let o=n.parentNode;o&&o!==g;o=o.parentNode){let n=u.clone(o,!1);for(let o=0;oW(s,(n=>Fy(e,n,o,t,t))),m=t=>{const o=ue(t.childNodes),n=d(t)||W(s,(e=>zb(i,t,e))),r=t.parentNode;if(!n&&C(r)&&Gu(a)&&d(r),a.deep&&o.length)for(let e=0;e{Wn(t)&&e.dom.getStyle(t,"text-decoration")===o&&t.parentNode&&Vu(i,t.parentNode)===o&&Fy(e,{deep:!1,exact:!0,inline:"span",styles:{textDecoration:o}},void 0,t)}))},u=e=>{const t=i.get(e?"_start":"_end");if(t){let o=t[e?"firstChild":"lastChild"];return(e=>mu(e)&&Wn(e)&&("_start"===e.id||"_end"===e.id))(o)&&(o=o[e?"firstChild":"lastChild"]),tr(o)&&0===o.data.length&&(o=e?t.previousSibling||t.nextSibling:t.nextSibling||t.previousSibling),i.remove(t,!0),o}return null},g=t=>{let o,n,r=mg(i,t,s,t.collapsed);if(a.split){if(r=dh(r),o=Ty(e,r,!0),n=Ty(e,r),o!==n){if(o=Oy(o,!0),n=Oy(n,!1),Ey(i,o,n)){const e=F.from(o.firstChild).getOr(o);return c(Ay(i,e,!0,"span",{id:"_start","data-mce-type":"bookmark"})),void u(!0)}if(Ey(i,n,o)){const e=F.from(n.lastChild).getOr(n);return c(Ay(i,e,!1,"span",{id:"_end","data-mce-type":"bookmark"})),void u(!1)}o=Dy(i,o,"span",{id:"_start","data-mce-type":"bookmark"}),n=Dy(i,n,"span",{id:"_end","data-mce-type":"bookmark"});const e=i.createRng();e.setStartAfter(o),e.setEndBefore(n),ug(i,e,(e=>{q(e,(e=>{mu(e)||mu(e.parentNode)||c(e)}))})),c(o),c(n),o=u(!0),n=u()}else o=n=c(o);r.startContainer=o.parentNode?o.parentNode:o,r.startOffset=i.nodeIndex(o),r.endContainer=n.parentNode?n.parentNode:n,r.endOffset=i.nodeIndex(n)+1}ug(i,r,(e=>{q(e,m)}))};if(n){if(Ou(n)){const e=i.createRng();e.setStartBefore(n),e.setEndAfter(n),g(e)}else g(n);_g(e,t,n,o)}else l.isCollapsed()&&qu(a)&&!yu(e).length?Qb(e,t,o,r):(Au(e,(()=>Eu(e,g)),(n=>qu(a)&&Ub(e,t,o,n))),e.nodeChanged()),((e,t,o)=>{"removeformat"===t?q(gy(e.selection),(t=>{q(ay,(o=>e.dom.setStyle(t,o,""))),Ry(e.dom,t)})):ly(e.formatter,t).each((t=>{q(gy(e.selection),(n=>By(e.dom,n,t,o,null)))}))})(e,t,o),_g(e,t,n,o)},Py=(e,t,o,n,r)=>{(n||e.selection.isEditable())&&Iy(e,t,o,n,r)},Fy=(e,t,o,n,r)=>Ly(e,t,o,n,r).fold(I,(t=>(e.dom.rename(n,t),!0)),P),zy=Bt.each,Vy=(e,t,o,n)=>{zy(t,(t=>{qu(t)&&zy(e.dom.select(t.inline,n),(n=>{py(n)&&Fy(e,t,o,n,t.exact?n:null)})),((e,t,o)=>{if(t.clear_child_styles){const n=t.links?"*:not(a)":"*";hy(e.select(n,o),(o=>{py(o)&&e.isEditable(o)&&hy(t.styles,((t,n)=>{e.setStyle(o,n,"")}))}))}})(e.dom,t,n)}))},Zy=Bt.each,Uy=(e,t,o,n)=>{if(Zy(o.styles,((o,r)=>{e.setStyle(t,r,Iu(o,n))})),o.styles){const o=e.getAttrib(t,"style");o&&e.setAttrib(t,"data-mce-style",o)}},jy=(e,t,o,n)=>{const r=e.formatter.get(t),s=r[0],a=!n&&e.selection.isCollapsed(),i=e.dom,l=e.selection,c=(e,t=s)=>{S(t.onformat)&&t.onformat(e,t,o,n),Uy(i,e,t,o),Zy(t.attributes,((t,n)=>{i.setAttrib(e,n,Iu(t,o))})),Zy(t.classes,(t=>{const n=Iu(t,o);i.hasClass(e,n)||i.addClass(e,n)}))},d=(e,t)=>{let o=!1;return Zy(e,(e=>!(!$u(e)||("false"!==i.getContentEditable(t)||e.ceFalseOverride)&&(!C(e.collapsed)||e.collapsed===a)&&i.is(t,e.selector)&&!Xm(t)&&(c(t,e),o=!0,1)))),o},m=e=>{if(h(e)){const t=i.create(e);return c(t),t}return null},u=(n,a,i)=>{const l=[];let u=!0;const g=s.inline||s.block,h=m(g),p=n=>(e=>Wu(e)&&!0===e.wrapper)(s)&&Zb(e,n,t,o),f=(t,o,n)=>{const r=(e=>Wu(e)&&!0!==e.wrapper)(s)&&Ru(e.schema,t)&&Bu(e,o,g);return n&&r};ug(n,a,(t=>{let o;const a=t=>{let m=!1,v=u,b=!1;const y=t.parentNode,w=y.nodeName.toLowerCase(),x=n.getContentEditable(t);C(x)&&(v=u,u="true"===x,m=!0,b=Hu(e,t));const S=u&&!m;if(ir(t)&&!((e,t,o,n)=>{if(Hc(e)&&qu(t)&&o.parentNode){const t=va(e.schema),r=Cv(yo.fromDom(o),(e=>Xm(e.dom)));return Ee(t,n)&&ys(yo.fromDom(o.parentNode),!1)&&!r}return!1})(e,s,t,w))return o=null,void(Wu(s)&&n.remove(t));if(p(t))o=null;else{if(f(t,w,S)){const e=n.rename(t,g);return c(e),l.push(e),void(o=null)}if($u(s)){let e=d(r,t);if(!e&&C(y)&&Gu(s)&&(e=d(r,y)),!qu(s)||e)return void(o=null)}C(h)&&((t,o,r,a)=>{const l=t.nodeName.toLowerCase(),c=Bu(e,g,l)&&Bu(e,o,g),d=!i&&tr(t)&&Lr(t.data),m=Xm(t),u=!qu(s)||!n.isBlock(t);return(r||a)&&c&&!d&&!m&&u})(t,w,S,b)?(o||(o=n.clone(h,!1),y.insertBefore(o,t),l.push(o)),b&&m&&(u=v),o.appendChild(t)):(o=null,q(ue(t.childNodes),a),m&&(u=v),o=null)}};q(t,a)})),!0===s.links&&q(l,(e=>{const t=e=>{"A"===e.nodeName&&c(e,s),q(ue(e.childNodes),t)};t(e)})),q(l,(a=>{const i=(e=>{let t=0;return q(e.childNodes,(e=>{(e=>C(e)&&tr(e)&&0===e.length)(e)||mu(e)||t++})),t})(a);!(l.length>1)&&n.isBlock(a)||0!==i?(qu(s)||Wu(s)&&s.wrapper)&&(s.exact||1!==i||(a=(e=>{const t=ee(e.childNodes,Du).filter((e=>"false"!==n.getContentEditable(e)&&zb(n,e,s)));return t.map((t=>{const o=n.clone(t,!1);return c(o),n.replace(o,e,!0),n.remove(t,!0),o})).getOr(e)})(a)),Vy(e,r,o,a),((e,t,o,n,r)=>{const s=r.parentNode;Zb(e,s,o,n)&&Fy(e,t,n,r)||t.merge_with_parents&&s&&e.dom.getParent(s,(s=>!!Zb(e,s,o,n)&&(Fy(e,t,n,r),!0)))})(e,s,t,o,a),((e,t,o,n)=>{if(t.styles&&t.styles.backgroundColor){const r=wy(e,"fontSize");yy(n,(t=>r(t)&&e.isEditable(t)),xy(e,"backgroundColor",Iu(t.styles.backgroundColor,o)))}})(n,s,o,a),((e,t,o,n)=>{const r=t=>{if($n(t)&&Wn(t.parentNode)&&e.isEditable(t)){const o=Vu(e,t.parentNode);e.getStyle(t,"color")&&o?e.setStyle(t,"text-decoration",o):e.getStyle(t,"text-decoration")===o&&e.setStyle(t,"text-decoration",null)}};t.styles&&(t.styles.color||t.styles.textDecoration)&&(Bt.walk(n,r,"childNodes"),r(n))})(n,s,0,a),((e,t,o,n)=>{if(qu(t)&&("sub"===t.inline||"sup"===t.inline)){const o=wy(e,"fontSize");yy(n,(t=>o(t)&&e.isEditable(t)),xy(e,"fontSize",""));const r=Y(e.select("sup"===t.inline?"sub":"sup",n),e.isEditable);e.remove(r,!0)}})(n,s,0,a),by(e,s,0,a)):n.remove(a,!0)}))},g=Ou(n)?n:l.getNode();if("false"===i.getContentEditable(g)&&!Hu(e,g))return d(r,n=g),void kg(e,t,n,o);if(s){if(n)if(Ou(n)){if(!d(r,n)){const e=i.createRng();e.setStartBefore(n),e.setEndAfter(n),u(i,mg(i,e,r),!0)}}else u(i,n,!0);else a&&qu(s)&&!yu(e).length?((e,t,o)=>{let n;const r=e.selection,s=e.formatter.get(t);if(!s)return;const a=r.getRng();let i=a.startOffset;const l=a.startContainer.nodeValue;n=Jm(e.getBody(),r.getStart());const c=/[^\s\u00a0\u00ad\u200b\ufeff]/;if(l&&i>0&&i{Eu(e,((e,t)=>{const o=t?e:mg(i,e,r);u(i,o,!1)}))}),P),e.nodeChanged()),ly(e.formatter,t).each((t=>{q(uy(e.selection),(e=>Uy(i,e,t,o)))}));((e,t)=>{_e(ry,e)&&q(ry[e],(e=>{e(t)}))})(t,e)}kg(e,t,n,o)},Wy=(e,t,o,n)=>{(n||e.selection.isEditable())&&jy(e,t,o,n)},$y=e=>_e(e,"vars"),qy=e=>e.selection.getStart(),Gy=(e,t,o,n,r)=>Q(t,(t=>{const s=e.formatter.matchNode(t,o,null!=r?r:{},n);return!w(s)}),(t=>!!Pb(e,t,o)||!n&&C(e.formatter.matchNode(t,o,r,!0)))),Ky=(e,t)=>{const o=null!=t?t:qy(e);return Y(Zu(e.dom,o),(e=>Wn(e)&&!Xn(e)))},Yy=(e,t,o)=>{const n=Ky(e,t);fe(o,((o,r)=>{const s=o=>{const s=Gy(e,n,r,o.similar,$y(o)?o.vars:void 0),a=s.isSome();if(o.state.get()!==a){o.state.set(a);const e=s.getOr(t);$y(o)?o.callback(a,{node:e,format:r,parents:n}):q(o.callbacks,(t=>t(a,{node:e,format:r,parents:n})))}};q([o.withSimilar,o.withoutSimilar],s),q(o.withVars,s)}))},Xy=(e,t,o,n,r,s)=>(((e,t,o,n,r,s)=>{const a=t.get();q(o.split(","),(t=>{const o=ke(a,t).getOrThunk((()=>{const e={withSimilar:{state:Qa(!1),similar:!0,callbacks:[]},withoutSimilar:{state:Qa(!1),similar:!1,callbacks:[]},withVars:[]};return a[t]=e,e})),i=()=>{const o=Ky(e);return Gy(e,o,t,r,s).isSome()};if(w(s)){const e=r?o.withSimilar:o.withoutSimilar;e.callbacks.push(n),1===e.callbacks.length&&e.state.set(i())}else o.withVars.push({state:Qa(i()),similar:r,vars:s,callback:n})})),t.set(a)})(e,t,o,n,r,s),{unbind:()=>((e,t,o)=>{const n=e.get();q(t.split(","),(e=>ke(n,e).each((t=>{n[e]={withSimilar:{...t.withSimilar,callbacks:Y(t.withSimilar.callbacks,(e=>e!==o))},withoutSimilar:{...t.withoutSimilar,callbacks:Y(t.withoutSimilar.callbacks,(e=>e!==o))},withVars:Y(t.withVars,(e=>e.callback!==o))}})))),e.set(n)})(t,o,n)}),Jy=Bt.explode,Qy=()=>{const e={};return{addFilter:(t,o)=>{q(Jy(t),(t=>{_e(e,t)||(e[t]={name:t,callbacks:[]}),e[t].callbacks.push(o)}))},getFilters:()=>Se(e),removeFilter:(t,o)=>{q(Jy(t),(t=>{if(_e(e,t))if(C(o)){const n=e[t],r=Y(n.callbacks,(e=>e!==o));r.length>0?n.callbacks=r:delete e[t]}else delete e[t]}))}}},ew=(e,t,o)=>{e.addNodeFilter("font",(e=>{q(e,(e=>{const n=t.parse(e.attr("style")),r=e.attr("color"),s=e.attr("face"),a=e.attr("size");r&&(n.color=r),s&&(n["font-family"]=s),a&&Je(a).each((e=>{n["font-size"]=o[e-1]})),e.name="span",e.attr("style",t.serialize(n)),((e,t)=>{q(t,(t=>{e.attr(t,null)}))})(e,["color","face","size"])}))}))},tw=(e,t,o)=>{var n;const r=Aa();t.convert_fonts_to_spans&&ew(e,r,Bt.explode(null!==(n=t.font_size_legacy_values)&&void 0!==n?n:"")),((e,t,o)=>{e.addNodeFilter("strike",(e=>{const n="html4"!==t.type;q(e,(e=>{if(n)e.name="s";else{const t=o.parse(e.attr("style"));t["text-decoration"]="line-through",e.name="span",e.attr("style",o.serialize(t))}}))}))})(e,o,r)},ow=(e,t,o)=>{t.addNodeFilter("br",((t,n,r)=>{const s=Bt.extend({},o.getBlockElements()),a=o.getNonEmptyElements(),i=o.getWhitespaceElements();s.body=1;const l=e=>e.name in s||Is(o,e);for(let n=0,c=t.length;n{const[t,...o]=e.split(","),n=o.join(","),r=/data:([^/]+\/[^;]+)(;.+)?/.exec(t);if(r){const e=";base64"===r[2],t=e?(e=>{const t=/([a-z0-9+\/=\s]+)/i.exec(e);return t?t[1]:""})(n):decodeURIComponent(n);return F.some({type:r[1],data:t,base64Encoded:e})}return F.none()},rw=(e,t,o=!0)=>{let n=t;if(o)try{n=atob(t)}catch(e){return F.none()}const r=new Uint8Array(n.length);for(let e=0;e{return je(e,"blob:")?(e=>fetch(e).then((e=>e.ok?e.blob():Promise.reject())).catch((()=>Promise.reject({message:`Cannot convert ${e} to Blob. Resource might not exist or is inaccessible.`,uriType:"blob"}))))(e):je(e,"data:")?(t=e,new Promise(((e,o)=>{nw(t).bind((({type:e,data:t,base64Encoded:o})=>rw(e,t,o))).fold((()=>o("Invalid data URI")),e)}))):Promise.reject("Unknown URI format");var t},aw=e=>new Promise(((t,o)=>{const n=new FileReader;n.onloadend=()=>{t(n.result)},n.onerror=()=>{var e;o(null===(e=n.error)||void 0===e?void 0:e.message)},n.readAsDataURL(e)}));let iw=0;const lw=(e,t,o)=>nw(e).bind((({data:e,type:n,base64Encoded:r})=>{if(t&&!r)return F.none();{const t=r?e:btoa(e);return o(t,n)}})),cw=(e,t,o)=>{const n=e.create((r||"blobid")+iw++,t,o);var r;return e.add(n),n},dw=(e,t,o=!1)=>lw(t,o,((t,o)=>F.from(e.getByData(t,o)).orThunk((()=>rw(o,t).map((o=>cw(e,o,t))))))),mw=(e,t)=>{const{blob_cache:o}=t;if(o){const t=e=>{const t=e.attr("src");(e=>e.attr("src")===At.transparentSrc||C(e.attr("data-mce-placeholder")))(e)||(e=>C(e.attr("data-mce-bogus")))(e)||x(t)||dw(o,t,!0).each((t=>{e.attr("src",t.blobUri())}))};e.addAttributeFilter("src",(e=>q(e,t)))}},uw=(e,t)=>je(e,`${t}/`),gw=(e,t)=>{const o=e.schema;t.remove_trailing_brs&&ow(t,e,o),e.addAttributeFilter("href",(e=>{let o=e.length;const n=e=>{const t=e?Bt.trim(e):"";return/\b(noopener)\b/g.test(t)?t:(e=>e.split(" ").filter((e=>e.length>0)).concat(["noopener"]).sort().join(" "))(t)};if(!t.allow_unsafe_link_target)for(;o--;){const t=e[o];"a"===t.name&&"_blank"===t.attr("target")&&t.attr("rel",n(t.attr("rel")))}})),t.allow_html_in_named_anchor||e.addAttributeFilter("id,name",(e=>{let t,o,n,r,s=e.length;for(;s--;)if(r=e[s],"a"===r.name&&r.firstChild&&!r.attr("href"))for(n=r.parent,t=r.lastChild;t&&n;)o=t.prev,n.insert(t,r),t=o})),t.fix_list_elements&&e.addNodeFilter("ul,ol",(e=>{let t,o,n=e.length;for(;n--;)if(t=e[n],o=t.parent,o&&("ul"===o.name||"ol"===o.name))if(t.prev&&"li"===t.prev.name)t.prev.append(t);else{const e=new Ep("li",1);e.attr("style","list-style-type: none"),t.wrap(e)}}));const n=o.getValidClasses();t.validate&&n&&e.addAttributeFilter("class",(e=>{var t;let o=e.length;for(;o--;){const r=e[o],s=null!==(t=r.attr("class"))&&void 0!==t?t:"",a=Bt.explode(s," ");let i="";for(let e=0;eq(e,(e=>{e.replace(((e,t,o,n,r)=>{let s;s=w(e)?"iframe":uw(e,"image")?"img":uw(e,"video")?"video":uw(e,"audio")?"audio":"iframe";const a=new Ep(s,1);return a.attr("audio"===s?{src:t}:{src:t,width:o,height:n}),"audio"!==s&&"video"!==s||a.attr("controls",""),"iframe"===s&&r&&a.attr("sandbox",""),a})(e.attr("type"),"object"===e.name?e.attr("data"):e.attr("src"),e.attr("width"),e.attr("height"),t.sandbox_iframes))})))),t.sandbox_iframes&&e.addNodeFilter("iframe",(e=>q(e,(e=>e.attr("sandbox","")))))},{entries:hw,setPrototypeOf:pw,isFrozen:fw,getPrototypeOf:vw,getOwnPropertyDescriptor:bw}=Object;let{freeze:yw,seal:ww,create:xw}=Object,{apply:Cw,construct:Sw}="undefined"!=typeof Reflect&&Reflect;Cw||(Cw=function(e,t,o){return e.apply(t,o)}),yw||(yw=function(e){return e}),ww||(ww=function(e){return e}),Sw||(Sw=function(e,t){return new e(...t)});const kw=Hw(Array.prototype.forEach),_w=Hw(Array.prototype.pop),Ew=Hw(Array.prototype.push),Tw=Hw(String.prototype.toLowerCase),Ow=Hw(String.prototype.toString),Dw=Hw(String.prototype.match),Aw=Hw(String.prototype.replace),Mw=Hw(String.prototype.indexOf),Nw=Hw(String.prototype.trim),Rw=Hw(RegExp.prototype.test),Bw=(Lw=TypeError,function(){for(var e=arguments.length,t=new Array(e),o=0;o1?o-1:0),r=1;r/gm),Qw=ww(/\${[\w\W]*}/gm),ex=ww(/^data-[\-\w.\u00B7-\uFFFF]/),tx=ww(/^aria-[\-\w]+$/),ox=ww(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),nx=ww(/^(?:\w+script|data):/i),rx=ww(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sx=ww(/^html$/i);var ax=Object.freeze({__proto__:null,MUSTACHE_EXPR:Xw,ERB_EXPR:Jw,TMPLIT_EXPR:Qw,DATA_ATTR:ex,ARIA_ATTR:tx,IS_ALLOWED_URI:ox,IS_SCRIPT_OR_DATA:nx,ATTR_WHITESPACE:rx,DOCTYPE_NAME:sx});const ix=()=>"undefined"==typeof window?null:window;var lx=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ix();const o=t=>e(t);if(o.version="3.0.5",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;const n=t.document,r=n.currentScript;let{document:s}=t;const{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:m=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:h}=t,p=c.prototype,f=Fw(p,"cloneNode"),v=Fw(p,"nextSibling"),b=Fw(p,"childNodes"),y=Fw(p,"parentNode");if("function"==typeof i){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let w,x="";const{implementation:C,createNodeIterator:S,createDocumentFragment:k,getElementsByTagName:_}=s,{importNode:E}=n;let T={};o.isSupported="function"==typeof hw&&"function"==typeof y&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:D,TMPLIT_EXPR:A,DATA_ATTR:M,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:R,ATTR_WHITESPACE:B}=ax;let{IS_ALLOWED_URI:L}=ax,H=null;const I=Iw({},[...zw,...Vw,...Zw,...jw,...$w]);let P=null;const F=Iw({},[...qw,...Gw,...Kw,...Yw]);let z=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,Z=null,U=!0,j=!0,W=!1,$=!0,q=!1,G=!1,K=!1,Y=!1,X=!1,J=!1,Q=!1,ee=!0,te=!1,oe=!0,ne=!1,re={},se=null;const ae=Iw({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ie=null;const le=Iw({},["audio","video","img","source","image","track"]);let ce=null;const de=Iw({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),me="http://www.w3.org/1998/Math/MathML",ue="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml";let he=ge,pe=!1,fe=null;const ve=Iw({},[me,ue,ge],Ow);let be;const ye=["application/xhtml+xml","text/html"];let we,xe=null;const Ce=s.createElement("form"),Se=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){if(!xe||xe!==e){if(e&&"object"==typeof e||(e={}),e=Pw(e),be=be=-1===ye.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,we="application/xhtml+xml"===be?Ow:Tw,H="ALLOWED_TAGS"in e?Iw({},e.ALLOWED_TAGS,we):I,P="ALLOWED_ATTR"in e?Iw({},e.ALLOWED_ATTR,we):F,fe="ALLOWED_NAMESPACES"in e?Iw({},e.ALLOWED_NAMESPACES,Ow):ve,ce="ADD_URI_SAFE_ATTR"in e?Iw(Pw(de),e.ADD_URI_SAFE_ATTR,we):de,ie="ADD_DATA_URI_TAGS"in e?Iw(Pw(le),e.ADD_DATA_URI_TAGS,we):le,se="FORBID_CONTENTS"in e?Iw({},e.FORBID_CONTENTS,we):ae,V="FORBID_TAGS"in e?Iw({},e.FORBID_TAGS,we):{},Z="FORBID_ATTR"in e?Iw({},e.FORBID_ATTR,we):{},re="USE_PROFILES"in e&&e.USE_PROFILES,U=!1!==e.ALLOW_ARIA_ATTR,j=!1!==e.ALLOW_DATA_ATTR,W=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,q=e.SAFE_FOR_TEMPLATES||!1,G=e.WHOLE_DOCUMENT||!1,X=e.RETURN_DOM||!1,J=e.RETURN_DOM_FRAGMENT||!1,Q=e.RETURN_TRUSTED_TYPE||!1,Y=e.FORCE_BODY||!1,ee=!1!==e.SANITIZE_DOM,te=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,ne=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||ox,he=e.NAMESPACE||ge,z=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(j=!1),J&&(X=!0),re&&(H=Iw({},[...$w]),P=[],!0===re.html&&(Iw(H,zw),Iw(P,qw)),!0===re.svg&&(Iw(H,Vw),Iw(P,Gw),Iw(P,Yw)),!0===re.svgFilters&&(Iw(H,Zw),Iw(P,Gw),Iw(P,Yw)),!0===re.mathMl&&(Iw(H,jw),Iw(P,Kw),Iw(P,Yw))),e.ADD_TAGS&&(H===I&&(H=Pw(H)),Iw(H,e.ADD_TAGS,we)),e.ADD_ATTR&&(P===F&&(P=Pw(P)),Iw(P,e.ADD_ATTR,we)),e.ADD_URI_SAFE_ATTR&&Iw(ce,e.ADD_URI_SAFE_ATTR,we),e.FORBID_CONTENTS&&(se===ae&&(se=Pw(se)),Iw(se,e.FORBID_CONTENTS,we)),oe&&(H["#text"]=!0),G&&Iw(H,["html","head","body"]),H.table&&(Iw(H,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Bw('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Bw('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,x=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let o=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));const r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,r)),null!==w&&"string"==typeof x&&(x=w.createHTML(""));yw&&yw(e),xe=e}},_e=Iw({},["mi","mo","mn","ms","mtext"]),Ee=Iw({},["foreignobject","desc","title","annotation-xml"]),Te=Iw({},["title","style","font","a","script"]),Oe=Iw({},Vw);Iw(Oe,Zw),Iw(Oe,Uw);const De=Iw({},jw);Iw(De,Ww);const Ae=function(e){Ew(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},Me=function(e,t){try{Ew(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Ew(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!P[e])if(X||J)try{Ae(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ne=function(e){let t,o;if(Y)e=""+e;else{const t=Dw(e,/^[\r\n\t ]+/);o=t&&t[0]}"application/xhtml+xml"===be&&he===ge&&(e=''+e+"");const n=w?w.createHTML(e):e;if(he===ge)try{t=(new g).parseFromString(n,be)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(he,"template",null);try{t.documentElement.innerHTML=pe?x:n}catch(e){}}const r=t.body||t.documentElement;return e&&o&&r.insertBefore(s.createTextNode(o),r.childNodes[0]||null),he===ge?_.call(t,G?"html":"body")[0]:G?t.documentElement:r},Re=function(e){return S.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Be=function(e){return"object"==typeof l?e instanceof l:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Le=function(e,t,n){T[e]&&kw(T[e],(e=>{e.call(o,t,n,xe)}))},He=function(e){let t;if(Le("beforeSanitizeElements",e,null),(n=e)instanceof u&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof m)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore||"function"!=typeof n.hasChildNodes))return Ae(e),!0;var n;const r=we(e.nodeName);if(Le("uponSanitizeElement",e,{tagName:r,allowedTags:H}),e.hasChildNodes()&&!Be(e.firstElementChild)&&(!Be(e.content)||!Be(e.content.firstElementChild))&&Rw(/<[/\w]/g,e.innerHTML)&&Rw(/<[/\w]/g,e.textContent))return Ae(e),!0;if(!H[r]||V[r]){if(!V[r]&&Pe(r)){if(z.tagNameCheck instanceof RegExp&&Rw(z.tagNameCheck,r))return!1;if(z.tagNameCheck instanceof Function&&z.tagNameCheck(r))return!1}if(oe&&!se[r]){const t=y(e)||e.parentNode,o=b(e)||e.childNodes;if(o&&t)for(let n=o.length-1;n>=0;--n)t.insertBefore(f(o[n],!0),v(e))}return Ae(e),!0}return e instanceof c&&!function(e){let t=y(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});const o=Tw(e.tagName),n=Tw(t.tagName);return!!fe[e.namespaceURI]&&(e.namespaceURI===ue?t.namespaceURI===ge?"svg"===o:t.namespaceURI===me?"svg"===o&&("annotation-xml"===n||_e[n]):Boolean(Oe[o]):e.namespaceURI===me?t.namespaceURI===ge?"math"===o:t.namespaceURI===ue?"math"===o&&Ee[n]:Boolean(De[o]):e.namespaceURI===ge?!(t.namespaceURI===ue&&!Ee[n])&&!(t.namespaceURI===me&&!_e[n])&&!De[o]&&(Te[o]||!Oe[o]):!("application/xhtml+xml"!==be||!fe[e.namespaceURI]))}(e)?(Ae(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!Rw(/<\/no(script|embed|frames)/i,e.innerHTML)?(q&&3===e.nodeType&&(t=e.textContent,t=Aw(t,O," "),t=Aw(t,D," "),t=Aw(t,A," "),e.textContent!==t&&(Ew(o.removed,{element:e.cloneNode()}),e.textContent=t)),Le("afterSanitizeElements",e,null),!1):(Ae(e),!0)},Ie=function(e,t,o){if(ee&&("id"===t||"name"===t)&&(o in s||o in Ce))return!1;if(j&&!Z[t]&&Rw(M,t));else if(U&&Rw(N,t));else if(!P[t]||Z[t]){if(!(Pe(e)&&(z.tagNameCheck instanceof RegExp&&Rw(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&Rw(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t))||"is"===t&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&Rw(z.tagNameCheck,o)||z.tagNameCheck instanceof Function&&z.tagNameCheck(o))))return!1}else if(ce[t]);else if(Rw(L,Aw(o,B,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Mw(o,"data:")||!ie[e])if(W&&!Rw(R,Aw(o,B,"")));else if(o)return!1;return!0},Pe=function(e){return e.indexOf("-")>0},Fe=function(e){let t,o,n,r;Le("beforeSanitizeAttributes",e,null);const{attributes:s}=e;if(!s)return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P};for(r=s.length;r--;){t=s[r];const{name:i,namespaceURI:l}=t;o="value"===i?t.value:Nw(t.value);const c=o;if(n=we(i),a.attrName=n,a.attrValue=o,a.keepAttr=!0,a.forceKeepAttr=void 0,Le("uponSanitizeAttribute",e,a),o=a.attrValue,a.forceKeepAttr)continue;if(!a.keepAttr){Me(i,e);continue}if(!$&&Rw(/\/>/i,o)){Me(i,e);continue}q&&(o=Aw(o,O," "),o=Aw(o,D," "),o=Aw(o,A," "));const d=we(e.nodeName);if(Ie(d,n,o)){if(!te||"id"!==n&&"name"!==n||(Me(i,e),o="user-content-"+o),w&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(l);else switch(h.getAttributeType(d,n)){case"TrustedHTML":o=w.createHTML(o);break;case"TrustedScriptURL":o=w.createScriptURL(o)}if(o!==c)try{l?e.setAttributeNS(l,i,o):e.setAttribute(i,o)}catch(t){Me(i,e)}}else Me(i,e)}Le("afterSanitizeAttributes",e,null)},ze=function e(t){let o;const n=Re(t);for(Le("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Le("uponSanitizeShadowNode",o,null),He(o)||(o.content instanceof a&&e(o.content),Fe(o));Le("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t,r,s,i,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(pe=!e,pe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Be(e)){if("function"!=typeof e.toString)throw Bw("toString is not a function");if("string"!=typeof(e=e.toString()))throw Bw("dirty is not a string, aborting")}if(!o.isSupported)return e;if(K||ke(c),o.removed=[],"string"==typeof e&&(ne=!1),ne){if(e.nodeName){const t=we(e.nodeName);if(!H[t]||V[t])throw Bw("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)t=Ne("\x3c!----\x3e"),r=t.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?t=r:t.appendChild(r);else{if(!X&&!q&&!G&&-1===e.indexOf("<"))return w&&Q?w.createHTML(e):e;if(t=Ne(e),!t)return X?null:Q?x:""}t&&Y&&Ae(t.firstChild);const d=Re(ne?e:t);for(;s=d.nextNode();)He(s)||(s.content instanceof a&&ze(s.content),Fe(s));if(ne)return e;if(X){if(J)for(i=k.call(t.ownerDocument);t.firstChild;)i.appendChild(t.firstChild);else i=t;return(P.shadowroot||P.shadowrootmode)&&(i=E.call(n,i,!0)),i}let m=G?t.outerHTML:t.innerHTML;return G&&H["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&Rw(sx,t.ownerDocument.doctype.name)&&(m="\n"+m),q&&(m=Aw(m,O," "),m=Aw(m,D," "),m=Aw(m,A," ")),w&&Q?w.createHTML(m):m},o.setConfig=function(e){ke(e),K=!0},o.clearConfig=function(){xe=null,K=!1},o.isValidAttribute=function(e,t,o){xe||ke({});const n=we(e),r=we(t);return Ie(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(T[e]=T[e]||[],Ew(T[e],t))},o.removeHook=function(e){if(T[e])return _w(T[e])},o.removeHooks=function(e){T[e]&&(T[e]=[])},o.removeAllHooks=function(){T={}},o}();const cx=Bt.each,dx=Bt.trim,mx=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],ux={ftp:21,http:80,https:443,mailto:25},gx=["img","video"],hx=(e,t,o)=>{const n=(e=>{try{return decodeURIComponent(e)}catch(t){return unescape(e)}})(t).replace(/\s/g,"");return!e.allow_script_urls&&(!!/((java|vb)script|mhtml):/i.test(n)||!e.allow_html_data_urls&&(/^data:image\//i.test(n)?((e,t)=>C(e)?!e:!C(t)||!j(gx,t))(e.allow_svg_data_urls,o)&&/^data:image\/svg\+xml/i.test(n):/^data:/i.test(n)))};class px{static parseDataUri(e){let t;const o=decodeURIComponent(e).split(","),n=/data:([^;]+)/.exec(o[0]);return n&&(t=n[1]),{type:t,data:o[1]}}static isDomSafe(e,t,o={}){if(o.allow_script_urls)return!0;{const n=ia.decode(e).replace(/[\s\u0000-\u001F]+/g,"");return!hx(o,n,t)}}static getDocumentBaseUrl(e){var t;let o;return o=0!==e.protocol.indexOf("http")&&"file:"!==e.protocol?null!==(t=e.href)&&void 0!==t?t:"":e.protocol+"//"+e.host+e.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(o)&&(o=o.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(o)||(o+="/")),o}constructor(e,t={}){this.path="",this.directory="",e=dx(e),this.settings=t;const o=t.base_uri,n=this;if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(n.source=e);const r=0===e.indexOf("//");if(0!==e.indexOf("/")||r||(e=(o&&o.protocol||"http")+"://mce_host"+e),!/^[\w\-]*:?\/\//.test(e)){const t=o?o.path:new px(document.location.href).directory;if(""===(null==o?void 0:o.protocol))e="//mce_host"+n.toAbsPath(t,e);else{const r=/([^#?]*)([#?]?.*)/.exec(e);r&&(e=(o&&o.protocol||"http")+"://mce_host"+n.toAbsPath(t,r[1])+r[2])}}e=e.replace(/@@/g,"(mce_at)");const s=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);s&&cx(mx,((e,t)=>{let o=s[t];o&&(o=o.replace(/\(mce_at\)/g,"@@")),n[e]=o})),o&&(n.protocol||(n.protocol=o.protocol),n.userInfo||(n.userInfo=o.userInfo),n.port||"mce_host"!==n.host||(n.port=o.port),n.host&&"mce_host"!==n.host||(n.host=o.host),n.source=""),r&&(n.protocol="")}setPath(e){const t=/^(.*?)\/?(\w+)?$/.exec(e);t&&(this.path=t[0],this.directory=t[1],this.file=t[2]),this.source="",this.getURI()}toRelative(e){if("./"===e)return e;const t=new px(e,{base_uri:this});if("mce_host"!==t.host&&this.host!==t.host&&t.host||this.port!==t.port||this.protocol!==t.protocol&&""!==t.protocol)return t.getURI();const o=this.getURI(),n=t.getURI();if(o===n||"/"===o.charAt(o.length-1)&&o.substr(0,o.length-1)===n)return o;let r=this.toRelPath(this.path,t.path);return t.query&&(r+="?"+t.query),t.anchor&&(r+="#"+t.anchor),r}toAbsolute(e,t){const o=new px(e,{base_uri:this});return o.getURI(t&&this.isSameOrigin(o))}isSameOrigin(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;const t=this.protocol?ux[this.protocol]:null;if(t&&(this.port||t)==(e.port||t))return!0}return!1}toRelPath(e,t){let o,n,r=0,s="";const a=e.substring(0,e.lastIndexOf("/")).split("/"),i=t.split("/");if(a.length>=i.length)for(o=0,n=a.length;o=i.length||a[o]!==i[o]){r=o+1;break}if(a.length=a.length||a[o]!==i[o]){r=o+1;break}if(1===r)return t;for(o=0,n=a.length-(r-1);o{e&&a.push(e)}));const i=[];for(let e=s.length-1;e>=0;e--)0!==s[e].length&&"."!==s[e]&&(".."!==s[e]?o>0?o--:i.push(s[e]):o++);const l=a.length-o;let c;return c=l<=0?se(i).join("/"):a.slice(0,l).join("/")+"/"+se(i).join("/"),0!==c.indexOf("/")&&(c="/"+c),n&&c.lastIndexOf("/")!==c.length-1&&(c+=n),c}getURI(e=!1){let t;return this.source&&!e||(t="",e||(this.protocol?t+=this.protocol+"://":t+="//",this.userInfo&&(t+=this.userInfo+"@"),this.host&&(t+=this.host),this.port&&(t+=":"+this.port)),this.path&&(t+=this.path),this.query&&(t+="?"+this.query),this.anchor&&(t+="#"+this.anchor),this.source=t),this.source}}const fx=Bt.makeMap("src,href,data,background,action,formaction,poster,xlink:href"),vx="data-mce-type";let bx=0;const yx=(e,t,o,n,r)=>{var s,a,i,l;const c=t.validate,d=o.getSpecialElements();8===e.nodeType&&!t.allow_conditional_comments&&/^\[if/i.test(null!==(s=e.nodeValue)&&void 0!==s?s:"")&&(e.nodeValue=" "+e.nodeValue);const m=null!==(a=null==r?void 0:r.tagName)&&void 0!==a?a:e.nodeName.toLowerCase();if("html"!==n&&o.isValid(n))return void(C(r)&&(r.allowedTags[m]=!0));if(1!==e.nodeType||"body"===m)return;const u=yo.fromDom(e),g=ro(u,vx),p=oo(u,"data-mce-bogus");if(!g&&h(p))return void("all"===p?Cn(u):Sn(u));const f=o.getElementRule(m);if(!c||f){if(C(r)&&(r.allowedTags[m]=!0),c&&f&&!g){if(q(null!==(i=f.attributesForced)&&void 0!==i?i:[],(e=>{eo(u,e.name,"{$uid}"===e.value?"mce_"+bx++:e.value)})),q(null!==(l=f.attributesDefault)&&void 0!==l?l:[],(e=>{ro(u,e.name)||eo(u,e.name,"{$uid}"===e.value?"mce_"+bx++:e.value)})),f.attributesRequired&&!W(f.attributesRequired,(e=>ro(u,e))))return void Sn(u);if(f.removeEmptyAttrs&&(e=>{const t=e.dom.attributes;return null==t||0===t.length})(u))return void Sn(u);f.outputName&&f.outputName!==m&&Ei(u,f.outputName)}}else _e(d,m)?Cn(u):Sn(u)},wx=(e,t,o,n,r,s)=>"html"!==o&&!ws(n)||!(r in fx&&hx(e,s,n))&&(!e.validate||t.isValid(n,r)||je(r,"data-")||je(r,"aria-")),xx=(e,t)=>e.hasAttribute(vx)&&("id"===t||"class"===t||"style"===t),Cx=(e,t)=>e in t.getBoolAttrs(),Sx=(e,t,o,n)=>{const{attributes:r}=e;for(let s=r.length-1;s>=0;s--){const a=r[s],i=a.name,l=a.value;wx(t,o,n,e.tagName.toLowerCase(),i,l)||xx(e,i)?Cx(i,o)&&e.setAttribute(i,i):e.removeAttribute(i)}},kx=(e,t,o)=>{const n=lx();return n.addHook("uponSanitizeElement",((n,r)=>{yx(n,e,t,o.track(n),r)})),n.addHook("uponSanitizeAttribute",((n,r)=>{((e,t,o,n,r)=>{const s=e.tagName.toLowerCase(),{attrName:a,attrValue:i}=r;r.keepAttr=wx(t,o,n,s,a,i),r.keepAttr?(r.allowedAttributes[a]=!0,Cx(a,o)&&(r.attrValue=a),t.allow_svg_data_urls&&je(i,"data:image/svg+xml")&&(r.forceKeepAttr=!0)):xx(e,a)&&(r.forceKeepAttr=!0)})(n,e,t,o.current(),r)})),n},_x=e=>{const t=["type","href","role","arcrole","title","show","actuate","label","from","to"].map((e=>`xlink:${e}`)),o={IN_PLACE:!0,USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ALLOWED_ATTR:t};return lx().sanitize(e,o),e.innerHTML},Ex=(e,t)=>{const o=(()=>{let e=[];const t=()=>e[e.length-1];return{track:o=>{xs(o)&&e.push(o);let n=t();return n&&!n.contains(o)&&(e.pop(),n=t()),Cs(n)},current:()=>Cs(t()),reset:()=>{e=[]}}})();if(e.sanitize){const n=kx(e,t,o),r=(t,r)=>{n.sanitize(t,((e,t)=>{const o={IN_PLACE:!0,ALLOW_UNKNOWN_PROTOCOLS:!0,ALLOWED_TAGS:["#comment","#cdata-section","body"],ALLOWED_ATTR:[]};return o.PARSER_MEDIA_TYPE=t,e.allow_script_urls?o.ALLOWED_URI_REGEXP=/.*/:e.allow_html_data_urls&&(o.ALLOWED_URI_REGEXP=/^(?!(\w+script|mhtml):)/i),o})(e,r)),n.removed=[],o.reset()};return{sanitizeHtmlElement:r,sanitizeNamespaceElement:_x}}return{sanitizeHtmlElement:(n,r)=>{const s=document.createNodeIterator(n,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let a;for(;a=s.nextNode();){const n=o.track(a);yx(a,e,t,n),Wn(a)&&Sx(a,e,t,n)}o.reset()},sanitizeNamespaceElement:E}},Tx=Bt.makeMap,Ox=Bt.extend,Dx=(e,t,o,n)=>{const r=e.name,s=r in o&&"title"!==r&&"textarea"!==r,a=t.childNodes;for(let t=0,r=a.length;t{const r=o.validate,s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=Ox(Tx("script,style,head,html,body,title,meta,param"),t.getBlockElements()),l=va(t),c=/[ \t\r\n]+/g,d=/^[ \t\r\n]+/,m=/[ \t\r\n]+$/,u=e=>{let t=e.parent;for(;C(t);){if(t.name in a)return!0;t=t.parent}return!1},g=o=>o.name in i||Is(t,o)||ws(o.name)&&o.parent===e,h=(t,o)=>{const r=o?t.prev:t.next;return!C(r)&&!x(t.parent)&&g(t.parent)&&(t.parent!==e||!0===n.isRootContent)};return[e=>{var t;if(3===e.type&&!u(e)){let o=null!==(t=e.value)&&void 0!==t?t:"";o=o.replace(c," "),(((e,t)=>C(e)&&(t(e)||"br"===e.name))(e.prev,g)||h(e,!0))&&(o=o.replace(d,"")),0===o.length?e.remove():e.value=o}},e=>{var i;if(1===e.type){const i=t.getElementRule(e.name);if(r&&i){const r=mb(t,s,a,e);i.paddInEmptyBlock&&r&&(e=>{let o=e;for(;C(o);){if(o.name in l)return mb(t,s,a,o);o=o.parent}return!1})(e)?cb(o,n,g,e):i.removeEmpty&&r?g(e)?e.remove():e.unwrap():i.paddEmpty&&(r||(e=>{var t;return db(e,"#text")&&(null===(t=null==e?void 0:e.firstChild)||void 0===t?void 0:t.value)===br})(e))&&cb(o,n,g,e)}}else if(3===e.type&&!u(e)){let t=null!==(i=e.value)&&void 0!==i?i:"";(e.next&&g(e.next)||h(e,!1))&&(t=t.replace(m,"")),0===t.length?e.remove():e.value=t}}]},Mx=(e={},t=ya())=>{const o=Qy(),n=Qy(),r={validate:!0,root_name:"body",sanitize:!0,...e},s=new DOMParser,a=Ex(r,t),i=o.addFilter,l=o.getFilters,c=o.removeFilter,d=n.addFilter,m=n.getFilters,u=n.removeFilter,g=(e,o)=>{const n=h(o.attr(vx)),r=1===o.type&&!_e(e,o.name)&&!Is(t,o)&&!ws(o.name);return 3===o.type||r&&!n},p={schema:t,addAttributeFilter:d,getAttributeFilters:m,removeAttributeFilter:u,addNodeFilter:i,getNodeFilters:l,removeNodeFilter:c,parse:(e,o={})=>{var n;const i=r.validate,c=null!==(n=o.context)&&void 0!==n?n:r.root_name,d=((e,o,n="html")=>{const r="xhtml"===n?"application/xhtml+xml":"text/html",i=_e(t.getSpecialElements(),o.toLowerCase()),l=i?`<${o}>${e}`:e,c="xhtml"===n?`${l}`:`${l}`,d=s.parseFromString(c,r).body;return a.sanitizeHtmlElement(d,r),i?d.firstChild:d})(e,c,o.format);As(t,d);const u=new Ep(c,11);Dx(u,d,t.getSpecialElements(),a.sanitizeNamespaceElement),d.innerHTML="";const[h,p]=Ax(u,t,r,o),f=[],v=i?e=>((e,o)=>{pb(t,e)&&o.push(e)})(e,f):E,b={nodes:{},attributes:{}},y=e=>ab(l(),m(),e,b);if(((e,t,o)=>{const n=[];for(let o=e,r=o;o;r=o,o=o.walk()){const s=o;q(t,(e=>e(s))),x(s.parent)&&s!==e?o=r:n.push(s)}for(let e=n.length-1;e>=0;e--){const t=n[e];q(o,(e=>e(t)))}})(u,[h,y],[p,v]),f.reverse(),i&&f.length>0)if(o.context){const{pass:e,fail:n}=K(f,(e=>e.parent===u));hb(n,t,u,y),o.invalid=e.length>0}else hb(f,t,u,y);const w=((e,t)=>{var o;const n=null!==(o=t.forced_root_block)&&void 0!==o?o:e.forced_root_block;return!1===n?"":!0===n?"p":n})(r,o);return w&&("body"===u.name||o.isRootContent)&&((e,o)=>{const n=Ox(Tx("script,style,head,html,body,title,meta,param"),t.getBlockElements()),s=/^[ \t\r\n]+/,a=/[ \t\r\n]+$/;let i=e.firstChild,l=null;const c=e=>{var t,o;e&&(i=e.firstChild,i&&3===i.type&&(i.value=null===(t=i.value)||void 0===t?void 0:t.replace(s,"")),i=e.lastChild,i&&3===i.type&&(i.value=null===(o=i.value)||void 0===o?void 0:o.replace(a,"")))};if(t.isValidChild(e.name,o.toLowerCase())){for(;i;){const t=i.next;g(n,i)?(l||(l=new Ep(o,1),l.attr(r.forced_root_block_attrs),e.insert(l,i)),l.append(i)):(c(l),l=null),i=t}c(l)}})(u,w),o.invalid||ib(b,o),u}};return gw(p,r),((e,t,o)=>{t.inline_styles&&tw(e,t,o)})(p,r,t),p},Nx=(e,t,o)=>{const n=(e=>Nb(e)?$p({validate:!1}).serialize(e):e)(e),r=t(n);if(r.isDefaultPrevented())return r;if(Nb(e)){if(r.content!==n){const t=Mx({validate:!1,forced_root_block:!1,...o}).parse(r.content,{context:e.name});return{...r,content:t}}return{...r,content:e}}return r},Rx=(e,t)=>{if(t.no_events)return Dl.value(t);{const o=((e,t)=>e.dispatch("BeforeGetContent",t))(e,t);return o.isDefaultPrevented()?Dl.error(Tg(e,{content:"",...o}).content):Dl.value(o)}},Bx=(e,t,o)=>{if(o.no_events)return t;{const n=Nx(t,(t=>Tg(e,{...o,content:t})),{sanitize:Td(e),sandbox_iframes:Bd(e)});return n.content}},Lx=(e,t)=>{if(t.no_events)return Dl.value(t);{const o=Nx(t.content,(o=>((e,t)=>e.dispatch("BeforeSetContent",t))(e,{...t,content:o})),{sanitize:Td(e),sandbox_iframes:Bd(e)});return o.isDefaultPrevented()?(Eg(e,o),Dl.error(void 0)):Dl.value(o)}},Hx=(e,t,o)=>{o.no_events||Eg(e,{...o,content:t})},Ix=(e,t,o)=>({element:e,width:t,rows:o}),Px=(e,t)=>({element:e,cells:t}),Fx=(e,t)=>({x:e,y:t}),zx=(e,t)=>no(e,t).bind(Je).getOr(1),Vx=(e,t,o)=>{const n=e.rows;return!!(n[o]?n[o].cells:[])[t]},Zx=e=>J(e,((e,t)=>t.cells.length>e?t.cells.length:e),0),Ux=(e,t)=>{const o=e.rows;for(let e=0;e{const s=[],a=e.rows;for(let e=o;e<=r;e++){const o=a[e].cells,r=t{const t=Ix(ki(e),0,[]);return q(zn(e,"tr"),((e,o)=>{q(zn(e,"td,th"),((n,r)=>{((e,t,o,n,r)=>{const s=zx(r,"rowspan"),a=zx(r,"colspan"),i=e.rows;for(let e=o;e{for(;Vx(e,t,o);)t++;return t})(t,r,o),o,e,n)}))})),Ix(t.element,Zx(t.rows),t.rows)},$x=e=>((e,t)=>{const o=ki(e.element),n=yo.fromTag("tbody");return wn(n,t),bn(o,n),o})(e,(e=>$(e.rows,(e=>{const t=$(e.cells,(e=>{const t=_i(e);return so(t,"colspan"),so(t,"rowspan"),t})),o=ki(e.element);return wn(o,t),o})))(e)),qx=(e,t,o)=>Ux(e,t).bind((t=>Ux(e,o).map((o=>((e,t,o)=>{const n=t.x,r=t.y,s=o.x,a=o.y,i=ree(e,(e=>"li"===jt(e)&&Su(e,t))).fold(D([]),(t=>(e=>ee(e,(e=>"ul"===jt(e)||"ol"===jt(e))))(e).map((e=>{const t=yo.fromTag(jt(e)),o=xe(gn(e),((e,t)=>je(t,"list-style")));return cn(t,o),[yo.fromTag("li"),t]})).getOr([]))),Kx=(e,t,o)=>{const n=yo.fromDom(t.commonAncestorContainer),r=pf(n,e),s=Y(r,(e=>o.isWrapper(jt(e)))),a=Gx(r,t),i=s.concat(a.length?a:(e=>Tr(e)?Oo(e).filter(Er).fold(D([]),(t=>[e,t])):Er(e)?[e]:[])(n));return $(i,ki)},Yx=()=>Xg([]),Xx=(e,t,o)=>((e,t)=>{const o=J(t,((e,t)=>(bn(t,e),t)),e);return t.length>0?Xg([o]):o})(yo.fromDom(t.cloneContents()),Kx(e,t,o)),Jx=(e,t)=>((e,t)=>en(t,"table",N(So,e)))(e,t[0]).bind((e=>{const o=t[0],n=t[t.length-1],r=Wx(e);return qx(r,o,n).map((e=>Xg([$x(e)])))})).getOrThunk(Yx),Qx=(e,t,o)=>{const n=bu(t,e);return n.length>0?Jx(e,n):((e,t,o)=>t.length>0&&t[0].collapsed?Yx():Xx(e,t[0],o))(e,t,o)},eC=(e,t)=>t>=0&&tHr(e.innerText),oC=(e,t)=>{if("text"===t.format)return(e=>F.from(e.selection.getRng()).map((t=>{var o;const n=F.from(e.dom.getParent(t.commonAncestorContainer,e.dom.isBlock)),r=e.getBody(),s=(e=>e.map((e=>e.nodeName)).getOr("div").toLowerCase())(n),a=yo.fromDom(t.cloneContents());zp(a),Vp(a);const i=e.dom.add(r,s,{"data-mce-bogus":"all",style:"overflow: hidden; opacity: 0;"},a.dom),l=tC(i),c=Hr(null!==(o=i.textContent)&&void 0!==o?o:"");if(e.dom.remove(i),eC(c,0)||eC(c,c.length-1)){const e=n.getOr(r),t=tC(e),o=t.indexOf(l);return-1===o?l:(eC(t,o-1)?" ":"")+l+(eC(t,o+l.length)?" ":"")}return l})).getOr(""))(e);{const o=((e,t)=>{const o=e.selection.getRng(),n=e.dom.create("body"),r=e.selection.getSel(),s=pp(e,fu(r)),a=t.contextual?Qx(yo.fromDom(e.getBody()),s,e.schema).dom:o.cloneContents();return a&&n.appendChild(a),e.selection.serializer.serialize(n,t)})(e,t);return"tree"===t.format?o:e.selection.isCollapsed()?"":o}},nC=e=>Wn(e)?e.outerHTML:tr(e)?ia.encodeRaw(e.data,!1):rr(e)?"\x3c!--"+e.data+"--\x3e":"",rC=(e,t,o)=>{const n=(e=>{let t;const o=document.createElement("div"),n=document.createDocumentFragment();for(e&&(o.innerHTML=e);t=o.firstChild;)n.appendChild(t);return n})(t);if(e.hasChildNodes()&&o(((e,t)=>{let o=0;q(e,(e=>{0===e[0]?o++:1===e[0]?(rC(t,e[1],o),o++):2===e[0]&&((e,t)=>{if(e.hasChildNodes()&&t{const o=e.length+t.length+2,n=new Array(o),r=new Array(o),s=(o,n,r,a,l)=>{const c=i(o,n,r,a);if(null===c||c.start===n&&c.diag===n-a||c.end===o&&c.diag===o-r){let s=o,i=r;for(;sa-r?(l.push([2,e[s]]),++s):(l.push([1,t[i]]),++i)}else{s(o,c.start,r,c.start-c.diag,l);for(let t=c.start;t{let a=o;for(;a-n({start:e,end:t,diag:o}))(o,a,n)},i=(o,s,i,l)=>{const c=s-o,d=l-i;if(0===c||0===d)return null;const m=c-d,u=d+c,g=(u%2==0?u:u+1)/2;let h,p,f,v,b;for(n[1+g]=o,r[1+g]=s+1,h=0;h<=g;++h){for(p=-h;p<=h;p+=2){for(f=p+g,p===-h||p!==h&&n[f-1]=o&&b>=i&&e[v]===t[b];)r[f]=v--,b--;if(m%2==0&&-h<=p&&p<=h&&r[f]<=n[f+m])return a(r[f],p+o-i,s,l)}}return null},l=[];return s(0,e.length,0,t.length,l),l})($(ue(t.childNodes),nC),e),t),t),aC=He((()=>document.implementation.createHTMLDocument("undo"))),iC=e=>{const t=e.serializer.getTempAttrs(),o=Fp(e.getBody(),t);return(e=>null!==e.querySelector("iframe"))(o)?(n=((e,t)=>Y($(ue(e.childNodes),t?T(Hr,nC):nC),(e=>e.length>0)))(o,!0),{type:"fragmented",fragments:n,content:"",bookmark:null,beforeBookmark:null}):{type:"complete",fragments:null,content:Hr(o.innerHTML),bookmark:null,beforeBookmark:null};var n},lC=(e,t,o)=>{const n=o?t.beforeBookmark:t.bookmark;"fragmented"===t.type?sC(t.fragments,e.getBody()):e.setContent(t.content,{format:"raw",no_selection:!C(n)||!eu(n)||!n.isFakeCaret}),n&&(e.selection.moveToBookmark(n),e.selection.scrollIntoView())},cC=e=>"fragmented"===e.type?e.fragments.join(""):e.content,dC=e=>{const t=yo.fromTag("body",aC());return En(t,cC(e)),q(zn(t,"*[data-mce-bogus]"),Sn),_n(t)},mC=(e,t)=>!(!e||!t)&&(!!((e,t)=>cC(e)===cC(t))(e,t)||((e,t)=>dC(e)===dC(t))(e,t)),uC=e=>0===e.get(),gC=(e,t,o)=>{uC(o)&&(e.typing=t)},hC=(e,t)=>{e.typing&&(gC(e,!1,t),e.add())},pC=e=>({init:{bindEvents:E},undoManager:{beforeChange:(t,o)=>((e,t,o)=>{uC(t)&&o.set(El(e.selection))})(e,t,o),add:(t,o,n,r,s,a)=>((e,t,o,n,r,s,a)=>{const i=iC(e),l=Bt.extend(s||{},i);if(!uC(n)||e.removed)return null;const c=t.data[o.get()];if(e.dispatch("BeforeAddUndo",{level:l,lastLevel:c,originalEvent:a}).isDefaultPrevented())return null;if(c&&mC(c,l))return null;t.data[o.get()]&&r.get().each((e=>{t.data[o.get()].beforeBookmark=e}));const d=jc(e);if(d&&t.data.length>d){for(let e=0;e0?(e.setDirty(!0),e.dispatch("AddUndo",m),e.dispatch("change",m)):e.dispatch("AddUndo",m),l})(e,t,o,n,r,s,a),undo:(t,o,n)=>((e,t,o,n)=>{let r;return t.typing&&(t.add(),t.typing=!1,gC(t,!1,o)),n.get()>0&&(n.set(n.get()-1),r=t.data[n.get()],lC(e,r,!0),e.setDirty(!0),e.dispatch("Undo",{level:r})),r})(e,t,o,n),redo:(t,o)=>((e,t,o)=>{let n;return t.get()((e,t,o)=>{t.data=[],o.set(0),t.typing=!1,e.dispatch("ClearUndos")})(e,t,o),reset:e=>(e=>{e.clear(),e.add()})(e),hasUndo:(t,o)=>((e,t,o)=>o.get()>0||t.typing&&t.data[0]&&!mC(iC(e),t.data[0]))(e,t,o),hasRedo:(e,t)=>((e,t)=>t.get()((e,t,o)=>(hC(e,t),e.beforeChange(),e.ignore(o),e.add()))(e,t,o),ignore:(e,t)=>((e,t)=>{try{e.set(e.get()+1),t()}finally{e.set(e.get()-1)}})(e,t),extra:(t,o,n,r)=>((e,t,o,n,r)=>{if(t.transact(n)){const n=t.data[o.get()].bookmark,s=t.data[o.get()-1];lC(e,s,!0),t.transact(r)&&(t.data[o.get()-1].beforeBookmark=n)}})(e,t,o,n,r)},formatter:{match:(t,o,n,r)=>Ub(e,t,o,n,r),matchAll:(t,o)=>((e,t,o)=>{const n=[],r={},s=e.selection.getStart();return e.dom.getParent(s,(s=>{for(let a=0;aZb(e,t,o,n,r),canApply:t=>((e,t)=>{const o=e.formatter.get(t),n=e.dom;if(o&&e.selection.isEditable()){const t=e.selection.getStart(),r=Zu(n,t);for(let e=o.length-1;e>=0;e--){const t=o[e];if(!$u(t))return!0;for(let e=r.length-1;e>=0;e--)if(n.is(r[e],t.selector))return!0}}return!1})(e,t),closest:t=>jb(e,t),apply:(t,o,n)=>Wy(e,t,o,n),remove:(t,o,n,r)=>Py(e,t,o,n,r),toggle:(t,o,n)=>((e,t,o,n)=>{const r=e.formatter.get(t);r&&(!Ub(e,t,o,n)||"toggle"in r[0]&&!r[0].toggle?Wy(e,t,o,n):Py(e,t,o,n))})(e,t,o,n),formatChanged:(t,o,n,r,s)=>Xy(e,t,o,n,r,s)},editor:{getContent:t=>((e,t)=>F.from(e.getBody()).fold(D("tree"===t.format?new Ep("body",11):""),(o=>Up(e,t,o))))(e,t),setContent:(t,o)=>Bb(e,t,o),insertContent:(t,o)=>Mb(e,t,o),addVisual:t=>((e,t)=>{const o=e.dom,n=C(t)?t:e.getBody();q(o.select("table,a",n),(t=>{switch(t.nodeName){case"TABLE":const n=Qc(e),r=o.getAttrib(t,"border");r&&"0"!==r||!e.hasVisual?o.removeClass(t,n):o.addClass(t,n);break;case"A":if(!o.getAttrib(t,"href")){const n=o.getAttrib(t,"name")||t.id,r=ed(e);n&&e.hasVisual?o.addClass(t,r):o.removeClass(t,r)}}})),e.dispatch("VisualAid",{element:t,hasVisual:e.hasVisual})})(e,t)},selection:{getContent:(t,o)=>((e,t,o={})=>{const n=((e,t)=>({...e,format:t,get:!0,selection:!0,getInner:!0}))(o,t);return Rx(e,n).fold(A,(t=>{const o=oC(e,t);return Bx(e,o,t)}))})(e,t,o)},autocompleter:{addDecoration:t=>wp(e,t),removeDecoration:()=>((e,t)=>xp(t).each((t=>{const o=e.selection.getBookmark();Sn(t),e.selection.moveToBookmark(o)})))(e,yo.fromDom(e.getBody()))},raw:{getModel:()=>F.none()}}),fC=e=>_e(e.plugins,"rtc"),vC=e=>{const t=e;return(e=>ke(e.plugins,"rtc").bind((e=>F.from(e.setup))))(e).fold((()=>(t.rtcInstance=pC(e),F.none())),(e=>(t.rtcInstance=(()=>{const e=D(null),t=D("");return{init:{bindEvents:E},undoManager:{beforeChange:E,add:e,undo:e,redo:e,clear:E,reset:E,hasUndo:I,hasRedo:I,transact:e,ignore:E,extra:E},formatter:{match:I,matchAll:D([]),matchNode:D(void 0),canApply:I,closest:t,apply:E,remove:E,toggle:E,formatChanged:D({unbind:E})},editor:{getContent:t,setContent:D({content:"",html:""}),insertContent:D(""),addVisual:E},selection:{getContent:t},autocompleter:{addDecoration:E,removeDecoration:E},raw:{getModel:D(F.none())}}})(),F.some((()=>e().then((e=>(t.rtcInstance=(e=>{const t=e=>p(e)?e:{},{init:o,undoManager:n,formatter:r,editor:s,selection:a,autocompleter:i,raw:l}=e;return{init:{bindEvents:o.bindEvents},undoManager:{beforeChange:n.beforeChange,add:n.add,undo:n.undo,redo:n.redo,clear:n.clear,reset:n.reset,hasUndo:n.hasUndo,hasRedo:n.hasRedo,transact:(e,t,o)=>n.transact(o),ignore:(e,t)=>n.ignore(t),extra:(e,t,o,r)=>n.extra(o,r)},formatter:{match:(e,o,n,s)=>r.match(e,t(o),s),matchAll:r.matchAll,matchNode:r.matchNode,canApply:e=>r.canApply(e),closest:e=>r.closest(e),apply:(e,o,n)=>r.apply(e,t(o)),remove:(e,o,n,s)=>r.remove(e,t(o)),toggle:(e,o,n)=>r.toggle(e,t(o)),formatChanged:(e,t,o,n,s)=>r.formatChanged(t,o,n,s)},editor:{getContent:e=>s.getContent(e),setContent:(e,t)=>({content:s.setContent(e,t),html:""}),insertContent:(e,t)=>(s.insertContent(e),""),addVisual:s.addVisual},selection:{getContent:(e,t)=>a.getContent(t)},autocompleter:{addDecoration:i.addDecoration,removeDecoration:i.removeDecoration},raw:{getModel:()=>F.some(l.getRawModel())}}})(e),e.rtc.isRemote))))))))},bC=e=>e.rtcInstance?e.rtcInstance:pC(e),yC=e=>{const t=e.rtcInstance;if(t)return t;throw new Error("Failed to get RTC instance not yet initialized.")},wC=e=>yC(e).init.bindEvents(),xC=(e,t={})=>((e,t,o)=>yC(e).selection.getContent(t,o))(e,t.format?t.format:"html",t),CC=e=>0===e.dom.length?(Cn(e),F.none()):F.some(e),SC=(e,t,o,n,r)=>{e.bind((e=>((n?Kf:Gf)(e.dom,n?e.dom.length:0,r),t.filter(Kt).map((t=>((e,t,o,n,r)=>{const s=e.dom,a=t.dom,i=n?s.length:a.length;n?(Yf(s,a,r,!1,!n),o.setStart(a,i)):(Yf(a,s,r,!1,!n),o.setEnd(a,i))})(e,t,o,n,r)))))).orThunk((()=>{const e=((e,t)=>e.filter((e=>xg.isBookmarkNode(e.dom))).bind(t?No:Mo))(t,n).or(t).filter(Kt);return e.map((e=>((e,t,o)=>{Oo(e).each((n=>{const r=e.dom;t&&Pf(n,rl(r,0),o)?Gf(r,0,o):!t&&Ff(n,rl(r,r.length),o)&&Kf(r,r.length,o)}))})(e,n,r)))}))},kC=(e,t,o={})=>{const n=((e,t)=>({format:"html",...e,set:!0,selection:!0,content:t}))(o,t);Lx(e,n).each((t=>{const o=((e,t)=>{if("raw"!==t.format){const o=e.selection.getRng(),n=e.dom.getParent(o.commonAncestorContainer,e.dom.isBlock),r=n?{context:n.nodeName.toLowerCase()}:{},s=e.parser.parse(t.content,{forced_root_block:!1,...r,...t});return $p({validate:!1},e.schema).serialize(s)}return t.content})(e,t),n=e.selection.getRng();((e,t,o)=>{const n=F.from(t.firstChild).map(yo.fromDom),r=F.from(t.lastChild).map(yo.fromDom);e.deleteContents(),e.insertNode(t);const s=n.bind(Mo).filter(Kt).bind(CC),a=r.bind(No).filter(Kt).bind(CC);SC(s,n,e,!0,o),SC(a,r,e,!1,o),e.collapse(!1)})(n,n.createContextualFragment(o),e.schema),e.selection.setRng(n),Rh(e,n),Hx(e,o,t)}))},_C=(e,t,o)=>{if(_e(e,t)){const n=Y(e[t],(e=>e!==o));0===n.length?delete e[t]:e[t]=n}};var EC=(e,t)=>{let o,n;const r=(t,o)=>ee(o,(o=>e.is(o,t))),s=t=>e.getParents(t,void 0,e.getRoot());return{selectorChangedWithUnbind:(e,a)=>(o||(o={},n={},t.on("NodeChange",(e=>{const t=e.element,a=s(t),i={};fe(o,((e,t)=>{r(t,a).each((o=>{n[t]||(q(e,(e=>{e(!0,{node:o,selector:t,parents:a})})),n[t]=e),i[t]=e}))})),fe(n,((e,o)=>{i[o]||(delete n[o],q(e,(e=>{e(!1,{node:t,selector:o,parents:a})})))}))}))),o[e]||(o[e]=[]),o[e].push(a),r(e,s(t.selection.getStart())).each((()=>{n[e]=o[e]})),{unbind:()=>{_C(o,e,a),_C(n,e,a)}})}};const TC=e=>!(!e||!e.ownerDocument)&&ko(yo.fromDom(e.ownerDocument),yo.fromDom(e)),OC=(e,t,o,n)=>{let r,s;const{selectorChangedWithUnbind:a}=EC(e,n),i=(e,t)=>kC(n,e,t),l=e=>{const t=d();t.collapse(!!e),m(t)},c=()=>t.getSelection?t.getSelection():t.document.selection,d=()=>{let o;const a=(e,t,o)=>{try{return t.compareBoundaryPoints(e,o)}catch(e){return-1}},i=t.document;if(C(n.bookmark)&&!ap(n)){const e=Wh(n);if(e.isSome())return e.map((e=>pp(n,[e])[0])).getOr(i.createRange())}try{const e=c();e&&!jn(e.anchorNode)&&(o=e.rangeCount>0?e.getRangeAt(0):i.createRange(),o=pp(n,[o])[0])}catch(e){}if(o||(o=i.createRange()),sr(o.startContainer)&&o.collapsed){const t=e.getRoot();o.setStart(t,0),o.setEnd(t,0)}return r&&s&&(0===a(o.START_TO_START,o,r)&&0===a(o.END_TO_END,o,r)?o=s:(r=null,s=null)),o},m=(e,t)=>{if(!(e=>!!e&&TC(e.startContainer)&&TC(e.endContainer))(e))return;const o=c();if(e=n.dispatch("SetSelectionRange",{range:e,forward:t}).range,o){s=e;try{o.removeAllRanges(),o.addRange(e)}catch(e){}!1===t&&o.extend&&(o.collapse(e.endContainer,e.endOffset),o.extend(e.startContainer,e.startOffset)),r=o.rangeCount>0?o.getRangeAt(0):null}if(!e.collapsed&&e.startContainer===e.endContainer&&(null==o?void 0:o.setBaseAndExtent)&&e.endOffset-e.startOffset<2&&e.startContainer.hasChildNodes()){const t=e.startContainer.childNodes[e.startOffset];t&&"IMG"===t.nodeName&&(o.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset),o.anchorNode===e.startContainer&&o.focusNode===e.endContainer||o.setBaseAndExtent(t,0,t,1))}n.dispatch("AfterSetSelectionRange",{range:e,forward:t})},u=()=>{const t=c(),o=null==t?void 0:t.anchorNode,n=null==t?void 0:t.focusNode;if(!t||!o||!n||jn(o)||jn(n))return!0;const r=e.createRng(),s=e.createRng();try{r.setStart(o,t.anchorOffset),r.collapse(!0),s.setStart(n,t.focusOffset),s.collapse(!0)}catch(e){return!0}return r.compareBoundaryPoints(r.START_TO_START,s)<=0},g={dom:e,win:t,serializer:o,editor:n,expand:(t={type:"word"})=>m(mh(e).expand(d(),t)),collapse:l,setCursorLocation:(t,o)=>{const r=e.createRng();C(t)&&C(o)?(r.setStart(t,o),r.setEnd(t,o),m(r),l(!1)):(ku(e,r,n.getBody(),!0),m(r))},getContent:e=>xC(n,e),setContent:i,getBookmark:(e,t)=>h.getBookmark(e,t),moveToBookmark:e=>h.moveToBookmark(e),select:(t,o)=>(((e,t,o)=>F.from(t).bind((t=>F.from(t.parentNode).map((n=>{const r=e.nodeIndex(t),s=e.createRng();return s.setStart(n,r),s.setEnd(n,r+1),o&&(ku(e,s,t,!0),ku(e,s,t,!1)),s})))))(e,t,o).each(m),t),isCollapsed:()=>{const e=d(),t=c();return!(!e||e.item)&&(e.compareEndPoints?0===e.compareEndPoints("StartToEnd",e):!t||e.collapsed)},isEditable:()=>{const t=d(),o=n.getBody().querySelectorAll('[data-mce-selected="1"]');return o.length>0?re(o,(t=>e.isEditable(t.parentElement))):dp(e,t)},isForward:u,setNode:t=>(i(e.getOuterHTML(t)),t),getNode:()=>((e,t)=>{if(!t)return e;let o=t.startContainer,n=t.endContainer;const r=t.startOffset,s=t.endOffset;let a=t.commonAncestorContainer;t.collapsed||(o===n&&s-r<2&&o.hasChildNodes()&&(a=o.childNodes[r]),tr(o)&&tr(n)&&(o=o.length===r?hp(o.nextSibling,!0):o.parentNode,n=0===s?hp(n.previousSibling,!1):n.parentNode,o&&o===n&&(a=o)));const i=tr(a)?a.parentNode:a;return $n(i)?i:e})(n.getBody(),d()),getSel:c,setRng:m,getRng:d,getStart:e=>up(n.getBody(),d(),e),getEnd:e=>gp(n.getBody(),d(),e),getSelectedBlocks:(t,o)=>((e,t,o,n)=>{const r=[],s=e.getRoot(),a=e.getParent(o||up(s,t,t.collapsed),e.isBlock),i=e.getParent(n||gp(s,t,t.collapsed),e.isBlock);if(a&&a!==s&&r.push(a),a&&i&&a!==i){let t;const o=new Zn(a,s);for(;(t=o.next())&&t!==i;)e.isBlock(t)&&r.push(t)}return i&&a!==i&&i!==s&&r.push(i),r})(e,d(),t,o),normalize:()=>{const t=d(),o=c();if(!(fu(o).length>1)&&_u(n)){const o=lh(e,t);return o.each((e=>{m(e,u())})),o.getOr(t)}return t},selectorChanged:(e,t)=>(a(e,t),g),selectorChangedWithUnbind:a,getScrollContainer:()=>{let t,o=e.getRoot();for(;o&&"BODY"!==o.nodeName;){if(o.scrollHeight>o.clientHeight){t=o;break}o=o.parentNode}return t},scrollIntoView:(e,t)=>{C(e)?((e,t,o)=>{(e.inline?Ah:Nh)(e,t,o)})(n,e,t):Rh(n,d(),t)},placeCaretAt:(e,t)=>m(eh(e,t,n.getDoc())),getBoundingClientRect:()=>{const e=d();return e.collapsed?rl.fromRangeStart(e).getClientRects()[0]:e.getBoundingClientRect()},destroy:()=>{t=r=s=null,p.destroy()}},h=xg(g),p=Bg(g,n);return g.bookmarkManager=h,g.controlSelection=p,g},DC=(e,t,o)=>((e,t)=>C(e)&&e.hasEventListeners("PreProcess")&&!t.no_events)(e,o)?((e,t,o)=>{let n;const r=e.dom;let s=t.cloneNode(!0);const a=document.implementation;if(a.createHTMLDocument){const e=a.createHTMLDocument("");Bt.each("BODY"===s.nodeName?s.childNodes:[s],(t=>{e.body.appendChild(e.importNode(t,!0))})),s="BODY"!==s.nodeName?e.body.firstChild:e.body,n=r.doc,r.doc=e}return((e,t)=>{e.dispatch("PreProcess",t)})(e,{...o,node:s}),n&&(r.doc=n),s})(e,t,o):t,AC=(e,t,o)=>{-1===Bt.inArray(t,o)&&(e.addAttributeFilter(o,((e,t)=>{let o=e.length;for(;o--;)e[o].attr(t,null)})),t.push(o))},MC=(e,t,o,n,r)=>{const s=((e,t,o)=>$p(e,t).serialize(o))(t,o,n);return((e,t,o)=>{if(!t.no_events&&e){const n=((e,t)=>e.dispatch("PostProcess",t))(e,{...t,content:o});return n.content}return o})(e,r,s)},NC=(e,t)=>{const o=["data-mce-selected"],n={entity_encoding:"named",remove_trailing_brs:!0,pad_empty_with_br:!1,...e},r=t&&t.dom?t.dom:Ya.DOM,s=t&&t.schema?t.schema:ya(n),a=Mx(n,s);return((e,t,o)=>{e.addAttributeFilter("data-mce-tabindex",((e,t)=>{let o=e.length;for(;o--;){const n=e[o];n.attr("tabindex",n.attr("data-mce-tabindex")),n.attr(t,null)}})),e.addAttributeFilter("src,href,style",((e,n)=>{const r="data-mce-"+n,s=t.url_converter,a=t.url_converter_scope;let i=e.length;for(;i--;){const t=e[i];let l=t.attr(r);void 0!==l?(t.attr(n,l.length>0?l:null),t.attr(r,null)):(l=t.attr(n),"style"===n?l=o.serializeStyle(o.parseStyle(l),t.name):s&&(l=s.call(a,l,n,t.name)),t.attr(n,l.length>0?l:null))}})),e.addAttributeFilter("class",(e=>{let t=e.length;for(;t--;){const o=e[t];let n=o.attr("class");n&&(n=n.replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),o.attr("class",n.length>0?n:null))}})),e.addAttributeFilter("data-mce-type",((e,t,o)=>{let n=e.length;for(;n--;){const t=e[n];if("bookmark"===t.attr("data-mce-type")&&!o.cleanup){const e=F.from(t.firstChild).exists((e=>{var t;return!Lr(null!==(t=e.value)&&void 0!==t?t:"")}));e?t.unwrap():t.remove()}}})),e.addNodeFilter("noscript",(e=>{var t;let o=e.length;for(;o--;){const n=e[o].firstChild;n&&(n.value=ia.decode(null!==(t=n.value)&&void 0!==t?t:""))}})),e.addNodeFilter("script,style",((e,o)=>{var n;const r=e=>e.replace(/()/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*(()?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"");let s=e.length;for(;s--;){const a=e[s],i=a.firstChild,l=null!==(n=null==i?void 0:i.value)&&void 0!==n?n:"";if("script"===o){const e=a.attr("type");e&&a.attr("type","mce-no/type"===e?null:e.replace(/^mce\-/,"")),"xhtml"===t.element_format&&i&&l.length>0&&(i.value="// ")}else"xhtml"===t.element_format&&i&&l.length>0&&(i.value="\x3c!--\n"+r(l)+"\n--\x3e")}})),e.addNodeFilter("#comment",(e=>{let n=e.length;for(;n--;){const r=e[n],s=r.value;t.preserve_cdata&&0===(null==s?void 0:s.indexOf("[CDATA["))?(r.name="#cdata",r.type=4,r.value=o.decode(s.replace(/^\[CDATA\[|\]\]$/g,""))):0===(null==s?void 0:s.indexOf("mce:protected "))&&(r.name="#text",r.type=3,r.raw=!0,r.value=unescape(s).substr(14))}})),e.addNodeFilter("xml:namespace,input",((e,t)=>{let o=e.length;for(;o--;){const n=e[o];7===n.type?n.remove():1===n.type&&("input"!==t||n.attr("type")||n.attr("type","text"))}})),e.addAttributeFilter("data-mce-type",(t=>{q(t,(t=>{"format-caret"===t.attr("data-mce-type")&&(t.isEmpty(e.schema.getNonEmptyElements())?t.remove():t.unwrap())}))})),e.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-block,data-mce-type,data-mce-resize,data-mce-placeholder",((e,t)=>{let o=e.length;for(;o--;)e[o].attr(t,null)})),t.remove_trailing_brs&&ow(t,e,e.schema)})(a,n,r),{schema:s,addNodeFilter:a.addNodeFilter,addAttributeFilter:a.addAttributeFilter,serialize:(e,o={})=>{const i={format:"html",...o},l=DC(t,e,i),c=((e,t,o)=>{const n=Hr(o.getInner?t.innerHTML:e.getOuterHTML(t));return o.selection||Ar(yo.fromDom(t))?n:Bt.trim(n)})(r,l,i),d=((e,t,o)=>{const n=o.selection?{forced_root_block:!1,...o}:o,r=e.parse(t,n);return(e=>{const t=e=>"br"===(null==e?void 0:e.name),o=e.lastChild;if(t(o)){const e=o.prev;t(e)&&(o.remove(),e.remove())}})(r),r})(a,c,i);return"tree"===i.format?d:MC(t,n,s,d,i)},addRules:s.addValidElements,setRules:s.setValidElements,addTempAttr:N(AC,a,o),getTempAttrs:D(o),getNodeFilters:a.getNodeFilters,getAttributeFilters:a.getAttributeFilters,removeNodeFilter:a.removeNodeFilter,removeAttributeFilter:a.removeAttributeFilter}},RC=(e,t)=>{const o=NC(e,t);return{schema:o.schema,addNodeFilter:o.addNodeFilter,addAttributeFilter:o.addAttributeFilter,serialize:o.serialize,addRules:o.addRules,setRules:o.setRules,addTempAttr:o.addTempAttr,getTempAttrs:o.getTempAttrs,getNodeFilters:o.getNodeFilters,getAttributeFilters:o.getAttributeFilters,removeNodeFilter:o.removeNodeFilter,removeAttributeFilter:o.removeAttributeFilter}},BC=(e,t={})=>{const o=((e,t)=>({...e,format:t,get:!0,getInner:!0}))(t,t.format?t.format:"html");return Rx(e,o).fold(A,(t=>{const o=((e,t)=>bC(e).editor.getContent(t))(e,t);return Bx(e,o,t)}))},LC=(e,t,o={})=>{const n=((e,t)=>({format:"html",...e,set:!0,content:t}))(o,t);return Lx(e,n).map((t=>{const o=((e,t,o)=>bC(e).editor.setContent(t,o))(e,t.content,t);return Hx(e,o.html,t),o.content})).getOr(t)},HC="autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists".split(","),IC="template_cdate_classes,template_mdate_classes,template_selected_content_classes,template_preview_replace_values,template_replace_values,templates,template_cdate_format,template_mdate_format".split(","),PC="bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor".split(","),FC=[{name:"template",replacedWith:"Advanced Template"},{name:"rtc"}],zC=(e,t)=>{const o=Y(t,(t=>_e(e,t)));return le(o)},VC=e=>{const t=zC(e,HC),o=e.forced_root_block;return!1!==o&&""!==o||t.push("forced_root_block (false only)"),le(t)},ZC=e=>zC(e,IC),UC=(e,t)=>{const o=Bt.makeMap(e.plugins," "),n=Y(t,(e=>_e(o,e)));return le(n)},jC=e=>UC(e,PC),WC=e=>UC(e,FC.map((e=>e.name))),$C=e=>ee(FC,(t=>t.name===e)).fold((()=>e),(t=>t.replacedWith?`${e}, replaced by ${t.replacedWith}`:e)),qC=(e,t)=>{((e,t)=>{const o=VC(e),n=jC(t),r=n.length>0,s=o.length>0,a="mobile"===t.theme;if(r||s||a){const e="\n- ",t=a?`\n\nThemes:${e}mobile`:"",i=r?`\n\nPlugins:${e}${n.join(e)}`:"",l=s?`\n\nOptions:${e}${o.join(e)}`:"";console.warn("The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information."+t+i+l)}})(e,t),((e,t)=>{const o=ZC(e),n=WC(t),r=n.length>0,s=o.length>0;if(r||s){const e="\n- ",t=r?`\n\nPlugins:${e}${n.map($C).join(e)}`:"",a=s?`\n\nOptions:${e}${o.join(e)}`:"";console.warn("The following deprecated features are currently enabled but will be removed soon."+t+a)}})(e,t)},GC=Ya.DOM,KC=e=>F.from(e).each((e=>e.destroy())),YC=e=>{if(!e.removed){const{_selectionOverrides:t,editorUpload:o}=e,n=e.getBody(),r=e.getElement();n&&e.save({is_removing:!0}),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&C(null==r?void 0:r.nextSibling)&&GC.remove(r.nextSibling),(e=>{e.dispatch("remove")})(e),e.editorManager.remove(e),!e.inline&&n&&(e=>{GC.setStyle(e.id,"display",e.orgDisplay)})(e),(e=>{e.dispatch("detach")})(e),GC.remove(e.getContainer()),KC(t),KC(o),e.destroy()}},XC=(e,t)=>{const{selection:o,dom:n}=e;e.destroyed||(t||e.removed?(t||(e.editorManager.off("beforeunload",e._beforeUnload),e.theme&&e.theme.destroy&&e.theme.destroy(),KC(o),KC(n)),(e=>{const t=e.formElement;t&&(t._mceOldSubmit&&(t.submit=t._mceOldSubmit,delete t._mceOldSubmit),GC.unbind(t,"submit reset",e.formEventDelegate))})(e),(e=>{const t=e;t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null;const o=e.selection;if(o){const e=o.dom;t.selection=o.win=o.dom=e.doc=null}})(e),e.destroyed=!0):e.remove())},JC=(()=>{const e={};return{add:(t,o)=>{e[t]=o},get:t=>e[t]?e[t]:{icons:{}},has:t=>_e(e,t)}})(),QC=ri.ModelManager,eS=(e,t)=>t.dom[e],tS=(e,t)=>parseInt(dn(t,e),10),oS=N(eS,"clientWidth"),nS=N(eS,"clientHeight"),rS=N(tS,"margin-top"),sS=N(tS,"margin-left"),aS=(e,t,o)=>{const n=yo.fromDom(e.getBody()),r=e.inline?n:(s=n,yo.fromDom(Eo(s).dom.documentElement));var s;const a=((e,t,o,n)=>{const r=(e=>e.dom.getBoundingClientRect())(t);return{x:o-(e?r.left+t.dom.clientLeft+sS(t):0),y:n-(e?r.top+t.dom.clientTop+rS(t):0)}})(e.inline,r,t,o);return((e,t,o)=>{const n=oS(e),r=nS(e);return t>=0&&o>=0&&t<=n&&o<=r})(r,a.x,a.y)},iS=e=>{const t=e.inline?e.getBody():e.getContentAreaContainer();return(o=t,F.from(o).map(yo.fromDom)).map(Go).getOr(!1);var o},lS=e=>{const t=[],o=()=>{const t=e.theme;return t&&t.getNotificationManagerImpl?t.getNotificationManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a NotificationManager implementation.")};return{open:e,close:e,getArgs:e}})()},n=()=>F.from(t[0]),r=()=>{q(t,(e=>{e.reposition()}))},s=e=>{te(t,(t=>t===e)).each((e=>{t.splice(e,1)}))},a=(a,i=!0)=>e.removed||!iS(e)?{}:(i&&e.dispatch("BeforeOpenNotification",{notification:a}),ee(t,(e=>{return t=o().getArgs(e),n=a,!(t.type!==n.type||t.text!==n.text||t.progressBar||t.timeout||n.progressBar||n.timeout);var t,n})).getOrThunk((()=>{e.editorManager.setActive(e);const i=o().open(a,(()=>{s(i),r(),ip(e)&&n().fold((()=>e.focus()),(e=>Bh(yo.fromDom(e.getEl()))))}));return(e=>{t.push(e)})(i),r(),e.dispatch("OpenNotification",{notification:{...i}}),i}))),i=D(t);return(e=>{e.on("SkinLoaded",(()=>{const t=Oc(e);t&&a({text:t,type:"warning",timeout:0},!1),r()})),e.on("show ResizeEditor ResizeWindow NodeChange",(()=>{requestAnimationFrame(r)})),e.on("remove",(()=>{q(t.slice(),(e=>{o().close(e)}))}))})(e),{open:a,close:()=>{n().each((e=>{o().close(e),s(e),r()}))},getNotifications:i}},cS=ri.PluginManager,dS=ri.ThemeManager,mS=e=>{let t=[];const o=()=>{const t=e.theme;return t&&t.getWindowManagerImpl?t.getWindowManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a WindowManager implementation.")};return{open:e,openUrl:e,alert:e,confirm:e,close:e}})()},n=(e,t)=>(...o)=>t?t.apply(e,o):void 0,r=o=>{t.push(o),(t=>{e.dispatch("OpenWindow",{dialog:t})})(o)},s=o=>{(t=>{e.dispatch("CloseWindow",{dialog:t})})(o),t=Y(t,(e=>e!==o)),0===t.length&&e.focus()},a=t=>{e.editorManager.setActive(e),jh(e),e.ui.show();const o=t();return r(o),o};return e.on("remove",(()=>{q(t,(e=>{o().close(e)}))})),{open:(e,t)=>a((()=>o().open(e,t,s))),openUrl:e=>a((()=>o().openUrl(e,s))),alert:(e,t,r)=>{const s=o();s.alert(e,n(r||s,t))},confirm:(e,t,r)=>{const s=o();s.confirm(e,n(r||s,t))},close:()=>{F.from(t[t.length-1]).each((e=>{o().close(e),s(e)}))}}},uS=(e,t)=>{e.notificationManager.open({type:"error",text:t})},gS=(e,t)=>{e._skinLoaded?uS(e,t):e.on("SkinLoaded",(()=>{uS(e,t)}))},hS=(e,t,o)=>{Sg(e,t,{message:o}),console.error(o)},pS=(e,t,o)=>o?`Failed to load ${e}: ${o} from url ${t}`:`Failed to load ${e} url: ${t}`,fS=(e,...t)=>{const o=window.console;o&&(o.error?o.error(e,...t):o.log(e,...t))},vS=e=>"content/"+e+"/content.css",bS=(e,t)=>{const o=e.editorManager.baseURL+"/skins/content",n=`content${e.editorManager.suffix}.css`;return $(t,(t=>(e=>tinymce.Resource.has(vS(e)))(t)?t:(e=>/^[a-z0-9\-]+$/i.test(e))(t)&&!e.inline?`${o}/${t}/${n}`:e.documentBaseURI.toAbsolute(t)))},yS=e=>{e.contentCSS=e.contentCSS.concat((e=>bS(e,yc(e)))(e),(e=>bS(e,xc(e)))(e))},wS=(e,t)=>{const o={};return{findAll:(n,r=P)=>{const s=Y((e=>e?ue(e.getElementsByTagName("img")):[])(n),(t=>{const o=t.src;return!t.hasAttribute("data-mce-bogus")&&!t.hasAttribute("data-mce-placeholder")&&!(!o||o===At.transparentSrc)&&(je(o,"blob:")?!e.isUploaded(o)&&r(t):!!je(o,"data:")&&r(t))})),a=$(s,(e=>{const n=e.src;if(_e(o,n))return o[n].then((t=>h(t)?t:{image:e,blobInfo:t.blobInfo}));{const r=((e,t)=>{const o=()=>Promise.reject("Invalid data URI");if(je(t,"blob:")){const n=e.getByUri(t);return C(n)?Promise.resolve(n):sw(t).then((t=>aw(t).then((n=>lw(n,!1,(o=>F.some(cw(e,t,o)))).getOrThunk(o)))))}return je(t,"data:")?dw(e,t).fold(o,(e=>Promise.resolve(e))):Promise.reject("Unknown image data format")})(t,n).then((t=>(delete o[n],{image:e,blobInfo:t}))).catch((e=>(delete o[n],e)));return o[n]=r,r}}));return Promise.all(a)}}},xS=()=>{let e={};const t=(e,t)=>({status:e,resultUri:t}),o=t=>t in e;return{hasBlobUri:o,getResultUri:t=>{const o=e[t];return o?o.resultUri:null},isPending:t=>!!o(t)&&1===e[t].status,isUploaded:t=>!!o(t)&&2===e[t].status,markPending:o=>{e[o]=t(1,null)},markUploaded:(o,n)=>{e[o]=t(2,n)},removeFailed:t=>{delete e[t]},destroy:()=>{e={}}}};let CS=0;const SS=e=>e+CS+++(()=>{const e=()=>Math.round(4294967295*Math.random()).toString(36);return"s"+(new Date).getTime().toString(36)+e()+e()+e()})(),kS=(e,t)=>{const o={},n=(e,o)=>new Promise(((n,r)=>{const s=new XMLHttpRequest;s.open("POST",t.url),s.withCredentials=t.credentials,s.upload.onprogress=e=>{o(e.loaded/e.total*100)},s.onerror=()=>{r("Image upload failed due to a XHR Transport error. Code: "+s.status)},s.onload=()=>{if(s.status<200||s.status>=300)return void r("HTTP Error: "+s.status);const e=JSON.parse(s.responseText);var o,a;e&&h(e.location)?n((o=t.basePath,a=e.location,o?o.replace(/\/$/,"")+"/"+a.replace(/^\//,""):a)):r("Invalid JSON: "+s.responseText)};const a=new FormData;a.append("file",e.blob(),e.filename()),s.send(a)})),r=S(t.handler)?t.handler:n,s=(e,t)=>({url:t,blobInfo:e,status:!0}),a=(e,t)=>({url:"",blobInfo:e,status:!1,error:t}),i=(e,t)=>{Bt.each(o[e],(e=>{e(t)})),delete o[e]},l=(t,n)=>(t=Bt.grep(t,(t=>!e.isUploaded(t.blobUri()))),Promise.all(Bt.map(t,(t=>e.isPending(t.blobUri())?(e=>{const t=e.blobUri();return new Promise((e=>{o[t]=o[t]||[],o[t].push(e)}))})(t):((t,o,n)=>(e.markPending(t.blobUri()),new Promise((r=>{let l,c;try{const d=()=>{l&&(l.close(),c=E)},m=o=>{d(),e.markUploaded(t.blobUri(),o),i(t.blobUri(),s(t,o)),r(s(t,o))},u=o=>{d(),e.removeFailed(t.blobUri()),i(t.blobUri(),a(t,o)),r(a(t,o))};c=e=>{e<0||e>100||F.from(l).orThunk((()=>F.from(n).map(L))).each((t=>{l=t,t.progressBar.value(e)}))},o(t,c).then(m,(e=>{u(h(e)?{message:e}:e)}))}catch(e){r(a(t,e))}}))))(t,r,n)))));return{upload:(e,o)=>t.url||r!==n?l(e,o):new Promise((e=>{e([])}))}},_S=e=>()=>e.notificationManager.open({text:e.translate("Image uploading..."),type:"info",timeout:-1,progressBar:!0}),ES=(e,t)=>kS(t,{url:cc(e),basePath:dc(e),credentials:mc(e),handler:uc(e)}),TS=e=>t=>{((e,t)=>e.dom.isEmpty(t.dom)&&C(e.schema.getTextBlockElements()[jt(t)]))(e,t)&&bn(t,yo.fromHtml('
    '))},OS=e=>{const t=(()=>{let e=[];const t=e=>{if(!e.blob||!e.base64)throw new Error("blob and base64 representations of the image are required for BlobInfo to be created");const t=e.id||SS("blobid"),o=e.name||t,n=e.blob;return{id:D(t),name:D(o),filename:D(e.filename||o+"."+(r=n.type,{"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png","image/apng":"apng","image/avif":"avif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff"}[r.toLowerCase()]||"dat")),blob:D(n),base64:D(e.base64),blobUri:D(e.blobUri||URL.createObjectURL(n)),uri:D(e.uri)};var r},o=t=>ee(e,t).getOrUndefined(),n=e=>o((t=>t.id()===e));return{create:(e,o,n,r,s)=>{if(h(e))return t({id:e,name:r,filename:s,blob:o,base64:n});if(p(e))return t(e);throw new Error("Unknown input type")},add:t=>{n(t.id())||e.push(t)},get:n,getByUri:e=>o((t=>t.blobUri()===e)),getByData:(e,t)=>o((o=>o.base64()===e&&o.blob().type===t)),findFirst:o,removeByUri:t=>{e=Y(e,(e=>e.blobUri()!==t||(URL.revokeObjectURL(e.blobUri()),!1)))},destroy:()=>{q(e,(e=>{URL.revokeObjectURL(e.blobUri())})),e=[]}}})();let o,n;const r=xS(),s=[],a=t=>o=>e.selection?t(o):[],i=(e,t,o)=>{let n=0;do{n=e.indexOf(t,n),-1!==n&&(e=e.substring(0,n)+o+e.substr(n+t.length),n+=o.length-t.length+1)}while(-1!==n);return e},l=(e,t,o)=>{const n=`src="${o}"${o===At.transparentSrc?' data-mce-placeholder="1"':""}`;return e=i(e,`src="${t}"`,n),e=i(e,'data-mce-src="'+t+'"','data-mce-src="'+o+'"')},c=(t,o)=>{q(e.undoManager.data,(e=>{"fragmented"===e.type?e.fragments=$(e.fragments,(e=>l(e,t,o))):e.content=l(e.content,t,o)}))},d=()=>(o||(o=ES(e,r)),g().then(a((n=>{const r=$(n,(e=>e.blobInfo));return o.upload(r,_S(e)).then(a((o=>{const r=[];let s=!1;const a=$(o,((o,a)=>{const{blobInfo:i,image:l}=n[a];let d=!1;return o.status&&ac(e)?(o.url&&!Ue(l.src,o.url)&&(s=!0),t.removeByUri(l.src),fC(e)||((t,o)=>{const n=e.convertURL(o,"src");var r;c(t.src,o),to(yo.fromDom(t),{src:sc(e)?(r=o,r+(-1===r.indexOf("?")?"?":"&")+(new Date).getTime()):o,"data-mce-src":n})})(l,o.url)):o.error&&(o.error.remove&&(c(l.src,At.transparentSrc),r.push(l),d=!0),((e,t)=>{gS(e,ni.translate(["Failed to upload image: {0}",t]))})(e,o.error.message)),{element:l,status:o.status,uploadUri:o.url,blobInfo:i,removed:d}}));return r.length>0&&!fC(e)?e.undoManager.transact((()=>{q(kn(r),(o=>{const n=Oo(o);Cn(o),n.each(TS(e)),t.removeByUri(o.dom.src)}))})):s&&e.undoManager.dispatchChange(),a})))})))),m=()=>rc(e)?d():Promise.resolve([]),u=e=>re(s,(t=>t(e))),g=()=>(n||(n=wS(r,t)),n.findAll(e.getBody(),u).then(a((t=>{const o=Y(t,(t=>h(t)?(gS(e,t),!1):"blob"!==t.uriType));return fC(e)||q(o,(e=>{c(e.image.src,e.blobInfo.blobUri()),e.image.src=e.blobInfo.blobUri(),e.image.removeAttribute("data-mce-src")})),o})))),f=o=>o.replace(/src="(blob:[^"]+)"/g,((o,n)=>{const s=r.getResultUri(n);if(s)return'src="'+s+'"';let a=t.getByUri(n);return a||(a=J(e.editorManager.get(),((e,t)=>e||t.editorUpload&&t.editorUpload.blobCache.getByUri(n)),void 0)),a?'src="data:'+a.blob().type+";base64,"+a.base64()+'"':o}));return e.on("SetContent",(()=>{rc(e)?m():g()})),e.on("RawSaveContent",(e=>{e.content=f(e.content)})),e.on("GetContent",(e=>{e.source_view||"raw"===e.format||"tree"===e.format||(e.content=f(e.content))})),e.on("PostRender",(()=>{e.parser.addNodeFilter("img",(e=>{q(e,(e=>{const o=e.attr("src");if(!o||t.getByUri(o))return;const n=r.getResultUri(o);n&&e.attr("src",n)}))}))})),{blobCache:t,addFilter:e=>{s.push(e)},uploadImages:d,uploadImagesAuto:m,scanForImages:g,destroy:()=>{t.destroy(),r.destroy(),n=o=null}}},DS={remove_similar:!0,inherit:!1},AS={selector:"td,th",...DS},MS={tablecellbackgroundcolor:{styles:{backgroundColor:"%value"},...AS},tablecellverticalalign:{styles:{"vertical-align":"%value"},...AS},tablecellbordercolor:{styles:{borderColor:"%value"},...AS},tablecellclass:{classes:["%value"],...AS},tableclass:{selector:"table",classes:["%value"],...DS},tablecellborderstyle:{styles:{borderStyle:"%value"},...AS},tablecellborderwidth:{styles:{borderWidth:"%value"},...AS}},NS=D(MS),RS=e=>{const t={},o=(e,n)=>{e&&(h(e)?(v(n)||(n=[n]),q(n,(e=>{w(e.deep)&&(e.deep=!$u(e)),w(e.split)&&(e.split=!$u(e)||qu(e)),w(e.remove)&&$u(e)&&!qu(e)&&(e.remove="none"),$u(e)&&qu(e)&&(e.mixed=!0,e.block_expand=!0),h(e.classes)&&(e.classes=e.classes.split(/\s+/))})),t[e]=n):fe(e,((e,t)=>{o(t,e)})))};return o((e=>{const t=e.dom,o=e.schema.type,n={valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}],alignleft:[{selector:"figure.image",collapsed:!1,classes:"align-left",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"left"},inherit:!1,preview:!1},{selector:"img,audio,video",collapsed:!1,styles:{float:"left"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginLeft:"0px",marginRight:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"center"},inherit:!1,preview:"font-family font-size"},{selector:"figure.image",collapsed:!1,classes:"align-center",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{display:"block",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"table",collapsed:!1,styles:{marginLeft:"auto",marginRight:"auto"},preview:"font-family font-size"},{selector:".mce-preview-object",ceFalseOverride:!0,styles:{display:"table",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{marginLeft:"auto",marginRight:"auto"},preview:!1}],alignright:[{selector:"figure.image",collapsed:!1,classes:"align-right",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"right"},inherit:!1,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{float:"right"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginRight:"0px",marginLeft:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"right"},preview:!1}],alignjustify:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"justify"},inherit:!1,preview:"font-family font-size"}],bold:[{inline:"strong",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all",preserve_attributes:["class","style"]}],italic:[{inline:"em",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all",preserve_attributes:["class","style"]}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:!0},{inline:"u",remove:"all",preserve_attributes:["class","style"]}],strikethrough:(()=>{const e={inline:"span",styles:{textDecoration:"line-through"},exact:!0},t={inline:"strike",remove:"all",preserve_attributes:["class","style"]},n={inline:"s",remove:"all",preserve_attributes:["class","style"]};return"html4"!==o?[n,e,t]:[e,n,t]})(),forecolor:{inline:"span",styles:{color:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},fontname:{inline:"span",toggle:!1,styles:{fontFamily:"%value"},clear_child_styles:!0},fontsize:{inline:"span",toggle:!1,styles:{fontSize:"%value"},clear_child_styles:!0},lineheight:{selector:"h1,h2,h3,h4,h5,h6,p,li,td,th,div",styles:{lineHeight:"%value"}},fontsize_class:{inline:"span",attributes:{class:"%value"}},blockquote:{block:"blockquote",wrapper:!0,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},code:{inline:"code"},link:{inline:"a",selector:"a",remove:"all",split:!0,deep:!0,onmatch:(e,t,o)=>Wn(e)&&e.hasAttribute("href"),onformat:(e,o,n)=>{Bt.each(n,((o,n)=>{t.setAttrib(e,n,o)}))}},lang:{inline:"span",clear_child_styles:!0,remove_similar:!0,attributes:{lang:"%value","data-mce-lang":e=>{var t;return null!==(t=null==e?void 0:e.customValue)&&void 0!==t?t:null}}},removeformat:[{selector:"b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small",remove:"all",split:!0,expand:!1,block_expand:!0,deep:!0},{selector:"span",attributes:["style","class"],remove:"empty",split:!0,expand:!1,deep:!0},{selector:"*",attributes:["style","class"],split:!1,expand:!1,deep:!0}]};return Bt.each("p h1 h2 h3 h4 h5 h6 div address pre dt dd samp".split(/\s/),(e=>{n[e]={block:e,remove:"all"}})),n})(e)),o(NS()),o(Bc(e)),{get:e=>C(e)?t[e]:t,has:e=>_e(t,e),register:o,unregister:e=>(e&&t[e]&&delete t[e],t)}},BS=Bt.each,LS=Ya.DOM,HS=e=>C(e)&&p(e),IS=(e,t)=>{const o=t&&t.schema||ya({}),n=e=>{const t=h(e)?{name:e,classes:[],attrs:{}}:e,o=LS.create(t.name);return((e,t)=>{t.classes.length>0&&LS.addClass(e,t.classes.join(" ")),LS.setAttribs(e,t.attrs)})(o,t),o},r=(e,t,s)=>{let a;const i=t[0],l=HS(i)?i.name:void 0,c=((e,t)=>{const n=o.getElementRule(e.nodeName.toLowerCase()),r=null==n?void 0:n.parentsRequired;return!(!r||!r.length)&&(t&&j(r,t)?t:r[0])})(e,l);if(c)l===c?(a=i,t=t.slice(1)):a=c;else if(i)a=i,t=t.slice(1);else if(!s)return e;const d=a?n(a):LS.create("div");d.appendChild(e),s&&Bt.each(s,(t=>{const o=n(t);d.insertBefore(o,e)}));const m=HS(a)?a.siblings:void 0;return r(d,t,m)},s=LS.create("div");if(e.length>0){const t=e[0],o=n(t),a=HS(t)?t.siblings:void 0;s.appendChild(r(o,e.slice(1),a))}return s},PS=e=>{let t="div";const o={name:t,classes:[],attrs:{},selector:e=Bt.trim(e)};return"*"!==e&&(t=e.replace(/(?:([#\.]|::?)([\w\-]+)|(\[)([^\]]+)\]?)/g,((e,t,n,r,s)=>{switch(t){case"#":o.attrs.id=n;break;case".":o.classes.push(n);break;case":":-1!==Bt.inArray("checked disabled enabled read-only required".split(" "),n)&&(o.attrs[n]=n)}if("["===r){const e=s.match(/([\w\-]+)(?:\=\"([^\"]+))?/);e&&(o.attrs[e[1]]=e[2])}return""}))),o.name=t||"div",o},FS=(e,t)=>{let o="",n=Lc(e);if(""===n)return"";const r=e=>h(e)?e.replace(/%(\w+)/g,""):"",s=(t,o)=>LS.getStyle(null!=o?o:e.getBody(),t,!0);if(h(t)){const o=e.formatter.get(t);if(!o)return"";t=o[0]}if("preview"in t){const e=t.preview;if(!1===e)return"";n=e||n}let a,i=t.block||t.inline||"span";const l=(c=t.selector,h(c)?(c=(c=c.split(/\s*,\s*/)[0]).replace(/\s*(~\+|~|\+|>)\s*/g,"$1"),Bt.map(c.split(/(?:>|\s+(?![^\[\]]+\]))/),(e=>{const t=Bt.map(e.split(/(?:~\+|~|\+)/),PS),o=t.pop();return t.length&&(o.siblings=t),o})).reverse()):[]);var c;l.length>0?(l[0].name||(l[0].name=i),i=t.selector,a=IS(l,e)):a=IS([i],e);const d=LS.select(i,a)[0]||a.firstChild;BS(t.styles,((e,t)=>{const o=r(e);o&&LS.setStyle(d,t,o)})),BS(t.attributes,((e,t)=>{const o=r(e);o&&LS.setAttrib(d,t,o)})),BS(t.classes,(e=>{const t=r(e);LS.hasClass(d,t)||LS.addClass(d,t)})),e.dispatch("PreviewFormats"),LS.setStyles(a,{position:"absolute",left:-65535}),e.getBody().appendChild(a);const m=s("fontSize"),u=/px$/.test(m)?parseInt(m,10):0;return BS(n.split(" "),(e=>{let t=s(e,d);if(!("background-color"===e&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(t)&&(t=s(e),"#ffffff"===Da(t).toLowerCase())||"color"===e&&"#000000"===Da(t).toLowerCase())){if("font-size"===e&&/em|%$/.test(t)){if(0===u)return;t=parseFloat(t)/(/%$/.test(t)?100:1)*u+"px"}"border"===e&&t&&(o+="padding:0 2px;"),o+=e+":"+t+";"}})),e.dispatch("AfterPreviewFormats"),LS.remove(a),o},zS=e=>{const t=RS(e),o=Qa({});return(e=>{e.addShortcut("meta+b","","Bold"),e.addShortcut("meta+i","","Italic"),e.addShortcut("meta+u","","Underline");for(let t=1;t<=6;t++)e.addShortcut("access+"+t,"",["FormatBlock",!1,"h"+t]);e.addShortcut("access+7","",["FormatBlock",!1,"p"]),e.addShortcut("access+8","",["FormatBlock",!1,"div"]),e.addShortcut("access+9","",["FormatBlock",!1,"address"])})(e),ey(e),fC(e)||((e,t)=>{e.set({}),t.on("NodeChange",(o=>{Yy(t,o.element,e.get())})),t.on("FormatApply FormatRemove",(o=>{const n=F.from(o.node).map((e=>Ou(e)?e:e.startContainer)).bind((e=>Wn(e)?F.some(e):F.from(e.parentElement))).getOrThunk((()=>qy(t)));Yy(t,n,e.get())}))})(o,e),{get:t.get,has:t.has,register:t.register,unregister:t.unregister,apply:(t,o,n)=>{((e,t,o,n)=>{yC(e).formatter.apply(t,o,n)})(e,t,o,n)},remove:(t,o,n,r)=>{((e,t,o,n,r)=>{yC(e).formatter.remove(t,o,n,r)})(e,t,o,n,r)},toggle:(t,o,n)=>{((e,t,o,n)=>{yC(e).formatter.toggle(t,o,n)})(e,t,o,n)},match:(t,o,n,r)=>((e,t,o,n,r)=>yC(e).formatter.match(t,o,n,r))(e,t,o,n,r),closest:t=>((e,t)=>yC(e).formatter.closest(t))(e,t),matchAll:(t,o)=>((e,t,o)=>yC(e).formatter.matchAll(t,o))(e,t,o),matchNode:(t,o,n,r)=>((e,t,o,n,r)=>yC(e).formatter.matchNode(t,o,n,r))(e,t,o,n,r),canApply:t=>((e,t)=>yC(e).formatter.canApply(t))(e,t),formatChanged:(t,n,r,s)=>((e,t,o,n,r,s)=>yC(e).formatter.formatChanged(t,o,n,r,s))(e,o,t,n,r,s),getCssText:N(FS,e)}},VS=e=>{switch(e.toLowerCase()){case"undo":case"redo":case"mcefocus":return!0;default:return!1}},ZS=e=>{const t=ai(),o=Qa(0),n=Qa(0),r={data:[],typing:!1,beforeChange:()=>{((e,t,o)=>{yC(e).undoManager.beforeChange(t,o)})(e,o,t)},add:(s,a)=>((e,t,o,n,r,s,a)=>yC(e).undoManager.add(t,o,n,r,s,a))(e,r,n,o,t,s,a),dispatchChange:()=>{e.setDirty(!0);const t=iC(e);t.bookmark=El(e.selection),e.dispatch("change",{level:t,lastLevel:ce(r.data,n.get()).getOrUndefined()})},undo:()=>((e,t,o,n)=>yC(e).undoManager.undo(t,o,n))(e,r,o,n),redo:()=>((e,t,o)=>yC(e).undoManager.redo(t,o))(e,n,r.data),clear:()=>{((e,t,o)=>{yC(e).undoManager.clear(t,o)})(e,r,n)},reset:()=>{((e,t)=>{yC(e).undoManager.reset(t)})(e,r)},hasUndo:()=>((e,t,o)=>yC(e).undoManager.hasUndo(t,o))(e,r,n),hasRedo:()=>((e,t,o)=>yC(e).undoManager.hasRedo(t,o))(e,r,n),transact:t=>((e,t,o,n)=>yC(e).undoManager.transact(t,o,n))(e,r,o,t),ignore:t=>{((e,t,o)=>{yC(e).undoManager.ignore(t,o)})(e,o,t)},extra:(t,o)=>{((e,t,o,n,r)=>{yC(e).undoManager.extra(t,o,n,r)})(e,r,n,t,o)}};return fC(e)||((e,t,o)=>{const n=Qa(!1),r=e=>{gC(t,!1,o),t.add({},e)};e.on("init",(()=>{t.add()})),e.on("BeforeExecCommand",(e=>{const n=e.command;VS(n)||(hC(t,o),t.beforeChange())})),e.on("ExecCommand",(e=>{const t=e.command;VS(t)||r(e)})),e.on("ObjectResizeStart cut",(()=>{t.beforeChange()})),e.on("SaveContent ObjectResized blur",r),e.on("dragend",r),e.on("keyup",(o=>{const s=o.keyCode;if(o.isDefaultPrevented())return;const a=At.os.isMacOS()&&"Meta"===o.key;(s>=33&&s<=36||s>=37&&s<=40||45===s||o.ctrlKey||a)&&(r(),e.nodeChanged()),46!==s&&8!==s||e.nodeChanged(),n.get()&&t.typing&&!mC(iC(e),t.data[0])&&(e.isDirty()||e.setDirty(!0),e.dispatch("TypingUndo"),n.set(!1),e.nodeChanged())})),e.on("keydown",(e=>{const s=e.keyCode;if(e.isDefaultPrevented())return;if(s>=33&&s<=36||s>=37&&s<=40||45===s)return void(t.typing&&r(e));const a=e.ctrlKey&&!e.altKey||e.metaKey;if((s<16||s>20)&&224!==s&&91!==s&&!t.typing&&!a)return t.beforeChange(),gC(t,!0,o),t.add({},e),void n.set(!0);(At.os.isMacOS()?e.metaKey:e.ctrlKey&&!e.altKey)&&t.beforeChange()})),e.on("mousedown",(e=>{t.typing&&r(e)})),e.on("input",(e=>{var t;e.inputType&&("insertReplacementText"===e.inputType||"insertText"===(t=e).inputType&&null===t.data||(e=>"insertFromPaste"===e.inputType||"insertFromDrop"===e.inputType)(e))&&r(e)})),e.on("AddUndo Undo Redo ClearUndos",(t=>{t.isDefaultPrevented()||e.nodeChanged()}))})(e,r,o),(e=>{e.addShortcut("meta+z","","Undo"),e.addShortcut("meta+y,meta+shift+z","","Redo")})(e),r},US=[9,27,Dg.HOME,Dg.END,19,20,44,144,145,33,34,45,16,17,18,91,92,93,Dg.DOWN,Dg.UP,Dg.LEFT,Dg.RIGHT].concat(At.browser.isFirefox()?[224]:[]),jS="data-mce-placeholder",WS=e=>"keydown"===e.type||"keyup"===e.type,$S=e=>{const t=e.keyCode;return t===Dg.BACKSPACE||t===Dg.DELETE},qS=e=>{var t;const o=e.dom,n=Xl(e),r=null!==(t=Ec(e))&&void 0!==t?t:"",s=(t,a)=>{if((e=>{if(WS(e)){const t=e.keyCode;return!$S(e)&&(Dg.metaKeyPressed(e)||e.altKey||t>=112&&t<=123||j(US,t))}return!1})(t))return;const i=e.getBody(),l=!(e=>WS(e)&&!($S(e)||"keyup"===e.type&&229===e.keyCode))(t)&&((e,t,o)=>{if(ys(yo.fromDom(t),!1)){const n=t.firstElementChild;return!n||!e.getStyle(t.firstElementChild,"padding-left")&&!e.getStyle(t.firstElementChild,"padding-right")&&o===n.nodeName.toLowerCase()}return!1})(o,i,n);(""!==o.getAttrib(i,jS)!==l||a)&&(o.setAttrib(i,jS,l?r:null),o.setAttrib(i,"aria-placeholder",l?r:null),((e,t)=>{e.dispatch("PlaceholderToggle",{state:t})})(e,l),e.on(l?"keydown":"keyup",s),e.off(l?"keyup":"keydown",s))};Ye(r)&&e.on("init",(t=>{s(t,!0),e.on("change SetContent ExecCommand",s),e.on("paste",(t=>qh.setEditorTimeout(e,(()=>s(t)))))}))},GS=(e,t)=>({from:e,to:t}),KS=(e,t)=>{const o=yo.fromDom(e),n=yo.fromDom(t.container());return vv(o,n).map((e=>((e,t)=>({block:e,position:t}))(e,t)))},YS=(e,t)=>Xo(t,(e=>Dr(e)||cr(e.dom)),(t=>So(t,e))).filter(Gt).getOr(e),XS=(e,t,o)=>{const n=KS(e,rl.fromRangeStart(o)),r=n.bind((o=>Zm(t,e,o.position).bind((o=>KS(e,o).map((o=>((e,t,o)=>ir(o.position.getNode())&&!ys(o.block)?Wm(!1,o.block.dom).bind((n=>n.isEqual(o.position)?Zm(t,e,n).bind((t=>KS(e,t))):F.some(o))).getOr(o):o)(e,t,o)))))));return It(n,r,GS).filter((t=>(e=>!So(e.from.block,e.to.block))(t)&&((e,t)=>{const o=yo.fromDom(e);return So(YS(o,t.from.block),YS(o,t.to.block))})(e,t)&&(e=>!1===dr(e.from.block.dom)&&!1===dr(e.to.block.dom))(t)&&(e=>{const t=e=>_r(e)||Ns(e.dom);return t(e.from.block)&&t(e.to.block)})(t)))},JS=(e,t)=>{const o=((e,t)=>{const o=Lo(e);return te(o,(e=>t.isBlock(jt(e)))).fold(D(o),(e=>o.slice(0,e)))})(e,t);return q(o,Cn),o},QS=(e,t)=>{const o=pf(t,e);return ee(o.reverse(),(e=>ys(e))).each(Cn)},ek=(e,t,o,n,r)=>{if(ys(o))return Rr(o),Gm(o.dom);0===Y(Ro(r),(e=>!ys(e))).length&&ys(t)&&pn(r,yo.fromTag("br"));const s=qm(o.dom,rl.before(r.dom));return q(JS(t,n),(e=>{pn(r,e)})),QS(e,t),s},tk=(e,t,o,n)=>{if(ys(o)){if(ys(t)){const e=e=>{const t=(e,o)=>Io(e).fold((()=>o),(e=>((e,t)=>e.isInline(jt(t)))(n,e)?t(e,o.concat(ki(e))):o));return t(e,[])},r=X(e(o),((e,t)=>(yn(e,t),t)),Nr());xn(t),bn(t,r)}return Cn(o),Gm(t.dom)}const r=Km(o.dom);return q(JS(t,n),(e=>{bn(o,e)})),QS(e,t),r},ok=(e,t)=>ko(t,e)?((e,t)=>{const o=pf(t,e);return F.from(o[o.length-1])})(t,e):F.none(),nk=(e,t)=>{Wm(e,t.dom).bind((e=>F.from(e.getNode()))).map(yo.fromDom).filter(kr).each(Cn)},rk=(e,t,o,n)=>(nk(!0,t),nk(!1,o),ok(t,o).fold(N(tk,e,t,o,n),N(ek,e,t,o,n))),sk=(e,t,o,n,r)=>t?rk(e,n,o,r):rk(e,o,n,r),ak=(e,t)=>{const o=yo.fromDom(e.getBody()),n=((e,t,o)=>o.collapsed?XS(e,t,o):F.none())(o.dom,t,e.selection.getRng()).map((n=>()=>{sk(o,t,n.from.block,n.to.block,e.schema).each((t=>{e.selection.setRng(t.toRange())}))}));return n},ik=(e,t)=>{const o=yo.fromDom(t),n=N(So,e);return Yo(o,Dr,n).isSome()},lk=(e,t)=>{const o=qm(e.dom,rl.fromRangeStart(t)).isNone(),n=$m(e.dom,rl.fromRangeEnd(t)).isNone();return!((e,t)=>ik(e,t.startContainer)||ik(e,t.endContainer))(e,t)&&o&&n},ck=e=>{const t=yo.fromDom(e.getBody()),o=e.selection.getRng();return lk(t,o)?(e=>F.some((()=>{e.setContent(""),e.selection.setCursorLocation()})))(e):((e,t,o)=>{const n=t.getRng();return It(vv(e,yo.fromDom(n.startContainer)),vv(e,yo.fromDom(n.endContainer)),((r,s)=>So(r,s)?F.none():F.some((()=>{n.deleteContents(),sk(e,!0,r,s,o).each((e=>{t.setRng(e.toRange())}))})))).getOr(F.none())})(t,e.selection,e.schema)},dk=(e,t)=>e.selection.isCollapsed()?F.none():ck(e),mk=(e,t,o,n,r)=>F.from(t._selectionOverrides.showCaret(e,o,n,r)),uk=(e,t)=>e.dispatch("BeforeObjectSelected",{target:t}).isDefaultPrevented()?F.none():F.some((e=>{const t=e.ownerDocument.createRange();return t.selectNode(e),t})(t)),gk=(e,t,o)=>t.collapsed?((e,t,o)=>{const n=wm(1,e.getBody(),t),r=rl.fromRangeStart(n),s=r.getNode();if(Xd(s))return mk(1,e,s,!r.isAtEnd(),!1);const a=r.getNode(!0);if(Xd(a))return mk(1,e,a,!1,!1);const i=tb(e.dom.getRoot(),r.getNode());return Xd(i)?mk(1,e,i,!1,o):F.none()})(e,t,o).getOr(t):t,hk=e=>uf(e)||lf(e),pk=e=>gf(e)||cf(e),fk=(e,t,o,n,r,s)=>{mk(n,e,s.getNode(!r),r,!0).each((o=>{if(t.collapsed){const e=t.cloneRange();r?e.setEnd(o.startContainer,o.startOffset):e.setStart(o.endContainer,o.endOffset),e.deleteContents()}else t.deleteContents();e.selection.setRng(o)})),((e,t)=>{tr(t)&&0===t.data.length&&e.remove(t)})(e.dom,o)},vk=(e,t)=>((e,t)=>{const o=e.selection.getRng();if(!tr(o.commonAncestorContainer))return F.none();const n=t?Em.Forwards:Em.Backwards,r=Im(e.getBody()),s=N(km,t?r.next:r.prev),a=t?hk:pk,i=Cm(n,e.getBody(),o),l=s(i),c=l?mv(t,l):l;if(!c||!_m(i,c))return F.none();if(a(c))return F.some((()=>fk(e,o,i.getNode(),n,t,c)));const d=s(c);return d&&a(d)&&_m(c,d)?F.some((()=>fk(e,o,i.getNode(),n,t,d))):F.none()})(e,t),bk=(e,t)=>{const o=e.getBody();return t?Gm(o).filter(uf):Km(o).filter(gf)},yk=e=>{const t=e.selection.getRng();return!t.collapsed&&(bk(e,!0).exists((e=>e.isEqual(rl.fromRangeStart(t))))||bk(e,!1).exists((e=>e.isEqual(rl.fromRangeEnd(t)))))},wk=Al([{remove:["element"]},{moveToElement:["element"]},{moveToPosition:["position"]}]),xk=(e,t,o,n)=>{const r=n.getNode(!t);return vv(yo.fromDom(e),yo.fromDom(o.getNode())).map((e=>ys(e)?wk.remove(e.dom):wk.moveToElement(r))).orThunk((()=>F.some(wk.moveToElement(r))))},Ck=(e,t,o,n)=>Zm(t,e,o).bind((r=>{return s=r.getNode(),C(s)&&(Dr(yo.fromDom(s))||Tr(yo.fromDom(s)))||((e,t,o,n,r)=>{const s=t=>r.isInline(t.nodeName.toLowerCase())&&!gm(o,n,e);return xm(!t,o).fold((()=>xm(t,n).fold(I,s)),s)})(e,t,o,r,n)?F.none():t&&dr(r.getNode())||!t&&dr(r.getNode(!0))?xk(e,t,o,r):t&&gf(o)||!t&&uf(o)?F.some(wk.moveToPosition(r)):F.none();var s})),Sk=(e,t,o,n)=>((e,t)=>{const o=t.getNode(!e),n=e?"after":"before";return Wn(o)&&o.getAttribute("data-mce-caret")===n})(t,o)?((e,t)=>x(t)?F.none():e&&dr(t.nextSibling)?F.some(wk.moveToElement(t.nextSibling)):!e&&dr(t.previousSibling)?F.some(wk.moveToElement(t.previousSibling)):F.none())(t,o.getNode(!t)).orThunk((()=>Ck(e,t,o,n))):Ck(e,t,o,n).bind((t=>((e,t,o)=>o.fold((e=>F.some(wk.remove(e))),(e=>F.some(wk.moveToElement(e))),(o=>gm(t,o,e)?F.none():F.some(wk.moveToPosition(o)))))(e,o,t))),kk=(e,t)=>F.from(tb(e.getBody(),t)),_k=(e,t)=>{const o=e.selection.getNode();return kk(e,o).filter(dr).fold((()=>((e,t,o,n)=>{const r=wm(t?1:-1,e,o),s=rl.fromRangeStart(r),a=yo.fromDom(e);return!t&&gf(s)?F.some(wk.remove(s.getNode(!0))):t&&uf(s)?F.some(wk.remove(s.getNode())):!t&&uf(s)&&Tf(a,s,n)?Of(a,s,n).map((e=>wk.remove(e.getNode()))):t&&gf(s)&&Ef(a,s,n)?Df(a,s,n).map((e=>wk.remove(e.getNode()))):Sk(e,t,s,n)})(e.getBody(),t,e.selection.getRng(),e.schema).map((o=>()=>o.fold(((e,t)=>o=>(e._selectionOverrides.hideFakeCaret(),av(e,t,yo.fromDom(o)),!0))(e,t),((e,t)=>o=>{const n=t?rl.before(o):rl.after(o);return e.selection.setRng(n.toRange()),!0})(e,t),(e=>t=>(e.selection.setRng(t.toRange()),!0))(e))))),(()=>F.some(E)))},Ek=(e,t)=>{const o=e.selection.getNode();return dr(o)&&!mr(o)?kk(e,o.parentNode).filter(dr).fold((()=>F.some((()=>{var o;o=yo.fromDom(e.getBody()),q(zn(o,".mce-offscreen-selection"),Cn),av(e,t,yo.fromDom(e.selection.getNode())),bv(e)}))),(()=>F.some(E))):yk(e)?F.some((()=>{xv(e,e.selection.getRng(),yo.fromDom(e.getBody()))})):F.none()},Tk=e=>{const t=e.dom,o=e.selection,n=tb(e.getBody(),o.getNode());if(cr(n)&&t.isBlock(n)&&t.isEmpty(n)){const e=t.create("br",{"data-mce-bogus":"1"});t.setHTML(n,""),n.appendChild(e),o.setRng(rl.before(e).toRange())}return!0},Ok=(e,t)=>e.selection.isCollapsed()?_k(e,t):Ek(e,t),Dk=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const o=rl.fromRangeStart(e.selection.getRng());return Zm(t,e.getBody(),o).filter((e=>t?sf(e):af(e))).bind((e=>hm(t?0:-1,e))).map((t=>()=>e.selection.select(t)))})(e,t):F.none(),Ak=tr,Mk=e=>Ak(e)&&e.data[0]===Br,Nk=e=>Ak(e)&&e.data[e.data.length-1]===Br,Rk=e=>{var t;return(null!==(t=e.ownerDocument)&&void 0!==t?t:document).createTextNode(Br)},Bk=(e,t)=>e?(e=>{var t;if(Ak(e.previousSibling))return Nk(e.previousSibling)||e.previousSibling.appendData(Br),e.previousSibling;if(Ak(e))return Mk(e)||e.insertData(0,Br),e;{const o=Rk(e);return null===(t=e.parentNode)||void 0===t||t.insertBefore(o,e),o}})(t):(e=>{var t,o;if(Ak(e.nextSibling))return Mk(e.nextSibling)||e.nextSibling.insertData(0,Br),e.nextSibling;if(Ak(e))return Nk(e)||e.appendData(Br),e;{const n=Rk(e);return e.nextSibling?null===(t=e.parentNode)||void 0===t||t.insertBefore(n,e.nextSibling):null===(o=e.parentNode)||void 0===o||o.appendChild(n),n}})(t),Lk=N(Bk,!0),Hk=N(Bk,!1),Ik=(e,t)=>tr(e.container())?Bk(t,e.container()):Bk(t,e.getNode()),Pk=(e,t)=>{const o=t.get();return o&&e.container()===o&&zr(o)},Fk=(e,t)=>t.fold((t=>{jd(e.get());const o=Lk(t);return e.set(o),F.some(rl(o,o.length-1))}),(t=>Gm(t).map((t=>{if(Pk(t,e)){const t=e.get();return rl(t,1)}{jd(e.get());const o=Ik(t,!0);return e.set(o),rl(o,1)}}))),(t=>Km(t).map((t=>{if(Pk(t,e)){const t=e.get();return rl(t,t.length-1)}{jd(e.get());const o=Ik(t,!1);return e.set(o),rl(o,o.length-1)}}))),(t=>{jd(e.get());const o=Hk(t);return e.set(o),F.some(rl(o,1))})),zk=(e,t)=>{for(let o=0;o{const o=um(t,e);return o||e},Uk=(e,t,o)=>{const n=uv(o),r=Zk(t,n.container());return dv(e,r,n).fold((()=>$m(r,n).bind(N(dv,e,r)).map((e=>Vk.before(e)))),F.none)},jk=(e,t)=>null===Jm(e,t),Wk=(e,t,o)=>dv(e,t,o).filter(N(jk,t)),$k=(e,t,o)=>{const n=gv(o);return Wk(e,t,n).bind((e=>qm(e,n).isNone()?F.some(Vk.start(e)):F.none()))},qk=(e,t,o)=>{const n=uv(o);return Wk(e,t,n).bind((e=>$m(e,n).isNone()?F.some(Vk.end(e)):F.none()))},Gk=(e,t,o)=>{const n=gv(o),r=Zk(t,n.container());return dv(e,r,n).fold((()=>qm(r,n).bind(N(dv,e,r)).map((e=>Vk.after(e)))),F.none)},Kk=e=>!cv(Xk(e)),Yk=(e,t,o)=>zk([Uk,$k,qk,Gk],[e,t,o]).filter(Kk),Xk=e=>e.fold(A,A,A,A),Jk=e=>e.fold(D("before"),D("start"),D("end"),D("after")),Qk=e=>e.fold(Vk.before,Vk.before,Vk.after,Vk.after),e_=e=>e.fold(Vk.start,Vk.start,Vk.end,Vk.end),t_=(e,t,o,n,r,s)=>It(dv(t,o,n),dv(t,o,r),((t,n)=>t!==n&&((e,t,o)=>{const n=um(t,e),r=um(o,e);return C(n)&&n===r})(o,t,n)?Vk.after(e?t:n):s)).getOr(s),o_=(e,t)=>e.fold(P,(e=>{return n=t,!(Jk(o=e)===Jk(n)&&Xk(o)===Xk(n));var o,n})),n_=(e,t)=>e?t.fold(T(F.some,Vk.start),F.none,T(F.some,Vk.after),F.none):t.fold(F.none,T(F.some,Vk.before),F.none,T(F.some,Vk.end)),r_=(e,t,o,n)=>{const r=mv(e,n),s=Yk(t,o,r);return Yk(t,o,r).bind(N(n_,e)).orThunk((()=>((e,t,o,n,r)=>{const s=mv(e,r);return Zm(e,o,s).map(N(mv,e)).fold((()=>n.map(Qk)),(r=>Yk(t,o,r).map(N(t_,e,t,o,s,r)).filter(N(o_,n)))).filter(Kk)})(e,t,o,s,n)))},s_=(e,t,o)=>{const n=e?1:-1;return t.setRng(rl(o.container(),o.offset()+n).toRange()),t.getSel().modify("move",e?"forward":"backward","word"),!0},a_=(e,t)=>{const o=t.selection.getRng(),n=e?rl.fromRangeEnd(o):rl.fromRangeStart(o);return!!(e=>S(e.selection.getSel().modify))(t)&&(e&&Ur(n)?s_(!0,t.selection,n):!(e||!jr(n))&&s_(!1,t.selection,n))};var i_;!function(e){e[e.Br=0]="Br",e[e.Block=1]="Block",e[e.Wrap=2]="Wrap",e[e.Eol=3]="Eol"}(i_||(i_={}));const l_=(e,t)=>e===Em.Backwards?se(t):t,c_=(e,t,o)=>e===Em.Forwards?t.next(o):t.prev(o),d_=(e,t,o,n)=>ir(n.getNode(t===Em.Forwards))?i_.Br:!1===gm(o,n)?i_.Block:i_.Wrap,m_=(e,t,o,n)=>{const r=Im(o);let s=n;const a=[];for(;s;){const o=c_(t,r,s);if(!o)break;if(ir(o.getNode(!1)))return t===Em.Forwards?{positions:l_(t,a).concat([o]),breakType:i_.Br,breakAt:F.some(o)}:{positions:l_(t,a),breakType:i_.Br,breakAt:F.some(o)};if(o.isVisible()){if(e(s,o)){const e=d_(0,t,s,o);return{positions:l_(t,a),breakType:e,breakAt:F.some(o)}}a.push(o),s=o}else s=o}return{positions:l_(t,a),breakType:i_.Eol,breakAt:F.none()}},u_=(e,t,o,n)=>t(o,n).breakAt.map((n=>{const r=t(o,n).positions;return e===Em.Backwards?r.concat(n):[n].concat(r)})).getOr([]),g_=(e,t)=>J(e,((e,o)=>e.fold((()=>F.some(o)),(n=>It(de(n.getClientRects()),de(o.getClientRects()),((e,r)=>{const s=Math.abs(t-e.left);return Math.abs(t-r.left)<=s?o:n})).or(e)))),F.none()),h_=(e,t)=>de(t.getClientRects()).bind((t=>g_(e,t.left))),p_=N(m_,rl.isAbove,-1),f_=N(m_,rl.isBelow,1),v_=N(u_,-1,p_),b_=N(u_,1,f_),y_=(e,t)=>p_(e,t).breakAt.isNone(),w_=(e,t)=>f_(e,t).breakAt.isNone(),x_=(e,t)=>h_(v_(e,t),t),C_=(e,t)=>h_(b_(e,t),t),S_=dr,k_=(e,t)=>Math.abs(e.left-t),__=(e,t)=>Math.abs(e.right-t),E_=(e,t)=>Re(e,((e,o)=>{const n=Math.min(k_(e,t),__(e,t)),r=Math.min(k_(o,t),__(o,t));return r===n&&Ee(o,"node")&&S_(o.node)||r{const t=t=>$(t,(t=>{const o=Ai(t);return o.node=e,o}));if(Wn(e))return t(e.getClientRects());if(tr(e)){const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(e,e.data.length),t(o.getClientRects())}return[]},O_=e=>ne(e,T_);var D_;!function(e){e[e.Up=-1]="Up",e[e.Down=1]="Down"}(D_||(D_={}));const A_=(e,t,o,n,r,s)=>{let a=0;const i=[],l=n=>{let s=O_([n]);-1===e&&(s=s.reverse());for(let e=0;e0&&t(n,Le(i))&&a++,n.line=a,r(n))return!0;i.push(n)}}return!1},c=Le(s.getClientRects());if(!c)return i;const d=s.getNode();return d&&(l(d),((e,t,o,n)=>{let r=n;for(;r=mm(r,e,ss,t);)if(o(r))return})(e,n,l,d)),i},M_=N(A_,D_.Up,Ri,Bi),N_=N(A_,D_.Down,Bi,Ri),R_=e=>Le(e.getClientRects()),B_=e=>t=>((e,t)=>t.line>e)(e,t),L_=e=>t=>((e,t)=>t.line===e)(e,t),H_=(e,t)=>{e.selection.setRng(t),Rh(e,e.selection.getRng())},I_=(e,t,o)=>F.some(gk(e,t,o)),P_=(e,t,o,n,r,s)=>{const a=t===Em.Forwards,i=Im(e.getBody()),l=N(km,a?i.next:i.prev),c=a?n:r;if(!o.collapsed){const n=Hi(o);if(s(n))return mk(t,e,n,t===Em.Backwards,!1);if(yk(e)){const e=o.cloneRange();return e.collapse(t===Em.Backwards),F.from(e)}}const d=Cm(t,e.getBody(),o);if(c(d))return uk(e,d.getNode(!a));let m=l(d);const u=Gr(o);if(!m)return u?F.some(o):F.none();if(m=mv(a,m),c(m))return mk(t,e,m.getNode(!a),a,!1);const g=l(m);return g&&c(g)&&_m(m,g)?mk(t,e,g.getNode(!a),a,!1):u?I_(e,m.toRange(),!1):F.none()},F_=(e,t,o,n,r,s)=>{const a=Cm(t,e.getBody(),o),i=Le(a.getClientRects()),l=t===D_.Down,c=e.getBody();if(!i)return F.none();if(yk(e)){const e=l?rl.fromRangeEnd(o):rl.fromRangeStart(o);return(l?C_:x_)(c,e).orThunk((()=>F.from(e))).map((e=>e.toRange()))}const d=(l?N_:M_)(c,B_(1),a),m=Y(d,L_(1)),u=i.left,g=E_(m,u);if(g&&s(g.node)){const o=Math.abs(u-g.left),n=Math.abs(u-g.right);return mk(t,e,g.node,o{const r=Im(t);let s,a,i,l;const c=[];let d=0;1===e?(s=r.next,a=Bi,i=Ri,l=rl.after(n)):(s=r.prev,a=Ri,i=Bi,l=rl.before(n));const m=R_(l);do{if(!l.isVisible())continue;const e=R_(l);if(i(e,m))continue;c.length>0&&a(e,Le(c))&&d++;const t=Ai(e);if(t.position=l,t.line=d,o(t))return c;c.push(t)}while(l=s(l));return c})(t,c,B_(1),h);let n=E_(Y(o,L_(1)),u);if(n)return I_(e,n.position.toRange(),!1);if(n=Le(Y(o,L_(0))),n)return I_(e,n.position.toRange(),!1)}return 0===m.length?z_(e,l).filter(l?r:n).map((t=>gk(e,t.toRange(),!1))):F.none()},z_=(e,t)=>{const o=e.selection.getRng(),n=t?rl.fromRangeEnd(o):rl.fromRangeStart(o),r=(s=n.container(),a=e.getBody(),Yo(yo.fromDom(s),(e=>Qd(e.dom)),(e=>e.dom===a)).map((e=>e.dom)).getOr(a));var s,a;if(t){const e=f_(r,n);return me(e.positions)}{const e=p_(r,n);return de(e.positions)}},V_=(e,t,o)=>z_(e,t).filter(o).exists((t=>(e.selection.setRng(t.toRange()),!0))),Z_=(e,t)=>{const o=e.dom.createRng();o.setStart(t.container(),t.offset()),o.setEnd(t.container(),t.offset()),e.selection.setRng(o)},U_=(e,t)=>{e?t.setAttribute("data-mce-selected","inline-boundary"):t.removeAttribute("data-mce-selected")},j_=(e,t,o)=>Fk(t,o).map((t=>(Z_(e,t),o))),W_=(e,t,o)=>{const n=e.getBody(),r=((e,t,o)=>{const n=rl.fromRangeStart(e);if(e.collapsed)return n;{const r=rl.fromRangeEnd(e);return o?qm(t,r).getOr(r):$m(t,n).getOr(n)}})(e.selection.getRng(),n,o),s=N(lv,e);return r_(o,s,n,r).bind((o=>j_(e,t,o)))},$_=(e,t)=>{const o=t.get();if(e.selection.isCollapsed()&&!e.composing&&o){const n=rl.fromRangeStart(e.selection.getRng());rl.isTextPosition(n)&&!(e=>Ur(e)||jr(e))(n)&&(Z_(e,Ud(o,n)),t.set(null))}},q_=(e,t,o)=>!!Rc(e)&&W_(e,t,o).isSome(),G_=(e,t,o)=>!!Rc(t)&&a_(e,t),K_=e=>{const t=Qa(null),o=N(lv,e);return e.on("NodeChange",(n=>{Rc(e)&&(((e,t,o)=>{const n=$(zn(yo.fromDom(t.getRoot()),'*[data-mce-selected="inline-boundary"]'),(e=>e.dom)),r=Y(n,e),s=Y(o,e);q(ae(r,s),N(U_,!1)),q(ae(s,r),N(U_,!0))})(o,e.dom,n.parents),$_(e,t),((e,t,o,n)=>{if(t.selection.isCollapsed()){const r=Y(n,e);q(r,(n=>{const r=rl.fromRangeStart(t.selection.getRng());Yk(e,t.getBody(),r).bind((e=>j_(t,o,e)))}))}})(o,e,t,n.parents))})),t},Y_=N(G_,!0),X_=N(G_,!1),J_=(e,t,o)=>{if(Rc(e)){const n=z_(e,t).getOrThunk((()=>{const o=e.selection.getRng();return t?rl.fromRangeEnd(o):rl.fromRangeStart(o)}));return Yk(N(lv,e),e.getBody(),n).exists((t=>{const n=Qk(t);return Fk(o,n).exists((t=>(Z_(e,t),!0)))}))}return!1},Q_=(e,t)=>o=>Fk(t,o).map((t=>()=>Z_(e,t))),eE=(e,t,o,n)=>{const r=e.getBody(),s=N(lv,e);e.undoManager.ignore((()=>{e.selection.setRng(((e,t)=>{const o=document.createRange();return o.setStart(e.container(),e.offset()),o.setEnd(t.container(),t.offset()),o})(o,n)),pv(e),Yk(s,r,rl.fromRangeStart(e.selection.getRng())).map(e_).bind(Q_(e,t)).each(H)})),e.nodeChanged()},tE=(e,t,o,n)=>{const r=((e,t)=>{const o=um(t,e);return o||e})(e.getBody(),n.container()),s=N(lv,e),a=Yk(s,r,n);return a.bind((e=>o?e.fold(D(F.some(e_(e))),F.none,D(F.some(Qk(e))),F.none):e.fold(F.none,D(F.some(Qk(e))),F.none,D(F.some(e_(e)))))).map(Q_(e,t)).getOrThunk((()=>{const i=Um(o,r,n),l=i.bind((e=>Yk(s,r,e)));return It(a,l,(()=>dv(s,r,n).bind((t=>(e=>It(Gm(e),Km(e),((t,o)=>{const n=mv(!0,t),r=mv(!1,o);return $m(e,n).forall((e=>e.isEqual(r)))})).getOr(!0))(t)?F.some((()=>{av(e,o,yo.fromDom(t))})):F.none())))).getOrThunk((()=>l.bind((()=>i.map((r=>()=>{o?eE(e,t,n,r):eE(e,t,r,n)}))))))}))},oE=(e,t,o)=>{if(e.selection.isCollapsed()&&Rc(e)){const n=rl.fromRangeStart(e.selection.getRng());return tE(e,t,o,n)}return F.none()},nE=(e,t)=>{const o=yo.fromDom(e.getBody()),n=yo.fromDom(e.selection.getStart()),r=pf(n,o);return te(r,t).fold(D(r),(e=>r.slice(0,e)))},rE=e=>1===Fo(e),sE=e=>nE(e,(t=>e.schema.isBlock(jt(t))||(e=>Fo(e)>1)(t))),aE=(e,t)=>{const o=N(ny,e);return ne(t,(e=>o(e)?[e.dom]:[]))},iE=e=>{const t=(e=>nE(e,(t=>e.schema.isBlock(jt(t)))))(e);return aE(e,t)},lE=(e,t)=>{const o=Y(sE(e),rE);return me(o).bind((n=>{const r=rl.fromRangeStart(e.selection.getRng());return yv(t,r,n.dom)&&!Yu(n)?F.some((()=>((e,t,o,n)=>{const r=aE(t,n);if(0===r.length)av(t,e,o);else{const e=oy(o.dom,r);t.selection.setRng(e.toRange())}})(t,e,n,o))):F.none()}))},cE=(e,t)=>{const o=e.selection.getStart(),n=((e,t)=>{const o=t.parentElement;return ir(t)&&!b(o)&&e.dom.isEmpty(o)})(e,o)||(r=o,Yu(yo.fromDom(r)))?oy(o,t):((e,t)=>{const{caretContainer:o,caretPosition:n}=ty(t);return e.insertNode(o.dom),n})(e.selection.getRng(),t);var r;e.selection.setRng(n.toRange())},dE=e=>tr(e.startContainer),mE=e=>(e=>{const t=e.startContainer.parentNode,o=e.endContainer.parentNode;return!b(t)&&!b(o)&&t.isEqualNode(o)})(e)&&(e=>{const t=e.endContainer;return e.endOffset===(tr(t)?t.length:t.childNodes.length)})(e),uE=e=>{const t=e.selection.getRng();return(e=>0===e.startOffset&&dE(e))(t)&&((e,t)=>{const o=t.startContainer.parentElement;return!b(o)&&ny(e,yo.fromDom(o))})(e,t)&&(e=>mE(e)||(e=>!e.endContainer.isEqualNode(e.commonAncestorContainer))(e))(t)},gE=e=>{if(uE(e)){const t=iE(e);return F.some((()=>{pv(e),((e,t)=>{const o=ae(t,iE(e));o.length>0&&cE(e,o)})(e,t)}))}return F.none()},hE=(e,t)=>e.selection.isCollapsed()?lE(e,t):gE(e),pE=(e,t)=>((e,t,o)=>Yo(e,t,o).isSome())(e,(e=>Xm(e.dom)),(e=>t.isBlock(jt(e)))),fE=e=>{const t=e.selection.getRng();return t.collapsed&&(dE(t)||e.dom.isEmpty(t.startContainer))&&!(e=>pE(yo.fromDom(e.selection.getStart()),e.schema))(e)},vE=e=>(fE(e)&&cE(e,[]),!0),bE=(e,t,o)=>C(o)?F.some((()=>{e._selectionOverrides.hideFakeCaret(),av(e,t,yo.fromDom(o))})):F.none(),yE=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const o=t?lf:cf,n=t?Em.Forwards:Em.Backwards,r=Cm(n,e.getBody(),e.selection.getRng());return o(r)?bE(e,t,r.getNode(!t)):F.from(mv(t,r)).filter((e=>o(e)&&_m(r,e))).bind((o=>bE(e,t,o.getNode(!t))))})(e,t):((e,t)=>{const o=e.selection.getNode();return gr(o)?bE(e,t,o):F.none()})(e,t),wE=e=>Je(null!=e?e:"").getOr(0),xE=(e,t)=>(e||"table"===jt(t)?"margin":"padding")+("rtl"===dn(t,"direction")?"-right":"-left"),CE=e=>{const t=kE(e);return!e.mode.isReadOnly()&&(t.length>1||((e,t)=>re(t,(t=>{const o=xE(vc(e),t),n=un(t,o).map(wE).getOr(0);return"false"!==e.dom.getContentEditable(t.dom)&&n>0})))(e,t))},SE=e=>Er(e)||Tr(e),kE=e=>Y(kn(e.selection.getSelectedBlocks()),(e=>!SE(e)&&!(e=>Oo(e).exists(SE))(e)&&Xo(e,(e=>cr(e.dom)||dr(e.dom))).exists((e=>cr(e.dom))))),_E=(e,t)=>{var o,n;const{dom:r}=e,s=bc(e),a=null!==(n=null===(o=/[a-z%]+$/i.exec(s))||void 0===o?void 0:o[0])&&void 0!==n?n:"px",i=wE(s),l=vc(e);q(kE(e),(e=>{((e,t,o,n,r,s)=>{const a=xE(o,yo.fromDom(s)),i=wE(e.getStyle(s,a));if("outdent"===t){const t=Math.max(0,i-n);e.setStyle(s,a,t?t+r:"")}else{const t=i+n+r;e.setStyle(s,a,t)}})(r,t,l,i,a,e.dom)}))},EE=e=>_E(e,"outdent"),TE=e=>{if(e.selection.isCollapsed()&&CE(e)){const t=e.dom,o=e.selection.getRng(),n=rl.fromRangeStart(o),r=t.getParent(o.startContainer,t.isBlock);if(null!==r&&wf(yo.fromDom(r),n,e.schema))return F.some((()=>EE(e)))}return F.none()},OE=(e,t,o)=>ge([TE,Ok,vk,(e,o)=>oE(e,t,o),ak,eb,Dk,yE,dk,hE],(t=>t(e,o))).filter((t=>e.selection.isEditable())),DE=(e,t)=>{OE(e,t,!0).fold((()=>{e.selection.isEditable()&&(e=>{hv(e,"ForwardDelete")})(e)}),H)},AE=(e,t)=>{e.addCommand("delete",(()=>{((e,t)=>{OE(e,t,!1).fold((()=>{e.selection.isEditable()&&(pv(e),bv(e))}),H)})(e,t)})),e.addCommand("forwardDelete",(()=>{DE(e,t)}))},ME=e=>void 0===e.touches||1!==e.touches.length?F.none():F.some(e.touches[0]),NE=e=>{const t=ai(),o=Qa(!1),n=li((t=>{e.dispatch("longpress",{...t,type:"longpress"}),o.set(!0)}),400);e.on("touchstart",(e=>{ME(e).each((r=>{n.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};n.throttle(e),o.set(!1),t.set(s)}))}),!0),e.on("touchmove",(r=>{n.cancel(),ME(r).each((n=>{t.on((r=>{((e,t)=>{const o=Math.abs(e.clientX-t.x),n=Math.abs(e.clientY-t.y);return o>5||n>5})(n,r)&&(t.clear(),o.set(!1),e.dispatch("longpresscancel"))}))}))}),!0),e.on("touchend touchcancel",(r=>{n.cancel(),"touchcancel"!==r.type&&t.get().filter((e=>e.target.isEqualNode(r.target))).each((()=>{o.get()?r.preventDefault():e.dispatch("tap",{...r,type:"tap"})}))}),!0)},RE=(e,t)=>_e(e,t.nodeName),BE=(e,t)=>!!tr(t)||!!Wn(t)&&!(RE(e.getBlockElements(),t)||mu(t)||Ls(e,t)||xs(t)),LE=(e,t)=>{if(tr(t)){if(0===t.data.length)return!0;if(/^\s+$/.test(t.data))return!t.nextSibling||RE(e,t.nextSibling)||xs(t.nextSibling)}return!1},HE=e=>e.dom.create(Xl(e),Jl(e)),IE=e=>{const t=e.dom,o=e.selection,n=e.schema,r=n.getBlockElements(),s=o.getStart(),a=e.getBody();let i,l,c=!1;const d=Xl(e);if(!s||!Wn(s))return;const m=a.nodeName.toLowerCase();if(!n.isValidChild(m,d.toLowerCase())||((e,t,o)=>W(hf(yo.fromDom(o),yo.fromDom(t)),(t=>RE(e,t.dom))))(r,a,s))return;const u=o.getRng(),{startContainer:g,startOffset:h,endContainer:p,endOffset:f}=u,v=ap(e);let b=a.firstChild;for(;b;)if(Wn(b)&&Ms(n,b),BE(n,b)){if(LE(r,b)){l=b,b=b.nextSibling,t.remove(l);continue}i||(i=HE(e),a.insertBefore(i,b),c=!0),l=b,b=b.nextSibling,i.appendChild(l)}else i=null,b=b.nextSibling;c&&v&&(u.setStart(g,h),u.setEnd(p,f),o.setRng(u),e.nodeChanged())},PE=(e,t,o)=>{const n=yo.fromDom(HE(e)),r=Nr();bn(n,r),o(t,n);const s=document.createRange();return s.setStartBefore(r.dom),s.setEndBefore(r.dom),s},FE=e=>t=>-1!==(" "+t.attr("class")+" ").indexOf(e),zE=(e,t,o)=>function(n){const r=arguments,s=r[r.length-2],a=s>0?t.charAt(s-1):"";if('"'===a)return n;if(">"===a){const e=t.lastIndexOf("<",s);if(-1!==e&&-1!==t.substring(e,s).indexOf('contenteditable="false"'))return n}return''+e.dom.encode("string"==typeof r[1]?r[1]:r[0])+""},VE=e=>{const t="contenteditable",o=" "+Bt.trim(Sd(e))+" ",n=" "+Bt.trim(Cd(e))+" ",r=FE(o),s=FE(n),a=kd(e);a.length>0&&e.on("BeforeSetContent",(t=>{((e,t,o)=>{let n=t.length,r=o.content;if("raw"!==o.format){for(;n--;)r=r.replace(t[n],zE(e,r,Cd(e)));o.content=r}})(e,a,t)})),e.parser.addAttributeFilter("class",(e=>{let o=e.length;for(;o--;){const n=e[o];r(n)?n.attr(t,"true"):s(n)&&n.attr(t,"false")}})),e.serializer.addAttributeFilter(t,(e=>{let o=e.length;for(;o--;){const n=e[o];(r(n)||s(n))&&(a.length>0&&n.attr("data-mce-content")?(n.name="#text",n.type=3,n.raw=!0,n.value=n.attr("data-mce-content")):n.attr(t,null))}}))},ZE=(e,t)=>{t.hasAttribute("data-mce-caret")&&(qr(t),e.selection.setRng(e.selection.getRng()),e.selection.scrollIntoView(t))},UE=(e,t)=>{const o=(e=>tn(yo.fromDom(e.getBody()),"*[data-mce-caret]").map((e=>e.dom)).getOrNull())(e);if(o)return"compositionstart"===t.type?(t.preventDefault(),t.stopPropagation(),void ZE(e,o)):void(Zr(o)&&(ZE(e,o),e.undoManager.add()))},jE=dr,WE=(e,t,o)=>{const n=Im(e.getBody()),r=N(km,1===t?n.next:n.prev);if(o.collapsed){const n=e.dom.getParent(o.startContainer,"PRE");if(!n)return;if(!r(rl.fromRangeStart(o))){const o=yo.fromDom((e=>{const t=e.dom.create(Xl(e));return t.innerHTML='
    ',t})(e));1===t?fn(yo.fromDom(n),o):pn(yo.fromDom(n),o),e.selection.select(o.dom,!0),e.selection.collapse()}}},$E=(e,t)=>{const o=t?Em.Forwards:Em.Backwards,n=e.selection.getRng();return((e,t,o)=>P_(t,e,o,uf,gf,jE))(o,e,n).orThunk((()=>(WE(e,o,n),F.none())))},qE=(e,t)=>{const o=t?1:-1,n=e.selection.getRng();return((e,t,o)=>F_(t,e,o,(e=>uf(e)||df(e)),(e=>gf(e)||mf(e)),jE))(o,e,n).orThunk((()=>(WE(e,o,n),F.none())))},GE=(e,t)=>$E(e,((e,t)=>{const o=t?e.getEnd(!0):e.getStart(!0);return cv(o)?!t:t})(e.selection,t)).exists((t=>(H_(e,t),!0))),KE=(e,t)=>qE(e,t).exists((t=>(H_(e,t),!0))),YE=(e,t)=>V_(e,t,t?gf:uf),XE=(e,t)=>bk(e,!t).map((o=>{const n=o.toRange(),r=e.selection.getRng();return t?n.setStart(r.startContainer,r.startOffset):n.setEnd(r.endContainer,r.endOffset),n})).exists((t=>(H_(e,t),!0))),JE=e=>j(["figcaption"],jt(e)),QE=(e,t)=>{const o=yo.fromDom(e.getBody()),n=rl.fromRangeStart(e.selection.getRng());return((e,t,o)=>{const n=N(So,t);return Xo(yo.fromDom(e.container()),(e=>o.isBlock(jt(e))),n).filter(JE)})(n,o,e.schema).exists((()=>{if(((e,t,o)=>t?w_(e.dom,o):y_(e.dom,o))(o,t,n)){const n=PE(e,o,t?bn:vn);return e.selection.setRng(n),!0}return!1}))},eT=(e,t)=>!!e.selection.isCollapsed()&&QE(e,t),tT=(e,t)=>t?F.from(e.dom.getParent(e.selection.getNode(),"details")).map((t=>((e,t)=>{const o=e.selection.getRng(),n=rl.fromRangeStart(o);return!(e.getBody().lastChild!==t||!w_(t,n)||(e.execCommand("InsertNewBlockAfter"),0))})(e,t))).getOr(!1):F.from(e.dom.getParent(e.selection.getNode(),"summary")).bind((t=>F.from(e.dom.getParent(t,"details")).map((o=>((e,t,o)=>{const n=e.selection.getRng(),r=rl.fromRangeStart(n);return!(e.getBody().firstChild!==t||!y_(o,r)||(e.execCommand("InsertNewBlockBefore"),0))})(e,o,t))))).getOr(!1),oT=(e,t)=>tT(e,t),nT={shiftKey:!1,altKey:!1,ctrlKey:!1,metaKey:!1,keyCode:0},rT=(e,t)=>t.keyCode===e.keyCode&&t.shiftKey===e.shiftKey&&t.altKey===e.altKey&&t.ctrlKey===e.ctrlKey&&t.metaKey===e.metaKey,sT=(e,t)=>ne((e=>$(e,(e=>({...nT,...e}))))(e),(e=>rT(e,t)?[e]:[])),aT=(e,t)=>ne((e=>$(e,(e=>({...nT,...e}))))(e),(e=>rT(e,t)?[e]:[])),iT=(e,...t)=>()=>e.apply(null,t),lT=(e,t)=>ee(sT(e,t),(e=>e.action())),cT=(e,t)=>ge(aT(e,t),(e=>e.action())),dT=(e,t)=>{const o=t?Em.Forwards:Em.Backwards,n=e.selection.getRng();return P_(e,o,n,lf,cf,gr).exists((t=>(H_(e,t),!0)))},mT=(e,t)=>{const o=t?1:-1,n=e.selection.getRng();return F_(e,o,n,lf,cf,gr).exists((t=>(H_(e,t),!0)))},uT=(e,t)=>V_(e,t,t?cf:lf),gT=Al([{none:["current"]},{first:["current"]},{middle:["current","target"]},{last:["current"]}]),hT={...gT,none:e=>gT.none(e)},pT=(e,t,o)=>ne(Lo(e),(e=>xo(e,t)?o(e)?[e]:[]:pT(e,t,o))),fT=(e,t)=>((e,t,o=I)=>o(t)?F.none():j(e,jt(t))?F.some(t):en(t,e.join(","),(e=>xo(e,"table")||o(e))))(["td","th"],e,t),vT=e=>pT(e,"th,td",P),bT=(e,t)=>on(e,"table",t),yT=(e,t,o,n,r=P)=>{const s=1===n;if(!s&&o<=0)return hT.first(e[0]);if(s&&o>=e.length-1)return hT.last(e[e.length-1]);{const s=o+n,a=e[s];return r(a)?hT.middle(t,a):yT(e,t,s,n,r)}},wT=(e,t)=>bT(e,t).bind((t=>{const o=vT(t);return te(o,(t=>So(e,t))).map((e=>({index:e,all:o})))})),xT=(e,t,o,n,r)=>{const s=zn(yo.fromDom(o),"td,th,caption").map((e=>e.dom)),a=Y(((e,t)=>ne(t,(t=>{const o=((e,t)=>({left:e.left-t,top:e.top-t,right:e.right+2*t,bottom:e.bottom+2*t,width:e.width+t,height:e.height+t}))(Ai(t.getBoundingClientRect()),-1);return[{x:o.left,y:e(o),cell:t},{x:o.right,y:e(o),cell:t}]})))(e,s),(e=>t(e,r)));return((e,t,o)=>J(e,((e,n)=>e.fold((()=>F.some(n)),(e=>{const r=Math.sqrt(Math.abs(e.x-t)+Math.abs(e.y-o)),s=Math.sqrt(Math.abs(n.x-t)+Math.abs(n.y-o));return F.some(se.cell))},CT=N(xT,(e=>e.bottom),((e,t)=>e.ye.top),((e,t)=>e.y>t)),kT=(e,t)=>de(t.getClientRects()).bind((t=>CT(e,t.left,t.top))).bind((e=>{return h_(Km(o=e).map((e=>p_(o,e).positions.concat(e))).getOr([]),t);var o})),_T=(e,t)=>me(t.getClientRects()).bind((t=>ST(e,t.left,t.top))).bind((e=>{return h_(Gm(o=e).map((e=>[e].concat(f_(o,e).positions))).getOr([]),t);var o})),ET=(e,t,o)=>{const n=e(t,o);return(e=>e.breakType===i_.Wrap&&0===e.positions.length)(n)||!ir(o.getNode())&&(e=>e.breakType===i_.Br&&1===e.positions.length)(n)?!((e,t,o)=>o.breakAt.exists((o=>e(t,o).breakAt.isSome())))(e,t,n):n.breakAt.isNone()},TT=N(ET,p_),OT=N(ET,f_),DT=(e,t,o,n)=>{const r=e.selection.getRng(),s=t?1:-1;return!(!Yd()||!((e,t,o)=>{const n=rl.fromRangeStart(t);return Wm(!e,o).exists((e=>e.isEqual(n)))})(t,r,o)||(mk(s,e,o,!t,!1).each((t=>{H_(e,t)})),0))},AT=(e,t)=>{const o=t.getNode(e);return Jn(o)?F.some(o):F.none()},MT=(e,t,o)=>{const n=AT(!!t,o),r=!1===t;n.fold((()=>H_(e,o.toRange())),(n=>Wm(r,e.getBody()).filter((e=>e.isEqual(o))).fold((()=>H_(e,o.toRange())),(o=>((e,t,o)=>{t.undoManager.transact((()=>{const n=e?fn:pn,r=PE(t,yo.fromDom(o),n);H_(t,r)}))})(t,e,n)))))},NT=(e,t,o,n)=>{const r=e.selection.getRng(),s=rl.fromRangeStart(r),a=e.getBody();if(!t&&TT(n,s)){const n=((e,t,o)=>kT(t,o).orThunk((()=>de(o.getClientRects()).bind((o=>g_(v_(e,rl.before(t)),o.left))))).getOr(rl.before(t)))(a,o,s);return MT(e,t,n),!0}if(t&&OT(n,s)){const n=((e,t,o)=>_T(t,o).orThunk((()=>de(o.getClientRects()).bind((o=>g_(b_(e,rl.after(t)),o.left))))).getOr(rl.after(t)))(a,o,s);return MT(e,t,n),!0}return!1},RT=(e,t,o)=>F.from(e.dom.getParent(e.selection.getNode(),"td,th")).bind((n=>F.from(e.dom.getParent(n,"table")).map((r=>o(e,t,r,n))))).getOr(!1),BT=(e,t)=>RT(e,t,DT),LT=(e,t)=>RT(e,t,NT),HT=(e,t,o)=>o.fold(F.none,F.none,((e,t)=>{return(o=t,Qo(o,vp)).map((e=>(e=>{const t=qg.exact(e,0,e,0);return Jg(t)})(e)));var o}),(o=>(e.execCommand("mceTableInsertRowAfter"),IT(e,t,o)))),IT=(e,t,o)=>HT(e,t,((e,t,o)=>wT(e,o).fold((()=>hT.none(e)),(o=>yT(o.all,e,o.index,1,t))))(o,nn)),PT=(e,t,o)=>HT(e,t,((e,t,o)=>wT(e,o).fold((()=>hT.none()),(o=>yT(o.all,e,o.index,-1,t))))(o,nn)),FT=(e,t)=>{const o=["table","li","dl"],n=yo.fromDom(e.getBody()),r=e=>{const t=jt(e);return So(e,n)||j(o,t)},s=e.selection.getRng(),a=yo.fromDom(t?s.endContainer:s.startContainer);return fT(a,r).map((o=>(bT(o,r).each((t=>{e.model.table.clearSelectedCells(t.dom)})),e.selection.collapse(!t),(t?IT:PT)(e,r,o).each((t=>{e.selection.setRng(t)})),!0))).getOr(!1)},zT=(e,t)=>{e.on("keydown",(o=>{o.isDefaultPrevented()||((e,t,o)=>{const n=At.os.isMacOS()||At.os.isiOS();lT([{keyCode:Dg.RIGHT,action:iT(GE,e,!0)},{keyCode:Dg.LEFT,action:iT(GE,e,!1)},{keyCode:Dg.UP,action:iT(KE,e,!1)},{keyCode:Dg.DOWN,action:iT(KE,e,!0)},...n?[{keyCode:Dg.UP,action:iT(XE,e,!1),metaKey:!0,shiftKey:!0},{keyCode:Dg.DOWN,action:iT(XE,e,!0),metaKey:!0,shiftKey:!0}]:[],{keyCode:Dg.RIGHT,action:iT(BT,e,!0)},{keyCode:Dg.LEFT,action:iT(BT,e,!1)},{keyCode:Dg.UP,action:iT(LT,e,!1)},{keyCode:Dg.DOWN,action:iT(LT,e,!0)},{keyCode:Dg.UP,action:iT(LT,e,!1)},{keyCode:Dg.UP,action:iT(oT,e,!1)},{keyCode:Dg.DOWN,action:iT(oT,e,!0)},{keyCode:Dg.RIGHT,action:iT(dT,e,!0)},{keyCode:Dg.LEFT,action:iT(dT,e,!1)},{keyCode:Dg.UP,action:iT(mT,e,!1)},{keyCode:Dg.DOWN,action:iT(mT,e,!0)},{keyCode:Dg.RIGHT,action:iT(q_,e,t,!0)},{keyCode:Dg.LEFT,action:iT(q_,e,t,!1)},{keyCode:Dg.RIGHT,ctrlKey:!n,altKey:n,action:iT(Y_,e,t)},{keyCode:Dg.LEFT,ctrlKey:!n,altKey:n,action:iT(X_,e,t)},{keyCode:Dg.UP,action:iT(eT,e,!1)},{keyCode:Dg.DOWN,action:iT(eT,e,!0)}],o).each((e=>{o.preventDefault()}))})(e,t,o)}))},VT=(e,t)=>({container:e,offset:t}),ZT=Ya.DOM,UT=e=>t=>e===t?-1:0,jT=(e,t,o)=>{if(tr(e)&&t>=0)return F.some(VT(e,t));{const n=Oi(ZT);return F.from(n.backwards(e,t,UT(e),o)).map((e=>VT(e.container,e.container.data.length)))}},WT=(e,t,o)=>{if(!tr(e))return F.none();const n=e.data;if(t>=0&&t<=n.length)return F.some(VT(e,t));{const n=Oi(ZT);return F.from(n.backwards(e,t,UT(e),o)).bind((e=>{const n=e.container.data;return WT(e.container,t+n.length,o)}))}},$T=(e,t,o)=>{if(!tr(e))return F.none();const n=e.data;if(t<=n.length)return F.some(VT(e,t));{const r=Oi(ZT);return F.from(r.forwards(e,t,UT(e),o)).bind((e=>$T(e.container,t-n.length,o)))}},qT=(e,t,o,n,r)=>{const s=Oi(e,(e=>t=>e.isBlock(t)||j(["BR","IMG","HR","INPUT"],t.nodeName)||"false"===e.getContentEditable(t))(e));return F.from(s.backwards(t,o,n,r))},GT=e=>Hr(e.toString().replace(/\u00A0/g," ")),KT=e=>""!==e&&-1!=="  \f\n\r\t\v".indexOf(e),YT=(e,t)=>e.substring(t.length),XT=(e,t,o,n=0)=>{if(!(r=t).collapsed||!tr(r.startContainer))return F.none();var r;const s={text:"",offset:0},a=e.getParent(t.startContainer,e.isBlock)||e.getRoot();return qT(e,t.startContainer,t.startOffset,((e,t,n)=>(s.text=n+s.text,s.offset+=t,((e,t,o)=>{let n;const r=o.charAt(0);for(n=t-1;n>=0;n--){const s=e.charAt(n);if(KT(s))return F.none();if(r===s&&Ue(e,o,n,t))break}return F.some(n)})(s.text,s.offset,o).getOr(t))),a).bind((e=>{const r=t.cloneRange();if(r.setStart(e.container,e.offset),r.setEnd(t.endContainer,t.endOffset),r.collapsed)return F.none();const s=GT(r);return 0!==s.lastIndexOf(o)||YT(s,o).length{return(r=yo.fromDom(t.startContainer),on(r,yp)).fold((()=>XT(e,t,o,n)),(t=>{const n=e.createRng();n.selectNode(t.dom);const r=GT(n);return F.some({range:n,text:YT(r,o),trigger:o})}));var r},QT=e=>{if((e=>3===e.nodeType)(e))return VT(e,e.data.length);{const t=e.childNodes;return t.length>0?QT(t[t.length-1]):VT(e,t.length)}},eO=(e,t)=>{const o=e.childNodes;return o.length>0&&t0&&(e=>1===e.nodeType)(e)&&o.length===t?QT(o[o.length-1]):VT(e,t)},tO=e=>t=>{const o=eO(t.startContainer,t.startOffset);return!((e,t)=>{var o;const n=null!==(o=e.getParent(t.container,e.isBlock))&&void 0!==o?o:e.getRoot();return qT(e,t.container,t.offset,((e,t)=>0===t?-1:t),n).filter((e=>{const t=e.container.data.charAt(e.offset-1);return!KT(t)})).isSome()})(e,o)},oO=(e,t)=>{const o=t(),n=e.selection.getRng();return((e,t,o)=>ge(o.triggers,(o=>JT(e,t,o))))(e.dom,n,o).bind((o=>nO(e,t,o)))},nO=(e,t,o,n={})=>{var r;const s=t(),a=null!==(r=e.selection.getRng().startContainer.nodeValue)&&void 0!==r?r:"",i=Y(s.lookupByTrigger(o.trigger),(t=>o.text.length>=t.minChars&&t.matches.getOrThunk((()=>tO(e.dom)))(o.range,a,o.text)));if(0===i.length)return F.none();const l=Promise.all($(i,(e=>e.fetch(o.text,e.maxResults,n).then((t=>({matchText:o.text,items:t,columns:e.columns,onAction:e.onAction,highlightOn:e.highlightOn}))))));return F.some({lookupData:l,context:o})};var rO;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(rO||(rO={}));const sO=(e,t,o)=>e.stype===rO.Error?t(e.serror):o(e.svalue),aO=e=>({stype:rO.Value,svalue:e}),iO=e=>({stype:rO.Error,serror:e}),lO=e=>sO(e,Dl.error,Dl.value),cO=aO,dO=e=>{const t=[],o=[];return q(e,(e=>{sO(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}},mO=iO,uO=(e,t)=>e.stype===rO.Error?t(e.serror):e,gO=(e,t)=>e.stype===rO.Value?{stype:rO.Value,svalue:t(e.svalue)}:e,hO=(e,t)=>e.stype===rO.Error?{stype:rO.Error,serror:t(e.serror)}:e,pO=sO,fO=e=>p(e)&&he(e).length>100?" removed due to size":JSON.stringify(e,null,2),vO=(e,t)=>mO([{path:e,getErrorInfo:t}]),bO=(e,t,o,n)=>ke(o,n).fold((()=>((e,t,o)=>vO(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+fO(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))),yO=(e,t)=>({extract:(o,n)=>ke(n,e).fold((()=>((e,t)=>vO(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>bO(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+he(t)}),wO=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;nf(e)&&f(t)?xO(e,t):t)),CO=(wO(((e,t)=>t)),e=>({tag:"defaultedThunk",process:D(e)})),SO=e=>T(mO,oe)(e),kO=e=>{const t=dO(e);return t.errors.length>0?SO(t.errors):cO(t.values)},_O=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},EO=e=>({extract:(t,o)=>uO(e(o),(e=>((e,t)=>vO(e,D(t)))(t,e))),toString:D("val")}),TO=EO(cO),OO=(e,t,o,n)=>ke(t,o).fold((()=>((e,t,o)=>vO(e,(()=>'Could not find valid *required* value for "'+t+'" in '+fO(o))))(e,o,t)),n),DO=(e,t,o,n)=>n(ke(e,t).getOrThunk((()=>o(e)))),AO=(e,t,o,n,r)=>{const s=e=>r.extract(t.concat([n]),e),a=e=>e.fold((()=>cO(F.none())),(e=>{const o=r.extract(t.concat([n]),e);return gO(o,F.some)}));switch(e.tag){case"required":return OO(t,o,n,s);case"defaultedThunk":return DO(o,n,e.process,s);case"option":return((e,t,o)=>o(ke(e,t)))(o,n,a);case"defaultedOptionThunk":return((e,t,o,n)=>n(ke(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,a);case"mergeWithThunk":return DO(o,n,D({}),(t=>{const n=xO(e.process(o),t);return s(n)}))}},MO=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const s of o)_O(s,((o,s,a,i)=>{const l=AO(a,e,t,o,i);pO(l,(e=>{r.push(...e)}),(e=>{n[s]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?mO(r):cO(n)})(t,o,e),toString:()=>{const t=$(e,(e=>_O(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),NO=e=>({extract:(t,o)=>{const n=$(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return kO(n)},toString:()=>"array("+e.toString()+")"}),RO=(e,t,o)=>lO(((e,t,o)=>{const n=t.extract([e],o);return hO(n,(e=>({input:o,errors:e})))})(e,t,o)),BO=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:D("... (only showing first ten failures)")}]):e;return $(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+fO(e.input),LO=(e,t)=>yO(e,ve(t,MO)),HO=D(TO),IO=(e,t)=>EO((o=>{const n=typeof o;return e(o)?cO(o):mO(`Expected type: ${t} but got: ${n}`)})),PO=IO(k,"number"),FO=IO(h,"string"),zO=IO(y,"boolean"),VO=IO(S,"function"),ZO=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),UO=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),jO=e=>{return t=t=>j(e,t)?Dl.value(t):Dl.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`),EO((e=>t(e).fold(mO,cO)));var t},WO=(e,t)=>ZO(e,e,{tag:"required",process:{}},t),$O=e=>WO(e,FO),qO=e=>WO(e,VO),GO=(e,t)=>ZO(e,e,{tag:"option",process:{}},t),KO=e=>GO(e,FO),YO=(e,t,o)=>ZO(e,e,CO(t),o),XO=(e,t)=>YO(e,t,PO),JO=(e,t,o)=>YO(e,t,jO(o)),QO=(e,t)=>YO(e,t,zO),eD=(e,t)=>YO(e,t,VO),tD=$O("type"),oD=qO("fetch"),nD=qO("onAction"),rD=eD("onSetup",(()=>E)),sD=KO("text"),aD=KO("icon"),iD=KO("tooltip"),lD=KO("label"),cD=QO("active",!1),dD=QO("enabled",!0),mD=QO("primary",!1),uD=e=>((e,t)=>YO(e,t,FO))("type",e),gD=MO([tD,$O("trigger"),XO("minChars",1),(pD=1,((e,t)=>ZO(e,e,CO(t),HO()))("columns",pD)),XO("maxResults",10),(hD="matches",GO(hD,VO)),oD,nD,((e,t,o)=>YO(e,t,NO(o)))("highlightOn",[],FO)]);var hD,pD;const fD=[dD,iD,aD,sD,rD],vD=[cD].concat(fD),bD=[eD("predicate",I),JO("scope","node",["node","editor"]),JO("position","selection",["node","selection","line"])],yD=fD.concat([uD("contextformbutton"),mD,nD,UO("original",A)]),wD=vD.concat([uD("contextformbutton"),mD,nD,UO("original",A)]),xD=fD.concat([uD("contextformbutton")]),CD=vD.concat([uD("contextformtogglebutton")]),SD=LO("type",{contextformbutton:yD,contextformtogglebutton:wD});MO([uD("contextform"),eD("initValue",D("")),lD,((e,t)=>ZO(e,e,{tag:"required",process:{}},NO(t)))("commands",SD),GO("launch",LO("type",{contextformbutton:xD,contextformtogglebutton:CD}))].concat(bD));const kD=e=>{const t=e.ui.registry.getAll().popups,o=ve(t,(e=>{return(t=e,RO("Autocompleter",gD,{trigger:t.ch,...t})).fold((e=>{throw new Error(BO(e))}),A);var t})),n=Te(Ce(o,(e=>e.trigger))),r=Se(o);return{dataset:o,triggers:n,lookupByTrigger:e=>Y(r,(t=>t.trigger===e))}},_D=e=>{const t=ai(),o=Qa(!1),n=t.isSet,r=()=>{n()&&((e=>{yC(e).autocompleter.removeDecoration()})(e),(e=>{e.dispatch("AutocompleterEnd")})(e),o.set(!1),t.clear())},s=o=>{n()||(((e,t)=>{yC(e).autocompleter.addDecoration(t)})(e,o.range),t.set({trigger:o.trigger,matchLength:o.text.length}))},a=He((()=>kD(e))),i=n=>{(o=>t.get().map((t=>JT(e.dom,e.selection.getRng(),t.trigger).bind((t=>nO(e,a,t,o))))).getOrThunk((()=>oO(e,a))))(n).fold(r,(n=>{s(n.context),n.lookupData.then((s=>{t.get().map((a=>{const i=n.context;a.trigger===i.trigger&&(i.text.length-a.matchLength>=10?r():(t.set({...a,matchLength:i.text.length}),o.get()?((e,t)=>{e.dispatch("AutocompleterUpdate",t)})(e,{lookupData:s}):(o.set(!0),((e,t)=>{e.dispatch("AutocompleterStart",t)})(e,{lookupData:s}))))}))}))}))};e.addCommand("mceAutocompleterReload",((e,t)=>{const o=p(t)?t.fetchOptions:{};i(o)})),e.addCommand("mceAutocompleterClose",r),((e,t)=>{const o=li(t.load,50);e.on("keypress compositionend",(e=>{27!==e.which&&o.throttle()})),e.on("keydown",(e=>{const n=e.which;8===n?o.throttle():27===n&&t.cancelIfNecessary()})),e.on("remove",o.cancel)})(e,{cancelIfNecessary:r,load:i})},ED=St().browser.isSafari(),TD=e=>Rr(yo.fromDom(e)),OD=(e,t)=>{var o;return 0===e.startOffset&&e.endOffset===(null===(o=t.textContent)||void 0===o?void 0:o.length)},DD=(e,t)=>F.from(e.getParent(t.container(),"details")),AD=(e,t)=>DD(e,t).isSome(),MD=(e,t)=>t.startSummary.exists((t=>((e,t)=>Gm(t).exists((t=>t.isEqual(e))))(e,t))),ND=(e,t)=>t.startSummary.exists((t=>((e,t)=>Km(t).exists((o=>ir(o.getNode())&&qm(t,o).exists((t=>t.isEqual(e)))||o.isEqual(e))))(e,t))),RD=(e,t)=>{const o=t.getNode();w(o)||e.selection.setCursorLocation(o,t.offset())},BD=(e,t,o)=>{const n=e.dom.getParent(t.container(),"details");if(n&&!n.open){const t=e.dom.select("summary",n)[0];t&&(o?Gm(t):Km(t)).each((t=>RD(e,t)))}else RD(e,t)},LD=(e,t,o)=>{const{dom:n,selection:r}=e,s=e.getBody();if("character"===o){const o=rl.fromRangeStart(r.getRng()),a=n.getParent(o.container(),n.isBlock),i=DD(n,o),l=a&&n.isEmpty(a),c=b(null==a?void 0:a.previousSibling),d=b(null==a?void 0:a.nextSibling);return!!(l&&(t?d:c)&&Um(!t,s,o).exists((e=>AD(n,e)&&!Ht(i,DD(n,e)))))||Um(t,s,o).fold(I,(o=>{const r=DD(n,o);if(AD(n,o)&&!Ht(i,r)){if(t||BD(e,o,!1),a&&l){if(t&&c)return!0;if(!t&&d)return!0;BD(e,o,t),e.dom.remove(a)}return!0}return!1}))}return!1},HD=(e,t,o,n)=>{const r=e.selection.getRng(),s=rl.fromRangeStart(r),a=e.getBody();return"selection"===n?((e,t)=>{const o=t.startSummary.exists((t=>t.contains(e.startContainer))),n=t.startSummary.exists((t=>t.contains(e.endContainer))),r=t.startDetails.forall((e=>t.endDetails.forall((t=>e!==t))));return(o||n)&&!(o&&n)||r})(r,t):o?ND(s,t)||((e,t,o)=>o.startDetails.exists((o=>$m(e,t).forall((e=>!o.contains(e.container()))))))(a,s,t):MD(s,t)||((e,t)=>t.startDetails.exists((o=>qm(o,e).forall((o=>t.startSummary.exists((t=>!t.contains(e.container())&&t.contains(o.container()))))))))(s,t)},ID=(e,t,o)=>((e,t)=>{const o=F.from(e.getParent(t.startContainer,"details")),n=F.from(e.getParent(t.endContainer,"details"));if(o.isSome()||n.isSome()){const t=o.bind((t=>F.from(e.select("summary",t)[0])));return F.some({startSummary:t,startDetails:o,endDetails:n})}return F.none()})(e.dom,e.selection.getRng()).fold((()=>LD(e,t,o)),(n=>HD(e,n,t,o)||LD(e,t,o))),PD=(e,t,o)=>{const n=e.selection,r=n.getNode(),s=n.getRng(),a=rl.fromRangeStart(s);return!!fr(r)&&("selection"===o&&OD(s,r)||yv(t,a,r)?TD(r):e.undoManager.transact((()=>{const s=n.getSel();let{anchorNode:a,anchorOffset:i,focusNode:l,focusOffset:c}=null!=s?s:{};const d=()=>{C(a)&&C(i)&&C(l)&&C(c)&&(null==s||s.setBaseAndExtent(a,i,l,c))},m=(e,t)=>{q(e.childNodes,(e=>{Ou(e)&&t.appendChild(e)}))},u=e.dom.create("span",{"data-mce-bogus":"1"});m(r,u),r.appendChild(u),d(),"word"!==o&&"line"!==o||null==s||s.modify("extend",t?"right":"left",o),!n.isCollapsed()&&OD(n.getRng(),u)?TD(r):(e.execCommand(t?"ForwardDelete":"Delete"),a=null==s?void 0:s.anchorNode,i=null==s?void 0:s.anchorOffset,l=null==s?void 0:s.focusNode,c=null==s?void 0:s.focusOffset,m(u,r),d()),e.dom.remove(u)})),!0)},FD=(e,t,o)=>ID(e,t,o)||ED&&PD(e,t,o)?F.some(E):F.none(),zD=e=>(t,o,n={})=>{const r=t.getBody(),s={bubbles:!0,composed:!0,data:null,isComposing:!1,detail:0,view:null,target:r,currentTarget:r,eventPhase:Event.AT_TARGET,originalTarget:r,explicitOriginalTarget:r,isTrusted:!1,srcElement:r,cancelable:!1,preventDefault:E,inputType:o},a=Ra(new InputEvent(e));return t.dispatch(e,{...a,...s,...n})},VD=zD("input"),ZD=zD("beforeinput"),UD=St(),jD=UD.os,WD=jD.isMacOS()||jD.isiOS(),$D=UD.browser.isFirefox(),qD=(e,t)=>{let o=!1;e.on("keydown",(n=>{o=n.keyCode===Dg.BACKSPACE,n.isDefaultPrevented()||((e,t,o)=>{const n=o.keyCode===Dg.BACKSPACE?"deleteContentBackward":"deleteContentForward",r=e.selection.isCollapsed(),s=r?"character":"selection",a=e=>r?e?"word":"line":"selection";cT([{keyCode:Dg.BACKSPACE,action:iT(TE,e)},{keyCode:Dg.BACKSPACE,action:iT(Ok,e,!1)},{keyCode:Dg.DELETE,action:iT(Ok,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(vk,e,!1)},{keyCode:Dg.DELETE,action:iT(vk,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(oE,e,t,!1)},{keyCode:Dg.DELETE,action:iT(oE,e,t,!0)},{keyCode:Dg.BACKSPACE,action:iT(eb,e,!1)},{keyCode:Dg.DELETE,action:iT(eb,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(FD,e,!1,s)},{keyCode:Dg.DELETE,action:iT(FD,e,!0,s)},...WD?[{keyCode:Dg.BACKSPACE,altKey:!0,action:iT(FD,e,!1,a(!0))},{keyCode:Dg.DELETE,altKey:!0,action:iT(FD,e,!0,a(!0))},{keyCode:Dg.BACKSPACE,metaKey:!0,action:iT(FD,e,!1,a(!1))}]:[{keyCode:Dg.BACKSPACE,ctrlKey:!0,action:iT(FD,e,!1,a(!0))},{keyCode:Dg.DELETE,ctrlKey:!0,action:iT(FD,e,!0,a(!0))}],{keyCode:Dg.BACKSPACE,action:iT(Dk,e,!1)},{keyCode:Dg.DELETE,action:iT(Dk,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(yE,e,!1)},{keyCode:Dg.DELETE,action:iT(yE,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(dk,e,!1)},{keyCode:Dg.DELETE,action:iT(dk,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(ak,e,!1)},{keyCode:Dg.DELETE,action:iT(ak,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(hE,e,!1)},{keyCode:Dg.DELETE,action:iT(hE,e,!0)}],o).filter((t=>e.selection.isEditable())).each((t=>{o.preventDefault(),ZD(e,n).isDefaultPrevented()||(t(),VD(e,n))}))})(e,t,n)})),e.on("keyup",(t=>{t.isDefaultPrevented()||((e,t,o)=>{lT([{keyCode:Dg.BACKSPACE,action:iT(Tk,e)},{keyCode:Dg.DELETE,action:iT(Tk,e)},...WD?[{keyCode:Dg.BACKSPACE,altKey:!0,action:iT(vE,e)},{keyCode:Dg.DELETE,altKey:!0,action:iT(vE,e)},...o?[{keyCode:$D?224:91,action:iT(vE,e)}]:[]]:[{keyCode:Dg.BACKSPACE,ctrlKey:!0,action:iT(vE,e)},{keyCode:Dg.DELETE,ctrlKey:!0,action:iT(vE,e)}]],t)})(e,t,o),o=!1}))},GD=(e,t)=>{const o=e.dom,n=e.schema.getMoveCaretBeforeOnEnterElements();if(!t)return;if(/^(LI|DT|DD)$/.test(t.nodeName)){const e=(e=>{for(;e;){if(Wn(e)||tr(e)&&e.data&&/[\r\n\s]/.test(e.data))return e;e=e.nextSibling}return null})(t.firstChild);e&&/^(UL|OL|DL)$/.test(e.nodeName)&&t.insertBefore(o.doc.createTextNode(br),t.firstChild)}const r=o.createRng();if(t.normalize(),t.hasChildNodes()){const e=new Zn(t,t);let o,s=t;for(;o=e.current();){if(tr(o)){r.setStart(o,0),r.setEnd(o,0);break}if(n[o.nodeName.toLowerCase()]){r.setStartBefore(o),r.setEndBefore(o);break}s=o,o=e.next()}o||(r.setStart(s,0),r.setEnd(s,0))}else ir(t)?t.nextSibling&&o.isBlock(t.nextSibling)?(r.setStartBefore(t),r.setEndBefore(t)):(r.setStartAfter(t),r.setEndAfter(t)):(r.setStart(t,0),r.setEnd(t,0));e.selection.setRng(r),Rh(e,r)},KD=(e,t)=>{const o=e.getRoot();let n,r=t;for(;r!==o&&r&&"false"!==e.getContentEditable(r);){if("true"===e.getContentEditable(r)){n=r;break}r=r.parentNode}return r!==o?n:o},YD=e=>F.from(e.dom.getParent(e.selection.getStart(!0),e.dom.isBlock)),XD=e=>{e.innerHTML='
    '},JD=(e,t)=>{Xl(e).toLowerCase()===t.tagName.toLowerCase()&&((e,t,o)=>{const n=e.dom;F.from(o.style).map(n.parseStyle).each((e=>{const o={...gn(yo.fromDom(t)),...e};n.setStyles(t,o)}));const r=F.from(o.class).map((e=>e.split(/\s+/))),s=F.from(t.className).map((e=>Y(e.split(/\s+/),(e=>""!==e))));It(r,s,((e,o)=>{const r=Y(o,(t=>!j(e,t))),s=[...e,...r];n.setAttrib(t,"class",s.join(" "))}));const a=["style","class"],i=xe(o,((e,t)=>!j(a,t)));n.setAttribs(t,i)})(e,t,Jl(e))},QD=(e,t,o,n,r=!0,s,a)=>{const i=e.dom,l=e.schema,c=Xl(e),d=o?o.nodeName.toUpperCase():"";let m=t;const u=l.getTextInlineElements();let g;g=s||"TABLE"===d||"HR"===d?i.create(s||c,a||{}):o.cloneNode(!1);let h=g;if(r){do{if(u[m.nodeName]){if(Xm(m)||mu(m))continue;const e=m.cloneNode(!1);i.setAttrib(e,"id",""),g.hasChildNodes()?(e.appendChild(g.firstChild),g.appendChild(e)):(h=e,g.appendChild(e))}}while((m=m.parentNode)&&m!==n)}else i.setAttrib(g,"style",null),i.setAttrib(g,"class",null);return JD(e,g),XD(h),g},eA=(e,t,o)=>!t&&o.nodeName.toLowerCase()===Xl(e)&&e.dom.isEmpty(o)&&((e,t,o)=>{let n=t;for(;n&&n!==e&&b(n.nextSibling);){const e=n.parentElement;if(!e||!o(e))return pr(e);n=e}return!1})(e.getBody(),o,(t=>_e(e.schema.getTextBlockElements(),t.nodeName.toLowerCase()))),tA=(e,t,o)=>{var n,r,s;const a=t(Xl(e)),i=((e,t)=>e.dom.getParent(t,pr))(e,o);i&&(e.dom.insertAfter(a,i),GD(e,a),(null!==(s=null===(r=null===(n=o.parentElement)||void 0===n?void 0:n.childNodes)||void 0===r?void 0:r.length)&&void 0!==s?s:0)>1&&e.dom.remove(o))},oA=(e,t)=>{const o=null==e?void 0:e.parentNode;return C(o)&&o.nodeName===t},nA=e=>C(e)&&/^(OL|UL|LI)$/.test(e.nodeName),rA=e=>C(e)&&/^(LI|DT|DD)$/.test(e.nodeName),sA=e=>{const t=e.parentNode;return rA(t)?t:e},aA=(e,t,o)=>{let n=e[o?"firstChild":"lastChild"];for(;n&&!Wn(n);)n=n[o?"nextSibling":"previousSibling"];return n===t},iA=e=>J(Ce(gn(yo.fromDom(e)),((e,t)=>`${t}: ${e};`)),((e,t)=>e+t),""),lA=(e,t,o,n,r)=>{const s=e.dom,a=e.selection.getRng(),i=o.parentNode;if(o===e.getBody()||!i)return;var l;nA(l=o)&&nA(l.parentNode)&&(r="LI");const c=rA(n)?iA(n):void 0;let d=rA(n)&&c?t(r,{style:iA(n)}):t(r);if(aA(o,n,!0)&&aA(o,n,!1))if(oA(o,"LI")){const e=sA(o);s.insertAfter(d,e),(e=>{var t;return(null===(t=e.parentNode)||void 0===t?void 0:t.firstChild)===e})(o)?s.remove(e):s.remove(o)}else s.replace(d,o);else if(aA(o,n,!0))oA(o,"LI")?(s.insertAfter(d,sA(o)),d.appendChild(s.doc.createTextNode(" ")),d.appendChild(o)):i.insertBefore(d,o),s.remove(n);else if(aA(o,n,!1))s.insertAfter(d,sA(o)),s.remove(n);else{o=sA(o);const e=a.cloneRange();e.setStartAfter(n),e.setEndAfter(o);const t=e.extractContents();if("LI"===r&&((e,t)=>e.firstChild&&e.firstChild.nodeName===t)(t,"LI")){const e=Y($(d.children,yo.fromDom),R(Jt("br")));d=t.firstChild,s.insertAfter(t,o),q(e,(e=>vn(yo.fromDom(d),e))),c&&d.setAttribute("style",c)}else s.insertAfter(t,o),s.insertAfter(d,o);s.remove(n)}GD(e,d)},cA=(e,t)=>t&&"A"===t.nodeName&&e.isEmpty(t),dA=(e,t)=>e.nodeName===t||e.previousSibling&&e.previousSibling.nodeName===t,mA=(e,t)=>C(t)&&e.isBlock(t)&&!/^(TD|TH|CAPTION|FORM)$/.test(t.nodeName)&&!/^(fixed|absolute)/i.test(t.style.position)&&e.isEditable(t.parentNode)&&"false"!==e.getContentEditable(t),uA=(e,t,o)=>tr(t)?e?1===o&&t.data.charAt(o-1)===Br?0:o:o===t.data.length-1&&t.data.charAt(o)===Br?t.data.length:o:o,gA={insert:(e,t)=>{let o,n,r,s,a=!1;const i=e.dom,l=e.schema.getNonEmptyElements(),c=e.selection.getRng(),d=Xl(e),m=yo.fromDom(c.startContainer),u=Ho(m,c.startOffset),g=u.exists((e=>qt(e)&&!nn(e))),p=c.collapsed&&g,f=(t,n)=>QD(e,o,k,S,oc(e),t,n),v=e=>{const t=uA(e,o,n);if(tr(o)&&(e?t>0:t{let t;return t=/^(H[1-6]|PRE|FIGURE)$/.test(r)&&"HGROUP"!==_?f(d):f(),((e,t)=>{const o=nc(e);return!x(t)&&(h(o)?j(Bt.explode(o),t.nodeName.toLowerCase()):o)})(e,s)&&mA(i,s)&&i.isEmpty(k,void 0,{includeZwsp:!0})?t=i.split(s,k):i.insertAfter(t,k),GD(e,t),t};lh(i,c).each((e=>{c.setStart(e.startContainer,e.startOffset),c.setEnd(e.endContainer,e.endOffset)})),o=c.startContainer,n=c.startOffset;const y=!(!t||!t.shiftKey),w=!(!t||!t.ctrlKey);Wn(o)&&o.hasChildNodes()&&!p&&(a=n>o.childNodes.length-1,o=o.childNodes[Math.min(n,o.childNodes.length-1)]||o,n=a&&tr(o)?o.data.length:0);const S=KD(i,o);if(!S||((e,t)=>{const o=e.dom.getParent(t,"ol,ul,dl");return null!==o&&"false"===e.dom.getContentEditableParent(o)})(e,o))return;y||(o=((e,t,o,n,r)=>{var s,a;const i=e.dom,l=null!==(s=KD(i,n))&&void 0!==s?s:i.getRoot();let c=i.getParent(n,i.isBlock);if(!c||!mA(i,c)){if(c=c||l,!c.hasChildNodes()){const n=i.create(t);return JD(e,n),c.appendChild(n),o.setStart(n,0),o.setEnd(n,0),n}let s,d=n;for(;d&&d.parentNode!==c;)d=d.parentNode;for(;d&&!i.isBlock(d);)s=d,d=d.previousSibling;const m=null===(a=null==s?void 0:s.parentElement)||void 0===a?void 0:a.nodeName;if(s&&m&&e.schema.isValidChild(m,t.toLowerCase())){const a=s.parentNode,l=i.create(t);for(JD(e,l),a.insertBefore(l,s),d=s;d&&!i.isBlock(d);){const e=d.nextSibling;l.appendChild(d),d=e}o.setStart(n,r),o.setEnd(n,r)}}return n})(e,d,c,o,n));let k=i.getParent(o,i.isBlock)||i.getRoot();s=C(null==k?void 0:k.parentNode)?i.getParent(k.parentNode,i.isBlock):null,r=k?k.nodeName.toUpperCase():"";const _=s?s.nodeName.toUpperCase():"";if("LI"!==_||w||(k=s,s=s.parentNode,r=_),Wn(s)&&eA(e,y,k))return tA(e,f,k);if(/^(LI|DT|DD)$/.test(r)&&Wn(s)&&i.isEmpty(k))return void lA(e,f,s,k,d);if(!(p||k!==e.getBody()&&mA(i,k)))return;const E=k.parentNode;let T;if(p)T=f(d),u.fold((()=>{bn(m,yo.fromDom(T))}),(e=>{pn(e,yo.fromDom(T))})),e.selection.setCursorLocation(T,0);else if(Fr(k))T=qr(k),i.isEmpty(k)&&XD(k),JD(e,T),GD(e,T);else if(v(!1))T=b();else if(v(!0)&&E){T=E.insertBefore(f(),k);const t=yo.fromDom(c.startContainer).dom.hasChildNodes()&&c.collapsed;GD(e,dA(k,"HR")||t?T:k)}else{const t=(e=>{const t=e.cloneRange();return t.setStart(e.startContainer,uA(!0,e.startContainer,e.startOffset)),t.setEnd(e.endContainer,uA(!1,e.endContainer,e.endOffset)),t})(c).cloneRange();t.setEndAfter(k);const o=t.extractContents();(e=>{q(Fn(yo.fromDom(e),Kt),(e=>{const t=e.dom;t.nodeValue=Hr(t.data)}))})(o),(e=>{let t=e;do{tr(t)&&(t.data=t.data.replace(/^[\r\n]+/,"")),t=t.firstChild}while(t)})(o),T=o.firstChild,i.insertAfter(o,k),((e,t,o)=>{var n;const r=[];if(!o)return;let s=o;for(;s=s.firstChild;){if(e.isBlock(s))return;Wn(s)&&!t[s.nodeName.toLowerCase()]&&r.push(s)}let a=r.length;for(;a--;)s=r[a],(!s.hasChildNodes()||s.firstChild===s.lastChild&&""===(null===(n=s.firstChild)||void 0===n?void 0:n.nodeValue)||cA(e,s))&&e.remove(s)})(i,l,T),((e,t)=>{t.normalize();const o=t.lastChild;(!o||Wn(o)&&/^(left|right)$/gi.test(e.getStyle(o,"float",!0)))&&e.add(t,"br")})(i,k),i.isEmpty(k)&&XD(k),T.normalize(),i.isEmpty(T)?(i.remove(T),b()):(JD(e,T),GD(e,T))}i.setAttrib(T,"id",""),e.dispatch("NewBlock",{newBlock:T})},fakeEventName:"insertParagraph"},hA=(e,t,o)=>{const n=e.dom.createRng();o?(n.setStartBefore(t),n.setEndBefore(t)):(n.setStartAfter(t),n.setEndAfter(t)),e.selection.setRng(n),Rh(e,n)},pA=(e,t)=>{const o=e.selection,n=e.dom,r=o.getRng();let s,a=!1;lh(n,r).each((e=>{r.setStart(e.startContainer,e.startOffset),r.setEnd(e.endContainer,e.endOffset)}));let i=r.startOffset,l=r.startContainer;if(Wn(l)&&l.hasChildNodes()){const e=i>l.childNodes.length-1;l=l.childNodes[Math.min(i,l.childNodes.length-1)]||l,i=e&&tr(l)?l.data.length:0}let c=n.getParent(l,n.isBlock);const d=c&&c.parentNode?n.getParent(c.parentNode,n.isBlock):null,m=d?d.nodeName.toUpperCase():"",u=!(!t||!t.ctrlKey);"LI"!==m||u||(c=d),tr(l)&&i>=l.data.length&&(((e,t,o)=>{const n=new Zn(t,o);let r;const s=e.getNonEmptyElements();for(;r=n.next();)if(s[r.nodeName.toLowerCase()]||tr(r)&&r.length>0)return!0;return!1})(e.schema,l,c||n.getRoot())||(s=n.create("br"),r.insertNode(s),r.setStartAfter(s),r.setEndAfter(s),a=!0)),s=n.create("br"),al(n,r,s),hA(e,s,a),e.undoManager.add()},fA=(e,t)=>{const o=yo.fromTag("br");pn(yo.fromDom(t),o),e.undoManager.add()},vA=(e,t)=>{bA(e.getBody(),t)||fn(yo.fromDom(t),yo.fromTag("br"));const o=yo.fromTag("br");fn(yo.fromDom(t),o),hA(e,o.dom,!1),e.undoManager.add()},bA=(e,t)=>{return o=rl.after(t),!!ir(o.getNode())||$m(e,rl.after(t)).map((e=>ir(e.getNode()))).getOr(!1);var o},yA=e=>e&&"A"===e.nodeName&&"href"in e,wA=e=>e.fold(I,yA,yA,I),xA=(e,t)=>{t.fold(E,N(fA,e),N(vA,e),E)},CA={insert:(e,t)=>{const o=(e=>{const t=N(lv,e),o=rl.fromRangeStart(e.selection.getRng());return Yk(t,e.getBody(),o).filter(wA)})(e);o.isSome()?o.each(N(xA,e)):pA(e,t)},fakeEventName:"insertLineBreak"},SA=(e,t)=>YD(e).filter((e=>t.length>0&&xo(yo.fromDom(e),t))).isSome(),kA=Al([{br:[]},{block:[]},{none:[]}]),_A=(e,t)=>(e=>SA(e,tc(e)))(e),EA=e=>(t,o)=>(e=>YD(e).filter((e=>Tr(yo.fromDom(e)))).isSome())(t)===e,TA=(e,t)=>(o,n)=>{const r=(e=>YD(e).fold(D(""),(e=>e.nodeName.toUpperCase())))(o)===e.toUpperCase();return r===t},OA=e=>{const t=KD(e.dom,e.selection.getStart());return x(t)},DA=e=>TA("pre",e),AA=e=>(t,o)=>Yl(t)===e,MA=(e,t)=>(e=>SA(e,ec(e)))(e),NA=(e,t)=>t,RA=e=>{const t=Xl(e),o=KD(e.dom,e.selection.getStart());return C(o)&&e.schema.isValidChild(o.nodeName,t)},BA=e=>{const t=e.selection.getRng(),o=yo.fromDom(t.startContainer),n=Ho(o,t.startOffset).map((e=>qt(e)&&!nn(e)));return t.collapsed&&n.getOr(!0)},LA=(e,t)=>(o,n)=>J(e,((e,t)=>e&&t(o,n)),!0)?F.some(t):F.none(),HA=(e,t,o)=>{t.selection.isCollapsed()||(e=>{e.execCommand("delete")})(t),C(o)&&ZD(t,e.fakeEventName).isDefaultPrevented()||(e.insert(t,o),C(o)&&VD(t,e.fakeEventName))},IA=(e,t)=>{const o=()=>HA(CA,e,t),n=()=>HA(gA,e,t),r=((e,t)=>zk([LA([_A],kA.none()),LA([DA(!0),OA],kA.none()),LA([TA("summary",!0)],kA.br()),LA([DA(!0),AA(!1),NA],kA.br()),LA([DA(!0),AA(!1)],kA.block()),LA([DA(!0),AA(!0),NA],kA.block()),LA([DA(!0),AA(!0)],kA.br()),LA([EA(!0),NA],kA.br()),LA([EA(!0)],kA.block()),LA([MA],kA.br()),LA([NA],kA.br()),LA([RA],kA.block()),LA([BA],kA.block())],[e,!(!t||!t.shiftKey)]).getOr(kA.none()))(e,t);switch(Ql(e)){case"linebreak":r.fold(o,o,E);break;case"block":r.fold(n,n,E);break;case"invert":r.fold(n,o,E);break;default:r.fold(o,n,E)}},PA=St(),FA=PA.os.isiOS()&&PA.browser.isSafari(),zA=(e,t)=>{var o;t.isDefaultPrevented()||(t.preventDefault(),(o=e.undoManager).typing&&(o.typing=!1,o.add()),e.undoManager.transact((()=>{IA(e,t)})))},VA=e=>{let t=F.none();e.on("keydown",(o=>{o.keyCode===Dg.ENTER&&(FA&&(e=>{if(!e.collapsed)return!1;const t=e.startContainer;if(tr(t)){const o=/^[\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]$/,n=t.data.charAt(e.startOffset-1);return o.test(n)}return!1})(e.selection.getRng())?(e=>{t=F.some(e.selection.getBookmark()),e.undoManager.add()})(e):zA(e,o))})),e.on("keyup",(o=>{o.keyCode===Dg.ENTER&&t.each((()=>((e,o)=>{e.undoManager.undo(),t.fold(E,(t=>e.selection.moveToBookmark(t))),zA(e,o),t=F.none()})(e,o)))}))},ZA=(e,t)=>{e.on("keydown",(o=>{o.isDefaultPrevented()||((e,t,o)=>{const n=At.os.isMacOS()||At.os.isiOS();lT([{keyCode:Dg.END,action:iT(YE,e,!0)},{keyCode:Dg.HOME,action:iT(YE,e,!1)},...n?[]:[{keyCode:Dg.HOME,action:iT(XE,e,!1),ctrlKey:!0,shiftKey:!0},{keyCode:Dg.END,action:iT(XE,e,!0),ctrlKey:!0,shiftKey:!0}],{keyCode:Dg.END,action:iT(uT,e,!0)},{keyCode:Dg.HOME,action:iT(uT,e,!1)},{keyCode:Dg.END,action:iT(J_,e,!0,t)},{keyCode:Dg.HOME,action:iT(J_,e,!1,t)}],o).each((e=>{o.preventDefault()}))})(e,t,o)}))},UA=e=>{e.on("input",(t=>{t.isComposing||(e=>{const t=yo.fromDom(e.getBody());e.selection.isCollapsed()&&$f(t,rl.fromRangeStart(e.selection.getRng()),e.schema).each((t=>{e.selection.setRng(t.toRange())}))})(e)}))},jA=St(),WA=e=>e.stopImmediatePropagation(),$A=e=>e.keyCode===Dg.PAGE_UP||e.keyCode===Dg.PAGE_DOWN,qA=(e,t,o)=>{o&&!e.get()?t.on("NodeChange",WA,!0):!o&&e.get()&&t.off("NodeChange",WA),e.set(o)},GA=(e,t)=>{if(jA.os.isMacOS())return;const o=Qa(!1);e.on("keydown",(t=>{$A(t)&&qA(o,e,!0)})),e.on("keyup",(n=>{n.isDefaultPrevented()||((e,t,o)=>{lT([{keyCode:Dg.PAGE_UP,action:iT(J_,e,!1,t)},{keyCode:Dg.PAGE_DOWN,action:iT(J_,e,!0,t)}],o)})(e,t,n),$A(n)&&o.get()&&(qA(o,e,!1),e.nodeChanged())}))},KA=(e,t)=>{const o=t.container(),n=t.offset();return tr(o)?(o.insertData(n,e),F.some(rl(o,n+e.length))):Sm(t).map((o=>{const n=yo.fromText(e);return t.isAtEnd()?fn(o,n):pn(o,n),rl(n.dom,e.length)}))},YA=N(KA,br),XA=N(KA," "),JA=e=>t=>{e.selection.setRng(t.toRange()),e.nodeChanged()},QA=e=>{const t=rl.fromRangeStart(e.selection.getRng()),o=yo.fromDom(e.getBody());if(e.selection.isCollapsed()){const n=N(lv,e),r=rl.fromRangeStart(e.selection.getRng());return Yk(n,e.getBody(),r).bind((e=>t=>t.fold((t=>qm(e.dom,rl.before(t))),(e=>Gm(e)),(e=>Km(e)),(t=>$m(e.dom,rl.after(t)))))(o)).map((n=>()=>((e,t,o)=>n=>If(e,n,o)?YA(t):XA(t))(o,t,e.schema)(n).each(JA(e))))}return F.none()},eM=e=>{return Pt(At.browser.isFirefox()&&e.selection.isEditable()&&(t=e.dom,o=e.selection.getRng().startContainer,t.isEditable(t.getParent(o,"summary"))),(()=>{const t=yo.fromDom(e.getBody());e.selection.isCollapsed()||e.getDoc().execCommand("Delete"),((e,t,o)=>If(e,t,o)?YA(t):XA(t))(t,rl.fromRangeStart(e.selection.getRng()),e.schema).each(JA(e))}));var t,o},tM=e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{cT([{keyCode:Dg.SPACEBAR,action:iT(QA,e)},{keyCode:Dg.SPACEBAR,action:iT(eM,e)}],t).each((o=>{t.preventDefault(),ZD(e,"insertText",{data:" "}).isDefaultPrevented()||(o(),VD(e,"insertText",{data:" "}))}))})(e,t)}))},oM=e=>Ad(e)?[{keyCode:Dg.TAB,action:iT(FT,e,!0)},{keyCode:Dg.TAB,shiftKey:!0,action:iT(FT,e,!1)}]:[],nM=e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{lT([...oM(e)],t).each((e=>{t.preventDefault()}))})(e,t)}))},rM=e=>{if(e.addShortcut("Meta+P","","mcePrint"),_D(e),fC(e))return Qa(null);{const t=K_(e);return(e=>{e.on("beforeinput",(t=>{e.selection.isEditable()&&!W(t.getTargetRanges(),(t=>!dp(e.dom,t)))||t.preventDefault()}))})(e),(e=>{e.on("keyup compositionstart",N(UE,e))})(e),zT(e,t),qD(e,t),VA(e),tM(e),UA(e),nM(e),ZA(e,t),GA(e,t),t}};class sM{constructor(e){let t;this.lastPath=[],this.editor=e;const o=this;"onselectionchange"in e.getDoc()||e.on("NodeChange click mouseup keyup focus",(o=>{const n=e.selection.getRng(),r={startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset};"nodechange"!==o.type&&th(r,t)||e.dispatch("SelectionChange"),t=r})),e.on("contextmenu",(()=>{e.dispatch("SelectionChange")})),e.on("SelectionChange",(()=>{const t=e.selection.getStart(!0);t&&_u(e)&&!o.isSameElementPath(t)&&e.dom.isChildOf(t,e.getBody())&&e.nodeChanged({selectionChange:!0})})),e.on("mouseup",(t=>{!t.isDefaultPrevented()&&_u(e)&&("IMG"===e.selection.getNode().nodeName?qh.setEditorTimeout(e,(()=>{e.nodeChanged()})):e.nodeChanged())}))}nodeChanged(e={}){const t=this.editor.selection;let o;if(this.editor.initialized&&t&&!Wc(this.editor)&&!this.editor.mode.isReadOnly()){const n=this.editor.getBody();o=t.getStart(!0)||n,o.ownerDocument===this.editor.getDoc()&&this.editor.dom.isChildOf(o,n)||(o=n);const r=[];this.editor.dom.getParent(o,(e=>e===n||(r.push(e),!1))),this.editor.dispatch("NodeChange",{...e,element:o,parents:r})}}isSameElementPath(e){let t;const o=this.editor,n=se(o.dom.getParents(e,P,o.getBody()));if(n.length===this.lastPath.length){for(t=n.length;t>=0&&n[t]===this.lastPath[t];t--);if(-1===t)return this.lastPath=n,!0}return this.lastPath=n,!1}}const aM=Ci("image"),iM=Ci("event"),lM=e=>t=>{t[iM]=e},cM=lM(0),dM=lM(2),mM=lM(1),uM=(gM=0,e=>{const t=e;return F.from(t[iM]).exists((e=>e===gM))});var gM;const hM=Ci("mode"),pM=e=>t=>{t[hM]=e},fM=(e,t)=>pM(t)(e),vM=pM(0),bM=pM(2),yM=pM(1),wM=e=>t=>{const o=t;return F.from(o[hM]).exists((t=>t===e))},xM=wM(0),CM=wM(1),SM=["none","copy","link","move"],kM=["none","copy","copyLink","copyMove","link","linkMove","move","all","uninitialized"],_M=()=>{const e=new window.DataTransfer;let t="move",o="all";const n={get dropEffect(){return t},set dropEffect(e){j(SM,e)&&(t=e)},get effectAllowed(){return o},set effectAllowed(e){uM(n)&&j(kM,e)&&(o=e)},get items(){return((e,t)=>({...t,get length(){return t.length},add:(o,n)=>{if(xM(e)){if(!h(o))return t.add(o);if(!w(n))return t.add(o,n)}return null},remove:o=>{xM(e)&&t.remove(o)},clear:()=>{xM(e)&&t.clear()}}))(n,e.items)},get files(){return CM(n)?Object.freeze({length:0,item:e=>null}):e.files},get types(){return e.types},setDragImage:(t,o,r)=>{var s;xM(n)&&(s={image:t,x:o,y:r},n[aM]=s,e.setDragImage(t,o,r))},getData:t=>CM(n)?"":e.getData(t),setData:(t,o)=>{xM(n)&&e.setData(t,o)},clearData:t=>{xM(n)&&e.clearData(t)}};return vM(n),n},EM=e=>{const t=_M(),o=(e=>{const t=e;return F.from(t[hM])})(e);return bM(e),cM(t),t.dropEffect=e.dropEffect,t.effectAllowed=e.effectAllowed,(e=>{const t=e;return F.from(t[aM])})(e).each((e=>t.setDragImage(e.image,e.x,e.y))),q(e.types,(o=>{"Files"!==o&&t.setData(o,e.getData(o))})),q(e.files,(e=>t.items.add(e))),(e=>{const t=e;return F.from(t[iM])})(e).each((e=>{((e,t)=>{lM(t)(e)})(t,e)})),o.each((o=>{fM(e,o),fM(t,o)})),t},TM=(e,t)=>e.setData("text/html",t),OM="x-tinymce/html",DM=D(OM),AM="\x3c!-- "+OM+" --\x3e",MM=e=>AM+e,NM=e=>-1!==e.indexOf(AM),RM=(e,t,o)=>{const n=e.split(/\n\n/),r=((e,t)=>{let o="<"+e;const n=Ce(t,((e,t)=>t+'="'+ia.encodeAllRaw(e)+'"'));return n.length&&(o+=" "+n.join(" ")),o+">"})(t,o),s="",a=$(n,(e=>e.split(/\n/).join("
    ")));return 1===a.length?a[0]:$(a,(e=>r+e+s)).join("")},BM="%MCEPASTEBIN%",LM=e=>e.dom.get("mcepastebin"),HM=e=>C(e)&&"mcepastebin"===e.id,IM=e=>e===BM,PM=e=>{const t=Qa(null);return{create:()=>((e,t)=>{const{dom:o,selection:n}=e,r=e.getBody();t.set(n.getRng());const s=o.add(e.getBody(),"div",{id:"mcepastebin",class:"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},BM);At.browser.isFirefox()&&o.setStyle(s,"left","rtl"===o.getStyle(r,"direction",!0)?65535:-65535),o.bind(s,"beforedeactivate focusin focusout",(e=>{e.stopPropagation()})),s.focus(),n.select(s,!0)})(e,t),remove:()=>((e,t)=>{const o=e.dom;if(LM(e)){let n;const r=t.get();for(;n=LM(e);)o.remove(n),o.unbind(n);r&&e.selection.setRng(r)}t.set(null)})(e,t),getEl:()=>LM(e),getHtml:()=>(e=>{const t=e.dom,o=(e,o)=>{e.appendChild(o),t.remove(o,!0)},[n,...r]=Y(e.getBody().childNodes,HM);q(r,(e=>{o(n,e)}));const s=t.select("div[id=mcepastebin]",n);for(let e=s.length-1;e>=0;e--){const r=t.create("div");n.insertBefore(r,s[e]),o(r,s[e])}return n?n.innerHTML:""})(e),getLastRng:t.get}},FM=(e,t)=>(Bt.each(t,(t=>{e=g(t,RegExp)?e.replace(t,""):e.replace(t[0],t[1])})),e),zM=e=>e=FM(e,[/^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/|/g,[/( ?)\u00a0<\/span>( ?)/g,(e,t,o)=>t||o?br:" "],/
    /g,/
    $/i]),VM=(e,t)=>({content:e,cancelled:t}),ZM=(e,t,o)=>{const n=((e,t,o)=>e.dispatch("PastePreProcess",{content:t,internal:o}))(e,t,o),r=((e,t)=>{const o=Mx({sanitize:Td(e),sandbox_iframes:Bd(e)},e.schema);o.addNodeFilter("meta",(e=>{Bt.each(e,(e=>{e.remove()}))}));const n=o.parse(t,{forced_root_block:!1,isRootContent:!0});return $p({validate:!0},e.schema).serialize(n)})(e,n.content);return e.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()?((e,t,o)=>{const n=e.dom.create("div",{style:"display:none"},t),r=((e,t,o)=>e.dispatch("PastePostProcess",{node:t,internal:o}))(e,n,o);return VM(r.node.innerHTML,r.isDefaultPrevented())})(e,r,o):VM(r,n.isDefaultPrevented())},UM=(e,t)=>(e.insertContent(t,{merge:pd(e),paste:!0}),!0),jM=e=>/^https?:\/\/[\w\-\/+=.,!;:&%@^~(){}?#]+$/i.test(e),WM=(e,t,o)=>!(e.selection.isCollapsed()||!jM(t))&&((e,t,o)=>(e.undoManager.extra((()=>{o(e,t)}),(()=>{e.execCommand("mceInsertLink",!1,t)})),!0))(e,t,o),$M=(e,t,o)=>!!((e,t)=>jM(t)&&W(Dd(e),(e=>We(t.toLowerCase(),`.${e.toLowerCase()}`))))(e,t)&&((e,t,o)=>(e.undoManager.extra((()=>{o(e,t)}),(()=>{e.insertContent('')})),!0))(e,t,o),qM=(e,t,o)=>{o||!fd(e)?UM(e,t):((e,t)=>{Bt.each([WM,$M,UM],(o=>!o(e,t,UM)))})(e,t)},GM=(e=>{let t=0;return()=>e+t++})("mceclip"),KM=e=>{const t=_M();return TM(t,e),bM(t),t},YM=(e,t,o,n,r)=>{const s=((e,t,o)=>ZM(e,t,o))(e,t,o);if(!s.cancelled){const t=s.content,o=()=>qM(e,t,n);r?ZD(e,"insertFromPaste",{dataTransfer:KM(t)}).isDefaultPrevented()||(o(),VD(e,"insertFromPaste")):o()}},XM=(e,t,o,n)=>{const r=o||NM(t);YM(e,(e=>e.replace(AM,""))(t),r,!1,n)},JM=(e,t,o)=>{const n=e.dom.encode(t).replace(/\r\n/g,"\n"),r=ds(n,bd(e)),s=RM(r,Xl(e),Jl(e));YM(e,s,!1,!0,o)},QM=e=>{const t={};if(e&&e.types)for(let o=0;ot in e&&e[t].length>0,tN=e=>eN(e,"text/html")||eN(e,"text/plain"),oN=(e,t,o,n)=>{const r=GM(),s=sc(e)&&C(o.name),a=s?((e,t)=>{const o=t.match(/([\s\S]+?)(?:\.[a-z0-9.]+)$/i);return C(o)?e.dom.encode(o[1]):void 0})(e,o.name):r,i=s?o.name:void 0,l=t.create(r,o,n,a,i);return t.add(l),l},nN=e=>{const t=Dd(e);return e=>je(e.type,"image/")&&W(t,(t=>(e=>{const t=e.toLowerCase(),o={jpg:"jpeg",jpe:"jpeg",jfi:"jpeg",jif:"jpeg",jfif:"jpeg",pjpeg:"jpeg",pjp:"jpeg",svg:"svg+xml"};return Bt.hasOwn(o,t)?"image/"+o[t]:"image/"+t})(t)===e.type))},rN=(e,t,o)=>{const n="paste"===t.type?t.clipboardData:t.dataTransfer;var r;if(cd(e)&&n){const s=((e,t)=>{const o=t.items?ne(ue(t.items),(e=>"file"===e.kind?[e.getAsFile()]:[])):[],n=t.files?ue(t.files):[];return Y(o.length>0?o:n,nN(e))})(e,n);if(s.length>0)return t.preventDefault(),(r=s,Promise.all($(r,(e=>aw(e).then((t=>({file:e,uri:t}))))))).then((t=>{o&&e.selection.setRng(o),q(t,(t=>{((e,t)=>{nw(t.uri).each((({data:o,type:n,base64Encoded:r})=>{const s=r?o:btoa(o),a=t.file,i=e.editorUpload.blobCache,l=i.getByData(s,n),c=null!=l?l:oN(e,i,a,s);XM(e,``,!1,!0)}))})(e,t)}))})),!0}return!1},sN=(e,t,o,n,r)=>{let s=zM(o);const a=eN(t,DM())||NM(o),i=!a&&(e=>!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e))(s),l=jM(s);(IM(s)||!s.length||i&&!l)&&(n=!0),(n||l)&&(s=eN(t,"text/plain")&&i?t["text/plain"]:(e=>{const t=ya(),o=Mx({},t);let n="";const r=t.getVoidElements(),s=Bt.makeMap("script noscript style textarea video audio iframe object"," "),a=t.getBlockElements(),i=e=>{const o=e.name,l=e;if("br"!==o){if("wbr"!==o)if(r[o]&&(n+=" "),s[o])n+=" ";else{if(3===e.type&&(n+=e.value),!(e.name in t.getVoidElements())){let t=e.firstChild;if(t)do{i(t)}while(t=t.next)}a[o]&&l.next&&(n+="\n","p"===o&&(n+="\n"))}}else n+="\n"};return e=FM(e,[//g]),i(o.parse(e)),n})(s)),IM(s)||(n?JM(e,s,r):XM(e,s,a,r))},aN=(e,t,o)=>{let n;e.on("keydown",(e=>{(e=>Dg.metaKeyPressed(e)&&86===e.keyCode||e.shiftKey&&45===e.keyCode)(e)&&!e.isDefaultPrevented()&&(n=e.shiftKey&&86===e.keyCode)})),e.on("paste",(r=>{if(r.isDefaultPrevented()||(e=>{var t,o;return At.os.isAndroid()&&0===(null===(o=null===(t=e.clipboardData)||void 0===t?void 0:t.items)||void 0===o?void 0:o.length)})(r))return;const s="text"===o.get()||n;n=!1;const a=QM(r.clipboardData);!tN(a)&&rN(e,r,t.getLastRng()||e.selection.getRng())||(eN(a,"text/html")?(r.preventDefault(),sN(e,a,a["text/html"],s,!0)):eN(a,"text/plain")&&eN(a,"text/uri-list")?(r.preventDefault(),sN(e,a,a["text/plain"],s,!0)):(t.create(),qh.setEditorTimeout(e,(()=>{const o=t.getHtml();t.remove(),sN(e,a,o,s,!1)}),0)))}))},iN=(e,t,o)=>{aN(e,t,o),(e=>{const t=e=>je(e,"webkit-fake-url"),o=e=>je(e,"data:");e.parser.addNodeFilter("img",((n,r,s)=>{if(!cd(e)&&(e=>{var t;return!0===(null===(t=e.data)||void 0===t?void 0:t.paste)})(s))for(const r of n){const n=r.attr("src");h(n)&&!r.attr("data-mce-object")&&n!==At.transparentSrc&&(t(n)||!yd(e)&&o(n))&&r.remove()}}))})(e)},lN=(e,t)=>{e.addCommand("mceTogglePlainTextPaste",(()=>{((e,t)=>{"text"===t.get()?(t.set("html"),Og(e,!1)):(t.set("text"),Og(e,!0)),e.focus()})(e,t)})),e.addCommand("mceInsertClipboardContent",((t,o)=>{o.html&&XM(e,o.html,o.internal,!1),o.text&&JM(e,o.text,!1)}))},cN=(e,t,o,n)=>{((e,t,o)=>{if(!e)return!1;try{return e.clearData(),e.setData("text/html",t),e.setData("text/plain",o),e.setData(DM(),t),!0}catch(e){return!1}})(e.clipboardData,t.html,t.text)?(e.preventDefault(),n()):o(t.html,n)},dN=e=>(t,o)=>{const{dom:n,selection:r}=e,s=n.create("div",{contenteditable:"false","data-mce-bogus":"all"}),a=n.create("div",{contenteditable:"true"},t);n.setStyles(s,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),s.appendChild(a),n.add(e.getBody(),s);const i=r.getRng();a.focus();const l=n.createRng();l.selectNodeContents(a),r.setRng(l),qh.setEditorTimeout(e,(()=>{r.setRng(i),n.remove(s),o()}),0)},mN=e=>({html:MM(e.selection.getContent({contextual:!0})),text:e.selection.getContent({format:"text"})}),uN=e=>!e.selection.isCollapsed()||(e=>!!e.dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody()))(e),gN=e=>{e.on("cut",(e=>t=>{!t.isDefaultPrevented()&&uN(e)&&e.selection.isEditable()&&cN(t,mN(e),dN(e),(()=>{if(At.browser.isChromium()||At.browser.isFirefox()){const t=e.selection.getRng();qh.setEditorTimeout(e,(()=>{e.selection.setRng(t),e.execCommand("Delete")}),0)}else e.execCommand("Delete")}))})(e)),e.on("copy",(e=>t=>{!t.isDefaultPrevented()&&uN(e)&&cN(t,mN(e),dN(e),E)})(e))},hN=(e,t)=>{var o,n;return mh.getCaretRangeFromPoint(null!==(o=t.clientX)&&void 0!==o?o:0,null!==(n=t.clientY)&&void 0!==n?n:0,e.getDoc())},pN=(e,t)=>{e.focus(),t&&e.selection.setRng(t)},fN=(e,t)=>{ld(e)&&e.on("dragend dragover draggesture dragdrop drop drag",(e=>{e.preventDefault(),e.stopPropagation()})),cd(e)||e.on("drop",(e=>{const t=e.dataTransfer;t&&(e=>W(e.files,(e=>/^image\//.test(e.type))))(t)&&e.preventDefault()})),e.on("drop",(o=>{if(o.isDefaultPrevented())return;const n=hN(e,o);if(x(n))return;const r=QM(o.dataTransfer),s=eN(r,DM());if((!tN(r)||(e=>{const t=e["text/plain"];return!!t&&0===t.indexOf("file://")})(r))&&rN(e,o,n))return;const a=r[DM()],i=a||r["text/html"]||r["text/plain"],l=((e,t,o,n)=>{const r=e.getParent(o,(e=>Ls(t,e)));if(!b(e.getParent(o,"summary")))return!0;if(r&&_e(n,"text/html")){const e=(new DOMParser).parseFromString(n["text/html"],"text/html").body;return!b(e.querySelector(r.nodeName.toLowerCase()))}return!1})(e.dom,e.schema,n.startContainer,r),c=t.get();c&&!l||i&&(o.preventDefault(),qh.setEditorTimeout(e,(()=>{e.undoManager.transact((()=>{(a||c&&l)&&e.execCommand("Delete"),pN(e,n);const t=zM(i);r["text/html"]?XM(e,t,s,!0):JM(e,t,!0)}))})))})),e.on("dragstart",(e=>{t.set(!0)})),e.on("dragover dragend",(o=>{cd(e)&&!t.get()&&(o.preventDefault(),pN(e,hN(e,o))),"dragend"===o.type&&t.set(!1)})),(e=>{e.on("input",(t=>{const o=e=>b(e.querySelector("summary"));if("deleteByDrag"===t.inputType){const t=Y(e.dom.select("details"),o);q(t,(t=>{ir(t.firstChild)&&t.firstChild.remove();const o=e.dom.create("summary");o.appendChild(Nr().dom),t.prepend(o)}))}}))})(e)},vN=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,bN=e=>Bt.trim(e).replace(vN,Da).toLowerCase(),yN=(e,t,o)=>{const n=gd(e);if(o||"all"===n||!hd(e))return t;const r=n?n.split(/[, ]/):[];if(r&&"none"!==n){const o=e.dom,n=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,((e,t,s,a)=>{const i=o.parseStyle(o.decode(s)),l={};for(let e=0;e]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,((e,t,o,n)=>t+' style="'+o+'"'+n)),t},wN=e=>{const t=Qa(!1),o=Qa(vd(e)?"text":"html"),n=PM(e);(e=>{(At.browser.isChromium()||At.browser.isSafari())&&((e,t)=>{e.on("PastePreProcess",(o=>{o.content=t(e,o.content,o.internal)}))})(e,yN)})(e),lN(e,o),(e=>{const t=t=>o=>{t(e,o)},o=dd(e);S(o)&&e.on("PastePreProcess",t(o));const n=md(e);S(n)&&e.on("PastePostProcess",t(n))})(e),e.on("PreInit",(()=>{gN(e),fN(e,t),iN(e,n,o)}))},xN=e=>{(e=>{e.on("click",(t=>{e.dom.getParent(t.target,"details")&&t.preventDefault()}))})(e),(e=>{e.parser.addNodeFilter("details",(t=>{const o=Md(e);q(t,(e=>{"expanded"===o?e.attr("open","open"):"collapsed"===o&&e.attr("open",null)}))})),e.serializer.addNodeFilter("details",(t=>{const o=Nd(e);q(t,(e=>{"expanded"===o?e.attr("open","open"):"collapsed"===o&&e.attr("open",null)}))}))})(e)},CN=ir,SN=tr,kN=e=>dr(e.dom),_N=e=>t=>So(yo.fromDom(e),t),EN=(e,t,o)=>Xo(yo.fromDom(e),(e=>(e=>cr(e.dom))(e)||o.isBlock(jt(e))),_N(t)).getOr(yo.fromDom(t)).dom,TN=(e,t)=>Xo(yo.fromDom(e),kN,_N(t)),ON=(e,t,o)=>{const n=new Zn(e,t),r=o?n.next.bind(n):n.prev.bind(n);let s=e;for(let t=o?e:r();t&&!CN(t);t=r())ns(t)&&(s=t);return s},DN=e=>{const t=((e,t,o)=>{const n=rl.fromRangeStart(e).getNode(),r=EN(n,t,o),s=ON(n,r,!1),a=ON(n,r,!0),i=document.createRange();return TN(s,r).fold((()=>{SN(s)?i.setStart(s,0):i.setStartBefore(s)}),(e=>i.setStartBefore(e.dom))),TN(a,r).fold((()=>{SN(a)?i.setEnd(a,a.data.length):i.setEndAfter(a)}),(e=>i.setEndAfter(e.dom))),i})(e.selection.getRng(),e.getBody(),e.schema);e.selection.setRng(vb(t))};var AN;!function(e){e.Before="before",e.After="after"}(AN||(AN={}));const MN=(e,t)=>Math.abs(e.left-t),NN=(e,t)=>Math.abs(e.right-t),RN=(e,t)=>{const o=((e,t)=>Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)))(e,t)/Math.min(e.height,t.height);return((e,t)=>e.topt.top)(e,t)&&o>.5},BN=(e,t)=>(e=>J(e,((e,t)=>e.fold((()=>F.some(t)),(e=>{const o=Math.min(t.left,e.left),n=Math.min(t.top,e.top),r=Math.max(t.right,e.right),s=Math.max(t.bottom,e.bottom);return F.some({top:n,right:r,bottom:s,left:o,width:r-o,height:s-n})}))),F.none()))(Y(e,(e=>{return(o=t)>=(n=e).top&&o<=n.bottom;var o,n}))).fold((()=>[[],e]),(t=>{const{pass:o,fail:n}=K(e,(e=>RN(e,t)));return[o,n]})),LN=(e,t,o)=>t>e.left&&t{const r=e=>ns(e.node)?F.some(e):Wn(e.node)?HN(ue(e.node.childNodes),t,o,!1):F.none(),s=(e,s)=>{const a=le(e,((e,n)=>s(e,t,o)-s(n,t,o)));return ge(a,r).map((e=>n&&!tr(e.node)&&a.length>1?((e,n,s)=>r(n).filter((n=>Math.abs(s(e,t,o)-s(n,t,o))<2&&tr(n.node))))(e,a[1],s).getOr(e):e))},[a,i]=BN(O_(e),o),{pass:l,fail:c}=K(i,(e=>e.tops(c,Li))).orThunk((()=>s(l,Li)))},IN=(e,t,o)=>{const n=yo.fromDom(e),r=Eo(n),s=yo.fromPoint(r,t,o).filter((e=>ko(n,e))).getOr(n);return((e,t,o,n)=>{const r=(t,s)=>{const a=Y(t.dom.childNodes,R((e=>Wn(e)&&e.classList.contains("mce-drag-container"))));return s.fold((()=>HN(a,o,n,!0)),(e=>{const t=Y(a,(t=>t!==e.dom));return HN(t,o,n,!0)})).orThunk((()=>(So(t,e)?F.none():Do(t)).bind((e=>r(e,F.some(t))))))};return r(t,F.none())})(n,s,t,o)},PN=(e,t,o)=>IN(e,t,o).filter((e=>Jd(e.node))).map((e=>((e,t)=>({node:e.node,position:MN(e,t){var t,o;const n=e.getBoundingClientRect(),r=e.ownerDocument,s=r.documentElement,a=r.defaultView;return{top:n.top+(null!==(t=null==a?void 0:a.scrollY)&&void 0!==t?t:0)-s.clientTop,left:n.left+(null!==(o=null==a?void 0:a.scrollX)&&void 0!==o?o:0)-s.clientLeft}},zN=(e,t)=>{return o=(e=>e.inline?FN(e.getBody()):{left:0,top:0})(e),n=(e=>{const t=e.getBody();return e.inline?{left:t.scrollLeft,top:t.scrollTop}:{left:0,top:0}})(e),r=((e,t)=>{if(t.target.ownerDocument!==e.getDoc()){const o=FN(e.getContentAreaContainer()),n=(e=>{const t=e.getBody(),o=e.getDoc().documentElement,n={left:t.scrollLeft,top:t.scrollTop},r={left:t.scrollLeft||o.scrollLeft,top:t.scrollTop||o.scrollTop};return e.inline?n:r})(e);return{left:t.pageX-o.left+n.left,top:t.pageY-o.top+n.top}}return{left:t.pageX,top:t.pageY}})(e,t),{pageX:r.left-o.left+n.left,pageY:r.top-o.top+n.top};var o,n,r},VN=e=>({target:e,srcElement:e}),ZN=(e,t,o,n)=>{const r=((e,t)=>{const o=EM(e);return"dragstart"===t?(cM(o),vM(o)):"drop"===t?(dM(o),bM(o)):(mM(o),yM(o)),o})(o,e);return w(n)?((e,t,o)=>{const n=B("Function not supported on simulated event.");return{bubbles:!0,cancelBubble:!1,cancelable:!0,composed:!1,currentTarget:null,defaultPrevented:!1,eventPhase:0,isTrusted:!0,returnValue:!1,timeStamp:0,type:e,composedPath:n,initEvent:n,preventDefault:E,stopImmediatePropagation:E,stopPropagation:E,AT_TARGET:window.Event.AT_TARGET,BUBBLING_PHASE:window.Event.BUBBLING_PHASE,CAPTURING_PHASE:window.Event.CAPTURING_PHASE,NONE:window.Event.NONE,altKey:!1,button:0,buttons:0,clientX:0,clientY:0,ctrlKey:!1,metaKey:!1,movementX:0,movementY:0,offsetX:0,offsetY:0,pageX:0,pageY:0,relatedTarget:null,screenX:0,screenY:0,shiftKey:!1,x:0,y:0,detail:0,view:null,which:0,initUIEvent:n,initMouseEvent:n,getModifierState:n,dataTransfer:o,...VN(t)}})(e,t,r):((e,t,o,n)=>({...t,dataTransfer:n,type:e,...VN(o)}))(e,n,t,r)},UN=dr,jN=((...e)=>t=>{for(let o=0;o{const r=e.dom,s=t.cloneNode(!0);r.setStyles(s,{width:o,height:n}),r.setAttrib(s,"data-mce-selected",null);const a=r.create("div",{class:"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return r.setStyles(a,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:o,height:n}),r.setStyles(s,{margin:0,boxSizing:"border-box"}),a.appendChild(s),a},$N=(e,t)=>o=>()=>{const n="left"===e?o.scrollX:o.scrollY;o.scroll({[e]:n+t,behavior:"smooth"})},qN=$N("left",-32),GN=$N("left",32),KN=$N("top",-32),YN=$N("top",32),XN=e=>{e&&e.parentNode&&e.parentNode.removeChild(e)},JN=(e,t)=>o=>{if((e=>0===e.button)(o)){const n=ee(t.dom.getParents(o.target),jN).getOr(null);if(C(n)&&((e,t,o)=>UN(o)&&o!==t&&e.isEditable(o.parentElement))(t.dom,t.getBody(),n)){const r=t.dom.getPos(n),s=t.getBody(),a=t.getDoc().documentElement;e.set({element:n,dataTransfer:_M(),dragging:!1,screenX:o.screenX,screenY:o.screenY,maxX:(t.inline?s.scrollWidth:a.offsetWidth)-2,maxY:(t.inline?s.scrollHeight:a.offsetHeight)-2,relX:o.pageX-r.x,relY:o.pageY-r.y,width:n.offsetWidth,height:n.offsetHeight,ghost:WN(t,n,n.offsetWidth,n.offsetHeight),intervalId:si(100)})}}},QN=(e,t,o,n,r)=>{"dragstart"===t&&TM(n,e.dom.getOuterHTML(o));const s=ZN(t,o,n,r);return e.dispatch(t,s)},eR=(e,t)=>{const o=ii(((e,o)=>((e,t,o)=>{e._selectionOverrides.hideFakeCaret(),PN(e.getBody(),t,o).fold((()=>e.selection.placeCaretAt(t,o)),(n=>{const r=e._selectionOverrides.showCaret(1,n.node,n.position===AN.Before,!1);r?e.selection.setRng(r):e.selection.placeCaretAt(t,o)}))})(t,e,o)),0);t.on("remove",o.cancel);const n=e;return r=>e.on((e=>{const s=Math.max(Math.abs(r.screenX-e.screenX),Math.abs(r.screenY-e.screenY));if(!e.dragging&&s>10){const o=QN(t,"dragstart",e.element,e.dataTransfer,r);if(C(o.dataTransfer)&&(e.dataTransfer=o.dataTransfer),o.isDefaultPrevented())return;e.dragging=!0,t.focus()}if(e.dragging){const s=r.currentTarget===t.getDoc().documentElement,l=((e,t)=>({pageX:t.pageX-e.relX,pageY:t.pageY+5}))(e,zN(t,r));a=e.ghost,i=t.getBody(),a.parentNode!==i&&i.appendChild(a),((e,t,o,n,r,s,a,i,l,c,d,m)=>{let u=0,g=0;e.style.left=t.pageX+"px",e.style.top=t.pageY+"px",t.pageX+o>r&&(u=t.pageX+o-r),t.pageY+n>s&&(g=t.pageY+n-s),e.style.width=o-u+"px",e.style.height=n-g+"px";const h=l.clientHeight,p=l.clientWidth,f=a+l.getBoundingClientRect().top,v=i+l.getBoundingClientRect().left;d.on((e=>{e.intervalId.clear(),e.dragging&&m&&(a+8>=h?e.intervalId.set(YN(c)):a-8<=0?e.intervalId.set(KN(c)):i+8>=p?e.intervalId.set(GN(c)):i-8<=0?e.intervalId.set(qN(c)):f+16>=window.innerHeight?e.intervalId.set(YN(window)):f-16<=0?e.intervalId.set(KN(window)):v+16>=window.innerWidth?e.intervalId.set(GN(window)):v-16<=0&&e.intervalId.set(qN(window)))}))})(e.ghost,l,e.width,e.height,e.maxX,e.maxY,r.clientY,r.clientX,t.getContentAreaContainer(),t.getWin(),n,s),o.throttle(r.clientX,r.clientY)}var a,i}))},tR=(e,t)=>o=>{e.on((e=>{var n;if(e.intervalId.clear(),e.dragging){if(((e,t,o)=>!x(t)&&t!==o&&!e.dom.isChildOf(t,o)&&e.dom.isEditable(t))(t,(e=>{const t=e.getSel();if(C(t)){const e=t.getRangeAt(0).startContainer;return tr(e)?e.parentNode:e}return null})(t.selection),e.element)){const r=null!==(n=t.getDoc().elementFromPoint(o.clientX,o.clientY))&&void 0!==n?n:t.getBody();QN(t,"drop",r,e.dataTransfer,o).isDefaultPrevented()||t.undoManager.transact((()=>{((e,t)=>{const o=e.getParent(t.parentNode,e.isBlock);XN(t),o&&o!==e.getRoot()&&e.isEmpty(o)&&Rr(yo.fromDom(o))})(t.dom,e.element),(e=>{const t=e.getData("text/html");return""===t?F.none():F.some(t)})(e.dataTransfer).each((e=>t.insertContent(e))),t._selectionOverrides.hideFakeCaret()}))}QN(t,"dragend",t.getBody(),e.dataTransfer,o)}})),nR(e)},oR=(e,t,o)=>{e.on((e=>{e.intervalId.clear(),e.dragging&&o.fold((()=>QN(t,"dragend",e.element,e.dataTransfer)),(o=>QN(t,"dragend",e.element,e.dataTransfer,o)))})),nR(e)},nR=e=>{e.on((e=>{e.intervalId.clear(),XN(e.ghost)})),e.clear()},rR=e=>{const t=ai(),o=Ya.DOM,n=document,r=JN(t,e),s=eR(t,e),a=tR(t,e),i=((e,t)=>o=>oR(e,t,F.some(o)))(t,e);e.on("mousedown",r),e.on("mousemove",s),e.on("mouseup",a),o.bind(n,"mousemove",s),o.bind(n,"mouseup",i),e.on("remove",(()=>{o.unbind(n,"mousemove",s),o.unbind(n,"mouseup",i)})),e.on("keydown",(o=>{o.keyCode===Dg.ESC&&oR(t,e,F.none())}))},sR=e=>{rR(e),Xc(e)&&(e=>{const t=t=>{if(!t.isDefaultPrevented()){const o=t.dataTransfer;o&&(j(o.types,"Files")||o.files.length>0)&&(t.preventDefault(),"drop"===t.type&&gS(e,"Dropped file type is not supported"))}},o=o=>{Jh(e,o.target)&&t(o)},n=()=>{const n=Ya.DOM,r=e.dom,s=document,a=e.inline?e.getBody():e.getDoc(),i=["drop","dragover"];q(i,(e=>{n.bind(s,e,o),r.bind(a,e,t)})),e.on("remove",(()=>{q(i,(e=>{n.unbind(s,e,o),r.unbind(a,e,t)}))}))};e.on("init",(()=>{qh.setEditorTimeout(e,n,0)}))})(e)},aR=dr,iR=(e,t)=>tb(e.getBody(),t),lR=e=>{const t=e.selection,o=e.dom,n=e.getBody(),r=Kd(e,n,o.isBlock,(()=>ap(e))),s="sel-"+o.uniqueId(),a="data-mce-selected";let i;const l=e=>e!==n&&(aR(e)||gr(e))&&o.isChildOf(e,n)&&o.isEditable(e.parentNode),c=(o,n,s,a=!0)=>e.dispatch("ShowCaret",{target:n,direction:o,before:s}).isDefaultPrevented()?null:(a&&t.scrollIntoView(n,-1===o),r.show(s,n)),d=()=>{e.on("click",(t=>{o.isEditable(t.target)||(t.preventDefault(),e.focus())})),e.on("blur NewBlock",f),e.on("ResizeWindow FullscreenStateChanged",r.reposition),e.on("tap",(t=>{const o=t.target,n=iR(e,o);aR(n)?(t.preventDefault(),uk(e,n).each(p)):l(o)&&uk(e,o).each(p)}),!0),e.on("mousedown",(r=>{const s=r.target;if(s!==n&&"HTML"!==s.nodeName&&!o.isChildOf(s,n))return;if(!aS(e,r.clientX,r.clientY))return;f(),v();const a=iR(e,s);aR(a)?(r.preventDefault(),uk(e,a).each(p)):PN(n,r.clientX,r.clientY).each((o=>{r.preventDefault(),(e=>{e&&t.setRng(e)})(c(1,o.node,o.position===AN.Before,!1)),$n(a)?a.focus():e.getBody().focus()}))})),e.on("keypress",(e=>{Dg.modifierPressed(e)||aR(t.getNode())&&e.preventDefault()})),e.on("GetSelectionRange",(e=>{let t=e.range;if(i){if(!i.parentNode)return void(i=null);t=t.cloneRange(),t.selectNode(i),e.range=t}})),e.on("SetSelectionRange",(e=>{e.range=g(e.range);const t=p(e.range,e.forward);t&&(e.range=t)})),e.on("AfterSetSelectionRange",(e=>{const t=e.range,n=t.startContainer.parentElement;var r;u(t)||Wn(r=n)&&"mcepastebin"===r.id||v(),(e=>C(e)&&o.hasClass(e,"mce-offscreen-selection"))(n)||f()})),sR(e),(e=>{const t=ii((()=>{if(!e.removed&&e.getBody().contains(document.activeElement)){const t=e.selection.getRng();if(t.collapsed){const o=gk(e,t,!1);e.selection.setRng(o)}}}),0);e.on("focus",(()=>{t.throttle()})),e.on("blur",(()=>{t.cancel()}))})(e),(e=>{e.on("init",(()=>{e.on("focusin",(t=>{const o=t.target;if(gr(o)){const t=tb(e.getBody(),o),n=dr(t)?t:o;e.selection.getNode()!==n&&uk(e,n).each((t=>e.selection.setRng(t)))}}))}))})(e)},m=e=>Vr(e)||Wr(e)||$r(e),u=e=>m(e.startContainer)||m(e.endContainer),g=t=>{const n=e.schema.getVoidElements(),r=o.createRng(),s=t.startContainer,a=t.startOffset,i=t.endContainer,l=t.endOffset;return _e(n,s.nodeName.toLowerCase())?0===a?r.setStartBefore(s):r.setStartAfter(s):r.setStart(s,a),_e(n,i.nodeName.toLowerCase())?0===l?r.setEndBefore(i):r.setEndAfter(i):r.setEnd(i,l),r},h=n=>{const r=n.cloneNode(!0),l=e.dispatch("ObjectSelected",{target:n,targetClone:r});if(l.isDefaultPrevented())return null;const c=((n,r)=>{const a=yo.fromDom(e.getBody()),i=e.getDoc(),l=tn(a,"#"+s).getOrThunk((()=>{const e=yo.fromHtml('
    ',i);return eo(e,"id",s),bn(a,e),e})),c=o.createRng();xn(l),wn(l,[yo.fromText(br,i),yo.fromDom(r),yo.fromText(br,i)]),c.setStart(l.dom.firstChild,1),c.setEnd(l.dom.lastChild,0),cn(l,{top:o.getPos(n,e.getBody()).y+"px"}),Bh(l);const d=t.getSel();return d&&(d.removeAllRanges(),d.addRange(c)),c})(n,l.targetClone),d=yo.fromDom(n);return q(zn(yo.fromDom(e.getBody()),`*[${a}]`),(e=>{So(d,e)||so(e,a)})),o.getAttrib(n,a)||n.setAttribute(a,"1"),i=n,v(),c},p=(e,t)=>{if(!e)return null;if(e.collapsed){if(!u(e)){const r=t?1:-1,s=Cm(r,n,e),a=s.getNode(!t);if(C(a)){if(Jd(a))return c(r,a,!!t&&!s.isAtEnd(),!1);if(zr(a)&&dr(a.nextSibling)){const e=o.createRng();return e.setStart(a,0),e.setEnd(a,0),e}}const i=s.getNode(t);if(C(i)){if(Jd(i))return c(r,i,!t&&!s.isAtEnd(),!1);if(zr(i)&&dr(i.previousSibling)){const e=o.createRng();return e.setStart(i,1),e.setEnd(i,1),e}}}return null}let r=e.startContainer,s=e.startOffset;const a=e.endOffset;if(tr(r)&&0===s&&aR(r.parentNode)&&(r=r.parentNode,s=o.nodeIndex(r),r=r.parentNode),!Wn(r))return null;if(a===s+1&&r===e.endContainer){const e=r.childNodes[s];if(l(e))return h(e)}return null},f=()=>{i&&i.removeAttribute(a),tn(yo.fromDom(e.getBody()),"#"+s).each(Cn),i=null},v=()=>{r.hide()};return fC(e)||d(),{showCaret:c,showBlockCaretContainer:e=>{e.hasAttribute("data-mce-caret")&&(qr(e),t.scrollIntoView(e))},hideFakeCaret:v,destroy:()=>{r.destroy(),i=null}}},cR=(e,t)=>{let o=t;for(let t=e.previousSibling;tr(t);t=t.previousSibling)o+=t.data.length;return o},dR=(e,t,o,n,r)=>{if(tr(o)&&(n<0||n>o.data.length))return[];const s=r&&tr(o)?[cR(o,n)]:[n];let a=o;for(;a!==t&&a.parentNode;)s.push(e.nodeIndex(a,r)),a=a.parentNode;return a===t?s.reverse():[]},mR=(e,t,o,n,r,s,a=!1)=>({start:dR(e,t,o,n,a),end:dR(e,t,r,s,a)}),uR=(e,t)=>{const o=t.slice(),n=o.pop();return k(n)?J(o,((e,t)=>e.bind((e=>F.from(e.childNodes[t])))),F.some(e)).bind((e=>tr(e)&&(n<0||n>e.data.length)?F.none():F.some({node:e,offset:n}))):F.none()},gR=(e,t)=>uR(e,t.start).bind((({node:o,offset:n})=>uR(e,t.end).map((({node:e,offset:t})=>{const r=document.createRange();return r.setStart(o,n),r.setEnd(e,t),r})))),hR=(e,t,o)=>{if(t&&e.isEmpty(t)&&!o(t)){const n=t.parentNode;e.remove(t,tr(t.firstChild)&&is(t.firstChild.data)),hR(e,n,o)}},pR=(e,t,o,n=!0)=>{const r=t.startContainer.parentNode,s=t.endContainer.parentNode;t.deleteContents(),n&&!o(t.startContainer)&&(tr(t.startContainer)&&0===t.startContainer.data.length&&e.remove(t.startContainer),tr(t.endContainer)&&0===t.endContainer.data.length&&e.remove(t.endContainer),hR(e,r,o),r!==s&&hR(e,s,o))},fR=(e,t)=>F.from(e.dom.getParent(t.startContainer,e.dom.isBlock)),vR=(e,t,o)=>{const n=e.dynamicPatternsLookup({text:o,block:t});return{...e,blockPatterns:Bl(n).concat(e.blockPatterns),inlinePatterns:Ll(n).concat(e.inlinePatterns)}},bR=(e,t,o,n)=>{const r=e.createRng();return r.setStart(t,0),r.setEnd(o,n),r.toString()},yR=(e,t,o)=>{const n=((e,t,o)=>{if(tr(e)&&t>=e.length)return F.some(VT(e,t));{const n=Oi(ZT);return F.from(n.forwards(e,t,UT(e),o)).map((e=>VT(e.container,0)))}})(t,0,t);n.each((n=>{const r=n.container;$T(r,o.start.length,t).each((o=>{const n=e.createRng();n.setStart(r,0),n.setEnd(o.container,o.offset),pR(e,n,(e=>e===t))}));const s=yo.fromDom(r),a=xr(s);/^\s[^\s]/.test(a)&&((e,t)=>{wr.set(e,t)})(s,a.slice(1))}))},wR=(e,t)=>{const o=e.dom,n=t.pattern,r=gR(o.getRoot(),t.range).getOrDie("Unable to resolve path range");return fR(e,r).each((t=>{"block-format"===n.type?((e,t)=>{const o=t.get(e);return v(o)&&de(o).exists((e=>_e(e,"block")))})(n.format,e.formatter)&&e.undoManager.transact((()=>{yR(e.dom,t,n),e.formatter.apply(n.format)})):"block-command"===n.type&&e.undoManager.transact((()=>{yR(e.dom,t,n),e.execCommand(n.cmd,!1,n.value)}))})),!0},xR=(e,t)=>{const o=(e=>le(e,((e,t)=>t.start.length-e.start.length)))(e),n=t.replace(br," ");return ee(o,(e=>0===t.indexOf(e.start)||0===n.indexOf(e.start)))},CR=(e,t)=>e.create("span",{"data-mce-type":"bookmark",id:t}),SR=(e,t)=>{const o=e.createRng();return o.setStartAfter(t.start),o.setEndBefore(t.end),o},kR=(e,t,o)=>{const n=gR(e.getRoot(),o).getOrDie("Unable to resolve path range"),r=n.startContainer,s=n.endContainer,a=0===n.endOffset?s:s.splitText(n.endOffset),i=0===n.startOffset?r:r.splitText(n.startOffset),l=i.parentNode;return{prefix:t,end:a.parentNode.insertBefore(CR(e,t+"-end"),a),start:l.insertBefore(CR(e,t+"-start"),i)}},_R=(e,t,o)=>{hR(e,e.get(t.prefix+"-end"),o),hR(e,e.get(t.prefix+"-start"),o)},ER=e=>0===e.start.length,TR=(e,t,o,n)=>{const r=t.start;var s;return qT(e,n.container,n.offset,(s=r,(e,t)=>{const o=e.data.substring(0,t),n=o.lastIndexOf(s.charAt(s.length-1)),r=o.lastIndexOf(s);return-1!==r?r+s.length:-1!==n?n+1:-1}),o).bind((n=>{var s,a;const i=null!==(a=null===(s=o.textContent)||void 0===s?void 0:s.indexOf(r))&&void 0!==a?a:-1;if(-1!==i&&n.offset>=i+r.length){const t=e.createRng();return t.setStart(n.container,n.offset-r.length),t.setEnd(n.container,n.offset),F.some(t)}{const s=n.offset-r.length;return WT(n.container,s,o).map((t=>{const o=e.createRng();return o.setStart(t.container,t.offset),o.setEnd(n.container,n.offset),o})).filter((e=>e.toString()===r)).orThunk((()=>TR(e,t,o,VT(n.container,0))))}}))},OR=(e,t,o,n)=>{const r=e.dom,s=r.getRoot(),a=o.pattern,i=o.position.container,l=o.position.offset;return WT(i,l-o.pattern.end.length,t).bind((c=>{const d=mR(r,s,c.container,c.offset,i,l,n);if(ER(a))return F.some({matches:[{pattern:a,startRng:d,endRng:d}],position:c});{const i=DR(e,o.remainingPatterns,c.container,c.offset,t,n),l=i.getOr({matches:[],position:c}),m=l.position,u=((e,t,o,n,r,s=!1)=>{if(0===t.start.length&&!s){const t=e.createRng();return t.setStart(o,n),t.setEnd(o,n),F.some(t)}return jT(o,n,r).bind((o=>TR(e,t,r,o).bind((e=>{var t;if(s){if(e.endContainer===o.container&&e.endOffset===o.offset)return F.none();if(0===o.offset&&(null===(t=e.endContainer.textContent)||void 0===t?void 0:t.length)===e.endOffset)return F.none()}return F.some(e)}))))})(r,a,m.container,m.offset,t,i.isNone());return u.map((e=>{const t=((e,t,o,n=!1)=>mR(e,t,o.startContainer,o.startOffset,o.endContainer,o.endOffset,n))(r,s,e,n);return{matches:l.matches.concat([{pattern:a,startRng:t,endRng:d}]),position:VT(e.startContainer,e.startOffset)}}))}}))},DR=(e,t,o,n,r,s)=>{const a=e.dom;return jT(o,n,a.getRoot()).bind((i=>{const l=bR(a,r,o,n);for(let a=0;a0)return DR(e,t,o,n-1,r,s);if(m.isSome())return m}return F.none()}))},AR=(e,t,o)=>{e.selection.setRng(o),"inline-format"===t.type?q(t.format,(t=>{e.formatter.apply(t)})):e.execCommand(t.cmd,!1,t.value)},MR=(e,t,o,n,r,s)=>{var a;return((e,t)=>{const o=re(e,(e=>W(t,(t=>e.pattern.start===t.pattern.start&&e.pattern.end===t.pattern.end))));return e.length===t.length?o?e:t:e.length>t.length?e:t})(DR(e,r.inlinePatterns,o,n,t,s).fold((()=>[]),(e=>e.matches)),DR(e,(a=r.inlinePatterns,le(a,((e,t)=>t.end.length-e.end.length))),o,n,t,s).fold((()=>[]),(e=>e.matches)))},NR=(e,t)=>{if(0===t.length)return;const o=e.dom,n=e.selection.getBookmark(),r=((e,t)=>{const o=Ci("mce_textpattern"),n=X(t,((t,n)=>{const r=kR(e,o+`_end${t.length}`,n.endRng);return t.concat([{...n,endMarker:r}])}),[]);return X(n,((t,r)=>{const s=n.length-t.length-1,a=ER(r.pattern)?r.endMarker:kR(e,o+`_start${s}`,r.startRng);return t.concat([{...r,startMarker:a}])}),[])})(o,t);q(r,(t=>{const n=o.getParent(t.startMarker.start,o.isBlock),r=e=>e===n;ER(t.pattern)?((e,t,o,n)=>{const r=SR(e.dom,o);pR(e.dom,r,n),AR(e,t,r)})(e,t.pattern,t.endMarker,r):((e,t,o,n,r)=>{const s=e.dom,a=SR(s,n),i=SR(s,o);pR(s,i,r),pR(s,a,r);const l={prefix:o.prefix,start:o.end,end:n.start},c=SR(s,l);AR(e,t,c)})(e,t.pattern,t.startMarker,t.endMarker,r),_R(o,t.endMarker,r),_R(o,t.startMarker,r)})),e.selection.moveToBookmark(n)},RR=(e,t)=>{const o=e.selection.getRng();return fR(e,o).map((n=>{var r;const s=Math.max(0,o.startOffset),a=vR(t,n,null!==(r=n.textContent)&&void 0!==r?r:""),i=MR(e,n,o.startContainer,s,a,!0),l=((e,t,o,n)=>{var r;const s=e.dom,a=Xl(e);if(!s.is(t,a))return[];const i=null!==(r=t.textContent)&&void 0!==r?r:"";return xR(o.blockPatterns,i).map((e=>Bt.trim(i).length===e.start.length?[]:[{pattern:e,range:mR(s,s.getRoot(),t,0,t,0,n)}])).getOr([])})(e,n,a,!0);return(l.length>0||i.length>0)&&(e.undoManager.add(),e.undoManager.extra((()=>{e.execCommand("mceInsertNewLine")}),(()=>{(e=>{e.insertContent(Br,{preserve_zwsp:!0})})(e),NR(e,i),((e,t)=>{if(0===t.length)return;const o=e.selection.getBookmark();q(t,(t=>wR(e,t))),e.selection.moveToBookmark(o)})(e,l);const t=e.selection.getRng(),o=jT(t.startContainer,t.startOffset,e.dom.getRoot());e.execCommand("mceInsertNewLine"),o.each((t=>{const o=t.container;o.data.charAt(t.offset-1)===vr&&(o.deleteData(t.offset-1,1),hR(e.dom,o.parentNode,(t=>t===e.dom.getRoot())))}))})),!0)})).getOr(!1)},BR=(e,t,o)=>{for(let n=0;n{const t=[",",".",";",":","!","?"],o=[32],n=()=>{return t=wd(e),o=xd(e),{inlinePatterns:Ll(t),blockPatterns:Bl(t),dynamicPatternsLookup:o};var t,o},r=()=>(e=>e.options.isSet("text_patterns_lookup"))(e);e.on("keydown",(t=>{if(13===t.keyCode&&!Dg.modifierPressed(t)&&e.selection.isCollapsed()){const o=n();(o.inlinePatterns.length>0||o.blockPatterns.length>0||r())&&RR(e,o)&&t.preventDefault()}}),!0);const s=()=>{if(e.selection.isCollapsed()){const t=n();(t.inlinePatterns.length>0||r())&&((e,t)=>{const o=e.selection.getRng();fR(e,o).map((n=>{const r=Math.max(0,o.startOffset-1),s=bR(e.dom,n,o.startContainer,r),a=vR(t,n,s),i=MR(e,n,o.startContainer,r,a,!1);i.length>0&&e.undoManager.transact((()=>{NR(e,i)}))}))})(e,t)}};e.on("keyup",(e=>{BR(o,e,((e,t)=>e===t.keyCode&&!Dg.modifierPressed(t)))&&s()})),e.on("keypress",(o=>{BR(t,o,((e,t)=>e.charCodeAt(0)===t.charCode))&&qh.setEditorTimeout(e,s)}))},HR=e=>{const t=Bt.each,o=Dg.BACKSPACE,n=Dg.DELETE,r=e.dom,s=e.selection,a=e.parser,i=At.browser,l=i.isFirefox(),c=i.isChromium()||i.isSafari(),d=At.deviceType.isiPhone()||At.deviceType.isiPad(),m=At.os.isMacOS()||At.os.isiOS(),u=(t,o)=>{try{e.getDoc().execCommand(t,!1,String(o))}catch(e){}},g=e=>e.isDefaultPrevented(),p=()=>{const t=e=>{const t=r.create("body"),o=e.cloneContents();return t.appendChild(o),s.serializer.serialize(t,{format:"html"})};e.on("keydown",(s=>{const a=s.keyCode;if(!g(s)&&(a===n||a===o)&&e.selection.isEditable()){const o=e.selection.isCollapsed(),n=e.getBody();if(o&&!ys(yo.fromDom(n)))return;if(!o&&!(o=>{const n=t(o),s=r.createRng();return s.selectNode(e.getBody()),n===t(s)})(e.selection.getRng()))return;s.preventDefault(),e.setContent(""),n.firstChild&&r.isBlock(n.firstChild)?e.selection.setCursorLocation(n.firstChild,0):e.selection.setCursorLocation(n,0),e.nodeChanged()}}))},f=()=>{e.shortcuts.add("meta+a",null,"SelectAll")},v=()=>{e.inline||r.bind(e.getDoc(),"mousedown mouseup",(t=>{let o;if(t.target===e.getDoc().documentElement)if(o=s.getRng(),e.getBody().focus(),"mousedown"===t.type){if(Vr(o.startContainer))return;s.placeCaretAt(t.clientX,t.clientY)}else s.setRng(o)}))},b=()=>{Range.prototype.getClientRects||e.on("mousedown",(t=>{if(!g(t)&&"HTML"===t.target.nodeName){const t=e.getBody();t.blur(),qh.setEditorTimeout(e,(()=>{t.focus()}))}}))},y=()=>{const t=ed(e);e.on("click",(o=>{const n=o.target;/^(IMG|HR)$/.test(n.nodeName)&&r.isEditable(n)&&(o.preventDefault(),e.selection.select(n),e.nodeChanged()),"A"===n.nodeName&&r.hasClass(n,t)&&0===n.childNodes.length&&r.isEditable(n.parentNode)&&(o.preventDefault(),s.select(n))}))},w=()=>{e.on("keydown",(e=>{if(!g(e)&&e.keyCode===o&&s.isCollapsed()&&0===s.getRng().startOffset){const t=s.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}return!0}))},x=()=>{const t=()=>{u("StyleWithCSS",!1),u("enableInlineTableEditing",!1),kc(e)||u("enableObjectResizing",!1)};$c(e)||e.on("BeforeExecCommand mousedown",t)},C=()=>{e.on("SetContent ExecCommand",(e=>{"setcontent"!==e.type&&"mceInsertLink"!==e.command||t(r.select("a:not([data-mce-block])"),(e=>{var t;let o=e.parentNode;const n=r.getRoot();if((null==o?void 0:o.lastChild)===e){for(;o&&!r.isBlock(o);){if((null===(t=o.parentNode)||void 0===t?void 0:t.lastChild)!==o||o===n)return;o=o.parentNode}r.add(o,"br",{"data-mce-bogus":1})}}))}))},S=()=>{e.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")},k=()=>{e.inline||e.on("keydown",(()=>{document.activeElement===document.body&&e.getWin().focus()}))},_=()=>{e.inline||(e.contentStyles.push("body {min-height: 150px}"),e.on("click",(t=>{let o;"HTML"===t.target.nodeName&&(o=e.selection.getRng(),e.getBody().focus(),e.selection.setRng(o),e.selection.normalize(),e.nodeChanged())})))},T=()=>{m&&e.on("keydown",(t=>{!Dg.metaKeyPressed(t)||t.shiftKey||37!==t.keyCode&&39!==t.keyCode||(t.preventDefault(),e.selection.getSel().modify("move",37===t.keyCode?"backward":"forward","lineboundary"))}))},O=()=>{e.on("click",(e=>{let t=e.target;do{if("A"===t.tagName)return void e.preventDefault()}while(t=t.parentNode)})),e.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")},D=()=>{e.on("init",(()=>{e.dom.bind(e.getBody(),"submit",(e=>{e.preventDefault()}))}))},A=E,M=()=>{e.on("keydown",(t=>{if(g(t)||t.keyCode!==Dg.BACKSPACE)return;let o=s.getRng();const n=o.startContainer,a=o.startOffset,i=r.getRoot();let l=n;if(o.collapsed&&0===a){for(;l.parentNode&&l.parentNode.firstChild===l&&l.parentNode!==i;)l=l.parentNode;"BLOCKQUOTE"===l.nodeName&&(e.formatter.toggle("blockquote",void 0,l),o=r.createRng(),o.setStart(n,0),o.setEnd(n,0),s.setRng(o))}})),p(),At.windowsPhone||e.on("keyup focusin mouseup",(t=>{Dg.modifierPressed(t)||(e=>{const t=e.getBody(),o=e.selection.getRng();return o.startContainer===o.endContainer&&o.startContainer===t&&0===o.startOffset&&o.endOffset===t.childNodes.length})(e)||s.normalize()}),!0),c&&(v(),y(),e.on("init",(()=>{u("DefaultParagraphSeparator",Xl(e))})),D(),w(),a.addNodeFilter("br",(e=>{let t=e.length;for(;t--;)"Apple-interchange-newline"===e[t].attr("class")&&e[t].remove()})),d?(k(),_(),O()):f()),l&&(e.on("keydown",(t=>{if(!g(t)&&t.keyCode===o){if(!e.getBody().getElementsByTagName("hr").length)return;if(s.isCollapsed()&&0===s.getRng().startOffset){const e=s.getNode(),o=e.previousSibling;if("HR"===e.nodeName)return r.remove(e),void t.preventDefault();o&&o.nodeName&&"hr"===o.nodeName.toLowerCase()&&(r.remove(o),t.preventDefault())}}})),b(),(()=>{const o=()=>{const o=r.getAttribs(s.getStart().cloneNode(!1));return()=>{const n=s.getStart();n!==e.getBody()&&(r.setAttrib(n,"style",null),t(o,(e=>{n.setAttributeNode(e.cloneNode(!0))})))}},n=()=>!s.isCollapsed()&&r.getParent(s.getStart(),r.isBlock)!==r.getParent(s.getEnd(),r.isBlock);e.on("keypress",(t=>{let r;return!(!(g(t)||8!==t.keyCode&&46!==t.keyCode)&&n()&&(r=o(),e.getDoc().execCommand("delete",!1),r(),t.preventDefault(),1))})),r.bind(e.getDoc(),"cut",(t=>{if(!g(t)&&n()){const t=o();qh.setEditorTimeout(e,(()=>{t()}))}}))})(),x(),C(),S(),T(),w(),e.on("drop",(t=>{var o;const n=null===(o=t.dataTransfer)||void 0===o?void 0:o.getData("text/html");h(n)&&/^]*>$/.test(n)&&e.dispatch("dragend",new window.DragEvent("dragend",t))})))};return fC(e)?(c&&(v(),y(),D(),f(),d&&(k(),_(),O())),l&&(b(),x(),S(),T())):M(),{refreshContentEditable:A,isHidden:()=>{if(!l||e.removed)return!1;const t=e.selection.getSel();return!t||!t.rangeCount||0===t.rangeCount}}},IR=Ya.DOM,PR=e=>e.inline?e.getElement().nodeName.toLowerCase():void 0,FR=e=>xe(e,(e=>!1===w(e))),zR=e=>{const t=e.options.get,o=e.editorUpload.blobCache;return FR({allow_conditional_comments:t("allow_conditional_comments"),allow_html_data_urls:t("allow_html_data_urls"),allow_svg_data_urls:t("allow_svg_data_urls"),allow_html_in_named_anchor:t("allow_html_in_named_anchor"),allow_script_urls:t("allow_script_urls"),allow_unsafe_link_target:t("allow_unsafe_link_target"),convert_unsafe_embeds:t("convert_unsafe_embeds"),convert_fonts_to_spans:t("convert_fonts_to_spans"),fix_list_elements:t("fix_list_elements"),font_size_legacy_values:t("font_size_legacy_values"),forced_root_block:t("forced_root_block"),forced_root_block_attrs:t("forced_root_block_attrs"),preserve_cdata:t("preserve_cdata"),inline_styles:t("inline_styles"),root_name:PR(e),sandbox_iframes:t("sandbox_iframes"),sanitize:t("xss_sanitization"),validate:!0,blob_cache:o,document:e.getDoc()})},VR=e=>{const t=e.options.get;return FR({custom_elements:t("custom_elements"),extended_valid_elements:t("extended_valid_elements"),invalid_elements:t("invalid_elements"),invalid_styles:t("invalid_styles"),schema:t("schema"),valid_children:t("valid_children"),valid_classes:t("valid_classes"),valid_elements:t("valid_elements"),valid_styles:t("valid_styles"),verify_html:t("verify_html"),padd_empty_block_inline_children:t("format_empty_lines")})},ZR=e=>{e.bindPendingEventDelegates(),e.initialized=!0,(e=>{e.dispatch("Init")})(e),e.focus(!0),(e=>{const t=e.dom.getRoot();e.inline||_u(e)&&e.selection.getStart(!0)!==t||Gm(t).each((t=>{const o=t.getNode(),n=Jn(o)?Gm(o).getOr(t):t;e.selection.setRng(n.toRange())}))})(e),e.nodeChanged({initial:!0});const t=nd(e);S(t)&&t.call(e,e),(e=>{const t=sd(e);t&&qh.setEditorTimeout(e,(()=>{let o;o=!0===t?e:e.editorManager.get(t),o&&!o.destroyed&&(o.focus(),o.selection.scrollIntoView())}),100)})(e)},UR=e=>e.inline?e.ui.styleSheetLoader:e.dom.styleSheetLoader,jR=e=>{const t=UR(e),o=xc(e),n=e.contentCSS,r=()=>{t.unloadAll(n),e.inline||e.ui.styleSheetLoader.unloadAll(o)},s=()=>{e.removed?r():e.on("remove",r)};if(e.contentStyles.length>0){let t="";Bt.each(e.contentStyles,(e=>{t+=e+"\r\n"})),e.dom.addStyle(t)}const a=Promise.all(((e,t,o)=>{const{pass:n,fail:r}=K(t,(e=>tinymce.Resource.has(vS(e)))),s=n.map((t=>{const o=tinymce.Resource.get(vS(t));return h(o)?Promise.resolve(UR(e).loadRawCss(t,o)):Promise.resolve()})),a=[...s,UR(e).loadAll(r)];return e.inline?a:a.concat([e.ui.styleSheetLoader.loadAll(o)])})(e,n,o)).then(s).catch(s),i=wc(e);return i&&((e,t)=>{const o=yo.fromDom(e.getBody()),n=jo(Uo(o)),r=yo.fromTag("style");eo(r,"type","text/css"),bn(r,yo.fromText(t)),bn(n,r),e.on("remove",(()=>{Cn(r)}))})(e,i),a},WR=e=>{!0!==e.removed&&((e=>{fC(e)||e.load({initial:!0,format:"html"}),e.startContent=e.getContent({format:"raw"})})(e),ZR(e))},$R=e=>{const t=e.getElement();let o=e.getDoc();e.inline&&(IR.addClass(t,"mce-content-body"),e.contentDocument=o=document,e.contentWindow=window,e.bodyElement=t,e.contentAreaContainer=t);const n=e.getBody();n.disabled=!0,e.readonly=$c(e),e._editableRoot=qc(e),!e.readonly&&e.hasEditableRoot()&&(e.inline&&"static"===IR.getStyle(n,"position",!0)&&(n.style.position="relative"),n.contentEditable="true"),n.disabled=!1,e.editorUpload=OS(e),e.schema=ya(VR(e)),e.dom=Ya(o,{keep_values:!0,url_converter:e.convertURL,url_converter_scope:e,update_styles:!0,root_element:e.inline?e.getBody():null,collect:e.inline,schema:e.schema,contentCssCors:gc(e),referrerPolicy:hc(e),onSetAttrib:t=>{e.dispatch("SetAttrib",t)},force_hex_color:Rd(e)}),e.parser=(e=>{const t=Mx(zR(e),e.schema);return t.addAttributeFilter("src,href,style,tabindex",((t,o)=>{const n=e.dom,r="data-mce-"+o;let s=t.length;for(;s--;){const a=t[s];let i=a.attr(o);if(i&&!a.attr(r)){if(0===i.indexOf("data:")||0===i.indexOf("blob:"))continue;"style"===o?(i=n.serializeStyle(n.parseStyle(i),a.name),i.length||(i=null),a.attr(r,i),a.attr(o,i)):"tabindex"===o?(a.attr(r,i),a.attr(o,null)):a.attr(r,e.convertURL(i,o,a.name))}}})),t.addNodeFilter("script",(e=>{let t=e.length;for(;t--;){const o=e[t],n=o.attr("type")||"no/type";0!==n.indexOf("mce-")&&o.attr("type","mce-"+n)}})),_d(e)&&t.addNodeFilter("#cdata",(t=>{var o;let n=t.length;for(;n--;){const r=t[n];r.type=8,r.name="#comment",r.value="[CDATA["+e.dom.encode(null!==(o=r.value)&&void 0!==o?o:"")+"]]"}})),t.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",(t=>{let o=t.length;const n=e.schema.getNonEmptyElements();for(;o--;){const e=t[o];e.isEmpty(n)&&0===e.getAll("br").length&&e.append(new Ep("br",1))}})),t})(e),e.serializer=RC((e=>{const t=e.options.get;return{...zR(e),...VR(e),...FR({remove_trailing_brs:t("remove_trailing_brs"),pad_empty_with_br:t("pad_empty_with_br"),url_converter:t("url_converter"),url_converter_scope:t("url_converter_scope"),element_format:t("element_format"),entities:t("entities"),entity_encoding:t("entity_encoding"),indent:t("indent"),indent_after:t("indent_after"),indent_before:t("indent_before")})}})(e),e),e.selection=OC(e.dom,e.getWin(),e.serializer,e),e.annotator=wg(e),e.formatter=zS(e),e.undoManager=ZS(e),e._nodeChangeDispatcher=new sM(e),e._selectionOverrides=lR(e),NE(e),xN(e),VE(e),fC(e)||((e=>{e.on("mousedown",(t=>{t.detail>=3&&(t.preventDefault(),DN(e))}))})(e),(e=>{LR(e)})(e));const r=rM(e);AE(e,r),(e=>{e.on("NodeChange",N(IE,e))})(e),qS(e),wN(e);const s=vC(e);(e=>{const t=e.getDoc(),o=e.getBody();(e=>{e.dispatch("PreInit")})(e),ad(e)||(t.body.spellcheck=!1,IR.setAttrib(o,"spellcheck","false")),e.quirks=HR(e),(e=>{e.dispatch("PostRender")})(e);const n=Cc(e);void 0!==n&&(o.dir=n);const r=id(e);r&&e.on("BeforeSetContent",(e=>{Bt.each(r,(t=>{e.content=e.content.replace(t,(e=>"\x3c!--mce:protected "+escape(e)+"--\x3e"))}))})),e.on("SetContent",(()=>{e.addVisual(e.getBody())})),e.on("compositionstart compositionend",(t=>{e.composing="compositionstart"===t.type}))})(e),s.fold((()=>{const t=(e=>{let t=!1;const o=setTimeout((()=>{t||e.setProgressState(!0)}),500);return()=>{clearTimeout(o),t=!0,e.setProgressState(!1)}})(e);jR(e).then((()=>{WR(e),t()}))}),(t=>{e.setProgressState(!0),jR(e).then((()=>{t().then((t=>{e.setProgressState(!1),WR(e),wC(e)}),(t=>{e.notificationManager.open({type:"error",text:String(t)}),WR(e),wC(e)}))}))}))},qR=P,GR=Ya.DOM,KR=(e,t)=>{const o=e.translate("Rich Text Area"),n=no(yo.fromDom(e.getElement()),"tabindex").bind(Je),r=((e,t,o,n)=>{const r=yo.fromTag("iframe");return n.each((e=>eo(r,"tabindex",e))),to(r,o),to(r,{id:e+"_ifr",frameBorder:"0",allowTransparency:"true",title:t}),go(r,"tox-edit-area__iframe"),r})(e.id,o,jl(e),n).dom;r.onload=()=>{r.onload=null,e.dispatch("load")},e.contentAreaContainer=t.iframeContainer,e.iframeElement=r,e.iframeHTML=(e=>{let t=Wl(e)+"";$l(e)!==e.documentBaseUrl&&(t+=''),t+='';const o=ql(e),n=Gl(e),r=e.translate(td(e));return Kl(e)&&(t+=''),t+=`
    `,t})(e),GR.add(t.iframeContainer,r)},YR=e=>{const t=e.iframeElement,o=()=>{e.contentDocument=t.contentDocument,$R(e)};if(Od(e)||At.browser.isFirefox()){const t=e.getDoc();t.open(),t.write(e.iframeHTML),t.close(),o()}else{const r=(n=yo.fromDom(t),On(n,"load",qR,(()=>{r.unbind(),o()})));t.srcdoc=e.iframeHTML}var n},XR=Ya.DOM,JR=(e,t,o)=>{const n=cS.get(o),r=cS.urls[o]||e.documentBaseUrl.replace(/\/$/,"");if(o=Bt.trim(o),n&&-1===Bt.inArray(t,o)){if(e.plugins[o])return;try{const s=n(e,r)||{};e.plugins[o]=s,S(s.init)&&(s.init(e,r),t.push(o))}catch(t){((e,t,o)=>{const n=ni.translate(["Failed to initialize plugin: {0}",t]);Sg(e,"PluginLoadError",{message:n}),fS(n,o),gS(e,n)})(e,o,t)}}},QR=(e,t)=>({editorContainer:e,iframeContainer:t,api:{}}),eB=e=>{const t=e.getElement();return e.inline?QR(null):(e=>{const t=XR.create("div");return XR.insertAfter(t,e),QR(t,t)})(t)},tB=e=>{const t=e.getElement();return e.orgDisplay=t.style.display,h(Dc(e))?(e=>{const t=e.theme.renderUI;return t?t():eB(e)})(e):S(Dc(e))?(e=>{const t=e.getElement(),o=Dc(e)(e,t);return o.editorContainer.nodeType&&(o.editorContainer.id=o.editorContainer.id||e.id+"_parent"),o.iframeContainer&&o.iframeContainer.nodeType&&(o.iframeContainer.id=o.iframeContainer.id||e.id+"_iframecontainer"),o.height=o.iframeHeight?o.iframeHeight:t.offsetHeight,o})(e):eB(e)},oB=async e=>{e.dispatch("ScriptsLoaded"),(e=>{const t=Bt.trim(ic(e)),o=e.ui.registry.getAll().icons,n={...JC.get("default").icons,...JC.get(t).icons};fe(n,((t,n)=>{_e(o,n)||e.ui.registry.addIcon(n,t)}))})(e),(e=>{const t=Dc(e);if(h(t)){const o=dS.get(t);e.theme=o(e,dS.urls[t])||{},S(e.theme.init)&&e.theme.init(e,dS.urls[t]||e.documentBaseUrl.replace(/\/$/,""))}else e.theme={}})(e),(e=>{const t=Mc(e),o=QC.get(t);e.model=o(e,QC.urls[t])})(e),(e=>{const t=[];q(Kc(e),(o=>{JR(e,t,(e=>e.replace(/^\-/,""))(o))}))})(e);const t=await tB(e);((e,t)=>{const o={show:F.from(t.show).getOr(E),hide:F.from(t.hide).getOr(E),isEnabled:F.from(t.isEnabled).getOr(P),setEnabled:o=>{e.mode.isReadOnly()||F.from(t.setEnabled).each((e=>e(o)))}};e.ui={...e.ui,...o}})(e,F.from(t.api).getOr({})),e.editorContainer=t.editorContainer,yS(e),e.inline?$R(e):((e,t)=>{KR(e,t),t.editorContainer&&(t.editorContainer.style.display=e.orgDisplay,e.hidden=GR.isHidden(t.editorContainer)),e.getElement().style.display="none",GR.setAttrib(e.id,"aria-hidden","true"),e.getElement().style.visibility=e.orgVisibility,YR(e)})(e,{editorContainer:t.editorContainer,iframeContainer:t.iframeContainer})},nB=Ya.DOM,rB=e=>"-"===e.charAt(0),sB=(e,t)=>{const o=pc(t),n=fc(t);if(!ni.hasCode(o)&&"en"!==o){const r=Ye(n)?n:`${t.editorManager.baseURL}/langs/${o}.js`;e.add(r).catch((()=>{((e,t,o)=>{hS(e,"LanguageLoadError",pS("language",t,o))})(t,r,o)}))}},aB=(e,t)=>{const o=Dc(e);if(h(o)&&!rB(o)&&!_e(dS.urls,o)){const n=Ac(e),r=n?e.documentBaseURI.toAbsolute(n):`themes/${o}/theme${t}.js`;dS.load(o,r).catch((()=>{((e,t,o)=>{hS(e,"ThemeLoadError",pS("theme",t,o))})(e,r,o)}))}},iB=(e,t)=>{const o=Mc(e);if("plugin"!==o&&!_e(QC.urls,o)){const n=Nc(e),r=h(n)?e.documentBaseURI.toAbsolute(n):`models/${o}/model${t}.js`;QC.load(o,r).catch((()=>{((e,t,o)=>{hS(e,"ModelLoadError",pS("model",t,o))})(e,r,o)}))}},lB=(e,t,o)=>F.from(t).filter((e=>Ye(e)&&!JC.has(e))).map((t=>({url:`${e.editorManager.baseURL}/icons/${t}/icons${o}.js`,name:F.some(t)}))),cB=(e,t,o)=>{const n=lB(t,"default",o),r=(e=>F.from(lc(e)).filter(Ye).map((e=>({url:e,name:F.none()}))))(t).orThunk((()=>lB(t,ic(t),"")));q((e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t{e.add(o.url).catch((()=>{((e,t,o)=>{hS(e,"IconsLoadError",pS("icons",t,o))})(t,o.url,o.name.getOrUndefined())}))}))},dB=(e,t)=>{const o=(t,o)=>{cS.load(t,o).catch((()=>{((e,t,o)=>{hS(e,"PluginLoadError",pS("plugin",t,o))})(e,o,t)}))};fe(Yc(e),((t,n)=>{o(n,t),e.options.set("plugins",Kc(e).concat(n))})),q(Kc(e),(e=>{!(e=Bt.trim(e))||cS.urls[e]||rB(e)||o(e,`plugins/${e}/plugin${t}.js`)}))},mB=(e,t)=>{const o=Ja.ScriptLoader,n=()=>{!e.removed&&(e=>{const t=Dc(e);return!h(t)||C(dS.get(t))})(e)&&(e=>{const t=Mc(e);return C(QC.get(t))})(e)&&oB(e)};aB(e,t),iB(e,t),sB(o,e),cB(o,e,t),dB(e,t),o.loadQueue().then(n,n)},uB=e=>{const t=e.id;ni.setCode(pc(e));const o=()=>{nB.unbind(window,"ready",o),e.render()};if(!za.Event.domLoaded)return void nB.bind(window,"ready",o);if(!e.getElement())return;const n=yo.fromDom(e.getElement()),r=ao(n);e.on("remove",(()=>{G(n.dom.attributes,(e=>so(n,e.name))),to(n,r)})),e.ui.styleSheetLoader=((e,t)=>Us.forElement(e,{contentCssCors:Gc(t),referrerPolicy:hc(t)}))(n,e),Fc(e)?e.inline=!0:(e.orgVisibility=e.getElement().style.visibility,e.getElement().style.visibility="hidden");const s=e.getElement().form||nB.getParent(t,"form");s&&(e.formElement=s,zc(e)&&!er(e.getElement())&&(nB.insertAfter(nB.create("input",{type:"hidden",name:t}),t),e.hasHiddenInput=!0),e.formEventDelegate=t=>{e.dispatch(t.type,t)},nB.bind(s,"submit reset",e.formEventDelegate),e.on("reset",(()=>{e.resetContent()})),!Vc(e)||s.submit.nodeType||s.submit.length||s._mceOldSubmit||(s._mceOldSubmit=s.submit,s.submit=()=>(e.editorManager.triggerSave(),e.setDirty(!1),s._mceOldSubmit(s)))),e.windowManager=mS(e),e.notificationManager=lS(e),(e=>"xml"===e.options.get("encoding"))(e)&&e.on("GetContent",(e=>{e.save&&(e.content=nB.encode(e.content))})),Zc(e)&&e.on("submit",(()=>{e.initialized&&e.save()})),Uc(e)&&(e._beforeUnload=()=>{!e.initialized||e.destroyed||e.isHidden()||e.save({format:"raw",no_events:!0,set_dirty:!1})},e.editorManager.on("BeforeUnload",e._beforeUnload)),e.editorManager.add(e),mB(e,e.suffix)},gB=St().deviceType,hB=gB.isPhone(),pB=gB.isTablet(),fB=e=>{if(x(e))return[];{const t=v(e)?e:e.split(/[ ,]/),o=$(t,qe);return Y(o,Ye)}},vB=(e,t)=>{const o=((e,t)=>{const o={},n={};return we(e,t,ye(o),ye(n)),{t:o,f:n}})(t,((t,o)=>j(e,o)));return n=o.t,r=o.f,{sections:D(n),options:D(r)};var n,r},bB=(e,t)=>_e(e.sections(),t),yB=(e,t)=>({table_grid:!1,object_resizing:!1,resize:!1,toolbar_mode:ke(e,"toolbar_mode").getOr("scrolling"),toolbar_sticky:!1,...t?{menubar:!1}:{}}),wB=(e,t)=>{var o;const n=null!==(o=t.external_plugins)&&void 0!==o?o:{};return e&&e.external_plugins?Bt.extend({},e.external_plugins,n):n},xB=(e,t,o,n)=>{const r=fB(o.forced_plugins),s=fB(n.plugins),a=((e,t)=>bB(e,t)?e.sections()[t]:{})(t,"mobile"),i=((e,t,o,n)=>e&&bB(t,"mobile")?n:o)(e,t,s,a.plugins?fB(a.plugins):s),l=((e,t)=>[...fB(e),...fB(t)])(r,i);return Bt.extend(n,{forced_plugins:r,plugins:l})},CB=(e,t,o,n,r)=>{var s;const a=e?{mobile:yB(null!==(s=r.mobile)&&void 0!==s?s:{},t)}:{},i=vB(["mobile"],xO(a,r)),l=Bt.extend(o,n,i.options(),((e,t)=>e&&bB(t,"mobile"))(e,i)?((e,t,o={})=>{const n=e.sections(),r=ke(n,t).getOr({});return Bt.extend({},o,r)})(i,"mobile"):{},{external_plugins:wB(n,i.options())});return xB(e,i,n,l)},SB=(e,t)=>((e,t)=>yC(e).editor.addVisual(t))(e,t),kB=e=>{const t=t=>()=>{q("left,center,right,justify".split(","),(o=>{t!==o&&e.formatter.remove("align"+o)})),"none"!==t&&((t,o)=>{e.formatter.toggle(t,o),e.nodeChanged()})("align"+t)};e.editorCommands.addCommands({JustifyLeft:t("left"),JustifyCenter:t("center"),JustifyRight:t("right"),JustifyFull:t("justify"),JustifyNone:t("none")})},_B=e=>{kB(e),(e=>{const t=t=>()=>{const o=e.selection,n=o.isCollapsed()?[e.dom.getParent(o.getNode(),e.dom.isBlock)]:o.getSelectedBlocks();return W(n,(o=>C(e.formatter.matchNode(o,t))))};e.editorCommands.addCommands({JustifyLeft:t("alignleft"),JustifyCenter:t("aligncenter"),JustifyRight:t("alignright"),JustifyFull:t("alignjustify")},"state")})(e)},EB=(e,t)=>{const o=e.selection,n=e.dom;return/^ | $/.test(t)?((e,t,o,n)=>{const r=yo.fromDom(e.getRoot());return o=Pf(r,rl.fromRangeStart(t),n)?o.replace(/^ /," "):o.replace(/^ /," "),Ff(r,rl.fromRangeEnd(t),n)?o.replace(/( | )()?$/," "):o.replace(/ ()?$/," ")})(n,o.getRng(),t,e.schema):t},TB=(e,t)=>{if(e.selection.isEditable()){const{content:o,details:n}=(e=>{if("string"!=typeof e){const t=Bt.extend({paste:e.paste,data:{paste:e.paste}},e);return{content:e.content,details:t}}return{content:e,details:{}}})(t);Lx(e,{...n,content:EB(e,o),format:"html",set:!1,selection:!0}).each((t=>{const o=((e,t,o)=>bC(e).editor.insertContent(t,o))(e,t.content,n);Hx(e,o,t),e.addVisual()}))}},OB={"font-size":"size","font-family":"face"},DB=Jt("font"),AB=(e,t,o)=>Hb(yo.fromDom(o),(t=>(t=>un(t,e).orThunk((()=>DB(t)?ke(OB,e).bind((e=>no(t,e))):F.none())))(t)),(e=>So(yo.fromDom(t),e))),MB=e=>(t,o)=>F.from(o).map(yo.fromDom).filter(Gt).bind((o=>AB(e,t,o.dom).or(((e,t)=>F.from(Ya.DOM.getStyle(t,e,!0)))(e,o.dom)))).getOr(""),NB=MB("font-size"),RB=T((e=>e.replace(/[\'\"\\]/g,"").replace(/,\s+/g,",")),MB("font-family")),BB=e=>Gm(e.getBody()).bind((e=>{const t=e.container();return F.from(tr(t)?t.parentNode:t)})),LB=(e,t)=>(e=>F.from(e.selection.getRng()).bind((t=>{const o=e.getBody();return t.startContainer===o&&0===t.startOffset?F.none():F.from(e.selection.getStart(!0))})))(e).orThunk(N(BB,e)).map(yo.fromDom).filter(Gt).bind(t),HB=(e,t)=>LB(e,O(F.some,t)),IB=(e,t)=>{if(/^[0-9.]+$/.test(t)){const o=parseInt(t,10);if(o>=1&&o<=7){const n=(e=>Bt.explode(e.options.get("font_size_style_values")))(e),r=(e=>Bt.explode(e.options.get("font_size_classes")))(e);return r.length>0?r[o-1]||t:n[o-1]||t}return t}return t},PB=e=>{const t=e.split(/\s*,\s*/);return $(t,(e=>-1===e.indexOf(" ")||je(e,'"')||je(e,"'")?e:`'${e}'`)).join(",")},FB=e=>{const t=(t,o)=>{e.formatter.toggle(t,o),e.nodeChanged()};e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>{t(e)},"ForeColor,HiliteColor":(e,o,n)=>{t(e,{value:n})},BackColor:(e,o,n)=>{t("hilitecolor",{value:n})},FontName:(t,o,n)=>{((e,t)=>{const o=IB(e,t);e.formatter.toggle("fontname",{value:PB(o)}),e.nodeChanged()})(e,n)},FontSize:(t,o,n)=>{((e,t)=>{e.formatter.toggle("fontsize",{value:IB(e,t)}),e.nodeChanged()})(e,n)},LineHeight:(t,o,n)=>{((e,t)=>{e.formatter.toggle("lineheight",{value:String(t)}),e.nodeChanged()})(e,n)},Lang:(e,o,n)=>{var r;t(e,{value:n.code,customValue:null!==(r=n.customCode)&&void 0!==r?r:null})},RemoveFormat:t=>{e.formatter.remove(t)},mceBlockQuote:()=>{t("blockquote")},FormatBlock:(e,o,n)=>{t(h(n)?n:"p")},mceToggleFormat:(e,o,n)=>{t(n)}})},zB=e=>{const t=t=>e.formatter.match(t);e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>t(e),mceBlockQuote:()=>t("blockquote")},"state"),e.editorCommands.addQueryValueHandler("FontName",(()=>(e=>HB(e,(t=>RB(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("FontSize",(()=>(e=>HB(e,(t=>NB(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("LineHeight",(()=>(e=>HB(e,(t=>{const o=yo.fromDom(e.getBody()),n=Hb(t,(e=>un(e,"line-height")),N(So,o));return n.getOrThunk((()=>{const e=parseFloat(dn(t,"line-height")),o=parseFloat(dn(t,"font-size"));return String(e/o)}))})).getOr(""))(e)))},VB=e=>{e.editorCommands.addCommands({Indent:()=>{(e=>{_E(e,"indent")})(e)},Outdent:()=>{EE(e)}}),e.editorCommands.addCommands({Outdent:()=>CE(e)},"state")},ZB=(e,t)=>{const o=e.dom,n=e.selection.getRng(),r=t?e.selection.getStart():e.selection.getEnd(),s=t?n.startContainer:n.endContainer,a=KD(o,s);if(!a||!a.isContentEditable)return;const i=t?pn:fn,l=Xl(e);((e,t,o,n)=>{const r=e.dom,s=e=>r.isBlock(e)&&e.parentElement===o,a=s(t)?t:r.getParent(n,s,o);return F.from(a).map(yo.fromDom)})(e,r,a,s).each((t=>{const o=QD(e,s,t.dom,a,!1,l);i(t,yo.fromDom(o)),e.selection.setCursorLocation(o,0),e.dispatch("NewBlock",{newBlock:o}),VD(e,"insertParagraph")}))},UB=e=>{e.editorCommands.addCommands({InsertNewBlockBefore:()=>{(e=>{ZB(e,!0)})(e)},InsertNewBlockAfter:()=>{(e=>{ZB(e,!1)})(e)}})},jB=e=>{_B(e),(e=>{e.editorCommands.addCommands({"Cut,Copy,Paste":t=>{const o=e.getDoc();let n;try{o.execCommand(t)}catch(e){n=!0}if("paste"!==t||o.queryCommandEnabled(t)||(n=!0),n||!o.queryCommandSupported(t)){let t=e.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");(At.os.isMacOS()||At.os.isiOS())&&(t=t.replace(/Ctrl\+/g,"⌘+")),e.notificationManager.open({text:t,type:"error"})}}})})(e),(e=>{e.editorCommands.addCommands({mceAddUndoLevel:()=>{e.undoManager.add()},mceEndUndoLevel:()=>{e.undoManager.add()},Undo:()=>{e.undoManager.undo()},Redo:()=>{e.undoManager.redo()}})})(e),(e=>{e.editorCommands.addCommands({mceSelectNodeDepth:(t,o,n)=>{let r=0;e.dom.getParent(e.selection.getNode(),(t=>!Wn(t)||r++!==n||(e.selection.select(t),!1)),e.getBody())},mceSelectNode:(t,o,n)=>{e.selection.select(n)},selectAll:()=>{const t=e.dom.getParent(e.selection.getStart(),cr);if(t){const o=e.dom.createRng();o.selectNodeContents(t),e.selection.setRng(o)}}})})(e),(e=>{e.editorCommands.addCommands({mceCleanup:()=>{const t=e.selection.getBookmark();e.setContent(e.getContent()),e.selection.moveToBookmark(t)},insertImage:(t,o,n)=>{TB(e,e.dom.createHTML("img",{src:n}))},insertHorizontalRule:()=>{e.execCommand("mceInsertContent",!1,"
    ")},insertText:(t,o,n)=>{TB(e,e.dom.encode(n))},insertHTML:(t,o,n)=>{TB(e,n)},mceInsertContent:(t,o,n)=>{TB(e,n)},mceSetContent:(t,o,n)=>{e.setContent(n)},mceReplaceContent:(t,o,n)=>{e.execCommand("mceInsertContent",!1,n.replace(/\{\$selection\}/g,e.selection.getContent({format:"text"})))},mceNewDocument:()=>{e.setContent(ud(e))}})})(e),(e=>{const t=(t,o,n)=>{const r=h(n)?{href:n}:n,s=e.dom.getParent(e.selection.getNode(),"a");p(r)&&h(r.href)&&(r.href=r.href.replace(/ /g,"%20"),s&&r.href||e.formatter.remove("link"),r.href&&e.formatter.apply("link",r,s))};e.editorCommands.addCommands({unlink:()=>{if(e.selection.isEditable()){if(e.selection.isCollapsed()){const t=e.dom.getParent(e.selection.getStart(),"a");return void(t&&e.dom.remove(t,!0))}e.formatter.remove("link")}},mceInsertLink:t,createLink:t})})(e),VB(e),UB(e),(e=>{e.editorCommands.addCommands({insertParagraph:()=>{HA(gA,e)},mceInsertNewLine:(t,o,n)=>{IA(e,n)},InsertLineBreak:(t,o,n)=>{HA(CA,e)}})})(e),(e=>{(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{e.getDoc().execCommand(t);const o=e.dom.getParent(e.selection.getNode(),"ol,ul");if(o){const t=o.parentNode;if(t&&/^(H[1-6]|P|ADDRESS|PRE)$/.test(t.nodeName)){const n=e.selection.getBookmark();e.dom.split(t,o),e.selection.moveToBookmark(n)}}}})})(e),(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{const o=e.dom.getParent(e.selection.getNode(),"ul,ol");return o&&("insertunorderedlist"===t&&"UL"===o.tagName||"insertorderedlist"===t&&"OL"===o.tagName)}},"state")})(e)})(e),(e=>{FB(e),zB(e)})(e),(e=>{e.editorCommands.addCommands({mceRemoveNode:(t,o,n)=>{const r=null!=n?n:e.selection.getNode();if(r!==e.getBody()){const t=e.selection.getBookmark();e.dom.remove(r,!0),e.selection.moveToBookmark(t)}},mcePrint:()=>{e.getWin().print()},mceFocus:(t,o,n)=>{cp(e,!0===n)},mceToggleVisualAid:()=>{e.hasVisual=!e.hasVisual,e.addVisual()}})})(e)},WB=["toggleview"],$B=e=>j(WB,e.toLowerCase());class qB{constructor(e){this.commands={state:{},exec:{},value:{}},this.editor=e}execCommand(e,t=!1,o,n){const r=this.editor,s=e.toLowerCase(),a=null==n?void 0:n.skip_focus;if(r.removed)return!1;if("mcefocus"!==s&&(/^(mceAddUndoLevel|mceEndUndoLevel)$/i.test(s)||a?(e=>{Wh(e).each((t=>e.selection.setRng(t)))})(r):r.focus()),r.dispatch("BeforeExecCommand",{command:e,ui:t,value:o}).isDefaultPrevented())return!1;const i=this.commands.exec[s];return!!S(i)&&(i(s,t,o),r.dispatch("ExecCommand",{command:e,ui:t,value:o}),!0)}queryCommandState(e){if(!$B(e)&&this.editor.quirks.isHidden()||this.editor.removed)return!1;const t=e.toLowerCase(),o=this.commands.state[t];return!!S(o)&&o(t)}queryCommandValue(e){if(!$B(e)&&this.editor.quirks.isHidden()||this.editor.removed)return"";const t=e.toLowerCase(),o=this.commands.value[t];return S(o)?o(t):""}addCommands(e,t="exec"){const o=this.commands;fe(e,((e,n)=>{q(n.toLowerCase().split(","),(n=>{o[t][n]=e}))}))}addCommand(e,t,o){const n=e.toLowerCase();this.commands.exec[n]=(e,n,r)=>t.call(null!=o?o:this.editor,n,r)}queryCommandSupported(e){const t=e.toLowerCase();return!!this.commands.exec[t]}addQueryStateHandler(e,t,o){this.commands.state[e.toLowerCase()]=()=>t.call(null!=o?o:this.editor)}addQueryValueHandler(e,t,o){this.commands.value[e.toLowerCase()]=()=>t.call(null!=o?o:this.editor)}}const GB="data-mce-contenteditable",KB=(e,t,o)=>{try{e.getDoc().execCommand(t,!1,String(o))}catch(e){}},YB=(e,t)=>{e.dom.contentEditable=t?"true":"false"},XB=(e,t)=>{const o=yo.fromDom(e.getBody());((e,t,o)=>{vo(e,t)&&!o?po(e,t):o&&go(e,t)})(o,"mce-content-readonly",t),t?(e.selection.controlSelection.hideResizeRect(),e._selectionOverrides.hideFakeCaret(),(e=>{F.from(e.selection.getNode()).each((e=>{e.removeAttribute("data-mce-selected")}))})(e),e.readonly=!0,YB(o,!1),q(zn(o,'*[contenteditable="true"]'),(e=>{eo(e,GB,"true"),YB(e,!1)}))):(e.readonly=!1,e.hasEditableRoot()&&YB(o,!0),(e=>{q(zn(e,`*[${GB}="true"]`),(e=>{so(e,GB),YB(e,!0)}))})(o),KB(e,"StyleWithCSS",!1),KB(e,"enableInlineTableEditing",!1),KB(e,"enableObjectResizing",!1),ip(e)&&e.focus(),(e=>{e.selection.setRng(e.selection.getRng())})(e),e.nodeChanged())},JB=e=>e.readonly,QB=e=>{e.parser.addAttributeFilter("contenteditable",(t=>{JB(e)&&q(t,(e=>{e.attr(GB,e.attr("contenteditable")),e.attr("contenteditable","false")}))})),e.serializer.addAttributeFilter(GB,(t=>{JB(e)&&q(t,(e=>{e.attr("contenteditable",e.attr(GB))}))})),e.serializer.addTempAttr(GB)},eL=["copy"],tL=(e,t)=>{if((e=>"click"===e.type)(t)&&!Dg.metaKeyPressed(t)){const o=yo.fromDom(t.target);((e,t)=>on(t,"a",(t=>So(t,yo.fromDom(e.getBody())))).bind((e=>no(e,"href"))))(e,o).each((o=>{if(t.preventDefault(),/^#/.test(o)){const t=e.dom.select(`${o},[name="${Ze(o,"#")}"]`);t.length&&e.selection.scrollIntoView(t[0],!0)}else window.open(o,"_blank","rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes")}))}else(e=>j(eL,e.type))(t)&&e.dispatch(t.type,t)},oL=Bt.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel"," ");class nL{static isNative(e){return!!oL[e.toLowerCase()]}constructor(e){this.bindings={},this.settings=e||{},this.scope=this.settings.scope||this,this.toggleEvent=this.settings.toggleEvent||I}fire(e,t){return this.dispatch(e,t)}dispatch(e,t){const o=e.toLowerCase(),n=Ba(o,null!=t?t:{},this.scope);this.settings.beforeFire&&this.settings.beforeFire(n);const r=this.bindings[o];if(r)for(let e=0,t=r.length;e{this.toggleEvent(t,!1),delete this.bindings[t]})),this;if(s){if(t){const e=K(s,(e=>e.func===t));s=e.fail,this.bindings[r]=s,q(e.pass,(e=>{e.removed=!0}))}else s.length=0;s.length||(this.toggleEvent(e,!1),delete this.bindings[r])}}}else fe(this.bindings,((e,t)=>{this.toggleEvent(t,!1)})),this.bindings={};return this}once(e,t,o){return this.on(e,t,o,{once:!0})}has(e){e=e.toLowerCase();const t=this.bindings[e];return!(!t||0===t.length)}}const rL=e=>(e._eventDispatcher||(e._eventDispatcher=new nL({scope:e,toggleEvent:(t,o)=>{nL.isNative(t)&&e.toggleNativeEvent&&e.toggleNativeEvent(t,o)}})),e._eventDispatcher),sL={fire(e,t,o){return this.dispatch(e,t,o)},dispatch(e,t,o){const n=this;if(n.removed&&"remove"!==e&&"detach"!==e)return Ba(e.toLowerCase(),null!=t?t:{},n);const r=rL(n).dispatch(e,t);if(!1!==o&&n.parent){let t=n.parent();for(;t&&!r.isPropagationStopped();)t.dispatch(e,r,!1),t=t.parent?t.parent():void 0}return r},on(e,t,o){return rL(this).on(e,t,o)},off(e,t){return rL(this).off(e,t)},once(e,t){return rL(this).once(e,t)},hasEventListeners(e){return rL(this).has(e)}},aL=Ya.DOM;let iL;const lL=(e,t)=>{if("selectionchange"===t)return e.getDoc();if(!e.inline&&/^(?:mouse|touch|click|contextmenu|drop|dragover|dragend)/.test(t))return e.getDoc().documentElement;const o=Tc(e);return o?(e.eventRoot||(e.eventRoot=aL.select(o)[0]),e.eventRoot):e.getBody()},cL=(e,t,o)=>{(e=>!e.hidden&&!JB(e))(e)?e.dispatch(t,o):JB(e)&&tL(e,o)},dL=(e,t)=>{if(e.delegates||(e.delegates={}),e.delegates[t]||e.removed)return;const o=lL(e,t);if(Tc(e)){if(iL||(iL={},e.editorManager.on("removeEditor",(()=>{e.editorManager.activeEditor||iL&&(fe(iL,((t,o)=>{e.dom.unbind(lL(e,o))})),iL=null)}))),iL[t])return;const n=o=>{const n=o.target,r=e.editorManager.get();let s=r.length;for(;s--;){const e=r[s].getBody();(e===n||aL.isChildOf(n,e))&&cL(r[s],t,o)}};iL[t]=n,aL.bind(o,t,n)}else{const n=o=>{cL(e,t,o)};aL.bind(o,t,n),e.delegates[t]=n}},mL={...sL,bindPendingEventDelegates(){const e=this;Bt.each(e._pendingNativeEvents,(t=>{dL(e,t)}))},toggleNativeEvent(e,t){const o=this;"focus"!==e&&"blur"!==e&&(o.removed||(t?o.initialized?dL(o,e):o._pendingNativeEvents?o._pendingNativeEvents.push(e):o._pendingNativeEvents=[e]:o.initialized&&o.delegates&&(o.dom.unbind(lL(o,e),e,o.delegates[e]),delete o.delegates[e])))},unbindAllNativeEvents(){const e=this,t=e.getBody(),o=e.dom;e.delegates&&(fe(e.delegates,((t,o)=>{e.dom.unbind(lL(e,o),o,t)})),delete e.delegates),!e.inline&&t&&o&&(t.onload=null,o.unbind(e.getWin()),o.unbind(e.getDoc())),o&&(o.unbind(t),o.unbind(e.getContainer()))}},uL=e=>h(e)?{value:e.split(/[ ,]/),valid:!0}:_(e,h)?{value:e,valid:!0}:{valid:!1,message:"The value must be a string[] or a comma/space separated string."},gL=(e,t)=>e+(Xe(t.message)?"":`. ${t.message}`),hL=e=>e.valid,pL=(e,t,o="")=>{const n=t(e);return y(n)?n?{value:e,valid:!0}:{valid:!1,message:o}:n},fL=(e,t)=>{const o={},n={},r=(e,t,o)=>{const r=pL(t,o);return hL(r)?(n[e]=r.value,!0):(console.warn(gL(`Invalid value passed for the ${e} option`,r)),!1)},s=e=>_e(o,e);return{register:(e,s)=>{const a=(e=>h(e.processor))(s)?(e=>{const t=(()=>{switch(e){case"array":return v;case"boolean":return y;case"function":return S;case"number":return k;case"object":return p;case"string":return h;case"string[]":return uL;case"object[]":return e=>_(e,p);case"regexp":return e=>g(e,RegExp);default:return P}})();return o=>pL(o,t,`The value must be a ${e}.`)})(s.processor):s.processor,i=((e,t,o)=>{if(!w(t)){const n=pL(t,o);if(hL(n))return n.value;console.error(gL(`Invalid default value passed for the "${e}" option`,n))}})(e,s.default,a);o[e]={...s,default:i,processor:a},ke(n,e).orThunk((()=>ke(t,e))).each((t=>r(e,t,a)))},isRegistered:s,get:e=>ke(n,e).orThunk((()=>ke(o,e).map((e=>e.default)))).getOrUndefined(),set:(e,t)=>{if(s(e)){const n=o[e];return n.immutable?(console.error(`"${e}" is an immutable option and cannot be updated`),!1):r(e,t,n.processor)}return console.warn(`"${e}" is not a registered option. Ensure the option has been registered before setting a value.`),!1},unset:e=>{const t=s(e);return t&&delete n[e],t},isSet:e=>_e(n,e)}},vL=["design","readonly"],bL=(e,t,o,n)=>{const r=o[t.get()],s=o[n];try{s.activate()}catch(e){return void console.error(`problem while activating editor mode ${n}:`,e)}r.deactivate(),r.editorReadOnly!==s.editorReadOnly&&XB(e,s.editorReadOnly),t.set(n),((e,t)=>{e.dispatch("SwitchMode",{mode:t})})(e,n)},yL=e=>{const t=Qa("design"),o=Qa({design:{activate:E,deactivate:E,editorReadOnly:!1},readonly:{activate:E,deactivate:E,editorReadOnly:!0}});return(e=>{e.serializer?QB(e):e.on("PreInit",(()=>{QB(e)}))})(e),(e=>{e.on("ShowCaret",(t=>{JB(e)&&t.preventDefault()})),e.on("ObjectSelected",(t=>{JB(e)&&t.preventDefault()}))})(e),{isReadOnly:()=>JB(e),set:n=>((e,t,o,n)=>{if(n!==o.get()){if(!_e(t,n))throw new Error(`Editor mode '${n}' is invalid`);e.initialized?bL(e,o,t,n):e.on("init",(()=>bL(e,o,t,n)))}})(e,o.get(),t,n),get:()=>t.get(),register:(e,t)=>{o.set(((e,t,o)=>{if(j(vL,t))throw new Error(`Cannot override default mode ${t}`);return{...e,[t]:{...o,deactivate:()=>{try{o.deactivate()}catch(e){console.error(`problem while deactivating editor mode ${t}:`,e)}}}}})(o.get(),e,t))}}},wL=Bt.each,xL=Bt.explode,CL={f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},SL=Bt.makeMap("alt,ctrl,shift,meta,access"),kL=e=>{const t={},o=At.os.isMacOS()||At.os.isiOS();wL(xL(e.toLowerCase(),"+"),(e=>{(e=>e in SL)(e)?t[e]=!0:/^[0-9]{2,}$/.test(e)?t.keyCode=parseInt(e,10):(t.charCode=e.charCodeAt(0),t.keyCode=CL[e]||e.toUpperCase().charCodeAt(0))}));const n=[t.keyCode];let r;for(r in SL)t[r]?n.push(r):t[r]=!1;return t.id=n.join(","),t.access&&(t.alt=!0,o?t.ctrl=!0:t.shift=!0),t.meta&&(o?t.meta=!0:(t.ctrl=!0,t.meta=!1)),t};class _L{constructor(e){this.shortcuts={},this.pendingPatterns=[],this.editor=e;const t=this;e.on("keyup keypress keydown",(e=>{!t.hasModifier(e)&&!t.isFunctionKey(e)||e.isDefaultPrevented()||(wL(t.shortcuts,(o=>{t.matchShortcut(e,o)&&(t.pendingPatterns=o.subpatterns.slice(0),"keydown"===e.type&&t.executeShortcutAction(o))})),t.matchShortcut(e,t.pendingPatterns[0])&&(1===t.pendingPatterns.length&&"keydown"===e.type&&t.executeShortcutAction(t.pendingPatterns[0]),t.pendingPatterns.shift()))}))}add(e,t,o,n){const r=this,s=r.normalizeCommandFunc(o);return wL(xL(Bt.trim(e)),(e=>{const o=r.createShortcut(e,t,s,n);r.shortcuts[o.id]=o})),!0}remove(e){const t=this.createShortcut(e);return!!this.shortcuts[t.id]&&(delete this.shortcuts[t.id],!0)}normalizeCommandFunc(e){const t=this,o=e;return"string"==typeof o?()=>{t.editor.execCommand(o,!1,null)}:Bt.isArray(o)?()=>{t.editor.execCommand(o[0],o[1],o[2])}:o}createShortcut(e,t,o,n){const r=Bt.map(xL(e,">"),kL);return r[r.length-1]=Bt.extend(r[r.length-1],{func:o,scope:n||this.editor}),Bt.extend(r[0],{desc:this.editor.translate(t),subpatterns:r.slice(1)})}hasModifier(e){return e.altKey||e.ctrlKey||e.metaKey}isFunctionKey(e){return"keydown"===e.type&&e.keyCode>=112&&e.keyCode<=123}matchShortcut(e,t){return!!t&&t.ctrl===e.ctrlKey&&t.meta===e.metaKey&&t.alt===e.altKey&&t.shift===e.shiftKey&&!!(e.keyCode===t.keyCode||e.charCode&&e.charCode===t.charCode)&&(e.preventDefault(),!0)}executeShortcutAction(e){return e.func?e.func.call(e.scope):null}}const EL=()=>{const e=(()=>{const e={},t={},o={},n={},r={},s={},a={},i={},l=(e,t)=>(o,n)=>{e[o.toLowerCase()]={...n,type:t}};return{addButton:l(e,"button"),addGroupToolbarButton:l(e,"grouptoolbarbutton"),addToggleButton:l(e,"togglebutton"),addMenuButton:l(e,"menubutton"),addSplitButton:l(e,"splitbutton"),addMenuItem:l(t,"menuitem"),addNestedMenuItem:l(t,"nestedmenuitem"),addToggleMenuItem:l(t,"togglemenuitem"),addAutocompleter:l(o,"autocompleter"),addContextMenu:l(r,"contextmenu"),addContextToolbar:l(s,"contexttoolbar"),addContextForm:l(s,"contextform"),addSidebar:l(a,"sidebar"),addView:l(i,"views"),addIcon:(e,t)=>n[e.toLowerCase()]=t,getAll:()=>({buttons:e,menuItems:t,icons:n,popups:o,contextMenus:r,contextToolbars:s,sidebars:a,views:i})}})();return{addAutocompleter:e.addAutocompleter,addButton:e.addButton,addContextForm:e.addContextForm,addContextMenu:e.addContextMenu,addContextToolbar:e.addContextToolbar,addIcon:e.addIcon,addMenuButton:e.addMenuButton,addMenuItem:e.addMenuItem,addNestedMenuItem:e.addNestedMenuItem,addSidebar:e.addSidebar,addSplitButton:e.addSplitButton,addToggleButton:e.addToggleButton,addGroupToolbarButton:e.addGroupToolbarButton,addToggleMenuItem:e.addToggleMenuItem,addView:e.addView,getAll:e.getAll}},TL=Ya.DOM,OL=Bt.extend,DL=Bt.each;class AL{constructor(e,t,o){this.plugins={},this.contentCSS=[],this.contentStyles=[],this.loadedCSS={},this.isNotDirty=!1,this.composing=!1,this.destroyed=!1,this.hasHiddenInput=!1,this.iframeElement=null,this.initialized=!1,this.readonly=!1,this.removed=!1,this.startContent="",this._pendingNativeEvents=[],this._skinLoaded=!1,this._editableRoot=!0,this.editorManager=o,this.documentBaseUrl=o.documentBaseURL,OL(this,mL);const n=this;this.id=e,this.hidden=!1;const r=((e,t)=>CB(hB||pB,hB,t,e,t))(o.defaultOptions,t);this.options=fL(0,r),(e=>{const t=e.options.register;t("id",{processor:"string",default:e.id}),t("selector",{processor:"string"}),t("target",{processor:"object"}),t("suffix",{processor:"string"}),t("cache_suffix",{processor:"string"}),t("base_url",{processor:"string"}),t("referrer_policy",{processor:"string",default:""}),t("language_load",{processor:"boolean",default:!0}),t("inline",{processor:"boolean",default:!1}),t("iframe_attrs",{processor:"object",default:{}}),t("doctype",{processor:"string",default:""}),t("document_base_url",{processor:"string",default:e.documentBaseUrl}),t("body_id",{processor:Ul(e,"tinymce"),default:"tinymce"}),t("body_class",{processor:Ul(e),default:""}),t("content_security_policy",{processor:"string",default:""}),t("br_in_pre",{processor:"boolean",default:!0}),t("forced_root_block",{processor:e=>{const t=h(e)&&Ye(e);return t?{value:e,valid:t}:{valid:!1,message:"Must be a non-empty string."}},default:"p"}),t("forced_root_block_attrs",{processor:"object",default:{}}),t("newline_behavior",{processor:e=>{const t=j(["block","linebreak","invert","default"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: block, linebreak, invert or default."}},default:"default"}),t("br_newline_selector",{processor:"string",default:".mce-toc h2,figcaption,caption"}),t("no_newline_selector",{processor:"string",default:""}),t("keep_styles",{processor:"boolean",default:!0}),t("end_container_on_empty_block",{processor:e=>y(e)||h(e)?{valid:!0,value:e}:{valid:!1,message:"Must be boolean or a string"},default:"blockquote"}),t("font_size_style_values",{processor:"string",default:"xx-small,x-small,small,medium,large,x-large,xx-large"}),t("font_size_legacy_values",{processor:"string",default:"xx-small,small,medium,large,x-large,xx-large,300%"}),t("font_size_classes",{processor:"string",default:""}),t("automatic_uploads",{processor:"boolean",default:!0}),t("images_reuse_filename",{processor:"boolean",default:!1}),t("images_replace_blob_uris",{processor:"boolean",default:!0}),t("icons",{processor:"string",default:""}),t("icons_url",{processor:"string",default:""}),t("images_upload_url",{processor:"string",default:""}),t("images_upload_base_path",{processor:"string",default:""}),t("images_upload_credentials",{processor:"boolean",default:!1}),t("images_upload_handler",{processor:"function"}),t("language",{processor:"string",default:"en"}),t("language_url",{processor:"string",default:""}),t("entity_encoding",{processor:"string",default:"named"}),t("indent",{processor:"boolean",default:!0}),t("indent_before",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_after",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_use_margin",{processor:"boolean",default:!1}),t("indentation",{processor:"string",default:"40px"}),t("content_css",{processor:e=>{const t=!1===e||h(e)||_(e,h);return t?h(e)?{value:$(e.split(","),qe),valid:t}:v(e)?{value:e,valid:t}:!1===e?{value:[],valid:t}:{value:e,valid:t}:{valid:!1,message:"Must be false, a string or an array of strings."}},default:Fc(e)?[]:["default"]}),t("content_style",{processor:"string"}),t("content_css_cors",{processor:"boolean",default:!1}),t("font_css",{processor:e=>{const t=h(e)||_(e,h);return t?{value:v(e)?e:$(e.split(","),qe),valid:t}:{valid:!1,message:"Must be a string or an array of strings."}},default:[]}),t("inline_boundaries",{processor:"boolean",default:!0}),t("inline_boundaries_selector",{processor:"string",default:"a[href],code,span.mce-annotation"}),t("object_resizing",{processor:e=>{const t=y(e)||h(e);return t?!1===e||Il.isiPhone()||Il.isiPad()?{value:"",valid:t}:{value:!0===e?"table,img,figure.image,div,video,iframe":e,valid:t}:{valid:!1,message:"Must be boolean or a string"}},default:!Pl}),t("resize_img_proportional",{processor:"boolean",default:!0}),t("event_root",{processor:"object"}),t("service_message",{processor:"string"}),t("theme",{processor:e=>!1===e||h(e)||S(e),default:"silver"}),t("theme_url",{processor:"string"}),t("formats",{processor:"object"}),t("format_empty_lines",{processor:"boolean",default:!1}),t("format_noneditable_selector",{processor:"string",default:""}),t("preview_styles",{processor:e=>{const t=!1===e||h(e);return t?{value:!1===e?"":e,valid:t}:{valid:!1,message:"Must be false or a string"}},default:"font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow"}),t("custom_ui_selector",{processor:"string",default:""}),t("hidden_input",{processor:"boolean",default:!0}),t("submit_patch",{processor:"boolean",default:!0}),t("encoding",{processor:"string"}),t("add_form_submit_trigger",{processor:"boolean",default:!0}),t("add_unload_trigger",{processor:"boolean",default:!0}),t("custom_undo_redo_levels",{processor:"number",default:0}),t("disable_nodechange",{processor:"boolean",default:!1}),t("readonly",{processor:"boolean",default:!1}),t("editable_root",{processor:"boolean",default:!0}),t("plugins",{processor:"string[]",default:[]}),t("external_plugins",{processor:"object"}),t("forced_plugins",{processor:"string[]"}),t("model",{processor:"string",default:e.hasPlugin("rtc")?"plugin":"dom"}),t("model_url",{processor:"string"}),t("block_unsupported_drop",{processor:"boolean",default:!0}),t("visual",{processor:"boolean",default:!0}),t("visual_table_class",{processor:"string",default:"mce-item-table"}),t("visual_anchor_class",{processor:"string",default:"mce-item-anchor"}),t("iframe_aria_text",{processor:"string",default:"Rich Text Area. Press ALT-0 for help."}),t("setup",{processor:"function"}),t("init_instance_callback",{processor:"function"}),t("url_converter",{processor:"function",default:e.convertURL}),t("url_converter_scope",{processor:"object",default:e}),t("urlconverter_callback",{processor:"function"}),t("allow_conditional_comments",{processor:"boolean",default:!1}),t("allow_html_data_urls",{processor:"boolean",default:!1}),t("allow_svg_data_urls",{processor:"boolean"}),t("allow_html_in_named_anchor",{processor:"boolean",default:!1}),t("allow_script_urls",{processor:"boolean",default:!1}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("convert_fonts_to_spans",{processor:"boolean",default:!0,deprecated:!0}),t("fix_list_elements",{processor:"boolean",default:!1}),t("preserve_cdata",{processor:"boolean",default:!1}),t("remove_trailing_brs",{processor:"boolean",default:!0}),t("pad_empty_with_br",{processor:"boolean",default:!1}),t("inline_styles",{processor:"boolean",default:!0,deprecated:!0}),t("element_format",{processor:"string",default:"html"}),t("entities",{processor:"string"}),t("schema",{processor:"string",default:"html5"}),t("convert_urls",{processor:"boolean",default:!0}),t("relative_urls",{processor:"boolean",default:!0}),t("remove_script_host",{processor:"boolean",default:!0}),t("custom_elements",{processor:"string"}),t("extended_valid_elements",{processor:"string"}),t("invalid_elements",{processor:"string"}),t("invalid_styles",{processor:Zl}),t("valid_children",{processor:"string"}),t("valid_classes",{processor:Zl}),t("valid_elements",{processor:"string"}),t("valid_styles",{processor:Zl}),t("verify_html",{processor:"boolean",default:!0}),t("auto_focus",{processor:e=>h(e)||!0===e}),t("browser_spellcheck",{processor:"boolean",default:!1}),t("protect",{processor:"array"}),t("images_file_types",{processor:"string",default:"jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp"}),t("deprecation_warnings",{processor:"boolean",default:!0}),t("a11y_advanced_options",{processor:"boolean",default:!1}),t("api_key",{processor:"string"}),t("paste_block_drop",{processor:"boolean",default:!1}),t("paste_data_images",{processor:"boolean",default:!0}),t("paste_preprocess",{processor:"function"}),t("paste_postprocess",{processor:"function"}),t("paste_webkit_styles",{processor:"string",default:"none"}),t("paste_remove_styles_if_webkit",{processor:"boolean",default:!0}),t("paste_merge_formats",{processor:"boolean",default:!0}),t("smart_paste",{processor:"boolean",default:!0}),t("paste_as_text",{processor:"boolean",default:!1}),t("paste_tab_spaces",{processor:"number",default:4}),t("text_patterns",{processor:e=>_(e,p)||!1===e?{value:Hl(!1===e?[]:e),valid:!0}:{valid:!1,message:"Must be an array of objects or false."},default:[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}]}),t("text_patterns_lookup",{processor:e=>{return S(e)?{value:(t=e,e=>{const o=t(e);return Hl(o)}),valid:!0}:{valid:!1,message:"Must be a single function"};var t},default:e=>[]}),t("noneditable_class",{processor:"string",default:"mceNonEditable"}),t("editable_class",{processor:"string",default:"mceEditable"}),t("noneditable_regexp",{processor:e=>_(e,zl)?{value:e,valid:!0}:zl(e)?{value:[e],valid:!0}:{valid:!1,message:"Must be a RegExp or an array of RegExp."},default:[]}),t("table_tab_navigation",{processor:"boolean",default:!0}),t("highlight_on_focus",{processor:"boolean",default:!1}),t("xss_sanitization",{processor:"boolean",default:!0}),t("details_initial_state",{processor:e=>{const t=j(["inherited","collapsed","expanded"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: inherited, collapsed, or expanded."}},default:"inherited"}),t("details_serialized_state",{processor:e=>{const t=j(["inherited","collapsed","expanded"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: inherited, collapsed, or expanded."}},default:"inherited"}),t("init_content_sync",{processor:"boolean",default:!1}),t("newdocument_content",{processor:"string",default:""}),t("force_hex_color",{processor:e=>{const t=["always","rgb_only","off"],o=j(t,e);return o?{value:e,valid:o}:{valid:!1,message:`Must be one of: ${t.join(", ")}.`}},default:"off"}),t("sandbox_iframes",{processor:"boolean",default:!1}),t("convert_unsafe_embeds",{processor:"boolean",default:!1}),e.on("ScriptsLoaded",(()=>{t("directionality",{processor:"string",default:ni.isRtl()?"rtl":void 0}),t("placeholder",{processor:"string",default:Fl.getAttrib(e.getElement(),"placeholder")})}))})(n);const s=this.options.get;s("deprecation_warnings")&&qC(t,r);const a=s("suffix");a&&(o.suffix=a),this.suffix=o.suffix;const i=s("base_url");i&&o._setBaseUrl(i),this.baseUri=o.baseURI;const l=hc(n);l&&(Ja.ScriptLoader._setReferrerPolicy(l),Ya.DOM.styleSheetLoader._setReferrerPolicy(l));const c=Gc(n);C(c)&&Ya.DOM.styleSheetLoader._setContentCssCors(c),ri.languageLoad=s("language_load"),ri.baseURL=o.baseURL,this.setDirty(!1),this.documentBaseURI=new px($l(n),{base_uri:this.baseUri}),this.baseURI=this.baseUri,this.inline=Fc(n),this.hasVisual=Jc(n),this.shortcuts=new _L(this),this.editorCommands=new qB(this),jB(this);const d=s("cache_suffix");d&&(At.cacheSuffix=d.replace(/^[\?\&]+/,"")),this.ui={registry:EL(),styleSheetLoader:void 0,show:E,hide:E,setEnabled:E,isEnabled:P},this.mode=yL(n),o.dispatch("SetupEditor",{editor:this});const m=od(n);S(m)&&m.call(n,n)}render(){uB(this)}focus(e){this.execCommand("mceFocus",!1,e)}hasFocus(){return ap(this)}translate(e){return ni.translate(e)}getParam(e,t,o){const n=this.options;return n.isRegistered(e)||(C(o)?n.register(e,{processor:o,default:t}):n.register(e,{processor:P,default:t})),n.isSet(e)||w(t)?n.get(e):t}hasPlugin(e,t){return!(!j(Kc(this),e)||t&&void 0===cS.get(e))}nodeChanged(e){this._nodeChangeDispatcher.nodeChanged(e)}addCommand(e,t,o){this.editorCommands.addCommand(e,t,o)}addQueryStateHandler(e,t,o){this.editorCommands.addQueryStateHandler(e,t,o)}addQueryValueHandler(e,t,o){this.editorCommands.addQueryValueHandler(e,t,o)}addShortcut(e,t,o,n){this.shortcuts.add(e,t,o,n)}execCommand(e,t,o,n){return this.editorCommands.execCommand(e,t,o,n)}queryCommandState(e){return this.editorCommands.queryCommandState(e)}queryCommandValue(e){return this.editorCommands.queryCommandValue(e)}queryCommandSupported(e){return this.editorCommands.queryCommandSupported(e)}show(){const e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable="true":(TL.show(e.getContainer()),TL.hide(e.id)),e.load(),e.dispatch("show"))}hide(){const e=this;e.hidden||(e.save(),e.inline?(e.getBody().contentEditable="false",e===e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(TL.hide(e.getContainer()),TL.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.dispatch("hide"))}isHidden(){return this.hidden}setProgressState(e,t){this.dispatch("ProgressState",{state:e,time:t})}load(e={}){const t=this,o=t.getElement();if(t.removed)return"";if(o){const n={...e,load:!0},r=er(o)?o.value:o.innerHTML,s=t.setContent(r,n);return n.no_events||t.dispatch("LoadContent",{...n,element:o}),s}return""}save(e={}){const t=this;let o=t.getElement();if(!o||!t.initialized||t.removed)return"";const n={...e,save:!0,element:o};let r=t.getContent(n);const s={...n,content:r};if(s.no_events||t.dispatch("SaveContent",s),"raw"===s.format&&t.dispatch("RawSaveContent",s),r=s.content,er(o))o.value=r;else{!e.is_removing&&t.inline||(o.innerHTML=r);const n=TL.getParent(t.id,"form");n&&DL(n.elements,(e=>e.name!==t.id||(e.value=r,!1)))}return s.element=n.element=o=null,!1!==s.set_dirty&&t.setDirty(!1),r}setContent(e,t){return LC(this,e,t)}getContent(e){return BC(this,e)}insertContent(e,t){t&&(e=OL({content:e},t)),this.execCommand("mceInsertContent",!1,e)}resetContent(e){void 0===e?LC(this,this.startContent,{format:"raw"}):LC(this,e),this.undoManager.reset(),this.setDirty(!1),this.nodeChanged()}isDirty(){return!this.isNotDirty}setDirty(e){const t=!this.isNotDirty;this.isNotDirty=!e,e&&e!==t&&this.dispatch("dirty")}getContainer(){const e=this;return e.container||(e.container=e.editorContainer||TL.get(e.id+"_parent")),e.container}getContentAreaContainer(){return this.contentAreaContainer}getElement(){return this.targetElm||(this.targetElm=TL.get(this.id)),this.targetElm}getWin(){const e=this;if(!e.contentWindow){const t=e.iframeElement;t&&(e.contentWindow=t.contentWindow)}return e.contentWindow}getDoc(){const e=this;if(!e.contentDocument){const t=e.getWin();t&&(e.contentDocument=t.document)}return e.contentDocument}getBody(){var e,t;const o=this.getDoc();return null!==(t=null!==(e=this.bodyElement)&&void 0!==e?e:null==o?void 0:o.body)&&void 0!==t?t:null}convertURL(e,t,o){const n=this,r=n.options.get,s=rd(n);if(S(s))return s.call(n,e,o,!0,t);if(!r("convert_urls")||"link"===o||p(o)&&"LINK"===o.nodeName||0===e.indexOf("file:")||0===e.length)return e;const a=new px(e);return"http"!==a.protocol&&"https"!==a.protocol&&""!==a.protocol?e:r("relative_urls")?n.documentBaseURI.toRelative(e):e=n.documentBaseURI.toAbsolute(e,r("remove_script_host"))}addVisual(e){SB(this,e)}setEditableRoot(e){((e,t)=>{e._editableRoot!==t&&(e._editableRoot=t,e.readonly||(e.getBody().contentEditable=String(e.hasEditableRoot()),e.nodeChanged()),((e,t)=>{e.dispatch("EditableRootStateChange",{state:t})})(e,t))})(this,e)}hasEditableRoot(){return this._editableRoot}remove(){YC(this)}destroy(e){XC(this,e)}uploadImages(){return this.editorUpload.uploadImages()}_scanForImages(){return this.editorUpload.scanForImages()}}const ML=Ya.DOM,NL=Bt.each;let RL,BL=!1,LL=[];const HL=e=>{const t=e.type;NL(zL.get(),(o=>{switch(t){case"scroll":o.dispatch("ScrollWindow",e);break;case"resize":o.dispatch("ResizeWindow",e)}}))},IL=e=>{if(e!==BL){const t=Ya.DOM;e?(t.bind(window,"resize",HL),t.bind(window,"scroll",HL)):(t.unbind(window,"resize",HL),t.unbind(window,"scroll",HL)),BL=e}},PL=e=>{const t=LL;return LL=Y(LL,(t=>e!==t)),zL.activeEditor===e&&(zL.activeEditor=LL.length>0?LL[0]:null),zL.focusedEditor===e&&(zL.focusedEditor=null),t.length!==LL.length},FL="CSS1Compat"!==document.compatMode,zL={...sL,baseURI:null,baseURL:null,defaultOptions:{},documentBaseURL:null,suffix:null,majorVersion:"6",minorVersion:"8.2",releaseDate:"2023-12-11",i18n:ni,activeEditor:null,focusedEditor:null,setup(){const e=this;let t="",o="",n=px.getDocumentBaseUrl(document.location);/^[^:]+:\/\/\/?[^\/]+\//.test(n)&&(n=n.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(n)||(n+="/"));const r=window.tinymce||window.tinyMCEPreInit;if(r)t=r.base||r.baseURL,o=r.suffix;else{const e=document.getElementsByTagName("script");for(let n=0;n{ri.PluginManager.urls[t]=e}))},init(e){const t=this;let o;const n=Bt.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu"," ");let r=e=>{o=e};const s=()=>{let o=0;const a=[];let i;ML.unbind(window,"ready",s),(o=>{const n=e[o];n&&n.apply(t,[])})("onpageload"),i=((e,t)=>{const o=[],n=S(t)?e=>W(o,(o=>t(o,e))):e=>j(o,e);for(let t=0,r=e.length;tAt.browser.isIE()||At.browser.isEdge()?(fS("TinyMCE does not support the browser you are using. For a list of supported browsers please see: https://www.tiny.cloud/docs/tinymce/6/support/#supportedwebbrowsers"),[]):FL?(fS("Failed to initialize the editor as the document is not in standards mode. TinyMCE requires standards mode."),[]):h(e.selector)?ML.select(e.selector):C(e.target)?[e.target]:[])(e)),Bt.each(i,(e=>{var o;(o=t.get(e.id))&&o.initialized&&!(o.getContainer()||o.getBody()).parentNode&&(PL(o),o.unbindAllNativeEvents(),o.destroy(!0),o.removed=!0)})),i=Bt.grep(i,(e=>!t.get(e.id))),0===i.length?r([]):NL(i,(s=>{((e,t)=>e.inline&&t.tagName.toLowerCase()in n)(e,s)?fS("Could not initialize inline editor on invalid inline target element",s):((e,n,s)=>{const l=new AL(e,n,t);a.push(l),l.on("init",(()=>{++o===i.length&&r(a)})),l.targetElm=l.targetElm||s,l.render()})((e=>{let t=e.id;return t||(t=ke(e,"name").filter((e=>!ML.get(e))).getOrThunk(ML.uniqueId),e.setAttribute("id",t)),t})(s),e,s)}))};return ML.bind(window,"ready",s),new Promise((e=>{o?e(o):r=t=>{e(t)}}))},get(e){return 0===arguments.length?LL.slice(0):h(e)?ee(LL,(t=>t.id===e)).getOr(null):k(e)&&LL[e]?LL[e]:null},add(e){const t=this,o=t.get(e.id);return o===e||(null===o&&LL.push(e),IL(!0),t.activeEditor=e,t.dispatch("AddEditor",{editor:e}),RL||(RL=e=>{const o=t.dispatch("BeforeUnload");if(o.returnValue)return e.preventDefault(),e.returnValue=o.returnValue,o.returnValue},window.addEventListener("beforeunload",RL))),e},createEditor(e,t){return this.add(new AL(e,t,this))},remove(e){const t=this;let o;if(e){if(!h(e))return o=e,b(t.get(o.id))?null:(PL(o)&&t.dispatch("RemoveEditor",{editor:o}),0===LL.length&&window.removeEventListener("beforeunload",RL),o.remove(),IL(LL.length>0),o);NL(ML.select(e),(e=>{o=t.get(e.id),o&&t.remove(o)}))}else for(let e=LL.length-1;e>=0;e--)t.remove(LL[e])},execCommand(e,t,o){var n;const r=this,s=p(o)?null!==(n=o.id)&&void 0!==n?n:o.index:o;switch(e){case"mceAddEditor":if(!r.get(s)){const e=o.options;new AL(s,e,r).render()}return!0;case"mceRemoveEditor":{const e=r.get(s);return e&&e.remove(),!0}case"mceToggleEditor":{const e=r.get(s);return e?(e.isHidden()?e.show():e.hide(),!0):(r.execCommand("mceAddEditor",!1,o),!0)}}return!!r.activeEditor&&r.activeEditor.execCommand(e,t,o)},triggerSave:()=>{NL(LL,(e=>{e.save()}))},addI18n:(e,t)=>{ni.add(e,t)},translate:e=>ni.translate(e),setActive(e){const t=this.activeEditor;this.activeEditor!==e&&(t&&t.dispatch("deactivate",{relatedTarget:e}),e.dispatch("activate",{relatedTarget:t})),this.activeEditor=e},_setBaseUrl(e){this.baseURL=new px(this.documentBaseURL).toAbsolute(e.replace(/\/+$/,"")),this.baseURI=new px(this.baseURL)}};zL.setup();const VL=(()=>{const e=ai();return{FakeClipboardItem:e=>({items:e,types:he(e),getType:t=>ke(e,t).getOrUndefined()}),write:t=>{e.set(t)},read:()=>e.get().getOrUndefined(),clear:e.clear}})(),ZL=Math.min,UL=Math.max,jL=Math.round,WL=(e,t,o)=>{let n=t.x,r=t.y;const s=e.w,a=e.h,i=t.w,l=t.h,c=(o||"").split("");return"b"===c[0]&&(r+=l),"r"===c[1]&&(n+=i),"c"===c[0]&&(r+=jL(l/2)),"c"===c[1]&&(n+=jL(i/2)),"b"===c[3]&&(r-=a),"r"===c[4]&&(n-=s),"c"===c[3]&&(r-=jL(a/2)),"c"===c[4]&&(n-=jL(s/2)),$L(n,r,s,a)},$L=(e,t,o,n)=>({x:e,y:t,w:o,h:n}),qL={inflate:(e,t,o)=>$L(e.x-t,e.y-o,e.w+2*t,e.h+2*o),relativePosition:WL,findBestRelativePosition:(e,t,o,n)=>{for(let r=0;r=o.x&&s.x+s.w<=o.w+o.x&&s.y>=o.y&&s.y+s.h<=o.h+o.y)return n[r]}return null},intersect:(e,t)=>{const o=UL(e.x,t.x),n=UL(e.y,t.y),r=ZL(e.x+e.w,t.x+t.w),s=ZL(e.y+e.h,t.y+t.h);return r-o<0||s-n<0?null:$L(o,n,r-o,s-n)},clamp:(e,t,o)=>{let n=e.x,r=e.y,s=e.x+e.w,a=e.y+e.h;const i=t.x+t.w,l=t.y+t.h,c=UL(0,t.x-n),d=UL(0,t.y-r),m=UL(0,s-i),u=UL(0,a-l);return n+=c,r+=d,o&&(s+=c,a+=d,n-=m,r-=u),s-=m,a-=u,$L(n,r,s-n,a-r)},create:$L,fromClientRect:e=>$L(e.left,e.top,e.width,e.height)},GL=(()=>{const e={},t={},o={};return{load:(o,n)=>{const r=`Script at URL "${n}" failed to load`,s=`Script at URL "${n}" did not call \`tinymce.Resource.add('${o}', data)\` within 1 second`;if(void 0!==e[o])return e[o];{const a=new Promise(((e,a)=>{const i=((e,t,o=1e3)=>{let n=!1,r=null;const s=e=>(...t)=>{n||(n=!0,null!==r&&(clearTimeout(r),r=null),e.apply(null,t))},a=s(e),i=s(t);return{start:(...e)=>{n||null!==r||(r=setTimeout((()=>i.apply(null,e)),o))},resolve:a,reject:i}})(e,a);t[o]=i.resolve,Ja.ScriptLoader.loadScript(n).then((()=>i.start(s)),(()=>i.reject(r)))}));return e[o]=a,a}},add:(n,r)=>{void 0!==t[n]&&(t[n](r),delete t[n]),e[n]=Promise.resolve(r),o[n]=r},has:e=>e in o,get:e=>o[e],unload:t=>{delete e[t]}}})();let KL;try{const e="__storage_test__";KL=window.localStorage,KL.setItem(e,e),KL.removeItem(e)}catch(e){KL=(()=>{let e={},t=[];const o={getItem:t=>e[t]||null,setItem:(o,n)=>{t.push(o),e[o]=String(n)},key:e=>t[e],removeItem:o=>{t=t.filter((e=>e===o)),delete e[o]},clear:()=>{t=[],e={}},length:0};return Object.defineProperty(o,"length",{get:()=>t.length,configurable:!1,enumerable:!1}),o})()}const YL={geom:{Rect:qL},util:{Delay:qh,Tools:Bt,VK:Dg,URI:px,EventDispatcher:nL,Observable:sL,I18n:ni,LocalStorage:KL,ImageUploader:e=>{const t=xS(),o=ES(e,t);return{upload:(t,n=!0)=>o.upload(t,n?_S(e):void 0)}}},dom:{EventUtils:za,TreeWalker:Zn,TextSeeker:Oi,DOMUtils:Ya,ScriptLoader:Ja,RangeUtils:mh,Serializer:RC,StyleSheetLoader:Zs,ControlSelection:Bg,BookmarkManager:xg,Selection:OC,Event:za.Event},html:{Styles:Aa,Entities:ia,Node:Ep,Schema:ya,DomParser:Mx,Writer:Wp,Serializer:$p},Env:At,AddOnManager:ri,Annotator:wg,Formatter:zS,UndoManager:ZS,EditorCommands:qB,WindowManager:mS,NotificationManager:lS,EditorObservable:mL,Shortcuts:_L,Editor:AL,FocusManager:$h,EditorManager:zL,DOM:Ya.DOM,ScriptLoader:Ja.ScriptLoader,PluginManager:cS,ThemeManager:dS,ModelManager:QC,IconManager:JC,Resource:GL,FakeClipboard:VL,trim:Bt.trim,isArray:Bt.isArray,is:Bt.is,toArray:Bt.toArray,makeMap:Bt.makeMap,each:Bt.each,map:Bt.map,grep:Bt.grep,inArray:Bt.inArray,extend:Bt.extend,walk:Bt.walk,resolve:Bt.resolve,explode:Bt.explode,_addCacheSuffix:Bt._addCacheSuffix},XL=Bt.extend(zL,YL);(e=>{window.tinymce=e,window.tinyMCE=e})(XL),(e=>{try{t.exports=e}catch(e){}})(XL)}();var n=e(o.exports);tinymce.IconManager.add("default",{icons:{"accessibility-check":'',"accordion-toggle":'',accordion:'',"action-next":'',"action-prev":'',addtag:'',"ai-prompt":'',ai:'',"align-center":'',"align-justify":'',"align-left":'',"align-none":'',"align-right":'',"arrow-left":'',"arrow-right":'',bold:'',bookmark:'',"border-style":'',"border-width":'',brightness:'',browse:'',cancel:'',"cell-background-color":'',"cell-border-color":'',"change-case":'',"character-count":'',"checklist-rtl":'',checklist:'',checkmark:'',"chevron-down":'',"chevron-left":'',"chevron-right":'',"chevron-up":'',close:'',"code-sample":'',"color-levels":'',"color-picker":'',"color-swatch-remove-color":'',"color-swatch":'',"comment-add":'',comment:'',contrast:'',copy:'',crop:'',"cut-column":'',"cut-row":'',cut:'',"document-properties":'',drag:'',"duplicate-column":'',"duplicate-row":'',duplicate:'',"edit-block":'',"edit-image":'',"embed-page":'',embed:'',emoji:'',export:'',fill:'',"flip-horizontally":'',"flip-vertically":'',footnote:'',"format-painter":'',format:'',fullscreen:'',gallery:'',gamma:'',help:'',"highlight-bg-color":'',home:'',"horizontal-rule":'',"image-options":'',image:'',indent:'',info:'',"insert-character":'',"insert-time":'',invert:'',italic:'',language:'',"line-height":'',line:'',link:'',"list-bull-circle":'',"list-bull-default":'',"list-bull-square":'',"list-num-default-rtl":'',"list-num-default":'',"list-num-lower-alpha-rtl":'',"list-num-lower-alpha":'',"list-num-lower-greek-rtl":'',"list-num-lower-greek":'',"list-num-lower-roman-rtl":'',"list-num-lower-roman":'',"list-num-upper-alpha-rtl":'',"list-num-upper-alpha":'',"list-num-upper-roman-rtl":'',"list-num-upper-roman":'',lock:'',ltr:'',minus:'',"more-drawer":'',"new-document":'',"new-tab":'',"non-breaking":'',notice:'',"ordered-list-rtl":'',"ordered-list":'',orientation:'',outdent:'',"page-break":'',paragraph:'',"paste-column-after":'',"paste-column-before":'',"paste-row-after":'',"paste-row-before":'',"paste-text":'',paste:'',"permanent-pen":'',plus:'',preferences:'',preview:'',print:'',quote:'',redo:'',reload:'',"remove-formatting":'',remove:'',"resize-handle":'',resize:'',"restore-draft":'',"rotate-left":'',"rotate-right":'',rtl:'',save:'',search:'',"select-all":'',selected:'',send:'',settings:'',sharpen:'',sourcecode:'',"spell-check":'',"strike-through":'',subscript:'',superscript:'',"table-caption":'',"table-cell-classes":'',"table-cell-properties":'',"table-cell-select-all":'',"table-cell-select-inner":'',"table-classes":'',"table-delete-column":'',"table-delete-row":'',"table-delete-table":'',"table-insert-column-after":'',"table-insert-column-before":'',"table-insert-row-above":'',"table-insert-row-after":'',"table-left-header":'',"table-merge-cells":'',"table-row-numbering-rtl":'',"table-row-numbering":'',"table-row-properties":'',"table-split-cells":'',"table-top-header":'',table:'',"template-add":'',template:'',"temporary-placeholder":'',"text-color":'',"text-size-decrease":'',"text-size-increase":'',toc:'',translate:'',typography:'',underline:'',undo:'',unlink:'',unlock:'',"unordered-list":'',unselected:'',upload:'',user:'',"vertical-align":'',visualblocks:'',visualchars:'',warning:'',"zoom-in":'',"zoom-out":''}}),function(){const e=Object.getPrototypeOf,t=(e,t,o)=>{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},o=e=>o=>(e=>{const o=typeof e;return null===e?"null":"object"===o&&Array.isArray(e)?"array":"object"===o&&t(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":o})(o)===e,n=e=>t=>typeof t===e,r=e=>t=>e===t,s=o("string"),a=o("object"),i=o=>((o,n)=>a(o)&&t(o,n,((t,o)=>e(t)===o)))(o,Object),l=o("array"),c=r(null),d=n("boolean"),m=r(void 0),u=e=>null==e,g=e=>!u(e),h=n("function"),p=n("number"),f=(e,t)=>{if(l(e)){for(let o=0,n=e.length;o{},b=e=>()=>e(),y=(e,t)=>(...o)=>e(t.apply(null,o)),w=e=>()=>e,x=e=>e,C=(e,t)=>e===t;function S(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const k=e=>t=>!e(t),_=e=>()=>{throw new Error(e)},E=e=>e(),T=w(!1),O=w(!0);class D{constructor(e,t){this.tag=e,this.value=t}static some(e){return new D(!0,e)}static none(){return D.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?D.some(e(this.value)):D.none()}bind(e){return this.tag?e(this.value):D.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:D.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return g(e)?D.some(e):D.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}D.singletonNone=new D(!1);const A=Array.prototype.slice,M=Array.prototype.indexOf,N=Array.prototype.push,R=(e,t)=>M.call(e,t),B=(e,t)=>{const o=R(e,t);return-1===o?D.none():D.some(o)},L=(e,t)=>R(e,t)>-1,H=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),j=(e,t,o)=>(z(e,((e,n)=>{o=t(o,e,n)})),o),W=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oq(F(e,t)),K=(e,t)=>{for(let o=0,n=e.length;o{const t=A.call(e,0);return t.reverse(),t},X=(e,t)=>Z(e,(e=>!L(t,e))),J=(e,t)=>{const o={};for(let n=0,r=e.length;n[e],ee=(e,t)=>{const o=A.call(e,0);return o.sort(t),o},te=(e,t)=>t>=0&&tte(e,0),ne=e=>te(e,e.length-1),re=h(Array.from)?Array.from:e=>A.call(e),se=(e,t)=>{for(let o=0;o{const o=ae(e);for(let n=0,r=o.length;nde(e,((e,o)=>({k:o,v:t(e,o)}))),de=(e,t)=>{const o={};return le(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},me=e=>(t,o)=>{e[o]=t},ue=(e,t,o,n)=>{le(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},ge=(e,t)=>{const o={};return ue(e,t,me(o),v),o},he=(e,t)=>{const o=[];return le(e,((e,n)=>{o.push(t(e,n))})),o},pe=(e,t)=>{const o=ae(e);for(let n=0,r=o.length;nhe(e,x),ve=(e,t)=>be(e,t)?D.from(e[t]):D.none(),be=(e,t)=>ie.call(e,t),ye=(e,t)=>be(e,t)&&void 0!==e[t]&&null!==e[t],we=(e,t,o=C)=>e.exists((e=>o(e,t))),xe=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te.isSome()&&t.isSome()?D.some(o(e.getOrDie(),t.getOrDie())):D.none(),Se=(e,t)=>null!=e?D.some(t(e)):D.none(),ke=(e,t)=>e?D.some(t):D.none(),_e=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Ee=(e,t)=>Oe(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Te=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!m(n)||r+t.length<=n)},Oe=(e,t)=>_e(e,t,0),De=(e,t)=>_e(e,t,e.length-t.length),Ae=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Me=e=>e.length>0,Ne=e=>!Me(e),Re=e=>void 0!==e.style&&h(e.style.getPropertyValue),Be=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Le={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Be(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return Be(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return Be(o)},fromDom:Be,fromPoint:(e,t,o)=>D.from(e.dom.elementFromPoint(t,o)).map(Be)},He="undefined"!=typeof window?window:Function("return this;")(),Ie=(e,t)=>((e,t)=>{let o=null!=t?t:He;for(let t=0;t{const o=((e,t)=>Ie(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},Fe=Object.getPrototypeOf,ze=e=>{const t=Ie("ownerDocument.defaultView",e);return a(e)&&((e=>Pe("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Fe(e).constructor.name))},Ve=e=>e.dom.nodeName.toLowerCase(),Ze=e=>t=>(e=>e.dom.nodeType)(t)===e,Ue=e=>je(e)&&ze(e.dom),je=Ze(1),We=Ze(3),$e=Ze(9),qe=Ze(11),Ge=e=>t=>je(t)&&Ve(t)===e,Ke=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Ye=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Xe=(e,t)=>e.dom===t.dom,Je=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Qe=e=>Le.fromDom(e.dom.ownerDocument),et=e=>$e(e)?e:Qe(e),tt=e=>Le.fromDom(et(e).dom.documentElement),ot=e=>Le.fromDom(et(e).dom.defaultView),nt=e=>D.from(e.dom.parentNode).map(Le.fromDom),rt=e=>D.from(e.dom.parentElement).map(Le.fromDom),st=e=>D.from(e.dom.offsetParent).map(Le.fromDom),at=e=>F(e.dom.childNodes,Le.fromDom),it=(e,t)=>{const o=e.dom.childNodes;return D.from(o[t]).map(Le.fromDom)},lt=e=>it(e,0),ct=(e,t)=>({element:e,offset:t}),dt=(e,t)=>{const o=at(e);return o.length>0&&tqe(e)&&g(e.dom.host),ut=h(Element.prototype.attachShadow)&&h(Node.prototype.getRootNode),gt=w(ut),ht=ut?e=>Le.fromDom(e.dom.getRootNode()):et,pt=e=>mt(e)?e:Le.fromDom(et(e).dom.body),ft=e=>{const t=ht(e);return mt(t)?D.some(t):D.none()},vt=e=>Le.fromDom(e.dom.host),bt=e=>g(e.dom.shadowRoot),yt=e=>{const t=We(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return ft(Le.fromDom(t)).fold((()=>o.body.contains(t)),(n=yt,r=vt,e=>n(r(e))));var n,r},wt=()=>xt(Le.fromDom(document)),xt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Le.fromDom(t)},Ct=(e,t,o)=>{if(!(s(o)||d(o)||p(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},St=(e,t,o)=>{Ct(e.dom,t,o)},kt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Ct(o,t,e)}))},_t=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Et=(e,t)=>D.from(_t(e,t)),Tt=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},Ot=(e,t)=>{e.dom.removeAttribute(t)},Dt=(e,t,o)=>{if(!s(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Re(e)&&e.style.setProperty(t,o)},At=(e,t)=>{Re(e)&&e.style.removeProperty(t)},Mt=(e,t,o)=>{const n=e.dom;Dt(n,t,o)},Nt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Dt(o,t,e)}))},Rt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{e.fold((()=>{At(o,t)}),(e=>{Dt(o,t,e)}))}))},Bt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||yt(e)?n:Lt(o,t)},Lt=(e,t)=>Re(e)?e.style.getPropertyValue(t):"",Ht=(e,t)=>{const o=e.dom,n=Lt(o,t);return D.from(n).filter((e=>e.length>0))},It=e=>{const t={},o=e.dom;if(Re(o))for(let e=0;e{const n=Le.fromTag(e);Mt(n,t,o);return Ht(n,t).isSome()},Ft=(e,t)=>{const o=e.dom;At(o,t),we(Et(e,"style").map(Ae),"")&&Ot(e,"style")},zt=e=>e.dom.offsetWidth,Vt=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Bt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>j(t,((t,o)=>{const n=Bt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!p(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Re(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Zt=Vt("height",(e=>{const t=e.dom;return yt(e)?t.getBoundingClientRect().height:t.offsetHeight})),Ut=e=>Zt.get(e),jt=e=>Zt.getOuter(e),Wt=(e,t)=>({left:e,top:t,translate:(o,n)=>Wt(e+o,t+n)}),$t=Wt,qt=(e,t)=>void 0!==e?e:void 0!==t?t:0,Gt=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return $t(o.offsetLeft,o.offsetTop);const s=qt(null==n?void 0:n.pageYOffset,r.scrollTop),a=qt(null==n?void 0:n.pageXOffset,r.scrollLeft),i=qt(r.clientTop,o.clientTop),l=qt(r.clientLeft,o.clientLeft);return Kt(e).translate(a-l,s-i)},Kt=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?$t(o.offsetLeft,o.offsetTop):yt(e)?(e=>{const t=e.getBoundingClientRect();return $t(t.left,t.top)})(t):$t(0,0)},Yt=Vt("width",(e=>e.dom.offsetWidth)),Xt=e=>Yt.get(e),Jt=e=>Yt.getOuter(e),Qt=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},eo=()=>to(0,0),to=(e,t)=>({major:e,minor:t}),oo={nu:to,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?eo():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return to(n(1),n(2))})(e,o)},unknown:eo},no=(e,t)=>{const o=String(t).toLowerCase();return W(e,(e=>e.search(o)))},ro=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,so=e=>t=>Te(t,e),ao=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Te(e,"edge/")&&Te(e,"chrome")&&Te(e,"safari")&&Te(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ro],search:e=>Te(e,"chrome")&&!Te(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Te(e,"msie")||Te(e,"trident")},{name:"Opera",versionRegexes:[ro,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:so("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:so("firefox")},{name:"Safari",versionRegexes:[ro,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Te(e,"safari")||Te(e,"mobile/"))&&Te(e,"applewebkit")}],io=[{name:"Windows",search:so("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Te(e,"iphone")||Te(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:so("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:so("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:so("linux"),versionRegexes:[]},{name:"Solaris",search:so("sunos"),versionRegexes:[]},{name:"FreeBSD",search:so("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:so("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],lo={browsers:w(ao),oses:w(io)},co="Edge",mo="Chromium",uo="Opera",go="Firefox",ho="Safari",po=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(co),isChromium:n(mo),isIE:n("IE"),isOpera:n(uo),isFirefox:n(go),isSafari:n(ho)}},fo={unknown:()=>po({current:void 0,version:oo.unknown()}),nu:po,edge:w(co),chromium:w(mo),ie:w("IE"),opera:w(uo),firefox:w(go),safari:w(ho)},vo="Windows",bo="Android",yo="Linux",wo="macOS",xo="Solaris",Co="FreeBSD",So="ChromeOS",ko=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(vo),isiOS:n("iOS"),isAndroid:n(bo),isMacOS:n(wo),isLinux:n(yo),isSolaris:n(xo),isFreeBSD:n(Co),isChromeOS:n(So)}},_o={unknown:()=>ko({current:void 0,version:oo.unknown()}),nu:ko,windows:w(vo),ios:w("iOS"),android:w(bo),linux:w(yo),macos:w(wo),solaris:w(xo),freebsd:w(Co),chromeos:w(So)},Eo=(e,t,o)=>{const n=lo.browsers(),r=lo.oses(),s=t.bind((e=>((e,t)=>se(t.brands,(t=>{const o=t.brand.toLowerCase();return W(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:oo.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>no(e,t).map((e=>{const o=oo.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(fo.unknown,fo.nu),a=((e,t)=>no(e,t).map((e=>{const o=oo.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(_o.unknown,_o.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:w(r),isiPhone:w(s),isTablet:w(l),isPhone:w(c),isTouch:w(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:w(d),isDesktop:w(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},To=e=>window.matchMedia(e).matches;let Oo=Qt((()=>Eo(navigator.userAgent,D.from(navigator.userAgentData),To)));const Do=()=>Oo(),Ao=e=>{const t=Le.fromDom((e=>{if(gt()&&g(e.target)){const t=Le.fromDom(e.target);if(je(t)&&bt(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return oe(t)}}return D.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=y(n,o);return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Mo=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Ao(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:S(No,e,t,s,r)}},No=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Ro=(e,t)=>{nt(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Bo=(e,t)=>{const o=(e=>D.from(e.dom.nextSibling).map(Le.fromDom))(e);o.fold((()=>{nt(e).each((e=>{Ho(e,t)}))}),(e=>{Ro(e,t)}))},Lo=(e,t)=>{lt(e).fold((()=>{Ho(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Ho=(e,t)=>{e.dom.appendChild(t.dom)},Io=(e,t)=>{z(t,(t=>{Ho(e,t)}))},Po=e=>{e.dom.textContent="",z(at(e),(e=>{Fo(e)}))},Fo=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},zo=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return $t(o,n)},Vo=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Zo=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Uo=e=>{const t=void 0===e?window:e,o=t.document,n=zo(Le.fromDom(o));return(e=>{const t=void 0===e?window:e;return Do().browser.isFirefox()?D.none():D.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return Zo(n.left,n.top,o,r)}),(e=>Zo(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},jo=()=>Le.fromDom(document),Wo=(e,t)=>e.view(t).fold(w([]),(t=>{const o=e.owner(t),n=Wo(e,o);return[t].concat(n)}));var $o=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?D.none():D.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(Le.fromDom)},owner:e=>Qe(e)});const qo=e=>{const t=jo(),o=zo(t),n=((e,t)=>{const o=t.owner(e),n=Wo(t,o);return D.some(n)})(e,$o);return n.fold(S(Gt,e),(t=>{const n=Kt(e),r=U(t,((e,t)=>{const o=Kt(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return $t(r.left+n.left+o.left,r.top+n.top+o.top)}))},Go=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Ko=e=>{const t=Gt(e),o=Jt(e),n=jt(e);return Go(t.left,t.top,o,n)},Yo=e=>{const t=qo(e),o=Jt(e),n=jt(e);return Go(t.left,t.top,o,n)},Xo=(e,t)=>{const o=Math.max(e.x,t.x),n=Math.max(e.y,t.y),r=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom);return Go(o,n,r-o,s-n)},Jo=()=>Uo(window);var Qo=tinymce.util.Tools.resolve("tinymce.ThemeManager");const en=e=>{const t=t=>t(e),o=w(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:O,isError:T,map:t=>on.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>D.some(e)};return r},tn=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:T,isError:O,map:t,mapError:t=>on.error(t(e)),bind:t,exists:T,forall:O,getOr:x,or:x,getOrThunk:E,orThunk:E,getOrDie:_(String(e)),each:v,toOptional:D.none};return o},on={value:en,error:tn,fromOption:(e,t)=>e.fold((()=>tn(t)),en)};var nn;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(nn||(nn={}));const rn=(e,t,o)=>e.stype===nn.Error?t(e.serror):o(e.svalue),sn=e=>({stype:nn.Value,svalue:e}),an=e=>({stype:nn.Error,serror:e}),ln=e=>e.fold(an,sn),cn=e=>rn(e,on.error,on.value),dn=sn,mn=e=>{const t=[],o=[];return z(e,(e=>{rn(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}},un=an,gn=(e,t)=>e.stype===nn.Value?t(e.svalue):e,hn=(e,t)=>e.stype===nn.Error?t(e.serror):e,pn=(e,t)=>e.stype===nn.Value?{stype:nn.Value,svalue:t(e.svalue)}:e,fn=(e,t)=>e.stype===nn.Error?{stype:nn.Error,serror:t(e.serror)}:e,vn=rn,bn=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),yn=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},wn=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;ni(e)&&i(t)?xn(e,t):t)),Cn=wn(((e,t)=>t)),Sn=e=>({tag:"defaultedThunk",process:e}),kn=e=>Sn(w(e)),_n=e=>({tag:"mergeWithThunk",process:e}),En=e=>y(un,q)(e),Tn=e=>{const t=mn(e);return t.errors.length>0?En(t.errors):dn(t.values)},On=e=>a(e)&&ae(e).length>100?" removed due to size":JSON.stringify(e,null,2),Dn=(e,t)=>un([{path:e,getErrorInfo:t}]),An=e=>({extract:(t,o)=>hn(e(o),(e=>((e,t)=>Dn(e,w(t)))(t,e))),toString:w("val")}),Mn=An(dn),Nn=(e,t,o,n)=>ve(t,o).fold((()=>((e,t,o)=>Dn(e,(()=>'Could not find valid *required* value for "'+t+'" in '+On(o))))(e,o,t)),n),Rn=(e,t,o,n)=>n(ve(e,t).getOrThunk((()=>o(e)))),Bn=(e,t,o,n,r)=>{const s=e=>r.extract(t.concat([n]),e),a=e=>e.fold((()=>dn(D.none())),(e=>{const o=r.extract(t.concat([n]),e);return pn(o,D.some)}));switch(e.tag){case"required":return Nn(t,o,n,s);case"defaultedThunk":return Rn(o,n,e.process,s);case"option":return((e,t,o)=>o(ve(e,t)))(o,n,a);case"defaultedOptionThunk":return((e,t,o,n)=>n(ve(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,a);case"mergeWithThunk":return Rn(o,n,w({}),(t=>{const n=xn(e.process(o),t);return s(n)}))}},Ln=e=>({extract:(t,o)=>e().extract(t,o),toString:()=>e().toString()}),Hn=e=>ae(ge(e,g)),In=e=>{const t=Pn(e),o=U(e,((e,t)=>yn(t,(t=>xn(e,{[t]:!0})),w(e))),{});return{extract:(e,n)=>{const r=d(n)?[]:Hn(n),s=Z(r,(e=>!ye(o,e)));return 0===s.length?t.extract(e,n):((e,t)=>Dn(e,(()=>"There are unsupported fields: ["+t.join(", ")+"] specified")))(e,s)},toString:t.toString}},Pn=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const s of o)yn(s,((o,s,a,i)=>{const l=Bn(a,e,t,o,i);vn(l,(e=>{r.push(...e)}),(e=>{n[s]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?un(r):dn(n)})(t,o,e),toString:()=>{const t=F(e,(e=>yn(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),Fn=e=>({extract:(t,o)=>{const n=F(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return Tn(n)},toString:()=>"array("+e.toString()+")"}),zn=(e,t)=>{const o=void 0!==t?t:x;return{extract:(t,n)=>{const r=[];for(const s of e){const e=s.extract(t,n);if(e.stype===nn.Value)return{stype:nn.Value,svalue:o(e.svalue)};r.push(e)}return Tn(r)},toString:()=>"oneOf("+F(e,(e=>e.toString())).join(", ")+")"}},Vn=(e,t)=>({extract:(o,n)=>{const r=ae(n),s=((t,o)=>Fn(An(e)).extract(t,o))(o,r);return gn(s,(e=>{const r=F(e,(e=>bn(e,e,{tag:"required",process:{}},t)));return Pn(r).extract(o,n)}))},toString:()=>"setOf("+t.toString()+")"}),Zn=y(Fn,Pn),Un=w(Mn),jn=(e,t)=>An((o=>{const n=typeof o;return e(o)?dn(o):un(`Expected type: ${t} but got: ${n}`)})),Wn=jn(p,"number"),$n=jn(s,"string"),qn=jn(d,"boolean"),Gn=jn(h,"function"),Kn=e=>{if(Object(e)!==e)return!0;switch({}.toString.call(e).slice(8,-1)){case"Boolean":case"Number":case"String":case"Date":case"RegExp":case"Blob":case"FileList":case"ImageData":case"ImageBitmap":case"ArrayBuffer":return!0;case"Array":case"Object":return Object.keys(e).every((t=>Kn(e[t])));default:return!1}},Yn=An((e=>Kn(e)?dn(e):un("Expected value to be acceptable for sending via postMessage"))),Xn=(e,t,o,n)=>ve(o,n).fold((()=>((e,t,o)=>Dn(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+On(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))),Jn=(e,t)=>({extract:(o,n)=>ve(n,e).fold((()=>((e,t)=>Dn(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>Xn(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+ae(t)}),Qn=e=>An((t=>e(t).fold(un,dn))),er=(e,t)=>Vn((t=>ln(e(t))),t),tr=(e,t,o)=>cn(((e,t,o)=>{const n=t.extract([e],o);return fn(n,(e=>({input:o,errors:e})))})(e,t,o)),or=e=>e.fold((e=>{throw new Error(rr(e))}),x),nr=(e,t,o)=>or(tr(e,t,o)),rr=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:w("... (only showing first ten failures)")}]):e;return F(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+On(e.input),sr=(e,t)=>Jn(e,ce(t,Pn)),ar=(e,t)=>((e,t)=>{const o=Qt(t);return{extract:(e,t)=>o().extract(e,t),toString:()=>o().toString()}})(0,t),ir=bn,lr=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),cr=e=>Qn((t=>L(e,t)?on.value(t):on.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`))),dr=e=>ir(e,e,{tag:"required",process:{}},Un()),mr=(e,t)=>ir(e,e,{tag:"required",process:{}},t),ur=e=>mr(e,Wn),gr=e=>mr(e,$n),hr=(e,t)=>ir(e,e,{tag:"required",process:{}},cr(t)),pr=e=>mr(e,Gn),fr=(e,t)=>ir(e,e,{tag:"required",process:{}},Pn(t)),vr=(e,t)=>ir(e,e,{tag:"required",process:{}},Zn(t)),br=(e,t)=>ir(e,e,{tag:"required",process:{}},Fn(t)),yr=e=>ir(e,e,{tag:"option",process:{}},Un()),wr=(e,t)=>ir(e,e,{tag:"option",process:{}},t),xr=e=>wr(e,Wn),Cr=e=>wr(e,$n),Sr=(e,t)=>wr(e,cr(t)),kr=e=>wr(e,Gn),_r=(e,t)=>wr(e,Fn(t)),Er=(e,t)=>wr(e,Pn(t)),Tr=(e,t)=>ir(e,e,kn(t),Un()),Or=(e,t,o)=>ir(e,e,kn(t),o),Dr=(e,t)=>Or(e,t,Wn),Ar=(e,t)=>Or(e,t,$n),Mr=(e,t,o)=>Or(e,t,cr(o)),Nr=(e,t)=>Or(e,t,qn),Rr=(e,t)=>Or(e,t,Gn),Br=(e,t,o)=>Or(e,t,Fn(o)),Lr=(e,t,o)=>Or(e,t,Pn(o)),Hr=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Ir=e=>{if(!l(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return z(e,((n,r)=>{const s=ae(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!l(i))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=ae(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!K(t,(e=>L(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o};Ir([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Pr=(e,t)=>((e,t)=>{const o={};return le(e,((e,n)=>{L(t,n)||(o[n]=e)})),o})(e,t),Fr=(e,t)=>((e,t)=>({[e]:t}))(e,t),zr=e=>(e=>{const t={};return z(e,(e=>{t[e.key]=e.value})),t})(e),Vr=(e,t)=>{const o=(e=>{const t=[],o=[];return z(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})(e);return o.errors.length>0?(n=o.errors,on.error(q(n))):((e,t)=>0===e.length?on.value(t):on.value(xn(t,Cn.apply(void 0,e))))(o.values,t);var n},Zr=e=>h(e)?e:T,Ur=(e,t,o)=>{let n=e.dom;const r=Zr(o);for(;n.parentNode;){n=n.parentNode;const e=Le.fromDom(n),o=t(e);if(o.isSome())return o;if(r(e))break}return D.none()},jr=(e,t,o)=>{const n=t(e),r=Zr(o);return n.orThunk((()=>r(e)?D.none():Ur(e,t,r)))},Wr=(e,t)=>Xe(e.element,t.event.target),$r={can:O,abort:T,run:v},qr=e=>{if(!ye(e,"can")&&!ye(e,"abort")&&!ye(e,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(e,null,2)+" does not have can, abort, or run!");return{...$r,...e}},Gr=e=>{const t=((e,t)=>(...o)=>j(e,((e,n)=>e&&t(n).apply(void 0,o)),!0))(e,(e=>e.can)),o=((e,t)=>(...o)=>j(e,((e,n)=>e||t(n).apply(void 0,o)),!1))(e,(e=>e.abort));return{can:t,abort:o,run:(...t)=>{z(e,(e=>{e.run.apply(void 0,t)}))}}},Kr=w,Yr=Kr("touchstart"),Xr=Kr("touchmove"),Jr=Kr("touchend"),Qr=Kr("touchcancel"),es=Kr("mousedown"),ts=Kr("mousemove"),os=Kr("mouseout"),ns=Kr("mouseup"),rs=Kr("mouseover"),ss=Kr("focusin"),as=Kr("focusout"),is=Kr("keydown"),ls=Kr("keyup"),cs=Kr("input"),ds=Kr("change"),ms=Kr("click"),us=Kr("transitioncancel"),gs=Kr("transitionend"),hs=Kr("transitionstart"),ps=Kr("selectstart"),fs=e=>w("alloy."+e),vs={tap:fs("tap")},bs=fs("focus"),ys=fs("blur.post"),ws=fs("paste.post"),xs=fs("receive"),Cs=fs("execute"),Ss=fs("focus.item"),ks=vs.tap,_s=fs("longpress"),Es=fs("sandbox.close"),Ts=fs("typeahead.cancel"),Os=fs("system.init"),Ds=fs("system.touchmove"),As=fs("system.touchend"),Ms=fs("system.scroll"),Ns=fs("system.resize"),Rs=fs("system.attached"),Bs=fs("system.detached"),Ls=fs("system.dismissRequested"),Hs=fs("system.repositionRequested"),Is=fs("focusmanager.shifted"),Ps=fs("slotcontainer.visibility"),Fs=fs("system.external.element.scroll"),zs=fs("change.tab"),Vs=fs("dismiss.tab"),Zs=fs("highlight"),Us=fs("dehighlight"),js=(e,t)=>{Gs(e,e.element,t,{})},Ws=(e,t,o)=>{Gs(e,e.element,t,o)},$s=e=>{js(e,Cs())},qs=(e,t,o)=>{Gs(e,t,o,{})},Gs=(e,t,o,n)=>{const r={target:t,...n};e.getSystem().triggerEvent(o,t,r)},Ks=(e,t,o,n)=>{e.getSystem().triggerEvent(o,t,n.event)},Ys=e=>zr(e),Xs=(e,t)=>({key:e,value:qr({abort:t})}),Js=e=>({key:e,value:qr({run:(e,t)=>{t.event.prevent()}})}),Qs=(e,t)=>({key:e,value:qr({run:t})}),ea=(e,t,o)=>({key:e,value:qr({run:(e,n)=>{t.apply(void 0,[e,n].concat(o))}})}),ta=e=>t=>({key:e,value:qr({run:(e,o)=>{Wr(e,o)&&t(e,o)}})}),oa=(e,t,o)=>((e,t)=>Qs(e,((o,n)=>{o.getSystem().getByUid(t).each((t=>{Ks(t,t.element,e,n)}))})))(e,t.partUids[o]),na=(e,t)=>Qs(e,((e,o)=>{const n=o.event,r=e.getSystem().getByDom(n.target).getOrThunk((()=>jr(n.target,(t=>e.getSystem().getByDom(t).toOptional()),T).getOr(e)));t(e,r,o)})),ra=e=>Qs(e,((e,t)=>{t.cut()})),sa=e=>Qs(e,((e,t)=>{t.stop()})),aa=(e,t)=>ta(e)(t),ia=ta(Rs()),la=ta(Bs()),ca=ta(Os()),da=(e=>t=>Qs(e,t))(Cs()),ma=e=>e.dom.innerHTML,ua=(e,t)=>{const o=Qe(e).dom,n=Le.fromDom(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,at(Le.fromDom(o))})(t,o);Io(n,r),Po(e),Ho(e,n)},ga=(e,t)=>Le.fromDom(e.dom.cloneNode(t)),ha=e=>{if(mt(e))return"#shadow-root";{const t=(e=>ga(e,!1))(e);return(e=>{const t=Le.fromTag("div"),o=Le.fromDom(e.dom.cloneNode(!0));return Ho(t,o),ma(t)})(t)}},pa=e=>ha(e),fa=Ys([((e,t)=>({key:e,value:qr({can:t})}))(bs(),((e,t)=>{const o=t.event,n=o.originator,r=o.target;return!((e,t,o)=>Xe(t,e.element)&&!Xe(t,o))(e,n,r)||(console.warn(bs()+" did not get interpreted by the desired target. \nOriginator: "+pa(n)+"\nTarget: "+pa(r)+"\nCheck the "+bs()+" event handlers"),!1)}))]);var va=Object.freeze({__proto__:null,events:fa});let ba=0;const ya=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return ba++,e+"_"+o+ba+String(t)},wa=w("alloy-id-"),xa=w("data-alloy-id"),Ca=wa(),Sa=xa(),ka=(e,t)=>{Object.defineProperty(e.dom,Sa,{value:t,writable:!0})},_a=e=>{const t=je(e)?e.dom[Sa]:null;return D.from(t)},Ea=e=>ya(e),Ta=x,Oa=e=>{const t=t=>`The component must be in a context to execute: ${t}`+(e?"\n"+pa(e().element)+" is not in context.":""),o=e=>()=>{throw new Error(t(e))},n=e=>()=>{console.warn(t(e))};return{debugInfo:w("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),build:o("build"),buildOrPatch:o("buildOrPatch"),addToWorld:o("addToWorld"),removeFromWorld:o("removeFromWorld"),addToGui:o("addToGui"),removeFromGui:o("removeFromGui"),getByUid:o("getByUid"),getByDom:o("getByDom"),isConnected:T}},Da=Oa(),Aa=e=>F(e,(e=>De(e,"/*")?e.substring(0,e.length-2):e)),Ma=(e,t)=>{const o=e.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:Aa(s)}),e},Na=ya("alloy-premade"),Ra=e=>(Object.defineProperty(e.element.dom,Na,{value:e.uid,writable:!0}),Fr(Na,e)),Ba=e=>ve(e,Na),La=e=>((e,t)=>{const o=t.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:"OVERRIDE",parameters:Aa(s.slice(1))}),e})(((t,...o)=>e(t.getApis(),t,...o)),e),Ha={init:()=>Ia({readState:w("No State required")})},Ia=e=>e,Pa=(e,t)=>{const o={};return le(e,((e,n)=>{le(e,((e,r)=>{const s=ve(o,r).getOr([]);o[r]=s.concat([t(n,e)])}))})),o},Fa=e=>({classes:m(e.classes)?[]:e.classes,attributes:m(e.attributes)?{}:e.attributes,styles:m(e.styles)?{}:e.styles}),za=e=>e.cHandler,Va=(e,t)=>({name:e,handler:t}),Za=(e,t)=>{const o={};return z(e,(e=>{o[e.name()]=e.handlers(t)})),o},Ua=(e,t,o,n)=>{const r=((e,t,o)=>{const n={...o,...Za(t,e)};return Pa(n,Va)})(e,o,n);return $a(r,t)},ja=e=>{const t=(e=>h(e)?{can:O,abort:T,run:e}:e)(e);return(e,o,...n)=>{const r=[e,o].concat(n);t.abort.apply(void 0,r)?o.stop():t.can.apply(void 0,r)&&t.run.apply(void 0,r)}},Wa=(e,t,o)=>{const n=t[o];return n?((e,t,o,n)=>{try{const r=ee(o,((o,r)=>{const s=o[t],a=r[t],i=n.indexOf(s),l=n.indexOf(a);if(-1===i)throw new Error("The ordering for "+e+" does not have an entry for "+s+".\nOrder specified: "+JSON.stringify(n,null,2));if(-1===l)throw new Error("The ordering for "+e+" does not have an entry for "+a+".\nOrder specified: "+JSON.stringify(n,null,2));return i{const t=F(e,(e=>e.handler));return Gr(t)})):((e,t)=>on.error(["The event ("+e+') 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: '+JSON.stringify(F(t,(e=>e.name)),null,2)]))(o,e)},$a=(e,t)=>{const o=he(e,((e,o)=>(1===e.length?on.value(e[0].handler):Wa(e,t,o)).map((n=>{const r=ja(n),s=e.length>1?Z(t[o],(t=>H(e,(e=>e.name===t)))).join(" > "):e[0].name;return Fr(o,((e,t)=>({handler:e,purpose:t}))(r,s))}))));return Vr(o,{})},qa="alloy.base.behaviour",Ga=Pn([ir("dom","dom",{tag:"required",process:{}},Pn([dr("tag"),Tr("styles",{}),Tr("classes",[]),Tr("attributes",{}),yr("value"),yr("innerHtml")])),dr("components"),dr("uid"),Tr("events",{}),Tr("apis",{}),ir("eventOrder","eventOrder",(e=>_n(w(e)))({[Cs()]:["disabling",qa,"toggling","typeaheadevents"],[bs()]:[qa,"focusing","keying"],[Os()]:[qa,"disabling","toggling","representing"],[cs()]:[qa,"representing","streaming","invalidating"],[Bs()]:[qa,"representing","item-events","tooltipping"],[es()]:["focusing",qa,"item-type-events"],[Yr()]:["focusing",qa,"item-type-events"],[rs()]:["item-type-events","tooltipping"],[xs()]:["receiving","reflecting","tooltipping"]}),Un()),yr("domModification")]),Ka=e=>e.events,Ya=(e,t)=>{const o=_t(e,t);return void 0===o||""===o?[]:o.split(" ")},Xa=e=>void 0!==e.dom.classList,Ja=e=>Ya(e,"class"),Qa=(e,t)=>((e,t,o)=>{const n=Ya(e,t).concat([o]);return St(e,t,n.join(" ")),!0})(e,"class",t),ei=(e,t)=>((e,t,o)=>{const n=Z(Ya(e,t),(e=>e!==o));return n.length>0?St(e,t,n.join(" ")):Ot(e,t),!1})(e,"class",t),ti=(e,t)=>{Xa(e)?e.dom.classList.add(t):Qa(e,t)},oi=e=>{0===(Xa(e)?e.dom.classList:Ja(e)).length&&Ot(e,"class")},ni=(e,t)=>{if(Xa(e)){e.dom.classList.remove(t)}else ei(e,t);oi(e)},ri=(e,t)=>{const o=Xa(e)?e.dom.classList.toggle(t):((e,t)=>L(Ja(e),t)?ei(e,t):Qa(e,t))(e,t);return oi(e),o},si=(e,t)=>Xa(e)&&e.dom.classList.contains(t),ai=(e,t)=>{z(t,(t=>{ti(e,t)}))},ii=(e,t)=>{z(t,(t=>{ni(e,t)}))},li=e=>Xa(e)?(e=>{const t=e.dom.classList,o=new Array(t.length);for(let e=0;ee.dom.value,di=(e,t)=>{if(void 0===t)throw new Error("Value.set was undefined");e.dom.value=t},mi=(e,t,o)=>{o.fold((()=>Ho(e,t)),(e=>{Xe(e,t)||(Ro(e,t),Fo(e))}))},ui=(e,t,o)=>{const n=F(t,o),r=at(e);return z(r.slice(n.length),Fo),n},gi=(e,t,o,n)=>{const r=it(e,t),s=n(o,r),a=((e,t,o)=>it(e,t).map((e=>{if(o.exists((t=>!Xe(t,e)))){const t=o.map(Ve).getOr("span"),n=Le.fromTag(t);return Ro(e,n),n}return e})))(e,t,r);return mi(e,s.element,a),s},hi=(e,t)=>{const o=ae(e),n=ae(t),r=X(n,o),s=((e,t)=>{const o={},n={};return ue(e,t,me(o),me(n)),{t:o,f:n}})(e,((e,o)=>!be(t,o)||e!==t[o])).t;return{toRemove:r,toSet:s}},pi=(e,t)=>{const{class:o,style:n,...r}=(e=>j(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))(t),{toSet:s,toRemove:a}=hi(e.attributes,r),i=It(t),{toSet:l,toRemove:c}=hi(e.styles,i),d=li(t),m=X(d,e.classes),u=X(e.classes,d);return z(a,(e=>Ot(t,e))),kt(t,s),ai(t,u),ii(t,m),z(c,(e=>Ft(t,e))),Nt(t,l),e.innerHtml.fold((()=>{const o=e.domChildren;((e,t)=>{ui(e,t,((t,o)=>{const n=it(e,o);return mi(e,t,n),t}))})(t,o)}),(e=>{ua(t,e)})),(()=>{const o=t,n=e.value.getOrUndefined();n!==ci(o)&&di(o,null!=n?n:"")})(),t},fi=(e,t)=>{const o=t.filter((t=>Ve(t)===e.tag&&!(e=>e.innerHtml.isSome()&&e.domChildren.length>0)(e)&&!(e=>be(e.dom,Na))(t))).bind((t=>((e,t)=>{try{const o=pi(e,t);return D.some(o)}catch(e){return D.none()}})(e,t))).getOrThunk((()=>(e=>{const t=Le.fromTag(e.tag);kt(t,e.attributes),ai(t,e.classes),Nt(t,e.styles),e.innerHtml.each((e=>ua(t,e)));const o=e.domChildren;return Io(t,o),e.value.each((e=>{di(t,e)})),t})(e)));return ka(o,e.uid),o},vi=(e,t)=>((e,t)=>{const o=F(t,(e=>Er(e.name(),[dr("config"),Tr("state",Ha)]))),n=tr("component.behaviours",Pn(o),e.behaviours).fold((t=>{throw new Error(rr(t)+"\nComplete spec:\n"+JSON.stringify(e,null,2))}),x);return{list:t,data:ce(n,(e=>{const t=e.map((e=>({config:e.config,state:e.state.init(e.config)})));return w(t)}))}})(e,t),bi=e=>{const t=(e=>{const t=ve(e,"behaviours").getOr({});return G(ae(t),(e=>{const o=t[e];return g(o)?[o.me]:[]}))})(e);return vi(e,t)},yi=(e,t,o)=>{const n={...(r=e).dom,uid:r.uid,domChildren:F(r.components,(e=>e.element))};var r;const s=(e=>e.domModification.fold((()=>Fa({})),Fa))(e),a={"alloy.base.modification":s},i=t.length>0?((e,t,o,n)=>{const r={...t};z(o,(t=>{r[t.name()]=t.exhibit(e,n)}));const s=Pa(r,((e,t)=>({name:e,modification:t}))),a=e=>U(e,((e,t)=>({...t.modification,...e})),{}),i=U(s.classes,((e,t)=>t.modification.concat(e)),[]),l=a(s.attributes),c=a(s.styles);return Fa({classes:i,attributes:l,styles:c})})(o,a,t,n):s;return l=n,c=i,{...l,attributes:{...l.attributes,...c.attributes},styles:{...l.styles,...c.styles},classes:l.classes.concat(c.classes)};var l,c},wi=(e,t)=>{const o=()=>u,n=Hr(Da),r=or((e=>tr("custom.definition",Ga,e))(e)),s=bi(e),a=(e=>e.list)(s),i=(e=>e.data)(s),l=yi(r,a,i),c=fi(l,t),d=((e,t,o)=>{const n={"alloy.base.behaviour":Ka(e)};return Ua(o,e.eventOrder,t,n).getOrDie()})(r,a,i),m=Hr(r.components),u={uid:e.uid,getSystem:n.get,config:t=>{const o=i;return(h(o[t.name()])?o[t.name()]:()=>{throw new Error("Could not find "+t.name()+" in "+JSON.stringify(e,null,2))})()},hasConfigured:e=>h(i[e.name()]),spec:e,readState:e=>i[e]().map((e=>e.state.readState())).getOr("not enabled"),getApis:()=>r.apis,connect:e=>{n.set(e)},disconnect:()=>{n.set(Oa(o))},element:c,syncComponents:()=>{const e=at(c),t=G(e,(e=>n.get().getByDom(e).fold((()=>[]),Q)));m.set(t)},components:m.get,events:d};return u},xi=(e,t)=>{const{events:o,...n}=Ta(e),r=((e,t)=>{const o=ve(e,"components").getOr([]);return t.fold((()=>F(o,Ei)),(e=>F(o,((t,o)=>_i(t,it(e,o))))))})(n,t),s={...n,events:{...va,...o},components:r};return on.value(wi(s,t))},Ci=e=>{const t=Le.fromText(e);return Si({element:t})},Si=e=>{const t=nr("external.component",In([dr("element"),yr("uid")]),e),o=Hr(Oa()),n=t.uid.getOrThunk((()=>Ea("external")));ka(t.element,n);const r={uid:n,getSystem:o.get,config:D.none,hasConfigured:T,connect:e=>{o.set(e)},disconnect:()=>{o.set(Oa((()=>r)))},getApis:()=>({}),element:t.element,spec:e,readState:w("No state"),syncComponents:v,components:w([]),events:{}};return Ra(r)},ki=Ea,_i=(e,t)=>Ba(e).getOrThunk((()=>{const o=(e=>be(e,"uid"))(e)?e:{uid:ki(""),...e};return xi(o,t).getOrDie()})),Ei=e=>_i(e,D.none()),Ti=Ra;var Oi=(e,t,o,n,r)=>e(o,n)?D.some(o):h(r)&&r(o)?D.none():t(o,n,r);const Di=(e,t,o)=>{let n=e.dom;const r=h(o)?o:T;for(;n.parentNode;){n=n.parentNode;const e=Le.fromDom(n);if(t(e))return D.some(e);if(r(e))break}return D.none()},Ai=(e,t,o)=>Oi(((e,t)=>t(e)),Di,e,t,o),Mi=(e,t,o)=>Ai(e,t,o).isSome(),Ni=(e,t,o)=>Di(e,(e=>Ke(e,t)),o),Ri=(e,t)=>((e,t)=>W(e.dom.childNodes,(e=>t(Le.fromDom(e)))).map(Le.fromDom))(e,(e=>Ke(e,t))),Bi=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ye(o)?D.none():D.from(o.querySelector(e)).map(Le.fromDom)})(t,e),Li=(e,t,o)=>Oi(((e,t)=>Ke(e,t)),Ni,e,t,o),Hi="aria-controls",Ii=()=>{const e=ya(Hi);return{id:e,link:t=>{St(t,Hi,e)},unlink:e=>{Ot(e,Hi)}}},Pi=(e,t)=>(e=>Ai(e,(e=>{if(!je(e))return!1;const t=_t(e,"id");return void 0!==t&&t.indexOf(Hi)>-1})).bind((e=>{const t=_t(e,"id"),o=ht(e);return Bi(o,`[${Hi}="${t}"]`)})))(t).exists((t=>Fi(e,t))),Fi=(e,t)=>Mi(t,(t=>Xe(t,e.element)),T)||Pi(e,t),zi="unknown";var Vi;!function(e){e[e.STOP=0]="STOP",e[e.NORMAL=1]="NORMAL",e[e.LOGGING=2]="LOGGING"}(Vi||(Vi={}));const Zi=Hr({}),Ui=(e,t,o)=>{switch(ve(Zi.get(),e).orThunk((()=>{const t=ae(Zi.get());return se(t,(t=>e.indexOf(t)>-1?D.some(Zi.get()[t]):D.none()))})).getOr(Vi.NORMAL)){case Vi.NORMAL:return o($i());case Vi.LOGGING:{const n=((e,t)=>{const o=[],n=(new Date).getTime();return{logEventCut:(e,t,n)=>{o.push({outcome:"cut",target:t,purpose:n})},logEventStopped:(e,t,n)=>{o.push({outcome:"stopped",target:t,purpose:n})},logNoParent:(e,t,n)=>{o.push({outcome:"no-parent",target:t,purpose:n})},logEventNoHandlers:(e,t)=>{o.push({outcome:"no-handlers-left",target:t})},logEventResponse:(e,t,n)=>{o.push({outcome:"response",purpose:n,target:t})},write:()=>{const r=(new Date).getTime();L(["mousemove","mouseover","mouseout",Os()],e)||console.log(e,{event:e,time:r-n,target:t.dom,sequence:F(o,(e=>L(["cut","stopped","response"],e.outcome)?"{"+e.purpose+"} "+e.outcome+" at ("+pa(e.target)+")":e.outcome))})}}})(e,t),r=o(n);return n.write(),r}case Vi.STOP:return!0}},ji=["alloy/data/Fields","alloy/debugging/Debugging"],Wi=(e,t,o)=>Ui(e,t,o),$i=w({logEventCut:v,logEventStopped:v,logNoParent:v,logEventNoHandlers:v,logEventResponse:v,write:v}),qi=w([dr("menu"),dr("selectedMenu")]),Gi=w([dr("item"),dr("selectedItem")]);w(Pn(Gi().concat(qi())));const Ki=w(Pn(Gi())),Yi=fr("initSize",[dr("numColumns"),dr("numRows")]),Xi=()=>fr("markers",[dr("backgroundMenu")].concat(qi()).concat(Gi())),Ji=e=>fr("markers",F(e,dr)),Qi=(e,t,o)=>((()=>{const e=new Error;if(void 0!==e.stack){const t=e.stack.split("\n");return W(t,(e=>e.indexOf("alloy")>0&&!H(ji,(t=>e.indexOf(t)>-1)))).getOr(zi)}})(),ir(t,t,o,Qn((e=>on.value(((...t)=>e.apply(void 0,t))))))),el=e=>Qi(0,e,kn(v)),tl=e=>Qi(0,e,kn(D.none)),ol=e=>Qi(0,e,{tag:"required",process:{}}),nl=e=>Qi(0,e,{tag:"required",process:{}}),rl=(e,t)=>lr(e,w(t)),sl=e=>lr(e,x),al=w(Yi),il=(e,t,o,n,r,s,a,i=!1)=>({x:e,y:t,bubble:o,direction:n,placement:r,restriction:s,label:`${a}-${r}`,alwaysFit:i}),ll=Ir([{southeast:[]},{southwest:[]},{northeast:[]},{northwest:[]},{south:[]},{north:[]},{east:[]},{west:[]}]),cl=ll.southeast,dl=ll.southwest,ml=ll.northeast,ul=ll.northwest,gl=ll.south,hl=ll.north,pl=ll.east,fl=ll.west,vl=(e,t,o,n)=>{const r=e+t;return r>n?o:rMath.min(Math.max(e,t),o),yl=(e,t)=>J(["left","right","top","bottom"],(o=>ve(t,o).map((t=>((e,t)=>{switch(t){case 1:return e.x;case 0:return e.x+e.width;case 2:return e.y;case 3:return e.y+e.height}})(e,t))))),wl="layout",xl=e=>e.x,Cl=(e,t)=>e.x+e.width/2-t.width/2,Sl=(e,t)=>e.x+e.width-t.width,kl=(e,t)=>e.y-t.height,_l=e=>e.y+e.height,El=(e,t)=>e.y+e.height/2-t.height/2,Tl=(e,t,o)=>il(xl(e),_l(e),o.southeast(),cl(),"southeast",yl(e,{left:1,top:3}),wl),Ol=(e,t,o)=>il(Sl(e,t),_l(e),o.southwest(),dl(),"southwest",yl(e,{right:0,top:3}),wl),Dl=(e,t,o)=>il(xl(e),kl(e,t),o.northeast(),ml(),"northeast",yl(e,{left:1,bottom:2}),wl),Al=(e,t,o)=>il(Sl(e,t),kl(e,t),o.northwest(),ul(),"northwest",yl(e,{right:0,bottom:2}),wl),Ml=(e,t,o)=>il(Cl(e,t),kl(e,t),o.north(),hl(),"north",yl(e,{bottom:2}),wl),Nl=(e,t,o)=>il(Cl(e,t),_l(e),o.south(),gl(),"south",yl(e,{top:3}),wl),Rl=(e,t,o)=>il((e=>e.x+e.width)(e),El(e,t),o.east(),pl(),"east",yl(e,{left:0}),wl),Bl=(e,t,o)=>il(((e,t)=>e.x-t.width)(e,t),El(e,t),o.west(),fl(),"west",yl(e,{right:1}),wl),Ll=()=>[Tl,Ol,Dl,Al,Nl,Ml,Rl,Bl],Hl=()=>[Ol,Tl,Al,Dl,Nl,Ml,Rl,Bl],Il=()=>[Dl,Al,Tl,Ol,Ml,Nl],Pl=()=>[Al,Dl,Ol,Tl,Ml,Nl],Fl=()=>[Tl,Ol,Dl,Al,Nl,Ml],zl=()=>[Ol,Tl,Al,Dl,Nl,Ml];var Vl=Object.freeze({__proto__:null,events:e=>Ys([Qs(xs(),((t,o)=>{const n=e.channels,r=ae(n),s=o,a=((e,t)=>t.universal?e:Z(e,(e=>L(t.channels,e))))(r,s);z(a,(e=>{const o=n[e],r=o.schema,a=nr("channel["+e+"] data\nReceiver: "+pa(t.element),r,s.data);o.onReceive(t,a)}))}))])}),Zl=[mr("channels",er(on.value,In([ol("onReceive"),Tr("schema",Un())])))];const Ul=(e,t,o)=>ca(((n,r)=>{o(n,e,t)})),jl=(e,t,o)=>((e,t,o)=>{const n=o.toString(),r=n.indexOf(")")+1,s=n.indexOf("("),a=n.substring(s+1,r-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:Aa(a.slice(0,1).concat(a.slice(3)))}),e})(((n,...r)=>{const s=[n].concat(r);return n.config({name:w(e)}).fold((()=>{throw new Error("We could not find any behaviour configuration for: "+e+". Using API: "+o)}),(e=>{const o=Array.prototype.slice.call(s,1);return t.apply(void 0,[n,e.config,e.state].concat(o))}))}),o,t),Wl=e=>({key:e,value:void 0}),$l=(e,t,o,n,r,s,a)=>{const i=e=>ye(e,o)?e[o]():D.none(),l=ce(r,((e,t)=>jl(o,e,t))),c={...ce(s,((e,t)=>Ma(e,t))),...l,revoke:S(Wl,o),config:t=>{const n=nr(o+"-config",e,t);return{key:o,value:{config:n,me:c,configAsRaw:Qt((()=>nr(o+"-config",e,t))),initialConfig:t,state:a}}},schema:w(t),exhibit:(e,t)=>Ce(i(e),ve(n,"exhibit"),((e,o)=>o(t,e.config,e.state))).getOrThunk((()=>Fa({}))),name:w(o),handlers:e=>i(e).map((e=>ve(n,"events").getOr((()=>({})))(e.config,e.state))).getOr({})};return c},ql=e=>zr(e),Gl=In([dr("fields"),dr("name"),Tr("active",{}),Tr("apis",{}),Tr("state",Ha),Tr("extra",{})]),Kl=e=>{const t=nr("Creating behaviour: "+e.name,Gl,e);return((e,t,o,n,r,s)=>{const a=In(e),i=Er(t,[(l="config",c=e,wr(l,In(c)))]);var l,c;return $l(a,i,t,o,n,r,s)})(t.fields,t.name,t.active,t.apis,t.extra,t.state)},Yl=In([dr("branchKey"),dr("branches"),dr("name"),Tr("active",{}),Tr("apis",{}),Tr("state",Ha),Tr("extra",{})]),Xl=e=>{const t=nr("Creating behaviour: "+e.name,Yl,e);return((e,t,o,n,r,s)=>{const a=e,i=Er(t,[wr("config",e)]);return $l(a,i,t,o,n,r,s)})(sr(t.branchKey,t.branches),t.name,t.active,t.apis,t.extra,t.state)},Jl=w(void 0),Ql=Kl({fields:Zl,name:"receiving",active:Vl});var ec=Object.freeze({__proto__:null,exhibit:(e,t)=>Fa({classes:[],styles:t.useFixed()?{}:{position:"relative"}})});const tc=(e,t=!1)=>e.dom.focus({preventScroll:t}),oc=e=>e.dom.blur(),nc=e=>{const t=ht(e).dom;return e.dom===t.activeElement},rc=(e=jo())=>D.from(e.dom.activeElement).map(Le.fromDom),sc=e=>rc(ht(e)).filter((t=>e.dom.contains(t.dom))),ac=(e,t)=>{const o=ht(t),n=rc(o).bind((e=>{const o=t=>Xe(e,t);return o(t)?D.some(t):((e,t)=>{const o=e=>{for(let n=0;n{rc(o).filter((t=>Xe(t,e))).fold((()=>{tc(e)}),v)})),r},ic=(e,t,o,n,r)=>{const s=e=>e+"px";return{position:e,left:t.map(s),top:o.map(s),right:n.map(s),bottom:r.map(s)}},lc=(e,t)=>{Rt(e,(e=>({...e,position:D.some(e.position)}))(t))},cc=Ir([{none:[]},{relative:["x","y","width","height"]},{fixed:["x","y","width","height"]}]),dc=(e,t,o,n,r,s)=>{const a=t.rect,i=a.x-o,l=a.y-n,c=r-(i+a.width),d=s-(l+a.height),m=D.some(i),u=D.some(l),g=D.some(c),h=D.some(d),p=D.none();return((e,t,o,n,r,s,a,i,l)=>e.fold(t,o,n,r,s,a,i,l))(t.direction,(()=>ic(e,m,u,p,p)),(()=>ic(e,p,u,g,p)),(()=>ic(e,m,p,p,h)),(()=>ic(e,p,p,g,h)),(()=>ic(e,m,u,p,p)),(()=>ic(e,m,p,p,h)),(()=>ic(e,m,u,p,p)),(()=>ic(e,p,u,g,p)))},mc=(e,t)=>e.fold((()=>{const e=t.rect;return ic("absolute",D.some(e.x),D.some(e.y),D.none(),D.none())}),((e,o,n,r)=>dc("absolute",t,e,o,n,r)),((e,o,n,r)=>dc("fixed",t,e,o,n,r))),uc=(e,t)=>{const o=S(qo,t),n=e.fold(o,o,(()=>{const e=zo();return qo(t).translate(-e.left,-e.top)})),r=Jt(t),s=jt(t);return Go(n.left,n.top,r,s)},gc=(e,t)=>t.fold((()=>e.fold(Jo,Jo,Go)),(t=>e.fold(w(t),w(t),(()=>{const o=hc(e,t.x,t.y);return Go(o.left,o.top,t.width,t.height)})))),hc=(e,t,o)=>{const n=$t(t,o);return e.fold(w(n),w(n),(()=>{const e=zo();return n.translate(-e.left,-e.top)}))};cc.none;const pc=cc.relative,fc=cc.fixed,vc=(e,t)=>((e,t)=>({anchorBox:e,origin:t}))(e,t),bc="data-alloy-placement",yc=e=>Et(e,bc),wc=Ir([{fit:["reposition"]},{nofit:["reposition","visibleW","visibleH","isVisible"]}]),xc=(e,t,o,n)=>{const r=e.bubble,s=r.offset,a=((e,t,o)=>{const n=(n,r)=>t[n].map((t=>{const s="top"===n||"bottom"===n,a=s?o.top:o.left,i=("left"===n||"top"===n?Math.max:Math.min)(t,r)+a;return s?bl(i,e.y,e.bottom):bl(i,e.x,e.right)})).getOr(r),r=n("left",e.x),s=n("top",e.y),a=n("right",e.right),i=n("bottom",e.bottom);return Go(r,s,a-r,i-s)})(n,e.restriction,s),i=e.x+s.left,l=e.y+s.top,c=Go(i,l,t,o),{originInBounds:d,sizeInBounds:m,visibleW:u,visibleH:g}=((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,right:l,bottom:c,width:d,height:m}=e;return{originInBounds:a>=o&&a<=r&&i>=n&&i<=s,sizeInBounds:l<=r&&l>=o&&c<=s&&c>=n,visibleW:Math.min(d,a>=o?r-a:l-o),visibleH:Math.min(m,i>=n?s-i:c-n)}})(c,a),h=d&&m,p=h?c:((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,width:l,height:c}=e,d=Math.max(o,r-l),m=Math.max(n,s-c),u=bl(a,o,d),g=bl(i,n,m),h=Math.min(u+l,r)-u,p=Math.min(g+c,s)-g;return Go(u,g,h,p)})(c,a),f=p.width>0&&p.height>0,{maxWidth:v,maxHeight:b}=((e,t,o)=>{const n=w(t.bottom-o.y),r=w(o.bottom-t.y),s=((e,t,o,n)=>e.fold(t,t,n,n,t,n,o,o))(e,r,r,n),a=w(t.right-o.x),i=w(o.right-t.x),l=((e,t,o,n)=>e.fold(t,n,t,n,o,o,t,n))(e,i,i,a);return{maxWidth:l,maxHeight:s}})(e.direction,p,n),y={rect:p,maxHeight:b,maxWidth:v,direction:e.direction,placement:e.placement,classes:{on:r.classesOn,off:r.classesOff},layout:e.label,testY:l};return h||e.alwaysFit?wc.fit(y):wc.nofit(y,u,g,f)},Cc=e=>{const t=Hr(D.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(D.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(D.some(e))}}},Sc=()=>Cc((e=>e.unbind())),kc=()=>{const e=Cc(v);return{...e,on:t=>e.get().each(t)}},_c=O,Ec=(e,t,o)=>((e,t,o,n)=>Mo(e,t,o,n,!1))(e,t,_c,o),Tc=(e,t,o)=>((e,t,o,n)=>Mo(e,t,o,n,!0))(e,t,_c,o),Oc=Ao,Dc=["top","bottom","right","left"],Ac="data-alloy-transition-timer",Mc=(e,t)=>((e,t)=>K(t,(t=>si(e,t))))(e,t.classes),Nc=(e,t)=>{const o=e=>parseFloat(e).toFixed(3);return pe(t,((t,n)=>!((e,t,o=C)=>Ce(e,t,o).getOr(e.isNone()&&t.isNone()))(e[n].map(o),t.map(o)))).isSome()},Rc=(e,t)=>{const o=Sc(),n=Sc();let r;const a=t=>{var o;const n=null!==(o=t.raw.pseudoElement)&&void 0!==o?o:"";return Xe(t.target,e)&&Ne(n)&&L(Dc,t.raw.propertyName)},i=s=>{if(u(s)||a(s)){o.clear(),n.clear();const a=null==s?void 0:s.raw.type;(u(a)||a===gs())&&(clearTimeout(r),Ot(e,Ac),ii(e,t.classes))}},l=Ec(e,hs(),(t=>{a(t)&&(l.unbind(),o.set(Ec(e,gs(),i)),n.set(Ec(e,us(),i)))})),c=(e=>{const t=t=>{const o=Bt(e,t).split(/\s*,\s*/);return Z(o,Me)},o=e=>{if(s(e)&&/^[\d.]+/.test(e)){const t=parseFloat(e);return De(e,"ms")?t:1e3*t}return 0},n=t("transition-delay"),r=t("transition-duration");return j(r,((e,t,r)=>{const s=o(n[r])+o(t);return Math.max(e,s)}),0)})(e);requestAnimationFrame((()=>{r=setTimeout(i,c+17),St(e,Ac,r)}))},Bc=(e,t,o,n,r,s)=>{const a=((e,t,o)=>o.exists((o=>{const n=e.mode;return"all"===n||o[n]!==t[n]})))(n,r,s);if(a||Mc(e,n)){Mt(e,"position",o.position);const s=uc(t,e),i=mc(t,{...r,rect:s}),l=J(Dc,(e=>i[e]));Nc(o,l)&&(Rt(e,l),a&&((e,t)=>{ai(e,t.classes),Et(e,Ac).each((t=>{clearTimeout(parseInt(t,10)),Ot(e,Ac)})),Rc(e,t)})(e,n),zt(e))}else ii(e,n.classes)},Lc=(e,t,o,n)=>{Ft(t,"max-height"),Ft(t,"max-width");const r={width:Jt(s=t),height:jt(s)};var s;return((e,t,o,n,r,s)=>{const a=n.width,i=n.height,l=(t,l,c,d,m)=>{const u=t(o,n,r,e,s),g=xc(u,a,i,s);return g.fold(w(g),((e,t,o,n)=>(m===n?o>d||t>c:!m&&n)?g:wc.nofit(l,c,d,m)))},c=j(t,((e,t)=>{const o=S(l,t);return e.fold(w(e),o)}),wc.nofit({rect:o,maxHeight:n.height,maxWidth:n.width,direction:cl(),placement:"southeast",classes:{on:[],off:[]},layout:"none",testY:o.y},-1,-1,!1));return c.fold(x,x)})(t,n.preference,e,r,o,n.bounds)},Hc=(e,t)=>{((e,t)=>{St(e,bc,t)})(e,t.placement)},Ic=(e,t)=>{((e,t)=>{const o=Zt.max(e,t,["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"]);Mt(e,"max-height",o+"px")})(e,Math.floor(t))},Pc=w(((e,t)=>{Ic(e,t),Nt(e,{"overflow-x":"hidden","overflow-y":"auto"})})),Fc=w(((e,t)=>{Ic(e,t)})),zc=(e,t,o)=>void 0===e[t]?o:e[t],Vc=(e,t,o,n)=>{const r=Lc(e,t,o,n);return((e,t,o)=>{const n=mc(o.origin,t);o.transition.each((r=>{Bc(e,o.origin,n,r,t,o.lastPlacement)})),lc(e,n)})(t,r,n),Hc(t,r),((e,t)=>{const o=t.classes;ii(e,o.off),ai(e,o.on)})(t,r),((e,t,o)=>{(0,o.maxHeightFunction)(e,t.maxHeight)})(t,r,n),((e,t,o)=>{(0,o.maxWidthFunction)(e,t.maxWidth)})(t,r,n),{layout:r.layout,placement:r.placement}},Zc=["valignCentre","alignLeft","alignRight","alignCentre","top","bottom","left","right","inset"],Uc=(e,t,o,n=1)=>{const r=e*n,s=t*n,a=e=>ve(o,e).getOr([]),i=(e,t,o)=>{const n=X(Zc,o);return{offset:$t(e,t),classesOn:G(o,a),classesOff:G(n,a)}};return{southeast:()=>i(-e,t,["top","alignLeft"]),southwest:()=>i(e,t,["top","alignRight"]),south:()=>i(-e/2,t,["top","alignCentre"]),northeast:()=>i(-e,-t,["bottom","alignLeft"]),northwest:()=>i(e,-t,["bottom","alignRight"]),north:()=>i(-e/2,-t,["bottom","alignCentre"]),east:()=>i(e,-t/2,["valignCentre","left"]),west:()=>i(-e,-t/2,["valignCentre","right"]),insetNortheast:()=>i(r,s,["top","alignLeft","inset"]),insetNorthwest:()=>i(-r,s,["top","alignRight","inset"]),insetNorth:()=>i(-r/2,s,["top","alignCentre","inset"]),insetSoutheast:()=>i(r,-s,["bottom","alignLeft","inset"]),insetSouthwest:()=>i(-r,-s,["bottom","alignRight","inset"]),insetSouth:()=>i(-r/2,-s,["bottom","alignCentre","inset"]),insetEast:()=>i(-r,-s/2,["valignCentre","right","inset"]),insetWest:()=>i(r,-s/2,["valignCentre","left","inset"])}},jc=()=>Uc(0,0,{}),Wc=x,$c=(e,t)=>o=>"rtl"===qc(o)?t:e,qc=e=>"rtl"===Bt(e,"direction")?"rtl":"ltr";var Gc;!function(e){e.TopToBottom="toptobottom",e.BottomToTop="bottomtotop"}(Gc||(Gc={}));const Kc="data-alloy-vertical-dir",Yc=e=>Mi(e,(e=>je(e)&&_t(e,"data-alloy-vertical-dir")===Gc.BottomToTop)),Xc=()=>Er("layouts",[dr("onLtr"),dr("onRtl"),yr("onBottomLtr"),yr("onBottomRtl")]),Jc=(e,t,o,n,r,s,a)=>{const i=a.map(Yc).getOr(!1),l=t.layouts.map((t=>t.onLtr(e))),c=t.layouts.map((t=>t.onRtl(e))),d=i?t.layouts.bind((t=>t.onBottomLtr.map((t=>t(e))))).or(l).getOr(r):l.getOr(o),m=i?t.layouts.bind((t=>t.onBottomRtl.map((t=>t(e))))).or(c).getOr(s):c.getOr(n);return $c(d,m)(e)};var Qc=[dr("hotspot"),yr("bubble"),Tr("overrides",{}),Xc(),rl("placement",((e,t,o)=>{const n=t.hotspot,r=uc(o,n.element),s=Jc(e.element,t,Fl(),zl(),Il(),Pl(),D.some(t.hotspot.element));return D.some(Wc({anchorBox:r,bubble:t.bubble.getOr(jc()),overrides:t.overrides,layouts:s}))}))];var ed=[dr("x"),dr("y"),Tr("height",0),Tr("width",0),Tr("bubble",jc()),Tr("overrides",{}),Xc(),rl("placement",((e,t,o)=>{const n=hc(o,t.x,t.y),r=Go(n.left,n.top,t.width,t.height),s=Jc(e.element,t,Ll(),Hl(),Ll(),Hl(),D.none());return D.some(Wc({anchorBox:r,bubble:t.bubble,overrides:t.overrides,layouts:s}))}))];const td=Ir([{screen:["point"]},{absolute:["point","scrollLeft","scrollTop"]}]),od=e=>e.fold(x,((e,t,o)=>e.translate(-t,-o))),nd=e=>e.fold(x,x),rd=e=>j(e,((e,t)=>e.translate(t.left,t.top)),$t(0,0)),sd=e=>{const t=F(e,nd);return rd(t)},ad=td.screen,id=td.absolute,ld=(e,t,o)=>{const n=Qe(e.element),r=zo(n),s=((e,t,o)=>{const n=ot(o.root).dom;return D.from(n.frameElement).map(Le.fromDom).filter((t=>{const o=Qe(t),n=Qe(e.element);return Xe(o,n)})).map(Gt)})(e,0,o).getOr(r);return id(s,r.left,r.top)},cd=(e,t,o,n)=>{const r=ad($t(e,t));return D.some(((e,t,o)=>({point:e,width:t,height:o}))(r,o,n))},dd=(e,t,o,n,r)=>e.map((e=>{const s=[t,e.point],a=(i=()=>sd(s),l=()=>sd(s),c=()=>(e=>{const t=F(e,od);return rd(t)})(s),n.fold(i,l,c));var i,l,c;const d=((e,t,o,n)=>({x:e,y:t,width:o,height:n}))(a.left,a.top,e.width,e.height),m=o.showAbove?Il():Fl(),u=o.showAbove?Pl():zl(),g=Jc(r,o,m,u,m,u,D.none());return Wc({anchorBox:d,bubble:o.bubble.getOr(jc()),overrides:o.overrides,layouts:g})}));var md=[dr("node"),dr("root"),yr("bubble"),Xc(),Tr("overrides",{}),Tr("showAbove",!1),rl("placement",((e,t,o)=>{const n=ld(e,0,t);return t.node.filter(yt).bind((r=>{const s=r.dom.getBoundingClientRect(),a=cd(s.left,s.top,s.width,s.height),i=t.node.getOr(e.element);return dd(a,n,t,o,i)}))}))];const ud=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),gd=Ir([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),hd=(gd.before,gd.on,gd.after,e=>e.fold(x,x,x)),pd=Ir([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),fd={domRange:pd.domRange,relative:pd.relative,exact:pd.exact,exactFromRange:e=>pd.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Le.fromDom(e.startContainer),relative:(e,t)=>hd(e),exact:(e,t,o,n)=>e}))(e);return ot(t)},range:ud},vd=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},bd=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},yd=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),wd=Ir([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),xd=(e,t,o)=>t(Le.fromDom(o.startContainer),o.startOffset,Le.fromDom(o.endContainer),o.endOffset),Cd=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:w(e),rtl:D.none}),relative:(t,o)=>({ltr:Qt((()=>vd(e,t,o))),rtl:Qt((()=>D.some(vd(e,o,t))))}),exact:(t,o,n,r)=>({ltr:Qt((()=>bd(e,t,o,n,r))),rtl:Qt((()=>D.some(bd(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();if(o.collapsed)return t.rtl().filter((e=>!1===e.collapsed)).map((e=>wd.rtl(Le.fromDom(e.endContainer),e.endOffset,Le.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>xd(0,wd.ltr,o)));return xd(0,wd.ltr,o)})(0,o)},Sd=(e,t)=>Cd(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});wd.ltr,wd.rtl;const kd=(e,t,o)=>Z(((e,t)=>{const o=h(t)?t:T;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Le.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r})(e,o),t),_d=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ye(o)?[]:F(o.querySelectorAll(e),Le.fromDom)})(t,e),Ed=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Qe(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Xe(e,o)&&t===n;return r.collapsed&&!s},Td=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return D.some(ud(Le.fromDom(t.startContainer),t.startOffset,Le.fromDom(o.endContainer),o.endOffset))}return D.none()},Od=e=>{if(null===e.anchorNode||null===e.focusNode)return Td(e);{const t=Le.fromDom(e.anchorNode),o=Le.fromDom(e.focusNode);return Ed(t,e.anchorOffset,o,e.focusOffset)?D.some(ud(t,e.anchorOffset,o,e.focusOffset)):Td(e)}},Dd=e=>(e=>D.from(e.getSelection()))(e).filter((e=>e.rangeCount>0)).bind(Od),Ad=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?D.some(o).map(yd):D.none()})(Sd(e,t)),Md=(e,t)=>(e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0?D.some(t).map(yd):D.none()})(Sd(e,t)),Nd=((e,t)=>{const o=t=>e(t)?D.from(t.dom.nodeValue):D.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(We,"text"),Rd=(e,t)=>({element:e,offset:t}),Bd=(e,t)=>{const o=at(e);if(0===o.length)return Rd(e,t);if(tNd.get(e))(e).length:at(e).length;return Rd(e,t)}},Ld=(e,t)=>We(e)?Rd(e,t):Bd(e,t),Hd=e=>void 0!==e.foffset,Id=(e,t)=>t.getSelection.getOrThunk((()=>()=>Dd(e)))().map((e=>{if(Hd(e)){const t=Ld(e.start,e.soffset),o=Ld(e.finish,e.foffset);return fd.range(t.element,t.offset,o.element,o.offset)}return e}));var Pd=[yr("getSelection"),dr("root"),yr("bubble"),Xc(),Tr("overrides",{}),Tr("showAbove",!1),rl("placement",((e,t,o)=>{const n=ot(t.root).dom,r=ld(e,0,t),s=Id(n,t).bind((e=>{if(Hd(e)){const t=Md(n,fd.exactFromRange(e)).orThunk((()=>{const t=Le.fromText("\ufeff");Ro(e.start,t);const o=Ad(n,fd.exact(t,0,t,1));return Fo(t),o}));return t.bind((e=>cd(e.left,e.top,e.width,e.height)))}{const t=ce(e,(e=>e.dom.getBoundingClientRect())),o={left:Math.min(t.firstCell.left,t.lastCell.left),right:Math.max(t.firstCell.right,t.lastCell.right),top:Math.min(t.firstCell.top,t.lastCell.top),bottom:Math.max(t.firstCell.bottom,t.lastCell.bottom)};return cd(o.left,o.top,o.right-o.left,o.bottom-o.top)}})),a=Id(n,t).bind((e=>Hd(e)?je(e.start)?D.some(e.start):rt(e.start):D.some(e.firstCell))).getOr(e.element);return dd(s,r,t,o,a)}))];const Fd="link-layout",zd=e=>e.x+e.width,Vd=(e,t)=>e.x-t.width,Zd=(e,t)=>e.y-t.height+e.height,Ud=e=>e.y,jd=(e,t,o)=>il(zd(e),Ud(e),o.southeast(),cl(),"southeast",yl(e,{left:0,top:2}),Fd),Wd=(e,t,o)=>il(Vd(e,t),Ud(e),o.southwest(),dl(),"southwest",yl(e,{right:1,top:2}),Fd),$d=(e,t,o)=>il(zd(e),Zd(e,t),o.northeast(),ml(),"northeast",yl(e,{left:0,bottom:3}),Fd),qd=(e,t,o)=>il(Vd(e,t),Zd(e,t),o.northwest(),ul(),"northwest",yl(e,{right:1,bottom:3}),Fd),Gd=()=>[jd,Wd,$d,qd],Kd=()=>[Wd,jd,qd,$d];var Yd=[dr("item"),Xc(),Tr("overrides",{}),rl("placement",((e,t,o)=>{const n=uc(o,t.item.element),r=Jc(e.element,t,Gd(),Kd(),Gd(),Kd(),D.none());return D.some(Wc({anchorBox:n,bubble:jc(),overrides:t.overrides,layouts:r}))}))],Xd=sr("type",{selection:Pd,node:md,hotspot:Qc,submenu:Yd,makeshift:ed});const Jd=[br("classes",$n),Mr("mode","all",["all","layout","placement"])],Qd=[Tr("useFixed",T),yr("getBounds")],em=[mr("anchor",Xd),Er("transition",Jd)],tm=(e,t,o,n,r,s)=>((e,t,o,n,r,s,a,i)=>{const l=zc(a,"maxHeightFunction",Pc()),c=zc(a,"maxWidthFunction",v),d=e.anchorBox,m=e.origin,u={bounds:gc(m,s),origin:m,preference:n,maxHeightFunction:l,maxWidthFunction:c,lastPlacement:r,transition:i};return Vc(d,t,o,u)})(vc(t.anchorBox,e),n.element,t.bubble,t.layouts,r,o,t.overrides,s),om=(e,t,o,n,r,s)=>{const a=nr("placement.info",Pn(em),r),i=a.anchor,l=n.element,c=o.get(n.uid);ac((()=>{Mt(l,"position","fixed");const r=Ht(l,"visibility");Mt(l,"visibility","hidden");const d=t.useFixed()?(()=>{const e=document.documentElement;return fc(0,0,e.clientWidth,e.clientHeight)})():(e=>{const t=Gt(e.element),o=e.element.dom.getBoundingClientRect();return pc(t.left,t.top,o.width,o.height)})(e);i.placement(e,i,d).each((e=>{const r=s.orThunk((()=>t.getBounds.map(E))),i=tm(d,e,r,n,c,a.transition);o.set(n.uid,i)})),r.fold((()=>{Ft(l,"visibility")}),(e=>{Mt(l,"visibility",e)})),Ht(l,"left").isNone()&&Ht(l,"top").isNone()&&Ht(l,"right").isNone()&&Ht(l,"bottom").isNone()&&we(Ht(l,"position"),"fixed")&&Ft(l,"position")}),l)};var nm=Object.freeze({__proto__:null,position:(e,t,o,n,r)=>{const s=D.none();om(e,t,o,n,r,s)},positionWithinBounds:om,getMode:(e,t,o)=>t.useFixed()?"fixed":"absolute",reset:(e,t,o,n)=>{const r=n.element;z(["position","left","right","top","bottom"],(e=>Ft(r,e))),(e=>{Ot(e,bc)})(r),o.clear(n.uid)}});const rm=Kl({fields:Qd,name:"positioning",active:ec,apis:nm,state:Object.freeze({__proto__:null,init:()=>{let e={};return Ia({readState:()=>e,clear:t=>{g(t)?delete e[t]:e={}},set:(t,o)=>{e[t]=o},get:t=>ve(e,t)})}})}),sm=e=>e.getSystem().isConnected(),am=e=>{js(e,Bs());const t=e.components();z(t,am)},im=e=>{const t=e.components();z(t,im),js(e,Rs())},lm=(e,t)=>{e.getSystem().addToWorld(t),yt(e.element)&&im(t)},cm=e=>{am(e),e.getSystem().removeFromWorld(e)},dm=(e,t)=>{Ho(e.element,t.element)},mm=(e,t,o)=>{const n=e.components();(e=>{z(e.components(),(e=>Fo(e.element))),Po(e.element),e.syncComponents()})(e);const r=o(t),s=X(n,r);z(s,(t=>{am(t),e.getSystem().removeFromWorld(t)})),z(r,(t=>{sm(t)?dm(e,t):(e.getSystem().addToWorld(t),dm(e,t),yt(e.element)&&im(t))})),e.syncComponents()},um=(e,t)=>{gm(e,t,Ho)},gm=(e,t,o)=>{e.getSystem().addToWorld(t),o(e.element,t.element),yt(e.element)&&im(t),e.syncComponents()},hm=e=>{am(e),Fo(e.element),e.getSystem().removeFromWorld(e)},pm=e=>{const t=nt(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()));hm(e),t.each((e=>{e.syncComponents()}))},fm=e=>{const t=e.components();z(t,hm),Po(e.element),e.syncComponents()},vm=(e,t)=>{ym(e,t,Ho)},bm=(e,t)=>{ym(e,t,Bo)},ym=(e,t,o)=>{o(e,t.element);const n=at(t.element);z(n,(e=>{t.getByDom(e).each(im)}))},wm=e=>{const t=at(e.element);z(t,(t=>{e.getByDom(t).each(am)})),Fo(e.element)},xm=(e,t,o,n)=>{o.get().each((t=>{fm(e)}));const r=t.getAttachPoint(e);um(r,e);const s=e.getSystem().build(n);return um(e,s),o.set(s),s},Cm=(e,t,o,n)=>{const r=xm(e,t,o,n);return t.onOpen(e,r),r},Sm=(e,t,o)=>{o.get().each((n=>{fm(e),pm(e),t.onClose(e,n),o.clear()}))},km=(e,t,o)=>o.isOpen(),_m=(e,t,o)=>{const n=t.getAttachPoint(e);Mt(e.element,"position",rm.getMode(n)),((e,t,o,n)=>{Ht(e.element,t).fold((()=>{Ot(e.element,o)}),(t=>{St(e.element,o,t)})),Mt(e.element,t,n)})(e,"visibility",t.cloakVisibilityAttr,"hidden")},Em=(e,t,o)=>{(e=>H(["top","left","right","bottom"],(t=>Ht(e,t).isSome())))(e.element)||Ft(e.element,"position"),((e,t,o)=>{Et(e.element,o).fold((()=>Ft(e.element,t)),(o=>Mt(e.element,t,o)))})(e,"visibility",t.cloakVisibilityAttr)};var Tm=Object.freeze({__proto__:null,cloak:_m,decloak:Em,open:Cm,openWhileCloaked:(e,t,o,n,r)=>{_m(e,t),Cm(e,t,o,n),r(),Em(e,t)},close:Sm,isOpen:km,isPartOf:(e,t,o,n)=>km(0,0,o)&&o.get().exists((o=>t.isPartOf(e,o,n))),getState:(e,t,o)=>o.get(),setContent:(e,t,o,n)=>o.get().map((()=>xm(e,t,o,n)))});var Om=Object.freeze({__proto__:null,events:(e,t)=>Ys([Qs(Es(),((o,n)=>{Sm(o,e,t)}))])}),Dm=[el("onOpen"),el("onClose"),dr("isPartOf"),dr("getAttachPoint"),Tr("cloakVisibilityAttr","data-precloak-visibility")];var Am=Object.freeze({__proto__:null,init:()=>{const e=kc(),t=w("not-implemented");return Ia({readState:t,isOpen:e.isSet,clear:e.clear,set:e.set,get:e.get})}});const Mm=Kl({fields:Dm,name:"sandboxing",active:Om,apis:Tm,state:Am}),Nm=w("dismiss.popups"),Rm=w("reposition.popups"),Bm=w("mouse.released"),Lm=In([Tr("isExtraPart",T),Er("fireEventInstead",[Tr("event",Ls())])]),Hm=e=>{const t=nr("Dismissal",Lm,e);return{[Nm()]:{schema:In([dr("target")]),onReceive:(e,o)=>{if(Mm.isOpen(e)){Mm.isPartOf(e,o.target)||t.isExtraPart(e,o.target)||t.fireEventInstead.fold((()=>Mm.close(e)),(t=>js(e,t.event)))}}}}},Im=In([Er("fireEventInstead",[Tr("event",Hs())]),pr("doReposition")]),Pm=e=>{const t=nr("Reposition",Im,e);return{[Rm()]:{onReceive:e=>{Mm.isOpen(e)&&t.fireEventInstead.fold((()=>t.doReposition(e)),(t=>js(e,t.event)))}}}},Fm=(e,t,o)=>{t.store.manager.onLoad(e,t,o)},zm=(e,t,o)=>{t.store.manager.onUnload(e,t,o)};var Vm=Object.freeze({__proto__:null,onLoad:Fm,onUnload:zm,setValue:(e,t,o,n)=>{t.store.manager.setValue(e,t,o,n)},getValue:(e,t,o)=>t.store.manager.getValue(e,t,o),getState:(e,t,o)=>o});var Zm=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.resetOnDom?[ia(((o,n)=>{Fm(o,e,t)})),la(((o,n)=>{zm(o,e,t)}))]:[Ul(e,t,Fm)];return Ys(o)}});const Um=()=>{const e=Hr(null);return Ia({set:e.set,get:e.get,isNotSet:()=>null===e.get(),clear:()=>{e.set(null)},readState:()=>({mode:"memory",value:e.get()})})},jm=()=>{const e=Hr({}),t=Hr({});return Ia({readState:()=>({mode:"dataset",dataByValue:e.get(),dataByText:t.get()}),lookup:o=>ve(e.get(),o).orThunk((()=>ve(t.get(),o))),update:o=>{const n=e.get(),r=t.get(),s={},a={};z(o,(e=>{s[e.value]=e,ve(e,"meta").each((t=>{ve(t,"text").each((t=>{a[t]=e}))}))})),e.set({...n,...s}),t.set({...r,...a})},clear:()=>{e.set({}),t.set({})}})};var Wm=Object.freeze({__proto__:null,memory:Um,dataset:jm,manual:()=>Ia({readState:v}),init:e=>e.store.manager.state(e)});const $m=(e,t,o,n)=>{const r=t.store;o.update([n]),r.setValue(e,n),t.onSetValue(e,n)};var qm=[yr("initialValue"),dr("getFallbackEntry"),dr("getDataKey"),dr("setValue"),rl("manager",{setValue:$m,getValue:(e,t,o)=>{const n=t.store,r=n.getDataKey(e);return o.lookup(r).getOrThunk((()=>n.getFallbackEntry(r)))},onLoad:(e,t,o)=>{t.store.initialValue.each((n=>{$m(e,t,o,n)}))},onUnload:(e,t,o)=>{o.clear()},state:jm})];var Gm=[dr("getValue"),Tr("setValue",v),yr("initialValue"),rl("manager",{setValue:(e,t,o,n)=>{t.store.setValue(e,n),t.onSetValue(e,n)},getValue:(e,t,o)=>t.store.getValue(e),onLoad:(e,t,o)=>{t.store.initialValue.each((o=>{t.store.setValue(e,o)}))},onUnload:v,state:Ha.init})];var Km=[yr("initialValue"),rl("manager",{setValue:(e,t,o,n)=>{o.set(n),t.onSetValue(e,n)},getValue:(e,t,o)=>o.get(),onLoad:(e,t,o)=>{t.store.initialValue.each((e=>{o.isNotSet()&&o.set(e)}))},onUnload:(e,t,o)=>{o.clear()},state:Um})],Ym=[Or("store",{mode:"memory"},sr("mode",{memory:Km,manual:Gm,dataset:qm})),el("onSetValue"),Tr("resetOnDom",!1)];const Xm=Kl({fields:Ym,name:"representing",active:Zm,apis:Vm,extra:{setValueFrom:(e,t)=>{const o=Xm.getValue(t);Xm.setValue(e,o)}},state:Wm}),Jm=(e,t)=>Lr(e,{},F(t,(t=>{return o=t.name(),n="Cannot configure "+t.name()+" for "+e,ir(o,o,{tag:"option",process:{}},An((e=>un("The field: "+o+" is forbidden. "+n))));var o,n})).concat([lr("dump",x)])),Qm=e=>e.dump,eu=(e,t)=>({...ql(t),...e.dump}),tu=Jm,ou=eu,nu="placeholder",ru=Ir([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),su=e=>be(e,"uiType"),au=(e,t,o,n)=>su(o)&&o.uiType===nu?((e,t,o,n)=>e.exists((e=>e!==o.owner))?ru.single(!0,w(o)):ve(n,o.name).fold((()=>{throw new Error("Unknown placeholder component: "+o.name+"\nKnown: ["+ae(n)+"]\nNamespace: "+e.getOr("none")+"\nSpec: "+JSON.stringify(o,null,2))}),(e=>e.replace())))(e,0,o,n):ru.single(!1,w(o)),iu=(e,t,o,n)=>au(e,0,o,n).fold(((r,s)=>{const a=su(o)?s(t,o.config,o.validated):s(t),i=ve(a,"components").getOr([]),l=G(i,(o=>iu(e,t,o,n)));return[{...a,components:l}]}),((e,n)=>{if(su(o)){const e=n(t,o.config,o.validated);return o.validated.preprocess.getOr(x)(e)}return n(t)})),lu=(e,t,o,n)=>{const r=ce(n,((e,t)=>((e,t)=>{let o=!1;return{name:w(e),required:()=>t.fold(((e,t)=>e),((e,t)=>e)),used:()=>o,replace:()=>{if(o)throw new Error("Trying to use the same placeholder more than once: "+e);return o=!0,t}}})(t,e))),s=((e,t,o,n)=>G(o,(o=>iu(e,t,o,n))))(e,t,o,r);return le(r,(o=>{if(!1===o.used()&&o.required())throw new Error("Placeholder: "+o.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+JSON.stringify(t.components,null,2))})),s},cu=ru.single,du=ru.multiple,mu=w(nu),uu=Ir([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),gu=Tr("factory",{sketch:x}),hu=Tr("schema",[]),pu=dr("name"),fu=ir("pname","pname",Sn((e=>"")),Un()),vu=lr("schema",(()=>[yr("preprocess")])),bu=Tr("defaults",w({})),yu=Tr("overrides",w({})),wu=Pn([gu,hu,pu,fu,bu,yu]),xu=Pn([gu,hu,pu,bu,yu]),Cu=Pn([gu,hu,pu,fu,bu,yu]),Su=Pn([gu,vu,pu,dr("unit"),fu,bu,yu]),ku=e=>e.fold(D.some,D.none,D.some,D.some),_u=e=>{const t=e=>e.name;return e.fold(t,t,t,t)},Eu=(e,t)=>o=>{const n=nr("Converting part type",t,o);return e(n)},Tu=Eu(uu.required,wu),Ou=Eu(uu.external,xu),Du=Eu(uu.optional,Cu),Au=Eu(uu.group,Su),Mu=w("entirety");var Nu=Object.freeze({__proto__:null,required:Tu,external:Ou,optional:Du,group:Au,asNamedPart:ku,name:_u,asCommon:e=>e.fold(x,x,x,x),original:Mu});const Ru=(e,t,o,n)=>xn(t.defaults(e,o,n),o,{uid:e.partUids[t.name]},t.overrides(e,o,n)),Bu=(e,t)=>{const o={};return z(t,(t=>{ku(t).each((t=>{const n=Lu(e,t.pname);o[t.name]=o=>{const r=nr("Part: "+t.name+" in "+e,Pn(t.schema),o);return{...n,config:o,validated:r}}}))})),o},Lu=(e,t)=>({uiType:mu(),owner:e,name:t}),Hu=(e,t,o)=>({uiType:mu(),owner:e,name:t,config:o,validated:{}}),Iu=e=>G(e,(e=>e.fold(D.none,D.some,D.none,D.none).map((e=>fr(e.name,e.schema.concat([sl(Mu())])))).toArray())),Pu=e=>F(e,_u),Fu=(e,t,o)=>((e,t,o)=>{const n={},r={};return z(o,(e=>{e.fold((e=>{n[e.pname]=cu(!0,((t,o,n)=>e.factory.sketch(Ru(t,e,o,n))))}),(e=>{const o=t.parts[e.name];r[e.name]=w(e.factory.sketch(Ru(t,e,o[Mu()]),o))}),(e=>{n[e.pname]=cu(!1,((t,o,n)=>e.factory.sketch(Ru(t,e,o,n))))}),(e=>{n[e.pname]=du(!0,((t,o,n)=>{const r=t[e.name];return F(r,(o=>e.factory.sketch(xn(e.defaults(t,o,n),o,e.overrides(t,o)))))}))}))})),{internals:w(n),externals:w(r)}})(0,t,o),zu=(e,t,o)=>lu(D.some(e),t,t.components,o),Vu=(e,t,o)=>{const n=t.partUids[o];return e.getSystem().getByUid(n).toOptional()},Zu=(e,t,o)=>Vu(e,t,o).getOrDie("Could not find part: "+o),Uu=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return z(o,(e=>{n[e]=w(s.getByUid(r[e]))})),n},ju=(e,t)=>{const o=e.getSystem();return ce(t.partUids,((e,t)=>w(o.getByUid(e))))},Wu=e=>ae(e.partUids),$u=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return z(o,(e=>{n[e]=w(s.getByUid(r[e]).getOrDie())})),n},qu=(e,t)=>{const o=Pu(t);return zr(F(o,(t=>({key:t,value:e+"-"+t}))))},Gu=e=>ir("partUids","partUids",_n((t=>qu(t.uid,e))),Un());var Ku=Object.freeze({__proto__:null,generate:Bu,generateOne:Hu,schemas:Iu,names:Pu,substitutes:Fu,components:zu,defaultUids:qu,defaultUidsSchema:Gu,getAllParts:ju,getAllPartNames:Wu,getPart:Vu,getPartOrDie:Zu,getParts:Uu,getPartsOrDie:$u});const Yu=(e,t,o,n,r)=>{const s=((e,t)=>(e.length>0?[fr("parts",e)]:[]).concat([dr("uid"),Tr("dom",{}),Tr("components",[]),sl("originalSpec"),Tr("debug.sketcher",{})]).concat(t))(n,r);return nr(e+" [SpecSchema]",In(s.concat(t)),o)},Xu=(e,t,o,n,r)=>{const s=Ju(r),a=Iu(o),i=Gu(o),l=Yu(e,t,s,a,[i]),c=Fu(0,l,o);return n(l,zu(e,l,c.internals()),s,c.externals())},Ju=e=>(e=>be(e,"uid"))(e)?e:{...e,uid:Ea("uid")},Qu=In([dr("name"),dr("factory"),dr("configFields"),Tr("apis",{}),Tr("extraApis",{})]),eg=In([dr("name"),dr("factory"),dr("configFields"),dr("partFields"),Tr("apis",{}),Tr("extraApis",{})]),tg=e=>{const t=nr("Sketcher for "+e.name,Qu,e),o=ce(t.apis,La),n=ce(t.extraApis,((e,t)=>Ma(e,t)));return{name:t.name,configFields:t.configFields,sketch:e=>((e,t,o,n)=>{const r=Ju(n);return o(Yu(e,t,r,[],[]),r)})(t.name,t.configFields,t.factory,e),...o,...n}},og=e=>{const t=nr("Sketcher for "+e.name,eg,e),o=Bu(t.name,t.partFields),n=ce(t.apis,La),r=ce(t.extraApis,((e,t)=>Ma(e,t)));return{name:t.name,partFields:t.partFields,configFields:t.configFields,sketch:e=>Xu(t.name,t.configFields,t.partFields,t.factory,e),parts:o,...n,...r}},ng=e=>Ge("input")(e)&&"radio"!==_t(e,"type")||Ge("textarea")(e);var rg=Object.freeze({__proto__:null,getCurrent:(e,t,o)=>t.find(e)});const sg=[dr("find")],ag=Kl({fields:sg,name:"composing",apis:rg}),ig=["input","button","textarea","select"],lg=(e,t,o)=>{(t.disabled()?hg:pg)(e,t)},cg=(e,t)=>!0===t.useNative&&L(ig,Ve(e.element)),dg=e=>{St(e.element,"disabled","disabled")},mg=e=>{Ot(e.element,"disabled")},ug=e=>{St(e.element,"aria-disabled","true")},gg=e=>{St(e.element,"aria-disabled","false")},hg=(e,t,o)=>{t.disableClass.each((t=>{ti(e.element,t)}));(cg(e,t)?dg:ug)(e),t.onDisabled(e)},pg=(e,t,o)=>{t.disableClass.each((t=>{ni(e.element,t)}));(cg(e,t)?mg:gg)(e),t.onEnabled(e)},fg=(e,t)=>cg(e,t)?(e=>Tt(e.element,"disabled"))(e):(e=>"true"===_t(e.element,"aria-disabled"))(e);var vg=Object.freeze({__proto__:null,enable:pg,disable:hg,isDisabled:fg,onLoad:lg,set:(e,t,o,n)=>{(n?hg:pg)(e,t)}});var bg=Object.freeze({__proto__:null,exhibit:(e,t)=>Fa({classes:t.disabled()?t.disableClass.toArray():[]}),events:(e,t)=>Ys([Xs(Cs(),((t,o)=>fg(t,e))),Ul(e,t,lg)])}),yg=[Rr("disabled",T),Tr("useNative",!0),yr("disableClass"),el("onDisabled"),el("onEnabled")];const wg=Kl({fields:yg,name:"disabling",active:bg,apis:vg}),xg=(e,t,o,n)=>{const r=_d(e.element,"."+t.highlightClass);z(r,(o=>{H(n,(e=>Xe(e.element,o)))||(ni(o,t.highlightClass),e.getSystem().getByDom(o).each((o=>{t.onDehighlight(e,o),js(o,Us())})))}))},Cg=(e,t,o,n)=>{xg(e,t,0,[n]),Sg(e,t,o,n)||(ti(n.element,t.highlightClass),t.onHighlight(e,n),js(n,Zs()))},Sg=(e,t,o,n)=>si(n.element,t.highlightClass),kg=(e,t,o,n)=>{const r=_d(e.element,"."+t.itemClass);return D.from(r[n]).fold((()=>on.error(new Error("No element found with index "+n))),e.getSystem().getByDom)},_g=(e,t,o)=>Bi(e.element,"."+t.itemClass).bind((t=>e.getSystem().getByDom(t).toOptional())),Eg=(e,t,o)=>{const n=_d(e.element,"."+t.itemClass);return(n.length>0?D.some(n[n.length-1]):D.none()).bind((t=>e.getSystem().getByDom(t).toOptional()))},Tg=(e,t,o,n)=>{const r=_d(e.element,"."+t.itemClass),s=$(r,(e=>si(e,t.highlightClass)));return s.bind((t=>{const o=vl(t,n,0,r.length-1);return e.getSystem().getByDom(r[o]).toOptional()}))},Og=(e,t,o)=>{const n=_d(e.element,"."+t.itemClass);return xe(F(n,(t=>e.getSystem().getByDom(t).toOptional())))};var Dg=Object.freeze({__proto__:null,dehighlightAll:(e,t,o)=>xg(e,t,0,[]),dehighlight:(e,t,o,n)=>{Sg(e,t,o,n)&&(ni(n.element,t.highlightClass),t.onDehighlight(e,n),js(n,Us()))},highlight:Cg,highlightFirst:(e,t,o)=>{_g(e,t).each((n=>{Cg(e,t,o,n)}))},highlightLast:(e,t,o)=>{Eg(e,t).each((n=>{Cg(e,t,o,n)}))},highlightAt:(e,t,o,n)=>{kg(e,t,o,n).fold((e=>{throw e}),(n=>{Cg(e,t,o,n)}))},highlightBy:(e,t,o,n)=>{const r=Og(e,t);W(r,n).each((n=>{Cg(e,t,o,n)}))},isHighlighted:Sg,getHighlighted:(e,t,o)=>Bi(e.element,"."+t.highlightClass).bind((t=>e.getSystem().getByDom(t).toOptional())),getFirst:_g,getLast:Eg,getPrevious:(e,t,o)=>Tg(e,t,0,-1),getNext:(e,t,o)=>Tg(e,t,0,1),getCandidates:Og}),Ag=[dr("highlightClass"),dr("itemClass"),el("onHighlight"),el("onDehighlight")];const Mg=Kl({fields:Ag,name:"highlighting",apis:Dg}),Ng=[8],Rg=[9],Bg=[13],Lg=[27],Hg=[32],Ig=[37],Pg=[38],Fg=[39],zg=[40],Vg=(e,t,o)=>{const n=Y(e.slice(0,t)),r=Y(e.slice(t+1));return W(n.concat(r),o)},Zg=(e,t,o)=>{const n=Y(e.slice(0,t));return W(n,o)},Ug=(e,t,o)=>{const n=e.slice(0,t),r=e.slice(t+1);return W(r.concat(n),o)},jg=(e,t,o)=>{const n=e.slice(t+1);return W(n,o)},Wg=e=>t=>{const o=t.raw;return L(e,o.which)},$g=e=>t=>K(e,(e=>e(t))),qg=e=>!0===e.raw.shiftKey,Gg=e=>!0===e.raw.ctrlKey,Kg=k(qg),Yg=(e,t)=>({matches:e,classification:t}),Xg=(e,t,o)=>{t.exists((e=>o.exists((t=>Xe(t,e)))))||Ws(e,Is(),{prevFocus:t,newFocus:o})},Jg=()=>{const e=e=>sc(e.element);return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().triggerFocus(o,t.element);const r=e(t);Xg(t,n,r)}}},Qg=()=>{const e=e=>Mg.getHighlighted(e).map((e=>e.element));return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().getByDom(o).fold(v,(e=>{Mg.highlight(t,e)}));const r=e(t);Xg(t,n,r)}}};var eh;!function(e){e.OnFocusMode="onFocus",e.OnEnterOrSpaceMode="onEnterOrSpace",e.OnApiMode="onApi"}(eh||(eh={}));const th=(e,t,o,n,r)=>{const s=(e,t,o,n,r)=>((e,t)=>{const o=W(e,(e=>e.matches(t)));return o.map((e=>e.classification))})(o(e,t,n,r),t.event).bind((o=>o(e,t,n,r))),a={schema:()=>e.concat([Tr("focusManager",Jg()),Or("focusInside","onFocus",Qn((e=>L(["onFocus","onEnterOrSpace","onApi"],e)?on.value(e):on.error("Invalid value for focusInside")))),rl("handler",a),rl("state",t),rl("sendFocusIn",r)]),processKey:s,toEvents:(e,t)=>{const a=e.focusInside!==eh.OnFocusMode?D.none():r(e).map((o=>Qs(bs(),((n,r)=>{o(n,e,t),r.stop()})))),i=[Qs(is(),((n,a)=>{s(n,a,o,e,t).fold((()=>{((o,n)=>{const s=Wg(Hg.concat(Bg))(n.event);e.focusInside===eh.OnEnterOrSpaceMode&&s&&Wr(o,n)&&r(e).each((r=>{r(o,e,t),n.stop()}))})(n,a)}),(e=>{a.stop()}))})),Qs(ls(),((o,r)=>{s(o,r,n,e,t).each((e=>{r.stop()}))}))];return Ys(a.toArray().concat(i))}};return a},oh=e=>{const t=[yr("onEscape"),yr("onEnter"),Tr("selector",'[data-alloy-tabstop="true"]:not(:disabled)'),Tr("firstTabstop",0),Tr("useTabstopAt",O),yr("visibilitySelector")].concat([e]),o=(e,t)=>{const o=e.visibilitySelector.bind((e=>Li(t,e))).getOr(t);return Ut(o)>0},n=(e,t)=>t.focusManager.get(e).bind((e=>Li(e,t.selector))),r=(e,t,n)=>{((e,t)=>{const n=_d(e.element,t.selector),r=Z(n,(e=>o(t,e)));return D.from(r[t.firstTabstop])})(e,t).each((o=>{t.focusManager.set(e,o)}))},s=(e,t,n,r,s)=>s(t,n,(e=>((e,t)=>o(e,t)&&e.useTabstopAt(t))(r,e))).fold((()=>r.cyclic?D.some(!0):D.none()),(t=>(r.focusManager.set(e,t),D.some(!0)))),a=(e,t,o,r)=>{const a=_d(e.element,o.selector);return n(e,o).bind((t=>$(a,S(Xe,t)).bind((t=>s(e,a,t,o,r)))))},i=(e,t,o)=>{const n=o.cyclic?Vg:Zg;return a(e,0,o,n)},l=(e,t,o)=>{const n=o.cyclic?Ug:jg;return a(e,0,o,n)},c=e=>(e=>nt(e))(e).bind(lt).exists((t=>Xe(t,e))),d=w([Yg($g([qg,Wg(Rg)]),i),Yg(Wg(Rg),l),Yg($g([Kg,Wg(Bg)]),((e,t,o)=>o.onEnter.bind((o=>o(e,t)))))]),m=w([Yg(Wg(Lg),((e,t,o)=>o.onEscape.bind((o=>o(e,t))))),Yg(Wg(Rg),((e,t,o)=>n(e,o).filter((e=>!o.useTabstopAt(e))).bind((n=>(c(n)?i:l)(e,t,o)))))]);return th(t,Ha.init,d,m,(()=>D.some(r)))};var nh=oh(lr("cyclic",T)),rh=oh(lr("cyclic",O));const sh=(e,t,o)=>ng(o)&&Wg(Hg)(t.event)?D.none():((e,t,o)=>(qs(e,o,Cs()),D.some(!0)))(e,0,o),ah=(e,t)=>D.some(!0),ih=[Tr("execute",sh),Tr("useSpace",!1),Tr("useEnter",!0),Tr("useControlEnter",!1),Tr("useDown",!1)],lh=(e,t,o)=>o.execute(e,t,e.element);var ch=th(ih,Ha.init,((e,t,o,n)=>{const r=o.useSpace&&!ng(e.element)?Hg:[],s=o.useEnter?Bg:[],a=o.useDown?zg:[],i=r.concat(s).concat(a);return[Yg(Wg(i),lh)].concat(o.useControlEnter?[Yg($g([Gg,Wg(Bg)]),lh)]:[])}),((e,t,o,n)=>o.useSpace&&!ng(e.element)?[Yg(Wg(Hg),ah)]:[]),(()=>D.none()));const dh=()=>{const e=kc();return Ia({readState:()=>e.get().map((e=>({numRows:String(e.numRows),numColumns:String(e.numColumns)}))).getOr({numRows:"?",numColumns:"?"}),setGridSize:(t,o)=>{e.set({numRows:t,numColumns:o})},getNumRows:()=>e.get().map((e=>e.numRows)),getNumColumns:()=>e.get().map((e=>e.numColumns))})};var mh=Object.freeze({__proto__:null,flatgrid:dh,init:e=>e.state(e)});const uh=e=>(t,o,n,r)=>{const s=e(t.element);return fh(s,t,o,n,r)},gh=(e,t)=>{const o=$c(e,t);return uh(o)},hh=(e,t)=>{const o=$c(t,e);return uh(o)},ph=e=>(t,o,n,r)=>fh(e,t,o,n,r),fh=(e,t,o,n,r)=>n.focusManager.get(t).bind((o=>e(t.element,o,n,r))).map((e=>(n.focusManager.set(t,e),!0))),vh=ph,bh=ph,yh=ph,wh=e=>!(e=>e.offsetWidth<=0&&e.offsetHeight<=0)(e.dom),xh=(e,t,o)=>{const n=_d(e,o);return((e,t)=>$(e,t).map((t=>({index:t,candidates:e}))))(Z(n,wh),(e=>Xe(e,t)))},Ch=(e,t)=>$(e,(e=>Xe(t,e))),Sh=(e,t,o,n)=>n(Math.floor(t/o),t%o).bind((t=>{const n=t.row*o+t.column;return n>=0&&nSh(e,t,n,((t,s)=>{const a=t===o-1?e.length-t*n:n,i=vl(s,r,0,a-1);return D.some({row:t,column:i})})),_h=(e,t,o,n,r)=>Sh(e,t,n,((t,s)=>{const a=vl(t,r,0,o-1),i=a===o-1?e.length-a*n:n,l=bl(s,0,i-1);return D.some({row:a,column:l})})),Eh=[dr("selector"),Tr("execute",sh),tl("onEscape"),Tr("captureTab",!1),al()],Th=(e,t,o)=>{Bi(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},Oh=e=>(t,o,n,r)=>xh(t,o,n.selector).bind((t=>e(t.candidates,t.index,r.getNumRows().getOr(n.initSize.numRows),r.getNumColumns().getOr(n.initSize.numColumns)))),Dh=(e,t,o)=>o.captureTab?D.some(!0):D.none(),Ah=Oh(((e,t,o,n)=>kh(e,t,o,n,-1))),Mh=Oh(((e,t,o,n)=>kh(e,t,o,n,1))),Nh=Oh(((e,t,o,n)=>_h(e,t,o,n,-1))),Rh=Oh(((e,t,o,n)=>_h(e,t,o,n,1))),Bh=w([Yg(Wg(Ig),gh(Ah,Mh)),Yg(Wg(Fg),hh(Ah,Mh)),Yg(Wg(Pg),vh(Nh)),Yg(Wg(zg),bh(Rh)),Yg($g([qg,Wg(Rg)]),Dh),Yg($g([Kg,Wg(Rg)]),Dh),Yg(Wg(Hg.concat(Bg)),((e,t,o,n)=>((e,t)=>t.focusManager.get(e).bind((e=>Li(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n)))))]),Lh=w([Yg(Wg(Lg),((e,t,o)=>o.onEscape(e,t))),Yg(Wg(Hg),ah)]);var Hh=th(Eh,dh,Bh,Lh,(()=>D.some(Th)));const Ih=(e,t,o,n,r)=>{const s=(e,t,o)=>r(e,t,n,0,o.length-1,o[t],(t=>{return n=o[t],"button"===Ve(n)&&"disabled"===_t(n,"disabled")?s(e,t,o):D.from(o[t]);var n}));return xh(e,o,t).bind((e=>{const t=e.index,o=e.candidates;return s(t,t,o)}))},Ph=(e,t,o,n)=>Ih(e,t,o,n,((e,t,o,n,r,s,a)=>{const i=bl(t+o,n,r);return i===e?D.from(s):a(i)})),Fh=(e,t,o,n)=>Ih(e,t,o,n,((e,t,o,n,r,s,a)=>{const i=vl(t,o,n,r);return i===e?D.none():a(i)})),zh=[dr("selector"),Tr("getInitial",D.none),Tr("execute",sh),tl("onEscape"),Tr("executeOnMove",!1),Tr("allowVertical",!0),Tr("allowHorizontal",!0),Tr("cycles",!0)],Vh=(e,t,o)=>((e,t)=>t.focusManager.get(e).bind((e=>Li(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n))),Zh=(e,t,o)=>{t.getInitial(e).orThunk((()=>Bi(e.element,t.selector))).each((o=>{t.focusManager.set(e,o)}))},Uh=(e,t,o)=>(o.cycles?Fh:Ph)(e,o.selector,t,-1),jh=(e,t,o)=>(o.cycles?Fh:Ph)(e,o.selector,t,1),Wh=e=>(t,o,n,r)=>e(t,o,n,r).bind((()=>n.executeOnMove?Vh(t,o,n):D.some(!0))),$h=w([Yg(Wg(Hg),ah),Yg(Wg(Lg),((e,t,o)=>o.onEscape(e,t)))]);var qh=th(zh,Ha.init,((e,t,o,n)=>{const r=[...o.allowHorizontal?Ig:[]].concat(o.allowVertical?Pg:[]),s=[...o.allowHorizontal?Fg:[]].concat(o.allowVertical?zg:[]);return[Yg(Wg(r),Wh(gh(Uh,jh))),Yg(Wg(s),Wh(hh(Uh,jh))),Yg(Wg(Bg),Vh),Yg(Wg(Hg),Vh)]}),$h,(()=>D.some(Zh)));const Gh=(e,t,o)=>D.from(e[t]).bind((e=>D.from(e[o]).map((e=>({rowIndex:t,columnIndex:o,cell:e}))))),Kh=(e,t,o,n)=>{const r=e[t].length,s=vl(o,n,0,r-1);return Gh(e,t,s)},Yh=(e,t,o,n)=>{const r=vl(o,n,0,e.length-1),s=e[r].length,a=bl(t,0,s-1);return Gh(e,r,a)},Xh=(e,t,o,n)=>{const r=e[t].length,s=bl(o+n,0,r-1);return Gh(e,t,s)},Jh=(e,t,o,n)=>{const r=bl(o+n,0,e.length-1),s=e[r].length,a=bl(t,0,s-1);return Gh(e,r,a)},Qh=[fr("selectors",[dr("row"),dr("cell")]),Tr("cycles",!0),Tr("previousSelector",D.none),Tr("execute",sh)],ep=(e,t,o)=>{t.previousSelector(e).orThunk((()=>{const o=t.selectors;return Bi(e.element,o.cell)})).each((o=>{t.focusManager.set(e,o)}))},tp=(e,t)=>(o,n,r)=>{const s=r.cycles?e:t;return Li(n,r.selectors.row).bind((e=>{const t=_d(e,r.selectors.cell);return Ch(t,n).bind((t=>{const n=_d(o,r.selectors.row);return Ch(n,e).bind((e=>{const o=((e,t)=>F(e,(e=>_d(e,t.selectors.cell))))(n,r);return s(o,e,t).map((e=>e.cell))}))}))}))},op=tp(((e,t,o)=>Kh(e,t,o,-1)),((e,t,o)=>Xh(e,t,o,-1))),np=tp(((e,t,o)=>Kh(e,t,o,1)),((e,t,o)=>Xh(e,t,o,1))),rp=tp(((e,t,o)=>Yh(e,o,t,-1)),((e,t,o)=>Jh(e,o,t,-1))),sp=tp(((e,t,o)=>Yh(e,o,t,1)),((e,t,o)=>Jh(e,o,t,1))),ap=w([Yg(Wg(Ig),gh(op,np)),Yg(Wg(Fg),hh(op,np)),Yg(Wg(Pg),vh(rp)),Yg(Wg(zg),bh(sp)),Yg(Wg(Hg.concat(Bg)),((e,t,o)=>sc(e.element).bind((n=>o.execute(e,t,n)))))]),ip=w([Yg(Wg(Hg),ah)]);var lp=th(Qh,Ha.init,ap,ip,(()=>D.some(ep)));const cp=[dr("selector"),Tr("execute",sh),Tr("moveOnTab",!1)],dp=(e,t,o)=>o.focusManager.get(e).bind((n=>o.execute(e,t,n))),mp=(e,t,o)=>{Bi(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},up=(e,t,o)=>Fh(e,o.selector,t,-1),gp=(e,t,o)=>Fh(e,o.selector,t,1),hp=w([Yg(Wg(Pg),yh(up)),Yg(Wg(zg),yh(gp)),Yg($g([qg,Wg(Rg)]),((e,t,o,n)=>o.moveOnTab?yh(up)(e,t,o,n):D.none())),Yg($g([Kg,Wg(Rg)]),((e,t,o,n)=>o.moveOnTab?yh(gp)(e,t,o,n):D.none())),Yg(Wg(Bg),dp),Yg(Wg(Hg),dp)]),pp=w([Yg(Wg(Hg),ah)]);var fp=th(cp,Ha.init,hp,pp,(()=>D.some(mp)));const vp=[tl("onSpace"),tl("onEnter"),tl("onShiftEnter"),tl("onLeft"),tl("onRight"),tl("onTab"),tl("onShiftTab"),tl("onUp"),tl("onDown"),tl("onEscape"),Tr("stopSpaceKeyup",!1),yr("focusIn")];var bp=th(vp,Ha.init,((e,t,o)=>[Yg(Wg(Hg),o.onSpace),Yg($g([Kg,Wg(Bg)]),o.onEnter),Yg($g([qg,Wg(Bg)]),o.onShiftEnter),Yg($g([qg,Wg(Rg)]),o.onShiftTab),Yg($g([Kg,Wg(Rg)]),o.onTab),Yg(Wg(Pg),o.onUp),Yg(Wg(zg),o.onDown),Yg(Wg(Ig),o.onLeft),Yg(Wg(Fg),o.onRight),Yg(Wg(Hg),o.onSpace)]),((e,t,o)=>[...o.stopSpaceKeyup?[Yg(Wg(Hg),ah)]:[],Yg(Wg(Lg),o.onEscape)]),(e=>e.focusIn));const yp=nh.schema(),wp=rh.schema(),xp=qh.schema(),Cp=Hh.schema(),Sp=lp.schema(),kp=ch.schema(),_p=fp.schema(),Ep=bp.schema();const Tp=Xl({branchKey:"mode",branches:Object.freeze({__proto__:null,acyclic:yp,cyclic:wp,flow:xp,flatgrid:Cp,matrix:Sp,execution:kp,menu:_p,special:Ep}),name:"keying",active:{events:(e,t)=>e.handler.toEvents(e,t)},apis:{focusIn:(e,t,o)=>{t.sendFocusIn(t).fold((()=>{e.getSystem().triggerFocus(e.element,e.element)}),(n=>{n(e,t,o)}))},setGridSize:(e,t,o,n,r)=>{(e=>ye(e,"setGridSize"))(o)?o.setGridSize(n,r):console.error("Layout does not support setGridSize")}},state:mh}),Op=(e,t)=>{ac((()=>{mm(e,t,(()=>F(t,e.getSystem().build)))}),e.element)},Dp=(e,t)=>{ac((()=>{((e,t,o)=>{const n=e.components(),r=G(t,(e=>Ba(e).toArray()));z(n,(e=>{L(r,e)||cm(e)}));const s=o(t),a=X(n,s);z(a,(e=>{sm(e)&&cm(e)})),z(s,(t=>{sm(t)||lm(e,t)})),e.syncComponents()})(e,t,(()=>((e,t,o)=>ui(e,t,((t,n)=>gi(e,n,t,o))))(e.element,t,e.getSystem().buildOrPatch)))}),e.element)},Ap=(e,t,o,n)=>{cm(t);const r=gi(e.element,o,n,e.getSystem().buildOrPatch);lm(e,r),e.syncComponents()},Mp=(e,t,o)=>{const n=e.getSystem().build(o);gm(e,n,t)},Np=(e,t,o,n)=>{pm(t),Mp(e,((e,t)=>((e,t,o)=>{it(e,o).fold((()=>{Ho(e,t)}),(e=>{Ro(e,t)}))})(e,t,o)),n)},Rp=(e,t)=>e.components(),Bp=(e,t,o,n,r)=>{const s=Rp(e);return D.from(s[n]).map((o=>(r.fold((()=>pm(o)),(r=>{(t.reuseDom?Ap:Np)(e,o,n,r)})),o)))};var Lp=Object.freeze({__proto__:null,append:(e,t,o,n)=>{Mp(e,Ho,n)},prepend:(e,t,o,n)=>{Mp(e,Lo,n)},remove:(e,t,o,n)=>{const r=Rp(e),s=W(r,(e=>Xe(n.element,e.element)));s.each(pm)},replaceAt:Bp,replaceBy:(e,t,o,n,r)=>{const s=Rp(e);return $(s,n).bind((o=>Bp(e,t,0,o,r)))},set:(e,t,o,n)=>(t.reuseDom?Dp:Op)(e,n),contents:Rp});const Hp=Kl({fields:[Nr("reuseDom",!0)],name:"replacing",apis:Lp}),Ip=(e,t)=>{const o=((e,t)=>{const o=Ys(t);return Kl({fields:[dr("enabled")],name:e,active:{events:w(o)}})})(e,t);return{key:e,value:{config:{},me:o,configAsRaw:w({}),initialConfig:{},state:Ha}}},Pp=(e,t)=>{t.ignore||(tc(e.element),t.onFocus(e))};var Fp=Object.freeze({__proto__:null,focus:Pp,blur:(e,t)=>{t.ignore||oc(e.element)},isFocused:e=>nc(e.element)});var zp=Object.freeze({__proto__:null,exhibit:(e,t)=>{const o=t.ignore?{}:{attributes:{tabindex:"-1"}};return Fa(o)},events:e=>Ys([Qs(bs(),((t,o)=>{Pp(t,e),o.stop()}))].concat(e.stopMousedown?[Qs(es(),((e,t)=>{t.event.prevent()}))]:[]))}),Vp=[el("onFocus"),Tr("stopMousedown",!1),Tr("ignore",!1)];const Zp=Kl({fields:Vp,name:"focusing",active:zp,apis:Fp}),Up=(e,t,o,n)=>{const r=o.get();o.set(n),((e,t,o)=>{t.toggleClass.each((t=>{o.get()?ti(e.element,t):ni(e.element,t)}))})(e,t,o),((e,t,o)=>{const n=t.aria;n.update(e,n,o.get())})(e,t,o),r!==n&&t.onToggled(e,n)},jp=(e,t,o)=>{Up(e,t,o,!o.get())},Wp=(e,t,o)=>{Up(e,t,o,t.selected)};var $p=Object.freeze({__proto__:null,onLoad:Wp,toggle:jp,isOn:(e,t,o)=>o.get(),on:(e,t,o)=>{Up(e,t,o,!0)},off:(e,t,o)=>{Up(e,t,o,!1)},set:Up});var qp=Object.freeze({__proto__:null,exhibit:()=>Fa({}),events:(e,t)=>{const o=(n=e,r=t,s=jp,da((e=>{s(e,n,r)})));var n,r,s;const a=Ul(e,t,Wp);return Ys(q([e.toggleOnExecute?[o]:[],[a]]))}});const Gp=(e,t,o)=>{St(e.element,"aria-expanded",o)};var Kp=[Tr("selected",!1),yr("toggleClass"),Tr("toggleOnExecute",!0),el("onToggled"),Or("aria",{mode:"none"},sr("mode",{pressed:[Tr("syncWithExpanded",!1),rl("update",((e,t,o)=>{St(e.element,"aria-pressed",o),t.syncWithExpanded&&Gp(e,t,o)}))],checked:[rl("update",((e,t,o)=>{St(e.element,"aria-checked",o)}))],expanded:[rl("update",Gp)],selected:[rl("update",((e,t,o)=>{St(e.element,"aria-selected",o)}))],none:[rl("update",v)]}))];const Yp=Kl({fields:Kp,name:"toggling",active:qp,apis:$p,state:(Xp=!1,{init:()=>{const e=Hr(Xp);return{get:()=>e.get(),set:t=>e.set(t),clear:()=>e.set(Xp),readState:()=>e.get()}}})});var Xp;const Jp=()=>{const e=(e,t)=>{t.stop(),$s(e)};return[Qs(ms(),e),Qs(ks(),e),ra(Yr()),ra(es())]},Qp=e=>Ys(q([e.map((e=>da(((t,o)=>{e(t),o.stop()})))).toArray(),Jp()])),ef="alloy.item-hover",tf="alloy.item-focus",of="alloy.item-toggled",nf=e=>{(sc(e.element).isNone()||Zp.isFocused(e))&&(Zp.isFocused(e)||Zp.focus(e),Ws(e,ef,{item:e}))},rf=e=>{Ws(e,tf,{item:e})},sf=w(ef),af=w(tf),lf=w(of),cf=e=>e.toggling.map((e=>e.exclusive?"menuitemradio":"menuitemcheckbox")).getOr("menuitem"),df=e=>({aria:{mode:"checked"},...ge(e,((e,t)=>"exclusive"!==t)),onToggled:(t,o)=>{h(e.onToggled)&&e.onToggled(t,o),((e,t)=>{Ws(e,of,{item:e,state:t})})(t,o)}}),mf=[dr("data"),dr("components"),dr("dom"),Tr("hasSubmenu",!1),yr("toggling"),tu("itemBehaviours",[Yp,Zp,Tp,Xm]),Tr("ignoreFocus",!1),Tr("domModification",{}),rl("builder",(e=>({dom:e.dom,domModification:{...e.domModification,attributes:{role:cf(e),...e.domModification.attributes,"aria-haspopup":e.hasSubmenu,...e.hasSubmenu?{"aria-expanded":!1}:{}}},behaviours:ou(e.itemBehaviours,[e.toggling.fold(Yp.revoke,(e=>Yp.config(df(e)))),Zp.config({ignore:e.ignoreFocus,stopMousedown:e.ignoreFocus,onFocus:e=>{rf(e)}}),Tp.config({mode:"execution"}),Xm.config({store:{mode:"memory",initialValue:e.data}}),Ip("item-type-events",[...Jp(),Qs(rs(),nf),Qs(Ss(),Zp.focus)])]),components:e.components,eventOrder:e.eventOrder}))),Tr("eventOrder",{})],uf=[dr("dom"),dr("components"),rl("builder",(e=>({dom:e.dom,components:e.components,events:Ys([sa(Ss())])})))],gf=w("item-widget"),hf=w([Tu({name:"widget",overrides:e=>({behaviours:ql([Xm.config({store:{mode:"manual",getValue:t=>e.data,setValue:v}})])})})]),pf=[dr("uid"),dr("data"),dr("components"),dr("dom"),Tr("autofocus",!1),Tr("ignoreFocus",!1),tu("widgetBehaviours",[Xm,Zp,Tp]),Tr("domModification",{}),Gu(hf()),rl("builder",(e=>{const t=Fu(gf(),e,hf()),o=zu(gf(),e,t.internals()),n=t=>Vu(t,e,"widget").map((e=>(Tp.focusIn(e),e))),r=(t,o)=>ng(o.event.target)?D.none():e.autofocus?(o.setSource(t.element),D.none()):D.none();return{dom:e.dom,components:o,domModification:e.domModification,events:Ys([da(((e,t)=>{n(e).each((e=>{t.stop()}))})),Qs(rs(),nf),Qs(Ss(),((t,o)=>{e.autofocus?n(t):Zp.focus(t)}))]),behaviours:ou(e.widgetBehaviours,[Xm.config({store:{mode:"memory",initialValue:e.data}}),Zp.config({ignore:e.ignoreFocus,onFocus:e=>{rf(e)}}),Tp.config({mode:"special",focusIn:e.autofocus?e=>{n(e)}:Jl(),onLeft:r,onRight:r,onEscape:(t,o)=>Zp.isFocused(t)||e.autofocus?e.autofocus?(o.setSource(t.element),D.none()):D.none():(Zp.focus(t),D.some(!0))})])}}))],ff=sr("type",{widget:pf,item:mf,separator:uf}),vf=w([Au({factory:{sketch:e=>{const t=nr("menu.spec item",ff,e);return t.builder(t)}},name:"items",unit:"item",defaults:(e,t)=>be(t,"uid")?t:{...t,uid:Ea("item")},overrides:(e,t)=>({type:t.type,ignoreFocus:e.fakeFocus,domModification:{classes:[e.markers.item]}})})]),bf=w([dr("value"),dr("items"),dr("dom"),dr("components"),Tr("eventOrder",{}),Jm("menuBehaviours",[Mg,Xm,ag,Tp]),Or("movement",{mode:"menu",moveOnTab:!0},sr("mode",{grid:[al(),rl("config",((e,t)=>({mode:"flatgrid",selector:"."+e.markers.item,initSize:{numColumns:t.initSize.numColumns,numRows:t.initSize.numRows},focusManager:e.focusManager})))],matrix:[rl("config",((e,t)=>({mode:"matrix",selectors:{row:t.rowSelector,cell:"."+e.markers.item},previousSelector:t.previousSelector,focusManager:e.focusManager}))),dr("rowSelector"),Tr("previousSelector",D.none)],menu:[Tr("moveOnTab",!0),rl("config",((e,t)=>({mode:"menu",selector:"."+e.markers.item,moveOnTab:t.moveOnTab,focusManager:e.focusManager})))]})),mr("markers",Ki()),Tr("fakeFocus",!1),Tr("focusManager",Jg()),el("onHighlight"),el("onDehighlight")]),yf=w("alloy.menu-focus"),wf=og({name:"Menu",configFields:bf(),partFields:vf(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,markers:e.markers,behaviours:eu(e.menuBehaviours,[Mg.config({highlightClass:e.markers.selectedItem,itemClass:e.markers.item,onHighlight:e.onHighlight,onDehighlight:e.onDehighlight}),Xm.config({store:{mode:"memory",initialValue:e.value}}),ag.config({find:D.some}),Tp.config(e.movement.config(e,e.movement))]),events:Ys([Qs(af(),((e,t)=>{const o=t.event;e.getSystem().getByDom(o.target).each((o=>{Mg.highlight(e,o),t.stop(),Ws(e,yf(),{menu:e,item:o})}))})),Qs(sf(),((e,t)=>{const o=t.event.item;Mg.highlight(e,o)})),Qs(lf(),((e,t)=>{const{item:o,state:n}=t.event;n&&"menuitemradio"===_t(o.element,"role")&&((e,t)=>{const o=_d(e.element,'[role="menuitemradio"][aria-checked="true"]');z(o,(o=>{Xe(o,t.element)||e.getSystem().getByDom(o).each((e=>{Yp.off(e)}))}))})(e,o)}))]),components:t,eventOrder:e.eventOrder,domModification:{attributes:{role:"menu"}}})}),xf=(e,t,o,n)=>ve(o,n).bind((n=>ve(e,n).bind((n=>{const r=xf(e,t,o,n);return D.some([n].concat(r))})))).getOr([]),Cf=(e,t)=>{const o={};le(e,((e,t)=>{z(e,(e=>{o[e]=t}))}));const n=t,r=de(t,((e,t)=>({k:e,v:t})));const s=ce(r,((e,t)=>[t].concat(xf(o,n,r,t))));return ce(o,(e=>ve(s,e).getOr([e])))},Sf=e=>"prepared"===e.type?D.some(e.menu):D.none(),kf={init:()=>{const e=Hr({}),t=Hr({}),o=Hr({}),n=kc(),r=Hr({}),s=(t,o,n)=>a(t).bind((r=>(t=>pe(e.get(),((e,o)=>e===t)))(t).bind((e=>o(e).map((e=>({triggeredMenu:r,triggeringItem:e,triggeringPath:n}))))))),a=e=>i(e).bind(Sf),i=e=>ve(t.get(),e),l=t=>ve(e.get(),t);return{setMenuBuilt:(e,o)=>{t.set({...t.get(),[e]:{type:"prepared",menu:o}})},setContents:(s,a,i,l)=>{n.set(s),e.set(i),t.set(a),r.set(l);const c=Cf(l,i);o.set(c)},expand:t=>ve(e.get(),t).map((e=>{const n=ve(o.get(),t).getOr([]);return[e].concat(n)})),refresh:e=>ve(o.get(),e),collapse:e=>ve(o.get(),e).bind((e=>e.length>1?D.some(e.slice(1)):D.none())),lookupMenu:i,lookupItem:l,otherMenus:e=>{const t=r.get();return X(ae(t),e)},getPrimary:()=>n.get().bind(a),getMenus:()=>t.get(),clear:()=>{e.set({}),t.set({}),o.set({}),n.clear()},isClear:()=>n.get().isNone(),getTriggeringPath:(e,t)=>{const r=Z(l(e).toArray(),(e=>a(e).isSome()));return ve(o.get(),e).bind((e=>{const o=Y(r.concat(e));return(e=>{const t=[];for(let o=0;os(e,t,o.slice(0,r+1)).fold((()=>we(n.get(),e)?[]:[D.none()]),(e=>[D.some(e)])))))}))}}},extractPreparedMenu:Sf},_f=ya("tiered-menu-item-highlight"),Ef=ya("tiered-menu-item-dehighlight");var Tf;!function(e){e[e.HighlightMenuAndItem=0]="HighlightMenuAndItem",e[e.HighlightJustMenu=1]="HighlightJustMenu",e[e.HighlightNone=2]="HighlightNone"}(Tf||(Tf={}));const Of=w("collapse-item"),Df=tg({name:"TieredMenu",configFields:[nl("onExecute"),nl("onEscape"),ol("onOpenMenu"),ol("onOpenSubmenu"),el("onRepositionMenu"),el("onCollapseMenu"),Tr("highlightOnOpen",Tf.HighlightMenuAndItem),fr("data",[dr("primary"),dr("menus"),dr("expansions")]),Tr("fakeFocus",!1),el("onHighlightItem"),el("onDehighlightItem"),el("onHover"),Xi(),dr("dom"),Tr("navigateOnHover",!0),Tr("stayInDom",!1),Jm("tmenuBehaviours",[Tp,Mg,ag,Hp]),Tr("eventOrder",{})],apis:{collapseMenu:(e,t)=>{e.collapseMenu(t)},highlightPrimary:(e,t)=>{e.highlightPrimary(t)},repositionMenus:(e,t)=>{e.repositionMenus(t)}},factory:(e,t)=>{const o=kc(),n=kf.init(),r=t=>{const o=((t,o,n)=>ce(n,((n,r)=>{const s=()=>wf.sketch({...n,value:r,markers:e.markers,fakeFocus:e.fakeFocus,onHighlight:(e,t)=>{Ws(e,_f,{menuComp:e,itemComp:t})},onDehighlight:(e,t)=>{Ws(e,Ef,{menuComp:e,itemComp:t})},focusManager:e.fakeFocus?Qg():Jg()});return r===o?{type:"prepared",menu:t.getSystem().build(s())}:{type:"notbuilt",nbMenu:s}})))(t,e.data.primary,e.data.menus),r=a();return n.setContents(e.data.primary,o,e.data.expansions,r),n.getPrimary()},s=e=>Xm.getValue(e).value,a=t=>ce(e.data.menus,((e,t)=>G(e.items,(e=>"separator"===e.type?[]:[e.data.value])))),i=Mg.highlight,l=(t,o)=>{i(t,o),Mg.getHighlighted(o).orThunk((()=>Mg.getFirst(o))).each((n=>{e.fakeFocus?Mg.highlight(o,n):qs(t,n.element,Ss())}))},c=(e,t)=>xe(F(t,(t=>e.lookupMenu(t).bind((e=>"prepared"===e.type?D.some(e.menu):D.none()))))),d=(t,o,n)=>{const r=c(o,o.otherMenus(n));z(r,(o=>{ii(o.element,[e.markers.backgroundMenu]),e.stayInDom||Hp.remove(t,o)}))},m=(t,n)=>{const r=(t=>o.get().getOrThunk((()=>{const n={},r=_d(t.element,`.${e.markers.item}`),a=Z(r,(e=>"true"===_t(e,"aria-haspopup")));return z(a,(e=>{t.getSystem().getByDom(e).each((e=>{const t=s(e);n[t]=e}))})),o.set(n),n})))(t);le(r,((e,t)=>{const o=L(n,t);St(e.element,"aria-expanded",o)}))},u=(t,o,n)=>D.from(n[0]).bind((r=>o.lookupMenu(r).bind((r=>{if("notbuilt"===r.type)return D.none();{const s=r.menu,a=c(o,n.slice(1));return z(a,(t=>{ti(t.element,e.markers.backgroundMenu)})),yt(s.element)||Hp.append(t,Ti(s)),ii(s.element,[e.markers.backgroundMenu]),l(t,s),d(t,o,n),D.some(s)}}))));let g;!function(e){e[e.HighlightSubmenu=0]="HighlightSubmenu",e[e.HighlightParent=1]="HighlightParent"}(g||(g={}));const h=(t,o,r=g.HighlightSubmenu)=>{if(o.hasConfigured(wg)&&wg.isDisabled(o))return D.some(o);{const a=s(o);return n.expand(a).bind((s=>(m(t,s),D.from(s[0]).bind((a=>n.lookupMenu(a).bind((i=>{const l=((e,t,o)=>{if("notbuilt"===o.type){const r=e.getSystem().build(o.nbMenu());return n.setMenuBuilt(t,r),r}return o.menu})(t,a,i);return yt(l.element)||Hp.append(t,Ti(l)),e.onOpenSubmenu(t,o,l,Y(s)),r===g.HighlightSubmenu?(Mg.highlightFirst(l),u(t,n,s)):(Mg.dehighlightAll(l),D.some(o))})))))))}},p=(t,o)=>{const r=s(o);return n.collapse(r).bind((r=>(m(t,r),u(t,n,r).map((n=>(e.onCollapseMenu(t,o,n),n))))))},f=t=>(o,n)=>Li(n.getSource(),`.${e.markers.item}`).bind((e=>o.getSystem().getByDom(e).toOptional().bind((e=>t(o,e).map(O))))),b=Ys([Qs(yf(),((e,t)=>{const o=t.event.item;n.lookupItem(s(o)).each((()=>{const o=t.event.menu;Mg.highlight(e,o);const r=s(t.event.item);n.refresh(r).each((t=>d(e,n,t)))}))})),da(((t,o)=>{const n=o.event.target;t.getSystem().getByDom(n).each((o=>{0===s(o).indexOf("collapse-item")&&p(t,o),h(t,o,g.HighlightSubmenu).fold((()=>{e.onExecute(t,o)}),v)}))})),ia(((t,o)=>{r(t).each((o=>{Hp.append(t,Ti(o)),e.onOpenMenu(t,o),e.highlightOnOpen===Tf.HighlightMenuAndItem?l(t,o):e.highlightOnOpen===Tf.HighlightJustMenu&&i(t,o)}))})),Qs(_f,((t,o)=>{e.onHighlightItem(t,o.event.menuComp,o.event.itemComp)})),Qs(Ef,((t,o)=>{e.onDehighlightItem(t,o.event.menuComp,o.event.itemComp)})),...e.navigateOnHover?[Qs(sf(),((t,o)=>{const r=o.event.item;((e,t)=>{const o=s(t);n.refresh(o).bind((t=>(m(e,t),u(e,n,t))))})(t,r),h(t,r,g.HighlightParent),e.onHover(t,r)}))]:[]]),y=e=>Mg.getHighlighted(e).bind(Mg.getHighlighted),w={collapseMenu:e=>{y(e).each((t=>{p(e,t)}))},highlightPrimary:e=>{n.getPrimary().each((t=>{l(e,t)}))},repositionMenus:t=>{const o=n.getPrimary().bind((e=>y(t).bind((e=>{const t=s(e),o=fe(n.getMenus()),r=xe(F(o,kf.extractPreparedMenu));return n.getTriggeringPath(t,(e=>((e,t,o)=>se(t,(e=>{if(!e.getSystem().isConnected())return D.none();const t=Mg.getCandidates(e);return W(t,(e=>s(e)===o))})))(0,r,e)))})).map((t=>({primary:e,triggeringPath:t})))));o.fold((()=>{(e=>D.from(e.components()[0]).filter((e=>"menu"===_t(e.element,"role"))))(t).each((o=>{e.onRepositionMenu(t,o,[])}))}),(({primary:o,triggeringPath:n})=>{e.onRepositionMenu(t,o,n)}))}};return{uid:e.uid,dom:e.dom,markers:e.markers,behaviours:eu(e.tmenuBehaviours,[Tp.config({mode:"special",onRight:f(((e,t)=>ng(t.element)?D.none():h(e,t,g.HighlightSubmenu))),onLeft:f(((e,t)=>ng(t.element)?D.none():p(e,t))),onEscape:f(((t,o)=>p(t,o).orThunk((()=>e.onEscape(t,o).map((()=>t)))))),focusIn:(e,t)=>{n.getPrimary().each((t=>{qs(e,t.element,Ss())}))}}),Mg.config({highlightClass:e.markers.selectedMenu,itemClass:e.markers.menu}),ag.config({find:e=>Mg.getHighlighted(e)}),Hp.config({})]),eventOrder:e.eventOrder,apis:w,events:b}},extraApis:{tieredData:(e,t,o)=>({primary:e,menus:t,expansions:o}),singleData:(e,t)=>({primary:e,menus:Fr(e,t),expansions:{}}),collapseItem:e=>({value:ya(Of()),meta:{text:e}})}}),Af=tg({name:"InlineView",configFields:[dr("lazySink"),el("onShow"),el("onHide"),kr("onEscape"),Jm("inlineBehaviours",[Mm,Xm,Ql]),Er("fireDismissalEventInstead",[Tr("event",Ls())]),Er("fireRepositionEventInstead",[Tr("event",Hs())]),Tr("getRelated",D.none),Tr("isExtraPart",T),Tr("eventOrder",D.none)],factory:(e,t)=>{const o=(t,o,n,r)=>{const s=e.lazySink(t).getOrDie();Mm.openWhileCloaked(t,o,(()=>rm.positionWithinBounds(s,t,n,r()))),Xm.setValue(t,D.some({mode:"position",config:n,getBounds:r}))},n=(t,o,n,r)=>{const s=((e,t,o,n,r)=>{const s=()=>e.lazySink(t),a="horizontal"===n.type?{layouts:{onLtr:()=>Fl(),onRtl:()=>zl()}}:{},i=e=>(e=>2===e.length)(e)?a:{};return Df.sketch({dom:{tag:"div"},data:n.data,markers:n.menu.markers,highlightOnOpen:n.menu.highlightOnOpen,fakeFocus:n.menu.fakeFocus,onEscape:()=>(Mm.close(t),e.onEscape.map((e=>e(t))),D.some(!0)),onExecute:()=>D.some(!0),onOpenMenu:(e,t)=>{rm.positionWithinBounds(s().getOrDie(),t,o,r())},onOpenSubmenu:(e,t,o,n)=>{const r=s().getOrDie();rm.position(r,o,{anchor:{type:"submenu",item:t,...i(n)}})},onRepositionMenu:(e,t,n)=>{const a=s().getOrDie();rm.positionWithinBounds(a,t,o,r()),z(n,(e=>{const t=i(e.triggeringPath);rm.position(a,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem,...t}})}))}})})(e,t,o,n,r);Mm.open(t,s),Xm.setValue(t,D.some({mode:"menu",menu:s}))},r=t=>{Mm.isOpen(t)&&Xm.getValue(t).each((o=>{switch(o.mode){case"menu":Mm.getState(t).each(Df.repositionMenus);break;case"position":const n=e.lazySink(t).getOrDie();rm.positionWithinBounds(n,t,o.config,o.getBounds())}}))},s={setContent:(e,t)=>{Mm.setContent(e,t)},showAt:(e,t,n)=>{const r=D.none;o(e,t,n,r)},showWithinBounds:o,showMenuAt:(e,t,o)=>{n(e,t,o,D.none)},showMenuWithinBounds:n,hide:e=>{Mm.isOpen(e)&&(Xm.setValue(e,D.none()),Mm.close(e))},getContent:e=>Mm.getState(e),reposition:r,isOpen:Mm.isOpen};return{uid:e.uid,dom:e.dom,behaviours:eu(e.inlineBehaviours,[Mm.config({isPartOf:(t,o,n)=>Fi(o,n)||((t,o)=>e.getRelated(t).exists((e=>Fi(e,o))))(t,n),getAttachPoint:t=>e.lazySink(t).getOrDie(),onOpen:t=>{e.onShow(t)},onClose:t=>{e.onHide(t)}}),Xm.config({store:{mode:"memory",initialValue:D.none()}}),Ql.config({channels:{...Hm({isExtraPart:t.isExtraPart,...e.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Pm({...e.fireRepositionEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({}),doReposition:r})}})]),eventOrder:e.eventOrder,apis:s}},apis:{showAt:(e,t,o,n)=>{e.showAt(t,o,n)},showWithinBounds:(e,t,o,n,r)=>{e.showWithinBounds(t,o,n,r)},showMenuAt:(e,t,o,n)=>{e.showMenuAt(t,o,n)},showMenuWithinBounds:(e,t,o,n,r)=>{e.showMenuWithinBounds(t,o,n,r)},hide:(e,t)=>{e.hide(t)},isOpen:(e,t)=>e.isOpen(t),getContent:(e,t)=>e.getContent(t),setContent:(e,t,o)=>{e.setContent(t,o)},reposition:(e,t)=>{e.reposition(t)}}});var Mf=tinymce.util.Tools.resolve("tinymce.util.Delay");const Nf=tg({name:"Button",factory:e=>{const t=Qp(e.action),o=e.dom.tag,n=t=>ve(e.dom,"attributes").bind((e=>ve(e,t)));return{uid:e.uid,dom:e.dom,components:e.components,events:t,behaviours:ou(e.buttonBehaviours,[Zp.config({}),Tp.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:(()=>{if("button"===o){return{type:n("type").getOr("button"),...n("role").map((e=>({role:e}))).getOr({})}}return{role:e.role.getOr(n("role").getOr("button"))}})()},eventOrder:e.eventOrder}},configFields:[Tr("uid",void 0),dr("dom"),Tr("components",[]),tu("buttonBehaviours",[Zp,Tp]),yr("action"),yr("role"),Tr("eventOrder",{})]}),Rf=e=>{const t=Le.fromHtml(e),o=at(t),n=(e=>{const t=void 0!==e.dom.attributes?e.dom.attributes:[];return j(t,((e,t)=>"class"===t.name?e:{...e,[t.name]:t.value}),{})})(t),r=(e=>Array.prototype.slice.call(e.dom.classList,0))(t),s=0===o.length?{}:{innerHtml:ma(t)};return{tag:Ve(t),classes:r,attributes:n,...s}},Bf=e=>{const t=(e=>void 0!==e.uid)(e)&&ye(e,"uid")?e.uid:Ea("memento");return{get:e=>e.getSystem().getByUid(t).getOrDie(),getOpt:e=>e.getSystem().getByUid(t).toOptional(),asSpec:()=>({...e,uid:t})}},{entries:Lf,setPrototypeOf:Hf,isFrozen:If,getPrototypeOf:Pf,getOwnPropertyDescriptor:Ff}=Object;let{freeze:zf,seal:Vf,create:Zf}=Object,{apply:Uf,construct:jf}="undefined"!=typeof Reflect&&Reflect;Uf||(Uf=function(e,t,o){return e.apply(t,o)}),zf||(zf=function(e){return e}),Vf||(Vf=function(e){return e}),jf||(jf=function(e,t){return new e(...t)});const Wf=nv(Array.prototype.forEach),$f=nv(Array.prototype.pop),qf=nv(Array.prototype.push),Gf=nv(String.prototype.toLowerCase),Kf=nv(String.prototype.toString),Yf=nv(String.prototype.match),Xf=nv(String.prototype.replace),Jf=nv(String.prototype.indexOf),Qf=nv(String.prototype.trim),ev=nv(RegExp.prototype.test),tv=(ov=TypeError,function(){for(var e=arguments.length,t=new Array(e),o=0;o1?o-1:0),r=1;r/gm),wv=Vf(/\${[\w\W]*}/gm),xv=Vf(/^data-[\-\w.\u00B7-\uFFFF]/),Cv=Vf(/^aria-[\-\w]+$/),Sv=Vf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kv=Vf(/^(?:\w+script|data):/i),_v=Vf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ev=Vf(/^html$/i);var Tv=Object.freeze({__proto__:null,MUSTACHE_EXPR:bv,ERB_EXPR:yv,TMPLIT_EXPR:wv,DATA_ATTR:xv,ARIA_ATTR:Cv,IS_ALLOWED_URI:Sv,IS_SCRIPT_OR_DATA:kv,ATTR_WHITESPACE:_v,DOCTYPE_NAME:Ev});const Ov=()=>"undefined"==typeof window?null:window;var Dv=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ov();const o=t=>e(t);if(o.version="3.0.5",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;const n=t.document,r=n.currentScript;let{document:s}=t;const{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:m=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:h}=t,p=c.prototype,f=av(p,"cloneNode"),v=av(p,"nextSibling"),b=av(p,"childNodes"),y=av(p,"parentNode");if("function"==typeof i){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let w,x="";const{implementation:C,createNodeIterator:S,createDocumentFragment:k,getElementsByTagName:_}=s,{importNode:E}=n;let T={};o.isSupported="function"==typeof Lf&&"function"==typeof y&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:D,TMPLIT_EXPR:A,DATA_ATTR:M,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:R,ATTR_WHITESPACE:B}=Tv;let{IS_ALLOWED_URI:L}=Tv,H=null;const I=rv({},[...iv,...lv,...cv,...mv,...gv]);let P=null;const F=rv({},[...hv,...pv,...fv,...vv]);let z=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,Z=null,U=!0,j=!0,W=!1,$=!0,q=!1,G=!1,K=!1,Y=!1,X=!1,J=!1,Q=!1,ee=!0,te=!1,oe=!0,ne=!1,re={},se=null;const ae=rv({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ie=null;const le=rv({},["audio","video","img","source","image","track"]);let ce=null;const de=rv({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),me="http://www.w3.org/1998/Math/MathML",ue="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml";let he=ge,pe=!1,fe=null;const ve=rv({},[me,ue,ge],Kf);let be;const ye=["application/xhtml+xml","text/html"];let we,xe=null;const Ce=s.createElement("form"),Se=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){if(!xe||xe!==e){if(e&&"object"==typeof e||(e={}),e=sv(e),be=be=-1===ye.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,we="application/xhtml+xml"===be?Kf:Gf,H="ALLOWED_TAGS"in e?rv({},e.ALLOWED_TAGS,we):I,P="ALLOWED_ATTR"in e?rv({},e.ALLOWED_ATTR,we):F,fe="ALLOWED_NAMESPACES"in e?rv({},e.ALLOWED_NAMESPACES,Kf):ve,ce="ADD_URI_SAFE_ATTR"in e?rv(sv(de),e.ADD_URI_SAFE_ATTR,we):de,ie="ADD_DATA_URI_TAGS"in e?rv(sv(le),e.ADD_DATA_URI_TAGS,we):le,se="FORBID_CONTENTS"in e?rv({},e.FORBID_CONTENTS,we):ae,V="FORBID_TAGS"in e?rv({},e.FORBID_TAGS,we):{},Z="FORBID_ATTR"in e?rv({},e.FORBID_ATTR,we):{},re="USE_PROFILES"in e&&e.USE_PROFILES,U=!1!==e.ALLOW_ARIA_ATTR,j=!1!==e.ALLOW_DATA_ATTR,W=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,q=e.SAFE_FOR_TEMPLATES||!1,G=e.WHOLE_DOCUMENT||!1,X=e.RETURN_DOM||!1,J=e.RETURN_DOM_FRAGMENT||!1,Q=e.RETURN_TRUSTED_TYPE||!1,Y=e.FORCE_BODY||!1,ee=!1!==e.SANITIZE_DOM,te=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,ne=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||Sv,he=e.NAMESPACE||ge,z=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(j=!1),J&&(X=!0),re&&(H=rv({},[...gv]),P=[],!0===re.html&&(rv(H,iv),rv(P,hv)),!0===re.svg&&(rv(H,lv),rv(P,pv),rv(P,vv)),!0===re.svgFilters&&(rv(H,cv),rv(P,pv),rv(P,vv)),!0===re.mathMl&&(rv(H,mv),rv(P,fv),rv(P,vv))),e.ADD_TAGS&&(H===I&&(H=sv(H)),rv(H,e.ADD_TAGS,we)),e.ADD_ATTR&&(P===F&&(P=sv(P)),rv(P,e.ADD_ATTR,we)),e.ADD_URI_SAFE_ATTR&&rv(ce,e.ADD_URI_SAFE_ATTR,we),e.FORBID_CONTENTS&&(se===ae&&(se=sv(se)),rv(se,e.FORBID_CONTENTS,we)),oe&&(H["#text"]=!0),G&&rv(H,["html","head","body"]),H.table&&(rv(H,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw tv('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw tv('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,x=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let o=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));const r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,r)),null!==w&&"string"==typeof x&&(x=w.createHTML(""));zf&&zf(e),xe=e}},_e=rv({},["mi","mo","mn","ms","mtext"]),Ee=rv({},["foreignobject","desc","title","annotation-xml"]),Te=rv({},["title","style","font","a","script"]),Oe=rv({},lv);rv(Oe,cv),rv(Oe,dv);const De=rv({},mv);rv(De,uv);const Ae=function(e){qf(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},Me=function(e,t){try{qf(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){qf(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!P[e])if(X||J)try{Ae(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ne=function(e){let t,o;if(Y)e=""+e;else{const t=Yf(e,/^[\r\n\t ]+/);o=t&&t[0]}"application/xhtml+xml"===be&&he===ge&&(e=''+e+"");const n=w?w.createHTML(e):e;if(he===ge)try{t=(new g).parseFromString(n,be)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(he,"template",null);try{t.documentElement.innerHTML=pe?x:n}catch(e){}}const r=t.body||t.documentElement;return e&&o&&r.insertBefore(s.createTextNode(o),r.childNodes[0]||null),he===ge?_.call(t,G?"html":"body")[0]:G?t.documentElement:r},Re=function(e){return S.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Be=function(e){return"object"==typeof l?e instanceof l:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Le=function(e,t,n){T[e]&&Wf(T[e],(e=>{e.call(o,t,n,xe)}))},He=function(e){let t;if(Le("beforeSanitizeElements",e,null),(n=e)instanceof u&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof m)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore||"function"!=typeof n.hasChildNodes))return Ae(e),!0;var n;const r=we(e.nodeName);if(Le("uponSanitizeElement",e,{tagName:r,allowedTags:H}),e.hasChildNodes()&&!Be(e.firstElementChild)&&(!Be(e.content)||!Be(e.content.firstElementChild))&&ev(/<[/\w]/g,e.innerHTML)&&ev(/<[/\w]/g,e.textContent))return Ae(e),!0;if(!H[r]||V[r]){if(!V[r]&&Pe(r)){if(z.tagNameCheck instanceof RegExp&&ev(z.tagNameCheck,r))return!1;if(z.tagNameCheck instanceof Function&&z.tagNameCheck(r))return!1}if(oe&&!se[r]){const t=y(e)||e.parentNode,o=b(e)||e.childNodes;if(o&&t){for(let n=o.length-1;n>=0;--n)t.insertBefore(f(o[n],!0),v(e))}}return Ae(e),!0}return e instanceof c&&!function(e){let t=y(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});const o=Gf(e.tagName),n=Gf(t.tagName);return!!fe[e.namespaceURI]&&(e.namespaceURI===ue?t.namespaceURI===ge?"svg"===o:t.namespaceURI===me?"svg"===o&&("annotation-xml"===n||_e[n]):Boolean(Oe[o]):e.namespaceURI===me?t.namespaceURI===ge?"math"===o:t.namespaceURI===ue?"math"===o&&Ee[n]:Boolean(De[o]):e.namespaceURI===ge?!(t.namespaceURI===ue&&!Ee[n])&&!(t.namespaceURI===me&&!_e[n])&&!De[o]&&(Te[o]||!Oe[o]):!("application/xhtml+xml"!==be||!fe[e.namespaceURI]))}(e)?(Ae(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!ev(/<\/no(script|embed|frames)/i,e.innerHTML)?(q&&3===e.nodeType&&(t=e.textContent,t=Xf(t,O," "),t=Xf(t,D," "),t=Xf(t,A," "),e.textContent!==t&&(qf(o.removed,{element:e.cloneNode()}),e.textContent=t)),Le("afterSanitizeElements",e,null),!1):(Ae(e),!0)},Ie=function(e,t,o){if(ee&&("id"===t||"name"===t)&&(o in s||o in Ce))return!1;if(j&&!Z[t]&&ev(M,t));else if(U&&ev(N,t));else if(!P[t]||Z[t]){if(!(Pe(e)&&(z.tagNameCheck instanceof RegExp&&ev(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&ev(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t))||"is"===t&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ev(z.tagNameCheck,o)||z.tagNameCheck instanceof Function&&z.tagNameCheck(o))))return!1}else if(ce[t]);else if(ev(L,Xf(o,B,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Jf(o,"data:")||!ie[e]){if(W&&!ev(R,Xf(o,B,"")));else if(o)return!1}else;return!0},Pe=function(e){return e.indexOf("-")>0},Fe=function(e){let t,o,n,r;Le("beforeSanitizeAttributes",e,null);const{attributes:s}=e;if(!s)return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P};for(r=s.length;r--;){t=s[r];const{name:i,namespaceURI:l}=t;o="value"===i?t.value:Qf(t.value);const c=o;if(n=we(i),a.attrName=n,a.attrValue=o,a.keepAttr=!0,a.forceKeepAttr=void 0,Le("uponSanitizeAttribute",e,a),o=a.attrValue,a.forceKeepAttr)continue;if(!a.keepAttr){Me(i,e);continue}if(!$&&ev(/\/>/i,o)){Me(i,e);continue}q&&(o=Xf(o,O," "),o=Xf(o,D," "),o=Xf(o,A," "));const d=we(e.nodeName);if(Ie(d,n,o)){if(!te||"id"!==n&&"name"!==n||(Me(i,e),o="user-content-"+o),w&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(l);else switch(h.getAttributeType(d,n)){case"TrustedHTML":o=w.createHTML(o);break;case"TrustedScriptURL":o=w.createScriptURL(o)}if(o!==c)try{l?e.setAttributeNS(l,i,o):e.setAttribute(i,o)}catch(t){Me(i,e)}}else Me(i,e)}Le("afterSanitizeAttributes",e,null)},ze=function e(t){let o;const n=Re(t);for(Le("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Le("uponSanitizeShadowNode",o,null),He(o)||(o.content instanceof a&&e(o.content),Fe(o));Le("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t,r,s,i,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(pe=!e,pe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Be(e)){if("function"!=typeof e.toString)throw tv("toString is not a function");if("string"!=typeof(e=e.toString()))throw tv("dirty is not a string, aborting")}if(!o.isSupported)return e;if(K||ke(c),o.removed=[],"string"==typeof e&&(ne=!1),ne){if(e.nodeName){const t=we(e.nodeName);if(!H[t]||V[t])throw tv("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)t=Ne("\x3c!----\x3e"),r=t.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?t=r:t.appendChild(r);else{if(!X&&!q&&!G&&-1===e.indexOf("<"))return w&&Q?w.createHTML(e):e;if(t=Ne(e),!t)return X?null:Q?x:""}t&&Y&&Ae(t.firstChild);const d=Re(ne?e:t);for(;s=d.nextNode();)He(s)||(s.content instanceof a&&ze(s.content),Fe(s));if(ne)return e;if(X){if(J)for(i=k.call(t.ownerDocument);t.firstChild;)i.appendChild(t.firstChild);else i=t;return(P.shadowroot||P.shadowrootmode)&&(i=E.call(n,i,!0)),i}let m=G?t.outerHTML:t.innerHTML;return G&&H["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&ev(Ev,t.ownerDocument.doctype.name)&&(m="\n"+m),q&&(m=Xf(m,O," "),m=Xf(m,D," "),m=Xf(m,A," ")),w&&Q?w.createHTML(m):m},o.setConfig=function(e){ke(e),K=!0},o.clearConfig=function(){xe=null,K=!1},o.isValidAttribute=function(e,t,o){xe||ke({});const n=we(e),r=we(t);return Ie(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(T[e]=T[e]||[],qf(T[e],t))},o.removeHook=function(e){if(T[e])return $f(T[e])},o.removeHooks=function(e){T[e]&&(T[e]=[])},o.removeAllHooks=function(){T={}},o}();const Av=e=>Dv().sanitize(e);var Mv=tinymce.util.Tools.resolve("tinymce.util.I18n");const Nv={indent:!0,outdent:!0,"table-insert-column-after":!0,"table-insert-column-before":!0,"paste-column-after":!0,"paste-column-before":!0,"unordered-list":!0,"list-bull-circle":!0,"list-bull-default":!0,"list-bull-square":!0},Rv="temporary-placeholder",Bv=e=>()=>ve(e,Rv).getOr("!not found!"),Lv=(e,t)=>{const o=e.toLowerCase();if(Mv.isRtl()){const e=((e,t)=>De(e,t)?e:((e,t)=>e+t)(e,t))(o,"-rtl");return be(t,e)?e:o}return o},Hv=(e,t)=>ve(t,Lv(e,t)),Iv=(e,t)=>{const o=t();return Hv(e,o).getOrThunk(Bv(o))},Pv=()=>Ip("add-focusable",[ia((e=>{Ri(e.element,"svg").each((e=>St(e,"focusable","false")))}))]),Fv=(e,t,o,n)=>{var r,s;const a=(e=>!!Mv.isRtl()&&be(Nv,e))(t)?["tox-icon--flip"]:[],i=ve(o,Lv(t,o)).or(n).getOrThunk(Bv(o));return{dom:{tag:e.tag,attributes:null!==(r=e.attributes)&&void 0!==r?r:{},classes:e.classes.concat(a),innerHtml:i},behaviours:ql([...null!==(s=e.behaviours)&&void 0!==s?s:[],Pv()])}},zv=(e,t,o,n=D.none())=>Fv(t,e,o(),n),Vv={success:"checkmark",error:"warning",err:"error",warning:"warning",warn:"warning",info:"info"},Zv=tg({name:"Notification",factory:e=>{const t=Bf({dom:Rf(`

    ${Av(e.translationProvider(e.text))}

    `),behaviours:ql([Hp.config({})])}),o=e=>({dom:{tag:"div",classes:["tox-bar"],styles:{width:`${e}%`}}}),n=e=>({dom:{tag:"div",classes:["tox-text"],innerHtml:`${e}%`}}),r=Bf({dom:{tag:"div",classes:e.progress?["tox-progress-bar","tox-progress-indicator"]:["tox-progress-bar"]},components:[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(0)]},n(0)],behaviours:ql([Hp.config({})])}),s={updateProgress:(e,t)=>{e.getSystem().isConnected()&&r.getOpt(e).each((e=>{Hp.set(e,[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(t)]},n(t)])}))},updateText:(e,o)=>{if(e.getSystem().isConnected()){const n=t.get(e);Hp.set(n,[Ci(o)])}}},a=q([e.icon.toArray(),e.level.toArray(),e.level.bind((e=>D.from(Vv[e]))).toArray()]),i=Bf(Nf.sketch({dom:{tag:"button",classes:["tox-notification__dismiss","tox-button","tox-button--naked","tox-button--icon"]},components:[zv("close",{tag:"span",classes:["tox-icon"],attributes:{"aria-label":e.translationProvider("Close")}},e.iconProvider)],action:t=>{e.onAction(t)}})),l=((e,t,o)=>{const n=o(),r=W(e,(e=>be(n,Lv(e,n))));return Fv(t,r.getOr(Rv),n,D.none())})(a,{tag:"div",classes:["tox-notification__icon"]},e.iconProvider),c=[l,{dom:{tag:"div",classes:["tox-notification__body"]},components:[t.asSpec()],behaviours:ql([Hp.config({})])}];return{uid:e.uid,dom:{tag:"div",attributes:{role:"alert"},classes:e.level.map((e=>["tox-notification","tox-notification--in",`tox-notification--${e}`])).getOr(["tox-notification","tox-notification--in"])},behaviours:ql([Zp.config({}),Ip("notification-events",[Qs(ss(),(e=>{i.getOpt(e).each(Zp.focus)}))])]),components:c.concat(e.progress?[r.asSpec()]:[]).concat(e.closeButton?[i.asSpec()]:[]),apis:s}},configFields:[yr("level"),dr("progress"),yr("icon"),dr("onAction"),dr("text"),dr("iconProvider"),dr("translationProvider"),Nr("closeButton",!0)],apis:{updateProgress:(e,t,o)=>{e.updateProgress(t,o)},updateText:(e,t,o)=>{e.updateText(t,o)}}});var Uv,jv,Wv=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),$v=tinymce.util.Tools.resolve("tinymce.EditorManager"),qv=tinymce.util.Tools.resolve("tinymce.Env");!function(e){e.default="wrap",e.floating="floating",e.sliding="sliding",e.scrolling="scrolling"}(Uv||(Uv={})),function(e){e.auto="auto",e.top="top",e.bottom="bottom"}(jv||(jv={}));const Gv=e=>t=>t.options.get(e),Kv=e=>t=>D.from(e(t)),Yv=e=>{const t=qv.deviceType.isPhone(),o=qv.deviceType.isTablet()||t,n=e.options.register,r=e=>s(e)||!1===e,a=e=>s(e)||p(e);n("skin",{processor:e=>s(e)||!1===e,default:"oxide"}),n("skin_url",{processor:"string"}),n("height",{processor:a,default:Math.max(e.getElement().offsetHeight,400)}),n("width",{processor:a,default:Wv.DOM.getStyle(e.getElement(),"width")}),n("min_height",{processor:"number",default:100}),n("min_width",{processor:"number"}),n("max_height",{processor:"number"}),n("max_width",{processor:"number"}),n("style_formats",{processor:"object[]"}),n("style_formats_merge",{processor:"boolean",default:!1}),n("style_formats_autohide",{processor:"boolean",default:!1}),n("line_height_formats",{processor:"string",default:"1 1.1 1.2 1.3 1.4 1.5 2"}),n("font_family_formats",{processor:"string",default:"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats"}),n("font_size_formats",{processor:"string",default:"8pt 10pt 12pt 14pt 18pt 24pt 36pt"}),n("font_size_input_default_unit",{processor:"string",default:"pt"}),n("block_formats",{processor:"string",default:"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre"}),n("content_langs",{processor:"object[]"}),n("removed_menuitems",{processor:"string",default:""}),n("menubar",{processor:e=>s(e)||d(e),default:!t}),n("menu",{processor:"object",default:{}}),n("toolbar",{processor:e=>d(e)||s(e)||l(e)?{value:e,valid:!0}:{valid:!1,message:"Must be a boolean, string or array."},default:!0}),I(9,(e=>{n("toolbar"+(e+1),{processor:"string"})})),n("toolbar_mode",{processor:"string",default:o?"scrolling":"floating"}),n("toolbar_groups",{processor:"object",default:{}}),n("toolbar_location",{processor:"string",default:jv.auto}),n("toolbar_persist",{processor:"boolean",default:!1}),n("toolbar_sticky",{processor:"boolean",default:e.inline}),n("toolbar_sticky_offset",{processor:"number",default:0}),n("fixed_toolbar_container",{processor:"string",default:""}),n("fixed_toolbar_container_target",{processor:"object"}),n("ui_mode",{processor:"string",default:"combined"}),n("file_picker_callback",{processor:"function"}),n("file_picker_validator_handler",{processor:"function"}),n("file_picker_types",{processor:"string"}),n("typeahead_urls",{processor:"boolean",default:!0}),n("anchor_top",{processor:r,default:"#top"}),n("anchor_bottom",{processor:r,default:"#bottom"}),n("draggable_modal",{processor:"boolean",default:!1}),n("statusbar",{processor:"boolean",default:!0}),n("elementpath",{processor:"boolean",default:!0}),n("branding",{processor:"boolean",default:!0}),n("promotion",{processor:"boolean",default:!0}),n("resize",{processor:e=>"both"===e||d(e),default:!qv.deviceType.isTouch()}),n("sidebar_show",{processor:"string"}),n("help_accessibility",{processor:"boolean",default:e.hasPlugin("help")}),n("default_font_stack",{processor:"string[]",default:[]})},Xv=Gv("readonly"),Jv=Gv("height"),Qv=Gv("width"),eb=Kv(Gv("min_width")),tb=Kv(Gv("min_height")),ob=Kv(Gv("max_width")),nb=Kv(Gv("max_height")),rb=Kv(Gv("style_formats")),sb=Gv("style_formats_merge"),ab=Gv("style_formats_autohide"),ib=Gv("content_langs"),lb=Gv("removed_menuitems"),cb=Gv("toolbar_mode"),db=Gv("toolbar_groups"),mb=Gv("toolbar_location"),ub=Gv("fixed_toolbar_container"),gb=Gv("fixed_toolbar_container_target"),hb=Gv("toolbar_persist"),pb=Gv("toolbar_sticky_offset"),fb=Gv("menubar"),vb=Gv("toolbar"),bb=Gv("file_picker_callback"),yb=Gv("file_picker_validator_handler"),wb=Gv("font_size_input_default_unit"),xb=Gv("file_picker_types"),Cb=Gv("typeahead_urls"),Sb=Gv("anchor_top"),kb=Gv("anchor_bottom"),_b=Gv("draggable_modal"),Eb=Gv("statusbar"),Tb=Gv("elementpath"),Ob=Gv("branding"),Db=Gv("resize"),Ab=Gv("paste_as_text"),Mb=Gv("sidebar_show"),Nb=Gv("promotion"),Rb=Gv("help_accessibility"),Bb=Gv("default_font_stack"),Lb=e=>!1===e.options.get("skin"),Hb=e=>!1!==e.options.get("menubar"),Ib=e=>{const t=e.options.get("skin_url");if(Lb(e))return t;if(t)return e.documentBaseURI.toAbsolute(t);{const t=e.options.get("skin");return $v.baseURL+"/skins/ui/"+t}},Pb=e=>D.from(e.options.get("skin_url")),Fb=e=>e.options.get("line_height_formats").split(" "),zb=e=>{const t=vb(e),o=s(t),n=l(t)&&t.length>0;return!Zb(e)&&(n||o||!0===t)},Vb=e=>{const t=I(9,(t=>e.options.get("toolbar"+(t+1)))),o=Z(t,s);return ke(o.length>0,o)},Zb=e=>Vb(e).fold((()=>{const t=vb(e);return f(t,s)&&t.length>0}),O),Ub=e=>mb(e)===jv.bottom,jb=e=>{var t;if(!e.inline)return D.none();const o=null!==(t=ub(e))&&void 0!==t?t:"";if(o.length>0)return Bi(wt(),o);const n=gb(e);return g(n)?D.some(Le.fromDom(n)):D.none()},Wb=e=>e.inline&&jb(e).isSome(),$b=e=>jb(e).getOrThunk((()=>pt(ht(Le.fromDom(e.getElement()))))),qb=e=>e.inline&&!Hb(e)&&!zb(e)&&!Zb(e),Gb=e=>(e.options.get("toolbar_sticky")||e.inline)&&!Wb(e)&&!qb(e),Kb=e=>!Wb(e)&&"split"===e.options.get("ui_mode"),Yb=e=>{const t=e.options.get("menu");return ce(t,(e=>({...e,items:e.items})))};var Xb=Object.freeze({__proto__:null,get ToolbarMode(){return Uv},get ToolbarLocation(){return jv},register:Yv,getSkinUrl:Ib,getSkinUrlOption:Pb,isReadOnly:Xv,isSkinDisabled:Lb,getHeightOption:Jv,getWidthOption:Qv,getMinWidthOption:eb,getMinHeightOption:tb,getMaxWidthOption:ob,getMaxHeightOption:nb,getUserStyleFormats:rb,shouldMergeStyleFormats:sb,shouldAutoHideStyleFormats:ab,getLineHeightFormats:Fb,getContentLanguages:ib,getRemovedMenuItems:lb,isMenubarEnabled:Hb,isMultipleToolbars:Zb,isToolbarEnabled:zb,isToolbarPersist:hb,getMultipleToolbarsOption:Vb,getUiContainer:$b,useFixedContainer:Wb,isSplitUiMode:Kb,getToolbarMode:cb,isDraggableModal:_b,isDistractionFree:qb,isStickyToolbar:Gb,getStickyToolbarOffset:pb,getToolbarLocation:mb,isToolbarLocationBottom:Ub,getToolbarGroups:db,getMenus:Yb,getMenubar:fb,getToolbar:vb,getFilePickerCallback:bb,getFilePickerTypes:xb,useTypeaheadUrls:Cb,getAnchorTop:Sb,getAnchorBottom:kb,getFilePickerValidatorHandler:yb,getFontSizeInputDefaultUnit:wb,useStatusBar:Eb,useElementPath:Tb,promotionEnabled:Nb,useBranding:Ob,getResize:Db,getPasteAsText:Ab,getSidebarShow:Mb,useHelpAccessibility:Rb,getDefaultFontStack:Bb});const Jb="[data-mce-autocompleter]",Qb=e=>Li(e,Jb),ey=(e,t)=>{const o=(e,t)=>{Ws(e,is(),{raw:t})},n=()=>e.getMenu().bind(Mg.getHighlighted);t.on("keydown",(t=>{const r=t.which;e.isActive()&&(e.isMenuOpen()?13===r?(n().each($s),t.preventDefault()):40===r?(n().fold((()=>{e.getMenu().each(Mg.highlightFirst)}),(e=>{o(e,t)})),t.preventDefault(),t.stopImmediatePropagation()):37!==r&&38!==r&&39!==r||n().each((e=>{o(e,t),t.preventDefault(),t.stopImmediatePropagation()})):13!==r&&38!==r&&40!==r||e.cancelIfNecessary())})),t.on("NodeChange",(t=>{e.isActive()&&!e.isProcessingAction()&&Qb(Le.fromDom(t.element)).isNone()&&e.cancelIfNecessary()}))};var ty;!function(e){e[e.CLOSE_ON_EXECUTE=0]="CLOSE_ON_EXECUTE",e[e.BUBBLE_TO_SANDBOX=1]="BUBBLE_TO_SANDBOX"}(ty||(ty={}));var oy=ty;const ny="tox-menu-nav__js",ry="tox-collection__item",sy="tox-swatch",ay={normal:ny,color:sy},iy="tox-collection__item--enabled",ly="tox-collection__item-icon",cy="tox-collection__item-label",dy="tox-collection__item-caret",my="tox-collection__item--active",uy="tox-collection__item-container",gy="tox-collection__item-container--row",hy=e=>ve(ay,e).getOr(ny),py=e=>"color"===e?"tox-swatches":"tox-menu",fy=e=>({backgroundMenu:"tox-background-menu",selectedMenu:"tox-selected-menu",selectedItem:"tox-collection__item--active",hasIcons:"tox-menu--has-icons",menu:py(e),tieredMenu:"tox-tiered-menu"}),vy=e=>{const t=fy(e);return{backgroundMenu:t.backgroundMenu,selectedMenu:t.selectedMenu,menu:t.menu,selectedItem:t.selectedItem,item:hy(e)}},by=(e,t,o)=>{const n=fy(o);return{tag:"div",classes:q([[n.menu,`tox-menu-${t}-column`],e?[n.hasIcons]:[]])}},yy=[wf.parts.items({})],wy=(e,t,o)=>{const n=fy(o);return{dom:{tag:"div",classes:q([[n.tieredMenu]])},markers:vy(o)}},xy=w([yr("data"),Tr("inputAttributes",{}),Tr("inputStyles",{}),Tr("tag","input"),Tr("inputClasses",[]),el("onSetValue"),Tr("styles",{}),Tr("eventOrder",{}),Jm("inputBehaviours",[Xm,Zp]),Tr("selectOnFocus",!0)]),Cy=e=>ql([Zp.config({onFocus:e.selectOnFocus?e=>{const t=e.element,o=ci(t);t.dom.setSelectionRange(0,o.length)}:v})]),Sy=e=>({...Cy(e),...eu(e.inputBehaviours,[Xm.config({store:{mode:"manual",...e.data.map((e=>({initialValue:e}))).getOr({}),getValue:e=>ci(e.element),setValue:(e,t)=>{ci(e.element)!==t&&di(e.element,t)}},onSetValue:e.onSetValue})])}),ky=e=>({tag:e.tag,attributes:{type:"text",...e.inputAttributes},styles:e.inputStyles,classes:e.inputClasses}),_y=tg({name:"Input",configFields:xy(),factory:(e,t)=>({uid:e.uid,dom:ky(e),components:[],behaviours:Sy(e),eventOrder:e.eventOrder})}),Ey=ya("refetch-trigger-event"),Ty=ya("redirect-menu-item-interaction"),Oy="tox-menu__searcher",Dy=e=>Bi(e.element,`.${Oy}`).bind((t=>e.getSystem().getByDom(t).toOptional())),Ay=Dy,My=e=>({fetchPattern:Xm.getValue(e),selectionStart:e.element.dom.selectionStart,selectionEnd:e.element.dom.selectionEnd}),Ny=e=>{const t=(e,t)=>(t.cut(),D.none()),o=(e,t)=>{const o={interactionEvent:t.event,eventType:t.event.raw.type};return Ws(e,Ty,o),D.some(!0)},n="searcher-events";return{dom:{tag:"div",classes:[ry]},components:[_y.sketch({inputClasses:[Oy,"tox-textfield"],inputAttributes:{...e.placeholder.map((t=>({placeholder:e.i18n(t)}))).getOr({}),type:"search","aria-autocomplete":"list"},inputBehaviours:ql([Ip(n,[Qs(cs(),(e=>{js(e,Ey)})),Qs(is(),((e,t)=>{"Escape"===t.event.raw.key&&t.stop()}))]),Tp.config({mode:"special",onLeft:t,onRight:t,onSpace:t,onEnter:o,onEscape:o,onUp:o,onDown:o})]),eventOrder:{keydown:[n,Tp.name()]}})]}},Ry="tox-collection--results__js",By=e=>{var t;return e.dom?{...e,dom:{...e.dom,attributes:{...null!==(t=e.dom.attributes)&&void 0!==t?t:{},id:ya("aria-item-search-result-id"),"aria-selected":"false"}}}:e},Ly=(e,t)=>o=>{const n=P(o,t);return F(n,(t=>({dom:e,components:t})))},Hy=(e,t)=>{const o=[];let n=[];return z(e,((e,r)=>{t(e,r)?(n.length>0&&o.push(n),n=[],(be(e.dom,"innerHtml")||e.components&&e.components.length>0)&&n.push(e)):n.push(e)})),n.length>0&&o.push(n),F(o,(e=>({dom:{tag:"div",classes:["tox-collection__group"]},components:e})))},Iy=(e,t,o)=>wf.parts.items({preprocess:n=>{const r=F(n,o);return"auto"!==e&&e>1?Ly({tag:"div",classes:["tox-collection__group"]},e)(r):Hy(r,((e,o)=>"separator"===t[o].type))}}),Py=(e,t,o=!0)=>({dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Iy(e,t,x)]}),Fy=e=>H(e,(e=>"icon"in e&&void 0!==e.icon)),zy=e=>(console.error(rr(e)),console.log(e),D.none()),Vy=(e,t,o,n,r)=>{const s=(a=o,{dom:{tag:"div",classes:["tox-collection","tox-collection--horizontal"]},components:[wf.parts.items({preprocess:e=>Hy(e,((e,t)=>"separator"===a[t].type))})]});var a;return{value:e,dom:s.dom,components:s.components,items:o}},Zy=(e,t,o,n,r)=>{const s=()=>"searchable"!==r.menuType?Py(n,o):"search-with-field"===r.searchMode.searchMode?((e,t,o)=>{const n=ya("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Ny({i18n:Mv.translate,placeholder:o.placeholder}),{dom:{tag:"div",classes:[...1===e?["tox-collection--list"]:["tox-collection--grid"],Ry],attributes:{id:n}},components:[Iy(e,t,By)]}]}})(n,o,r.searchMode):((e,t,o=!0)=>{const n=ya("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection",Ry].concat(1===e?["tox-collection--list"]:["tox-collection--grid"]),attributes:{id:n}},components:[Iy(e,t,By)]}})(n,o);if("color"===r.menuType){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-swatches-menu"]},components:[{dom:{tag:"div",classes:["tox-swatches"]},components:[wf.parts.items({preprocess:"auto"!==e?Ly({tag:"div",classes:["tox-swatches__row"]},e):x})]}]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType&&"auto"===n){const t=Py(n,o);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType||"searchable"===r.menuType){const t=s();return{value:e,dom:t.dom,components:t.components,items:o}}if("listpreview"===r.menuType&&"auto"!==n){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-collection","tox-collection--toolbar","tox-collection--toolbar-lg"]},components:[wf.parts.items({preprocess:Ly({tag:"div",classes:["tox-collection__group"]},e)})]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}return{value:e,dom:by(t,n,r.menuType),components:yy,items:o}},Uy=gr("type"),jy=gr("name"),Wy=gr("label"),$y=gr("text"),qy=gr("title"),Gy=gr("icon"),Ky=gr("value"),Yy=pr("fetch"),Xy=pr("getSubmenuItems"),Jy=pr("onAction"),Qy=pr("onItemAction"),ew=Rr("onSetup",(()=>v)),tw=Cr("name"),ow=Cr("text"),nw=Cr("icon"),rw=Cr("tooltip"),sw=Cr("label"),aw=Cr("shortcut"),iw=kr("select"),lw=Nr("active",!1),cw=Nr("borderless",!1),dw=Nr("enabled",!0),mw=Nr("primary",!1),uw=e=>Tr("columns",e),gw=Tr("meta",{}),hw=Rr("onAction",v),pw=e=>Ar("type",e),fw=e=>ir("name","name",Sn((()=>ya(`${e}-name`))),$n),vw=Pn([Uy,ow]),bw=Pn([pw("autocompleteitem"),lw,dw,gw,Ky,ow,nw]),yw=[dw,rw,nw,ow,ew],ww=Pn([Uy,Jy].concat(yw)),xw=e=>tr("toolbarbutton",ww,e),Cw=[lw].concat(yw),Sw=Pn(Cw.concat([Uy,Jy])),kw=e=>tr("ToggleButton",Sw,e),_w=[Rr("predicate",T),Mr("scope","node",["node","editor"]),Mr("position","selection",["node","selection","line"])],Ew=yw.concat([pw("contextformbutton"),mw,Jy,lr("original",x)]),Tw=Cw.concat([pw("contextformbutton"),mw,Jy,lr("original",x)]),Ow=yw.concat([pw("contextformbutton")]),Dw=Cw.concat([pw("contextformtogglebutton")]),Aw=sr("type",{contextformbutton:Ew,contextformtogglebutton:Tw}),Mw=Pn([pw("contextform"),Rr("initValue",w("")),sw,br("commands",Aw),wr("launch",sr("type",{contextformbutton:Ow,contextformtogglebutton:Dw}))].concat(_w)),Nw=Pn([pw("contexttoolbar"),gr("items")].concat(_w)),Rw=[Uy,gr("src"),Cr("alt"),Br("classes",[],$n)],Bw=Pn(Rw),Lw=[Uy,$y,tw,Br("classes",["tox-collection__item-label"],$n)],Hw=Pn(Lw),Iw=Ln((()=>Jn("type",{cardimage:Bw,cardtext:Hw,cardcontainer:Pw}))),Pw=Pn([Uy,Ar("direction","horizontal"),Ar("align","left"),Ar("valign","middle"),br("items",Iw)]),Fw=[dw,ow,aw,(zw="menuitem",ir("value","value",Sn((()=>ya(`${zw}-value`))),Un())),gw];var zw;const Vw=Pn([Uy,sw,br("items",Iw),ew,hw].concat(Fw)),Zw=Pn([Uy,lw,nw].concat(Fw)),Uw=[Uy,gr("fancytype"),hw],jw=[Tr("initData",{})].concat(Uw),Ww=[kr("select"),Lr("initData",{},[Nr("allowCustomColors",!0),Ar("storageKey","default"),_r("colors",Un())])].concat(Uw),$w=sr("fancytype",{inserttable:jw,colorswatch:Ww}),qw=Pn([Uy,ew,hw,nw].concat(Fw)),Gw=Pn([Uy,Xy,ew,nw].concat(Fw)),Kw=Pn([Uy,nw,lw,ew,Jy].concat(Fw)),Yw=(e,t,o)=>{const n=_d(e.element,"."+o);if(n.length>0){const e=$(n,(e=>{const o=e.dom.getBoundingClientRect().top,r=n[0].dom.getBoundingClientRect().top;return Math.abs(o-r)>t})).getOr(n.length);return D.some({numColumns:e,numRows:Math.ceil(n.length/e)})}return D.none()},Xw=(e,t)=>ql([Ip(e,t)]),Jw=e=>Xw(ya("unnamed-events"),e),Qw=ya("tooltip.exclusive"),ex=ya("tooltip.show"),tx=ya("tooltip.hide"),ox=(e,t,o)=>{e.getSystem().broadcastOn([Qw],{})};var nx=Object.freeze({__proto__:null,hideAllExclusive:ox,setComponents:(e,t,o,n)=>{o.getTooltip().each((e=>{e.getSystem().isConnected()&&Hp.set(e,n)}))}});var rx=Object.freeze({__proto__:null,events:(e,t)=>{const o=o=>{t.getTooltip().each((n=>{pm(n),e.onHide(o,n),t.clearTooltip()})),t.clearTimer()};return Ys(q([[Qs(ex,(o=>{t.resetTimer((()=>{(o=>{if(!t.isShowing()){ox(o);const n=e.lazySink(o).getOrDie(),r=o.getSystem().build({dom:e.tooltipDom,components:e.tooltipComponents,events:Ys("normal"===e.mode?[Qs(rs(),(e=>{js(o,ex)})),Qs(os(),(e=>{js(o,tx)}))]:[]),behaviours:ql([Hp.config({})])});t.setTooltip(r),um(n,r),e.onShow(o,r),rm.position(n,r,{anchor:e.anchor(o)})}})(o)}),e.delay)})),Qs(tx,(n=>{t.resetTimer((()=>{o(n)}),e.delay)})),Qs(xs(),((e,t)=>{const n=t;n.universal||L(n.channels,Qw)&&o(e)})),la((e=>{o(e)}))],"normal"===e.mode?[Qs(ss(),(e=>{js(e,ex)})),Qs(ys(),(e=>{js(e,tx)})),Qs(rs(),(e=>{js(e,ex)})),Qs(os(),(e=>{js(e,tx)}))]:[Qs(Zs(),((e,t)=>{js(e,ex)})),Qs(Us(),(e=>{js(e,tx)}))]]))}}),sx=[dr("lazySink"),dr("tooltipDom"),Tr("exclusive",!0),Tr("tooltipComponents",[]),Tr("delay",300),Mr("mode","normal",["normal","follow-highlight"]),Tr("anchor",(e=>({type:"hotspot",hotspot:e,layouts:{onLtr:w([Nl,Ml,Tl,Dl,Ol,Al]),onRtl:w([Nl,Ml,Tl,Dl,Ol,Al])}}))),el("onHide"),el("onShow")];var ax=Object.freeze({__proto__:null,init:()=>{const e=kc(),t=kc(),o=()=>{e.on(clearTimeout)},n=w("not-implemented");return Ia({getTooltip:t.get,isShowing:t.isSet,setTooltip:t.set,clearTooltip:t.clear,clearTimer:o,resetTimer:(t,n)=>{o(),e.set(setTimeout(t,n))},readState:n})}});const ix=Kl({fields:sx,name:"tooltipping",active:rx,state:ax,apis:nx}),lx="silver.readonly",cx=Pn([(dx="readonly",mr(dx,qn))]);var dx;const mx=(e,t)=>{const o=e.mainUi.outerContainer.element,n=[e.mainUi.mothership,...e.uiMotherships];t&&z(n,(e=>{e.broadcastOn([Nm()],{target:o})})),z(n,(e=>{e.broadcastOn([lx],{readonly:t})}))},ux=(e,t)=>{e.on("init",(()=>{e.mode.isReadOnly()&&mx(t,!0)})),e.on("SwitchMode",(()=>mx(t,e.mode.isReadOnly()))),Xv(e)&&e.mode.set("readonly")},gx=()=>Ql.config({channels:{[lx]:{schema:cx,onReceive:(e,t)=>{wg.set(e,t.readonly)}}}}),hx=e=>wg.config({disabled:e,disableClass:"tox-collection__item--state-disabled"}),px=e=>wg.config({disabled:e}),fx=e=>wg.config({disabled:e,disableClass:"tox-tbtn--disabled"}),vx=e=>wg.config({disabled:e,disableClass:"tox-tbtn--disabled",useNative:!1}),bx=(e,t)=>{const o=e.getApi(t);return e=>{e(o)}},yx=(e,t)=>ia((o=>{bx(e,o)((o=>{const n=e.onSetup(o);h(n)&&t.set(n)}))})),wx=(e,t)=>la((o=>bx(e,o)(t.get()))),xx=(e,t)=>da(((o,n)=>{bx(e,o)(e.onAction),e.triggersSubmenu||t!==oy.CLOSE_ON_EXECUTE||(o.getSystem().isConnected()&&js(o,Es()),n.stop())})),Cx={[Cs()]:["disabling","alloy.base.behaviour","toggling","item-events"]},Sx=xe,kx=(e,t,o,n)=>{const r=Hr(v);return{type:"item",dom:t.dom,components:Sx(t.optComponents),data:e.data,eventOrder:Cx,hasSubmenu:e.triggersSubmenu,itemBehaviours:ql([Ip("item-events",[xx(e,o),yx(e,r),wx(e,r)]),hx((()=>!e.enabled||n.isDisabled())),gx(),Hp.config({})].concat(e.itemBehaviours))}},_x=e=>({value:e.value,meta:{text:e.text.getOr(""),...e.meta}}),Ex=e=>{const t=qv.os.isMacOS()||qv.os.isiOS(),o=t?{alt:"⌥",ctrl:"⌃",shift:"⇧",meta:"⌘",access:"⌃⌥"}:{meta:"Ctrl",access:"Shift+Alt"},n=e.split("+"),r=F(n,(e=>{const t=e.toLowerCase().trim();return be(o,t)?o[t]:e}));return t?r.join(""):r.join("+")},Tx=(e,t,o=[ly])=>zv(e,{tag:"div",classes:o},t),Ox=e=>({dom:{tag:"div",classes:[cy]},components:[Ci(Mv.translate(e))]}),Dx=(e,t)=>({dom:{tag:"div",classes:t,innerHtml:e}}),Ax=(e,t)=>({dom:{tag:"div",classes:[cy]},components:[{dom:{tag:e.tag,styles:e.styles},components:[Ci(Mv.translate(t))]}]}),Mx=e=>({dom:{tag:"div",classes:["tox-collection__item-accessory"]},components:[Ci(Ex(e))]}),Nx=e=>Tx("checkmark",e,["tox-collection__item-checkmark"]),Rx=(e,t,o)=>{const n=e.ariaLabel,r=e.value,s=e.iconContent.map((e=>((e,t,o)=>{const n=t();return Hv(e,n).or(o).getOrThunk(Bv(n))})(e,t.icons,o)));return{dom:(()=>{const e=sy,o=s.getOr(""),a=n.map((e=>({title:t.translate(e)}))).getOr({}),i={tag:"div",attributes:a,classes:[e]};return"custom"===r?{...i,tag:"button",classes:[...i.classes,"tox-swatches__picker-btn"],innerHtml:o}:"remove"===r?{...i,classes:[...i.classes,"tox-swatch--remove"],innerHtml:o}:g(r)?{...i,attributes:{...i.attributes,"data-mce-color":r},styles:{"background-color":r},innerHtml:o}:i})(),optComponents:[]}},Bx=e=>{const t=e.map((e=>({attributes:{title:Mv.translate(e),id:ya("menu-item")}}))).getOr({});return{tag:"div",classes:[ny,ry],...t}},Lx=(e,t,o,n=D.none())=>"color"===e.presets?Rx(e,t,n):((e,t,o,n)=>{const r={tag:"div",classes:[ly]},s=o?e.iconContent.map((e=>zv(e,r,t.icons,n))).orThunk((()=>D.some({dom:r}))):D.none(),a=e.checkMark,i=D.from(e.meta).fold((()=>Ox),(e=>be(e,"style")?S(Ax,e.style):Ox)),l=e.htmlContent.fold((()=>e.textContent.map(i)),(e=>D.some(Dx(e,[cy]))));return{dom:Bx(e.ariaLabel),optComponents:[s,l,e.shortcutContent.map(Mx),a,e.caret]}})(e,t,o,n),Hx=(e,t)=>ve(e,"tooltipWorker").map((e=>[ix.config({lazySink:t.getSink,tooltipDom:{tag:"div",classes:["tox-tooltip-worker-container"]},tooltipComponents:[],anchor:e=>({type:"submenu",item:e,overrides:{maxHeightFunction:Fc}}),mode:"follow-highlight",onShow:(t,o)=>{e((e=>{ix.setComponents(t,[Si({element:Le.fromDom(e)})])}))}})])).getOr([]),Ix=(e,t)=>{const o=(e=>Wv.DOM.encode(e))(Mv.translate(e));if(t.length>0){const e=new RegExp((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(t),"gi");return o.replace(e,(e=>`${e}`))}return o},Px=(e,t)=>F(e,(e=>{switch(e.type){case"cardcontainer":return((e,t)=>{const o="vertical"===e.direction?"tox-collection__item-container--column":gy,n="left"===e.align?"tox-collection__item-container--align-left":"tox-collection__item-container--align-right";return{dom:{tag:"div",classes:[uy,o,n,(()=>{switch(e.valign){case"top":return"tox-collection__item-container--valign-top";case"middle":return"tox-collection__item-container--valign-middle";case"bottom":return"tox-collection__item-container--valign-bottom"}})()]},components:t}})(e,Px(e.items,t));case"cardimage":return((e,t,o)=>({dom:{tag:"img",classes:t,attributes:{src:e,alt:o.getOr("")}}}))(e.src,e.classes,e.alt);case"cardtext":const o=e.name.exists((e=>L(t.cardText.highlightOn,e))),n=o?D.from(t.cardText.matchText).getOr(""):"";return Dx(Ix(e.text,n),e.classes)}})),Fx=Bu(gf(),hf()),zx=e=>({value:jx(e)}),Vx=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Zx=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Ux=e=>Vx.test(e)||Zx.test(e),jx=e=>Ee(e,"#").toUpperCase(),Wx=e=>{const t=(e=>{const t=e.value.replace(Vx,((e,t,o,n)=>t+t+o+o+n+n));return{value:t}})(e),o=Zx.exec(t.value);return null===o?["FFFFFF","FF","FF","FF"]:o},$x=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},qx=e=>{const t=$x(e.red)+$x(e.green)+$x(e.blue);return zx(t)},Gx=Math.min,Kx=Math.max,Yx=Math.round,Xx=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,Jx=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,Qx=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),eC=e=>{const t=parseInt(e,10);return t.toString()===e&&t>=0&&t<=255},tC=e=>{let t,o,n;const r=(e.hue||0)%360;let s=e.saturation/100,a=e.value/100;if(s=Kx(0,Gx(s,1)),a=Kx(0,Gx(a,1)),0===s)return t=o=n=Yx(255*a),Qx(t,o,n,1);const i=r/60,l=a*s,c=l*(1-Math.abs(i%2-1)),d=a-l;switch(Math.floor(i)){case 0:t=l,o=c,n=0;break;case 1:t=c,o=l,n=0;break;case 2:t=0,o=l,n=c;break;case 3:t=0,o=c,n=l;break;case 4:t=c,o=0,n=l;break;case 5:t=l,o=0,n=c;break;default:t=o=n=0}return t=Yx(255*(t+d)),o=Yx(255*(o+d)),n=Yx(255*(n+d)),Qx(t,o,n,1)},oC=e=>{const t=Wx(e),o=parseInt(t[1],16),n=parseInt(t[2],16),r=parseInt(t[3],16);return Qx(o,n,r,1)},nC=(e,t,o,n)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(o,10),i=parseFloat(n);return Qx(r,s,a,i)},rC=e=>{if("transparent"===e)return D.some(Qx(0,0,0,0));const t=Xx.exec(e);if(null!==t)return D.some(nC(t[1],t[2],t[3],"1"));const o=Jx.exec(e);return null!==o?D.some(nC(o[1],o[2],o[3],o[4])):D.none()},sC=e=>`rgba(${e.red},${e.green},${e.blue},${e.alpha})`,aC=Qx(255,0,0,1),iC=(e,t)=>{e.dispatch("ResizeContent",t)},lC=(e,t)=>{e.dispatch("TextColorChange",t)},cC=(e,t)=>e.dispatch("ResolveName",{name:t.nodeName.toLowerCase(),target:t}),dC=(e,t)=>()=>{e(),t()},mC=e=>gC(e,"NodeChange",(t=>{t.setEnabled(e.selection.isEditable())})),uC=(e,t)=>o=>{const n=mC(e)(o),r=((e,t)=>o=>{const n=Sc(),r=()=>{o.setActive(e.formatter.match(t));const r=e.formatter.formatChanged(t,o.setActive);n.set(r)};return e.initialized?r():e.once("init",r),()=>{e.off("init",r),n.clear()}})(e,t)(o);return()=>{n(),r()}},gC=(e,t,o)=>n=>{const r=()=>o(n),s=()=>{o(n),e.on(t,r)};return e.initialized?s():e.once("init",s),()=>{e.off("init",s),e.off(t,r)}},hC=e=>t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("mceToggleFormat",!1,t.format)}))},pC=(e,t)=>()=>e.execCommand(t);var fC=tinymce.util.Tools.resolve("tinymce.util.LocalStorage");const vC={},bC=e=>ve(vC,e).getOrThunk((()=>{const t=`tinymce-custom-colors-${e}`,o=fC.getItem(t);if(u(o)){const e=fC.getItem("tinymce-custom-colors");fC.setItem(t,g(e)?e:"[]")}const n=((e,t=10)=>{const o=fC.getItem(e),n=s(o)?JSON.parse(o):[],r=t-(a=n).length<0?a.slice(0,t):a;var a;const i=e=>{r.splice(e,1)};return{add:o=>{B(r,o).each(i),r.unshift(o),r.length>t&&r.pop(),fC.setItem(e,JSON.stringify(r))},state:()=>r.slice(0)}})(t,10);return vC[e]=n,n})),yC=(e,t)=>{bC(e).add(t)},wC=(e,t,o)=>({hue:e,saturation:t,value:o}),xC=e=>{let t=0,o=0,n=0;const r=e.red/255,s=e.green/255,a=e.blue/255,i=Math.min(r,Math.min(s,a)),l=Math.max(r,Math.max(s,a));if(i===l)return n=i,wC(0,0,100*n);return t=r===i?3:a===i?1:5,t=60*(t-(r===i?s-a:a===i?r-s:a-r)/(l-i)),o=(l-i)/l,n=l,wC(Math.round(t),Math.round(100*o),Math.round(100*n))},CC=e=>qx(tC(e)),SC=e=>{return(t=e,Ux(t)?D.some({value:jx(t)}):D.none()).orThunk((()=>rC(e).map(qx))).getOrThunk((()=>{const t=document.createElement("canvas");t.height=1,t.width=1;const o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),o.fillStyle="#FFFFFF",o.fillStyle=e,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data,r=n[0],s=n[1],a=n[2],i=n[3];return qx(Qx(r,s,a,i))}));var t},kC="forecolor",_C="hilitecolor",EC=e=>{const t=[];for(let o=0;ot=>t.options.get(e),OC="#000000",DC=(e,t)=>t===kC&&e.options.isSet("color_map_foreground")?TC("color_map_foreground")(e):t===_C&&e.options.isSet("color_map_background")?TC("color_map_background")(e):TC("color_map")(e),AC=(e,t="default")=>Math.max(5,Math.ceil(Math.sqrt(DC(e,t).length))),MC=(e,t)=>{const o=TC("color_cols")(e),n=AC(e,t);return o===AC(e)?n:o},NC=(e,t="default")=>Math.round(t===kC?TC("color_cols_foreground")(e):t===_C?TC("color_cols_background")(e):TC("color_cols")(e)),RC=TC("custom_colors"),BC=TC("color_default_foreground"),LC=TC("color_default_background"),HC=e=>jr(e,(e=>{if(je(e)){const t=Bt(e,"background-color");return ke((e=>rC(e).exists((e=>0!==e.alpha)))(t),t)}return D.none()})).getOr("rgba(0, 0, 0, 0)"),IC=(e,t)=>{const o=Le.fromDom(e.selection.getStart()),n="hilitecolor"===t?HC(o):Bt(o,"color");return rC(n).map((e=>"#"+qx(e).value))},PC=e=>{const t="choiceitem",o={type:t,text:"Remove color",icon:"color-swatch-remove-color",value:"remove"};return e?[o,{type:t,text:"Custom color",icon:"color-picker",value:"custom"}]:[o]},FC=(e,t,o,n)=>{if("custom"===o){GC(e)((o=>{o.each((o=>{yC(t,o),e.execCommand("mceApplyTextcolor",t,o),n(o)}))}),IC(e,t).getOr(OC))}else"remove"===o?(n(""),e.execCommand("mceRemoveTextcolor",t)):(n(o),e.execCommand("mceApplyTextcolor",t,o))},zC=(e,t,o)=>e.concat((e=>F(bC(e).state(),(e=>({type:"choiceitem",text:e,icon:"checkmark",value:e}))))(t).concat(PC(o))),VC=(e,t,o)=>n=>{n(zC(e,t,o))},ZC=(e,t,o)=>{const n="forecolor"===t?"tox-icon-text-color__color":"tox-icon-highlight-bg-color__color";e.setIconFill(n,o)},UC=(e,t)=>{e.setTooltip(t)},jC=(e,t)=>o=>{const n=IC(e,t);return we(n,o.toUpperCase())},WC=(e,t,o)=>{if(Ne(o))return"forecolor"===t?"Text color":"Background color";const n="forecolor"===t?"Text color {0}":"Background color {0}",r=zC(DC(e,t),t,!1),s=W(r,(e=>e.value===o)).getOr({text:""}).text;return e.translate([n,e.translate(s)])},$C=(e,t,o,n)=>{e.ui.registry.addSplitButton(t,{tooltip:WC(e,o,n.get()),presets:"color",icon:"forecolor"===t?"text-color":"highlight-bg-color",select:jC(e,o),columns:NC(e,o),fetch:VC(DC(e,o),o,RC(e)),onAction:t=>{FC(e,o,n.get(),v)},onItemAction:(r,s)=>{FC(e,o,s,(o=>{n.set(o),lC(e,{name:t,color:o})}))},onSetup:r=>{ZC(r,t,n.get());const s=n=>{n.name===t&&(ZC(r,n.name,n.color),UC(r,WC(e,o,n.color)))};return e.on("TextColorChange",s),dC(mC(e)(r),(()=>{e.off("TextColorChange",s)}))}})},qC=(e,t,o,n,r)=>{e.ui.registry.addNestedMenuItem(t,{text:n,icon:"forecolor"===t?"text-color":"highlight-bg-color",onSetup:n=>(UC(n,WC(e,o,r.get())),ZC(n,t,r.get()),mC(e)(n)),getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"colorswatch",select:jC(e,o),initData:{storageKey:o},onAction:n=>{FC(e,o,n.value,(o=>{r.set(o),lC(e,{name:t,color:o})}))}}]})},GC=e=>(t,o)=>{let n=!1;const r={colorpicker:o};e.windowManager.open({title:"Color Picker",size:"normal",body:{type:"panel",items:[{type:"colorpicker",name:"colorpicker",label:"Color"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:r,onAction:(e,t)=>{"hex-valid"===t.name&&(n=t.value)},onSubmit:o=>{const r=o.getData().colorpicker;n?(t(D.from(r)),o.close()):e.windowManager.alert(e.translate(["Invalid hex color code: {0}",r]))},onClose:v,onCancel:()=>{t(D.none())}})},KC=(e,t,o,n,r,s,a,i)=>{const l=Fy(t),c=YC(t,o,n,"color"!==r?"normal":"color",s,a,i);return Zy(e,l,c,n,{menuType:r})},YC=(e,t,o,n,r,s,a)=>xe(F(e,(i=>{return"choiceitem"===i.type?(l=i,tr("choicemenuitem",Zw,l)).fold(zy,(i=>D.some(((e,t,o,n,r,s,a,i=!0)=>{const l=Lx({presets:o,textContent:t?e.text:D.none(),htmlContent:D.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:t?e.shortcut:D.none(),checkMark:t?D.some(Nx(a.icons)):D.none(),caret:D.none(),value:e.value},a,i);return xn(kx({data:_x(e),enabled:e.enabled,getApi:e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t)}),onAction:t=>n(e.value),onSetup:e=>(e.setActive(r),v),triggersSubmenu:!1,itemBehaviours:[]},l,s,a),{toggling:{toggleClass:iy,toggleOnExecute:!1,selected:e.active,exclusive:!0}})})(i,1===o,n,t,s(i.value),r,a,Fy(e))))):D.none();var l}))),XC=(e,t)=>{const o=vy(t);if(1===e)return{mode:"menu",moveOnTab:!0};if("auto"===e)return{mode:"grid",selector:"."+o.item,initSize:{numColumns:1,numRows:1}};return{mode:"matrix",rowSelector:"."+("color"===t?"tox-swatches__row":"tox-collection__group"),previousSelector:e=>"color"===t?Bi(e.element,"[aria-checked=true]"):D.none()}},JC=(e,t)=>{const o=e.initData.allowCustomColors&&t.colorinput.hasCustomColors();return e.initData.colors.fold((()=>zC(t.colorinput.getColors(e.initData.storageKey),e.initData.storageKey,o)),(e=>e.concat(PC(o))))},QC=ya("cell-over"),eS=ya("cell-execute"),tS=(e,t,o)=>{const n=o=>Ws(o,eS,{row:e,col:t}),r=(e,t)=>{t.stop(),n(e)};return Ei({dom:{tag:"div",attributes:{role:"button","aria-label":o}},behaviours:ql([Ip("insert-table-picker-cell",[Qs(rs(),Zp.focus),Qs(Cs(),n),Qs(ms(),r),Qs(ks(),r)]),Yp.config({toggleClass:"tox-insert-table-picker__selected",toggleOnExecute:!1}),Zp.config({onFocus:o=>Ws(o,QC,{row:e,col:t})})])})},oS=e=>G(e,(e=>F(e,Ti))),nS=(e,t)=>Ci(`${t}x${e}`),rS={inserttable:(e,t)=>{const o=(e=>(t,o)=>e.shared.providers.translate(["{0} columns, {1} rows",o,t]))(t),n=((e,t,o)=>{const n=[];for(let r=0;r{Hp.set(s.get(e),[r])})),na(QC,((e,t,o)=>{const{row:r,col:a}=o.event;((e,t,o,n,r)=>{for(let s=0;s{const{row:r,col:s}=n.event;e.onAction({numRows:r+1,numColumns:s+1}),js(t,Es())}))]),Tp.config({initSize:{numRows:10,numColumns:10},mode:"flatgrid",selector:'[role="button"]'})])})]}},colorswatch:(e,t)=>{const o=JC(e,t),n=t.colorinput.getColorCols(e.initData.storageKey),r="color",s=KC(ya("menu-value"),o,(t=>{e.onAction({value:t})}),n,r,oy.CLOSE_ON_EXECUTE,e.select.getOr(T),t.shared.providers),a={...s,markers:vy(r),movement:XC(n,r)};return{type:"widget",data:{value:ya("widget-id")},dom:{tag:"div",classes:["tox-fancymenuitem"]},autofocus:!0,components:[Fx.widget(wf.sketch(a))]}}},sS=(e,t,o,n,r,s,a,i=!0)=>{const l=Lx({presets:n,textContent:D.none(),htmlContent:o?e.text.map((e=>Ix(e,t))):D.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:D.none(),checkMark:D.none(),caret:D.none(),value:e.value},a.providers,i,e.icon);return kx({data:_x(e),enabled:e.enabled,getApi:w({}),onAction:t=>r(e.value,e.meta),onSetup:w(v),triggersSubmenu:!1,itemBehaviours:Hx(e.meta,a)},l,s,a.providers)},aS=e=>({type:"separator",dom:{tag:"div",classes:[ry,"tox-collection__group-heading"]},components:e.text.map(Ci).toArray()}),iS=(e,t,o,n=!0)=>{const r=Lx({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:D.none(),ariaLabel:e.text,caret:D.none(),checkMark:D.none(),shortcutContent:e.shortcut},o,n);return kx({data:_x(e),getApi:e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t)}),enabled:e.enabled,onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o)},lS=(e,t,o,n=!0,r=!1)=>{const s=r?(a=o.icons,Tx("chevron-down",a,[dy])):(e=>Tx("chevron-right",e,[dy]))(o.icons);var a;const i=Lx({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:D.none(),ariaLabel:e.text,caret:D.some(s),checkMark:D.none(),shortcutContent:e.shortcut},o,n);return kx({data:_x(e),getApi:e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setIconFill:(t,o)=>{Bi(e.element,`svg path[class="${t}"], rect[class="${t}"]`).each((e=>{St(e,"fill",o)}))},setTooltip:t=>{const n=o.translate(t);kt(e.element,{"aria-label":n,title:n})}}),enabled:e.enabled,onAction:v,onSetup:e.onSetup,triggersSubmenu:!0,itemBehaviours:[]},i,t,o)},cS=(e,t,o,n=!0)=>{const r=Lx({iconContent:e.icon,textContent:e.text,htmlContent:D.none(),ariaLabel:e.text,checkMark:D.some(Nx(o.icons)),caret:D.none(),shortcutContent:e.shortcut,presets:"normal",meta:e.meta},o,n);return xn(kx({data:_x(e),enabled:e.enabled,getApi:e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t)}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o),{toggling:{toggleClass:iy,toggleOnExecute:!1,selected:e.active}})},dS=(e,t)=>ve(rS,e.fancytype).map((o=>o(e,t))),mS=(e,t,o,n)=>{const r={dom:Bx(e.label),optComponents:[D.some({dom:{tag:"div",classes:[uy,gy]},components:Px(e.items,n)})]};return kx({data:_x({text:D.none(),...e}),enabled:e.enabled,getApi:e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>{wg.set(e,!t),z(_d(e.element,"*"),(o=>{e.getSystem().getByDom(o).each((e=>{e.hasConfigured(wg)&&wg.set(e,!t)}))}))}}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:D.from(n.itemBehaviours).getOr([])},r,t,o.providers)};var uS=Object.freeze({__proto__:null,getCoupled:(e,t,o,n)=>o.getOrCreate(e,t,n),getExistingCoupled:(e,t,o,n)=>o.getExisting(e,t,n)}),gS=[mr("others",er(on.value,Un()))];var hS=Object.freeze({__proto__:null,init:()=>{const e={},t=(t,o)=>{if(0===ae(t.others).length)throw new Error("Cannot find any known coupled components");return ve(e,o)},o=w({});return Ia({readState:o,getExisting:(e,o,n)=>t(o,n).orThunk((()=>(ve(o.others,n).getOrDie("No information found for coupled component: "+n),D.none()))),getOrCreate:(o,n,r)=>t(n,r).getOrThunk((()=>{const t=ve(n.others,r).getOrDie("No information found for coupled component: "+r)(o),s=o.getSystem().build(t);return e[r]=s,s}))})}});const pS=Kl({fields:gS,name:"coupling",apis:uS,state:hS}),fS=e=>{let t=D.none(),o=[];const n=e=>{r()?a(e):o.push(e)},r=()=>t.isSome(),s=e=>{z(e,a)},a=e=>{t.each((t=>{setTimeout((()=>{e(t)}),0)}))};return e((e=>{r()||(t=D.some(e),s(o),o=[])})),{get:n,map:e=>fS((t=>{n((o=>{t(e(o))}))})),isReady:r}},vS={nu:fS,pure:e=>fS((t=>{t(e)}))},bS=e=>{setTimeout((()=>{throw e}),0)},yS=e=>{const t=t=>{e().then(t,bS)};return{map:t=>yS((()=>e().then(t))),bind:t=>yS((()=>e().then((e=>t(e).toPromise())))),anonBind:t=>yS((()=>e().then((()=>t.toPromise())))),toLazy:()=>vS.nu(t),toCached:()=>{let t=null;return yS((()=>(null===t&&(t=e()),t)))},toPromise:e,get:t}},wS=e=>yS((()=>new Promise(e))),xS=e=>yS((()=>Promise.resolve(e))),CS=w("sink"),SS=w(Du({name:CS(),overrides:w({dom:{tag:"div"},behaviours:ql([rm.config({useFixed:O})]),events:Ys([ra(is()),ra(es()),ra(ms())])})})),kS=(e,t)=>{const o=e.getHotspot(t).getOr(t),n="hotspot",r=e.getAnchorOverrides();return e.layouts.fold((()=>({type:n,hotspot:o,overrides:r})),(e=>({type:n,hotspot:o,overrides:r,layouts:e})))},_S=(e,t,o,n,r,s,a)=>{const i=((e,t,o,n,r,s,a)=>{const i=((e,t,o)=>(0,e.fetch)(o).map(t))(e,t,n),l=DS(n,e);return i.map((e=>e.bind((e=>D.from(Df.sketch({...s.menu(),uid:Ea(""),data:e,highlightOnOpen:a,onOpenMenu:(e,t)=>{const n=l().getOrDie();rm.position(n,t,{anchor:o}),Mm.decloak(r)},onOpenSubmenu:(e,t,o)=>{const n=l().getOrDie();rm.position(n,o,{anchor:{type:"submenu",item:t}}),Mm.decloak(r)},onRepositionMenu:(e,t,n)=>{const r=l().getOrDie();rm.position(r,t,{anchor:o}),z(n,(e=>{rm.position(r,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem}})}))},onEscape:()=>(Zp.focus(n),Mm.close(r),D.some(!0))}))))))})(e,t,kS(e,o),o,n,r,a);return i.map((e=>(e.fold((()=>{Mm.isOpen(n)&&Mm.close(n)}),(e=>{Mm.cloak(n),Mm.open(n,e),s(n)})),n)))},ES=(e,t,o,n,r,s,a)=>(Mm.close(n),xS(n)),TS=(e,t,o,n,r,s)=>{const a=pS.getCoupled(o,"sandbox");return(Mm.isOpen(a)?ES:_S)(e,t,o,a,n,r,s)},OS=(e,t,o)=>{const n=ag.getCurrent(t).getOr(t),r=Xt(e.element);o?Mt(n.element,"min-width",r+"px"):((e,t)=>{Yt.set(e,t)})(n.element,r)},DS=(e,t)=>e.getSystem().getByUid(t.uid+"-"+CS()).map((e=>()=>on.value(e))).getOrThunk((()=>t.lazySink.fold((()=>()=>on.error(new Error("No internal sink is specified, nor could an external sink be found"))),(t=>()=>t(e))))),AS=e=>{Mm.getState(e).each((e=>{Df.repositionMenus(e)}))},MS=(e,t,o)=>{const n=Ii(),r=DS(t,e);return{dom:{tag:"div",classes:e.sandboxClasses,attributes:{id:n.id,role:"listbox"}},behaviours:ou(e.sandboxBehaviours,[Xm.config({store:{mode:"memory",initialValue:t}}),Mm.config({onOpen:(r,s)=>{const a=kS(e,t);n.link(t.element),e.matchWidth&&OS(a.hotspot,s,e.useMinWidth),e.onOpen(a,r,s),void 0!==o&&void 0!==o.onOpen&&o.onOpen(r,s)},onClose:(e,r)=>{n.unlink(t.element),void 0!==o&&void 0!==o.onClose&&o.onClose(e,r)},isPartOf:(e,o,n)=>Fi(o,n)||Fi(t,n),getAttachPoint:()=>r().getOrDie()}),ag.config({find:e=>Mm.getState(e).bind((e=>ag.getCurrent(e)))}),Ql.config({channels:{...Hm({isExtraPart:T}),...Pm({doReposition:AS})}})])}},NS=e=>{const t=pS.getCoupled(e,"sandbox");AS(t)},RS=()=>[Tr("sandboxClasses",[]),tu("sandboxBehaviours",[ag,Ql,Mm,Xm])],BS=w([dr("dom"),dr("fetch"),el("onOpen"),tl("onExecute"),Tr("getHotspot",D.some),Tr("getAnchorOverrides",w({})),Xc(),Jm("dropdownBehaviours",[Yp,pS,Tp,Zp]),dr("toggleClass"),Tr("eventOrder",{}),yr("lazySink"),Tr("matchWidth",!1),Tr("useMinWidth",!1),yr("role")].concat(RS())),LS=w([Ou({schema:[Xi(),Tr("fakeFocus",!1)],name:"menu",defaults:e=>({onExecute:e.onExecute})}),SS()]),HS=og({name:"Dropdown",configFields:BS(),partFields:LS(),factory:(e,t,o,n)=>{const r=e=>{Mm.getState(e).each((e=>{Df.highlightPrimary(e)}))},s=(t,o,r)=>TS(e,x,t,n,o,r),a={expand:e=>{Yp.isOn(e)||s(e,v,Tf.HighlightNone).get(v)},open:e=>{Yp.isOn(e)||s(e,v,Tf.HighlightMenuAndItem).get(v)},refetch:t=>pS.getExistingCoupled(t,"sandbox").fold((()=>s(t,v,Tf.HighlightMenuAndItem).map(v)),(o=>_S(e,x,t,o,n,v,Tf.HighlightMenuAndItem).map(v))),isOpen:Yp.isOn,close:e=>{Yp.isOn(e)&&s(e,v,Tf.HighlightMenuAndItem).get(v)},repositionMenus:e=>{Yp.isOn(e)&&NS(e)}},i=(e,t)=>($s(e),D.some(!0));return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.dropdownBehaviours,[Yp.config({toggleClass:e.toggleClass,aria:{mode:"expanded"}}),pS.config({others:{sandbox:t=>MS(e,t,{onOpen:()=>Yp.on(t),onClose:()=>Yp.off(t)})}}),Tp.config({mode:"special",onSpace:i,onEnter:i,onDown:(e,t)=>{if(HS.isOpen(e)){const t=pS.getCoupled(e,"sandbox");r(t)}else HS.open(e);return D.some(!0)},onEscape:(e,t)=>HS.isOpen(e)?(HS.close(e),D.some(!0)):D.none()}),Zp.config({})]),events:Qp(D.some((e=>{s(e,r,Tf.HighlightMenuAndItem).get(v)}))),eventOrder:{...e.eventOrder,[Cs()]:["disabling","toggling","alloy.base.behaviour"]},apis:a,domModification:{attributes:{"aria-haspopup":"true",...e.role.fold((()=>({})),(e=>({role:e}))),..."button"===e.dom.tag?{type:(l="type",ve(e.dom,"attributes").bind((e=>ve(e,l)))).getOr("button")}:{}}}};var l},apis:{open:(e,t)=>e.open(t),refetch:(e,t)=>e.refetch(t),expand:(e,t)=>e.expand(t),close:(e,t)=>e.close(t),isOpen:(e,t)=>e.isOpen(t),repositionMenus:(e,t)=>e.repositionMenus(t)}}),IS=e=>{const t=Xm.getValue(e),o=Dy(e).map(My);HS.refetch(t).get((()=>{const e=pS.getCoupled(t,"sandbox");o.each((t=>Dy(e).each((e=>((e,t)=>{Xm.setValue(e,t.fetchPattern),e.element.dom.selectionStart=t.selectionStart,e.element.dom.selectionEnd=t.selectionEnd})(e,t)))))}))},PS=e=>Mm.getState(e).bind(Mg.getHighlighted).bind(Mg.getHighlighted),FS=(e,t,o)=>{Ay(e).each((e=>{((e,t)=>{Et(t.element,"id").each((t=>St(e.element,"aria-activedescendant",t)))})(e,o);var n;(si((n=t).element,Ry)?D.some(n.element):Bi(n.element,"."+Ry)).each((t=>{Et(t,"id").each((t=>St(e.element,"aria-controls",t)))}))})),St(o.element,"aria-selected","true")},zS=(e,t,o)=>{St(o.element,"aria-selected","false")},VS=e=>pS.getExistingCoupled(e,"sandbox").bind(Dy).map(My).map((e=>e.fetchPattern)).getOr("");var ZS;!function(e){e[e.ContentFocus=0]="ContentFocus",e[e.UiFocus=1]="UiFocus"}(ZS||(ZS={}));const US=(e,t,o,n,r)=>{const s=o.shared.providers,a=e=>r?{...e,shortcut:D.none(),icon:e.text.isSome()?D.none():e.icon}:e;switch(e.type){case"menuitem":return(i=e,tr("menuitem",qw,i)).fold(zy,(e=>D.some(iS(a(e),t,s,n))));case"nestedmenuitem":return(e=>tr("nestedmenuitem",Gw,e))(e).fold(zy,(e=>D.some(lS(a(e),t,s,n,r))));case"togglemenuitem":return(e=>tr("togglemenuitem",Kw,e))(e).fold(zy,(e=>D.some(cS(a(e),t,s,n))));case"separator":return(e=>tr("separatormenuitem",vw,e))(e).fold(zy,(e=>D.some(aS(e))));case"fancymenuitem":return(e=>tr("fancymenuitem",$w,e))(e).fold(zy,(e=>dS(e,o)));default:return console.error("Unknown item in general menu",e),D.none()}var i},jS=(e,t,o,n,r,s,a)=>{const i=1===n,l=!i||Fy(e);return xe(F(e,(e=>{switch(e.type){case"separator":return(n=e,tr("Autocompleter.Separator",vw,n)).fold(zy,(e=>D.some(aS(e))));case"cardmenuitem":return(e=>tr("cardmenuitem",Vw,e))(e).fold(zy,(e=>D.some(mS({...e,onAction:t=>{e.onAction(t),o(e.value,e.meta)}},r,s,{itemBehaviours:Hx(e.meta,s),cardText:{matchText:t,highlightOn:a}}))));default:return(e=>tr("Autocompleter.Item",bw,e))(e).fold(zy,(e=>D.some(sS(e,t,i,"normal",o,r,s,l))))}var n})))},WS=(e,t,o,n,r,s)=>{const a=Fy(t),i=xe(F(t,(e=>{const t=e=>US(e,o,n,(e=>r?!be(e,"text"):a)(e),r);return"nestedmenuitem"===e.type&&e.getSubmenuItems().length<=0?t({...e,enabled:!1}):t(e)}))),l=(e=>"no-search"===e.searchMode?{menuType:"normal"}:{menuType:"searchable",searchMode:e})(s);return(r?Vy:Zy)(e,a,i,1,l)},$S=e=>Df.singleData(e.value,e),qS=(e,t)=>{const o=ya("autocompleter"),n=Hr(!1),r=Hr(!1),s=Ei(Af.sketch({dom:{tag:"div",classes:["tox-autocompleter"],attributes:{id:o}},components:[],fireDismissalEventInstead:{},inlineBehaviours:ql([Ip("dismissAutocompleter",[Qs(Ls(),(()=>d())),Qs(Zs(),((t,o)=>{Et(o.event.target,"id").each((t=>St(Le.fromDom(e.getBody()),"aria-activedescendant",t)))}))])]),lazySink:t.getSink})),a=()=>Af.isOpen(s),i=r.get,l=()=>{if(a()){Af.hide(s),e.dom.remove(o,!1);const t=Le.fromDom(e.getBody());Et(t,"aria-owns").filter((e=>e===o)).each((()=>{Ot(t,"aria-owns"),Ot(t,"aria-activedescendant")}))}},c=()=>Af.getContent(s).bind((e=>te(e.components(),0))),d=()=>e.execCommand("mceAutocompleterClose"),m=o=>{const r=se(o,(e=>D.from(e.columns))).getOr(1);return G(o,(o=>{const s=o.items;return jS(s,o.matchText,((t,r)=>{const s=e.selection.getRng();((e,t)=>Qb(Le.fromDom(t.startContainer)).map((t=>{const o=e.createRng();return o.selectNode(t.dom),o})))(e.dom,s).each((s=>{const a={hide:()=>d(),reload:t=>{l(),e.execCommand("mceAutocompleterReload",!1,{fetchOptions:t})}};n.set(!0),o.onAction(a,s,t,r),n.set(!1)}))}),r,oy.BUBBLE_TO_SANDBOX,t,o.highlightOn)}))},u=(t,o)=>{var n;(n=Le.fromDom(e.getBody()),Bi(n,Jb)).each((n=>{const r=se(t,(e=>D.from(e.columns))).getOr(1);Af.showMenuAt(s,{anchor:{type:"node",root:Le.fromDom(e.getBody()),node:D.from(n)}},((e,t,o,n)=>{const r=XC(t,n),s=vy(n);return{data:$S({...e,movement:r,menuBehaviours:Jw("auto"!==t?[]:[ia(((e,t)=>{Yw(e,4,s.item).each((({numColumns:t,numRows:o})=>{Tp.setGridSize(e,o,t)}))}))])}),menu:{markers:vy(n),fakeFocus:o===ZS.ContentFocus}}})(Zy("autocompleter-value",!0,o,r,{menuType:"normal"}),r,ZS.ContentFocus,"normal"))})),c().each(Mg.highlightFirst)},g=t=>{const n=m(t);n.length>0?(u(t,n),St(Le.fromDom(e.getBody()),"aria-owns",o),e.inline||h()):l()},h=()=>{e.dom.get(o)&&e.dom.remove(o,!1);const t=e.getDoc().documentElement,n=e.selection.getNode(),r=(e=>ga(e,!0))(s.element);Nt(r,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",top:`${n.offsetTop}px`,left:`${n.offsetLeft}px`}),e.dom.add(t,r.dom),Bi(r,'[role="menu"]').each((e=>{Ft(e,"position"),Ft(e,"max-height")}))};e.on("AutocompleterStart",(({lookupData:e})=>{r.set(!0),n.set(!1),g(e)})),e.on("AutocompleterUpdate",(({lookupData:e})=>g(e))),e.on("AutocompleterEnd",(()=>{l(),r.set(!1),n.set(!1)}));const p={cancelIfNecessary:d,isMenuOpen:a,isActive:i,isProcessingAction:n.get,getMenu:c};ey(p,e)},GS=["visible","hidden","clip"],KS=e=>Ae(e).length>0&&!L(GS,e),YS=e=>{if(Ue(e)){const t=Bt(e,"overflow-x"),o=Bt(e,"overflow-y");return KS(t)||KS(o)}return!1},XS=(e,t)=>Kb(e)?(e=>{const t=kd(e,YS),o=0===t.length?ft(e).map(vt).map((e=>kd(e,YS))).getOr([]):t;return oe(o).map((e=>({element:e,others:o.slice(1)})))})(t):D.none(),JS=e=>{const t=[...F(e.others,Ko),Jo()];return((e,t)=>j(t,((e,t)=>Xo(e,t)),e))(Ko(e.element),t)},QS=(e,t,o)=>Li(e,t,o).isSome(),ek=(e,t)=>{let o=null;return{cancel:()=>{null!==o&&(clearTimeout(o),o=null)},schedule:(...n)=>{o=setTimeout((()=>{e.apply(null,n),o=null}),t)}}},tk=e=>{const t=e.raw;return void 0===t.touches||1!==t.touches.length?D.none():D.some(t.touches[0])},ok=e=>{const t=kc(),o=Hr(!1),n=ek((t=>{e.triggerEvent(_s(),t),o.set(!0)}),400),r=zr([{key:Yr(),value:e=>(tk(e).each((r=>{n.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};n.schedule(e),o.set(!1),t.set(s)})),D.none())},{key:Xr(),value:e=>(n.cancel(),tk(e).each((e=>{t.on((o=>{((e,t)=>{const o=Math.abs(e.clientX-t.x),n=Math.abs(e.clientY-t.y);return o>5||n>5})(e,o)&&t.clear()}))})),D.none())},{key:Jr(),value:r=>{n.cancel();return t.get().filter((e=>Xe(e.target,r.target))).map((t=>o.get()?(r.prevent(),!1):e.triggerEvent(ks(),r)))}}]);return{fireIfReady:(e,t)=>ve(r,t).bind((t=>t(e)))}},nk=(e,t)=>{const o={stopBackspace:!0,...t},n=ok(o),r=F(["touchstart","touchmove","touchend","touchcancel","gesturestart","mousedown","mouseup","mouseover","mousemove","mouseout","click"].concat(["selectstart","input","contextmenu","change","transitionend","transitioncancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","keyup"]),(t=>Ec(e,t,(e=>{n.fireIfReady(e,t).each((t=>{t&&e.kill()}));o.triggerEvent(t,e)&&e.kill()})))),s=kc(),a=Ec(e,"paste",(e=>{n.fireIfReady(e,"paste").each((t=>{t&&e.kill()}));o.triggerEvent("paste",e)&&e.kill(),s.set(setTimeout((()=>{o.triggerEvent(ws(),e)}),0))})),i=Ec(e,"keydown",(e=>{o.triggerEvent("keydown",e)?e.kill():o.stopBackspace&&(e=>e.raw.which===Ng[0]&&!L(["input","textarea"],Ve(e.target))&&!QS(e.target,'[contenteditable="true"]'))(e)&&e.prevent()})),l=Ec(e,"focusin",(e=>{o.triggerEvent("focusin",e)&&e.kill()})),c=kc(),d=Ec(e,"focusout",(e=>{o.triggerEvent("focusout",e)&&e.kill(),c.set(setTimeout((()=>{o.triggerEvent(ys(),e)}),0))}));return{unbind:()=>{z(r,(e=>{e.unbind()})),i.unbind(),l.unbind(),d.unbind(),a.unbind(),s.on(clearTimeout),c.on(clearTimeout)}}},rk=(e,t)=>{const o=ve(e,"target").getOr(t);return Hr(o)},sk=Ir([{stopped:[]},{resume:["element"]},{complete:[]}]),ak=(e,t,o,n,r,s)=>{const a=e(t,n),i=((e,t)=>{const o=Hr(!1),n=Hr(!1);return{stop:()=>{o.set(!0)},cut:()=>{n.set(!0)},isStopped:o.get,isCut:n.get,event:e,setSource:t.set,getSource:t.get}})(o,r);return a.fold((()=>(s.logEventNoHandlers(t,n),sk.complete())),(e=>{const o=e.descHandler;return za(o)(i),i.isStopped()?(s.logEventStopped(t,e.element,o.purpose),sk.stopped()):i.isCut()?(s.logEventCut(t,e.element,o.purpose),sk.complete()):nt(e.element).fold((()=>(s.logNoParent(t,e.element,o.purpose),sk.complete())),(n=>(s.logEventResponse(t,e.element,o.purpose),sk.resume(n))))}))},ik=(e,t,o,n,r,s)=>ak(e,t,o,n,r,s).fold(O,(n=>ik(e,t,o,n,r,s)),T),lk=(e,t,o)=>{const n=(e=>{const t=Hr(!1);return{stop:()=>{t.set(!0)},cut:v,isStopped:t.get,isCut:T,event:e,setSource:_("Cannot set source of a broadcasted event"),getSource:_("Cannot get source of a broadcasted event")}})(t);return z(e,(e=>{const t=e.descHandler;za(t)(n)})),n.isStopped()},ck=(e,t,o,n,r)=>{const s=rk(o,n);return ik(e,t,o,n,s,r)},dk=()=>{const e={};return{registerId:(t,o,n)=>{le(n,((n,r)=>{const s=void 0!==e[r]?e[r]:{};s[o]=((e,t)=>{return o=S.apply(void 0,[e.handler].concat(t)),n=e.purpose,{cHandler:o,purpose:n};var o,n})(n,t),e[r]=s}))},unregisterId:t=>{le(e,((e,o)=>{be(e,t)&&delete e[t]}))},filterByType:t=>ve(e,t).map((e=>he(e,((e,t)=>((e,t)=>({id:e,descHandler:t}))(t,e))))).getOr([]),find:(t,o,n)=>ve(e,o).bind((e=>jr(n,(t=>((e,t)=>_a(t).bind((t=>ve(e,t))).map((e=>((e,t)=>({element:e,descHandler:t}))(t,e))))(e,t)),t)))}},mk=()=>{const e=dk(),t={},o=e=>{const t=e.element;return _a(t).getOrThunk((()=>((e,t)=>{const o=ya(Ca+e);return ka(t,o),o})("uid-",e.element)))},n=o=>{_a(o.element).each((o=>{delete t[o],e.unregisterId(o)}))};return{find:(t,o,n)=>e.find(t,o,n),filter:t=>e.filterByType(t),register:r=>{const s=o(r);ye(t,s)&&((e,o)=>{const r=t[o];if(r!==e)throw new Error('The tagId "'+o+'" is already used by: '+pa(r.element)+"\nCannot use it for: "+pa(e.element)+"\nThe conflicting element is"+(yt(r.element)?" ":" not ")+"already in the DOM");n(e)})(r,s);const a=[r];e.registerId(a,s,r.events),t[s]=r},unregister:n,getById:e=>ve(t,e)}},uk=tg({name:"Container",factory:e=>{const{attributes:t,...o}=e.dom;return{uid:e.uid,dom:{tag:"div",attributes:{role:"presentation",...t},...o},components:e.components,behaviours:Qm(e.containerBehaviours),events:e.events,domModification:e.domModification,eventOrder:e.eventOrder}},configFields:[Tr("components",[]),Jm("containerBehaviours",[]),Tr("events",{}),Tr("domModification",{}),Tr("eventOrder",{})]}),gk=e=>{const t=t=>nt(e.element).fold(O,(e=>Xe(t,e))),o=mk(),n=(e,n)=>o.find(t,e,n),r=nk(e.element,{triggerEvent:(e,t)=>Wi(e,t.target,(o=>((e,t,o,n)=>ck(e,t,o,o.target,n))(n,e,t,o)))}),s={debugInfo:w("real"),triggerEvent:(e,t,o)=>{Wi(e,t,(r=>ck(n,e,o,t,r)))},triggerFocus:(e,t)=>{_a(e).fold((()=>{tc(e)}),(o=>{Wi(bs(),e,(o=>(((e,t,o,n,r)=>{const s=rk(o,n);ak(e,t,o,n,s,r)})(n,bs(),{originator:t,kill:v,prevent:v,target:e},e,o),!1)))}))},triggerEscape:(e,t)=>{s.triggerEvent("keydown",e.element,t.event)},getByUid:e=>h(e),getByDom:e=>p(e),build:Ei,buildOrPatch:_i,addToGui:e=>{l(e)},removeFromGui:e=>{c(e)},addToWorld:e=>{a(e)},removeFromWorld:e=>{i(e)},broadcast:e=>{m(e)},broadcastOn:(e,t)=>{u(e,t)},broadcastEvent:(e,t)=>{g(e,t)},isConnected:O},a=e=>{e.connect(s),We(e.element)||(o.register(e),z(e.components(),a),s.triggerEvent(Os(),e.element,{target:e.element}))},i=e=>{We(e.element)||(z(e.components(),i),o.unregister(e)),e.disconnect()},l=t=>{um(e,t)},c=e=>{pm(e)},d=e=>{const t=o.filter(xs());z(t,(t=>{const o=t.descHandler;za(o)(e)}))},m=e=>{d({universal:!0,data:e})},u=(e,t)=>{d({universal:!1,channels:e,data:t})},g=(e,t)=>{const n=o.filter(e);return lk(n,t)},h=e=>o.getById(e).fold((()=>on.error(new Error('Could not find component with uid: "'+e+'" in system.'))),on.value),p=e=>{const t=_a(e).getOr("not found");return h(t)};return a(e),{root:e,element:e.element,destroy:()=>{r.unbind(),Fo(e.element)},add:l,remove:c,getByUid:h,getByDom:p,addToWorld:a,removeFromWorld:i,broadcast:m,broadcastOn:u,broadcastEvent:g}},hk=w([Tr("prefix","form-field"),Jm("fieldBehaviours",[ag,Xm])]),pk=w([Du({schema:[dr("dom")],name:"label"}),Du({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[dr("text")],name:"aria-descriptor"}),Tu({factory:{sketch:e=>{const t=Pr(e,["factory"]);return e.factory.sketch(t)}},schema:[dr("factory")],name:"field"})]),fk=og({name:"FormField",configFields:hk(),partFields:pk(),factory:(e,t,o,n)=>{const r=eu(e.fieldBehaviours,[ag.config({find:t=>Vu(t,e,"field")}),Xm.config({store:{mode:"manual",getValue:e=>ag.getCurrent(e).bind(Xm.getValue),setValue:(e,t)=>{ag.getCurrent(e).each((e=>{Xm.setValue(e,t)}))}}})]),s=Ys([ia(((t,o)=>{const n=Uu(t,e,["label","field","aria-descriptor"]);n.field().each((t=>{const o=ya(e.prefix);n.label().each((e=>{St(e.element,"for",o),St(t.element,"id",o)})),n["aria-descriptor"]().each((o=>{const n=ya(e.prefix);St(o.element,"id",n),St(t.element,"aria-describedby",n)}))}))}))]),a={getField:t=>Vu(t,e,"field"),getLabel:t=>Vu(t,e,"label")};return{uid:e.uid,dom:e.dom,components:t,behaviours:r,events:s,apis:a}},apis:{getField:(e,t)=>e.getField(t),getLabel:(e,t)=>e.getLabel(t)}});var vk=Object.freeze({__proto__:null,exhibit:(e,t)=>Fa({attributes:zr([{key:t.tabAttr,value:"true"}])})}),bk=[Tr("tabAttr","data-alloy-tabstop")];const yk=Kl({fields:bk,name:"tabstopping",active:vk});var wk=tinymce.util.Tools.resolve("tinymce.html.Entities");const xk=(e,t,o,n)=>{const r=Ck(e,t,o,n);return fk.sketch(r)},Ck=(e,t,o,n)=>({dom:Sk(o),components:e.toArray().concat([t]),fieldBehaviours:ql(n)}),Sk=e=>({tag:"div",classes:["tox-form__group"].concat(e)}),kk=(e,t)=>fk.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[Ci(t.translate(e))]}),_k=ya("form-component-change"),Ek=ya("form-close"),Tk=ya("form-cancel"),Ok=ya("form-action"),Dk=ya("form-submit"),Ak=ya("form-block"),Mk=ya("form-unblock"),Nk=ya("form-tabchange"),Rk=ya("form-resize"),Bk=(e,t,o)=>{const n=e.label.map((e=>kk(e,t))),r=t.icons(),s=e=>(t,o)=>{Li(o.event.target,"[data-collection-item-value]").each((n=>{e(t,o,n,_t(n,"data-collection-item-value"))}))},a=(o,n)=>{const s=F(n,(o=>{const n=Mv.translate(o.text),s=1===e.columns?`
    ${n}
    `:"",a=`
    ${(e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})(o.icon)}
    `,i={_:" "," - ":" ","-":" "},l=n.replace(/\_| \- |\-/g,(e=>i[e]));return`
    ${a}${s}
    `})),a="auto"!==e.columns&&e.columns>1?P(s,e.columns):[s],i=F(a,(e=>`
    ${e.join("")}
    `));ua(o.element,i.join(""))},i=s(((o,n,r,s)=>{n.stop(),t.isDisabled()||Ws(o,Ok,{name:e.name,value:s})})),l=[Qs(rs(),s(((e,t,o)=>{tc(o)}))),Qs(ms(),i),Qs(ks(),i),Qs(ss(),s(((e,t,o)=>{Bi(e.element,"."+my).each((e=>{ni(e,my)})),ti(o,my)}))),Qs(as(),s((e=>{Bi(e.element,"."+my).each((e=>{ni(e,my)}))}))),da(s(((t,o,n,r)=>{Ws(t,Ok,{name:e.name,value:r})})))],c=(e,t)=>F(_d(e.element,".tox-collection__item"),t),d=fk.parts.field({dom:{tag:"div",classes:["tox-collection"].concat(1!==e.columns?["tox-collection--grid"]:["tox-collection--list"])},components:[],factory:{sketch:x},behaviours:ql([wg.config({disabled:t.isDisabled,onDisabled:e=>{c(e,(e=>{ti(e,"tox-collection__item--state-disabled"),St(e,"aria-disabled",!0)}))},onEnabled:e=>{c(e,(e=>{ni(e,"tox-collection__item--state-disabled"),Ot(e,"aria-disabled")}))}}),gx(),Hp.config({}),Xm.config({store:{mode:"memory",initialValue:o.getOr([])},onSetValue:(t,o)=>{a(t,o),"auto"===e.columns&&Yw(t,5,"tox-collection__item").each((({numRows:e,numColumns:o})=>{Tp.setGridSize(t,e,o)})),js(t,Rk)}}),yk.config({}),Tp.config((m=e.columns,u="normal",1===m?{mode:"menu",moveOnTab:!1,selector:".tox-collection__item"}:"auto"===m?{mode:"flatgrid",selector:".tox-collection__item",initSize:{numColumns:1,numRows:1}}:{mode:"matrix",selectors:{row:"color"===u?".tox-swatches__row":".tox-collection__group",cell:"color"===u?`.${sy}`:`.${ry}`}})),Ip("collection-events",l)]),eventOrder:{[Cs()]:["disabling","alloy.base.behaviour","collection-events"]}});var m,u;return xk(n,d,["tox-form__group--collection"],[])},Lk=["input","textarea"],Hk=e=>{const t=Ve(e);return L(Lk,t)},Ik=(e,t)=>{const o=t.getRoot(e).getOr(e.element);ni(o,t.invalidClass),t.notify.each((t=>{Hk(e.element)&&St(e.element,"aria-invalid",!1),t.getContainer(e).each((e=>{ua(e,t.validHtml)})),t.onValid(e)}))},Pk=(e,t,o,n)=>{const r=t.getRoot(e).getOr(e.element);ti(r,t.invalidClass),t.notify.each((t=>{Hk(e.element)&&St(e.element,"aria-invalid",!0),t.getContainer(e).each((e=>{ua(e,n)})),t.onInvalid(e,n)}))},Fk=(e,t,o)=>t.validator.fold((()=>xS(on.value(!0))),(t=>t.validate(e))),zk=(e,t,o)=>(t.notify.each((t=>{t.onValidate(e)})),Fk(e,t).map((o=>e.getSystem().isConnected()?o.fold((o=>(Pk(e,t,0,o),on.error(o))),(o=>(Ik(e,t),on.value(o)))):on.error("No longer in system"))));var Vk=Object.freeze({__proto__:null,markValid:Ik,markInvalid:Pk,query:Fk,run:zk,isInvalid:(e,t)=>{const o=t.getRoot(e).getOr(e.element);return si(o,t.invalidClass)}});var Zk=Object.freeze({__proto__:null,events:(e,t)=>e.validator.map((t=>Ys([Qs(t.onEvent,(t=>{zk(t,e).get(x)}))].concat(t.validateOnLoad?[ia((t=>{zk(t,e).get(v)}))]:[])))).getOr({})}),Uk=[dr("invalidClass"),Tr("getRoot",D.none),Er("notify",[Tr("aria","alert"),Tr("getContainer",D.none),Tr("validHtml",""),el("onValid"),el("onInvalid"),el("onValidate")]),Er("validator",[dr("validate"),Tr("onEvent","input"),Tr("validateOnLoad",!0)])];const jk=Kl({fields:Uk,name:"invalidating",active:Zk,apis:Vk,extra:{validation:e=>t=>{const o=Xm.getValue(t);return xS(e(o))}}});const Wk=Kl({fields:[],name:"unselecting",active:Object.freeze({__proto__:null,events:()=>Ys([Xs(ps(),O)]),exhibit:()=>Fa({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})})}),$k=ya("color-input-change"),qk=ya("color-swatch-change"),Gk=ya("color-picker-cancel"),Kk=(e,t,o,n)=>{const r=fk.parts.field({factory:_y,inputClasses:["tox-textfield"],data:n,onSetValue:e=>jk.run(e).get(v),inputBehaviours:ql([wg.config({disabled:t.providers.isDisabled}),gx(),yk.config({}),jk.config({invalidClass:"tox-textbox-field-invalid",getRoot:e=>rt(e.element),notify:{onValid:e=>{const t=Xm.getValue(e);Ws(e,$k,{color:t})}},validator:{validateOnLoad:!1,validate:e=>{const t=Xm.getValue(e);if(0===t.length)return xS(on.value(!0));{const e=Le.fromTag("span");Mt(e,"background-color",t);const o=Ht(e,"background-color").fold((()=>on.error("blah")),(e=>on.value(t)));return xS(o)}}}})]),selectOnFocus:!1}),s=e.label.map((e=>kk(e,t.providers))),a=(e,t)=>{Ws(e,qk,{value:t})},i=Bf(((e,t)=>HS.sketch({dom:e.dom,components:e.components,toggleClass:"mce-active",dropdownBehaviours:ql([px(t.providers.isDisabled),gx(),Wk.config({}),yk.config({})]),layouts:e.layouts,sandboxClasses:["tox-dialog__popups"],lazySink:t.getSink,fetch:o=>wS((t=>e.fetch(t))).map((n=>D.from($S(xn(KC(ya("menu-value"),n,(t=>{e.onItemAction(o,t)}),e.columns,e.presets,oy.CLOSE_ON_EXECUTE,T,t.providers),{movement:XC(e.columns,e.presets)}))))),parts:{menu:wy(0,0,e.presets)}}))({dom:{tag:"span",attributes:{"aria-label":t.providers.translate("Color swatch")}},layouts:{onRtl:()=>[Ol,Tl,Nl],onLtr:()=>[Tl,Ol,Nl]},components:[],fetch:VC(o.getColors(e.storageKey),e.storageKey,o.hasCustomColors()),columns:o.getColorCols(e.storageKey),presets:"color",onItemAction:(t,n)=>{i.getOpt(t).each((t=>{"custom"===n?o.colorPicker((o=>{o.fold((()=>js(t,Gk)),(o=>{a(t,o),yC(e.storageKey,o)}))}),"#ffffff"):a(t,"remove"===n?"":n)}))}},t));return fk.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:s.toArray().concat([{dom:{tag:"div",classes:["tox-color-input"]},components:[r,i.asSpec()]}]),fieldBehaviours:ql([Ip("form-field-events",[Qs($k,((t,o)=>{i.getOpt(t).each((e=>{Mt(e.element,"background-color",o.event.color)})),Ws(t,_k,{name:e.name})})),Qs(qk,((e,t)=>{fk.getField(e).each((o=>{Xm.setValue(o,t.event.value),ag.getCurrent(e).each(Zp.focus)}))})),Qs(Gk,((e,t)=>{fk.getField(e).each((t=>{ag.getCurrent(e).each(Zp.focus)}))}))])])})},Yk=Du({schema:[dr("dom")],name:"label"}),Xk=e=>Du({name:e+"-edge",overrides:t=>t.model.manager.edgeActions[e].fold((()=>({})),(e=>({events:Ys([ea(Yr(),((t,o,n)=>e(t,n)),[t]),ea(es(),((t,o,n)=>e(t,n)),[t]),ea(ts(),((t,o,n)=>{n.mouseIsDown.get()&&e(t,n)}),[t])])})))}),Jk=Xk("top-left"),Qk=Xk("top"),e_=Xk("top-right"),t_=Xk("right"),o_=Xk("bottom-right"),n_=Xk("bottom"),r_=Xk("bottom-left"),s_=Xk("left"),a_=Tu({name:"thumb",defaults:w({dom:{styles:{position:"absolute"}}}),overrides:e=>({events:Ys([oa(Yr(),e,"spectrum"),oa(Xr(),e,"spectrum"),oa(Jr(),e,"spectrum"),oa(es(),e,"spectrum"),oa(ts(),e,"spectrum"),oa(ns(),e,"spectrum")])})}),i_=e=>qg(e.event),l_=Tu({schema:[lr("mouseIsDown",(()=>Hr(!1)))],name:"spectrum",overrides:e=>{const t=e.model.manager,o=(o,n)=>t.getValueFromEvent(n).map((n=>t.setValueFrom(o,e,n)));return{behaviours:ql([Tp.config({mode:"special",onLeft:(o,n)=>t.onLeft(o,e,i_(n)),onRight:(o,n)=>t.onRight(o,e,i_(n)),onUp:(o,n)=>t.onUp(o,e,i_(n)),onDown:(o,n)=>t.onDown(o,e,i_(n))}),yk.config({}),Zp.config({})]),events:Ys([Qs(Yr(),o),Qs(Xr(),o),Qs(es(),o),Qs(ts(),((t,n)=>{e.mouseIsDown.get()&&o(t,n)}))])}}});var c_=[Yk,s_,t_,Qk,n_,Jk,e_,r_,o_,a_,l_];const d_=w("slider.change.value"),m_=e=>{const t=e.event.raw;if((e=>-1!==e.type.indexOf("touch"))(t)){const e=t;return void 0!==e.touches&&1===e.touches.length?D.some(e.touches[0]).map((e=>$t(e.clientX,e.clientY))):D.none()}{const e=t;return void 0!==e.clientX?D.some(e).map((e=>$t(e.clientX,e.clientY))):D.none()}},u_=e=>e.model.minX,g_=e=>e.model.minY,h_=e=>e.model.minX-1,p_=e=>e.model.minY-1,f_=e=>e.model.maxX,v_=e=>e.model.maxY,b_=e=>e.model.maxX+1,y_=e=>e.model.maxY+1,w_=(e,t,o)=>t(e)-o(e),x_=e=>w_(e,f_,u_),C_=e=>w_(e,v_,g_),S_=e=>x_(e)/2,k_=e=>C_(e)/2,__=(e,t)=>t?e.stepSize*e.speedMultiplier:e.stepSize,E_=e=>e.snapToGrid,T_=e=>e.snapStart,O_=e=>e.rounded,D_=(e,t)=>void 0!==e[t+"-edge"],A_=e=>D_(e,"left"),M_=e=>D_(e,"right"),N_=e=>D_(e,"top"),R_=e=>D_(e,"bottom"),B_=e=>e.model.value.get(),L_=(e,t)=>({x:e,y:t}),H_=(e,t)=>{Ws(e,d_(),{value:t})},I_=(e,t,o,n)=>eo?o:e===t?t-1:Math.max(t,e-n),P_=(e,t,o,n)=>e>o?e:eMath.max(t,Math.min(o,e)),z_=e=>{const{min:t,max:o,range:n,value:r,step:s,snap:a,snapStart:i,rounded:l,hasMinEdge:c,hasMaxEdge:d,minBound:m,maxBound:u,screenRange:g}=e,h=c?t-1:t,p=d?o+1:o;if(ru)return p;{const e=((e,t,o)=>Math.min(o,Math.max(e,t))-t)(r,m,u),c=F_(e/g*n+t,h,p);return a&&c>=t&&c<=o?((e,t,o,n,r)=>r.fold((()=>{const r=e-t,s=Math.round(r/n)*n;return F_(t+s,t-1,o+1)}),(t=>{const r=(e-t)%n,s=Math.round(r/n),a=Math.floor((e-t)/n),i=Math.floor((o-t)/n),l=t+Math.min(i,a+s)*n;return Math.max(t,l)})))(c,t,o,s,i):l?Math.round(c):c}},V_=e=>{const{min:t,max:o,range:n,value:r,hasMinEdge:s,hasMaxEdge:a,maxBound:i,maxOffset:l,centerMinEdge:c,centerMaxEdge:d}=e;return ro?a?i:d:(r-t)/n*l},Z_="top",U_="right",j_="bottom",W_="left",$_=e=>e.element.dom.getBoundingClientRect(),q_=(e,t)=>e[t],G_=e=>{const t=$_(e);return q_(t,W_)},K_=e=>{const t=$_(e);return q_(t,U_)},Y_=e=>{const t=$_(e);return q_(t,Z_)},X_=e=>{const t=$_(e);return q_(t,j_)},J_=e=>{const t=$_(e);return q_(t,"width")},Q_=e=>{const t=$_(e);return q_(t,"height")},eE=(e,t,o)=>(e+t)/2-o,tE=(e,t)=>{const o=$_(e),n=$_(t),r=q_(o,W_),s=q_(o,U_),a=q_(n,W_);return eE(r,s,a)},oE=(e,t)=>{const o=$_(e),n=$_(t),r=q_(o,Z_),s=q_(o,j_),a=q_(n,Z_);return eE(r,s,a)},nE=(e,t)=>{Ws(e,d_(),{value:t})},rE=(e,t,o)=>{const n={min:u_(t),max:f_(t),range:x_(t),value:o,step:__(t),snap:E_(t),snapStart:T_(t),rounded:O_(t),hasMinEdge:A_(t),hasMaxEdge:M_(t),minBound:G_(e),maxBound:K_(e),screenRange:J_(e)};return z_(n)},sE=e=>(t,o,n)=>((e,t,o,n)=>{const r=(e>0?P_:I_)(B_(o),u_(o),f_(o),__(o,n));return nE(t,r),D.some(r)})(e,t,o,n).map(O),aE=(e,t,o,n,r,s)=>{const a=((e,t,o,n,r)=>{const s=J_(e),a=n.bind((t=>D.some(tE(t,e)))).getOr(0),i=r.bind((t=>D.some(tE(t,e)))).getOr(s),l={min:u_(t),max:f_(t),range:x_(t),value:o,hasMinEdge:A_(t),hasMaxEdge:M_(t),minBound:G_(e),minOffset:0,maxBound:K_(e),maxOffset:s,centerMinEdge:a,centerMaxEdge:i};return V_(l)})(t,s,o,n,r);return G_(t)-G_(e)+a},iE=sE(-1),lE=sE(1),cE=D.none,dE=D.none,mE={"top-left":D.none(),top:D.none(),"top-right":D.none(),right:D.some(((e,t)=>{H_(e,b_(t))})),"bottom-right":D.none(),bottom:D.none(),"bottom-left":D.none(),left:D.some(((e,t)=>{H_(e,h_(t))}))};var uE=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=rE(e,t,o);return nE(e,n),n},setToMin:(e,t)=>{const o=u_(t);nE(e,o)},setToMax:(e,t)=>{const o=f_(t);nE(e,o)},findValueOfOffset:rE,getValueFromEvent:e=>m_(e).map((e=>e.left)),findPositionOfValue:aE,setPositionFromValue:(e,t,o,n)=>{const r=B_(o),s=aE(e,n.getSpectrum(e),r,n.getLeftEdge(e),n.getRightEdge(e),o),a=Xt(t.element)/2;Mt(t.element,"left",s-a+"px")},onLeft:iE,onRight:lE,onUp:cE,onDown:dE,edgeActions:mE});const gE=(e,t)=>{Ws(e,d_(),{value:t})},hE=(e,t,o)=>{const n={min:g_(t),max:v_(t),range:C_(t),value:o,step:__(t),snap:E_(t),snapStart:T_(t),rounded:O_(t),hasMinEdge:N_(t),hasMaxEdge:R_(t),minBound:Y_(e),maxBound:X_(e),screenRange:Q_(e)};return z_(n)},pE=e=>(t,o,n)=>((e,t,o,n)=>{const r=(e>0?P_:I_)(B_(o),g_(o),v_(o),__(o,n));return gE(t,r),D.some(r)})(e,t,o,n).map(O),fE=(e,t,o,n,r,s)=>{const a=((e,t,o,n,r)=>{const s=Q_(e),a=n.bind((t=>D.some(oE(t,e)))).getOr(0),i=r.bind((t=>D.some(oE(t,e)))).getOr(s),l={min:g_(t),max:v_(t),range:C_(t),value:o,hasMinEdge:N_(t),hasMaxEdge:R_(t),minBound:Y_(e),minOffset:0,maxBound:X_(e),maxOffset:s,centerMinEdge:a,centerMaxEdge:i};return V_(l)})(t,s,o,n,r);return Y_(t)-Y_(e)+a},vE=D.none,bE=D.none,yE=pE(-1),wE=pE(1),xE={"top-left":D.none(),top:D.some(((e,t)=>{H_(e,p_(t))})),"top-right":D.none(),right:D.none(),"bottom-right":D.none(),bottom:D.some(((e,t)=>{H_(e,y_(t))})),"bottom-left":D.none(),left:D.none()};var CE=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=hE(e,t,o);return gE(e,n),n},setToMin:(e,t)=>{const o=g_(t);gE(e,o)},setToMax:(e,t)=>{const o=v_(t);gE(e,o)},findValueOfOffset:hE,getValueFromEvent:e=>m_(e).map((e=>e.top)),findPositionOfValue:fE,setPositionFromValue:(e,t,o,n)=>{const r=B_(o),s=fE(e,n.getSpectrum(e),r,n.getTopEdge(e),n.getBottomEdge(e),o),a=Ut(t.element)/2;Mt(t.element,"top",s-a+"px")},onLeft:vE,onRight:bE,onUp:yE,onDown:wE,edgeActions:xE});const SE=(e,t)=>{Ws(e,d_(),{value:t})},kE=(e,t)=>({x:e,y:t}),_E=(e,t)=>(o,n,r)=>((e,t,o,n,r)=>{const s=e>0?P_:I_,a=t?B_(n).x:s(B_(n).x,u_(n),f_(n),__(n,r)),i=t?s(B_(n).y,g_(n),v_(n),__(n,r)):B_(n).y;return SE(o,kE(a,i)),D.some(a)})(e,t,o,n,r).map(O),EE=_E(-1,!1),TE=_E(1,!1),OE=_E(-1,!0),DE=_E(1,!0),AE={"top-left":D.some(((e,t)=>{H_(e,L_(h_(t),p_(t)))})),top:D.some(((e,t)=>{H_(e,L_(S_(t),p_(t)))})),"top-right":D.some(((e,t)=>{H_(e,L_(b_(t),p_(t)))})),right:D.some(((e,t)=>{H_(e,L_(b_(t),k_(t)))})),"bottom-right":D.some(((e,t)=>{H_(e,L_(b_(t),y_(t)))})),bottom:D.some(((e,t)=>{H_(e,L_(S_(t),y_(t)))})),"bottom-left":D.some(((e,t)=>{H_(e,L_(h_(t),y_(t)))})),left:D.some(((e,t)=>{H_(e,L_(h_(t),k_(t)))}))};var ME=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=rE(e,t,o.left),r=hE(e,t,o.top),s=kE(n,r);return SE(e,s),s},setToMin:(e,t)=>{const o=u_(t),n=g_(t);SE(e,kE(o,n))},setToMax:(e,t)=>{const o=f_(t),n=v_(t);SE(e,kE(o,n))},getValueFromEvent:e=>m_(e),setPositionFromValue:(e,t,o,n)=>{const r=B_(o),s=aE(e,n.getSpectrum(e),r.x,n.getLeftEdge(e),n.getRightEdge(e),o),a=fE(e,n.getSpectrum(e),r.y,n.getTopEdge(e),n.getBottomEdge(e),o),i=Xt(t.element)/2,l=Ut(t.element)/2;Mt(t.element,"left",s-i+"px"),Mt(t.element,"top",a-l+"px")},onLeft:EE,onRight:TE,onUp:OE,onDown:DE,edgeActions:AE});const NE=og({name:"Slider",configFields:[Tr("stepSize",1),Tr("speedMultiplier",10),Tr("onChange",v),Tr("onChoose",v),Tr("onInit",v),Tr("onDragStart",v),Tr("onDragEnd",v),Tr("snapToGrid",!1),Tr("rounded",!0),yr("snapStart"),mr("model",sr("mode",{x:[Tr("minX",0),Tr("maxX",100),lr("value",(e=>Hr(e.mode.minX))),dr("getInitialValue"),rl("manager",uE)],y:[Tr("minY",0),Tr("maxY",100),lr("value",(e=>Hr(e.mode.minY))),dr("getInitialValue"),rl("manager",CE)],xy:[Tr("minX",0),Tr("maxX",100),Tr("minY",0),Tr("maxY",100),lr("value",(e=>Hr({x:e.mode.minX,y:e.mode.minY}))),dr("getInitialValue"),rl("manager",ME)]})),Jm("sliderBehaviours",[Tp,Xm]),lr("mouseIsDown",(()=>Hr(!1)))],partFields:c_,factory:(e,t,o,n)=>{const r=t=>Zu(t,e,"thumb"),s=t=>Zu(t,e,"spectrum"),a=t=>Vu(t,e,"left-edge"),i=t=>Vu(t,e,"right-edge"),l=t=>Vu(t,e,"top-edge"),c=t=>Vu(t,e,"bottom-edge"),d=e.model,m=d.manager,u=(t,o)=>{m.setPositionFromValue(t,o,e,{getLeftEdge:a,getRightEdge:i,getTopEdge:l,getBottomEdge:c,getSpectrum:s})},g=(e,t)=>{d.value.set(t);const o=r(e);u(e,o)},h=t=>{const o=e.mouseIsDown.get();e.mouseIsDown.set(!1),o&&Vu(t,e,"thumb").each((o=>{const n=d.value.get();e.onChoose(t,o,n)}))},p=(t,o)=>{o.stop(),e.mouseIsDown.set(!0),e.onDragStart(t,r(t))},f=(t,o)=>{o.stop(),e.onDragEnd(t,r(t)),h(t)},v=t=>{Vu(t,e,"spectrum").map(Tp.focusIn)};return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.sliderBehaviours,[Tp.config({mode:"special",focusIn:v}),Xm.config({store:{mode:"manual",getValue:e=>d.value.get(),setValue:g}}),Ql.config({channels:{[Bm()]:{onReceive:h}}})]),events:Ys([Qs(d_(),((t,o)=>{((t,o)=>{g(t,o);const n=r(t);e.onChange(t,n,o),D.some(!0)})(t,o.event.value)})),ia(((t,o)=>{const n=d.getInitialValue();d.value.set(n);const a=r(t);u(t,a);const i=s(t);e.onInit(t,a,i,d.value.get())})),Qs(Yr(),p),Qs(Jr(),f),Qs(es(),((e,t)=>{v(e),p(e,t)})),Qs(ns(),f)]),apis:{resetToMin:t=>{m.setToMin(t,e)},resetToMax:t=>{m.setToMax(t,e)},setValue:g,refresh:u},domModification:{styles:{position:"relative"}}}},apis:{setValue:(e,t,o)=>{e.setValue(t,o)},resetToMin:(e,t)=>{e.resetToMin(t)},resetToMax:(e,t)=>{e.resetToMax(t)},refresh:(e,t)=>{e.refresh(t)}}}),RE=ya("rgb-hex-update"),BE=ya("slider-update"),LE=ya("palette-update"),HE="form",IE=[Jm("formBehaviours",[Xm])],PE=e=>"",FE=(e,t)=>({uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.formBehaviours,[Xm.config({store:{mode:"manual",getValue:t=>{const o=ju(t,e);return ce(o,((e,t)=>e().bind((e=>{const o=ag.getCurrent(e);return n=o,r=new Error(`Cannot find a current component to extract the value from for form part '${t}': `+pa(e.element)),n.fold((()=>on.error(r)),on.value);var n,r})).map(Xm.getValue)))},setValue:(t,o)=>{le(o,((o,n)=>{Vu(t,e,n).each((e=>{ag.getCurrent(e).each((e=>{Xm.setValue(e,o)}))}))}))}}})]),apis:{getField:(t,o)=>Vu(t,e,o).bind(ag.getCurrent)}}),zE={getField:La(((e,t,o)=>e.getField(t,o))),sketch:e=>{const t=(()=>{const e=[];return{field:(t,o)=>(e.push(t),Hu(HE,PE(t),o)),record:w(e)}})(),o=e(t),n=t.record(),r=F(n,(e=>Tu({name:e,pname:PE(e)})));return Xu(HE,IE,r,FE,o)}},VE=ya("valid-input"),ZE=ya("invalid-input"),UE=ya("validating-input"),jE="colorcustom.rgb.",WE=(e,t,o,n)=>{const r=(o,n)=>jk.config({invalidClass:t("invalid"),notify:{onValidate:e=>{Ws(e,UE,{type:o})},onValid:e=>{Ws(e,VE,{type:o,value:Xm.getValue(e)})},onInvalid:e=>{Ws(e,ZE,{type:o,value:Xm.getValue(e)})}},validator:{validate:t=>{const o=Xm.getValue(t),r=n(o)?on.value(!0):on.error(e("aria.input.invalid"));return xS(r)},validateOnLoad:!1}}),s=(o,n,s,a,i)=>{const l=e(jE+"range"),c=fk.parts.label({dom:{tag:"label",attributes:{"aria-label":a}},components:[Ci(s)]}),d=fk.parts.field({data:i,factory:_y,inputAttributes:{type:"text",..."hex"===n?{"aria-live":"polite"}:{}},inputClasses:[t("textfield")],inputBehaviours:ql([r(n,o),yk.config({})]),onSetValue:e=>{if(jk.isInvalid(e)){jk.run(e).get(v)}}}),m=[c,d],u="hex"!==n?[fk.parts["aria-descriptor"]({text:l})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:m.concat(u)}},a=(e,t)=>{const o=t.red,n=t.green,r=t.blue;Xm.setValue(e,{red:o,green:n,blue:r})},i=Bf({dom:{tag:"div",classes:[t("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),l=(e,t)=>{i.getOpt(e).each((e=>{Mt(e.element,"background-color","#"+t.value)}))},c=tg({factory:()=>{const r={red:Hr(D.some(255)),green:Hr(D.some(255)),blue:Hr(D.some(255)),hex:Hr(D.some("ffffff"))},c=e=>r[e].get(),d=(e,t)=>{r[e].set(t)},m=e=>{const t=e.red,o=e.green,n=e.blue;d("red",D.some(t)),d("green",D.some(o)),d("blue",D.some(n))},u=(e,t)=>{const o=t.event;"hex"!==o.type?d(o.type,D.none()):n(e)},g=(e,t,o)=>{const n=parseInt(o,10);d(t,D.some(n)),c("red").bind((e=>c("green").bind((t=>c("blue").map((o=>Qx(e,t,o,1))))))).each((t=>{const o=((e,t)=>{const o=qx(t);return zE.getField(e,"hex").each((t=>{Zp.isFocused(t)||Xm.setValue(e,{hex:o.value})})),o})(e,t);Ws(e,RE,{hex:o}),l(e,o)}))},h=(e,t)=>{const n=t.event;(e=>"hex"===e.type)(n)?((e,t)=>{o(e);const n=zx(t);d("hex",D.some(n.value));const r=oC(n);a(e,r),m(r),Ws(e,RE,{hex:n}),l(e,n)})(e,n.value):g(e,n.type,n.value)},p=t=>({label:e(jE+t+".label"),description:e(jE+t+".description")}),f=p("red"),v=p("green"),b=p("blue"),y=p("hex");return xn(zE.sketch((o=>({dom:{tag:"form",classes:[t("rgb-form")],attributes:{"aria-label":e("aria.color.picker")}},components:[o.field("red",fk.sketch(s(eC,"red",f.label,f.description,255))),o.field("green",fk.sketch(s(eC,"green",v.label,v.description,255))),o.field("blue",fk.sketch(s(eC,"blue",b.label,b.description,255))),o.field("hex",fk.sketch(s(Ux,"hex",y.label,y.description,"ffffff"))),i.asSpec()],formBehaviours:ql([jk.config({invalidClass:t("form-invalid")}),Ip("rgb-form-events",[Qs(VE,h),Qs(ZE,u),Qs(UE,u)])])}))),{apis:{updateHex:(e,t)=>{Xm.setValue(e,{hex:t.value}),((e,t)=>{const o=oC(t);a(e,o),m(o)})(e,t),l(e,t)}}})},name:"RgbForm",configFields:[],apis:{updateHex:(e,t,o)=>{e.updateHex(t,o)}},extraApis:{}});return c},$E=(e,t)=>{const o=NE.parts.spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[t("sv-palette-spectrum")]}}),n=NE.parts.thumb({dom:{tag:"div",attributes:{role:"presentation"},classes:[t("sv-palette-thumb")],innerHtml:``}}),r=(e,t)=>{const{width:o,height:n}=e,r=e.getContext("2d");if(null===r)return;r.fillStyle=t,r.fillRect(0,0,o,n);const s=r.createLinearGradient(0,0,o,0);s.addColorStop(0,"rgba(255,255,255,1)"),s.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=s,r.fillRect(0,0,o,n);const a=r.createLinearGradient(0,0,0,n);a.addColorStop(0,"rgba(0,0,0,0)"),a.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=a,r.fillRect(0,0,o,n)},s=tg({factory:s=>{const a=w({x:0,y:0}),i=ql([ag.config({find:D.some}),Zp.config({})]);return NE.sketch({dom:{tag:"div",attributes:{role:"slider","aria-valuetext":e(["Saturation {0}%, Brightness {1}%",0,0])},classes:[t("sv-palette")]},model:{mode:"xy",getInitialValue:a},rounded:!1,components:[o,n],onChange:(t,o,n)=>{p(n)||St(t.element,"aria-valuetext",e(["Saturation {0}%, Brightness {1}%",Math.floor(n.x),Math.floor(100-n.y)])),Ws(t,LE,{value:n})},onInit:(e,t,o,n)=>{r(o.element.dom,sC(aC))},sliderBehaviours:i})},name:"SaturationBrightnessPalette",configFields:[],apis:{setHue:(e,t,o)=>{((e,t)=>{const o=e.components()[0].element.dom,n=wC(t,100,100),s=tC(n);r(o,sC(s))})(t,o)},setThumb:(t,o,n)=>{((t,o)=>{const n=xC(oC(o));NE.setValue(t,{x:n.saturation,y:100-n.value}),St(t.element,"aria-valuetext",e(["Saturation {0}%, Brightness {1}%",n.saturation,n.value]))})(o,n)}},extraApis:{}});return s},qE=(e,t)=>{const o=tg({name:"ColourPicker",configFields:[dr("dom"),Tr("onValidHex",v),Tr("onInvalidHex",v)],factory:o=>{const n=WE(e,t,o.onValidHex,o.onInvalidHex),r=$E(e,t),s={paletteRgba:Hr(aC),paletteHue:Hr(0)},a=Bf(((e,t)=>{const o=NE.parts.spectrum({dom:{tag:"div",classes:[t("hue-slider-spectrum")],attributes:{role:"presentation"}}}),n=NE.parts.thumb({dom:{tag:"div",classes:[t("hue-slider-thumb")],attributes:{role:"presentation"}}});return NE.sketch({dom:{tag:"div",classes:[t("hue-slider")],attributes:{role:"slider","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":120}},rounded:!1,model:{mode:"y",getInitialValue:w(0)},components:[o,n],sliderBehaviours:ql([Zp.config({})]),onChange:(e,t,o)=>{St(e.element,"aria-valuenow",Math.floor(360-3.6*o)),Ws(e,BE,{value:o})}})})(0,t)),i=Bf(r.sketch({})),l=Bf(n.sketch({})),c=(e,t,o)=>{i.getOpt(e).each((e=>{r.setHue(e,o)}))},d=(e,t)=>{l.getOpt(e).each((e=>{n.updateHex(e,t)}))},m=(e,t,o)=>{a.getOpt(e).each((e=>{NE.setValue(e,(e=>100-e/360*100)(o))}))},u=(e,t)=>{i.getOpt(e).each((e=>{r.setThumb(e,t)}))},g=(e,t,o,n)=>{((e,t)=>{const o=oC(e);s.paletteRgba.set(o),s.paletteHue.set(t)})(t,o),z(n,(n=>{n(e,t,o)}))};return{uid:o.uid,dom:o.dom,components:[i.asSpec(),a.asSpec(),l.asSpec()],behaviours:ql([Ip("colour-picker-events",[Qs(RE,(()=>{const e=[c,m,u];return(t,o)=>{const n=o.event.hex,r=(e=>xC(oC(e)))(n);g(t,n,r.hue,e)}})()),Qs(LE,(()=>{const e=[d];return(t,o)=>{const n=o.event.value,r=s.paletteHue.get(),a=wC(r,n.x,100-n.y),i=CC(a);g(t,i,r,e)}})()),Qs(BE,(()=>{const e=[c,d];return(t,o)=>{const n=(e=>(100-e)/100*360)(o.event.value),r=s.paletteRgba.get(),a=xC(r),i=wC(n,a.saturation,a.value),l=CC(i);g(t,l,n,e)}})())]),ag.config({find:e=>l.getOpt(e)}),Tp.config({mode:"acyclic"})])}}});return o},GE=()=>ag.config({find:D.some}),KE=e=>ag.config({find:e.getOpt}),YE=e=>ag.config({find:t=>it(t.element,e).bind((e=>t.getSystem().getByDom(e).toOptional()))}),XE=Pn([Tr("preprocess",x),Tr("postprocess",x)]),JE=(e,t)=>{const o=nr("RepresentingConfigs.memento processors",XE,t);return Xm.config({store:{mode:"manual",getValue:t=>{const n=e.get(t),r=Xm.getValue(n);return o.postprocess(r)},setValue:(t,n)=>{const r=o.preprocess(n),s=e.get(t);Xm.setValue(s,r)}}})},QE=(e,t,o)=>Xm.config({store:{mode:"manual",...e.map((e=>({initialValue:e}))).getOr({}),getValue:t,setValue:o}}),eT=(e,t,o)=>QE(e,(e=>t(e.element)),((e,t)=>o(e.element,t))),tT=e=>Xm.config({store:{mode:"memory",initialValue:e}}),oT={"colorcustom.rgb.red.label":"R","colorcustom.rgb.red.description":"Red component","colorcustom.rgb.green.label":"G","colorcustom.rgb.green.description":"Green component","colorcustom.rgb.blue.label":"B","colorcustom.rgb.blue.description":"Blue component","colorcustom.rgb.hex.label":"#","colorcustom.rgb.hex.description":"Hex color code","colorcustom.rgb.range":"Range 0 to 255","aria.color.picker":"Color Picker","aria.input.invalid":"Invalid input"},nT=(e,t,o)=>{const n=e=>"tox-"+e,r=qE((e=>t=>s(t)?e.translate(oT[t]):e.translate(t))(t),n),a=Bf(r.sketch({dom:{tag:"div",classes:[n("color-picker-container")],attributes:{role:"presentation"}},onValidHex:e=>{Ws(e,Ok,{name:"hex-valid",value:!0})},onInvalidHex:e=>{Ws(e,Ok,{name:"hex-valid",value:!1})}}));return{dom:{tag:"div"},components:[a.asSpec()],behaviours:ql([QE(o,(e=>{const t=a.get(e);return ag.getCurrent(t).bind((e=>Xm.getValue(e).hex)).map((e=>"#"+Ee(e,"#"))).getOr("")}),((e,t)=>{const o=D.from(/^#([a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?)/.exec(t)).bind((e=>te(e,1))),n=a.get(e);ag.getCurrent(n).fold((()=>{console.log("Can not find form")}),(e=>{Xm.setValue(e,{hex:o.getOr("")}),zE.getField(e,"hex").each((e=>{js(e,cs())}))}))})),GE()])}};var rT=tinymce.util.Tools.resolve("tinymce.Resource");var sT=tinymce.util.Tools.resolve("tinymce.util.Tools");const aT=(e,t,o)=>{const n=(e,t)=>{t.stop()},r=e=>(t,o)=>{z(e,(e=>{e(t,o)}))},s=(e,t)=>{var o;if(!wg.isDisabled(e)){const n=t.event.raw;i(e,null===(o=n.dataTransfer)||void 0===o?void 0:o.files)}},a=(e,t)=>{const o=t.event.raw.target;i(e,o.files)},i=(o,n)=>{n&&(Xm.setValue(o,((e,t)=>{const o=sT.explode(t.getOption("images_file_types"));return Z(re(e),(e=>H(o,(t=>De(e.name.toLowerCase(),`.${t.toLowerCase()}`)))))})(n,t)),Ws(o,_k,{name:e.name}))},l=Bf({dom:{tag:"input",attributes:{type:"file",accept:"image/*"},styles:{display:"none"}},behaviours:ql([Ip("input-file-events",[ra(ms()),ra(ks())])])}),c=e.label.map((e=>kk(e,t))),d=fk.parts.field({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-dropzone-container"]},behaviours:ql([tT(o.getOr([])),GE(),wg.config({}),Yp.config({toggleClass:"dragenter",toggleOnExecute:!1}),Ip("dropzone-events",[Qs("dragenter",r([n,Yp.toggle])),Qs("dragleave",r([n,Yp.toggle])),Qs("dragover",n),Qs("drop",r([n,s])),Qs(ds(),a)])]),components:[{dom:{tag:"div",classes:["tox-dropzone"],styles:{}},components:[{dom:{tag:"p"},components:[Ci(t.translate("Drop an image here"))]},Nf.sketch({dom:{tag:"button",styles:{position:"relative"},classes:["tox-button","tox-button--secondary"]},components:[Ci(t.translate("Browse for an image")),l.asSpec()],action:e=>{l.get(e).element.dom.click()},buttonBehaviours:ql([yk.config({}),px(t.isDisabled),gx()])})]}]})}});return xk(c,d,["tox-form__group--stretched"],[])},iT=(e,t)=>{let o=null;const n=()=>{c(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},lT=ya("alloy-fake-before-tabstop"),cT=ya("alloy-fake-after-tabstop"),dT=e=>({dom:{tag:"div",styles:{width:"1px",height:"1px",outline:"none"},attributes:{tabindex:"0"},classes:e},behaviours:ql([Zp.config({ignore:!0}),yk.config({})])}),mT=(e,t)=>({dom:{tag:"div",classes:["tox-navobj",...e.getOr([])]},components:[dT([lT]),t,dT([cT])],behaviours:ql([YE(1)])}),uT=(e,t)=>{Ws(e,is(),{raw:{which:9,shiftKey:t}})},gT=(e,t)=>{const o=t.element;si(o,lT)?uT(e,!0):si(o,cT)&&uT(e,!1)},hT=e=>QS(e,["."+lT,"."+cT].join(","),T),pT=ya("update-dialog"),fT=ya("update-title"),vT=ya("update-body"),bT=ya("update-footer"),yT=ya("body-send-message"),wT=ya("dialog-focus-shifted"),xT=Do().browser,CT=xT.isSafari(),ST=xT.isFirefox(),kT=CT||ST,_T=xT.isChromium(),ET=({scrollTop:e,scrollHeight:t,clientHeight:o})=>Math.ceil(e)+o>=t,TT=(e,t)=>e.scrollTo(0,"bottom"===t?99999999:t),OT=(e,t,o)=>{const n=e.dom;D.from(n.contentDocument).fold(o,(e=>{let o=0;const r=((e,t)=>{const o=e.body;return D.from(!/^1))?o:e.documentElement)})(e,t).map((e=>(o=e.scrollTop,e))).forall(ET),s=()=>{const e=n.contentWindow;g(e)&&(r?TT(e,"bottom"):!r&&kT&&0!==o&&TT(e,o))};CT&&n.addEventListener("load",s,{once:!0}),e.open(),e.write(t),e.close(),CT||s()}))},DT=ke(kT,CT?500:200).map((e=>((e,t)=>{let o=null,n=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null,n=null)},throttle:(...r)=>{n=r,c(o)&&(o=setTimeout((()=>{const t=n;o=null,n=null,e.apply(null,t)}),t))}}})(OT,e))),AT=(e,t,o)=>{const n="tox-dialog__iframe",r=e.transparent?[]:[`${n}--opaque`],s=e.border?["tox-navobj-bordered"]:[],a={...e.label.map((e=>({title:e}))).getOr({}),...o.map((e=>({srcdoc:e}))).getOr({}),...e.sandboxed?{sandbox:"allow-scripts allow-same-origin"}:{}},i=((e,t)=>{const o=Hr(e.getOr(""));return{getValue:e=>o.get(),setValue:(e,n)=>{if(o.get()!==n){const o=e.element,r=()=>St(o,"srcdoc",n);t?DT.fold(w(OT),(e=>e.throttle))(o,n,r):r()}o.set(n)}}})(o,e.streamContent),l=e.label.map((e=>kk(e,t))),c=fk.parts.field({factory:{sketch:e=>mT(D.from(s),{uid:e.uid,dom:{tag:"iframe",attributes:a,classes:[n,...r]},behaviours:ql([yk.config({}),Zp.config({}),QE(o,i.getValue,i.setValue),Ql.config({channels:{[wT]:{onReceive:(e,t)=>{t.newFocus.each((t=>{rt(e.element).each((o=>{(Xe(e.element,t)?ti:ni)(o,"tox-navobj-bordered-focus")}))}))}}}})])})}});return xk(l,c,["tox-form__group--stretched"],[])},MT=(e,t)=>{const o=Hr(t.getOr({url:""})),n=Bf({dom:{tag:"img",classes:["tox-imagepreview__image"],attributes:t.map((e=>({src:e.url}))).getOr({})}}),r=Bf({dom:{tag:"div",classes:["tox-imagepreview__container"],attributes:{role:"presentation"}},components:[n.asSpec()]}),s={};e.height.each((e=>s.height=e));const a=t.map((e=>({url:e.url,zoom:D.from(e.zoom),cachedWidth:D.from(e.cachedWidth),cachedHeight:D.from(e.cachedHeight)})));return{dom:{tag:"div",classes:["tox-imagepreview"],styles:s,attributes:{role:"presentation"}},components:[r.asSpec()],behaviours:ql([GE(),QE(a,(()=>o.get()),((e,t)=>{const s={url:t.url};t.zoom.each((e=>s.zoom=e)),t.cachedWidth.each((e=>s.cachedWidth=e)),t.cachedHeight.each((e=>s.cachedHeight=e)),o.set(s);const a=()=>{const{cachedWidth:t,cachedHeight:o,zoom:n}=s;if(!m(t)&&!m(o)){if(m(n)){const n=((e,t,o)=>{const n=Xt(e),r=Ut(e);return Math.min(n/t,r/o,1)})(e.element,t,o);s.zoom=n}const a=((e,t,o,n,r)=>{const s=o*r,a=n*r,i=Math.max(0,e/2-s/2),l=Math.max(0,t/2-a/2);return{left:i.toString()+"px",top:l.toString()+"px",width:s.toString()+"px",height:a.toString()+"px"}})(Xt(e.element),Ut(e.element),t,o,s.zoom);r.getOpt(e).each((e=>{Nt(e.element,a)}))}};n.getOpt(e).each((o=>{const n=o.element;t.url!==_t(n,"src")&&(St(n,"src",t.url),ni(e.element,"tox-imagepreview__loaded")),a(),(e=>new Promise(((t,o)=>{const n=()=>{s(),t(e)},r=[Ec(e,"load",n),Ec(e,"error",(()=>{s(),o("Unable to load data from image: "+e.dom.src)}))],s=()=>z(r,(e=>e.unbind()));e.dom.complete&&n()})))(n).then((t=>{e.getSystem().isConnected()&&(ti(e.element,"tox-imagepreview__loaded"),s.cachedWidth=t.dom.naturalWidth,s.cachedHeight=t.dom.naturalHeight,a())}))}))}))])}},NT=ya("toolbar.button.execute"),RT=ya("common-button-display-events"),BT={[Cs()]:["disabling","alloy.base.behaviour","toggling","toolbar-button-events"],[Rs()]:["toolbar-button-events",RT],[es()]:["focusing","alloy.base.behaviour",RT]},LT=e=>Mt(e.element,"width",Bt(e.element,"width")),HT=(e,t,o)=>zv(e,{tag:"span",classes:["tox-icon","tox-tbtn__icon-wrap"],behaviours:o},t),IT=(e,t)=>HT(e,t,[]),PT=(e,t)=>HT(e,t,[Hp.config({})]),FT=(e,t,o)=>({dom:{tag:"span",classes:[`${t}__select-label`]},components:[Ci(o.translate(e))],behaviours:ql([Hp.config({})])}),zT=ya("update-menu-text"),VT=ya("update-menu-icon"),ZT=(e,t,o)=>{const n=Hr(v),r=e.text.map((e=>Bf(FT(e,t,o.providers)))),s=e.icon.map((e=>Bf(PT(e,o.providers.icons)))),a=(e,t)=>{const o=Xm.getValue(e);return Zp.focus(o),Ws(o,"keydown",{raw:t.event.raw}),HS.close(o),D.some(!0)},i=e.role.fold((()=>({})),(e=>({role:e}))),l=e.tooltip.fold((()=>({})),(e=>{const t=o.providers.translate(e);return{title:t,"aria-label":t}})),c=zv("chevron-down",{tag:"div",classes:[`${t}__select-chevron`]},o.providers.icons),d=ya("common-button-display-events"),m=Bf(HS.sketch({...e.uid?{uid:e.uid}:{},...i,dom:{tag:"button",classes:[t,`${t}--select`].concat(F(e.classes,(e=>`${t}--${e}`))),attributes:{...l}},components:Sx([s.map((e=>e.asSpec())),r.map((e=>e.asSpec())),D.some(c)]),matchWidth:!0,useMinWidth:!0,onOpen:(t,o,n)=>{e.searchable&&(e=>{Ay(e).each((e=>Zp.focus(e)))})(n)},dropdownBehaviours:ql([...e.dropdownBehaviours,px((()=>e.disabled||o.providers.isDisabled())),gx(),Wk.config({}),Hp.config({}),Ip("dropdown-events",[yx(e,n),wx(e,n)]),Ip(d,[ia(((e,t)=>LT(e)))]),Ip("menubutton-update-display-text",[Qs(zT,((e,t)=>{r.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[Ci(o.providers.translate(t.event.text))])}))})),Qs(VT,((e,t)=>{s.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[PT(t.event.icon,o.providers.icons)])}))}))])]),eventOrder:xn(BT,{mousedown:["focusing","alloy.base.behaviour","item-type-events","normal-dropdown-events"],[Rs()]:["toolbar-button-events","dropdown-events",d]}),sandboxBehaviours:ql([Tp.config({mode:"special",onLeft:a,onRight:a}),Ip("dropdown-sandbox-events",[Qs(Ey,((e,t)=>{IS(e),t.stop()})),Qs(Ty,((e,t)=>{((e,t)=>{PS(e).each((o=>{((e,t,o,n)=>{const r={...n,target:t};e.getSystem().triggerEvent(o,t,r)})(e,o.element,t.event.eventType,t.event.interactionEvent)}))})(e,t),t.stop()}))])]),lazySink:o.getSink,toggleClass:`${t}--active`,parts:{menu:{...wy(0,e.columns,e.presets),fakeFocus:e.searchable,onHighlightItem:FS,onCollapseMenu:(e,t,o)=>{Mg.getHighlighted(o).each((t=>{FS(e,o,t)}))},onDehighlightItem:zS}},getAnchorOverrides:()=>({maxHeightFunction:(e,t)=>{Pc()(e,t-10)}}),fetch:t=>wS(S(e.fetch,t))}));return m.asSpec()},UT=e=>"separator"===e.type,jT={type:"separator"},WT=(e,t)=>{const o=j(e,((e,o)=>(e=>s(e))(o)?""===o?e:"|"===o?e.length>0&&!UT(e[e.length-1])?e.concat([jT]):e:be(t,o.toLowerCase())?e.concat([t[o.toLowerCase()]]):e:e.concat([o])),[]);return o.length>0&&UT(o[o.length-1])&&o.pop(),o},$T=(e,t)=>{const o=WT(s(e)?e.split(" "):e,t);return U(o,((e,o)=>{if((e=>be(e,"getSubmenuItems"))(o)){const n=(e=>{const t=ve(e,"value").getOrThunk((()=>ya("generated-menu-item")));return xn({value:t},e)})(o),r=((e,t)=>{const o=e.getSubmenuItems(),n=$T(o,t);return{item:e,menus:xn(n.menus,{[e.value]:n.items}),expansions:xn(n.expansions,{[e.value]:e.value})}})(n,t);return{menus:xn(e.menus,r.menus),items:[r.item,...e.items],expansions:xn(e.expansions,r.expansions)}}return{...e,items:[o,...e.items]}}),{menus:{},expansions:{},items:[]})},qT=(e,t,o,n)=>{const r=ya("primary-menu"),s=$T(e,o.shared.providers.menuItems());if(0===s.items.length)return D.none();const a=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-field",placeholder:e.placeholder}))))(n),i=WS(r,s.items,t,o,n.isHorizontalMenu,a),l=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-results"}))))(n),c=ce(s.menus,((e,n)=>WS(n,e,t,o,!1,l))),d=xn(c,Fr(r,i));return D.from(Df.tieredData(r,d,s.expansions))},GT=e=>!be(e,"items"),KT="data-value",YT=(e,t,o,n)=>F(o,(o=>GT(o)?{type:"togglemenuitem",text:o.text,value:o.value,active:o.value===n,onAction:()=>{Xm.setValue(e,o.value),Ws(e,_k,{name:t}),Zp.focus(e)}}:{type:"nestedmenuitem",text:o.text,getSubmenuItems:()=>YT(e,t,o.items,n)})),XT=(e,t)=>se(e,(e=>GT(e)?ke(e.value===t,e):XT(e.items,t))),JT=tg({name:"HtmlSelect",configFields:[dr("options"),Jm("selectBehaviours",[Zp,Xm]),Tr("selectClasses",[]),Tr("selectAttributes",{}),yr("data")],factory:(e,t)=>{const o=F(e.options,(e=>({dom:{tag:"option",value:e.value,innerHtml:e.text}}))),n=e.data.map((e=>Fr("initialValue",e))).getOr({});return{uid:e.uid,dom:{tag:"select",classes:e.selectClasses,attributes:e.selectAttributes},components:o,behaviours:eu(e.selectBehaviours,[Zp.config({}),Xm.config({store:{mode:"manual",getValue:e=>ci(e.element),setValue:(t,o)=>{const n=oe(e.options);W(e.options,(e=>e.value===o)).isSome()?di(t.element,o):-1===t.element.dom.selectedIndex&&""===o&&n.each((e=>di(t.element,e.value)))},...n}})])}}}),QT=w([Tr("field1Name","field1"),Tr("field2Name","field2"),ol("onLockedChange"),Ji(["lockClass"]),Tr("locked",!1),tu("coupledFieldBehaviours",[ag,Xm])]),eO=(e,t)=>Tu({factory:fk,name:e,overrides:e=>({fieldBehaviours:ql([Ip("coupled-input-behaviour",[Qs(cs(),(o=>{((e,t,o)=>Vu(e,t,o).bind(ag.getCurrent))(o,e,t).each((t=>{Vu(o,e,"lock").each((n=>{Yp.isOn(n)&&e.onLockedChange(o,t,n)}))}))}))])])})}),tO=w([eO("field1","field2"),eO("field2","field1"),Tu({factory:Nf,schema:[dr("dom")],name:"lock",overrides:e=>({buttonBehaviours:ql([Yp.config({selected:e.locked,toggleClass:e.markers.lockClass,aria:{mode:"pressed"}})])})})]),oO=og({name:"FormCoupledInputs",configFields:QT(),partFields:tO(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:ou(e.coupledFieldBehaviours,[ag.config({find:D.some}),Xm.config({store:{mode:"manual",getValue:t=>{const o=$u(t,e,["field1","field2"]);return{[e.field1Name]:Xm.getValue(o.field1()),[e.field2Name]:Xm.getValue(o.field2())}},setValue:(t,o)=>{const n=$u(t,e,["field1","field2"]);ye(o,e.field1Name)&&Xm.setValue(n.field1(),o[e.field1Name]),ye(o,e.field2Name)&&Xm.setValue(n.field2(),o[e.field2Name])}}})]),apis:{getField1:t=>Vu(t,e,"field1"),getField2:t=>Vu(t,e,"field2"),getLock:t=>Vu(t,e,"lock")}}),apis:{getField1:(e,t)=>e.getField1(t),getField2:(e,t)=>e.getField2(t),getLock:(e,t)=>e.getLock(t)}}),nO=e=>{const t=/^\s*(\d+(?:\.\d+)?)\s*(|cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)\s*$/.exec(e);if(null!==t){const e=parseFloat(t[1]),o=t[2];return on.value({value:e,unit:o})}return on.error(e)},rO=(e,t)=>{const o={"":96,px:96,pt:72,cm:2.54,pc:12,mm:25.4,in:1},n=e=>be(o,e);return e.unit===t?D.some(e.value):n(e.unit)&&n(t)?o[e.unit]===o[t]?D.some(e.value):D.some(e.value/o[e.unit]*o[t]):D.none()},sO=e=>D.none(),aO=(e,t)=>{const o=nO(e).toOptional(),n=nO(t).toOptional();return Ce(o,n,((e,t)=>rO(e,t.unit).map((e=>t.value/e)).map((e=>{return o=e,n=t.unit,e=>rO(e,n).map((e=>({value:e*o,unit:n})));var o,n})).getOr(sO))).getOr(sO)},iO=(e,t)=>{const o=e.label.map((e=>kk(e,t))),n=[wg.config({disabled:()=>e.disabled||t.isDisabled()}),gx(),Tp.config({mode:"execution",useEnter:!0!==e.multiline,useControlEnter:!0===e.multiline,execute:e=>(js(e,Dk),D.some(!0))}),Ip("textfield-change",[Qs(cs(),((t,o)=>{Ws(t,_k,{name:e.name})})),Qs(ws(),((t,o)=>{Ws(t,_k,{name:e.name})}))]),yk.config({})],r=e.validation.map((e=>jk.config({getRoot:e=>rt(e.element),invalidClass:"tox-invalid",validator:{validate:t=>{const o=Xm.getValue(t),n=e.validator(o);return xS(!0===n?on.value(o):on.error(n))},validateOnLoad:e.validateOnLoad}}))).toArray(),s={...e.placeholder.fold(w({}),(e=>({placeholder:t.translate(e)}))),...e.inputMode.fold(w({}),(e=>({inputmode:e})))},a=fk.parts.field({tag:!0===e.multiline?"textarea":"input",...e.data.map((e=>({data:e}))).getOr({}),inputAttributes:s,inputClasses:[e.classname],inputBehaviours:ql(q([n,r])),selectOnFocus:!1,factory:_y}),i=e.multiline?{dom:{tag:"div",classes:["tox-textarea-wrap"]},components:[a]}:a,l=(e.flex?["tox-form__group--stretched"]:[]).concat(e.maximized?["tox-form-group--maximize"]:[]),c=[wg.config({disabled:()=>e.disabled||t.isDisabled(),onDisabled:e=>{fk.getField(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable)}}),gx()];return xk(o,i,l,c)},lO=(e,t)=>t.getAnimationRoot.fold((()=>e.element),(t=>t(e))),cO=e=>e.dimension.property,dO=(e,t)=>e.dimension.getDimension(t),mO=(e,t)=>{const o=lO(e,t);ii(o,[t.shrinkingClass,t.growingClass])},uO=(e,t)=>{ni(e.element,t.openClass),ti(e.element,t.closedClass),Mt(e.element,cO(t),"0px"),zt(e.element)},gO=(e,t)=>{ni(e.element,t.closedClass),ti(e.element,t.openClass),Ft(e.element,cO(t))},hO=(e,t,o,n)=>{o.setCollapsed(),Mt(e.element,cO(t),dO(t,e.element)),mO(e,t),uO(e,t),t.onStartShrink(e),t.onShrunk(e)},pO=(e,t,o,n)=>{const r=n.getOrThunk((()=>dO(t,e.element)));o.setCollapsed(),Mt(e.element,cO(t),r),zt(e.element);const s=lO(e,t);ni(s,t.growingClass),ti(s,t.shrinkingClass),uO(e,t),t.onStartShrink(e)},fO=(e,t,o)=>{const n=dO(t,e.element);("0px"===n?hO:pO)(e,t,o,D.some(n))},vO=(e,t,o)=>{const n=lO(e,t),r=si(n,t.shrinkingClass),s=dO(t,e.element);gO(e,t);const a=dO(t,e.element);(r?()=>{Mt(e.element,cO(t),s),zt(e.element)}:()=>{uO(e,t)})(),ni(n,t.shrinkingClass),ti(n,t.growingClass),gO(e,t),Mt(e.element,cO(t),a),o.setExpanded(),t.onStartGrow(e)},bO=(e,t,o)=>{const n=lO(e,t);return!0===si(n,t.growingClass)},yO=(e,t,o)=>{const n=lO(e,t);return!0===si(n,t.shrinkingClass)};var wO=Object.freeze({__proto__:null,refresh:(e,t,o)=>{if(o.isExpanded()){Ft(e.element,cO(t));const o=dO(t,e.element);Mt(e.element,cO(t),o)}},grow:(e,t,o)=>{o.isExpanded()||vO(e,t,o)},shrink:(e,t,o)=>{o.isExpanded()&&fO(e,t,o)},immediateShrink:(e,t,o)=>{o.isExpanded()&&hO(e,t,o)},hasGrown:(e,t,o)=>o.isExpanded(),hasShrunk:(e,t,o)=>o.isCollapsed(),isGrowing:bO,isShrinking:yO,isTransitioning:(e,t,o)=>bO(e,t)||yO(e,t),toggleGrow:(e,t,o)=>{(o.isExpanded()?fO:vO)(e,t,o)},disableTransitions:mO,immediateGrow:(e,t,o)=>{o.isExpanded()||(gO(e,t),Mt(e.element,cO(t),dO(t,e.element)),mO(e,t),o.setExpanded(),t.onStartGrow(e),t.onGrown(e))}});var xO=Object.freeze({__proto__:null,exhibit:(e,t,o)=>{const n=t.expanded;return Fa(n?{classes:[t.openClass],styles:{}}:{classes:[t.closedClass],styles:Fr(t.dimension.property,"0px")})},events:(e,t)=>Ys([aa(gs(),((o,n)=>{if(n.event.raw.propertyName===e.dimension.property){mO(o,e),t.isExpanded()&&Ft(o.element,e.dimension.property);(t.isExpanded()?e.onGrown:e.onShrunk)(o)}}))])}),CO=[dr("closedClass"),dr("openClass"),dr("shrinkingClass"),dr("growingClass"),yr("getAnimationRoot"),el("onShrunk"),el("onStartShrink"),el("onGrown"),el("onStartGrow"),Tr("expanded",!1),mr("dimension",sr("property",{width:[rl("property","width"),rl("getDimension",(e=>Xt(e)+"px"))],height:[rl("property","height"),rl("getDimension",(e=>Ut(e)+"px"))]}))];const SO=Kl({fields:CO,name:"sliding",active:xO,apis:wO,state:Object.freeze({__proto__:null,init:e=>{const t=Hr(e.expanded);return Ia({isExpanded:()=>!0===t.get(),isCollapsed:()=>!1===t.get(),setCollapsed:S(t.set,!1),setExpanded:S(t.set,!0),readState:()=>"expanded: "+t.get()})}})}),kO=e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setActive:t=>{const o=e.element;t?(ti(o,"tox-tbtn--enabled"),St(o,"aria-pressed",!0)):(ni(o,"tox-tbtn--enabled"),Ot(o,"aria-pressed"))},isActive:()=>si(e.element,"tox-tbtn--enabled"),setText:t=>{Ws(e,zT,{text:t})},setIcon:t=>Ws(e,VT,{icon:t})}),_O=(e,t,o,n,r=!0)=>ZT({text:e.text,icon:e.icon,tooltip:e.tooltip,searchable:e.search.isSome(),role:n,fetch:(t,n)=>{const r={pattern:e.search.isSome()?VS(t):""};e.fetch((t=>{n(qT(t,oy.CLOSE_ON_EXECUTE,o,{isHorizontalMenu:!1,search:e.search}))}),r,kO(t))},onSetup:e.onSetup,getApi:kO,columns:1,presets:"normal",classes:[],dropdownBehaviours:[...r?[yk.config({})]:[]]},t,o.shared),EO=(e,t,o)=>{const n=e=>n=>{const r=!n.isActive();n.setActive(r),e.storage.set(r),o.shared.getSink().each((o=>{t().getOpt(o).each((t=>{tc(t.element),Ws(t,Ok,{name:e.name,value:e.storage.get()})}))}))},r=e=>t=>{t.setActive(e.storage.get())};return t=>{t(F(e,(e=>{const t=e.text.fold((()=>({})),(e=>({text:e})));return{type:e.type,active:!1,...t,onAction:n(e),onSetup:r(e)}})))}},TO=e=>({dom:{tag:"span",classes:["tox-tree__label"],attributes:{title:e,"aria-label":e}},components:[Ci(e)]}),OO=ya("leaf-label-event-id"),DO=({leaf:e,onLeafAction:t,visible:o,treeId:n,selectedId:r,backstage:s})=>{const a=e.menu.map((e=>_O(e,"tox-mbtn",s,D.none(),o))),i=[TO(e.title)];return a.each((e=>i.push(e))),Nf.sketch({dom:{tag:"div",classes:["tox-tree--leaf__label","tox-trbtn"].concat(o?["tox-tree--leaf__label--visible"]:[])},components:i,role:"treeitem",action:o=>{t(e.id),o.getSystem().broadcastOn([`update-active-item-${n}`],{value:e.id})},eventOrder:{[is()]:[OO,"keying"]},buttonBehaviours:ql([...o?[yk.config({})]:[],Yp.config({toggleClass:"tox-trbtn--enabled",toggleOnExecute:!1,aria:{mode:"selected"}}),Ql.config({channels:{[`update-active-item-${n}`]:{onReceive:(t,o)=>{(o.value===e.id?Yp.on:Yp.off)(t)}}}}),Ip(OO,[ia(((t,o)=>{r.each((o=>{(o===e.id?Yp.on:Yp.off)(t)}))})),Qs(is(),((e,t)=>{const o="ArrowLeft"===t.event.raw.code,n="ArrowRight"===t.event.raw.code;o?(Ni(e.element,".tox-tree--directory").each((t=>{e.getSystem().getByDom(t).each((e=>{Ri(t,".tox-tree--directory__label").each((t=>{e.getSystem().getByDom(t).each(Zp.focus)}))}))})),t.stop()):n&&t.stop()}))])])})},AO=(e,t)=>((e,t,o)=>zv(e,{tag:"span",classes:["tox-tree__icon-wrap","tox-icon"],behaviours:o},t))(e,t,[]),MO=ya("directory-label-event-id"),NO=({directory:e,visible:t,noChildren:o,backstage:n})=>{const r=e.menu.map((e=>_O(e,"tox-mbtn",n,D.none()))),s=[{dom:{tag:"div",classes:["tox-chevron"]},components:[AO("chevron-right",n.shared.providers.icons)]},TO(e.title)];r.each((e=>{s.push(e)}));const a=t=>{Ni(t.element,".tox-tree--directory").each((o=>{t.getSystem().getByDom(o).each((o=>{const n=!Yp.isOn(o);Yp.toggle(o),Ws(t,"expand-tree-node",{expanded:n,node:e.id})}))}))};return Nf.sketch({dom:{tag:"div",classes:["tox-tree--directory__label","tox-trbtn"].concat(t?["tox-tree--directory__label--visible"]:[])},components:s,action:a,eventOrder:{[is()]:[MO,"keying"]},buttonBehaviours:ql([...t?[yk.config({})]:[],Ip(MO,[Qs(is(),((e,t)=>{const n="ArrowRight"===t.event.raw.code,r="ArrowLeft"===t.event.raw.code;n&&o&&t.stop(),(n||r)&&Ni(e.element,".tox-tree--directory").each((o=>{e.getSystem().getByDom(o).each((o=>{!Yp.isOn(o)&&n||Yp.isOn(o)&&r?(a(e),t.stop()):r&&!Yp.isOn(o)&&(Ni(o.element,".tox-tree--directory").each((e=>{Ri(e,".tox-tree--directory__label").each((e=>{o.getSystem().getByDom(e).each(Zp.focus)}))})),t.stop())}))}))}))])])})},RO=({children:e,onLeafAction:t,visible:o,treeId:n,expandedIds:r,selectedId:s,backstage:a})=>({dom:{tag:"div",classes:["tox-tree--directory__children"]},components:e.map((e=>"leaf"===e.type?DO({leaf:e,selectedId:s,onLeafAction:t,visible:o,treeId:n,backstage:a}):LO({directory:e,expandedIds:r,selectedId:s,onLeafAction:t,labelTabstopping:o,treeId:n,backstage:a}))),behaviours:ql([SO.config({dimension:{property:"height"},closedClass:"tox-tree--directory__children--closed",openClass:"tox-tree--directory__children--open",growingClass:"tox-tree--directory__children--growing",shrinkingClass:"tox-tree--directory__children--shrinking",expanded:o}),Hp.config({})])}),BO=ya("directory-event-id"),LO=({directory:e,onLeafAction:t,labelTabstopping:o,treeId:n,backstage:r,expandedIds:s,selectedId:a})=>{const{children:i}=e,l=Hr(s),c=s.includes(e.id);return{dom:{tag:"div",classes:["tox-tree--directory"],attributes:{role:"treeitem"}},components:[NO({directory:e,visible:o,noChildren:0===e.children.length,backstage:r}),RO({children:i,expandedIds:s,selectedId:a,onLeafAction:t,visible:c,treeId:n,backstage:r})],behaviours:ql([Ip(BO,[ia(((e,t)=>{Yp.set(e,c)})),Qs("expand-tree-node",((e,t)=>{const{expanded:o,node:n}=t.event;l.set(o?[...l.get(),n]:l.get().filter((e=>e!==n)))}))]),Yp.config({...e.children.length>0?{aria:{mode:"expanded"}}:{},toggleClass:"tox-tree--directory--expanded",onToggled:(e,o)=>{const s=e.components()[1],c=(d=o,i.map((e=>"leaf"===e.type?DO({leaf:e,selectedId:a,onLeafAction:t,visible:d,treeId:n,backstage:r}):LO({directory:e,expandedIds:l.get(),selectedId:a,onLeafAction:t,labelTabstopping:d,treeId:n,backstage:r}))));var d;o?SO.grow(s):SO.shrink(s),Hp.set(s,c)}})])}},HO=ya("tree-event-id");var IO=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.stream.streams.setup(e,t);return Ys([Qs(e.event,o),la((()=>t.cancel()))].concat(e.cancelEvent.map((e=>[Qs(e,(()=>t.cancel()))])).getOr([])))}});const PO=e=>{const t=Hr(null);return Ia({readState:()=>({timer:null!==t.get()?"set":"unset"}),setTimer:e=>{t.set(e)},cancel:()=>{const e=t.get();null!==e&&e.cancel()}})};var FO=Object.freeze({__proto__:null,throttle:PO,init:e=>e.stream.streams.state(e)});var zO=[mr("stream",sr("mode",{throttle:[dr("delay"),Tr("stopEvent",!0),rl("streams",{setup:(e,t)=>{const o=e.stream,n=iT(e.onStream,o.delay);return t.setTimer(n),(e,t)=>{n.throttle(e,t),o.stopEvent&&t.stop()}},state:PO})]})),Tr("event","input"),yr("cancelEvent"),ol("onStream")];const VO=Kl({fields:zO,name:"streaming",active:IO,state:FO}),ZO=(e,t,o)=>{const n=Xm.getValue(o);Xm.setValue(t,n),jO(t)},UO=(e,t)=>{const o=e.element,n=ci(o),r=o.dom;"number"!==_t(o,"type")&&t(r,n)},jO=e=>{UO(e,((e,t)=>e.setSelectionRange(t.length,t.length)))},WO=(e,t,o)=>{if(e.selectsOver){const n=Xm.getValue(t),r=e.getDisplayText(n),s=Xm.getValue(o);return 0===e.getDisplayText(s).indexOf(r)?D.some((()=>{ZO(0,t,o),((e,t)=>{UO(e,((e,o)=>e.setSelectionRange(t,o.length)))})(t,r.length)})):D.none()}return D.none()},$O=w("alloy.typeahead.itemexecute"),qO=w([yr("lazySink"),dr("fetch"),Tr("minChars",5),Tr("responseTime",1e3),el("onOpen"),Tr("getHotspot",D.some),Tr("getAnchorOverrides",w({})),Tr("layouts",D.none()),Tr("eventOrder",{}),Lr("model",{},[Tr("getDisplayText",(e=>void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.value)),Tr("selectsOver",!0),Tr("populateFromBrowse",!0)]),el("onSetValue"),tl("onExecute"),el("onItemExecute"),Tr("inputClasses",[]),Tr("inputAttributes",{}),Tr("inputStyles",{}),Tr("matchWidth",!0),Tr("useMinWidth",!1),Tr("dismissOnBlur",!0),Ji(["openClass"]),yr("initialData"),Jm("typeaheadBehaviours",[Zp,Xm,VO,Tp,Yp,pS]),lr("lazyTypeaheadComp",(()=>Hr(D.none))),lr("previewing",(()=>Hr(!0)))].concat(xy()).concat(RS())),GO=w([Ou({schema:[Xi()],name:"menu",overrides:e=>({fakeFocus:!0,onHighlightItem:(t,o,n)=>{e.previewing.get()?e.lazyTypeaheadComp.get().each((t=>{WO(e.model,t,n).fold((()=>{e.model.selectsOver?(Mg.dehighlight(o,n),e.previewing.set(!0)):e.previewing.set(!1)}),(t=>{t(),e.previewing.set(!1)}))})):e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&ZO(e.model,t,n),Et(n.element,"id").each((e=>St(t.element,"aria-activedescendant",e)))}))},onExecute:(t,o)=>e.lazyTypeaheadComp.get().map((e=>(Ws(e,$O(),{item:o}),!0))),onHover:(t,o)=>{e.previewing.set(!1),e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&ZO(e.model,t,o)}))}})})]),KO=og({name:"Typeahead",configFields:qO(),partFields:GO(),factory:(e,t,o,n)=>{const r=(t,o,r)=>{e.previewing.set(!1);const s=pS.getCoupled(t,"sandbox");if(Mm.isOpen(s))ag.getCurrent(s).each((e=>{Mg.getHighlighted(e).fold((()=>{r(e)}),(()=>{Ks(s,e.element,"keydown",o)}))}));else{const o=e=>{ag.getCurrent(e).each(r)};_S(e,a(t),t,s,n,o,Tf.HighlightMenuAndItem).get(v)}},s=Cy(e),a=e=>t=>t.map((t=>{const o=fe(t.menus),n=G(o,(e=>Z(e.items,(e=>"item"===e.type))));return Xm.getState(e).update(F(n,(e=>e.data))),t})),i=e=>ag.getCurrent(e),l="typeaheadevents",c=[Zp.config({}),Xm.config({onSetValue:e.onSetValue,store:{mode:"dataset",getDataKey:e=>ci(e.element),getFallbackEntry:e=>({value:e,meta:{}}),setValue:(t,o)=>{di(t.element,e.model.getDisplayText(o))},...e.initialData.map((e=>Fr("initialValue",e))).getOr({})}}),VO.config({stream:{mode:"throttle",delay:e.responseTime,stopEvent:!1},onStream:(t,o)=>{const r=pS.getCoupled(t,"sandbox");if(Zp.isFocused(t)&&ci(t.element).length>=e.minChars){const o=i(r).bind((e=>Mg.getHighlighted(e).map(Xm.getValue)));e.previewing.set(!0);const s=t=>{i(r).each((t=>{o.fold((()=>{e.model.selectsOver&&Mg.highlightFirst(t)}),(e=>{Mg.highlightBy(t,(t=>Xm.getValue(t).value===e.value)),Mg.getHighlighted(t).orThunk((()=>(Mg.highlightFirst(t),D.none())))}))}))};_S(e,a(t),t,r,n,s,Tf.HighlightJustMenu).get(v)}},cancelEvent:Ts()}),Tp.config({mode:"special",onDown:(e,t)=>(r(e,t,Mg.highlightFirst),D.some(!0)),onEscape:e=>{const t=pS.getCoupled(e,"sandbox");return Mm.isOpen(t)?(Mm.close(t),D.some(!0)):D.none()},onUp:(e,t)=>(r(e,t,Mg.highlightLast),D.some(!0)),onEnter:t=>{const o=pS.getCoupled(t,"sandbox"),n=Mm.isOpen(o);if(n&&!e.previewing.get())return i(o).bind((e=>Mg.getHighlighted(e))).map((e=>(Ws(t,$O(),{item:e}),!0)));{const r=Xm.getValue(t);return js(t,Ts()),e.onExecute(o,t,r),n&&Mm.close(o),D.some(!0)}}}),Yp.config({toggleClass:e.markers.openClass,aria:{mode:"expanded"}}),pS.config({others:{sandbox:t=>MS(e,t,{onOpen:()=>Yp.on(t),onClose:()=>{e.lazyTypeaheadComp.get().each((e=>Ot(e.element,"aria-activedescendant"))),Yp.off(t)}})}}),Ip(l,[ia((t=>{e.lazyTypeaheadComp.set(D.some(t))})),la((t=>{e.lazyTypeaheadComp.set(D.none())})),da((t=>{const o=v;TS(e,a(t),t,n,o,Tf.HighlightMenuAndItem).get(v)})),Qs($O(),((t,o)=>{const n=pS.getCoupled(t,"sandbox");ZO(e.model,t,o.event.item),js(t,Ts()),e.onItemExecute(t,n,o.event.item,Xm.getValue(t)),Mm.close(n),jO(t)}))].concat(e.dismissOnBlur?[Qs(ys(),(e=>{const t=pS.getCoupled(e,"sandbox");sc(t.element).isNone()&&Mm.close(t)}))]:[]))],d={[Bs()]:[Xm.name(),VO.name(),l],...e.eventOrder};return{uid:e.uid,dom:ky(xn(e,{inputAttributes:{role:"combobox","aria-autocomplete":"list","aria-haspopup":"true"}})),behaviours:{...s,...eu(e.typeaheadBehaviours,c)},eventOrder:d}}}),YO=e=>({...e,toCached:()=>YO(e.toCached()),bindFuture:t=>YO(e.bind((e=>e.fold((e=>xS(on.error(e))),(e=>t(e)))))),bindResult:t=>YO(e.map((e=>e.bind(t)))),mapResult:t=>YO(e.map((e=>e.map(t)))),mapError:t=>YO(e.map((e=>e.mapError(t)))),foldResult:(t,o)=>e.map((e=>e.fold(t,o))),withTimeout:(t,o)=>YO(wS((n=>{let r=!1;const s=setTimeout((()=>{r=!0,n(on.error(o()))}),t);e.get((e=>{r||(clearTimeout(s),n(e))}))})))}),XO=e=>YO(wS(e)),JO=XO,QO=(e,t,o=[],n,r,s)=>{const a=t.fold((()=>({})),(e=>({action:e}))),i={buttonBehaviours:ql([px((()=>!e.enabled||s.isDisabled())),gx(),yk.config({}),Ip("button press",[Js("click"),Js("mousedown")])].concat(o)),eventOrder:{click:["button press","alloy.base.behaviour"],mousedown:["button press","alloy.base.behaviour"]},...a},l=xn(i,{dom:n});return xn(l,{components:r})},eD=(e,t,o,n=[])=>{const r={tag:"button",classes:["tox-tbtn"],attributes:e.tooltip.map((e=>({"aria-label":o.translate(e),title:o.translate(e)}))).getOr({})},s=e.icon.map((e=>IT(e,o.icons))),a=Sx([s]);return QO(e,t,n,r,a,o)},tD=e=>{switch(e){case"primary":return["tox-button"];case"toolbar":return["tox-tbtn"];default:return["tox-button","tox-button--secondary"]}},oD=(e,t,o,n=[],r=[])=>{const s=o.translate(e.text),a=e.icon.map((e=>IT(e,o.icons))),i=[a.getOrThunk((()=>Ci(s)))],l=e.buttonType.getOr(e.primary||e.borderless?"primary":"secondary"),c=[...tD(l),...a.isSome()?["tox-button--icon"]:[],...e.borderless?["tox-button--naked"]:[],...r];return QO(e,t,n,{tag:"button",classes:c,attributes:{title:s}},i,o)},nD=(e,t,o,n=[],r=[])=>{const s=oD(e,D.some(t),o,n,r);return Nf.sketch(s)},rD=(e,t)=>o=>{"custom"===t?Ws(o,Ok,{name:e,value:{}}):"submit"===t?js(o,Dk):"cancel"===t?js(o,Tk):console.error("Unknown button type: ",t)},sD=(e,t,o)=>{if(((e,t)=>"menu"===t)(0,t)){const t=()=>s,n=e,r={...e,type:"menubutton",search:D.none(),onSetup:t=>(t.setEnabled(e.enabled),v),fetch:EO(n.items,t,o)},s=Bf(_O(r,"tox-tbtn",o,D.none()));return s.asSpec()}if(((e,t)=>"custom"===t||"cancel"===t||"submit"===t)(0,t)){const n=rD(e.name,t),r={...e,borderless:!1};return nD(r,n,o.shared.providers,[])}if(((e,t)=>"togglebutton"===t)(0,t))return((e,t)=>{var o,n;const r=e.icon.map((e=>PT(e,t.icons))).map(Bf),s=e.buttonType.getOr(e.primary?"primary":"secondary"),a={...e,name:null!==(o=e.name)&&void 0!==o?o:"",primary:"primary"===s,tooltip:D.from(e.tooltip),enabled:null!==(n=e.enabled)&&void 0!==n&&n,borderless:!1},i=a.tooltip.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),l=tD(null!=s?s:"secondary"),c=e.icon.isSome()&&e.text.isSome(),d={tag:"button",classes:[...l.concat(e.icon.isSome()?["tox-button--icon"]:[]),...e.active?["tox-button--enabled"]:[],...c?["tox-button--icon-and-text"]:[]],attributes:i},m=t.translate(e.text.getOr("")),u=Ci(m),g=[...Sx([r.map((e=>e.asSpec()))]),...e.text.isSome()?[u]:[]],h=QO(a,D.some((o=>{Ws(o,Ok,{name:e.name,value:{setIcon:e=>{r.map((n=>n.getOpt(o).each((o=>{Hp.set(o,[PT(e,t.icons)])}))))}}})})),[],d,g,t);return Nf.sketch(h)})(e,o.shared.providers);throw console.error("Unknown footer button type: ",t),new Error("Unknown footer button type")},aD=(e,t)=>{const o=rD(e.name,"custom");return n=D.none(),r=fk.parts.field({factory:Nf,...oD(e,D.some(o),t,[tT(""),GE()])}),xk(n,r,[],[]);var n,r},iD={type:"separator"},lD=e=>({type:"menuitem",value:e.url,text:e.title,meta:{attach:e.attach},onAction:v}),cD=(e,t)=>({type:"menuitem",value:t,text:e,meta:{attach:void 0},onAction:v}),dD=(e,t)=>(e=>F(e,lD))(((e,t)=>Z(t,(t=>t.type===e)))(e,t)),mD=e=>dD("header",e.targets),uD=e=>dD("anchor",e.targets),gD=e=>D.from(e.anchorTop).map((e=>cD("",e))).toArray(),hD=e=>D.from(e.anchorBottom).map((e=>cD("",e))).toArray(),pD=(e,t)=>{const o=e.toLowerCase();return Z(t,(e=>{var t;const n=void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.text,r=null!==(t=e.value)&&void 0!==t?t:"";return Te(n.toLowerCase(),o)||Te(r.toLowerCase(),o)}))},fD=(e,t,o)=>{var n,r;const s=Xm.getValue(t),a=null!==(r=null===(n=null==s?void 0:s.meta)||void 0===n?void 0:n.text)&&void 0!==r?r:s.value;return o.getLinkInformation().fold((()=>[]),(t=>{const n=pD(a,(e=>F(e,(e=>cD(e,e))))(o.getHistory(e)));return"file"===e?(r=[n,pD(a,mD(t)),pD(a,q([gD(t),uD(t),hD(t)]))],j(r,((e,t)=>0===e.length||0===t.length?e.concat(t):e.concat(iD,t)),[])):n;var r}))},vD=ya("aria-invalid"),bD=(e,t)=>{e.dom.checked=t},yD=e=>e.dom.checked,wD=e=>(t,o,n,r)=>ve(o,"name").fold((()=>e(o,r,D.none())),(s=>t.field(s,e(o,r,ve(n,s))))),xD={bar:wD(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-bar","tox-form__controls-h-stack"]},components:F(e.items,t.interpreter)}))(e,t.shared))),collection:wD(((e,t,o)=>Bk(e,t.shared.providers,o))),alertbanner:wD(((e,t)=>((e,t)=>{const o=Iv(e.icon,t.icons);return uk.sketch({dom:{tag:"div",attributes:{role:"alert"},classes:["tox-notification","tox-notification--in",`tox-notification--${e.level}`]},components:[{dom:{tag:"div",classes:["tox-notification__icon"],innerHtml:e.url?void 0:o},components:e.url?[Nf.sketch({dom:{tag:"button",classes:["tox-button","tox-button--naked","tox-button--icon"],innerHtml:o,attributes:{title:t.translate(e.iconTooltip)}},action:t=>Ws(t,Ok,{name:"alert-banner",value:e.url}),buttonBehaviours:ql([Pv()])})]:void 0},{dom:{tag:"div",classes:["tox-notification__body"],innerHtml:t.translate(e.text)}}]})})(e,t.shared.providers))),input:wD(((e,t,o)=>((e,t,o)=>iO({name:e.name,multiline:!1,label:e.label,inputMode:e.inputMode,placeholder:e.placeholder,flex:!1,disabled:!e.enabled,classname:"tox-textfield",validation:D.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),textarea:wD(((e,t,o)=>((e,t,o)=>iO({name:e.name,multiline:!0,label:e.label,inputMode:D.none(),placeholder:e.placeholder,flex:!0,disabled:!e.enabled,classname:"tox-textarea",validation:D.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),label:wD(((e,t)=>((e,t)=>{const o="tox-label";return{dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"label",classes:[o,..."center"===e.align?[`${o}--center`]:[],..."end"===e.align?[`${o}--end`]:[]]},components:[Ci(t.providers.translate(e.label))]},...F(e.items,t.interpreter)],behaviours:ql([GE(),Hp.config({}),(n=D.none(),eT(n,ma,ua)),Tp.config({mode:"acyclic"})])};var n})(e,t.shared))),iframe:(e=>(t,o,n,r)=>{const s=xn(o,{source:"dynamic"});return wD(e)(t,s,n,r)})(((e,t,o)=>AT(e,t.shared.providers,o))),button:wD(((e,t)=>aD(e,t.shared.providers))),checkbox:wD(((e,t,o)=>((e,t,o)=>{const n=e=>(e.element.dom.click(),D.some(!0)),r=fk.parts.field({factory:{sketch:x},dom:{tag:"input",classes:["tox-checkbox__input"],attributes:{type:"checkbox"}},behaviours:ql([GE(),wg.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{rt(e.element).each((e=>ti(e,"tox-checkbox--disabled")))},onEnabled:e=>{rt(e.element).each((e=>ni(e,"tox-checkbox--disabled")))}}),yk.config({}),Zp.config({}),eT(o,yD,bD),Tp.config({mode:"special",onEnter:n,onSpace:n,stopSpaceKeyup:!0}),Ip("checkbox-events",[Qs(ds(),((t,o)=>{Ws(t,_k,{name:e.name})}))])])}),s=fk.parts.label({dom:{tag:"span",classes:["tox-checkbox__label"]},components:[Ci(t.translate(e.label))],behaviours:ql([Wk.config({})])}),a=e=>zv("checked"===e?"selected":"unselected",{tag:"span",classes:["tox-icon","tox-checkbox-icon__"+e]},t.icons),i=Bf({dom:{tag:"div",classes:["tox-checkbox__icons"]},components:[a("checked"),a("unchecked")]});return fk.sketch({dom:{tag:"label",classes:["tox-checkbox"]},components:[r,i.asSpec(),s],fieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),gx()])})})(e,t.shared.providers,o))),colorinput:wD(((e,t,o)=>Kk(e,t.shared,t.colorinput,o))),colorpicker:wD(((e,t,o)=>nT(0,t.shared.providers,o))),dropzone:wD(((e,t,o)=>aT(e,t.shared.providers,o))),grid:wD(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-form__grid",`tox-form__grid--${e.columns}col`]},components:F(e.items,t.interpreter)}))(e,t.shared))),listbox:wD(((e,t,o)=>((e,t,o)=>{const n=t.shared.providers,r=o.bind((t=>XT(e.items,t))).orThunk((()=>oe(e.items).filter(GT))),s=e.label.map((e=>kk(e,n))),a=fk.parts.field({dom:{},factory:{sketch:o=>ZT({uid:o.uid,text:r.map((e=>e.text)),icon:D.none(),tooltip:e.label,role:D.none(),fetch:(o,n)=>{const r=YT(o,e.name,e.items,Xm.getValue(o));n(qT(r,oy.CLOSE_ON_EXECUTE,t,{isHorizontalMenu:!1,search:D.none()}))},onSetup:w(v),getApi:w({}),columns:1,presets:"normal",classes:[],dropdownBehaviours:[yk.config({}),QE(r.map((e=>e.value)),(e=>_t(e.element,KT)),((t,o)=>{XT(e.items,o).each((e=>{St(t.element,KT,e.value),Ws(t,zT,{text:e.text})}))}))]},"tox-listbox",t.shared)}}),i={dom:{tag:"div",classes:["tox-listboxfield"]},components:[a]};return fk.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([s.toArray(),[i]]),fieldBehaviours:ql([wg.config({disabled:w(!e.enabled),onDisabled:e=>{fk.getField(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable)}})])})})(e,t,o))),selectbox:wD(((e,t,o)=>((e,t,o)=>{const n=F(e.items,(e=>({text:t.translate(e.text),value:e.value}))),r=e.label.map((e=>kk(e,t))),s=fk.parts.field({dom:{},...o.map((e=>({data:e}))).getOr({}),selectAttributes:{size:e.size},options:n,factory:JT,selectBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),yk.config({}),Ip("selectbox-change",[Qs(ds(),((t,o)=>{Ws(t,_k,{name:e.name})}))])])}),a=e.size>1?D.none():D.some(zv("chevron-down",{tag:"div",classes:["tox-selectfield__icon-js"]},t.icons)),i={dom:{tag:"div",classes:["tox-selectfield"]},components:q([[s],a.toArray()])};return fk.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([r.toArray(),[i]]),fieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{fk.getField(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable)}}),gx()])})})(e,t.shared.providers,o))),sizeinput:wD(((e,t)=>((e,t)=>{let o=sO;const n=ya("ratio-event"),r=e=>zv(e,{tag:"span",classes:["tox-icon","tox-lock-icon__"+e]},t.icons),s=oO.parts.lock({dom:{tag:"button",classes:["tox-lock","tox-button","tox-button--naked","tox-button--icon"],attributes:{title:t.translate(e.label.getOr("Constrain proportions"))}},components:[r("lock"),r("unlock")],buttonBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),gx(),yk.config({})])}),a=e=>({dom:{tag:"div",classes:["tox-form__group"]},components:e}),i=o=>fk.parts.field({factory:_y,inputClasses:["tox-textfield"],inputBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),gx(),yk.config({}),Ip("size-input-events",[Qs(ss(),((e,t)=>{Ws(e,n,{isField1:o})})),Qs(ds(),((t,o)=>{Ws(t,_k,{name:e.name})}))])]),selectOnFocus:!1}),l=e=>({dom:{tag:"label",classes:["tox-label"]},components:[Ci(t.translate(e))]}),c=oO.parts.field1(a([fk.parts.label(l("Width")),i(!0)])),d=oO.parts.field2(a([fk.parts.label(l("Height")),i(!1)]));return oO.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:[c,d,a([l(" "),s])]}],field1Name:"width",field2Name:"height",locked:!0,markers:{lockClass:"tox-locked"},onLockedChange:(e,t,n)=>{nO(Xm.getValue(e)).each((e=>{o(e).each((e=>{Xm.setValue(t,(e=>{const t={"":0,px:0,pt:1,mm:1,pc:2,ex:2,em:2,ch:2,rem:2,cm:3,in:4,"%":4};let o=e.value.toFixed((n=e.unit)in t?t[n]:1);var n;return-1!==o.indexOf(".")&&(o=o.replace(/\.?0*$/,"")),o+e.unit})(e))}))}))},coupledFieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{oO.getField1(e).bind(fk.getField).each(wg.disable),oO.getField2(e).bind(fk.getField).each(wg.disable),oO.getLock(e).each(wg.disable)},onEnabled:e=>{oO.getField1(e).bind(fk.getField).each(wg.enable),oO.getField2(e).bind(fk.getField).each(wg.enable),oO.getLock(e).each(wg.enable)}}),gx(),Ip("size-input-events2",[Qs(n,((e,t)=>{const n=t.event.isField1,r=n?oO.getField1(e):oO.getField2(e),s=n?oO.getField2(e):oO.getField1(e),a=r.map(Xm.getValue).getOr(""),i=s.map(Xm.getValue).getOr("");o=aO(a,i)}))])])})})(e,t.shared.providers))),slider:wD(((e,t,o)=>((e,t,o)=>{const n=NE.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[Ci(t.translate(e.label))]}),r=NE.parts.spectrum({dom:{tag:"div",classes:["tox-slider__rail"],attributes:{role:"presentation"}}}),s=NE.parts.thumb({dom:{tag:"div",classes:["tox-slider__handle"],attributes:{role:"presentation"}}});return NE.sketch({dom:{tag:"div",classes:["tox-slider"],attributes:{role:"presentation"}},model:{mode:"x",minX:e.min,maxX:e.max,getInitialValue:w(o.getOrThunk((()=>(Math.abs(e.max)-Math.abs(e.min))/2)))},components:[n,r,s],sliderBehaviours:ql([GE(),Zp.config({})]),onChoose:(t,o,n)=>{Ws(t,_k,{name:e.name,value:n})}})})(e,t.shared.providers,o))),urlinput:wD(((e,t,o)=>((e,t,o,n)=>{const r=t.shared.providers,s=t=>{const n=Xm.getValue(t);o.addToHistory(n.value,e.filetype)},a={...n.map((e=>({initialData:e}))).getOr({}),dismissOnBlur:!0,inputClasses:["tox-textfield"],sandboxClasses:["tox-dialog__popups"],inputAttributes:{"aria-errormessage":vD,type:"url"},minChars:0,responseTime:0,fetch:n=>{const r=fD(e.filetype,n,o),s=qT(r,oy.BUBBLE_TO_SANDBOX,t,{isHorizontalMenu:!1,search:D.none()});return xS(s)},getHotspot:e=>g.getOpt(e),onSetValue:(e,t)=>{e.hasConfigured(jk)&&jk.run(e).get(v)},typeaheadBehaviours:ql([...o.getValidationHandler().map((t=>jk.config({getRoot:e=>rt(e.element),invalidClass:"tox-control-wrap--status-invalid",notify:{onInvalid:(e,t)=>{c.getOpt(e).each((e=>{St(e.element,"title",r.translate(t))}))}},validator:{validate:o=>{const n=Xm.getValue(o);return JO((o=>{t({type:e.filetype,url:n.value},(e=>{if("invalid"===e.status){const t=on.error(e.message);o(t)}else{const t=on.value(e.message);o(t)}}))}))},validateOnLoad:!1}}))).toArray(),wg.config({disabled:()=>!e.enabled||r.isDisabled()}),yk.config({}),Ip("urlinput-events",[Qs(cs(),(t=>{const o=ci(t.element),n=o.trim();n!==o&&di(t.element,n),"file"===e.filetype&&Ws(t,_k,{name:e.name})})),Qs(ds(),(t=>{Ws(t,_k,{name:e.name}),s(t)})),Qs(ws(),(t=>{Ws(t,_k,{name:e.name}),s(t)}))])]),eventOrder:{[cs()]:["streaming","urlinput-events","invalidating"]},model:{getDisplayText:e=>e.value,selectsOver:!1,populateFromBrowse:!1},markers:{openClass:"tox-textfield--popup-open"},lazySink:t.shared.getSink,parts:{menu:wy(0,0,"normal")},onExecute:(e,t,o)=>{Ws(t,Dk,{})},onItemExecute:(t,o,n,r)=>{s(t),Ws(t,_k,{name:e.name})}},i=fk.parts.field({...a,factory:KO}),l=e.label.map((e=>kk(e,r))),c=Bf(((e,t,o=e,n=e)=>zv(o,{tag:"div",classes:["tox-icon","tox-control-wrap__status-icon-"+e],attributes:{title:r.translate(n),"aria-live":"polite",...t.fold((()=>({})),(e=>({id:e})))}},r.icons))("invalid",D.some(vD),"warning")),d=Bf({dom:{tag:"div",classes:["tox-control-wrap__status-icon-wrap"]},components:[c.asSpec()]}),m=o.getUrlPicker(e.filetype),u=ya("browser.url.event"),g=Bf({dom:{tag:"div",classes:["tox-control-wrap"]},components:[i,d.asSpec()],behaviours:ql([wg.config({disabled:()=>!e.enabled||r.isDisabled()})])}),h=Bf(nD({name:e.name,icon:D.some("browse"),text:e.picker_text.or(e.label).getOr(""),enabled:e.enabled,primary:!1,buttonType:D.none(),borderless:!0},(e=>js(e,u)),r,[],["tox-browse-url"]));return fk.sketch({dom:Sk([]),components:l.toArray().concat([{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:q([[g.asSpec()],m.map((()=>h.asSpec())).toArray()])}]),fieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||r.isDisabled(),onDisabled:e=>{fk.getField(e).each(wg.disable),h.getOpt(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable),h.getOpt(e).each(wg.enable)}}),gx(),Ip("url-input-events",[Qs(u,(t=>{ag.getCurrent(t).each((o=>{const n=Xm.getValue(o),r={fieldname:e.name,...n};m.each((n=>{n(r).get((n=>{Xm.setValue(o,n),Ws(t,_k,{name:e.name})}))}))}))}))])])})})(e,t,t.urlinput,o))),customeditor:wD((e=>{const t=kc(),o=Bf({dom:{tag:e.tag}}),n=kc();return{dom:{tag:"div",classes:["tox-custom-editor"]},behaviours:ql([Ip("custom-editor-events",[ia((r=>{o.getOpt(r).each((o=>{((e=>be(e,"init"))(e)?e.init(o.element.dom):rT.load(e.scriptId,e.scriptUrl).then((t=>t(o.element.dom,e.settings)))).then((e=>{n.on((t=>{e.setValue(t)})),n.clear(),t.set(e)}))}))}))]),QE(D.none(),(()=>t.get().fold((()=>n.get().getOr("")),(e=>e.getValue()))),((e,o)=>{t.get().fold((()=>n.set(o)),(e=>e.setValue(o)))})),GE()]),components:[o.asSpec()]}})),htmlpanel:wD((e=>"presentation"===e.presets?uk.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html}}):uk.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html,attributes:{role:"document"}},containerBehaviours:ql([yk.config({}),Zp.config({})])}))),imagepreview:wD(((e,t,o)=>MT(e,o))),table:wD(((e,t)=>((e,t)=>{const o=e=>({dom:{tag:"th",innerHtml:t.translate(e)}}),n=e=>({dom:{tag:"td",innerHtml:t.translate(e)}}),r=e=>({dom:{tag:"tr"},components:F(e,n)});return{dom:{tag:"table",classes:["tox-dialog__table"]},components:[(a=e.header,{dom:{tag:"thead"},components:[{dom:{tag:"tr"},components:F(a,o)}]}),(s=e.cells,{dom:{tag:"tbody"},components:F(s,r)})],behaviours:ql([yk.config({}),Zp.config({})])};var s,a})(e,t.shared.providers))),tree:wD(((e,t)=>((e,t)=>{const o=e.onLeafAction.getOr(v),n=e.onToggleExpand.getOr(v),r=e.defaultExpandedIds,s=Hr(r),a=Hr(e.defaultSelectedId),i=ya("tree-id"),l=(n,r)=>e.items.map((e=>"leaf"===e.type?DO({leaf:e,selectedId:n,onLeafAction:o,visible:!0,treeId:i,backstage:t}):LO({directory:e,selectedId:n,onLeafAction:o,expandedIds:r,labelTabstopping:!0,treeId:i,backstage:t})));return{dom:{tag:"div",classes:["tox-tree"],attributes:{role:"tree"}},components:l(a.get(),s.get()),behaviours:ql([Tp.config({mode:"flow",selector:".tox-tree--leaf__label--visible, .tox-tree--directory__label--visible",cycles:!1}),Ip(HO,[Qs("expand-tree-node",((e,t)=>{const{expanded:o,node:r}=t.event;s.set(o?[...s.get(),r]:s.get().filter((e=>e!==r))),n(s.get(),{expanded:o,node:r})}))]),Ql.config({channels:{[`update-active-item-${i}`]:{onReceive:(e,t)=>{a.set(D.some(t.value)),Hp.set(e,l(D.some(t.value),s.get()))}}}}),Hp.config({})])}})(e,t))),panel:wD(((e,t)=>((e,t)=>({dom:{tag:"div",classes:e.classes},components:F(e.items,t.shared.interpreter)}))(e,t)))},CD={field:(e,t)=>t,record:w([])},SD=(e,t,o,n)=>{const r=xn(n,{shared:{interpreter:t=>kD(e,t,o,r)}});return kD(e,t,o,r)},kD=(e,t,o,n)=>ve(xD,t.type).fold((()=>(console.error(`Unknown factory type "${t.type}", defaulting to container: `,t),t)),(r=>r(e,t,o,n))),_D=(e,t,o)=>kD(CD,e,t,o),ED="layout-inset",TD=e=>e.x,OD=(e,t)=>e.x+e.width/2-t.width/2,DD=(e,t)=>e.x+e.width-t.width,AD=e=>e.y,MD=(e,t)=>e.y+e.height-t.height,ND=(e,t)=>e.y+e.height/2-t.height/2,RD=(e,t,o)=>il(DD(e,t),MD(e,t),o.insetSouthwest(),ul(),"southwest",yl(e,{right:0,bottom:3}),ED),BD=(e,t,o)=>il(TD(e),MD(e,t),o.insetSoutheast(),ml(),"southeast",yl(e,{left:1,bottom:3}),ED),LD=(e,t,o)=>il(DD(e,t),AD(e),o.insetNorthwest(),dl(),"northwest",yl(e,{right:0,top:2}),ED),HD=(e,t,o)=>il(TD(e),AD(e),o.insetNortheast(),cl(),"northeast",yl(e,{left:1,top:2}),ED),ID=(e,t,o)=>il(OD(e,t),AD(e),o.insetNorth(),gl(),"north",yl(e,{top:2}),ED),PD=(e,t,o)=>il(OD(e,t),MD(e,t),o.insetSouth(),hl(),"south",yl(e,{bottom:3}),ED),FD=(e,t,o)=>il(DD(e,t),ND(e,t),o.insetEast(),fl(),"east",yl(e,{right:0}),ED),zD=(e,t,o)=>il(TD(e),ND(e,t),o.insetWest(),pl(),"west",yl(e,{left:1}),ED),VD=e=>{switch(e){case"north":return ID;case"northeast":return HD;case"northwest":return LD;case"south":return PD;case"southeast":return BD;case"southwest":return RD;case"east":return FD;case"west":return zD}},ZD=(e,t,o,n,r)=>yc(n).map(VD).getOr(ID)(e,t,o,n,r),UD=e=>{switch(e){case"north":return PD;case"northeast":return BD;case"northwest":return RD;case"south":return ID;case"southeast":return HD;case"southwest":return LD;case"east":return zD;case"west":return FD}},jD=(e,t,o,n,r)=>yc(n).map(UD).getOr(ID)(e,t,o,n,r),WD={valignCentre:[],alignCentre:[],alignLeft:[],alignRight:[],right:[],left:[],bottom:[],top:[]},$D=(e,t,o)=>{const n={maxHeightFunction:Fc()};return()=>o()?{type:"node",root:pt(ht(e())),node:D.from(e()),bubble:Uc(12,12,WD),layouts:{onRtl:()=>[HD],onLtr:()=>[LD]},overrides:n}:{type:"hotspot",hotspot:t(),bubble:Uc(-12,12,WD),layouts:{onRtl:()=>[Tl,Ol,Nl],onLtr:()=>[Ol,Tl,Nl]},overrides:n}},qD=(e,t,o,n)=>{const r={maxHeightFunction:Fc()};return()=>n()?{type:"node",root:pt(ht(t())),node:D.from(t()),bubble:Uc(12,12,WD),layouts:{onRtl:()=>[ID],onLtr:()=>[ID]},overrides:r}:e?{type:"node",root:pt(ht(t())),node:D.from(t()),bubble:Uc(0,-jt(t()),WD),layouts:{onRtl:()=>[Ml],onLtr:()=>[Ml]},overrides:r}:{type:"hotspot",hotspot:o(),bubble:Uc(0,0,WD),layouts:{onRtl:()=>[Ml],onLtr:()=>[Ml]},overrides:r}},GD=(e,t,o)=>()=>o()?{type:"node",root:pt(ht(e())),node:D.from(e()),layouts:{onRtl:()=>[ID],onLtr:()=>[ID]}}:{type:"hotspot",hotspot:t(),layouts:{onRtl:()=>[Nl],onLtr:()=>[Nl]}},KD=(e,t)=>()=>({type:"selection",root:t(),getSelection:()=>{const t=e.selection.getRng(),o=e.model.table.getSelectedCells();if(o.length>1){const e=o[0],t=o[o.length-1],n={firstCell:Le.fromDom(e),lastCell:Le.fromDom(t)};return D.some(n)}return D.some(fd.range(Le.fromDom(t.startContainer),t.startOffset,Le.fromDom(t.endContainer),t.endOffset))}}),YD=e=>t=>({type:"node",root:e(),node:t}),XD=(e,t,o,n)=>{const r=Wb(e),s=()=>Le.fromDom(e.getBody()),a=()=>Le.fromDom(e.getContentAreaContainer()),i=()=>r||!n();return{inlineDialog:$D(a,t,i),inlineBottomDialog:qD(e.inline,a,o,i),banner:GD(a,t,i),cursor:KD(e,s),node:YD(s)}},JD=e=>(t,o)=>{GC(e)(t,o)},QD=e=>()=>RC(e),eA=e=>t=>DC(e,t),tA=e=>t=>NC(e,t),oA=e=>()=>_b(e),nA=e=>ye(e,"items"),rA=e=>ye(e,"format"),sA=[{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",format:"bold"},{title:"Italic",format:"italic"},{title:"Underline",format:"underline"},{title:"Strikethrough",format:"strikethrough"},{title:"Superscript",format:"superscript"},{title:"Subscript",format:"subscript"},{title:"Code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Align",items:[{title:"Left",format:"alignleft"},{title:"Center",format:"aligncenter"},{title:"Right",format:"alignright"},{title:"Justify",format:"alignjustify"}]}],aA=e=>j(e,((e,t)=>{if(be(t,"items")){const o=aA(t.items);return{customFormats:e.customFormats.concat(o.customFormats),formats:e.formats.concat([{title:t.title,items:o.formats}])}}if((e=>be(e,"inline"))(t)||(e=>be(e,"block"))(t)||(e=>be(e,"selector"))(t)){const o=`custom-${s(t.name)?t.name:t.title.toLowerCase()}`;return{customFormats:e.customFormats.concat([{name:o,format:t}]),formats:e.formats.concat([{title:t.title,format:o,icon:t.icon}])}}return{...e,formats:e.formats.concat(t)}}),{customFormats:[],formats:[]}),iA=e=>rb(e).map((t=>{const o=((e,t)=>{const o=aA(t),n=t=>{z(t,(t=>{e.formatter.has(t.name)||e.formatter.register(t.name,t.format)}))};return e.formatter?n(o.customFormats):e.on("init",(()=>{n(o.customFormats)})),o.formats})(e,t);return sb(e)?sA.concat(o):o})).getOr(sA),lA=(e,t,o)=>({...e,type:"formatter",isSelected:t(e.format),getStylePreview:o(e.format)}),cA=(e,t,o,n)=>{const r=t=>F(t,(t=>nA(t)?(e=>{const t=r(e.items);return{...e,type:"submenu",getStyleItems:w(t)}})(t):rA(t)?(e=>lA(e,o,n))(t):(e=>{const t=ae(e);return 1===t.length&&L(t,"title")})(t)?{...t,type:"separator"}:(t=>{const r=s(t.name)?t.name:ya(t.title),a=`custom-${r}`,i={...t,type:"formatter",format:a,isSelected:o(a),getStylePreview:n(a)};return e.formatter.register(r,i),i})(t)));return r(t)},dA=sT.trim,mA=e=>t=>{if((e=>g(e)&&1===e.nodeType)(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},uA=mA("true"),gA=mA("false"),hA=(e,t,o,n,r)=>({type:e,title:t,url:o,level:n,attach:r}),pA=e=>e.innerText||e.textContent,fA=e=>(e=>e&&"A"===e.nodeName&&void 0!==(e.id||e.name))(e)&&bA(e),vA=e=>e&&/^(H[1-6])$/.test(e.nodeName),bA=e=>(e=>{let t=e;for(;t=t.parentNode;){const e=t.contentEditable;if(e&&"inherit"!==e)return uA(t)}return!1})(e)&&!gA(e),yA=e=>vA(e)&&bA(e),wA=e=>{var t;const o=(e=>e.id?e.id:ya("h"))(e);return hA("header",null!==(t=pA(e))&&void 0!==t?t:"","#"+o,(e=>vA(e)?parseInt(e.nodeName.substr(1),10):0)(e),(()=>{e.id=o}))},xA=e=>{const t=e.id||e.name,o=pA(e);return hA("anchor",o||"#"+t,"#"+t,0,v)},CA=e=>{const t=(o="h1,h2,h3,h4,h5,h6,a:not([href])",n=e,F(_d(Le.fromDom(n),o),(e=>e.dom)));var o,n;return t},SA=e=>dA(e.title).length>0,kA=e=>{const t=CA(e);return Z((e=>F(Z(e,yA),wA))(t).concat((e=>F(Z(e,fA),xA))(t)),SA)},_A="tinymce-url-history",EA=e=>s(e)&&/^https?/.test(e),TA=e=>a(e)&&pe(e,(e=>{return!(l(t=e)&&t.length<=5&&K(t,EA));var t})).isNone(),OA=()=>{const e=fC.getItem(_A);if(null===e)return{};let t;try{t=JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return console.log("Local storage "+_A+" was not valid JSON",e),{};throw e}return TA(t)?t:(console.log("Local storage "+_A+" was not valid format",t),{})},DA=e=>{const t=OA();return ve(t,e).getOr([])},AA=(e,t)=>{if(!EA(e))return;const o=OA(),n=ve(o,t).getOr([]),r=Z(n,(t=>t!==e));o[t]=[e].concat(r).slice(0,5),(e=>{if(!TA(e))throw new Error("Bad format for history:\n"+JSON.stringify(e));fC.setItem(_A,JSON.stringify(e))})(o)},MA=e=>!!e,NA=e=>ce(sT.makeMap(e,/[, ]/),MA),RA=e=>D.from(bb(e)),BA=(e,t)=>{const o=(e=>{const t=D.from(xb(e)).filter(MA).map(NA);return RA(e).fold(T,(e=>t.fold(O,(e=>ae(e).length>0&&e))))})(e);return d(o)?o?RA(e):D.none():o[t]?RA(e):D.none()},LA=e=>D.from(e).filter(s).getOrUndefined(),HA=e=>({getHistory:DA,addToHistory:AA,getLinkInformation:()=>(e=>Cb(e)?D.some({targets:kA(e.getBody()),anchorTop:LA(Sb(e)),anchorBottom:LA(kb(e))}):D.none())(e),getValidationHandler:()=>(e=>D.from(yb(e)))(e),getUrlPicker:t=>((e,t)=>BA(e,t).map((o=>n=>wS((r=>{const i={filetype:t,fieldname:n.fieldname,...D.from(n.meta).getOr({})};o.call(e,((e,t)=>{if(!s(e))throw new Error("Expected value to be string");if(void 0!==t&&!a(t))throw new Error("Expected meta to be a object");r({value:e,meta:t})}),n.value,i)})))))(e,t)}),IA=(e,t,o,n)=>{const r=Hr(!1),s=(e=>{const t=Hr(Ub(e)?"bottom":"top");return{isPositionedAtTop:()=>"top"===t.get(),getDockingMode:t.get,setDockingMode:t.set}})(t),a={icons:()=>t.ui.registry.getAll().icons,menuItems:()=>t.ui.registry.getAll().menuItems,translate:Mv.translate,isDisabled:()=>t.mode.isReadOnly()||!t.ui.isEnabled(),getOption:t.options.get},i=HA(t),l=(e=>{const t=t=>()=>e.formatter.match(t),o=t=>()=>{const o=e.formatter.get(t);return void 0!==o?D.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):D.none()},n=Hr([]),r=Hr([]),s=Hr(!1);return e.on("PreInit",(r=>{const s=iA(e),a=cA(e,s,t,o);n.set(a)})),e.on("addStyleModifications",(n=>{const a=cA(e,n.items,t,o);r.set(a),s.set(n.replace)})),{getData:()=>{const e=s.get()?[]:n.get(),t=r.get();return e.concat(t)}}})(t),c=(e=>({colorPicker:JD(e),hasCustomColors:QD(e),getColors:eA(e),getColorCols:tA(e)}))(t),d=(e=>({isDraggableModal:oA(e)}))(t),m={shared:{providers:a,anchors:XD(t,o,n,s.isPositionedAtTop),header:s},urlinput:i,styles:l,colorinput:c,dialog:d,isContextMenuOpen:()=>r.get(),setContextMenuState:e=>r.set(e)},u={...m,shared:{...m.shared,interpreter:e=>_D(e,{},u),getSink:e.popup}},g={...m,shared:{...m.shared,interpreter:e=>_D(e,{},g),getSink:e.dialog}};return{popup:u,dialog:g}},PA=Ku,FA=Nu,zA=w([Tr("shell",!1),dr("makeItem"),Tr("setupItem",v),tu("listBehaviours",[Hp])]),VA=Du({name:"items",overrides:()=>({behaviours:ql([Hp.config({})])})}),ZA=w([VA]),UA=og({name:w("CustomList")(),configFields:zA(),partFields:ZA(),factory:(e,t,o,n)=>{const r=e.shell?{behaviours:[Hp.config({})],components:[]}:{behaviours:[],components:t},s=t=>e.shell?D.some(t):Vu(t,e,"items");return{uid:e.uid,dom:e.dom,components:r.components,behaviours:eu(e.listBehaviours,r.behaviours),apis:{setItems:(t,o)=>{s(t).fold((()=>{throw console.error("Custom List was defined to not be a shell, but no item container was specified in components"),new Error("Custom List was defined to not be a shell, but no item container was specified in components")}),(n=>{const r=Hp.contents(n),s=o.length,a=s-r.length,i=a>0?I(a,(()=>e.makeItem())):[],l=r.slice(s);z(l,(e=>Hp.remove(n,e))),z(i,(e=>Hp.append(n,e)));const c=Hp.contents(n);z(c,((n,r)=>{e.setupItem(t,n,o[r],r)}))}))}}}},apis:{setItems:(e,t,o)=>{e.setItems(t,o)}}}),jA=w([dr("dom"),Tr("shell",!0),Jm("toolbarBehaviours",[Hp])]),WA=w([Du({name:"groups",overrides:()=>({behaviours:ql([Hp.config({})])})})]),$A=og({name:"Toolbar",configFields:jA(),partFields:WA(),factory:(e,t,o,n)=>{const r=t=>e.shell?D.some(t):Vu(t,e,"groups"),s=e.shell?{behaviours:[Hp.config({})],components:[]}:{behaviours:[],components:t};return{uid:e.uid,dom:e.dom,components:s.components,behaviours:eu(e.toolbarBehaviours,s.behaviours),apis:{setGroups:(e,t)=>{r(e).fold((()=>{throw console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")}),(e=>{Hp.set(e,t)}))},refresh:v},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)}}}),qA=v,GA=T,KA=w([]);var YA=Object.freeze({__proto__:null,setup:qA,isDocked:GA,getBehaviours:KA});const XA=e=>(we(Ht(e,"position"),"fixed")?D.none():st(e)).orThunk((()=>{const t=Le.fromTag("span");return nt(e).bind((e=>{Ho(e,t);const o=st(t);return Fo(t),o}))})),JA=e=>XA(e).map(Gt).getOrThunk((()=>$t(0,0))),QA=(e,t)=>{const o=e.element;ti(o,t.transitionClass),ni(o,t.fadeOutClass),ti(o,t.fadeInClass),t.onShow(e)},eM=(e,t)=>{const o=e.element;ti(o,t.transitionClass),ni(o,t.fadeInClass),ti(o,t.fadeOutClass),t.onHide(e)},tM=(e,t)=>e.y>=t.y,oM=(e,t)=>e.bottom<=t.bottom,nM=(e,t,o)=>({location:"top",leftX:t,topY:o.bounds.y-e.y}),rM=(e,t,o)=>({location:"bottom",leftX:t,bottomY:e.bottom-o.bounds.bottom}),sM=e=>e.box.x-e.win.x,aM=(e,t,o)=>o.getInitialPos().map((o=>{const n=((e,t)=>{const o=t.optScrollEnv.fold(w(e.bounds.y),(t=>t.scrollElmTop+(e.bounds.y-t.currentScrollTop)));return $t(e.bounds.x,o)})(o,t);return{box:Go(n.left,n.top,Xt(e),Ut(e)),location:o.location}})),iM=(e,t,o,n,r)=>{const s=((e,t)=>{const o=t.optScrollEnv.fold(w(e.y),(t=>e.y+t.currentScrollTop-t.scrollElmTop));return $t(e.x,o)})(t,o),a=Go(s.left,s.top,t.width,t.height);n.setInitialPos({style:It(e),position:Bt(e,"position")||"static",bounds:a,location:r.location})},lM=(e,t,o)=>o.getInitialPos().bind((n=>{var r;switch(o.clearInitialPos(),n.position){case"static":return D.some({morph:"static"});case"absolute":const o=XA(e).getOr(wt()),s=Ko(o),a=null!==(r=o.dom.scrollTop)&&void 0!==r?r:0;return D.some({morph:"absolute",positionCss:ic("absolute",ve(n.style,"left").map((e=>t.x-s.x)),ve(n.style,"top").map((e=>t.y-s.y+a)),ve(n.style,"right").map((e=>s.right-t.right)),ve(n.style,"bottom").map((e=>s.bottom-t.bottom)))});default:return D.none()}})),cM=(e,t,o)=>aM(e,t,o).filter((({box:e})=>((e,t,o)=>K(e,(e=>{switch(e){case"bottom":return oM(t,o.bounds);case"top":return tM(t,o.bounds)}})))(o.getModes(),e,t))).bind((({box:t})=>lM(e,t,o))),dM=e=>{switch(e.location){case"top":return D.some({morph:"fixed",positionCss:ic("fixed",D.some(e.leftX),D.some(e.topY),D.none(),D.none())});case"bottom":return D.some({morph:"fixed",positionCss:ic("fixed",D.some(e.leftX),D.none(),D.none(),D.some(e.bottomY))});default:return D.none()}},mM=(e,t,o)=>{const n=Ko(e),r=Jo(),s=((e,t,o)=>{const n=t.win,r=t.box,s=sM(t);return se(e,(e=>{switch(e){case"bottom":return oM(r,o.bounds)?D.none():D.some(rM(n,s,o));case"top":return tM(r,o.bounds)?D.none():D.some(nM(n,s,o));default:return D.none()}})).getOr({location:"no-dock"})})(o.getModes(),{win:r,box:n},t);return"top"===s.location||"bottom"===s.location?(iM(e,n,t,o,s),dM(s)):D.none()},uM=(e,t,o)=>{const n=e.element;return we(Ht(n,"position"),"fixed")?((e,t,o)=>cM(e,t,o).orThunk((()=>t.optScrollEnv.bind((n=>aM(e,t,o))).bind((({box:e,location:o})=>{const n=Jo(),r=sM({win:n,box:e}),s="top"===o?nM(n,r,t):rM(n,r,t);return dM(s)})))))(n,t,o):mM(n,t,o)},gM=(e,t,o,n)=>{const r=Ko(e),s=Jo(),a=n(s,sM({win:s,box:r}),t);return"bottom"===a.location||"top"===a.location?(((e,t,o,n,r)=>{n.getInitialPos().fold((()=>iM(e,t,o,n,r)),(()=>v))})(e,r,t,o,a),dM(a)):D.none()},hM=(e,t,o)=>{o.setDocked(!1),z(["left","right","top","bottom","position"],(t=>Ft(e.element,t))),t.onUndocked(e)},pM=(e,t,o,n)=>{const r="fixed"===n.position;o.setDocked(r),lc(e.element,n);(r?t.onDocked:t.onUndocked)(e)},fM=(e,t,o,n,r=!1)=>{t.contextual.each((t=>{t.lazyContext(e).each((s=>{const a=((e,t)=>e.yt.y)(s,n.bounds);if(a!==o.isVisible())if(o.setVisible(a),r&&!a)ai(e.element,[t.fadeOutClass]),t.onHide(e);else{(a?QA:eM)(e,t)}}))}))},vM=(e,t,o,n,r)=>{fM(e,t,o,n,!0),pM(e,t,o,r.positionCss)},bM=(e,t,o)=>{const n=t.lazyViewport(e);fM(e,t,o,n),uM(e,n,o).each((r=>{((e,t,o,n,r)=>{switch(r.morph){case"static":return hM(e,t,o);case"absolute":return pM(e,t,o,r.positionCss);case"fixed":vM(e,t,o,n,r)}})(e,t,o,n,r)}))},yM=(e,t,o)=>{const n=e.element;o.setDocked(!1);const r=t.lazyViewport(e);((e,t,o)=>{const n=e.element;return aM(n,t,o).bind((({box:e})=>lM(n,e,o)))})(e,r,o).each((n=>{switch(n.morph){case"static":hM(e,t,o);break;case"absolute":pM(e,t,o,n.positionCss)}})),o.setVisible(!0),t.contextual.each((t=>{ii(n,[t.fadeInClass,t.fadeOutClass,t.transitionClass]),t.onShow(e)})),wM(e,t,o)},wM=(e,t,o)=>{e.getSystem().isConnected()&&bM(e,t,o)},xM=(e,t,o)=>{o.isDocked()&&yM(e,t,o)},CM=e=>(t,o,n)=>{const r=o.lazyViewport(t);gM(t.element,r,n,e).each((e=>{vM(t,o,n,r,e)}))},SM=CM(nM),kM=CM(rM);var _M=Object.freeze({__proto__:null,refresh:wM,reset:xM,isDocked:(e,t,o)=>o.isDocked(),getModes:(e,t,o)=>o.getModes(),setModes:(e,t,o,n)=>o.setModes(n),forceDockToTop:SM,forceDockToBottom:kM});var EM=Object.freeze({__proto__:null,events:(e,t)=>Ys([aa(gs(),((o,n)=>{e.contextual.each((e=>{if(si(o.element,e.transitionClass)){ii(o.element,[e.transitionClass,e.fadeInClass]);(t.isVisible()?e.onShown:e.onHidden)(o)}n.stop()}))})),Qs(Ms(),((o,n)=>{wM(o,e,t)})),Qs(Fs(),((o,n)=>{wM(o,e,t)})),Qs(Ns(),((o,n)=>{xM(o,e,t)}))])}),TM=[Er("contextual",[gr("fadeInClass"),gr("fadeOutClass"),gr("transitionClass"),pr("lazyContext"),el("onShow"),el("onShown"),el("onHide"),el("onHidden")]),Rr("lazyViewport",(()=>({bounds:Jo(),optScrollEnv:D.none()}))),Br("modes",["top","bottom"],$n),el("onDocked"),el("onUndocked")];const OM=Kl({fields:TM,name:"docking",active:EM,apis:_M,state:Object.freeze({__proto__:null,init:e=>{const t=Hr(!1),o=Hr(!0),n=kc(),r=Hr(e.modes);return Ia({isDocked:t.get,setDocked:t.set,getInitialPos:n.get,setInitialPos:n.set,clearInitialPos:n.clear,isVisible:o.get,setVisible:o.set,getModes:r.get,setModes:r.set,readState:()=>`docked: ${t.get()}, visible: ${o.get()}, modes: ${r.get().join(",")}`})}})}),DM=w(ya("toolbar-height-change")),AM={fadeInClass:"tox-editor-dock-fadein",fadeOutClass:"tox-editor-dock-fadeout",transitionClass:"tox-editor-dock-transition"},MM="tox-tinymce--toolbar-sticky-on",NM="tox-tinymce--toolbar-sticky-off",RM=(e,t)=>L(OM.getModes(e),t),BM=e=>{const t=e.element;rt(t).each((o=>{const n="padding-"+OM.getModes(e)[0];if(OM.isDocked(e)){const e=Xt(o);Mt(t,"width",e+"px"),Mt(o,n,(e=>jt(e)+(parseInt(Bt(e,"margin-top"),10)||0)+(parseInt(Bt(e,"margin-bottom"),10)||0))(t)+"px")}else Ft(t,"width"),Ft(o,n)}))},LM=(e,t)=>{t?(ni(e,AM.fadeOutClass),ai(e,[AM.transitionClass,AM.fadeInClass])):(ni(e,AM.fadeInClass),ai(e,[AM.fadeOutClass,AM.transitionClass]))},HM=(e,t)=>{const o=Le.fromDom(e.getContainer());t?(ti(o,MM),ni(o,NM)):(ti(o,NM),ni(o,MM))},IM=(e,t)=>{const o=kc(),n=t.getSink,r=e=>{n().each((t=>e(t.element)))},s=t=>{e.inline||BM(t),HM(e,OM.isDocked(t)),t.getSystem().broadcastOn([Rm()],{}),n().each((e=>e.getSystem().broadcastOn([Rm()],{})))},a=e.inline?[]:[Ql.config({channels:{[DM()]:{onReceive:BM}}})];return[Zp.config({}),OM.config({contextual:{lazyContext:t=>{const o=jt(t.element),n=e.inline?e.getContentAreaContainer():e.getContainer();return D.from(n).map((n=>{const r=Ko(Le.fromDom(n));return XS(e,t.element).fold((()=>{const e=r.height-o,n=r.y+(RM(t,"top")?0:o);return Go(r.x,n,r.width,e)}),(e=>{const n=Xo(r,JS(e)),s=RM(t,"top")?n.y:n.y+o;return Go(n.x,s,n.width,n.height-o)}))}))},onShow:()=>{r((e=>LM(e,!0)))},onShown:e=>{r((e=>ii(e,[AM.transitionClass,AM.fadeInClass]))),o.get().each((t=>{((e,t)=>{const o=Qe(t);rc(o).filter((e=>!Xe(t,e))).filter((t=>Xe(t,Le.fromDom(o.dom.body))||Je(e,t))).each((()=>tc(t)))})(e.element,t),o.clear()}))},onHide:e=>{((e,t)=>sc(e).orThunk((()=>t().toOptional().bind((e=>sc(e.element))))))(e.element,n).fold(o.clear,o.set),r((e=>LM(e,!1)))},onHidden:()=>{r((e=>ii(e,[AM.transitionClass])))},...AM},lazyViewport:t=>XS(e,t.element).fold((()=>{const o=Jo(),n=pb(e),r=o.y+(RM(t,"top")?n:0),s=o.height-(RM(t,"bottom")?n:0);return{bounds:Go(o.x,r,o.width,s),optScrollEnv:D.none()}}),(e=>({bounds:JS(e),optScrollEnv:D.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))),modes:[t.header.getDockingMode()],onDocked:s,onUndocked:s}),...a]};var PM=Object.freeze({__proto__:null,setup:(e,t,o)=>{e.inline||(t.header.isPositionedAtTop()||e.on("ResizeEditor",(()=>{o().each(OM.reset)})),e.on("ResizeWindow ResizeEditor",(()=>{o().each(BM)})),e.on("SkinLoaded",(()=>{o().each((e=>{OM.isDocked(e)?OM.reset(e):OM.refresh(e)}))})),e.on("FullscreenStateChanged",(()=>{o().each(OM.reset)}))),e.on("AfterScrollIntoView",(e=>{o().each((t=>{OM.refresh(t);const o=t.element;wh(o)&&((e,t)=>{const o=Qe(t),n=ot(t).dom.innerHeight,r=zo(o),s=Le.fromDom(e.elm),a=Yo(s),i=Ut(s),l=a.y,c=l+i,d=Gt(t),m=Ut(t),u=d.top,g=u+m,h=Math.abs(u-r.top)<2,p=Math.abs(g-(r.top+n))<2;if(h&&lu){const e=l-n+i+m;Vo(r.left,e,o)}})(e,o)}))})),e.on("PostRender",(()=>{HM(e,!1)}))},isDocked:e=>e().map(OM.isDocked).getOr(!1),getBehaviours:IM});const FM=Pn([Uy,mr("items",zn([Zn([jy,br("items",$n)]),$n]))].concat(yw)),zM=[Cr("text"),Cr("tooltip"),Cr("icon"),Or("search",!1,zn([qn,Pn([Cr("placeholder")])],(e=>d(e)?e?D.some({placeholder:D.none()}):D.none():D.some(e)))),pr("fetch"),Rr("onSetup",(()=>v))],VM=Pn([Uy,...zM]),ZM=e=>tr("menubutton",VM,e),UM=Pn([Uy,rw,nw,ow,iw,Yy,ew,Mr("presets","normal",["normal","color","listpreview"]),uw(1),Jy,Qy]);var jM=tg({factory:(e,t)=>{const o={focus:Tp.focusIn,setMenus:(e,o)=>{const n=F(o,(e=>{const o={type:"menubutton",text:e.text,fetch:t=>{t(e.getItems())}},n=ZM(o).mapError((e=>rr(e))).getOrDie();return _O(n,"tox-mbtn",t.backstage,D.some("menuitem"))}));Hp.set(e,n)}};return{uid:e.uid,dom:e.dom,components:[],behaviours:ql([Hp.config({}),Ip("menubar-events",[ia((t=>{e.onSetup(t)})),Qs(rs(),((e,t)=>{Bi(e.element,".tox-mbtn--active").each((o=>{Li(t.event.target,".tox-mbtn").each((t=>{Xe(o,t)||e.getSystem().getByDom(o).each((o=>{e.getSystem().getByDom(t).each((e=>{HS.expand(e),HS.close(o),Zp.focus(e)}))}))}))}))})),Qs(Is(),((e,t)=>{t.event.prevFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((o=>{t.event.newFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((e=>{HS.isOpen(o)&&(HS.expand(e),HS.close(o))}))}))}))]),Tp.config({mode:"flow",selector:".tox-mbtn",onEscape:t=>(e.onEscape(t),D.some(!0))}),yk.config({})]),apis:o,domModification:{attributes:{role:"menubar"}}}},name:"silver.Menubar",configFields:[dr("dom"),dr("uid"),dr("onEscape"),dr("backstage"),Tr("onSetup",v)],apis:{focus:(e,t)=>{e.focus(t)},setMenus:(e,t,o)=>{e.setMenus(t,o)}}});const WM="container",$M=[Jm("slotBehaviours",[])],qM=e=>"",GM=(e,t)=>{const o=t=>Wu(e),n=(t,o)=>(n,r)=>Vu(n,e,r).map((e=>t(e,r))).getOr(o),r=(e,t)=>"true"!==_t(e.element,"aria-hidden"),s=n(r,!1),a=n(((e,t)=>{if(r(e)){const o=e.element;Mt(o,"display","none"),St(o,"aria-hidden","true"),Ws(e,Ps(),{name:t,visible:!1})}})),i=(e=>(t,o)=>{z(o,(o=>e(t,o)))})(a),l=n(((e,t)=>{if(!r(e)){const o=e.element;Ft(o,"display"),Ot(o,"aria-hidden"),Ws(e,Ps(),{name:t,visible:!0})}})),c={getSlotNames:o,getSlot:(t,o)=>Vu(t,e,o),isShowing:s,hideSlot:a,hideAllSlots:e=>i(e,o()),showSlot:l};return{uid:e.uid,dom:e.dom,components:t,behaviours:Qm(e.slotBehaviours),apis:c}},KM=ce({getSlotNames:(e,t)=>e.getSlotNames(t),getSlot:(e,t,o)=>e.getSlot(t,o),isShowing:(e,t,o)=>e.isShowing(t,o),hideSlot:(e,t,o)=>e.hideSlot(t,o),hideAllSlots:(e,t)=>e.hideAllSlots(t),showSlot:(e,t,o)=>e.showSlot(t,o)},(e=>La(e))),YM={...KM,sketch:e=>{const t=(()=>{const e=[];return{slot:(t,o)=>(e.push(t),Hu(WM,qM(t),o)),record:w(e)}})(),o=e(t),n=t.record(),r=F(n,(e=>Tu({name:e,pname:qM(e)})));return Xu(WM,$M,r,GM,o)}},XM=Pn([nw,rw,Rr("onShow",v),Rr("onHide",v),ew]),JM=e=>({element:()=>e.element.dom}),QM=(e,t)=>{const o=F(ae(t),(e=>{const o=t[e],n=or((e=>tr("sidebar",XM,e))(o));return{name:e,getApi:JM,onSetup:n.onSetup,onShow:n.onShow,onHide:n.onHide}}));return F(o,(t=>{const n=Hr(v);return e.slot(t.name,{dom:{tag:"div",classes:["tox-sidebar__pane"]},behaviours:Jw([yx(t,n),wx(t,n),Qs(Ps(),((e,t)=>{const n=t.event,r=W(o,(e=>e.name===n.name));r.each((t=>{(n.visible?t.onShow:t.onHide)(t.getApi(e))}))}))])})}))},eN=e=>YM.sketch((t=>({dom:{tag:"div",classes:["tox-sidebar__pane-container"]},components:QM(t,e),slotBehaviours:Jw([ia((e=>YM.hideAllSlots(e)))])}))),tN=(e,t)=>{St(e,"role",t)},oN=e=>ag.getCurrent(e).bind((e=>{if(SO.isGrowing(e)||SO.hasGrown(e)){return ag.getCurrent(e).bind((e=>W(YM.getSlotNames(e),(t=>YM.isShowing(e,t)))))}return D.none()})),nN=ya("FixSizeEvent"),rN=ya("AutoSizeEvent");var sN=Object.freeze({__proto__:null,block:(e,t,o,n)=>{St(e.element,"aria-busy",!0);const r=t.getRoot(e).getOr(e),s=ql([Tp.config({mode:"special",onTab:()=>D.some(!0),onShiftTab:()=>D.some(!0)}),Zp.config({})]),a=n(r,s),i=r.getSystem().build(a);Hp.append(r,Ti(i)),i.hasConfigured(Tp)&&t.focus&&Tp.focusIn(i),o.isBlocked()||t.onBlock(e),o.blockWith((()=>Hp.remove(r,i)))},unblock:(e,t,o)=>{Ot(e.element,"aria-busy"),o.isBlocked()&&t.onUnblock(e),o.clear()},isBlocked:(e,t,o)=>o.isBlocked()}),aN=[Rr("getRoot",D.none),Nr("focus",!0),el("onBlock"),el("onUnblock")];const iN=Kl({fields:aN,name:"blocking",apis:sN,state:Object.freeze({__proto__:null,init:()=>{const e=Cc((e=>e.destroy()));return Ia({readState:e.isSet,blockWith:t=>{e.set({destroy:t})},clear:e.clear,isBlocked:e.isSet})}})}),lN=e=>ag.getCurrent(e).each((e=>tc(e.element,!0))),cN=(e,t,o,n)=>{const r=t.element;if(((e,t)=>{const o="tabindex",n=`data-mce-${o}`;D.from(e.iframeElement).map(Le.fromDom).each((e=>{t?(Et(e,o).each((t=>St(e,n,t))),St(e,o,-1)):(Ot(e,o),Et(e,n).each((t=>{St(e,o,t),Ot(e,n)})))}))})(e,o),o)iN.block(t,(e=>(t,o)=>({dom:{tag:"div",attributes:{"aria-label":e.translate("Loading..."),tabindex:"0"},classes:["tox-throbber__busy-spinner"]},components:[{dom:Rf('
    ')}]}))(n)),Ft(r,"display"),Ot(r,"aria-hidden"),e.hasFocus()&&lN(t);else{const o=ag.getCurrent(t).exists((e=>nc(e.element)));iN.unblock(t),Mt(r,"display","none"),St(r,"aria-hidden","true"),o&&e.focus()}},dN=(e,t,o)=>{const n=Hr(!1),r=kc(),s=o=>{n.get()&&!(e=>{if((e=>"focusin"===e.type)(e))return(e.composed?oe(e.composedPath()):D.from(e.target)).map(Le.fromDom).filter(je).exists((e=>si(e,"mce-pastebin")));return!1})(o)&&(o.preventDefault(),lN(t()),e.editorManager.setActive(e))};e.inline||e.on("PreInit",(()=>{e.dom.bind(e.getWin(),"focusin",s),e.on("BeforeExecCommand",(e=>{"mcefocus"===e.command.toLowerCase()&&!0!==e.value&&s(e)}))}));const a=r=>{r!==n.get()&&(n.set(r),cN(e,t(),r,o.providers),((e,t)=>{e.dispatch("AfterProgressState",{state:t})})(e,r))};e.on("ProgressState",(t=>{if(r.on(clearTimeout),p(t.time)){const o=Mf.setEditorTimeout(e,(()=>a(t.state)),t.time);r.set(o)}else a(t.state),r.clear()}))},mN=(e,t,o)=>({within:e,extra:t,withinWidth:o}),uN=(e,t,o)=>{const n=((e,t)=>{const o=j(e,((e,o)=>t(o,e.len).fold(w(e),(t=>({len:t.finish,list:e.list.concat([t])})))),{len:0,list:[]});return o.list})(e,((e,t)=>{const n=o(e);return D.some({element:e,start:t,finish:t+n,width:n})})),r=Z(n,(e=>e.finish<=t)),s=U(r,((e,t)=>e+t.width),0);return{within:r,extra:n.slice(r.length),withinWidth:s}},gN=e=>F(e,(e=>e.element)),hN=(e,t,o,n)=>{const r=((e,t,o)=>{const n=uN(t,e,o);return 0===n.extra.length?D.some(n):D.none()})(e,t,o).getOrThunk((()=>uN(t,e-o(n),o))),s=r.within,a=r.extra,i=r.withinWidth;return 1===a.length&&a[0].width<=o(n)?((e,t,o)=>{const n=gN(e.concat(t));return mN(n,[],o)})(s,a,i):a.length>=1?((e,t,o,n)=>{const r=gN(e).concat([o]);return mN(r,gN(t),n)})(s,a,n,i):((e,t,o)=>mN(gN(e),[],o))(s,0,i)},pN=(e,t)=>{const o=F(t,(e=>Ti(e)));$A.setGroups(e,o)},fN=(e,t,o)=>{const n=t.builtGroups.get();if(0===n.length)return;const r=Zu(e,t,"primary"),s=pS.getCoupled(e,"overflowGroup");Mt(r.element,"visibility","hidden");const a=n.concat([s]),i=se(a,(e=>sc(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()))));o([]),pN(r,a);const l=Xt(r.element),c=hN(l,t.builtGroups.get(),(e=>Xt(e.element)),s);0===c.extra.length?(Hp.remove(r,s),o([])):(pN(r,c.within),o(c.extra)),Ft(r.element,"visibility"),zt(r.element),i.each(Zp.focus)},vN=w([Jm("splitToolbarBehaviours",[pS]),lr("builtGroups",(()=>Hr([])))]),bN=w([Ji(["overflowToggledClass"]),kr("getOverflowBounds"),dr("lazySink"),lr("overflowGroups",(()=>Hr([]))),el("onOpened"),el("onClosed")].concat(vN())),yN=w([Tu({factory:$A,schema:jA(),name:"primary"}),Ou({schema:jA(),name:"overflow"}),Ou({name:"overflow-button"}),Ou({name:"overflow-group"})]),wN=w(((e,t)=>{((e,t)=>{const o=Yt.max(e,t,["margin-left","border-left-width","padding-left","padding-right","border-right-width","margin-right"]);Mt(e,"max-width",o+"px")})(e,Math.floor(t))})),xN=w([Ji(["toggledClass"]),dr("lazySink"),pr("fetch"),kr("getBounds"),Er("fireDismissalEventInstead",[Tr("event",Ls())]),Xc(),el("onToggled")]),CN=w([Ou({name:"button",overrides:e=>({dom:{attributes:{"aria-haspopup":"true"}},buttonBehaviours:ql([Yp.config({toggleClass:e.markers.toggledClass,aria:{mode:"expanded"},toggleOnExecute:!1,onToggled:e.onToggled})])})}),Ou({factory:$A,schema:jA(),name:"toolbar",overrides:e=>({toolbarBehaviours:ql([Tp.config({mode:"cyclic",onEscape:t=>(Vu(t,e,"button").each(Zp.focus),D.none())})])})})]),SN=kc(),kN=(e,t)=>{const o=pS.getCoupled(e,"toolbarSandbox");Mm.isOpen(o)?Mm.close(o):Mm.open(o,t.toolbar())},_N=(e,t,o,n)=>{const r=o.getBounds.map((e=>e())),s=o.lazySink(e).getOrDie();rm.positionWithinBounds(s,t,{anchor:{type:"hotspot",hotspot:e,layouts:n,overrides:{maxWidthFunction:wN()}}},r)},EN=(e,t,o,n,r)=>{$A.setGroups(t,r),_N(e,t,o,n),Yp.on(e)},TN=og({name:"FloatingToolbarButton",factory:(e,t,o,n)=>({...Nf.sketch({...n.button(),action:e=>{kN(e,n)},buttonBehaviours:ou({dump:n.button().buttonBehaviours},[pS.config({others:{toolbarSandbox:t=>((e,t,o)=>{const n=Ii();return{dom:{tag:"div",attributes:{id:n.id}},behaviours:ql([Tp.config({mode:"special",onEscape:e=>(Mm.close(e),D.some(!0))}),Mm.config({onOpen:(r,s)=>{const a=SN.get().getOr(!1);o.fetch().get((r=>{EN(e,s,o,t.layouts,r),n.link(e.element),a||Tp.focusIn(s)}))},onClose:()=>{Yp.off(e),SN.get().getOr(!1)||Zp.focus(e),n.unlink(e.element)},isPartOf:(t,o,n)=>Fi(o,n)||Fi(e,n),getAttachPoint:()=>o.lazySink(e).getOrDie()}),Ql.config({channels:{...Hm({isExtraPart:T,...o.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Pm({doReposition:()=>{Mm.getState(pS.getCoupled(e,"toolbarSandbox")).each((n=>{_N(e,n,o,t.layouts)}))}})}})])}})(t,o,e)}})])}),apis:{setGroups:(t,n)=>{Mm.getState(pS.getCoupled(t,"toolbarSandbox")).each((r=>{EN(t,r,e,o.layouts,n)}))},reposition:t=>{Mm.getState(pS.getCoupled(t,"toolbarSandbox")).each((n=>{_N(t,n,e,o.layouts)}))},toggle:e=>{kN(e,n)},toggleWithoutFocusing:e=>{((e,t)=>{SN.set(!0),kN(e,t),SN.clear()})(e,n)},getToolbar:e=>Mm.getState(pS.getCoupled(e,"toolbarSandbox")),isOpen:e=>Mm.isOpen(pS.getCoupled(e,"toolbarSandbox"))}}),configFields:xN(),partFields:CN(),apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},toggleWithoutFocusing:(e,t)=>{e.toggleWithoutFocusing(t)},getToolbar:(e,t)=>e.getToolbar(t),isOpen:(e,t)=>e.isOpen(t)}}),ON=w([dr("items"),Ji(["itemSelector"]),Jm("tgroupBehaviours",[Tp])]),DN=w([Au({name:"items",unit:"item"})]),AN=og({name:"ToolbarGroup",configFields:ON(),partFields:DN(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.tgroupBehaviours,[Tp.config({mode:"flow",selector:e.markers.itemSelector})]),domModification:{attributes:{role:"toolbar"}}})}),MN=e=>F(e,(e=>Ti(e))),NN=(e,t,o)=>{fN(e,o,(n=>{o.overflowGroups.set(n),t.getOpt(e).each((e=>{TN.setGroups(e,MN(n))}))}))},RN=og({name:"SplitFloatingToolbar",configFields:bN(),partFields:yN(),factory:(e,t,o,n)=>{const r=Bf(TN.sketch({fetch:()=>wS((t=>{t(MN(e.overflowGroups.get()))})),layouts:{onLtr:()=>[Ol,Tl],onRtl:()=>[Tl,Ol],onBottomLtr:()=>[Al,Dl],onBottomRtl:()=>[Dl,Al]},getBounds:o.getOverflowBounds,lazySink:e.lazySink,fireDismissalEventInstead:{},markers:{toggledClass:e.markers.overflowToggledClass},parts:{button:n["overflow-button"](),toolbar:n.overflow()},onToggled:(t,o)=>e[o?"onOpened":"onClosed"](t)}));return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.splitToolbarBehaviours,[pS.config({others:{overflowGroup:()=>AN.sketch({...n["overflow-group"](),items:[r.asSpec()]})}})]),apis:{setGroups:(t,o)=>{e.builtGroups.set(F(o,t.getSystem().build)),NN(t,r,e)},refresh:t=>NN(t,r,e),toggle:e=>{r.getOpt(e).each((e=>{TN.toggle(e)}))},toggleWithoutFocusing:e=>{r.getOpt(e).each(TN.toggleWithoutFocusing)},isOpen:e=>r.getOpt(e).map(TN.isOpen).getOr(!1),reposition:e=>{r.getOpt(e).each((e=>{TN.reposition(e)}))},getOverflow:e=>r.getOpt(e).bind(TN.getToolbar)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},toggleWithoutFocusing:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t),getOverflow:(e,t)=>e.getOverflow(t)}}),BN=w([Ji(["closedClass","openClass","shrinkingClass","growingClass","overflowToggledClass"]),el("onOpened"),el("onClosed")].concat(vN())),LN=w([Tu({factory:$A,schema:jA(),name:"primary"}),Tu({factory:$A,schema:jA(),name:"overflow",overrides:e=>({toolbarBehaviours:ql([SO.config({dimension:{property:"height"},closedClass:e.markers.closedClass,openClass:e.markers.openClass,shrinkingClass:e.markers.shrinkingClass,growingClass:e.markers.growingClass,onShrunk:t=>{Vu(t,e,"overflow-button").each((e=>{Yp.off(e),Zp.focus(e)})),e.onClosed(t)},onGrown:t=>{Tp.focusIn(t),e.onOpened(t)},onStartGrow:t=>{Vu(t,e,"overflow-button").each(Yp.on)}}),Tp.config({mode:"acyclic",onEscape:t=>(Vu(t,e,"overflow-button").each(Zp.focus),D.some(!0))})])})}),Ou({name:"overflow-button",overrides:e=>({buttonBehaviours:ql([Yp.config({toggleClass:e.markers.overflowToggledClass,aria:{mode:"pressed"},toggleOnExecute:!1})])})}),Ou({name:"overflow-group"})]),HN=(e,t)=>{Vu(e,t,"overflow-button").bind((()=>Vu(e,t,"overflow"))).each((o=>{IN(e,t),SO.toggleGrow(o)}))},IN=(e,t)=>{Vu(e,t,"overflow").each((o=>{fN(e,t,(e=>{const t=F(e,(e=>Ti(e)));$A.setGroups(o,t)})),Vu(e,t,"overflow-button").each((e=>{SO.hasGrown(o)&&Yp.on(e)})),SO.refresh(o)}))},PN=og({name:"SplitSlidingToolbar",configFields:BN(),partFields:LN(),factory:(e,t,o,n)=>{const r="alloy.toolbar.toggle";return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.splitToolbarBehaviours,[pS.config({others:{overflowGroup:e=>AN.sketch({...n["overflow-group"](),items:[Nf.sketch({...n["overflow-button"](),action:t=>{js(e,r)}})]})}}),Ip("toolbar-toggle-events",[Qs(r,(t=>{HN(t,e)}))])]),apis:{setGroups:(t,o)=>{((t,o)=>{const n=F(o,t.getSystem().build);e.builtGroups.set(n)})(t,o),IN(t,e)},refresh:t=>IN(t,e),toggle:t=>HN(t,e),isOpen:t=>((e,t)=>Vu(e,t,"overflow").map(SO.hasGrown).getOr(!1))(t,e)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},toggle:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t)}}),FN=e=>{const t=e.title.fold((()=>({})),(e=>({attributes:{title:e}})));return{dom:{tag:"div",classes:["tox-toolbar__group"],...t},components:[AN.parts.items({})],items:e.items,markers:{itemSelector:"*:not(.tox-split-button) > .tox-tbtn:not([disabled]), .tox-split-button:not([disabled]), .tox-toolbar-nav-js:not([disabled]), .tox-number-input:not([disabled])"},tgroupBehaviours:ql([yk.config({}),Zp.config({})])}},zN=e=>AN.sketch(FN(e)),VN=(e,t)=>{const o=ia((t=>{const o=F(e.initGroups,zN);$A.setGroups(t,o)}));return ql([vx(e.providers.isDisabled),gx(),Tp.config({mode:t,onEscape:e.onEscape,selector:".tox-toolbar__group"}),Ip("toolbar-events",[o])])},ZN=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return{uid:e.uid,dom:{tag:"div",classes:["tox-toolbar-overlord"]},parts:{"overflow-group":FN({title:D.none(),items:[]}),"overflow-button":eD({name:"more",icon:D.some("more-drawer"),enabled:!0,tooltip:D.some("Reveal or hide additional toolbar items"),primary:!1,buttonType:D.none(),borderless:!1},D.none(),e.providers)},splitToolbarBehaviours:VN(e,t)}},UN=e=>{const t=ZN(e),o=RN.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}});return RN.sketch({...t,lazySink:e.getSink,getOverflowBounds:()=>{const t=e.moreDrawerData.lazyHeader().element,o=Yo(t),n=tt(t),r=Yo(n),s=Math.max(n.dom.scrollHeight,r.height);return Go(o.x+4,r.y,o.width-8,s)},parts:{...t.parts,overflow:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:e.attributes}}},components:[o],markers:{overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>e.onToggled(t,!0),onClosed:t=>e.onToggled(t,!1)})},jN=e=>{const t=PN.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}}),o=PN.parts.overflow({dom:{tag:"div",classes:["tox-toolbar__overflow"]}}),n=ZN(e);return PN.sketch({...n,components:[t,o],markers:{openClass:"tox-toolbar__overflow--open",closedClass:"tox-toolbar__overflow--closed",growingClass:"tox-toolbar__overflow--growing",shrinkingClass:"tox-toolbar__overflow--shrinking",overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>{t.getSystem().broadcastOn([DM()],{type:"opened"}),e.onToggled(t,!0)},onClosed:t=>{t.getSystem().broadcastOn([DM()],{type:"closed"}),e.onToggled(t,!1)}})},WN=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return $A.sketch({uid:e.uid,dom:{tag:"div",classes:["tox-toolbar"].concat(e.type===Uv.scrolling?["tox-toolbar--scrolling"]:[])},components:[$A.parts.groups({})],toolbarBehaviours:VN(e,t)})},$N=[ow,nw,Cr("tooltip"),Mr("buttonType","secondary",["primary","secondary"]),Nr("borderless",!1),pr("onAction")],qN={button:[...$N,$y,hr("type",["button"])],togglebutton:[...$N,Nr("active",!1),hr("type",["togglebutton"])]},GN=[hr("type",["group"]),Br("buttons",[],sr("type",qN))],KN=sr("type",{...qN,group:GN}),YN=Pn([Br("buttons",[],KN),pr("onShow"),pr("onHide")]),XN=(e,t)=>((e,t)=>{var o,n;const r="togglebutton"===e.type,s=e.icon.map((e=>PT(e,t.icons))).map(Bf),a=o=>{const n=e=>{s.map((n=>n.getOpt(o).each((o=>{Hp.set(o,[PT(e,t.icons)])}))))},a=e=>{const t=o.element;e?(ti(t,"tox-button--enabled"),St(t,"aria-pressed",!0)):(ni(t,"tox-button--enabled"),Ot(t,"aria-pressed"))},i=()=>si(o.element,"tox-button--enabled");return r?e.onAction({setIcon:n,setActive:a,isActive:i}):"button"===e.type?e.onAction({setIcon:n}):void 0},i={...e,name:r?e.text.getOr(e.icon.getOr("")):null!==(o=e.text)&&void 0!==o?o:e.icon.getOr(""),primary:"primary"===e.buttonType,buttonType:D.from(e.buttonType),tooltip:e.tooltip,icon:e.icon,enabled:!0,borderless:e.borderless},l=tD(null!==(n=e.buttonType)&&void 0!==n?n:"secondary"),c=r?e.text.map(t.translate):D.some(t.translate(e.text)),d=c.map(Ci),m=i.tooltip.or(c).map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),u=s.map((e=>e.asSpec())),g=Sx([u,d]),h=e.icon.isSome()&&d.isSome(),p={tag:"button",classes:l.concat(...e.icon.isSome()&&!h?["tox-button--icon"]:[]).concat(...h?["tox-button--icon-and-text"]:[]).concat(...e.borderless?["tox-button--naked"]:[]).concat(..."togglebutton"===e.type&&e.active?["tox-button--enabled"]:[]),attributes:m},f=QO(i,D.some(a),[],p,g,t);return Nf.sketch(f)})(e,t),JN=Do().deviceType,QN=JN.isPhone(),eR=JN.isTablet();var tR=og({name:"silver.View",configFields:[dr("viewConfig")],partFields:[Du({factory:{sketch:e=>{let t=!1;const o=F(e.buttons,(o=>"group"===o.type?(t=!0,((e,t)=>({dom:{tag:"div",classes:["tox-view__toolbar__group"]},components:F(e.buttons,(e=>XN(e,t)))}))(o,e.providers)):XN(o,e.providers)));return{uid:e.uid,dom:{tag:"div",classes:[t?"tox-view__toolbar":"tox-view__header",...QN||eR?["tox-view--mobile","tox-view--scrolling"]:[]]},behaviours:ql([Zp.config({}),Tp.config({mode:"flow",selector:"button, .tox-button",focusInside:eh.OnEnterOrSpaceMode})]),components:t?o:[uk.sketch({dom:{tag:"div",classes:["tox-view__header-start"]},components:[]}),uk.sketch({dom:{tag:"div",classes:["tox-view__header-end"]},components:o})]}}},schema:[dr("buttons"),dr("providers")],name:"header"}),Du({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-view__pane"]}})},schema:[],name:"pane"})],factory:(e,t,o,n)=>{const r={getPane:t=>PA.getPart(t,e,"pane"),getOnShow:t=>e.viewConfig.onShow,getOnHide:t=>e.viewConfig.onHide};return{uid:e.uid,dom:e.dom,components:t,apis:r}},apis:{getPane:(e,t)=>e.getPane(t),getOnShow:(e,t)=>e.getOnShow(t),getOnHide:(e,t)=>e.getOnHide(t)}});const oR=(e,t,o)=>he(t,((t,n)=>{const r=or(tr("view",YN,t));return e.slot(n,tR.sketch({dom:{tag:"div",classes:["tox-view"]},viewConfig:r,components:[...r.buttons.length>0?[tR.parts.header({buttons:r.buttons,providers:o})]:[],tR.parts.pane({})]}))})),nR=(e,t)=>YM.sketch((o=>({dom:{tag:"div",classes:["tox-view-wrap__slot-container"]},components:oR(o,e,t),slotBehaviours:Jw([ia((e=>YM.hideAllSlots(e)))])}))),rR=e=>W(YM.getSlotNames(e),(t=>YM.isShowing(e,t))),sR=(e,t,o)=>{YM.getSlot(e,t).each((e=>{tR.getPane(e).each((t=>{var n;o(e)((n=t.element.dom,{getContainer:w(n)}))}))}))};var aR=tg({factory:(e,t)=>{const o={setViews:(e,o)=>{Hp.set(e,[nR(o,t.backstage.shared.providers)])},whichView:e=>ag.getCurrent(e).bind(rR),toggleView:(e,t,o,n)=>ag.getCurrent(e).exists((r=>{const s=rR(r),a=s.exists((e=>n===e)),i=YM.getSlot(r,n).isSome();return i&&(YM.hideAllSlots(r),a?((e=>{const t=e.element;Mt(t,"display","none"),St(t,"aria-hidden","true")})(e),t()):(o(),(e=>{const t=e.element;Ft(t,"display"),Ot(t,"aria-hidden")})(e),YM.showSlot(r,n),((e,t)=>{sR(e,t,tR.getOnShow)})(r,n)),s.each((e=>((e,t)=>sR(e,t,tR.getOnHide))(r,e)))),i}))};return{uid:e.uid,dom:{tag:"div",classes:["tox-view-wrap"],attributes:{"aria-hidden":"true"},styles:{display:"none"}},components:[],behaviours:ql([Hp.config({}),ag.config({find:e=>{const t=Hp.contents(e);return oe(t)}})]),apis:o}},name:"silver.ViewWrapper",configFields:[dr("backstage")],apis:{setViews:(e,t,o)=>e.setViews(t,o),toggleView:(e,t,o,n,r)=>e.toggleView(t,o,n,r),whichView:(e,t)=>e.whichView(t)}});const iR=FA.optional({factory:jM,name:"menubar",schema:[dr("backstage")]}),lR=FA.optional({factory:{sketch:e=>UA.sketch({uid:e.uid,dom:e.dom,listBehaviours:ql([Tp.config({mode:"acyclic",selector:".tox-toolbar"})]),makeItem:()=>WN({type:e.type,uid:ya("multiple-toolbar-item"),cyclicKeying:!1,initGroups:[],providers:e.providers,onEscape:()=>(e.onEscape(),D.some(!0))}),setupItem:(e,t,o,n)=>{$A.setGroups(t,o)},shell:!0})},name:"multiple-toolbar",schema:[dr("dom"),dr("onEscape")]}),cR=FA.optional({factory:{sketch:e=>{const t=(e=>e.type===Uv.sliding?jN:e.type===Uv.floating?UN:WN)(e);return t({type:e.type,uid:e.uid,onEscape:()=>(e.onEscape(),D.some(!0)),onToggled:(t,o)=>e.onToolbarToggled(o),cyclicKeying:!1,initGroups:[],getSink:e.getSink,providers:e.providers,moreDrawerData:{lazyToolbar:e.lazyToolbar,lazyMoreButton:e.lazyMoreButton,lazyHeader:e.lazyHeader},attributes:e.attributes})}},name:"toolbar",schema:[dr("dom"),dr("onEscape"),dr("getSink")]}),dR=FA.optional({factory:{sketch:e=>{const t=e.editor,o=e.sticky?IM:KA;return{uid:e.uid,dom:e.dom,components:e.components,behaviours:ql(o(t,e.sharedBackstage))}}},name:"header",schema:[dr("dom")]}),mR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:e.dom,components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/tinymce-self-hosted-premium-features/?utm_source=TinyMCE&utm_medium=SPAP&utm_campaign=SPAP&utm_id=editorreferral",rel:"noopener",target:"_blank","aria-hidden":"true"},classes:["tox-promotion-link"],innerHtml:"⚡️Upgrade"}}]})},name:"promotion",schema:[dr("dom")]}),uR=FA.optional({name:"socket",schema:[dr("dom")]}),gR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-sidebar"],attributes:{role:"presentation"}},components:[{dom:{tag:"div",classes:["tox-sidebar__slider"]},components:[],behaviours:ql([yk.config({}),Zp.config({}),SO.config({dimension:{property:"width"},closedClass:"tox-sidebar--sliding-closed",openClass:"tox-sidebar--sliding-open",shrinkingClass:"tox-sidebar--sliding-shrinking",growingClass:"tox-sidebar--sliding-growing",onShrunk:e=>{ag.getCurrent(e).each(YM.hideAllSlots),js(e,rN)},onGrown:e=>{js(e,rN)},onStartGrow:e=>{Ws(e,nN,{width:Ht(e.element,"width").getOr("")})},onStartShrink:e=>{Ws(e,nN,{width:Xt(e.element)+"px"})}}),Hp.config({}),ag.config({find:e=>{const t=Hp.contents(e);return oe(t)}})])}],behaviours:ql([YE(0),Ip("sidebar-sliding-events",[Qs(nN,((e,t)=>{Mt(e.element,"width",t.event.width)})),Qs(rN,((e,t)=>{Ft(e.element,"width")}))])])})},name:"sidebar",schema:[dr("dom")]}),hR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",attributes:{"aria-hidden":"true"},classes:["tox-throbber"],styles:{display:"none"}},behaviours:ql([Hp.config({}),iN.config({focus:!1}),ag.config({find:e=>oe(e.components())})]),components:[]})},name:"throbber",schema:[dr("dom")]}),pR=FA.optional({factory:aR,name:"viewWrapper",schema:[dr("backstage")]}),fR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-editor-container"]},components:e.components})},name:"editorContainer",schema:[]});var vR=og({name:"OuterContainer",factory:(e,t,o)=>{let n=!1;const r={getSocket:t=>PA.getPart(t,e,"socket"),setSidebar:(t,o,n)=>{PA.getPart(t,e,"sidebar").each((e=>((e,t,o)=>{ag.getCurrent(e).each((n=>{Hp.set(n,[eN(t)]);const r=null==o?void 0:o.toLowerCase();s(r)&&be(t,r)&&ag.getCurrent(n).each((t=>{YM.showSlot(t,r),SO.immediateGrow(n),Ft(n.element,"width"),tN(e.element,"region")}))}))})(e,o,n)))},toggleSidebar:(t,o)=>{PA.getPart(t,e,"sidebar").each((e=>((e,t)=>{ag.getCurrent(e).each((o=>{ag.getCurrent(o).each((n=>{SO.hasGrown(o)?YM.isShowing(n,t)?(SO.shrink(o),tN(e.element,"presentation")):(YM.hideAllSlots(n),YM.showSlot(n,t),tN(e.element,"region")):(YM.hideAllSlots(n),YM.showSlot(n,t),SO.grow(o),tN(e.element,"region"))}))}))})(e,o)))},whichSidebar:t=>PA.getPart(t,e,"sidebar").bind(oN).getOrNull(),getHeader:t=>PA.getPart(t,e,"header"),getToolbar:t=>PA.getPart(t,e,"toolbar"),setToolbar:(t,o)=>{PA.getPart(t,e,"toolbar").each((e=>{const t=F(o,zN);e.getApis().setGroups(e,t)}))},setToolbars:(t,o)=>{PA.getPart(t,e,"multiple-toolbar").each((e=>{const t=F(o,(e=>F(e,zN)));UA.setItems(e,t)}))},refreshToolbar:t=>{PA.getPart(t,e,"toolbar").each((e=>e.getApis().refresh(e)))},toggleToolbarDrawer:t=>{PA.getPart(t,e,"toolbar").each((e=>{Se(e.getApis().toggle,(t=>t(e)))}))},toggleToolbarDrawerWithoutFocusing:t=>{PA.getPart(t,e,"toolbar").each((e=>{Se(e.getApis().toggleWithoutFocusing,(t=>t(e)))}))},isToolbarDrawerToggled:t=>PA.getPart(t,e,"toolbar").bind((e=>D.from(e.getApis().isOpen).map((t=>t(e))))).getOr(!1),getThrobber:t=>PA.getPart(t,e,"throbber"),focusToolbar:t=>{PA.getPart(t,e,"toolbar").orThunk((()=>PA.getPart(t,e,"multiple-toolbar"))).each((e=>{Tp.focusIn(e)}))},setMenubar:(t,o)=>{PA.getPart(t,e,"menubar").each((e=>{jM.setMenus(e,o)}))},focusMenubar:t=>{PA.getPart(t,e,"menubar").each((e=>{jM.focus(e)}))},setViews:(t,o)=>{PA.getPart(t,e,"viewWrapper").each((e=>{aR.setViews(e,o)}))},toggleView:(t,o)=>PA.getPart(t,e,"viewWrapper").exists((e=>aR.toggleView(e,(()=>r.showMainView(t)),(()=>r.hideMainView(t)),o))),whichView:t=>PA.getPart(t,e,"viewWrapper").bind(aR.whichView).getOrNull(),hideMainView:t=>{n=r.isToolbarDrawerToggled(t),n&&r.toggleToolbarDrawer(t),PA.getPart(t,e,"editorContainer").each((e=>{const t=e.element;Mt(t,"display","none"),St(t,"aria-hidden","true")}))},showMainView:t=>{n&&r.toggleToolbarDrawer(t),PA.getPart(t,e,"editorContainer").each((e=>{const t=e.element;Ft(t,"display"),Ot(t,"aria-hidden")}))}};return{uid:e.uid,dom:e.dom,components:t,apis:r,behaviours:e.behaviours}},configFields:[dr("dom"),dr("behaviours")],partFields:[dR,iR,cR,lR,uR,gR,mR,hR,pR,fR],apis:{getSocket:(e,t)=>e.getSocket(t),setSidebar:(e,t,o,n)=>{e.setSidebar(t,o,n)},toggleSidebar:(e,t,o)=>{e.toggleSidebar(t,o)},whichSidebar:(e,t)=>e.whichSidebar(t),getHeader:(e,t)=>e.getHeader(t),getToolbar:(e,t)=>e.getToolbar(t),setToolbar:(e,t,o)=>{e.setToolbar(t,o)},setToolbars:(e,t,o)=>{e.setToolbars(t,o)},refreshToolbar:(e,t)=>e.refreshToolbar(t),toggleToolbarDrawer:(e,t)=>{e.toggleToolbarDrawer(t)},toggleToolbarDrawerWithoutFocusing:(e,t)=>{e.toggleToolbarDrawerWithoutFocusing(t)},isToolbarDrawerToggled:(e,t)=>e.isToolbarDrawerToggled(t),getThrobber:(e,t)=>e.getThrobber(t),setMenubar:(e,t,o)=>{e.setMenubar(t,o)},focusMenubar:(e,t)=>{e.focusMenubar(t)},focusToolbar:(e,t)=>{e.focusToolbar(t)},setViews:(e,t,o)=>{e.setViews(t,o)},toggleView:(e,t,o)=>e.toggleView(t,o),whichView:(e,t)=>e.whichView(t)}});const bR={file:{title:"File",items:"newdocument restoredraft | preview | export print | deleteallconversations"},edit:{title:"Edit",items:"undo redo | cut copy paste pastetext | selectall | searchreplace"},view:{title:"View",items:"code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments"},insert:{title:"Insert",items:"image link media addcomment pageembed template inserttemplate codesample inserttable accordion | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents footnotes | mergetags | insertdatetime"},format:{title:"Format",items:"bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat"},tools:{title:"Tools",items:"aidialog aishortcuts | spellchecker spellcheckerlanguage | autocorrect capitalization | a11ycheck code typography wordcount addtemplate"},table:{title:"Table",items:"inserttable | cell row column | advtablesort | tableprops deletetable"},help:{title:"Help",items:"help"}},yR=e=>e.split(" "),wR=(e,t)=>{const o={...bR,...t.menus},n=ae(t.menus).length>0,r=void 0===t.menubar||!0===t.menubar?yR("file edit view insert format tools table help"):yR(!1===t.menubar?"":t.menubar),a=Z(r,(e=>{const o=be(bR,e);return n?o||ve(t.menus,e).exists((e=>be(e,"items"))):o})),i=F(a,(n=>{const r=o[n];return((e,t,o)=>{const n=lb(o).split(/[ ,]/);return{text:e.title,getItems:()=>G(e.items,(e=>{const o=e.toLowerCase();return 0===o.trim().length||H(n,(e=>e===o))?[]:"separator"===o||"|"===o?[{type:"separator"}]:t.menuItems[o]?[t.menuItems[o]]:[]}))}})({title:r.title,items:yR(r.items)},t,e)}));return Z(i,(e=>e.getItems().length>0&&H(e.getItems(),(e=>s(e)||"separator"!==e.type))))},xR=(e,t,o)=>(e.on("remove",(()=>o.unload(t))),o.load(t)),CR=(e,t,o,n)=>(e.on("remove",(()=>n.unloadRawCss(t))),n.loadRawCss(t,o)),SR=async(e,t)=>{const o="ui/"+Pb(e).getOr("default")+"/skin.css",n=tinymce.Resource.get(o);if(s(n))return Promise.resolve(CR(e,o,n,e.ui.styleSheetLoader));return xR(e,t+"/skin.min.css",e.ui.styleSheetLoader)},kR=async(e,t)=>{var o;if(o=Le.fromDom(e.getElement()),ft(o).isSome()){const o=t+"/skin.shadowdom.css",n=tinymce.Resource.get(o);if(s(n))return CR(e,o,n,Wv.DOM.styleSheetLoader),Promise.resolve();return xR(e,t+"/skin.shadowdom.min.css",Wv.DOM.styleSheetLoader)}},_R=(e,t)=>(async(e,t)=>{Pb(t).fold((()=>{const o=Ib(t);o&&t.contentCSS.push(o+(e?"/content.inline":"/content")+".min.css")}),(o=>{const n="ui/"+o+(e?"/content.inline":"/content")+".css",r=tinymce.Resource.get(n);if(s(r))CR(t,n,r,t.ui.styleSheetLoader);else{const o=Ib(t);o&&t.contentCSS.push(o+(e?"/content.inline":"/content")+".min.css")}}));const o=Ib(t);if(!Lb(t)&&s(o))return Promise.all([SR(t,o),kR(t,o)]).then()})(e,t).then((e=>{const t=()=>{e._skinLoaded=!0,(e=>{e.dispatch("SkinLoaded")})(e)};return()=>{e.initialized?t():e.on("init",t)}})(t),((e,t)=>()=>((e,t)=>{e.dispatch("SkinLoadError",t)})(e,{message:t}))(t,"Skin could not be loaded")),ER=S(_R,!1),TR=S(_R,!0),OR=(e,t,o)=>e.translate([t,e.translate(o)]),DR=(e,t,o)=>{const n=(e,n,s,a)=>{const i=t.shared.providers.translate(e.title);if("separator"===e.type)return D.some({type:"separator",text:i});if("submenu"===e.type){const t=G(e.getStyleItems(),(e=>r(e,n,a)));return 0===n&&t.length<=0?D.none():D.some({type:"nestedmenuitem",text:i,enabled:t.length>0,getSubmenuItems:()=>G(e.getStyleItems(),(e=>r(e,n,a)))})}return D.some({type:"togglemenuitem",text:i,icon:e.icon,active:e.isSelected(a),enabled:!s,onAction:o.onAction(e),...e.getStylePreview().fold((()=>({})),(e=>({meta:{style:e}})))})},r=(e,t,r)=>{const s="formatter"===e.type&&o.isInvalid(e);return 0===t?s?[]:n(e,t,!1,r).toArray():n(e,t,s,r).toArray()},s=e=>{const t=o.getCurrentValue(),n=o.shouldHide?0:1;return G(e,(e=>r(e,n,t)))};return{validateItems:s,getFetch:(e,t)=>(o,n)=>{const r=t(),a=s(r);n(qT(a,oy.CLOSE_ON_EXECUTE,e,{isHorizontalMenu:!1,search:D.none()}))}}},AR=(e,t,o)=>{const n=o.dataset,r="basic"===n.type?()=>F(n.data,(e=>lA(e,o.isSelectedFor,o.getPreviewFor))):n.getData;return{items:DR(0,t,o),getStyleItems:r}},MR=(e,t,o,n,r)=>{const{items:s,getStyleItems:a}=AR(0,t,o);return ZT({text:o.icon.isSome()?D.none():o.text,icon:o.icon,tooltip:D.from(o.tooltip),role:D.none(),fetch:s.getFetch(t,a),onSetup:t=>{const s=o=>t.setTooltip(OR(e,n,o.value));return e.on(r,s),dC(gC(e,"NodeChange",(t=>{const n=t.getComponent();o.updateText(n),wg.set(t.getComponent(),!e.selection.isEditable())}))(t),(()=>e.off(r,s)))},getApi:e=>({getComponent:w(e),setTooltip:o=>{const n=t.shared.providers.translate(o);kt(e.element,{"aria-label":n,title:n})}}),columns:1,presets:"normal",classes:o.icon.isSome()?[]:["bespoke"],dropdownBehaviours:[]},"tox-tbtn",t.shared)};var NR;!function(e){e[e.SemiColon=0]="SemiColon",e[e.Space=1]="Space"}(NR||(NR={}));const RR=(e,t,o)=>{const n=(e=>F(e,(e=>{let t=e,o=e;const n=e.split("=");return n.length>1&&(t=n[0],o=n[1]),{title:t,format:o}})))(((e,t)=>t===NR.SemiColon?e.replace(/;$/,"").split(";"):e.split(" "))(e.options.get(t),o));return{type:"basic",data:n}},BR="Alignment {0}",LR="left",HR=[{title:"Left",icon:"align-left",format:"alignleft",command:"JustifyLeft"},{title:"Center",icon:"align-center",format:"aligncenter",command:"JustifyCenter"},{title:"Right",icon:"align-right",format:"alignright",command:"JustifyRight"},{title:"Justify",icon:"align-justify",format:"alignjustify",command:"JustifyFull"}],IR=e=>{const t={type:"basic",data:HR};return{tooltip:OR(e,BR,LR),text:D.none(),icon:D.some("align-left"),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:D.none,getPreviewFor:e=>D.none,onAction:t=>()=>W(HR,(e=>e.format===t.format)).each((t=>e.execCommand(t.command))),updateText:t=>{const o=W(HR,(t=>e.formatter.match(t.format))),n=o.fold(w(LR),(e=>e.title.toLowerCase()));Ws(t,VT,{icon:`align-${n}`}),((e,t)=>{e.dispatch("AlignTextUpdate",t)})(e,{value:n})},dataset:t,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},PR=(e,t)=>{const o=t(),n=F(o,(e=>e.format));return D.from(e.formatter.closest(n)).bind((e=>W(o,(t=>t.format===e)))).orThunk((()=>ke(e.formatter.match("p"),{title:"Paragraph",format:"p"})))},FR="Block {0}",zR="Paragraph",VR=e=>{const t=RR(e,"block_formats",NR.SemiColon);return{tooltip:OR(e,FR,zR),text:D.some(zR),icon:D.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:D.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return o?D.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):D.none()},onAction:hC(e),updateText:o=>{const n=PR(e,(()=>t.data)).fold(w(zR),(e=>e.title));Ws(o,zT,{text:n}),((e,t)=>{e.dispatch("BlocksTextUpdate",t)})(e,{value:n})},dataset:t,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},ZR="Font {0}",UR="System Font",jR=["-apple-system","Segoe UI","Roboto","Helvetica Neue","sans-serif"],WR=e=>{const t=e.split(/\s*,\s*/);return F(t,(e=>e.replace(/^['"]+|['"]+$/g,"")))},$R=(e,t)=>t.length>0&&K(t,(t=>e.indexOf(t.toLowerCase())>-1)),qR=e=>{const t=()=>{const t=e=>e?WR(e)[0]:"",n=e.queryCommandValue("FontName"),r=o.data,s=n?n.toLowerCase():"",a=Bb(e),i=W(r,(e=>{const o=e.format;return o.toLowerCase()===s||t(o).toLowerCase()===t(s).toLowerCase()})).orThunk((()=>ke(((e,t)=>{if(0===e.indexOf("-apple-system")||t.length>0){const o=WR(e.toLowerCase());return $R(o,jR)||$R(o,t)}return!1})(s,a),{title:UR,format:s})));return{matchOpt:i,font:n}},o=RR(e,"font_family_formats",NR.SemiColon);return{tooltip:OR(e,ZR,UR),text:D.some(UR),icon:D.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getCurrentValue:()=>{const{matchOpt:e}=t();return e},getPreviewFor:e=>()=>D.some({tag:"div",styles:-1===e.indexOf("dings")?{"font-family":e}:{}}),onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontName",!1,t.format)}))},updateText:o=>{const{matchOpt:n,font:r}=t(),s=n.fold(w(r),(e=>e.title));Ws(o,zT,{text:s}),((e,t)=>{e.dispatch("FontFamilyTextUpdate",t)})(e,{value:s})},dataset:o,shouldHide:!1,isInvalid:T}},GR={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},KR=(()=>{const e="[0-9]+",t="[eE]"+("[+-]?"+e),o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^(${`[+-]?(?:${n})`})(.*)$`)})(),YR=(e,t)=>D.from(KR.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>H(t,(t=>H(GR[t],(t=>e===t)))))(n,t)?D.some({value:o,unit:n}):D.none()})),XR={tab:w(9),escape:w(27),enter:w(13),backspace:w(8),delete:w(46),left:w(37),up:w(38),right:w(39),down:w(40),space:w(32),home:w(36),end:w(35),pageUp:w(33),pageDown:w(34)},JR=(e,t,o)=>{let n=D.none();const r=gC(e,"NodeChange SwitchMode",(t=>{const r=t.getComponent();n=D.some(r),o.updateInputValue(r),wg.set(r,!e.selection.isEditable())})),s=e=>({getComponent:w(e)}),a=Hr(v),i=ya("custom-number-input-events"),l=(e,t,r)=>{const s=n.map((e=>Xm.getValue(e))).getOr("");const a=o.getNewValue(s,e),i=s.length-`${a}`.length,l=n.map((e=>e.element.dom.selectionStart-i)),c=n.map((e=>e.element.dom.selectionEnd-i));o.onAction(a,r),n.each((e=>{Xm.setValue(e,a),t&&(l.each((t=>e.element.dom.selectionStart=t)),c.each((t=>e.element.dom.selectionEnd=t)))}))},c=(e,t)=>l(((e,t)=>e-t),e,t),d=(e,t)=>l(((e,t)=>e+t),e,t),m=e=>rt(e.element).fold(D.none,(e=>(tc(e),D.some(!0)))),u=e=>nc(e.element)?(lt(e.element).each((e=>tc(e))),D.some(!0)):D.none(),g=(o,n,r,a)=>{const i=Hr(v),l=t.shared.providers.translate(r),c=ya("altExecuting"),d=gC(e,"NodeChange SwitchMode",(t=>{wg.set(t.getComponent(),!e.selection.isEditable())})),m=e=>{wg.isDisabled(e)||o(!0)};return Nf.sketch({dom:{tag:"button",attributes:{title:l,"aria-label":l},classes:a.concat(n)},components:[IT(n,t.shared.providers.icons)],buttonBehaviours:ql([wg.config({}),Ip(c,[yx({onSetup:d,getApi:s},i),wx({getApi:s},i),Qs(is(),((e,t)=>{t.event.raw.keyCode!==XR.space()&&t.event.raw.keyCode!==XR.enter()||wg.isDisabled(e)||o(!1)})),Qs(ms(),m),Qs(Jr(),m)])]),eventOrder:{[is()]:[c,"keying"],[ms()]:[c,"alloy.base.behaviour"],[Jr()]:[c,"alloy.base.behaviour"]}})},h=Bf(g((e=>c(!1,e)),"minus","Decrease font size",[])),p=Bf(g((e=>d(!1,e)),"plus","Increase font size",[])),f=Bf({dom:{tag:"div",classes:["tox-input-wrapper"]},components:[_y.sketch({inputBehaviours:ql([wg.config({}),Ip(i,[yx({onSetup:r,getApi:s},a),wx({getApi:s},a)]),Ip("input-update-display-text",[Qs(zT,((e,t)=>{Xm.setValue(e,t.event.text)})),Qs(as(),(e=>{o.onAction(Xm.getValue(e))})),Qs(ds(),(e=>{o.onAction(Xm.getValue(e))}))]),Tp.config({mode:"special",onEnter:e=>(l(x,!0,!0),D.some(!0)),onEscape:m,onUp:e=>(d(!0,!1),D.some(!0)),onDown:e=>(c(!0,!1),D.some(!0)),onLeft:(e,t)=>(t.cut(),D.none()),onRight:(e,t)=>(t.cut(),D.none())})])})],behaviours:ql([Zp.config({}),Tp.config({mode:"special",onEnter:u,onSpace:u,onEscape:m}),Ip("input-wrapper-events",[Qs(rs(),(e=>{z([h,p],(t=>{const o=Le.fromDom(t.get(e).element.dom);nc(o)&&oc(o)}))}))])])});return{dom:{tag:"div",classes:["tox-number-input"]},components:[h.asSpec(),f.asSpec(),p.asSpec()],behaviours:ql([Zp.config({}),Tp.config({mode:"flow",focusInside:eh.OnEnterOrSpaceMode,cycles:!1,selector:"button, .tox-input-wrapper",onEscape:e=>nc(e.element)?D.none():(tc(e.element),D.some(!0))})])}},QR="Font size {0}",eB="12pt",tB={"8pt":"1","10pt":"2","12pt":"3","14pt":"4","18pt":"5","24pt":"6","36pt":"7"},oB={"xx-small":"7pt","x-small":"8pt",small:"10pt",medium:"12pt",large:"14pt","x-large":"18pt","xx-large":"24pt"},nB=(e,t)=>/[0-9.]+px$/.test(e)?((e,t)=>{const o=Math.pow(10,t);return Math.round(e*o)/o})(72*parseInt(e,10)/96,t||0)+"pt":ve(oB,e).getOr(e),rB=e=>ve(tB,e).getOr(""),sB=e=>{const t=()=>{let t=D.none();const o=n.data,r=e.queryCommandValue("FontSize");if(r)for(let e=3;t.isNone()&&e>=0;e--){const n=nB(r,e),s=rB(n);t=W(o,(e=>e.format===r||e.format===n||e.format===s))}return{matchOpt:t,size:r}},o=w(D.none),n=RR(e,"font_size_formats",NR.Space);return{tooltip:OR(e,QR,eB),text:D.some(eB),icon:D.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getPreviewFor:o,getCurrentValue:()=>{const{matchOpt:e}=t();return e},onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontSize",!1,t.format)}))},updateText:o=>{const{matchOpt:n,size:r}=t(),s=n.fold(w(r),(e=>e.title));Ws(o,zT,{text:s}),((e,t)=>{e.dispatch("FontSizeTextUpdate",t)})(e,{value:s})},dataset:n,shouldHide:!1,isInvalid:T}},aB="Format {0}",iB=(e,t)=>{const o="Paragraph";return{tooltip:OR(e,aB,o),text:D.some(o),icon:D.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:D.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return void 0!==o?D.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):D.none()},onAction:hC(e),updateText:t=>{const n=e=>nA(e)?G(e.items,n):rA(e)?[{title:e.title,format:e.format}]:[],r=G(iA(e),n),s=PR(e,w(r)).fold(w(o),(e=>e.title));Ws(t,zT,{text:s}),((e,t)=>{e.dispatch("StylesTextUpdate",t)})(e,{value:s})},shouldHide:ab(e),isInvalid:t=>!e.formatter.canApply(t.format),dataset:t}},lB=w([dr("toggleClass"),dr("fetch"),ol("onExecute"),Tr("getHotspot",D.some),Tr("getAnchorOverrides",w({})),Xc(),ol("onItemExecute"),yr("lazySink"),dr("dom"),el("onOpen"),Jm("splitDropdownBehaviours",[pS,Tp,Zp]),Tr("matchWidth",!1),Tr("useMinWidth",!1),Tr("eventOrder",{}),yr("role")].concat(RS())),cB=Tu({factory:Nf,schema:[dr("dom")],name:"arrow",defaults:()=>({buttonBehaviours:ql([Zp.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each($s)},buttonBehaviours:ql([Yp.config({toggleOnExecute:!1,toggleClass:e.toggleClass})])})}),dB=Tu({factory:Nf,schema:[dr("dom")],name:"button",defaults:()=>({buttonBehaviours:ql([Zp.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each((o=>{e.onExecute(o,t)}))}})}),mB=w([cB,dB,Du({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[dr("text")],name:"aria-descriptor"}),Ou({schema:[Xi()],name:"menu",defaults:e=>({onExecute:(t,o)=>{t.getSystem().getByUid(e.uid).each((n=>{e.onItemExecute(n,t,o)}))}})}),SS()]),uB=og({name:"SplitDropdown",configFields:lB(),partFields:mB(),factory:(e,t,o,n)=>{const r=e=>{ag.getCurrent(e).each((e=>{Mg.highlightFirst(e),Tp.focusIn(e)}))},s=t=>{TS(e,x,t,n,r,Tf.HighlightMenuAndItem).get(v)},a=t=>{const o=Zu(t,e,"button");return $s(o),D.some(!0)},i={...Ys([ia(((t,o)=>{Vu(t,e,"aria-descriptor").each((e=>{const o=ya("aria");St(e.element,"id",o),St(t.element,"aria-describedby",o)}))}))]),...Qp(D.some(s))},l={repositionMenus:e=>{Yp.isOn(e)&&NS(e)}};return{uid:e.uid,dom:e.dom,components:t,apis:l,eventOrder:{...e.eventOrder,[Cs()]:["disabling","toggling","alloy.base.behaviour"]},events:i,behaviours:eu(e.splitDropdownBehaviours,[pS.config({others:{sandbox:t=>{const o=Zu(t,e,"arrow");return MS(e,t,{onOpen:()=>{Yp.on(o),Yp.on(t)},onClose:()=>{Yp.off(o),Yp.off(t)}})}}}),Tp.config({mode:"special",onSpace:a,onEnter:a,onDown:e=>(s(e),D.some(!0))}),Zp.config({}),Yp.config({toggleOnExecute:!1,aria:{mode:"expanded"}})]),domModification:{attributes:{role:e.role.getOr("button"),"aria-haspopup":!0}}}},apis:{repositionMenus:(e,t)=>e.repositionMenus(t)}}),gB=e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setText:t=>Ws(e,zT,{text:t}),setIcon:t=>Ws(e,VT,{icon:t})}),hB=e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setText:t=>Ws(e,zT,{text:t}),setIcon:t=>Ws(e,VT,{icon:t})}),pB=(e,t)=>e.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),fB=ya("focus-button"),vB=(e,t,o,n,r)=>{const s=t.map((e=>Bf(FT(e,"tox-tbtn",r)))),a=e.map((e=>Bf(PT(e,r.icons))));return{dom:{tag:"button",classes:["tox-tbtn"].concat(t.isSome()?["tox-tbtn--select"]:[]),attributes:pB(o,r)},components:Sx([a.map((e=>e.asSpec())),s.map((e=>e.asSpec()))]),eventOrder:{[es()]:["focusing","alloy.base.behaviour",RT],[Rs()]:[RT,"toolbar-group-button-events"]},buttonBehaviours:ql([vx(r.isDisabled),gx(),Ip(RT,[ia(((e,t)=>LT(e))),Qs(zT,((e,t)=>{s.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[Ci(r.translate(t.event.text))])}))})),Qs(VT,((e,t)=>{a.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[PT(t.event.icon,r.icons)])}))})),Qs(es(),((e,t)=>{t.event.prevent(),js(e,fB)}))])].concat(n.getOr([])))}},bB=(e,t,o)=>{var n;const r=Hr(v),s=vB(e.icon,e.text,e.tooltip,D.none(),o);return Nf.sketch({dom:s.dom,components:s.components,eventOrder:BT,buttonBehaviours:{...ql([Ip("toolbar-button-events",[(a={onAction:e.onAction,getApi:t.getApi},da(((e,t)=>{bx(a,e)((t=>{Ws(e,NT,{buttonApi:t}),a.onAction(t)}))}))),yx(t,r),wx(t,r)]),vx((()=>!e.enabled||o.isDisabled())),gx()].concat(t.toolbarButtonBehaviours)),[RT]:null===(n=s.buttonBehaviours)||void 0===n?void 0:n[RT]}});var a},yB=(e,t,o)=>bB(e,{toolbarButtonBehaviours:o.length>0?[Ip("toolbarButtonWith",o)]:[],getApi:gB,onSetup:e.onSetup},t),wB=(e,t,o)=>bB(e,{toolbarButtonBehaviours:[Hp.config({}),Yp.config({toggleClass:"tox-tbtn--enabled",aria:{mode:"pressed"},toggleOnExecute:!1})].concat(o.length>0?[Ip("toolbarToggleButtonWith",o)]:[]),getApi:hB,onSetup:e.onSetup},t),xB=(e,t,o)=>n=>wS((e=>t.fetch(e))).map((r=>D.from($S(xn(KC(ya("menu-value"),r,(o=>{t.onItemAction(e(n),o)}),t.columns,t.presets,oy.CLOSE_ON_EXECUTE,t.select.getOr(T),o),{movement:XC(t.columns,t.presets),menuBehaviours:Jw("auto"!==t.columns?[]:[ia(((e,o)=>{Yw(e,4,hy(t.presets)).each((({numRows:t,numColumns:o})=>{Tp.setGridSize(e,t,o)}))}))])}))))),CB=[{name:"history",items:["undo","redo"]},{name:"ai",items:["aidialog","aishortcuts"]},{name:"styles",items:["styles"]},{name:"formatting",items:["bold","italic"]},{name:"alignment",items:["alignleft","aligncenter","alignright","alignjustify"]},{name:"indentation",items:["outdent","indent"]},{name:"permanent pen",items:["permanentpen"]},{name:"comments",items:["addcomment"]}],SB=(e,t)=>(o,n,r)=>{const s=e(o).mapError((e=>rr(e))).getOrDie();return t(s,n,r)},kB={button:SB(xw,((e,t)=>{return o=e,n=t.shared.providers,yB(o,n,[]);var o,n})),togglebutton:SB(kw,((e,t)=>{return o=e,n=t.shared.providers,wB(o,n,[]);var o,n})),menubutton:SB(ZM,((e,t)=>_O(e,"tox-tbtn",t,D.none(),!1))),splitbutton:SB((e=>tr("SplitButton",UM,e)),((e,t)=>((e,t)=>{const o=e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setIconFill:(t,o)=>{Bi(e.element,`svg path[class="${t}"], rect[class="${t}"]`).each((e=>{St(e,"fill",o)}))},setActive:t=>{St(e.element,"aria-pressed",t),Bi(e.element,"span").each((o=>{e.getSystem().getByDom(o).each((e=>Yp.set(e,t)))}))},isActive:()=>Bi(e.element,"span").exists((t=>e.getSystem().getByDom(t).exists(Yp.isOn))),setText:t=>Bi(e.element,"span").each((o=>e.getSystem().getByDom(o).each((e=>Ws(e,zT,{text:t}))))),setIcon:t=>Bi(e.element,"span").each((o=>e.getSystem().getByDom(o).each((e=>Ws(e,VT,{icon:t}))))),setTooltip:o=>{const n=t.providers.translate(o);kt(e.element,{"aria-label":n,title:n})}}),n=Hr(v),r={getApi:o,onSetup:e.onSetup};return uB.sketch({dom:{tag:"div",classes:["tox-split-button"],attributes:{"aria-pressed":!1,...pB(e.tooltip,t.providers)}},onExecute:t=>{const n=o(t);n.isEnabled()&&e.onAction(n)},onItemExecute:(e,t,o)=>{},splitDropdownBehaviours:ql([fx(t.providers.isDisabled),gx(),Ip("split-dropdown-events",[ia(((e,t)=>LT(e))),Qs(fB,Zp.focus),yx(r,n),wx(r,n)]),Wk.config({})]),eventOrder:{[Rs()]:["alloy.base.behaviour","split-dropdown-events"]},toggleClass:"tox-tbtn--enabled",lazySink:t.getSink,fetch:xB(o,e,t.providers),parts:{menu:wy(0,e.columns,e.presets)},components:[uB.parts.button(vB(e.icon,e.text,D.none(),D.some([Yp.config({toggleClass:"tox-tbtn--enabled",toggleOnExecute:!1})]),t.providers)),uB.parts.arrow({dom:{tag:"button",classes:["tox-tbtn","tox-split-button__chevron"],innerHtml:Iv("chevron-down",t.providers.icons)},buttonBehaviours:ql([fx(t.providers.isDisabled),gx(),Pv()])}),uB.parts["aria-descriptor"]({text:t.providers.translate("To open the popup, press Shift+Enter")})]})})(e,t.shared))),grouptoolbarbutton:SB((e=>tr("GroupToolbarButton",FM,e)),((e,t,o)=>{const n=o.ui.registry.getAll().buttons,r=e=>OB(o,{buttons:n,toolbar:e,allowToolbarGroups:!1},t,D.none()),s={[Kc]:t.shared.header.isPositionedAtTop()?Gc.TopToBottom:Gc.BottomToTop};if(cb(o)===Uv.floating)return((e,t,o,n)=>{const r=t.shared,s=Hr(v),a={toolbarButtonBehaviours:[],getApi:gB,onSetup:e.onSetup},i=[Ip("toolbar-group-button-events",[yx(a,s),wx(a,s)])];return TN.sketch({lazySink:r.getSink,fetch:()=>wS((t=>{t(F(o(e.items),zN))})),markers:{toggledClass:"tox-tbtn--enabled"},parts:{button:vB(e.icon,e.text,e.tooltip,D.some(i),r.providers),toolbar:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:n}}}})})(e,t,r,s);throw new Error("Toolbar groups are only supported when using floating toolbar mode")}))},_B={styles:(e,t)=>{const o={type:"advanced",...t.styles};return MR(e,t,iB(e,o),aB,"StylesTextUpdate")},fontsize:(e,t)=>MR(e,t,sB(e),QR,"FontSizeTextUpdate"),fontsizeinput:(e,t)=>JR(e,t,(e=>{const t=()=>e.queryCommandValue("FontSize");return{updateInputValue:e=>Ws(e,zT,{text:t()}),onAction:(t,o)=>e.execCommand("FontSize",!1,t,{skip_focus:!o}),getNewValue:(o,n)=>{YR(o,["unsupportedLength","empty"]);const r=t(),s=YR(o,["unsupportedLength","empty"]).or(YR(r,["unsupportedLength","empty"])),a=s.map((e=>e.value)).getOr(16),i=wb(e),l=s.map((e=>e.unit)).filter((e=>""!==e)).getOr(i),c=n(a,(e=>{var t;return null!==(t={em:{step:.1},cm:{step:.1},in:{step:.1},pc:{step:.1},ch:{step:.1},rem:{step:.1}}[e])&&void 0!==t?t:{step:1}})(l).step),d=`${(e=>e>=0)(c)?c:a}${l}`;return d!==r&&((e,t)=>{e.dispatch("FontSizeInputTextUpdate",t)})(e,{value:d}),d}}})(e)),fontfamily:(e,t)=>MR(e,t,qR(e),ZR,"FontFamilyTextUpdate"),blocks:(e,t)=>MR(e,t,VR(e),FR,"BlocksTextUpdate"),align:(e,t)=>MR(e,t,IR(e),BR,"AlignTextUpdate")},EB=e=>{const t=e.toolbar,o=e.buttons;return!1===t?[]:void 0===t||!0===t?(e=>{const t=F(CB,(t=>{const o=Z(t.items,(t=>be(e,t)||be(_B,t)));return{name:t.name,items:o}}));return Z(t,(e=>e.items.length>0))})(o):s(t)?(e=>{const t=e.split("|");return F(t,(e=>({items:e.trim().split(" ")})))})(t):(e=>f(e,(e=>be(e,"name")&&be(e,"items"))))(t)?t:(console.error("Toolbar type should be string, string[], boolean or ToolbarGroup[]"),[])},TB=(e,t,o,n,r,s)=>ve(t,o.toLowerCase()).orThunk((()=>s.bind((e=>se(e,(e=>ve(t,e+o.toLowerCase()))))))).fold((()=>ve(_B,o.toLowerCase()).map((t=>t(e,r)))),(t=>"grouptoolbarbutton"!==t.type||n?((e,t,o)=>ve(kB,e.type).fold((()=>(console.error("skipping button defined by",e),D.none())),(n=>D.some(n(e,t,o)))))(t,r,e):(console.warn(`Ignoring the '${o}' toolbar button. Group toolbar buttons are only supported when using floating toolbar mode and cannot be nested.`),D.none()))),OB=(e,t,o,n)=>{const r=EB(t),s=F(r,(r=>{const s=G(r.items,(r=>0===r.trim().length?[]:TB(e,t.buttons,r,t.allowToolbarGroups,o,n).toArray()));return{title:D.from(e.translate(r.name)),items:s}}));return Z(s,(e=>e.items.length>0))},DB=(e,t,o,n)=>{const r=t.mainUi.outerContainer,a=o.toolbar,i=o.buttons;if(f(a,s)){const t=a.map((t=>{const r={toolbar:t,buttons:i,allowToolbarGroups:o.allowToolbarGroups};return OB(e,r,n,D.none())}));vR.setToolbars(r,t)}else vR.setToolbar(r,OB(e,o,n,D.none()))},AB=Do(),MB=AB.os.isiOS()&&AB.os.version.major<=12;var NB=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:s,uiMotherships:a}=t,i=Hr(0),l=s.outerContainer;ER(e);const d=Le.fromDom(r.targetNode),m=pt(ht(d));bm(d,s.mothership),((e,t,o)=>{Kb(e)&&bm(o.mainUi.mothership.element,o.popupUi.mothership),vm(t,o.dialogUi.mothership)})(e,m,t),e.on("SkinLoaded",(()=>{vR.setSidebar(l,o.sidebar,Mb(e)),DB(e,t,o,n),i.set(e.getWin().innerWidth),vR.setMenubar(l,wR(e,o)),vR.setViews(l,o.views),((e,t)=>{const{uiMotherships:o}=t,n=e.dom;let r=e.getWin();const s=e.getDoc().documentElement,a=Hr($t(r.innerWidth,r.innerHeight)),i=Hr($t(s.offsetWidth,s.offsetHeight)),l=()=>{const t=a.get();t.left===r.innerWidth&&t.top===r.innerHeight||(a.set($t(r.innerWidth,r.innerHeight)),iC(e))},c=()=>{const t=e.getDoc().documentElement,o=i.get();o.left===t.offsetWidth&&o.top===t.offsetHeight||(i.set($t(t.offsetWidth,t.offsetHeight)),iC(e))},d=t=>{((e,t)=>{e.dispatch("ScrollContent",t)})(e,t)};n.bind(r,"resize",l),n.bind(r,"scroll",d);const m=Tc(Le.fromDom(e.getBody()),"load",c);e.on("hide",(()=>{z(o,(e=>{Mt(e.element,"display","none")}))})),e.on("show",(()=>{z(o,(e=>{Ft(e.element,"display")}))})),e.on("NodeChange",c),e.on("remove",(()=>{m.unbind(),n.unbind(r,"resize",l),n.unbind(r,"scroll",d),r=null}))})(e,t)}));const u=vR.getSocket(l).getOrDie("Could not find expected socket element");if(MB){Nt(u.element,{overflow:"scroll","-webkit-overflow-scrolling":"touch"});const t=((e,t)=>{let o=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{c(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}})((()=>{e.dispatch("ScrollContent")}),20),o=Ec(u.element,"scroll",t.throttle);e.on("remove",o.unbind)}ux(e,t),e.addCommand("ToggleSidebar",((t,o)=>{vR.toggleSidebar(l,o),e.dispatch("ToggleSidebar")})),e.addQueryValueHandler("ToggleSidebar",(()=>{var e;return null!==(e=vR.whichSidebar(l))&&void 0!==e?e:""})),e.addCommand("ToggleView",((t,o)=>{if(vR.toggleView(l,o)){const t=l.element;s.mothership.broadcastOn([Nm()],{target:t}),z(a,(e=>{e.broadcastOn([Nm()],{target:t})})),c(vR.whichView(l))&&(e.focus(),e.nodeChanged(),vR.refreshToolbar(l))}})),e.addQueryValueHandler("ToggleView",(()=>{var e;return null!==(e=vR.whichView(l))&&void 0!==e?e:""}));const g=cb(e);g!==Uv.sliding&&g!==Uv.floating||e.on("ResizeWindow ResizeEditor ResizeContent",(()=>{const o=e.getWin().innerWidth;o!==i.get()&&(vR.refreshToolbar(t.mainUi.outerContainer),i.set(o))}));const h={setEnabled:e=>{mx(t,!e)},isEnabled:()=>!wg.isDisabled(l)};return{iframeContainer:u.element.dom,editorContainer:l.element.dom,api:h}}});const RB=e=>/^[0-9\.]+(|px)$/i.test(""+e)?D.some(parseInt(""+e,10)):D.none(),BB=e=>p(e)?e+"px":e,LB=(e,t,o)=>{const n=t.filter((t=>ee>t));return n.or(r).getOr(e)},HB=e=>{const t=(e=>{const t=Jv(e),o=tb(e),n=nb(e);return RB(t).map((e=>LB(e,o,n)))})(e);return t.getOr(Jv(e))},IB=e=>{const t=Qv(e),o=eb(e),n=ob(e);return RB(t).map((e=>LB(e,o,n)))},{ToolbarLocation:PB,ToolbarMode:FB}=Xb,zB=(e,t,o,n,r)=>{const{mainUi:s,uiMotherships:a}=o,i=Wv.DOM,l=Wb(e),c=Gb(e),d=ob(e).or(IB(e)),m=n.shared.header,u=m.isPositionedAtTop,g=cb(e),h=g===FB.sliding||g===FB.floating,p=Hr(!1),f=()=>p.get()&&!e.removed,v=e=>h?e.fold(w(0),(e=>e.components().length>1?Ut(e.components()[1].element):0)):0,b=(e,t)=>Kb(e)?XA(t):D.none(),y=()=>{z(a,(e=>{e.broadcastOn([Rm()],{})}))},x=o=>{if(!f())return;l||r.on((e=>{const o=d.getOrThunk((()=>{const e=RB(Bt(wt(),"margin-left")).getOr(0);return Xt(wt())-Gt(t).left+e}));Mt(e.element,"max-width",o+"px")}));const n=l?D.none():(()=>{if(l)return D.none();if(Gt(s.outerContainer.element).left+Jt(s.outerContainer.element)>=window.innerWidth-40||Ht(s.outerContainer.element,"width").isSome()){Mt(s.outerContainer.element,"position","absolute"),Mt(s.outerContainer.element,"left","0px"),Ft(s.outerContainer.element,"width");const e=Jt(s.outerContainer.element);return D.some(e)}return D.none()})();h&&vR.refreshToolbar(s.outerContainer),l||(o=>{r.on((n=>{const r=vR.getToolbar(s.outerContainer),a=v(r),i=Ko(t),{top:l,left:c}=b(e,s.outerContainer.element).fold((()=>({top:u()?Math.max(i.y-Ut(n.element)+a,0):i.bottom,left:i.x})),(e=>{var t;const o=Ko(e),r=null!==(t=e.dom.scrollTop)&&void 0!==t?t:0,s=Xe(e,wt()),l=s?Math.max(i.y-Ut(n.element)+a,0):i.y-o.y+r-Ut(n.element)+a;return{top:u()?l:i.bottom,left:s?i.x:i.x-o.x}})),d={position:"absolute",left:Math.round(c)+"px",top:Math.round(l)+"px"},m=o.map((e=>{const t=zo(),o=window.innerWidth-(c-t.left);return{width:Math.max(Math.min(e,o),150)+"px"}})).getOr({});Nt(s.outerContainer.element,{...d,...m})}))})(n),c&&r.on(o),y()},C=()=>!(l||!c||!f())&&r.get().exists((o=>{const n=m.getDockingMode(),a=(o=>{switch(mb(e)){case PB.auto:const e=vR.getToolbar(s.outerContainer),n=v(e),r=Ut(o.element)-n,a=Ko(t);if(a.y>r)return"top";{const e=tt(t),o=Math.max(e.dom.scrollHeight,Ut(e));return a.bottom{OM.setModes(e,[i]),m.setDockingMode(i);const t=u()?Gc.TopToBottom:Gc.BottomToTop;St(e.element,Kc,t)})),!0);var i}));return{isVisible:f,isPositionedAtTop:u,show:()=>{p.set(!0),Mt(s.outerContainer.element,"display","flex"),i.addClass(e.getBody(),"mce-edit-focus"),z(a,(e=>{Ft(e.element,"display")})),C(),Kb(e)?x((e=>OM.isDocked(e)?OM.reset(e):OM.refresh(e))):x(OM.refresh)},hide:()=>{p.set(!1),Mt(s.outerContainer.element,"display","none"),i.removeClass(e.getBody(),"mce-edit-focus"),z(a,(e=>{Mt(e.element,"display","none")}))},update:x,updateMode:()=>{C()&&x(OM.reset)},repositionPopups:y}},VB=(e,t)=>{const o=Ko(e);return{pos:t?o.y:o.bottom,bounds:o}};var ZB=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:s}=t,a=kc(),i=Le.fromDom(r.targetNode),l=zB(e,i,t,n,a),c=hb(e);TR(e);const d=()=>{if(a.isSet())return void l.show();a.set(vR.getHeader(s.outerContainer).getOrDie());const r=$b(e);Kb(e)?(bm(i,s.mothership),bm(i,t.popupUi.mothership)):vm(r,s.mothership),vm(r,t.dialogUi.mothership),DB(e,t,o,n),vR.setMenubar(s.outerContainer,wR(e,o)),l.show(),((e,t,o,n)=>{const r=Hr(VB(t,o.isPositionedAtTop())),s=n=>{const{pos:s,bounds:a}=VB(t,o.isPositionedAtTop()),{pos:i,bounds:l}=r.get(),c=a.height!==l.height||a.width!==l.width;r.set({pos:s,bounds:a}),c&&iC(e,n),o.isVisible()&&(i!==s?o.update(OM.reset):c&&(o.updateMode(),o.repositionPopups()))};n||(e.on("activate",o.show),e.on("deactivate",o.hide)),e.on("SkinLoaded ResizeWindow",(()=>o.update(OM.reset))),e.on("NodeChange keydown",(e=>{requestAnimationFrame((()=>s(e)))}));let a=0;const i=iT((()=>o.update(OM.refresh)),33);e.on("ScrollWindow",(()=>{const e=zo().left;e!==a&&(a=e,i.throttle()),o.updateMode()})),Kb(e)&&e.on("ElementScroll",(e=>{o.update(OM.refresh)}));const l=Sc();l.set(Tc(Le.fromDom(e.getBody()),"load",(e=>s(e.raw)))),e.on("remove",(()=>{l.clear()}))})(e,i,l,c),e.nodeChanged()};e.on("show",d),e.on("hide",l.hide),c||(e.on("focus",d),e.on("blur",l.hide)),e.on("init",(()=>{(e.hasFocus()||c)&&d()})),ux(e,t);const m={show:d,hide:l.hide,setEnabled:e=>{mx(t,!e)},isEnabled:()=>!wg.isDisabled(s.outerContainer)};return{editorContainer:s.outerContainer.element.dom,api:m}}});const UB="contexttoolbar-hide",jB=(e,t)=>Qs(NT,((o,n)=>{const r=(e=>({hide:()=>js(e,Es()),getValue:()=>Xm.getValue(e)}))(e.get(o));t.onAction(r,n.event.buttonApi)})),WB=(e,t,o)=>(e=>"contextformtogglebutton"===e.type)(t)?((e,t,o)=>{const{primary:n,...r}=t.original,s=or(kw({...r,type:"togglebutton",onAction:v}));return wB(s,o,[jB(e,t)])})(e,t,o):((e,t,o)=>{const{primary:n,...r}=t.original,s=or(xw({...r,type:"button",onAction:v}));return yB(s,o,[jB(e,t)])})(e,t,o),$B=(e,t)=>{const o=e.label.fold((()=>({})),(e=>({"aria-label":e}))),n=Bf(_y.sketch({inputClasses:["tox-toolbar-textfield","tox-toolbar-nav-js"],data:e.initValue(),inputAttributes:o,selectOnFocus:!0,inputBehaviours:ql([Tp.config({mode:"special",onEnter:e=>r.findPrimary(e).map((e=>($s(e),!0))),onLeft:(e,t)=>(t.cut(),D.none()),onRight:(e,t)=>(t.cut(),D.none())})])})),r=((e,t,o)=>{const n=F(t,(t=>Bf(WB(e,t,o))));return{asSpecs:()=>F(n,(e=>e.asSpec())),findPrimary:e=>se(t,((t,o)=>t.primary?D.from(n[o]).bind((t=>t.getOpt(e))).filter(k(wg.isDisabled)):D.none()))}})(n,e.commands,t);return[{title:D.none(),items:[n.asSpec()]},{title:D.none(),items:r.asSpecs()}]},qB=$B,GB=(e,t,o)=>t.bottom-e.y>=o&&e.bottom-t.y>=o,KB=e=>{const t=(e=>{const t=e.getBoundingClientRect();if(t.height<=0&&t.width<=0){const o=dt(Le.fromDom(e.startContainer),e.startOffset).element;return(We(o)?nt(o):D.some(o)).filter(je).map((e=>e.dom.getBoundingClientRect())).getOr(t)}return t})(e.selection.getRng());if(e.inline){const e=zo();return Go(e.left+t.left,e.top+t.top,t.width,t.height)}{const o=Yo(Le.fromDom(e.getBody()));return Go(o.x+t.left,o.y+t.top,t.width,t.height)}},YB=(e,t,o,n=0)=>{const r=Uo(window),s=Ko(Le.fromDom(e.getContentAreaContainer())),a=Hb(e)||zb(e)||Zb(e),{x:i,width:l}=((e,t,o)=>{const n=Math.max(e.x+o,t.x);return{x:n,width:Math.min(e.right-o,t.right)-n}})(s,r,n);if(e.inline&&!a)return Go(i,r.y,l,r.height);{const a=t.header.isPositionedAtTop(),{y:c,bottom:d}=((e,t,o,n,r,s)=>{const a=Le.fromDom(e.getContainer()),i=Bi(a,".tox-editor-header").getOr(a),l=Ko(i),c=l.y>=t.bottom,d=n&&!c;if(e.inline&&d)return{y:Math.max(l.bottom+s,o.y),bottom:o.bottom};if(e.inline&&!d)return{y:o.y,bottom:Math.min(l.y-s,o.bottom)};const m="line"===r?Ko(a):t;return d?{y:Math.max(l.bottom+s,o.y),bottom:Math.min(m.bottom-s,o.bottom)}:{y:Math.max(m.y+s,o.y),bottom:Math.min(l.y-s,o.bottom)}})(e,s,r,a,o,n);return Go(i,c,l,d-c)}},XB={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"],inset:["tox-pop--inset"]},JB={maxHeightFunction:Fc(),maxWidthFunction:wN()},QB=e=>"node"===e,eL=(e,t,o,n,r)=>{const s=KB(e),a=n.lastElement().exists((e=>Xe(o,e)));if(((e,t)=>{const o=e.selection.getRng(),n=dt(Le.fromDom(o.startContainer),o.startOffset);return o.startContainer===o.endContainer&&o.startOffset===o.endOffset-1&&Xe(n.element,t)})(e,o))return a?ZD:ID;if(a)return((e,t,o)=>{const n=Ht(e,"position");Mt(e,"position",t);const r=o(e);return n.each((t=>Mt(e,"position",t))),r})(t,n.getMode(),(()=>GB(s,Ko(t),-20)&&!n.isReposition()?jD:ZD));return("fixed"===n.getMode()?r.y+zo().top:r.y)+(Ut(t)+12)<=s.y?ID:PD},tL=(e,t,o,n)=>{const r=t=>(n,r,s,a,i)=>({...eL(e,a,t,o,i)({...n,y:i.y,height:i.height},r,s,a,i),alwaysFit:!0}),s=e=>QB(n)?[r(e)]:[];return t?{onLtr:e=>[Nl,Tl,Ol,Dl,Al,Ml].concat(s(e)),onRtl:e=>[Nl,Ol,Tl,Al,Dl,Ml].concat(s(e))}:{onLtr:e=>[Ml,Nl,Dl,Tl,Al,Ol].concat(s(e)),onRtl:e=>[Ml,Nl,Al,Ol,Dl,Tl].concat(s(e))}},oL=(e,t)=>{const o=Z(t,(t=>t.predicate(e.dom))),{pass:n,fail:r}=V(o,(e=>"contexttoolbar"===e.type));return{contextToolbars:n,contextForms:r}},nL=(e,t,o)=>{const n=oL(e,t);if(n.contextForms.length>0)return D.some({elem:e,toolbars:[n.contextForms[0]]});{const t=oL(e,o);if(t.contextForms.length>0)return D.some({elem:e,toolbars:[t.contextForms[0]]});if(n.contextToolbars.length>0||t.contextToolbars.length>0){const o=(e=>{if(e.length<=1)return e;{const t=t=>H(e,(e=>e.position===t)),o=t=>Z(e,(e=>e.position===t)),n=t("selection"),r=t("node");if(n||r){if(r&&n){const e=o("node"),t=F(o("selection"),(e=>({...e,position:"node"})));return e.concat(t)}return o(n?"selection":"node")}return o("line")}})(n.contextToolbars.concat(t.contextToolbars));return D.some({elem:e,toolbars:o})}return D.none()}},rL=(e,t,o)=>e(t)?D.none():Ur(t,(e=>{if(je(e)){const{contextToolbars:t,contextForms:n}=oL(e,o.inNodeScope),r=n.length>0?n:(e=>{if(e.length<=1)return e;{const t=t=>W(e,(e=>e.position===t)),o=t("selection").orThunk((()=>t("node"))).orThunk((()=>t("line"))).map((e=>e.position));return o.fold((()=>[]),(t=>Z(e,(e=>e.position===t))))}})(t);return r.length>0?D.some({elem:e,toolbars:r}):D.none()}return D.none()}),e),sL=(e,t)=>{const o={},n=[],r=[],s={},a={},i=(e,i)=>{const l=or(tr("ContextForm",Mw,i));o[e]=l,l.launch.map((o=>{s["form:"+e]={...i.launch,type:"contextformtogglebutton"===o.type?"togglebutton":"button",onAction:()=>{t(l)}}})),"editor"===l.scope?r.push(l):n.push(l),a[e]=l},l=(e,t)=>{var o;(o=t,tr("ContextToolbar",Nw,o)).each((o=>{"editor"===t.scope?r.push(o):n.push(o),a[e]=o}))},c=ae(e);return z(c,(t=>{const o=e[t];"contextform"===o.type?i(t,o):"contexttoolbar"===o.type&&l(t,o)})),{forms:o,inNodeScope:n,inEditorScope:r,lookupTable:a,formNavigators:s}},aL=ya("forward-slide"),iL=ya("backward-slide"),lL=ya("change-slide-event"),cL="tox-pop--resizing",dL="tox-pop--transition",mL=(e,t,o,n)=>{const r=n.backstage,s=r.shared,a=Do().deviceType.isTouch,i=kc(),l=kc(),c=kc(),d=Ei((e=>{const t=Hr([]);return Af.sketch({dom:{tag:"div",classes:["tox-pop"]},fireDismissalEventInstead:{event:"doNotDismissYet"},onShow:e=>{t.set([]),Af.getContent(e).each((e=>{Ft(e.element,"visibility")})),ni(e.element,cL),Ft(e.element,"width")},inlineBehaviours:ql([Ip("context-toolbar-events",[aa(gs(),((e,t)=>{"width"===t.event.raw.propertyName&&(ni(e.element,cL),Ft(e.element,"width"))})),Qs(lL,((e,t)=>{const o=e.element;Ft(o,"width");const n=Xt(o);Af.setContent(e,t.event.contents),ti(o,cL);const r=Xt(o);Mt(o,"width",n+"px"),Af.getContent(e).each((e=>{t.event.focus.bind((e=>(tc(e),sc(o)))).orThunk((()=>(Tp.focusIn(e),rc(ht(o)))))})),setTimeout((()=>{Mt(e.element,"width",r+"px")}),0)})),Qs(aL,((e,o)=>{Af.getContent(e).each((o=>{t.set(t.get().concat([{bar:o,focus:rc(ht(e.element))}]))})),Ws(e,lL,{contents:o.event.forwardContents,focus:D.none()})})),Qs(iL,((e,o)=>{ne(t.get()).each((o=>{t.set(t.get().slice(0,t.get().length-1)),Ws(e,lL,{contents:Ti(o.bar),focus:o.focus})}))}))]),Tp.config({mode:"special",onEscape:o=>ne(t.get()).fold((()=>e.onEscape()),(e=>(js(o,iL),D.some(!0))))})]),lazySink:()=>on.value(e.sink)})})({sink:o,onEscape:()=>(e.focus(),D.some(!0))})),m=()=>{const t=c.get().getOr("node"),o=QB(t)?1:0;return YB(e,s,t,o)},u=()=>!(e.removed||a()&&r.isContextMenuOpen()),g=()=>{if(u()){const t=m(),o=we(c.get(),"node")?((e,t)=>t.filter((e=>yt(e)&&Ue(e))).map(Yo).getOrThunk((()=>KB(e))))(e,i.get()):KB(e);return t.height<=0||!GB(o,t,.01)}return!0},h=()=>{i.clear(),l.clear(),c.clear(),Af.hide(d)},p=()=>{if(Af.isOpen(d)){const e=d.element;Ft(e,"display"),g()?Mt(e,"display","none"):(l.set(0),Af.reposition(d))}},f=t=>({dom:{tag:"div",classes:["tox-pop__dialog"]},components:[t],behaviours:ql([Tp.config({mode:"acyclic"}),Ip("pop-dialog-wrap-events",[ia((t=>{e.shortcuts.add("ctrl+F9","focus statusbar",(()=>Tp.focusIn(t)))})),la((t=>{e.shortcuts.remove("ctrl+F9")}))])])}),b=Qt((()=>sL(t,(e=>{const t=y([e]);Ws(d,aL,{forwardContents:f(t)})})))),y=t=>{const{buttons:o}=e.ui.registry.getAll(),r={...o,...b().formNavigators},a=cb(e)===Uv.scrolling?Uv.scrolling:Uv.default,i=q(F(t,(t=>"contexttoolbar"===t.type?((t,o)=>OB(e,{buttons:t,toolbar:o.items,allowToolbarGroups:!1},n.backstage,D.some(["form:"])))(r,t):((e,t)=>qB(e,t))(t,s.providers))));return WN({type:a,uid:ya("context-toolbar"),initGroups:i,onEscape:D.none,cyclicKeying:!0,providers:s.providers})},w=(t,n)=>{const r="node"===t?s.anchors.node(n):s.anchors.cursor(),c=((e,t,o,n)=>"line"===t?{bubble:Uc(12,0,XB),layouts:{onLtr:()=>[Rl],onRtl:()=>[Bl]},overrides:JB}:{bubble:Uc(0,12,XB,1/12),layouts:tL(e,o,n,t),overrides:JB})(e,t,a(),{lastElement:i.get,isReposition:()=>we(l.get(),0),getMode:()=>rm.getMode(o)});return xn(r,c)},x=(e,t)=>{if(S.cancel(),!u())return;const n=y(e),r=e[0].position,s=w(r,t);c.set(r),l.set(1);const a=d.element;Ft(a,"display"),(e=>we(Ce(e,i.get(),Xe),!0))(t)||(ni(a,dL),rm.reset(o,d)),Af.showWithinBounds(d,f(n),{anchor:s,transition:{classes:[dL],mode:"placement"}},(()=>D.some(m()))),t.fold(i.clear,i.set),g()&&Mt(a,"display","none")};let C=!1;const S=iT((()=>{if(e.hasFocus()&&!e.removed&&!C)if(si(d.element,dL))S.throttle();else{((e,t)=>{const o=Le.fromDom(t.getBody()),n=e=>Xe(e,o),r=Le.fromDom(t.selection.getNode());return(e=>!n(e)&&!Je(o,e))(r)?D.none():nL(r,e.inNodeScope,e.inEditorScope).orThunk((()=>rL(n,r,e)))})(b(),e).fold(h,(e=>{x(e.toolbars,D.some(e.elem))}))}}),17);e.on("init",(()=>{e.on("remove",h),e.on("ScrollContent ScrollWindow ObjectResized ResizeEditor longpress",p),e.on("click keyup focus SetContent",S.throttle),e.on(UB,h),e.on("contexttoolbar-show",(t=>{const o=b();ve(o.lookupTable,t.toolbarKey).each((o=>{x([o],ke(t.target!==e,t.target)),Af.getContent(d).each(Tp.focusIn)}))})),e.on("focusout",(t=>{Mf.setEditorTimeout(e,(()=>{sc(o.element).isNone()&&sc(d.element).isNone()&&h()}),0)})),e.on("SwitchMode",(()=>{e.mode.isReadOnly()&&h()})),e.on("AfterProgressState",(t=>{t.state?h():e.hasFocus()&&S.throttle()})),e.on("dragstart",(()=>{C=!0})),e.on("dragend drop",(()=>{C=!1})),e.on("NodeChange",(e=>{sc(d.element).fold(S.throttle,v)}))}))},uL=(e,t)=>{const o=()=>{const o=t.getOptions(e),n=t.getCurrent(e).map(t.hash),r=kc();return F(o,(o=>({type:"togglemenuitem",text:t.display(o),onSetup:s=>{const a=e=>{e&&(r.on((e=>e.setActive(!1))),r.set(s)),s.setActive(e)};a(we(n,t.hash(o)));const i=t.watcher(e,o,a);return()=>{r.clear(),i()}},onAction:()=>t.setCurrent(e,o)})))};e.ui.registry.addMenuButton(t.name,{tooltip:t.text,icon:t.icon,fetch:e=>e(o()),onSetup:t.onToolbarSetup}),e.ui.registry.addNestedMenuItem(t.name,{type:"nestedmenuitem",text:t.text,getSubmenuItems:o,onSetup:t.onMenuSetup})},gL=e=>({name:"lineheight",text:"Line height",icon:"line-height",getOptions:Fb,hash:e=>((e,t)=>YR(e,t).map((({value:e,unit:t})=>e+t)))(e,["fixed","relative","empty"]).getOr(e),display:x,watcher:(e,t,o)=>e.formatter.formatChanged("lineheight",o,!1,{value:t}).unbind,getCurrent:e=>D.from(e.queryCommandValue("LineHeight")),setCurrent:(e,t)=>e.execCommand("LineHeight",!1,t),onToolbarSetup:mC(e),onMenuSetup:mC(e)}),hL=e=>{uL(e,gL(e)),(e=>D.from(ib(e)).map((t=>({name:"language",text:"Language",icon:"language",getOptions:w(t),hash:e=>m(e.customCode)?e.code:`${e.code}/${e.customCode}`,display:e=>e.title,watcher:(e,t,o)=>{var n;return e.formatter.formatChanged("lang",o,!1,{value:t.code,customValue:null!==(n=t.customCode)&&void 0!==n?n:null}).unbind},getCurrent:e=>{const t=Le.fromDom(e.selection.getNode());return jr(t,(e=>D.some(e).filter(je).bind((e=>Et(e,"lang").map((t=>({code:t,customCode:Et(e,"data-mce-lang").getOrUndefined(),title:""})))))))},setCurrent:(e,t)=>e.execCommand("Lang",!1,t),onToolbarSetup:t=>{const o=Sc();return t.setActive(e.formatter.match("lang",{},void 0,!0)),o.set(e.formatter.formatChanged("lang",t.setActive,!0)),dC(o.clear,mC(e)(t))},onMenuSetup:mC(e)}))))(e).each((t=>uL(e,t)))},pL=(e,t)=>{((e,t)=>{const o=AR(0,t,IR(e));e.ui.registry.addNestedMenuItem("align",{text:t.shared.providers.translate("Align"),onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=AR(0,t,qR(e));e.ui.registry.addNestedMenuItem("fontfamily",{text:t.shared.providers.translate("Fonts"),onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o={type:"advanced",...t.styles},n=AR(0,t,iB(e,o));e.ui.registry.addNestedMenuItem("styles",{text:"Formats",onSetup:mC(e),getSubmenuItems:()=>n.items.validateItems(n.getStyleItems())})})(e,t),((e,t)=>{const o=AR(0,t,VR(e));e.ui.registry.addNestedMenuItem("blocks",{text:"Blocks",onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=AR(0,t,sB(e));e.ui.registry.addNestedMenuItem("fontsize",{text:"Font sizes",onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t)},fL=e=>gC(e,"NodeChange",(t=>{t.setEnabled(e.queryCommandState("outdent")&&e.selection.isEditable())})),vL=e=>{(e=>{e.ui.registry.addButton("outdent",{tooltip:"Decrease indent",icon:"outdent",onSetup:fL(e),onAction:pC(e,"outdent")}),e.ui.registry.addButton("indent",{tooltip:"Increase indent",icon:"indent",onSetup:mC(e),onAction:pC(e,"indent")})})(e)},bL=(e,t)=>o=>{o.setActive(t.get());const n=e=>{t.set(e.state),o.setActive(e.state)};return e.on("PastePlainTextToggle",n),dC((()=>e.off("PastePlainTextToggle",n)),mC(e)(o))},yL=(e,t)=>()=>{e.execCommand("mceToggleFormat",!1,t)},wL=e=>{(e=>{sT.each([{name:"bold",text:"Bold",icon:"bold"},{name:"italic",text:"Italic",icon:"italic"},{name:"underline",text:"Underline",icon:"underline"},{name:"strikethrough",text:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",icon:"superscript"}],((t,o)=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:uC(e,t.name),onAction:yL(e,t.name)})}));for(let t=1;t<=6;t++){const o="h"+t;e.ui.registry.addToggleButton(o,{text:o.toUpperCase(),tooltip:"Heading "+t,onSetup:uC(e,o),onAction:yL(e,o)})}})(e),(e=>{sT.each([{name:"copy",text:"Copy",action:"Copy",icon:"copy"},{name:"help",text:"Help",action:"mceHelp",icon:"help"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all"},{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"print",text:"Print",action:"mcePrint",icon:"print"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onAction:pC(e,t.action)})})),sT.each([{name:"cut",text:"Cut",action:"Cut",icon:"cut"},{name:"paste",text:"Paste",action:"Paste",icon:"paste"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"remove",text:"Remove",action:"Delete",icon:"remove"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:mC(e),onAction:pC(e,t.action)})}))})(e),(e=>{sT.each([{name:"blockquote",text:"Blockquote",action:"mceBlockQuote",icon:"quote"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:pC(e,t.action),onSetup:uC(e,t.name)})}))})(e)},xL=e=>{wL(e),(e=>{sT.each([{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"copy",text:"Copy",action:"Copy",icon:"copy",shortcut:"Meta+C"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all",shortcut:"Meta+A"},{name:"print",text:"Print...",action:"mcePrint",icon:"print",shortcut:"Meta+P"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onAction:pC(e,t.action)})})),sT.each([{name:"bold",text:"Bold",action:"Bold",icon:"bold",shortcut:"Meta+B"},{name:"italic",text:"Italic",action:"Italic",icon:"italic",shortcut:"Meta+I"},{name:"underline",text:"Underline",action:"Underline",icon:"underline",shortcut:"Meta+U"},{name:"strikethrough",text:"Strikethrough",action:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",action:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",action:"Superscript",icon:"superscript"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"cut",text:"Cut",action:"Cut",icon:"cut",shortcut:"Meta+X"},{name:"paste",text:"Paste",action:"Paste",icon:"paste",shortcut:"Meta+V"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onSetup:mC(e),onAction:pC(e,t.action)})})),e.ui.registry.addMenuItem("codeformat",{text:"Code",icon:"sourcecode",onSetup:mC(e),onAction:yL(e,"code")})})(e)},CL=(e,t)=>gC(e,"Undo Redo AddUndo TypingUndo ClearUndos SwitchMode",(o=>{o.setEnabled(!e.mode.isReadOnly()&&e.undoManager[t]())})),SL=e=>{(e=>{e.ui.registry.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onSetup:CL(e,"hasUndo"),onAction:pC(e,"undo")}),e.ui.registry.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onSetup:CL(e,"hasRedo"),onAction:pC(e,"redo")})})(e),(e=>{e.ui.registry.addButton("undo",{tooltip:"Undo",icon:"undo",enabled:!1,onSetup:CL(e,"hasUndo"),onAction:pC(e,"undo")}),e.ui.registry.addButton("redo",{tooltip:"Redo",icon:"redo",enabled:!1,onSetup:CL(e,"hasRedo"),onAction:pC(e,"redo")})})(e)},kL=e=>gC(e,"VisualAid",(t=>{t.setActive(e.hasVisual)})),_L=e=>{(e=>{e.ui.registry.addButton("visualaid",{tooltip:"Visual aids",text:"Visual aids",onAction:pC(e,"mceToggleVisualAid")})})(e),(e=>{e.ui.registry.addToggleMenuItem("visualaid",{text:"Visual aids",onSetup:kL(e),onAction:pC(e,"mceToggleVisualAid")})})(e)},EL=(e,t)=>{(e=>{z([{name:"alignleft",text:"Align left",cmd:"JustifyLeft",icon:"align-left"},{name:"aligncenter",text:"Align center",cmd:"JustifyCenter",icon:"align-center"},{name:"alignright",text:"Align right",cmd:"JustifyRight",icon:"align-right"},{name:"alignjustify",text:"Justify",cmd:"JustifyFull",icon:"align-justify"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:pC(e,t.cmd),onSetup:uC(e,t.name)})})),e.ui.registry.addButton("alignnone",{tooltip:"No alignment",icon:"align-none",onSetup:mC(e),onAction:pC(e,"JustifyNone")})})(e),xL(e),pL(e,t),SL(e),(e=>{(e=>{e.addCommand("mceApplyTextcolor",((t,o)=>{((e,t,o)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.apply(t,{value:o}),e.nodeChanged()}))})(e,t,o)})),e.addCommand("mceRemoveTextcolor",(t=>{((e,t)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.remove(t,{value:null},void 0,!0),e.nodeChanged()}))})(e,t)}))})(e);const t=BC(e),o=LC(e),n=Hr(t),r=Hr(o);$C(e,"forecolor","forecolor",n),$C(e,"backcolor","hilitecolor",r),qC(e,"forecolor","forecolor","Text color",n),qC(e,"backcolor","hilitecolor","Background color",r)})(e),_L(e),vL(e),hL(e),(e=>{const t=Hr(Ab(e)),o=()=>e.execCommand("mceTogglePlainTextPaste");e.ui.registry.addToggleButton("pastetext",{active:!1,icon:"paste-text",tooltip:"Paste as text",onAction:o,onSetup:bL(e,t)}),e.ui.registry.addToggleMenuItem("pastetext",{text:"Paste as text",icon:"paste-text",onAction:o,onSetup:bL(e,t)})})(e)},TL=e=>s(e)?e.split(/[ ,]/):e,OL=e=>t=>t.options.get(e),DL=OL("contextmenu_never_use_native"),AL=OL("contextmenu_avoid_overlap"),ML=e=>{const t=e.ui.registry.getAll().contextMenus,o=e.options.get("contextmenu");return e.options.isSet("contextmenu")?o:Z(o,(e=>be(t,e)))},NL=(e,t)=>({type:"makeshift",x:e,y:t}),RL=e=>"longpress"===e.type||0===e.type.indexOf("touch"),BL=(e,t)=>{const o=Wv.DOM.getPos(e);return((e,t,o)=>NL(e.x+t,e.y+o))(t,o.x,o.y)},LL=(e,t)=>"contextmenu"===t.type||"longpress"===t.type?e.inline?(e=>{if(RL(e)){const t=e.touches[0];return NL(t.pageX,t.pageY)}return NL(e.pageX,e.pageY)})(t):BL(e.getContentAreaContainer(),(e=>{if(RL(e)){const t=e.touches[0];return NL(t.clientX,t.clientY)}return NL(e.clientX,e.clientY)})(t)):HL(e),HL=e=>({type:"selection",root:Le.fromDom(e.selection.getNode())}),IL=(e,t,o)=>{switch(o){case"node":return(e=>({type:"node",node:D.some(Le.fromDom(e.selection.getNode())),root:Le.fromDom(e.getBody())}))(e);case"point":return LL(e,t);case"selection":return HL(e)}},PL=(e,t,o,n,r,s)=>{const a=o(),i=IL(e,t,s);qT(a,oy.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!1,search:D.none()}).map((e=>{t.preventDefault(),Af.showMenuAt(r,{anchor:i},{menu:{markers:vy("normal")},data:e})}))},FL={onLtr:()=>[Nl,Tl,Ol,Dl,Al,Ml,ID,PD,HD,BD,LD,RD],onRtl:()=>[Nl,Ol,Tl,Al,Dl,Ml,ID,PD,LD,RD,HD,BD]},zL={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"]},VL=(e,t,o,n,r,s,a)=>{const i=((e,t,o)=>{const n=IL(e,t,o);return{bubble:Uc(0,"point"===o?12:0,zL),layouts:FL,overrides:{maxWidthFunction:wN(),maxHeightFunction:Fc()},...n}})(e,t,s);qT(o,oy.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!0,search:D.none()}).map((o=>{t.preventDefault();const l=a?Tf.HighlightMenuAndItem:Tf.HighlightNone;Af.showMenuWithinBounds(r,{anchor:i},{menu:{markers:vy("normal"),highlightOnOpen:l},data:o,type:"horizontal"},(()=>D.some(YB(e,n.shared,"node"===s?"node":"selection")))),e.dispatch(UB)}))},ZL=(e,t,o,n,r,s)=>{const a=Do(),i=a.os.isiOS(),l=a.os.isMacOS(),c=a.os.isAndroid(),d=a.deviceType.isTouch(),m=()=>{const a=o();VL(e,t,a,n,r,s,!(c||i||l&&d))};if((l||i)&&"node"!==s){const o=()=>{(e=>{const t=e.selection.getRng(),o=()=>{Mf.setEditorTimeout(e,(()=>{e.selection.setRng(t)}),10),s()};e.once("touchend",o);const n=e=>{e.preventDefault(),e.stopImmediatePropagation()};e.on("mousedown",n,!0);const r=()=>s();e.once("longpresscancel",r);const s=()=>{e.off("touchend",o),e.off("longpresscancel",r),e.off("mousedown",n)}})(e),m()};((e,t)=>{const o=e.selection;if(o.isCollapsed()||t.touches.length<1)return!1;{const n=t.touches[0],r=o.getRng();return Ad(e.getWin(),fd.domRange(r)).exists((e=>e.left<=n.clientX&&e.right>=n.clientX&&e.top<=n.clientY&&e.bottom>=n.clientY))}})(e,t)?o():(e.once("selectionchange",o),e.once("touchend",(()=>e.off("selectionchange",o))))}else m()},UL=e=>s(e)?"|"===e:"separator"===e.type,jL={type:"separator"},WL=e=>{const t=e=>({text:e.text,icon:e.icon,enabled:e.enabled,shortcut:e.shortcut});if(s(e))return e;switch(e.type){case"separator":return jL;case"submenu":return{type:"nestedmenuitem",...t(e),getSubmenuItems:()=>{const t=e.getSubmenuItems();return s(t)?t:F(t,WL)}};default:const o=e;return{type:"menuitem",...t(o),onAction:b(o.onAction)}}},$L=(e,t)=>{if(0===t.length)return e;const o=ne(e).filter((e=>!UL(e))),n=o.fold((()=>[]),(e=>[jL]));return e.concat(n).concat(t).concat([jL])},qL=(e,t)=>!(e=>"longpress"===e.type||be(e,"touches"))(t)&&(2!==t.button||t.target===e.getBody()&&""===t.pointerType),GL=(e,t)=>qL(e,t)?e.selection.getStart(!0):t.target,KL=(e,t,o)=>{const n=Do().deviceType.isTouch,r=Ei(Af.sketch({dom:{tag:"div"},lazySink:t,onEscape:()=>e.focus(),onShow:()=>o.setContextMenuState(!0),onHide:()=>o.setContextMenuState(!1),fireDismissalEventInstead:{},inlineBehaviours:ql([Ip("dismissContextMenu",[Qs(Ls(),((t,o)=>{Mm.close(t),e.focus()}))])])})),a=()=>Af.hide(r),i=t=>{if(DL(e)&&t.preventDefault(),((e,t)=>t.ctrlKey&&!DL(e))(e,t)||(e=>0===ML(e).length)(e))return;const a=((e,t)=>{const o=AL(e),n=qL(e,t)?"selection":"point";if(Me(o)){const r=GL(e,t);return QS(Le.fromDom(r),o)?"node":n}return n})(e,t);(n()?ZL:PL)(e,t,(()=>{const o=GL(e,t),n=e.ui.registry.getAll(),r=ML(e);return((e,t,o)=>{const n=j(t,((t,n)=>ve(e,n.toLowerCase()).map((e=>{const n=e.update(o);if(s(n)&&Me(Ae(n)))return $L(t,n.split(" "));if(l(n)&&n.length>0){const e=F(n,WL);return $L(t,e)}return t})).getOrThunk((()=>t.concat([n])))),[]);return n.length>0&&UL(n[n.length-1])&&n.pop(),n})(n.contextMenus,r,o)}),o,r,a)};e.on("init",(()=>{const t="ResizeEditor ScrollContent ScrollWindow longpresscancel"+(n()?"":" ResizeWindow");e.on(t,a),e.on("longpress contextmenu",i)}))},YL=Ir([{offset:["x","y"]},{absolute:["x","y"]},{fixed:["x","y"]}]),XL=e=>t=>t.translate(-e.left,-e.top),JL=e=>t=>t.translate(e.left,e.top),QL=e=>(t,o)=>j(e,((e,t)=>t(e)),$t(t,o)),eH=(e,t,o)=>e.fold(QL([JL(o),XL(t)]),QL([XL(t)]),QL([])),tH=(e,t,o)=>e.fold(QL([JL(o)]),QL([]),QL([JL(t)])),oH=(e,t,o)=>e.fold(QL([]),QL([XL(o)]),QL([JL(t),XL(o)])),nH=(e,t,o)=>{const n=e.fold(((e,t)=>({position:D.some("absolute"),left:D.some(e+"px"),top:D.some(t+"px")})),((e,t)=>({position:D.some("absolute"),left:D.some(e-o.left+"px"),top:D.some(t-o.top+"px")})),((e,t)=>({position:D.some("fixed"),left:D.some(e+"px"),top:D.some(t+"px")})));return{right:D.none(),bottom:D.none(),...n}},rH=(e,t,o,n)=>{const r=(e,r)=>(s,a)=>{const i=e(t,o,n);return r(s.getOr(i.left),a.getOr(i.top))};return e.fold(r(oH,sH),r(tH,aH),r(eH,iH))},sH=YL.offset,aH=YL.absolute,iH=YL.fixed,lH=(e,t)=>{const o=_t(e,t);return m(o)?NaN:parseInt(o,10)},cH=(e,t,o,n)=>((e,t)=>{const o=e.element,n=lH(o,t.leftAttr),r=lH(o,t.topAttr);return isNaN(n)||isNaN(r)?D.none():D.some($t(n,r))})(e,t).fold((()=>o),(e=>iH(e.left+n.left,e.top+n.top))),dH=(e,t,o,n,r,s)=>{const a=cH(e,t,o,n),i=t.mustSnap?gH(e,t,a,r,s):hH(e,t,a,r,s),l=eH(a,r,s);return((e,t,o)=>{const n=e.element;St(n,t.leftAttr,o.left+"px"),St(n,t.topAttr,o.top+"px")})(e,t,l),i.fold((()=>({coord:iH(l.left,l.top),extra:D.none()})),(e=>({coord:e.output,extra:e.extra})))},mH=(e,t)=>{((e,t)=>{const o=e.element;Ot(o,t.leftAttr),Ot(o,t.topAttr)})(e,t)},uH=(e,t,o,n)=>se(e,(e=>{const r=e.sensor,s=((e,t,o,n,r,s)=>{const a=tH(e,r,s),i=tH(t,r,s);return Math.abs(a.left-i.left)<=o&&Math.abs(a.top-i.top)<=n})(t,r,e.range.left,e.range.top,o,n);return s?D.some({output:rH(e.output,t,o,n),extra:e.extra}):D.none()})),gH=(e,t,o,n,r)=>{const s=t.getSnapPoints(e);return uH(s,o,n,r).orThunk((()=>{const e=j(s,((e,t)=>{const s=t.sensor,a=((e,t,o,n,r,s)=>{const a=tH(e,r,s),i=tH(t,r,s),l=Math.abs(a.left-i.left),c=Math.abs(a.top-i.top);return $t(l,c)})(o,s,t.range.left,t.range.top,n,r);return e.deltas.fold((()=>({deltas:D.some(a),snap:D.some(t)})),(o=>(a.left+a.top)/2<=(o.left+o.top)/2?{deltas:D.some(a),snap:D.some(t)}:e))}),{deltas:D.none(),snap:D.none()});return e.snap.map((e=>({output:rH(e.output,o,n,r),extra:e.extra})))}))},hH=(e,t,o,n,r)=>{const s=t.getSnapPoints(e);return uH(s,o,n,r)};var pH=Object.freeze({__proto__:null,snapTo:(e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const t=Qe(e.element),o=zo(t),s=JA(r),a=((e,t,o)=>({coord:rH(e.output,e.output,t,o),extra:e.extra}))(n,o,s),i=nH(a.coord,0,s);Rt(r,i)}}});const fH="data-initial-z-index",vH=(e,t)=>{e.getSystem().addToGui(t),(e=>{nt(e.element).filter(je).each((t=>{Ht(t,"z-index").each((e=>{St(t,fH,e)})),Mt(t,"z-index",Bt(e.element,"z-index"))}))})(t)},bH=e=>{(e=>{nt(e.element).filter(je).each((e=>{Et(e,fH).fold((()=>Ft(e,"z-index")),(t=>Mt(e,"z-index",t))),Ot(e,fH)}))})(e),e.getSystem().removeFromGui(e)},yH=(e,t,o)=>e.getSystem().build(uk.sketch({dom:{styles:{left:"0px",top:"0px",width:"100%",height:"100%",position:"fixed","z-index":"1000000000000000"},classes:[t]},events:o}));var wH=Er("snaps",[dr("getSnapPoints"),el("onSensor"),dr("leftAttr"),dr("topAttr"),Tr("lazyViewport",Jo),Tr("mustSnap",!1)]);const xH=[Tr("useFixed",T),dr("blockerClass"),Tr("getTarget",x),Tr("onDrag",v),Tr("repositionTarget",!0),Tr("onDrop",v),Rr("getBounds",Jo),wH],CH=e=>((e,t,o,n)=>e.isSome()&&t.isSome()&&o.isSome()?D.some(n(e.getOrDie(),t.getOrDie(),o.getOrDie())):D.none())(Ht(e,"left"),Ht(e,"top"),Ht(e,"position"),((e,t,o)=>("fixed"===o?iH:sH)(parseInt(e,10),parseInt(t,10)))).getOrThunk((()=>{const t=Gt(e);return aH(t.left,t.top)})),SH=(e,t,o,n,r,s,a)=>((e,t,o,n,r)=>{const s=r.bounds,a=tH(t,o,n),i=bl(a.left,s.x,s.x+s.width-r.width),l=bl(a.top,s.y,s.y+s.height-r.height),c=aH(i,l);return t.fold((()=>{const e=oH(c,o,n);return sH(e.left,e.top)}),w(c),(()=>{const e=eH(c,o,n);return iH(e.left,e.top)}))})(0,t.fold((()=>{const e=(t=o,a=s.left,i=s.top,t.fold(((e,t)=>sH(e+a,t+i)),((e,t)=>aH(e+a,t+i)),((e,t)=>iH(e+a,t+i))));var t,a,i;const l=eH(e,n,r);return iH(l.left,l.top)}),(t=>{const a=dH(e,t,o,s,n,r);return a.extra.each((o=>{t.onSensor(e,o)})),a.coord})),n,r,a),kH=(e,t)=>({bounds:e.getBounds(),height:jt(t.element),width:Jt(t.element)}),_H=(e,t,o,n,r)=>{const s=o.update(n,r),a=o.getStartData().getOrThunk((()=>kH(t,e)));s.each((o=>{((e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const s=Qe(e.element),a=zo(s),i=JA(r),l=CH(r),c=SH(e,t.snaps,l,a,i,n,o),d=nH(c,0,i);Rt(r,d)}t.onDrag(e,r,n)})(e,t,a,o)}))},EH=(e,t,o,n)=>{t.each(bH),o.snaps.each((t=>{mH(e,t)}));const r=o.getTarget(e.element);n.reset(),o.onDrop(e,r)},TH=e=>(t,o)=>{const n=e=>{o.setStartData(kH(t,e))};return Ys([Qs(Ms(),(e=>{o.getStartData().each((()=>n(e)))})),...e(t,o,n)])};var OH=Object.freeze({__proto__:null,getData:e=>D.from($t(e.x,e.y)),getDelta:(e,t)=>$t(t.left-e.left,t.top-e.top)});const DH=(e,t,o)=>[Qs(es(),((n,r)=>{if(0!==r.event.raw.button)return;r.stop();const s=()=>EH(n,D.some(l),e,t),a=ek(s,200),i={drop:s,delayDrop:a.schedule,forceDrop:s,move:o=>{a.cancel(),_H(n,e,t,OH,o)}},l=yH(n,e.blockerClass,(e=>Ys([Qs(es(),e.forceDrop),Qs(ns(),e.drop),Qs(ts(),((t,o)=>{e.move(o.event)})),Qs(os(),e.delayDrop)]))(i));o(n),vH(n,l)}))],AH=[...xH,rl("dragger",{handlers:TH(DH)})];var MH=Object.freeze({__proto__:null,getData:e=>{const t=e.raw.touches;return 1===t.length?(e=>{const t=e[0];return D.some($t(t.clientX,t.clientY))})(t):D.none()},getDelta:(e,t)=>$t(t.left-e.left,t.top-e.top)});const NH=(e,t,o)=>{const n=kc(),r=o=>{EH(o,n.get(),e,t),n.clear()};return[Qs(Yr(),((s,a)=>{a.stop();const i=()=>r(s),l={drop:i,delayDrop:v,forceDrop:i,move:o=>{_H(s,e,t,MH,o)}},c=yH(s,e.blockerClass,(e=>Ys([Qs(Yr(),e.forceDrop),Qs(Jr(),e.drop),Qs(Qr(),e.drop),Qs(Xr(),((t,o)=>{e.move(o.event)}))]))(l));n.set(c);o(s),vH(s,c)})),Qs(Xr(),((o,n)=>{n.stop(),_H(o,e,t,MH,n.event)})),Qs(Jr(),((e,t)=>{t.stop(),r(e)})),Qs(Qr(),r)]},RH=AH,BH=[...xH,rl("dragger",{handlers:TH(NH)})],LH=[...xH,rl("dragger",{handlers:TH(((e,t,o)=>[...DH(e,t,o),...NH(e,t,o)]))})];var HH=Object.freeze({__proto__:null,mouse:RH,touch:BH,mouseOrTouch:LH});var IH=Object.freeze({__proto__:null,init:()=>{let e=D.none(),t=D.none();const o=w({});return Ia({readState:o,reset:()=>{e=D.none(),t=D.none()},update:(t,o)=>t.getData(o).bind((o=>((t,o)=>{const n=e.map((e=>t.getDelta(e,o)));return e=D.some(o),n})(t,o))),getStartData:()=>t,setStartData:e=>{t=D.some(e)}})}});const PH=Xl({branchKey:"mode",branches:HH,name:"dragging",active:{events:(e,t)=>e.dragger.handlers(e,t)},extra:{snap:e=>({sensor:e.sensor,range:e.range,output:e.output,extra:D.from(e.extra)})},state:IH,apis:pH}),FH=(e,t,o,n,r,s)=>e.fold((()=>PH.snap({sensor:aH(o-20,n-20),range:$t(r,s),output:aH(D.some(o),D.some(n)),extra:{td:t}})),(e=>{const r=o-20,s=n-20,a=e.element.dom.getBoundingClientRect();return PH.snap({sensor:aH(r,s),range:$t(40,40),output:aH(D.some(o-a.width/2),D.some(n-a.height/2)),extra:{td:t}})})),zH=(e,t,o)=>({getSnapPoints:e,leftAttr:"data-drag-left",topAttr:"data-drag-top",onSensor:(e,n)=>{const r=n.td;((e,t)=>e.exists((e=>Xe(e,t))))(t.get(),r)||(t.set(r),o(r))},mustSnap:!0}),VH=e=>Bf(Nf.sketch({dom:{tag:"div",classes:["tox-selector"]},buttonBehaviours:ql([PH.config({mode:"mouseOrTouch",blockerClass:"blocker",snaps:e}),Wk.config({})]),eventOrder:{mousedown:["dragging","alloy.base.behaviour"],touchstart:["dragging","alloy.base.behaviour"]}})),ZH=(e,t)=>{const o=Hr([]),n=Hr([]),r=Hr(!1),s=kc(),a=kc(),i=e=>{const o=Yo(e);return FH(m.getOpt(t),e,o.x,o.y,o.width,o.height)},l=e=>{const o=Yo(e);return FH(u.getOpt(t),e,o.right,o.bottom,o.width,o.height)},c=zH((()=>F(o.get(),(e=>i(e)))),s,(t=>{a.get().each((o=>{e.dispatch("TableSelectorChange",{start:t,finish:o})}))})),d=zH((()=>F(n.get(),(e=>l(e)))),a,(t=>{s.get().each((o=>{e.dispatch("TableSelectorChange",{start:o,finish:t})}))})),m=VH(c),u=VH(d),g=Ei(m.asSpec()),h=Ei(u.asSpec()),p=(t,o,n,r)=>{const s=n(o);PH.snapTo(t,s);((t,o,n,r)=>{const s=o.dom.getBoundingClientRect();Ft(t.element,"display");const a=ot(Le.fromDom(e.getBody())).dom.innerHeight,i=n(s),l=r(s,a);(i||l)&&Mt(t.element,"display","none")})(t,o,(e=>e[r]<0),((e,t)=>e[r]>t))},f=e=>p(g,e,i,"top"),v=e=>p(h,e,l,"bottom");Do().deviceType.isTouch()&&(e.on("TableSelectionChange",(e=>{r.get()||(um(t,g),um(t,h),r.set(!0)),s.set(e.start),a.set(e.finish),e.otherCells.each((t=>{o.set(t.upOrLeftCells),n.set(t.downOrRightCells),f(e.start),v(e.finish)}))})),e.on("ResizeEditor ResizeWindow ScrollContent",(()=>{s.get().each(f),a.get().each(v)})),e.on("TableSelectionClear",(()=>{r.get()&&(pm(g),pm(h),r.set(!1)),s.clear(),a.clear()})))};const UH=(e,t,o)=>{var n;const r=null!==(n=t.delimiter)&&void 0!==n?n:"›",s=t=>j(t,((t,n,s)=>{const a=((t,n,r)=>Nf.sketch({dom:{tag:"div",classes:["tox-statusbar__path-item"],attributes:{"data-index":r,"aria-level":r+1}},components:[Ci(t)],action:t=>{e.focus(),e.selection.select(n),e.nodeChanged()},buttonBehaviours:ql([px(o.isDisabled),gx()])}))(n.name,n.element,s);return 0===s?t.concat([a]):t.concat([{dom:{tag:"div",classes:["tox-statusbar__path-divider"],attributes:{"aria-hidden":!0}},components:[Ci(` ${r} `)]},a])}),[]);return{dom:{tag:"div",classes:["tox-statusbar__path"],attributes:{role:"navigation"}},behaviours:ql([Tp.config({mode:"flow",selector:"div[role=button]"}),wg.config({disabled:o.isDisabled}),gx(),yk.config({}),Hp.config({}),Ip("elementPathEvents",[ia(((t,o)=>{e.shortcuts.add("alt+F11","focus statusbar elementpath",(()=>Tp.focusIn(t))),e.on("NodeChange",(o=>{const n=(t=>{const o=[];let n=t.length;for(;n-- >0;){const s=t[n];if(1===s.nodeType&&"BR"!==(r=s).nodeName&&!r.getAttribute("data-mce-bogus")&&"bookmark"!==r.getAttribute("data-mce-type")){const t=cC(e,s);if(t.isDefaultPrevented()||o.push({name:t.name,element:s}),t.isPropagationStopped())break}}var r;return o})(o.parents),r=n.length>0?s(n):[];Hp.set(t,r)}))}))])]),components:[]}};var jH;!function(e){e[e.None=0]="None",e[e.Both=1]="Both",e[e.Vertical=2]="Vertical"}(jH||(jH={}));const WH=(e,t,o)=>{const n=Le.fromDom(e.getContainer()),r=((e,t,o,n,r)=>{const s={height:LB(n+t.top,tb(e),nb(e))};return o===jH.Both&&(s.width=LB(r+t.left,eb(e),ob(e))),s})(e,t,o,Ut(n),Xt(n));le(r,((e,t)=>{p(e)&&Mt(n,t,BB(e))})),(e=>{e.dispatch("ResizeEditor")})(e)},$H=(e,t,o,n)=>{const r=$t(20*o,20*n);return WH(e,r,t),D.some(!0)},qH=(e,t)=>{const o=(e=>{const t=Db(e);return!1===t?jH.None:"both"===t?jH.Both:jH.Vertical})(e);if(o===jH.None)return D.none();const n=o===jH.Both?"Press the arrow keys to resize the editor.":"Press the Up and Down arrow keys to resize the editor.";return D.some(zv("resize-handle",{tag:"div",classes:["tox-statusbar__resize-handle"],attributes:{title:t.translate("Resize"),"aria-label":t.translate(n)},behaviours:[PH.config({mode:"mouse",repositionTarget:!1,onDrag:(t,n,r)=>WH(e,r,o),blockerClass:"tox-blocker"}),Tp.config({mode:"special",onLeft:()=>$H(e,o,-1,0),onRight:()=>$H(e,o,1,0),onUp:()=>$H(e,o,0,-1),onDown:()=>$H(e,o,0,1)}),yk.config({}),Zp.config({})]},t.icons))},GH=(e,t)=>{const o=()=>{const o=[];return e.hasPlugin("wordcount")&&o.push(((e,t)=>{const o=(e,o,n)=>Hp.set(e,[Ci(t.translate(["{0} "+n,o[n]]))]);return Nf.sketch({dom:{tag:"button",classes:["tox-statusbar__wordcount"]},components:[],buttonBehaviours:ql([px(t.isDisabled),gx(),yk.config({}),Hp.config({}),Xm.config({store:{mode:"memory",initialValue:{mode:"words",count:{words:0,characters:0}}}}),Ip("wordcount-events",[da((e=>{const t=Xm.getValue(e),n="words"===t.mode?"characters":"words";Xm.setValue(e,{mode:n,count:t.count}),o(e,t.count,n)})),ia((t=>{e.on("wordCountUpdate",(e=>{const{mode:n}=Xm.getValue(t);Xm.setValue(t,{mode:n,count:e.wordCount}),o(t,e.wordCount,n)}))}))])]),eventOrder:{[Cs()]:["disabling","alloy.base.behaviour","wordcount-events"]}})})(e,t)),Ob(e)&&o.push({dom:{tag:"span",classes:["tox-statusbar__branding"]},components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/powered-by-tiny?utm_campaign=editor_referral&utm_medium=poweredby&utm_source=tinymce&utm_content=v6",rel:"noopener",target:"_blank","aria-label":Mv.translate(["Powered by {0}","Tiny"])},innerHtml:'\n \n\n'.trim()},behaviours:ql([Zp.config({})])}]}),{dom:{tag:"div",classes:["tox-statusbar__right-container"]},components:o}},n=()=>{const n=[],r=Rb(e),s=Tb(e),a=Ob(e)||e.hasPlugin("wordcount"),i=()=>{const e="tox-statusbar__text-container--flex-start",t="tox-statusbar__text-container--flex-end";if(r){const o="tox-statusbar__text-container-3-cols";return a||s?a&&!s?[o,t]:[o,e]:[o,"tox-statusbar__text-container--space-around"]}return[a&&!s?t:e]};return s&&n.push(UH(e,{},t)),r&&n.push((()=>{const e=Ex("Alt+0");return{dom:{tag:"div",classes:["tox-statusbar__help-text"]},components:[Ci(Mv.translate(["Press {0} for help",e]))]}})()),a&&n.push(o()),n.length>0?[{dom:{tag:"div",classes:["tox-statusbar__text-container",...i()]},components:n}]:[]};return{dom:{tag:"div",classes:["tox-statusbar"]},components:(()=>{const o=n(),r=qH(e,t);return o.concat(r.toArray())})()}},KH=(e,t)=>t.get().getOrDie(`UI for ${e} has not been rendered`),YH=(e,t)=>{const o=e.inline,n=o?ZB:NB,r=Gb(e)?PM:YA,s=(()=>{const e=kc(),t=kc(),o=kc();return{dialogUi:e,popupUi:t,mainUi:o,getUiMotherships:()=>{const o=e.get().map((e=>e.mothership)),n=t.get().map((e=>e.mothership));return o.fold((()=>n.toArray()),(e=>n.fold((()=>[e]),(t=>Xe(e.element,t.element)?[e]:[e,t]))))},lazyGetInOuterOrDie:(e,t)=>()=>o.get().bind((e=>t(e.outerContainer))).getOrDie(`Could not find ${e} element in OuterContainer`)}})(),a=kc(),i=kc(),l=kc(),c=Do().deviceType.isTouch()?["tox-platform-touch"]:[],d=Ub(e),m=cb(e),u=Bf({dom:{tag:"div",classes:["tox-anchorbar"]}}),g=Bf({dom:{tag:"div",classes:["tox-bottom-anchorbar"]}}),h=()=>s.mainUi.get().map((e=>e.outerContainer)).bind(vR.getHeader),p=s.lazyGetInOuterOrDie("anchor bar",u.getOpt),f=s.lazyGetInOuterOrDie("bottom anchor bar",g.getOpt),v=s.lazyGetInOuterOrDie("toolbar",vR.getToolbar),b=s.lazyGetInOuterOrDie("throbber",vR.getThrobber),y=IA({popup:()=>on.fromOption(s.popupUi.get().map((e=>e.sink)),"(popup) UI has not been rendered"),dialog:()=>on.fromOption(s.dialogUi.get().map((e=>e.sink)),"UI has not been rendered")},e,p,f),w=()=>vR.parts.promotion({dom:{tag:"div",classes:["tox-promotion"]}}),x=()=>{const t=(()=>{const t={attributes:{[Kc]:d?Gc.BottomToTop:Gc.TopToBottom}},o=vR.parts.menubar({dom:{tag:"div",classes:["tox-menubar"]},backstage:y.popup,onEscape:()=>{e.focus()}}),n=vR.parts.toolbar({dom:{tag:"div",classes:["tox-toolbar"]},getSink:y.popup.shared.getSink,providers:y.popup.shared.providers,onEscape:()=>{e.focus()},onToolbarToggled:t=>{((e,t)=>{e.dispatch("ToggleToolbarDrawer",{state:t})})(e,t)},type:m,lazyToolbar:v,lazyHeader:()=>h().getOrDie("Could not find header element"),...t}),r=vR.parts["multiple-toolbar"]({dom:{tag:"div",classes:["tox-toolbar-overlord"]},providers:y.popup.shared.providers,onEscape:()=>{e.focus()},type:m}),s=Zb(e),a=zb(e),i=Hb(e),l=Nb(e),c=w(),g=s||a||i,p=l?[c,o]:[o];return vR.parts.header({dom:{tag:"div",classes:["tox-editor-header"].concat(g?[]:["tox-editor-header--empty"]),...t},components:q([i?p:[],s?[r]:a?[n]:[],Wb(e)?[]:[u.asSpec()]]),sticky:Gb(e),editor:e,sharedBackstage:y.popup.shared})})(),n={dom:{tag:"div",classes:["tox-sidebar-wrap"]},components:[vR.parts.socket({dom:{tag:"div",classes:["tox-edit-area"]}}),vR.parts.sidebar({dom:{tag:"div",classes:["tox-sidebar"]}})]},r=vR.parts.throbber({dom:{tag:"div",classes:["tox-throbber"]},backstage:y.popup}),s=vR.parts.viewWrapper({backstage:y.popup}),i=Eb(e)&&!o?D.some(GH(e,y.popup.shared.providers)):D.none(),l=q([d?[]:[t],o?[]:[n],d?[t]:[]]),p=vR.parts.editorContainer({components:q([l,o?[]:[g.asSpec(),...i.toArray()]])}),f=qb(e),b={role:"application",...Mv.isRtl()?{dir:"rtl"}:{},...f?{"aria-hidden":"true"}:{}},x=Ei(vR.sketch({dom:{tag:"div",classes:["tox","tox-tinymce"].concat(o?["tox-tinymce-inline"]:[]).concat(d?["tox-tinymce--toolbar-bottom"]:[]).concat(c),styles:{visibility:"hidden",...f?{opacity:"0",border:"0"}:{}},attributes:b},components:[p,...o?[]:[s],r],behaviours:ql([gx(),wg.config({disableClass:"tox-tinymce--disabled"}),Tp.config({mode:"cyclic",selector:".tox-menubar, .tox-toolbar, .tox-toolbar__primary, .tox-toolbar__overflow--open, .tox-sidebar__overflow--open, .tox-statusbar__path, .tox-statusbar__wordcount, .tox-statusbar__branding a, .tox-statusbar__resize-handle"})])})),C=gk(x);return a.set(C),{mothership:C,outerContainer:x}},C=t=>{const o=BB(HB(e)),n=BB((e=>IB(e).getOr(Qv(e)))(e));return e.inline||(Pt("div","width",n)&&Mt(t.element,"width",n),Pt("div","height",o)?Mt(t.element,"height",o):Mt(t.element,"height","400px")),o},S=t=>{const{mainUi:o,popupUi:s,uiMotherships:a}=t;ce(db(e),((t,o)=>{e.ui.registry.addGroupToolbarButton(o,t)}));const{buttons:i,menuItems:l,contextToolbars:c,sidebars:d,views:u}=e.ui.registry.getAll(),g=Vb(e),p={menuItems:l,menus:Yb(e),menubar:fb(e),toolbar:g.getOrThunk((()=>vb(e))),allowToolbarGroups:m===Uv.floating,buttons:i,sidebar:d,views:u};var f;f=o.outerContainer,e.addShortcut("alt+F9","focus menubar",(()=>{vR.focusMenubar(f)})),e.addShortcut("alt+F10","focus toolbar",(()=>{vR.focusToolbar(f)})),e.addCommand("ToggleToolbarDrawer",((e,t)=>{(null==t?void 0:t.skipFocus)?vR.toggleToolbarDrawerWithoutFocusing(f):vR.toggleToolbarDrawer(f)})),e.addQueryStateHandler("ToggleToolbarDrawer",(()=>vR.isToolbarDrawerToggled(f))),((e,t,o)=>{const n=(e,n)=>{z([t,...o],(t=>{t.broadcastEvent(e,n)}))},r=(e,n)=>{z([t,...o],(t=>{t.broadcastOn([e],n)}))},s=e=>r(Nm(),{target:e.target}),a=jo(),i=Ec(a,"touchstart",s),l=Ec(a,"touchmove",(e=>n(Ds(),e))),c=Ec(a,"touchend",(e=>n(As(),e))),d=Ec(a,"mousedown",s),m=Ec(a,"mouseup",(e=>{0===e.raw.button&&r(Bm(),{target:e.target})})),u=e=>r(Nm(),{target:Le.fromDom(e.target)}),g=e=>{0===e.button&&r(Bm(),{target:Le.fromDom(e.target)})},h=()=>{z(e.editorManager.get(),(t=>{e!==t&&t.dispatch("DismissPopups",{relatedTarget:e})}))},p=e=>n(Ms(),Oc(e)),f=e=>{r(Rm(),{}),n(Ns(),Oc(e))},v=ht(Le.fromDom(e.getElement())),b=Tc(v,"scroll",(o=>{requestAnimationFrame((()=>{if(null!=e.getContainer()){const r=XS(e,t.element).map((e=>[e.element,...e.others])).getOr([]);H(r,(e=>Xe(e,o.target)))&&(e.dispatch("ElementScroll",{target:o.target.dom}),n(Fs(),o))}}))})),y=()=>r(Rm(),{}),w=t=>{t.state&&r(Nm(),{target:Le.fromDom(e.getContainer())})},x=e=>{r(Nm(),{target:Le.fromDom(e.relatedTarget.getContainer())})};e.on("PostRender",(()=>{e.on("click",u),e.on("tap",u),e.on("mouseup",g),e.on("mousedown",h),e.on("ScrollWindow",p),e.on("ResizeWindow",f),e.on("ResizeEditor",y),e.on("AfterProgressState",w),e.on("DismissPopups",x)})),e.on("remove",(()=>{e.off("click",u),e.off("tap",u),e.off("mouseup",g),e.off("mousedown",h),e.off("ScrollWindow",p),e.off("ResizeWindow",f),e.off("ResizeEditor",y),e.off("AfterProgressState",w),e.off("DismissPopups",x),d.unbind(),i.unbind(),l.unbind(),c.unbind(),m.unbind(),b.unbind()})),e.on("detach",(()=>{z([t,...o],wm),z([t,...o],(e=>e.destroy()))}))})(e,o.mothership,a),r.setup(e,y.popup.shared,h),EL(e,y.popup),KL(e,y.popup.shared.getSink,y.popup),(e=>{const{sidebars:t}=e.ui.registry.getAll();z(ae(t),(o=>{const n=t[o],r=()=>we(D.from(e.queryCommandValue("ToggleSidebar")),o);e.ui.registry.addToggleButton(o,{icon:n.icon,tooltip:n.tooltip,onAction:t=>{e.execCommand("ToggleSidebar",!1,o),t.setActive(r())},onSetup:t=>{t.setActive(r());const o=()=>t.setActive(r());return e.on("ToggleSidebar",o),()=>{e.off("ToggleSidebar",o)}}})}))})(e),dN(e,b,y.popup.shared),mL(e,c,s.sink,{backstage:y.popup}),ZH(e,s.sink);const v={targetNode:e.getElement(),height:C(o.outerContainer)};return n.render(e,t,p,y.popup,v)};return{popups:{backstage:y.popup,getMothership:()=>KH("popups",l)},dialogs:{backstage:y.dialog,getMothership:()=>KH("dialogs",i)},renderUI:()=>{const o=x(),n=(()=>{const t=$b(e),o=Xe(wt(),t)&&"grid"===Bt(t,"display"),n={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-tinymce-aux"].concat(c),attributes:{...Mv.isRtl()?{dir:"rtl"}:{}}},behaviours:ql([rm.config({useFixed:()=>r.isDocked(h)})])},s={dom:{styles:{width:document.body.clientWidth+"px"}},events:Ys([Qs(Ns(),(e=>{Mt(e.element,"width",document.body.clientWidth+"px")}))])},a=Ei(xn(n,o?s:{})),l=gk(a);return i.set(l),{sink:a,mothership:l}})(),a=Kb(e)?(()=>{const e={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-silver-popup-sink","tox-tinymce-aux"].concat(c),attributes:{...Mv.isRtl()?{dir:"rtl"}:{}}},behaviours:ql([rm.config({useFixed:()=>r.isDocked(h),getBounds:()=>t.getPopupSinkBounds()})])},o=Ei(e),n=gk(o);return l.set(n),{sink:o,mothership:n}})():(e=>(l.set(e.mothership),e))(n);s.dialogUi.set(n),s.popupUi.set(a),s.mainUi.set(o);const d={popupUi:a,dialogUi:n,mainUi:o,uiMotherships:s.getUiMotherships()};return S(d)}}},XH=w([dr("lazySink"),yr("dragBlockClass"),Rr("getBounds",Jo),Tr("useTabstopAt",O),Tr("firstTabstop",0),Tr("eventOrder",{}),Jm("modalBehaviours",[Tp]),tl("onExecute"),nl("onEscape")]),JH={sketch:x},QH=w([Du({name:"draghandle",overrides:(e,t)=>({behaviours:ql([PH.config({mode:"mouse",getTarget:e=>Ni(e,'[role="dialog"]').getOr(e),blockerClass:e.dragBlockClass.getOrDie(new Error("The drag blocker class was not specified for a dialog with a drag handle: \n"+JSON.stringify(t,null,2)).message),getBounds:e.getDragBounds})])})}),Tu({schema:[dr("dom")],name:"title"}),Tu({factory:JH,schema:[dr("dom")],name:"close"}),Tu({factory:JH,schema:[dr("dom")],name:"body"}),Du({factory:JH,schema:[dr("dom")],name:"footer"}),Ou({factory:{sketch:(e,t)=>({...e,dom:t.dom,components:t.components})},schema:[Tr("dom",{tag:"div",styles:{position:"fixed",left:"0px",top:"0px",right:"0px",bottom:"0px"}}),Tr("components",[])],name:"blocker"})]),eI=og({name:"ModalDialog",configFields:XH(),partFields:QH(),factory:(e,t,o,n)=>{const r=kc(),s=ya("modal-events"),a={...e.eventOrder,[Rs()]:[s].concat(e.eventOrder["alloy.system.attached"]||[])};return{uid:e.uid,dom:e.dom,components:t,apis:{show:t=>{r.set(t);const o=e.lazySink(t).getOrDie(),s=n.blocker(),a=o.getSystem().build({...s,components:s.components.concat([Ti(t)]),behaviours:ql([Zp.config({}),Ip("dialog-blocker-events",[aa(ss(),(()=>{iN.isBlocked(t)||Tp.focusIn(t)}))])])});um(o,a),Tp.focusIn(t)},hide:e=>{r.clear(),nt(e.element).each((t=>{e.getSystem().getByDom(t).each((e=>{pm(e)}))}))},getBody:t=>Zu(t,e,"body"),getFooter:t=>Vu(t,e,"footer"),setIdle:e=>{iN.unblock(e)},setBusy:(e,t)=>{iN.block(e,t)}},eventOrder:a,domModification:{attributes:{role:"dialog","aria-modal":"true"}},behaviours:eu(e.modalBehaviours,[Hp.config({}),Tp.config({mode:"cyclic",onEnter:e.onExecute,onEscape:e.onEscape,useTabstopAt:e.useTabstopAt,firstTabstop:e.firstTabstop}),iN.config({getRoot:r.get}),Ip(s,[ia((t=>{((e,t)=>{const o=Et(e,"id").fold((()=>{const e=ya("dialog-label");return St(t,"id",e),e}),x);St(e,"aria-labelledby",o)})(t.element,Zu(t,e,"title").element)}))])])}},apis:{show:(e,t)=>{e.show(t)},hide:(e,t)=>{e.hide(t)},getBody:(e,t)=>e.getBody(t),getFooter:(e,t)=>e.getFooter(t),setBusy:(e,t,o)=>{e.setBusy(t,o)},setIdle:(e,t)=>{e.setIdle(t)}}}),tI=Pn([Uy,jy].concat(Fw)),oI=qn,nI=[fw("button"),nw,Mr("align","end",["start","end"]),mw,dw,Sr("buttonType",["primary","secondary"])],rI=[...nI,$y],sI=[hr("type",["submit","cancel","custom"]),...rI],aI=[hr("type",["menu"]),ow,rw,nw,br("items",tI),...nI],iI=[...nI,hr("type",["togglebutton"]),gr("tooltip"),nw,ow,Nr("active",!1)],lI=sr("type",{submit:sI,cancel:sI,custom:sI,menu:aI,togglebutton:iI}),cI=[Uy,$y,hr("level",["info","warn","error","success"]),Gy,Tr("url","")],dI=Pn(cI),mI=[Uy,$y,dw,fw("button"),nw,cw,Sr("buttonType",["primary","secondary","toolbar"]),mw],uI=Pn(mI),gI=[Uy,jy],hI=gI.concat([sw]),pI=gI.concat([Wy,dw]),fI=Pn(pI),vI=qn,bI=hI.concat([uw("auto")]),yI=Pn(bI),wI=Zn([Ky,$y,Gy]),xI=hI.concat([Ar("storageKey","default")]),CI=Pn(xI),SI=$n,kI=Pn(hI),_I=$n,EI=gI.concat([Ar("tag","textarea"),gr("scriptId"),gr("scriptUrl"),((e,t)=>Or(e,t,Yn))("settings",void 0)]),TI=gI.concat([Ar("tag","textarea"),pr("init")]),OI=Qn((e=>tr("customeditor.old",In(TI),e).orThunk((()=>tr("customeditor.new",In(EI),e))))),DI=$n,AI=Pn(hI),MI=Fn(Mn),NI=e=>[Uy,ur("columns"),e],RI=[Uy,gr("html"),Mr("presets","presentation",["presentation","document"])],BI=Pn(RI),LI=hI.concat([Nr("border",!1),Nr("sandboxed",!0),Nr("streamContent",!1),Nr("transparent",!0)]),HI=Pn(LI),II=$n,PI=Pn(gI.concat([Cr("height")])),FI=Pn([gr("url"),xr("zoom"),xr("cachedWidth"),xr("cachedHeight")]),zI=hI.concat([Cr("inputMode"),Cr("placeholder"),Nr("maximized",!1),dw]),VI=Pn(zI),ZI=$n,UI=e=>[Uy,Wy,e,Mr("align","start",["start","center","end"])],jI=[$y,Ky],WI=[$y,br("items",ar(0,(()=>$I)))],$I=zn([Pn(jI),Pn(WI)]),qI=hI.concat([br("items",$I),dw]),GI=Pn(qI),KI=$n,YI=hI.concat([vr("items",[$y,Ky]),Dr("size",1),dw]),XI=Pn(YI),JI=$n,QI=hI.concat([Nr("constrain",!0),dw]),eP=Pn(QI),tP=Pn([gr("width"),gr("height")]),oP=gI.concat([Wy,Dr("min",0),Dr("max",0)]),nP=Pn(oP),rP=Wn,sP=[Uy,br("header",$n),br("cells",Fn($n))],aP=Pn(sP),iP=hI.concat([Cr("placeholder"),Nr("maximized",!1),dw]),lP=Pn(iP),cP=$n,dP=[hr("type",["directory","leaf"]),qy,gr("id"),wr("menu",VM)],mP=Pn(dP),uP=dP.concat([br("children",ar(0,(()=>Jn("type",{directory:gP,leaf:mP}))))]),gP=Pn(uP),hP=Jn("type",{directory:gP,leaf:mP}),pP=[Uy,br("items",hP),kr("onLeafAction"),kr("onToggleExpand"),Br("defaultExpandedIds",[],$n),Cr("defaultSelectedId")],fP=Pn(pP),vP=hI.concat([Mr("filetype","file",["image","media","file"]),dw,Cr("picker_text")]),bP=Pn(vP),yP=Pn([Ky,gw]),wP=e=>ir("items","items",{tag:"required",process:{}},Fn(Qn((t=>tr(`Checking item of ${e}`,xP,t).fold((e=>on.error(rr(e))),(e=>on.value(e))))))),xP=Ln((()=>{return Jn("type",{alertbanner:dI,bar:Pn((e=wP("bar"),[Uy,e])),button:uI,checkbox:fI,colorinput:CI,colorpicker:kI,dropzone:AI,grid:Pn(NI(wP("grid"))),iframe:HI,input:VI,listbox:GI,selectbox:XI,sizeinput:eP,slider:nP,textarea:lP,urlinput:bP,customeditor:OI,htmlpanel:BI,imagepreview:PI,collection:yI,label:Pn(UI(wP("label"))),table:aP,tree:fP,panel:SP});var e})),CP=[Uy,Tr("classes",[]),br("items",xP)],SP=Pn(CP),kP=[fw("tab"),qy,br("items",xP)],_P=[Uy,vr("tabs",kP)],EP=Pn(_P),TP=rI,OP=lI,DP=Pn([gr("title"),mr("body",Jn("type",{panel:SP,tabpanel:EP})),Ar("size","normal"),Br("buttons",[],OP),Tr("initialData",{}),Rr("onAction",v),Rr("onChange",v),Rr("onSubmit",v),Rr("onClose",v),Rr("onCancel",v),Rr("onTabChange",v)]),AP=Pn([hr("type",["cancel","custom"]),...TP]),MP=Pn([gr("title"),gr("url"),xr("height"),xr("width"),_r("buttons",AP),Rr("onAction",v),Rr("onCancel",v),Rr("onClose",v),Rr("onMessage",v)]),NP=e=>a(e)?[e].concat(G(fe(e),NP)):l(e)?G(e,NP):[],RP=e=>s(e.type)&&s(e.name),BP={checkbox:vI,colorinput:SI,colorpicker:_I,dropzone:MI,input:ZI,iframe:II,imagepreview:FI,selectbox:JI,sizeinput:tP,slider:rP,listbox:KI,size:tP,textarea:cP,urlinput:yP,customeditor:DI,collection:wI,togglemenuitem:oI},LP=e=>{const t=(e=>Z(NP(e),RP))(e),o=G(t,(e=>(e=>D.from(BP[e.type]))(e).fold((()=>[]),(t=>[mr(e.name,t)]))));return Pn(o)},HP=e=>{var t;return{internalDialog:or(tr("dialog",DP,e)),dataValidator:LP(e),initialData:null!==(t=e.initialData)&&void 0!==t?t:{}}},IP={open:(e,t)=>{const o=HP(t);return e(o.internalDialog,o.initialData,o.dataValidator)},openUrl:(e,t)=>e(or(tr("dialog",MP,t))),redial:e=>HP(e)};var PP=Object.freeze({__proto__:null,events:(e,t)=>{const o=(o,n)=>{e.updateState.each((e=>{const r=e(o,n);t.set(r)})),e.renderComponents.each((r=>{const s=r(n,t.get());(e.reuseDom?Dp:Op)(o,s)}))};return Ys([Qs(xs(),((t,n)=>{const r=n;if(!r.universal){const n=e.channel;L(r.channels,n)&&o(t,r.data)}})),ia(((t,n)=>{e.initialData.each((e=>{o(t,e)}))}))])}});var FP=Object.freeze({__proto__:null,getState:(e,t,o)=>o}),zP=[dr("channel"),yr("renderComponents"),yr("updateState"),yr("initialData"),Nr("reuseDom",!0)];const VP=Kl({fields:zP,name:"reflecting",active:PP,apis:FP,state:Object.freeze({__proto__:null,init:()=>{const e=Hr(D.none());return{readState:()=>e.get().getOr("none"),get:e.get,set:e.set,clear:()=>e.set(D.none())}}})}),ZP=e=>{const t=[],o={};return le(e,((e,n)=>{e.fold((()=>{t.push(n)}),(e=>{o[n]=e}))})),t.length>0?on.error(t):on.value(o)},UP=(e,t,o)=>{const n=Bf(zE.sketch((n=>({dom:{tag:"div",classes:["tox-form"].concat(e.classes)},components:F(e.items,(e=>SD(n,e,t,o)))}))));return{dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[n.asSpec()]}],behaviours:ql([Tp.config({mode:"acyclic",useTabstopAt:k(hT)}),KE(n),JE(n,{postprocess:e=>ZP(e).fold((e=>(console.error(e),{})),x)}),Ip("dialog-body-panel",[Qs(ss(),((e,t)=>{e.getSystem().broadcastOn([wT],{newFocus:D.some(t.event.target)})}))])])}},jP=tg({name:"TabButton",configFields:[Tr("uid",void 0),dr("value"),ir("dom","dom",_n((()=>({attributes:{role:"tab",id:ya("aria"),"aria-selected":"false"}}))),Un()),yr("action"),Tr("domModification",{}),Jm("tabButtonBehaviours",[Zp,Tp,Xm]),dr("view")],factory:(e,t)=>({uid:e.uid,dom:e.dom,components:e.components,events:Qp(e.action),behaviours:eu(e.tabButtonBehaviours,[Zp.config({}),Tp.config({mode:"execution",useSpace:!0,useEnter:!0}),Xm.config({store:{mode:"memory",initialValue:e.value}})]),domModification:e.domModification})}),WP=w([dr("tabs"),dr("dom"),Tr("clickToDismiss",!1),Jm("tabbarBehaviours",[Mg,Tp]),Ji(["tabClass","selectedClass"])]),$P=Au({factory:jP,name:"tabs",unit:"tab",overrides:e=>{const t=(e,t)=>{Mg.dehighlight(e,t),Ws(e,Vs(),{tabbar:e,button:t})},o=(e,t)=>{Mg.highlight(e,t),Ws(e,zs(),{tabbar:e,button:t})};return{action:n=>{const r=n.getSystem().getByUid(e.uid).getOrDie(),s=Mg.isHighlighted(r,n);(s&&e.clickToDismiss?t:s?v:o)(r,n)},domModification:{classes:[e.markers.tabClass]}}}}),qP=w([$P]),GP=og({name:"Tabbar",configFields:WP(),partFields:qP(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,"debug.sketcher":"Tabbar",domModification:{attributes:{role:"tablist"}},behaviours:eu(e.tabbarBehaviours,[Mg.config({highlightClass:e.markers.selectedClass,itemClass:e.markers.tabClass,onHighlight:(e,t)=>{St(t.element,"aria-selected","true")},onDehighlight:(e,t)=>{St(t.element,"aria-selected","false")}}),Tp.config({mode:"flow",getInitial:e=>Mg.getHighlighted(e).map((e=>e.element)),selector:"."+e.markers.tabClass,executeOnMove:!0})])})}),KP=tg({name:"Tabview",configFields:[Jm("tabviewBehaviours",[Hp])],factory:(e,t)=>({uid:e.uid,dom:e.dom,behaviours:eu(e.tabviewBehaviours,[Hp.config({})]),domModification:{attributes:{role:"tabpanel"}}})}),YP=w([Tr("selectFirst",!0),el("onChangeTab"),el("onDismissTab"),Tr("tabs",[]),Jm("tabSectionBehaviours",[])]),XP=Tu({factory:GP,schema:[dr("dom"),fr("markers",[dr("tabClass"),dr("selectedClass")])],name:"tabbar",defaults:e=>({tabs:e.tabs})}),JP=Tu({factory:KP,name:"tabview"}),QP=w([XP,JP]),eF=og({name:"TabSection",configFields:YP(),partFields:QP(),factory:(e,t,o,n)=>{const r=(t,o)=>{Vu(t,e,"tabbar").each((e=>{o(e).each($s)}))};return{uid:e.uid,dom:e.dom,components:t,behaviours:Qm(e.tabSectionBehaviours),events:Ys(q([e.selectFirst?[ia(((e,t)=>{r(e,Mg.getFirst)}))]:[],[Qs(zs(),((t,o)=>{(t=>{const o=Xm.getValue(t);Vu(t,e,"tabview").each((n=>{const r=W(e.tabs,(e=>e.value===o));r.each((o=>{const r=o.view();Et(t.element,"id").each((e=>{St(n.element,"aria-labelledby",e)})),Hp.set(n,r),e.onChangeTab(n,t,r)}))}))})(o.event.button)})),Qs(Vs(),((t,o)=>{const n=o.event.button;e.onDismissTab(t,n)}))]])),apis:{getViewItems:t=>Vu(t,e,"tabview").map((e=>Hp.contents(e))).getOr([]),showTab:(e,t)=>{r(e,(e=>{const o=Mg.getCandidates(e);return W(o,(e=>Xm.getValue(e)===t)).filter((t=>!Mg.isHighlighted(e,t)))}))}}}},apis:{getViewItems:(e,t)=>e.getViewItems(t),showTab:(e,t,o)=>{e.showTab(t,o)}}}),tF=(e,t)=>{Mt(e,"height",t+"px"),Mt(e,"flex-basis",t+"px")},oF=(e,t,o)=>{Ni(e,'[role="dialog"]').each((e=>{Bi(e,'[role="tablist"]').each((n=>{o.get().map((o=>(Mt(t,"height","0"),Mt(t,"flex-basis","0"),Math.min(o,((e,t,o)=>{const n=tt(e).dom,r=Ni(e,".tox-dialog-wrap").getOr(e);let s;s="fixed"===Bt(r,"position")?Math.max(n.clientHeight,window.innerHeight):Math.max(n.offsetHeight,n.scrollHeight);const a=Ut(t),i=t.dom.offsetLeft>=o.dom.offsetLeft+Xt(o)?Math.max(Ut(o),a):a,l=parseInt(Bt(e,"margin-top"),10)||0,c=parseInt(Bt(e,"margin-bottom"),10)||0;return s-(Ut(e)+l+c-i)})(e,t,n))))).each((e=>{tF(t,e)}))}))}))},nF=e=>Bi(e,'[role="tabpanel"]'),rF=e=>{const t=kc(),o=[ia((o=>{const n=o.element;nF(n).each((r=>{Mt(r,"visibility","hidden"),o.getSystem().getByDom(r).toOptional().each((o=>{const n=((e,t,o)=>F(e,((n,r)=>{Hp.set(o,e[r].view());const s=t.dom.getBoundingClientRect();return Hp.set(o,[]),s.height})))(e,r,o),s=(e=>oe(ee(e,((e,t)=>e>t?-1:e{oe(e).each((e=>eF.showTab(t,e.value)))})(e,o),requestAnimationFrame((()=>{oF(n,r,t)}))}))})),Qs(Ns(),(e=>{const o=e.element;nF(o).each((e=>{oF(o,e,t)}))})),Qs(Rk,((e,o)=>{const n=e.element;nF(n).each((e=>{const o=rc(ht(e));Mt(e,"visibility","hidden");const r=Ht(e,"height").map((e=>parseInt(e,10)));Ft(e,"height"),Ft(e,"flex-basis");const s=e.dom.getBoundingClientRect().height;r.forall((e=>s>e))?(t.set(s),oF(n,e,t)):r.each((t=>{tF(e,t)})),Ft(e,"visibility"),o.each(tc)}))}))];return{extraEvents:o,selectFirst:!1}},sF="send-data-to-section",aF="send-data-to-view",iF=(e,t,o)=>{const n=Hr({}),r=e=>{const t=Xm.getValue(e),o=ZP(t).getOr({}),r=n.get(),s=xn(r,o);n.set(s)},s=e=>{const t=n.get();Xm.setValue(e,t)},a=Hr(null),i=F(e.tabs,(e=>({value:e.name,dom:{tag:"div",classes:["tox-dialog__body-nav-item"]},components:[Ci(o.shared.providers.translate(e.title))],view:()=>[zE.sketch((n=>({dom:{tag:"div",classes:["tox-form"]},components:F(e.items,(e=>SD(n,e,t,o))),formBehaviours:ql([Tp.config({mode:"acyclic",useTabstopAt:k(hT)}),Ip("TabView.form.events",[ia(s),la(r)]),Ql.config({channels:zr([{key:sF,value:{onReceive:r}},{key:aF,value:{onReceive:s}}])})])})))]}))),l=rF(i);return eF.sketch({dom:{tag:"div",classes:["tox-dialog__body"]},onChangeTab:(e,t,o)=>{const n=Xm.getValue(t);Ws(e,Nk,{name:n,oldName:a.get()}),a.set(n)},tabs:i,components:[eF.parts.tabbar({dom:{tag:"div",classes:["tox-dialog__body-nav"]},components:[GP.parts.tabs({})],markers:{tabClass:"tox-tab",selectedClass:"tox-dialog__body-nav-item--active"},tabbarBehaviours:ql([yk.config({})])}),eF.parts.tabview({dom:{tag:"div",classes:["tox-dialog__body-content"]}})],selectFirst:l.selectFirst,tabSectionBehaviours:ql([Ip("tabpanel",l.extraEvents),Tp.config({mode:"acyclic"}),ag.config({find:e=>oe(eF.getViewItems(e))}),QE(D.none(),(e=>(e.getSystem().broadcastOn([sF],{}),n.get())),((e,t)=>{n.set(t),e.getSystem().broadcastOn([aF],{})}))])})},lF=(e,t,o,n,r)=>({dom:{tag:"div",classes:["tox-dialog__content-js"],attributes:{...o.map((e=>({id:e}))).getOr({}),...r?{"aria-live":"polite"}:{}}},components:[],behaviours:ql([YE(0),VP.config({channel:`${vT}-${t}`,updateState:(e,t)=>D.some({isTabPanel:()=>"tabpanel"===t.body.type}),renderComponents:e=>{const t=e.body;return"tabpanel"===t.type?[iF(t,e.initialData,n)]:[UP(t,e.initialData,n)]},initialData:e})])}),cF=qv.deviceType.isTouch(),dF=(e,t)=>({dom:{tag:"div",styles:{display:"none"},classes:["tox-dialog__header"]},components:[e,t]}),mF=(e,t)=>eI.parts.close(Nf.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":t.translate("Close")}},action:e,buttonBehaviours:ql([yk.config({})])})),uF=()=>eI.parts.title({dom:{tag:"div",classes:["tox-dialog__title"],innerHtml:"",styles:{display:"none"}}}),gF=(e,t)=>eI.parts.body({dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[{dom:Rf(`

    ${Av(t.translate(e))}

    `)}]}]}),hF=e=>eI.parts.footer({dom:{tag:"div",classes:["tox-dialog__footer"]},components:e}),pF=(e,t)=>[uk.sketch({dom:{tag:"div",classes:["tox-dialog__footer-start"]},components:e}),uk.sketch({dom:{tag:"div",classes:["tox-dialog__footer-end"]},components:t})],fF=e=>{const t="tox-dialog",o=t+"-wrap",n=o+"__backdrop",r=t+"__disable-scroll";return eI.sketch({lazySink:e.lazySink,onEscape:t=>(e.onEscape(t),D.some(!0)),useTabstopAt:e=>!hT(e),firstTabstop:e.firstTabstop,dom:{tag:"div",classes:[t].concat(e.extraClasses),styles:{position:"relative",...e.extraStyles}},components:[e.header,e.body,...e.footer.toArray()],parts:{blocker:{dom:Rf(`
    `),components:[{dom:{tag:"div",classes:cF?[n,n+"--opaque"]:[n]}}]}},dragBlockClass:o,modalBehaviours:ql([Zp.config({}),Ip("dialog-events",e.dialogEvents.concat([aa(ss(),((e,t)=>{iN.isBlocked(e)||Tp.focusIn(e)})),Qs(Is(),((e,t)=>{e.getSystem().broadcastOn([wT],{newFocus:t.event.newFocus})}))])),Ip("scroll-lock",[ia((()=>{ti(wt(),r)})),la((()=>{ni(wt(),r)}))]),...e.extraBehaviours]),eventOrder:{[Cs()]:["dialog-events"],[Rs()]:["scroll-lock","dialog-events","alloy.base.behaviour"],[Bs()]:["alloy.base.behaviour","dialog-events","scroll-lock"],...e.eventOrder}})},vF=e=>Nf.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":e.translate("Close"),title:e.translate("Close")}},buttonBehaviours:ql([yk.config({})]),components:[zv("close",{tag:"span",classes:["tox-icon"]},e.icons)],action:e=>{js(e,Tk)}}),bF=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__title"],attributes:{...o.map((e=>({id:e}))).getOr({})}},components:[],behaviours:ql([VP.config({channel:`${fT}-${t}`,initialData:e,renderComponents:e=>[Ci(n.translate(e.title))]})])}),yF=()=>({dom:Rf('
    ')}),wF=(e,t,o)=>((e,t,o)=>{const n=eI.parts.title(bF(e,t,D.none(),o)),r=eI.parts.draghandle(yF()),s=eI.parts.close(vF(o)),a=[n].concat(e.draggable?[r]:[]).concat([s]);return uk.sketch({dom:Rf('
    '),components:a})})({title:o.shared.providers.translate(e),draggable:o.dialog.isDraggableModal()},t,o.shared.providers),xF=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__busy-spinner"],attributes:{"aria-label":o.translate(e)},styles:{left:"0px",right:"0px",bottom:"0px",top:`${n.getOr(0)}px`,position:"absolute"}},behaviours:t,components:[{dom:Rf('
    ')}]}),CF=(e,t,o)=>({onClose:()=>o.closeWindow(),onBlock:o=>{const n=Bi(e().element,".tox-dialog__header").map((e=>Ut(e)));eI.setBusy(e(),((e,r)=>xF(o.message,r,t,n)))},onUnblock:()=>{eI.setIdle(e())}}),SF="tox-dialog--fullscreen",kF="tox-dialog--width-lg",_F="tox-dialog--width-md",EF=e=>{switch(e){case"large":return D.some(kF);case"medium":return D.some(_F);default:return D.none()}},TF=(e,t)=>{const o=Le.fromDom(t.element.dom);si(o,SF)||(ii(o,[kF,_F]),EF(e).each((e=>ti(o,e))))},OF=(e,t)=>{const o=Le.fromDom(e.element.dom),n=li(o),r=W(n,(e=>e===kF||e===_F)).or(EF(t));((e,t)=>{z(t,(t=>{ri(e,t)}))})(o,[SF,...r.toArray()])},DF=(e,t,o)=>Ei(fF({...e,firstTabstop:1,lazySink:o.shared.getSink,extraBehaviours:[tT({}),...e.extraBehaviours],onEscape:e=>{js(e,Tk)},dialogEvents:t,eventOrder:{[xs()]:[VP.name(),Ql.name()],[Rs()]:["scroll-lock",VP.name(),"messages","dialog-events","alloy.base.behaviour"],[Bs()]:["alloy.base.behaviour","dialog-events","messages",VP.name(),"scroll-lock"]}})),AF=(e,t={})=>F(e,(e=>"menu"===e.type?(e=>{const o=F(e.items,(e=>{const o=ve(t,e.name).getOr(Hr(!1));return{...e,storage:o}}));return{...e,items:o}})(e):e)),MF=e=>j(e,((e,t)=>{if("menu"===t.type){return j(t.items,((e,t)=>(e[t.name]=t.storage,e)),e)}return e}),{}),NF=(e,t)=>[na(ss(),gT),e(Ek,((e,o,n,r)=>{rc(ht(r.element)).fold(v,oc),t.onClose(),o.onClose()})),e(Tk,((e,t,o,n)=>{t.onCancel(e),js(n,Ek)})),Qs(Mk,((e,o)=>t.onUnblock())),Qs(Ak,((e,o)=>t.onBlock(o.event)))],RF=(e,t,o)=>{const n=(t,o)=>Qs(t,((t,n)=>{r(t,((r,s)=>{o(e(),r,n.event,t)}))})),r=(e,t)=>{VP.getState(e).get().each((o=>{t(o.internalDialog,e)}))};return[...NF(n,t),n(Dk,((e,t)=>t.onSubmit(e))),n(_k,((e,t,o)=>{t.onChange(e,{name:o.name})})),n(Ok,((e,t,n,r)=>{const s=()=>r.getSystem().isConnected()?Tp.focusIn(r):void 0,a=e=>Tt(e,"disabled")||Et(e,"aria-disabled").exists((e=>"true"===e)),i=ht(r.element),l=rc(i);t.onAction(e,{name:n.name,value:n.value}),rc(i).fold(s,(e=>{a(e)||l.exists((t=>Je(e,t)&&a(t)))?s():o().toOptional().filter((t=>!Je(t.element,e))).each(s)}))})),n(Nk,((e,t,o)=>{t.onTabChange(e,{newTabName:o.name,oldTabName:o.oldName})})),la((t=>{const o=e();Xm.setValue(t,o.getData())}))]},BF=(e,t)=>{const o=t.map((e=>e.footerButtons)).getOr([]),n=V(o,(e=>"start"===e.align)),r=(e,t)=>uk.sketch({dom:{tag:"div",classes:[`tox-dialog__footer-${e}`]},components:F(t,(e=>e.memento.asSpec()))});return[r("start",n.pass),r("end",n.fail)]},LF=(e,t,o)=>({dom:Rf(''),components:[],behaviours:ql([VP.config({channel:`${bT}-${t}`,initialData:e,updateState:(e,t)=>{const n=F(t.buttons,(e=>{const t=Bf(((e,t)=>sD(e,e.type,t))(e,o));return{name:e.name,align:e.align,memento:t}}));return D.some({lookupByName:t=>((e,t,o)=>W(t,(e=>e.name===o)).bind((t=>t.memento.getOpt(e))))(e,n,t),footerButtons:n})},renderComponents:BF})])}),HF=(e,t,o)=>eI.parts.footer(LF(e,t,o)),IF=(e,t)=>{if(e.getRoot().getSystem().isConnected()){const o=ag.getCurrent(e.getFormWrapper()).getOr(e.getFormWrapper());return zE.getField(o,t).orThunk((()=>{const o=e.getFooter().bind((e=>VP.getState(e).get()));return o.bind((e=>e.lookupByName(t)))}))}return D.none()},PF=(e,t,o)=>{const n=t=>{const o=e.getRoot();o.getSystem().isConnected()&&t(o)},r={getData:()=>{const t=e.getRoot(),n=t.getSystem().isConnected()?e.getFormWrapper():t;return{...Xm.getValue(n),...ce(o,(e=>e.get()))}},setData:t=>{n((n=>{const s=r.getData(),a=xn(s,t),i=((e,t)=>{const o=e.getRoot();return VP.getState(o).get().map((e=>or(tr("data",e.dataValidator,t)))).getOr(t)})(e,a),l=e.getFormWrapper();Xm.setValue(l,i),le(o,((e,t)=>{be(a,t)&&e.set(a[t])}))}))},setEnabled:(t,o)=>{IF(e,t).each(o?wg.enable:wg.disable)},focus:t=>{IF(e,t).each(Zp.focus)},block:e=>{if(!s(e))throw new Error("The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument");n((t=>{Ws(t,Ak,{message:e})}))},unblock:()=>{n((e=>{js(e,Mk)}))},showTab:t=>{n((o=>{const n=e.getBody();VP.getState(n).get().exists((e=>e.isTabPanel()))&&ag.getCurrent(n).each((e=>{eF.showTab(e,t)}))}))},redial:s=>{n((n=>{const a=e.getId(),i=t(s),l=AF(i.internalDialog.buttons,o);n.getSystem().broadcastOn([`${pT}-${a}`],i),n.getSystem().broadcastOn([`${fT}-${a}`],i.internalDialog),n.getSystem().broadcastOn([`${vT}-${a}`],i.internalDialog),n.getSystem().broadcastOn([`${bT}-${a}`],{...i.internalDialog,buttons:l}),r.setData(i.initialData)}))},close:()=>{n((e=>{js(e,Ek)}))},toggleFullscreen:e.toggleFullscreen};return r},FF=(e,t,o)=>{const n=ya("dialog"),r=e.internalDialog,s=wF(r.title,n,o),a=Hr(r.size),i=EF(a.get()).toArray(),l=((e,t,o)=>{const n=lF(e,t,D.none(),o,!1);return eI.parts.body(n)})({body:r.body,initialData:r.initialData},n,o),c=AF(r.buttons),d=MF(c),m=ke(0!==c.length,HF({buttons:c},n,o)),u=RF((()=>f),CF((()=>h),o.shared.providers,t),o.shared.getSink),g={id:n,header:s,body:l,footer:m,extraClasses:i,extraBehaviours:[VP.config({channel:`${pT}-${n}`,updateState:(e,t)=>(a.set(t.internalDialog.size),TF(t.internalDialog.size,e),D.some(t)),initialData:e})],extraStyles:{}},h=DF(g,u,o),p={getId:w(n),getRoot:w(h),getBody:()=>eI.getBody(h),getFooter:()=>eI.getFooter(h),getFormWrapper:()=>{const e=eI.getBody(h);return ag.getCurrent(e).getOr(e)},toggleFullscreen:()=>{OF(h,a.get())}},f=PF(p,t.redial,d);return{dialog:h,instanceApi:f}},zF=(e,t,o,n=!1,r)=>{const s=ya("dialog"),a=ya("dialog-label"),i=ya("dialog-content"),l=e.internalDialog,c=Hr(l.size),d=EF(c.get()).toArray(),m=Bf(((e,t,o,n)=>uk.sketch({dom:Rf('
    '),components:[bF(e,t,D.some(o),n),yF(),vF(n)],containerBehaviours:ql([PH.config({mode:"mouse",blockerClass:"blocker",getTarget:e=>Li(e,'[role="dialog"]').getOrDie(),snaps:{getSnapPoints:()=>[],leftAttr:"data-drag-left",topAttr:"data-drag-top"}})])}))({title:l.title,draggable:!0},s,a,o.shared.providers)),u=Bf(((e,t,o,n,r)=>lF(e,t,D.some(o),n,r))({body:l.body,initialData:l.initialData},s,i,o,n)),g=AF(l.buttons),h=MF(g),p=ke(0!==g.length,Bf(((e,t,o)=>LF(e,t,o))({buttons:g},s,o))),f=RF((()=>b),{onBlock:e=>{iN.block(v,((t,n)=>{const r=m.getOpt(v).map((e=>Ut(e.element)));return xF(e.message,n,o.shared.providers,r)}))},onUnblock:()=>{iN.unblock(v)},onClose:()=>t.closeWindow()},o.shared.getSink),v=Ei({dom:{tag:"div",classes:["tox-dialog","tox-dialog-inline",...d],attributes:{role:"dialog","aria-labelledby":a}},eventOrder:{[xs()]:[VP.name(),Ql.name()],[Cs()]:["execute-on-form"],[Rs()]:["reflecting","execute-on-form"]},behaviours:ql([Tp.config({mode:"cyclic",onEscape:e=>(js(e,Ek),D.some(!0)),useTabstopAt:e=>!hT(e)&&("button"!==Ve(e)||"disabled"!==_t(e,"disabled")),firstTabstop:1}),VP.config({channel:`${pT}-${s}`,updateState:(e,t)=>(c.set(t.internalDialog.size),TF(t.internalDialog.size,e),r(),D.some(t)),initialData:e}),Zp.config({}),Ip("execute-on-form",f.concat([aa(ss(),((e,t)=>{Tp.focusIn(e)})),Qs(Is(),((e,t)=>{e.getSystem().broadcastOn([wT],{newFocus:t.event.newFocus})}))])),iN.config({getRoot:()=>D.some(v)}),Hp.config({}),tT({})]),components:[m.asSpec(),u.asSpec(),...p.map((e=>e.asSpec())).toArray()]}),b=PF({getId:w(s),getRoot:w(v),getFooter:()=>p.map((e=>e.get(v))),getBody:()=>u.get(v),getFormWrapper:()=>{const e=u.get(v);return ag.getCurrent(e).getOr(e)},toggleFullscreen:()=>{OF(v,c.get())}},t.redial,h);return{dialog:v,instanceApi:b}};var VF=tinymce.util.Tools.resolve("tinymce.util.URI");const ZF=["insertContent","setContent","execCommand","close","block","unblock"],UF=e=>a(e)&&-1!==ZF.indexOf(e.mceAction),jF=(e,t,o,n)=>{const r=ya("dialog"),i=wF(e.title,r,n),l=(e=>{const t={dom:{tag:"div",classes:["tox-dialog__content-js"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-iframe"]},components:[mT(D.none(),{dom:{tag:"iframe",attributes:{src:e.url}},behaviours:ql([yk.config({}),Zp.config({})])})]}],behaviours:ql([Tp.config({mode:"acyclic",useTabstopAt:k(hT)})])};return eI.parts.body(t)})(e),c=e.buttons.bind((e=>0===e.length?D.none():D.some(HF({buttons:e},r,n)))),m=((e,t)=>{const o=(t,o)=>Qs(t,((t,r)=>{n(t,((n,s)=>{o(e(),n,r.event,t)}))})),n=(e,t)=>{VP.getState(e).get().each((o=>{t(o,e)}))};return[...NF(o,t),o(Ok,((e,t,o)=>{t.onAction(e,{name:o.name})}))]})((()=>w),CF((()=>y),n.shared.providers,t)),u={...e.height.fold((()=>({})),(e=>({height:e+"px","max-height":e+"px"}))),...e.width.fold((()=>({})),(e=>({width:e+"px","max-width":e+"px"})))},h=e.width.isNone()&&e.height.isNone()?["tox-dialog--width-lg"]:[],p=new VF(e.url,{base_uri:new VF(window.location.href)}),f=`${p.protocol}://${p.host}${p.port?":"+p.port:""}`,v=Sc(),b=[VP.config({channel:`${pT}-${r}`,updateState:(e,t)=>D.some(t),initialData:e}),Ip("messages",[ia((()=>{const t=Ec(Le.fromDom(window),"message",(t=>{if(p.isSameOrigin(new VF(t.raw.origin))){const n=t.raw.data;UF(n)?((e,t,o)=>{switch(o.mceAction){case"insertContent":e.insertContent(o.content);break;case"setContent":e.setContent(o.content);break;case"execCommand":const n=!!d(o.ui)&&o.ui;e.execCommand(o.cmd,n,o.value);break;case"close":t.close();break;case"block":t.block(o.message);break;case"unblock":t.unblock()}})(o,w,n):(e=>!UF(e)&&a(e)&&be(e,"mceAction"))(n)&&e.onMessage(w,n)}}));v.set(t)})),la(v.clear)]),Ql.config({channels:{[yT]:{onReceive:(e,t)=>{Bi(e.element,"iframe").each((e=>{const o=e.dom.contentWindow;g(o)&&o.postMessage(t,f)}))}}}})],y=DF({id:r,header:i,body:l,footer:c,extraClasses:h,extraBehaviours:b,extraStyles:u},m,n),w=(e=>{const t=t=>{e.getSystem().isConnected()&&t(e)};return{block:e=>{if(!s(e))throw new Error("The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument");t((t=>{Ws(t,Ak,{message:e})}))},unblock:()=>{t((e=>{js(e,Mk)}))},close:()=>{t((e=>{js(e,Ek)}))},sendMessage:e=>{t((t=>{t.getSystem().broadcastOn([yT],e)}))}}})(y);return{dialog:y,instanceApi:w}},WF=(e,t)=>or(tr("data",t,e)),$F=e=>QS(e,".tox-alert-dialog")||QS(e,".tox-confirm-dialog"),qF=(e,t,o)=>t&&o?[]:[OM.config({contextual:{lazyContext:()=>D.some(Ko(Le.fromDom(e.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top"],lazyViewport:t=>XS(e,t.element).map((e=>({bounds:JS(e),optScrollEnv:D.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))).getOrThunk((()=>({bounds:Jo(),optScrollEnv:D.none()})))})],GF=e=>{const t=e.editor,o=Gb(t),n=(e=>{const t=e.shared;return{open:(o,n)=>{const r=()=>{eI.hide(l),n()},s=Bf(sD({name:"close-alert",text:"OK",primary:!0,buttonType:D.some("primary"),align:"end",enabled:!0,icon:D.none()},"cancel",e)),a=uF(),i=mF(r,t.providers),l=Ei(fF({lazySink:()=>t.getSink(),header:dF(a,i),body:gF(o,t.providers),footer:D.some(hF(pF([],[s.asSpec()]))),onEscape:r,extraClasses:["tox-alert-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Qs(Tk,r)],eventOrder:{}}));eI.show(l);const c=s.get(l);Zp.focus(c)}}})(e.backstages.dialog),r=(e=>{const t=e.shared;return{open:(o,n)=>{const r=e=>{eI.hide(c),n(e)},s=Bf(sD({name:"yes",text:"Yes",primary:!0,buttonType:D.some("primary"),align:"end",enabled:!0,icon:D.none()},"submit",e)),a=sD({name:"no",text:"No",primary:!1,buttonType:D.some("secondary"),align:"end",enabled:!0,icon:D.none()},"cancel",e),i=uF(),l=mF((()=>r(!1)),t.providers),c=Ei(fF({lazySink:()=>t.getSink(),header:dF(i,l),body:gF(o,t.providers),footer:D.some(hF(pF([],[a,s.asSpec()]))),onEscape:()=>r(!1),extraClasses:["tox-confirm-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Qs(Tk,(()=>r(!1))),Qs(Dk,(()=>r(!0)))],eventOrder:{}}));eI.show(c);const d=s.get(c);Zp.focus(d)}}})(e.backstages.dialog),s=(o,n)=>IP.openUrl((o=>{const r=jF(o,{closeWindow:()=>{eI.hide(r.dialog),n(r.instanceApi)}},t,e.backstages.dialog);return eI.show(r.dialog),r.instanceApi}),o),a=(t,o)=>IP.open(((t,n,r)=>{const s=n,a=FF({dataValidator:r,initialData:s,internalDialog:t},{redial:IP.redial,closeWindow:()=>{eI.hide(a.dialog),o(a.instanceApi)}},e.backstages.dialog);return eI.show(a.dialog),a.instanceApi.setData(s),a.instanceApi}),t),i=(n,r,s,a)=>IP.open(((n,i,l)=>{const c=WF(i,l),d=kc(),m=e.backstages.popup.shared.header.isPositionedAtTop(),u=()=>d.on((e=>{Af.reposition(e),o&&m||OM.refresh(e)})),g=zF({dataValidator:l,initialData:c,internalDialog:n},{redial:IP.redial,closeWindow:()=>{d.on(Af.hide),t.off("ResizeEditor",u),d.clear(),s(g.instanceApi)}},e.backstages.popup,a.ariaAttrs,u),h=Ei(Af.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:a.persistent?{event:"doNotDismissYet"}:{},...m?{}:{fireRepositionEventInstead:{}},inlineBehaviours:ql([Ip("window-manager-inline-events",[Qs(Ls(),((e,t)=>{js(g.dialog,Tk)}))]),...qF(t,o,m)]),isExtraPart:(e,t)=>$F(t)}));d.set(h);return Af.showWithinBounds(h,Ti(g.dialog),{anchor:r},(()=>{const e=t.inline?wt():Le.fromDom(t.getContainer()),o=Ko(e);return D.some(o)})),o&&m||(OM.refresh(h),t.on("ResizeEditor",u)),g.instanceApi.setData(c),Tp.focusIn(g.dialog),g.instanceApi}),n),l=(o,n,r,s)=>IP.open(((o,a,i)=>{const l=WF(a,i),c=kc(),d=e.backstages.popup.shared.header.isPositionedAtTop(),m=()=>c.on((e=>{Af.reposition(e),OM.refresh(e)})),u=zF({dataValidator:i,initialData:l,internalDialog:o},{redial:IP.redial,closeWindow:()=>{c.on(Af.hide),t.off("ResizeEditor ScrollWindow ElementScroll",m),c.clear(),r(u.instanceApi)}},e.backstages.popup,s.ariaAttrs,m),g=Ei(Af.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:s.persistent?{event:"doNotDismissYet"}:{},...d?{}:{fireRepositionEventInstead:{}},inlineBehaviours:ql([Ip("window-manager-inline-events",[Qs(Ls(),((e,t)=>{js(u.dialog,Tk)}))]),OM.config({contextual:{lazyContext:()=>D.some(Ko(Le.fromDom(t.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top","bottom"],lazyViewport:e=>XS(t,e.element).map((e=>({bounds:JS(e),optScrollEnv:D.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))).getOrThunk((()=>({bounds:Jo(),optScrollEnv:D.none()})))})]),isExtraPart:(e,t)=>$F(t)}));c.set(g);return Af.showWithinBounds(g,Ti(u.dialog),{anchor:n},(()=>e.backstages.popup.shared.getSink().toOptional().bind((e=>{const o=XS(t,e.element).map((e=>JS(e))).getOr(Jo()),n=Ko(Le.fromDom(t.getContentAreaContainer())),r=Xo(n,o);return D.some(Go(r.x,r.y,r.width,r.height-15))})))),OM.refresh(g),t.on("ResizeEditor ScrollWindow ElementScroll ResizeWindow",m),u.instanceApi.setData(l),Tp.focusIn(u.dialog),u.instanceApi}),o);return{open:(t,o,n)=>{if(!m(o)){if("toolbar"===o.inline)return i(t,e.backstages.popup.shared.anchors.inlineDialog(),n,o);if("bottom"===o.inline)return l(t,e.backstages.popup.shared.anchors.inlineBottomDialog(),n,o);if("cursor"===o.inline)return i(t,e.backstages.popup.shared.anchors.cursor(),n,o)}return a(t,n)},openUrl:(e,t)=>s(e,t),alert:(e,t)=>{n.open(e,t)},close:e=>{e.close()},confirm:(e,t)=>{r.open(e,t)}}},KF=e=>{Yv(e),(e=>{const t=e.options.register,o=e=>f(e,s)?{value:EC(e),valid:!0}:{valid:!1,message:"Must be an array of strings."},n=e=>p(e)&&e>0?{value:e,valid:!0}:{valid:!1,message:"Must be a positive number."};t("color_map",{processor:o,default:["#BFEDD2","Light Green","#FBEEB8","Light Yellow","#F8CAC6","Light Red","#ECCAFA","Light Purple","#C2E0F4","Light Blue","#2DC26B","Green","#F1C40F","Yellow","#E03E2D","Red","#B96AD9","Purple","#3598DB","Blue","#169179","Dark Turquoise","#E67E23","Orange","#BA372A","Dark Red","#843FA1","Dark Purple","#236FA1","Dark Blue","#ECF0F1","Light Gray","#CED4D9","Medium Gray","#95A5A6","Gray","#7E8C8D","Dark Gray","#34495E","Navy Blue","#000000","Black","#ffffff","White"]}),t("color_map_background",{processor:o}),t("color_map_foreground",{processor:o}),t("color_cols",{processor:n,default:AC(e)}),t("color_cols_foreground",{processor:n,default:MC(e,kC)}),t("color_cols_background",{processor:n,default:MC(e,_C)}),t("custom_colors",{processor:"boolean",default:!0}),t("color_default_foreground",{processor:"string",default:OC}),t("color_default_background",{processor:"string",default:OC})})(e),(e=>{const t=e.options.register;t("contextmenu_avoid_overlap",{processor:"string",default:""}),t("contextmenu_never_use_native",{processor:"boolean",default:!1}),t("contextmenu",{processor:e=>!1===e?{value:[],valid:!0}:s(e)||f(e,s)?{value:TL(e),valid:!0}:{valid:!1,message:"Must be false or a string."},default:"link linkchecker image editimage table spellchecker configurepermanentpen"})})(e)};Qo.add("silver",(e=>{KF(e);let t=()=>Jo();const{dialogs:o,popups:n,renderUI:r}=YH(e,{getPopupSinkBounds:()=>t()});qS(e,n.backstage.shared);const s=GF({editor:e,backstages:{popup:n.backstage,dialog:o.backstage}});return{renderUI:()=>{const o=r();return XS(e,n.getMothership().element).each((e=>{t=()=>JS(e)})),o},getWindowManagerImpl:w(s),getNotificationManagerImpl:()=>((e,t,o)=>{const n=t.backstage.shared,r=()=>{const t=Ko(Le.fromDom(e.getContentAreaContainer())),o=Jo(),n=bl(o.x,t.x,t.right),r=bl(o.y,t.y,t.bottom),s=Math.max(t.right,o.right),a=Math.max(t.bottom,o.bottom);return D.some(Go(n,r,s-n,a-r))};return{open:(t,s)=>{const a=()=>{s(),Af.hide(l)},i=Ei(Zv.sketch({text:t.text,level:L(["success","error","warning","warn","info"],t.type)?t.type:void 0,progress:!0===t.progressBar,icon:t.icon,closeButton:t.closeButton,onAction:a,iconProvider:n.providers.icons,translationProvider:n.providers.translate})),l=Ei(Af.sketch({dom:{tag:"div",classes:["tox-notifications-container"]},lazySink:n.getSink,fireDismissalEventInstead:{},...n.header.isPositionedAtTop()?{}:{fireRepositionEventInstead:{}}}));o.add(l),p(t.timeout)&&t.timeout>0&&Mf.setEditorTimeout(e,(()=>{a()}),t.timeout);const c={close:a,reposition:()=>{const t=Ti(i),o={maxHeightFunction:Fc()},s=e.notificationManager.getNotifications();if(s[0]===c){const e={...n.anchors.banner(),overrides:o};Af.showWithinBounds(l,t,{anchor:e},r)}else B(s,c).each((e=>{const n=s[e-1].getEl(),a={type:"node",root:wt(),node:D.some(Le.fromDom(n)),overrides:o,layouts:{onRtl:()=>[Nl],onLtr:()=>[Nl]}};Af.showWithinBounds(l,t,{anchor:a},r)}))},text:e=>{Zv.updateText(i,e)},settings:t,getEl:()=>i.element.dom,progressBar:{value:e=>{Zv.updateProgress(i,e)}}};return c},close:e=>{e.close()},getArgs:e=>e.settings}})(e,{backstage:n.backstage},n.getMothership())}}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.ModelManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=e=>t=>e===t,r=t("string"),s=t("object"),a=t("array"),i=n(null),l=o("boolean"),c=n(void 0),d=e=>!(e=>null==e)(e),m=o("function"),u=o("number"),g=()=>{},h=e=>()=>e,p=e=>e,f=(e,t)=>e===t;function v(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const b=e=>t=>!e(t),y=e=>e(),w=h(!1),x=h(!0);class C{constructor(e,t){this.tag=e,this.value=t}static some(e){return new C(!0,e)}static none(){return C.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?C.some(e(this.value)):C.none()}bind(e){return this.tag?e(this.value):C.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:C.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return d(e)?C.some(e):C.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}C.singletonNone=new C(!1);const S=Array.prototype.slice,k=Array.prototype.indexOf,_=Array.prototype.push,E=(e,t)=>{return o=e,n=t,k.call(o,n)>-1;var o,n},T=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),B=(e,t,o)=>(A(e,((e,n)=>{o=t(o,e,n)})),o),L=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oI(D(e,t)),F=(e,t)=>{for(let o=0,n=e.length;o{const o={};for(let n=0,r=e.length;nt>=0&&tV(e,0),U=e=>V(e,e.length-1),j=(e,t)=>{for(let o=0;o{const o=W(e);for(let n=0,r=o.length;nK(e,((e,o)=>({k:o,v:t(e,o)}))),K=(e,t)=>{const o={};return q(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},Y=(e,t)=>{const o={};return((e,t,o,n)=>{q(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(e=>(t,o)=>{e[o]=t})(o),g),o},X=(e,t)=>{const o=[];return q(e,((e,n)=>{o.push(t(e,n))})),o},J=e=>X(e,p),Q=(e,t)=>$.call(e,t),ee="undefined"!=typeof window?window:Function("return this;")(),te=(e,t)=>((e,t)=>{let o=null!=t?t:ee;for(let t=0;t{const o=((e,t)=>te(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},ne=Object.getPrototypeOf,re=e=>{const t=te("ownerDocument.defaultView",e);return s(e)&&((e=>oe("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(ne(e).constructor.name))},se=e=>e.dom.nodeName.toLowerCase(),ae=e=>e.dom.nodeType,ie=e=>t=>ae(t)===e,le=e=>8===ae(e)||"#comment"===se(e),ce=e=>de(e)&&re(e.dom),de=ie(1),me=ie(3),ue=ie(9),ge=ie(11),he=e=>t=>de(t)&&se(t)===e,pe=(e,t,o)=>{if(!(r(o)||l(o)||u(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},fe=(e,t,o)=>{pe(e.dom,t,o)},ve=(e,t)=>{const o=e.dom;q(t,((e,t)=>{pe(o,t,e)}))},be=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},ye=(e,t)=>C.from(be(e,t)),we=(e,t)=>{e.dom.removeAttribute(t)},xe=e=>B(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Ce=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Se={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Ce(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return Ce(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return Ce(o)},fromDom:Ce,fromPoint:(e,t,o)=>C.from(e.dom.elementFromPoint(t,o)).map(Ce)},ke=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},_e=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Ee=(e,t)=>{const o=void 0===t?document:t.dom;return _e(o)?C.none():C.from(o.querySelector(e)).map(Se.fromDom)},Te=(e,t)=>e.dom===t.dom,Oe=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},De=ke,Ae=e=>Se.fromDom(e.dom.ownerDocument),Me=e=>ue(e)?e:Ae(e),Ne=e=>C.from(e.dom.parentNode).map(Se.fromDom),Re=e=>C.from(e.dom.parentElement).map(Se.fromDom),Be=(e,t)=>{const o=m(t)?t:w;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Se.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Le=e=>C.from(e.dom.previousSibling).map(Se.fromDom),He=e=>C.from(e.dom.nextSibling).map(Se.fromDom),Ie=e=>D(e.dom.childNodes,Se.fromDom),Pe=(e,t)=>{const o=e.dom.childNodes;return C.from(o[t]).map(Se.fromDom)},Fe=(e,t)=>{Ne(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},ze=(e,t)=>{He(e).fold((()=>{Ne(e).each((e=>{Ze(e,t)}))}),(e=>{Fe(e,t)}))},Ve=(e,t)=>{const o=(e=>Pe(e,0))(e);o.fold((()=>{Ze(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Ze=(e,t)=>{e.dom.appendChild(t.dom)},Ue=(e,t)=>{Fe(e,t),Ze(t,e)},je=(e,t)=>{A(t,((o,n)=>{const r=0===n?e:t[n-1];ze(r,o)}))},We=(e,t)=>{A(t,(t=>{Ze(e,t)}))},$e=e=>{e.dom.textContent="",A(Ie(e),(e=>{qe(e)}))},qe=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Ge=e=>{const t=Ie(e);t.length>0&&je(e,t),qe(e)},Ke=(e,t)=>Se.fromDom(e.dom.cloneNode(t)),Ye=e=>Ke(e,!1),Xe=e=>Ke(e,!0),Je=(e,t)=>{const o=Se.fromTag(t),n=xe(e);return ve(o,n),o},Qe=["tfoot","thead","tbody","colgroup"],et=(e,t,o)=>({element:e,rowspan:t,colspan:o}),tt=(e,t,o)=>({element:e,cells:t,section:o}),ot=(e,t,o)=>({element:e,isNew:t,isLocked:o}),nt=(e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}),rt=m(Element.prototype.attachShadow)&&m(Node.prototype.getRootNode),st=h(rt),at=rt?e=>Se.fromDom(e.dom.getRootNode()):Me,it=e=>{const t=at(e);return ge(o=t)&&d(o.dom.host)?C.some(t):C.none();var o},lt=e=>Se.fromDom(e.dom.host),ct=e=>d(e.dom.shadowRoot),dt=e=>{const t=me(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return it(Se.fromDom(t)).fold((()=>o.body.contains(t)),(n=dt,r=lt,e=>n(r(e))));var n,r},mt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Se.fromDom(t)},ut=(e,t)=>{let o=[];return A(Ie(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(ut(e,t))})),o},gt=(e,t,o)=>((e,t,o)=>N(Be(e,o),t))(e,(e=>ke(e,t)),o),ht=(e,t)=>((e,t)=>N(Ie(e),t))(e,(e=>ke(e,t))),pt=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return _e(o)?[]:D(o.querySelectorAll(e),Se.fromDom)})(t,e);var ft=(e,t,o,n,r)=>e(o,n)?C.some(o):m(r)&&r(o)?C.none():t(o,n,r);const vt=(e,t,o)=>{let n=e.dom;const r=m(o)?o:w;for(;n.parentNode;){n=n.parentNode;const e=Se.fromDom(n);if(t(e))return C.some(e);if(r(e))break}return C.none()},bt=(e,t,o)=>ft(((e,t)=>t(e)),vt,e,t,o),yt=(e,t,o)=>vt(e,(e=>ke(e,t)),o),wt=(e,t)=>((e,t)=>L(e.dom.childNodes,(e=>t(Se.fromDom(e)))).map(Se.fromDom))(e,(e=>ke(e,t))),xt=(e,t)=>Ee(t,e),Ct=(e,t,o)=>ft(((e,t)=>ke(e,t)),yt,e,t,o),St=(e,t,o=f)=>e.exists((e=>o(e,t))),kt=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?C.some(t):C.none(),Et=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Tt=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!c(n)||r+t.length<=n)},Ot=(e,t)=>Et(e,t,0),Dt=(e,t)=>Et(e,t,e.length-t.length),At=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Mt=e=>e.length>0,Nt=e=>void 0!==e.style&&m(e.style.getPropertyValue),Rt=(e,t,o)=>{if(!r(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Nt(e)&&e.style.setProperty(t,o)},Bt=(e,t,o)=>{const n=e.dom;Rt(n,t,o)},Lt=(e,t)=>{const o=e.dom;q(t,((e,t)=>{Rt(o,t,e)}))},Ht=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||dt(e)?n:It(o,t)},It=(e,t)=>Nt(e)?e.style.getPropertyValue(t):"",Pt=(e,t)=>{const o=e.dom,n=It(o,t);return C.from(n).filter((e=>e.length>0))},Ft=(e,t)=>{((e,t)=>{Nt(e)&&e.style.removeProperty(t)})(e.dom,t),St(ye(e,"style").map(At),"")&&we(e,"style")},zt=(e,t,o=0)=>ye(e,t).map((e=>parseInt(e,10))).getOr(o),Vt=(e,t)=>zt(e,t,1),Zt=e=>he("col")(e)?zt(e,"span",1)>1:Vt(e,"colspan")>1,Ut=e=>Vt(e,"rowspan")>1,jt=(e,t)=>parseInt(Ht(e,t),10),Wt=h(10),$t=h(10),qt=(e,t)=>Gt(e,t,x),Gt=(e,t,o)=>P(Ie(e),(e=>ke(e,t)?o(e)?[e]:[]:Gt(e,t,o))),Kt=(e,t)=>((e,t,o=w)=>o(t)?C.none():E(e,se(t))?C.some(t):yt(t,e.join(","),(e=>ke(e,"table")||o(e))))(["td","th"],e,t),Yt=e=>qt(e,"th,td"),Xt=e=>ke(e,"colgroup")?ht(e,"col"):P(eo(e),(e=>ht(e,"col"))),Jt=(e,t)=>Ct(e,"table",t),Qt=e=>qt(e,"tr"),eo=e=>Jt(e).fold(h([]),(e=>ht(e,"colgroup"))),to=(e,t)=>D(e,(e=>{if("colgroup"===se(e)){const t=D(Xt(e),(e=>{const t=zt(e,"span",1);return et(e,1,t)}));return tt(e,t,"colgroup")}{const o=D(Yt(e),(e=>{const t=zt(e,"rowspan",1),o=zt(e,"colspan",1);return et(e,t,o)}));return tt(e,o,t(e))}})),oo=e=>Ne(e).map((e=>{const t=se(e);return(e=>E(Qe,e))(t)?t:"tbody"})).getOr("tbody"),no=e=>{const t=Qt(e),o=[...eo(e),...t];return to(o,oo)},ro=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},so=()=>ao(0,0),ao=(e,t)=>({major:e,minor:t}),io={nu:ao,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?so():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return ao(n(1),n(2))})(e,o)},unknown:so},lo=(e,t)=>{const o=String(t).toLowerCase();return L(e,(e=>e.search(o)))},co=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,mo=e=>t=>Tt(t,e),uo=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Tt(e,"edge/")&&Tt(e,"chrome")&&Tt(e,"safari")&&Tt(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,co],search:e=>Tt(e,"chrome")&&!Tt(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Tt(e,"msie")||Tt(e,"trident")},{name:"Opera",versionRegexes:[co,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:mo("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:mo("firefox")},{name:"Safari",versionRegexes:[co,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Tt(e,"safari")||Tt(e,"mobile/"))&&Tt(e,"applewebkit")}],go=[{name:"Windows",search:mo("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Tt(e,"iphone")||Tt(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:mo("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:mo("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:mo("linux"),versionRegexes:[]},{name:"Solaris",search:mo("sunos"),versionRegexes:[]},{name:"FreeBSD",search:mo("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:mo("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],ho={browsers:h(uo),oses:h(go)},po="Edge",fo="Chromium",vo="Opera",bo="Firefox",yo="Safari",wo=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(po),isChromium:n(fo),isIE:n("IE"),isOpera:n(vo),isFirefox:n(bo),isSafari:n(yo)}},xo={unknown:()=>wo({current:void 0,version:io.unknown()}),nu:wo,edge:h(po),chromium:h(fo),ie:h("IE"),opera:h(vo),firefox:h(bo),safari:h(yo)},Co="Windows",So="Android",ko="Linux",_o="macOS",Eo="Solaris",To="FreeBSD",Oo="ChromeOS",Do=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(Co),isiOS:n("iOS"),isAndroid:n(So),isMacOS:n(_o),isLinux:n(ko),isSolaris:n(Eo),isFreeBSD:n(To),isChromeOS:n(Oo)}},Ao={unknown:()=>Do({current:void 0,version:io.unknown()}),nu:Do,windows:h(Co),ios:h("iOS"),android:h(So),linux:h(ko),macos:h(_o),solaris:h(Eo),freebsd:h(To),chromeos:h(Oo)},Mo=(e,t,o)=>{const n=ho.browsers(),r=ho.oses(),s=t.bind((e=>((e,t)=>j(t.brands,(t=>{const o=t.brand.toLowerCase();return L(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:io.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>lo(e,t).map((e=>{const o=io.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(xo.unknown,xo.nu),a=((e,t)=>lo(e,t).map((e=>{const o=io.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(Ao.unknown,Ao.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:h(r),isiPhone:h(s),isTablet:h(l),isPhone:h(c),isTouch:h(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:h(d),isDesktop:h(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},No=e=>window.matchMedia(e).matches;let Ro=ro((()=>Mo(navigator.userAgent,C.from(navigator.userAgentData),No)));const Bo=()=>Ro(),Lo=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Ht(o,e);return parseFloat(t)||0}return n},n=(e,t)=>B(t,((t,o)=>{const n=Ht(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!u(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Nt(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Ho=(e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?C.none():C.some(t)})(e).getOr(t),Io=(e,t,o)=>Ho(Ht(e,t),o),Po=(e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-Io(e,`padding-${o}`,0)-Io(e,`padding-${n}`,0)-Io(e,`border-${o}-width`,0)-Io(e,`border-${n}-width`,0))(e,n,"left","right")},Fo=Lo("width",(e=>e.dom.offsetWidth)),zo=e=>Fo.get(e),Vo=e=>Fo.getOuter(e),Zo=e=>Po(e,"content-box"),Uo=e=>Io(e,"width",e.dom.offsetWidth),jo=(e,t,o)=>{const n=e.cells,r=n.slice(0,t),s=n.slice(t),a=r.concat(o).concat(s);return qo(e,a)},Wo=(e,t,o)=>jo(e,t,[o]),$o=(e,t,o)=>{e.cells[t]=o},qo=(e,t)=>nt(e.element,t,e.section,e.isNew),Go=(e,t)=>e.cells[t],Ko=(e,t)=>Go(e,t).element,Yo=e=>e.cells.length,Xo=e=>{const t=M(e,(e=>"colgroup"===e.section));return{rows:t.fail,cols:t.pass}},Jo=(e,t,o)=>{const n=D(e.cells,o);return nt(t(e.element),n,e.section,!0)},Qo="data-snooker-locked-cols",en=e=>ye(e,Qo).bind((e=>C.from(e.match(/\d+/g)))).map((e=>z(e,x))),tn=e=>{const t=B(Xo(e).rows,((e,t)=>(A(t.cells,((t,o)=>{t.isLocked&&(e[o]=!0)})),e)),{}),o=X(t,((e,t)=>parseInt(t,10)));return((e,t)=>{const o=S.call(e,0);return o.sort(t),o})(o)},on=(e,t)=>e+","+t,nn=(e,t)=>{const o=P(e.all,(e=>e.cells));return N(o,t)},rn=e=>{const t={},o=[],n=Z(e).map((e=>e.element)).bind(Jt).bind(en).getOr({});let r=0,s=0,a=0;const{pass:i,fail:l}=M(e,(e=>"colgroup"===e.section));A(l,(e=>{const i=[];A(e.cells,(e=>{let o=0;for(;void 0!==t[on(a,o)];)o++;const r=((e,t)=>Q(e,t)&&void 0!==e[t]&&null!==e[t])(n,o.toString()),l=((e,t,o,n,r,s)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:s}))(e.element,e.rowspan,e.colspan,a,o,r);for(let n=0;n{const t=(e=>{const t={};let o=0;return A(e.cells,(e=>{const n=e.colspan;O(n,(r=>{const s=o+r;t[s]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,n,s)})),o+=n})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,J(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),m=((e,t)=>({rows:e,columns:t}))(r,s);return{grid:m,access:t,all:o,columns:c,colgroups:d}},sn={fromTable:e=>{const t=no(e);return rn(t)},generate:rn,getAt:(e,t,o)=>C.from(e.access[on(t,o)]),findItem:(e,t,o)=>{const n=nn(e,(e=>o(t,e.element)));return n.length>0?C.some(n[0]):C.none()},filterItems:nn,justCells:e=>P(e.all,(e=>e.cells)),justColumns:e=>J(e.columns),hasColumns:e=>W(e.columns).length>0,getColumnAt:(e,t)=>C.from(e.columns[t])},an=(e,t=x)=>{const o=e.grid,n=O(o.columns,p),r=O(o.rows,p);return D(n,(o=>ln((()=>P(r,(t=>sn.getAt(e,t,o).filter((e=>e.column===o)).toArray()))),(e=>1===e.colspan&&t(e.element)),(()=>sn.getAt(e,0,o)))))},ln=(e,t,o)=>{const n=e();return L(n,t).orThunk((()=>C.from(n[0]).orThunk(o))).map((e=>e.element))},cn=e=>{const t=e.grid,o=O(t.rows,p),n=O(t.columns,p);return D(o,(t=>ln((()=>P(n,(o=>sn.getAt(e,t,o).filter((e=>e.row===t)).fold(h([]),(e=>[e]))))),(e=>1===e.rowspan),(()=>sn.getAt(e,t,0)))))},dn=(e,t)=>{if(t<0||t>=e.length-1)return C.none();const o=e[t].fold((()=>{const o=(e=>{const t=S.call(e,0);return t.reverse(),t})(e.slice(0,t));return j(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:0}))),n=e[t+1].fold((()=>{const o=e.slice(t+1);return j(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:1})));return o.bind((e=>n.map((t=>{const o=t.delta+e.delta;return Math.abs(t.value-e.value)/o}))))},mn=(e,t)=>o=>"rtl"===un(o)?t:e,un=e=>"rtl"===Ht(e,"direction")?"rtl":"ltr",gn=Lo("height",(e=>{const t=e.dom;return dt(e)?t.getBoundingClientRect().height:t.offsetHeight})),hn=e=>gn.get(e),pn=e=>gn.getOuter(e),fn=e=>Io(e,"height",e.dom.offsetHeight),vn=(e,t)=>({left:e,top:t,translate:(o,n)=>vn(e+o,t+n)}),bn=vn,yn=(e,t)=>void 0!==e?e:void 0!==t?t:0,wn=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return bn(o.offsetLeft,o.offsetTop);const s=yn(null==n?void 0:n.pageYOffset,r.scrollTop),a=yn(null==n?void 0:n.pageXOffset,r.scrollLeft),i=yn(r.clientTop,o.clientTop),l=yn(r.clientLeft,o.clientLeft);return xn(e).translate(a-l,s-i)},xn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?bn(o.offsetLeft,o.offsetTop):dt(e)?(e=>{const t=e.getBoundingClientRect();return bn(t.left,t.top)})(t):bn(0,0)},Cn=(e,t)=>({row:e,y:t}),Sn=(e,t)=>({col:e,x:t}),kn=e=>wn(e).left+Vo(e),_n=e=>wn(e).left,En=(e,t)=>Sn(e,_n(t)),Tn=(e,t)=>Sn(e,kn(t)),On=e=>wn(e).top,Dn=(e,t)=>Cn(e,On(t)),An=(e,t)=>Cn(e,On(t)+pn(t)),Mn=(e,t,o)=>{if(0===o.length)return[];const n=D(o.slice(1),((t,o)=>t.map((t=>e(o,t))))),r=o[o.length-1].map((e=>t(o.length-1,e)));return n.concat([r])},Nn={delta:p,positions:e=>Mn(Dn,An,e),edge:On},Rn=mn({delta:p,edge:_n,positions:e=>Mn(En,Tn,e)},{delta:e=>-e,edge:kn,positions:e=>Mn(Tn,En,e)}),Bn={delta:(e,t)=>Rn(t).delta(e,t),positions:(e,t)=>Rn(t).positions(e,t),edge:e=>Rn(e).edge(e)},Ln={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},Hn=(()=>{const e="[0-9]+",t="[eE]"+("[+-]?"+e),o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^(${`[+-]?(?:${n})`})(.*)$`)})(),In=(e,t)=>C.from(Hn.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>T(t,(t=>T(Ln[t],(t=>e===t)))))(n,t)?C.some({value:o,unit:n}):C.none()})),Pn=/(\d+(\.\d+)?)%/,Fn=/(\d+(\.\d+)?)px|em/,zn=he("col"),Vn=(e,t,o)=>{const n=Re(e).getOrThunk((()=>mt(Ae(e))));return t(e)/o(n)*100},Zn=(e,t)=>{Bt(e,"width",t+"px")},Un=(e,t)=>{Bt(e,"width",t+"%")},jn=(e,t)=>{Bt(e,"height",t+"px")},Wn=(e,t,o,n)=>{const r=parseFloat(e);return Dt(e,"%")&&"table"!==se(t)?((e,t,o,n)=>{const r=Jt(e).map((e=>{const n=o(e);return Math.floor(t/100*n)})).getOr(t);return n(e,r),r})(t,r,o,n):r},$n=e=>{const t=(e=>fn(e)+"px")(e);return t?Wn(t,e,hn,jn):hn(e)},qn=(e,t)=>Pt(e,t).orThunk((()=>ye(e,t).map((e=>e+"px")))),Gn=e=>qn(e,"width"),Kn=e=>Vn(e,zo,Zo),Yn=e=>zn(e)?zo(e):Uo(e),Xn=e=>((e,t,o)=>o(e)/Vt(e,t))(e,"rowspan",$n),Jn=(e,t,o)=>{Bt(e,"width",t+o)},Qn=e=>Vn(e,zo,Zo)+"%",er=h(Pn),tr=he("col"),or=e=>Gn(e).getOrThunk((()=>Yn(e)+"px")),nr=e=>{return(t=e,qn(t,"height")).getOrThunk((()=>Xn(e)+"px"));var t},rr=(e,t,o,n,r,s)=>e.filter(n).fold((()=>s(dn(o,t))),(e=>r(e))),sr=(e,t,o,n)=>{const r=an(e),s=sn.hasColumns(e)?(e=>D(sn.justColumns(e),(e=>C.from(e.element))))(e):r,a=[C.some(Bn.edge(t))].concat(D(Bn.positions(r,t),(e=>e.map((e=>e.x))))),i=b(Zt);return D(s,((e,t)=>rr(e,t,a,i,(e=>{if((e=>{const t=Bo().browser,o=t.isChromium()||t.isFirefox();return!tr(e)||o})(e))return o(e);{const e=(s=r[t],l=p,null!=s?l(s):C.none());return rr(e,t,a,i,(e=>n(C.some(zo(e)))),n)}var s,l}),n)))},ar=e=>e.map((e=>e+"px")).getOr(""),ir=(e,t,o)=>sr(e,t,Yn,(e=>e.getOrThunk(o.minCellWidth))),lr=(e,t,o,n,r)=>{const s=cn(e),a=[C.some(o.edge(t))].concat(D(o.positions(s,t),(e=>e.map((e=>e.y)))));return D(s,((e,t)=>rr(e,t,a,b(Ut),n,r)))},cr=(e,t)=>()=>dt(e)?t(e):parseFloat(Pt(e,"width").getOr("0")),dr=e=>{const t=cr(e,zo),o=h(0);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:o,singleColumnWidth:h([0]),minCellWidth:o,setElementWidth:g,adjustTableWidth:g,isRelative:!0,label:"none"}},mr=e=>{const t=cr(e,(e=>parseFloat(Qn(e)))),o=cr(e,zo);return{width:t,pixelWidth:o,getWidths:(t,o)=>((e,t,o)=>sr(e,t,Kn,(e=>e.fold((()=>o.minCellWidth()),(e=>e/o.pixelWidth()*100)))))(t,e,o),getCellDelta:e=>e/o()*100,singleColumnWidth:(e,t)=>[100-e],minCellWidth:()=>Wt()/o()*100,setElementWidth:Un,adjustTableWidth:o=>{const n=t();Un(e,n+o/100*n)},isRelative:!0,label:"percent"}},ur=e=>{const t=cr(e,zo);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:p,singleColumnWidth:(e,t)=>[Math.max(Wt(),e+t)-e],minCellWidth:Wt,setElementWidth:Zn,adjustTableWidth:o=>{const n=t()+o;Zn(e,n)},isRelative:!1,label:"pixel"}},gr=e=>Gn(e).fold((()=>dr(e)),(t=>((e,t)=>null!==er().exec(t)?mr(e):ur(e))(e,t))),hr=ur,pr=mr,fr=(e,t,o)=>{const n=e[o].element,r=Se.fromTag("td");Ze(r,Se.fromTag("br"));(t?Ze:Ve)(n,r)},vr=(e,t)=>{const o=e=>ke(e.element,t),n=Xe(e),r=no(n),s=gr(e),a=sn.generate(r),i=((e,t)=>{const o=e.grid.columns;let n=e.grid.rows,r=o,s=0,a=0;const i=[],l=[];return q(e.access,(e=>{if(i.push(e),t(e)){l.push(e);const t=e.row,o=t+e.rowspan-1,i=e.column,c=i+e.colspan-1;ts&&(s=o),ia&&(a=c)}})),((e,t,o,n,r,s)=>({minRow:e,minCol:t,maxRow:o,maxCol:n,allCells:r,selectedCells:s}))(n,r,s,a,i,l)})(a,o),l="th:not("+t+"),td:not("+t+")",c=Gt(n,"th,td",(e=>ke(e,l)));A(c,qe),((e,t,o,n)=>{const r=N(e,(e=>"colgroup"!==e.section)),s=t.grid.columns,a=t.grid.rows;for(let e=0;eo.maxRow||io.maxCol||(sn.getAt(t,e,i).filter(n).isNone()?fr(r,a,e):a=!0)}})(r,a,i,o);const d=((e,t,o,n)=>{if(0===n.minCol&&t.grid.columns===n.maxCol+1)return 0;const r=ir(t,e,o),s=B(r,((e,t)=>e+t),0),a=B(r.slice(n.minCol,n.maxCol+1),((e,t)=>e+t),0),i=a/s*o.pixelWidth()-o.pixelWidth();return o.getCellDelta(i)})(e,sn.fromTable(e),s,i);return((e,t,o,n)=>{q(o.columns,(e=>{(e.columnt.maxCol)&&qe(e.element)}));const r=N(qt(e,"tr"),(e=>0===e.dom.childElementCount));A(r,qe),t.minCol!==t.maxCol&&t.minRow!==t.maxRow||A(qt(e,"th,td"),(e=>{we(e,"rowspan"),we(e,"colspan")})),we(e,Qo),we(e,"data-snooker-col-series"),gr(e).adjustTableWidth(n)})(n,i,a,d),n},br=((e,t)=>{const o=t=>e(t)?C.from(t.dom.nodeValue):C.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(me,"text"),yr=e=>br.get(e),wr=e=>br.getOption(e),xr=(e,t)=>br.set(e,t),Cr=e=>"img"===se(e)?1:wr(e).fold((()=>Ie(e).length),(e=>e.length)),Sr=["img","br"],kr=e=>wr(e).filter((e=>0!==e.trim().length||e.indexOf(" ")>-1)).isSome()||E(Sr,se(e))||(e=>ce(e)&&"false"===be(e,"contenteditable"))(e),_r=e=>((e,t)=>{const o=e=>{for(let n=0;nTr(e,kr),Tr=(e,t)=>{const o=e=>{const n=Ie(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return C.some(r);const s=o(r);if(s.isSome())return s}return C.none()};return o(e)},Or={scope:["row","col"]},Dr=e=>()=>{const t=Se.fromTag("td",e.dom);return Ze(t,Se.fromTag("br",e.dom)),t},Ar=e=>()=>Se.fromTag("col",e.dom),Mr=e=>()=>Se.fromTag("colgroup",e.dom),Nr=e=>()=>Se.fromTag("tr",e.dom),Rr=(e,t,o)=>{const n=((e,t)=>{const o=Je(e,t),n=Ie(Xe(e));return We(o,n),o})(e,t);return q(o,((e,t)=>{null===e?we(n,t):fe(n,t,e)})),n},Br=e=>e,Lr=(e,t,o)=>{const n=(e,t)=>{((e,t)=>{const o=e.dom,n=t.dom;Nt(o)&&Nt(n)&&(n.style.cssText=o.style.cssText)})(e.element,t),Ft(t,"height"),1!==e.colspan&&Ft(t,"width")};return{col:o=>{const r=Se.fromTag(se(o.element),t.dom);return n(o,r),e(o.element,r),r},colgroup:Mr(t),row:Nr(t),cell:r=>{const s=Se.fromTag(se(r.element),t.dom),a=o.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),i=a.length>0?((e,t,o)=>_r(e).map((n=>{const r=o.join(","),s=gt(n,r,(t=>Te(t,e)));return R(s,((e,t)=>{const o=Ye(t);return Ze(e,o),o}),t)})).getOr(t))(r.element,s,a):s;return Ze(i,Se.fromTag("br")),n(r,s),((e,t)=>{q(Or,((o,n)=>ye(e,n).filter((e=>E(o,e))).each((e=>fe(t,n,e)))))})(r.element,s),e(r.element,s),s},replace:Rr,colGap:Ar(t),gap:Dr(t)}},Hr=e=>({col:Ar(e),colgroup:Mr(e),row:Nr(e),cell:Dr(e),replace:Br,colGap:Ar(e),gap:Dr(e)}),Ir=e=>t=>t.options.get(e),Pr="100%",Fr=e=>{var t;const o=e.dom,n=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return Zo(Se.fromDom(n))+"px"},zr=e=>C.from(e.options.get("table_clone_elements")),Vr=Ir("table_header_type"),Zr=Ir("table_column_resizing"),Ur=e=>"preservetable"===Zr(e),jr=e=>"resizetable"===Zr(e),Wr=Ir("table_sizing_mode"),$r=e=>"relative"===Wr(e),qr=e=>"fixed"===Wr(e),Gr=e=>"responsive"===Wr(e),Kr=Ir("table_resize_bars"),Yr=Ir("table_style_by_css"),Xr=Ir("table_merge_content_on_paste"),Jr=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Gr(e)||Yr(e)?t:qr(e)?{...t,width:Fr(e)}:{...t,width:Pr})(e,o)},Qr=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Gr(e)||!Yr(e)?t:qr(e)?{...t,width:Fr(e)}:{...t,width:Pr})(e,o)},es=Ir("table_use_colgroups"),ts=e=>Ct(e,"[contenteditable]"),os=(e,t=!1)=>dt(e)?e.dom.isContentEditable:ts(e).fold(h(t),(e=>"true"===ns(e))),ns=e=>e.dom.contentEditable,rs=e=>Se.fromDom(e.getBody()),ss=e=>t=>Te(t,rs(e)),as=e=>{we(e,"data-mce-style");const t=e=>we(e,"data-mce-style");A(Yt(e),t),A(Xt(e),t),A(Qt(e),t)},is=e=>Se.fromDom(e.selection.getStart()),ls=e=>e.getBoundingClientRect().width,cs=e=>e.getBoundingClientRect().height,ds=e=>bt(e,he("table")).exists(os),ms=(e,t)=>{const o=t.column,n=t.column+t.colspan-1,r=t.row,s=t.row+t.rowspan-1;return o<=e.finishCol&&n>=e.startCol&&r<=e.finishRow&&s>=e.startRow},us=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,gs=(e,t,o)=>{const n=sn.findItem(e,t,Te),r=sn.findItem(e,o,Te);return n.bind((e=>r.map((t=>{return o=e,n=t,r=Math.min(o.row,n.row),s=Math.min(o.column,n.column),a=Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),i=Math.max(o.column+o.colspan-1,n.column+n.colspan-1),{startRow:r,startCol:s,finishRow:a,finishCol:i};var o,n,r,s,a,i}))))},hs=(e,t,o)=>gs(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=v(us,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let s=t.startCol;s<=t.finishCol;s++)o=o&&sn.getAt(e,r,s).exists(n);return o?C.some(t):C.none()})(e,t))),ps=(e,t,o)=>gs(e,t,o).map((t=>{const o=sn.filterItems(e,v(ms,t));return D(o,(e=>e.element))})),fs=(e,t)=>sn.findItem(e,t,((e,t)=>Oe(t,e))).map((e=>e.element)),vs=(e,t,o)=>Jt(e).bind((n=>((e,t,o,n)=>sn.findItem(e,t,Te).bind((t=>{const r=o>0?t.row+t.rowspan-1:t.row,s=n>0?t.column+t.colspan-1:t.column;return sn.getAt(e,r+o,s+n).map((e=>e.element))})))(ws(n),e,t,o))),bs=(e,t,o)=>{const n=ws(e);return ps(n,t,o)},ys=(e,t,o,n,r)=>{const s=ws(e),a=Te(e,o)?C.some(t):fs(s,t),i=Te(e,r)?C.some(n):fs(s,n);return a.bind((e=>i.bind((t=>ps(s,e,t)))))},ws=sn.fromTable;var xs=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Cs=()=>({up:h({selector:yt,closest:Ct,predicate:vt,all:Be}),down:h({selector:pt,predicate:ut}),styles:h({get:Ht,getRaw:Pt,set:Bt,remove:Ft}),attrs:h({get:be,set:fe,remove:we,copyTo:(e,t)=>{const o=xe(e);ve(t,o)}}),insert:h({before:Fe,after:ze,afterAll:je,append:Ze,appendAll:We,prepend:Ve,wrap:Ue}),remove:h({unwrap:Ge,remove:qe}),create:h({nu:Se.fromTag,clone:e=>Se.fromDom(e.dom.cloneNode(!1)),text:Se.fromText}),query:h({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:Le,nextSibling:He}),property:h({children:Ie,name:se,parent:Ne,document:e=>Me(e).dom,isText:me,isComment:le,isElement:de,isSpecial:e=>{const t=se(e);return E(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>de(e)?ye(e,"lang"):C.none(),getText:yr,setText:xr,isBoundary:e=>!!de(e)&&("body"===se(e)||E(xs,se(e))),isEmptyTag:e=>!!de(e)&&E(["br","img","hr","input"],se(e)),isNonEditable:e=>de(e)&&"false"===be(e,"contenteditable")}),eq:Te,is:De});const Ss=(e,t,o,n)=>{const r=t(e,o);return R(n,((o,n)=>{const r=t(e,n);return ks(e,o,r)}),r)},ks=(e,t,o)=>t.bind((t=>o.filter(v(e.eq,t)))),_s=(e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,Ss):C.none(),Es=(e,t,o,n=w)=>{const r=[t].concat(e.up().all(t)),s=[o].concat(e.up().all(o)),a=e=>H(e,n).fold((()=>e),(t=>e.slice(0,t+1))),i=a(r),l=a(s),c=L(i,(t=>T(l,((e,t)=>v(e.eq,t))(e,t))));return{firstpath:i,secondpath:l,shared:c}},Ts=Cs(),Os=(e,t)=>_s(Ts,((t,o)=>e(o)),t),Ds=e=>yt(e,"table"),As=(e,t,o)=>{const n=e=>t=>void 0!==o&&o(t)||Te(t,e);return Te(e,t)?C.some({boxes:C.some([e]),start:e,finish:t}):Ds(e).bind((r=>Ds(t).bind((s=>{if(Te(r,s))return C.some({boxes:bs(r,e,t),start:e,finish:t});if(Oe(r,s)){const o=gt(t,"td,th",n(r)),a=o.length>0?o[o.length-1]:t;return C.some({boxes:ys(r,e,r,t,s),start:e,finish:a})}if(Oe(s,r)){const o=gt(e,"td,th",n(s)),a=o.length>0?o[o.length-1]:e;return C.some({boxes:ys(s,e,r,t,s),start:e,finish:a})}return((e,t,o)=>Es(Ts,e,t,o))(e,t).shared.bind((a=>Ct(a,"table",o).bind((o=>{const a=gt(t,"td,th",n(o)),i=a.length>0?a[a.length-1]:t,l=gt(e,"td,th",n(o)),c=l.length>0?l[l.length-1]:e;return C.some({boxes:ys(o,e,r,t,s),start:c,finish:i})}))))}))))},Ms=(e,t)=>{const o=pt(e,t);return o.length>0?C.some(o):C.none()},Ns=(e,t,o)=>xt(e,t).bind((t=>xt(e,o).bind((e=>Os(Ds,[t,e]).map((o=>({first:t,last:e,table:o}))))))),Rs=(e,t,o,n,r)=>((e,t)=>L(e,(e=>ke(e,t))))(e,r).bind((e=>vs(e,t,o).bind((e=>((e,t)=>yt(e,"table").bind((o=>xt(o,t).bind((t=>As(t,e).bind((e=>e.boxes.map((t=>({boxes:t,start:e.start,finish:e.finish}))))))))))(e,n))))),Bs=(e,t)=>Ms(e,t),Ls=(e,t,o)=>Ns(e,t,o).bind((t=>{const o=t=>Te(e,t),n="thead,tfoot,tbody,table",r=yt(t.first,n,o),s=yt(t.last,n,o);return r.bind((e=>s.bind((o=>Te(e,o)?((e,t,o)=>{const n=ws(e);return hs(n,t,o)})(t.table,t.first,t.last):C.none()))))})),Hs=p,Is=e=>{const t=(e,t)=>ye(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&F(e,(e=>t(e,"rowspan")||t(e,"colspan")))?C.some(e):C.none()},Ps=(e,t,o)=>t.length<=1?C.none():Ls(e,o.firstSelectedSelector,o.lastSelectedSelector).map((e=>({bounds:e,cells:t}))),Fs="data-mce-selected",zs="td["+Fs+"],th["+Fs+"]",Vs="["+Fs+"]",Zs="data-mce-first-selected",Us="td["+Zs+"],th["+Zs+"]",js="data-mce-last-selected",Ws="td["+js+"],th["+js+"]",$s=Vs,qs={selected:Fs,selectedSelector:zs,firstSelected:Zs,firstSelectedSelector:Us,lastSelected:js,lastSelectedSelector:Ws},Gs=(e,t,o)=>({element:o,mergable:Ps(t,e,qs),unmergable:Is(e),selection:Hs(e)}),Ks=e=>(t,o)=>{const n=se(t),r="col"===n||"colgroup"===n?Jt(s=t).bind((e=>Bs(e,qs.firstSelectedSelector))).fold(h(s),(e=>e[0])):t;var s;return Ct(r,e,o)},Ys=Ks("th,td,caption"),Xs=Ks("th,td"),Js=e=>{return t=e.model.table.getSelectedCells(),D(t,Se.fromDom);var t},Qs=(e,t)=>{e.on("BeforeGetContent",(t=>{const o=o=>{t.preventDefault(),(e=>Jt(e[0]).map((e=>{const t=vr(e,$s);return as(t),[t]})))(o).each((o=>{t.content="text"===t.format?(e=>D(e,(e=>e.dom.innerText)).join(""))(o):((e,t)=>D(t,(t=>e.selection.serializer.serialize(t.dom,{}))).join(""))(e,o)}))};if(!0===t.selection){const t=(e=>N(Js(e),(e=>ke(e,qs.selectedSelector))))(e);t.length>=1&&o(t)}})),e.on("BeforeSetContent",(o=>{if(!0===o.selection&&!0===o.paste){const n=Js(e);Z(n).each((n=>{Jt(n).each((r=>{const s=N(((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Ie(Se.fromDom(o))})(o.content),(e=>"meta"!==se(e))),a=he("table");if(Xr(e)&&1===s.length&&a(s[0])){o.preventDefault();const a=Se.fromDom(e.getDoc()),i=Hr(a),l=((e,t,o)=>({element:e,clipboard:t,generators:o}))(n,s[0],i);t.pasteCells(r,l).each((()=>{e.focus()}))}}))}))}}))},ea=(e,t)=>({element:e,offset:t}),ta=(e,t,o)=>e.property().isText(t)&&0===e.property().getText(t).trim().length||e.property().isComment(t)?o(t).bind((t=>ta(e,t,o).orThunk((()=>C.some(t))))):C.none(),oa=(e,t)=>{if(e.property().isText(t))return e.property().getText(t).length;return e.property().children(t).length},na=(e,t)=>{const o=ta(e,t,e.query().prevSibling).getOr(t);if(e.property().isText(o))return ea(o,oa(e,o));const n=e.property().children(o);return n.length>0?na(e,n[n.length-1]):ea(o,oa(e,o))},ra=na,sa=Cs(),aa=(e,t)=>{if(!Zt(e)){const o=(e=>Gn(e).bind((e=>In(e,["fixed","relative","empty"]))))(e);o.each((o=>{const n=o.value/2;Jn(e,n,o.unit),Jn(t,n,o.unit)}))}},ia=e=>D(e,h(0)),la=(e,t,o,n,r)=>r(e.slice(0,t)).concat(n).concat(r(e.slice(o))),ca=e=>(t,o,n,r)=>{if(e(n)){const e=Math.max(r,t[o]-Math.abs(n)),s=Math.abs(e-t[o]);return n>=0?s:-s}return n},da=ca((e=>e<0)),ma=ca(x),ua=()=>{const e=(e,t,o,n)=>{const r=(100+o)/100,s=Math.max(n,(e[t]+o)/r);return D(e,((e,o)=>(o===t?s:e/r)-e))},t=(t,o,n,r,s,a)=>a?e(t,o,r,s):((e,t,o,n,r)=>{const s=da(e,t,n,r);return la(e,t,o+1,[s,0],ia)})(t,o,n,r,s);return{resizeTable:(e,t)=>e(t),clampTableDelta:da,calcLeftEdgeDeltas:t,calcMiddleDeltas:(e,o,n,r,s,a,i)=>t(e,n,r,s,a,i),calcRightEdgeDeltas:(t,o,n,r,s,a)=>{if(a)return e(t,n,r,s);{const e=da(t,n,r,s);return ia(t.slice(0,n)).concat([e])}},calcRedestributedWidths:(e,t,o,n)=>{if(n){const n=(t+o)/t,r=D(e,(e=>e/n));return{delta:100*n-100,newSizes:r}}return{delta:o,newSizes:e}}}},ga=()=>{const e=(e,t,o,n,r)=>{const s=ma(e,n>=0?o:t,n,r);return la(e,t,o+1,[s,-s],ia)};return{resizeTable:(e,t,o)=>{o&&e(t)},clampTableDelta:(e,t,o,n,r)=>{if(r){if(o>=0)return o;{const t=B(e,((e,t)=>e+t-n),0);return Math.max(-t,o)}}return da(e,t,o,n)},calcLeftEdgeDeltas:e,calcMiddleDeltas:(t,o,n,r,s,a)=>e(t,n,r,s,a),calcRightEdgeDeltas:(e,t,o,n,r,s)=>{if(s)return ia(e);{const t=n/e.length;return D(e,h(t))}},calcRedestributedWidths:(e,t,o,n)=>({delta:0,newSizes:e})}},ha=e=>sn.fromTable(e).grid,pa=he("th"),fa=e=>F(e,(e=>pa(e.element))),va=(e,t)=>e&&t?"sectionCells":e?"section":"cells",ba=e=>{const t="thead"===e.section,o=St(ya(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:va(t,o)}:{type:"body"}},ya=e=>{const t=N(e,(e=>pa(e.element)));return 0===t.length?C.some("td"):t.length===e.length?C.some("th"):C.none()},wa=(e,t,o)=>ot(o(e.element,t),!0,e.isLocked),xa=(e,t)=>e.section!==t?nt(e.element,e.cells,t,e.isNew):e,Ca=()=>({transformRow:xa,transformCell:(e,t,o)=>{const n=o(e.element,t),r="td"!==se(n)?((e,t)=>{const o=Je(e,t);ze(e,o);const n=Ie(e);return We(o,n),qe(e),o})(n,"td"):n;return ot(r,e.isNew,e.isLocked)}}),Sa=()=>({transformRow:xa,transformCell:wa}),ka=()=>({transformRow:(e,t)=>xa(e,"thead"===t?"tbody":t),transformCell:wa}),_a=(e,t)=>{const o=(e=>j(e.all,(e=>{const t=ba(e);return"header"===t.type?C.from(t.subType):C.none()})))(sn.fromTable(e)).getOr(t);switch(o){case"section":return Ca();case"sectionCells":return Sa();case"cells":return ka()}},Ea=Ca,Ta=Sa,Oa=ka,Da=()=>({transformRow:p,transformCell:wa}),Aa=(e,t,o,n)=>{o===n?we(e,t):fe(e,t,o)},Ma=(e,t,o)=>{U(ht(e,t)).fold((()=>Ve(e,o)),(e=>ze(e,o)))},Na=(e,t)=>{const o=[],n=[],r=e=>D(e,(e=>{e.isNew&&o.push(e.element);const t=e.element;return $e(t),A(e.cells,(e=>{e.isNew&&n.push(e.element),Aa(e.element,"colspan",e.colspan,1),Aa(e.element,"rowspan",e.rowspan,1),Ze(t,e.element)})),t})),s=e=>P(e,(e=>D(e.cells,(e=>(Aa(e.element,"span",e.colspan,1),e.element))))),a=(t,o)=>{const n=((e,t)=>{const o=wt(e,t).getOrThunk((()=>{const o=Se.fromTag(t,Ae(e).dom);return"thead"===t?Ma(e,"caption,colgroup",o):"colgroup"===t?Ma(e,"caption",o):Ze(e,o),o}));return $e(o),o})(e,o),a=("colgroup"===o?s:r)(t);We(n,a)},i=(t,o)=>{t.length>0?a(t,o):(t=>{wt(e,t).each(qe)})(o)},l=[],c=[],d=[],m=[];return A(t,(e=>{switch(e.section){case"thead":l.push(e);break;case"tbody":c.push(e);break;case"tfoot":d.push(e);break;case"colgroup":m.push(e)}})),i(m,"colgroup"),i(l,"thead"),i(c,"tbody"),i(d,"tfoot"),{newRows:o,newCells:n}},Ra=(e,t)=>{if(0===e.length)return 0;const o=e[0];return H(e,(e=>!t(o.element,e.element))).getOr(e.length)},Ba=(e,t,o,n)=>{const r=((e,t)=>e[t])(e,t),s="colgroup"===r.section,a=Ra(r.cells.slice(o),n),i=s?1:Ra(((e,t)=>D(e,(e=>Go(e,t))))(e.slice(t),o),n);return{colspan:a,rowspan:i}},La=(e,t)=>{const o=D(e,(e=>D(e.cells,w)));return D(e,((n,r)=>{const s=P(n.cells,((n,s)=>{if(!1===o[r][s]){const d=Ba(e,r,s,t);return((e,t,n,r)=>{for(let s=e;s({element:e,cells:t,section:o,isNew:n}))(n.element,s,n.section,n.isNew)}))},Ha=(e,t,o)=>{const n=[];A(e.colgroups,(r=>{const s=[];for(let n=0;not(e.element,o,!1))).getOrThunk((()=>ot(t.colGap(),!0,!1)));s.push(r)}n.push(nt(r.element,s,"colgroup",o))}));for(let r=0;rot(e.element,o,e.isLocked))).getOrThunk((()=>ot(t.gap(),!0,!1)));s.push(a)}const a=e.all[r],i=nt(a.element,s,a.section,o);n.push(i)}return n},Ia=e=>La(e,Te),Pa=(e,t)=>j(e.all,(e=>L(e.cells,(e=>Te(t,e.element))))),Fa=(e,t,o)=>{const n=D(t.selection,(t=>Kt(t).bind((t=>Pa(e,t))).filter(o))),r=kt(n);return _t(r.length>0,r)},za=(e,t,o,n,r)=>(s,a,i,l)=>{const c=sn.fromTable(s),d=C.from(null==l?void 0:l.section).getOrThunk(Da);return t(c,a).map((t=>{const o=((e,t)=>Ha(e,t,!1))(c,i),n=e(o,t,Te,r(i),d),s=tn(n.grid);return{info:t,grid:Ia(n.grid),cursor:n.cursor,lockedColumns:s}})).bind((e=>{const t=Na(s,e.grid),r=C.from(null==l?void 0:l.sizing).getOrThunk((()=>gr(s))),a=C.from(null==l?void 0:l.resize).getOrThunk(ga);return o(s,e.grid,e.info,{sizing:r,resize:a,section:d}),n(s),we(s,Qo),e.lockedColumns.length>0&&fe(s,Qo,e.lockedColumns.join(",")),C.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})}))},Va=(e,t)=>Fa(e,t,x).map((e=>({cells:e,generators:t.generators,clipboard:t.clipboard}))),Za=(e,t)=>Fa(e,t,x),Ua=(e,t)=>Fa(e,t,(e=>!e.isLocked)),ja=(e,t)=>F(t,(t=>((e,t)=>Pa(e,t).exists((e=>!e.isLocked)))(e,t))),Wa=(e,t,o,n)=>{const r=Xo(e).rows;let s=!0;for(let e=0;e{const r=Xo(e).rows;if(t>0&&tB(e,((e,o)=>T(e,(e=>t(e.element,o.element)))?e:e.concat([o])),[]))(r[t-1].cells,o);A(e,(e=>{let s=C.none();for(let a=t;a{$o(i,t,ot(e,!0,l.isLocked))})))}}))}return e},qa=e=>{const t=t=>t(e),o=h(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:x,isError:w,map:t=>Ka.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>C.some(e)};return r},Ga=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:w,isError:x,map:t,mapError:t=>Ka.error(t(e)),bind:t,exists:w,forall:x,getOr:p,or:p,getOrThunk:y,orThunk:y,getOrDie:(n=String(e),()=>{throw new Error(n)}),each:g,toOptional:C.none};var n;return o},Ka={value:qa,error:Ga,fromOption:(e,t)=>e.fold((()=>Ga(t)),qa)},Ya=(e,t)=>({rowDelta:0,colDelta:Yo(e[0])-Yo(t[0])}),Xa=(e,t)=>({rowDelta:e.length-t.length,colDelta:0}),Ja=(e,t,o,n)=>{const r="colgroup"===t.section?o.col:o.cell;return O(e,(e=>ot(r(),!0,n(e))))},Qa=(e,t,o,n)=>{const r=e[e.length-1];return e.concat(O(t,(()=>{const e="colgroup"===r.section?o.colgroup:o.row,t=Jo(r,e,p),s=Ja(t.cells.length,t,o,(e=>Q(n,e.toString())));return qo(t,s)})))},ei=(e,t,o,n)=>D(e,(e=>{const r=Ja(t,e,o,w);return jo(e,n,r)})),ti=(e,t,o)=>{const n=t.colDelta<0?ei:p,r=t.rowDelta<0?Qa:p,s=tn(e),a=Yo(e[0]),i=T(s,(e=>e===a-1)),l=n(e,Math.abs(t.colDelta),o,i?a-1:a),c=tn(l);return r(l,Math.abs(t.rowDelta),o,z(c,x))},oi=(e,t,o,n)=>{const r=v(n,Go(e[t],o).element),s=e[t];return e.length>1&&Yo(s)>1&&(o>0&&r(Ko(s,o-1))||o0&&r(Ko(e[t-1],o))||tN(o,(o=>o>=e.column&&o<=Yo(t[0])+e.column)),ri=(e,t,o,n,r)=>{const s=tn(t),a=((e,t,o)=>{const n=Yo(t[0]),r=Xo(t).cols.length+e.row,s=O(n-e.column,(t=>t+e.column)),a=L(s,(e=>F(o,(t=>t!==e)))).getOr(n-1);return{row:r,column:a}})(e,t,s),i=Xo(o).rows,l=ni(a,i,s),c=((e,t,o)=>{if(e.row>=t.length||e.column>Yo(t[0]))return Ka.error("invalid start address out of table bounds, row: "+e.row+", column: "+e.column);const n=t.slice(e.row),r=n[0].cells.slice(e.column),s=Yo(o[0]),a=o.length;return Ka.value({rowDelta:n.length-a,colDelta:r.length-s})})(a,t,i);return c.map((e=>{const o={...e,colDelta:e.colDelta-l.length},s=ti(t,o,n),c=tn(s),d=ni(a,i,c);return((e,t,o,n,r,s)=>{const a=e.row,i=e.column,l=a+o.length,c=i+Yo(o[0])+s.length,d=z(s,x);for(let e=a;e{((e,t,o,n)=>{t>0&&t{const r=e.cells[t-1];let s=0;const a=n();for(;e.cells.length>t+s&&o(r.element,e.cells[t+s].element);)$o(e,t+s,ot(a,!0,e.cells[t+s].isLocked)),s++}))})(t,e,r,n.cell);const s=Xa(o,t),a=ti(o,s,n),i=Xa(t,a),l=ti(t,i,n);return D(l,((t,o)=>jo(t,e,a[o].cells)))},ai=(e,t,o,n,r)=>{$a(t,e,r,n.cell);const s=tn(t),a=Ya(t,o),i={...a,colDelta:a.colDelta-s.length},l=ti(t,i,n),{cols:c,rows:d}=Xo(l),m=tn(l),u=Ya(o,t),g={...u,colDelta:u.colDelta+m.length},h=((e,t,o)=>D(e,(e=>B(o,((o,n)=>{const r=Ja(1,e,t,x)[0];return Wo(o,n,r)}),e))))(o,n,m),p=ti(h,g,n);return[...c,...d.slice(0,e),...p,...d.slice(e,d.length)]},ii=(e,t,o,n,r)=>{const{rows:s,cols:a}=Xo(e),i=s.slice(0,t),l=s.slice(t),c=((e,t,o,n)=>Jo(e,(e=>n(e,o)),t))(s[o],((e,o)=>t>0&&tD(e,(e=>{const s=t>0&&t{if("colgroup"!==o&&n)return Go(e,t);{const t=Go(e,r);return ot(a(t.element,s),!0,!1)}})(e,t,e.section,s,o,n,r);return Wo(e,t,a)})),ci=(e,t,o,n)=>((e,t,o,n)=>void 0!==Ko(e[t],o)&&t>0&&n(Ko(e[t-1],o),Ko(e[t],o)))(e,t,o,n)||((e,t,o)=>t>0&&o(Ko(e,t-1),Ko(e,t)))(e[t],o,n),di=(e,t,o,n)=>{const r=e=>(e=>"row"===e?Ut(t):Zt(t))(e)?`${e}group`:e;if(e)return pa(t)?r(o):null;if(n&&pa(t)){return r("row"===o?"col":"row")}return null},mi=(e,t,o)=>ot(o(e.element,t),!0,e.isLocked),ui=(e,t,o,n,r,s,a)=>D(e,((e,i)=>((e,t)=>{const o=e.cells,n=D(o,t);return nt(e.element,n,e.section,e.isNew)})(e,((e,l)=>{if((e=>T(t,(t=>o(e.element,t.element))))(e)){const t=a(e,i,l)?r(e,o,n):e;return s(t,i,l).each((e=>{var o,n;o=t.element,n={scope:C.from(e)},q(n,((e,t)=>{e.fold((()=>{we(o,t)}),(e=>{pe(o.dom,t,e)}))}))})),t}return e})))),gi=(e,t,o)=>P(e,((n,r)=>ci(e,r,t,o)?[]:[Go(n,t)])),hi=(e,t,o,n,r)=>{const s=Xo(e).rows,a=P(t,(e=>gi(s,e,n))),i=D(s,(e=>fa(e.cells))),l=((e,t)=>F(t,p)&&fa(e)?x:(e,o,n)=>!("th"===se(e.element)&&t[o]))(a,i),c=((e,t)=>(o,n)=>C.some(di(e,o.element,"row",t[n])))(o,i);return ui(e,a,n,r,mi,c,l)},pi=(e,t,o,n,r,s,a)=>{const{cols:i,rows:l}=Xo(e),c=l[t[0]],d=P(t,(e=>((e,t,o)=>{const n=e[t];return P(n.cells,((n,r)=>ci(e,t,r,o)?[]:[n]))})(l,e,r))),m=D(c.cells,((e,t)=>fa(gi(l,t,r)))),u=[...l];A(t,(e=>{u[e]=a.transformRow(l[e],o)}));const g=[...i,...u],h=((e,t)=>F(t,p)&&fa(e.cells)?x:(e,o,n)=>!("th"===se(e.element)&&t[n]))(c,m),f=((e,t)=>(o,n,r)=>C.some(di(e,o.element,"col",t[r])))(n,m);return ui(g,d,r,s,a.transformCell,f,h)},fi=(e,t,o,n)=>{const r=Xo(e).rows,s=D(t,(e=>Go(r[e.row],e.column)));return ui(e,s,o,n,mi,C.none,x)},vi=e=>{if(!a(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return A(e,((n,r)=>{const s=W(n);if(1!==s.length)throw new Error("one and only one name per case");const i=s[0],l=n[i];if(void 0!==o[i])throw new Error("duplicate key detected:"+i);if("cata"===i)throw new Error("cannot have a case named cata (sorry)");if(!a(l))throw new Error("case arguments must be an array");t.push(i),o[i]=(...o)=>{const n=o.length;if(n!==l.length)throw new Error("Wrong number of arguments to case "+i+". Expected "+l.length+" ("+l+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=W(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!F(t,(e=>E(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[i].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:i,params:o})}}}})),o},bi={...vi([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}])},yi=(e,t,o,n,r)=>{const s=e.slice(0),a=((e,t)=>0===e.length?bi.none():1===e.length?bi.only(0):0===t?bi.left(0,1):t===e.length-1?bi.right(t-1,t):t>0&&tn.singleColumnWidth(s[e],o)),((e,t)=>r.calcLeftEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)),((e,t,a)=>r.calcMiddleDeltas(s,e,t,a,o,n.minCellWidth(),n.isRelative)),((e,t)=>r.calcRightEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)))},wi=(e,t,o)=>{let n=0;for(let r=e;r{const o=sn.justCells(e);return D(o,(e=>{const o=wi(e.row,e.row+e.rowspan,t);return{element:e.element,height:o,rowspan:e.rowspan}}))},Ci=(e,t)=>sn.hasColumns(e)?((e,t)=>{const o=sn.justColumns(e);return D(o,((e,o)=>({element:e.element,width:t[o],colspan:e.colspan})))})(e,t):((e,t)=>{const o=sn.justCells(e);return D(o,(e=>{const o=wi(e.column,e.column+e.colspan,t);return{element:e.element,width:o,colspan:e.colspan}}))})(e,t),Si=(e,t,o)=>{const n=Ci(e,t);A(n,(e=>{o.setElementWidth(e.element,e.width)}))},ki=(e,t,o,n,r)=>{const s=sn.fromTable(e),a=r.getCellDelta(t),i=r.getWidths(s,r),l=o===s.grid.columns-1,c=n.clampTableDelta(i,o,a,r.minCellWidth(),l),d=yi(i,o,c,r,n),m=D(d,((e,t)=>e+i[t]));Si(s,m,r),n.resizeTable(r.adjustTableWidth,c,l)},_i=(e,t,o,n)=>{const r=sn.fromTable(e),s=((e,t,o)=>lr(e,t,o,Xn,(e=>e.getOrThunk($t))))(r,e,n),a=D(s,((e,n)=>o===n?Math.max(t+e,$t()):e)),i=xi(r,a),l=((e,t)=>D(e.all,((e,o)=>({element:e.element,height:t[o]}))))(r,a);A(l,(e=>{jn(e.element,e.height)})),A(i,(e=>{jn(e.element,e.height)}));const c=R(a,((e,t)=>e+t),0);jn(e,c)},Ei=e=>B(e,((e,t)=>T(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),Ti=he("col"),Oi=he("colgroup"),Di=e=>"tr"===se(e)||Oi(e),Ai=e=>({element:e,colspan:zt(e,"colspan",1),rowspan:zt(e,"rowspan",1)}),Mi=e=>ye(e,"scope").map((e=>e.substr(0,3))),Ni=(e,t=Ai)=>{const o=o=>{if(Di(o))return Oi((r={element:o}).element)?e.colgroup(r):e.row(r);{const r=o,s=(t=>Ti(t.element)?e.col(t):e.cell(t))(t(r));return n=C.some({item:r,replacement:s}),s}var r};let n=C.none();return{getOrInit:(e,t)=>n.fold((()=>o(e)),(n=>t(e,n.item)?n.replacement:o(e)))}},Ri=e=>t=>{const o=[],n=n=>{const r="td"===e?{scope:null}:{},s=t.replace(n,e,r);return o.push({item:n,sub:s}),s};return{replaceOrInit:(e,t)=>{if(Di(e)||Ti(e))return e;{const r=e;return((e,t)=>L(o,(o=>t(o.item,e))))(r,t).fold((()=>n(r)),(o=>t(e,o.item)?o.sub:n(r)))}}}},Bi=e=>({unmerge:t=>{const o=Mi(t);return o.each((e=>fe(t,"scope",e))),()=>{const n=e.cell({element:t,colspan:1,rowspan:1});return Ft(n,"width"),Ft(t,"width"),o.each((e=>fe(n,"scope",e))),n}},merge:e=>(Ft(e[0],"width"),(()=>{const t=kt(D(e,Mi));if(0===t.length)return C.none();{const e=t[0],o=["row","col"];return T(t,(t=>t!==e&&E(o,t)))?C.none():C.from(e)}})().fold((()=>we(e[0],"scope")),(t=>fe(e[0],"scope",t+"group"))),h(e[0]))}),Li=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Hi=Cs(),Ii=e=>((e,t)=>{const o=e.property().name(t);return E(Li,o)})(Hi,e),Pi=e=>((e,t)=>{const o=e.property().name(t);return E(["ol","ul"],o)})(Hi,e),Fi=e=>((e,t)=>E(["br","img","hr","input"],e.property().name(t)))(Hi,e),zi=e=>{const t=he("br"),o=e=>Er(e).bind((o=>{const n=He(o).map((e=>!!Ii(e)||!!Fi(e)&&"img"!==se(e))).getOr(!1);return Ne(o).map((r=>!0===n||(e=>"li"===se(e)||vt(e,Pi).isSome())(r)||t(o)||Ii(r)&&!Te(e,r)?[]:[Se.fromTag("br")]))})).getOr([]),n=(()=>{const n=P(e,(e=>{const n=Ie(e);return(e=>F(e,(e=>t(e)||me(e)&&0===yr(e).trim().length)))(n)?[]:n.concat(o(e))}));return 0===n.length?[Se.fromTag("br")]:n})();$e(e[0]),We(e[0],n)},Vi=e=>os(e,!0),Zi=e=>{0===Yt(e).length&&qe(e)},Ui=(e,t)=>({grid:e,cursor:t}),ji=(e,t,o)=>{var n,r;const s=Xo(e).rows;return C.from(null===(r=null===(n=s[t])||void 0===n?void 0:n.cells[o])||void 0===r?void 0:r.element).filter(Vi).orThunk((()=>(e=>j(e,(e=>j(e.cells,(e=>{const t=e.element;return _t(Vi(t),t)})))))(s)))},Wi=(e,t,o)=>{const n=ji(e,t,o);return Ui(e,n)},$i=e=>B(e,((e,t)=>T(e,(e=>e.row===t.row))?e:e.concat([t])),[]).sort(((e,t)=>e.row-t.row)),qi=(e,t)=>(o,n,r,s,a)=>{const i=$i(n),l=D(i,(e=>e.row)),c=pi(o,l,e,t,r,s.replaceOrInit,a);return Wi(c,n[0].row,n[0].column)},Gi=qi("thead",!0),Ki=qi("tbody",!1),Yi=qi("tfoot",!1),Xi=(e,t,o)=>{const n=((e,t)=>to(e,(()=>t)))(e,o.section),r=sn.generate(n);return Ha(r,t,!0)},Ji=(e,t,o,n)=>((e,t,o,n)=>{const r=sn.generate(t),s=n.getWidths(r,n);Si(r,s,n)})(0,t,0,n.sizing),Qi=(e,t,o,n)=>((e,t,o,n,r)=>{const s=sn.generate(t),a=n.getWidths(s,n),i=n.pixelWidth(),{newSizes:l,delta:c}=r.calcRedestributedWidths(a,i,o.pixelDelta,n.isRelative);Si(s,l,n),n.adjustTableWidth(c)})(0,t,o,n.sizing,n.resize),el=(e,t)=>T(t,(e=>0===e.column&&e.isLocked)),tl=(e,t)=>T(t,(t=>t.column+t.colspan>=e.grid.columns&&t.isLocked)),ol=(e,t)=>{const o=an(e),n=Ei(t);return B(n,((e,t)=>e+o[t.column].map(Vo).getOr(0)),0)},nl=e=>(t,o)=>Za(t,o).filter((o=>!(e?el:tl)(t,o))).map((e=>({details:e,pixelDelta:ol(t,e)}))),rl=e=>(t,o)=>Va(t,o).filter((o=>!(e?el:tl)(t,o.cells))),sl=Ri("th"),al=Ri("td"),il=za(((e,t,o,n)=>{const r=t[0].row,s=$i(t),a=R(s,((e,t)=>({grid:ii(e.grid,r,t.row+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return Wi(a,r,t[0].column)}),Za,g,g,Ni),ll=za(((e,t,o,n)=>{const r=$i(t),s=r[r.length-1],a=s.row+s.rowspan,i=R(r,((e,t)=>ii(e,a,t.row,o,n.getOrInit)),e);return Wi(i,a,t[0].column)}),Za,g,g,Ni),cl=za(((e,t,o,n)=>{const r=t.details,s=Ei(r),a=s[0].column,i=R(s,((e,t)=>({grid:li(e.grid,a,t.column+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return Wi(i,r[0].row,a)}),nl(!0),Qi,g,Ni),dl=za(((e,t,o,n)=>{const r=t.details,s=r[r.length-1],a=s.column+s.colspan,i=Ei(r),l=R(i,((e,t)=>li(e,a,t.column,o,n.getOrInit)),e);return Wi(l,r[0].row,a)}),nl(!1),Qi,g,Ni),ml=za(((e,t,o,n)=>{const r=Ei(t.details),s=((e,t)=>P(e,(e=>{const o=e.cells,n=R(t,((e,t)=>t>=0&&t0?[nt(e.element,n,e.section,e.isNew)]:[]})))(e,D(r,(e=>e.column))),a=s.length>0?s[0].cells.length-1:0;return Wi(s,r[0].row,Math.min(r[0].column,a))}),((e,t)=>Ua(e,t).map((t=>({details:t,pixelDelta:-ol(e,t)})))),Qi,Zi,Ni),ul=za(((e,t,o,n)=>{const r=$i(t),s=((e,t,o)=>{const{rows:n,cols:r}=Xo(e);return[...r,...n.slice(0,t),...n.slice(o+1)]})(e,r[0].row,r[r.length-1].row),a=s.length>0?s.length-1:0;return Wi(s,Math.min(t[0].row,a),t[0].column)}),Za,g,Zi,Ni),gl=za(((e,t,o,n)=>{const r=Ei(t),s=D(r,(e=>e.column)),a=hi(e,s,!0,o,n.replaceOrInit);return Wi(a,t[0].row,t[0].column)}),Ua,g,g,sl),hl=za(((e,t,o,n)=>{const r=Ei(t),s=D(r,(e=>e.column)),a=hi(e,s,!1,o,n.replaceOrInit);return Wi(a,t[0].row,t[0].column)}),Ua,g,g,al),pl=za(Gi,Ua,g,g,sl),fl=za(Ki,Ua,g,g,al),vl=za(Yi,Ua,g,g,al),bl=za(((e,t,o,n)=>{const r=fi(e,t,o,n.replaceOrInit);return Wi(r,t[0].row,t[0].column)}),Ua,g,g,sl),yl=za(((e,t,o,n)=>{const r=fi(e,t,o,n.replaceOrInit);return Wi(r,t[0].row,t[0].column)}),Ua,g,g,al),wl=za(((e,t,o,n)=>{const r=t.cells;zi(r);const s=((e,t,o,n)=>{const r=Xo(e).rows;if(0===r.length)return e;for(let e=t.startRow;e<=t.finishRow;e++)for(let o=t.startCol;o<=t.finishCol;o++){const t=r[e],s=Go(t,o).isLocked;$o(t,o,ot(n(),!1,s))}return e})(e,t.bounds,0,n.merge(r));return Ui(s,C.from(r[0]))}),((e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>ja(e,t.cells)))),Ji,g,Bi),xl=za(((e,t,o,n)=>{const r=R(t,((e,t)=>Wa(e,t,o,n.unmerge(t))),e);return Ui(r,C.from(t[0]))}),((e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>ja(e,t)))),Ji,g,Bi),Cl=za(((e,t,o,n)=>{const r=((e,t)=>{const o=sn.fromTable(e);return Ha(o,t,!0)})(t.clipboard,t.generators),s=((e,t)=>({row:e,column:t}))(t.row,t.column);return ri(s,e,r,t.generators,o).fold((()=>Ui(e,C.some(t.element))),(e=>Wi(e,t.row,t.column)))}),((e,t)=>Kt(t.element).bind((o=>Pa(e,o).map((e=>({...e,generators:t.generators,clipboard:t.clipboard})))))),Ji,g,Ni),Sl=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[0].column,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=si(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),rl(!0),g,g,Ni),kl=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[t.cells.length-1].column+t.cells[t.cells.length-1].colspan,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=si(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),rl(!1),g,g,Ni),_l=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[0].row,a=r[s],i=Xi(t.clipboard,t.generators,a),l=ai(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),Va,g,g,Ni),El=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[t.cells.length-1].row+t.cells[t.cells.length-1].rowspan,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=ai(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),Va,g,g,Ni),Tl=(e,t)=>{const o=sn.fromTable(e);return Za(o,t).bind((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=I(D(o.all,(e=>N(e.cells,(e=>e.column>=n&&e.column{const o=sn.fromTable(e);return Za(o,t).bind(ya).getOr("")},Dl=(e,t)=>{const o=sn.fromTable(e);return Za(o,t).bind((e=>{const t=e[e.length-1],n=e[0].row,r=t.row+t.rowspan;return(e=>{const t=D(e,(e=>ba(e).type)),o=E(t,"header"),n=E(t,"footer");if(o||n){const e=E(t,"body");return!o||e||n?o||e||!n?C.none():C.some("footer"):C.some("header")}return C.some("body")})(o.all.slice(n,r))})).getOr("")},Al=(e,t)=>e.dispatch("NewRow",{node:t}),Ml=(e,t)=>e.dispatch("NewCell",{node:t}),Nl=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},Rl={structure:!1,style:!0},Bl={structure:!0,style:!1},Ll={structure:!0,style:!0},Hl=(e,t)=>$r(e)?pr(t):qr(e)?hr(t):gr(t),Il=(e,t,o)=>{const n=e=>"table"===se(rs(e)),r=zr(e),s=jr(e)?g:aa,a=t=>{switch(Vr(e)){case"section":return Ea();case"sectionCells":return Ta();case"cells":return Oa();default:return _a(t,"section")}},i=(t,n)=>n.cursor.fold((()=>{const n=Yt(t);return Z(n).filter(dt).map((n=>{o.clearSelectedCells(t.dom);const r=e.dom.createRng();return r.selectNode(n.dom),e.selection.setRng(r),fe(n,"data-mce-selected","1"),r}))}),(n=>{const r=ra(sa,n);const s=e.dom.createRng();return s.setStart(r.element.dom,r.offset),s.setEnd(r.element.dom,r.offset),e.selection.setRng(s),o.clearSelectedCells(t.dom),C.some(s)})),l=(o,n,s,l)=>(c,d,m=!1)=>{as(c);const u=Se.fromDom(e.getDoc()),g=Lr(s,u,r),h={sizing:Hl(e,c),resize:jr(e)?ua():ga(),section:a(c)};return n(c)?o(c,d,g,h).bind((o=>{t.refresh(c.dom),A(o.newRows,(t=>{Al(e,t.dom)})),A(o.newCells,(t=>{Ml(e,t.dom)}));const n=i(c,o);return dt(c)&&(as(c),m||Nl(e,c.dom,l)),n.map((e=>({rng:e,effect:l})))})):C.none()},c=l(ul,(t=>!n(e)||ha(t).rows>1),g,Bl),d=l(ml,(t=>!n(e)||ha(t).columns>1),g,Bl);return{deleteRow:c,deleteColumn:d,insertRowsBefore:l(il,x,g,Bl),insertRowsAfter:l(ll,x,g,Bl),insertColumnsBefore:l(cl,x,s,Bl),insertColumnsAfter:l(dl,x,s,Bl),mergeCells:l(wl,x,g,Bl),unmergeCells:l(xl,x,g,Bl),pasteColsBefore:l(Sl,x,g,Bl),pasteColsAfter:l(kl,x,g,Bl),pasteRowsBefore:l(_l,x,g,Bl),pasteRowsAfter:l(El,x,g,Bl),pasteCells:l(Cl,x,g,Ll),makeCellsHeader:l(bl,x,g,Bl),unmakeCellsHeader:l(yl,x,g,Bl),makeColumnsHeader:l(gl,x,g,Bl),unmakeColumnsHeader:l(hl,x,g,Bl),makeRowsHeader:l(pl,x,g,Bl),makeRowsBody:l(fl,x,g,Bl),makeRowsFooter:l(vl,x,g,Bl),getTableRowType:Dl,getTableCellType:Ol,getTableColType:Tl}},Pl=(e,t,o)=>{const n=zt(e,t,1);1===o||n<=1?we(e,t):fe(e,t,Math.min(o,n))},Fl=(e,t)=>o=>{const n=o.column+o.colspan-1,r=o.column;return n>=e&&r{const o=sn.fromTable(e);return Ua(o,t).map((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=((e,t,o)=>{if(sn.hasColumns(e)){const n=N(sn.justColumns(e),Fl(t,o)),r=D(n,(e=>{const n=Xe(e.element);return Pl(n,"span",o-t),n})),s=Se.fromTag("colgroup");return We(s,r),[s]}return[]})(o,n,r),a=((e,t,o)=>D(e.all,(e=>{const n=N(e.cells,Fl(t,o)),r=D(n,(e=>{const n=Xe(e.element);return Pl(n,"colspan",o-t),n})),s=Se.fromTag("tr");return We(s,r),s})))(o,n,r);return[...s,...a]}))},Vl=(e,t,o)=>{const n=sn.fromTable(e);return Za(n,t).bind((e=>{const t=Ha(n,o,!1),r=Xo(t).rows.slice(e[0].row,e[e.length-1].row+e[e.length-1].rowspan),s=P(r,(e=>{const t=N(e.cells,(e=>!e.isLocked));return t.length>0?[{...e,cells:t}]:[]})),a=Ia(s);return _t(a.length>0,a)})).map((e=>(e=>D(e,(e=>{const t=Ye(e.element);return A(e.cells,(e=>{const o=Xe(e.element);Aa(o,"colspan",e.colspan,1),Aa(o,"rowspan",e.rowspan,1),Ze(t,o)})),t})))(e)))},Zl=vi([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),Ul=(e,t,o)=>{const n=o.substring(0,o.length-e.length),r=parseFloat(n);return n===r.toString()?t(r):Zl.invalid(o)},jl={...Zl,from:e=>Dt(e,"%")?Ul("%",Zl.percent,e):Dt(e,"px")?Ul("px",Zl.pixels,e):Zl.invalid(e)},Wl=(e,t,o)=>e.fold((()=>t),(e=>((e,t,o)=>{const n=o/t;return D(e,(e=>jl.from(e).fold((()=>e),(e=>e*n+"px"),(e=>e/100*o+"px"))))})(t,o,e)),(e=>((e,t)=>D(e,(e=>jl.from(e).fold((()=>e),(e=>e/t*100+"%"),(e=>e+"%")))))(t,o))),$l=(e,t,o)=>{const n=jl.from(o),r=F(e,(e=>"0px"===e))?((e,t)=>{const o=e.fold((()=>h("")),(e=>h(e/t+"px")),(()=>h(100/t+"%")));return O(t,o)})(n,e.length):Wl(n,e,t);return Kl(r)},ql=(e,t)=>0===e.length?t:R(e,((e,t)=>jl.from(t).fold(h(0),p,p)+e),0),Gl=(e,t)=>jl.from(e).fold(h(e),(e=>e+t+"px"),(e=>e+t+"%")),Kl=e=>{if(0===e.length)return e;const t=R(e,((e,t)=>{const o=jl.from(t).fold((()=>({value:t,remainder:0})),(e=>((e,t)=>{const o=Math.floor(e);return{value:o+t,remainder:e-o}})(e,"px")),(e=>({value:e+"%",remainder:0})));return{output:[o.value].concat(e.output),remainder:e.remainder+o.remainder}}),{output:[],remainder:0}),o=t.output;return o.slice(0,o.length-1).concat([Gl(o[o.length-1],Math.round(t.remainder))])},Yl=jl.from,Xl=e=>Yl(e).fold(h("px"),h("px"),h("%")),Jl=(e,t,o)=>{const n=sn.fromTable(e),r=n.all,s=sn.justCells(n),a=sn.justColumns(n);t.each((t=>{const o=Xl(t),r=zo(e),i=((e,t)=>sr(e,t,or,ar))(n,e),l=$l(i,r,t);sn.hasColumns(n)?((e,t,o)=>{A(t,((t,n)=>{const r=ql([e[n]],Wt());Bt(t.element,"width",r+o)}))})(l,a,o):((e,t,o)=>{A(t,(t=>{const n=e.slice(t.column,t.colspan+t.column),r=ql(n,Wt());Bt(t.element,"width",r+o)}))})(l,s,o),Bt(e,"width",t)})),o.each((t=>{const o=Xl(t),a=hn(e),i=((e,t,o)=>lr(e,t,o,nr,ar))(n,e,Nn);((e,t,o,n)=>{A(o,(t=>{const o=e.slice(t.row,t.rowspan+t.row),r=ql(o,$t());Bt(t.element,"height",r+n)})),A(t,((t,o)=>{Bt(t.element,"height",e[o])}))})($l(i,a,t),r,s,o),Bt(e,"height",t)}))},Ql=e=>Gn(e).exists((e=>Pn.test(e))),ec=e=>Gn(e).exists((e=>Fn.test(e))),tc=e=>Gn(e).isNone(),oc=e=>{we(e,"width")},nc=e=>{const t=Qn(e);Jl(e,C.some(t),C.none()),oc(e)},rc=e=>{const t=(e=>zo(e)+"px")(e);Jl(e,C.some(t),C.none()),oc(e)},sc=e=>{Ft(e,"width");const t=Xt(e),o=t.length>0?t:Yt(e);A(o,(e=>{Ft(e,"width"),oc(e)})),oc(e)},ac={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},colGroups:!1},ic=e=>{const t=Se.fromTag("colgroup");return O(e,(()=>Ze(t,Se.fromTag("col")))),t},lc=(e,t,o,n)=>O(e,(e=>((e,t,o,n)=>{const r=Se.fromTag("tr");for(let s=0;s{e.selection.select(t.dom,!0),e.selection.collapse(!0)},dc=(e,t,o,n,s)=>{const a=Qr(e),i={styles:a,attributes:Jr(e),colGroups:es(e)};return e.undoManager.ignore((()=>{const r=((e,t,o,n,r,s=ac)=>{const a=Se.fromTag("table"),i="cells"!==r;Lt(a,s.styles),ve(a,s.attributes),s.colGroups&&Ze(a,ic(t));const l=Math.min(e,o);if(i&&o>0){const e=Se.fromTag("thead");Ze(a,e);const s=lc(o,t,"sectionCells"===r?l:0,n);We(e,s)}const c=Se.fromTag("tbody");Ze(a,c);const d=lc(i?e-l:e,t,i?0:o,n);return We(c,d),a})(o,t,s,n,Vr(e),i);fe(r,"data-mce-id","__mce");const a=(e=>{const t=Se.fromTag("div"),o=Se.fromDom(e.dom.cloneNode(!0));return Ze(t,o),(e=>e.dom.innerHTML)(t)})(r);e.insertContent(a),e.addVisual()})),xt(rs(e),'table[data-mce-id="__mce"]').map((t=>(qr(e)?rc(t):Gr(e)?sc(t):($r(e)||(e=>r(e)&&-1!==e.indexOf("%"))(a.width))&&nc(t),as(t),we(t,"data-mce-id"),((e,t)=>{A(pt(t,"tr"),(t=>{Al(e,t.dom),A(pt(t,"th,td"),(t=>{Ml(e,t.dom)}))}))})(e,t),((e,t)=>{xt(t,"td,th").each(v(cc,e))})(e,t),t.dom))).getOrNull()};var mc=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const uc="x-tinymce/dom-table-",gc=uc+"rows",hc=uc+"columns",pc=e=>{const t=mc.FakeClipboardItem(e);mc.write([t])},fc=e=>{var t;const o=null!==(t=mc.read())&&void 0!==t?t:[];return j(o,(t=>C.from(t.getType(e))))},vc=e=>{fc(e).isSome()&&mc.clear()},bc=e=>{e.fold(wc,(e=>pc({[gc]:e})))},yc=()=>fc(gc),wc=()=>vc(gc),xc=e=>{e.fold(Sc,(e=>pc({[hc]:e})))},Cc=()=>fc(hc),Sc=()=>vc(hc),kc=e=>Ys(is(e),ss(e)).filter(ds),_c=(e,t)=>{const o=ss(e),n=e=>Jt(e,o),a=t=>(e=>Xs(is(e),ss(e)).filter(ds))(e).bind((e=>n(e).map((o=>t(o,e))))),i=t=>{e.focus()},l=(t,o=!1)=>a(((n,r)=>{const s=Gs(Js(e),n,r);t(n,s,o).each(i)})),c=()=>a(((t,o)=>{const n=Gs(Js(e),t,o),r=Lr(g,Se.fromDom(e.getDoc()),C.none());return Vl(t,n,r)})),d=()=>a(((t,o)=>{const n=Gs(Js(e),t,o);return zl(t,n)})),m=(t,o)=>o().each((o=>{const n=D(o,(e=>Xe(e)));a(((o,r)=>{const s=Hr(Se.fromDom(e.getDoc())),a=((e,t,o,n)=>({selection:Hs(e),clipboard:o,generators:n}))(Js(e),0,n,s);t(o,a).each(i)}))})),h=e=>(t,o)=>((e,t)=>Q(e,t)?C.from(e[t]):C.none())(o,"type").each((t=>{l(e(t),o.no_events)}));q({mceTableSplitCells:()=>l(t.unmergeCells),mceTableMergeCells:()=>l(t.mergeCells),mceTableInsertRowBefore:()=>l(t.insertRowsBefore),mceTableInsertRowAfter:()=>l(t.insertRowsAfter),mceTableInsertColBefore:()=>l(t.insertColumnsBefore),mceTableInsertColAfter:()=>l(t.insertColumnsAfter),mceTableDeleteCol:()=>l(t.deleteColumn),mceTableDeleteRow:()=>l(t.deleteRow),mceTableCutCol:()=>d().each((e=>{xc(e),l(t.deleteColumn)})),mceTableCutRow:()=>c().each((e=>{bc(e),l(t.deleteRow)})),mceTableCopyCol:()=>d().each((e=>xc(e))),mceTableCopyRow:()=>c().each((e=>bc(e))),mceTablePasteColBefore:()=>m(t.pasteColsBefore,Cc),mceTablePasteColAfter:()=>m(t.pasteColsAfter,Cc),mceTablePasteRowBefore:()=>m(t.pasteRowsBefore,yc),mceTablePasteRowAfter:()=>m(t.pasteRowsAfter,yc),mceTableDelete:()=>kc(e).each((t=>{Jt(t,o).filter(b(o)).each((t=>{const o=Se.fromText("");if(ze(t,o),qe(t),e.dom.isEmpty(e.getBody()))e.setContent(""),e.selection.setCursorLocation();else{const t=e.dom.createRng();t.setStart(o.dom,0),t.setEnd(o.dom,0),e.selection.setRng(t),e.nodeChanged()}}))})),mceTableCellToggleClass:(t,o)=>{a((t=>{const n=Js(e),r=F(n,(t=>e.formatter.match("tablecellclass",{value:o},t.dom))),s=r?e.formatter.remove:e.formatter.apply;A(n,(e=>s("tablecellclass",{value:o},e.dom))),Nl(e,t.dom,Rl)}))},mceTableToggleClass:(t,o)=>{a((t=>{e.formatter.toggle("tableclass",{value:o},t.dom),Nl(e,t.dom,Rl)}))},mceTableToggleCaption:()=>{kc(e).each((t=>{Jt(t,o).each((o=>{wt(o,"caption").fold((()=>{const t=Se.fromTag("caption");Ze(t,Se.fromText("Caption")),((e,t,o)=>{Pe(e,o).fold((()=>{Ze(e,t)}),(e=>{Fe(e,t)}))})(o,t,0),e.selection.setCursorLocation(t.dom,0)}),(n=>{he("caption")(t)&&Ee("td",o).each((t=>e.selection.setCursorLocation(t.dom,0))),qe(n)})),Nl(e,o.dom,Bl)}))}))},mceTableSizingMode:(t,n)=>(t=>kc(e).each((n=>{Gr(e)||qr(e)||$r(e)||Jt(n,o).each((o=>{"relative"!==t||Ql(o)?"fixed"!==t||ec(o)?"responsive"!==t||tc(o)||sc(o):rc(o):nc(o),as(o),Nl(e,o.dom,Bl)}))})))(n),mceTableCellType:h((e=>"th"===e?t.makeCellsHeader:t.unmakeCellsHeader)),mceTableColType:h((e=>"th"===e?t.makeColumnsHeader:t.unmakeColumnsHeader)),mceTableRowType:h((e=>{switch(e){case"header":return t.makeRowsHeader;case"footer":return t.makeRowsFooter;default:return t.makeRowsBody}}))},((t,o)=>e.addCommand(o,t))),e.addCommand("mceInsertTable",((t,o)=>{((e,t,o,n={})=>{const r=e=>u(e)&&e>0;if(r(t)&&r(o)){const r=n.headerRows||0,s=n.headerColumns||0;return dc(e,o,t,s,r)}console.error("Invalid values for mceInsertTable - rows and columns values are required to insert a table.")})(e,o.rows,o.columns,o.options)})),e.addCommand("mceTableApplyCellStyle",((t,o)=>{const a=e=>"tablecell"+e.toLowerCase().replace("-","");if(!s(o))return;const i=N(Js(e),ds);if(0===i.length)return;const l=Y(o,((t,o)=>e.formatter.has(a(o))&&r(t)));(e=>{for(const t in e)if($.call(e,t))return!1;return!0})(l)||(q(l,((t,o)=>{const n=a(o);A(i,(o=>{""===t?e.formatter.remove(n,{value:null},o.dom,!0):e.formatter.apply(n,{value:t},o.dom)}))})),n(i[0]).each((t=>Nl(e,t.dom,Rl))))}))},Ec=vi([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Tc={before:Ec.before,on:Ec.on,after:Ec.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(p,p,p)},Oc=(e,t)=>({selection:e,kill:t}),Dc=(e,t)=>{const o=e.document.createRange();return o.selectNode(t.dom),o},Ac=(e,t)=>{const o=e.document.createRange();return Mc(o,t),o},Mc=(e,t)=>e.selectNodeContents(t.dom),Nc=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Rc=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Bc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),Lc=vi([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Hc=(e,t,o)=>t(Se.fromDom(o.startContainer),o.startOffset,Se.fromDom(o.endContainer),o.endOffset),Ic=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:h(e),rtl:C.none}),relative:(t,o)=>({ltr:ro((()=>Nc(e,t,o))),rtl:ro((()=>C.some(Nc(e,o,t))))}),exact:(t,o,n,r)=>({ltr:ro((()=>Rc(e,t,o,n,r))),rtl:ro((()=>C.some(Rc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();if(o.collapsed)return t.rtl().filter((e=>!1===e.collapsed)).map((e=>Lc.rtl(Se.fromDom(e.endContainer),e.endOffset,Se.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>Hc(0,Lc.ltr,o)));return Hc(0,Lc.ltr,o)})(0,o)},Pc=(e,t)=>Ic(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});Lc.ltr,Lc.rtl;const Fc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),zc=(e,t,o,n)=>({start:Tc.on(e,t),finish:Tc.on(o,n)}),Vc=(e,t)=>{const o=Pc(e,t);return Fc(Se.fromDom(o.startContainer),o.startOffset,Se.fromDom(o.endContainer),o.endOffset)},Zc=zc,Uc=(e,t,o,n,r)=>Te(o,n)?C.none():As(o,n,t).bind((t=>{const n=t.boxes.getOr([]);return n.length>1?(r(e,n,t.start,t.finish),C.some(Oc(C.some(Zc(o,0,o,Cr(o))),!0))):C.none()})),jc=(e,t)=>({item:e,mode:t}),Wc=(e,t,o,n=$c)=>e.property().parent(t).map((e=>jc(e,n))),$c=(e,t,o,n=qc)=>o.sibling(e,t).map((e=>jc(e,n))),qc=(e,t,o,n=qc)=>{const r=e.property().children(t);return o.first(r).map((e=>jc(e,n)))},Gc=[{current:Wc,next:$c,fallback:C.none()},{current:$c,next:qc,fallback:C.some(Wc)},{current:qc,next:qc,fallback:C.some($c)}],Kc=(e,t,o,n,r=Gc)=>L(r,(e=>e.current===o)).bind((o=>o.current(e,t,n,o.next).orThunk((()=>o.fallback.bind((o=>Kc(e,t,o,n))))))),Yc=()=>({sibling:(e,t)=>e.query().prevSibling(t),first:e=>e.length>0?C.some(e[e.length-1]):C.none()}),Xc=()=>({sibling:(e,t)=>e.query().nextSibling(t),first:e=>e.length>0?C.some(e[0]):C.none()}),Jc=(e,t,o,n,r,s)=>Kc(e,t,n,r).bind((t=>s(t.item)?C.none():o(t.item)?C.some(t.item):Jc(e,t.item,o,t.mode,r,s))),Qc=e=>t=>0===e.property().children(t).length,ed=(e,t,o,n)=>Jc(e,t,o,$c,Yc(),n),td=(e,t,o,n)=>Jc(e,t,o,$c,Xc(),n),od=Cs(),nd=(e,t)=>((e,t,o)=>ed(e,t,Qc(e),o))(od,e,t),rd=(e,t)=>((e,t,o)=>td(e,t,Qc(e),o))(od,e,t),sd=vi([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),ad=e=>Ct(e,"tr"),id={...sd,verify:(e,t,o,n,r,s,a)=>Ct(n,"td,th",a).bind((o=>Ct(t,"td,th",a).map((t=>Te(o,t)?Te(n,o)&&Cr(o)===r?s(t):sd.none("in same cell"):Os(ad,[o,t]).fold((()=>((e,t,o)=>{const n=e.getRect(t),r=e.getRect(o);return r.right>n.left&&r.lefts(t))))))).getOr(sd.none("default")),cata:(e,t,o,n,r)=>e.fold(t,o,n,r)},ld=(e,t)=>H(e,v(Te,t)),cd=he("br"),dd=(e,t,o)=>t(e,o).bind((e=>me(e)&&0===yr(e).trim().length?dd(e,t,o):C.some(e))),md=(e,t,o,n)=>((e,t)=>Pe(e,t).filter(cd).orThunk((()=>Pe(e,t-1).filter(cd))))(t,o).bind((t=>n.traverse(t).fold((()=>dd(t,n.gather,e).map(n.relative)),(e=>(e=>Ne(e).bind((t=>{const o=Ie(t);return ld(o,e).map((n=>((e,t,o,n)=>({parent:e,children:t,element:o,index:n}))(t,o,e,n)))})))(e).map((e=>Tc.on(e.parent,e.index))))))),ud=(e,t,o,n)=>{const r=cd(t)?((e,t,o)=>o.traverse(t).orThunk((()=>dd(t,o.gather,e))).map(o.relative))(e,t,n):md(e,t,o,n);return r.map((e=>({start:e,finish:e})))},gd=(e,t)=>({left:e.left,top:e.top+t,right:e.right,bottom:e.bottom+t}),hd=(e,t)=>({left:e.left,top:e.top-t,right:e.right,bottom:e.bottom-t}),pd=(e,t,o)=>({left:e.left+t,top:e.top+o,right:e.right+t,bottom:e.bottom+o}),fd=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom}),vd=(e,t)=>C.some(e.getRect(t)),bd=(e,t,o)=>de(t)?vd(e,t).map(fd):me(t)?((e,t,o)=>o>=0&&o0?e.getRangedRect(t,o-1,t,o):C.none())(e,t,o).map(fd):C.none(),yd=(e,t)=>de(t)?vd(e,t).map(fd):me(t)?e.getRangedRect(t,0,t,Cr(t)).map(fd):C.none(),wd=vi([{none:[]},{retry:["caret"]}]),xd=(e,t,o)=>bt(t,Ii).fold(w,(t=>yd(e,t).exists((e=>((e,t)=>e.leftt.right)(o,e))))),Cd={point:e=>e.bottom,adjuster:(e,t,o,n,r)=>{const s=gd(r,5);return Math.abs(o.bottom-n.bottom)<1||o.top>r.bottom?wd.retry(s):o.top===r.bottom?wd.retry(gd(r,1)):xd(e,t,r)?wd.retry(pd(s,5,0)):wd.none()},move:gd,gather:rd},Sd=(e,t,o,n,r)=>0===r?C.some(n):((e,t,o)=>e.elementFromPoint(t,o).filter((e=>"table"===se(e))).isSome())(e,n.left,t.point(n))?((e,t,o,n,r)=>Sd(e,t,o,t.move(n,5),r))(e,t,o,n,r-1):e.situsFromPoint(n.left,t.point(n)).bind((s=>s.start.fold(C.none,(s=>yd(e,s).bind((a=>t.adjuster(e,s,a,o,n).fold(C.none,(n=>Sd(e,t,o,n,r-1))))).orThunk((()=>C.some(n)))),C.none))),kd=(e,t,o)=>{const n=e.move(o,5),r=Sd(t,e,o,n,100).getOr(n);return((e,t,o)=>e.point(t)>o.getInnerHeight()?C.some(e.point(t)-o.getInnerHeight()):e.point(t)<0?C.some(-e.point(t)):C.none())(e,r,t).fold((()=>t.situsFromPoint(r.left,e.point(r))),(o=>(t.scrollBy(0,o),t.situsFromPoint(r.left,e.point(r)-o))))},_d={tryUp:v(kd,{point:e=>e.top,adjuster:(e,t,o,n,r)=>{const s=hd(r,5);return Math.abs(o.top-n.top)<1||o.bottome.getSelection().bind((n=>ud(t,n.finish,n.foffset,o).fold((()=>C.some(ea(n.finish,n.foffset))),(r=>{const s=e.fromSitus(r);return(e=>id.cata(e,(e=>C.none()),(()=>C.none()),(e=>C.some(ea(e,0))),(e=>C.some(ea(e,Cr(e))))))(id.verify(e,n.finish,n.foffset,s.finish,s.foffset,o.failure,t))})))),Td=(e,t,o,n,r,s)=>0===s?C.none():Ad(e,t,o,n,r).bind((a=>{const i=e.fromSitus(a),l=id.verify(e,o,n,i.finish,i.foffset,r.failure,t);return id.cata(l,(()=>C.none()),(()=>C.some(a)),(a=>Te(o,a)&&0===n?Od(e,o,n,hd,r):Td(e,t,a,0,r,s-1)),(a=>Te(o,a)&&n===Cr(a)?Od(e,o,n,gd,r):Td(e,t,a,Cr(a),r,s-1)))})),Od=(e,t,o,n,r)=>bd(e,t,o).bind((t=>Dd(e,r,n(t,_d.getJumpSize())))),Dd=(e,t,o)=>{const n=Bo().browser;return n.isChromium()||n.isSafari()||n.isFirefox()?t.retry(e,o):C.none()},Ad=(e,t,o,n,r)=>bd(e,o,n).bind((t=>Dd(e,r,t))),Md=(e,t)=>{return vt(e,(e=>Ne(e).exists((e=>Te(e,t)))),o).isSome();var o},Nd=(e,t,o,n,r)=>Ct(n,"td,th",t).bind((n=>Ct(n,"table",t).bind((s=>Md(r,s)?((e,t,o)=>Ed(e,t,o).bind((n=>Td(e,t,n.element,n.offset,o,20).map(e.fromSitus))))(e,t,o).bind((e=>Ct(e.finish,"td,th",t).map((t=>({start:n,finish:t,range:e}))))):C.none())))),Rd=(e,t,o,n,r,s)=>s(n,t).orThunk((()=>Nd(e,t,o,n,r).map((e=>{const t=e.range;return Oc(C.some(Zc(t.start,t.soffset,t.finish,t.foffset)),!0)})))),Bd=(e,t)=>Ct(e,"tr",t).bind((e=>Ct(e,"table",t).bind((o=>{const n=pt(o,"tr");return Te(e,n[0])?((e,t,o)=>ed(od,e,t,o))(o,(e=>Er(e).isSome()),t).map((e=>{const t=Cr(e);return Oc(C.some(Zc(e,t,e,t)),!0)})):C.none()})))),Ld=(e,t)=>Ct(e,"tr",t).bind((e=>Ct(e,"table",t).bind((o=>{const n=pt(o,"tr");return Te(e,n[n.length-1])?((e,t,o)=>td(od,e,t,o))(o,(e=>_r(e).isSome()),t).map((e=>Oc(C.some(Zc(e,0,e,0)),!0))):C.none()})))),Hd=(e,t,o,n,r,s,a)=>Nd(e,o,n,r,s).bind((e=>Uc(t,o,e.start,e.finish,a))),Id=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Pd=()=>{const e=(e=>{const t=Id(C.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(C.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(C.some(e))}}})(g);return{...e,on:t=>e.get().each(t)}},Fd=(e,t)=>Ct(e,"td,th",t),zd=e=>Re(e).exists(os),Vd={traverse:He,gather:rd,relative:Tc.before,retry:_d.tryDown,failure:id.failedDown},Zd={traverse:Le,gather:nd,relative:Tc.before,retry:_d.tryUp,failure:id.failedUp},Ud=e=>t=>t===e,jd=Ud(38),Wd=Ud(40),$d=e=>e>=37&&e<=40,qd={isBackward:Ud(37),isForward:Ud(39)},Gd={isBackward:Ud(39),isForward:Ud(37)},Kd=vi([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Yd={domRange:Kd.domRange,relative:Kd.relative,exact:Kd.exact,exactFromRange:e=>Kd.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Se.fromDom(e.startContainer),relative:(e,t)=>Tc.getStart(e),exact:(e,t,o,n)=>e}))(e);return o=t,Se.fromDom(Me(o).dom.defaultView);var o},range:Fc},Xd=(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return C.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),C.some(o)}))},Jd=(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))},Qd=document.caretPositionFromPoint?Xd:document.caretRangeFromPoint?Jd:C.none,em=(e,t)=>{const o=se(e);return"input"===o?Tc.after(e):E(["br","img"],o)?0===t?Tc.before(e):Tc.after(e):Tc.on(e,t)},tm=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Ae(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Te(e,o)&&t===n;return r.collapsed&&!s},om=e=>C.from(e.getSelection()),nm=(e,t)=>{om(e).each((e=>{e.removeAllRanges(),e.addRange(t)}))},rm=(e,t,o,n,r)=>{const s=Rc(e,t,o,n,r);nm(e,s)},sm=(e,t)=>Ic(e,t).match({ltr:(t,o,n,r)=>{rm(e,t,o,n,r)},rtl:(t,o,n,r)=>{om(e).each((s=>{if(s.setBaseAndExtent)s.setBaseAndExtent(t.dom,o,n.dom,r);else if(s.extend)try{((e,t,o,n,r,s)=>{t.collapse(o.dom,n),t.extend(r.dom,s)})(0,s,t,o,n,r)}catch(s){rm(e,n,r,t,o)}else rm(e,n,r,t,o)}))}}),am=(e,t,o,n,r)=>{const s=((e,t,o,n)=>{const r=em(e,t),s=em(o,n);return Yd.relative(r,s)})(t,o,n,r);sm(e,s)},im=(e,t,o)=>{const n=((e,t)=>{const o=e.fold(Tc.before,em,Tc.after),n=t.fold(Tc.before,em,Tc.after);return Yd.relative(o,n)})(t,o);sm(e,n)},lm=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return C.some(Fc(Se.fromDom(t.startContainer),t.startOffset,Se.fromDom(o.endContainer),o.endOffset))}return C.none()},cm=e=>{if(null===e.anchorNode||null===e.focusNode)return lm(e);{const t=Se.fromDom(e.anchorNode),o=Se.fromDom(e.focusNode);return tm(t,e.anchorOffset,o,e.focusOffset)?C.some(Fc(t,e.anchorOffset,o,e.focusOffset)):lm(e)}},dm=(e,t,o=!0)=>{const n=(o?Ac:Dc)(e,t);nm(e,n)},mm=e=>(e=>om(e).filter((e=>e.rangeCount>0)).bind(cm))(e).map((e=>Yd.exact(e.start,e.soffset,e.finish,e.foffset))),um=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?C.some(o).map(Bc):C.none()})(Pc(e,t)),gm=(e,t,o)=>((e,t,o)=>{const n=Se.fromDom(e.document);return Qd(n,t,o).map((e=>Fc(Se.fromDom(e.startContainer),e.startOffset,Se.fromDom(e.endContainer),e.endOffset)))})(e,t,o),hm=e=>({elementFromPoint:(t,o)=>Se.fromPoint(Se.fromDom(e.document),t,o),getRect:e=>e.dom.getBoundingClientRect(),getRangedRect:(t,o,n,r)=>{const s=Yd.exact(t,o,n,r);return um(e,s)},getSelection:()=>mm(e).map((t=>Vc(e,t))),fromSitus:t=>{const o=Yd.relative(t.start,t.finish);return Vc(e,o)},situsFromPoint:(t,o)=>gm(e,t,o).map((e=>zc(e.start,e.soffset,e.finish,e.foffset))),clearSelection:()=>{(e=>{om(e).each((e=>e.removeAllRanges()))})(e)},collapseSelection:(t=!1)=>{mm(e).each((o=>o.fold((e=>e.collapse(t)),((o,n)=>{const r=t?o:n;im(e,r,r)}),((o,n,r,s)=>{const a=t?o:r,i=t?n:s;am(e,a,i,a,i)}))))},setSelection:t=>{am(e,t.start,t.soffset,t.finish,t.foffset)},setRelativeSelection:(t,o)=>{im(e,t,o)},selectNode:t=>{dm(e,t,!1)},selectContents:t=>{dm(e,t)},getInnerHeight:()=>e.innerHeight,getScrollY:()=>(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return bn(o,n)})(Se.fromDom(e.document)).top,scrollBy:(t,o)=>{((e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollBy(e,t)})(t,o,Se.fromDom(e.document))}}),pm=(e,t)=>({rows:e,cols:t}),fm=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Pd(),s=r.clear,a=s=>{r.on((r=>{n.clearBeforeUpdate(t),Fd(s.target,o).each((a=>{As(r,a,o).each((o=>{const r=o.boxes.getOr([]);if(1===r.length){const o=r[0],a="false"===ns(o),i=St(ts(s.target),o,Te);a&&i&&(n.selectRange(t,r,o,o),e.selectContents(o))}else r.length>1&&(n.selectRange(t,r,o.start,o.finish),e.selectContents(a))}))}))}))};return{clearstate:s,mousedown:e=>{n.clear(t),Fd(e.target,o).filter(zd).each(r.set)},mouseover:e=>{a(e)},mouseup:e=>{a(e),s()}}})(hm(e),t,o,n);return{clearstate:r.clearstate,mousedown:r.mousedown,mouseover:r.mouseover,mouseup:r.mouseup}},vm=e=>bt(e,ce).exists(os),bm=(e,t)=>vm(e)||vm(t),ym=(e,t,o,n)=>{const r=hm(e),s=()=>(n.clear(t),C.none());return{keydown:(e,a,i,l,c,d)=>{const m=e.raw,u=m.which,g=!0===m.shiftKey,h=Ms(t,n.selectedSelector).fold((()=>($d(u)&&!g&&n.clearBeforeUpdate(t),$d(u)&&g&&!bm(a,l)?C.none:Wd(u)&&g?v(Hd,r,t,o,Vd,l,a,n.selectRange):jd(u)&&g?v(Hd,r,t,o,Zd,l,a,n.selectRange):Wd(u)?v(Rd,r,o,Vd,l,a,Ld):jd(u)?v(Rd,r,o,Zd,l,a,Bd):C.none)),(e=>{const o=o=>()=>{const s=j(o,(o=>((e,t,o,n,r)=>Rs(n,e,t,r.firstSelectedSelector,r.lastSelectedSelector).map((e=>(r.clearBeforeUpdate(o),r.selectRange(o,e.boxes,e.start,e.finish),e.boxes))))(o.rows,o.cols,t,e,n)));return s.fold((()=>Ns(t,n.firstSelectedSelector,n.lastSelectedSelector).map((e=>{const o=Wd(u)||d.isForward(u)?Tc.after:Tc.before;return r.setRelativeSelection(Tc.on(e.first,0),o(e.table)),n.clear(t),Oc(C.none(),!0)}))),(e=>C.some(Oc(C.none(),!0))))};return $d(u)&&g&&!bm(a,l)?C.none:Wd(u)&&g?o([pm(1,0)]):jd(u)&&g?o([pm(-1,0)]):d.isBackward(u)&&g?o([pm(0,-1),pm(-1,0)]):d.isForward(u)&&g?o([pm(0,1),pm(1,0)]):$d(u)&&!g?s:C.none}));return h()},keyup:(e,r,s,a,i)=>Ms(t,n.selectedSelector).fold((()=>{const l=e.raw,c=l.which;return!0===l.shiftKey&&$d(c)&&bm(r,a)?((e,t,o,n,r,s,a)=>Te(o,r)&&n===s?C.none():Ct(o,"td,th",t).bind((o=>Ct(r,"td,th",t).bind((n=>Uc(e,t,o,n,a))))))(t,o,r,s,a,i,n.selectRange):C.none()}),C.none)}},wm=(e,t)=>{const o=be(e,t);return void 0===o||""===o?[]:o.split(" ")},xm=e=>void 0!==e.dom.classList,Cm=(e,t)=>((e,t,o)=>{const n=wm(e,t).concat([o]);return fe(e,t,n.join(" ")),!0})(e,"class",t),Sm=(e,t)=>{xm(e)?e.dom.classList.add(t):Cm(e,t)},km=(e,t)=>xm(e)&&e.dom.classList.contains(t),_m=(e,t,o)=>{const n=t=>{we(t,e.selected),we(t,e.firstSelected),we(t,e.lastSelected)},r=t=>{fe(t,e.selected,"1")},s=e=>{a(e),o()},a=t=>{const o=pt(t,`${e.selectedSelector},${e.firstSelectedSelector},${e.lastSelectedSelector}`);A(o,n)};return{clearBeforeUpdate:a,clear:s,selectRange:(o,n,a,i)=>{s(o),A(n,r),fe(a,e.firstSelected,"1"),fe(i,e.lastSelected,"1"),t(n,a,i)},selectedSelector:e.selectedSelector,firstSelectedSelector:e.firstSelectedSelector,lastSelectedSelector:e.lastSelectedSelector}},Em=()=>({tag:"none"}),Tm=e=>({tag:"multiple",elements:e}),Om=e=>({tag:"single",element:e}),Dm=(e,t,o)=>{const n=sn.fromTable(e);return Za(n,t).map((e=>{const t=Ha(n,o,!1),{rows:r}=Xo(t),s=((e,t)=>{const o=e.slice(0,t[t.length-1].row+1),n=Ia(o);return P(n,(e=>{const o=e.cells.slice(0,t[t.length-1].column+1);return D(o,(e=>e.element))}))})(r,e),a=((e,t)=>{const o=e.slice(t[0].row+t[0].rowspan-1,e.length),n=Ia(o);return P(n,(e=>{const o=e.cells.slice(t[0].column+t[0].colspan-1,e.cells.length);return D(o,(e=>e.element))}))})(r,e);return{upOrLeftCells:s,downOrRightCells:a}}))},Am=e=>{const t=Se.fromDom((e=>{if(st()&&d(e.target)){const t=Se.fromDom(e.target);if(de(t)&&ct(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return Z(t)}}return C.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(s=n,a=o,(...e)=>s(a.apply(null,e)));var s,a;return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Mm=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Am(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:v(Nm,e,t,s,r)}},Nm=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Rm=x,Bm=(e,t,o)=>((e,t,o,n)=>Mm(e,t,o,n,!1))(e,t,Rm,o),Lm=Am,Hm=e=>!km(Se.fromDom(e.target),"ephox-snooker-resizer-bar"),Im=(e,t)=>{const o=((e,t,o)=>({get:()=>Bs(e(),o).fold((()=>t().fold(Em,Om)),Tm)}))((()=>Se.fromDom(e.getBody())),(()=>Xs(is(e),ss(e))),qs.selectedSelector),n=_m(qs,((t,o,n)=>{Jt(o).each((r=>{const s=zr(e),a=Lr(g,Se.fromDom(e.getDoc()),s),i=Js(e),l=Dm(r,{selection:i},a);((e,t,o,n,r)=>{e.dispatch("TableSelectionChange",{cells:t,start:o,finish:n,otherCells:r})})(e,t,o,n,l)}))}),(()=>(e=>{e.dispatch("TableSelectionClear")})(e)));e.on("init",(o=>{const r=e.getWin(),s=rs(e),a=ss(e),i=fm(r,s,a,n),l=ym(r,s,a,n),c=((e,t,o,n)=>{const r=hm(e);return(e,s)=>{n.clearBeforeUpdate(t),As(e,s,o).each((e=>{const o=e.boxes.getOr([]);n.selectRange(t,o,e.start,e.finish),r.selectContents(s),r.collapseSelection()}))}})(r,s,a,n);e.on("TableSelectorChange",(e=>c(e.start,e.finish)));const d=(t,o)=>{(e=>!0===e.raw.shiftKey)(t)&&(o.kill&&t.kill(),o.selection.each((t=>{const o=Yd.relative(t.start,t.finish),n=Pc(r,o);e.selection.setRng(n)})))},m=e=>0===e.button,u=(()=>{const e=Id(Se.fromDom(s)),t=Id(0);return{touchEnd:o=>{const n=Se.fromDom(o.target);if(he("td")(n)||he("th")(n)){const r=e.get(),s=t.get();Te(r,n)&&o.timeStamp-s<300&&(o.preventDefault(),c(n,n))}e.set(n),t.set(o.timeStamp)}}})();e.on("dragstart",(e=>{i.clearstate()})),e.on("mousedown",(e=>{m(e)&&Hm(e)&&i.mousedown(Lm(e))})),e.on("mouseover",(e=>{var t;void 0!==(t=e).buttons&&0==(1&t.buttons)||!Hm(e)||i.mouseover(Lm(e))})),e.on("mouseup",(e=>{m(e)&&Hm(e)&&i.mouseup(Lm(e))})),e.on("touchend",u.touchEnd),e.on("keyup",(t=>{const o=Lm(t);if(o.raw.shiftKey&&$d(o.raw.which)){const t=e.selection.getRng(),n=Se.fromDom(t.startContainer),r=Se.fromDom(t.endContainer);l.keyup(o,n,t.startOffset,r,t.endOffset).each((e=>{d(o,e)}))}})),e.on("keydown",(o=>{const n=Lm(o);t.hide();const r=e.selection.getRng(),s=Se.fromDom(r.startContainer),a=Se.fromDom(r.endContainer),i=mn(qd,Gd)(Se.fromDom(e.selection.getStart()));l.keydown(n,s,r.startOffset,a,r.endOffset,i).each((e=>{d(n,e)})),t.show()})),e.on("NodeChange",(()=>{const t=e.selection,o=Se.fromDom(t.getStart()),r=Se.fromDom(t.getEnd());Os(Jt,[o,r]).fold((()=>n.clear(s)),g)}))})),e.on("PreInit",(()=>{e.serializer.addTempAttr(qs.firstSelected),e.serializer.addTempAttr(qs.lastSelected)}));return{getSelectedCells:()=>((e,t,o,n)=>{switch(e.tag){case"none":return t();case"single":return n(e.element);case"multiple":return o(e.elements)}})(o.get(),h([]),(e=>D(e,(e=>e.dom))),(e=>[e.dom])),clearSelectedCells:e=>n.clear(Se.fromDom(e))}},Pm=e=>{let t=[];return{bind:e=>{if(void 0===e)throw new Error("Event bind error: undefined handler");t.push(e)},unbind:e=>{t=N(t,(t=>t!==e))},trigger:(...o)=>{const n={};A(e,((e,t)=>{n[e]=o[t]})),A(t,(e=>{e(n)}))}}},Fm=e=>({registry:G(e,(e=>({bind:e.bind,unbind:e.unbind}))),trigger:G(e,(e=>e.trigger))}),zm=e=>e.slice(0).sort(),Vm=(e,t,o)=>{if(0===t.length)throw new Error("You must specify at least one required field.");return((e,t)=>{if(!a(t))throw new Error("The "+e+" fields must be an array. Was: "+t+".");A(t,(t=>{if(!r(t))throw new Error("The value "+t+" in the "+e+" fields was not a string.")}))})("required",t),(e=>{const t=zm(e);L(t,((e,o)=>o{throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+t.join(", ")+"].")}))})(t),n=>{const r=W(n);F(t,(e=>E(r,e)))||((e,t)=>{throw new Error("All required keys ("+zm(e).join(", ")+") were not specified. Specified keys were: "+zm(t).join(", ")+".")})(t,r),e(t,r);const s=N(t,(e=>!o.validate(n[e],e)));return s.length>0&&((e,t)=>{throw new Error("All values need to be of type: "+t+". Keys ("+zm(e).join(", ")+") were not.")})(s,o.label),n}},Zm=(e,t)=>{const o=N(t,(t=>!E(e,t)));o.length>0&&(e=>{throw new Error("Unsupported keys for object: "+zm(e).join(", "))})(o)},Um=e=>((e,t)=>Vm(e,t,{validate:m,label:"function"}))(Zm,e),jm=Um(["compare","extract","mutate","sink"]),Wm=Um(["element","start","stop","destroy"]),$m=Um(["forceDrop","drop","move","delayDrop"]),qm=()=>{let e=C.none();const t=Fm({move:Pm(["info"])});return{onEvent:(o,n)=>{n.extract(o).each((o=>{const r=((t,o)=>{const n=e.map((e=>t.compare(e,o)));return e=C.some(o),n})(n,o);r.each((e=>{t.trigger.move(e)}))}))},reset:()=>{e=C.none()},events:t.registry}},Gm=()=>{const e=(()=>{const e=Fm({move:Pm(["info"])});return{onEvent:g,reset:g,events:e.registry}})(),t=qm();let o=e;return{on:()=>{o.reset(),o=t},off:()=>{o.reset(),o=e},isOn:()=>o===t,onEvent:(e,t)=>{o.onEvent(e,t)},events:t.events}},Km=(e,t,o)=>{let n=!1;const r=Fm({start:Pm([]),stop:Pm([])}),s=Gm(),a=()=>{d.stop(),s.isOn()&&(s.off(),r.trigger.stop())},l=((e,t)=>{let o=null;const n=()=>{i(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}})(a,200);s.events.move.bind((o=>{t.mutate(e,o.info)}));const c=e=>(...t)=>{n&&e.apply(null,t)},d=t.sink($m({forceDrop:a,drop:c(a),move:c((e=>{l.cancel(),s.onEvent(e,t)})),delayDrop:c(l.throttle)}),o);return{element:d.element,go:e=>{d.start(e),s.on(),r.trigger.start()},on:()=>{n=!0},off:()=>{n=!1},isActive:()=>n,destroy:()=>{d.destroy()},events:r.registry}},Ym=e=>{const t=e.replace(/\./g,"-");return{resolve:e=>t+"-"+e}},Xm=Ym("ephox-dragster").resolve;var Jm=jm({compare:(e,t)=>bn(t.left-e.left,t.top-e.top),extract:e=>C.some(bn(e.x,e.y)),sink:(e,t)=>{const o=(e=>{const t={layerClass:Xm("blocker"),...e},o=Se.fromTag("div");return fe(o,"role","presentation"),Lt(o,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),Sm(o,Xm("blocker")),Sm(o,t.layerClass),{element:h(o),destroy:()=>{qe(o)}}})(t),n=Bm(o.element(),"mousedown",e.forceDrop),r=Bm(o.element(),"mouseup",e.drop),s=Bm(o.element(),"mousemove",e.move),a=Bm(o.element(),"mouseout",e.delayDrop);return Wm({element:o.element,start:e=>{Ze(e,o.element())},stop:()=>{qe(o.element())},destroy:()=>{o.destroy(),r.unbind(),s.unbind(),a.unbind(),n.unbind()}})},mutate:(e,t)=>{e.mutate(t.left,t.top)}});const Qm=Ym("ephox-snooker").resolve,eu=()=>{const e=Fm({drag:Pm(["xDelta","yDelta","target"])});let t=C.none();const o=(()=>{const e=Fm({drag:Pm(["xDelta","yDelta"])});return{mutate:(t,o)=>{e.trigger.drag(t,o)},events:e.registry}})();o.events.drag.bind((o=>{t.each((t=>{e.trigger.drag(o.xDelta,o.yDelta,t)}))}));return{assign:e=>{t=C.some(e)},get:()=>t,mutate:o.mutate,events:e.registry}},tu=Qm("resizer-bar"),ou=Qm("resizer-rows"),nu=Qm("resizer-cols"),ru=e=>{const t=pt(e.parent(),"."+tu);A(t,qe)},su=(e,t,o)=>{const n=e.origin();A(t,(t=>{t.each((t=>{const r=o(n,t);Sm(r,tu),Ze(e.parent(),r)}))}))},au=(e,t,o,n)=>{su(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=Se.fromTag("div");return Lt(s,{position:"absolute",left:t-n/2+"px",top:o+"px",height:r+"px",width:n+"px"}),ve(s,{"data-column":e,role:"presentation"}),s})(t.col,t.x-e.left,o.top-e.top,7,n);return Sm(r,nu),r}))},iu=(e,t,o,n)=>{su(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=Se.fromTag("div");return Lt(s,{position:"absolute",left:t+"px",top:o-r/2+"px",height:r+"px",width:n+"px"}),ve(s,{"data-row":e,role:"presentation"}),s})(t.row,o.left-e.left,t.y-e.top,n,7);return Sm(r,ou),r}))},lu=(e,t,o,n,r)=>{const s=wn(o),a=t.isResizable,i=n.length>0?Nn.positions(n,o):[],l=i.length>0?((e,t)=>P(e.all,((e,o)=>t(e.element)?[o]:[])))(e,a):[],c=N(i,((e,t)=>T(l,(e=>t===e))));iu(t,c,s,Vo(o));const d=r.length>0?Bn.positions(r,o):[],m=d.length>0?((e,t)=>{const o=[];return O(e.grid.columns,(n=>{const r=sn.getColumnAt(e,n).map((e=>e.element));r.forall(t)&&o.push(n)})),N(o,(o=>{const n=sn.filterItems(e,(e=>e.column===o));return F(n,(e=>t(e.element)))}))})(e,a):[],u=N(d,((e,t)=>T(m,(e=>t===e))));au(t,u,s,pn(o))},cu=(e,t)=>{if(ru(e),e.isResizable(t)){const o=sn.fromTable(t),n=cn(o),r=an(o);lu(o,e,t,n,r)}},du=(e,t)=>{const o=pt(e.parent(),"."+tu);A(o,t)},mu=e=>{du(e,(e=>{Bt(e,"display","none")}))},uu=e=>{du(e,(e=>{Bt(e,"display","block")}))},gu=Qm("resizer-bar-dragging"),hu=e=>{const t=eu(),o=((e,t={})=>{var o;const n=null!==(o=t.mode)&&void 0!==o?o:Jm;return Km(e,n,t)})(t,{});let n=C.none();const r=(e,t)=>C.from(be(e,t));t.events.drag.bind((e=>{r(e.target,"data-row").each((t=>{const o=jt(e.target,"top");Bt(e.target,"top",o+e.yDelta+"px")})),r(e.target,"data-column").each((t=>{const o=jt(e.target,"left");Bt(e.target,"left",o+e.xDelta+"px")}))}));const s=(e,t)=>jt(e,t)-zt(e,"data-initial-"+t,0);o.events.stop.bind((()=>{t.get().each((t=>{n.each((o=>{r(t,"data-row").each((e=>{const n=s(t,"top");we(t,"data-initial-top"),d.trigger.adjustHeight(o,n,parseInt(e,10))})),r(t,"data-column").each((e=>{const n=s(t,"left");we(t,"data-initial-left"),d.trigger.adjustWidth(o,n,parseInt(e,10))})),cu(e,o)}))}))}));const a=(n,r)=>{d.trigger.startAdjust(),t.assign(n),fe(n,"data-initial-"+r,jt(n,r)),Sm(n,gu),Bt(n,"opacity","0.2"),o.go(e.parent())},i=Bm(e.parent(),"mousedown",(e=>{var t;t=e.target,km(t,ou)&&a(e.target,"top"),(e=>km(e,nu))(e.target)&&a(e.target,"left")})),l=t=>Te(t,e.view()),c=Bm(e.view(),"mouseover",(t=>{var r;(r=t.target,Ct(r,"table",l).filter(os)).fold((()=>{dt(t.target)&&ru(e)}),(t=>{o.isActive()&&(n=C.some(t),cu(e,t))}))})),d=Fm({adjustHeight:Pm(["table","delta","row"]),adjustWidth:Pm(["table","delta","column"]),startAdjust:Pm([])});return{destroy:()=>{i.unbind(),c.unbind(),o.destroy(),ru(e)},refresh:t=>{cu(e,t)},on:o.on,off:o.off,hideBars:v(mu,e),showBars:v(uu,e),events:d.registry}},pu=(e,t,o)=>{const n=Nn,r=Bn,s=hu(e),a=Fm({beforeResize:Pm(["table","type"]),afterResize:Pm(["table","type"]),startDrag:Pm([])});return s.events.adjustHeight.bind((e=>{const t=e.table;a.trigger.beforeResize(t,"row");const o=n.delta(e.delta,t);_i(t,o,e.row,n),a.trigger.afterResize(t,"row")})),s.events.startAdjust.bind((e=>{a.trigger.startDrag()})),s.events.adjustWidth.bind((e=>{const n=e.table;a.trigger.beforeResize(n,"col");const s=r.delta(e.delta,n),i=o(n);ki(n,s,e.column,t,i),a.trigger.afterResize(n,"col")})),{on:s.on,off:s.off,refreshBars:s.refresh,hideBars:s.hideBars,showBars:s.showBars,destroy:s.destroy,events:a.registry}},fu=(e,t)=>{const o=ue(e)?(e=>Se.fromDom(Me(e).dom.documentElement))(e):e;return{parent:h(o),view:h(e),origin:h(bn(0,0)),isResizable:t}},vu=(e,t,o)=>({parent:h(t),view:h(e),origin:h(bn(0,0)),isResizable:o}),bu=()=>{const e=Se.fromTag("div");return Lt(e,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),Ze(mt(Se.fromDom(document)),e),e},yu=e=>d(e)&&"TABLE"===e.nodeName,wu="bar-",xu=e=>"false"!==be(e,"data-mce-resize"),Cu=e=>{const t=Pd(),o=Pd(),n=Pd();let r,s;const a=t=>Hl(e,t),i=()=>Ur(e)?ga():ua(),l=(t,o,n)=>{const l=Dt(o,"e");if(""===s&&nc(t),n!==r&&""!==s){Bt(t,"width",s);const o=i(),c=a(t),d=Ur(e)||l?(e=>ha(e).columns)(t)-1:0;ki(t,n-r,d,o,c)}else if((e=>/^(\d+(\.\d+)?)%$/.test(e))(s)){const e=parseFloat(s.replace("%",""));Bt(t,"width",n*e/r+"%")}(e=>/^(\d+(\.\d+)?)px$/.test(e))(s)&&(e=>{const t=sn.fromTable(e);sn.hasColumns(t)||A(Yt(e),(e=>{const t=Ht(e,"width");Bt(e,"width",t),we(e,"width")}))})(t)},c=()=>{o.on((e=>{e.destroy()})),n.on((t=>{((e,t)=>{e.inline&&qe(t.parent())})(e,t)}))};e.on("init",(()=>{const r=((e,t)=>e.inline?vu(Se.fromDom(e.getBody()),bu(),t):fu(Se.fromDom(e.getDoc()),t))(e,xu);if(n.set(r),(e=>{const t=e.options.get("object_resizing");return E(t.split(","),"table")})(e)&&Kr(e)){const n=i(),s=pu(r,n,a);s.on(),s.events.startDrag.bind((o=>{t.set(e.selection.getRng())})),s.events.beforeResize.bind((t=>{const o=t.table.dom;((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(e,o,ls(o),cs(o),wu+t.type)})),s.events.afterResize.bind((o=>{const n=o.table,r=n.dom;as(n),t.on((t=>{e.selection.setRng(t),e.focus()})),((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(e,r,ls(r),cs(r),wu+o.type),e.undoManager.add()})),o.set(s)}})),e.on("ObjectResizeStart",(t=>{const o=t.target;if(yu(o)){const n=Se.fromDom(o);A(e.dom.select(".mce-clonedresizable"),(t=>{e.dom.addClass(t,"mce-"+Zr(e)+"-columns")})),!ec(n)&&qr(e)?rc(n):!Ql(n)&&$r(e)&&nc(n),tc(n)&&Ot(t.origin,wu)&&nc(n),r=t.width,s=Gr(e)?"":((e,t)=>{const o=e.dom.getStyle(t,"width")||e.dom.getAttrib(t,"width");return C.from(o).filter(Mt)})(e,o).getOr("")}})),e.on("ObjectResized",(t=>{const o=t.target;if(yu(o)){const n=Se.fromDom(o),r=t.origin;Ot(r,"corner-")&&l(n,r,t.width),as(n),Nl(e,n.dom,Rl)}})),e.on("SwitchMode",(()=>{o.on((t=>{e.mode.isReadOnly()?t.hideBars():t.showBars()}))})),e.on("dragstart dragend",(e=>{o.on((t=>{"dragstart"===e.type?(t.hideBars(),t.off()):(t.on(),t.showBars())}))})),e.on("remove",(()=>{c()}));return{refresh:e=>{o.on((t=>t.refreshBars(Se.fromDom(e))))},hide:()=>{o.on((e=>e.hideBars()))},show:()=>{o.on((e=>e.showBars()))}}},Su=e=>{(e=>{const t=e.options.register;t("table_clone_elements",{processor:"string[]"}),t("table_use_colgroups",{processor:"boolean",default:!0}),t("table_header_type",{processor:e=>{const t=E(["section","cells","sectionCells","auto"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: section, cells, sectionCells or auto."}},default:"section"}),t("table_sizing_mode",{processor:"string",default:"auto"}),t("table_default_attributes",{processor:"object",default:{border:"1"}}),t("table_default_styles",{processor:"object",default:{"border-collapse":"collapse"}}),t("table_column_resizing",{processor:e=>{const t=E(["preservetable","resizetable"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be preservetable, or resizetable."}},default:"preservetable"}),t("table_resize_bars",{processor:"boolean",default:!0}),t("table_style_by_css",{processor:"boolean",default:!0}),t("table_merge_content_on_paste",{processor:"boolean",default:!0})})(e);const t=Cu(e),o=Im(e,t),n=Il(e,t,o);return _c(e,n),((e,t)=>{const o=ss(e),n=t=>Xs(is(e)).bind((n=>Jt(n,o).map((o=>{const r=Gs(Js(e),o,n);return t(o,r)})))).getOr("");q({mceTableRowType:()=>n(t.getTableRowType),mceTableCellType:()=>n(t.getTableCellType),mceTableColType:()=>n(t.getTableColType)},((t,o)=>e.addQueryValueHandler(o,t)))})(e,n),Qs(e,n),{getSelectedCells:o.getSelectedCells,clearSelectedCells:o.clearSelectedCells}},ku=e=>({table:Su(e)});e.add("dom",ku)}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),o=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=(r="allow_html_in_named_anchor",e=>e.options.get(r));var r;const s="a:not([href])",a=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),c=e=>{const n=e.dom;t(n).walk(e.selection.getRng(),(e=>{o.each(e,(e=>{var t;l(t=e)&&!t.firstChild&&n.remove(e,!1)}))}))},d=e=>e.dom.getParent(e.selection.getStart(),s),m=(e,t)=>{const o=d(e);o?((e,t,o)=>{o.removeAttribute("name"),o.id=t,e.addVisual(),e.undoManager.add()})(e,t,o):((e,t)=>{e.undoManager.transact((()=>{n(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:t})):(c(e),e.formatter.remove("namedAnchor",void 0,void 0,!0),e.formatter.apply("namedAnchor",{value:t}),e.addVisual())}))})(e,t),e.focus()},u=e=>{const t=(e=>{const t=d(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)?(m(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1))(e,t.getData().id)&&t.close()}})},g=e=>(e=>a(e.attr("href"))&&!a(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,h=e=>t=>{for(let o=0;ot=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("anchor",(e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("a",h("false")),e.serializer.addNodeFilter("a",h(null))}))})(e),(e=>{e.addCommand("mceAnchor",(()=>{u(e)}))})(e),(e=>{const t=()=>e.execCommand("mceAnchor");e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:t,onSetup:t=>{const o=e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind,n=p(e)(t);return()=>{o(),n()}}}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:t,onSetup:p(e)})})(e),e.on("PreInit",(()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:s,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,o)=>l(e)})})(e)}))}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(e,t)=>{const o=((e,t)=>e.dispatch("insertCustomChar",{chr:t}))(e,t).chr;e.execCommand("mceInsertContent",!1,o)},o=e=>t=>e===t,n=(r="array",e=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(s=n.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var o,n,r,s})(e)===r);var r;const s=o(null),a=o(void 0),i=(e=>t=>typeof t===e)("function"),l=(c=!1,()=>c);var c;class d{constructor(e,t){this.tag=e,this.value=t}static some(e){return new d(!0,e)}static none(){return d.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?d.some(e(this.value)):d.none()}bind(e){return this.tag?e(this.value):d.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:d.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return(e=>null==e)(e)?d.none():d.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}d.singletonNone=new d(!1);const m=Array.prototype.push,u=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r((e,t,o)=>{for(let n=0,r=e.length;n(e=>{const t=[];for(let o=0,r=e.length;ot=>t.options.get(e),v=f("charmap"),b=f("charmap_append"),y=p.isArray,w="User Defined",x=e=>{return y(e)?(t=e,p.grep(t,(e=>y(e)&&2===e.length))):"function"==typeof e?e():[];var t},C=e=>{const t=((e,t)=>{const o=v(e);o&&(t=[{name:w,characters:x(o)}]);const n=b(e);if(n){const e=p.grep(t,(e=>e.name===w));return e.length?(e[0].characters=[...e[0].characters,...x(n)],t):t.concat({name:w,characters:x(n)})}return t})(e,[{name:"Currency",characters:[[36,"dollar sign"],[162,"cent sign"],[8364,"euro sign"],[163,"pound sign"],[165,"yen sign"],[164,"currency sign"],[8352,"euro-currency sign"],[8353,"colon sign"],[8354,"cruzeiro sign"],[8355,"french franc sign"],[8356,"lira sign"],[8357,"mill sign"],[8358,"naira sign"],[8359,"peseta sign"],[8360,"rupee sign"],[8361,"won sign"],[8362,"new sheqel sign"],[8363,"dong sign"],[8365,"kip sign"],[8366,"tugrik sign"],[8367,"drachma sign"],[8368,"german penny symbol"],[8369,"peso sign"],[8370,"guarani sign"],[8371,"austral sign"],[8372,"hryvnia sign"],[8373,"cedi sign"],[8374,"livre tournois sign"],[8375,"spesmilo sign"],[8376,"tenge sign"],[8377,"indian rupee sign"],[8378,"turkish lira sign"],[8379,"nordic mark sign"],[8380,"manat sign"],[8381,"ruble sign"],[20870,"yen character"],[20803,"yuan character"],[22291,"yuan character, in hong kong and taiwan"],[22278,"yen/yuan character variant one"]]},{name:"Text",characters:[[169,"copyright sign"],[174,"registered sign"],[8482,"trade mark sign"],[8240,"per mille sign"],[181,"micro sign"],[183,"middle dot"],[8226,"bullet"],[8230,"three dot leader"],[8242,"minutes / feet"],[8243,"seconds / inches"],[167,"section sign"],[182,"paragraph sign"],[223,"sharp s / ess-zed"]]},{name:"Quotations",characters:[[8249,"single left-pointing angle quotation mark"],[8250,"single right-pointing angle quotation mark"],[171,"left pointing guillemet"],[187,"right pointing guillemet"],[8216,"left single quotation mark"],[8217,"right single quotation mark"],[8220,"left double quotation mark"],[8221,"right double quotation mark"],[8218,"single low-9 quotation mark"],[8222,"double low-9 quotation mark"],[60,"less-than sign"],[62,"greater-than sign"],[8804,"less-than or equal to"],[8805,"greater-than or equal to"],[8211,"en dash"],[8212,"em dash"],[175,"macron"],[8254,"overline"],[164,"currency sign"],[166,"broken bar"],[168,"diaeresis"],[161,"inverted exclamation mark"],[191,"turned question mark"],[710,"circumflex accent"],[732,"small tilde"],[176,"degree sign"],[8722,"minus sign"],[177,"plus-minus sign"],[247,"division sign"],[8260,"fraction slash"],[215,"multiplication sign"],[185,"superscript one"],[178,"superscript two"],[179,"superscript three"],[188,"fraction one quarter"],[189,"fraction one half"],[190,"fraction three quarters"]]},{name:"Mathematical",characters:[[402,"function / florin"],[8747,"integral"],[8721,"n-ary sumation"],[8734,"infinity"],[8730,"square root"],[8764,"similar to"],[8773,"approximately equal to"],[8776,"almost equal to"],[8800,"not equal to"],[8801,"identical to"],[8712,"element of"],[8713,"not an element of"],[8715,"contains as member"],[8719,"n-ary product"],[8743,"logical and"],[8744,"logical or"],[172,"not sign"],[8745,"intersection"],[8746,"union"],[8706,"partial differential"],[8704,"for all"],[8707,"there exists"],[8709,"diameter"],[8711,"backward difference"],[8727,"asterisk operator"],[8733,"proportional to"],[8736,"angle"]]},{name:"Extended Latin",characters:[[192,"A - grave"],[193,"A - acute"],[194,"A - circumflex"],[195,"A - tilde"],[196,"A - diaeresis"],[197,"A - ring above"],[256,"A - macron"],[198,"ligature AE"],[199,"C - cedilla"],[200,"E - grave"],[201,"E - acute"],[202,"E - circumflex"],[203,"E - diaeresis"],[274,"E - macron"],[204,"I - grave"],[205,"I - acute"],[206,"I - circumflex"],[207,"I - diaeresis"],[298,"I - macron"],[208,"ETH"],[209,"N - tilde"],[210,"O - grave"],[211,"O - acute"],[212,"O - circumflex"],[213,"O - tilde"],[214,"O - diaeresis"],[216,"O - slash"],[332,"O - macron"],[338,"ligature OE"],[352,"S - caron"],[217,"U - grave"],[218,"U - acute"],[219,"U - circumflex"],[220,"U - diaeresis"],[362,"U - macron"],[221,"Y - acute"],[376,"Y - diaeresis"],[562,"Y - macron"],[222,"THORN"],[224,"a - grave"],[225,"a - acute"],[226,"a - circumflex"],[227,"a - tilde"],[228,"a - diaeresis"],[229,"a - ring above"],[257,"a - macron"],[230,"ligature ae"],[231,"c - cedilla"],[232,"e - grave"],[233,"e - acute"],[234,"e - circumflex"],[235,"e - diaeresis"],[275,"e - macron"],[236,"i - grave"],[237,"i - acute"],[238,"i - circumflex"],[239,"i - diaeresis"],[299,"i - macron"],[240,"eth"],[241,"n - tilde"],[242,"o - grave"],[243,"o - acute"],[244,"o - circumflex"],[245,"o - tilde"],[246,"o - diaeresis"],[248,"o slash"],[333,"o macron"],[339,"ligature oe"],[353,"s - caron"],[249,"u - grave"],[250,"u - acute"],[251,"u - circumflex"],[252,"u - diaeresis"],[363,"u - macron"],[253,"y - acute"],[254,"thorn"],[255,"y - diaeresis"],[563,"y - macron"],[913,"Alpha"],[914,"Beta"],[915,"Gamma"],[916,"Delta"],[917,"Epsilon"],[918,"Zeta"],[919,"Eta"],[920,"Theta"],[921,"Iota"],[922,"Kappa"],[923,"Lambda"],[924,"Mu"],[925,"Nu"],[926,"Xi"],[927,"Omicron"],[928,"Pi"],[929,"Rho"],[931,"Sigma"],[932,"Tau"],[933,"Upsilon"],[934,"Phi"],[935,"Chi"],[936,"Psi"],[937,"Omega"],[945,"alpha"],[946,"beta"],[947,"gamma"],[948,"delta"],[949,"epsilon"],[950,"zeta"],[951,"eta"],[952,"theta"],[953,"iota"],[954,"kappa"],[955,"lambda"],[956,"mu"],[957,"nu"],[958,"xi"],[959,"omicron"],[960,"pi"],[961,"rho"],[962,"final sigma"],[963,"sigma"],[964,"tau"],[965,"upsilon"],[966,"phi"],[967,"chi"],[968,"psi"],[969,"omega"]]},{name:"Symbols",characters:[[8501,"alef symbol"],[982,"pi symbol"],[8476,"real part symbol"],[978,"upsilon - hook symbol"],[8472,"Weierstrass p"],[8465,"imaginary part"]]},{name:"Arrows",characters:[[8592,"leftwards arrow"],[8593,"upwards arrow"],[8594,"rightwards arrow"],[8595,"downwards arrow"],[8596,"left right arrow"],[8629,"carriage return"],[8656,"leftwards double arrow"],[8657,"upwards double arrow"],[8658,"rightwards double arrow"],[8659,"downwards double arrow"],[8660,"left right double arrow"],[8756,"therefore"],[8834,"subset of"],[8835,"superset of"],[8836,"not a subset of"],[8838,"subset of or equal to"],[8839,"superset of or equal to"],[8853,"circled plus"],[8855,"circled times"],[8869,"perpendicular"],[8901,"dot operator"],[8968,"left ceiling"],[8969,"right ceiling"],[8970,"left floor"],[8971,"right floor"],[9001,"left-pointing angle bracket"],[9002,"right-pointing angle bracket"],[9674,"lozenge"],[9824,"black spade suit"],[9827,"black club suit"],[9829,"black heart suit"],[9830,"black diamond suit"],[8194,"en space"],[8195,"em space"],[8201,"thin space"],[8204,"zero width non-joiner"],[8205,"zero width joiner"],[8206,"left-to-right mark"],[8207,"right-to-left mark"]]}]);return t.length>1?[{name:"All",characters:h(t,(e=>e.characters))}].concat(t):t},S=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},k=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!a(n)||r+t.length<=n)},_=String.fromCodePoint,E=(e,t)=>{const o=[],n=t.toLowerCase();return((e,t)=>{for(let o=0,n=e.length;o{((e,t,o)=>!!k(_(e).toLowerCase(),o)||k(t.toLowerCase(),o)||k(t.toLowerCase().replace(/\s+/g,""),o))(e[0],e[1],n)&&o.push(e)})),u(o,(e=>({text:e[1],value:_(e[0]),icon:_(e[0])})))},T="pattern",O=(e,o)=>{const n=()=>[{label:"Search",type:"input",name:T},{type:"collection",name:"results"}],r=1===o.length?S(w):S("All"),a=((e,t)=>{let o=null;const n=()=>{s(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}})((e=>{const t=e.getData().pattern;((e,t)=>{g(o,(e=>e.name===r.get())).each((o=>{const n=E(o,t);e.setData({results:n})}))})(e,t)}),40),i={title:"Special Character",size:"normal",body:1===o.length?{type:"panel",items:n()}:{type:"tabpanel",tabs:u(o,(e=>({title:e.name,name:e.name,items:n()})))},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{pattern:"",results:E(o[0],"")},onAction:(o,n)=>{"results"===n.name&&(t(e,n.value),o.close())},onTabChange:(e,t)=>{r.set(t.newTabName),a.throttle(e)},onChange:(e,t)=>{t.name===T&&a.throttle(e)}};e.windowManager.open(i).focus(T)},D=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("charmap",(e=>{(e=>{const t=e.options.register,o=e=>i(e)||n(e);t("charmap",{processor:o}),t("charmap_append",{processor:o})})(e);const o=C(e);return((e,t)=>{e.addCommand("mceShowCharmap",(()=>{O(e,t)}))})(e,o),(e=>{const t=()=>e.execCommand("mceShowCharmap");e.ui.registry.addButton("charmap",{icon:"insert-character",tooltip:"Special character",onAction:t,onSetup:D(e)}),e.ui.registry.addMenuItem("charmap",{icon:"insert-character",text:"Special character...",onAction:t,onSetup:D(e)})})(e),((e,t)=>{e.ui.registry.addAutocompleter("charmap",{trigger:":",columns:"auto",minChars:2,fetch:(e,o)=>new Promise(((o,n)=>{o(E(t,e))})),onAction:(t,o,n)=>{e.selection.setRng(o),e.insertContent(n),t.hide()}})})(e,o[0]),(e=>({getCharMap:()=>C(e),insertChar:o=>{t(e,o)}}))(e)}))}(),tinymce.util.Tools.resolve("tinymce.PluginManager").add("code",(e=>((e=>{e.addCommand("mceCodeEditor",(()=>{(e=>{const t=(e=>e.getContent({source_view:!0}))(e);e.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:t},onSubmit:t=>{((e,t)=>{e.focus(),e.undoManager.transact((()=>{e.setContent(t)})),e.selection.setCursorLocation(),e.nodeChanged()})(e,t.getData().code),t.close()}})})(e)}))})(e),(e=>{const t=()=>e.execCommand("mceCodeEditor");e.ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:t}),e.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:t})})(e),{}))),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>typeof t===e,o=(e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e)("string"),n=t("boolean"),r=e=>!(e=>null==e)(e),s=t("function"),a=t("number"),i=(l=!1,()=>l);var l;class c{constructor(e,t){this.tag=e,this.value=t}static some(e){return new c(!0,e)}static none(){return c.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?c.some(e(this.value)):c.none()}bind(e){return this.tag?e(this.value):c.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:c.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return r(e)?c.some(e):c.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}c.singletonNone=new c(!1);const d=(e,t)=>{for(let o=0,n=e.length;o{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},u={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return m(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return m(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return m(o)},fromDom:m,fromPoint:(e,t,o)=>c.from(e.dom.elementFromPoint(t,o)).map(m)},g=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}};"undefined"!=typeof window?window:Function("return this;")();const h=e=>t=>(e=>e.dom.nodeType)(t)===e,p=h(1),f=h(3),v=h(9),b=h(11),y=e=>((e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{((e,t,r)=>{if(!(o(r)||n(r)||a(r)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",r,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,r+"")})(e.dom,t,r)},x=(e,t)=>{e.dom.removeAttribute(t)},C=s(Element.prototype.attachShadow)&&s(Node.prototype.getRootNode)?e=>u.fromDom(e.dom.getRootNode()):e=>{return v(e)?e:(t=e,u.fromDom(t.dom.ownerDocument));var t},S=e=>{const t=C(e);return b(o=t)&&r(o.dom.host)?c.some(t):c.none();var o},k=e=>u.fromDom(e.dom.host),_=e=>{const t=f(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return S(u.fromDom(t)).fold((()=>o.body.contains(t)),(n=_,r=k,e=>n(r(e))));var n,r},E=(e,t,o)=>((e,t,o)=>{let n=e.dom;const r=s(o)?o:i;for(;n.parentNode;){n=n.parentNode;const e=u.fromDom(n);if(t(e))return c.some(e);if(r(e))break}return c.none()})(e,(e=>g(e,t)),o),T=(e,t)=>(e=>void 0!==e.style&&s(e.style.getPropertyValue))(e)?e.style.getPropertyValue(t):"",O=e=>"rtl"===((e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||_(e)?n:T(o,t)})(e,"direction")?"rtl":"ltr",D=(e,t)=>((e,t)=>((e,t)=>{const o=[];for(let n=0,r=e.length;ng(e,t))),A=e=>(e=>c.from(e.dom.parentNode).map(u.fromDom))(e).filter(p),M=(N="li",e=>p(e)&&e.dom.nodeName.toLowerCase()===N);var N;const R=(e,t,o)=>{d(t,(t=>{const n=u.fromDom(t),r=M(n),s=((e,t)=>(t?E(e,"ol,ul"):c.some(e)).getOr(e))(n,r);A(s).each((t=>{e.setStyle(s.dom,"direction",null);if(O(t)===o?x(s,"dir"):w(s,"dir",o),O(s)!==o&&e.setStyle(s.dom,"direction",o),r){const t=D(s,"li[dir],li[style]");d(t,(t=>{x(t,"dir"),e.setStyle(t.dom,"direction",null)}))}}))}))},B=(e,t)=>{e.selection.isEditable()&&(R(e.dom,e.selection.getSelectedBlocks(),t),e.nodeChanged())},L=(e,t)=>o=>{const n=n=>{const r=u.fromDom(n.element);o.setActive(O(r)===t),o.setEnabled(e.selection.isEditable())};return e.on("NodeChange",n),o.setEnabled(e.selection.isEditable()),()=>e.off("NodeChange",n)};e.add("directionality",(e=>{(e=>{e.addCommand("mceDirectionLTR",(()=>{B(e,"ltr")})),e.addCommand("mceDirectionRTL",(()=>{B(e,"rtl")}))})(e),(e=>{e.ui.registry.addToggleButton("ltr",{tooltip:"Left to right",icon:"ltr",onAction:()=>e.execCommand("mceDirectionLTR"),onSetup:L(e,"ltr")}),e.ui.registry.addToggleButton("rtl",{tooltip:"Right to left",icon:"rtl",onAction:()=>e.execCommand("mceDirectionRTL"),onSetup:L(e,"rtl")})})(e)}))}(),function(){const e=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}};var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const o=e=>({isFullscreen:()=>null!==e.get()}),n=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,r=e=>t=>typeof t===e,s=e=>t=>e===t,a=n("string"),i=n("array"),l=s(null),c=r("boolean"),d=s(void 0),m=e=>!(e=>null==e)(e),u=r("function"),g=r("number"),h=()=>{},p=e=>()=>e;function f(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const v=p(!1),b=p(!0);class y{constructor(e,t){this.tag=e,this.value=t}static some(e){return new y(!0,e)}static none(){return y.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?y.some(e(this.value)):y.none()}bind(e){return this.tag?e(this.value):y.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:y.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return m(e)?y.some(e):y.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}y.singletonNone=new y(!1);const w=t=>{const o=e(y.none()),n=()=>o.get().each(t);return{clear:()=>{n(),o.set(y.none())},isSet:()=>o.get().isSome(),get:()=>o.get(),set:e=>{n(),o.set(y.some(e))}}},x=()=>w((e=>e.unbind())),C=Array.prototype.push,S=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n((e,t,o)=>{for(let n=0,r=e.length;n(e=>{const t=[];for(let o=0,n=e.length;o((e,t)=>t>=0&&t{const r=e.indexOf(t,o);return-1!==r&&(!!d(n)||r+t.length<=n)},M=e=>void 0!==e.style&&u(e.style.getPropertyValue),N=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},R={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return N(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return N(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return N(o)},fromDom:N,fromPoint:(e,t,o)=>y.from(e.dom.elementFromPoint(t,o)).map(N)};"undefined"!=typeof window?window:Function("return this;")();const B=e=>t=>(e=>e.dom.nodeType)(t)===e,L=B(1),H=B(3),I=B(9),P=B(11),F=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},z=e=>R.fromDom(e.dom.ownerDocument),V=e=>(e=>y.from(e.dom.parentNode).map(R.fromDom))(e).map(Z).map((t=>_(t,(t=>{return o=t,!(e.dom===o.dom);var o})))).getOr([]),Z=e=>S(e.dom.childNodes,R.fromDom),U=u(Element.prototype.attachShadow)&&u(Node.prototype.getRootNode),j=p(U),W=U?e=>R.fromDom(e.dom.getRootNode()):e=>I(e)?e:z(e),$=e=>{const t=W(e);return P(o=t)&&m(o.dom.host)?y.some(t):y.none();var o},q=e=>R.fromDom(e.dom.host),G=e=>m(e.dom.shadowRoot),K=e=>{const t=H(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return $(R.fromDom(t)).fold((()=>o.body.contains(t)),(n=K,r=q,e=>n(r(e))));var n,r},Y=(e,t,o)=>{((e,t,o)=>{if(!(a(o)||c(o)||g(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(e.dom,t,o)},X=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},J=(e,t)=>{e.dom.removeAttribute(t)},Q=(e,t)=>{const o=e.dom;((e,t)=>{const o=D(e);for(let n=0,r=o.length;n{((e,t,o)=>{if(!a(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);M(e)&&e.style.setProperty(t,o)})(o,t,e)}))},ee=(e,t)=>M(e)?e.style.getPropertyValue(t):"",te=e=>{const t=R.fromDom((e=>{if(j()&&m(e.target)){const t=R.fromDom(e.target);if(L(t)&&G(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return O(t)}}return y.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(s=n,a=o,(...e)=>s(a.apply(null,e)));var s,a;return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},oe=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(te(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:f(ne,e,t,s,r)}},ne=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},re=b,se=(e,t,o)=>((e,t,o,n)=>oe(e,t,o,n,!1))(e,t,re,o),ae=()=>ie(0,0),ie=(e,t)=>({major:e,minor:t}),le={nu:ie,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?ae():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return ie(n(1),n(2))})(e,o)},unknown:ae},ce=(e,t)=>((e,t)=>{for(let o=0;o{const o=t.brand.toLowerCase();return E(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:le.nu(parseInt(t.version,10),0)})))})),de=(e,t)=>{const o=String(t).toLowerCase();return E(e,(e=>e.search(o)))},me=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ue=e=>t=>A(t,e),ge=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>A(e,"edge/")&&A(e,"chrome")&&A(e,"safari")&&A(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,me],search:e=>A(e,"chrome")&&!A(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>A(e,"msie")||A(e,"trident")},{name:"Opera",versionRegexes:[me,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:ue("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:ue("firefox")},{name:"Safari",versionRegexes:[me,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(A(e,"safari")||A(e,"mobile/"))&&A(e,"applewebkit")}],he=[{name:"Windows",search:ue("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>A(e,"iphone")||A(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:ue("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:ue("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:ue("linux"),versionRegexes:[]},{name:"Solaris",search:ue("sunos"),versionRegexes:[]},{name:"FreeBSD",search:ue("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:ue("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],pe={browsers:p(ge),oses:p(he)},fe="Edge",ve="Chromium",be="Opera",ye="Firefox",we="Safari",xe=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(fe),isChromium:n(ve),isIE:n("IE"),isOpera:n(be),isFirefox:n(ye),isSafari:n(we)}},Ce={unknown:()=>xe({current:void 0,version:le.unknown()}),nu:xe,edge:p(fe),chromium:p(ve),ie:p("IE"),opera:p(be),firefox:p(ye),safari:p(we)},Se="Windows",ke="Android",_e="Linux",Ee="macOS",Te="Solaris",Oe="FreeBSD",De="ChromeOS",Ae=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(Se),isiOS:n("iOS"),isAndroid:n(ke),isMacOS:n(Ee),isLinux:n(_e),isSolaris:n(Te),isFreeBSD:n(Oe),isChromeOS:n(De)}},Me={unknown:()=>Ae({current:void 0,version:le.unknown()}),nu:Ae,windows:p(Se),ios:p("iOS"),android:p(ke),linux:p(_e),macos:p(Ee),solaris:p(Te),freebsd:p(Oe),chromeos:p(De)},Ne=(e,t,o)=>{const n=pe.browsers(),r=pe.oses(),s=t.bind((e=>ce(n,e))).orThunk((()=>((e,t)=>de(e,t).map((e=>{const o=le.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(Ce.unknown,Ce.nu),a=((e,t)=>de(e,t).map((e=>{const o=le.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(Me.unknown,Me.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:p(r),isiPhone:p(s),isTablet:p(l),isPhone:p(c),isTouch:p(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:p(d),isDesktop:p(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},Re=e=>window.matchMedia(e).matches;let Be=(e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)})((()=>Ne(navigator.userAgent,y.from(navigator.userAgentData),Re)));const Le=(e,t)=>({left:e,top:t,translate:(o,n)=>Le(e+o,t+n)}),He=Le,Ie=e=>{const t=void 0===e?window:e;return Be().browser.isFirefox()?y.none():y.from(t.visualViewport)},Pe=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Fe=e=>{const t=void 0===e?window:e,o=t.document,n=(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return He(o,n)})(R.fromDom(o));return Ie(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return Pe(n.left,n.top,o,r)}),(e=>Pe(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},ze=(e,t,o)=>Ie(o).map((o=>{const n=e=>t(te(e));return o.addEventListener(e,n),{unbind:()=>o.removeEventListener(e,n)}})).getOrThunk((()=>({unbind:h})));var Ve=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),Ze=tinymce.util.Tools.resolve("tinymce.Env");const Ue=(e,t)=>{e.dispatch("FullscreenStateChanged",{state:t}),e.dispatch("ResizeEditor")},je=(We="fullscreen_native",e=>e.options.get(We));var We;const $e=e=>{const t=R.fromDom(e.getElement());return $(t).map(q).getOrThunk((()=>(e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return R.fromDom(t)})(z(t))))},qe=e=>{return e.dom===(void 0!==(t=z(e).dom).fullscreenElement?t.fullscreenElement:void 0!==t.msFullscreenElement?t.msFullscreenElement:void 0!==t.webkitFullscreenElement?t.webkitFullscreenElement:null);var t},Ge=(e,t,o)=>_(((e,t)=>{const o=u(t)?t:v;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=R.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r})(e,o),t),Ke=e=>((e,t)=>{const o=void 0===t?document:t.dom;return 1!==(n=o).nodeType&&9!==n.nodeType&&11!==n.nodeType||0===n.childElementCount?[]:S(o.querySelectorAll(e),R.fromDom);var n})(e),Ye=(e,t,o)=>Ge(e,(e=>F(e,t)),o),Xe=(e,t)=>((e,t)=>_(V(e),t))(e,(e=>F(e,t))),Je="data-ephox-mobile-fullscreen-style",Qe="position:absolute!important;",et="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",tt=Ze.os.isAndroid(),ot=e=>{const t=((e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||K(e)?n:ee(o,t)})(e,"background-color");return void 0!==t&&""!==t?"background-color:"+t+"!important":"background-color:rgb(255,255,255)!important;"},nt=Ve.DOM,rt=Ie().fold((()=>({bind:h,unbind:h})),(e=>{const t=(()=>{const e=w(h);return{...e,on:t=>e.get().each(t)}})(),o=x(),n=x(),r=((e,t)=>{let o=null;return{cancel:()=>{l(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{l(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}})((()=>{document.body.scrollTop=0,document.documentElement.scrollTop=0,window.requestAnimationFrame((()=>{t.on((t=>Q(t,{top:e.offsetTop+"px",left:e.offsetLeft+"px",height:e.height+"px",width:e.width+"px"})))}))}),50);return{bind:e=>{t.set(e),r.throttle(),o.set(ze("resize",r.throttle)),n.set(ze("scroll",r.throttle))},unbind:()=>{t.on((()=>{o.clear(),n.clear()})),t.clear()}}})),st=(e,t)=>{const o=document.body,n=document.documentElement,r=e.getContainer(),s=R.fromDom(r),a=$e(e),i=t.get(),l=R.fromDom(e.getBody()),c=Ze.deviceType.isTouch(),d=r.style,m=e.iframeElement,u=null==m?void 0:m.style,g=e=>{e(o,"tox-fullscreen"),e(n,"tox-fullscreen"),e(r,"tox-fullscreen"),$(s).map((e=>q(e).dom)).each((t=>{e(t,"tox-fullscreen"),e(t,"tox-shadowhost")}))},h=()=>{c&&(e=>{const t=Ke("["+Je+"]");k(t,(t=>{const o=X(t,Je);o&&"no-styles"!==o?Q(t,e.parseStyle(o)):J(t,"style"),J(t,Je)}))})(e.dom),g(nt.removeClass),rt.unbind(),y.from(t.get()).each((e=>e.fullscreenChangeHandler.unbind()))};if(i)i.fullscreenChangeHandler.unbind(),je(e)&&qe(a)&&(e=>{const t=e.dom;t.exitFullscreen?t.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.webkitCancelFullScreen&&t.webkitCancelFullScreen()})(z(a)),u.width=i.iframeWidth,u.height=i.iframeHeight,d.width=i.containerWidth,d.height=i.containerHeight,d.top=i.containerTop,d.left=i.containerLeft,h(),p=i.scrollPos,window.scrollTo(p.x,p.y),t.set(null),Ue(e,!1),e.off("remove",h);else{const o=se(z(a),void 0!==document.fullscreenElement?"fullscreenchange":void 0!==document.msFullscreenElement?"MSFullscreenChange":void 0!==document.webkitFullscreenElement?"webkitfullscreenchange":"fullscreenchange",(o=>{je(e)&&(qe(a)||null===t.get()||st(e,t))})),n={scrollPos:Fe(window),containerWidth:d.width,containerHeight:d.height,containerTop:d.top,containerLeft:d.left,iframeWidth:u.width,iframeHeight:u.height,fullscreenChangeHandler:o};c&&((e,t,o)=>{const n=t=>o=>{const n=X(o,"style"),r=void 0===n?"no-styles":n.trim();r!==t&&(Y(o,Je,r),Q(o,e.parseStyle(t)))},r=Ye(t,"*"),s=T(r,(e=>Xe(e,"*:not(.tox-silver-sink)"))),a=ot(o);k(s,n("display:none!important;")),k(r,n(Qe+et+a)),n((!0===tt?"":Qe)+et+a)(t)})(e.dom,s,l),u.width=u.height="100%",d.width=d.height="",g(nt.addClass),rt.bind(s),e.on("remove",h),t.set(n),je(e)&&(e=>{const t=e.dom;t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.webkitRequestFullScreen&&t.webkitRequestFullScreen()})(a),Ue(e,!0)}var p},at=(e,t)=>o=>{o.setActive(null!==t.get());const n=e=>o.setActive(e.state);return e.on("FullscreenStateChanged",n),()=>e.off("FullscreenStateChanged",n)};t.add("fullscreen",(t=>{const n=e(null);return t.inline||((e=>{(0,e.options.register)("fullscreen_native",{processor:"boolean",default:!1})})(t),((e,t)=>{e.addCommand("mceFullScreen",(()=>{st(e,t)}))})(t,n),((e,t)=>{const o=()=>e.execCommand("mceFullScreen");e.ui.registry.addToggleMenuItem("fullscreen",{text:"Fullscreen",icon:"fullscreen",shortcut:"Meta+Shift+F",onAction:o,onSetup:at(e,t)}),e.ui.registry.addToggleButton("fullscreen",{tooltip:"Fullscreen",icon:"fullscreen",onAction:o,onSetup:at(e,t)})})(t,n),t.addShortcut("Meta+Shift+F","","mceFullScreen")),o(n)}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),s=t("array"),a=(i=null,e=>i===e);var i;const l=o("boolean"),c=e=>!(e=>null==e)(e),d=o("function"),m=(e,t)=>{if(s(e)){for(let o=0,n=e.length;o{},g=(e,t)=>e===t;class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return c(e)?h.some(e):h.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1);const p=Array.prototype.indexOf,f=Array.prototype.push,v=(e,t)=>((e,t)=>p.call(e,t))(e,t)>-1,b=e=>{const t=[];for(let o=0,n=e.length;ob(((e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0;oe.exists((e=>o(e,t))),C=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?h.some(t):h.none(),k=e=>t=>t.options.get(e),_=k("link_assume_external_targets"),E=k("link_context_toolbar"),T=k("link_list"),O=k("link_default_target"),D=k("link_default_protocol"),A=k("link_target_list"),M=k("link_rel_list"),N=k("link_class_list"),R=k("link_title"),B=k("allow_unsafe_link_target"),L=k("link_quicklink");var H=tinymce.util.Tools.resolve("tinymce.util.Tools");const I=e=>n(e.value)?e.value:"",P=(e,t)=>{const o=[];return H.each(e,(e=>{const r=(e=>n(e.text)?e.text:n(e.title)?e.title:"")(e);if(void 0!==e.menu){const n=P(e.menu,t);o.push({text:r,items:n})}else{const n=t(e);o.push({text:r,value:n})}})),o},F=(e=I)=>t=>h.from(t).map((t=>P(t,e))),z={sanitize:e=>F(I)(e),sanitizeWith:F,createUi:(e,t)=>o=>({name:e,type:"listbox",label:t,items:o}),getValue:I},V=Object.keys,Z=Object.hasOwnProperty,U=(e,t,o,n)=>{((e,t)=>{const o=V(e);for(let n=0,r=o.length;n{(t(e,r)?o:n)(e,r)}))},j=(e,t)=>Z.call(e,t);var W=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),$=tinymce.util.Tools.resolve("tinymce.util.URI");const q=e=>c(e)&&"a"===e.nodeName.toLowerCase(),G=e=>q(e)&&!!X(e),K=(e,t)=>{if(e.collapsed)return[];{const o=e.cloneContents(),n=o.firstChild,r=new W(n,o),s=[];let a=n;do{t(a)&&s.push(a)}while(a=r.next());return s}},Y=e=>/^\w+:/i.test(e),X=e=>{var t,o;return null!==(o=null!==(t=e.getAttribute("data-mce-href"))&&void 0!==t?t:e.getAttribute("href"))&&void 0!==o?o:""},J=(e,t)=>{const o=["noopener"],n=e?e.split(/\s+/):[],r=e=>e.filter((e=>-1===H.inArray(o,e))),s=t?(e=>(e=r(e)).length>0?e.concat(o):o)(n):r(n);return s.length>0?(e=>H.trim(e.sort().join(" ")))(s):""},Q=(e,t)=>(t=t||oe(e.selection.getRng())[0]||e.selection.getNode(),ae(t)?h.from(e.dom.select("a[href]",t)[0]):h.from(e.dom.getParent(t,"a[href]"))),ee=(e,t)=>Q(e,t).isSome(),te=(e,t)=>(e=>e.replace(/\uFEFF/g,""))(t.fold((()=>e.getContent({format:"text"})),(e=>e.innerText||e.textContent||""))),oe=e=>K(e,G),ne=e=>H.grep(e,G),re=e=>ne(e).length>0,se=e=>{const t=e.schema.getTextInlineElements(),o=e=>1===e.nodeType&&!q(e)&&!j(t,e.nodeName.toLowerCase());if(Q(e).exists((e=>e.hasAttribute("data-mce-block"))))return!1;const n=e.selection.getRng();if(n.collapsed)return!0;return 0===K(n,o).length},ae=e=>c(e)&&"FIGURE"===e.nodeName&&/\bimage\b/i.test(e.className),ie=(e,t)=>{const o={...t};if(0===M(e).length&&!B(e)){const e=J(o.rel,"_blank"===o.target);o.rel=e||null}return h.from(o.target).isNone()&&!1===A(e)&&(o.target=O(e)),o.href=((e,t)=>"http"!==t&&"https"!==t||Y(e)?e:t+"://"+e)(o.href,_(e)),o},le=(e,t,o)=>{const n=e.selection.getNode(),r=Q(e,n),s=ie(e,(e=>{return t=["title","rel","class","target"],o=(t,o)=>(e[o].each((e=>{t[o]=e.length>0?e:null})),t),n={href:e.href},((e,t)=>{for(let o=0,n=e.length;o{n=o(n,e,t)})),n;var t,o,n})(o));e.undoManager.transact((()=>{o.href===t.href&&t.attach(),r.fold((()=>{((e,t,o,n)=>{const r=e.dom;ae(t)?ge(r,t,n):o.fold((()=>{e.execCommand("mceInsertLink",!1,n)}),(t=>{e.insertContent(r.createHTML("a",n,r.encode(t)))}))})(e,n,o.text,s)}),(t=>{e.focus(),((e,t,o,n)=>{o.each((e=>{j(t,"innerText")?t.innerText=e:t.textContent=e})),e.dom.setAttribs(t,n),e.selection.select(t)})(e,t,o.text,s)}))}))},ce=e=>{const{class:t,href:o,rel:n,target:r,text:s,title:i}=e;return((e,t)=>{const o={};var n;return U(e,t,(n=o,(e,t)=>{n[t]=e}),u),o})({class:t.getOrNull(),href:o,rel:n.getOrNull(),target:r.getOrNull(),text:s.getOrNull(),title:i.getOrNull()},((e,t)=>!1===a(e)))},de=(e,t,o)=>{const n=((e,t)=>{const o=e.options.get,n={allow_html_data_urls:o("allow_html_data_urls"),allow_script_urls:o("allow_script_urls"),allow_svg_data_urls:o("allow_svg_data_urls")},r=t.href;return{...t,href:$.isDomSafe(r,"a",n)?r:""}})(e,o);e.hasPlugin("rtc",!0)?e.execCommand("createlink",!1,ce(n)):le(e,t,n)},me=e=>{e.hasPlugin("rtc",!0)?e.execCommand("unlink"):(e=>{e.undoManager.transact((()=>{const t=e.selection.getNode();ae(t)?ue(e,t):(e=>{const t=e.dom,o=e.selection,n=o.getBookmark(),r=o.getRng().cloneRange(),s=t.getParent(r.startContainer,"a[href]",e.getBody()),a=t.getParent(r.endContainer,"a[href]",e.getBody());s&&r.setStartBefore(s),a&&r.setEndAfter(a),o.setRng(r),e.execCommand("unlink"),o.moveToBookmark(n)})(e),e.focus()}))})(e)},ue=(e,t)=>{var o;const n=e.dom.select("img",t)[0];if(n){const r=e.dom.getParents(n,"a[href]",t)[0];r&&(null===(o=r.parentNode)||void 0===o||o.insertBefore(n,r),e.dom.remove(r))}},ge=(e,t,o)=>{var n;const r=e.select("img",t)[0];if(r){const t=e.create("a",o);null===(n=r.parentNode)||void 0===n||n.insertBefore(t,r),t.appendChild(r)}},he=e=>{return j(t=e,o="items")&&void 0!==t[o]&&null!==t[o];var t,o},pe=(e,t)=>w(t,(t=>he(t)?pe(e,t.items):S(t.value===e,t))),fe=(e,t,o,n)=>{const r=n[t],s=e.length>0;return void 0!==r?pe(r,o).map((t=>({url:{value:t.value,meta:{text:s?e:t.text,attach:u}},text:s?e:t.text}))):h.none()},ve=(e,t)=>{const o={text:e.text,title:e.title},n=e=>{const t=(n=e.url,S(o.text.length<=0,h.from(null===(r=n.meta)||void 0===r?void 0:r.text).getOr(n.value)));var n,r;const s=(e=>{var t;return S(o.title.length<=0,h.from(null===(t=e.meta)||void 0===t?void 0:t.title).getOr(""))})(e.url);return t.isSome()||s.isSome()?h.some({...t.map((e=>({text:e}))).getOr({}),...s.map((e=>({title:e}))).getOr({})}):h.none()},r=(e,n)=>{const r=(s=t,a=n,"link"===a?s.link:"anchor"===a?s.anchor:h.none()).getOr([]);var s,a;return fe(o.text,n,r,e)};return{onChange:(e,t)=>{const s=t.name;return"url"===s?n(e()):v(["anchor","link"],s)?r(e(),s):"text"===s||"title"===s?(o[s]=e()[s],h.none()):h.none()}}};var be=tinymce.util.Tools.resolve("tinymce.util.Delay");const ye=e=>{const t=e.href;return t.indexOf("@")>0&&-1===t.indexOf("/")&&-1===t.indexOf("mailto:")?h.some({message:"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",preprocess:e=>({...e,href:"mailto:"+t})}):h.none()},we=(e,t)=>o=>{const n=o.href;return 1===e&&!Y(n)||0===e&&/^\s*www(\.|\d\.)/i.test(n)?h.some({message:`The URL you entered seems to be an external link. Do you want to add the required ${t}:// prefix?`,preprocess:e=>({...e,href:t+"://"+n})}):h.none()},xe=(e,t)=>w([ye,we(_(e),D(e))],(e=>e(t))).fold((()=>Promise.resolve(t)),(o=>new Promise((n=>{((e,t,o)=>{const n=e.selection.getRng();be.setEditorTimeout(e,(()=>{e.windowManager.confirm(t,(t=>{e.selection.setRng(n),o(t)}))}))})(e,o.message,(e=>{n(e?o.preprocess(t):t)}))})))),Ce=e=>{const t=e.dom.select("a:not([href])"),o=y(t,(e=>{const t=e.name||e.id;return t?[{text:t,value:"#"+t}]:[]}));return o.length>0?h.some([{text:"None",value:""}].concat(o)):h.none()},Se=e=>{const t=N(e);return t.length>0?z.sanitize(t):h.none()},ke=e=>{try{return h.some(JSON.parse(e))}catch(e){return h.none()}},_e=e=>{const t=t=>e.convertURL(t.value||t.url||"","href"),o=T(e);return new Promise((e=>{n(o)?fetch(o).then((e=>e.ok?e.text().then(ke):Promise.reject())).then(e,(()=>e(h.none()))):d(o)?o((t=>e(h.some(t)))):e(h.from(o))})).then((e=>e.bind(z.sanitizeWith(t)).map((e=>{if(e.length>0){return[{text:"None",value:""}].concat(e)}return e}))))},Ee=(e,t)=>{const o=M(e);if(o.length>0){const n=x(t,"_blank"),r=e=>J(z.getValue(e),n);return(!1===B(e)?z.sanitizeWith(r):z.sanitize)(o)}return h.none()},Te=[{text:"Current window",value:""},{text:"New window",value:"_blank"}],Oe=e=>{const t=A(e);return s(t)?z.sanitize(t).orThunk((()=>h.some(Te))):!1===t?h.none():h.some(Te)},De=(e,t,o)=>{const n=e.getAttrib(t,o);return null!==n&&n.length>0?h.some(n):h.none()},Ae=(e,t)=>_e(e).then((o=>{const n=((e,t)=>{const o=e.dom,n=se(e)?h.some(te(e.selection,t)):h.none(),r=t.bind((e=>h.from(o.getAttrib(e,"href")))),s=t.bind((e=>h.from(o.getAttrib(e,"target")))),a=t.bind((e=>De(o,e,"rel"))),i=t.bind((e=>De(o,e,"class")));return{url:r,text:n,title:t.bind((e=>De(o,e,"title"))),target:s,rel:a,linkClass:i}})(e,t);return{anchor:n,catalogs:{targets:Oe(e),rels:Ee(e,n.target),classes:Se(e),anchor:Ce(e),link:o},optNode:t,flags:{titleEnabled:R(e)}}})),Me=e=>{const t=(e=>{const t=Q(e);return Ae(e,t)})(e);t.then((t=>{const o=((e,t)=>o=>{const n=o.getData();if(!n.url.value)return me(e),void o.close();const r=e=>h.from(n[e]).filter((o=>!x(t.anchor[e],o))),s={href:n.url.value,text:r("text"),target:r("target"),rel:r("rel"),class:r("linkClass"),title:r("title")},a={href:n.url.value,attach:void 0!==n.url.meta&&n.url.meta.attach?n.url.meta.attach:u};xe(e,s).then((t=>{de(e,a,t)})),o.close()})(e,t);return((e,t,o)=>{const n=e.anchor.text.map((()=>({name:"text",type:"input",label:"Text to display"}))).toArray(),r=e.flags.titleEnabled?[{name:"title",type:"input",label:"Title"}]:[],s=((e,t)=>{const o=e.anchor,n=o.url.getOr("");return{url:{value:n,meta:{original:{value:n}}},text:o.text.getOr(""),title:o.title.getOr(""),anchor:n,link:n,rel:o.rel.getOr(""),target:o.target.or(t).getOr(""),linkClass:o.linkClass.getOr("")}})(e,h.from(O(o))),a=e.catalogs,i=ve(s,a);return{title:"Insert/Edit Link",size:"normal",body:{type:"panel",items:b([[{name:"url",type:"urlinput",filetype:"file",label:"URL",picker_text:"Browse links"}],n,r,C([a.anchor.map(z.createUi("anchor","Anchors")),a.rels.map(z.createUi("rel","Rel")),a.targets.map(z.createUi("target","Open link in...")),a.link.map(z.createUi("link","Link list")),a.classes.map(z.createUi("linkClass","Class"))])])},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:s,onChange:(e,{name:t})=>{i.onChange(e.getData,{name:t}).each((t=>{e.setData(t)}))},onSubmit:t}})(t,o,e)})).then((t=>{e.windowManager.open(t)}))};var Ne=tinymce.util.Tools.resolve("tinymce.util.VK");const Re=e=>{const t=document.createElement("a");t.target="_blank",t.href=e,t.rel="noreferrer noopener";const o=document.createEvent("MouseEvents");o.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),((e,t)=>{document.body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)})(t,o)},Be=(e,t)=>e.dom.getParent(t,"a[href]"),Le=e=>Be(e,e.selection.getStart()),He=(e,t)=>{if(t){const o=X(t);if(/^#/.test(o)){const t=e.dom.select(o);t.length&&e.selection.scrollIntoView(t[0],!0)}else Re(t.href)}},Ie=e=>()=>{e.execCommand("mceLink",!1,{dialog:!0})},Pe=e=>()=>{He(e,Le(e))},Fe=(e,t)=>(e.on("NodeChange",t),()=>e.off("NodeChange",t)),ze=e=>t=>{const o=()=>{t.setActive(!e.mode.isReadOnly()&&ee(e,e.selection.getNode())),t.setEnabled(e.selection.isEditable())};return o(),Fe(e,o)},Ve=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return o(),Fe(e,o)},Ze=e=>t=>{const o=()=>t.setEnabled((e=>1===(e.selection.isCollapsed()?ne(e.dom.getParents(e.selection.getStart())):oe(e.selection.getRng())).length)(e));return o(),Fe(e,o)},Ue=e=>t=>{const o=t=>{return re(t)||(o=e.selection.getRng(),oe(o).length>0);var o},n=e.dom.getParents(e.selection.getStart()),r=n=>{t.setEnabled(o(n)&&e.selection.isEditable())};return r(n),Fe(e,(e=>r(e.parents)))},je=e=>{const t=t=>{const o=e.selection.getNode();return t.setEnabled(ee(e,o)),u};e.ui.registry.addContextForm("quicklink",{launch:{type:"contextformtogglebutton",icon:"link",tooltip:"Link",onSetup:ze(e)},label:"Link",predicate:t=>E(e)&&ee(e,t),initValue:()=>{return Q(e).fold((t="",()=>t),X);var t},commands:[{type:"contextformtogglebutton",icon:"link",tooltip:"Link",primary:!0,onSetup:t=>{const o=e.selection.getNode();return t.setActive(ee(e,o)),ze(e)(t)},onAction:t=>{const o=t.getValue(),n=(t=>{const o=Q(e),n=se(e);if(o.isNone()&&n){const n=te(e.selection,o);return S(0===n.length,t)}return h.none()})(o);de(e,{href:o,attach:u},{href:o,text:n,title:h.none(),rel:h.none(),target:h.none(),class:h.none()}),(e=>{e.selection.collapse(!1)})(e),t.hide()}},{type:"contextformbutton",icon:"unlink",tooltip:"Remove link",onSetup:t,onAction:t=>{me(e),t.hide()}},{type:"contextformbutton",icon:"new-tab",tooltip:"Open link",onSetup:t,onAction:t=>{Pe(e)(),t.hide()}}]})};e.add("link",(e=>{(e=>{const t=e.options.register;t("link_assume_external_targets",{processor:e=>{const t=n(e)||l(e);return t?!0===e?{value:1,valid:t}:"http"===e||"https"===e?{value:e,valid:t}:{value:0,valid:t}:{valid:!1,message:"Must be a string or a boolean."}},default:!1}),t("link_context_toolbar",{processor:"boolean",default:!1}),t("link_list",{processor:e=>n(e)||d(e)||m(e,r)}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"}),t("link_target_list",{processor:e=>l(e)||m(e,r),default:!0}),t("link_rel_list",{processor:"object[]",default:[]}),t("link_class_list",{processor:"object[]",default:[]}),t("link_title",{processor:"boolean",default:!0}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("link_quicklink",{processor:"boolean",default:!1})})(e),(e=>{e.ui.registry.addToggleButton("link",{icon:"link",tooltip:"Insert/edit link",onAction:Ie(e),onSetup:ze(e)}),e.ui.registry.addButton("openlink",{icon:"new-tab",tooltip:"Open link",onAction:Pe(e),onSetup:Ze(e)}),e.ui.registry.addButton("unlink",{icon:"unlink",tooltip:"Remove link",onAction:()=>me(e),onSetup:Ue(e)})})(e),(e=>{e.ui.registry.addMenuItem("openlink",{text:"Open link",icon:"new-tab",onAction:Pe(e),onSetup:Ze(e)}),e.ui.registry.addMenuItem("link",{icon:"link",text:"Link...",shortcut:"Meta+K",onSetup:Ve(e),onAction:Ie(e)}),e.ui.registry.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onAction:()=>me(e),onSetup:Ue(e)})})(e),(e=>{e.ui.registry.addContextMenu("link",{update:t=>e.dom.isEditable(t)?re(e.dom.getParents(t,"a"))?"link unlink openlink":"link":""})})(e),je(e),(e=>{e.on("click",(t=>{const o=Be(e,t.target);o&&Ne.metaKeyPressed(t)&&(t.preventDefault(),He(e,o))})),e.on("keydown",(t=>{if(!t.isDefaultPrevented()&&13===t.keyCode&&(e=>!0===e.altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey)(t)){const o=Le(e);o&&(t.preventDefault(),He(e,o))}}))})(e),(e=>{e.addCommand("mceLink",((t,o)=>{!0!==(null==o?void 0:o.dialog)&&L(e)?e.dispatch("contexttoolbar-show",{toolbarKey:"quicklink"}):Me(e)}))})(e),(e=>{e.addShortcut("Meta+K","",(()=>{e.execCommand("mceLink")}))})(e)}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),s=t("array"),a=o("boolean"),i=e=>!(e=>null==e)(e),l=o("function"),c=o("number"),d=()=>{},m=e=>()=>e,u=(e,t)=>e===t;const g=e=>t=>!e(t),h=m(!1);class p{constructor(e,t){this.tag=e,this.value=t}static some(e){return new p(!0,e)}static none(){return p.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?p.some(e(this.value)):p.none()}bind(e){return this.tag?e(this.value):p.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:p.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return i(e)?p.some(e):p.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}p.singletonNone=new p(!1);const f=Array.prototype.slice,v=Array.prototype.indexOf,b=Array.prototype.push,y=(e,t)=>{return o=e,n=t,v.call(o,n)>-1;var o,n},w=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n(C(e,((e,n)=>{o=t(o,e,n)})),o),_=(e,t,o)=>{for(let n=0,r=e.length;n_(e,t,h),T=(e,t)=>(e=>{const t=[];for(let o=0,n=e.length;o{const t=f.call(e,0);return t.reverse(),t},D=(e,t)=>t>=0&&tD(e,0),M=e=>D(e,e.length-1),N=(e,t)=>{const o=[],n=l(t)?e=>w(o,(o=>t(o,e))):e=>y(o,e);for(let t=0,r=e.length;te.exists((e=>o(e,t))),B=(e,t,o)=>e.isSome()&&t.isSome()?p.some(o(e.getOrDie(),t.getOrDie())):p.none(),L=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},H={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return L(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return L(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return L(o)},fromDom:L,fromPoint:(e,t,o)=>p.from(e.dom.elementFromPoint(t,o)).map(L)},I=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},P=(e,t)=>e.dom===t.dom,F=I,z="undefined"!=typeof window?window:Function("return this;")(),V=(e,t)=>((e,t)=>{let o=null!=t?t:z;for(let t=0;t{const o=((e,t)=>V(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},U=Object.getPrototypeOf,j=e=>{const t=V("ownerDocument.defaultView",e);return r(e)&&((e=>Z("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(U(e).constructor.name))},W=e=>e.dom.nodeName.toLowerCase(),$=e=>e.dom.nodeType,q=e=>t=>$(t)===e,G=e=>K(e)&&j(e.dom),K=q(1),Y=q(3),X=q(9),J=q(11),Q=e=>t=>K(t)&&W(t)===e,ee=e=>p.from(e.dom.parentNode).map(H.fromDom),te=e=>x(e.dom.childNodes,H.fromDom),oe=(e,t)=>{const o=e.dom.childNodes;return p.from(o[t]).map(H.fromDom)},ne=e=>oe(e,0),re=e=>oe(e,e.dom.childNodes.length-1),se=l(Element.prototype.attachShadow)&&l(Node.prototype.getRootNode)?e=>H.fromDom(e.dom.getRootNode()):e=>{return X(e)?e:(t=e,H.fromDom(t.dom.ownerDocument));var t},ae=e=>{const t=se(e);return J(o=t)&&i(o.dom.host)?p.some(t):p.none();var o},ie=e=>H.fromDom(e.dom.host),le=e=>{const t=Y(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return ae(H.fromDom(t)).fold((()=>o.body.contains(t)),(n=le,r=ie,e=>n(r(e))));var n,r};var ce=(e,t,o,n,r)=>e(o,n)?p.some(o):l(r)&&r(o)?p.none():t(o,n,r);const de=(e,t,o)=>{let n=e.dom;const r=l(o)?o:h;for(;n.parentNode;){n=n.parentNode;const e=H.fromDom(n);if(t(e))return p.some(e);if(r(e))break}return p.none()},me=(e,t,o)=>ce(((e,t)=>t(e)),de,e,t,o),ue=(e,t,o)=>de(e,(e=>I(e,t)),o),ge=e=>{return ce(((e,t)=>I(e,t)),ue,e,"[contenteditable]",t);var t},he=e=>e.dom.contentEditable,pe=(e,t)=>{ee(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},fe=(e,t)=>{const o=(e=>p.from(e.dom.nextSibling).map(H.fromDom))(e);o.fold((()=>{ee(e).each((e=>{ve(e,t)}))}),(e=>{pe(e,t)}))},ve=(e,t)=>{e.dom.appendChild(t.dom)},be=(e,t)=>{C(t,(t=>{ve(e,t)}))},ye=e=>{e.dom.textContent="",C(te(e),(e=>{we(e)}))},we=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)};var xe=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),Ce=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),Se=tinymce.util.Tools.resolve("tinymce.util.VK");const ke=e=>x(e,H.fromDom),_e=Object.keys,Ee=(e,t)=>{const o=_e(e);for(let n=0,r=o.length;n{const o={};var n;return((e,t,o,n)=>{Ee(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(n=o,(e,t)=>{n[t]=e}),d),o},Oe=(e,t)=>{const o=e.dom;Ee(t,((e,t)=>{((e,t,o)=>{if(!(n(o)||a(o)||c(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(o,t,e)}))},De=e=>k(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Ae=e=>((e,t)=>H.fromDom(e.dom.cloneNode(t)))(e,!0),Me=(e,t)=>{const o=((e,t)=>{const o=H.fromTag(t),n=De(e);return Oe(o,n),o})(e,t);fe(e,o);const n=te(e);return be(o,n),we(e),o};var Ne=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),Re=tinymce.util.Tools.resolve("tinymce.util.Tools");const Be=e=>t=>i(t)&&t.nodeName.toLowerCase()===e,Le=e=>t=>i(t)&&e.test(t.nodeName),He=e=>i(e)&&3===e.nodeType,Ie=e=>i(e)&&1===e.nodeType,Pe=Le(/^(OL|UL|DL)$/),Fe=Le(/^(OL|UL)$/),ze=Be("ol"),Ve=Le(/^(LI|DT|DD)$/),Ze=Le(/^(DT|DD)$/),Ue=Le(/^(TH|TD)$/),je=Be("br"),We=(e,t)=>i(t)&&t.nodeName in e.schema.getTextBlockElements(),$e=(e,t)=>i(e)&&e.nodeName in t,qe=(e,t)=>i(t)&&t.nodeName in e.schema.getVoidElements(),Ge=(e,t,o)=>{const n=e.isEmpty(t);return!(o&&e.select("span[data-mce-type=bookmark]",t).length>0)&&n},Ke=(e,t)=>e.isChildOf(t,e.getRoot()),Ye=e=>t=>t.options.get(e),Xe=Ye("lists_indent_on_tab"),Je=Ye("forced_root_block"),Qe=Ye("forced_root_block_attrs"),et=(e,t)=>{const o=e.dom,n=e.schema.getBlockElements(),r=o.createFragment(),s=Je(e),a=Qe(e);let i,l,c=!1;for(l=o.create(s,a),$e(t.firstChild,n)||r.appendChild(l);i=t.firstChild;){const e=i.nodeName;c||"SPAN"===e&&"bookmark"===i.getAttribute("data-mce-type")||(c=!0),$e(i,n)?(r.appendChild(i),l=null):(l||(l=o.create(s,a),r.appendChild(l)),l.appendChild(i))}return!c&&l&&l.appendChild(o.create("br",{"data-mce-bogus":"1"})),r},tt=Ne.DOM,ot=(e,t,o)=>{const n=tt.select('span[data-mce-type="bookmark"]',t),r=et(e,o),s=tt.createRng();s.setStartAfter(o),s.setEndAfter(t);const a=s.extractContents();for(let t=a.firstChild;t;t=t.firstChild)if("LI"===t.nodeName&&e.dom.isEmpty(t)){tt.remove(t);break}e.dom.isEmpty(a)||tt.insertAfter(a,t),tt.insertAfter(r,t);const i=o.parentElement;i&&Ge(e.dom,i)&&(e=>{const t=e.parentNode;t&&Re.each(n,(e=>{t.insertBefore(e,o.parentNode)})),tt.remove(e)})(i),tt.remove(o),Ge(e.dom,t)&&tt.remove(t)},nt=Q("dd"),rt=Q("dt"),st=(e,t)=>{var o;nt(t)?Me(t,"dt"):rt(t)&&(o=t,p.from(o.dom.parentElement).map(H.fromDom)).each((o=>ot(e,o.dom,t.dom)))},at=e=>{rt(e)&&Me(e,"dd")},it=(e,t)=>{if(He(e))return{container:e,offset:t};const o=xe.getNode(e,t);return He(o)?{container:o,offset:t>=e.childNodes.length?o.data.length:0}:o.previousSibling&&He(o.previousSibling)?{container:o.previousSibling,offset:o.previousSibling.data.length}:o.nextSibling&&He(o.nextSibling)?{container:o.nextSibling,offset:0}:{container:e,offset:t}},lt=e=>{const t=e.cloneRange(),o=it(e.startContainer,e.startOffset);t.setStart(o.container,o.offset);const n=it(e.endContainer,e.endOffset);return t.setEnd(n.container,n.offset),t},ct=["OL","UL","DL"],dt=ct.join(","),mt=(e,t)=>{const o=t||e.selection.getStart(!0);return e.dom.getParent(o,dt,pt(e,o))},ut=e=>{const t=mt(e),o=e.selection.getSelectedBlocks();return((e,t)=>i(e)&&1===t.length&&t[0]===e)(t,o)?(e=>S(e.querySelectorAll(dt),Pe))(t):S(o,(e=>Pe(e)&&t!==e))},gt=e=>{const t=e.selection.getSelectedBlocks();return S(((e,t)=>{const o=Re.map(t,(t=>e.dom.getParent(t,"li,dd,dt",pt(e,t))||t));return N(o)})(e,t),Ve)},ht=(e,t)=>{const o=e.dom.getParents(t,"TD,TH");return o.length>0?o[0]:e.getBody()},pt=(e,t)=>{const o=e.dom.getParents(t,e.dom.isBlock),n=E(o,(t=>{return o=e.schema,!Pe(n=t)&&!Ve(n)&&w(ct,(e=>o.isValidChild(n.nodeName,e)));var o,n}));return n.getOr(e.getBody())},ft=(e,t)=>{const o=e.dom.getParents(t,"ol,ul",pt(e,t));return M(o)},vt=e=>{const t=(e=>{const t=ft(e,e.selection.getStart()),o=S(e.selection.getSelectedBlocks(),Fe);return t.toArray().concat(o)})(e),o=(e=>{const t=e.selection.getStart();return e.dom.getParents(t,"ol,ul",pt(e,t))})(e);return E(o,(e=>{return t=H.fromDom(e),ee(t).exists((e=>Ve(e.dom)&&ne(e).exists((e=>!Pe(e.dom)))&&re(e).exists((e=>!Pe(e.dom)))));var t})).fold((()=>bt(e,t)),(e=>[e]))},bt=(e,t)=>{const o=x(t,(t=>ft(e,t).getOr(t)));return N(o)},yt=e=>/\btox\-/.test(e.className),wt=(e,t)=>_(e,Pe,Ue).exists((e=>e.nodeName===t&&!yt(e))),xt=(e,t)=>null!==t&&!e.dom.isEditable(t),Ct=(e,t)=>{const o=e.dom.getParent(t,"ol,ul,dl");return xt(e,o)},St=(e,t)=>{const o=e.selection.getNode();return t({parents:e.dom.getParents(o),element:o}),e.on("NodeChange",t),()=>e.off("NodeChange",t)},kt=(e,t)=>{const o=(t||document).createDocumentFragment();return C(e,(e=>{o.appendChild(e.dom)})),H.fromDom(o)},_t=(e,t,o)=>e.dispatch("ListMutation",{action:t,element:o}),Et=(Tt=/^\s+|\s+$/g,e=>e.replace(Tt,""));var Tt;const Ot=(e,t,o)=>{if(!n(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);(e=>void 0!==e.style&&l(e.style.getPropertyValue))(e)&&e.style.setProperty(t,o)},Dt=(e,t,o)=>{const n=e.dom;Ot(n,t,o)},At=e=>F(e,"OL,UL"),Mt=e=>ne(e).exists(At),Nt=e=>"listAttributes"in e,Rt=e=>"isComment"in e,Bt=e=>e.depth>0,Lt=e=>e.isSelected,Ht=e=>{const t=te(e),o=re(e).exists(At)?t.slice(0,-1):t;return x(o,Ae)},It=(e,t)=>{ve(e.item,t.list)},Pt=(e,t)=>{const o={list:H.fromTag(t,e),item:H.fromTag("li",e)};return ve(o.list,o.item),o},Ft=(e,t,o)=>{const n=t.slice(0,o.depth);return M(n).each((t=>{if(Nt(o)){const n=((e,t,o)=>{const n=H.fromTag("li",e);return Oe(n,t),be(n,o),n})(e,o.itemAttributes,o.content);((e,t)=>{ve(e.list,t),e.item=t})(t,n),((e,t)=>{W(e.list)!==t.listType&&(e.list=Me(e.list,t.listType)),Oe(e.list,t.listAttributes)})(t,o)}else if((e=>"isFragment"in e)(o))be(t.item,o.content);else{const e=H.fromHtml(`\x3c!--${o.content}--\x3e`);ve(t.list,e)}})),n},zt=(e,t,o)=>{const n=((e,t,o)=>{const n=[];for(let r=0;r{for(let t=1;t{for(let t=0;t{Nt(t)&&(Oe(e.list,t.listAttributes),Oe(e.item,t.itemAttributes)),be(e.item,t.content)}))})(n,o),r=n,B(M(t),A(r),It),t.concat(n)},Vt=(e,t)=>{let o=p.none();const n=k(t,((t,n,r)=>Rt(n)?0===r?(o=p.some(n),t):Ft(e,t,n):n.depth>t.length?zt(e,t,n):Ft(e,t,n)),[]);return o.each((e=>{const t=H.fromHtml(`\x3c!--${e.content}--\x3e`);A(n).each((e=>{((e,t)=>{ne(e).fold((()=>{ve(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))})(e.list,t)}))})),A(n).map((e=>e.list))},Zt=e=>(C(e,((t,o)=>{((e,t)=>{const o=e[t].depth,n=e=>e.depth===o&&!e.dirty,r=e=>e.depth_(e.slice(t+1),n,r)))})(e,o).fold((()=>{t.dirty&&Nt(t)&&(e=>{e.listAttributes=Te(e.listAttributes,((e,t)=>"start"!==t))})(t)}),(e=>{return n=e,void(Nt(o=t)&&Nt(n)&&(o.listType=n.listType,o.listAttributes={...n.listAttributes}));var o,n}))})),e),Ut=(e,t,o,n)=>{var r,s;if(8===$(s=n)||"#comment"===W(s))return[{depth:e+1,content:null!==(r=n.dom.nodeValue)&&void 0!==r?r:"",dirty:!1,isSelected:!1,isComment:!0}];t.each((e=>{P(e.start,n)&&o.set(!0)}));const a=((e,t,o)=>ee(e).filter(K).map((n=>({depth:t,dirty:!1,isSelected:o,content:Ht(e),itemAttributes:De(e),listAttributes:De(n),listType:W(n),isInPreviousLi:!1}))))(n,e,o.get());t.each((e=>{P(e.end,n)&&o.set(!1)}));const i=re(n).filter(At).map((n=>Wt(e,t,o,n))).getOr([]);return a.toArray().concat(i)},jt=(e,t,o,n)=>ne(n).filter(At).fold((()=>Ut(e,t,o,n)),(r=>{const s=k(te(n),((n,s,a)=>{if(0===a)return n;if(F(s,"LI"))return n.concat(Ut(e,t,o,s));{const t={isFragment:!0,depth:e,content:[s],isSelected:!1,dirty:!1,parentListType:W(r)};return n.concat(t)}}),[]);return Wt(e,t,o,r).concat(s)})),Wt=(e,t,o,n)=>T(te(n),(n=>(At(n)?Wt:jt)(e+1,t,o,n))),$t=(e,t)=>T(((e,t)=>{if(0===e.length)return[];{let o=t(e[0]);const n=[];let r=[];for(let s=0,a=e.length;sA(t).exists(Bt)?((e,t)=>{const o=Zt(t);return Vt(e.contentDocument,o).toArray()})(e,t):((e,t)=>{const o=Zt(t);return x(o,(t=>{const o=Rt(t)?kt([H.fromHtml(`\x3c!--${t.content}--\x3e`)]):kt(t.content);return H.fromDom(et(e,o.dom))}))})(e,t))),qt=(e,t,o)=>{const n=((e,t)=>{const o=(e=>{let t=!1;return{get:()=>t,set:e=>{t=e}}})();return x(e,(e=>({sourceList:e,entries:Wt(0,t,o,e)})))})(t,(e=>{const t=x(gt(e),H.fromDom);return B(E(t,g(Mt)),E(O(t),g(Mt)),((e,t)=>({start:e,end:t})))})(e));C(n,(t=>{((e,t)=>{C(S(e,Lt),(e=>((e,t)=>{switch(e){case"Indent":t.depth++;break;case"Outdent":t.depth--;break;case"Flatten":t.depth=0}t.dirty=!0})(t,e)))})(t.entries,o);const n=$t(e,t.entries);var r;C(n,(t=>{_t(e,"Indent"===o?"IndentList":"OutdentList",t.dom)})),r=t.sourceList,C(n,(e=>{pe(r,e)})),we(t.sourceList)}))},Gt=(e,t)=>{const o=ke(vt(e)),n=ke((e=>S(gt(e),Ze))(e));let r=!1;if(o.length||n.length){const s=e.selection.getBookmark();qt(e,o,t),((e,t,o)=>{C(o,"Indent"===t?at:t=>st(e,t))})(e,t,n),e.selection.moveToBookmark(s),e.selection.setRng(lt(e.selection.getRng())),e.nodeChanged(),r=!0}return r},Kt=(e,t)=>!(e=>{const t=mt(e);return xt(e,t)})(e)&&Gt(e,t),Yt=e=>Kt(e,"Indent"),Xt=e=>Kt(e,"Outdent"),Jt=e=>Kt(e,"Flatten"),Qt=e=>"\ufeff"===e,eo=(e,t)=>{return o=e,n=function(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}(P,t),de(o,n,r).isSome();var o,n,r};var to=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager");const oo=Ne.DOM,no=e=>{const t={},o=o=>{let n=e[o?"startContainer":"endContainer"],r=e[o?"startOffset":"endOffset"];if(Ie(n)){const e=oo.create("span",{"data-mce-type":"bookmark"});n.hasChildNodes()?(r=Math.min(r,n.childNodes.length-1),o?n.insertBefore(e,n.childNodes[r]):oo.insertAfter(e,n.childNodes[r])):n.appendChild(e),n=e,r=0}t[o?"startContainer":"endContainer"]=n,t[o?"startOffset":"endOffset"]=r};return o(!0),e.collapsed||o(),t},ro=e=>{const t=t=>{let o=e[t?"startContainer":"endContainer"],n=e[t?"startOffset":"endOffset"];if(o){if(Ie(o)&&o.parentNode){const e=o;n=(e=>{var t;let o=null===(t=e.parentNode)||void 0===t?void 0:t.firstChild,n=0;for(;o;){if(o===e)return n;Ie(o)&&"bookmark"===o.getAttribute("data-mce-type")||n++,o=o.nextSibling}return-1})(o),o=o.parentNode,oo.remove(e),!o.hasChildNodes()&&oo.isBlock(o)&&o.appendChild(oo.create("br"))}e[t?"startContainer":"endContainer"]=o,e[t?"startOffset":"endOffset"]=n}};t(!0),t();const o=oo.createRng();return o.setStart(e.startContainer,e.startOffset),e.endContainer&&o.setEnd(e.endContainer,e.endOffset),lt(o)},so=e=>{switch(e){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},ao=(e,t)=>{Re.each(t,((t,o)=>{e.setAttribute(o,t)}))},io=(e,t,o)=>{((e,t,o)=>{const n=o["list-style-type"]?o["list-style-type"]:null;e.setStyle(t,"list-style-type",n)})(e,t,o),((e,t,o)=>{ao(t,o["list-attributes"]),Re.each(e.select("li",t),(e=>{ao(e,o["list-item-attributes"])}))})(e,t,o)},lo=(e,t)=>i(t)&&!$e(t,e.schema.getBlockElements()),co=(e,t,o,n)=>{let r=t[o?"startContainer":"endContainer"];const s=t[o?"startOffset":"endOffset"];Ie(r)&&(r=r.childNodes[Math.min(s,r.childNodes.length-1)]||r),!o&&je(r.nextSibling)&&(r=r.nextSibling);const a=(t,o)=>{var r;const s=new Ce(t,(t=>{for(;!e.dom.isBlock(t)&&t.parentNode&&n!==t;)t=t.parentNode;return t})(t)),a=o?"next":"prev";let i;for(;i=s[a]();)if(!qe(e,i)&&!Qt(i.textContent)&&0!==(null===(r=i.textContent)||void 0===r?void 0:r.length))return p.some(i);return p.none()};if(o&&He(r))if(Qt(r.textContent))r=a(r,!1).getOr(r);else for(null!==r.parentNode&&lo(e,r.parentNode)&&(r=r.parentNode);null!==r.previousSibling&&(lo(e,r.previousSibling)||He(r.previousSibling));)r=r.previousSibling;if(!o&&He(r))if(Qt(r.textContent))r=a(r,!0).getOr(r);else for(null!==r.parentNode&&lo(e,r.parentNode)&&(r=r.parentNode);null!==r.nextSibling&&(lo(e,r.nextSibling)||He(r.nextSibling));)r=r.nextSibling;for(;r.parentNode!==n;){const t=r.parentNode;if(We(e,r))return r;if(/^(TD|TH)$/.test(t.nodeName))return r;r=t}return r},mo=(e,t,o)=>{const n=e.selection.getRng();let r="LI";const s=pt(e,((e,t)=>{const o=e.selection.getStart(!0),n=co(e,t,!0,e.getBody());return eo(H.fromDom(n),H.fromDom(t.commonAncestorContainer))?t.commonAncestorContainer:o})(e,n)),a=e.dom;if("false"===a.getContentEditable(e.selection.getNode()))return;"DL"===(t=t.toUpperCase())&&(r="DT");const i=no(n),l=S(((e,t,o)=>{const n=[],r=e.dom,s=co(e,t,!0,o),a=co(e,t,!1,o);let i;const l=[];for(let e=s;e&&(l.push(e),e!==a);e=e.nextSibling);return Re.each(l,(t=>{var s;if(We(e,t))return n.push(t),void(i=null);if(r.isBlock(t)||je(t))return je(t)&&r.remove(t),void(i=null);const a=t.nextSibling;to.isBookmarkNode(t)&&(Pe(a)||We(e,a)||!a&&t.parentNode===o)?i=null:(i||(i=r.create("p"),null===(s=t.parentNode)||void 0===s||s.insertBefore(i,t),n.push(i)),i.appendChild(t))})),n})(e,n,s),e.dom.isEditable);Re.each(l,(n=>{let s;const i=n.previousSibling,l=n.parentNode;Ve(l)||(i&&Pe(i)&&i.nodeName===t&&((e,t,o)=>{const n=e.getStyle(t,"list-style-type");let r=o?o["list-style-type"]:"";return r=null===r?"":r,n===r})(a,i,o)?(s=i,n=a.rename(n,r),i.appendChild(n)):(s=a.create(t),l.insertBefore(s,n),s.appendChild(n),n=a.rename(n,r)),((e,t,o)=>{Re.each(o,(o=>e.setStyle(t,o,"")))})(a,n,["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"]),io(a,s,o),go(e.dom,s))})),e.selection.setRng(ro(i))},uo=(e,t,o)=>{return((e,t)=>Pe(e)&&e.nodeName===(null==t?void 0:t.nodeName))(t,o)&&((e,t,o)=>e.getStyle(t,"list-style-type",!0)===e.getStyle(o,"list-style-type",!0))(e,t,o)&&(n=o,t.className===n.className);var n},go=(e,t)=>{let o,n=t.nextSibling;if(uo(e,t,n)){const r=n;for(;o=r.firstChild;)t.appendChild(o);e.remove(r)}if(n=t.previousSibling,uo(e,t,n)){const r=n;for(;o=r.lastChild;)t.insertBefore(o,t.firstChild);e.remove(r)}},ho=(e,t,o,n)=>{if(t.nodeName!==o){const r=e.dom.rename(t,o);io(e.dom,r,n),_t(e,so(o),r)}else io(e.dom,t,n),_t(e,so(o),t)},po=(e,t,o,n)=>{if(t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),t.nodeName!==o){const r=e.dom.rename(t,o);io(e.dom,r,n),_t(e,so(o),r)}else io(e.dom,t,n),_t(e,so(o),t)},fo=e=>"list-style-type"in e,vo=(e,t,o)=>{const n=mt(e);if(Ct(e,n))return;const s=ut(e),a=r(o)?o:{};s.length>0?((e,t,o,n,r)=>{const s=Pe(t);if(!s||t.nodeName!==n||fo(r)||yt(t)){mo(e,n,r);const a=no(e.selection.getRng()),i=s?[t,...o]:o,l=s&&yt(t)?po:ho;Re.each(i,(t=>{l(e,t,n,r)})),e.selection.setRng(ro(a))}else Jt(e)})(e,n,s,t,a):((e,t,o,n)=>{if(t!==e.getBody())if(t)if(t.nodeName!==o||fo(n)||yt(t)){const r=no(e.selection.getRng());yt(t)&&t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),io(e.dom,t,n);const s=e.dom.rename(t,o);go(e.dom,s),e.selection.setRng(ro(r)),mo(e,o,n),_t(e,so(o),s)}else Jt(e);else mo(e,o,n),_t(e,so(o),t)})(e,n,t,a)},bo=Ne.DOM,yo=(e,t)=>{const o=Re.grep(e.select("ol,ul",t));Re.each(o,(t=>{((e,t)=>{const o=t.parentElement;if(o&&"LI"===o.nodeName&&o.firstChild===t){const n=o.previousSibling;n&&"LI"===n.nodeName?(n.appendChild(t),Ge(e,o)&&bo.remove(o)):bo.setStyle(o,"listStyleType","none")}if(Pe(o)){const e=o.previousSibling;e&&"LI"===e.nodeName&&e.appendChild(t)}})(e,t)}))},wo=(e,t,o,n)=>{let r=t.startContainer;const s=t.startOffset;if(He(r)&&(o?s0))return r;const a=e.schema.getNonEmptyElements();Ie(r)&&(r=xe.getNode(r,s));const i=new Ce(r,n);o&&((e,t)=>!!je(t)&&e.isBlock(t.nextSibling)&&!je(t.previousSibling))(e.dom,r)&&i.next();const l=o?i.next.bind(i):i.prev2.bind(i);for(;r=l();){if("LI"===r.nodeName&&!r.hasChildNodes())return r;if(a[r.nodeName])return r;if(He(r)&&r.data.length>0)return r}return null},xo=(e,t)=>{const o=t.childNodes;return 1===o.length&&!Pe(o[0])&&e.isBlock(o[0])},Co=e=>p.from(e).map(H.fromDom).filter(G).exists((e=>((e,t=!1)=>le(e)?e.dom.isContentEditable:ge(e).fold(m(t),(e=>"true"===he(e))))(e)&&!y(["details"],W(e)))),So=(e,t,o)=>{let n;const r=xo(e,o)?o.firstChild:o;if(((e,t)=>{xo(e,t)&&Co(t.firstChild)&&e.remove(t.firstChild,!0)})(e,t),!Ge(e,t,!0))for(;n=t.firstChild;)r.appendChild(n)},ko=(e,t,o)=>{let n;const r=t.parentNode;if(!Ke(e,t)||!Ke(e,o))return;Pe(o.lastChild)&&(n=o.lastChild),r===o.lastChild&&je(r.previousSibling)&&e.remove(r.previousSibling);const s=o.lastChild;s&&je(s)&&t.hasChildNodes()&&e.remove(s),Ge(e,o,!0)&&ye(H.fromDom(o)),So(e,t,o),n&&o.appendChild(n);const a=((e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)})(H.fromDom(o),H.fromDom(t))?e.getParents(t,Pe,o):[];e.remove(t),C(a,(t=>{Ge(e,t)&&t!==e.getRoot()&&e.remove(t)}))},_o=(e,t,o,n)=>{const r=e.dom;if(r.isEmpty(n))((e,t,o)=>{ye(H.fromDom(o)),ko(e.dom,t,o),e.selection.setCursorLocation(o,0)})(e,o,n);else{const s=no(t);ko(r,o,n),e.selection.setRng(ro(s))}},Eo=(e,t)=>{const o=e.dom,n=e.selection,r=n.getStart(),s=ht(e,r),a=o.getParent(n.getStart(),"LI",s);if(a){const r=a.parentElement;if(r===e.getBody()&&Ge(o,r))return!0;const i=lt(n.getRng()),l=o.getParent(wo(e,i,t,s),"LI",s),c=l&&(t?o.isChildOf(a,l):o.isChildOf(l,a));if(l&&l!==a&&!c)return e.undoManager.transact((()=>{var o,n;t?_o(e,i,l,a):(null===(n=(o=a).parentNode)||void 0===n?void 0:n.firstChild)===o?Xt(e):((e,t,o,n)=>{const r=no(t);ko(e.dom,o,n);const s=ro(r);e.selection.setRng(s)})(e,i,a,l)})),!0;if(c&&!t&&l!==a)return e.undoManager.transact((()=>{if(i.commonAncestorContainer.parentElement){const t=no(i),n=i.commonAncestorContainer.parentElement;So(o,i.commonAncestorContainer.parentElement,l),n.remove();const r=ro(t);e.selection.setRng(r)}})),!0;if(!l&&!t&&0===i.startOffset&&0===i.endOffset)return e.undoManager.transact((()=>{Jt(e)})),!0}return!1},To=(e,t)=>{const o=e.dom,n=e.selection.getStart(),r=ht(e,n),s=o.getParent(n,o.isBlock,r);if(s&&o.isEmpty(s)){const n=lt(e.selection.getRng()),a=o.getParent(wo(e,n,t,r),"LI",r);if(a){const i=e=>y(["td","th","caption"],W(e)),l=e=>e.dom===r;return!!((e,t,o=u)=>B(e,t,o).getOr(e.isNone()&&t.isNone()))(me(H.fromDom(a),i,l),me(H.fromDom(n.startContainer),i,l),P)&&(e.undoManager.transact((()=>{const n=a.parentNode;((e,t,o)=>{const n=e.getParent(t.parentNode,e.isBlock,o);e.remove(t),n&&e.isEmpty(n)&&e.remove(n)})(o,s,r),go(o,n),e.selection.select(a,!0),e.selection.collapse(t)})),!0)}}return!1},Oo=e=>{const t=e.selection.getStart(),o=ht(e,t);return e.dom.getParent(t,"LI,DT,DD",o)||gt(e).length>0},Do=(e,t)=>{const o=e.selection;return!Ct(e,o.getNode())&&(o.isCollapsed()?((e,t)=>Eo(e,t)||To(e,t))(e,t):(e=>!!Oo(e)&&(e.undoManager.transact((()=>{e.execCommand("Delete"),yo(e.dom,e.getBody())})),!0))(e))},Ao=e=>{const t=O(Et(e).split("")),o=x(t,((e,t)=>{const o=e.toUpperCase().charCodeAt(0)-"A".charCodeAt(0)+1;return Math.pow(26,t)*o}));return k(o,((e,t)=>e+t),0)},Mo=e=>{if(--e<0)return"";{const t=e%26,o=Math.floor(e/26);return Mo(o)+String.fromCharCode("A".charCodeAt(0)+t)}},No=e=>{const t=parseInt(e.start,10);return R(e.listStyleType,"upper-alpha")?Mo(t):R(e.listStyleType,"lower-alpha")?Mo(t).toLowerCase():e.start},Ro=e=>{const t=mt(e);ze(t)&&!Ct(e,t)&&e.windowManager.open({title:"List Properties",body:{type:"panel",items:[{type:"input",name:"start",label:"Start list at number",inputMode:"numeric"}]},initialData:{start:No({start:e.dom.getAttrib(t,"start","1"),listStyleType:p.from(e.dom.getStyle(t,"list-style-type"))})},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{(e=>{switch((e=>/^[0-9]+$/.test(e)?2:/^[A-Z]+$/.test(e)?0:(e=>/^[a-z]+$/.test(e))(e)?1:e.length>0?4:3)(e)){case 2:return p.some({listStyleType:p.none(),start:e});case 0:return p.some({listStyleType:p.some("upper-alpha"),start:Ao(e).toString()});case 1:return p.some({listStyleType:p.some("lower-alpha"),start:Ao(e).toString()});case 3:return p.some({listStyleType:p.none(),start:""});case 4:return p.none()}})(t.getData().start).each((t=>{e.execCommand("mceListUpdate",!1,{attrs:{start:"1"===t.start?"":t.start},styles:{"list-style-type":t.listStyleType.getOr("")}})})),t.close()}})},Bo=(e,t)=>()=>{const o=mt(e);return i(o)&&o.nodeName===t},Lo=e=>{e.addCommand("mceListProps",(()=>{Ro(e)}))},Ho=e=>{e.on("BeforeExecCommand",(t=>{const o=t.command.toLowerCase();"indent"===o?Yt(e):"outdent"===o&&Xt(e)})),e.addCommand("InsertUnorderedList",((t,o)=>{vo(e,"UL",o)})),e.addCommand("InsertOrderedList",((t,o)=>{vo(e,"OL",o)})),e.addCommand("InsertDefinitionList",((t,o)=>{vo(e,"DL",o)})),e.addCommand("RemoveList",(()=>{Jt(e)})),Lo(e),e.addCommand("mceListUpdate",((t,o)=>{r(o)&&((e,t)=>{const o=mt(e);null===o||Ct(e,o)||e.undoManager.transact((()=>{r(t.styles)&&e.dom.setStyles(o,t.styles),r(t.attrs)&&Ee(t.attrs,((t,n)=>e.dom.setAttrib(o,n,t)))}))})(e,o)})),e.addQueryStateHandler("InsertUnorderedList",Bo(e,"UL")),e.addQueryStateHandler("InsertOrderedList",Bo(e,"OL")),e.addQueryStateHandler("InsertDefinitionList",Bo(e,"DL"))};var Io=tinymce.util.Tools.resolve("tinymce.html.Node");const Po=e=>3===e.type,Fo=e=>0===e.length,zo=e=>{const t=(t,o)=>{const n=Io.create("li");C(t,(e=>n.append(e))),o?e.insert(n,o,!0):e.append(n)},o=k(e.children(),((e,o)=>Po(o)?[...e,o]:Fo(e)||Po(o)?e:(t(e,o),[])),[]);Fo(o)||t(o)},Vo=e=>{Xe(e)&&(e=>{e.on("keydown",(t=>{t.keyCode!==Se.TAB||Se.metaKeyPressed(t)||e.undoManager.transact((()=>{(t.shiftKey?Xt(e):Yt(e))&&t.preventDefault()}))}))})(e),(e=>{e.on("ExecCommand",(t=>{const o=t.command.toLowerCase();"delete"!==o&&"forwarddelete"!==o||!Oo(e)||yo(e.dom,e.getBody())})),e.on("keydown",(t=>{t.keyCode===Se.BACKSPACE?Do(e,!1)&&t.preventDefault():t.keyCode===Se.DELETE&&Do(e,!0)&&t.preventDefault()}))})(e)},Zo=(e,t)=>o=>(o.setEnabled(e.selection.isEditable()),St(e,(n=>{o.setActive(wt(n.parents,t)),o.setEnabled(!Ct(e,n.element)&&e.selection.isEditable())}))),Uo=(e,t)=>o=>St(e,(n=>o.setEnabled(wt(n.parents,t)&&!Ct(e,n.element))));e.add("lists",(e=>((e=>{(0,e.options.register)("lists_indent_on_tab",{processor:"boolean",default:!0})})(e),(e=>{e.on("PreInit",(()=>{const{parser:t}=e;t.addNodeFilter("ul,ol",(e=>C(e,zo)))}))})(e),e.hasPlugin("rtc",!0)?Lo(e):(Vo(e),Ho(e)),(e=>{const t=t=>()=>e.execCommand(t);e.hasPlugin("advlist")||(e.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:t("InsertOrderedList"),onSetup:Zo(e,"OL")}),e.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:t("InsertUnorderedList"),onSetup:Zo(e,"UL")}))})(e),(e=>{const t={text:"List properties...",icon:"ordered-list",onAction:()=>e.execCommand("mceListProps"),onSetup:Uo(e,"OL")};e.ui.registry.addMenuItem("listprops",t),e.ui.registry.addContextMenu("lists",{update:t=>{const o=mt(e,t);return ze(o)?["listprops"]:[]}})})(e),(e=>({backspaceDelete:t=>{Do(e,t)}}))(e))))}();export{n as default}; +function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,o={exports:{}};t=o,function(){var e=function(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=typeof e;return"object"===t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t},o=function(e){return{eq:e}},n=o((function(e,t){return e===t})),r=function(e){return o((function(t,o){if(t.length!==o.length)return!1;for(var n=t.length,r=0;r{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},d=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&c(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,m=e=>t=>typeof t===e,u=e=>t=>e===t,g=(e,t)=>p(e)&&c(e,t,((e,t)=>l(e)===t)),h=d("string"),p=d("object"),f=e=>g(e,Object),v=d("array"),b=u(null),y=m("boolean"),w=u(void 0),x=e=>null==e,C=e=>!x(e),S=m("function"),k=m("number"),_=(e,t)=>{if(v(e)){for(let o=0,n=e.length;o{},T=(e,t)=>(...o)=>e(t.apply(null,o)),O=(e,t)=>o=>e(t(o)),D=e=>()=>e,A=e=>e,M=(e,t)=>e===t;function N(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const R=e=>t=>!e(t),B=e=>()=>{throw new Error(e)},L=e=>e(),H=e=>{e()},I=D(!1),P=D(!0);class F{constructor(e,t){this.tag=e,this.value=t}static some(e){return new F(!0,e)}static none(){return F.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?F.some(e(this.value)):F.none()}bind(e){return this.tag?e(this.value):F.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:F.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return C(e)?F.some(e):F.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}F.singletonNone=new F(!1);const z=Array.prototype.slice,V=Array.prototype.indexOf,Z=Array.prototype.push,U=(e,t)=>V.call(e,t),j=(e,t)=>U(e,t)>-1,W=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{for(let o=e.length-1;o>=0;o--)t(e[o],o)},K=(e,t)=>{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(G(e,((e,n)=>{o=t(o,e,n)})),o),J=(e,t,o)=>(q(e,((e,n)=>{o=t(o,e,n)})),o),Q=(e,t,o)=>{for(let n=0,r=e.length;nQ(e,t,I),te=(e,t)=>{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;ooe($(e,t)),re=(e,t)=>{for(let o=0,n=e.length;o{const t=z.call(e,0);return t.reverse(),t},ae=(e,t)=>Y(e,(e=>!j(t,e))),ie=(e,t)=>{const o={};for(let n=0,r=e.length;n{const o=z.call(e,0);return o.sort(t),o},ce=(e,t)=>t>=0&&tce(e,0),me=e=>ce(e,e.length-1),ue=S(Array.from)?Array.from:e=>z.call(e),ge=(e,t)=>{for(let o=0;o{const o=he(e);for(let n=0,r=o.length;nbe(e,((e,o)=>({k:o,v:t(e,o)}))),be=(e,t)=>{const o={};return fe(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},ye=e=>(t,o)=>{e[o]=t},we=(e,t,o,n)=>{fe(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},xe=(e,t)=>{const o={};return we(e,t,ye(o),E),o},Ce=(e,t)=>{const o=[];return fe(e,((e,n)=>{o.push(t(e,n))})),o},Se=e=>Ce(e,A),ke=(e,t)=>_e(e,t)?F.from(e[t]):F.none(),_e=(e,t)=>pe.call(e,t),Ee=(e,t)=>_e(e,t)&&void 0!==e[t]&&null!==e[t],Te=e=>{const t={};return q(e,(e=>{t[e]={}})),he(t)},Oe=e=>void 0!==e.length,De=Array.isArray,Ae=(e,t,o)=>{if(!e)return!1;if(o=o||e,Oe(e)){for(let n=0,r=e.length;n{const o=[];return Ae(e,((n,r)=>{o.push(t(n,r,e))})),o},Ne=(e,t)=>{const o=[];return Ae(e,((n,r)=>{t&&!t(n,r,e)||o.push(n)})),o},Re=(e,t,o,n)=>{let r=w(o)?e[0]:o;for(let o=0;o{for(let n=0,r=e.length;ne[e.length-1],He=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Ie=()=>Pe(0,0),Pe=(e,t)=>({major:e,minor:t}),Fe={nu:Pe,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?Ie():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return Pe(n(1),n(2))})(e,o)},unknown:Ie},ze=(e,t)=>{const o=String(t).toLowerCase();return ee(e,(e=>e.search(o)))},Ve=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Ze=(e,t)=>je(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Ue=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!w(n)||r+t.length<=n)},je=(e,t)=>Ve(e,t,0),We=(e,t)=>Ve(e,t,e.length-t.length),$e=e=>t=>t.replace(e,""),qe=$e(/^\s+|\s+$/g),Ge=$e(/^\s+/g),Ke=$e(/\s+$/g),Ye=e=>e.length>0,Xe=e=>!Ye(e),Je=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?F.none():F.some(o)},Qe=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,et=e=>t=>Ue(t,e),tt=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Ue(e,"edge/")&&Ue(e,"chrome")&&Ue(e,"safari")&&Ue(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Qe],search:e=>Ue(e,"chrome")&&!Ue(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Ue(e,"msie")||Ue(e,"trident")},{name:"Opera",versionRegexes:[Qe,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:et("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:et("firefox")},{name:"Safari",versionRegexes:[Qe,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Ue(e,"safari")||Ue(e,"mobile/"))&&Ue(e,"applewebkit")}],ot=[{name:"Windows",search:et("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Ue(e,"iphone")||Ue(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:et("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:et("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:et("linux"),versionRegexes:[]},{name:"Solaris",search:et("sunos"),versionRegexes:[]},{name:"FreeBSD",search:et("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:et("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],nt={browsers:D(tt),oses:D(ot)},rt="Edge",st="Chromium",at="Opera",it="Firefox",lt="Safari",ct=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(rt),isChromium:n(st),isIE:n("IE"),isOpera:n(at),isFirefox:n(it),isSafari:n(lt)}},dt={unknown:()=>ct({current:void 0,version:Fe.unknown()}),nu:ct,edge:D(rt),chromium:D(st),ie:D("IE"),opera:D(at),firefox:D(it),safari:D(lt)},mt="Windows",ut="Android",gt="Linux",ht="macOS",pt="Solaris",ft="FreeBSD",vt="ChromeOS",bt=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(mt),isiOS:n("iOS"),isAndroid:n(ut),isMacOS:n(ht),isLinux:n(gt),isSolaris:n(pt),isFreeBSD:n(ft),isChromeOS:n(vt)}},yt={unknown:()=>bt({current:void 0,version:Fe.unknown()}),nu:bt,windows:D(mt),ios:D("iOS"),android:D(ut),linux:D(gt),macos:D(ht),solaris:D(pt),freebsd:D(ft),chromeos:D(vt)},wt=(e,t,o)=>{const n=nt.browsers(),r=nt.oses(),s=t.bind((e=>((e,t)=>ge(t.brands,(t=>{const o=t.brand.toLowerCase();return ee(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Fe.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>ze(e,t).map((e=>{const o=Fe.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(dt.unknown,dt.nu),a=((e,t)=>ze(e,t).map((e=>{const o=Fe.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(yt.unknown,yt.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:D(r),isiPhone:D(s),isTablet:D(l),isPhone:D(c),isTouch:D(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:D(d),isDesktop:D(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},xt=e=>window.matchMedia(e).matches;let Ct=He((()=>wt(navigator.userAgent,F.from(navigator.userAgentData),xt)));const St=()=>Ct(),kt=navigator.userAgent,_t=St(),Et=_t.browser,Tt=_t.os,Ot=_t.deviceType,Dt=-1!==kt.indexOf("Windows Phone"),At={transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",documentMode:Et.isIE()?document.documentMode||7:10,cacheSuffix:null,container:null,canHaveCSP:!Et.isIE(),windowsPhone:Dt,browser:{current:Et.current,version:Et.version,isChromium:Et.isChromium,isEdge:Et.isEdge,isFirefox:Et.isFirefox,isIE:Et.isIE,isOpera:Et.isOpera,isSafari:Et.isSafari},os:{current:Tt.current,version:Tt.version,isAndroid:Tt.isAndroid,isChromeOS:Tt.isChromeOS,isFreeBSD:Tt.isFreeBSD,isiOS:Tt.isiOS,isLinux:Tt.isLinux,isMacOS:Tt.isMacOS,isSolaris:Tt.isSolaris,isWindows:Tt.isWindows},deviceType:{isDesktop:Ot.isDesktop,isiPad:Ot.isiPad,isiPhone:Ot.isiPhone,isPhone:Ot.isPhone,isTablet:Ot.isTablet,isTouch:Ot.isTouch,isWebView:Ot.isWebView}},Mt=/^\s*|\s*$/g,Nt=e=>x(e)?"":(""+e).replace(Mt,""),Rt=function(e,t,o,n){n=n||this,e&&(o&&(e=e[o]),Ae(e,((e,r)=>!1!==t.call(n,e,r,o)&&(Rt(e,t,o,n),!0))))},Bt={trim:Nt,isArray:De,is:(e,t)=>t?!("array"!==t||!De(e))||typeof e===t:void 0!==e,toArray:e=>{if(De(e))return e;{const t=[];for(let o=0,n=e.length;o{const n=h(e)?e.split(t||","):e||[];let r=n.length;for(;r--;)o[n[r]]={};return o},each:Ae,map:Me,grep:Ne,inArray:(e,t)=>{if(e)for(let o=0,n=e.length;o{for(let o=0;o{const o=e.split(".");for(let e=0,n=o.length;ev(e)?e:""===e?[]:Me(e.split(t||","),Nt),_addCacheSuffix:e=>{const t=At.cacheSuffix;return t&&(e+=(-1===e.indexOf("?")?"?":"&")+t),e}},Lt=(e,t,o=M)=>e.exists((e=>o(e,t))),Ht=(e,t,o=M)=>It(e,t,o).getOr(e.isNone()&&t.isNone()),It=(e,t,o)=>e.isSome()&&t.isSome()?F.some(o(e.getOrDie(),t.getOrDie())):F.none(),Pt=(e,t)=>e?F.some(t):F.none(),Ft="undefined"!=typeof window?window:Function("return this;")(),zt=(e,t)=>((e,t)=>{let o=null!=t?t:Ft;for(let t=0;t{const o=((e,t)=>zt(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},Zt=Object.getPrototypeOf,Ut=e=>{const t=zt("ownerDocument.defaultView",e);return p(e)&&((e=>Vt("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Zt(e).constructor.name))},jt=e=>e.dom.nodeName.toLowerCase(),Wt=e=>e.dom.nodeType,$t=e=>t=>Wt(t)===e,qt=e=>Gt(e)&&Ut(e.dom),Gt=$t(1),Kt=$t(3),Yt=$t(9),Xt=$t(11),Jt=e=>t=>Gt(t)&&jt(t)===e,Qt=(e,t,o)=>{if(!(h(o)||y(o)||k(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},eo=(e,t,o)=>{Qt(e.dom,t,o)},to=(e,t)=>{const o=e.dom;fe(t,((e,t)=>{Qt(o,t,e)}))},oo=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},no=(e,t)=>F.from(oo(e,t)),ro=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},so=(e,t)=>{e.dom.removeAttribute(t)},ao=e=>J(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),io=(e,t)=>{const o=oo(e,t);return void 0===o||""===o?[]:o.split(" ")},lo=e=>void 0!==e.dom.classList,co=e=>io(e,"class"),mo=(e,t)=>((e,t,o)=>{const n=io(e,t).concat([o]);return eo(e,t,n.join(" ")),!0})(e,"class",t),uo=(e,t)=>((e,t,o)=>{const n=Y(io(e,t),(e=>e!==o));return n.length>0?eo(e,t,n.join(" ")):so(e,t),!1})(e,"class",t),go=(e,t)=>{lo(e)?e.dom.classList.add(t):mo(e,t)},ho=e=>{0===(lo(e)?e.dom.classList:co(e)).length&&so(e,"class")},po=(e,t)=>{lo(e)?e.dom.classList.remove(t):uo(e,t),ho(e)},fo=(e,t)=>{const o=lo(e)?e.dom.classList.toggle(t):((e,t)=>j(co(e),t)?uo(e,t):mo(e,t))(e,t);return ho(e),o},vo=(e,t)=>lo(e)&&e.dom.classList.contains(t),bo=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},yo={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return bo(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return bo(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return bo(o)},fromDom:bo,fromPoint:(e,t,o)=>F.from(e.dom.elementFromPoint(t,o)).map(bo)},wo=(e,t)=>{const o=[],n=e=>(o.push(e),t(e));let r=t(e);do{r=r.bind(n)}while(r.isSome());return o},xo=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Co=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,So=(e,t)=>e.dom===t.dom,ko=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},_o=e=>yo.fromDom(e.dom.ownerDocument),Eo=e=>Yt(e)?e:_o(e),To=e=>yo.fromDom(Eo(e).dom.defaultView),Oo=e=>F.from(e.dom.parentNode).map(yo.fromDom),Do=e=>F.from(e.dom.parentElement).map(yo.fromDom),Ao=(e,t)=>{const o=S(t)?t:I;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=yo.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Mo=e=>F.from(e.dom.previousSibling).map(yo.fromDom),No=e=>F.from(e.dom.nextSibling).map(yo.fromDom),Ro=e=>se(wo(e,Mo)),Bo=e=>wo(e,No),Lo=e=>$(e.dom.childNodes,yo.fromDom),Ho=(e,t)=>{const o=e.dom.childNodes;return F.from(o[t]).map(yo.fromDom)},Io=e=>Ho(e,0),Po=e=>Ho(e,e.dom.childNodes.length-1),Fo=e=>e.dom.childNodes.length,zo=e=>Xt(e)&&C(e.dom.host),Vo=S(Element.prototype.attachShadow)&&S(Node.prototype.getRootNode),Zo=D(Vo),Uo=Vo?e=>yo.fromDom(e.dom.getRootNode()):Eo,jo=e=>zo(e)?e:(e=>{const t=e.dom.head;if(null==t)throw new Error("Head is not available yet");return yo.fromDom(t)})(Eo(e)),Wo=e=>yo.fromDom(e.dom.host),$o=e=>{if(Zo()&&C(e.target)){const t=yo.fromDom(e.target);if(Gt(t)&&qo(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return de(t)}}return F.from(e.target)},qo=e=>C(e.dom.shadowRoot),Go=e=>{const t=Kt(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=Uo(e);return zo(t)?F.some(t):F.none()})(yo.fromDom(t)).fold((()=>o.body.contains(t)),O(Go,Wo))};var Ko=(e,t,o,n,r)=>e(o,n)?F.some(o):S(r)&&r(o)?F.none():t(o,n,r);const Yo=(e,t,o)=>{let n=e.dom;const r=S(o)?o:I;for(;n.parentNode;){n=n.parentNode;const e=yo.fromDom(n);if(t(e))return F.some(e);if(r(e))break}return F.none()},Xo=(e,t,o)=>Ko(((e,t)=>t(e)),Yo,e,t,o),Jo=(e,t)=>ee(e.dom.childNodes,(e=>t(yo.fromDom(e)))).map(yo.fromDom),Qo=(e,t)=>{const o=e=>{for(let n=0;nYo(e,(e=>xo(e,t)),o),tn=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Co(o)?F.none():F.from(o.querySelector(e)).map(yo.fromDom)})(t,e),on=(e,t,o)=>Ko(((e,t)=>xo(e,t)),en,e,t,o),nn=(e,t=!1)=>{return Go(e)?e.dom.isContentEditable:(o=e,on(o,"[contenteditable]")).fold(D(t),(e=>"true"===rn(e)));var o},rn=e=>e.dom.contentEditable,sn=e=>void 0!==e.style&&S(e.style.getPropertyValue),an=(e,t,o)=>{if(!h(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);sn(e)&&e.style.setProperty(t,o)},ln=(e,t,o)=>{const n=e.dom;an(n,t,o)},cn=(e,t)=>{const o=e.dom;fe(t,((e,t)=>{an(o,t,e)}))},dn=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||Go(e)?n:mn(o,t)},mn=(e,t)=>sn(e)?e.style.getPropertyValue(t):"",un=(e,t)=>{const o=e.dom,n=mn(o,t);return F.from(n).filter((e=>e.length>0))},gn=e=>{const t={},o=e.dom;if(sn(o))for(let e=0;e{((e,t)=>{sn(e)&&e.style.removeProperty(t)})(e.dom,t),Lt(no(e,"style").map(qe),"")&&so(e,"style")},pn=(e,t)=>{Oo(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},fn=(e,t)=>{No(e).fold((()=>{Oo(e).each((e=>{bn(e,t)}))}),(e=>{pn(e,t)}))},vn=(e,t)=>{Io(e).fold((()=>{bn(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},bn=(e,t)=>{e.dom.appendChild(t.dom)},yn=(e,t)=>{pn(e,t),bn(t,e)},wn=(e,t)=>{q(t,(t=>{bn(e,t)}))},xn=e=>{e.dom.textContent="",q(Lo(e),(e=>{Cn(e)}))},Cn=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Sn=e=>{const t=Lo(e);var o,n;t.length>0&&(o=e,q(n=t,((e,t)=>{const r=0===t?o:n[t-1];fn(r,e)}))),Cn(e)},kn=e=>$(e,yo.fromDom),_n=e=>e.dom.innerHTML,En=(e,t)=>{const o=_o(e).dom,n=yo.fromDom(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Lo(yo.fromDom(o))})(t,o);wn(n,r),xn(e),bn(e,n)},Tn=(e,t)=>o=>{e(o)&&t((e=>{const t=yo.fromDom($o(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=T(n,o);return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)})(o))},On=(e,t,o,n)=>((e,t,o,n,r)=>{const s=Tn(o,n);return e.dom.addEventListener(t,s,r),{unbind:N(Dn,e,t,s,r)}})(e,t,o,n,!1),Dn=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},An=(e,t)=>({left:e,top:t,translate:(o,n)=>An(e+o,t+n)}),Mn=An,Nn=(e,t)=>void 0!==e?e:void 0!==t?t:0,Rn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?Mn(o.offsetLeft,o.offsetTop):Go(e)?(e=>{const t=e.getBoundingClientRect();return Mn(t.left,t.top)})(t):Mn(0,0)},Bn=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return Mn(o,n)},Ln=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Hn=(e,t)=>{St().browser.isSafari()&&S(e.dom.scrollIntoViewIfNeeded)?e.dom.scrollIntoViewIfNeeded(!1):e.dom.scrollIntoView(t)},In=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Pn=e=>{const t=void 0===e?window:e,o=t.document,n=Bn(yo.fromDom(o));return(e=>{const t=void 0===e?window:e;return St().browser.isFirefox()?F.none():F.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return In(n.left,n.top,o,r)}),(e=>In(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Fn=(e,t)=>{let o=[];return q(Lo(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(Fn(e,t))})),o},zn=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Co(o)?[]:$(o.querySelectorAll(e),yo.fromDom)})(t,e),Vn=(e,t,o)=>en(e,t,o).isSome();class Zn{constructor(e,t){this.node=e,this.rootNode=t,this.current=this.current.bind(this),this.next=this.next.bind(this),this.prev=this.prev.bind(this),this.prev2=this.prev2.bind(this)}current(){return this.node}next(e){return this.node=this.findSibling(this.node,"firstChild","nextSibling",e),this.node}prev(e){return this.node=this.findSibling(this.node,"lastChild","previousSibling",e),this.node}prev2(e){return this.node=this.findPreviousNode(this.node,e),this.node}findSibling(e,t,o,n){if(e){if(!n&&e[t])return e[t];if(e!==this.rootNode){let t=e[o];if(t)return t;for(let n=e.parentNode;n&&n!==this.rootNode;n=n.parentNode)if(t=n[o],t)return t}}}findPreviousNode(e,t){if(e){const o=e.previousSibling;if(this.rootNode&&o===this.rootNode)return;if(o){if(!t)for(let e=o.lastChild;e;e=e.lastChild)if(!e.lastChild)return e;return o}const n=e.parentNode;if(n&&n!==this.rootNode)return n}}}const Un=e=>t=>!!t&&t.nodeType===e,jn=e=>!!e&&!Object.getPrototypeOf(e),Wn=Un(1),$n=e=>Wn(e)&&qt(yo.fromDom(e)),qn=e=>{const t=e.toLowerCase();return e=>C(e)&&e.nodeName.toLowerCase()===t},Gn=e=>{const t=e.map((e=>e.toLowerCase()));return e=>{if(e&&e.nodeName){const o=e.nodeName.toLowerCase();return j(t,o)}return!1}},Kn=(e,t)=>{const o=t.toLowerCase().split(" ");return t=>{if(Wn(t)){const n=t.ownerDocument.defaultView;if(n)for(let r=0;rt=>Wn(t)&&t.hasAttribute(e),Xn=e=>Wn(e)&&e.hasAttribute("data-mce-bogus"),Jn=e=>Wn(e)&&"TABLE"===e.tagName,Qn=e=>t=>{if($n(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},er=Gn(["textarea","input"]),tr=Un(3),or=Un(4),nr=Un(7),rr=Un(8),sr=Un(9),ar=Un(11),ir=qn("br"),lr=qn("img"),cr=Qn("true"),dr=Qn("false"),mr=Gn(["td","th"]),ur=Gn(["td","th","caption"]),gr=Gn(["video","audio","object","embed"]),hr=qn("li"),pr=qn("details"),fr=qn("summary"),vr="\ufeff",br=" ",yr=e=>e===vr,wr=((e,t)=>{const o=t=>e(t)?F.from(t.dom.nodeValue):F.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(Kt,"text"),xr=e=>wr.get(e),Cr=e=>wr.getOption(e),Sr=e=>{let t;return o=>(t=t||ie(e,P),_e(t,jt(o)))},kr=e=>Gt(e)&&"br"===jt(e),_r=Sr(["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"]),Er=Sr(["ul","ol","dl"]),Tr=Sr(["li","dd","dt"]),Or=Sr(["thead","tbody","tfoot"]),Dr=Sr(["td","th"]),Ar=Sr(["pre","script","textarea","style"]),Mr=e=>{const t=zn(e,"br"),o=Y((e=>{const t=[];let o=e.dom;for(;o;)t.push(yo.fromDom(o)),o=o.lastChild;return t})(e).slice(-1),kr);t.length===o.length&&q(o,Cn)},Nr=()=>{const e=yo.fromTag("br");return eo(e,"data-mce-bogus","1"),e},Rr=e=>{xn(e),bn(e,Nr())},Br=vr,Lr=yr,Hr=e=>e.replace(/\uFEFF/g,""),Ir=Wn,Pr=tr,Fr=e=>(Pr(e)&&(e=e.parentNode),Ir(e)&&e.hasAttribute("data-mce-caret")),zr=e=>Pr(e)&&Lr(e.data),Vr=e=>Fr(e)||zr(e),Zr=e=>e.firstChild!==e.lastChild||!ir(e.firstChild),Ur=e=>{const t=e.container();return!!tr(t)&&(t.data.charAt(e.offset())===Br||e.isAtStart()&&zr(t.previousSibling))},jr=e=>{const t=e.container();return!!tr(t)&&(t.data.charAt(e.offset()-1)===Br||e.isAtEnd()&&zr(t.nextSibling))},Wr=e=>Pr(e)&&e.data[0]===Br,$r=e=>Pr(e)&&e.data[e.data.length-1]===Br,qr=e=>e&&e.hasAttribute("data-mce-caret")?((e=>{var t;const o=e.getElementsByTagName("br"),n=o[o.length-1];Xn(n)&&(null===(t=n.parentNode)||void 0===t||t.removeChild(n))})(e),e.removeAttribute("data-mce-caret"),e.removeAttribute("data-mce-bogus"),e.removeAttribute("style"),e.removeAttribute("data-mce-style"),e.removeAttribute("_moz_abspos"),e):null,Gr=e=>Fr(e.startContainer),Kr=cr,Yr=dr,Xr=ir,Jr=tr,Qr=Gn(["script","style","textarea"]),es=Gn(["img","input","textarea","hr","iframe","video","audio","object","embed"]),ts=Gn(["table"]),os=Vr,ns=e=>!os(e)&&(Jr(e)?!Qr(e.parentNode):es(e)||Xr(e)||ts(e)||rs(e)),rs=e=>!(e=>Wn(e)&&"true"===e.getAttribute("unselectable"))(e)&&Yr(e),ss=(e,t)=>ns(e)&&((e,t)=>{for(let o=e.parentNode;o&&o!==t;o=o.parentNode){if(rs(o))return!1;if(Kr(o))return!0}return!0})(e,t),as=/^[ \t\r\n]*$/,is=e=>as.test(e),ls=e=>{for(const t of e)if(!yr(t))return!1;return!0},cs=e=>"\n"===e||"\r"===e,ds=(e,t=4,o=!0,n=!0)=>{const r=((e,t)=>t<=0?"":new Array(t+1).join(e))(" ",t),s=e.replace(/\t/g,r),a=J(s,((e,t)=>(e=>-1!==" \f\t\v".indexOf(e))(t)||t===br?e.pcIsSpace||""===e.str&&o||e.str.length===s.length-1&&n||((e,t)=>t=0&&cs(e[t]))(s,e.str.length+1)?{pcIsSpace:!1,str:e.str+br}:{pcIsSpace:!0,str:e.str+" "}:{pcIsSpace:cs(t),str:e.str+t}),{pcIsSpace:!1,str:""});return a.str},ms=(e,t)=>tr(e)&&is(e.data)&&!((e,t)=>{const o=yo.fromDom(t),n=yo.fromDom(e);return Vn(n,"pre,code",N(So,o))})(e,t),us=(e,t)=>ns(e)&&!ms(e,t)||(e=>Wn(e)&&"A"===e.nodeName&&!e.hasAttribute("href")&&(e.hasAttribute("name")||e.hasAttribute("id")))(e)||gs(e),gs=Yn("data-mce-bookmark"),hs=Yn("data-mce-bogus"),ps=(fs="data-mce-bogus",vs="all",e=>Wn(e)&&e.getAttribute(fs)===vs);var fs,vs;const bs=e=>Do(yo.fromDom(e)).exists((e=>!nn(e))),ys=(e,t=!0)=>((e,t)=>{let o=0;if(us(e,e))return!1;{let n=e.firstChild;if(!n)return!0;const r=new Zn(n,e);do{if(t){if(ps(n)){n=r.next(!0);continue}if(hs(n)){n=r.next();continue}}if(cr(n)&&bs(n))return!1;if(ir(n))o++,n=r.next();else{if(us(n,e))return!1;n=r.next()}}while(n);return o<=1}})(e.dom,t),ws=e=>"svg"===e.toLowerCase(),xs=e=>ws(e.nodeName),Cs=e=>"svg"===(null==e?void 0:e.nodeName)?"svg":"html",Ss=["svg"],ks="data-mce-block",_s=e=>$((e=>Y(he(e),(e=>!/[A-Z]/.test(e))))(e),(e=>`${e}:`+$(Ss,(t=>`not(${t} ${e})`)).join(":"))).join(","),Es=(e,t)=>C(t.querySelector(e))?(t.setAttribute(ks,"true"),"inline-boundary"===t.getAttribute("data-mce-selected")&&t.removeAttribute("data-mce-selected"),!0):(t.removeAttribute(ks),!1),Ts=(e,t)=>{const o=_s(e.getTransparentElements()),n=_s(e.getBlockElements());return Y(t.querySelectorAll(o),(e=>Es(n,e)))},Os=(e,t)=>{var o;const n=t?"lastChild":"firstChild";for(let t=e[n];t;t=t[n])if(ys(yo.fromDom(t)))return void(null===(o=t.parentNode)||void 0===o||o.removeChild(t))},Ds=(e,t,o)=>{const n=e.getBlockElements(),r=yo.fromDom(t),s=e=>jt(e)in n,a=e=>So(e,r);q(kn(o),(t=>{Yo(t,s,a).each((o=>{const n=((e,t)=>Y(Lo(e),t))(t,(t=>s(t)&&!e.isValidChild(jt(o),jt(t))));if(n.length>0){const t=Do(o);q(n,(e=>{Yo(e,s,a).each((t=>{((e,t)=>{const o=document.createRange(),n=e.parentNode;if(n){o.setStartBefore(e),o.setEndBefore(t);const r=o.extractContents();Os(r,!0),o.setStartAfter(t),o.setEndAfter(e);const s=o.extractContents();Os(s,!1),ys(yo.fromDom(r))||n.insertBefore(r,e),ys(yo.fromDom(t))||n.insertBefore(t,e),ys(yo.fromDom(s))||n.insertBefore(s,e),n.removeChild(e)}})(t.dom,e.dom)}))})),t.each((t=>Ts(e,t.dom)))}}))}))},As=(e,t)=>{const o=Ts(e,t);Ds(e,t,o),((e,t,o)=>{q([...o,...Ls(e,t)?[t]:[]],(t=>q(zn(yo.fromDom(t),t.nodeName.toLowerCase()),(t=>{Hs(e,t.dom)&&Sn(t)}))))})(e,t,o)},Ms=(e,t)=>{if(Bs(e,t)){const o=_s(e.getBlockElements());Es(o,t)}},Ns=e=>e.hasAttribute(ks),Rs=(e,t)=>_e(e.getTransparentElements(),t),Bs=(e,t)=>Wn(t)&&Rs(e,t.nodeName),Ls=(e,t)=>Bs(e,t)&&Ns(t),Hs=(e,t)=>Bs(e,t)&&!Ns(t),Is=(e,t)=>1===t.type&&Rs(e,t.name)&&h(t.attr(ks)),Ps=St().browser,Fs=e=>ee(e,Gt),zs=(e,t)=>e.children&&j(e.children,t),Vs=(e,t,o)=>{let n=0,r=0;const s=e.ownerDocument;if(o=o||e,t){if(o===e&&t.getBoundingClientRect&&"static"===dn(yo.fromDom(e),"position")){const o=t.getBoundingClientRect();return n=o.left+(s.documentElement.scrollLeft||e.scrollLeft)-s.documentElement.clientLeft,r=o.top+(s.documentElement.scrollTop||e.scrollTop)-s.documentElement.clientTop,{x:n,y:r}}let a=t;for(;a&&a!==o&&a.nodeType&&!zs(a,o);){const e=a;n+=e.offsetLeft||0,r+=e.offsetTop||0,a=e.offsetParent}for(a=t.parentNode;a&&a!==o&&a.nodeType&&!zs(a,o);)n-=a.scrollLeft||0,r-=a.scrollTop||0,a=a.parentNode;r+=(e=>Ps.isFirefox()&&"table"===jt(e)?Fs(Lo(e)).filter((e=>"caption"===jt(e))).bind((e=>Fs(Bo(e)).map((t=>{const o=t.dom.offsetTop,n=e.dom.offsetTop,r=e.dom.offsetHeight;return o<=n?-r:0})))).getOr(0):0)(yo.fromDom(t))}return{x:n,y:r}},Zs=(e,t={})=>{let o=0;const n={},r=yo.fromDom(e),s=Eo(r),a=e=>{bn(jo(r),e)},i=e=>{const t=jo(r);tn(t,"#"+e).each(Cn)},l=e=>ke(n,e).getOrThunk((()=>({id:"mce-u"+o++,passed:[],failed:[],count:0}))),c=e=>new Promise(((o,r)=>{let i;const c=Bt._addCacheSuffix(e),d=l(c);n[c]=d,d.count++;const m=(e,t)=>{q(e,H),d.status=t,d.passed=[],d.failed=[],i&&(i.onload=null,i.onerror=null,i=null)},u=()=>m(d.passed,2),g=()=>m(d.failed,3);if(o&&d.passed.push(o),r&&d.failed.push(r),1===d.status)return;if(2===d.status)return void u();if(3===d.status)return void g();d.status=1;const h=yo.fromTag("link",s.dom);to(h,{rel:"stylesheet",type:"text/css",id:d.id}),t.contentCssCors&&eo(h,"crossOrigin","anonymous"),t.referrerPolicy&&eo(h,"referrerpolicy",t.referrerPolicy),i=h.dom,i.onload=u,i.onerror=g,a(h),eo(h,"href",c)})),d=e=>{const t=Bt._addCacheSuffix(e);ke(n,t).each((e=>{0==--e.count&&(delete n[t],i(e.id))}))};return{load:c,loadRawCss:(e,t)=>{const o=l(e);n[e]=o,o.count++;const r=yo.fromTag("style",s.dom);to(r,{rel:"stylesheet",type:"text/css",id:o.id}),r.dom.innerHTML=t,a(r)},loadAll:e=>Promise.allSettled($(e,(e=>c(e).then(D(e))))).then((e=>{const t=K(e,(e=>"fulfilled"===e.status));return t.fail.length>0?Promise.reject($(t.fail,(e=>e.reason))):$(t.pass,(e=>e.value))})),unload:d,unloadRawCss:e=>{ke(n,e).each((t=>{0==--t.count&&(delete n[e],i(t.id))}))},unloadAll:e=>{q(e,(e=>{d(e)}))},_setReferrerPolicy:e=>{t.referrerPolicy=e},_setContentCssCors:e=>{t.contentCssCors=e}}},Us=(()=>{const e=new WeakMap;return{forElement:(t,o)=>{const n=Uo(t).dom;return F.from(e.get(n)).getOrThunk((()=>{const t=Zs(n,o);return e.set(n,t),t}))}}})(),js=(e,t,o)=>C(e)&&(us(e,t)||o.isInline(e.nodeName.toLowerCase())),Ws=e=>(e=>"span"===e.nodeName.toLowerCase())(e)&&"bookmark"===e.getAttribute("data-mce-type"),$s=(e,t,o)=>tr(e)&&e.data.length>0&&((e,t,o)=>{const n=new Zn(e,t).prev(!1),r=new Zn(e,t).next(!1),s=w(n)||js(n,t,o),a=w(r)||js(r,t,o);return s&&a})(e,t,o),qs=(e,t,o,n)=>{var r;const s=n||t;if(Wn(t)&&Ws(t))return t;const a=t.childNodes;for(let t=a.length-1;t>=0;t--)qs(e,a[t],o,s);if(Wn(t)){const e=t.childNodes;1===e.length&&Ws(e[0])&&(null===(r=t.parentNode)||void 0===r||r.insertBefore(e[0],t))}return(e=>ar(e)||sr(e))(t)||us(t,s)||(e=>!!Wn(e)&&e.childNodes.length>0)(t)||$s(t,s,o)||e.remove(t),t},Gs=Bt.makeMap,Ks=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ys=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Xs=/[<>&\"\']/g,Js=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,Qs={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"},ea={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},ta={"<":"<",">":">","&":"&",""":'"',"'":"'"},oa=(e,t)=>{const o={};if(e){const n=e.split(",");t=t||10;for(let e=0;ee.replace(t?Ks:Ys,(e=>ea[e]||e)),sa=(e,t)=>e.replace(t?Ks:Ys,(e=>e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":ea[e]||"&#"+e.charCodeAt(0)+";")),aa=(e,t,o)=>{const n=o||na;return e.replace(t?Ks:Ys,(e=>ea[e]||n[e]||e))},ia={encodeRaw:ra,encodeAllRaw:e=>(""+e).replace(Xs,(e=>ea[e]||e)),encodeNumeric:sa,encodeNamed:aa,getEncodeFunc:(e,t)=>{const o=oa(t)||na,n=(e,t)=>e.replace(t?Ks:Ys,(e=>void 0!==ea[e]?ea[e]:void 0!==o[e]?o[e]:e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":"&#"+e.charCodeAt(0)+";")),r=(e,t)=>aa(e,t,o),s=Gs(e.replace(/\+/g,","));return s.named&&s.numeric?n:s.named?t?r:aa:s.numeric?sa:ra},decode:e=>e.replace(Js,((e,t)=>t?(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10))>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):Qs[t]||String.fromCharCode(t):ta[e]||na[e]||(e=>{const t=yo.fromTag("div").dom;return t.innerHTML=e,t.textContent||t.innerText||e})(e)))},la=(e,t)=>(e=Bt.trim(e))?e.split(t||" "):[],ca=e=>new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$"),da=(e,t)=>{const o=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)])?$/;return ne(la(t,","),(t=>{const n=o.exec(t);if(n){const t=n[1],o=n[2],r=n[3],s=n[4],a=n[5],i={attributes:{},attributesOrder:[]};if(e.each((e=>((e,t)=>{fe(e.attributes,((e,o)=>{t.attributes[o]=e})),t.attributesOrder.push(...e.attributesOrder)})(e,i))),"#"===t?i.paddEmpty=!0:"-"===t&&(i.removeEmpty=!0),"!"===s&&(i.removeEmptyAttrs=!0),a&&((e,t)=>{const o=/^([!\-])?(\w+[\\:]:\w+|[^=~<]+)?(?:([=~<])(.*))?$/,n=/[*?+]/,{attributes:r,attributesOrder:s}=t;q(la(e,"|"),(e=>{const a=o.exec(e);if(a){const e={},o=a[1],i=a[2].replace(/[\\:]:/g,":"),l=a[3],c=a[4];if("!"===o&&(t.attributesRequired=t.attributesRequired||[],t.attributesRequired.push(i),e.required=!0),"-"===o)return delete r[i],void s.splice(Bt.inArray(s,i),1);if(l&&("="===l?(t.attributesDefault=t.attributesDefault||[],t.attributesDefault.push({name:i,value:c}),e.defaultValue=c):"~"===l?(t.attributesForced=t.attributesForced||[],t.attributesForced.push({name:i,value:c}),e.forcedValue=c):"<"===l&&(e.validValues=Bt.makeMap(c,"?"))),n.test(i)){const o=e;t.attributePatterns=t.attributePatterns||[],o.pattern=ca(i),t.attributePatterns.push(o)}else r[i]||s.push(i),r[i]=e}}))})(a,i),r&&(i.outputName=o),"@"===o){if(!e.isNone())return[];e=F.some(i)}return[r?{name:o,element:i,aliasName:r}:{name:o,element:i}]}return[]}))},ma={},ua=Bt.makeMap,ga=Bt.each,ha=Bt.extend,pa=Bt.explode,fa=(e,t={})=>{const o=ua(e," ",ua(e.toUpperCase()," "));return ha(o,t)},va=e=>fa("td th li dt dd figcaption caption details summary",e.getTextBlockElements()),ba=(e,t)=>{if(e){const o={};return h(e)&&(e={"*":e}),ga(e,((e,n)=>{o[n]=o[n.toUpperCase()]="map"===t?ua(e,/[, ]/):pa(e,/[, ]/)})),o}},ya=(e={})=>{var t;const o={},n={};let r=[];const s={},a={},i=(t,o,n)=>{const r=e[t];if(r)return ua(r,/[, ]/,ua(r.toUpperCase(),/[, ]/));{let e=ma[t];return e||(e=fa(o,n),ma[t]=e),e}},l=null!==(t=e.schema)&&void 0!==t?t:"html5",c=(e=>{const{globalAttributes:t,phrasingContent:o,flowContent:n}=(e=>{let t,o,n;t="id accesskey class dir lang style tabindex title role",o="address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul",n="a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment","html4"!==e&&(t+=" contenteditable contextmenu draggable dropzone hidden spellcheck translate",o+=" article aside details dialog figure main header footer hgroup section nav a ins del canvas map",n+=" audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen svg"),"html5-strict"!==e&&(t+=" xml:lang",n=[n,"acronym applet basefont big font strike tt"].join(" "),o=[o,"center dir isindex noframes"].join(" "));const r=[o,n].join(" ");return{globalAttributes:t,blockContent:o,phrasingContent:n,flowContent:r}})(e),r={},s=(e,t,o)=>{r[e]={attributes:ie(t,D({})),attributesOrder:t,children:ie(o,D({}))}},a=(e,o="",n="")=>{const r=la(n),a=la(e);let i=a.length;const l=la([t,o].join(" "));for(;i--;)s(a[i],l.slice(),r)},i=(e,t)=>{const o=la(e),n=la(t);let s=o.length;for(;s--;){const e=r[o[s]];for(let t=0,o=n.length;t{a(e,"",o)})),q(la("center dir isindex noframes"),(e=>{a(e,"",n)}))),a("html","manifest","head body"),a("head","","base command link meta noscript script style title"),a("title hr noscript br"),a("base","href target"),a("link","href rel media hreflang type sizes hreflang"),a("meta","name http-equiv content charset"),a("style","media type scoped"),a("script","src async defer type charset"),a("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",n),a("dd div","",n),a("address dt caption","","html4"===e?o:n),a("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",o),a("blockquote","cite",n),a("ol","reversed start type","li"),a("ul","","li"),a("li","value",n),a("dl","","dt dd"),a("a","href target rel media hreflang type","html4"===e?o:n),a("q","cite",o),a("ins del","cite datetime",n),a("img","src sizes srcset alt usemap ismap width height"),a("iframe","src name width height",n),a("embed","src type width height"),a("object","data type typemustmatch name usemap form width height",[n,"param"].join(" ")),a("param","name value"),a("map","name",[n,"area"].join(" ")),a("area","alt coords shape href target rel media hreflang type"),a("table","border","caption colgroup thead tfoot tbody tr"+("html4"===e?" col":"")),a("colgroup","span","col"),a("col","span"),a("tbody thead tfoot","","tr"),a("tr","","td th"),a("td","colspan rowspan headers",n),a("th","colspan rowspan headers scope abbr",n),a("form","accept-charset action autocomplete enctype method name novalidate target",n),a("fieldset","disabled form name",[n,"legend"].join(" ")),a("label","form for",o),a("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),a("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"===e?n:o),a("select","disabled form multiple name required size","option optgroup"),a("optgroup","disabled label","option"),a("option","disabled label selected value"),a("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),a("menu","type label",[n,"li"].join(" ")),a("noscript","",n),"html4"!==e&&(a("wbr"),a("ruby","",[o,"rt rp"].join(" ")),a("figcaption","",n),a("mark rt rp bdi","",o),a("summary","",[o,"h1 h2 h3 h4 h5 h6"].join(" ")),a("canvas","width height",n),a("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",[n,"track source"].join(" ")),a("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",[n,"track source"].join(" ")),a("picture","","img source"),a("source","src srcset type media sizes"),a("track","kind src srclang label default"),a("datalist","",[o,"option"].join(" ")),a("article section nav aside main header footer","",n),a("hgroup","","h1 h2 h3 h4 h5 h6"),a("figure","",[n,"figcaption"].join(" ")),a("time","datetime",o),a("dialog","open",n),a("command","type label icon disabled checked radiogroup command"),a("output","for form name",o),a("progress","value max",o),a("meter","value min max low high optimum",o),a("details","open",[n,"summary"].join(" ")),a("keygen","autofocus challenge disabled form keytype name"),s("svg","id tabindex lang xml:space class style x y width height viewBox preserveAspectRatio zoomAndPan transform".split(" "),[])),"html5-strict"!==e&&(i("script","language xml:space"),i("style","xml:space"),i("object","declare classid code codebase codetype archive standby align border hspace vspace"),i("embed","align name hspace vspace"),i("param","valuetype type"),i("a","charset name rev shape coords"),i("br","clear"),i("applet","codebase archive code object alt name width height align hspace vspace"),i("img","name longdesc align border hspace vspace"),i("iframe","longdesc frameborder marginwidth marginheight scrolling align"),i("font basefont","size color face"),i("input","usemap align"),i("select"),i("textarea"),i("h1 h2 h3 h4 h5 h6 div p legend caption","align"),i("ul","type compact"),i("li","type"),i("ol dl menu dir","compact"),i("pre","width xml:space"),i("hr","align noshade size width"),i("isindex","prompt"),i("table","summary width frame rules cellspacing cellpadding align bgcolor"),i("col","width align char charoff valign"),i("colgroup","width align char charoff valign"),i("thead","align char charoff valign"),i("tr","align char charoff valign bgcolor"),i("th","axis align char charoff valign nowrap bgcolor width height"),i("form","accept"),i("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),i("tfoot","align char charoff valign"),i("tbody","align char charoff valign"),i("area","nohref"),i("body","background bgcolor text link vlink alink")),"html4"!==e&&(i("input button select textarea","autofocus"),i("input textarea","placeholder"),i("a","download"),i("link script img","crossorigin"),i("img","loading"),i("iframe","sandbox seamless allow allowfullscreen loading")),"html4"!==e&&q([r.video,r.audio],(e=>{delete e.children.audio,delete e.children.video})),q(la("a form meter progress dfn"),(e=>{r[e]&&delete r[e].children[e]})),delete r.caption.children.table,delete r.script,r})(l);!1===e.verify_html&&(e.valid_elements="*[*]");const d=ba(e.valid_styles),m=ba(e.invalid_styles,"map"),u=ba(e.valid_classes,"map"),g=i("whitespace_elements","pre script noscript style textarea video audio iframe object code"),h=i("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),p=i("void_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),f=i("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls allowfullscreen"),v="td th iframe video audio object script code",b=i("non_empty_elements",v+" pre svg",p),y=i("move_caret_before_on_enter_elements",v+" table",p),w="h1 h2 h3 h4 h5 h6",x=i("text_block_elements",w+" p div address pre form blockquote center dir fieldset header footer article section hgroup aside main nav figure"),C=i("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption details summary html body multicol listing",x),S=i("text_inline_elements","span strong b em i font s strike u var cite dfn code mark q sup sub samp"),k=i("transparent_elements","a ins del canvas map"),_=i("wrap_block_elements","pre "+w);ga("script noscript iframe noframes noembed title style textarea xmp plaintext".split(" "),(e=>{a[e]=new RegExp("]*>","gi")}));const E=e=>{const t=F.from(o["@"]),n=/[*?+]/;q(da(t,null!=e?e:""),(({name:e,element:t,aliasName:s})=>{if(s&&(o[s]=t),n.test(e)){const o=t;o.pattern=ca(e),r.push(o)}else o[e]=t}))},T=e=>{r=[],q(he(o),(e=>{delete o[e]})),E(e)},O=e=>{delete ma.text_block_elements,delete ma.block_elements,q((e=>{const t=/^(~)?(.+)$/;return ne(la(e,","),(e=>{const o=t.exec(e);if(o){const e="~"===o[1];return[{inline:e,cloneName:e?"span":"div",name:o[2]}]}return[]}))})(null!=e?e:""),(({inline:e,name:t,cloneName:r})=>{if(n[t]=n[r],s[t]=r,b[t.toUpperCase()]={},b[t]={},e||(C[t.toUpperCase()]={},C[t]={}),!o[t]){let e=o[r];e=ha({},e),delete e.removeEmptyAttrs,delete e.removeEmpty,o[t]=e}fe(n,((e,o)=>{e[r]&&(n[o]=e=ha({},n[o]),e[t]=e[r])}))}))},A=e=>{q((e=>{const t=/^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;return ne(la(e,","),(e=>{const o=t.exec(e);if(o){const e=o[1],t=e?(e=>"-"===e?"remove":"add")(e):"replace";return[{operation:t,name:o[2],validChildren:la(o[3],"|")}]}return[]}))})(null!=e?e:""),(({operation:e,name:t,validChildren:o})=>{const r="replace"===e?{"#comment":{}}:n[t];q(o,(t=>{"remove"===e?delete r[t]:r[t]={}})),n[t]=r}))},M=e=>{const t=o[e];if(t)return t;let n=r.length;for(;n--;){const t=r[n];if(t.pattern.test(e))return t}};e.valid_elements?(T(e.valid_elements),ga(c,((e,t)=>{n[t]=e.children}))):(ga(c,((e,t)=>{o[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},n[t]=e.children})),ga(la("strong/b em/i"),(e=>{const t=la(e,"/");o[t[1]].outputName=t[0]})),ga(S,((t,n)=>{o[n]&&(e.padd_empty_block_inline_children&&(o[n].paddInEmptyBlock=!0),o[n].removeEmpty=!0)})),ga(la("ol ul blockquote a table tbody"),(e=>{o[e]&&(o[e].removeEmpty=!0)})),ga(la("p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary"),(e=>{o[e]&&(o[e].paddEmpty=!0)})),ga(la("span"),(e=>{o[e].removeEmptyAttrs=!0}))),delete o.svg,O(e.custom_elements),A(e.valid_children),E(e.extended_valid_elements),A("+ol[ul|ol],+ul[ul|ol]"),ga({dd:"dl",dt:"dl",li:"ul ol",td:"tr",th:"tr",tr:"tbody thead tfoot",tbody:"table",thead:"table",tfoot:"table",legend:"fieldset",area:"map",param:"video audio object"},((e,t)=>{o[t]&&(o[t].parentsRequired=la(e))})),e.invalid_elements&&ga(pa(e.invalid_elements),(e=>{o[e]&&delete o[e]})),M("span")||E("span[!data-mce-type|*]");const N=D(d),R=D(m),B=D(u),L=D(f),H=D(C),I=D(x),P=D(S),z=D(Object.seal(p)),V=D(h),Z=D(b),U=D(y),j=D(g),W=D(k),$=D(_),G=D(Object.seal(a)),K=(e,t)=>{const o=M(e);if(o){if(!t)return!0;{if(o.attributes[t])return!0;const e=o.attributePatterns;if(e){let o=e.length;for(;o--;)if(e[o].pattern.test(t))return!0}}}return!1},Y=e=>_e(H(),e),X=e=>!je(e,"#")&&K(e)&&!Y(e),J=D(s);return{type:l,children:n,elements:o,getValidStyles:N,getValidClasses:B,getBlockElements:H,getInvalidStyles:R,getVoidElements:z,getTextBlockElements:I,getTextInlineElements:P,getBoolAttrs:L,getElementRule:M,getSelfClosingElements:V,getNonEmptyElements:Z,getMoveCaretBeforeOnEnterElements:U,getWhitespaceElements:j,getTransparentElements:W,getSpecialElements:G,isValidChild:(e,t)=>{const o=n[e.toLowerCase()];return!(!o||!o[t.toLowerCase()])},isValid:K,isBlock:Y,isInline:X,isWrapper:e=>_e($(),e)||X(e),getCustomElements:J,addValidElements:E,setValidElements:T,addCustomElements:O,addValidChildren:A}},wa=e=>Ze(e,"#").toUpperCase(),xa=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Ca=e=>(e=>({value:wa(e)}))(xa(e.red)+xa(e.green)+xa(e.blue)),Sa=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,ka=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,_a=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),Ea=(e,t,o,n)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(o,10),i=parseFloat(n);return _a(r,s,a,i)},Ta=e=>{if("transparent"===e)return F.some(_a(0,0,0,0));const t=Sa.exec(e);if(null!==t)return F.some(Ea(t[1],t[2],t[3],"1"));const o=ka.exec(e);return null!==o?F.some(Ea(o[1],o[2],o[3],o[4])):F.none()},Oa=e=>`rgba(${e.red},${e.green},${e.blue},${e.alpha})`,Da=e=>Ta(e).map(Ca).map((e=>"#"+e.value)).getOr(e),Aa=(e={},t)=>{const o=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,n=/\s*([^:]+):\s*([^;]+);?/g,r=/\s+$/,s={};let a,i;const l=vr;t&&(a=t.getValidStyles(),i=t.getInvalidStyles());const c="\\\" \\' \\; \\: ; : \ufeff".split(" ");for(let e=0;e{const a={};let i=!1;const c=e.url_converter,m=e.url_converter_scope||d,u=(e,t,o)=>{const n=a[e+"-top"+t];if(!n)return;const r=a[e+"-right"+t];if(!r)return;const s=a[e+"-bottom"+t];if(!s)return;const i=a[e+"-left"+t];if(!i)return;const l=[n,r,s,i];let c=l.length-1;for(;c--&&l[c]===l[c+1];);c>-1&&o||(a[e+t]=-1===c?l[0]:l.join(" "),delete a[e+"-top"+t],delete a[e+"-right"+t],delete a[e+"-bottom"+t],delete a[e+"-left"+t])},g=e=>{const t=a[e];if(!t)return;const o=t.indexOf(",")>-1?[t]:t.split(" ");let n=o.length;for(;n--;)if(o[n]!==o[0])return!1;return a[e]=o[0],!0},p=e=>(i=!0,s[e]),f=(e,t)=>(i&&(e=e.replace(/\uFEFF[0-9]/g,(e=>s[e]))),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e),v=e=>String.fromCharCode(parseInt(e.slice(1),16)),b=e=>e.replace(/\\[0-9a-f]+/gi,v),y=(t,o,n,r,s,a)=>{if(s=s||a)return"'"+(s=f(s)).replace(/\'/g,"\\'")+"'";if(o=f(o||n||r||""),!e.allow_script_urls){const t=o.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(t))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(t))return""}return c&&(o=c.call(m,o,"style")),"url('"+o.replace(/\'/g,"\\'")+"')"};if(t){let s;for(t=(t=t.replace(/[\u0000-\u001F]/g,"")).replace(/\\[\"\';:\uFEFF]/g,p).replace(/\"[^\"]+\"|\'[^\']+\'/g,(e=>e.replace(/[;:]/g,p)));s=n.exec(t);){n.lastIndex=s.index+s[0].length;let t=s[1].replace(r,"").toLowerCase(),c=s[2].replace(r,"");if(t&&c){if(t=b(t),c=b(c),-1!==t.indexOf(l)||-1!==t.indexOf('"'))continue;if(!e.allow_script_urls&&("behavior"===t||/expression\s*\(|\/\*|\*\//.test(c)))continue;"font-weight"===t&&"700"===c?c="bold":"color"!==t&&"background-color"!==t||(c=c.toLowerCase()),h(e.force_hex_color)&&"off"!==e.force_hex_color&&Ta(c).each((t=>{"always"!==e.force_hex_color&&1!==t.alpha||(c=Da(Oa(t)))})),c=c.replace(o,y),a[t]=i?f(c,!0):c}}u("border","",!0),u("border","-width"),u("border","-color"),u("border","-style"),u("padding",""),u("margin",""),w="border",C="border-style",S="border-color",g(x="border-width")&&g(C)&&g(S)&&(a[w]=a[x]+" "+a[C]+" "+a[S],delete a[x],delete a[C],delete a[S]),"medium none"===a.border&&delete a.border,"none"===a["border-image"]&&delete a["border-image"]}var w,x,C,S;return a},serialize:(e,t)=>{let o="";const n=(t,n)=>{const r=n[t];if(r)for(let t=0,n=r.length;t0?" ":"")+n+": "+s+";")}};return t&&a?(n("*",a),n(t,a)):fe(e,((e,n)=>{e&&((e,t)=>{if(!i||!t)return!0;let o=i["*"];return!(o&&o[e]||(o=i[t],o&&o[e]))})(n,t)&&(o+=(o.length>0?" ":"")+n+": "+e+";")})),o}};return d},Ma={keyLocation:!0,layerX:!0,layerY:!0,returnValue:!0,webkitMovementX:!0,webkitMovementY:!0,keyIdentifier:!0,mozPressure:!0},Na=e=>x(e.preventDefault)||(e=>e instanceof Event||S(e.initEvent))(e),Ra=(e,t)=>{const o=null!=t?t:{};for(const t in e)_e(Ma,t)||(o[t]=e[t]);return C(e.composedPath)&&(o.composedPath=()=>e.composedPath()),C(e.getModifierState)&&(o.getModifierState=t=>e.getModifierState(t)),C(e.getTargetRanges)&&(o.getTargetRanges=()=>e.getTargetRanges()),o},Ba=(e,t,o,n)=>{var r;const s=Ra(t,n);return s.type=e,x(s.target)&&(s.target=null!==(r=s.srcElement)&&void 0!==r?r:o),Na(t)&&(s.preventDefault=()=>{s.defaultPrevented=!0,s.isDefaultPrevented=P,S(t.preventDefault)&&t.preventDefault()},s.stopPropagation=()=>{s.cancelBubble=!0,s.isPropagationStopped=P,S(t.stopPropagation)&&t.stopPropagation()},s.stopImmediatePropagation=()=>{s.isImmediatePropagationStopped=P,s.stopPropagation()},(e=>e.isDefaultPrevented===P||e.isDefaultPrevented===I)(s)||(s.isDefaultPrevented=!0===s.defaultPrevented?P:I,s.isPropagationStopped=!0===s.cancelBubble?P:I,s.isImmediatePropagationStopped=I)),s},La=/^(?:mouse|contextmenu)|click/,Ha=(e,t,o,n)=>{e.addEventListener(t,o,n||!1)},Ia=(e,t,o,n)=>{e.removeEventListener(t,o,n||!1)},Pa=(e,t)=>{const o=Ba(e.type,e,document,t);if((e=>C(e)&&La.test(e.type))(e)&&w(e.pageX)&&!w(e.clientX)){const t=o.target.ownerDocument||document,n=t.documentElement,r=t.body,s=o;s.pageX=e.clientX+(n&&n.scrollLeft||r&&r.scrollLeft||0)-(n&&n.clientLeft||r&&r.clientLeft||0),s.pageY=e.clientY+(n&&n.scrollTop||r&&r.scrollTop||0)-(n&&n.clientTop||r&&r.clientTop||0)}return o},Fa=(e,t,o)=>{const n=e.document,r={type:"ready"};if(o.domLoaded)return void t(r);const s=()=>{Ia(e,"DOMContentLoaded",s),Ia(e,"load",s),o.domLoaded||(o.domLoaded=!0,t(r)),e=null};"complete"===n.readyState||"interactive"===n.readyState&&n.body?s():Ha(e,"DOMContentLoaded",s),o.domLoaded||Ha(e,"load",s)};class za{constructor(){this.domLoaded=!1,this.events={},this.count=1,this.expando="mce-data-"+(+new Date).toString(32),this.hasFocusIn="onfocusin"in document.documentElement,this.count=1}bind(e,t,o,n){const r=this;let s;const a=window,i=e=>{r.executeHandlers(Pa(e||a.event),l)};if(!e||tr(e)||rr(e))return o;let l;e[r.expando]?l=e[r.expando]:(l=r.count++,e[r.expando]=l,r.events[l]={}),n=n||e;const c=t.split(" ");let d=c.length;for(;d--;){let t=c[d],m=i,u=!1,g=!1;"DOMContentLoaded"===t&&(t="ready"),r.domLoaded&&"ready"===t&&"complete"===e.readyState?o.call(n,Pa({type:t})):(r.hasFocusIn||"focusin"!==t&&"focusout"!==t||(u=!0,g="focusin"===t?"focus":"blur",m=e=>{const t=Pa(e||a.event);t.type="focus"===t.type?"focusin":"focusout",r.executeHandlers(t,l)}),s=r.events[l][t],s?"ready"===t&&r.domLoaded?o(Pa({type:t})):s.push({func:o,scope:n}):(r.events[l][t]=s=[{func:o,scope:n}],s.fakeName=g,s.capture=u,s.nativeHandler=m,"ready"===t?Fa(e,m,r):Ha(e,g||t,m,u)))}return e=s=null,o}unbind(e,t,o){if(!e||tr(e)||rr(e))return this;const n=e[this.expando];if(n){let r=this.events[n];if(t){const n=t.split(" ");let s=n.length;for(;s--;){const t=n[s],a=r[t];if(a){if(o){let e=a.length;for(;e--;)if(a[e].func===o){const o=a.nativeHandler,n=a.fakeName,s=a.capture,i=a.slice(0,e).concat(a.slice(e+1));i.nativeHandler=o,i.fakeName=n,i.capture=s,r[t]=i}}o&&0!==a.length||(delete r[t],Ia(e,a.fakeName||t,a.nativeHandler,a.capture))}}}else fe(r,((t,o)=>{Ia(e,t.fakeName||o,t.nativeHandler,t.capture)})),r={};for(const e in r)if(_e(r,e))return this;delete this.events[n];try{delete e[this.expando]}catch(t){e[this.expando]=null}}return this}fire(e,t,o){return this.dispatch(e,t,o)}dispatch(e,t,o){if(!e||tr(e)||rr(e))return this;const n=Pa({type:t,target:e},o);do{const t=e[this.expando];t&&this.executeHandlers(n,t),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow}while(e&&!n.isPropagationStopped());return this}clean(e){if(!e||tr(e)||rr(e))return this;if(e[this.expando]&&this.unbind(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName){this.unbind(e);const t=e.getElementsByTagName("*");let o=t.length;for(;o--;)(e=t[o])[this.expando]&&this.unbind(e)}return this}destroy(){this.events={}}cancel(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}executeHandlers(e,t){const o=this.events[t],n=o&&o[e.type];if(n)for(let t=0,o=n.length;t{x(o)||""===o?so(e,t):eo(e,t,o)},$a=e=>e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),qa=(e,t)=>{let o=0;if(e)for(let n=e.nodeType,r=e.previousSibling;r;r=r.previousSibling){const e=r.nodeType;(!t||!tr(r)||e!==n&&r.data.length)&&(o++,n=e)}return o},Ga=(e,t)=>{const o=oo(t,"style"),n=e.serialize(e.parse(o),jt(t));Wa(t,Ua,n)},Ka=(e,t,o)=>{const n=$a(t);x(o)||""===o?hn(e,n):ln(e,n,((e,t)=>k(e)?_e(ja,t)?e+"":e+"px":e)(o,n))},Ya=(e,t={})=>{const o={},n=window,r={};let s=0;const a=Us.forElement(yo.fromDom(e),{contentCssCors:t.contentCssCors,referrerPolicy:t.referrerPolicy}),i=[],l=t.schema?t.schema:ya({}),c=Aa({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope,force_hex_color:t.force_hex_color},t.schema),d=t.ownEvents?new za:za.Event,m=l.getBlockElements(),u=t=>t&&e&&h(t)?e.getElementById(t):t,g=e=>{const t=u(e);return C(t)?yo.fromDom(t):null},p=(e,t,o="")=>{let n;const r=g(e);if(C(r)&&Gt(r)){const e=G[t];n=e&&e.get?e.get(r.dom,t):oo(r,t)}return C(n)?n:o},f=e=>{const t=u(e);return x(t)?[]:t.attributes},b=(e,o,n)=>{M(e,(e=>{if(Wn(e)){const r=yo.fromDom(e),s=""===n?null:n,a=oo(r,o),i=G[o];i&&i.set?i.set(r.dom,s,o):Wa(r,o,s),a!==s&&t.onSetAttrib&&t.onSetAttrib({attrElm:r.dom,attrName:o,attrValue:s})}}))},y=()=>t.root_element||e.body,w=(t,o)=>Vs(e.body,u(t),o),k=(e,t,o)=>{const n=u(e);var r;if(!x(n)&&($n(n)||Wn(r=n)&&"http://www.w3.org/2000/svg"===r.namespaceURI))return o?dn(yo.fromDom(n),$a(t)):("float"===(t=t.replace(/-(\D)/g,((e,t)=>t.toUpperCase())))&&(t="cssFloat"),n.style?n.style[t]:void 0)},_=e=>{const t=u(e);if(!t)return{w:0,h:0};let o=k(t,"width"),n=k(t,"height");return o&&-1!==o.indexOf("px")||(o="0"),n&&-1!==n.indexOf("px")||(n="0"),{w:parseInt(o,10)||t.offsetWidth||t.clientWidth,h:parseInt(n,10)||t.offsetHeight||t.clientHeight}},T=(e,t)=>{if(!e)return!1;const o=v(e)?e:[e];return W(o,(e=>xo(yo.fromDom(e),t)))},O=(e,t,o,n)=>{const r=[];let s=u(e);n=void 0===n;const a=o||("BODY"!==y().nodeName?y().parentNode:null);if(h(t))if("*"===t)t=Wn;else{const e=t;t=t=>T(t,e)}for(;s&&!(s===a||x(s.nodeType)||sr(s)||ar(s));){if(!t||t(s)){if(!n)return[s];r.push(s)}s=s.parentNode}return n?r:null},A=(e,t,o)=>{let n=t;if(e){h(t)&&(n=e=>T(e,t));for(let t=e[o];t;t=t[o])if(S(n)&&n(t))return t}return null},M=function(e,t,o){const n=null!=o?o:this;if(v(e)){const o=[];return Va(e,((e,r)=>{const s=u(e);s&&o.push(t.call(n,s,r))})),o}{const o=u(e);return!!o&&t.call(n,o)}},N=(e,t)=>{M(e,(e=>{fe(t,((t,o)=>{b(e,o,t)}))}))},R=(e,t)=>{M(e,(e=>{const o=yo.fromDom(e);En(o,t)}))},B=(t,o,n,r,s)=>M(t,(t=>{const a=h(o)?e.createElement(o):o;return C(n)&&N(a,n),r&&(!h(r)&&r.nodeType?a.appendChild(r):h(r)&&R(a,r)),s?a:t.appendChild(a)})),L=(t,o,n)=>B(e.createElement(t),t,o,n,!0),H=ia.encodeAllRaw,I=(e,t)=>M(e,(e=>{const o=yo.fromDom(e);return t&&q(Lo(o),(e=>{Kt(e)&&0===e.dom.length?Cn(e):pn(o,e)})),Cn(o),o.dom})),P=(e,t,o)=>{M(e,(e=>{if(Wn(e)){const n=yo.fromDom(e),r=t.split(" ");q(r,(e=>{C(o)?(o?go:po)(n,e):fo(n,e)}))}}))},F=(e,t,o)=>M(t,(n=>{var r;const s=v(t)?e.cloneNode(!0):e;return o&&Va(Za(n.childNodes),(e=>{s.appendChild(e)})),null===(r=n.parentNode)||void 0===r||r.replaceChild(s,n),n})),z=e=>{if(Wn(e)){const t="a"===e.nodeName.toLowerCase()&&!p(e,"href")&&p(e,"id");if(p(e,"name")||p(e,"data-mce-bookmark")||t)return!0}return!1},V=()=>e.createRange(),Z=(o,r,s,a)=>{if(v(o)){let e=o.length;const t=[];for(;e--;)t[e]=Z(o[e],r,s,a);return t}return!t.collect||o!==e&&o!==n||i.push([o,r,s,a]),d.bind(o,r,s,a||$)},U=(t,o,r)=>{if(v(t)){let e=t.length;const n=[];for(;e--;)n[e]=U(t[e],o,r);return n}if(i.length>0&&(t===e||t===n)){let e=i.length;for(;e--;){const[n,s,a]=i[e];t!==n||o&&o!==s||r&&r!==a||d.unbind(n,s,a)}}return d.unbind(t,o,r)},j=e=>{if(e&&$n(e)){const t=e.getAttribute("data-mce-contenteditable");return t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null}return null},$={doc:e,settings:t,win:n,files:r,stdMode:!0,boxModel:!0,styleSheetLoader:a,boundEvents:i,styles:c,schema:l,events:d,isBlock:e=>h(e)?_e(m,e):Wn(e)&&(_e(m,e.nodeName)||Ls(l,e)),root:null,clone:(e,t)=>e.cloneNode(t),getRoot:y,getViewPort:e=>{const t=Pn(e);return{x:t.x,y:t.y,w:t.width,h:t.height}},getRect:e=>{const t=u(e),o=w(t),n=_(t);return{x:o.x,y:o.y,w:n.w,h:n.h}},getSize:_,getParent:(e,t,o)=>{const n=O(e,t,o,!1);return n&&n.length>0?n[0]:null},getParents:O,get:u,getNext:(e,t)=>A(e,t,"nextSibling"),getPrev:(e,t)=>A(e,t,"previousSibling"),select:(o,n)=>{var r,s;const a=null!==(s=null!==(r=u(n))&&void 0!==r?r:t.root_element)&&void 0!==s?s:e;return S(a.querySelectorAll)?ue(a.querySelectorAll(o)):[]},is:T,add:B,create:L,createHTML:(e,t,o="")=>{let n="<"+e;for(const e in t)Ee(t,e)&&(n+=" "+e+'="'+H(t[e])+'"');return Xe(o)&&_e(l.getVoidElements(),e)?n+" />":n+">"+o+""},createFragment:t=>{const o=e.createElement("div"),n=e.createDocumentFragment();let r;for(n.appendChild(o),t&&(o.innerHTML=t);r=o.firstChild;)n.appendChild(r);return n.removeChild(o),n},remove:I,setStyle:(e,o,n)=>{M(e,(e=>{const r=yo.fromDom(e);Ka(r,o,n),t.update_styles&&Ga(c,r)}))},getStyle:k,setStyles:(e,o)=>{M(e,(e=>{const n=yo.fromDom(e);fe(o,((e,t)=>{Ka(n,t,e)})),t.update_styles&&Ga(c,n)}))},removeAllAttribs:e=>M(e,(e=>{const t=e.attributes;for(let o=t.length-1;o>=0;o--)e.removeAttributeNode(t.item(o))})),setAttrib:b,setAttribs:N,getAttrib:p,getPos:w,parseStyle:e=>c.parse(e),serializeStyle:(e,t)=>c.serialize(e,t),addStyle:t=>{if($!==Ya.DOM&&e===document){if(o[t])return;o[t]=!0}let n=e.getElementById("mceDefaultStyles");if(!n){n=e.createElement("style"),n.id="mceDefaultStyles",n.type="text/css";const t=e.head;t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(e.createTextNode(t))},loadCSS:e=>{e||(e=""),q(e.split(","),(e=>{r[e]=!0,a.load(e).catch(E)}))},addClass:(e,t)=>{P(e,t,!0)},removeClass:(e,t)=>{P(e,t,!1)},hasClass:(e,t)=>{const o=g(e),n=t.split(" ");return C(o)&&re(n,(e=>vo(o,e)))},toggleClass:P,show:e=>{M(e,(e=>hn(yo.fromDom(e),"display")))},hide:e=>{M(e,(e=>ln(yo.fromDom(e),"display","none")))},isHidden:e=>{const t=g(e);return C(t)&&Lt(un(t,"display"),"none")},uniqueId:e=>(e||"mce_")+s++,setHTML:R,getOuterHTML:e=>{const t=g(e);return C(t)?Wn(t.dom)?t.dom.outerHTML:(e=>{const t=yo.fromTag("div"),o=yo.fromDom(e.dom.cloneNode(!0));return bn(t,o),_n(t)})(t):""},setOuterHTML:(e,t)=>{M(e,(e=>{Wn(e)&&(e.outerHTML=t)}))},decode:ia.decode,encode:H,insertAfter:(e,t)=>{const o=u(t);return M(e,(e=>{const t=null==o?void 0:o.parentNode,n=null==o?void 0:o.nextSibling;return t&&(n?t.insertBefore(e,n):t.appendChild(e)),e}))},replace:F,rename:(e,t)=>{if(e.nodeName!==t.toUpperCase()){const o=L(t);return Va(f(e),(t=>{b(o,t.nodeName,p(e,t.nodeName))})),F(o,e,!0),o}return e},findCommonAncestor:(e,t)=>{let o=e;for(;o;){let e=t;for(;e&&o!==e;)e=e.parentNode;if(o===e)break;o=o.parentNode}return!o&&e.ownerDocument?e.ownerDocument.documentElement:o},run:M,getAttribs:f,isEmpty:(e,t,o)=>{let n=0;if(z(e))return!1;const r=e.firstChild;if(r){const s=new Zn(r,e),a=l?l.getWhitespaceElements():{},i=t||(l?l.getNonEmptyElements():null);let c=r;do{if(Wn(c)){const e=c.getAttribute("data-mce-bogus");if(e){c=s.next("all"===e);continue}const t=c.nodeName.toLowerCase();if(i&&i[t]){if("br"===t){n++,c=s.next();continue}return!1}if(z(c))return!1}if(rr(c))return!1;if(tr(c)&&!is(c.data)&&(!(null==o?void 0:o.includeZwsp)||!ls(c.data)))return!1;if(tr(c)&&c.parentNode&&a[c.parentNode.nodeName]&&is(c.data))return!1;c=s.next()}while(c)}return n<=1},createRng:V,nodeIndex:qa,split:(e,t,o)=>{let n,r,s=V();if(e&&t&&e.parentNode&&t.parentNode){const a=e.parentNode;return s.setStart(a,qa(e)),s.setEnd(t.parentNode,qa(t)),n=s.extractContents(),s=V(),s.setStart(t.parentNode,qa(t)+1),s.setEnd(a,qa(e)+1),r=s.extractContents(),a.insertBefore(qs($,n,l),e),o?a.insertBefore(o,e):a.insertBefore(t,e),a.insertBefore(qs($,r,l),e),I(e),o||t}},bind:Z,unbind:U,fire:(e,t,o)=>d.dispatch(e,t,o),dispatch:(e,t,o)=>d.dispatch(e,t,o),getContentEditable:j,getContentEditableParent:e=>{const t=y();let o=null;for(let n=e;n&&n!==t&&(o=j(n),null===o);n=n.parentNode);return o},isEditable:e=>{if(C(e)){const t=Wn(e)?e:e.parentElement;return C(t)&&$n(t)&&nn(yo.fromDom(t))}return!1},destroy:()=>{if(i.length>0){let e=i.length;for(;e--;){const[t,o,n]=i[e];d.unbind(t,o,n)}}fe(r,((e,t)=>{a.unload(t),delete r[t]}))},isChildOf:(e,t)=>e===t||t.contains(e),dumpRng:e=>"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},G=((e,t,o)=>{const n=t.keep_values,r={set:(e,n,r)=>{const s=yo.fromDom(e);S(t.url_converter)&&C(n)&&(n=t.url_converter.call(t.url_converter_scope||o(),String(n),r,e)),Wa(s,"data-mce-"+r,n),Wa(s,r,n)},get:(e,t)=>{const o=yo.fromDom(e);return oo(o,"data-mce-"+t)||oo(o,t)}},s={style:{set:(t,o)=>{const r=yo.fromDom(t);n&&Wa(r,Ua,o),so(r,"style"),h(o)&&cn(r,e.parse(o))},get:t=>{const o=yo.fromDom(t),n=oo(o,Ua)||oo(o,"style");return e.serialize(e.parse(n),jt(o))}}};return n&&(s.href=s.src=r),s})(c,t,D($));return $};Ya.DOM=Ya(document),Ya.nodeIndex=qa;const Xa=Ya.DOM;class Ja{constructor(e={}){this.states={},this.queue=[],this.scriptLoadedCallbacks={},this.queueLoadedCallbacks=[],this.loading=!1,this.settings=e}_setReferrerPolicy(e){this.settings.referrerPolicy=e}loadScript(e){return new Promise(((t,o)=>{const n=Xa;let r;const s=()=>{n.remove(a),r&&(r.onerror=r.onload=r=null)},a=n.uniqueId();r=document.createElement("script"),r.id=a,r.type="text/javascript",r.src=Bt._addCacheSuffix(e),this.settings.referrerPolicy&&n.setAttrib(r,"referrerpolicy",this.settings.referrerPolicy),r.onload=()=>{s(),t()},r.onerror=()=>{s(),o("Failed to load script: "+e)},(document.getElementsByTagName("head")[0]||document.body).appendChild(r)}))}isDone(e){return 2===this.states[e]}markDone(e){this.states[e]=2}add(e){const t=this;return t.queue.push(e),void 0===t.states[e]&&(t.states[e]=0),new Promise(((o,n)=>{t.scriptLoadedCallbacks[e]||(t.scriptLoadedCallbacks[e]=[]),t.scriptLoadedCallbacks[e].push({resolve:o,reject:n})}))}load(e){return this.add(e)}remove(e){delete this.states[e],delete this.scriptLoadedCallbacks[e]}loadQueue(){const e=this.queue;return this.queue=[],this.loadScripts(e)}loadScripts(e){const t=this,o=(e,o)=>{ke(t.scriptLoadedCallbacks,o).each((t=>{q(t,(t=>t[e](o)))})),delete t.scriptLoadedCallbacks[o]},n=e=>{const t=Y(e,(e=>"rejected"===e.status));return t.length>0?Promise.reject(ne(t,(({reason:e})=>v(e)?e:[e]))):Promise.resolve()},r=e=>Promise.allSettled($(e,(e=>2===t.states[e]?(o("resolve",e),Promise.resolve()):3===t.states[e]?(o("reject",e),Promise.reject(e)):(t.states[e]=1,t.loadScript(e).then((()=>{t.states[e]=2,o("resolve",e);const s=t.queue;return s.length>0?(t.queue=[],r(s).then(n)):Promise.resolve()}),(()=>(t.states[e]=3,o("reject",e),Promise.reject(e)))))))),s=e=>(t.loading=!0,r(e).then((e=>{t.loading=!1;const o=t.queueLoadedCallbacks.shift();return F.from(o).each(H),n(e)}))),a=Te(e);return t.loading?new Promise(((e,o)=>{t.queueLoadedCallbacks.push((()=>{s(a).then(e,o)}))})):s(a)}}Ja.ScriptLoader=new Ja;const Qa=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},ei={},ti=Qa("en"),oi=()=>ke(ei,ti.get()),ni={getData:()=>ve(ei,(e=>({...e}))),setCode:e=>{e&&ti.set(e)},getCode:()=>ti.get(),add:(e,t)=>{let o=ei[e];o||(ei[e]=o={});const n=$(he(t),(e=>e.toLowerCase()));fe(t,((e,r)=>{const s=r.toLowerCase();s!==r&&((e,t)=>{const o=e.indexOf(t);return-1!==o&&e.indexOf(t,o+1)>o})(n,s)?(_e(t,s)||(o[s]=e),o[r]=e):o[s]=e}))},translate:e=>{const t=oi().getOr({}),o=e=>S(e)?Object.prototype.toString.call(e):n(e)?"":""+e,n=e=>""===e||null==e,r=e=>{const n=o(e);return _e(t,n)?o(t[n]):ke(t,n.toLowerCase()).map(o).getOr(n)},s=e=>e.replace(/{context:\w+}$/,"");if(n(e))return"";if(p(a=e)&&_e(a,"raw"))return o(e.raw);var a;if((e=>v(e)&&e.length>1)(e)){const t=e.slice(1);return s(r(e[0]).replace(/\{([0-9]+)\}/g,((e,n)=>_e(t,n)?o(t[n]):e)))}return s(r(e))},isRtl:()=>oi().bind((e=>ke(e,"_dir"))).exists((e=>"rtl"===e)),hasCode:e=>_e(ei,e)},ri=()=>{const e=[],t={},o={},n=[],r=(e,t)=>{const o=Y(n,(o=>o.name===e&&o.state===t));q(o,(e=>e.resolve()))},s=e=>_e(t,e),a=(e,o)=>{const n=ni.getCode();!n||o&&-1===(","+(o||"")+",").indexOf(","+n+",")||Ja.ScriptLoader.add(t[e]+"/langs/"+n+".js")},i=(e,t="added")=>"added"===t&&(e=>_e(o,e))(e)||"loaded"===t&&s(e)?Promise.resolve():new Promise((o=>{n.push({name:e,state:t,resolve:o})}));return{items:e,urls:t,lookup:o,get:e=>{if(o[e])return o[e].instance},requireLangPack:(e,t)=>{!1!==ri.languageLoad&&(s(e)?a(e,t):i(e,"loaded").then((()=>a(e,t))))},add:(t,n)=>(e.push(n),o[t]={instance:n},r(t,"added"),n),remove:e=>{delete t[e],delete o[e]},createUrl:(e,t)=>h(t)?h(e)?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}:t,load:(e,n)=>{if(t[e])return Promise.resolve();let s=h(n)?n:n.prefix+n.resource+n.suffix;0!==s.indexOf("/")&&-1===s.indexOf("://")&&(s=ri.baseURL+"/"+s),t[e]=s.substring(0,s.lastIndexOf("/"));const a=()=>(r(e,"loaded"),Promise.resolve());return o[e]?a():Ja.ScriptLoader.add(s).then(a)},waitFor:i}};ri.languageLoad=!0,ri.baseURL="",ri.PluginManager=ri(),ri.ThemeManager=ri(),ri.ModelManager=ri();const si=e=>{const t=Qa(F.none()),o=()=>t.get().each((e=>clearInterval(e)));return{clear:()=>{o(),t.set(F.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:n=>{o(),t.set(F.some(setInterval(n,e)))}}},ai=()=>{const e=(e=>{const t=Qa(F.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(F.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(F.some(e))}}})(E);return{...e,on:t=>e.get().each(t)}},ii=(e,t)=>{let o=null;return{cancel:()=>{b(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{b(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}},li=(e,t)=>{let o=null;const n=()=>{b(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},ci=D("mce-annotation"),di=D("data-mce-annotation"),mi=D("data-mce-annotation-uid"),ui=D("data-mce-annotation-active"),gi=D("data-mce-annotation-classes"),hi=D("data-mce-annotation-attrs"),pi=e=>t=>So(t,e),fi=(e,t)=>{const o=e.selection.getRng(),n=yo.fromDom(o.startContainer),r=yo.fromDom(e.getBody()),s=t.fold((()=>"."+ci()),(e=>`[${di()}="${e}"]`)),a=Ho(n,o.startOffset).getOr(n);return on(a,s,pi(r)).bind((t=>no(t,`${mi()}`).bind((o=>no(t,`${di()}`).map((t=>{const n=bi(e,o);return{uid:o,name:t,elements:n}}))))))},vi=(e,t)=>ro(e,"data-mce-bogus")||Vn(e,'[data-mce-bogus="all"]',pi(t)),bi=(e,t)=>{const o=yo.fromDom(e.getBody()),n=zn(o,`[${mi()}="${t}"]`);return Y(n,(e=>!vi(e,o)))},yi=(e,t)=>{const o=yo.fromDom(e.getBody()),n=zn(o,`[${di()}="${t}"]`),r={};return q(n,(e=>{if(!vi(e,o)){const t=oo(e,mi()),o=ke(r,t).getOr([]);r[t]=o.concat([e])}})),r},wi=(e,t)=>{const o=Qa({}),n=()=>({listeners:[],previous:ai()}),r=(e,t)=>{s(e,(e=>(t(e),e)))},s=(e,t)=>{const r=o.get(),s=t(ke(r,e).getOrThunk(n));r[e]=s,o.set(r)},a=(t,o)=>{q(bi(e,t),(e=>{o?eo(e,ui(),"true"):so(e,ui())}))},i=li((()=>{const o=le(t.getNames());q(o,(t=>{s(t,(o=>{const n=o.previous.get();return fi(e,F.some(t)).fold((()=>{n.each((e=>{(e=>{r(e,(t=>{q(t.listeners,(t=>t(!1,e)))}))})(t),o.previous.clear(),a(e,!1)}))}),(({uid:e,name:t,elements:s})=>{Lt(n,e)||(n.each((e=>a(e,!1))),((e,t,o)=>{r(e,(n=>{q(n.listeners,(n=>n(!0,e,{uid:t,nodes:$(o,(e=>e.dom))})))}))})(t,e,s),o.previous.set(e),a(e,!0))})),{previous:o.previous,listeners:o.listeners}}))}))}),30);return e.on("remove",(()=>{i.cancel()})),e.on("NodeChange",(()=>{i.throttle()})),{addListener:(e,t)=>{s(e,(e=>({previous:e.previous,listeners:e.listeners.concat([t])})))}}};let xi=0;const Ci=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return xi++,e+"_"+o+xi+String(t)},Si=(e,t)=>yo.fromDom(e.dom.cloneNode(t)),ki=e=>Si(e,!1),_i=e=>Si(e,!0),Ei=(e,t)=>{const o=((e,t)=>{const o=yo.fromTag(t),n=ao(e);return to(o,n),o})(e,t);fn(e,o);const n=Lo(e);return wn(o,n),Cn(e),o},Ti=(e,t,o=I)=>{const n=new Zn(e,t),r=e=>{let t;do{t=n[e]()}while(t&&!tr(t)&&!o(t));return F.from(t).filter(tr)};return{current:()=>F.from(n.current()).filter(tr),next:()=>r("next"),prev:()=>r("prev"),prev2:()=>r("prev2")}},Oi=(e,t)=>{const o=t||(t=>e.isBlock(t)||ir(t)||dr(t)),n=(e,t,o,r)=>{if(tr(e)){const o=r(e,t,e.data);if(-1!==o)return F.some({container:e,offset:o})}return o().bind((e=>n(e.container,e.offset,o,r)))};return{backwards:(t,r,s,a)=>{const i=Ti(t,null!=a?a:e.getRoot(),o);return n(t,r,(()=>i.prev().map((e=>({container:e,offset:e.length})))),s).getOrNull()},forwards:(t,r,s,a)=>{const i=Ti(t,null!=a?a:e.getRoot(),o);return n(t,r,(()=>i.next().map((e=>({container:e,offset:0})))),s).getOrNull()}}},Di=Math.round,Ai=e=>e?{left:Di(e.left),top:Di(e.top),bottom:Di(e.bottom),right:Di(e.right),width:Di(e.width),height:Di(e.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0},Mi=(e,t)=>(e=Ai(e),t||(e.left=e.left+e.width),e.right=e.left,e.width=0,e),Ni=(e,t,o)=>e>=0&&e<=Math.min(t.height,o.height)/2,Ri=(e,t)=>{const o=Math.min(t.height/2,e.height/2);return e.bottom-ot.bottom)&&Ni(t.top-e.bottom,e,t)},Bi=(e,t)=>e.top>t.bottom||!(e.bottom{const n=Math.max(Math.min(t,e.left+e.width),e.left),r=Math.max(Math.min(o,e.top+e.height),e.top);return Math.sqrt((t-n)*(t-n)+(o-r)*(o-r))},Hi=e=>{const t=e.startContainer,o=e.startOffset;return t===e.endContainer&&t.hasChildNodes()&&e.endOffset===o+1?t.childNodes[o]:null},Ii=(e,t)=>{if(Wn(e)&&e.hasChildNodes()){const o=e.childNodes,n=((e,t,o)=>Math.min(Math.max(e,t),o))(t,0,o.length-1);return o[n]}return e},Pi=new RegExp("[̀-ͯ҃-҇҈-҉֑-ֽֿׁ-ׂׄ-ׇׅؐ-ًؚ-ٰٟۖ-ۜ۟-ۤۧ-۪ۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣣ-ंऺ़ु-ै्॑-ॗॢ-ॣঁ়াু-ৄ্ৗৢ-ৣਁ-ਂ਼ੁ-ੂੇ-ੈੋ-੍ੑੰ-ੱੵઁ-ં઼ુ-ૅે-ૈ્ૢ-ૣଁ଼ାିୁ-ୄ୍ୖୗୢ-ୣஂாீ்ௗఀా-ీె-ైొ-్ౕ-ౖౢ-ౣಁ಼ಿೂೆೌ-್ೕ-ೖೢ-ೣഁാു-ൄ്ൗൢ-ൣ්ාි-ුූෟัิ-ฺ็-๎ັິ-ູົ-ຼ່-ໍ༘-ཱ༹༙༵༷-ཾྀ-྄྆-྇ྍ-ྗྙ-ྼ࿆ိ-ူဲ-့္-်ွ-ှၘ-ၙၞ-ၠၱ-ၴႂႅ-ႆႍႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒ-ᝓᝲ-ᝳ឴-឵ិ-ួំ៉-៓៝᠋-᠍ᢩᤠ-ᤢᤧ-ᤨᤲ᤹-᤻ᨗ-ᨘᨛᩖᩘ-ᩞ᩠ᩢᩥ-ᩬᩳ-᩿᩼᪰-᪽᪾ᬀ-ᬃ᬴ᬶ-ᬺᬼᭂ᭫-᭳ᮀ-ᮁᮢ-ᮥᮨ-ᮩ᮫-ᮭ᯦ᯨ-ᯩᯭᯯ-ᯱᰬ-ᰳᰶ-᰷᳐-᳔᳒-᳢᳠-᳨᳭᳴᳸-᳹᷀-᷵᷼-᷿‌-‍⃐-⃜⃝-⃠⃡⃢-⃤⃥-⃰⳯-⵿⳱ⷠ-〪ⷿ-〭〮-゙〯-゚꙯꙰-꙲ꙴ-꙽ꚞ-ꚟ꛰-꛱ꠂ꠆ꠋꠥ-ꠦ꣄꣠-꣱ꤦ-꤭ꥇ-ꥑꦀ-ꦂ꦳ꦶ-ꦹꦼꧥꨩ-ꨮꨱ-ꨲꨵ-ꨶꩃꩌꩼꪰꪲ-ꪴꪷ-ꪸꪾ-꪿꫁ꫬ-ꫭ꫶ꯥꯨ꯭ﬞ︀-️︠-゙︯-゚]"),Fi=e=>h(e)&&e.charCodeAt(0)>=768&&Pi.test(e),zi=Wn,Vi=ns,Zi=Kn("display","block table"),Ui=Kn("float","left right"),ji=((...e)=>t=>{for(let o=0;ot<0&&Wn(e)&&e.hasChildNodes()?void 0:Ii(e,t),Yi=e=>e?e.createRange():Ya.DOM.createRng(),Xi=e=>h(e)&&/[\r\n\t ]/.test(e),Ji=e=>!!e.setStart&&!!e.setEnd,Qi=e=>{const t=e.startContainer,o=e.startOffset;if(Xi(e.toString())&&Wi(t.parentNode)&&tr(t)){const e=t.data;if(Xi(e[o-1])||Xi(e[o+1]))return!0}return!1},el=e=>0===e.left&&0===e.right&&0===e.top&&0===e.bottom,tl=e=>{var t;let o;const n=e.getClientRects();return o=n.length>0?Ai(n[0]):Ai(e.getBoundingClientRect()),!Ji(e)&&qi(e)&&el(o)?(e=>{const t=e.ownerDocument,o=Yi(t),n=t.createTextNode(br),r=e.parentNode;r.insertBefore(n,e),o.setStart(n,0),o.setEnd(n,1);const s=Ai(o.getBoundingClientRect());return r.removeChild(n),s})(e):el(o)&&Ji(e)&&null!==(t=(e=>{const t=e.startContainer,o=e.endContainer,n=e.startOffset,r=e.endOffset;if(t===o&&tr(o)&&0===n&&1===r){const t=e.cloneRange();return t.setEndAfter(o),tl(t)}return null})(e))&&void 0!==t?t:o},ol=(e,t)=>{const o=Mi(e,t);return o.width=1,o.right=o.left+1,o},nl=e=>{const t=[],o=e=>{var o,n;0!==e.height&&(t.length>0&&(o=e,n=t[t.length-1],o.left===n.left&&o.top===n.top&&o.bottom===n.bottom&&o.right===n.right)||t.push(e))},n=(e,t)=>{const n=Yi(e.ownerDocument);if(t0&&(n.setStart(e,t-1),n.setEnd(e,t),Qi(n)||o(ol(tl(n),!1))),t{const n=()=>(o||(o=nl(rl(e,t))),o);return{container:D(e),offset:D(t),toRange:()=>{const o=Yi(e.ownerDocument);return o.setStart(e,t),o.setEnd(e,t),o},getClientRects:n,isVisible:()=>n().length>0,isAtStart:()=>($i(e),0===t),isAtEnd:()=>$i(e)?t>=e.data.length:t>=e.childNodes.length,isEqual:o=>o&&e===o.container()&&t===o.offset(),getNode:o=>Ki(e,o?t-1:t)}};rl.fromRangeStart=e=>rl(e.startContainer,e.startOffset),rl.fromRangeEnd=e=>rl(e.endContainer,e.endOffset),rl.after=e=>rl(e.parentNode,Gi(e)+1),rl.before=e=>rl(e.parentNode,Gi(e)),rl.isAbove=(e,t)=>It(de(t.getClientRects()),me(e.getClientRects()),Ri).getOr(!1),rl.isBelow=(e,t)=>It(me(t.getClientRects()),de(e.getClientRects()),Bi).getOr(!1),rl.isAtStart=e=>!!e&&e.isAtStart(),rl.isAtEnd=e=>!!e&&e.isAtEnd(),rl.isTextPosition=e=>!!e&&tr(e.container()),rl.isElementPosition=e=>!rl.isTextPosition(e);const sl=(e,t)=>{tr(t)&&0===t.data.length&&e.remove(t)},al=(e,t,o)=>{ar(o)?((e,t,o)=>{const n=F.from(o.firstChild),r=F.from(o.lastChild);t.insertNode(o),n.each((t=>sl(e,t.previousSibling))),r.each((t=>sl(e,t.nextSibling)))})(e,t,o):((e,t,o)=>{t.insertNode(o),sl(e,o.previousSibling),sl(e,o.nextSibling)})(e,t,o)},il=tr,ll=Xn,cl=Ya.nodeIndex,dl=e=>{const t=e.parentNode;return ll(t)?dl(t):t},ml=e=>e?Re(e.childNodes,((e,t)=>(ll(t)&&"BR"!==t.nodeName?e=e.concat(ml(t)):e.push(t),e)),[]):[],ul=e=>t=>e===t,gl=e=>(il(e)?"text()":e.nodeName.toLowerCase())+"["+(e=>{let t,o;t=ml(dl(e)),o=Be(t,ul(e),e),t=t.slice(0,o+1);const n=Re(t,((e,o,n)=>(il(o)&&il(t[n-1])&&e++,e)),0);return t=Ne(t,Gn([e.nodeName])),o=Be(t,ul(e),e),o-n})(e)+"]",hl=(e,t)=>{let o,n=[],r=t.container(),s=t.offset();if(il(r))o=((e,t)=>{let o=e;for(;(o=o.previousSibling)&&il(o);)t+=o.data.length;return t})(r,s);else{const e=r.childNodes;s>=e.length?(o="after",s=e.length-1):o="before",r=e[s]}n.push(gl(r));let a=((e,t,o)=>{const n=[];for(let r=t.parentNode;r&&r!==e&&(!o||!o(r));r=r.parentNode)n.push(r);return n})(e,r);return a=Ne(a,R(Xn)),n=n.concat(Me(a,(e=>gl(e)))),n.reverse().join("/")+","+o},pl=(e,t)=>{if(!t)return null;const o=t.split(","),n=o[0].split("/"),r=o.length>1?o[1]:"before",s=Re(n,((e,t)=>{const o=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t);return o?("text()"===o[1]&&(o[1]="#text"),((e,t,o)=>{let n=ml(e);return n=Ne(n,((e,t)=>!il(e)||!il(n[t-1]))),n=Ne(n,Gn([t])),n[o]})(e,o[1],parseInt(o[2],10))):null}),e);if(!s)return null;if(!il(s)&&s.parentNode){let e;return e="after"===r?cl(s)+1:cl(s),rl(s.parentNode,e)}return((e,t)=>{let o=e,n=0;for(;il(o);){const r=o.data.length;if(t>=n&&t<=n+r){e=o,t-=n;break}if(!il(o.nextSibling)){e=o,t=r;break}n+=r,o=o.nextSibling}return il(e)&&t>e.data.length&&(t=e.data.length),rl(e,t)})(s,parseInt(r,10))},fl=dr,vl=(e,t,o,n,r)=>{const s=r?n.startContainer:n.endContainer;let a=r?n.startOffset:n.endOffset;const i=[],l=e.getRoot();if(tr(s))i.push(o?((e,t,o)=>{let n=e(t.data.slice(0,o)).length;for(let o=t.previousSibling;o&&tr(o);o=o.previousSibling)n+=e(o.data).length;return n})(t,s,a):a);else{let t=0;const n=s.childNodes;a>=n.length&&n.length&&(t=1,a=Math.max(0,n.length-1)),i.push(e.nodeIndex(n[a],o)+t)}for(let t=s;t&&t!==l;t=t.parentNode)i.push(e.nodeIndex(t,o));return i},bl=(e,t,o)=>{let n=0;return Bt.each(e.select(t),(e=>"all"===e.getAttribute("data-mce-bogus")?void 0:e!==o&&void n++)),n},yl=(e,t)=>{let o=t?e.startContainer:e.endContainer,n=t?e.startOffset:e.endOffset;if(Wn(o)&&"TR"===o.nodeName){const r=o.childNodes;o=r[Math.min(t?n:n-1,r.length-1)],o&&(n=t?0:o.childNodes.length,t?e.setStart(o,n):e.setEnd(o,n))}},wl=e=>(yl(e,!0),yl(e,!1),e),xl=(e,t)=>{if(Wn(e)&&(e=Ii(e,t),fl(e)))return e;if(Vr(e)){tr(e)&&Fr(e)&&(e=e.parentNode);let t=e.previousSibling;if(fl(t))return t;if(t=e.nextSibling,fl(t))return t}},Cl=(e,t,o)=>{const n=o.getNode(),r=o.getRng();if("IMG"===n.nodeName||fl(n)){const e=n.nodeName;return{name:e,index:bl(o.dom,e,n)}}const s=(e=>xl(e.startContainer,e.startOffset)||xl(e.endContainer,e.endOffset))(r);if(s){const e=s.tagName;return{name:e,index:bl(o.dom,e,s)}}return((e,t,o,n)=>{const r=t.dom,s=vl(r,e,o,n,!0),a=t.isForward(),i=Gr(n)?{isFakeCaret:!0}:{};return t.isCollapsed()?{start:s,forward:a,...i}:{start:s,end:vl(r,e,o,n,!1),forward:a,...i}})(e,o,t,r)},Sl=(e,t,o)=>{const n={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return o?e.create("span",n,""):e.create("span",n)},kl=(e,t)=>{const o=e.dom;let n=e.getRng();const r=o.uniqueId(),s=e.isCollapsed(),a=e.getNode(),i=a.nodeName,l=e.isForward();if("IMG"===i)return{name:i,index:bl(o,i,a)};const c=wl(n.cloneRange());if(!s){c.collapse(!1);const e=Sl(o,r+"_end",t);al(o,c,e)}n=wl(n),n.collapse(!0);const d=Sl(o,r+"_start",t);return al(o,n,d),e.moveToBookmark({id:r,keep:!0,forward:l}),{id:r,forward:l}},_l=(e,t,o=!1)=>2===t?Cl(Hr,o,e):3===t?(e=>{const t=e.getRng();return{start:hl(e.dom.getRoot(),rl.fromRangeStart(t)),end:hl(e.dom.getRoot(),rl.fromRangeEnd(t)),forward:e.isForward()}})(e):t?(e=>({rng:e.getRng(),forward:e.isForward()}))(e):kl(e,!1),El=N(Cl,A,!0),Tl=e=>{const t=t=>t(e),o=D(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:P,isError:I,map:t=>Dl.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>F.some(e)};return r},Ol=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:I,isError:P,map:t,mapError:t=>Dl.error(t(e)),bind:t,exists:I,forall:P,getOr:A,or:A,getOrThunk:L,orThunk:L,getOrDie:B(String(e)),each:E,toOptional:F.none};return o},Dl={value:Tl,error:Ol,fromOption:(e,t)=>e.fold((()=>Ol(t)),Tl)},Al=e=>{if(!v(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return q(e,((n,r)=>{const s=he(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!v(i))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=he(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!re(t,(e=>j(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o};Al([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Ml=e=>"inline-command"===e.type||"inline-format"===e.type,Nl=e=>"block-command"===e.type||"block-format"===e.type,Rl=e=>{const t=t=>Dl.error({message:t,pattern:e}),o=(o,n,r)=>{if(void 0!==e.format){let r;if(v(e.format)){if(!re(e.format,h))return t(o+" pattern has non-string items in the `format` array");r=e.format}else{if(!h(e.format))return t(o+" pattern has non-string `format` parameter");r=[e.format]}return Dl.value(n(r))}return void 0!==e.cmd?h(e.cmd)?Dl.value(r(e.cmd,e.value)):t(o+" pattern has non-string `cmd` parameter"):t(o+" pattern is missing both `format` and `cmd` parameters")};if(!p(e))return t("Raw pattern is not an object");if(!h(e.start))return t("Raw pattern is missing `start` parameter");if(void 0!==e.end){if(!h(e.end))return t("Inline pattern has non-string `end` parameter");if(0===e.start.length&&0===e.end.length)return t("Inline pattern has empty `start` and `end` parameters");let n=e.start,r=e.end;return 0===r.length&&(r=n,n=""),o("Inline",(e=>({type:"inline-format",start:n,end:r,format:e})),((e,t)=>({type:"inline-command",start:n,end:r,cmd:e,value:t})))}return void 0!==e.replacement?h(e.replacement)?0===e.start.length?t("Replacement pattern has empty `start` parameter"):Dl.value({type:"inline-command",start:"",end:e.start,cmd:"mceInsertContent",value:e.replacement}):t("Replacement pattern has non-string `replacement` parameter"):0===e.start.length?t("Block pattern has empty `start` parameter"):o("Block",(t=>({type:"block-format",start:e.start,format:t[0]})),((t,o)=>({type:"block-command",start:e.start,cmd:t,value:o})))},Bl=e=>Y(e,Nl),Ll=e=>Y(e,Ml),Hl=e=>{const t=(e=>{const t=[],o=[];return q(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})($(e,Rl));return q(t.errors,(e=>console.error(e.message,e.pattern))),t.values},Il=St().deviceType,Pl=Il.isTouch(),Fl=Ya.DOM,zl=e=>g(e,RegExp),Vl=e=>t=>t.options.get(e),Zl=e=>h(e)||p(e),Ul=(e,t="")=>o=>{const n=h(o);if(n){if(-1!==o.indexOf("=")){const r=(e=>{const t=e.indexOf("=")>0?e.split(/[;,](?![^=;,]*(?:[;,]|$))/):e.split(",");return J(t,((e,t)=>{const o=t.split("="),n=o[0],r=o.length>1?o[1]:n;return e[qe(n)]=qe(r),e}),{})})(o);return{value:ke(r,e.id).getOr(t),valid:n}}return{value:o,valid:n}}return{valid:!1,message:"Must be a string."}},jl=Vl("iframe_attrs"),Wl=Vl("doctype"),$l=Vl("document_base_url"),ql=Vl("body_id"),Gl=Vl("body_class"),Kl=Vl("content_security_policy"),Yl=Vl("br_in_pre"),Xl=Vl("forced_root_block"),Jl=Vl("forced_root_block_attrs"),Ql=Vl("newline_behavior"),ec=Vl("br_newline_selector"),tc=Vl("no_newline_selector"),oc=Vl("keep_styles"),nc=Vl("end_container_on_empty_block"),rc=Vl("automatic_uploads"),sc=Vl("images_reuse_filename"),ac=Vl("images_replace_blob_uris"),ic=Vl("icons"),lc=Vl("icons_url"),cc=Vl("images_upload_url"),dc=Vl("images_upload_base_path"),mc=Vl("images_upload_credentials"),uc=Vl("images_upload_handler"),gc=Vl("content_css_cors"),hc=Vl("referrer_policy"),pc=Vl("language"),fc=Vl("language_url"),vc=Vl("indent_use_margin"),bc=Vl("indentation"),yc=Vl("content_css"),wc=Vl("content_style"),xc=Vl("font_css"),Cc=Vl("directionality"),Sc=Vl("inline_boundaries_selector"),kc=Vl("object_resizing"),_c=Vl("resize_img_proportional"),Ec=Vl("placeholder"),Tc=Vl("event_root"),Oc=Vl("service_message"),Dc=Vl("theme"),Ac=Vl("theme_url"),Mc=Vl("model"),Nc=Vl("model_url"),Rc=Vl("inline_boundaries"),Bc=Vl("formats"),Lc=Vl("preview_styles"),Hc=Vl("format_empty_lines"),Ic=Vl("format_noneditable_selector"),Pc=Vl("custom_ui_selector"),Fc=Vl("inline"),zc=Vl("hidden_input"),Vc=Vl("submit_patch"),Zc=Vl("add_form_submit_trigger"),Uc=Vl("add_unload_trigger"),jc=Vl("custom_undo_redo_levels"),Wc=Vl("disable_nodechange"),$c=Vl("readonly"),qc=Vl("editable_root"),Gc=Vl("content_css_cors"),Kc=Vl("plugins"),Yc=Vl("external_plugins"),Xc=Vl("block_unsupported_drop"),Jc=Vl("visual"),Qc=Vl("visual_table_class"),ed=Vl("visual_anchor_class"),td=Vl("iframe_aria_text"),od=Vl("setup"),nd=Vl("init_instance_callback"),rd=Vl("urlconverter_callback"),sd=Vl("auto_focus"),ad=Vl("browser_spellcheck"),id=Vl("protect"),ld=Vl("paste_block_drop"),cd=Vl("paste_data_images"),dd=Vl("paste_preprocess"),md=Vl("paste_postprocess"),ud=Vl("newdocument_content"),gd=Vl("paste_webkit_styles"),hd=Vl("paste_remove_styles_if_webkit"),pd=Vl("paste_merge_formats"),fd=Vl("smart_paste"),vd=Vl("paste_as_text"),bd=Vl("paste_tab_spaces"),yd=Vl("allow_html_data_urls"),wd=Vl("text_patterns"),xd=Vl("text_patterns_lookup"),Cd=Vl("noneditable_class"),Sd=Vl("editable_class"),kd=Vl("noneditable_regexp"),_d=Vl("preserve_cdata"),Ed=Vl("highlight_on_focus"),Td=Vl("xss_sanitization"),Od=Vl("init_content_sync"),Dd=e=>Bt.explode(e.options.get("images_file_types")),Ad=Vl("table_tab_navigation"),Md=Vl("details_initial_state"),Nd=Vl("details_serialized_state"),Rd=Vl("force_hex_color"),Bd=Vl("sandbox_iframes"),Ld=Wn,Hd=tr,Id=e=>{const t=e.parentNode;t&&t.removeChild(e)},Pd=e=>{const t=Hr(e);return{count:e.length-t.length,text:t}},Fd=e=>{let t;for(;-1!==(t=e.data.lastIndexOf(Br));)e.deleteData(t,1)},zd=(e,t)=>(jd(e),t),Vd=(e,t)=>{const o=t.container(),n=((e,t)=>{const o=U(e,t);return-1===o?F.none():F.some(o)})(ue(o.childNodes),e).map((e=>eHd(e)&&t.container()===e?((e,t)=>{const o=Pd(e.data.substr(0,t.offset())),n=Pd(e.data.substr(t.offset()));return(o.text+n.text).length>0?(Fd(e),rl(e,t.offset()-o.count)):t})(e,t):zd(e,t),Ud=(e,t)=>rl.isTextPosition(t)?Zd(e,t):((e,t)=>t.container()===e.parentNode?Vd(e,t):zd(e,t))(e,t),jd=e=>{Ld(e)&&Vr(e)&&(Zr(e)?e.removeAttribute("data-mce-caret"):Id(e)),Hd(e)&&(Fd(e),0===e.data.length&&Id(e))},Wd=dr,$d=gr,qd=mr,Gd=(e,t,o)=>{const n=Mi(t.getBoundingClientRect(),o);let r,s;if("BODY"===e.tagName){const t=e.ownerDocument.documentElement;r=e.scrollLeft||t.scrollLeft,s=e.scrollTop||t.scrollTop}else{const t=e.getBoundingClientRect();r=e.scrollLeft-t.left,s=e.scrollTop-t.top}n.left+=r,n.right+=r,n.top+=s,n.bottom+=s,n.width=1;let a=t.offsetWidth-t.clientWidth;return a>0&&(o&&(a*=-1),n.left+=a,n.right+=a),n},Kd=(e,t,o,n)=>{const r=ai();let s,a;const i=Xl(e),l=e.dom,c=()=>{(e=>{var t,o;const n=zn(yo.fromDom(e),"*[contentEditable=false],video,audio,embed,object");for(let e=0;e{l.remove(e.caret),r.clear()})),s&&(clearInterval(s),s=void 0)},d=()=>{s=setInterval((()=>{r.on((e=>{n()?l.toggleClass(e.caret,"mce-visual-caret-hidden"):l.addClass(e.caret,"mce-visual-caret-hidden")}))}),500)};return{show:(e,n)=>{let s;if(c(),qd(n))return null;if(!o(n))return a=((e,t)=>{var o;const n=(null!==(o=e.ownerDocument)&&void 0!==o?o:document).createTextNode(Br),r=e.parentNode;if(t){const t=e.previousSibling;if(Pr(t)){if(Vr(t))return t;if($r(t))return t.splitText(t.data.length-1)}null==r||r.insertBefore(n,e)}else{const t=e.nextSibling;if(Pr(t)){if(Vr(t))return t;if(Wr(t))return t.splitText(1),t}e.nextSibling?null==r||r.insertBefore(n,e.nextSibling):null==r||r.appendChild(n)}return n})(n,e),s=n.ownerDocument.createRange(),Xd(a.nextSibling)?(s.setStart(a,0),s.setEnd(a,0)):(s.setStart(a,1),s.setEnd(a,1)),s;{const o=((e,t,o)=>{var n;const r=(null!==(n=t.ownerDocument)&&void 0!==n?n:document).createElement(e);r.setAttribute("data-mce-caret",o?"before":"after"),r.setAttribute("data-mce-bogus","all"),r.appendChild(Nr().dom);const s=t.parentNode;return o?null==s||s.insertBefore(r,t):t.nextSibling?null==s||s.insertBefore(r,t.nextSibling):null==s||s.appendChild(r),r})(i,n,e),c=Gd(t,n,e);l.setStyle(o,"top",c.top),a=o;const m=l.create("div",{class:"mce-visual-caret","data-mce-bogus":"all"});l.setStyles(m,{...c}),l.add(t,m),r.set({caret:m,element:n,before:e}),e&&l.addClass(m,"mce-visual-caret-before"),d(),s=n.ownerDocument.createRange(),s.setStart(o,0),s.setEnd(o,0)}return s},hide:c,getCss:()=>".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}",reposition:()=>{r.on((e=>{const o=Gd(t,e.element,e.before);l.setStyles(e.caret,{...o})}))},destroy:()=>clearInterval(s)}},Yd=()=>At.browser.isFirefox(),Xd=e=>Wd(e)||$d(e),Jd=e=>(Xd(e)||Jn(e)&&Yd())&&Do(yo.fromDom(e)).exists(nn),Qd=cr,em=dr,tm=gr,om=Kn("display","block table table-cell table-caption list-item"),nm=Vr,rm=Fr,sm=Wn,am=tr,im=ns,lm=e=>e>0,cm=e=>e<0,dm=(e,t)=>{let o;for(;o=e(t);)if(!rm(o))return o;return null},mm=(e,t,o,n,r)=>{const s=new Zn(e,n),a=em(e)||rm(e);let i;if(cm(t)){if(a&&(i=dm(s.prev.bind(s),!0),o(i)))return i;for(;i=dm(s.prev.bind(s),r);)if(o(i))return i}if(lm(t)){if(a&&(i=dm(s.next.bind(s),!0),o(i)))return i;for(;i=dm(s.next.bind(s),r);)if(o(i))return i}return null},um=(e,t)=>{for(;e&&e!==t;){if(om(e))return e;e=e.parentNode}return null},gm=(e,t,o)=>um(e.container(),o)===um(t.container(),o),hm=(e,t)=>{if(!t)return F.none();const o=t.container(),n=t.offset();return sm(o)?F.from(o.childNodes[n+e]):F.none()},pm=(e,t)=>{var o;const n=(null!==(o=t.ownerDocument)&&void 0!==o?o:document).createRange();return e?(n.setStartBefore(t),n.setEndBefore(t)):(n.setStartAfter(t),n.setEndAfter(t)),n},fm=(e,t,o)=>um(t,e)===um(o,e),vm=(e,t,o)=>{const n=e?"previousSibling":"nextSibling";let r=o;for(;r&&r!==t;){let e=r[n];if(e&&nm(e)&&(e=e[n]),em(e)||tm(e)){if(fm(t,e,r))return e;break}if(im(e))break;r=r.parentNode}return null},bm=N(pm,!0),ym=N(pm,!1),wm=(e,t,o)=>{let n;const r=N(vm,!0,t),s=N(vm,!1,t),a=o.startContainer,i=o.startOffset;if(Fr(a)){const e=am(a)?a.parentNode:a,t=e.getAttribute("data-mce-caret");if("before"===t&&(n=e.nextSibling,Jd(n)))return bm(n);if("after"===t&&(n=e.previousSibling,Jd(n)))return ym(n)}if(!o.collapsed)return o;if(tr(a)){if(nm(a)){if(1===e){if(n=s(a),n)return bm(n);if(n=r(a),n)return ym(n)}if(-1===e){if(n=r(a),n)return ym(n);if(n=s(a),n)return bm(n)}return o}if($r(a)&&i>=a.data.length-1)return 1===e&&(n=s(a),n)?bm(n):o;if(Wr(a)&&i<=1)return-1===e&&(n=r(a),n)?ym(n):o;if(i===a.data.length)return n=s(a),n?bm(n):o;if(0===i)return n=r(a),n?ym(n):o}return o},xm=(e,t)=>hm(e?0:-1,t).filter(em),Cm=(e,t,o)=>{const n=wm(e,t,o);return-1===e?rl.fromRangeStart(n):rl.fromRangeEnd(n)},Sm=e=>F.from(e.getNode()).map(yo.fromDom),km=(e,t)=>{let o=t;for(;o=e(o);)if(o.isVisible())return o;return o},_m=(e,t)=>{const o=gm(e,t);return!(o||!ir(e.getNode()))||o};var Em;!function(e){e[e.Backwards=-1]="Backwards",e[e.Forwards=1]="Forwards"}(Em||(Em={}));const Tm=dr,Om=tr,Dm=Wn,Am=ir,Mm=ns,Nm=e=>es(e)||(e=>!!rs(e)&&!J(ue(e.getElementsByTagName("*")),((e,t)=>e||Kr(t)),!1))(e),Rm=ss,Bm=(e,t)=>e.hasChildNodes()&&t{if(lm(e)){if(Mm(t.previousSibling)&&!Om(t.previousSibling))return rl.before(t);if(Om(t))return rl(t,0)}if(cm(e)){if(Mm(t.nextSibling)&&!Om(t.nextSibling))return rl.after(t);if(Om(t))return rl(t,t.data.length)}return cm(e)?Am(t)?rl.before(t):rl.after(t):rl.before(t)},Hm=(e,t,o)=>{let n,r,s,a;if(!Dm(o)||!t)return null;if(t.isEqual(rl.after(o))&&o.lastChild){if(a=rl.after(o.lastChild),cm(e)&&Mm(o.lastChild)&&Dm(o.lastChild))return Am(o.lastChild)?rl.before(o.lastChild):a}else a=t;const i=a.container();let l=a.offset();if(Om(i)){if(cm(e)&&l>0)return rl(i,--l);if(lm(e)&&l0&&(r=Bm(i,l-1),Mm(r)))return!Nm(r)&&(s=mm(r,e,Rm,r),s)?Om(s)?rl(s,s.data.length):rl.after(s):Om(r)?rl(r,r.data.length):rl.before(r);if(lm(e)&&l{const o=t.nextSibling;return o&&Mm(o)?Om(o)?rl(o,0):rl.before(o):Hm(Em.Forwards,rl.after(t),e)})(o,r):!Nm(r)&&(s=mm(r,e,Rm,r),s)?Om(s)?rl(s,0):rl.before(s):Om(r)?rl(r,0):rl.after(r);n=r||a.getNode()}if(n&&(lm(e)&&a.isAtEnd()||cm(e)&&a.isAtStart())&&(n=mm(n,e,P,o,!0),Rm(n,o)))return Lm(e,n);r=n?mm(n,e,Rm,o):n;const c=Le(Y(((e,t)=>{const o=[];let n=e;for(;n&&n!==t;)o.push(n),n=n.parentNode;return o})(i,o),Tm));return!c||r&&c.contains(r)?r?Lm(e,r):null:(a=lm(e)?rl.after(c):rl.before(c),a)},Im=e=>({next:t=>Hm(Em.Forwards,t,e),prev:t=>Hm(Em.Backwards,t,e)}),Pm=e=>rl.isTextPosition(e)?0===e.offset():ns(e.getNode()),Fm=e=>{if(rl.isTextPosition(e)){const t=e.container();return e.offset()===t.data.length}return ns(e.getNode(!0))},zm=(e,t)=>!rl.isTextPosition(e)&&!rl.isTextPosition(t)&&e.getNode()===t.getNode(!0),Vm=(e,t,o)=>{return e?!zm(t,o)&&(n=t,!(!rl.isTextPosition(n)&&ir(n.getNode())))&&Fm(t)&&Pm(o):!zm(o,t)&&Pm(t)&&Fm(o);var n},Zm=(e,t,o)=>{const n=Im(t);return F.from(e?n.next(o):n.prev(o))},Um=(e,t,o)=>Zm(e,t,o).bind((n=>gm(o,n,t)&&Vm(e,o,n)?Zm(e,t,n):F.some(n))),jm=(e,t,o,n)=>Um(e,t,o).bind((o=>n(o)?jm(e,t,o,n):F.some(o))),Wm=(e,t)=>{const o=e?t.firstChild:t.lastChild;return tr(o)?F.some(rl(o,e?0:o.data.length)):o?ns(o)?F.some(e?rl.before(o):ir(n=o)?rl.before(n):rl.after(n)):((e,t,o)=>{const n=e?rl.before(o):rl.after(o);return Zm(e,t,n)})(e,t,o):F.none();var n},$m=N(Zm,!0),qm=N(Zm,!1),Gm=N(Wm,!0),Km=N(Wm,!1),Ym="_mce_caret",Xm=e=>Wn(e)&&e.id===Ym,Jm=(e,t)=>{let o=t;for(;o&&o!==e;){if(Xm(o))return o;o=o.parentNode}return null},Qm=e=>_e(e,"name"),eu=e=>Bt.isArray(e.start),tu=e=>!(!Qm(e)&&y(e.forward))||e.forward,ou=(e,t)=>(Wn(t)&&e.isBlock(t)&&!t.innerHTML&&(t.innerHTML='
    '),t),nu=(e,t)=>Km(e).fold(I,(e=>(t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0))),ru=(e,t,o)=>!(!(e=>!e.hasChildNodes())(t)||!Jm(e,t)||(((e,t)=>{var o;const n=(null!==(o=e.ownerDocument)&&void 0!==o?o:document).createTextNode(Br);e.appendChild(n),t.setStart(n,0),t.setEnd(n,0)})(t,o),0)),su=(e,t,o,n)=>{const r=o[t?"start":"end"],s=e.getRoot();if(r){let e=s,o=r[0];for(let t=r.length-1;e&&t>=1;t--){const o=e.childNodes;if(ru(s,e,n))return!0;if(r[t]>o.length-1)return!!ru(s,e,n)||nu(e,n);e=o[r[t]]}tr(e)&&(o=Math.min(r[0],e.data.length)),Wn(e)&&(o=Math.min(r[0],e.childNodes.length)),t?n.setStart(e,o):n.setEnd(e,o)}return!0},au=e=>tr(e)&&e.data.length>0,iu=(e,t,o)=>{const n=e.get(o.id+"_"+t),r=null==n?void 0:n.parentNode,s=o.keep;if(n&&r){let a,i;if("start"===t?s?n.hasChildNodes()?(a=n.firstChild,i=1):au(n.nextSibling)?(a=n.nextSibling,i=0):au(n.previousSibling)?(a=n.previousSibling,i=n.previousSibling.data.length):(a=r,i=e.nodeIndex(n)+1):(a=r,i=e.nodeIndex(n)):s?n.hasChildNodes()?(a=n.firstChild,i=1):au(n.previousSibling)?(a=n.previousSibling,i=n.previousSibling.data.length):(a=r,i=e.nodeIndex(n)):(a=r,i=e.nodeIndex(n)),!s){const r=n.previousSibling,s=n.nextSibling;let l;for(Bt.each(Bt.grep(n.childNodes),(e=>{tr(e)&&(e.data=e.data.replace(/\uFEFF/g,""))}));l=e.get(o.id+"_"+t);)e.remove(l,!0);if(tr(s)&&tr(r)&&!At.browser.isOpera()){const t=r.data.length;r.appendData(s.data),e.remove(s),a=r,i=t}}return F.some(rl(a,i))}return F.none()},lu=(e,t)=>{const o=e.dom;if(t){if(eu(t))return((e,t)=>{const o=e.createRng();return su(e,!0,t,o)&&su(e,!1,t,o)?F.some({range:o,forward:tu(t)}):F.none()})(o,t);if((e=>h(e.start))(t))return((e,t)=>{const o=F.from(pl(e.getRoot(),t.start)),n=F.from(pl(e.getRoot(),t.end));return It(o,n,((o,n)=>{const r=e.createRng();return r.setStart(o.container(),o.offset()),r.setEnd(n.container(),n.offset()),{range:r,forward:tu(t)}}))})(o,t);if((e=>_e(e,"id"))(t))return((e,t)=>{const o=iu(e,"start",t),n=iu(e,"end",t);return It(o,n.or(o),((o,n)=>{const r=e.createRng();return r.setStart(ou(e,o.container()),o.offset()),r.setEnd(ou(e,n.container()),n.offset()),{range:r,forward:tu(t)}}))})(o,t);if(Qm(t))return((e,t)=>F.from(e.select(t.name)[t.index]).map((t=>{const o=e.createRng();return o.selectNode(t),{range:o,forward:!0}})))(o,t);if((e=>_e(e,"rng"))(t))return F.some({range:t.rng,forward:tu(t)})}return F.none()},cu=(e,t,o)=>_l(e,t,o),du=(e,t)=>{lu(e,t).each((({range:t,forward:o})=>{e.setRng(t,o)}))},mu=e=>Wn(e)&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type"),uu=(gu=br,e=>gu===e);var gu;const hu=e=>""!==e&&-1!==" \f\n\r\t\v".indexOf(e),pu=e=>!hu(e)&&!uu(e)&&!yr(e),fu=e=>{const t=[];if(e)for(let o=0;oY((e=>ne(e,(e=>{const t=Hi(e);return t?[yo.fromDom(t)]:[]})))(e),Dr),bu=(e,t)=>{const o=zn(t,"td[data-mce-selected],th[data-mce-selected]");return o.length>0?o:vu(e)},yu=e=>bu(fu(e.selection.getSel()),yo.fromDom(e.getBody())),wu=(e,t)=>en(e,"table",t),xu=e=>Io(e).fold(D([e]),(t=>[e].concat(xu(t)))),Cu=e=>Po(e).fold(D([e]),(t=>"br"===jt(t)?Mo(t).map((t=>[e].concat(Cu(t)))).getOr([]):[e].concat(Cu(t)))),Su=(e,t)=>It((e=>{const t=e.startContainer,o=e.startOffset;return tr(t)?0===o?F.some(yo.fromDom(t)):F.none():F.from(t.childNodes[o]).map(yo.fromDom)})(t),(e=>{const t=e.endContainer,o=e.endOffset;return tr(t)?o===t.data.length?F.some(yo.fromDom(t)):F.none():F.from(t.childNodes[o-1]).map(yo.fromDom)})(t),((t,o)=>{const n=ee(xu(e),N(So,t)),r=ee(Cu(e),N(So,o));return n.isSome()&&r.isSome()})).getOr(!1),ku=(e,t,o,n)=>{const r=o,s=new Zn(o,r),a=xe(e.schema.getMoveCaretBeforeOnEnterElements(),((e,t)=>!j(["td","th","table"],t.toLowerCase())));let i=o;do{if(tr(i)&&0!==Bt.trim(i.data).length)return void(n?t.setStart(i,0):t.setEnd(i,i.data.length));if(a[i.nodeName])return void(n?t.setStartBefore(i):"BR"===i.nodeName?t.setEndBefore(i):t.setEndAfter(i))}while(i=n?s.next():s.prev());"BODY"===r.nodeName&&(n?t.setStart(r,0):t.setEnd(r,r.childNodes.length))},_u=e=>{const t=e.selection.getSel();return C(t)&&t.rangeCount>0},Eu=(e,t)=>{const o=yu(e);o.length>0?q(o,(o=>{const n=o.dom,r=e.dom.createRng();r.setStartBefore(n),r.setEndAfter(n),t(r,!0)})):t(e.selection.getRng(),!1)},Tu=(e,t,o)=>{const n=kl(e,t);o(n),e.moveToBookmark(n)},Ou=e=>k(null==e?void 0:e.nodeType),Du=e=>Wn(e)&&!mu(e)&&!Xm(e)&&!Xn(e),Au=(e,t,o)=>{const{selection:n,dom:r}=e,s=n.getNode(),a=dr(s);Tu(n,!0,(()=>{t()})),a&&dr(s)&&r.isChildOf(s,e.getBody())?e.selection.select(s):o(n.getStart())&&Mu(r,n)},Mu=(e,t)=>{var o,n;const r=t.getRng(),{startContainer:s,startOffset:a}=r;if(!((e,t)=>{if(Du(t)&&!/^(TD|TH)$/.test(t.nodeName)){const o=e.getAttrib(t,"data-mce-selected"),n=parseInt(o,10);return!isNaN(n)&&n>0}return!1})(e,t.getNode())&&Wn(s)){const i=s.childNodes,l=e.getRoot();let c;if(a{if(e){const n=t?"nextSibling":"previousSibling";for(e=o?e:e[n];e;e=e[n])if(Wn(e)||!Lu(e))return e}},Ru=(e,t)=>!!e.getTextBlockElements()[t.nodeName.toLowerCase()]||Ls(e,t),Bu=(e,t,o)=>e.schema.isValidChild(t,o),Lu=(e,t=!1)=>{if(C(e)&&tr(e)){const o=t?e.data.replace(/ /g," "):e.data;return is(o)}return!1},Hu=(e,t)=>{const o=e.dom;return Du(t)&&"false"===o.getContentEditable(t)&&((e,t)=>{const o="[data-mce-cef-wrappable]",n=Ic(e),r=Xe(n)?o:`${o},${n}`;return xo(yo.fromDom(t),r)})(e,t)&&0===o.select('[contenteditable="true"]',t).length},Iu=(e,t)=>S(e)?e(t):(C(t)&&(e=e.replace(/%(\w+)/g,((e,o)=>t[o]||e))),e),Pu=(e,t)=>(t=t||"",e=""+((e=e||"").nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()===t.toLowerCase()),Fu=(e,t)=>{if(x(e))return null;{let o=String(e);return"color"!==t&&"backgroundColor"!==t||(o=Da(o)),"fontWeight"===t&&700===e&&(o="bold"),"fontFamily"===t&&(o=o.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),o}},zu=(e,t,o)=>{const n=e.getStyle(t,o);return Fu(n,o)},Vu=(e,t)=>{let o;return e.getParent(t,(t=>!!Wn(t)&&(o=e.getStyle(t,"text-decoration"),!!o&&"none"!==o))),o},Zu=(e,t,o)=>e.getParents(t,o,e.getRoot()),Uu=(e,t,o)=>{const n=e.formatter.get(t);return C(n)&&W(n,o)},ju=(e,t,o)=>{const n=["inline","block","selector","attributes","styles","classes"],r=e=>xe(e,((e,t)=>W(n,(e=>e===t))));return Uu(e,t,(t=>{const n=r(t);return Uu(e,o,(e=>{const t=r(e);return((e,t,o=i)=>a(o).eq(e,t))(n,t)}))}))},Wu=e=>Ee(e,"block"),$u=e=>Ee(e,"selector"),qu=e=>Ee(e,"inline"),Gu=e=>$u(e)&&!1!==e.expand&&!qu(e),Ku=e=>(e=>{const t=[];let o=e;for(;o;){if(tr(o)&&o.data!==Br||o.childNodes.length>1)return[];Wn(o)&&t.push(o),o=o.firstChild}return t})(e).length>0,Yu=e=>Xm(e.dom)&&Ku(e.dom),Xu=mu,Ju=Zu,Qu=Lu,eg=Ru,tg=(e,t)=>{let o=t;for(;o;){if(Wn(o)&&e.getContentEditable(o))return"false"===e.getContentEditable(o)?o:t;o=o.parentNode}return t},og=(e,t,o,n)=>{const r=t.data;if(e){for(let e=o;e>0;e--)if(n(r.charAt(e-1)))return e}else for(let e=o;eog(e,t,o,(e=>uu(e)||hu(e))),rg=(e,t,o)=>og(e,t,o,pu),sg=(e,t,o,n,r,s)=>{let a;const i=e.getParent(o,e.isBlock)||t,l=(t,o,n)=>{const s=Oi(e),l=r?s.backwards:s.forwards;return F.from(l(t,o,((e,t)=>Xu(e.parentNode)?-1:(a=e,n(r,e,t))),i))};return l(o,n,ng).bind((e=>s?l(e.container,e.offset+(r?-1:0),rg):F.some(e))).orThunk((()=>a?F.some({container:a,offset:r?0:a.length}):F.none()))},ag=(e,t,o,n,r)=>{const s=n[r];tr(n)&&Xe(n.data)&&s&&(n=s);const a=Ju(e,n);for(let n=0;n{var r;let s=o;const a=e.getRoot(),i=t[0];if(Wu(i)&&(s=i.wrapper?null:e.getParent(o,i.block,a)),!s){const t=null!==(r=e.getParent(o,"LI,TD,TH,SUMMARY"))&&void 0!==r?r:a;s=e.getParent(tr(o)?o.parentNode:o,(t=>t!==a&&eg(e.schema,t)),t)}if(s&&Wu(i)&&i.wrapper&&(s=Ju(e,s,"ul,ol").reverse()[0]||s),!s)for(s=o;s&&s[n]&&!e.isBlock(s[n])&&(s=s[n],!Pu(s,"br")););return s||o},lg=(e,t,o,n)=>{const r=o.parentNode;return!C(o[n])&&(!(r!==t&&!x(r)&&!e.isBlock(r))||lg(e,t,r,n))},cg=(e,t,o,n,r)=>{let s=o;const a=r?"previousSibling":"nextSibling",i=e.getRoot();if(tr(o)&&!Qu(o)&&(r?n>0:nXu(e.parentNode)||Xu(e),mg=(e,t,o,n=!1)=>{let{startContainer:r,startOffset:s,endContainer:a,endOffset:i}=t;const l=o[0];return Wn(r)&&r.hasChildNodes()&&(r=Ii(r,s),tr(r)&&(s=0)),Wn(a)&&a.hasChildNodes()&&(a=Ii(a,t.collapsed?i:i-1),tr(a)&&(i=a.data.length)),r=tg(e,r),a=tg(e,a),dg(r)&&(r=Xu(r)?r:r.parentNode,r=t.collapsed?r.previousSibling||r:r.nextSibling||r,tr(r)&&(s=t.collapsed?r.length:0)),dg(a)&&(a=Xu(a)?a:a.parentNode,a=t.collapsed?a.nextSibling||a:a.previousSibling||a,tr(a)&&(i=t.collapsed?0:a.length)),t.collapsed&&(sg(e,e.getRoot(),r,s,!0,n).each((({container:e,offset:t})=>{r=e,s=t})),sg(e,e.getRoot(),a,i,!1,n).each((({container:e,offset:t})=>{a=e,i=t}))),(qu(l)||l.block_expand)&&(qu(l)&&tr(r)&&0!==s||(r=cg(e,o,r,s,!0)),qu(l)&&tr(a)&&i!==a.data.length||(a=cg(e,o,a,i,!1))),Gu(l)&&(r=ag(e,o,t,r,"previousSibling"),a=ag(e,o,t,a,"nextSibling")),(Wu(l)||$u(l))&&(r=ig(e,o,r,"previousSibling"),a=ig(e,o,a,"nextSibling"),Wu(l)&&(e.isBlock(r)||(r=cg(e,o,r,s,!0)),e.isBlock(a)||(a=cg(e,o,a,i,!1)))),Wn(r)&&r.parentNode&&(s=e.nodeIndex(r),r=r.parentNode),Wn(a)&&a.parentNode&&(i=e.nodeIndex(a)+1,a=a.parentNode),{startContainer:r,startOffset:s,endContainer:a,endOffset:i}},ug=(e,t,o)=>{var n;const r=t.startOffset,s=Ii(t.startContainer,r),a=t.endOffset,i=Ii(t.endContainer,a-1),l=e=>{const t=e[0];tr(t)&&t===s&&r>=t.data.length&&e.splice(0,1);const o=e[e.length-1];return 0===a&&e.length>0&&o===i&&tr(o)&&e.splice(e.length-1,1),e},c=(e,t,o)=>{const n=[];for(;e&&e!==o;e=e[t])n.push(e);return n},d=(t,o)=>e.getParent(t,(e=>e.parentNode===o),o),m=(e,t,n)=>{const r=n?"nextSibling":"previousSibling";for(let s=e,a=s.parentNode;s&&s!==t;s=a){a=s.parentNode;const t=c(s===e?s:s[r],r);t.length&&(n||t.reverse(),o(l(t)))}};if(s===i)return o(l([s]));const u=null!==(n=e.findCommonAncestor(s,i))&&void 0!==n?n:e.getRoot();if(e.isChildOf(s,i))return m(s,u,!0);if(e.isChildOf(i,s))return m(i,u);const g=d(s,u)||s,h=d(i,u)||i;m(s,g,!0);const p=c(g===s?g:g.nextSibling,"nextSibling",h===i?h.nextSibling:h);p.length&&o(l(p)),m(i,h)},gg=['pre[class*=language-][contenteditable="false"]',"figure.image","div[data-ephox-embed-iri]","div.tiny-pageembed","div.mce-toc","div[data-mce-toc]"],hg=(e,t,o,n)=>Oo(t).fold((()=>"skipping"),(r=>"br"===n||(e=>Kt(e)&&xr(e)===Br)(t)?"valid":(e=>Gt(e)&&vo(e,ci()))(t)?"existing":Xm(t.dom)?"caret":W(gg,(e=>xo(t,e)))?"valid-block":Bu(e,o,n)&&Bu(e,jt(r),o)?"valid":"invalid-child")),pg=(e,t,o,n,r,s)=>{const{uid:a=t,...i}=o;go(e,ci()),eo(e,`${mi()}`,a),eo(e,`${di()}`,n);const{attributes:l={},classes:c=[]}=r(a,i);if(to(e,l),((e,t)=>{q(t,(t=>{go(e,t)}))})(e,c),s){c.length>0&&eo(e,`${gi()}`,c.join(","));const t=he(l);t.length>0&&eo(e,`${hi()}`,t.join(","))}},fg=e=>{po(e,ci()),so(e,`${mi()}`),so(e,`${di()}`),so(e,`${ui()}`);const t=no(e,`${hi()}`).map((e=>e.split(","))).getOr([]),o=no(e,`${gi()}`).map((e=>e.split(","))).getOr([]);var n;q(t,(t=>so(e,t))),n=e,q(o,(e=>{po(n,e)})),so(e,`${gi()}`),so(e,`${hi()}`)},vg=(e,t,o,n,r)=>{const s=yo.fromTag("span",e);return pg(s,t,o,n,r,!1),s},bg=(e,t,o,n,r,s)=>{const a=[],i=vg(e.getDoc(),o,s,n,r),l=ai(),c=()=>{l.clear()},d=e=>{q(e,m)},m=t=>{switch(hg(e,t,"span",jt(t))){case"invalid-child":{c();const e=Lo(t);d(e),c();break}case"valid-block":c(),pg(t,o,s,n,r,!0);break;case"valid":{const e=l.get().getOrThunk((()=>{const e=ki(i);return a.push(e),l.set(e),e}));yn(t,e);break}}};return ug(e.dom,t,(e=>{c(),(e=>{const t=$(e,yo.fromDom);d(t)})(e)})),a},yg=(e,t,o,n)=>{e.undoManager.transact((()=>{const r=e.selection,s=r.getRng(),a=yu(e).length>0,i=Ci("mce-annotation");if(s.collapsed&&!a&&((e,t)=>{const o=mg(e.dom,t,[{inline:"span"}]);t.setStart(o.startContainer,o.startOffset),t.setEnd(o.endContainer,o.endOffset),e.selection.setRng(t)})(e,s),r.getRng().collapsed&&!a){const s=vg(e.getDoc(),i,n,t,o.decorate);En(s,br),r.getRng().insertNode(s.dom),r.select(s.dom)}else Tu(r,!1,(()=>{Eu(e,(r=>{bg(e,r,i,t,o.decorate,n)}))}))}))},wg=e=>{const t=(()=>{const e={};return{register:(t,o)=>{e[t]={name:t,settings:o}},lookup:t=>ke(e,t).map((e=>e.settings)),getNames:()=>he(e)}})();((e,t)=>{const o=di(),n=e=>F.from(e.attr(o)).bind(t.lookup),r=e=>{var t,o;e.attr(mi(),null),e.attr(di(),null),e.attr(ui(),null);const n=F.from(e.attr(hi())).map((e=>e.split(","))).getOr([]),r=F.from(e.attr(gi())).map((e=>e.split(","))).getOr([]);q(n,(t=>e.attr(t,null)));const s=null!==(o=null===(t=e.attr("class"))||void 0===t?void 0:t.split(" "))&&void 0!==o?o:[],a=ae(s,[ci()].concat(r));e.attr("class",a.length>0?a.join(" "):null),e.attr(gi(),null),e.attr(hi(),null)};e.serializer.addTempAttr(ui()),e.serializer.addAttributeFilter(o,(e=>{for(const t of e)n(t).each((e=>{!1===e.persistent&&("span"===t.name?t.unwrap():r(t))}))}))})(e,t);const o=wi(e,t),n=Jt("span"),r=e=>{q(e,(e=>{n(e)?Sn(e):fg(e)}))};return{register:(e,o)=>{t.register(e,o)},annotate:(o,n)=>{t.lookup(o).each((t=>{yg(e,o,t,n)}))},annotationChanged:(e,t)=>{o.addListener(e,t)},remove:t=>{fi(e,F.some(t)).each((({elements:t})=>{const o=e.selection.getBookmark();r(t),e.selection.moveToBookmark(o)}))},removeAll:t=>{const o=e.selection.getBookmark();fe(yi(e,t),((e,t)=>{r(e)})),e.selection.moveToBookmark(o)},getAll:t=>{const o=yi(e,t);return ve(o,(e=>$(e,(e=>e.dom))))}}},xg=e=>({getBookmark:N(cu,e),moveToBookmark:N(du,e)});xg.isBookmarkNode=mu;const Cg=(e,t,o)=>!o.collapsed&&W(o.getClientRects(),(o=>((e,t,o)=>t>=e.left&&t<=e.right&&o>=e.top&&o<=e.bottom)(o,e,t))),Sg=(e,t,o)=>{e.dispatch(t,o)},kg=(e,t,o,n)=>{e.dispatch("FormatApply",{format:t,node:o,vars:n})},_g=(e,t,o,n)=>{e.dispatch("FormatRemove",{format:t,node:o,vars:n})},Eg=(e,t)=>e.dispatch("SetContent",t),Tg=(e,t)=>e.dispatch("GetContent",t),Og=(e,t)=>e.dispatch("PastePlainTextToggle",{state:t}),Dg={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,modifierPressed:e=>e.shiftKey||e.ctrlKey||e.altKey||Dg.metaKeyPressed(e),metaKeyPressed:e=>At.os.isMacOS()||At.os.isiOS()?e.metaKey:e.ctrlKey&&!e.altKey},Ag="data-mce-selected",Mg=Math.abs,Ng=Math.round,Rg={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},Bg=(e,t)=>{const o=t.dom,n=t.getDoc(),r=document,s=t.getBody();let a,i,l,c,d,m,u,g,h,p,f,v,b,y,w;const x=e=>C(e)&&(lr(e)||o.is(e,"figure.image")),S=e=>gr(e)||o.hasClass(e,"mce-preview-object"),k=e=>{const o=e.target;((e,t)=>{if((e=>"longpress"===e.type||0===e.type.indexOf("touch"))(e)){const o=e.touches[0];return x(e.target)&&!Cg(o.clientX,o.clientY,t)}return x(e.target)&&!Cg(e.clientX,e.clientY,t)})(e,t.selection.getRng())&&!e.isDefaultPrevented()&&t.selection.select(o)},_=e=>o.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?[e,e.firstElementChild]:o.is(e,"figure.image")?[e.querySelector("img")]:[e],E=e=>{const n=kc(t);return!!n&&"false"!==e.getAttribute("data-mce-resize")&&e!==t.getBody()&&(o.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?xo(yo.fromDom(e.firstElementChild),n):xo(yo.fromDom(e),n))},T=(e,n,r)=>{if(C(r)){const s=_(e);q(s,(e=>{e.style[n]||!t.schema.isValid(e.nodeName.toLowerCase(),n)?o.setStyle(e,n,r):o.setAttrib(e,n,""+r)}))}},O=(e,t,o)=>{T(e,"width",t),T(e,"height",o)},D=e=>{let n,r,d,C,k;n=e.screenX-m,r=e.screenY-u,v=n*c[2]+g,b=r*c[3]+h,v=v<5?5:v,b=b<5?5:b,d=(x(a)||S(a))&&!1!==_c(t)?!Dg.modifierPressed(e):Dg.modifierPressed(e),d&&(Mg(n)>Mg(r)?(b=Ng(v*p),v=Ng(b/p)):(v=Ng(b/p),b=Ng(v*p))),O(i,v,b),C=c.startPos.x+n,k=c.startPos.y+r,C=C>0?C:0,k=k>0?k:0,o.setStyles(l,{left:C,top:k,display:"block"}),l.innerHTML=v+" × "+b,c[2]<0&&i.clientWidth<=v&&o.setStyle(i,"left",void 0+(g-v)),c[3]<0&&i.clientHeight<=b&&o.setStyle(i,"top",void 0+(h-b)),n=s.scrollWidth-y,r=s.scrollHeight-w,n+r!==0&&o.setStyles(l,{left:C-n,top:k-r}),f||(((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(t,a,g,h,"corner-"+c.name),f=!0)},A=()=>{const e=f;f=!1,e&&(T(a,"width",v),T(a,"height",b)),o.unbind(n,"mousemove",D),o.unbind(n,"mouseup",A),r!==n&&(o.unbind(r,"mousemove",D),o.unbind(r,"mouseup",A)),o.remove(i),o.remove(l),o.remove(d),M(a),e&&(((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(t,a,v,b,"corner-"+c.name),o.setAttrib(a,"style",o.getAttrib(a,"style"))),t.nodeChanged()},M=e=>{H();const f=o.getPos(e,s),x=f.x,C=f.y,k=e.getBoundingClientRect(),T=k.width||k.right-k.left,M=k.height||k.bottom-k.top;a!==e&&(R(),a=e,v=b=0);const N=t.dispatch("ObjectSelected",{target:e});E(e)&&!N.isDefaultPrevented()?fe(Rg,((e,t)=>{const f=f=>{const v=_(a)[0];var b;m=f.screenX,u=f.screenY,g=v.clientWidth,h=v.clientHeight,p=h/g,c=e,c.name=t,c.startPos={x:T*e[0]+x,y:M*e[1]+C},y=s.scrollWidth,w=s.scrollHeight,d=o.add(s,"div",{class:"mce-resize-backdrop","data-mce-bogus":"all"}),o.setStyles(d,{position:"fixed",left:"0",top:"0",width:"100%",height:"100%"}),i=S(b=a)?o.create("img",{src:At.transparentSrc}):b.cloneNode(!0),o.addClass(i,"mce-clonedresizable"),o.setAttrib(i,"data-mce-bogus","all"),i.contentEditable="false",o.setStyles(i,{left:x,top:C,margin:0}),O(i,T,M),i.removeAttribute(Ag),s.appendChild(i),o.bind(n,"mousemove",D),o.bind(n,"mouseup",A),r!==n&&(o.bind(r,"mousemove",D),o.bind(r,"mouseup",A)),l=o.add(s,"div",{class:"mce-resize-helper","data-mce-bogus":"all"},g+" × "+h)};let v=o.get("mceResizeHandle"+t);v&&o.remove(v),v=o.add(s,"div",{id:"mceResizeHandle"+t,"data-mce-bogus":"all",class:"mce-resizehandle",unselectable:!0,style:"cursor:"+t+"-resize; margin:0; padding:0"}),o.bind(v,"mousedown",(e=>{e.stopImmediatePropagation(),e.preventDefault(),f(e)})),e.elm=v,o.setStyles(v,{left:T*e[0]+x-v.offsetWidth/2,top:M*e[1]+C-v.offsetHeight/2})})):R(!1)},N=ii(M,0),R=(e=!0)=>{N.cancel(),H(),a&&e&&a.removeAttribute(Ag),fe(Rg,((e,t)=>{const n=o.get("mceResizeHandle"+t);n&&(o.unbind(n),o.remove(n))}))},B=(e,t)=>o.isChildOf(e,t),L=n=>{if(f||t.removed||t.composing)return;const r="mousedown"===n.type?n.target:e.getNode(),a=on(yo.fromDom(r),"table,img,figure.image,hr,video,span.mce-preview-object,details").map((e=>e.dom)).filter((e=>o.isEditable(e.parentElement)||"IMG"===e.nodeName&&o.isEditable(e))).getOrUndefined(),i=C(a)?o.getAttrib(a,Ag,"1"):"1";if(q(o.select(`img[${Ag}],hr[${Ag}]`),(e=>{e.removeAttribute(Ag)})),C(a)&&B(a,s)&&t.hasFocus()){I();const t=e.getStart(!0);if(B(t,a)&&B(e.getEnd(!0),a))return o.setAttrib(a,Ag,i),void N.throttle(a)}R()},H=()=>{fe(Rg,(e=>{e.elm&&(o.unbind(e.elm),delete e.elm)}))},I=()=>{try{t.getDoc().execCommand("enableObjectResizing",!1,"false")}catch(e){}};return t.on("init",(()=>{I(),t.on("NodeChange ResizeEditor ResizeWindow ResizeContent drop",L),t.on("keyup compositionend",(e=>{a&&"TABLE"===a.nodeName&&L(e)})),t.on("hide blur",R),t.on("contextmenu longpress",k,!0)})),t.on("remove",H),{isResizable:E,showResizeRect:M,hideResizeRect:R,updateResizeRect:L,destroy:()=>{N.cancel(),a=i=d=null}}},Lg=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Hg=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Ig=Al([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Pg=(e,t,o)=>t(yo.fromDom(o.startContainer),o.startOffset,yo.fromDom(o.endContainer),o.endOffset),Fg=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:D(e),rtl:F.none}),relative:(t,o)=>({ltr:He((()=>Lg(e,t,o))),rtl:He((()=>F.some(Lg(e,o,t))))}),exact:(t,o,n,r)=>({ltr:He((()=>Hg(e,t,o,n,r))),rtl:He((()=>F.some(Hg(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>Ig.rtl(yo.fromDom(e.endContainer),e.endOffset,yo.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>Pg(0,Ig.ltr,o))):Pg(0,Ig.ltr,o)})(0,o)};Ig.ltr,Ig.rtl;const zg=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),Vg=(e,t,o)=>{var n,r;return F.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return F.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),F.some(o)}))},Zg=(e,t,o)=>{var n,r;return F.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))},Ug=document.caretPositionFromPoint?Vg:document.caretRangeFromPoint?Zg:F.none,jg=Al([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Wg={before:jg.before,on:jg.on,after:jg.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(A,A,A)},$g=Al([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),qg={domRange:$g.domRange,relative:$g.relative,exact:$g.exact,exactFromRange:e=>$g.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>yo.fromDom(e.startContainer),relative:(e,t)=>Wg.getStart(e),exact:(e,t,o,n)=>e}))(e);return To(t)},range:zg},Gg=(e,t)=>{const o=jt(e);return"input"===o?Wg.after(e):j(["br","img"],o)?0===t?Wg.before(e):Wg.after(e):Wg.on(e,t)},Kg=(e,t)=>{const o=e.fold(Wg.before,Gg,Wg.after),n=t.fold(Wg.before,Gg,Wg.after);return qg.relative(o,n)},Yg=(e,t,o,n)=>{const r=Gg(e,t),s=Gg(o,n);return qg.relative(r,s)},Xg=(e,t)=>{const o=(t||document).createDocumentFragment();return q(e,(e=>{o.appendChild(e.dom)})),yo.fromDom(o)},Jg=e=>{const t=qg.getWin(e).dom,o=(e,o,n,r)=>Hg(t,e,o,n,r),n=(e=>e.match({domRange:e=>{const t=yo.fromDom(e.startContainer),o=yo.fromDom(e.endContainer);return Yg(t,e.startOffset,o,e.endOffset)},relative:Kg,exact:Yg}))(e);return Fg(t,n).match({ltr:o,rtl:o})},Qg=(e,t,o)=>((e,t,o)=>{const n=yo.fromDom(e.document);return Ug(n,t,o).map((e=>zg(yo.fromDom(e.startContainer),e.startOffset,yo.fromDom(e.endContainer),e.endOffset)))})(e,t,o),eh=(e,t,o)=>{const n=To(yo.fromDom(o));return Qg(n.dom,e,t).map((e=>{const t=o.createRange();return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),t})).getOrUndefined()},th=(e,t)=>C(e)&&C(t)&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset,oh=(e,t,o)=>null!==((e,t,o)=>{let n=e;for(;n&&n!==t;){if(o(n))return n;n=n.parentNode}return null})(e,t,o),nh=(e,t,o)=>oh(e,t,(e=>e.nodeName===o)),rh=(e,t)=>Vr(e)&&!oh(e,t,Xm),sh=(e,t,o)=>{const n=t.parentNode;if(n){const r=new Zn(t,e.getParent(n,e.isBlock)||e.getRoot());let s;for(;s=r[o?"prev":"next"]();)if(ir(s))return!0}return!1},ah=(e,t,o,n,r)=>{const s=e.getRoot(),a=e.schema.getNonEmptyElements(),i=r.parentNode;let l,c;if(!i)return F.none();const d=e.getParent(i,e.isBlock)||s;if(n&&ir(r)&&t&&e.isEmpty(d))return F.some(rl(i,e.nodeIndex(r)));const m=new Zn(r,d);for(;c=m[n?"prev":"next"]();){if("false"===e.getContentEditableParent(c)||rh(c,s))return F.none();if(tr(c)&&c.data.length>0)return nh(c,s,"A")?F.none():F.some(rl(c,n?c.data.length:0));if(e.isBlock(c)||a[c.nodeName.toLowerCase()])return F.none();l=c}return rr(l)?F.none():o&&l?F.some(rl(l,0)):F.none()},ih=(e,t,o,n)=>{const r=e.getRoot();let s,a=!1,i=o?n.startContainer:n.endContainer,l=o?n.startOffset:n.endOffset;const c=Wn(i)&&l===i.childNodes.length,d=e.schema.getNonEmptyElements();let m=o;if(Vr(i))return F.none();if(Wn(i)&&l>i.childNodes.length-1&&(m=!1),sr(i)&&(i=r,l=0),i===r){if(m&&(s=i.childNodes[l>0?l-1:0],s)){if(Vr(s))return F.none();if(d[s.nodeName]||Jn(s))return F.none()}if(i.hasChildNodes()){if(l=Math.min(!m&&l>0?l-1:l,i.childNodes.length-1),i=i.childNodes[l],l=tr(i)&&c?i.data.length:0,!t&&i===r.lastChild&&Jn(i))return F.none();if(((e,t)=>{let o=t;for(;o&&o!==e;){if(dr(o))return!0;o=o.parentNode}return!1})(r,i)||Vr(i))return F.none();if(pr(i))return F.none();if(i.hasChildNodes()&&!Jn(i)){s=i;const t=new Zn(i,r);do{if(dr(s)||Vr(s)){a=!1;break}if(tr(s)&&s.data.length>0){l=m?0:s.data.length,i=s,a=!0;break}if(d[s.nodeName.toLowerCase()]&&!ur(s)){l=e.nodeIndex(s),i=s.parentNode,m||l++,a=!0;break}}while(s=m?t.next():t.prev())}}}return t&&(tr(i)&&0===l&&ah(e,c,t,!0,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),Wn(i)&&(s=i.childNodes[l],s||(s=i.childNodes[l-1]),!s||!ir(s)||((e,t)=>{var o;return(null===(o=e.previousSibling)||void 0===o?void 0:o.nodeName)===t})(s,"A")||sh(e,s,!1)||sh(e,s,!0)||ah(e,c,t,!0,s).each((e=>{i=e.container(),l=e.offset(),a=!0})))),m&&!t&&tr(i)&&l===i.data.length&&ah(e,c,t,!1,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),a&&i?F.some(rl(i,l)):F.none()},lh=(e,t)=>{const o=t.collapsed,n=t.cloneRange(),r=rl.fromRangeStart(t);return ih(e,o,!0,n).each((e=>{o&&rl.isAbove(r,e)||n.setStart(e.container(),e.offset())})),o||ih(e,o,!1,n).each((e=>{n.setEnd(e.container(),e.offset())})),o&&n.collapse(!0),th(t,n)?F.none():F.some(n)},ch=(e,t)=>e.splitText(t),dh=e=>{let t=e.startContainer,o=e.startOffset,n=e.endContainer,r=e.endOffset;if(t===n&&tr(t)){if(o>0&&oo){r-=o;const e=ch(n,r).previousSibling;t=n=e,r=e.data.length,o=0}else r=0}else if(tr(t)&&o>0&&o0&&r({walk:(t,o)=>ug(e,t,o),split:dh,expand:(t,o={type:"word"})=>{if("word"===o.type){const o=mg(e,t,[{inline:"span"}]),n=e.createRng();return n.setStart(o.startContainer,o.startOffset),n.setEnd(o.endContainer,o.endOffset),n}return t},normalize:t=>lh(e,t).fold(I,(e=>(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),!0)))});mh.compareRanges=th,mh.getCaretRangeFromPoint=eh,mh.getSelectedNode=Hi,mh.getNode=Ii;const uh=((e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=dn(o,e);return parseFloat(t)||0}return n},n=(e,t)=>J(t,((t,o)=>{const n=dn(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!k(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;sn(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}})("height",(e=>{const t=e.dom;return Go(e)?t.getBoundingClientRect().height:t.offsetHeight})),gh=()=>yo.fromDom(document),hh=(e,t)=>e.view(t).fold(D([]),(t=>{const o=e.owner(t),n=hh(e,o);return[t].concat(n)}));var ph=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?F.none():F.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(yo.fromDom)},owner:e=>Eo(e)});const fh=e=>{const t=gh(),o=Bn(t),n=((e,t)=>{const o=t.owner(e);return hh(t,o)})(e,ph),r=Rn(e),s=X(n,((e,t)=>{const o=Rn(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return Mn(s.left+r.left+o.left,s.top+r.top+o.top)},vh=e=>"textarea"===jt(e),bh=(e,t)=>{const o=(e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return Mn(o.offsetLeft,o.offsetTop);const s=Nn(null==n?void 0:n.pageYOffset,r.scrollTop),a=Nn(null==n?void 0:n.pageXOffset,r.scrollLeft),i=Nn(r.clientTop,o.clientTop),l=Nn(r.clientLeft,o.clientLeft);return Rn(e).translate(a-l,s-i)})(e),n=(e=>uh.get(e))(e);return{element:e,bottom:o.top+n,height:n,pos:o,cleanup:t}},yh=(e,t)=>{const o=((e,t)=>{const o=Lo(e);if(0===o.length||vh(e))return{element:e,offset:t};if(t\ufeff
    ');return pn(o.element,n),bh(n,(()=>Cn(n)))},wh=(e,t,o,n)=>{kh(e,((r,s)=>Ch(e,t,o,n)),o)},xh=(e,t,o,n,r)=>{const s={elm:n.element.dom,alignToTop:r};((e,t)=>e.dispatch("ScrollIntoView",t).isDefaultPrevented())(e,s)||(o(e,t,Bn(t).top,n,r),((e,t)=>{e.dispatch("AfterScrollIntoView",t)})(e,s))},Ch=(e,t,o,n)=>{const r=yo.fromDom(e.getBody()),s=yo.fromDom(e.getDoc());r.dom.offsetWidth;const a=yh(yo.fromDom(o.startContainer),o.startOffset);xh(e,s,t,a,n),a.cleanup()},Sh=(e,t,o,n)=>{const r=yo.fromDom(e.getDoc());xh(e,r,o,(e=>bh(yo.fromDom(e),E))(t),n)},kh=(e,t,o)=>{const n=o.startContainer,r=o.startOffset,s=o.endContainer,a=o.endOffset;t(yo.fromDom(n),yo.fromDom(s));const i=e.dom.createRng();i.setStart(n,r),i.setEnd(s,a),e.selection.setRng(o)},_h=(e,t,o,n,r)=>{const s=t.pos;if(n)Ln(s.left,s.top,r);else{const n=s.top-o+t.height;Ln(-e.getBody().getBoundingClientRect().left,n,r)}},Eh=(e,t,o,n,r,s)=>{const a=n+o,i=r.pos.top,l=r.bottom,c=l-i>=n;ia?_h(e,r,n,c?!1!==s:!0===s,t):l>a&&!c&&_h(e,r,n,!0===s,t)},Th=(e,t,o,n,r)=>{const s=To(t).dom.innerHeight;Eh(e,t,o,s,n,r)},Oh=(e,t,o,n,r)=>{const s=To(t).dom.innerHeight;Eh(e,t,o,s,n,r);const a=fh(n.element),i=Pn(window);a.topi.bottom&&Hn(n.element,!0===r)},Dh=(e,t,o)=>wh(e,Th,t,o),Ah=(e,t,o)=>Sh(e,t,Th,o),Mh=(e,t,o)=>wh(e,Oh,t,o),Nh=(e,t,o)=>Sh(e,t,Oh,o),Rh=(e,t,o)=>{(e.inline?Dh:Mh)(e,t,o)},Bh=(e,t=!1)=>e.dom.focus({preventScroll:t}),Lh=e=>{const t=Uo(e).dom;return e.dom===t.activeElement},Hh=(e=gh())=>F.from(e.dom.activeElement).map(yo.fromDom),Ih=(e,t)=>{const o=Kt(t)?xr(t).length:Lo(t).length+1;return e>o?o:e<0?0:e},Ph=e=>qg.range(e.start,Ih(e.soffset,e.start),e.finish,Ih(e.foffset,e.finish)),Fh=(e,t)=>!jn(t.dom)&&(ko(e,t)||So(e,t)),zh=e=>t=>Fh(e,t.start)&&Fh(e,t.finish),Vh=e=>qg.range(yo.fromDom(e.startContainer),e.startOffset,yo.fromDom(e.endContainer),e.endOffset),Zh=e=>(e=>{const t=e.getSelection();return(t&&0!==t.rangeCount?F.from(t.getRangeAt(0)):F.none()).map(Vh)})(To(e).dom).filter(zh(e)),Uh=e=>{const t=document.createRange();try{return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),F.some(t)}catch(e){return F.none()}},jh=e=>{const t=(e=>e.inline||At.browser.isFirefox())(e)?Zh(yo.fromDom(e.getBody())):F.none();e.bookmark=t.isSome()?t:e.bookmark},Wh=e=>(e.bookmark?e.bookmark:F.none()).bind((t=>((e,t)=>F.from(t).filter(zh(e)).map(Ph))(yo.fromDom(e.getBody()),t))).bind(Uh),$h={isEditorUIElement:e=>{const t=e.className.toString();return-1!==t.indexOf("tox-")||-1!==t.indexOf("mce-")}},qh={setEditorTimeout:(e,t,o)=>((e,t)=>(k(t)||(t=0),setTimeout(e,t)))((()=>{e.removed||t()}),o),setEditorInterval:(e,t,o)=>{const n=((e,t)=>(k(t)||(t=0),setInterval(e,t)))((()=>{e.removed?clearInterval(n):t()}),o);return n}},Gh=e=>{const t=ii((()=>{jh(e)}),0);e.on("init",(()=>{e.inline&&((e,t)=>{const o=()=>{t.throttle()};Ya.DOM.bind(document,"mouseup",o),e.on("remove",(()=>{Ya.DOM.unbind(document,"mouseup",o)}))})(e,t),((e,t)=>{((e,t)=>{e.on("mouseup touchend",(e=>{t.throttle()}))})(e,t),e.on("keyup NodeChange AfterSetSelectionRange",(t=>{(e=>"nodechange"===e.type&&e.selectionChange)(t)||jh(e)}))})(e,t)})),e.on("remove",(()=>{t.cancel()}))};let Kh;const Yh=Ya.DOM,Xh=e=>{const t=e.classList;return void 0!==t&&(t.contains("tox-edit-area")||t.contains("tox-edit-area__iframe")||t.contains("mce-content-body"))},Jh=(e,t)=>{const o=Pc(e),n=Yh.getParent(t,(t=>(e=>Wn(e)&&$h.isEditorUIElement(e))(t)||!!o&&e.dom.is(t,o)));return null!==n},Qh=e=>{try{const t=Uo(yo.fromDom(e.getElement()));return Hh(t).fold((()=>document.body),(e=>e.dom))}catch(e){return document.body}},ep=(e,t)=>{const o=t.editor;Gh(o);const n=(e,t)=>{Ed(e)&&!0!==e.inline&&t(yo.fromDom(e.getContainer()),"tox-edit-focus")};o.on("focusin",(()=>{const t=e.focusedEditor;Xh(Qh(o))&&n(o,go),t!==o&&(t&&t.dispatch("blur",{focusedEditor:o}),e.setActive(o),e.focusedEditor=o,o.dispatch("focus",{blurredEditor:t}),o.focus(!0))})),o.on("focusout",(()=>{qh.setEditorTimeout(o,(()=>{const t=e.focusedEditor;Xh(Qh(o))&&t===o||n(o,po),Jh(o,Qh(o))||t!==o||(o.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null)}))})),Kh||(Kh=t=>{const o=e.activeEditor;o&&$o(t).each((t=>{const n=t;n.ownerDocument===document&&(n===document.body||Jh(o,n)||e.focusedEditor!==o||(o.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null))}))},Yh.bind(document,"focusin",Kh))},tp=(e,t)=>{e.focusedEditor===t.editor&&(e.focusedEditor=null),!e.activeEditor&&Kh&&(Yh.unbind(document,"focusin",Kh),Kh=null)},op=(e,t)=>(e=>e.collapsed?F.from(Ii(e.startContainer,e.startOffset)).map(yo.fromDom):F.none())(t).bind((t=>Or(t)?F.some(t):ko(e,t)?F.none():F.some(e))),np=(e,t)=>{op(yo.fromDom(e.getBody()),t).bind((e=>Gm(e.dom))).fold((()=>{e.selection.normalize()}),(t=>e.selection.setRng(t.toRange())))},rp=e=>{if(e.setActive)try{e.setActive()}catch(t){e.focus()}else e.focus()},sp=e=>{return Lh(e)||(t=e,Hh(Uo(t)).filter((e=>t.dom.contains(e.dom)))).isSome();var t},ap=e=>e.inline?(e=>{const t=e.getBody();return t&&sp(yo.fromDom(t))})(e):(e=>C(e.iframeElement)&&Lh(yo.fromDom(e.iframeElement)))(e),ip=e=>ap(e)||(e=>{const t=Uo(yo.fromDom(e.getElement()));return Hh(t).filter((t=>!Xh(t.dom)&&Jh(e,t.dom))).isSome()})(e),lp=e=>e.editorManager.setActive(e),cp=(e,t)=>{e.removed||(t?lp(e):(e=>{const t=e.selection,o=e.getBody();let n=t.getRng();e.quirks.refreshContentEditable(),C(e.bookmark)&&!ap(e)&&Wh(e).each((t=>{e.selection.setRng(t),n=t}));const r=((e,t)=>e.dom.getParent(t,(t=>"true"===e.dom.getContentEditable(t))))(e,t.getNode());if(r&&e.dom.isChildOf(r,o))return rp(r),np(e,n),void lp(e);e.inline||(At.browser.isOpera()||rp(o),e.getWin().focus()),(At.browser.isFirefox()||e.inline)&&(rp(o),np(e,n)),lp(e)})(e))},dp=(e,t)=>t.collapsed?e.isEditable(t.startContainer):e.isEditable(t.startContainer)&&e.isEditable(t.endContainer),mp=(e,t,o,n,r)=>{const s=o?t.startContainer:t.endContainer,a=o?t.startOffset:t.endOffset;return F.from(s).map(yo.fromDom).map((e=>n&&t.collapsed?e:Ho(e,r(e,a)).getOr(e))).bind((e=>Gt(e)?F.some(e):Oo(e).filter(Gt))).map((e=>e.dom)).getOr(e)},up=(e,t,o=!1)=>mp(e,t,!0,o,((e,t)=>Math.min(Fo(e),t))),gp=(e,t,o=!1)=>mp(e,t,!1,o,((e,t)=>t>0?t-1:t)),hp=(e,t)=>{const o=e;for(;e&&tr(e)&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||o},pp=(e,t)=>$(t,(t=>{const o=e.dispatch("GetSelectionRange",{range:t});return o.range!==t?o.range:t})),fp=["img","br"],vp=e=>{const t=Cr(e).filter((e=>0!==e.trim().length||e.indexOf(br)>-1)).isSome();return t||j(fp,jt(e))||(e=>qt(e)&&"false"===oo(e,"contenteditable"))(e)},bp=(e,t)=>{const o=e=>{const n=Lo(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return F.some(r);const s=o(r);if(s.isSome())return s}return F.none()};return o(e)},yp="[data-mce-autocompleter]",wp=(e,t)=>{if(xp(yo.fromDom(e.getBody())).isNone()){const n=yo.fromHtml('',e.getDoc());bn(n,yo.fromDom(t.extractContents())),t.insertNode(n.dom),Oo(n).each((e=>e.dom.normalize())),(o=n,bp(o,vp)).map((t=>{e.selection.setCursorLocation(t.dom,(e=>"img"===jt(e)?1:Cr(e).fold((()=>Lo(e).length),(e=>e.length)))(t))}))}var o},xp=e=>tn(e,yp),Cp={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},Sp=(e,t,o)=>{const n=o?"lastChild":"firstChild",r=o?"prev":"next";if(e[n])return e[n];if(e!==t){let o=e[r];if(o)return o;for(let n=e.parent;n&&n!==t;n=n.parent)if(o=n[r],o)return o}},kp=e=>{var t;const o=null!==(t=e.value)&&void 0!==t?t:"";if(!is(o))return!1;const n=e.parent;return!n||"span"===n.name&&!n.attr("style")||!/^[ ]+$/.test(o)},_p=e=>{const t="a"===e.name&&!e.attr("href")&&e.attr("id");return e.attr("name")||e.attr("id")&&!e.firstChild||e.attr("data-mce-bookmark")||t};class Ep{static create(e,t){const o=new Ep(e,Cp[e]||1);return t&&fe(t,((e,t)=>{o.attr(t,e)})),o}constructor(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}replace(e){const t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t}attr(e,t){const o=this;if(!h(e))return C(e)&&fe(e,((e,t)=>{o.attr(t,e)})),o;const n=o.attributes;if(n){if(void 0!==t){if(null===t){if(e in n.map){delete n.map[e];let t=n.length;for(;t--;)if(n[t].name===e)return n.splice(t,1),o}return o}if(e in n.map){let o=n.length;for(;o--;)if(n[o].name===e){n[o].value=t;break}}else n.push({name:e,value:t});return n.map[e]=t,o}return n.map[e]}}clone(){const e=this,t=new Ep(e.name,e.type),o=e.attributes;if(o){const e=[];e.map={};for(let t=0,n=o.length;th(e.nodeValue)&&e.nodeValue.includes(Br),Dp=e=>(0===e.length?"":`${$(e,(e=>`[${e}]`)).join(",")},`)+'[data-mce-bogus="all"]',Ap=e=>document.createTreeWalker(e,NodeFilter.SHOW_COMMENT,(e=>Op(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP)),Mp=e=>document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>{if(Op(e)){const t=e.parentNode;return t&&_e(Tp,t.nodeName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}return NodeFilter.FILTER_SKIP})),Np=e=>null!==Ap(e).nextNode(),Rp=e=>null!==Mp(e).nextNode(),Bp=(e,t)=>null!==t.querySelector(Dp(e)),Lp=(e,t)=>{q(((e,t)=>t.querySelectorAll(Dp(e)))(e,t),(t=>{const o=yo.fromDom(t);"all"===oo(o,"data-mce-bogus")?Cn(o):q(e,(e=>{ro(o,e)&&so(o,e)}))}))},Hp=e=>{let t=e.nextNode();for(;null!==t;)t.nodeValue=null,t=e.nextNode()},Ip=T(Hp,Ap),Pp=T(Hp,Mp),Fp=(e,t)=>{const o=[{condition:N(Bp,t),action:N(Lp,t)},{condition:Np,action:Ip},{condition:Rp,action:Pp}];let n=e,r=!1;return q(o,(({condition:t,action:o})=>{t(n)&&(r||(n=e.cloneNode(!0),r=!0),o(n))})),n},zp=e=>{const t=zn(e,"[data-mce-bogus]");q(t,(e=>{"all"===oo(e,"data-mce-bogus")?Cn(e):kr(e)?(pn(e,yo.fromText(vr)),Cn(e)):Sn(e)}))},Vp=e=>{const t=zn(e,"input");q(t,(e=>{so(e,"name")}))},Zp=(e,t)=>{const o=e.getDoc(),n=Uo(yo.fromDom(e.getBody())),r=yo.fromTag("div",o);eo(r,"data-mce-bogus","all"),cn(r,{position:"fixed",left:"-9999999px",top:"0"}),En(r,t.innerHTML),zp(r),Vp(r);const s=(e=>zo(e)?e:yo.fromDom(Eo(e).dom.body))(n);bn(s,r);const a=Hr(r.dom.innerText);return Cn(r),a},Up=(e,t,o)=>{let n;return n="raw"===t.format?Bt.trim(Hr(Fp(o,e.serializer.getTempAttrs()).innerHTML)):"text"===t.format?Zp(e,o):"tree"===t.format?e.serializer.serialize(o,t):((e,t)=>{const o=Xl(e),n=new RegExp(`^(<${o}[^>]*>( | |\\s| |
    |)<\\/${o}>[\r\n]*|
    [\r\n]*)$`);return t.replace(n,"")})(e,e.serializer.serialize(o,t)),"text"!==t.format&&!Ar(yo.fromDom(o))&&h(n)?Bt.trim(n):n},jp=Bt.makeMap,Wp=e=>{const t=[],o=(e=e||{}).indent,n=jp(e.indent_before||""),r=jp(e.indent_after||""),s=ia.getEncodeFunc(e.entity_encoding||"raw",e.entities),a="xhtml"!==e.element_format;return{start:(e,i,l)=>{if(o&&n[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}if(t.push("<",e),i)for(let e=0,o=i.length;e":" />",l&&o&&r[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}},end:e=>{let n;t.push(""),o&&r[e]&&t.length>0&&(n=t[t.length-1],n.length>0&&"\n"!==n&&t.push("\n"))},text:(e,o)=>{e.length>0&&(t[t.length]=o?e:s(e))},cdata:e=>{t.push("")},comment:e=>{t.push("\x3c!--",e,"--\x3e")},pi:(e,n)=>{n?t.push(""):t.push(""),o&&t.push("\n")},doctype:e=>{t.push("",o?"\n":"")},reset:()=>{t.length=0},getContent:()=>t.join("").replace(/\n$/,"")}},$p=(e={},t=ya())=>{const o=Wp(e);return e.validate=!("validate"in e)||e.validate,{serialize:n=>{const r=e.validate,s={3:e=>{var t;o.text(null!==(t=e.value)&&void 0!==t?t:"",e.raw)},8:e=>{var t;o.comment(null!==(t=e.value)&&void 0!==t?t:"")},7:e=>{o.pi(e.name,e.value)},10:e=>{var t;o.doctype(null!==(t=e.value)&&void 0!==t?t:"")},4:e=>{var t;o.cdata(null!==(t=e.value)&&void 0!==t?t:"")},11:e=>{let t=e;if(t=t.firstChild)do{a(t)}while(t=t.next)}};o.reset();const a=e=>{var n;const i=s[e.type];if(i)i(e);else{const s=e.name,i=s in t.getVoidElements();let l=e.attributes;if(r&&l&&l.length>1){const o=[];o.map={};const n=t.getElementRule(e.name);if(n){for(let e=0,t=n.attributesOrder.length;e{qp.add(e)}));const Gp=["font","text-decoration","text-emphasis"],Kp=(e,t)=>he(e.parseStyle(e.getAttrib(t,"style"))),Yp=(e,t)=>re(Kp(e,t),(e=>!(e=>qp.has(e))(e))),Xp=(e,t,o)=>{const n=Kp(e,t),r=Kp(e,o),s=n=>{var r,s;const a=null!==(r=e.getStyle(t,n))&&void 0!==r?r:"",i=null!==(s=e.getStyle(o,n))&&void 0!==s?s:"";return Ye(a)&&Ye(i)&&a!==i};return W(n,(e=>{const t=t=>W(t,(t=>t===e));if(!t(r)&&t(Gp)){const e=Y(r,(e=>W(Gp,(t=>je(e,t)))));return W(e,s)}return s(e)}))},Jp=(e,t,o)=>F.from(o.container()).filter(tr).exists((n=>{const r=e?0:-1;return t(n.data.charAt(o.offset()+r))})),Qp=N(Jp,!0,hu),ef=N(Jp,!1,hu),tf=e=>{const t=e.container();return tr(t)&&(0===t.data.length||Lr(t.data)&&xg.isBookmarkNode(t.parentNode))},of=(e,t)=>o=>hm(e?0:-1,o).filter(t).isSome(),nf=e=>lr(e)&&"block"===dn(yo.fromDom(e),"display"),rf=e=>dr(e)&&!(e=>Wn(e)&&"all"===e.getAttribute("data-mce-bogus"))(e),sf=of(!0,nf),af=of(!1,nf),lf=of(!0,gr),cf=of(!1,gr),df=of(!0,Jn),mf=of(!1,Jn),uf=of(!0,rf),gf=of(!1,rf),hf=(e,t)=>((e,t,o)=>ko(t,e)?Ao(e,(e=>o(e)||So(e,t))).slice(0,-1):[])(e,t,I),pf=(e,t)=>[e].concat(hf(e,t)),ff=(e,t,o)=>jm(e,t,o,tf),vf=(e,t,o)=>ee(pf(yo.fromDom(t.container()),e),(e=>t=>e.isBlock(jt(t)))(o)),bf=(e,t,o,n)=>ff(e,t.dom,o).forall((e=>vf(t,o,n).fold((()=>!gm(e,o,t.dom)),(n=>!gm(e,o,t.dom)&&ko(n,yo.fromDom(e.container())))))),yf=(e,t,o,n)=>vf(t,o,n).fold((()=>ff(e,t.dom,o).forall((e=>!gm(e,o,t.dom)))),(t=>ff(e,t.dom,o).isNone())),wf=N(yf,!1),xf=N(yf,!0),Cf=N(bf,!1),Sf=N(bf,!0),kf=e=>Sm(e).exists(kr),_f=(e,t,o,n)=>{const r=Y(pf(yo.fromDom(o.container()),t),(e=>n.isBlock(jt(e)))),s=de(r).getOr(t);return Zm(e,s.dom,o).filter(kf)},Ef=(e,t,o)=>Sm(t).exists(kr)||_f(!0,e,t,o).isSome(),Tf=(e,t,o)=>(e=>F.from(e.getNode(!0)).map(yo.fromDom))(t).exists(kr)||_f(!1,e,t,o).isSome(),Of=N(_f,!1),Df=N(_f,!0),Af=e=>rl.isTextPosition(e)&&!e.isAtStart()&&!e.isAtEnd(),Mf=(e,t,o)=>{const n=Y(pf(yo.fromDom(t.container()),e),(e=>o.isBlock(jt(e))));return de(n).getOr(e)},Nf=(e,t,o)=>Af(t)?ef(t):ef(t)||qm(Mf(e,t,o).dom,t).exists(ef),Rf=(e,t,o)=>Af(t)?Qp(t):Qp(t)||$m(Mf(e,t,o).dom,t).exists(Qp),Bf=e=>Sm(e).bind((e=>Xo(e,Gt))).exists((e=>(e=>j(["pre","pre-wrap"],e))(dn(e,"white-space")))),Lf=(e,t,o)=>((e,t)=>qm(e.dom,t).isNone())(e,t)||((e,t)=>$m(e.dom,t).isNone())(e,t)||wf(e,t,o)||xf(e,t,o)||Tf(e,t,o)||Ef(e,t,o),Hf=(e,t)=>o=>{return n=new Zn(o,e)[t](),C(n)&&dr(n)&&om(n);var n},If=(e,t,o)=>!Bf(t)&&(Lf(e,t,o)||Nf(e,t,o)||Rf(e,t,o)),Pf=(e,t,o)=>!Bf(t)&&(wf(e,t,o)||Cf(e,t,o)||Tf(e,t,o)||Nf(e,t,o)||((e,t)=>{const o=qm(e.dom,t).getOr(t),n=Hf(e.dom,"prev");return t.isAtStart()&&(n(t.container())||n(o.container()))})(e,t)),Ff=(e,t,o)=>!Bf(t)&&(xf(e,t,o)||Sf(e,t,o)||Ef(e,t,o)||Rf(e,t,o)||((e,t)=>{const o=$m(e.dom,t).getOr(t),n=Hf(e.dom,"next");return t.isAtEnd()&&(n(t.container())||n(o.container()))})(e,t)),zf=(e,t,o)=>Pf(e,t,o)||Ff(e,(e=>{const t=e.container(),o=e.offset();return tr(t)&&ouu(e.charAt(t)),Zf=(e,t)=>hu(e.charAt(t)),Uf=(e,t,o,n)=>{const r=t.data,s=rl(t,0);return o||!Vf(r,0)||zf(e,s,n)?!!(o&&Zf(r,0)&&Pf(e,s,n))&&(t.data=br+r.slice(1),!0):(t.data=" "+r.slice(1),!0)},jf=e=>{const t=e.data,o=(e=>{const t=e.split("");return $(t,((e,o)=>uu(e)&&o>0&&o{const r=t.data,s=rl(t,r.length-1);return o||!Vf(r,r.length-1)||zf(e,s,n)?!!(o&&Zf(r,r.length-1)&&Ff(e,s,n))&&(t.data=r.slice(0,-1)+br,!0):(t.data=r.slice(0,-1)+" ",!0)},$f=(e,t,o)=>{const n=t.container();if(!tr(n))return F.none();if((e=>{const t=e.container();return tr(t)&&Ue(t.data,br)})(t)){const r=Uf(e,n,!1,o)||jf(n)||Wf(e,n,!1,o);return Pt(r,t)}if(zf(e,t,o)){const r=Uf(e,n,!0,o)||Wf(e,n,!0,o);return Pt(r,t)}return F.none()},qf=(e,t,o,n)=>{if(0===o)return;const r=yo.fromDom(e),s=Yo(r,(e=>n.isBlock(jt(e)))).getOr(r),a=e.data.slice(t,t+o),i=t+o>=e.data.length&&Ff(s,rl(e,e.data.length),n),l=0===t&&Pf(s,rl(e,0),n);e.replaceData(t,o,ds(a,4,l,i))},Gf=(e,t,o)=>{const n=e.data.slice(t),r=n.length-Ge(n).length;qf(e,t,r,o)},Kf=(e,t,o)=>{const n=e.data.slice(0,t),r=n.length-Ke(n).length;qf(e,t-r,r,o)},Yf=(e,t,o,n,r=!0)=>{const s=Ke(e.data).length,a=r?e:t,i=r?t:e;return r?a.appendData(i.data):a.insertData(0,i.data),Cn(yo.fromDom(i)),n&&Gf(a,s,o),a},Xf=(e,t)=>((e,t)=>{const o=e.container(),n=e.offset();return!rl.isTextPosition(e)&&o===t.parentNode&&n>rl.before(t).offset()})(t,e)?rl(t.container(),t.offset()-1):t,Jf=e=>{return ns(e.previousSibling)?F.some((t=e.previousSibling,tr(t)?rl(t,t.data.length):rl.after(t))):e.previousSibling?Km(e.previousSibling):F.none();var t},Qf=e=>{return ns(e.nextSibling)?F.some((t=e.nextSibling,tr(t)?rl(t,0):rl.before(t))):e.nextSibling?Gm(e.nextSibling):F.none();var t},ev=(e,t)=>Jf(t).orThunk((()=>Qf(t))).orThunk((()=>((e,t)=>F.from(t.previousSibling?t.previousSibling:t.parentNode).bind((t=>qm(e,rl.before(t)))).orThunk((()=>$m(e,rl.after(t)))))(e,t))),tv=(e,t)=>Qf(t).orThunk((()=>Jf(t))).orThunk((()=>((e,t)=>$m(e,rl.after(t)).orThunk((()=>qm(e,rl.before(t)))))(e,t))),ov=(e,t,o)=>((e,t,o)=>e?tv(t,o):ev(t,o))(e,t,o).map(N(Xf,o)),nv=(e,t,o)=>{o.fold((()=>{e.focus()}),(o=>{e.selection.setRng(o.toRange(),t)}))},rv=(e,t)=>t&&_e(e.schema.getBlockElements(),jt(t)),sv=(e,t,o,n)=>{const r=Mo(e).filter(Kt),s=No(e).filter(Kt);return Cn(e),(a=r,i=s,l=t,c=(e,t,r)=>{const s=e.dom,a=t.dom,i=s.data.length;return Yf(s,a,o,n),r.container()===a?rl(s,i):r},a.isSome()&&i.isSome()&&l.isSome()?F.some(c(a.getOrDie(),i.getOrDie(),l.getOrDie())):F.none()).orThunk((()=>(n&&(r.each((e=>Kf(e.dom,e.dom.length,o))),s.each((e=>Gf(e.dom,0,o)))),t)));var a,i,l,c},av=(e,t,o,n=!0,r=!1)=>{const s=ov(t,e.getBody(),o.dom),a=Yo(o,N(rv,e),(i=e.getBody(),e=>e.dom===i));var i;const l=sv(o,s,e.schema,((e,t)=>_e(e.schema.getTextInlineElements(),jt(t)))(e,o));e.dom.isEmpty(e.getBody())?(e.setContent(""),e.selection.setCursorLocation()):a.bind((e=>((e,t)=>{if(ys(e)){const o=yo.fromHtml('
    ');return t?q(Lo(e),(e=>{Yu(e)||Cn(e)})):xn(e),bn(e,o),F.some(rl.before(o.dom))}return F.none()})(e,r))).fold((()=>{n&&nv(e,t,l)}),(o=>{n&&nv(e,t,F.some(o))}))},iv=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,lv=(e,t)=>xo(yo.fromDom(t),Sc(e))&&!Ls(e.schema,t)&&e.dom.isEditable(t),cv=e=>{var t;return"rtl"===Ya.DOM.getStyle(e,"direction",!0)||(e=>iv.test(e))(null!==(t=e.textContent)&&void 0!==t?t:"")},dv=(e,t,o)=>{const n=((e,t,o)=>Y(Ya.DOM.getParents(o.container(),"*",t),e))(e,t,o);return F.from(n[n.length-1])},mv=(e,t)=>{const o=t.container(),n=t.offset();return e?zr(o)?tr(o.nextSibling)?rl(o.nextSibling,0):rl.after(o):Ur(t)?rl(o,n+1):t:zr(o)?tr(o.previousSibling)?rl(o.previousSibling,o.previousSibling.data.length):rl.before(o):jr(t)?rl(o,n-1):t},uv=N(mv,!0),gv=N(mv,!1),hv=(e,t)=>{const o=e=>e.stopImmediatePropagation();e.on("beforeinput input",o,!0),e.getDoc().execCommand(t),e.off("beforeinput input",o)},pv=e=>hv(e,"Delete"),fv=e=>_r(e)||Tr(e),vv=(e,t)=>ko(e,t)?Xo(t,fv,(e=>t=>Lt(Oo(t),e,So))(e)):F.none(),bv=(e,t=!0)=>{e.dom.isEmpty(e.getBody())&&e.setContent("",{no_selection:!t})},yv=(e,t,o)=>It(Gm(o),Km(o),((n,r)=>{const s=mv(!0,n),a=mv(!1,r),i=mv(!1,t);return e?$m(o,i).exists((e=>e.isEqual(a)&&t.isEqual(s))):qm(o,i).exists((e=>e.isEqual(s)&&t.isEqual(a)))})).getOr(!0),wv=e=>{var t;return(8===Wt(t=e)||"#comment"===jt(t)?Mo(e):Po(e)).bind(wv).orThunk((()=>F.some(e)))},xv=(e,t,o,n=!0)=>{var r;t.deleteContents();const s=wv(o).getOr(o),a=yo.fromDom(null!==(r=e.dom.getParent(s.dom,e.dom.isBlock))&&void 0!==r?r:o.dom);if(a.dom===e.getBody()?bv(e,n):ys(a)&&(Rr(a),n&&e.selection.setCursorLocation(a.dom,0)),!So(o,a)){const e=Lt(Oo(a),o)?[]:Oo(i=a).map(Lo).map((e=>Y(e,(e=>!So(i,e))))).getOr([]);q(e.concat(Lo(o)),(e=>{So(e,a)||ko(e,a)||!ys(e)||Cn(e)}))}var i},Cv=(e,t)=>((e,t)=>{const o=e.dom;return o.parentNode?Jo(yo.fromDom(o.parentNode),(o=>!So(e,o)&&t(o))):F.none()})(e,t).isSome(),Sv=(e,t)=>Qo(e,t).isSome(),kv=e=>zn(e,"td,th"),_v=(e,t)=>wu(yo.fromDom(e),t),Ev=e=>(e=>It(e.startTable,e.endTable,((t,o)=>{const n=Sv(t,(e=>So(e,o))),r=Sv(o,(e=>So(e,t)));return n||r?{...e,startTable:n?F.none():e.startTable,endTable:r?F.none():e.endTable,isSameTable:!1,isMultiTable:!1}:e})).getOr(e))(e),Tv=(e,t)=>({start:e,end:t}),Ov=Al([{singleCellTable:["rng","cell"]},{fullTable:["table"]},{partialTable:["cells","outsideDetails"]},{multiTable:["startTableCells","endTableCells","betweenRng"]}]),Dv=(e,t)=>on(yo.fromDom(e),"td,th",t),Av=e=>!So(e.start,e.end),Mv=(e,t)=>wu(e.start,t).bind((o=>wu(e.end,t).bind((e=>Pt(So(o,e),o))))),Nv=e=>t=>Mv(t,e).map((e=>((e,t,o)=>({rng:e,table:t,cells:o}))(t,e,kv(e)))),Rv=(e,t,o,n)=>{if(o.collapsed||!e.forall(Av))return F.none();if(t.isSameTable){const t=e.bind(Nv(n));return F.some({start:t,end:t})}{const e=Dv(o.startContainer,n),t=Dv(o.endContainer,n),r=e.bind((e=>t=>wu(t,e).bind((e=>me(kv(e)).map((e=>Tv(t,e))))))(n)).bind(Nv(n)),s=t.bind((e=>t=>wu(t,e).bind((e=>de(kv(e)).map((e=>Tv(e,t))))))(n)).bind(Nv(n));return F.some({start:r,end:s})}},Bv=(e,t)=>te(e,(e=>So(e,t))),Lv=e=>It(Bv(e.cells,e.rng.start),Bv(e.cells,e.rng.end),((t,o)=>e.cells.slice(t,o+1))),Hv=(e,t,o)=>e.exists((e=>((e,t)=>!Av(e)&&Mv(e,t).exists((e=>{const t=e.dom.rows;return 1===t.length&&1===t[0].cells.length})))(e,o)&&Su(e.start,t))),Iv=(e,t)=>{const{startTable:o,endTable:n}=t,r=e.cloneRange();return o.each((e=>r.setStartAfter(e.dom))),n.each((e=>r.setEndBefore(e.dom))),r},Pv=(e,t)=>{const o=(e=>t=>So(e,t))(e),n=((e,t)=>{const o=Dv(e.startContainer,t),n=Dv(e.endContainer,t);return It(o,n,Tv)})(t,o),r=((e,t)=>{const o=_v(e.startContainer,t),n=_v(e.endContainer,t),r=o.isSome(),s=n.isSome(),a=It(o,n,So).getOr(!1);return Ev({startTable:o,endTable:n,isStartInTable:r,isEndInTable:s,isSameTable:a,isMultiTable:!a&&r&&s})})(t,o);return Hv(n,t,o)?n.map((e=>Ov.singleCellTable(t,e.start))):r.isMultiTable?((e,t,o,n)=>Rv(e,t,o,n).bind((({start:e,end:n})=>{const r=e.bind(Lv).getOr([]),s=n.bind(Lv).getOr([]);if(r.length>0&&s.length>0){const e=Iv(o,t);return F.some(Ov.multiTable(r,s,e))}return F.none()})))(n,r,t,o):((e,t,o,n)=>Rv(e,t,o,n).bind((({start:e,end:t})=>e.or(t))).bind((e=>{const{isSameTable:n}=t,r=Lv(e).getOr([]);if(n&&e.cells.length===r.length)return F.some(Ov.fullTable(e.table));if(r.length>0){if(n)return F.some(Ov.partialTable(r,F.none()));{const e=Iv(o,t);return F.some(Ov.partialTable(r,F.some({...t,rng:e})))}}return F.none()})))(n,r,t,o)},Fv=e=>q(e,(e=>{so(e,"contenteditable"),Rr(e)})),zv=(e,t,o,n)=>{const r=o.cloneRange();n?(r.setStart(o.startContainer,o.startOffset),r.setEndAfter(t.dom.lastChild)):(r.setStartBefore(t.dom.firstChild),r.setEnd(o.endContainer,o.endOffset)),jv(e,r,t,!1).each((e=>e()))},Vv=e=>{const t=yu(e),o=yo.fromDom(e.selection.getNode());mr(o.dom)&&ys(o)?e.selection.setCursorLocation(o.dom,0):e.selection.collapse(!0),t.length>1&&W(t,(e=>So(e,o)))&&eo(o,"data-mce-selected","1")},Zv=(e,t,o)=>F.some((()=>{const n=e.selection.getRng(),r=o.bind((({rng:o,isStartInTable:r})=>{const s=((e,t)=>F.from(e.dom.getParent(t,e.dom.isBlock)).map(yo.fromDom))(e,r?o.endContainer:o.startContainer);o.deleteContents(),((e,t,o)=>{o.each((o=>{t?Cn(o):(Rr(o),e.selection.setCursorLocation(o.dom,0))}))})(e,r,s.filter(ys));const a=r?t[0]:t[t.length-1];return zv(e,a,n,r),ys(a)?F.none():F.some(r?t.slice(1):t.slice(0,-1))})).getOr(t);Fv(r),Vv(e)})),Uv=(e,t,o,n)=>F.some((()=>{const r=e.selection.getRng(),s=t[0],a=o[o.length-1];zv(e,s,r,!0),zv(e,a,r,!1);const i=ys(s)?t:t.slice(1),l=ys(a)?o:o.slice(0,-1);Fv(i.concat(l)),n.deleteContents(),Vv(e)})),jv=(e,t,o,n=!0)=>F.some((()=>{xv(e,t,o,n)})),Wv=(e,t)=>F.some((()=>av(e,!1,t))),$v=(e,t,o,n)=>Gv(t,n).fold((()=>((e,t,o)=>Pv(t,o).bind((t=>t.fold(N(jv,e),N(Wv,e),N(Zv,e),N(Uv,e)))))(e,t,o)),(t=>((e,t)=>Kv(e,t))(e,t))),qv=(e,t)=>ee(pf(t,e),Dr),Gv=(e,t)=>ee(pf(t,e),Jt("caption")),Kv=(e,t)=>F.some((()=>{Rr(t),e.selection.setCursorLocation(t.dom,0)})),Yv=(e,t,o,n,r)=>Um(o,e.getBody(),r).fold((()=>F.some(E)),(s=>((e,t,o,n)=>Gm(e.dom).bind((r=>Km(e.dom).map((e=>t?o.isEqual(r)&&n.isEqual(e):o.isEqual(e)&&n.isEqual(r))))).getOr(!0))(n,o,r,s)?((e,t)=>Kv(e,t))(e,n):((e,t,o)=>Gv(e,yo.fromDom(o.getNode())).fold((()=>F.some(E)),(e=>Pt(!So(e,t),E))))(t,n,s))),Xv=(e,t,o,n)=>{const r=rl.fromRangeStart(e.selection.getRng());return qv(o,n).bind((n=>ys(n)?Kv(e,n):((e,t,o,n,r)=>Um(o,e.getBody(),r).bind((e=>qv(t,yo.fromDom(e.getNode())).bind((e=>So(e,n)?F.none():F.some(E))))))(e,o,t,n,r)))},Jv=(e,t)=>e?df(t):mf(t),Qv=(e,t,o)=>{const n=yo.fromDom(e.getBody());return Gv(n,o).fold((()=>Xv(e,t,n,o).orThunk((()=>Pt(((e,t)=>{const o=rl.fromRangeStart(e.selection.getRng());return Jv(t,o)||Zm(t,e.getBody(),o).exists((e=>Jv(t,e)))})(e,t),E)))),(o=>((e,t,o,n)=>{const r=rl.fromRangeStart(e.selection.getRng());return ys(n)?Kv(e,n):Yv(e,o,t,n,r)})(e,t,n,o)))},eb=(e,t)=>{const o=yo.fromDom(e.selection.getStart(!0)),n=yu(e);return e.selection.isCollapsed()&&0===n.length?Qv(e,t,o):((e,t,o)=>{const n=yo.fromDom(e.getBody()),r=e.selection.getRng();return 0!==o.length?Zv(e,o,F.none()):$v(e,n,r,t)})(e,o,n)},tb=(e,t)=>{let o=t;for(;o&&o!==e;){if(cr(o)||dr(o))return o;o=o.parentNode}return null},ob=["data-ephox-","data-mce-","data-alloy-","data-snooker-","_"],nb=Bt.each,rb=e=>{const t=e.dom,o=new Set(e.serializer.getTempAttrs()),n=e=>W(ob,(t=>je(e,t)))||o.has(e);return{compare:(e,o)=>{if(e.nodeName!==o.nodeName||e.nodeType!==o.nodeType)return!1;const r=e=>{const o={};return nb(t.getAttribs(e),(r=>{const s=r.nodeName.toLowerCase();"style"===s||n(s)||(o[s]=t.getAttrib(e,s))})),o},s=(e,t)=>{for(const o in e)if(_e(e,o)){const n=t[o];if(w(n))return!1;if(e[o]!==n)return!1;delete t[o]}for(const e in t)if(_e(t,e))return!1;return!0};if(Wn(e)&&Wn(o)){if(!s(r(e),r(o)))return!1;if(!s(t.parseStyle(t.getAttrib(e,"style")),t.parseStyle(t.getAttrib(o,"style"))))return!1}return!mu(e)&&!mu(o)},isAttributeInternal:n}},sb=e=>["h1","h2","h3","h4","h5","h6"].includes(e.name),ab=(e,t,o,n)=>{const r=o.name;for(let t=0,s=e.length;t{const o=(e,o)=>{fe(e,(e=>{const n=ue(e.nodes);q(e.filter.callbacks,(r=>{for(let t=n.length-1;t>=0;t--){const r=n[t];(o?void 0!==r.attr(e.filter.name):r.name===e.filter.name)&&!x(r.parent)||n.splice(t,1)}n.length>0&&r(n,e.filter.name,t)}))}))};o(e.nodes,!1),o(e.attributes,!0)},lb=(e,t,o,n={})=>{const r=((e,t,o)=>{const n={nodes:{},attributes:{}};return o.firstChild&&((e,t)=>{let o=e;for(;o=o.walk();)t(o)})(o,(o=>{ab(e,t,o,n)})),n})(e,t,o);ib(r,n)},cb=(e,t,o,n)=>{if((e.pad_empty_with_br||t.insert)&&o(n)){const e=new Ep("br",1);t.insert&&e.attr("data-mce-bogus","1"),n.empty().append(e)}else n.empty().append(new Ep("#text",3)).value=br},db=(e,t)=>{const o=null==e?void 0:e.firstChild;return C(o)&&o===e.lastChild&&o.name===t},mb=(e,t,o,n)=>n.isEmpty(t,o,(t=>((e,t)=>{const o=e.getElementRule(t.name);return!0===(null==o?void 0:o.paddEmpty)})(e,t))),ub=e=>{let t;for(let o=e;o;o=o.parent){const e=o.attr("contenteditable");if("false"===e)break;"true"===e&&(t=o)}return F.from(t)},gb=(e,t,o=e.parent)=>{if(t.getSpecialElements()[e.name])e.empty().remove();else{const n=e.children();for(const e of n)o&&!t.isValidChild(o.name,e.name)&&gb(e,t,o);e.unwrap()}},hb=(e,t,o,n=E)=>{const r=t.getTextBlockElements(),s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=Bt.makeMap("tr,td,th,tbody,thead,tfoot,table,summary"),l=new Set,c=e=>e!==o&&!i[e.name];for(let o=0;o1)if(pb(t,i,d))gb(i,t);else{g.reverse(),m=g[0].clone(),n(m);let e=m;for(let o=0;o0?(u=g[o].clone(),n(u),e.append(u)):u=e;for(let e=g[o].firstChild;e&&e!==g[o+1];){const t=e.next;u.append(e),e=t}e=u}mb(t,s,a,m)?d.insert(i,g[0],!0):(d.insert(m,g[0],!0),d.insert(i,m)),d=g[0],(mb(t,s,a,d)||db(d,"br"))&&d.empty().remove()}else if(i.parent){if("li"===i.name){let e=i.prev;if(e&&("ul"===e.name||"ol"===e.name)){e.append(i);continue}if(e=i.next,e&&("ul"===e.name||"ol"===e.name)&&e.firstChild){e.insert(i,e.firstChild,!0);continue}const t=new Ep("ul",1);n(t),i.wrap(t);continue}if(t.isValidChild(i.parent.name,"div")&&t.isValidChild("div",i.name)){const e=new Ep("div",1);n(e),i.wrap(e)}else gb(i,t)}}},pb=(e,t,o=t.parent)=>!(!o||(!e.children[t.name]||e.isValidChild(o.name,t.name))&&("a"!==t.name||!((e,t)=>{let o=e;for(;o;){if(o.name===t)return!0;o=o.parent}return!1})(o,"a"))&&(!(e=>"summary"===e.name)(o)||!sb(t)||(null==o?void 0:o.firstChild)===t&&(null==o?void 0:o.lastChild)===t)),fb=e=>{const t=rl.fromRangeStart(e),o=rl.fromRangeEnd(e),n=e.commonAncestorContainer;return Zm(!1,n,o).map((r=>!gm(t,o,n)&&gm(t,r,n)?((e,t,o,n)=>{const r=document.createRange();return r.setStart(e,t),r.setEnd(o,n),r})(t.container(),t.offset(),r.container(),r.offset()):e)).getOr(e)},vb=e=>e.collapsed?e:fb(e),bb=(e,t)=>e.getBlockElements()[t.name]&&(e=>C(e.firstChild)&&e.firstChild===e.lastChild)(t)&&(e=>"br"===e.name||e.value===br)(t.firstChild),yb=(e,t)=>{let o=t.firstChild,n=t.lastChild;return o&&"meta"===o.name&&(o=o.next),n&&"mce_marker"===n.attr("id")&&(n=n.prev),((e,t)=>{const o=e.getNonEmptyElements();return C(t)&&(t.isEmpty(o)||bb(e,t))})(e,n)&&(n=null==n?void 0:n.prev),!(!o||o!==n||"ul"!==o.name&&"ol"!==o.name)},wb=e=>C(null==e?void 0:e.firstChild)&&e.firstChild===e.lastChild&&(e=>e.data===br||ir(e))(e.firstChild),xb=e=>{return e.length>0&&(!(t=e[e.length-1]).firstChild||wb(t))?e.slice(0,-1):e;var t},Cb=(e,t)=>{const o=e.getParent(t,e.isBlock);return o&&"LI"===o.nodeName?o:null},Sb=(e,t)=>{const o=rl.after(e),n=Im(t).prev(o);return n?n.toRange():null},kb=(e,t,o)=>{const n=e.parentNode;return n&&Bt.each(t,(t=>{n.insertBefore(t,e)})),((e,t)=>{const o=rl.before(e),n=Im(t).next(o);return n?n.toRange():null})(e,o)},_b=(e,t,o,n)=>{const r=((e,t,o)=>{const n=t.serialize(o);return(e=>{var t,o;const n=e.firstChild,r=e.lastChild;return n&&"META"===n.nodeName&&(null===(t=n.parentNode)||void 0===t||t.removeChild(n)),r&&"mce_marker"===r.id&&(null===(o=r.parentNode)||void 0===o||o.removeChild(r)),e})(e.createFragment(n))})(t,e,n),s=Cb(t,o.startContainer),a=xb((i=r.firstChild,Y(null!==(l=null==i?void 0:i.childNodes)&&void 0!==l?l:[],(e=>"LI"===e.nodeName))));var i,l;const c=t.getRoot(),d=e=>{const n=rl.fromRangeStart(o),r=Im(t.getRoot()),a=1===e?r.prev(n):r.next(n),i=null==a?void 0:a.getNode();return!i||Cb(t,i)!==s};return s?d(1)?kb(s,a,c):d(2)?((e,t,o,n)=>(n.insertAfter(t.reverse(),e),Sb(t[0],o)))(s,a,c,t):((e,t,o,n)=>{const r=((e,t)=>{const o=t.cloneRange(),n=t.cloneRange();return o.setStartBefore(e),n.setEndAfter(e),[o.cloneContents(),n.cloneContents()]})(e,n),s=e.parentNode;return s&&(s.insertBefore(r[0],e),Bt.each(t,(t=>{s.insertBefore(t,e)})),s.insertBefore(r[1],e),s.removeChild(e)),Sb(t[t.length-1],o)})(s,a,c,o):null},Eb=["pre"],Tb=mr,Ob=(e,t,o)=>{F.from(e.getParent(t,"td,th")).map(yo.fromDom).each((e=>((e,t)=>{Po(e).each((o=>{Mo(o).each((n=>{t.isBlock(jt(e))&&kr(o)&&t.isBlock(jt(n))&&Cn(o)}))}))})(e,o)))},Db=(e,t)=>{var o,n,r;let s;const a=e.dom,i=e.selection;if(!t)return;i.scrollIntoView(t);const l=tb(e.getBody(),t);if(l&&"false"===a.getContentEditable(l))return a.remove(t),void i.select(l);let c=a.createRng();const d=t.previousSibling;if(tr(d)){c.setStart(d,null!==(n=null===(o=d.nodeValue)||void 0===o?void 0:o.length)&&void 0!==n?n:0);const e=t.nextSibling;tr(e)&&(d.appendData(e.data),null===(r=e.parentNode)||void 0===r||r.removeChild(e))}else c.setStartBefore(t),c.setEndBefore(t);const m=a.getParent(t,a.isBlock);if(a.remove(t),m&&a.isEmpty(m)){const t=Tb(m);xn(yo.fromDom(m)),c.setStart(m,0),c.setEnd(m,0),t||(e=>!!e.getAttribute("data-mce-fragment"))(m)||!(s=(t=>{let o=rl.fromRangeStart(t);return o=Im(e.getBody()).next(o),null==o?void 0:o.toRange()})(c))?a.add(m,a.create("br",t?{}:{"data-mce-bogus":"1"})):(c=s,a.remove(m))}i.setRng(c)},Ab=e=>{const t=e.dom,o=vb(e.selection.getRng());e.selection.setRng(o);const n=t.getParent(o.startContainer,Tb);((e,t,o)=>!!C(o)&&(o===e.getParent(t.endContainer,Tb)&&Su(yo.fromDom(o),t)))(t,o,n)?jv(e,o,yo.fromDom(n)):o.startContainer===o.endContainer&&o.endOffset-o.startOffset==1&&tr(o.startContainer.childNodes[o.startOffset])?o.deleteContents():e.getDoc().execCommand("Delete",!1)},Mb=(e,t,o)=>{var n,r;const s=e.selection,a=e.dom,i=e.parser,l=o.merge,c=$p({validate:!0},e.schema),d='';o.preserve_zwsp||(t=Hr(t)),-1===t.indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,d);let m=s.getRng();const u=m.startContainer,g=e.getBody();u===g&&s.isCollapsed()&&a.isBlock(g.firstChild)&&((e,t)=>C(t)&&!e.schema.getVoidElements()[t.nodeName])(e,g.firstChild)&&a.isEmpty(g.firstChild)&&(m=a.createRng(),m.setStart(g.firstChild,0),m.setEnd(g.firstChild,0),s.setRng(m)),s.isCollapsed()||Ab(e);const h=s.getNode(),p={context:h.nodeName.toLowerCase(),data:o.data,insert:!0},f=i.parse(t,p);if(!0===o.paste&&yb(e.schema,f)&&((e,t)=>!!Cb(e,t))(a,h))return m=_b(c,a,s.getRng(),f),m&&s.setRng(m),t;!0===o.paste&&((e,t,o,n)=>{var r;const s=t.firstChild,a=t.lastChild,i=s===("bookmark"===a.attr("data-mce-type")?a.prev:a),l=j(Eb,s.name);if(i&&l){const t="false"!==s.attr("contenteditable"),a=(null===(r=e.getParent(o,e.isBlock))||void 0===r?void 0:r.nodeName.toLowerCase())===s.name,i=F.from(tb(n,o)).forall(cr);return t&&a&&i}return!1})(a,f,h,e.getBody())&&(null===(n=f.firstChild)||void 0===n||n.unwrap()),(e=>{let t=e;for(;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")})(f);let v=f.lastChild;if(v&&"mce_marker"===v.attr("id")){const t=v;for(v=v.prev;v;v=v.walk(!0))if(3===v.type||!a.isBlock(v.name)){v.parent&&e.schema.isValidChild(v.parent.name,"span")&&v.parent.insert(t,v,"br"===v.name);break}}if(e._selectionOverrides.showBlockCaretContainer(h),p.invalid||((e,t,o)=>{var n;return W(o.children(),sb)&&"SUMMARY"===(null===(n=e.getParent(t,e.isBlock))||void 0===n?void 0:n.nodeName)})(a,h,f)){e.selection.setContent(d);let o,n=s.getNode();const l=e.getBody();for(sr(n)?n=o=l:o=n;o&&o!==l;)n=o,o=o.parentNode;t=n===l?l.innerHTML:a.getOuterHTML(n);const m=i.parse(t),u=(e=>{for(let t=e;t;t=t.walk())if("mce_marker"===t.attr("id"))return F.some(t);return F.none()})(m),g=u.bind(ub).getOr(m);u.each((e=>e.replace(f)));const h=f.children(),p=null!==(r=f.parent)&&void 0!==r?r:m;f.unwrap();const v=Y(h,(t=>pb(e.schema,t,p)));hb(v,e.schema,g),lb(i.getNodeFilters(),i.getAttributeFilters(),m),t=c.serialize(m),n===l?a.setHTML(l,t):a.setOuterHTML(n,t)}else t=c.serialize(f),((e,t,o)=>{var n;if("all"===o.getAttribute("data-mce-bogus"))null===(n=o.parentNode)||void 0===n||n.insertBefore(e.dom.createFragment(t),o);else{const n=o.firstChild,r=o.lastChild;!n||n===r&&"BR"===n.nodeName?e.dom.setHTML(o,t):e.selection.setContent(t,{no_events:!0})}})(e,t,h);var b;return((e,t)=>{const o=e.schema.getTextInlineElements(),n=e.dom;if(t){const t=e.getBody(),r=rb(e);Bt.each(n.select("*[data-mce-fragment]"),(e=>{if(C(o[e.nodeName.toLowerCase()])&&Yp(n,e))for(let o=e.parentElement;C(o)&&o!==t&&!Xp(n,e,o);o=o.parentElement)if(r.compare(o,e)){n.remove(e,!0);break}}))}})(e,l),Db(e,a.get("mce_marker")),b=e.getBody(),Bt.each(b.getElementsByTagName("*"),(e=>{e.removeAttribute("data-mce-fragment")})),Ob(a,s.getStart(),e.schema),((e,t,o)=>{const n=Ao(yo.fromDom(o),(e=>So(e,yo.fromDom(t))));ce(n,n.length-2).filter(Gt).fold((()=>As(e,t)),(t=>As(e,t.dom)))})(e.schema,e.getBody(),s.getStart()),t},Nb=e=>e instanceof Ep,Rb=(e,t,o)=>{e.dom.setHTML(e.getBody(),t),!0!==o&&(e=>{ap(e)&&Gm(e.getBody()).each((t=>{const o=t.getNode(),n=Jn(o)?Gm(o).getOr(t):t;e.selection.setRng(n.toRange())}))})(e)},Bb=(e,t,o)=>F.from(e.getBody()).map((n=>Nb(t)?((e,t,o,n)=>{lb(e.parser.getNodeFilters(),e.parser.getAttributeFilters(),o);const r=$p({validate:!1},e.schema).serialize(o),s=Hr(Ar(yo.fromDom(t))?r:Bt.trim(r));return Rb(e,s,n.no_selection),{content:o,html:s}})(e,n,t,o):((e,t,o,n)=>{if(0===(o=Hr(o)).length||/^\s+$/.test(o)){const r='
    ';"TABLE"===t.nodeName?o=""+r+"":/^(UL|OL)$/.test(t.nodeName)&&(o="
  • "+r+"
  • ");const s=Xl(e);return e.schema.isValidChild(t.nodeName.toLowerCase(),s.toLowerCase())?(o=r,o=e.dom.createHTML(s,Jl(e),o)):o||(o=r),Rb(e,o,n.no_selection),{content:o,html:o}}{"raw"!==n.format&&(o=$p({validate:!1},e.schema).serialize(e.parser.parse(o,{isRootContent:!0,insert:!0})));const r=Ar(yo.fromDom(t))?o:Bt.trim(o);return Rb(e,r,n.no_selection),{content:r,html:r}}})(e,n,t,o))).getOr({content:t,html:Nb(o.content)?"":o.content}),Lb=e=>S(e)?e:I,Hb=(e,t,o)=>{const n=t(e),r=Lb(o);return n.orThunk((()=>r(e)?F.none():((e,t,o)=>{let n=e.dom;const r=Lb(o);for(;n.parentNode;){n=n.parentNode;const e=yo.fromDom(n),o=t(e);if(o.isSome())return o;if(r(e))break}return F.none()})(e,t,r)))},Ib=Pu,Pb=(e,t,o)=>{const n=e.formatter.get(o);if(n)for(let o=0;o{const s=e.dom.getRoot();if(t===s)return!1;const a=e.dom.getParent(t,(t=>!!Pb(e,t,o)||t.parentNode===s||!!Zb(e,t,o,n,!0)));return!!Zb(e,a,o,n,r)},zb=(e,t,o)=>!(!qu(o)||!Ib(t,o.inline))||!(!Wu(o)||!Ib(t,o.block))||!!$u(o)&&Wn(t)&&e.is(t,o.selector),Vb=(e,t,o,n,r,s)=>{const a=o[n],i="attributes"===n;if(S(o.onmatch))return o.onmatch(t,o,n);if(a)if(Oe(a)){for(let o=0;o{const s=e.formatter.get(o),a=e.dom;if(s&&Wn(t))for(let o=0;o{if(n)return Fb(e,n,t,o,r);if(n=e.selection.getNode(),Fb(e,n,t,o,r))return!0;const s=e.selection.getStart();return!(s===n||!Fb(e,s,t,o,r))},jb=(e,t)=>{const o=t=>So(t,yo.fromDom(e.getBody()));return F.from(e.selection.getStart(!0)).bind((n=>Hb(yo.fromDom(n),(o=>ge(t,(t=>((t,o)=>Zb(e,t.dom,o)?F.some(o):F.none())(o,t)))),o))).getOrNull()},Wb=(e,t,o)=>J(o,((o,n)=>{const r=((e,t)=>Uu(e,t,(e=>{const t=e=>S(e)||e.length>1&&"%"===e.charAt(0);return W(["styles","attributes"],(o=>ke(e,o).exists((e=>{const o=v(e)?e:Se(e);return W(o,t)}))))})))(e,n);return e.formatter.matchNode(t,n,{},r)?o.concat([n]):o}),[]),$b=Br,qb=e=>{if(e){const t=new Zn(e,e);for(let e=t.current();e;e=t.next())if(tr(e))return e}return null},Gb=e=>{const t=yo.fromTag("span");return to(t,{id:Ym,"data-mce-bogus":"1","data-mce-type":"format-caret"}),e&&bn(t,yo.fromText($b)),t},Kb=(e,t,o)=>{const n=e.dom,r=e.selection;if(Ku(t))av(e,!1,yo.fromDom(t),o,!0);else{const e=r.getRng(),o=n.getParent(t,n.isBlock),s=e.startContainer,a=e.startOffset,i=e.endContainer,l=e.endOffset,c=(e=>{const t=qb(e);return t&&t.data.charAt(0)===$b&&t.deleteData(0,1),t})(t);n.remove(t,!0),s===c&&a>0&&e.setStart(c,a-1),i===c&&l>0&&e.setEnd(c,l-1),o&&n.isEmpty(o)&&Rr(yo.fromDom(o)),r.setRng(e)}},Yb=(e,t,o)=>{const n=e.dom,r=e.selection;if(t)Kb(e,t,o);else if(!(t=Jm(e.getBody(),r.getStart())))for(;t=n.get(Ym);)Kb(e,t,o)},Xb=(e,t)=>(e.appendChild(t),t),Jb=(e,t)=>{var o;const n=X(e,((e,t)=>Xb(e,t.cloneNode(!1))),t),r=null!==(o=n.ownerDocument)&&void 0!==o?o:document;return Xb(n,r.createTextNode($b))},Qb=(e,t,o,n)=>{const r=e.dom,s=e.selection;let a=!1;const i=e.formatter.get(t);if(!i)return;const l=s.getRng(),c=l.startContainer,d=l.startOffset;let m=c;tr(c)&&(d!==c.data.length&&(a=!0),m=m.parentNode);const u=[];let g;for(;m;){if(Zb(e,m,t,o,n)){g=m;break}m.nextSibling&&(a=!0),u.push(m),m=m.parentNode}if(g)if(a){const a=s.getBookmark();l.collapse(!0);let c=mg(r,l,i,!0);c=dh(c),e.formatter.remove(t,o,c,n),s.moveToBookmark(a)}else{const a=Jm(e.getBody(),g),i=C(a)?r.getParents(g.parentNode,P,a):[],l=Gb(!1).dom;((e,t,o)=>{var n,r;const s=e.dom,a=s.getParent(o,N(Ru,e.schema));a&&s.isEmpty(a)?null===(n=o.parentNode)||void 0===n||n.replaceChild(t,o):(Mr(yo.fromDom(o)),s.isEmpty(o)?null===(r=o.parentNode)||void 0===r||r.replaceChild(t,o):s.insertAfter(t,o))})(e,l,null!=a?a:g);const c=((e,t,o,n,r,s)=>{const a=e.formatter,i=e.dom,l=Y(he(a.get()),(e=>e!==n&&!Ue(e,"removeformat"))),c=Wb(e,o,l);if(Y(c,(t=>!ju(e,t,n))).length>0){const e=o.cloneNode(!1);return i.add(t,e),a.remove(n,r,e,s),i.remove(e),F.some(e)}return F.none()})(e,l,g,t,o,n),d=Jb([...u,...c.toArray(),...i],l);a&&Kb(e,a,C(a)),s.setCursorLocation(d,1),r.isEmpty(g)&&r.remove(g)}},ey=e=>{e.on("mouseup keydown",(t=>{var o;((e,t,o)=>{const n=e.selection,r=e.getBody();Yb(e,null,o),8!==t&&46!==t||!n.isCollapsed()||n.getStart().innerHTML!==$b||Yb(e,Jm(r,n.getStart()),!0),37!==t&&39!==t||Yb(e,Jm(r,n.getStart()),!0)})(e,t.keyCode,(o=e.selection.getRng().endContainer,tr(o)&&We(o.data,br)))}))},ty=e=>{const t=Gb(!1),o=Jb(e,t.dom);return{caretContainer:t,caretPosition:rl(o,0)}},oy=(e,t)=>{const{caretContainer:o,caretPosition:n}=ty(t);return pn(yo.fromDom(e),o),Cn(yo.fromDom(e)),n},ny=(e,t)=>{if(Xm(t.dom))return!1;const o=e.schema.getTextInlineElements();return _e(o,jt(t))&&!Xm(t.dom)&&!Xn(t.dom)},ry={},sy=Gn(["pre"]);((e,t)=>{ry[e]||(ry[e]=[]),ry[e].push(t)})("pre",(e=>{const t=e.selection.getRng();if(!t.collapsed){const t=e.selection.getSelectedBlocks(),o=Y(Y(t,sy),(e=>t=>{const o=t.previousSibling;return sy(o)&&j(e,o)})(t));q(o,(e=>{((e,t)=>{const o=yo.fromDom(t),n=Eo(o).dom;Cn(o),wn(yo.fromDom(e),[yo.fromTag("br",n),yo.fromTag("br",n),...Lo(o)])})(e.previousSibling,e)}))}}));const ay=["fontWeight","fontStyle","color","fontSize","fontFamily"],iy=e=>ee(e,(e=>qu(e)&&"span"===e.inline&&(e=>p(e.styles)&&W(he(e.styles),(e=>j(ay,e))))(e))),ly=(e,t)=>{const o=e.get(t);return v(o)?iy(o):F.none()},cy=(e,t)=>qm(t,rl.fromRangeStart(e)).isNone(),dy=(e,t)=>!1===$m(t,rl.fromRangeEnd(e)).exists((e=>!ir(e.getNode())||$m(t,e).isSome())),my=e=>t=>hr(t)&&e.isEditable(t),uy=e=>Y((e=>{const t=e.getSelectedBlocks(),o=e.getRng();if(e.isCollapsed())return[];if(1===t.length)return cy(o,t[0])&&dy(o,t[0])?t:[];{const e=de(t).filter((e=>cy(o,e))).toArray(),n=me(t).filter((e=>dy(o,e))).toArray(),r=t.slice(1,-1);return e.concat(r).concat(n)}})(e),my(e.dom)),gy=e=>Y(e.getSelectedBlocks(),my(e.dom)),hy=Bt.each,py=e=>Wn(e)&&!mu(e)&&!Xm(e)&&!Xn(e),fy=(e,t)=>{for(let o=e;o;o=o[t]){if(tr(o)&&Ye(o.data))return e;if(Wn(o)&&!mu(o))return o}return e},vy=(e,t,o)=>{const n=rb(e),r=$n(t)&&e.dom.isEditable(t),s=$n(o)&&e.dom.isEditable(o);if(r&&s){const r=fy(t,"previousSibling"),s=fy(o,"nextSibling");if(n.compare(r,s)){for(let e=r.nextSibling;e&&e!==s;){const t=e;e=e.nextSibling,r.appendChild(t)}return e.dom.remove(s),Bt.each(Bt.grep(s.childNodes),(e=>{r.appendChild(e)})),r}}return o},by=(e,t,o,n)=>{var r;if(n&&!1!==t.merge_siblings){const t=null!==(r=vy(e,Nu(n),n))&&void 0!==r?r:n;vy(e,t,Nu(t,!0))}},yy=(e,t,o)=>{hy(e.childNodes,(e=>{py(e)&&(t(e)&&o(e),e.hasChildNodes()&&yy(e,t,o))}))},wy=(e,t)=>o=>!(!o||!zu(e,o,t)),xy=(e,t,o)=>n=>{e.setStyle(n,t,o),""===n.getAttribute("style")&&n.removeAttribute("style"),((e,t)=>{"SPAN"===t.nodeName&&0===e.getAttribs(t).length&&e.remove(t,!0)})(e,n)},Cy=Al([{keep:[]},{rename:["name"]},{removed:[]}]),Sy=/^(src|href|style)$/,ky=Bt.each,_y=Pu,Ey=(e,t,o)=>e.isChildOf(t,o)&&t!==o&&!e.isBlock(o),Ty=(e,t,o)=>{let n=t[o?"startContainer":"endContainer"],r=t[o?"startOffset":"endOffset"];if(Wn(n)){const e=n.childNodes.length-1;!o&&r&&r--,n=n.childNodes[r>e?e:r]}return tr(n)&&o&&r>=n.data.length&&(n=new Zn(n,e.getBody()).next()||n),tr(n)&&!o&&0===r&&(n=new Zn(n,e.getBody()).prev()||n),n},Oy=(e,t)=>{const o=t?"firstChild":"lastChild",n=e[o];return(e=>/^(TR|TH|TD)$/.test(e.nodeName))(e)&&n?"TR"===e.nodeName&&n[o]||n:e},Dy=(e,t,o,n)=>{var r;const s=e.create(o,n);return null===(r=t.parentNode)||void 0===r||r.insertBefore(s,t),s.appendChild(t),s},Ay=(e,t,o,n,r)=>{const s=yo.fromDom(t),a=yo.fromDom(e.create(n,r)),i=o?Bo(s):Ro(s);return wn(a,i),o?(pn(s,a),vn(a,s)):(fn(s,a),bn(a,s)),a.dom},My=(e,t,o)=>{const n=t.parentNode;let r;const s=e.dom,a=Xl(e);Wu(o)&&n===s.getRoot()&&(o.list_block&&_y(t,o.list_block)||q(ue(t.childNodes),(t=>{Bu(e,a,t.nodeName.toLowerCase())?r?r.appendChild(t):(r=Dy(s,t,a),s.setAttribs(r,Jl(e))):r=null}))),(e=>$u(e)&&qu(e)&&Lt(ke(e,"mixed"),!0))(o)&&!_y(o.inline,t)||s.remove(t,!0)},Ny=(e,t,o)=>k(e)?{name:t,value:null}:{name:e,value:Iu(t,o)},Ry=(e,t)=>{""===e.getAttrib(t,"style")&&(t.removeAttribute("style"),t.removeAttribute("data-mce-style"))},By=(e,t,o,n,r)=>{let s=!1;ky(o.styles,((a,i)=>{const{name:l,value:c}=Ny(i,a,n),d=Fu(c,l);(o.remove_similar||b(c)||!Wn(r)||_y(zu(e,r,l),d))&&e.setStyle(t,l,""),s=!0})),s&&Ry(e,t)},Ly=(e,t,o,n,r)=>{const s=e.dom,a=rb(e),i=e.schema;if(qu(t)&&Rs(i,t.inline)&&Ls(i,n)&&n.parentElement===e.getBody())return My(e,n,t),Cy.removed();if(!t.ceFalseOverride&&n&&"false"===s.getContentEditableParent(n))return Cy.keep();if(n&&!zb(s,n,t)&&!((e,t)=>t.links&&"A"===e.nodeName)(n,t))return Cy.keep();const l=n,c=t.preserve_attributes;if(qu(t)&&"all"===t.remove&&v(c)){const e=Y(s.getAttribs(l),(e=>j(c,e.name.toLowerCase())));if(s.removeAllAttribs(l),q(e,(e=>s.setAttrib(l,e.name,e.value))),e.length>0)return Cy.rename("span")}if("all"!==t.remove){By(s,l,t,o,r),ky(t.attributes,((e,n)=>{const{name:a,value:i}=Ny(n,e,o);if(t.remove_similar||b(i)||!Wn(r)||_y(s.getAttrib(r,a),i)){if("class"===a){const e=s.getAttrib(l,a);if(e){let t="";if(q(e.split(/\s+/),(e=>{/mce\-\w+/.test(e)&&(t+=(t?" ":"")+e)})),t)return void s.setAttrib(l,a,t)}}if(Sy.test(a)&&l.removeAttribute("data-mce-"+a),"style"===a&&Gn(["li"])(l)&&"none"===s.getStyle(l,"list-style-type"))return l.removeAttribute(a),void s.setStyle(l,"list-style-type","none");"class"===a&&l.removeAttribute("className"),l.removeAttribute(a)}})),ky(t.classes,(e=>{e=Iu(e,o),Wn(r)&&!s.hasClass(r,e)||s.removeClass(l,e)}));const e=s.getAttribs(l);for(let t=0;tLy(e,t,o,n,n).fold(D(n),(t=>(e.dom.createFragment().appendChild(n),e.dom.rename(n,t))),D(null)),Iy=(e,t,o,n,r)=>{const s=e.formatter.get(t),a=s[0],i=e.dom,l=e.selection,c=n=>{const i=((e,t,o,n,r)=>{let s;return t.parentNode&&q(Zu(e.dom,t.parentNode).reverse(),(t=>{if(!s&&Wn(t)&&"_start"!==t.id&&"_end"!==t.id){const a=Zb(e,t,o,n,r);a&&!1!==a.split&&(s=t)}})),s})(e,n,t,o,r);return((e,t,o,n,r,s,a,i)=>{var l,c;let d,m;const u=e.dom;if(o){const g=o.parentNode;for(let o=n.parentNode;o&&o!==g;o=o.parentNode){let n=u.clone(o,!1);for(let o=0;oW(s,(n=>Fy(e,n,o,t,t))),m=t=>{const o=ue(t.childNodes),n=d(t)||W(s,(e=>zb(i,t,e))),r=t.parentNode;if(!n&&C(r)&&Gu(a)&&d(r),a.deep&&o.length)for(let e=0;e{Wn(t)&&e.dom.getStyle(t,"text-decoration")===o&&t.parentNode&&Vu(i,t.parentNode)===o&&Fy(e,{deep:!1,exact:!0,inline:"span",styles:{textDecoration:o}},void 0,t)}))},u=e=>{const t=i.get(e?"_start":"_end");if(t){let o=t[e?"firstChild":"lastChild"];return(e=>mu(e)&&Wn(e)&&("_start"===e.id||"_end"===e.id))(o)&&(o=o[e?"firstChild":"lastChild"]),tr(o)&&0===o.data.length&&(o=e?t.previousSibling||t.nextSibling:t.nextSibling||t.previousSibling),i.remove(t,!0),o}return null},g=t=>{let o,n,r=mg(i,t,s,t.collapsed);if(a.split){if(r=dh(r),o=Ty(e,r,!0),n=Ty(e,r),o!==n){if(o=Oy(o,!0),n=Oy(n,!1),Ey(i,o,n)){const e=F.from(o.firstChild).getOr(o);return c(Ay(i,e,!0,"span",{id:"_start","data-mce-type":"bookmark"})),void u(!0)}if(Ey(i,n,o)){const e=F.from(n.lastChild).getOr(n);return c(Ay(i,e,!1,"span",{id:"_end","data-mce-type":"bookmark"})),void u(!1)}o=Dy(i,o,"span",{id:"_start","data-mce-type":"bookmark"}),n=Dy(i,n,"span",{id:"_end","data-mce-type":"bookmark"});const e=i.createRng();e.setStartAfter(o),e.setEndBefore(n),ug(i,e,(e=>{q(e,(e=>{mu(e)||mu(e.parentNode)||c(e)}))})),c(o),c(n),o=u(!0),n=u()}else o=n=c(o);r.startContainer=o.parentNode?o.parentNode:o,r.startOffset=i.nodeIndex(o),r.endContainer=n.parentNode?n.parentNode:n,r.endOffset=i.nodeIndex(n)+1}ug(i,r,(e=>{q(e,m)}))};if(n){if(Ou(n)){const e=i.createRng();e.setStartBefore(n),e.setEndAfter(n),g(e)}else g(n);_g(e,t,n,o)}else l.isCollapsed()&&qu(a)&&!yu(e).length?Qb(e,t,o,r):(Au(e,(()=>Eu(e,g)),(n=>qu(a)&&Ub(e,t,o,n))),e.nodeChanged()),((e,t,o)=>{"removeformat"===t?q(gy(e.selection),(t=>{q(ay,(o=>e.dom.setStyle(t,o,""))),Ry(e.dom,t)})):ly(e.formatter,t).each((t=>{q(gy(e.selection),(n=>By(e.dom,n,t,o,null)))}))})(e,t,o),_g(e,t,n,o)},Py=(e,t,o,n,r)=>{(n||e.selection.isEditable())&&Iy(e,t,o,n,r)},Fy=(e,t,o,n,r)=>Ly(e,t,o,n,r).fold(I,(t=>(e.dom.rename(n,t),!0)),P),zy=Bt.each,Vy=(e,t,o,n)=>{zy(t,(t=>{qu(t)&&zy(e.dom.select(t.inline,n),(n=>{py(n)&&Fy(e,t,o,n,t.exact?n:null)})),((e,t,o)=>{if(t.clear_child_styles){const n=t.links?"*:not(a)":"*";hy(e.select(n,o),(o=>{py(o)&&e.isEditable(o)&&hy(t.styles,((t,n)=>{e.setStyle(o,n,"")}))}))}})(e.dom,t,n)}))},Zy=Bt.each,Uy=(e,t,o,n)=>{if(Zy(o.styles,((o,r)=>{e.setStyle(t,r,Iu(o,n))})),o.styles){const o=e.getAttrib(t,"style");o&&e.setAttrib(t,"data-mce-style",o)}},jy=(e,t,o,n)=>{const r=e.formatter.get(t),s=r[0],a=!n&&e.selection.isCollapsed(),i=e.dom,l=e.selection,c=(e,t=s)=>{S(t.onformat)&&t.onformat(e,t,o,n),Uy(i,e,t,o),Zy(t.attributes,((t,n)=>{i.setAttrib(e,n,Iu(t,o))})),Zy(t.classes,(t=>{const n=Iu(t,o);i.hasClass(e,n)||i.addClass(e,n)}))},d=(e,t)=>{let o=!1;return Zy(e,(e=>!(!$u(e)||("false"!==i.getContentEditable(t)||e.ceFalseOverride)&&(!C(e.collapsed)||e.collapsed===a)&&i.is(t,e.selector)&&!Xm(t)&&(c(t,e),o=!0,1)))),o},m=e=>{if(h(e)){const t=i.create(e);return c(t),t}return null},u=(n,a,i)=>{const l=[];let u=!0;const g=s.inline||s.block,h=m(g),p=n=>(e=>Wu(e)&&!0===e.wrapper)(s)&&Zb(e,n,t,o),f=(t,o,n)=>{const r=(e=>Wu(e)&&!0!==e.wrapper)(s)&&Ru(e.schema,t)&&Bu(e,o,g);return n&&r};ug(n,a,(t=>{let o;const a=t=>{let m=!1,v=u,b=!1;const y=t.parentNode,w=y.nodeName.toLowerCase(),x=n.getContentEditable(t);C(x)&&(v=u,u="true"===x,m=!0,b=Hu(e,t));const S=u&&!m;if(ir(t)&&!((e,t,o,n)=>{if(Hc(e)&&qu(t)&&o.parentNode){const t=va(e.schema),r=Cv(yo.fromDom(o),(e=>Xm(e.dom)));return Ee(t,n)&&ys(yo.fromDom(o.parentNode),!1)&&!r}return!1})(e,s,t,w))return o=null,void(Wu(s)&&n.remove(t));if(p(t))o=null;else{if(f(t,w,S)){const e=n.rename(t,g);return c(e),l.push(e),void(o=null)}if($u(s)){let e=d(r,t);if(!e&&C(y)&&Gu(s)&&(e=d(r,y)),!qu(s)||e)return void(o=null)}C(h)&&((t,o,r,a)=>{const l=t.nodeName.toLowerCase(),c=Bu(e,g,l)&&Bu(e,o,g),d=!i&&tr(t)&&Lr(t.data),m=Xm(t),u=!qu(s)||!n.isBlock(t);return(r||a)&&c&&!d&&!m&&u})(t,w,S,b)?(o||(o=n.clone(h,!1),y.insertBefore(o,t),l.push(o)),b&&m&&(u=v),o.appendChild(t)):(o=null,q(ue(t.childNodes),a),m&&(u=v),o=null)}};q(t,a)})),!0===s.links&&q(l,(e=>{const t=e=>{"A"===e.nodeName&&c(e,s),q(ue(e.childNodes),t)};t(e)})),q(l,(a=>{const i=(e=>{let t=0;return q(e.childNodes,(e=>{(e=>C(e)&&tr(e)&&0===e.length)(e)||mu(e)||t++})),t})(a);!(l.length>1)&&n.isBlock(a)||0!==i?(qu(s)||Wu(s)&&s.wrapper)&&(s.exact||1!==i||(a=(e=>{const t=ee(e.childNodes,Du).filter((e=>"false"!==n.getContentEditable(e)&&zb(n,e,s)));return t.map((t=>{const o=n.clone(t,!1);return c(o),n.replace(o,e,!0),n.remove(t,!0),o})).getOr(e)})(a)),Vy(e,r,o,a),((e,t,o,n,r)=>{const s=r.parentNode;Zb(e,s,o,n)&&Fy(e,t,n,r)||t.merge_with_parents&&s&&e.dom.getParent(s,(s=>!!Zb(e,s,o,n)&&(Fy(e,t,n,r),!0)))})(e,s,t,o,a),((e,t,o,n)=>{if(t.styles&&t.styles.backgroundColor){const r=wy(e,"fontSize");yy(n,(t=>r(t)&&e.isEditable(t)),xy(e,"backgroundColor",Iu(t.styles.backgroundColor,o)))}})(n,s,o,a),((e,t,o,n)=>{const r=t=>{if($n(t)&&Wn(t.parentNode)&&e.isEditable(t)){const o=Vu(e,t.parentNode);e.getStyle(t,"color")&&o?e.setStyle(t,"text-decoration",o):e.getStyle(t,"text-decoration")===o&&e.setStyle(t,"text-decoration",null)}};t.styles&&(t.styles.color||t.styles.textDecoration)&&(Bt.walk(n,r,"childNodes"),r(n))})(n,s,0,a),((e,t,o,n)=>{if(qu(t)&&("sub"===t.inline||"sup"===t.inline)){const o=wy(e,"fontSize");yy(n,(t=>o(t)&&e.isEditable(t)),xy(e,"fontSize",""));const r=Y(e.select("sup"===t.inline?"sub":"sup",n),e.isEditable);e.remove(r,!0)}})(n,s,0,a),by(e,s,0,a)):n.remove(a,!0)}))},g=Ou(n)?n:l.getNode();if("false"===i.getContentEditable(g)&&!Hu(e,g))return d(r,n=g),void kg(e,t,n,o);if(s){if(n)if(Ou(n)){if(!d(r,n)){const e=i.createRng();e.setStartBefore(n),e.setEndAfter(n),u(i,mg(i,e,r),!0)}}else u(i,n,!0);else a&&qu(s)&&!yu(e).length?((e,t,o)=>{let n;const r=e.selection,s=e.formatter.get(t);if(!s)return;const a=r.getRng();let i=a.startOffset;const l=a.startContainer.nodeValue;n=Jm(e.getBody(),r.getStart());const c=/[^\s\u00a0\u00ad\u200b\ufeff]/;if(l&&i>0&&i{Eu(e,((e,t)=>{const o=t?e:mg(i,e,r);u(i,o,!1)}))}),P),e.nodeChanged()),ly(e.formatter,t).each((t=>{q(uy(e.selection),(e=>Uy(i,e,t,o)))}));((e,t)=>{_e(ry,e)&&q(ry[e],(e=>{e(t)}))})(t,e)}kg(e,t,n,o)},Wy=(e,t,o,n)=>{(n||e.selection.isEditable())&&jy(e,t,o,n)},$y=e=>_e(e,"vars"),qy=e=>e.selection.getStart(),Gy=(e,t,o,n,r)=>Q(t,(t=>{const s=e.formatter.matchNode(t,o,null!=r?r:{},n);return!w(s)}),(t=>!!Pb(e,t,o)||!n&&C(e.formatter.matchNode(t,o,r,!0)))),Ky=(e,t)=>{const o=null!=t?t:qy(e);return Y(Zu(e.dom,o),(e=>Wn(e)&&!Xn(e)))},Yy=(e,t,o)=>{const n=Ky(e,t);fe(o,((o,r)=>{const s=o=>{const s=Gy(e,n,r,o.similar,$y(o)?o.vars:void 0),a=s.isSome();if(o.state.get()!==a){o.state.set(a);const e=s.getOr(t);$y(o)?o.callback(a,{node:e,format:r,parents:n}):q(o.callbacks,(t=>t(a,{node:e,format:r,parents:n})))}};q([o.withSimilar,o.withoutSimilar],s),q(o.withVars,s)}))},Xy=(e,t,o,n,r,s)=>(((e,t,o,n,r,s)=>{const a=t.get();q(o.split(","),(t=>{const o=ke(a,t).getOrThunk((()=>{const e={withSimilar:{state:Qa(!1),similar:!0,callbacks:[]},withoutSimilar:{state:Qa(!1),similar:!1,callbacks:[]},withVars:[]};return a[t]=e,e})),i=()=>{const o=Ky(e);return Gy(e,o,t,r,s).isSome()};if(w(s)){const e=r?o.withSimilar:o.withoutSimilar;e.callbacks.push(n),1===e.callbacks.length&&e.state.set(i())}else o.withVars.push({state:Qa(i()),similar:r,vars:s,callback:n})})),t.set(a)})(e,t,o,n,r,s),{unbind:()=>((e,t,o)=>{const n=e.get();q(t.split(","),(e=>ke(n,e).each((t=>{n[e]={withSimilar:{...t.withSimilar,callbacks:Y(t.withSimilar.callbacks,(e=>e!==o))},withoutSimilar:{...t.withoutSimilar,callbacks:Y(t.withoutSimilar.callbacks,(e=>e!==o))},withVars:Y(t.withVars,(e=>e.callback!==o))}})))),e.set(n)})(t,o,n)}),Jy=Bt.explode,Qy=()=>{const e={};return{addFilter:(t,o)=>{q(Jy(t),(t=>{_e(e,t)||(e[t]={name:t,callbacks:[]}),e[t].callbacks.push(o)}))},getFilters:()=>Se(e),removeFilter:(t,o)=>{q(Jy(t),(t=>{if(_e(e,t))if(C(o)){const n=e[t],r=Y(n.callbacks,(e=>e!==o));r.length>0?n.callbacks=r:delete e[t]}else delete e[t]}))}}},ew=(e,t,o)=>{e.addNodeFilter("font",(e=>{q(e,(e=>{const n=t.parse(e.attr("style")),r=e.attr("color"),s=e.attr("face"),a=e.attr("size");r&&(n.color=r),s&&(n["font-family"]=s),a&&Je(a).each((e=>{n["font-size"]=o[e-1]})),e.name="span",e.attr("style",t.serialize(n)),((e,t)=>{q(t,(t=>{e.attr(t,null)}))})(e,["color","face","size"])}))}))},tw=(e,t,o)=>{var n;const r=Aa();t.convert_fonts_to_spans&&ew(e,r,Bt.explode(null!==(n=t.font_size_legacy_values)&&void 0!==n?n:"")),((e,t,o)=>{e.addNodeFilter("strike",(e=>{const n="html4"!==t.type;q(e,(e=>{if(n)e.name="s";else{const t=o.parse(e.attr("style"));t["text-decoration"]="line-through",e.name="span",e.attr("style",o.serialize(t))}}))}))})(e,o,r)},ow=(e,t,o)=>{t.addNodeFilter("br",((t,n,r)=>{const s=Bt.extend({},o.getBlockElements()),a=o.getNonEmptyElements(),i=o.getWhitespaceElements();s.body=1;const l=e=>e.name in s||Is(o,e);for(let n=0,c=t.length;n{const[t,...o]=e.split(","),n=o.join(","),r=/data:([^/]+\/[^;]+)(;.+)?/.exec(t);if(r){const e=";base64"===r[2],t=e?(e=>{const t=/([a-z0-9+\/=\s]+)/i.exec(e);return t?t[1]:""})(n):decodeURIComponent(n);return F.some({type:r[1],data:t,base64Encoded:e})}return F.none()},rw=(e,t,o=!0)=>{let n=t;if(o)try{n=atob(t)}catch(e){return F.none()}const r=new Uint8Array(n.length);for(let e=0;e{return je(e,"blob:")?(e=>fetch(e).then((e=>e.ok?e.blob():Promise.reject())).catch((()=>Promise.reject({message:`Cannot convert ${e} to Blob. Resource might not exist or is inaccessible.`,uriType:"blob"}))))(e):je(e,"data:")?(t=e,new Promise(((e,o)=>{nw(t).bind((({type:e,data:t,base64Encoded:o})=>rw(e,t,o))).fold((()=>o("Invalid data URI")),e)}))):Promise.reject("Unknown URI format");var t},aw=e=>new Promise(((t,o)=>{const n=new FileReader;n.onloadend=()=>{t(n.result)},n.onerror=()=>{var e;o(null===(e=n.error)||void 0===e?void 0:e.message)},n.readAsDataURL(e)}));let iw=0;const lw=(e,t,o)=>nw(e).bind((({data:e,type:n,base64Encoded:r})=>{if(t&&!r)return F.none();{const t=r?e:btoa(e);return o(t,n)}})),cw=(e,t,o)=>{const n=e.create((r||"blobid")+iw++,t,o);var r;return e.add(n),n},dw=(e,t,o=!1)=>lw(t,o,((t,o)=>F.from(e.getByData(t,o)).orThunk((()=>rw(o,t).map((o=>cw(e,o,t))))))),mw=(e,t)=>{const{blob_cache:o}=t;if(o){const t=e=>{const t=e.attr("src");(e=>e.attr("src")===At.transparentSrc||C(e.attr("data-mce-placeholder")))(e)||(e=>C(e.attr("data-mce-bogus")))(e)||x(t)||dw(o,t,!0).each((t=>{e.attr("src",t.blobUri())}))};e.addAttributeFilter("src",(e=>q(e,t)))}},uw=(e,t)=>je(e,`${t}/`),gw=(e,t)=>{const o=e.schema;t.remove_trailing_brs&&ow(t,e,o),e.addAttributeFilter("href",(e=>{let o=e.length;const n=e=>{const t=e?Bt.trim(e):"";return/\b(noopener)\b/g.test(t)?t:(e=>e.split(" ").filter((e=>e.length>0)).concat(["noopener"]).sort().join(" "))(t)};if(!t.allow_unsafe_link_target)for(;o--;){const t=e[o];"a"===t.name&&"_blank"===t.attr("target")&&t.attr("rel",n(t.attr("rel")))}})),t.allow_html_in_named_anchor||e.addAttributeFilter("id,name",(e=>{let t,o,n,r,s=e.length;for(;s--;)if(r=e[s],"a"===r.name&&r.firstChild&&!r.attr("href"))for(n=r.parent,t=r.lastChild;t&&n;)o=t.prev,n.insert(t,r),t=o})),t.fix_list_elements&&e.addNodeFilter("ul,ol",(e=>{let t,o,n=e.length;for(;n--;)if(t=e[n],o=t.parent,o&&("ul"===o.name||"ol"===o.name))if(t.prev&&"li"===t.prev.name)t.prev.append(t);else{const e=new Ep("li",1);e.attr("style","list-style-type: none"),t.wrap(e)}}));const n=o.getValidClasses();t.validate&&n&&e.addAttributeFilter("class",(e=>{var t;let o=e.length;for(;o--;){const r=e[o],s=null!==(t=r.attr("class"))&&void 0!==t?t:"",a=Bt.explode(s," ");let i="";for(let e=0;eq(e,(e=>{e.replace(((e,t,o,n,r)=>{let s;s=w(e)?"iframe":uw(e,"image")?"img":uw(e,"video")?"video":uw(e,"audio")?"audio":"iframe";const a=new Ep(s,1);return a.attr("audio"===s?{src:t}:{src:t,width:o,height:n}),"audio"!==s&&"video"!==s||a.attr("controls",""),"iframe"===s&&r&&a.attr("sandbox",""),a})(e.attr("type"),"object"===e.name?e.attr("data"):e.attr("src"),e.attr("width"),e.attr("height"),t.sandbox_iframes))})))),t.sandbox_iframes&&e.addNodeFilter("iframe",(e=>q(e,(e=>e.attr("sandbox","")))))},{entries:hw,setPrototypeOf:pw,isFrozen:fw,getPrototypeOf:vw,getOwnPropertyDescriptor:bw}=Object;let{freeze:yw,seal:ww,create:xw}=Object,{apply:Cw,construct:Sw}="undefined"!=typeof Reflect&&Reflect;Cw||(Cw=function(e,t,o){return e.apply(t,o)}),yw||(yw=function(e){return e}),ww||(ww=function(e){return e}),Sw||(Sw=function(e,t){return new e(...t)});const kw=Hw(Array.prototype.forEach),_w=Hw(Array.prototype.pop),Ew=Hw(Array.prototype.push),Tw=Hw(String.prototype.toLowerCase),Ow=Hw(String.prototype.toString),Dw=Hw(String.prototype.match),Aw=Hw(String.prototype.replace),Mw=Hw(String.prototype.indexOf),Nw=Hw(String.prototype.trim),Rw=Hw(RegExp.prototype.test),Bw=(Lw=TypeError,function(){for(var e=arguments.length,t=new Array(e),o=0;o1?o-1:0),r=1;r/gm),Qw=ww(/\${[\w\W]*}/gm),ex=ww(/^data-[\-\w.\u00B7-\uFFFF]/),tx=ww(/^aria-[\-\w]+$/),ox=ww(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),nx=ww(/^(?:\w+script|data):/i),rx=ww(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sx=ww(/^html$/i);var ax=Object.freeze({__proto__:null,MUSTACHE_EXPR:Xw,ERB_EXPR:Jw,TMPLIT_EXPR:Qw,DATA_ATTR:ex,ARIA_ATTR:tx,IS_ALLOWED_URI:ox,IS_SCRIPT_OR_DATA:nx,ATTR_WHITESPACE:rx,DOCTYPE_NAME:sx});const ix=()=>"undefined"==typeof window?null:window;var lx=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ix();const o=t=>e(t);if(o.version="3.0.5",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;const n=t.document,r=n.currentScript;let{document:s}=t;const{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:m=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:h}=t,p=c.prototype,f=Fw(p,"cloneNode"),v=Fw(p,"nextSibling"),b=Fw(p,"childNodes"),y=Fw(p,"parentNode");if("function"==typeof i){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let w,x="";const{implementation:C,createNodeIterator:S,createDocumentFragment:k,getElementsByTagName:_}=s,{importNode:E}=n;let T={};o.isSupported="function"==typeof hw&&"function"==typeof y&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:D,TMPLIT_EXPR:A,DATA_ATTR:M,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:R,ATTR_WHITESPACE:B}=ax;let{IS_ALLOWED_URI:L}=ax,H=null;const I=Iw({},[...zw,...Vw,...Zw,...jw,...$w]);let P=null;const F=Iw({},[...qw,...Gw,...Kw,...Yw]);let z=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,Z=null,U=!0,j=!0,W=!1,$=!0,q=!1,G=!1,K=!1,Y=!1,X=!1,J=!1,Q=!1,ee=!0,te=!1,oe=!0,ne=!1,re={},se=null;const ae=Iw({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ie=null;const le=Iw({},["audio","video","img","source","image","track"]);let ce=null;const de=Iw({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),me="http://www.w3.org/1998/Math/MathML",ue="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml";let he=ge,pe=!1,fe=null;const ve=Iw({},[me,ue,ge],Ow);let be;const ye=["application/xhtml+xml","text/html"];let we,xe=null;const Ce=s.createElement("form"),Se=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){if(!xe||xe!==e){if(e&&"object"==typeof e||(e={}),e=Pw(e),be=be=-1===ye.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,we="application/xhtml+xml"===be?Ow:Tw,H="ALLOWED_TAGS"in e?Iw({},e.ALLOWED_TAGS,we):I,P="ALLOWED_ATTR"in e?Iw({},e.ALLOWED_ATTR,we):F,fe="ALLOWED_NAMESPACES"in e?Iw({},e.ALLOWED_NAMESPACES,Ow):ve,ce="ADD_URI_SAFE_ATTR"in e?Iw(Pw(de),e.ADD_URI_SAFE_ATTR,we):de,ie="ADD_DATA_URI_TAGS"in e?Iw(Pw(le),e.ADD_DATA_URI_TAGS,we):le,se="FORBID_CONTENTS"in e?Iw({},e.FORBID_CONTENTS,we):ae,V="FORBID_TAGS"in e?Iw({},e.FORBID_TAGS,we):{},Z="FORBID_ATTR"in e?Iw({},e.FORBID_ATTR,we):{},re="USE_PROFILES"in e&&e.USE_PROFILES,U=!1!==e.ALLOW_ARIA_ATTR,j=!1!==e.ALLOW_DATA_ATTR,W=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,q=e.SAFE_FOR_TEMPLATES||!1,G=e.WHOLE_DOCUMENT||!1,X=e.RETURN_DOM||!1,J=e.RETURN_DOM_FRAGMENT||!1,Q=e.RETURN_TRUSTED_TYPE||!1,Y=e.FORCE_BODY||!1,ee=!1!==e.SANITIZE_DOM,te=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,ne=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||ox,he=e.NAMESPACE||ge,z=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(j=!1),J&&(X=!0),re&&(H=Iw({},[...$w]),P=[],!0===re.html&&(Iw(H,zw),Iw(P,qw)),!0===re.svg&&(Iw(H,Vw),Iw(P,Gw),Iw(P,Yw)),!0===re.svgFilters&&(Iw(H,Zw),Iw(P,Gw),Iw(P,Yw)),!0===re.mathMl&&(Iw(H,jw),Iw(P,Kw),Iw(P,Yw))),e.ADD_TAGS&&(H===I&&(H=Pw(H)),Iw(H,e.ADD_TAGS,we)),e.ADD_ATTR&&(P===F&&(P=Pw(P)),Iw(P,e.ADD_ATTR,we)),e.ADD_URI_SAFE_ATTR&&Iw(ce,e.ADD_URI_SAFE_ATTR,we),e.FORBID_CONTENTS&&(se===ae&&(se=Pw(se)),Iw(se,e.FORBID_CONTENTS,we)),oe&&(H["#text"]=!0),G&&Iw(H,["html","head","body"]),H.table&&(Iw(H,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Bw('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Bw('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,x=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let o=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));const r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,r)),null!==w&&"string"==typeof x&&(x=w.createHTML(""));yw&&yw(e),xe=e}},_e=Iw({},["mi","mo","mn","ms","mtext"]),Ee=Iw({},["foreignobject","desc","title","annotation-xml"]),Te=Iw({},["title","style","font","a","script"]),Oe=Iw({},Vw);Iw(Oe,Zw),Iw(Oe,Uw);const De=Iw({},jw);Iw(De,Ww);const Ae=function(e){Ew(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},Me=function(e,t){try{Ew(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Ew(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!P[e])if(X||J)try{Ae(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ne=function(e){let t,o;if(Y)e=""+e;else{const t=Dw(e,/^[\r\n\t ]+/);o=t&&t[0]}"application/xhtml+xml"===be&&he===ge&&(e=''+e+"");const n=w?w.createHTML(e):e;if(he===ge)try{t=(new g).parseFromString(n,be)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(he,"template",null);try{t.documentElement.innerHTML=pe?x:n}catch(e){}}const r=t.body||t.documentElement;return e&&o&&r.insertBefore(s.createTextNode(o),r.childNodes[0]||null),he===ge?_.call(t,G?"html":"body")[0]:G?t.documentElement:r},Re=function(e){return S.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Be=function(e){return"object"==typeof l?e instanceof l:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Le=function(e,t,n){T[e]&&kw(T[e],(e=>{e.call(o,t,n,xe)}))},He=function(e){let t;if(Le("beforeSanitizeElements",e,null),(n=e)instanceof u&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof m)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore||"function"!=typeof n.hasChildNodes))return Ae(e),!0;var n;const r=we(e.nodeName);if(Le("uponSanitizeElement",e,{tagName:r,allowedTags:H}),e.hasChildNodes()&&!Be(e.firstElementChild)&&(!Be(e.content)||!Be(e.content.firstElementChild))&&Rw(/<[/\w]/g,e.innerHTML)&&Rw(/<[/\w]/g,e.textContent))return Ae(e),!0;if(!H[r]||V[r]){if(!V[r]&&Pe(r)){if(z.tagNameCheck instanceof RegExp&&Rw(z.tagNameCheck,r))return!1;if(z.tagNameCheck instanceof Function&&z.tagNameCheck(r))return!1}if(oe&&!se[r]){const t=y(e)||e.parentNode,o=b(e)||e.childNodes;if(o&&t)for(let n=o.length-1;n>=0;--n)t.insertBefore(f(o[n],!0),v(e))}return Ae(e),!0}return e instanceof c&&!function(e){let t=y(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});const o=Tw(e.tagName),n=Tw(t.tagName);return!!fe[e.namespaceURI]&&(e.namespaceURI===ue?t.namespaceURI===ge?"svg"===o:t.namespaceURI===me?"svg"===o&&("annotation-xml"===n||_e[n]):Boolean(Oe[o]):e.namespaceURI===me?t.namespaceURI===ge?"math"===o:t.namespaceURI===ue?"math"===o&&Ee[n]:Boolean(De[o]):e.namespaceURI===ge?!(t.namespaceURI===ue&&!Ee[n])&&!(t.namespaceURI===me&&!_e[n])&&!De[o]&&(Te[o]||!Oe[o]):!("application/xhtml+xml"!==be||!fe[e.namespaceURI]))}(e)?(Ae(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!Rw(/<\/no(script|embed|frames)/i,e.innerHTML)?(q&&3===e.nodeType&&(t=e.textContent,t=Aw(t,O," "),t=Aw(t,D," "),t=Aw(t,A," "),e.textContent!==t&&(Ew(o.removed,{element:e.cloneNode()}),e.textContent=t)),Le("afterSanitizeElements",e,null),!1):(Ae(e),!0)},Ie=function(e,t,o){if(ee&&("id"===t||"name"===t)&&(o in s||o in Ce))return!1;if(j&&!Z[t]&&Rw(M,t));else if(U&&Rw(N,t));else if(!P[t]||Z[t]){if(!(Pe(e)&&(z.tagNameCheck instanceof RegExp&&Rw(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&Rw(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t))||"is"===t&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&Rw(z.tagNameCheck,o)||z.tagNameCheck instanceof Function&&z.tagNameCheck(o))))return!1}else if(ce[t]);else if(Rw(L,Aw(o,B,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Mw(o,"data:")||!ie[e])if(W&&!Rw(R,Aw(o,B,"")));else if(o)return!1;return!0},Pe=function(e){return e.indexOf("-")>0},Fe=function(e){let t,o,n,r;Le("beforeSanitizeAttributes",e,null);const{attributes:s}=e;if(!s)return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P};for(r=s.length;r--;){t=s[r];const{name:i,namespaceURI:l}=t;o="value"===i?t.value:Nw(t.value);const c=o;if(n=we(i),a.attrName=n,a.attrValue=o,a.keepAttr=!0,a.forceKeepAttr=void 0,Le("uponSanitizeAttribute",e,a),o=a.attrValue,a.forceKeepAttr)continue;if(!a.keepAttr){Me(i,e);continue}if(!$&&Rw(/\/>/i,o)){Me(i,e);continue}q&&(o=Aw(o,O," "),o=Aw(o,D," "),o=Aw(o,A," "));const d=we(e.nodeName);if(Ie(d,n,o)){if(!te||"id"!==n&&"name"!==n||(Me(i,e),o="user-content-"+o),w&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(l);else switch(h.getAttributeType(d,n)){case"TrustedHTML":o=w.createHTML(o);break;case"TrustedScriptURL":o=w.createScriptURL(o)}if(o!==c)try{l?e.setAttributeNS(l,i,o):e.setAttribute(i,o)}catch(t){Me(i,e)}}else Me(i,e)}Le("afterSanitizeAttributes",e,null)},ze=function e(t){let o;const n=Re(t);for(Le("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Le("uponSanitizeShadowNode",o,null),He(o)||(o.content instanceof a&&e(o.content),Fe(o));Le("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t,r,s,i,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(pe=!e,pe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Be(e)){if("function"!=typeof e.toString)throw Bw("toString is not a function");if("string"!=typeof(e=e.toString()))throw Bw("dirty is not a string, aborting")}if(!o.isSupported)return e;if(K||ke(c),o.removed=[],"string"==typeof e&&(ne=!1),ne){if(e.nodeName){const t=we(e.nodeName);if(!H[t]||V[t])throw Bw("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)t=Ne("\x3c!----\x3e"),r=t.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?t=r:t.appendChild(r);else{if(!X&&!q&&!G&&-1===e.indexOf("<"))return w&&Q?w.createHTML(e):e;if(t=Ne(e),!t)return X?null:Q?x:""}t&&Y&&Ae(t.firstChild);const d=Re(ne?e:t);for(;s=d.nextNode();)He(s)||(s.content instanceof a&&ze(s.content),Fe(s));if(ne)return e;if(X){if(J)for(i=k.call(t.ownerDocument);t.firstChild;)i.appendChild(t.firstChild);else i=t;return(P.shadowroot||P.shadowrootmode)&&(i=E.call(n,i,!0)),i}let m=G?t.outerHTML:t.innerHTML;return G&&H["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&Rw(sx,t.ownerDocument.doctype.name)&&(m="\n"+m),q&&(m=Aw(m,O," "),m=Aw(m,D," "),m=Aw(m,A," ")),w&&Q?w.createHTML(m):m},o.setConfig=function(e){ke(e),K=!0},o.clearConfig=function(){xe=null,K=!1},o.isValidAttribute=function(e,t,o){xe||ke({});const n=we(e),r=we(t);return Ie(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(T[e]=T[e]||[],Ew(T[e],t))},o.removeHook=function(e){if(T[e])return _w(T[e])},o.removeHooks=function(e){T[e]&&(T[e]=[])},o.removeAllHooks=function(){T={}},o}();const cx=Bt.each,dx=Bt.trim,mx=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],ux={ftp:21,http:80,https:443,mailto:25},gx=["img","video"],hx=(e,t,o)=>{const n=(e=>{try{return decodeURIComponent(e)}catch(t){return unescape(e)}})(t).replace(/\s/g,"");return!e.allow_script_urls&&(!!/((java|vb)script|mhtml):/i.test(n)||!e.allow_html_data_urls&&(/^data:image\//i.test(n)?((e,t)=>C(e)?!e:!C(t)||!j(gx,t))(e.allow_svg_data_urls,o)&&/^data:image\/svg\+xml/i.test(n):/^data:/i.test(n)))};class px{static parseDataUri(e){let t;const o=decodeURIComponent(e).split(","),n=/data:([^;]+)/.exec(o[0]);return n&&(t=n[1]),{type:t,data:o[1]}}static isDomSafe(e,t,o={}){if(o.allow_script_urls)return!0;{const n=ia.decode(e).replace(/[\s\u0000-\u001F]+/g,"");return!hx(o,n,t)}}static getDocumentBaseUrl(e){var t;let o;return o=0!==e.protocol.indexOf("http")&&"file:"!==e.protocol?null!==(t=e.href)&&void 0!==t?t:"":e.protocol+"//"+e.host+e.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(o)&&(o=o.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(o)||(o+="/")),o}constructor(e,t={}){this.path="",this.directory="",e=dx(e),this.settings=t;const o=t.base_uri,n=this;if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(n.source=e);const r=0===e.indexOf("//");if(0!==e.indexOf("/")||r||(e=(o&&o.protocol||"http")+"://mce_host"+e),!/^[\w\-]*:?\/\//.test(e)){const t=o?o.path:new px(document.location.href).directory;if(""===(null==o?void 0:o.protocol))e="//mce_host"+n.toAbsPath(t,e);else{const r=/([^#?]*)([#?]?.*)/.exec(e);r&&(e=(o&&o.protocol||"http")+"://mce_host"+n.toAbsPath(t,r[1])+r[2])}}e=e.replace(/@@/g,"(mce_at)");const s=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);s&&cx(mx,((e,t)=>{let o=s[t];o&&(o=o.replace(/\(mce_at\)/g,"@@")),n[e]=o})),o&&(n.protocol||(n.protocol=o.protocol),n.userInfo||(n.userInfo=o.userInfo),n.port||"mce_host"!==n.host||(n.port=o.port),n.host&&"mce_host"!==n.host||(n.host=o.host),n.source=""),r&&(n.protocol="")}setPath(e){const t=/^(.*?)\/?(\w+)?$/.exec(e);t&&(this.path=t[0],this.directory=t[1],this.file=t[2]),this.source="",this.getURI()}toRelative(e){if("./"===e)return e;const t=new px(e,{base_uri:this});if("mce_host"!==t.host&&this.host!==t.host&&t.host||this.port!==t.port||this.protocol!==t.protocol&&""!==t.protocol)return t.getURI();const o=this.getURI(),n=t.getURI();if(o===n||"/"===o.charAt(o.length-1)&&o.substr(0,o.length-1)===n)return o;let r=this.toRelPath(this.path,t.path);return t.query&&(r+="?"+t.query),t.anchor&&(r+="#"+t.anchor),r}toAbsolute(e,t){const o=new px(e,{base_uri:this});return o.getURI(t&&this.isSameOrigin(o))}isSameOrigin(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;const t=this.protocol?ux[this.protocol]:null;if(t&&(this.port||t)==(e.port||t))return!0}return!1}toRelPath(e,t){let o,n,r=0,s="";const a=e.substring(0,e.lastIndexOf("/")).split("/"),i=t.split("/");if(a.length>=i.length)for(o=0,n=a.length;o=i.length||a[o]!==i[o]){r=o+1;break}if(a.length=a.length||a[o]!==i[o]){r=o+1;break}if(1===r)return t;for(o=0,n=a.length-(r-1);o{e&&a.push(e)}));const i=[];for(let e=s.length-1;e>=0;e--)0!==s[e].length&&"."!==s[e]&&(".."!==s[e]?o>0?o--:i.push(s[e]):o++);const l=a.length-o;let c;return c=l<=0?se(i).join("/"):a.slice(0,l).join("/")+"/"+se(i).join("/"),0!==c.indexOf("/")&&(c="/"+c),n&&c.lastIndexOf("/")!==c.length-1&&(c+=n),c}getURI(e=!1){let t;return this.source&&!e||(t="",e||(this.protocol?t+=this.protocol+"://":t+="//",this.userInfo&&(t+=this.userInfo+"@"),this.host&&(t+=this.host),this.port&&(t+=":"+this.port)),this.path&&(t+=this.path),this.query&&(t+="?"+this.query),this.anchor&&(t+="#"+this.anchor),this.source=t),this.source}}const fx=Bt.makeMap("src,href,data,background,action,formaction,poster,xlink:href"),vx="data-mce-type";let bx=0;const yx=(e,t,o,n,r)=>{var s,a,i,l;const c=t.validate,d=o.getSpecialElements();8===e.nodeType&&!t.allow_conditional_comments&&/^\[if/i.test(null!==(s=e.nodeValue)&&void 0!==s?s:"")&&(e.nodeValue=" "+e.nodeValue);const m=null!==(a=null==r?void 0:r.tagName)&&void 0!==a?a:e.nodeName.toLowerCase();if("html"!==n&&o.isValid(n))return void(C(r)&&(r.allowedTags[m]=!0));if(1!==e.nodeType||"body"===m)return;const u=yo.fromDom(e),g=ro(u,vx),p=oo(u,"data-mce-bogus");if(!g&&h(p))return void("all"===p?Cn(u):Sn(u));const f=o.getElementRule(m);if(!c||f){if(C(r)&&(r.allowedTags[m]=!0),c&&f&&!g){if(q(null!==(i=f.attributesForced)&&void 0!==i?i:[],(e=>{eo(u,e.name,"{$uid}"===e.value?"mce_"+bx++:e.value)})),q(null!==(l=f.attributesDefault)&&void 0!==l?l:[],(e=>{ro(u,e.name)||eo(u,e.name,"{$uid}"===e.value?"mce_"+bx++:e.value)})),f.attributesRequired&&!W(f.attributesRequired,(e=>ro(u,e))))return void Sn(u);if(f.removeEmptyAttrs&&(e=>{const t=e.dom.attributes;return null==t||0===t.length})(u))return void Sn(u);f.outputName&&f.outputName!==m&&Ei(u,f.outputName)}}else _e(d,m)?Cn(u):Sn(u)},wx=(e,t,o,n,r,s)=>"html"!==o&&!ws(n)||!(r in fx&&hx(e,s,n))&&(!e.validate||t.isValid(n,r)||je(r,"data-")||je(r,"aria-")),xx=(e,t)=>e.hasAttribute(vx)&&("id"===t||"class"===t||"style"===t),Cx=(e,t)=>e in t.getBoolAttrs(),Sx=(e,t,o,n)=>{const{attributes:r}=e;for(let s=r.length-1;s>=0;s--){const a=r[s],i=a.name,l=a.value;wx(t,o,n,e.tagName.toLowerCase(),i,l)||xx(e,i)?Cx(i,o)&&e.setAttribute(i,i):e.removeAttribute(i)}},kx=(e,t,o)=>{const n=lx();return n.addHook("uponSanitizeElement",((n,r)=>{yx(n,e,t,o.track(n),r)})),n.addHook("uponSanitizeAttribute",((n,r)=>{((e,t,o,n,r)=>{const s=e.tagName.toLowerCase(),{attrName:a,attrValue:i}=r;r.keepAttr=wx(t,o,n,s,a,i),r.keepAttr?(r.allowedAttributes[a]=!0,Cx(a,o)&&(r.attrValue=a),t.allow_svg_data_urls&&je(i,"data:image/svg+xml")&&(r.forceKeepAttr=!0)):xx(e,a)&&(r.forceKeepAttr=!0)})(n,e,t,o.current(),r)})),n},_x=e=>{const t=["type","href","role","arcrole","title","show","actuate","label","from","to"].map((e=>`xlink:${e}`)),o={IN_PLACE:!0,USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ALLOWED_ATTR:t};return lx().sanitize(e,o),e.innerHTML},Ex=(e,t)=>{const o=(()=>{let e=[];const t=()=>e[e.length-1];return{track:o=>{xs(o)&&e.push(o);let n=t();return n&&!n.contains(o)&&(e.pop(),n=t()),Cs(n)},current:()=>Cs(t()),reset:()=>{e=[]}}})();if(e.sanitize){const n=kx(e,t,o),r=(t,r)=>{n.sanitize(t,((e,t)=>{const o={IN_PLACE:!0,ALLOW_UNKNOWN_PROTOCOLS:!0,ALLOWED_TAGS:["#comment","#cdata-section","body"],ALLOWED_ATTR:[]};return o.PARSER_MEDIA_TYPE=t,e.allow_script_urls?o.ALLOWED_URI_REGEXP=/.*/:e.allow_html_data_urls&&(o.ALLOWED_URI_REGEXP=/^(?!(\w+script|mhtml):)/i),o})(e,r)),n.removed=[],o.reset()};return{sanitizeHtmlElement:r,sanitizeNamespaceElement:_x}}return{sanitizeHtmlElement:(n,r)=>{const s=document.createNodeIterator(n,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let a;for(;a=s.nextNode();){const n=o.track(a);yx(a,e,t,n),Wn(a)&&Sx(a,e,t,n)}o.reset()},sanitizeNamespaceElement:E}},Tx=Bt.makeMap,Ox=Bt.extend,Dx=(e,t,o,n)=>{const r=e.name,s=r in o&&"title"!==r&&"textarea"!==r,a=t.childNodes;for(let t=0,r=a.length;t{const r=o.validate,s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=Ox(Tx("script,style,head,html,body,title,meta,param"),t.getBlockElements()),l=va(t),c=/[ \t\r\n]+/g,d=/^[ \t\r\n]+/,m=/[ \t\r\n]+$/,u=e=>{let t=e.parent;for(;C(t);){if(t.name in a)return!0;t=t.parent}return!1},g=o=>o.name in i||Is(t,o)||ws(o.name)&&o.parent===e,h=(t,o)=>{const r=o?t.prev:t.next;return!C(r)&&!x(t.parent)&&g(t.parent)&&(t.parent!==e||!0===n.isRootContent)};return[e=>{var t;if(3===e.type&&!u(e)){let o=null!==(t=e.value)&&void 0!==t?t:"";o=o.replace(c," "),(((e,t)=>C(e)&&(t(e)||"br"===e.name))(e.prev,g)||h(e,!0))&&(o=o.replace(d,"")),0===o.length?e.remove():e.value=o}},e=>{var i;if(1===e.type){const i=t.getElementRule(e.name);if(r&&i){const r=mb(t,s,a,e);i.paddInEmptyBlock&&r&&(e=>{let o=e;for(;C(o);){if(o.name in l)return mb(t,s,a,o);o=o.parent}return!1})(e)?cb(o,n,g,e):i.removeEmpty&&r?g(e)?e.remove():e.unwrap():i.paddEmpty&&(r||(e=>{var t;return db(e,"#text")&&(null===(t=null==e?void 0:e.firstChild)||void 0===t?void 0:t.value)===br})(e))&&cb(o,n,g,e)}}else if(3===e.type&&!u(e)){let t=null!==(i=e.value)&&void 0!==i?i:"";(e.next&&g(e.next)||h(e,!1))&&(t=t.replace(m,"")),0===t.length?e.remove():e.value=t}}]},Mx=(e={},t=ya())=>{const o=Qy(),n=Qy(),r={validate:!0,root_name:"body",sanitize:!0,...e},s=new DOMParser,a=Ex(r,t),i=o.addFilter,l=o.getFilters,c=o.removeFilter,d=n.addFilter,m=n.getFilters,u=n.removeFilter,g=(e,o)=>{const n=h(o.attr(vx)),r=1===o.type&&!_e(e,o.name)&&!Is(t,o)&&!ws(o.name);return 3===o.type||r&&!n},p={schema:t,addAttributeFilter:d,getAttributeFilters:m,removeAttributeFilter:u,addNodeFilter:i,getNodeFilters:l,removeNodeFilter:c,parse:(e,o={})=>{var n;const i=r.validate,c=null!==(n=o.context)&&void 0!==n?n:r.root_name,d=((e,o,n="html")=>{const r="xhtml"===n?"application/xhtml+xml":"text/html",i=_e(t.getSpecialElements(),o.toLowerCase()),l=i?`<${o}>${e}`:e,c="xhtml"===n?`${l}`:`${l}`,d=s.parseFromString(c,r).body;return a.sanitizeHtmlElement(d,r),i?d.firstChild:d})(e,c,o.format);As(t,d);const u=new Ep(c,11);Dx(u,d,t.getSpecialElements(),a.sanitizeNamespaceElement),d.innerHTML="";const[h,p]=Ax(u,t,r,o),f=[],v=i?e=>((e,o)=>{pb(t,e)&&o.push(e)})(e,f):E,b={nodes:{},attributes:{}},y=e=>ab(l(),m(),e,b);if(((e,t,o)=>{const n=[];for(let o=e,r=o;o;r=o,o=o.walk()){const s=o;q(t,(e=>e(s))),x(s.parent)&&s!==e?o=r:n.push(s)}for(let e=n.length-1;e>=0;e--){const t=n[e];q(o,(e=>e(t)))}})(u,[h,y],[p,v]),f.reverse(),i&&f.length>0)if(o.context){const{pass:e,fail:n}=K(f,(e=>e.parent===u));hb(n,t,u,y),o.invalid=e.length>0}else hb(f,t,u,y);const w=((e,t)=>{var o;const n=null!==(o=t.forced_root_block)&&void 0!==o?o:e.forced_root_block;return!1===n?"":!0===n?"p":n})(r,o);return w&&("body"===u.name||o.isRootContent)&&((e,o)=>{const n=Ox(Tx("script,style,head,html,body,title,meta,param"),t.getBlockElements()),s=/^[ \t\r\n]+/,a=/[ \t\r\n]+$/;let i=e.firstChild,l=null;const c=e=>{var t,o;e&&(i=e.firstChild,i&&3===i.type&&(i.value=null===(t=i.value)||void 0===t?void 0:t.replace(s,"")),i=e.lastChild,i&&3===i.type&&(i.value=null===(o=i.value)||void 0===o?void 0:o.replace(a,"")))};if(t.isValidChild(e.name,o.toLowerCase())){for(;i;){const t=i.next;g(n,i)?(l||(l=new Ep(o,1),l.attr(r.forced_root_block_attrs),e.insert(l,i)),l.append(i)):(c(l),l=null),i=t}c(l)}})(u,w),o.invalid||ib(b,o),u}};return gw(p,r),((e,t,o)=>{t.inline_styles&&tw(e,t,o)})(p,r,t),p},Nx=(e,t,o)=>{const n=(e=>Nb(e)?$p({validate:!1}).serialize(e):e)(e),r=t(n);if(r.isDefaultPrevented())return r;if(Nb(e)){if(r.content!==n){const t=Mx({validate:!1,forced_root_block:!1,...o}).parse(r.content,{context:e.name});return{...r,content:t}}return{...r,content:e}}return r},Rx=(e,t)=>{if(t.no_events)return Dl.value(t);{const o=((e,t)=>e.dispatch("BeforeGetContent",t))(e,t);return o.isDefaultPrevented()?Dl.error(Tg(e,{content:"",...o}).content):Dl.value(o)}},Bx=(e,t,o)=>{if(o.no_events)return t;{const n=Nx(t,(t=>Tg(e,{...o,content:t})),{sanitize:Td(e),sandbox_iframes:Bd(e)});return n.content}},Lx=(e,t)=>{if(t.no_events)return Dl.value(t);{const o=Nx(t.content,(o=>((e,t)=>e.dispatch("BeforeSetContent",t))(e,{...t,content:o})),{sanitize:Td(e),sandbox_iframes:Bd(e)});return o.isDefaultPrevented()?(Eg(e,o),Dl.error(void 0)):Dl.value(o)}},Hx=(e,t,o)=>{o.no_events||Eg(e,{...o,content:t})},Ix=(e,t,o)=>({element:e,width:t,rows:o}),Px=(e,t)=>({element:e,cells:t}),Fx=(e,t)=>({x:e,y:t}),zx=(e,t)=>no(e,t).bind(Je).getOr(1),Vx=(e,t,o)=>{const n=e.rows;return!!(n[o]?n[o].cells:[])[t]},Zx=e=>J(e,((e,t)=>t.cells.length>e?t.cells.length:e),0),Ux=(e,t)=>{const o=e.rows;for(let e=0;e{const s=[],a=e.rows;for(let e=o;e<=r;e++){const o=a[e].cells,r=t{const t=Ix(ki(e),0,[]);return q(zn(e,"tr"),((e,o)=>{q(zn(e,"td,th"),((n,r)=>{((e,t,o,n,r)=>{const s=zx(r,"rowspan"),a=zx(r,"colspan"),i=e.rows;for(let e=o;e{for(;Vx(e,t,o);)t++;return t})(t,r,o),o,e,n)}))})),Ix(t.element,Zx(t.rows),t.rows)},$x=e=>((e,t)=>{const o=ki(e.element),n=yo.fromTag("tbody");return wn(n,t),bn(o,n),o})(e,(e=>$(e.rows,(e=>{const t=$(e.cells,(e=>{const t=_i(e);return so(t,"colspan"),so(t,"rowspan"),t})),o=ki(e.element);return wn(o,t),o})))(e)),qx=(e,t,o)=>Ux(e,t).bind((t=>Ux(e,o).map((o=>((e,t,o)=>{const n=t.x,r=t.y,s=o.x,a=o.y,i=ree(e,(e=>"li"===jt(e)&&Su(e,t))).fold(D([]),(t=>(e=>ee(e,(e=>"ul"===jt(e)||"ol"===jt(e))))(e).map((e=>{const t=yo.fromTag(jt(e)),o=xe(gn(e),((e,t)=>je(t,"list-style")));return cn(t,o),[yo.fromTag("li"),t]})).getOr([]))),Kx=(e,t,o)=>{const n=yo.fromDom(t.commonAncestorContainer),r=pf(n,e),s=Y(r,(e=>o.isWrapper(jt(e)))),a=Gx(r,t),i=s.concat(a.length?a:(e=>Tr(e)?Oo(e).filter(Er).fold(D([]),(t=>[e,t])):Er(e)?[e]:[])(n));return $(i,ki)},Yx=()=>Xg([]),Xx=(e,t,o)=>((e,t)=>{const o=J(t,((e,t)=>(bn(t,e),t)),e);return t.length>0?Xg([o]):o})(yo.fromDom(t.cloneContents()),Kx(e,t,o)),Jx=(e,t)=>((e,t)=>en(t,"table",N(So,e)))(e,t[0]).bind((e=>{const o=t[0],n=t[t.length-1],r=Wx(e);return qx(r,o,n).map((e=>Xg([$x(e)])))})).getOrThunk(Yx),Qx=(e,t,o)=>{const n=bu(t,e);return n.length>0?Jx(e,n):((e,t,o)=>t.length>0&&t[0].collapsed?Yx():Xx(e,t[0],o))(e,t,o)},eC=(e,t)=>t>=0&&tHr(e.innerText),oC=(e,t)=>{if("text"===t.format)return(e=>F.from(e.selection.getRng()).map((t=>{var o;const n=F.from(e.dom.getParent(t.commonAncestorContainer,e.dom.isBlock)),r=e.getBody(),s=(e=>e.map((e=>e.nodeName)).getOr("div").toLowerCase())(n),a=yo.fromDom(t.cloneContents());zp(a),Vp(a);const i=e.dom.add(r,s,{"data-mce-bogus":"all",style:"overflow: hidden; opacity: 0;"},a.dom),l=tC(i),c=Hr(null!==(o=i.textContent)&&void 0!==o?o:"");if(e.dom.remove(i),eC(c,0)||eC(c,c.length-1)){const e=n.getOr(r),t=tC(e),o=t.indexOf(l);return-1===o?l:(eC(t,o-1)?" ":"")+l+(eC(t,o+l.length)?" ":"")}return l})).getOr(""))(e);{const o=((e,t)=>{const o=e.selection.getRng(),n=e.dom.create("body"),r=e.selection.getSel(),s=pp(e,fu(r)),a=t.contextual?Qx(yo.fromDom(e.getBody()),s,e.schema).dom:o.cloneContents();return a&&n.appendChild(a),e.selection.serializer.serialize(n,t)})(e,t);return"tree"===t.format?o:e.selection.isCollapsed()?"":o}},nC=e=>Wn(e)?e.outerHTML:tr(e)?ia.encodeRaw(e.data,!1):rr(e)?"\x3c!--"+e.data+"--\x3e":"",rC=(e,t,o)=>{const n=(e=>{let t;const o=document.createElement("div"),n=document.createDocumentFragment();for(e&&(o.innerHTML=e);t=o.firstChild;)n.appendChild(t);return n})(t);if(e.hasChildNodes()&&o(((e,t)=>{let o=0;q(e,(e=>{0===e[0]?o++:1===e[0]?(rC(t,e[1],o),o++):2===e[0]&&((e,t)=>{if(e.hasChildNodes()&&t{const o=e.length+t.length+2,n=new Array(o),r=new Array(o),s=(o,n,r,a,l)=>{const c=i(o,n,r,a);if(null===c||c.start===n&&c.diag===n-a||c.end===o&&c.diag===o-r){let s=o,i=r;for(;sa-r?(l.push([2,e[s]]),++s):(l.push([1,t[i]]),++i)}else{s(o,c.start,r,c.start-c.diag,l);for(let t=c.start;t{let a=o;for(;a-n({start:e,end:t,diag:o}))(o,a,n)},i=(o,s,i,l)=>{const c=s-o,d=l-i;if(0===c||0===d)return null;const m=c-d,u=d+c,g=(u%2==0?u:u+1)/2;let h,p,f,v,b;for(n[1+g]=o,r[1+g]=s+1,h=0;h<=g;++h){for(p=-h;p<=h;p+=2){for(f=p+g,p===-h||p!==h&&n[f-1]=o&&b>=i&&e[v]===t[b];)r[f]=v--,b--;if(m%2==0&&-h<=p&&p<=h&&r[f]<=n[f+m])return a(r[f],p+o-i,s,l)}}return null},l=[];return s(0,e.length,0,t.length,l),l})($(ue(t.childNodes),nC),e),t),t),aC=He((()=>document.implementation.createHTMLDocument("undo"))),iC=e=>{const t=e.serializer.getTempAttrs(),o=Fp(e.getBody(),t);return(e=>null!==e.querySelector("iframe"))(o)?(n=((e,t)=>Y($(ue(e.childNodes),t?T(Hr,nC):nC),(e=>e.length>0)))(o,!0),{type:"fragmented",fragments:n,content:"",bookmark:null,beforeBookmark:null}):{type:"complete",fragments:null,content:Hr(o.innerHTML),bookmark:null,beforeBookmark:null};var n},lC=(e,t,o)=>{const n=o?t.beforeBookmark:t.bookmark;"fragmented"===t.type?sC(t.fragments,e.getBody()):e.setContent(t.content,{format:"raw",no_selection:!C(n)||!eu(n)||!n.isFakeCaret}),n&&(e.selection.moveToBookmark(n),e.selection.scrollIntoView())},cC=e=>"fragmented"===e.type?e.fragments.join(""):e.content,dC=e=>{const t=yo.fromTag("body",aC());return En(t,cC(e)),q(zn(t,"*[data-mce-bogus]"),Sn),_n(t)},mC=(e,t)=>!(!e||!t)&&(!!((e,t)=>cC(e)===cC(t))(e,t)||((e,t)=>dC(e)===dC(t))(e,t)),uC=e=>0===e.get(),gC=(e,t,o)=>{uC(o)&&(e.typing=t)},hC=(e,t)=>{e.typing&&(gC(e,!1,t),e.add())},pC=e=>({init:{bindEvents:E},undoManager:{beforeChange:(t,o)=>((e,t,o)=>{uC(t)&&o.set(El(e.selection))})(e,t,o),add:(t,o,n,r,s,a)=>((e,t,o,n,r,s,a)=>{const i=iC(e),l=Bt.extend(s||{},i);if(!uC(n)||e.removed)return null;const c=t.data[o.get()];if(e.dispatch("BeforeAddUndo",{level:l,lastLevel:c,originalEvent:a}).isDefaultPrevented())return null;if(c&&mC(c,l))return null;t.data[o.get()]&&r.get().each((e=>{t.data[o.get()].beforeBookmark=e}));const d=jc(e);if(d&&t.data.length>d){for(let e=0;e0?(e.setDirty(!0),e.dispatch("AddUndo",m),e.dispatch("change",m)):e.dispatch("AddUndo",m),l})(e,t,o,n,r,s,a),undo:(t,o,n)=>((e,t,o,n)=>{let r;return t.typing&&(t.add(),t.typing=!1,gC(t,!1,o)),n.get()>0&&(n.set(n.get()-1),r=t.data[n.get()],lC(e,r,!0),e.setDirty(!0),e.dispatch("Undo",{level:r})),r})(e,t,o,n),redo:(t,o)=>((e,t,o)=>{let n;return t.get()((e,t,o)=>{t.data=[],o.set(0),t.typing=!1,e.dispatch("ClearUndos")})(e,t,o),reset:e=>(e=>{e.clear(),e.add()})(e),hasUndo:(t,o)=>((e,t,o)=>o.get()>0||t.typing&&t.data[0]&&!mC(iC(e),t.data[0]))(e,t,o),hasRedo:(e,t)=>((e,t)=>t.get()((e,t,o)=>(hC(e,t),e.beforeChange(),e.ignore(o),e.add()))(e,t,o),ignore:(e,t)=>((e,t)=>{try{e.set(e.get()+1),t()}finally{e.set(e.get()-1)}})(e,t),extra:(t,o,n,r)=>((e,t,o,n,r)=>{if(t.transact(n)){const n=t.data[o.get()].bookmark,s=t.data[o.get()-1];lC(e,s,!0),t.transact(r)&&(t.data[o.get()-1].beforeBookmark=n)}})(e,t,o,n,r)},formatter:{match:(t,o,n,r)=>Ub(e,t,o,n,r),matchAll:(t,o)=>((e,t,o)=>{const n=[],r={},s=e.selection.getStart();return e.dom.getParent(s,(s=>{for(let a=0;aZb(e,t,o,n,r),canApply:t=>((e,t)=>{const o=e.formatter.get(t),n=e.dom;if(o&&e.selection.isEditable()){const t=e.selection.getStart(),r=Zu(n,t);for(let e=o.length-1;e>=0;e--){const t=o[e];if(!$u(t))return!0;for(let e=r.length-1;e>=0;e--)if(n.is(r[e],t.selector))return!0}}return!1})(e,t),closest:t=>jb(e,t),apply:(t,o,n)=>Wy(e,t,o,n),remove:(t,o,n,r)=>Py(e,t,o,n,r),toggle:(t,o,n)=>((e,t,o,n)=>{const r=e.formatter.get(t);r&&(!Ub(e,t,o,n)||"toggle"in r[0]&&!r[0].toggle?Wy(e,t,o,n):Py(e,t,o,n))})(e,t,o,n),formatChanged:(t,o,n,r,s)=>Xy(e,t,o,n,r,s)},editor:{getContent:t=>((e,t)=>F.from(e.getBody()).fold(D("tree"===t.format?new Ep("body",11):""),(o=>Up(e,t,o))))(e,t),setContent:(t,o)=>Bb(e,t,o),insertContent:(t,o)=>Mb(e,t,o),addVisual:t=>((e,t)=>{const o=e.dom,n=C(t)?t:e.getBody();q(o.select("table,a",n),(t=>{switch(t.nodeName){case"TABLE":const n=Qc(e),r=o.getAttrib(t,"border");r&&"0"!==r||!e.hasVisual?o.removeClass(t,n):o.addClass(t,n);break;case"A":if(!o.getAttrib(t,"href")){const n=o.getAttrib(t,"name")||t.id,r=ed(e);n&&e.hasVisual?o.addClass(t,r):o.removeClass(t,r)}}})),e.dispatch("VisualAid",{element:t,hasVisual:e.hasVisual})})(e,t)},selection:{getContent:(t,o)=>((e,t,o={})=>{const n=((e,t)=>({...e,format:t,get:!0,selection:!0,getInner:!0}))(o,t);return Rx(e,n).fold(A,(t=>{const o=oC(e,t);return Bx(e,o,t)}))})(e,t,o)},autocompleter:{addDecoration:t=>wp(e,t),removeDecoration:()=>((e,t)=>xp(t).each((t=>{const o=e.selection.getBookmark();Sn(t),e.selection.moveToBookmark(o)})))(e,yo.fromDom(e.getBody()))},raw:{getModel:()=>F.none()}}),fC=e=>_e(e.plugins,"rtc"),vC=e=>{const t=e;return(e=>ke(e.plugins,"rtc").bind((e=>F.from(e.setup))))(e).fold((()=>(t.rtcInstance=pC(e),F.none())),(e=>(t.rtcInstance=(()=>{const e=D(null),t=D("");return{init:{bindEvents:E},undoManager:{beforeChange:E,add:e,undo:e,redo:e,clear:E,reset:E,hasUndo:I,hasRedo:I,transact:e,ignore:E,extra:E},formatter:{match:I,matchAll:D([]),matchNode:D(void 0),canApply:I,closest:t,apply:E,remove:E,toggle:E,formatChanged:D({unbind:E})},editor:{getContent:t,setContent:D({content:"",html:""}),insertContent:D(""),addVisual:E},selection:{getContent:t},autocompleter:{addDecoration:E,removeDecoration:E},raw:{getModel:D(F.none())}}})(),F.some((()=>e().then((e=>(t.rtcInstance=(e=>{const t=e=>p(e)?e:{},{init:o,undoManager:n,formatter:r,editor:s,selection:a,autocompleter:i,raw:l}=e;return{init:{bindEvents:o.bindEvents},undoManager:{beforeChange:n.beforeChange,add:n.add,undo:n.undo,redo:n.redo,clear:n.clear,reset:n.reset,hasUndo:n.hasUndo,hasRedo:n.hasRedo,transact:(e,t,o)=>n.transact(o),ignore:(e,t)=>n.ignore(t),extra:(e,t,o,r)=>n.extra(o,r)},formatter:{match:(e,o,n,s)=>r.match(e,t(o),s),matchAll:r.matchAll,matchNode:r.matchNode,canApply:e=>r.canApply(e),closest:e=>r.closest(e),apply:(e,o,n)=>r.apply(e,t(o)),remove:(e,o,n,s)=>r.remove(e,t(o)),toggle:(e,o,n)=>r.toggle(e,t(o)),formatChanged:(e,t,o,n,s)=>r.formatChanged(t,o,n,s)},editor:{getContent:e=>s.getContent(e),setContent:(e,t)=>({content:s.setContent(e,t),html:""}),insertContent:(e,t)=>(s.insertContent(e),""),addVisual:s.addVisual},selection:{getContent:(e,t)=>a.getContent(t)},autocompleter:{addDecoration:i.addDecoration,removeDecoration:i.removeDecoration},raw:{getModel:()=>F.some(l.getRawModel())}}})(e),e.rtc.isRemote))))))))},bC=e=>e.rtcInstance?e.rtcInstance:pC(e),yC=e=>{const t=e.rtcInstance;if(t)return t;throw new Error("Failed to get RTC instance not yet initialized.")},wC=e=>yC(e).init.bindEvents(),xC=(e,t={})=>((e,t,o)=>yC(e).selection.getContent(t,o))(e,t.format?t.format:"html",t),CC=e=>0===e.dom.length?(Cn(e),F.none()):F.some(e),SC=(e,t,o,n,r)=>{e.bind((e=>((n?Kf:Gf)(e.dom,n?e.dom.length:0,r),t.filter(Kt).map((t=>((e,t,o,n,r)=>{const s=e.dom,a=t.dom,i=n?s.length:a.length;n?(Yf(s,a,r,!1,!n),o.setStart(a,i)):(Yf(a,s,r,!1,!n),o.setEnd(a,i))})(e,t,o,n,r)))))).orThunk((()=>{const e=((e,t)=>e.filter((e=>xg.isBookmarkNode(e.dom))).bind(t?No:Mo))(t,n).or(t).filter(Kt);return e.map((e=>((e,t,o)=>{Oo(e).each((n=>{const r=e.dom;t&&Pf(n,rl(r,0),o)?Gf(r,0,o):!t&&Ff(n,rl(r,r.length),o)&&Kf(r,r.length,o)}))})(e,n,r)))}))},kC=(e,t,o={})=>{const n=((e,t)=>({format:"html",...e,set:!0,selection:!0,content:t}))(o,t);Lx(e,n).each((t=>{const o=((e,t)=>{if("raw"!==t.format){const o=e.selection.getRng(),n=e.dom.getParent(o.commonAncestorContainer,e.dom.isBlock),r=n?{context:n.nodeName.toLowerCase()}:{},s=e.parser.parse(t.content,{forced_root_block:!1,...r,...t});return $p({validate:!1},e.schema).serialize(s)}return t.content})(e,t),n=e.selection.getRng();((e,t,o)=>{const n=F.from(t.firstChild).map(yo.fromDom),r=F.from(t.lastChild).map(yo.fromDom);e.deleteContents(),e.insertNode(t);const s=n.bind(Mo).filter(Kt).bind(CC),a=r.bind(No).filter(Kt).bind(CC);SC(s,n,e,!0,o),SC(a,r,e,!1,o),e.collapse(!1)})(n,n.createContextualFragment(o),e.schema),e.selection.setRng(n),Rh(e,n),Hx(e,o,t)}))},_C=(e,t,o)=>{if(_e(e,t)){const n=Y(e[t],(e=>e!==o));0===n.length?delete e[t]:e[t]=n}};var EC=(e,t)=>{let o,n;const r=(t,o)=>ee(o,(o=>e.is(o,t))),s=t=>e.getParents(t,void 0,e.getRoot());return{selectorChangedWithUnbind:(e,a)=>(o||(o={},n={},t.on("NodeChange",(e=>{const t=e.element,a=s(t),i={};fe(o,((e,t)=>{r(t,a).each((o=>{n[t]||(q(e,(e=>{e(!0,{node:o,selector:t,parents:a})})),n[t]=e),i[t]=e}))})),fe(n,((e,o)=>{i[o]||(delete n[o],q(e,(e=>{e(!1,{node:t,selector:o,parents:a})})))}))}))),o[e]||(o[e]=[]),o[e].push(a),r(e,s(t.selection.getStart())).each((()=>{n[e]=o[e]})),{unbind:()=>{_C(o,e,a),_C(n,e,a)}})}};const TC=e=>!(!e||!e.ownerDocument)&&ko(yo.fromDom(e.ownerDocument),yo.fromDom(e)),OC=(e,t,o,n)=>{let r,s;const{selectorChangedWithUnbind:a}=EC(e,n),i=(e,t)=>kC(n,e,t),l=e=>{const t=d();t.collapse(!!e),m(t)},c=()=>t.getSelection?t.getSelection():t.document.selection,d=()=>{let o;const a=(e,t,o)=>{try{return t.compareBoundaryPoints(e,o)}catch(e){return-1}},i=t.document;if(C(n.bookmark)&&!ap(n)){const e=Wh(n);if(e.isSome())return e.map((e=>pp(n,[e])[0])).getOr(i.createRange())}try{const e=c();e&&!jn(e.anchorNode)&&(o=e.rangeCount>0?e.getRangeAt(0):i.createRange(),o=pp(n,[o])[0])}catch(e){}if(o||(o=i.createRange()),sr(o.startContainer)&&o.collapsed){const t=e.getRoot();o.setStart(t,0),o.setEnd(t,0)}return r&&s&&(0===a(o.START_TO_START,o,r)&&0===a(o.END_TO_END,o,r)?o=s:(r=null,s=null)),o},m=(e,t)=>{if(!(e=>!!e&&TC(e.startContainer)&&TC(e.endContainer))(e))return;const o=c();if(e=n.dispatch("SetSelectionRange",{range:e,forward:t}).range,o){s=e;try{o.removeAllRanges(),o.addRange(e)}catch(e){}!1===t&&o.extend&&(o.collapse(e.endContainer,e.endOffset),o.extend(e.startContainer,e.startOffset)),r=o.rangeCount>0?o.getRangeAt(0):null}if(!e.collapsed&&e.startContainer===e.endContainer&&(null==o?void 0:o.setBaseAndExtent)&&e.endOffset-e.startOffset<2&&e.startContainer.hasChildNodes()){const t=e.startContainer.childNodes[e.startOffset];t&&"IMG"===t.nodeName&&(o.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset),o.anchorNode===e.startContainer&&o.focusNode===e.endContainer||o.setBaseAndExtent(t,0,t,1))}n.dispatch("AfterSetSelectionRange",{range:e,forward:t})},u=()=>{const t=c(),o=null==t?void 0:t.anchorNode,n=null==t?void 0:t.focusNode;if(!t||!o||!n||jn(o)||jn(n))return!0;const r=e.createRng(),s=e.createRng();try{r.setStart(o,t.anchorOffset),r.collapse(!0),s.setStart(n,t.focusOffset),s.collapse(!0)}catch(e){return!0}return r.compareBoundaryPoints(r.START_TO_START,s)<=0},g={dom:e,win:t,serializer:o,editor:n,expand:(t={type:"word"})=>m(mh(e).expand(d(),t)),collapse:l,setCursorLocation:(t,o)=>{const r=e.createRng();C(t)&&C(o)?(r.setStart(t,o),r.setEnd(t,o),m(r),l(!1)):(ku(e,r,n.getBody(),!0),m(r))},getContent:e=>xC(n,e),setContent:i,getBookmark:(e,t)=>h.getBookmark(e,t),moveToBookmark:e=>h.moveToBookmark(e),select:(t,o)=>(((e,t,o)=>F.from(t).bind((t=>F.from(t.parentNode).map((n=>{const r=e.nodeIndex(t),s=e.createRng();return s.setStart(n,r),s.setEnd(n,r+1),o&&(ku(e,s,t,!0),ku(e,s,t,!1)),s})))))(e,t,o).each(m),t),isCollapsed:()=>{const e=d(),t=c();return!(!e||e.item)&&(e.compareEndPoints?0===e.compareEndPoints("StartToEnd",e):!t||e.collapsed)},isEditable:()=>{const t=d(),o=n.getBody().querySelectorAll('[data-mce-selected="1"]');return o.length>0?re(o,(t=>e.isEditable(t.parentElement))):dp(e,t)},isForward:u,setNode:t=>(i(e.getOuterHTML(t)),t),getNode:()=>((e,t)=>{if(!t)return e;let o=t.startContainer,n=t.endContainer;const r=t.startOffset,s=t.endOffset;let a=t.commonAncestorContainer;t.collapsed||(o===n&&s-r<2&&o.hasChildNodes()&&(a=o.childNodes[r]),tr(o)&&tr(n)&&(o=o.length===r?hp(o.nextSibling,!0):o.parentNode,n=0===s?hp(n.previousSibling,!1):n.parentNode,o&&o===n&&(a=o)));const i=tr(a)?a.parentNode:a;return $n(i)?i:e})(n.getBody(),d()),getSel:c,setRng:m,getRng:d,getStart:e=>up(n.getBody(),d(),e),getEnd:e=>gp(n.getBody(),d(),e),getSelectedBlocks:(t,o)=>((e,t,o,n)=>{const r=[],s=e.getRoot(),a=e.getParent(o||up(s,t,t.collapsed),e.isBlock),i=e.getParent(n||gp(s,t,t.collapsed),e.isBlock);if(a&&a!==s&&r.push(a),a&&i&&a!==i){let t;const o=new Zn(a,s);for(;(t=o.next())&&t!==i;)e.isBlock(t)&&r.push(t)}return i&&a!==i&&i!==s&&r.push(i),r})(e,d(),t,o),normalize:()=>{const t=d(),o=c();if(!(fu(o).length>1)&&_u(n)){const o=lh(e,t);return o.each((e=>{m(e,u())})),o.getOr(t)}return t},selectorChanged:(e,t)=>(a(e,t),g),selectorChangedWithUnbind:a,getScrollContainer:()=>{let t,o=e.getRoot();for(;o&&"BODY"!==o.nodeName;){if(o.scrollHeight>o.clientHeight){t=o;break}o=o.parentNode}return t},scrollIntoView:(e,t)=>{C(e)?((e,t,o)=>{(e.inline?Ah:Nh)(e,t,o)})(n,e,t):Rh(n,d(),t)},placeCaretAt:(e,t)=>m(eh(e,t,n.getDoc())),getBoundingClientRect:()=>{const e=d();return e.collapsed?rl.fromRangeStart(e).getClientRects()[0]:e.getBoundingClientRect()},destroy:()=>{t=r=s=null,p.destroy()}},h=xg(g),p=Bg(g,n);return g.bookmarkManager=h,g.controlSelection=p,g},DC=(e,t,o)=>((e,t)=>C(e)&&e.hasEventListeners("PreProcess")&&!t.no_events)(e,o)?((e,t,o)=>{let n;const r=e.dom;let s=t.cloneNode(!0);const a=document.implementation;if(a.createHTMLDocument){const e=a.createHTMLDocument("");Bt.each("BODY"===s.nodeName?s.childNodes:[s],(t=>{e.body.appendChild(e.importNode(t,!0))})),s="BODY"!==s.nodeName?e.body.firstChild:e.body,n=r.doc,r.doc=e}return((e,t)=>{e.dispatch("PreProcess",t)})(e,{...o,node:s}),n&&(r.doc=n),s})(e,t,o):t,AC=(e,t,o)=>{-1===Bt.inArray(t,o)&&(e.addAttributeFilter(o,((e,t)=>{let o=e.length;for(;o--;)e[o].attr(t,null)})),t.push(o))},MC=(e,t,o,n,r)=>{const s=((e,t,o)=>$p(e,t).serialize(o))(t,o,n);return((e,t,o)=>{if(!t.no_events&&e){const n=((e,t)=>e.dispatch("PostProcess",t))(e,{...t,content:o});return n.content}return o})(e,r,s)},NC=(e,t)=>{const o=["data-mce-selected"],n={entity_encoding:"named",remove_trailing_brs:!0,pad_empty_with_br:!1,...e},r=t&&t.dom?t.dom:Ya.DOM,s=t&&t.schema?t.schema:ya(n),a=Mx(n,s);return((e,t,o)=>{e.addAttributeFilter("data-mce-tabindex",((e,t)=>{let o=e.length;for(;o--;){const n=e[o];n.attr("tabindex",n.attr("data-mce-tabindex")),n.attr(t,null)}})),e.addAttributeFilter("src,href,style",((e,n)=>{const r="data-mce-"+n,s=t.url_converter,a=t.url_converter_scope;let i=e.length;for(;i--;){const t=e[i];let l=t.attr(r);void 0!==l?(t.attr(n,l.length>0?l:null),t.attr(r,null)):(l=t.attr(n),"style"===n?l=o.serializeStyle(o.parseStyle(l),t.name):s&&(l=s.call(a,l,n,t.name)),t.attr(n,l.length>0?l:null))}})),e.addAttributeFilter("class",(e=>{let t=e.length;for(;t--;){const o=e[t];let n=o.attr("class");n&&(n=n.replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),o.attr("class",n.length>0?n:null))}})),e.addAttributeFilter("data-mce-type",((e,t,o)=>{let n=e.length;for(;n--;){const t=e[n];if("bookmark"===t.attr("data-mce-type")&&!o.cleanup){const e=F.from(t.firstChild).exists((e=>{var t;return!Lr(null!==(t=e.value)&&void 0!==t?t:"")}));e?t.unwrap():t.remove()}}})),e.addNodeFilter("noscript",(e=>{var t;let o=e.length;for(;o--;){const n=e[o].firstChild;n&&(n.value=ia.decode(null!==(t=n.value)&&void 0!==t?t:""))}})),e.addNodeFilter("script,style",((e,o)=>{var n;const r=e=>e.replace(/()/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*(()?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"");let s=e.length;for(;s--;){const a=e[s],i=a.firstChild,l=null!==(n=null==i?void 0:i.value)&&void 0!==n?n:"";if("script"===o){const e=a.attr("type");e&&a.attr("type","mce-no/type"===e?null:e.replace(/^mce\-/,"")),"xhtml"===t.element_format&&i&&l.length>0&&(i.value="// ")}else"xhtml"===t.element_format&&i&&l.length>0&&(i.value="\x3c!--\n"+r(l)+"\n--\x3e")}})),e.addNodeFilter("#comment",(e=>{let n=e.length;for(;n--;){const r=e[n],s=r.value;t.preserve_cdata&&0===(null==s?void 0:s.indexOf("[CDATA["))?(r.name="#cdata",r.type=4,r.value=o.decode(s.replace(/^\[CDATA\[|\]\]$/g,""))):0===(null==s?void 0:s.indexOf("mce:protected "))&&(r.name="#text",r.type=3,r.raw=!0,r.value=unescape(s).substr(14))}})),e.addNodeFilter("xml:namespace,input",((e,t)=>{let o=e.length;for(;o--;){const n=e[o];7===n.type?n.remove():1===n.type&&("input"!==t||n.attr("type")||n.attr("type","text"))}})),e.addAttributeFilter("data-mce-type",(t=>{q(t,(t=>{"format-caret"===t.attr("data-mce-type")&&(t.isEmpty(e.schema.getNonEmptyElements())?t.remove():t.unwrap())}))})),e.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-block,data-mce-type,data-mce-resize,data-mce-placeholder",((e,t)=>{let o=e.length;for(;o--;)e[o].attr(t,null)})),t.remove_trailing_brs&&ow(t,e,e.schema)})(a,n,r),{schema:s,addNodeFilter:a.addNodeFilter,addAttributeFilter:a.addAttributeFilter,serialize:(e,o={})=>{const i={format:"html",...o},l=DC(t,e,i),c=((e,t,o)=>{const n=Hr(o.getInner?t.innerHTML:e.getOuterHTML(t));return o.selection||Ar(yo.fromDom(t))?n:Bt.trim(n)})(r,l,i),d=((e,t,o)=>{const n=o.selection?{forced_root_block:!1,...o}:o,r=e.parse(t,n);return(e=>{const t=e=>"br"===(null==e?void 0:e.name),o=e.lastChild;if(t(o)){const e=o.prev;t(e)&&(o.remove(),e.remove())}})(r),r})(a,c,i);return"tree"===i.format?d:MC(t,n,s,d,i)},addRules:s.addValidElements,setRules:s.setValidElements,addTempAttr:N(AC,a,o),getTempAttrs:D(o),getNodeFilters:a.getNodeFilters,getAttributeFilters:a.getAttributeFilters,removeNodeFilter:a.removeNodeFilter,removeAttributeFilter:a.removeAttributeFilter}},RC=(e,t)=>{const o=NC(e,t);return{schema:o.schema,addNodeFilter:o.addNodeFilter,addAttributeFilter:o.addAttributeFilter,serialize:o.serialize,addRules:o.addRules,setRules:o.setRules,addTempAttr:o.addTempAttr,getTempAttrs:o.getTempAttrs,getNodeFilters:o.getNodeFilters,getAttributeFilters:o.getAttributeFilters,removeNodeFilter:o.removeNodeFilter,removeAttributeFilter:o.removeAttributeFilter}},BC=(e,t={})=>{const o=((e,t)=>({...e,format:t,get:!0,getInner:!0}))(t,t.format?t.format:"html");return Rx(e,o).fold(A,(t=>{const o=((e,t)=>bC(e).editor.getContent(t))(e,t);return Bx(e,o,t)}))},LC=(e,t,o={})=>{const n=((e,t)=>({format:"html",...e,set:!0,content:t}))(o,t);return Lx(e,n).map((t=>{const o=((e,t,o)=>bC(e).editor.setContent(t,o))(e,t.content,t);return Hx(e,o.html,t),o.content})).getOr(t)},HC="autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists".split(","),IC="template_cdate_classes,template_mdate_classes,template_selected_content_classes,template_preview_replace_values,template_replace_values,templates,template_cdate_format,template_mdate_format".split(","),PC="bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor".split(","),FC=[{name:"template",replacedWith:"Advanced Template"},{name:"rtc"}],zC=(e,t)=>{const o=Y(t,(t=>_e(e,t)));return le(o)},VC=e=>{const t=zC(e,HC),o=e.forced_root_block;return!1!==o&&""!==o||t.push("forced_root_block (false only)"),le(t)},ZC=e=>zC(e,IC),UC=(e,t)=>{const o=Bt.makeMap(e.plugins," "),n=Y(t,(e=>_e(o,e)));return le(n)},jC=e=>UC(e,PC),WC=e=>UC(e,FC.map((e=>e.name))),$C=e=>ee(FC,(t=>t.name===e)).fold((()=>e),(t=>t.replacedWith?`${e}, replaced by ${t.replacedWith}`:e)),qC=(e,t)=>{((e,t)=>{const o=VC(e),n=jC(t),r=n.length>0,s=o.length>0,a="mobile"===t.theme;if(r||s||a){const e="\n- ",t=a?`\n\nThemes:${e}mobile`:"",i=r?`\n\nPlugins:${e}${n.join(e)}`:"",l=s?`\n\nOptions:${e}${o.join(e)}`:"";console.warn("The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information."+t+i+l)}})(e,t),((e,t)=>{const o=ZC(e),n=WC(t),r=n.length>0,s=o.length>0;if(r||s){const e="\n- ",t=r?`\n\nPlugins:${e}${n.map($C).join(e)}`:"",a=s?`\n\nOptions:${e}${o.join(e)}`:"";console.warn("The following deprecated features are currently enabled but will be removed soon."+t+a)}})(e,t)},GC=Ya.DOM,KC=e=>F.from(e).each((e=>e.destroy())),YC=e=>{if(!e.removed){const{_selectionOverrides:t,editorUpload:o}=e,n=e.getBody(),r=e.getElement();n&&e.save({is_removing:!0}),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&C(null==r?void 0:r.nextSibling)&&GC.remove(r.nextSibling),(e=>{e.dispatch("remove")})(e),e.editorManager.remove(e),!e.inline&&n&&(e=>{GC.setStyle(e.id,"display",e.orgDisplay)})(e),(e=>{e.dispatch("detach")})(e),GC.remove(e.getContainer()),KC(t),KC(o),e.destroy()}},XC=(e,t)=>{const{selection:o,dom:n}=e;e.destroyed||(t||e.removed?(t||(e.editorManager.off("beforeunload",e._beforeUnload),e.theme&&e.theme.destroy&&e.theme.destroy(),KC(o),KC(n)),(e=>{const t=e.formElement;t&&(t._mceOldSubmit&&(t.submit=t._mceOldSubmit,delete t._mceOldSubmit),GC.unbind(t,"submit reset",e.formEventDelegate))})(e),(e=>{const t=e;t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null;const o=e.selection;if(o){const e=o.dom;t.selection=o.win=o.dom=e.doc=null}})(e),e.destroyed=!0):e.remove())},JC=(()=>{const e={};return{add:(t,o)=>{e[t]=o},get:t=>e[t]?e[t]:{icons:{}},has:t=>_e(e,t)}})(),QC=ri.ModelManager,eS=(e,t)=>t.dom[e],tS=(e,t)=>parseInt(dn(t,e),10),oS=N(eS,"clientWidth"),nS=N(eS,"clientHeight"),rS=N(tS,"margin-top"),sS=N(tS,"margin-left"),aS=(e,t,o)=>{const n=yo.fromDom(e.getBody()),r=e.inline?n:(s=n,yo.fromDom(Eo(s).dom.documentElement));var s;const a=((e,t,o,n)=>{const r=(e=>e.dom.getBoundingClientRect())(t);return{x:o-(e?r.left+t.dom.clientLeft+sS(t):0),y:n-(e?r.top+t.dom.clientTop+rS(t):0)}})(e.inline,r,t,o);return((e,t,o)=>{const n=oS(e),r=nS(e);return t>=0&&o>=0&&t<=n&&o<=r})(r,a.x,a.y)},iS=e=>{const t=e.inline?e.getBody():e.getContentAreaContainer();return(o=t,F.from(o).map(yo.fromDom)).map(Go).getOr(!1);var o},lS=e=>{const t=[],o=()=>{const t=e.theme;return t&&t.getNotificationManagerImpl?t.getNotificationManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a NotificationManager implementation.")};return{open:e,close:e,getArgs:e}})()},n=()=>F.from(t[0]),r=()=>{q(t,(e=>{e.reposition()}))},s=e=>{te(t,(t=>t===e)).each((e=>{t.splice(e,1)}))},a=(a,i=!0)=>e.removed||!iS(e)?{}:(i&&e.dispatch("BeforeOpenNotification",{notification:a}),ee(t,(e=>{return t=o().getArgs(e),n=a,!(t.type!==n.type||t.text!==n.text||t.progressBar||t.timeout||n.progressBar||n.timeout);var t,n})).getOrThunk((()=>{e.editorManager.setActive(e);const i=o().open(a,(()=>{s(i),r(),ip(e)&&n().fold((()=>e.focus()),(e=>Bh(yo.fromDom(e.getEl()))))}));return(e=>{t.push(e)})(i),r(),e.dispatch("OpenNotification",{notification:{...i}}),i}))),i=D(t);return(e=>{e.on("SkinLoaded",(()=>{const t=Oc(e);t&&a({text:t,type:"warning",timeout:0},!1),r()})),e.on("show ResizeEditor ResizeWindow NodeChange",(()=>{requestAnimationFrame(r)})),e.on("remove",(()=>{q(t.slice(),(e=>{o().close(e)}))}))})(e),{open:a,close:()=>{n().each((e=>{o().close(e),s(e),r()}))},getNotifications:i}},cS=ri.PluginManager,dS=ri.ThemeManager,mS=e=>{let t=[];const o=()=>{const t=e.theme;return t&&t.getWindowManagerImpl?t.getWindowManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a WindowManager implementation.")};return{open:e,openUrl:e,alert:e,confirm:e,close:e}})()},n=(e,t)=>(...o)=>t?t.apply(e,o):void 0,r=o=>{t.push(o),(t=>{e.dispatch("OpenWindow",{dialog:t})})(o)},s=o=>{(t=>{e.dispatch("CloseWindow",{dialog:t})})(o),t=Y(t,(e=>e!==o)),0===t.length&&e.focus()},a=t=>{e.editorManager.setActive(e),jh(e),e.ui.show();const o=t();return r(o),o};return e.on("remove",(()=>{q(t,(e=>{o().close(e)}))})),{open:(e,t)=>a((()=>o().open(e,t,s))),openUrl:e=>a((()=>o().openUrl(e,s))),alert:(e,t,r)=>{const s=o();s.alert(e,n(r||s,t))},confirm:(e,t,r)=>{const s=o();s.confirm(e,n(r||s,t))},close:()=>{F.from(t[t.length-1]).each((e=>{o().close(e),s(e)}))}}},uS=(e,t)=>{e.notificationManager.open({type:"error",text:t})},gS=(e,t)=>{e._skinLoaded?uS(e,t):e.on("SkinLoaded",(()=>{uS(e,t)}))},hS=(e,t,o)=>{Sg(e,t,{message:o}),console.error(o)},pS=(e,t,o)=>o?`Failed to load ${e}: ${o} from url ${t}`:`Failed to load ${e} url: ${t}`,fS=(e,...t)=>{const o=window.console;o&&(o.error?o.error(e,...t):o.log(e,...t))},vS=e=>"content/"+e+"/content.css",bS=(e,t)=>{const o=e.editorManager.baseURL+"/skins/content",n=`content${e.editorManager.suffix}.css`;return $(t,(t=>(e=>tinymce.Resource.has(vS(e)))(t)?t:(e=>/^[a-z0-9\-]+$/i.test(e))(t)&&!e.inline?`${o}/${t}/${n}`:e.documentBaseURI.toAbsolute(t)))},yS=e=>{e.contentCSS=e.contentCSS.concat((e=>bS(e,yc(e)))(e),(e=>bS(e,xc(e)))(e))},wS=(e,t)=>{const o={};return{findAll:(n,r=P)=>{const s=Y((e=>e?ue(e.getElementsByTagName("img")):[])(n),(t=>{const o=t.src;return!t.hasAttribute("data-mce-bogus")&&!t.hasAttribute("data-mce-placeholder")&&!(!o||o===At.transparentSrc)&&(je(o,"blob:")?!e.isUploaded(o)&&r(t):!!je(o,"data:")&&r(t))})),a=$(s,(e=>{const n=e.src;if(_e(o,n))return o[n].then((t=>h(t)?t:{image:e,blobInfo:t.blobInfo}));{const r=((e,t)=>{const o=()=>Promise.reject("Invalid data URI");if(je(t,"blob:")){const n=e.getByUri(t);return C(n)?Promise.resolve(n):sw(t).then((t=>aw(t).then((n=>lw(n,!1,(o=>F.some(cw(e,t,o)))).getOrThunk(o)))))}return je(t,"data:")?dw(e,t).fold(o,(e=>Promise.resolve(e))):Promise.reject("Unknown image data format")})(t,n).then((t=>(delete o[n],{image:e,blobInfo:t}))).catch((e=>(delete o[n],e)));return o[n]=r,r}}));return Promise.all(a)}}},xS=()=>{let e={};const t=(e,t)=>({status:e,resultUri:t}),o=t=>t in e;return{hasBlobUri:o,getResultUri:t=>{const o=e[t];return o?o.resultUri:null},isPending:t=>!!o(t)&&1===e[t].status,isUploaded:t=>!!o(t)&&2===e[t].status,markPending:o=>{e[o]=t(1,null)},markUploaded:(o,n)=>{e[o]=t(2,n)},removeFailed:t=>{delete e[t]},destroy:()=>{e={}}}};let CS=0;const SS=e=>e+CS+++(()=>{const e=()=>Math.round(4294967295*Math.random()).toString(36);return"s"+(new Date).getTime().toString(36)+e()+e()+e()})(),kS=(e,t)=>{const o={},n=(e,o)=>new Promise(((n,r)=>{const s=new XMLHttpRequest;s.open("POST",t.url),s.withCredentials=t.credentials,s.upload.onprogress=e=>{o(e.loaded/e.total*100)},s.onerror=()=>{r("Image upload failed due to a XHR Transport error. Code: "+s.status)},s.onload=()=>{if(s.status<200||s.status>=300)return void r("HTTP Error: "+s.status);const e=JSON.parse(s.responseText);var o,a;e&&h(e.location)?n((o=t.basePath,a=e.location,o?o.replace(/\/$/,"")+"/"+a.replace(/^\//,""):a)):r("Invalid JSON: "+s.responseText)};const a=new FormData;a.append("file",e.blob(),e.filename()),s.send(a)})),r=S(t.handler)?t.handler:n,s=(e,t)=>({url:t,blobInfo:e,status:!0}),a=(e,t)=>({url:"",blobInfo:e,status:!1,error:t}),i=(e,t)=>{Bt.each(o[e],(e=>{e(t)})),delete o[e]},l=(t,n)=>(t=Bt.grep(t,(t=>!e.isUploaded(t.blobUri()))),Promise.all(Bt.map(t,(t=>e.isPending(t.blobUri())?(e=>{const t=e.blobUri();return new Promise((e=>{o[t]=o[t]||[],o[t].push(e)}))})(t):((t,o,n)=>(e.markPending(t.blobUri()),new Promise((r=>{let l,c;try{const d=()=>{l&&(l.close(),c=E)},m=o=>{d(),e.markUploaded(t.blobUri(),o),i(t.blobUri(),s(t,o)),r(s(t,o))},u=o=>{d(),e.removeFailed(t.blobUri()),i(t.blobUri(),a(t,o)),r(a(t,o))};c=e=>{e<0||e>100||F.from(l).orThunk((()=>F.from(n).map(L))).each((t=>{l=t,t.progressBar.value(e)}))},o(t,c).then(m,(e=>{u(h(e)?{message:e}:e)}))}catch(e){r(a(t,e))}}))))(t,r,n)))));return{upload:(e,o)=>t.url||r!==n?l(e,o):new Promise((e=>{e([])}))}},_S=e=>()=>e.notificationManager.open({text:e.translate("Image uploading..."),type:"info",timeout:-1,progressBar:!0}),ES=(e,t)=>kS(t,{url:cc(e),basePath:dc(e),credentials:mc(e),handler:uc(e)}),TS=e=>t=>{((e,t)=>e.dom.isEmpty(t.dom)&&C(e.schema.getTextBlockElements()[jt(t)]))(e,t)&&bn(t,yo.fromHtml('
    '))},OS=e=>{const t=(()=>{let e=[];const t=e=>{if(!e.blob||!e.base64)throw new Error("blob and base64 representations of the image are required for BlobInfo to be created");const t=e.id||SS("blobid"),o=e.name||t,n=e.blob;return{id:D(t),name:D(o),filename:D(e.filename||o+"."+(r=n.type,{"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png","image/apng":"apng","image/avif":"avif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff"}[r.toLowerCase()]||"dat")),blob:D(n),base64:D(e.base64),blobUri:D(e.blobUri||URL.createObjectURL(n)),uri:D(e.uri)};var r},o=t=>ee(e,t).getOrUndefined(),n=e=>o((t=>t.id()===e));return{create:(e,o,n,r,s)=>{if(h(e))return t({id:e,name:r,filename:s,blob:o,base64:n});if(p(e))return t(e);throw new Error("Unknown input type")},add:t=>{n(t.id())||e.push(t)},get:n,getByUri:e=>o((t=>t.blobUri()===e)),getByData:(e,t)=>o((o=>o.base64()===e&&o.blob().type===t)),findFirst:o,removeByUri:t=>{e=Y(e,(e=>e.blobUri()!==t||(URL.revokeObjectURL(e.blobUri()),!1)))},destroy:()=>{q(e,(e=>{URL.revokeObjectURL(e.blobUri())})),e=[]}}})();let o,n;const r=xS(),s=[],a=t=>o=>e.selection?t(o):[],i=(e,t,o)=>{let n=0;do{n=e.indexOf(t,n),-1!==n&&(e=e.substring(0,n)+o+e.substr(n+t.length),n+=o.length-t.length+1)}while(-1!==n);return e},l=(e,t,o)=>{const n=`src="${o}"${o===At.transparentSrc?' data-mce-placeholder="1"':""}`;return e=i(e,`src="${t}"`,n),e=i(e,'data-mce-src="'+t+'"','data-mce-src="'+o+'"')},c=(t,o)=>{q(e.undoManager.data,(e=>{"fragmented"===e.type?e.fragments=$(e.fragments,(e=>l(e,t,o))):e.content=l(e.content,t,o)}))},d=()=>(o||(o=ES(e,r)),g().then(a((n=>{const r=$(n,(e=>e.blobInfo));return o.upload(r,_S(e)).then(a((o=>{const r=[];let s=!1;const a=$(o,((o,a)=>{const{blobInfo:i,image:l}=n[a];let d=!1;return o.status&&ac(e)?(o.url&&!Ue(l.src,o.url)&&(s=!0),t.removeByUri(l.src),fC(e)||((t,o)=>{const n=e.convertURL(o,"src");var r;c(t.src,o),to(yo.fromDom(t),{src:sc(e)?(r=o,r+(-1===r.indexOf("?")?"?":"&")+(new Date).getTime()):o,"data-mce-src":n})})(l,o.url)):o.error&&(o.error.remove&&(c(l.src,At.transparentSrc),r.push(l),d=!0),((e,t)=>{gS(e,ni.translate(["Failed to upload image: {0}",t]))})(e,o.error.message)),{element:l,status:o.status,uploadUri:o.url,blobInfo:i,removed:d}}));return r.length>0&&!fC(e)?e.undoManager.transact((()=>{q(kn(r),(o=>{const n=Oo(o);Cn(o),n.each(TS(e)),t.removeByUri(o.dom.src)}))})):s&&e.undoManager.dispatchChange(),a})))})))),m=()=>rc(e)?d():Promise.resolve([]),u=e=>re(s,(t=>t(e))),g=()=>(n||(n=wS(r,t)),n.findAll(e.getBody(),u).then(a((t=>{const o=Y(t,(t=>h(t)?(gS(e,t),!1):"blob"!==t.uriType));return fC(e)||q(o,(e=>{c(e.image.src,e.blobInfo.blobUri()),e.image.src=e.blobInfo.blobUri(),e.image.removeAttribute("data-mce-src")})),o})))),f=o=>o.replace(/src="(blob:[^"]+)"/g,((o,n)=>{const s=r.getResultUri(n);if(s)return'src="'+s+'"';let a=t.getByUri(n);return a||(a=J(e.editorManager.get(),((e,t)=>e||t.editorUpload&&t.editorUpload.blobCache.getByUri(n)),void 0)),a?'src="data:'+a.blob().type+";base64,"+a.base64()+'"':o}));return e.on("SetContent",(()=>{rc(e)?m():g()})),e.on("RawSaveContent",(e=>{e.content=f(e.content)})),e.on("GetContent",(e=>{e.source_view||"raw"===e.format||"tree"===e.format||(e.content=f(e.content))})),e.on("PostRender",(()=>{e.parser.addNodeFilter("img",(e=>{q(e,(e=>{const o=e.attr("src");if(!o||t.getByUri(o))return;const n=r.getResultUri(o);n&&e.attr("src",n)}))}))})),{blobCache:t,addFilter:e=>{s.push(e)},uploadImages:d,uploadImagesAuto:m,scanForImages:g,destroy:()=>{t.destroy(),r.destroy(),n=o=null}}},DS={remove_similar:!0,inherit:!1},AS={selector:"td,th",...DS},MS={tablecellbackgroundcolor:{styles:{backgroundColor:"%value"},...AS},tablecellverticalalign:{styles:{"vertical-align":"%value"},...AS},tablecellbordercolor:{styles:{borderColor:"%value"},...AS},tablecellclass:{classes:["%value"],...AS},tableclass:{selector:"table",classes:["%value"],...DS},tablecellborderstyle:{styles:{borderStyle:"%value"},...AS},tablecellborderwidth:{styles:{borderWidth:"%value"},...AS}},NS=D(MS),RS=e=>{const t={},o=(e,n)=>{e&&(h(e)?(v(n)||(n=[n]),q(n,(e=>{w(e.deep)&&(e.deep=!$u(e)),w(e.split)&&(e.split=!$u(e)||qu(e)),w(e.remove)&&$u(e)&&!qu(e)&&(e.remove="none"),$u(e)&&qu(e)&&(e.mixed=!0,e.block_expand=!0),h(e.classes)&&(e.classes=e.classes.split(/\s+/))})),t[e]=n):fe(e,((e,t)=>{o(t,e)})))};return o((e=>{const t=e.dom,o=e.schema.type,n={valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}],alignleft:[{selector:"figure.image",collapsed:!1,classes:"align-left",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"left"},inherit:!1,preview:!1},{selector:"img,audio,video",collapsed:!1,styles:{float:"left"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginLeft:"0px",marginRight:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"center"},inherit:!1,preview:"font-family font-size"},{selector:"figure.image",collapsed:!1,classes:"align-center",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{display:"block",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"table",collapsed:!1,styles:{marginLeft:"auto",marginRight:"auto"},preview:"font-family font-size"},{selector:".mce-preview-object",ceFalseOverride:!0,styles:{display:"table",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{marginLeft:"auto",marginRight:"auto"},preview:!1}],alignright:[{selector:"figure.image",collapsed:!1,classes:"align-right",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"right"},inherit:!1,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{float:"right"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginRight:"0px",marginLeft:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"right"},preview:!1}],alignjustify:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"justify"},inherit:!1,preview:"font-family font-size"}],bold:[{inline:"strong",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all",preserve_attributes:["class","style"]}],italic:[{inline:"em",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all",preserve_attributes:["class","style"]}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:!0},{inline:"u",remove:"all",preserve_attributes:["class","style"]}],strikethrough:(()=>{const e={inline:"span",styles:{textDecoration:"line-through"},exact:!0},t={inline:"strike",remove:"all",preserve_attributes:["class","style"]},n={inline:"s",remove:"all",preserve_attributes:["class","style"]};return"html4"!==o?[n,e,t]:[e,n,t]})(),forecolor:{inline:"span",styles:{color:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},fontname:{inline:"span",toggle:!1,styles:{fontFamily:"%value"},clear_child_styles:!0},fontsize:{inline:"span",toggle:!1,styles:{fontSize:"%value"},clear_child_styles:!0},lineheight:{selector:"h1,h2,h3,h4,h5,h6,p,li,td,th,div",styles:{lineHeight:"%value"}},fontsize_class:{inline:"span",attributes:{class:"%value"}},blockquote:{block:"blockquote",wrapper:!0,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},code:{inline:"code"},link:{inline:"a",selector:"a",remove:"all",split:!0,deep:!0,onmatch:(e,t,o)=>Wn(e)&&e.hasAttribute("href"),onformat:(e,o,n)=>{Bt.each(n,((o,n)=>{t.setAttrib(e,n,o)}))}},lang:{inline:"span",clear_child_styles:!0,remove_similar:!0,attributes:{lang:"%value","data-mce-lang":e=>{var t;return null!==(t=null==e?void 0:e.customValue)&&void 0!==t?t:null}}},removeformat:[{selector:"b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small",remove:"all",split:!0,expand:!1,block_expand:!0,deep:!0},{selector:"span",attributes:["style","class"],remove:"empty",split:!0,expand:!1,deep:!0},{selector:"*",attributes:["style","class"],split:!1,expand:!1,deep:!0}]};return Bt.each("p h1 h2 h3 h4 h5 h6 div address pre dt dd samp".split(/\s/),(e=>{n[e]={block:e,remove:"all"}})),n})(e)),o(NS()),o(Bc(e)),{get:e=>C(e)?t[e]:t,has:e=>_e(t,e),register:o,unregister:e=>(e&&t[e]&&delete t[e],t)}},BS=Bt.each,LS=Ya.DOM,HS=e=>C(e)&&p(e),IS=(e,t)=>{const o=t&&t.schema||ya({}),n=e=>{const t=h(e)?{name:e,classes:[],attrs:{}}:e,o=LS.create(t.name);return((e,t)=>{t.classes.length>0&&LS.addClass(e,t.classes.join(" ")),LS.setAttribs(e,t.attrs)})(o,t),o},r=(e,t,s)=>{let a;const i=t[0],l=HS(i)?i.name:void 0,c=((e,t)=>{const n=o.getElementRule(e.nodeName.toLowerCase()),r=null==n?void 0:n.parentsRequired;return!(!r||!r.length)&&(t&&j(r,t)?t:r[0])})(e,l);if(c)l===c?(a=i,t=t.slice(1)):a=c;else if(i)a=i,t=t.slice(1);else if(!s)return e;const d=a?n(a):LS.create("div");d.appendChild(e),s&&Bt.each(s,(t=>{const o=n(t);d.insertBefore(o,e)}));const m=HS(a)?a.siblings:void 0;return r(d,t,m)},s=LS.create("div");if(e.length>0){const t=e[0],o=n(t),a=HS(t)?t.siblings:void 0;s.appendChild(r(o,e.slice(1),a))}return s},PS=e=>{let t="div";const o={name:t,classes:[],attrs:{},selector:e=Bt.trim(e)};return"*"!==e&&(t=e.replace(/(?:([#\.]|::?)([\w\-]+)|(\[)([^\]]+)\]?)/g,((e,t,n,r,s)=>{switch(t){case"#":o.attrs.id=n;break;case".":o.classes.push(n);break;case":":-1!==Bt.inArray("checked disabled enabled read-only required".split(" "),n)&&(o.attrs[n]=n)}if("["===r){const e=s.match(/([\w\-]+)(?:\=\"([^\"]+))?/);e&&(o.attrs[e[1]]=e[2])}return""}))),o.name=t||"div",o},FS=(e,t)=>{let o="",n=Lc(e);if(""===n)return"";const r=e=>h(e)?e.replace(/%(\w+)/g,""):"",s=(t,o)=>LS.getStyle(null!=o?o:e.getBody(),t,!0);if(h(t)){const o=e.formatter.get(t);if(!o)return"";t=o[0]}if("preview"in t){const e=t.preview;if(!1===e)return"";n=e||n}let a,i=t.block||t.inline||"span";const l=(c=t.selector,h(c)?(c=(c=c.split(/\s*,\s*/)[0]).replace(/\s*(~\+|~|\+|>)\s*/g,"$1"),Bt.map(c.split(/(?:>|\s+(?![^\[\]]+\]))/),(e=>{const t=Bt.map(e.split(/(?:~\+|~|\+)/),PS),o=t.pop();return t.length&&(o.siblings=t),o})).reverse()):[]);var c;l.length>0?(l[0].name||(l[0].name=i),i=t.selector,a=IS(l,e)):a=IS([i],e);const d=LS.select(i,a)[0]||a.firstChild;BS(t.styles,((e,t)=>{const o=r(e);o&&LS.setStyle(d,t,o)})),BS(t.attributes,((e,t)=>{const o=r(e);o&&LS.setAttrib(d,t,o)})),BS(t.classes,(e=>{const t=r(e);LS.hasClass(d,t)||LS.addClass(d,t)})),e.dispatch("PreviewFormats"),LS.setStyles(a,{position:"absolute",left:-65535}),e.getBody().appendChild(a);const m=s("fontSize"),u=/px$/.test(m)?parseInt(m,10):0;return BS(n.split(" "),(e=>{let t=s(e,d);if(!("background-color"===e&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(t)&&(t=s(e),"#ffffff"===Da(t).toLowerCase())||"color"===e&&"#000000"===Da(t).toLowerCase())){if("font-size"===e&&/em|%$/.test(t)){if(0===u)return;t=parseFloat(t)/(/%$/.test(t)?100:1)*u+"px"}"border"===e&&t&&(o+="padding:0 2px;"),o+=e+":"+t+";"}})),e.dispatch("AfterPreviewFormats"),LS.remove(a),o},zS=e=>{const t=RS(e),o=Qa({});return(e=>{e.addShortcut("meta+b","","Bold"),e.addShortcut("meta+i","","Italic"),e.addShortcut("meta+u","","Underline");for(let t=1;t<=6;t++)e.addShortcut("access+"+t,"",["FormatBlock",!1,"h"+t]);e.addShortcut("access+7","",["FormatBlock",!1,"p"]),e.addShortcut("access+8","",["FormatBlock",!1,"div"]),e.addShortcut("access+9","",["FormatBlock",!1,"address"])})(e),ey(e),fC(e)||((e,t)=>{e.set({}),t.on("NodeChange",(o=>{Yy(t,o.element,e.get())})),t.on("FormatApply FormatRemove",(o=>{const n=F.from(o.node).map((e=>Ou(e)?e:e.startContainer)).bind((e=>Wn(e)?F.some(e):F.from(e.parentElement))).getOrThunk((()=>qy(t)));Yy(t,n,e.get())}))})(o,e),{get:t.get,has:t.has,register:t.register,unregister:t.unregister,apply:(t,o,n)=>{((e,t,o,n)=>{yC(e).formatter.apply(t,o,n)})(e,t,o,n)},remove:(t,o,n,r)=>{((e,t,o,n,r)=>{yC(e).formatter.remove(t,o,n,r)})(e,t,o,n,r)},toggle:(t,o,n)=>{((e,t,o,n)=>{yC(e).formatter.toggle(t,o,n)})(e,t,o,n)},match:(t,o,n,r)=>((e,t,o,n,r)=>yC(e).formatter.match(t,o,n,r))(e,t,o,n,r),closest:t=>((e,t)=>yC(e).formatter.closest(t))(e,t),matchAll:(t,o)=>((e,t,o)=>yC(e).formatter.matchAll(t,o))(e,t,o),matchNode:(t,o,n,r)=>((e,t,o,n,r)=>yC(e).formatter.matchNode(t,o,n,r))(e,t,o,n,r),canApply:t=>((e,t)=>yC(e).formatter.canApply(t))(e,t),formatChanged:(t,n,r,s)=>((e,t,o,n,r,s)=>yC(e).formatter.formatChanged(t,o,n,r,s))(e,o,t,n,r,s),getCssText:N(FS,e)}},VS=e=>{switch(e.toLowerCase()){case"undo":case"redo":case"mcefocus":return!0;default:return!1}},ZS=e=>{const t=ai(),o=Qa(0),n=Qa(0),r={data:[],typing:!1,beforeChange:()=>{((e,t,o)=>{yC(e).undoManager.beforeChange(t,o)})(e,o,t)},add:(s,a)=>((e,t,o,n,r,s,a)=>yC(e).undoManager.add(t,o,n,r,s,a))(e,r,n,o,t,s,a),dispatchChange:()=>{e.setDirty(!0);const t=iC(e);t.bookmark=El(e.selection),e.dispatch("change",{level:t,lastLevel:ce(r.data,n.get()).getOrUndefined()})},undo:()=>((e,t,o,n)=>yC(e).undoManager.undo(t,o,n))(e,r,o,n),redo:()=>((e,t,o)=>yC(e).undoManager.redo(t,o))(e,n,r.data),clear:()=>{((e,t,o)=>{yC(e).undoManager.clear(t,o)})(e,r,n)},reset:()=>{((e,t)=>{yC(e).undoManager.reset(t)})(e,r)},hasUndo:()=>((e,t,o)=>yC(e).undoManager.hasUndo(t,o))(e,r,n),hasRedo:()=>((e,t,o)=>yC(e).undoManager.hasRedo(t,o))(e,r,n),transact:t=>((e,t,o,n)=>yC(e).undoManager.transact(t,o,n))(e,r,o,t),ignore:t=>{((e,t,o)=>{yC(e).undoManager.ignore(t,o)})(e,o,t)},extra:(t,o)=>{((e,t,o,n,r)=>{yC(e).undoManager.extra(t,o,n,r)})(e,r,n,t,o)}};return fC(e)||((e,t,o)=>{const n=Qa(!1),r=e=>{gC(t,!1,o),t.add({},e)};e.on("init",(()=>{t.add()})),e.on("BeforeExecCommand",(e=>{const n=e.command;VS(n)||(hC(t,o),t.beforeChange())})),e.on("ExecCommand",(e=>{const t=e.command;VS(t)||r(e)})),e.on("ObjectResizeStart cut",(()=>{t.beforeChange()})),e.on("SaveContent ObjectResized blur",r),e.on("dragend",r),e.on("keyup",(o=>{const s=o.keyCode;if(o.isDefaultPrevented())return;const a=At.os.isMacOS()&&"Meta"===o.key;(s>=33&&s<=36||s>=37&&s<=40||45===s||o.ctrlKey||a)&&(r(),e.nodeChanged()),46!==s&&8!==s||e.nodeChanged(),n.get()&&t.typing&&!mC(iC(e),t.data[0])&&(e.isDirty()||e.setDirty(!0),e.dispatch("TypingUndo"),n.set(!1),e.nodeChanged())})),e.on("keydown",(e=>{const s=e.keyCode;if(e.isDefaultPrevented())return;if(s>=33&&s<=36||s>=37&&s<=40||45===s)return void(t.typing&&r(e));const a=e.ctrlKey&&!e.altKey||e.metaKey;if((s<16||s>20)&&224!==s&&91!==s&&!t.typing&&!a)return t.beforeChange(),gC(t,!0,o),t.add({},e),void n.set(!0);(At.os.isMacOS()?e.metaKey:e.ctrlKey&&!e.altKey)&&t.beforeChange()})),e.on("mousedown",(e=>{t.typing&&r(e)})),e.on("input",(e=>{var t;e.inputType&&("insertReplacementText"===e.inputType||"insertText"===(t=e).inputType&&null===t.data||(e=>"insertFromPaste"===e.inputType||"insertFromDrop"===e.inputType)(e))&&r(e)})),e.on("AddUndo Undo Redo ClearUndos",(t=>{t.isDefaultPrevented()||e.nodeChanged()}))})(e,r,o),(e=>{e.addShortcut("meta+z","","Undo"),e.addShortcut("meta+y,meta+shift+z","","Redo")})(e),r},US=[9,27,Dg.HOME,Dg.END,19,20,44,144,145,33,34,45,16,17,18,91,92,93,Dg.DOWN,Dg.UP,Dg.LEFT,Dg.RIGHT].concat(At.browser.isFirefox()?[224]:[]),jS="data-mce-placeholder",WS=e=>"keydown"===e.type||"keyup"===e.type,$S=e=>{const t=e.keyCode;return t===Dg.BACKSPACE||t===Dg.DELETE},qS=e=>{var t;const o=e.dom,n=Xl(e),r=null!==(t=Ec(e))&&void 0!==t?t:"",s=(t,a)=>{if((e=>{if(WS(e)){const t=e.keyCode;return!$S(e)&&(Dg.metaKeyPressed(e)||e.altKey||t>=112&&t<=123||j(US,t))}return!1})(t))return;const i=e.getBody(),l=!(e=>WS(e)&&!($S(e)||"keyup"===e.type&&229===e.keyCode))(t)&&((e,t,o)=>{if(ys(yo.fromDom(t),!1)){const n=t.firstElementChild;return!n||!e.getStyle(t.firstElementChild,"padding-left")&&!e.getStyle(t.firstElementChild,"padding-right")&&o===n.nodeName.toLowerCase()}return!1})(o,i,n);(""!==o.getAttrib(i,jS)!==l||a)&&(o.setAttrib(i,jS,l?r:null),o.setAttrib(i,"aria-placeholder",l?r:null),((e,t)=>{e.dispatch("PlaceholderToggle",{state:t})})(e,l),e.on(l?"keydown":"keyup",s),e.off(l?"keyup":"keydown",s))};Ye(r)&&e.on("init",(t=>{s(t,!0),e.on("change SetContent ExecCommand",s),e.on("paste",(t=>qh.setEditorTimeout(e,(()=>s(t)))))}))},GS=(e,t)=>({from:e,to:t}),KS=(e,t)=>{const o=yo.fromDom(e),n=yo.fromDom(t.container());return vv(o,n).map((e=>((e,t)=>({block:e,position:t}))(e,t)))},YS=(e,t)=>Xo(t,(e=>Dr(e)||cr(e.dom)),(t=>So(t,e))).filter(Gt).getOr(e),XS=(e,t,o)=>{const n=KS(e,rl.fromRangeStart(o)),r=n.bind((o=>Zm(t,e,o.position).bind((o=>KS(e,o).map((o=>((e,t,o)=>ir(o.position.getNode())&&!ys(o.block)?Wm(!1,o.block.dom).bind((n=>n.isEqual(o.position)?Zm(t,e,n).bind((t=>KS(e,t))):F.some(o))).getOr(o):o)(e,t,o)))))));return It(n,r,GS).filter((t=>(e=>!So(e.from.block,e.to.block))(t)&&((e,t)=>{const o=yo.fromDom(e);return So(YS(o,t.from.block),YS(o,t.to.block))})(e,t)&&(e=>!1===dr(e.from.block.dom)&&!1===dr(e.to.block.dom))(t)&&(e=>{const t=e=>_r(e)||Ns(e.dom);return t(e.from.block)&&t(e.to.block)})(t)))},JS=(e,t)=>{const o=((e,t)=>{const o=Lo(e);return te(o,(e=>t.isBlock(jt(e)))).fold(D(o),(e=>o.slice(0,e)))})(e,t);return q(o,Cn),o},QS=(e,t)=>{const o=pf(t,e);return ee(o.reverse(),(e=>ys(e))).each(Cn)},ek=(e,t,o,n,r)=>{if(ys(o))return Rr(o),Gm(o.dom);0===Y(Ro(r),(e=>!ys(e))).length&&ys(t)&&pn(r,yo.fromTag("br"));const s=qm(o.dom,rl.before(r.dom));return q(JS(t,n),(e=>{pn(r,e)})),QS(e,t),s},tk=(e,t,o,n)=>{if(ys(o)){if(ys(t)){const e=e=>{const t=(e,o)=>Io(e).fold((()=>o),(e=>((e,t)=>e.isInline(jt(t)))(n,e)?t(e,o.concat(ki(e))):o));return t(e,[])},r=X(e(o),((e,t)=>(yn(e,t),t)),Nr());xn(t),bn(t,r)}return Cn(o),Gm(t.dom)}const r=Km(o.dom);return q(JS(t,n),(e=>{bn(o,e)})),QS(e,t),r},ok=(e,t)=>ko(t,e)?((e,t)=>{const o=pf(t,e);return F.from(o[o.length-1])})(t,e):F.none(),nk=(e,t)=>{Wm(e,t.dom).bind((e=>F.from(e.getNode()))).map(yo.fromDom).filter(kr).each(Cn)},rk=(e,t,o,n)=>(nk(!0,t),nk(!1,o),ok(t,o).fold(N(tk,e,t,o,n),N(ek,e,t,o,n))),sk=(e,t,o,n,r)=>t?rk(e,n,o,r):rk(e,o,n,r),ak=(e,t)=>{const o=yo.fromDom(e.getBody()),n=((e,t,o)=>o.collapsed?XS(e,t,o):F.none())(o.dom,t,e.selection.getRng()).map((n=>()=>{sk(o,t,n.from.block,n.to.block,e.schema).each((t=>{e.selection.setRng(t.toRange())}))}));return n},ik=(e,t)=>{const o=yo.fromDom(t),n=N(So,e);return Yo(o,Dr,n).isSome()},lk=(e,t)=>{const o=qm(e.dom,rl.fromRangeStart(t)).isNone(),n=$m(e.dom,rl.fromRangeEnd(t)).isNone();return!((e,t)=>ik(e,t.startContainer)||ik(e,t.endContainer))(e,t)&&o&&n},ck=e=>{const t=yo.fromDom(e.getBody()),o=e.selection.getRng();return lk(t,o)?(e=>F.some((()=>{e.setContent(""),e.selection.setCursorLocation()})))(e):((e,t,o)=>{const n=t.getRng();return It(vv(e,yo.fromDom(n.startContainer)),vv(e,yo.fromDom(n.endContainer)),((r,s)=>So(r,s)?F.none():F.some((()=>{n.deleteContents(),sk(e,!0,r,s,o).each((e=>{t.setRng(e.toRange())}))})))).getOr(F.none())})(t,e.selection,e.schema)},dk=(e,t)=>e.selection.isCollapsed()?F.none():ck(e),mk=(e,t,o,n,r)=>F.from(t._selectionOverrides.showCaret(e,o,n,r)),uk=(e,t)=>e.dispatch("BeforeObjectSelected",{target:t}).isDefaultPrevented()?F.none():F.some((e=>{const t=e.ownerDocument.createRange();return t.selectNode(e),t})(t)),gk=(e,t,o)=>t.collapsed?((e,t,o)=>{const n=wm(1,e.getBody(),t),r=rl.fromRangeStart(n),s=r.getNode();if(Xd(s))return mk(1,e,s,!r.isAtEnd(),!1);const a=r.getNode(!0);if(Xd(a))return mk(1,e,a,!1,!1);const i=tb(e.dom.getRoot(),r.getNode());return Xd(i)?mk(1,e,i,!1,o):F.none()})(e,t,o).getOr(t):t,hk=e=>uf(e)||lf(e),pk=e=>gf(e)||cf(e),fk=(e,t,o,n,r,s)=>{mk(n,e,s.getNode(!r),r,!0).each((o=>{if(t.collapsed){const e=t.cloneRange();r?e.setEnd(o.startContainer,o.startOffset):e.setStart(o.endContainer,o.endOffset),e.deleteContents()}else t.deleteContents();e.selection.setRng(o)})),((e,t)=>{tr(t)&&0===t.data.length&&e.remove(t)})(e.dom,o)},vk=(e,t)=>((e,t)=>{const o=e.selection.getRng();if(!tr(o.commonAncestorContainer))return F.none();const n=t?Em.Forwards:Em.Backwards,r=Im(e.getBody()),s=N(km,t?r.next:r.prev),a=t?hk:pk,i=Cm(n,e.getBody(),o),l=s(i),c=l?mv(t,l):l;if(!c||!_m(i,c))return F.none();if(a(c))return F.some((()=>fk(e,o,i.getNode(),n,t,c)));const d=s(c);return d&&a(d)&&_m(c,d)?F.some((()=>fk(e,o,i.getNode(),n,t,d))):F.none()})(e,t),bk=(e,t)=>{const o=e.getBody();return t?Gm(o).filter(uf):Km(o).filter(gf)},yk=e=>{const t=e.selection.getRng();return!t.collapsed&&(bk(e,!0).exists((e=>e.isEqual(rl.fromRangeStart(t))))||bk(e,!1).exists((e=>e.isEqual(rl.fromRangeEnd(t)))))},wk=Al([{remove:["element"]},{moveToElement:["element"]},{moveToPosition:["position"]}]),xk=(e,t,o,n)=>{const r=n.getNode(!t);return vv(yo.fromDom(e),yo.fromDom(o.getNode())).map((e=>ys(e)?wk.remove(e.dom):wk.moveToElement(r))).orThunk((()=>F.some(wk.moveToElement(r))))},Ck=(e,t,o,n)=>Zm(t,e,o).bind((r=>{return s=r.getNode(),C(s)&&(Dr(yo.fromDom(s))||Tr(yo.fromDom(s)))||((e,t,o,n,r)=>{const s=t=>r.isInline(t.nodeName.toLowerCase())&&!gm(o,n,e);return xm(!t,o).fold((()=>xm(t,n).fold(I,s)),s)})(e,t,o,r,n)?F.none():t&&dr(r.getNode())||!t&&dr(r.getNode(!0))?xk(e,t,o,r):t&&gf(o)||!t&&uf(o)?F.some(wk.moveToPosition(r)):F.none();var s})),Sk=(e,t,o,n)=>((e,t)=>{const o=t.getNode(!e),n=e?"after":"before";return Wn(o)&&o.getAttribute("data-mce-caret")===n})(t,o)?((e,t)=>x(t)?F.none():e&&dr(t.nextSibling)?F.some(wk.moveToElement(t.nextSibling)):!e&&dr(t.previousSibling)?F.some(wk.moveToElement(t.previousSibling)):F.none())(t,o.getNode(!t)).orThunk((()=>Ck(e,t,o,n))):Ck(e,t,o,n).bind((t=>((e,t,o)=>o.fold((e=>F.some(wk.remove(e))),(e=>F.some(wk.moveToElement(e))),(o=>gm(t,o,e)?F.none():F.some(wk.moveToPosition(o)))))(e,o,t))),kk=(e,t)=>F.from(tb(e.getBody(),t)),_k=(e,t)=>{const o=e.selection.getNode();return kk(e,o).filter(dr).fold((()=>((e,t,o,n)=>{const r=wm(t?1:-1,e,o),s=rl.fromRangeStart(r),a=yo.fromDom(e);return!t&&gf(s)?F.some(wk.remove(s.getNode(!0))):t&&uf(s)?F.some(wk.remove(s.getNode())):!t&&uf(s)&&Tf(a,s,n)?Of(a,s,n).map((e=>wk.remove(e.getNode()))):t&&gf(s)&&Ef(a,s,n)?Df(a,s,n).map((e=>wk.remove(e.getNode()))):Sk(e,t,s,n)})(e.getBody(),t,e.selection.getRng(),e.schema).map((o=>()=>o.fold(((e,t)=>o=>(e._selectionOverrides.hideFakeCaret(),av(e,t,yo.fromDom(o)),!0))(e,t),((e,t)=>o=>{const n=t?rl.before(o):rl.after(o);return e.selection.setRng(n.toRange()),!0})(e,t),(e=>t=>(e.selection.setRng(t.toRange()),!0))(e))))),(()=>F.some(E)))},Ek=(e,t)=>{const o=e.selection.getNode();return dr(o)&&!mr(o)?kk(e,o.parentNode).filter(dr).fold((()=>F.some((()=>{var o;o=yo.fromDom(e.getBody()),q(zn(o,".mce-offscreen-selection"),Cn),av(e,t,yo.fromDom(e.selection.getNode())),bv(e)}))),(()=>F.some(E))):yk(e)?F.some((()=>{xv(e,e.selection.getRng(),yo.fromDom(e.getBody()))})):F.none()},Tk=e=>{const t=e.dom,o=e.selection,n=tb(e.getBody(),o.getNode());if(cr(n)&&t.isBlock(n)&&t.isEmpty(n)){const e=t.create("br",{"data-mce-bogus":"1"});t.setHTML(n,""),n.appendChild(e),o.setRng(rl.before(e).toRange())}return!0},Ok=(e,t)=>e.selection.isCollapsed()?_k(e,t):Ek(e,t),Dk=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const o=rl.fromRangeStart(e.selection.getRng());return Zm(t,e.getBody(),o).filter((e=>t?sf(e):af(e))).bind((e=>hm(t?0:-1,e))).map((t=>()=>e.selection.select(t)))})(e,t):F.none(),Ak=tr,Mk=e=>Ak(e)&&e.data[0]===Br,Nk=e=>Ak(e)&&e.data[e.data.length-1]===Br,Rk=e=>{var t;return(null!==(t=e.ownerDocument)&&void 0!==t?t:document).createTextNode(Br)},Bk=(e,t)=>e?(e=>{var t;if(Ak(e.previousSibling))return Nk(e.previousSibling)||e.previousSibling.appendData(Br),e.previousSibling;if(Ak(e))return Mk(e)||e.insertData(0,Br),e;{const o=Rk(e);return null===(t=e.parentNode)||void 0===t||t.insertBefore(o,e),o}})(t):(e=>{var t,o;if(Ak(e.nextSibling))return Mk(e.nextSibling)||e.nextSibling.insertData(0,Br),e.nextSibling;if(Ak(e))return Nk(e)||e.appendData(Br),e;{const n=Rk(e);return e.nextSibling?null===(t=e.parentNode)||void 0===t||t.insertBefore(n,e.nextSibling):null===(o=e.parentNode)||void 0===o||o.appendChild(n),n}})(t),Lk=N(Bk,!0),Hk=N(Bk,!1),Ik=(e,t)=>tr(e.container())?Bk(t,e.container()):Bk(t,e.getNode()),Pk=(e,t)=>{const o=t.get();return o&&e.container()===o&&zr(o)},Fk=(e,t)=>t.fold((t=>{jd(e.get());const o=Lk(t);return e.set(o),F.some(rl(o,o.length-1))}),(t=>Gm(t).map((t=>{if(Pk(t,e)){const t=e.get();return rl(t,1)}{jd(e.get());const o=Ik(t,!0);return e.set(o),rl(o,1)}}))),(t=>Km(t).map((t=>{if(Pk(t,e)){const t=e.get();return rl(t,t.length-1)}{jd(e.get());const o=Ik(t,!1);return e.set(o),rl(o,o.length-1)}}))),(t=>{jd(e.get());const o=Hk(t);return e.set(o),F.some(rl(o,1))})),zk=(e,t)=>{for(let o=0;o{const o=um(t,e);return o||e},Uk=(e,t,o)=>{const n=uv(o),r=Zk(t,n.container());return dv(e,r,n).fold((()=>$m(r,n).bind(N(dv,e,r)).map((e=>Vk.before(e)))),F.none)},jk=(e,t)=>null===Jm(e,t),Wk=(e,t,o)=>dv(e,t,o).filter(N(jk,t)),$k=(e,t,o)=>{const n=gv(o);return Wk(e,t,n).bind((e=>qm(e,n).isNone()?F.some(Vk.start(e)):F.none()))},qk=(e,t,o)=>{const n=uv(o);return Wk(e,t,n).bind((e=>$m(e,n).isNone()?F.some(Vk.end(e)):F.none()))},Gk=(e,t,o)=>{const n=gv(o),r=Zk(t,n.container());return dv(e,r,n).fold((()=>qm(r,n).bind(N(dv,e,r)).map((e=>Vk.after(e)))),F.none)},Kk=e=>!cv(Xk(e)),Yk=(e,t,o)=>zk([Uk,$k,qk,Gk],[e,t,o]).filter(Kk),Xk=e=>e.fold(A,A,A,A),Jk=e=>e.fold(D("before"),D("start"),D("end"),D("after")),Qk=e=>e.fold(Vk.before,Vk.before,Vk.after,Vk.after),e_=e=>e.fold(Vk.start,Vk.start,Vk.end,Vk.end),t_=(e,t,o,n,r,s)=>It(dv(t,o,n),dv(t,o,r),((t,n)=>t!==n&&((e,t,o)=>{const n=um(t,e),r=um(o,e);return C(n)&&n===r})(o,t,n)?Vk.after(e?t:n):s)).getOr(s),o_=(e,t)=>e.fold(P,(e=>{return n=t,!(Jk(o=e)===Jk(n)&&Xk(o)===Xk(n));var o,n})),n_=(e,t)=>e?t.fold(T(F.some,Vk.start),F.none,T(F.some,Vk.after),F.none):t.fold(F.none,T(F.some,Vk.before),F.none,T(F.some,Vk.end)),r_=(e,t,o,n)=>{const r=mv(e,n),s=Yk(t,o,r);return Yk(t,o,r).bind(N(n_,e)).orThunk((()=>((e,t,o,n,r)=>{const s=mv(e,r);return Zm(e,o,s).map(N(mv,e)).fold((()=>n.map(Qk)),(r=>Yk(t,o,r).map(N(t_,e,t,o,s,r)).filter(N(o_,n)))).filter(Kk)})(e,t,o,s,n)))},s_=(e,t,o)=>{const n=e?1:-1;return t.setRng(rl(o.container(),o.offset()+n).toRange()),t.getSel().modify("move",e?"forward":"backward","word"),!0},a_=(e,t)=>{const o=t.selection.getRng(),n=e?rl.fromRangeEnd(o):rl.fromRangeStart(o);return!!(e=>S(e.selection.getSel().modify))(t)&&(e&&Ur(n)?s_(!0,t.selection,n):!(e||!jr(n))&&s_(!1,t.selection,n))};var i_;!function(e){e[e.Br=0]="Br",e[e.Block=1]="Block",e[e.Wrap=2]="Wrap",e[e.Eol=3]="Eol"}(i_||(i_={}));const l_=(e,t)=>e===Em.Backwards?se(t):t,c_=(e,t,o)=>e===Em.Forwards?t.next(o):t.prev(o),d_=(e,t,o,n)=>ir(n.getNode(t===Em.Forwards))?i_.Br:!1===gm(o,n)?i_.Block:i_.Wrap,m_=(e,t,o,n)=>{const r=Im(o);let s=n;const a=[];for(;s;){const o=c_(t,r,s);if(!o)break;if(ir(o.getNode(!1)))return t===Em.Forwards?{positions:l_(t,a).concat([o]),breakType:i_.Br,breakAt:F.some(o)}:{positions:l_(t,a),breakType:i_.Br,breakAt:F.some(o)};if(o.isVisible()){if(e(s,o)){const e=d_(0,t,s,o);return{positions:l_(t,a),breakType:e,breakAt:F.some(o)}}a.push(o),s=o}else s=o}return{positions:l_(t,a),breakType:i_.Eol,breakAt:F.none()}},u_=(e,t,o,n)=>t(o,n).breakAt.map((n=>{const r=t(o,n).positions;return e===Em.Backwards?r.concat(n):[n].concat(r)})).getOr([]),g_=(e,t)=>J(e,((e,o)=>e.fold((()=>F.some(o)),(n=>It(de(n.getClientRects()),de(o.getClientRects()),((e,r)=>{const s=Math.abs(t-e.left);return Math.abs(t-r.left)<=s?o:n})).or(e)))),F.none()),h_=(e,t)=>de(t.getClientRects()).bind((t=>g_(e,t.left))),p_=N(m_,rl.isAbove,-1),f_=N(m_,rl.isBelow,1),v_=N(u_,-1,p_),b_=N(u_,1,f_),y_=(e,t)=>p_(e,t).breakAt.isNone(),w_=(e,t)=>f_(e,t).breakAt.isNone(),x_=(e,t)=>h_(v_(e,t),t),C_=(e,t)=>h_(b_(e,t),t),S_=dr,k_=(e,t)=>Math.abs(e.left-t),__=(e,t)=>Math.abs(e.right-t),E_=(e,t)=>Re(e,((e,o)=>{const n=Math.min(k_(e,t),__(e,t)),r=Math.min(k_(o,t),__(o,t));return r===n&&Ee(o,"node")&&S_(o.node)||r{const t=t=>$(t,(t=>{const o=Ai(t);return o.node=e,o}));if(Wn(e))return t(e.getClientRects());if(tr(e)){const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(e,e.data.length),t(o.getClientRects())}return[]},O_=e=>ne(e,T_);var D_;!function(e){e[e.Up=-1]="Up",e[e.Down=1]="Down"}(D_||(D_={}));const A_=(e,t,o,n,r,s)=>{let a=0;const i=[],l=n=>{let s=O_([n]);-1===e&&(s=s.reverse());for(let e=0;e0&&t(n,Le(i))&&a++,n.line=a,r(n))return!0;i.push(n)}}return!1},c=Le(s.getClientRects());if(!c)return i;const d=s.getNode();return d&&(l(d),((e,t,o,n)=>{let r=n;for(;r=mm(r,e,ss,t);)if(o(r))return})(e,n,l,d)),i},M_=N(A_,D_.Up,Ri,Bi),N_=N(A_,D_.Down,Bi,Ri),R_=e=>Le(e.getClientRects()),B_=e=>t=>((e,t)=>t.line>e)(e,t),L_=e=>t=>((e,t)=>t.line===e)(e,t),H_=(e,t)=>{e.selection.setRng(t),Rh(e,e.selection.getRng())},I_=(e,t,o)=>F.some(gk(e,t,o)),P_=(e,t,o,n,r,s)=>{const a=t===Em.Forwards,i=Im(e.getBody()),l=N(km,a?i.next:i.prev),c=a?n:r;if(!o.collapsed){const n=Hi(o);if(s(n))return mk(t,e,n,t===Em.Backwards,!1);if(yk(e)){const e=o.cloneRange();return e.collapse(t===Em.Backwards),F.from(e)}}const d=Cm(t,e.getBody(),o);if(c(d))return uk(e,d.getNode(!a));let m=l(d);const u=Gr(o);if(!m)return u?F.some(o):F.none();if(m=mv(a,m),c(m))return mk(t,e,m.getNode(!a),a,!1);const g=l(m);return g&&c(g)&&_m(m,g)?mk(t,e,g.getNode(!a),a,!1):u?I_(e,m.toRange(),!1):F.none()},F_=(e,t,o,n,r,s)=>{const a=Cm(t,e.getBody(),o),i=Le(a.getClientRects()),l=t===D_.Down,c=e.getBody();if(!i)return F.none();if(yk(e)){const e=l?rl.fromRangeEnd(o):rl.fromRangeStart(o);return(l?C_:x_)(c,e).orThunk((()=>F.from(e))).map((e=>e.toRange()))}const d=(l?N_:M_)(c,B_(1),a),m=Y(d,L_(1)),u=i.left,g=E_(m,u);if(g&&s(g.node)){const o=Math.abs(u-g.left),n=Math.abs(u-g.right);return mk(t,e,g.node,o{const r=Im(t);let s,a,i,l;const c=[];let d=0;1===e?(s=r.next,a=Bi,i=Ri,l=rl.after(n)):(s=r.prev,a=Ri,i=Bi,l=rl.before(n));const m=R_(l);do{if(!l.isVisible())continue;const e=R_(l);if(i(e,m))continue;c.length>0&&a(e,Le(c))&&d++;const t=Ai(e);if(t.position=l,t.line=d,o(t))return c;c.push(t)}while(l=s(l));return c})(t,c,B_(1),h);let n=E_(Y(o,L_(1)),u);if(n)return I_(e,n.position.toRange(),!1);if(n=Le(Y(o,L_(0))),n)return I_(e,n.position.toRange(),!1)}return 0===m.length?z_(e,l).filter(l?r:n).map((t=>gk(e,t.toRange(),!1))):F.none()},z_=(e,t)=>{const o=e.selection.getRng(),n=t?rl.fromRangeEnd(o):rl.fromRangeStart(o),r=(s=n.container(),a=e.getBody(),Yo(yo.fromDom(s),(e=>Qd(e.dom)),(e=>e.dom===a)).map((e=>e.dom)).getOr(a));var s,a;if(t){const e=f_(r,n);return me(e.positions)}{const e=p_(r,n);return de(e.positions)}},V_=(e,t,o)=>z_(e,t).filter(o).exists((t=>(e.selection.setRng(t.toRange()),!0))),Z_=(e,t)=>{const o=e.dom.createRng();o.setStart(t.container(),t.offset()),o.setEnd(t.container(),t.offset()),e.selection.setRng(o)},U_=(e,t)=>{e?t.setAttribute("data-mce-selected","inline-boundary"):t.removeAttribute("data-mce-selected")},j_=(e,t,o)=>Fk(t,o).map((t=>(Z_(e,t),o))),W_=(e,t,o)=>{const n=e.getBody(),r=((e,t,o)=>{const n=rl.fromRangeStart(e);if(e.collapsed)return n;{const r=rl.fromRangeEnd(e);return o?qm(t,r).getOr(r):$m(t,n).getOr(n)}})(e.selection.getRng(),n,o),s=N(lv,e);return r_(o,s,n,r).bind((o=>j_(e,t,o)))},$_=(e,t)=>{const o=t.get();if(e.selection.isCollapsed()&&!e.composing&&o){const n=rl.fromRangeStart(e.selection.getRng());rl.isTextPosition(n)&&!(e=>Ur(e)||jr(e))(n)&&(Z_(e,Ud(o,n)),t.set(null))}},q_=(e,t,o)=>!!Rc(e)&&W_(e,t,o).isSome(),G_=(e,t,o)=>!!Rc(t)&&a_(e,t),K_=e=>{const t=Qa(null),o=N(lv,e);return e.on("NodeChange",(n=>{Rc(e)&&(((e,t,o)=>{const n=$(zn(yo.fromDom(t.getRoot()),'*[data-mce-selected="inline-boundary"]'),(e=>e.dom)),r=Y(n,e),s=Y(o,e);q(ae(r,s),N(U_,!1)),q(ae(s,r),N(U_,!0))})(o,e.dom,n.parents),$_(e,t),((e,t,o,n)=>{if(t.selection.isCollapsed()){const r=Y(n,e);q(r,(n=>{const r=rl.fromRangeStart(t.selection.getRng());Yk(e,t.getBody(),r).bind((e=>j_(t,o,e)))}))}})(o,e,t,n.parents))})),t},Y_=N(G_,!0),X_=N(G_,!1),J_=(e,t,o)=>{if(Rc(e)){const n=z_(e,t).getOrThunk((()=>{const o=e.selection.getRng();return t?rl.fromRangeEnd(o):rl.fromRangeStart(o)}));return Yk(N(lv,e),e.getBody(),n).exists((t=>{const n=Qk(t);return Fk(o,n).exists((t=>(Z_(e,t),!0)))}))}return!1},Q_=(e,t)=>o=>Fk(t,o).map((t=>()=>Z_(e,t))),eE=(e,t,o,n)=>{const r=e.getBody(),s=N(lv,e);e.undoManager.ignore((()=>{e.selection.setRng(((e,t)=>{const o=document.createRange();return o.setStart(e.container(),e.offset()),o.setEnd(t.container(),t.offset()),o})(o,n)),pv(e),Yk(s,r,rl.fromRangeStart(e.selection.getRng())).map(e_).bind(Q_(e,t)).each(H)})),e.nodeChanged()},tE=(e,t,o,n)=>{const r=((e,t)=>{const o=um(t,e);return o||e})(e.getBody(),n.container()),s=N(lv,e),a=Yk(s,r,n);return a.bind((e=>o?e.fold(D(F.some(e_(e))),F.none,D(F.some(Qk(e))),F.none):e.fold(F.none,D(F.some(Qk(e))),F.none,D(F.some(e_(e)))))).map(Q_(e,t)).getOrThunk((()=>{const i=Um(o,r,n),l=i.bind((e=>Yk(s,r,e)));return It(a,l,(()=>dv(s,r,n).bind((t=>(e=>It(Gm(e),Km(e),((t,o)=>{const n=mv(!0,t),r=mv(!1,o);return $m(e,n).forall((e=>e.isEqual(r)))})).getOr(!0))(t)?F.some((()=>{av(e,o,yo.fromDom(t))})):F.none())))).getOrThunk((()=>l.bind((()=>i.map((r=>()=>{o?eE(e,t,n,r):eE(e,t,r,n)}))))))}))},oE=(e,t,o)=>{if(e.selection.isCollapsed()&&Rc(e)){const n=rl.fromRangeStart(e.selection.getRng());return tE(e,t,o,n)}return F.none()},nE=(e,t)=>{const o=yo.fromDom(e.getBody()),n=yo.fromDom(e.selection.getStart()),r=pf(n,o);return te(r,t).fold(D(r),(e=>r.slice(0,e)))},rE=e=>1===Fo(e),sE=e=>nE(e,(t=>e.schema.isBlock(jt(t))||(e=>Fo(e)>1)(t))),aE=(e,t)=>{const o=N(ny,e);return ne(t,(e=>o(e)?[e.dom]:[]))},iE=e=>{const t=(e=>nE(e,(t=>e.schema.isBlock(jt(t)))))(e);return aE(e,t)},lE=(e,t)=>{const o=Y(sE(e),rE);return me(o).bind((n=>{const r=rl.fromRangeStart(e.selection.getRng());return yv(t,r,n.dom)&&!Yu(n)?F.some((()=>((e,t,o,n)=>{const r=aE(t,n);if(0===r.length)av(t,e,o);else{const e=oy(o.dom,r);t.selection.setRng(e.toRange())}})(t,e,n,o))):F.none()}))},cE=(e,t)=>{const o=e.selection.getStart(),n=((e,t)=>{const o=t.parentElement;return ir(t)&&!b(o)&&e.dom.isEmpty(o)})(e,o)||(r=o,Yu(yo.fromDom(r)))?oy(o,t):((e,t)=>{const{caretContainer:o,caretPosition:n}=ty(t);return e.insertNode(o.dom),n})(e.selection.getRng(),t);var r;e.selection.setRng(n.toRange())},dE=e=>tr(e.startContainer),mE=e=>(e=>{const t=e.startContainer.parentNode,o=e.endContainer.parentNode;return!b(t)&&!b(o)&&t.isEqualNode(o)})(e)&&(e=>{const t=e.endContainer;return e.endOffset===(tr(t)?t.length:t.childNodes.length)})(e),uE=e=>{const t=e.selection.getRng();return(e=>0===e.startOffset&&dE(e))(t)&&((e,t)=>{const o=t.startContainer.parentElement;return!b(o)&&ny(e,yo.fromDom(o))})(e,t)&&(e=>mE(e)||(e=>!e.endContainer.isEqualNode(e.commonAncestorContainer))(e))(t)},gE=e=>{if(uE(e)){const t=iE(e);return F.some((()=>{pv(e),((e,t)=>{const o=ae(t,iE(e));o.length>0&&cE(e,o)})(e,t)}))}return F.none()},hE=(e,t)=>e.selection.isCollapsed()?lE(e,t):gE(e),pE=(e,t)=>((e,t,o)=>Yo(e,t,o).isSome())(e,(e=>Xm(e.dom)),(e=>t.isBlock(jt(e)))),fE=e=>{const t=e.selection.getRng();return t.collapsed&&(dE(t)||e.dom.isEmpty(t.startContainer))&&!(e=>pE(yo.fromDom(e.selection.getStart()),e.schema))(e)},vE=e=>(fE(e)&&cE(e,[]),!0),bE=(e,t,o)=>C(o)?F.some((()=>{e._selectionOverrides.hideFakeCaret(),av(e,t,yo.fromDom(o))})):F.none(),yE=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const o=t?lf:cf,n=t?Em.Forwards:Em.Backwards,r=Cm(n,e.getBody(),e.selection.getRng());return o(r)?bE(e,t,r.getNode(!t)):F.from(mv(t,r)).filter((e=>o(e)&&_m(r,e))).bind((o=>bE(e,t,o.getNode(!t))))})(e,t):((e,t)=>{const o=e.selection.getNode();return gr(o)?bE(e,t,o):F.none()})(e,t),wE=e=>Je(null!=e?e:"").getOr(0),xE=(e,t)=>(e||"table"===jt(t)?"margin":"padding")+("rtl"===dn(t,"direction")?"-right":"-left"),CE=e=>{const t=kE(e);return!e.mode.isReadOnly()&&(t.length>1||((e,t)=>re(t,(t=>{const o=xE(vc(e),t),n=un(t,o).map(wE).getOr(0);return"false"!==e.dom.getContentEditable(t.dom)&&n>0})))(e,t))},SE=e=>Er(e)||Tr(e),kE=e=>Y(kn(e.selection.getSelectedBlocks()),(e=>!SE(e)&&!(e=>Oo(e).exists(SE))(e)&&Xo(e,(e=>cr(e.dom)||dr(e.dom))).exists((e=>cr(e.dom))))),_E=(e,t)=>{var o,n;const{dom:r}=e,s=bc(e),a=null!==(n=null===(o=/[a-z%]+$/i.exec(s))||void 0===o?void 0:o[0])&&void 0!==n?n:"px",i=wE(s),l=vc(e);q(kE(e),(e=>{((e,t,o,n,r,s)=>{const a=xE(o,yo.fromDom(s)),i=wE(e.getStyle(s,a));if("outdent"===t){const t=Math.max(0,i-n);e.setStyle(s,a,t?t+r:"")}else{const t=i+n+r;e.setStyle(s,a,t)}})(r,t,l,i,a,e.dom)}))},EE=e=>_E(e,"outdent"),TE=e=>{if(e.selection.isCollapsed()&&CE(e)){const t=e.dom,o=e.selection.getRng(),n=rl.fromRangeStart(o),r=t.getParent(o.startContainer,t.isBlock);if(null!==r&&wf(yo.fromDom(r),n,e.schema))return F.some((()=>EE(e)))}return F.none()},OE=(e,t,o)=>ge([TE,Ok,vk,(e,o)=>oE(e,t,o),ak,eb,Dk,yE,dk,hE],(t=>t(e,o))).filter((t=>e.selection.isEditable())),DE=(e,t)=>{OE(e,t,!0).fold((()=>{e.selection.isEditable()&&(e=>{hv(e,"ForwardDelete")})(e)}),H)},AE=(e,t)=>{e.addCommand("delete",(()=>{((e,t)=>{OE(e,t,!1).fold((()=>{e.selection.isEditable()&&(pv(e),bv(e))}),H)})(e,t)})),e.addCommand("forwardDelete",(()=>{DE(e,t)}))},ME=e=>void 0===e.touches||1!==e.touches.length?F.none():F.some(e.touches[0]),NE=e=>{const t=ai(),o=Qa(!1),n=li((t=>{e.dispatch("longpress",{...t,type:"longpress"}),o.set(!0)}),400);e.on("touchstart",(e=>{ME(e).each((r=>{n.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};n.throttle(e),o.set(!1),t.set(s)}))}),!0),e.on("touchmove",(r=>{n.cancel(),ME(r).each((n=>{t.on((r=>{((e,t)=>{const o=Math.abs(e.clientX-t.x),n=Math.abs(e.clientY-t.y);return o>5||n>5})(n,r)&&(t.clear(),o.set(!1),e.dispatch("longpresscancel"))}))}))}),!0),e.on("touchend touchcancel",(r=>{n.cancel(),"touchcancel"!==r.type&&t.get().filter((e=>e.target.isEqualNode(r.target))).each((()=>{o.get()?r.preventDefault():e.dispatch("tap",{...r,type:"tap"})}))}),!0)},RE=(e,t)=>_e(e,t.nodeName),BE=(e,t)=>!!tr(t)||!!Wn(t)&&!(RE(e.getBlockElements(),t)||mu(t)||Ls(e,t)||xs(t)),LE=(e,t)=>{if(tr(t)){if(0===t.data.length)return!0;if(/^\s+$/.test(t.data))return!t.nextSibling||RE(e,t.nextSibling)||xs(t.nextSibling)}return!1},HE=e=>e.dom.create(Xl(e),Jl(e)),IE=e=>{const t=e.dom,o=e.selection,n=e.schema,r=n.getBlockElements(),s=o.getStart(),a=e.getBody();let i,l,c=!1;const d=Xl(e);if(!s||!Wn(s))return;const m=a.nodeName.toLowerCase();if(!n.isValidChild(m,d.toLowerCase())||((e,t,o)=>W(hf(yo.fromDom(o),yo.fromDom(t)),(t=>RE(e,t.dom))))(r,a,s))return;const u=o.getRng(),{startContainer:g,startOffset:h,endContainer:p,endOffset:f}=u,v=ap(e);let b=a.firstChild;for(;b;)if(Wn(b)&&Ms(n,b),BE(n,b)){if(LE(r,b)){l=b,b=b.nextSibling,t.remove(l);continue}i||(i=HE(e),a.insertBefore(i,b),c=!0),l=b,b=b.nextSibling,i.appendChild(l)}else i=null,b=b.nextSibling;c&&v&&(u.setStart(g,h),u.setEnd(p,f),o.setRng(u),e.nodeChanged())},PE=(e,t,o)=>{const n=yo.fromDom(HE(e)),r=Nr();bn(n,r),o(t,n);const s=document.createRange();return s.setStartBefore(r.dom),s.setEndBefore(r.dom),s},FE=e=>t=>-1!==(" "+t.attr("class")+" ").indexOf(e),zE=(e,t,o)=>function(n){const r=arguments,s=r[r.length-2],a=s>0?t.charAt(s-1):"";if('"'===a)return n;if(">"===a){const e=t.lastIndexOf("<",s);if(-1!==e&&-1!==t.substring(e,s).indexOf('contenteditable="false"'))return n}return''+e.dom.encode("string"==typeof r[1]?r[1]:r[0])+""},VE=e=>{const t="contenteditable",o=" "+Bt.trim(Sd(e))+" ",n=" "+Bt.trim(Cd(e))+" ",r=FE(o),s=FE(n),a=kd(e);a.length>0&&e.on("BeforeSetContent",(t=>{((e,t,o)=>{let n=t.length,r=o.content;if("raw"!==o.format){for(;n--;)r=r.replace(t[n],zE(e,r,Cd(e)));o.content=r}})(e,a,t)})),e.parser.addAttributeFilter("class",(e=>{let o=e.length;for(;o--;){const n=e[o];r(n)?n.attr(t,"true"):s(n)&&n.attr(t,"false")}})),e.serializer.addAttributeFilter(t,(e=>{let o=e.length;for(;o--;){const n=e[o];(r(n)||s(n))&&(a.length>0&&n.attr("data-mce-content")?(n.name="#text",n.type=3,n.raw=!0,n.value=n.attr("data-mce-content")):n.attr(t,null))}}))},ZE=(e,t)=>{t.hasAttribute("data-mce-caret")&&(qr(t),e.selection.setRng(e.selection.getRng()),e.selection.scrollIntoView(t))},UE=(e,t)=>{const o=(e=>tn(yo.fromDom(e.getBody()),"*[data-mce-caret]").map((e=>e.dom)).getOrNull())(e);if(o)return"compositionstart"===t.type?(t.preventDefault(),t.stopPropagation(),void ZE(e,o)):void(Zr(o)&&(ZE(e,o),e.undoManager.add()))},jE=dr,WE=(e,t,o)=>{const n=Im(e.getBody()),r=N(km,1===t?n.next:n.prev);if(o.collapsed){const n=e.dom.getParent(o.startContainer,"PRE");if(!n)return;if(!r(rl.fromRangeStart(o))){const o=yo.fromDom((e=>{const t=e.dom.create(Xl(e));return t.innerHTML='
    ',t})(e));1===t?fn(yo.fromDom(n),o):pn(yo.fromDom(n),o),e.selection.select(o.dom,!0),e.selection.collapse()}}},$E=(e,t)=>{const o=t?Em.Forwards:Em.Backwards,n=e.selection.getRng();return((e,t,o)=>P_(t,e,o,uf,gf,jE))(o,e,n).orThunk((()=>(WE(e,o,n),F.none())))},qE=(e,t)=>{const o=t?1:-1,n=e.selection.getRng();return((e,t,o)=>F_(t,e,o,(e=>uf(e)||df(e)),(e=>gf(e)||mf(e)),jE))(o,e,n).orThunk((()=>(WE(e,o,n),F.none())))},GE=(e,t)=>$E(e,((e,t)=>{const o=t?e.getEnd(!0):e.getStart(!0);return cv(o)?!t:t})(e.selection,t)).exists((t=>(H_(e,t),!0))),KE=(e,t)=>qE(e,t).exists((t=>(H_(e,t),!0))),YE=(e,t)=>V_(e,t,t?gf:uf),XE=(e,t)=>bk(e,!t).map((o=>{const n=o.toRange(),r=e.selection.getRng();return t?n.setStart(r.startContainer,r.startOffset):n.setEnd(r.endContainer,r.endOffset),n})).exists((t=>(H_(e,t),!0))),JE=e=>j(["figcaption"],jt(e)),QE=(e,t)=>{const o=yo.fromDom(e.getBody()),n=rl.fromRangeStart(e.selection.getRng());return((e,t,o)=>{const n=N(So,t);return Xo(yo.fromDom(e.container()),(e=>o.isBlock(jt(e))),n).filter(JE)})(n,o,e.schema).exists((()=>{if(((e,t,o)=>t?w_(e.dom,o):y_(e.dom,o))(o,t,n)){const n=PE(e,o,t?bn:vn);return e.selection.setRng(n),!0}return!1}))},eT=(e,t)=>!!e.selection.isCollapsed()&&QE(e,t),tT=(e,t)=>t?F.from(e.dom.getParent(e.selection.getNode(),"details")).map((t=>((e,t)=>{const o=e.selection.getRng(),n=rl.fromRangeStart(o);return!(e.getBody().lastChild!==t||!w_(t,n)||(e.execCommand("InsertNewBlockAfter"),0))})(e,t))).getOr(!1):F.from(e.dom.getParent(e.selection.getNode(),"summary")).bind((t=>F.from(e.dom.getParent(t,"details")).map((o=>((e,t,o)=>{const n=e.selection.getRng(),r=rl.fromRangeStart(n);return!(e.getBody().firstChild!==t||!y_(o,r)||(e.execCommand("InsertNewBlockBefore"),0))})(e,o,t))))).getOr(!1),oT=(e,t)=>tT(e,t),nT={shiftKey:!1,altKey:!1,ctrlKey:!1,metaKey:!1,keyCode:0},rT=(e,t)=>t.keyCode===e.keyCode&&t.shiftKey===e.shiftKey&&t.altKey===e.altKey&&t.ctrlKey===e.ctrlKey&&t.metaKey===e.metaKey,sT=(e,t)=>ne((e=>$(e,(e=>({...nT,...e}))))(e),(e=>rT(e,t)?[e]:[])),aT=(e,t)=>ne((e=>$(e,(e=>({...nT,...e}))))(e),(e=>rT(e,t)?[e]:[])),iT=(e,...t)=>()=>e.apply(null,t),lT=(e,t)=>ee(sT(e,t),(e=>e.action())),cT=(e,t)=>ge(aT(e,t),(e=>e.action())),dT=(e,t)=>{const o=t?Em.Forwards:Em.Backwards,n=e.selection.getRng();return P_(e,o,n,lf,cf,gr).exists((t=>(H_(e,t),!0)))},mT=(e,t)=>{const o=t?1:-1,n=e.selection.getRng();return F_(e,o,n,lf,cf,gr).exists((t=>(H_(e,t),!0)))},uT=(e,t)=>V_(e,t,t?cf:lf),gT=Al([{none:["current"]},{first:["current"]},{middle:["current","target"]},{last:["current"]}]),hT={...gT,none:e=>gT.none(e)},pT=(e,t,o)=>ne(Lo(e),(e=>xo(e,t)?o(e)?[e]:[]:pT(e,t,o))),fT=(e,t)=>((e,t,o=I)=>o(t)?F.none():j(e,jt(t))?F.some(t):en(t,e.join(","),(e=>xo(e,"table")||o(e))))(["td","th"],e,t),vT=e=>pT(e,"th,td",P),bT=(e,t)=>on(e,"table",t),yT=(e,t,o,n,r=P)=>{const s=1===n;if(!s&&o<=0)return hT.first(e[0]);if(s&&o>=e.length-1)return hT.last(e[e.length-1]);{const s=o+n,a=e[s];return r(a)?hT.middle(t,a):yT(e,t,s,n,r)}},wT=(e,t)=>bT(e,t).bind((t=>{const o=vT(t);return te(o,(t=>So(e,t))).map((e=>({index:e,all:o})))})),xT=(e,t,o,n,r)=>{const s=zn(yo.fromDom(o),"td,th,caption").map((e=>e.dom)),a=Y(((e,t)=>ne(t,(t=>{const o=((e,t)=>({left:e.left-t,top:e.top-t,right:e.right+2*t,bottom:e.bottom+2*t,width:e.width+t,height:e.height+t}))(Ai(t.getBoundingClientRect()),-1);return[{x:o.left,y:e(o),cell:t},{x:o.right,y:e(o),cell:t}]})))(e,s),(e=>t(e,r)));return((e,t,o)=>J(e,((e,n)=>e.fold((()=>F.some(n)),(e=>{const r=Math.sqrt(Math.abs(e.x-t)+Math.abs(e.y-o)),s=Math.sqrt(Math.abs(n.x-t)+Math.abs(n.y-o));return F.some(se.cell))},CT=N(xT,(e=>e.bottom),((e,t)=>e.ye.top),((e,t)=>e.y>t)),kT=(e,t)=>de(t.getClientRects()).bind((t=>CT(e,t.left,t.top))).bind((e=>{return h_(Km(o=e).map((e=>p_(o,e).positions.concat(e))).getOr([]),t);var o})),_T=(e,t)=>me(t.getClientRects()).bind((t=>ST(e,t.left,t.top))).bind((e=>{return h_(Gm(o=e).map((e=>[e].concat(f_(o,e).positions))).getOr([]),t);var o})),ET=(e,t,o)=>{const n=e(t,o);return(e=>e.breakType===i_.Wrap&&0===e.positions.length)(n)||!ir(o.getNode())&&(e=>e.breakType===i_.Br&&1===e.positions.length)(n)?!((e,t,o)=>o.breakAt.exists((o=>e(t,o).breakAt.isSome())))(e,t,n):n.breakAt.isNone()},TT=N(ET,p_),OT=N(ET,f_),DT=(e,t,o,n)=>{const r=e.selection.getRng(),s=t?1:-1;return!(!Yd()||!((e,t,o)=>{const n=rl.fromRangeStart(t);return Wm(!e,o).exists((e=>e.isEqual(n)))})(t,r,o)||(mk(s,e,o,!t,!1).each((t=>{H_(e,t)})),0))},AT=(e,t)=>{const o=t.getNode(e);return Jn(o)?F.some(o):F.none()},MT=(e,t,o)=>{const n=AT(!!t,o),r=!1===t;n.fold((()=>H_(e,o.toRange())),(n=>Wm(r,e.getBody()).filter((e=>e.isEqual(o))).fold((()=>H_(e,o.toRange())),(o=>((e,t,o)=>{t.undoManager.transact((()=>{const n=e?fn:pn,r=PE(t,yo.fromDom(o),n);H_(t,r)}))})(t,e,n)))))},NT=(e,t,o,n)=>{const r=e.selection.getRng(),s=rl.fromRangeStart(r),a=e.getBody();if(!t&&TT(n,s)){const n=((e,t,o)=>kT(t,o).orThunk((()=>de(o.getClientRects()).bind((o=>g_(v_(e,rl.before(t)),o.left))))).getOr(rl.before(t)))(a,o,s);return MT(e,t,n),!0}if(t&&OT(n,s)){const n=((e,t,o)=>_T(t,o).orThunk((()=>de(o.getClientRects()).bind((o=>g_(b_(e,rl.after(t)),o.left))))).getOr(rl.after(t)))(a,o,s);return MT(e,t,n),!0}return!1},RT=(e,t,o)=>F.from(e.dom.getParent(e.selection.getNode(),"td,th")).bind((n=>F.from(e.dom.getParent(n,"table")).map((r=>o(e,t,r,n))))).getOr(!1),BT=(e,t)=>RT(e,t,DT),LT=(e,t)=>RT(e,t,NT),HT=(e,t,o)=>o.fold(F.none,F.none,((e,t)=>{return(o=t,Qo(o,vp)).map((e=>(e=>{const t=qg.exact(e,0,e,0);return Jg(t)})(e)));var o}),(o=>(e.execCommand("mceTableInsertRowAfter"),IT(e,t,o)))),IT=(e,t,o)=>HT(e,t,((e,t,o)=>wT(e,o).fold((()=>hT.none(e)),(o=>yT(o.all,e,o.index,1,t))))(o,nn)),PT=(e,t,o)=>HT(e,t,((e,t,o)=>wT(e,o).fold((()=>hT.none()),(o=>yT(o.all,e,o.index,-1,t))))(o,nn)),FT=(e,t)=>{const o=["table","li","dl"],n=yo.fromDom(e.getBody()),r=e=>{const t=jt(e);return So(e,n)||j(o,t)},s=e.selection.getRng(),a=yo.fromDom(t?s.endContainer:s.startContainer);return fT(a,r).map((o=>(bT(o,r).each((t=>{e.model.table.clearSelectedCells(t.dom)})),e.selection.collapse(!t),(t?IT:PT)(e,r,o).each((t=>{e.selection.setRng(t)})),!0))).getOr(!1)},zT=(e,t)=>{e.on("keydown",(o=>{o.isDefaultPrevented()||((e,t,o)=>{const n=At.os.isMacOS()||At.os.isiOS();lT([{keyCode:Dg.RIGHT,action:iT(GE,e,!0)},{keyCode:Dg.LEFT,action:iT(GE,e,!1)},{keyCode:Dg.UP,action:iT(KE,e,!1)},{keyCode:Dg.DOWN,action:iT(KE,e,!0)},...n?[{keyCode:Dg.UP,action:iT(XE,e,!1),metaKey:!0,shiftKey:!0},{keyCode:Dg.DOWN,action:iT(XE,e,!0),metaKey:!0,shiftKey:!0}]:[],{keyCode:Dg.RIGHT,action:iT(BT,e,!0)},{keyCode:Dg.LEFT,action:iT(BT,e,!1)},{keyCode:Dg.UP,action:iT(LT,e,!1)},{keyCode:Dg.DOWN,action:iT(LT,e,!0)},{keyCode:Dg.UP,action:iT(LT,e,!1)},{keyCode:Dg.UP,action:iT(oT,e,!1)},{keyCode:Dg.DOWN,action:iT(oT,e,!0)},{keyCode:Dg.RIGHT,action:iT(dT,e,!0)},{keyCode:Dg.LEFT,action:iT(dT,e,!1)},{keyCode:Dg.UP,action:iT(mT,e,!1)},{keyCode:Dg.DOWN,action:iT(mT,e,!0)},{keyCode:Dg.RIGHT,action:iT(q_,e,t,!0)},{keyCode:Dg.LEFT,action:iT(q_,e,t,!1)},{keyCode:Dg.RIGHT,ctrlKey:!n,altKey:n,action:iT(Y_,e,t)},{keyCode:Dg.LEFT,ctrlKey:!n,altKey:n,action:iT(X_,e,t)},{keyCode:Dg.UP,action:iT(eT,e,!1)},{keyCode:Dg.DOWN,action:iT(eT,e,!0)}],o).each((e=>{o.preventDefault()}))})(e,t,o)}))},VT=(e,t)=>({container:e,offset:t}),ZT=Ya.DOM,UT=e=>t=>e===t?-1:0,jT=(e,t,o)=>{if(tr(e)&&t>=0)return F.some(VT(e,t));{const n=Oi(ZT);return F.from(n.backwards(e,t,UT(e),o)).map((e=>VT(e.container,e.container.data.length)))}},WT=(e,t,o)=>{if(!tr(e))return F.none();const n=e.data;if(t>=0&&t<=n.length)return F.some(VT(e,t));{const n=Oi(ZT);return F.from(n.backwards(e,t,UT(e),o)).bind((e=>{const n=e.container.data;return WT(e.container,t+n.length,o)}))}},$T=(e,t,o)=>{if(!tr(e))return F.none();const n=e.data;if(t<=n.length)return F.some(VT(e,t));{const r=Oi(ZT);return F.from(r.forwards(e,t,UT(e),o)).bind((e=>$T(e.container,t-n.length,o)))}},qT=(e,t,o,n,r)=>{const s=Oi(e,(e=>t=>e.isBlock(t)||j(["BR","IMG","HR","INPUT"],t.nodeName)||"false"===e.getContentEditable(t))(e));return F.from(s.backwards(t,o,n,r))},GT=e=>Hr(e.toString().replace(/\u00A0/g," ")),KT=e=>""!==e&&-1!=="  \f\n\r\t\v".indexOf(e),YT=(e,t)=>e.substring(t.length),XT=(e,t,o,n=0)=>{if(!(r=t).collapsed||!tr(r.startContainer))return F.none();var r;const s={text:"",offset:0},a=e.getParent(t.startContainer,e.isBlock)||e.getRoot();return qT(e,t.startContainer,t.startOffset,((e,t,n)=>(s.text=n+s.text,s.offset+=t,((e,t,o)=>{let n;const r=o.charAt(0);for(n=t-1;n>=0;n--){const s=e.charAt(n);if(KT(s))return F.none();if(r===s&&Ue(e,o,n,t))break}return F.some(n)})(s.text,s.offset,o).getOr(t))),a).bind((e=>{const r=t.cloneRange();if(r.setStart(e.container,e.offset),r.setEnd(t.endContainer,t.endOffset),r.collapsed)return F.none();const s=GT(r);return 0!==s.lastIndexOf(o)||YT(s,o).length{return(r=yo.fromDom(t.startContainer),on(r,yp)).fold((()=>XT(e,t,o,n)),(t=>{const n=e.createRng();n.selectNode(t.dom);const r=GT(n);return F.some({range:n,text:YT(r,o),trigger:o})}));var r},QT=e=>{if((e=>3===e.nodeType)(e))return VT(e,e.data.length);{const t=e.childNodes;return t.length>0?QT(t[t.length-1]):VT(e,t.length)}},eO=(e,t)=>{const o=e.childNodes;return o.length>0&&t0&&(e=>1===e.nodeType)(e)&&o.length===t?QT(o[o.length-1]):VT(e,t)},tO=e=>t=>{const o=eO(t.startContainer,t.startOffset);return!((e,t)=>{var o;const n=null!==(o=e.getParent(t.container,e.isBlock))&&void 0!==o?o:e.getRoot();return qT(e,t.container,t.offset,((e,t)=>0===t?-1:t),n).filter((e=>{const t=e.container.data.charAt(e.offset-1);return!KT(t)})).isSome()})(e,o)},oO=(e,t)=>{const o=t(),n=e.selection.getRng();return((e,t,o)=>ge(o.triggers,(o=>JT(e,t,o))))(e.dom,n,o).bind((o=>nO(e,t,o)))},nO=(e,t,o,n={})=>{var r;const s=t(),a=null!==(r=e.selection.getRng().startContainer.nodeValue)&&void 0!==r?r:"",i=Y(s.lookupByTrigger(o.trigger),(t=>o.text.length>=t.minChars&&t.matches.getOrThunk((()=>tO(e.dom)))(o.range,a,o.text)));if(0===i.length)return F.none();const l=Promise.all($(i,(e=>e.fetch(o.text,e.maxResults,n).then((t=>({matchText:o.text,items:t,columns:e.columns,onAction:e.onAction,highlightOn:e.highlightOn}))))));return F.some({lookupData:l,context:o})};var rO;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(rO||(rO={}));const sO=(e,t,o)=>e.stype===rO.Error?t(e.serror):o(e.svalue),aO=e=>({stype:rO.Value,svalue:e}),iO=e=>({stype:rO.Error,serror:e}),lO=e=>sO(e,Dl.error,Dl.value),cO=aO,dO=e=>{const t=[],o=[];return q(e,(e=>{sO(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}},mO=iO,uO=(e,t)=>e.stype===rO.Error?t(e.serror):e,gO=(e,t)=>e.stype===rO.Value?{stype:rO.Value,svalue:t(e.svalue)}:e,hO=(e,t)=>e.stype===rO.Error?{stype:rO.Error,serror:t(e.serror)}:e,pO=sO,fO=e=>p(e)&&he(e).length>100?" removed due to size":JSON.stringify(e,null,2),vO=(e,t)=>mO([{path:e,getErrorInfo:t}]),bO=(e,t,o,n)=>ke(o,n).fold((()=>((e,t,o)=>vO(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+fO(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))),yO=(e,t)=>({extract:(o,n)=>ke(n,e).fold((()=>((e,t)=>vO(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>bO(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+he(t)}),wO=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;nf(e)&&f(t)?xO(e,t):t)),CO=(wO(((e,t)=>t)),e=>({tag:"defaultedThunk",process:D(e)})),SO=e=>T(mO,oe)(e),kO=e=>{const t=dO(e);return t.errors.length>0?SO(t.errors):cO(t.values)},_O=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},EO=e=>({extract:(t,o)=>uO(e(o),(e=>((e,t)=>vO(e,D(t)))(t,e))),toString:D("val")}),TO=EO(cO),OO=(e,t,o,n)=>ke(t,o).fold((()=>((e,t,o)=>vO(e,(()=>'Could not find valid *required* value for "'+t+'" in '+fO(o))))(e,o,t)),n),DO=(e,t,o,n)=>n(ke(e,t).getOrThunk((()=>o(e)))),AO=(e,t,o,n,r)=>{const s=e=>r.extract(t.concat([n]),e),a=e=>e.fold((()=>cO(F.none())),(e=>{const o=r.extract(t.concat([n]),e);return gO(o,F.some)}));switch(e.tag){case"required":return OO(t,o,n,s);case"defaultedThunk":return DO(o,n,e.process,s);case"option":return((e,t,o)=>o(ke(e,t)))(o,n,a);case"defaultedOptionThunk":return((e,t,o,n)=>n(ke(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,a);case"mergeWithThunk":return DO(o,n,D({}),(t=>{const n=xO(e.process(o),t);return s(n)}))}},MO=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const s of o)_O(s,((o,s,a,i)=>{const l=AO(a,e,t,o,i);pO(l,(e=>{r.push(...e)}),(e=>{n[s]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?mO(r):cO(n)})(t,o,e),toString:()=>{const t=$(e,(e=>_O(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),NO=e=>({extract:(t,o)=>{const n=$(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return kO(n)},toString:()=>"array("+e.toString()+")"}),RO=(e,t,o)=>lO(((e,t,o)=>{const n=t.extract([e],o);return hO(n,(e=>({input:o,errors:e})))})(e,t,o)),BO=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:D("... (only showing first ten failures)")}]):e;return $(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+fO(e.input),LO=(e,t)=>yO(e,ve(t,MO)),HO=D(TO),IO=(e,t)=>EO((o=>{const n=typeof o;return e(o)?cO(o):mO(`Expected type: ${t} but got: ${n}`)})),PO=IO(k,"number"),FO=IO(h,"string"),zO=IO(y,"boolean"),VO=IO(S,"function"),ZO=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),UO=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),jO=e=>{return t=t=>j(e,t)?Dl.value(t):Dl.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`),EO((e=>t(e).fold(mO,cO)));var t},WO=(e,t)=>ZO(e,e,{tag:"required",process:{}},t),$O=e=>WO(e,FO),qO=e=>WO(e,VO),GO=(e,t)=>ZO(e,e,{tag:"option",process:{}},t),KO=e=>GO(e,FO),YO=(e,t,o)=>ZO(e,e,CO(t),o),XO=(e,t)=>YO(e,t,PO),JO=(e,t,o)=>YO(e,t,jO(o)),QO=(e,t)=>YO(e,t,zO),eD=(e,t)=>YO(e,t,VO),tD=$O("type"),oD=qO("fetch"),nD=qO("onAction"),rD=eD("onSetup",(()=>E)),sD=KO("text"),aD=KO("icon"),iD=KO("tooltip"),lD=KO("label"),cD=QO("active",!1),dD=QO("enabled",!0),mD=QO("primary",!1),uD=e=>((e,t)=>YO(e,t,FO))("type",e),gD=MO([tD,$O("trigger"),XO("minChars",1),(pD=1,((e,t)=>ZO(e,e,CO(t),HO()))("columns",pD)),XO("maxResults",10),(hD="matches",GO(hD,VO)),oD,nD,((e,t,o)=>YO(e,t,NO(o)))("highlightOn",[],FO)]);var hD,pD;const fD=[dD,iD,aD,sD,rD],vD=[cD].concat(fD),bD=[eD("predicate",I),JO("scope","node",["node","editor"]),JO("position","selection",["node","selection","line"])],yD=fD.concat([uD("contextformbutton"),mD,nD,UO("original",A)]),wD=vD.concat([uD("contextformbutton"),mD,nD,UO("original",A)]),xD=fD.concat([uD("contextformbutton")]),CD=vD.concat([uD("contextformtogglebutton")]),SD=LO("type",{contextformbutton:yD,contextformtogglebutton:wD});MO([uD("contextform"),eD("initValue",D("")),lD,((e,t)=>ZO(e,e,{tag:"required",process:{}},NO(t)))("commands",SD),GO("launch",LO("type",{contextformbutton:xD,contextformtogglebutton:CD}))].concat(bD));const kD=e=>{const t=e.ui.registry.getAll().popups,o=ve(t,(e=>{return(t=e,RO("Autocompleter",gD,{trigger:t.ch,...t})).fold((e=>{throw new Error(BO(e))}),A);var t})),n=Te(Ce(o,(e=>e.trigger))),r=Se(o);return{dataset:o,triggers:n,lookupByTrigger:e=>Y(r,(t=>t.trigger===e))}},_D=e=>{const t=ai(),o=Qa(!1),n=t.isSet,r=()=>{n()&&((e=>{yC(e).autocompleter.removeDecoration()})(e),(e=>{e.dispatch("AutocompleterEnd")})(e),o.set(!1),t.clear())},s=o=>{n()||(((e,t)=>{yC(e).autocompleter.addDecoration(t)})(e,o.range),t.set({trigger:o.trigger,matchLength:o.text.length}))},a=He((()=>kD(e))),i=n=>{(o=>t.get().map((t=>JT(e.dom,e.selection.getRng(),t.trigger).bind((t=>nO(e,a,t,o))))).getOrThunk((()=>oO(e,a))))(n).fold(r,(n=>{s(n.context),n.lookupData.then((s=>{t.get().map((a=>{const i=n.context;a.trigger===i.trigger&&(i.text.length-a.matchLength>=10?r():(t.set({...a,matchLength:i.text.length}),o.get()?((e,t)=>{e.dispatch("AutocompleterUpdate",t)})(e,{lookupData:s}):(o.set(!0),((e,t)=>{e.dispatch("AutocompleterStart",t)})(e,{lookupData:s}))))}))}))}))};e.addCommand("mceAutocompleterReload",((e,t)=>{const o=p(t)?t.fetchOptions:{};i(o)})),e.addCommand("mceAutocompleterClose",r),((e,t)=>{const o=li(t.load,50);e.on("keypress compositionend",(e=>{27!==e.which&&o.throttle()})),e.on("keydown",(e=>{const n=e.which;8===n?o.throttle():27===n&&t.cancelIfNecessary()})),e.on("remove",o.cancel)})(e,{cancelIfNecessary:r,load:i})},ED=St().browser.isSafari(),TD=e=>Rr(yo.fromDom(e)),OD=(e,t)=>{var o;return 0===e.startOffset&&e.endOffset===(null===(o=t.textContent)||void 0===o?void 0:o.length)},DD=(e,t)=>F.from(e.getParent(t.container(),"details")),AD=(e,t)=>DD(e,t).isSome(),MD=(e,t)=>t.startSummary.exists((t=>((e,t)=>Gm(t).exists((t=>t.isEqual(e))))(e,t))),ND=(e,t)=>t.startSummary.exists((t=>((e,t)=>Km(t).exists((o=>ir(o.getNode())&&qm(t,o).exists((t=>t.isEqual(e)))||o.isEqual(e))))(e,t))),RD=(e,t)=>{const o=t.getNode();w(o)||e.selection.setCursorLocation(o,t.offset())},BD=(e,t,o)=>{const n=e.dom.getParent(t.container(),"details");if(n&&!n.open){const t=e.dom.select("summary",n)[0];t&&(o?Gm(t):Km(t)).each((t=>RD(e,t)))}else RD(e,t)},LD=(e,t,o)=>{const{dom:n,selection:r}=e,s=e.getBody();if("character"===o){const o=rl.fromRangeStart(r.getRng()),a=n.getParent(o.container(),n.isBlock),i=DD(n,o),l=a&&n.isEmpty(a),c=b(null==a?void 0:a.previousSibling),d=b(null==a?void 0:a.nextSibling);return!!(l&&(t?d:c)&&Um(!t,s,o).exists((e=>AD(n,e)&&!Ht(i,DD(n,e)))))||Um(t,s,o).fold(I,(o=>{const r=DD(n,o);if(AD(n,o)&&!Ht(i,r)){if(t||BD(e,o,!1),a&&l){if(t&&c)return!0;if(!t&&d)return!0;BD(e,o,t),e.dom.remove(a)}return!0}return!1}))}return!1},HD=(e,t,o,n)=>{const r=e.selection.getRng(),s=rl.fromRangeStart(r),a=e.getBody();return"selection"===n?((e,t)=>{const o=t.startSummary.exists((t=>t.contains(e.startContainer))),n=t.startSummary.exists((t=>t.contains(e.endContainer))),r=t.startDetails.forall((e=>t.endDetails.forall((t=>e!==t))));return(o||n)&&!(o&&n)||r})(r,t):o?ND(s,t)||((e,t,o)=>o.startDetails.exists((o=>$m(e,t).forall((e=>!o.contains(e.container()))))))(a,s,t):MD(s,t)||((e,t)=>t.startDetails.exists((o=>qm(o,e).forall((o=>t.startSummary.exists((t=>!t.contains(e.container())&&t.contains(o.container()))))))))(s,t)},ID=(e,t,o)=>((e,t)=>{const o=F.from(e.getParent(t.startContainer,"details")),n=F.from(e.getParent(t.endContainer,"details"));if(o.isSome()||n.isSome()){const t=o.bind((t=>F.from(e.select("summary",t)[0])));return F.some({startSummary:t,startDetails:o,endDetails:n})}return F.none()})(e.dom,e.selection.getRng()).fold((()=>LD(e,t,o)),(n=>HD(e,n,t,o)||LD(e,t,o))),PD=(e,t,o)=>{const n=e.selection,r=n.getNode(),s=n.getRng(),a=rl.fromRangeStart(s);return!!fr(r)&&("selection"===o&&OD(s,r)||yv(t,a,r)?TD(r):e.undoManager.transact((()=>{const s=n.getSel();let{anchorNode:a,anchorOffset:i,focusNode:l,focusOffset:c}=null!=s?s:{};const d=()=>{C(a)&&C(i)&&C(l)&&C(c)&&(null==s||s.setBaseAndExtent(a,i,l,c))},m=(e,t)=>{q(e.childNodes,(e=>{Ou(e)&&t.appendChild(e)}))},u=e.dom.create("span",{"data-mce-bogus":"1"});m(r,u),r.appendChild(u),d(),"word"!==o&&"line"!==o||null==s||s.modify("extend",t?"right":"left",o),!n.isCollapsed()&&OD(n.getRng(),u)?TD(r):(e.execCommand(t?"ForwardDelete":"Delete"),a=null==s?void 0:s.anchorNode,i=null==s?void 0:s.anchorOffset,l=null==s?void 0:s.focusNode,c=null==s?void 0:s.focusOffset,m(u,r),d()),e.dom.remove(u)})),!0)},FD=(e,t,o)=>ID(e,t,o)||ED&&PD(e,t,o)?F.some(E):F.none(),zD=e=>(t,o,n={})=>{const r=t.getBody(),s={bubbles:!0,composed:!0,data:null,isComposing:!1,detail:0,view:null,target:r,currentTarget:r,eventPhase:Event.AT_TARGET,originalTarget:r,explicitOriginalTarget:r,isTrusted:!1,srcElement:r,cancelable:!1,preventDefault:E,inputType:o},a=Ra(new InputEvent(e));return t.dispatch(e,{...a,...s,...n})},VD=zD("input"),ZD=zD("beforeinput"),UD=St(),jD=UD.os,WD=jD.isMacOS()||jD.isiOS(),$D=UD.browser.isFirefox(),qD=(e,t)=>{let o=!1;e.on("keydown",(n=>{o=n.keyCode===Dg.BACKSPACE,n.isDefaultPrevented()||((e,t,o)=>{const n=o.keyCode===Dg.BACKSPACE?"deleteContentBackward":"deleteContentForward",r=e.selection.isCollapsed(),s=r?"character":"selection",a=e=>r?e?"word":"line":"selection";cT([{keyCode:Dg.BACKSPACE,action:iT(TE,e)},{keyCode:Dg.BACKSPACE,action:iT(Ok,e,!1)},{keyCode:Dg.DELETE,action:iT(Ok,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(vk,e,!1)},{keyCode:Dg.DELETE,action:iT(vk,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(oE,e,t,!1)},{keyCode:Dg.DELETE,action:iT(oE,e,t,!0)},{keyCode:Dg.BACKSPACE,action:iT(eb,e,!1)},{keyCode:Dg.DELETE,action:iT(eb,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(FD,e,!1,s)},{keyCode:Dg.DELETE,action:iT(FD,e,!0,s)},...WD?[{keyCode:Dg.BACKSPACE,altKey:!0,action:iT(FD,e,!1,a(!0))},{keyCode:Dg.DELETE,altKey:!0,action:iT(FD,e,!0,a(!0))},{keyCode:Dg.BACKSPACE,metaKey:!0,action:iT(FD,e,!1,a(!1))}]:[{keyCode:Dg.BACKSPACE,ctrlKey:!0,action:iT(FD,e,!1,a(!0))},{keyCode:Dg.DELETE,ctrlKey:!0,action:iT(FD,e,!0,a(!0))}],{keyCode:Dg.BACKSPACE,action:iT(Dk,e,!1)},{keyCode:Dg.DELETE,action:iT(Dk,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(yE,e,!1)},{keyCode:Dg.DELETE,action:iT(yE,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(dk,e,!1)},{keyCode:Dg.DELETE,action:iT(dk,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(ak,e,!1)},{keyCode:Dg.DELETE,action:iT(ak,e,!0)},{keyCode:Dg.BACKSPACE,action:iT(hE,e,!1)},{keyCode:Dg.DELETE,action:iT(hE,e,!0)}],o).filter((t=>e.selection.isEditable())).each((t=>{o.preventDefault(),ZD(e,n).isDefaultPrevented()||(t(),VD(e,n))}))})(e,t,n)})),e.on("keyup",(t=>{t.isDefaultPrevented()||((e,t,o)=>{lT([{keyCode:Dg.BACKSPACE,action:iT(Tk,e)},{keyCode:Dg.DELETE,action:iT(Tk,e)},...WD?[{keyCode:Dg.BACKSPACE,altKey:!0,action:iT(vE,e)},{keyCode:Dg.DELETE,altKey:!0,action:iT(vE,e)},...o?[{keyCode:$D?224:91,action:iT(vE,e)}]:[]]:[{keyCode:Dg.BACKSPACE,ctrlKey:!0,action:iT(vE,e)},{keyCode:Dg.DELETE,ctrlKey:!0,action:iT(vE,e)}]],t)})(e,t,o),o=!1}))},GD=(e,t)=>{const o=e.dom,n=e.schema.getMoveCaretBeforeOnEnterElements();if(!t)return;if(/^(LI|DT|DD)$/.test(t.nodeName)){const e=(e=>{for(;e;){if(Wn(e)||tr(e)&&e.data&&/[\r\n\s]/.test(e.data))return e;e=e.nextSibling}return null})(t.firstChild);e&&/^(UL|OL|DL)$/.test(e.nodeName)&&t.insertBefore(o.doc.createTextNode(br),t.firstChild)}const r=o.createRng();if(t.normalize(),t.hasChildNodes()){const e=new Zn(t,t);let o,s=t;for(;o=e.current();){if(tr(o)){r.setStart(o,0),r.setEnd(o,0);break}if(n[o.nodeName.toLowerCase()]){r.setStartBefore(o),r.setEndBefore(o);break}s=o,o=e.next()}o||(r.setStart(s,0),r.setEnd(s,0))}else ir(t)?t.nextSibling&&o.isBlock(t.nextSibling)?(r.setStartBefore(t),r.setEndBefore(t)):(r.setStartAfter(t),r.setEndAfter(t)):(r.setStart(t,0),r.setEnd(t,0));e.selection.setRng(r),Rh(e,r)},KD=(e,t)=>{const o=e.getRoot();let n,r=t;for(;r!==o&&r&&"false"!==e.getContentEditable(r);){if("true"===e.getContentEditable(r)){n=r;break}r=r.parentNode}return r!==o?n:o},YD=e=>F.from(e.dom.getParent(e.selection.getStart(!0),e.dom.isBlock)),XD=e=>{e.innerHTML='
    '},JD=(e,t)=>{Xl(e).toLowerCase()===t.tagName.toLowerCase()&&((e,t,o)=>{const n=e.dom;F.from(o.style).map(n.parseStyle).each((e=>{const o={...gn(yo.fromDom(t)),...e};n.setStyles(t,o)}));const r=F.from(o.class).map((e=>e.split(/\s+/))),s=F.from(t.className).map((e=>Y(e.split(/\s+/),(e=>""!==e))));It(r,s,((e,o)=>{const r=Y(o,(t=>!j(e,t))),s=[...e,...r];n.setAttrib(t,"class",s.join(" "))}));const a=["style","class"],i=xe(o,((e,t)=>!j(a,t)));n.setAttribs(t,i)})(e,t,Jl(e))},QD=(e,t,o,n,r=!0,s,a)=>{const i=e.dom,l=e.schema,c=Xl(e),d=o?o.nodeName.toUpperCase():"";let m=t;const u=l.getTextInlineElements();let g;g=s||"TABLE"===d||"HR"===d?i.create(s||c,a||{}):o.cloneNode(!1);let h=g;if(r){do{if(u[m.nodeName]){if(Xm(m)||mu(m))continue;const e=m.cloneNode(!1);i.setAttrib(e,"id",""),g.hasChildNodes()?(e.appendChild(g.firstChild),g.appendChild(e)):(h=e,g.appendChild(e))}}while((m=m.parentNode)&&m!==n)}else i.setAttrib(g,"style",null),i.setAttrib(g,"class",null);return JD(e,g),XD(h),g},eA=(e,t,o)=>!t&&o.nodeName.toLowerCase()===Xl(e)&&e.dom.isEmpty(o)&&((e,t,o)=>{let n=t;for(;n&&n!==e&&b(n.nextSibling);){const e=n.parentElement;if(!e||!o(e))return pr(e);n=e}return!1})(e.getBody(),o,(t=>_e(e.schema.getTextBlockElements(),t.nodeName.toLowerCase()))),tA=(e,t,o)=>{var n,r,s;const a=t(Xl(e)),i=((e,t)=>e.dom.getParent(t,pr))(e,o);i&&(e.dom.insertAfter(a,i),GD(e,a),(null!==(s=null===(r=null===(n=o.parentElement)||void 0===n?void 0:n.childNodes)||void 0===r?void 0:r.length)&&void 0!==s?s:0)>1&&e.dom.remove(o))},oA=(e,t)=>{const o=null==e?void 0:e.parentNode;return C(o)&&o.nodeName===t},nA=e=>C(e)&&/^(OL|UL|LI)$/.test(e.nodeName),rA=e=>C(e)&&/^(LI|DT|DD)$/.test(e.nodeName),sA=e=>{const t=e.parentNode;return rA(t)?t:e},aA=(e,t,o)=>{let n=e[o?"firstChild":"lastChild"];for(;n&&!Wn(n);)n=n[o?"nextSibling":"previousSibling"];return n===t},iA=e=>J(Ce(gn(yo.fromDom(e)),((e,t)=>`${t}: ${e};`)),((e,t)=>e+t),""),lA=(e,t,o,n,r)=>{const s=e.dom,a=e.selection.getRng(),i=o.parentNode;if(o===e.getBody()||!i)return;var l;nA(l=o)&&nA(l.parentNode)&&(r="LI");const c=rA(n)?iA(n):void 0;let d=rA(n)&&c?t(r,{style:iA(n)}):t(r);if(aA(o,n,!0)&&aA(o,n,!1))if(oA(o,"LI")){const e=sA(o);s.insertAfter(d,e),(e=>{var t;return(null===(t=e.parentNode)||void 0===t?void 0:t.firstChild)===e})(o)?s.remove(e):s.remove(o)}else s.replace(d,o);else if(aA(o,n,!0))oA(o,"LI")?(s.insertAfter(d,sA(o)),d.appendChild(s.doc.createTextNode(" ")),d.appendChild(o)):i.insertBefore(d,o),s.remove(n);else if(aA(o,n,!1))s.insertAfter(d,sA(o)),s.remove(n);else{o=sA(o);const e=a.cloneRange();e.setStartAfter(n),e.setEndAfter(o);const t=e.extractContents();if("LI"===r&&((e,t)=>e.firstChild&&e.firstChild.nodeName===t)(t,"LI")){const e=Y($(d.children,yo.fromDom),R(Jt("br")));d=t.firstChild,s.insertAfter(t,o),q(e,(e=>vn(yo.fromDom(d),e))),c&&d.setAttribute("style",c)}else s.insertAfter(t,o),s.insertAfter(d,o);s.remove(n)}GD(e,d)},cA=(e,t)=>t&&"A"===t.nodeName&&e.isEmpty(t),dA=(e,t)=>e.nodeName===t||e.previousSibling&&e.previousSibling.nodeName===t,mA=(e,t)=>C(t)&&e.isBlock(t)&&!/^(TD|TH|CAPTION|FORM)$/.test(t.nodeName)&&!/^(fixed|absolute)/i.test(t.style.position)&&e.isEditable(t.parentNode)&&"false"!==e.getContentEditable(t),uA=(e,t,o)=>tr(t)?e?1===o&&t.data.charAt(o-1)===Br?0:o:o===t.data.length-1&&t.data.charAt(o)===Br?t.data.length:o:o,gA={insert:(e,t)=>{let o,n,r,s,a=!1;const i=e.dom,l=e.schema.getNonEmptyElements(),c=e.selection.getRng(),d=Xl(e),m=yo.fromDom(c.startContainer),u=Ho(m,c.startOffset),g=u.exists((e=>qt(e)&&!nn(e))),p=c.collapsed&&g,f=(t,n)=>QD(e,o,k,S,oc(e),t,n),v=e=>{const t=uA(e,o,n);if(tr(o)&&(e?t>0:t{let t;return t=/^(H[1-6]|PRE|FIGURE)$/.test(r)&&"HGROUP"!==_?f(d):f(),((e,t)=>{const o=nc(e);return!x(t)&&(h(o)?j(Bt.explode(o),t.nodeName.toLowerCase()):o)})(e,s)&&mA(i,s)&&i.isEmpty(k,void 0,{includeZwsp:!0})?t=i.split(s,k):i.insertAfter(t,k),GD(e,t),t};lh(i,c).each((e=>{c.setStart(e.startContainer,e.startOffset),c.setEnd(e.endContainer,e.endOffset)})),o=c.startContainer,n=c.startOffset;const y=!(!t||!t.shiftKey),w=!(!t||!t.ctrlKey);Wn(o)&&o.hasChildNodes()&&!p&&(a=n>o.childNodes.length-1,o=o.childNodes[Math.min(n,o.childNodes.length-1)]||o,n=a&&tr(o)?o.data.length:0);const S=KD(i,o);if(!S||((e,t)=>{const o=e.dom.getParent(t,"ol,ul,dl");return null!==o&&"false"===e.dom.getContentEditableParent(o)})(e,o))return;y||(o=((e,t,o,n,r)=>{var s,a;const i=e.dom,l=null!==(s=KD(i,n))&&void 0!==s?s:i.getRoot();let c=i.getParent(n,i.isBlock);if(!c||!mA(i,c)){if(c=c||l,!c.hasChildNodes()){const n=i.create(t);return JD(e,n),c.appendChild(n),o.setStart(n,0),o.setEnd(n,0),n}let s,d=n;for(;d&&d.parentNode!==c;)d=d.parentNode;for(;d&&!i.isBlock(d);)s=d,d=d.previousSibling;const m=null===(a=null==s?void 0:s.parentElement)||void 0===a?void 0:a.nodeName;if(s&&m&&e.schema.isValidChild(m,t.toLowerCase())){const a=s.parentNode,l=i.create(t);for(JD(e,l),a.insertBefore(l,s),d=s;d&&!i.isBlock(d);){const e=d.nextSibling;l.appendChild(d),d=e}o.setStart(n,r),o.setEnd(n,r)}}return n})(e,d,c,o,n));let k=i.getParent(o,i.isBlock)||i.getRoot();s=C(null==k?void 0:k.parentNode)?i.getParent(k.parentNode,i.isBlock):null,r=k?k.nodeName.toUpperCase():"";const _=s?s.nodeName.toUpperCase():"";if("LI"!==_||w||(k=s,s=s.parentNode,r=_),Wn(s)&&eA(e,y,k))return tA(e,f,k);if(/^(LI|DT|DD)$/.test(r)&&Wn(s)&&i.isEmpty(k))return void lA(e,f,s,k,d);if(!(p||k!==e.getBody()&&mA(i,k)))return;const E=k.parentNode;let T;if(p)T=f(d),u.fold((()=>{bn(m,yo.fromDom(T))}),(e=>{pn(e,yo.fromDom(T))})),e.selection.setCursorLocation(T,0);else if(Fr(k))T=qr(k),i.isEmpty(k)&&XD(k),JD(e,T),GD(e,T);else if(v(!1))T=b();else if(v(!0)&&E){T=E.insertBefore(f(),k);const t=yo.fromDom(c.startContainer).dom.hasChildNodes()&&c.collapsed;GD(e,dA(k,"HR")||t?T:k)}else{const t=(e=>{const t=e.cloneRange();return t.setStart(e.startContainer,uA(!0,e.startContainer,e.startOffset)),t.setEnd(e.endContainer,uA(!1,e.endContainer,e.endOffset)),t})(c).cloneRange();t.setEndAfter(k);const o=t.extractContents();(e=>{q(Fn(yo.fromDom(e),Kt),(e=>{const t=e.dom;t.nodeValue=Hr(t.data)}))})(o),(e=>{let t=e;do{tr(t)&&(t.data=t.data.replace(/^[\r\n]+/,"")),t=t.firstChild}while(t)})(o),T=o.firstChild,i.insertAfter(o,k),((e,t,o)=>{var n;const r=[];if(!o)return;let s=o;for(;s=s.firstChild;){if(e.isBlock(s))return;Wn(s)&&!t[s.nodeName.toLowerCase()]&&r.push(s)}let a=r.length;for(;a--;)s=r[a],(!s.hasChildNodes()||s.firstChild===s.lastChild&&""===(null===(n=s.firstChild)||void 0===n?void 0:n.nodeValue)||cA(e,s))&&e.remove(s)})(i,l,T),((e,t)=>{t.normalize();const o=t.lastChild;(!o||Wn(o)&&/^(left|right)$/gi.test(e.getStyle(o,"float",!0)))&&e.add(t,"br")})(i,k),i.isEmpty(k)&&XD(k),T.normalize(),i.isEmpty(T)?(i.remove(T),b()):(JD(e,T),GD(e,T))}i.setAttrib(T,"id",""),e.dispatch("NewBlock",{newBlock:T})},fakeEventName:"insertParagraph"},hA=(e,t,o)=>{const n=e.dom.createRng();o?(n.setStartBefore(t),n.setEndBefore(t)):(n.setStartAfter(t),n.setEndAfter(t)),e.selection.setRng(n),Rh(e,n)},pA=(e,t)=>{const o=e.selection,n=e.dom,r=o.getRng();let s,a=!1;lh(n,r).each((e=>{r.setStart(e.startContainer,e.startOffset),r.setEnd(e.endContainer,e.endOffset)}));let i=r.startOffset,l=r.startContainer;if(Wn(l)&&l.hasChildNodes()){const e=i>l.childNodes.length-1;l=l.childNodes[Math.min(i,l.childNodes.length-1)]||l,i=e&&tr(l)?l.data.length:0}let c=n.getParent(l,n.isBlock);const d=c&&c.parentNode?n.getParent(c.parentNode,n.isBlock):null,m=d?d.nodeName.toUpperCase():"",u=!(!t||!t.ctrlKey);"LI"!==m||u||(c=d),tr(l)&&i>=l.data.length&&(((e,t,o)=>{const n=new Zn(t,o);let r;const s=e.getNonEmptyElements();for(;r=n.next();)if(s[r.nodeName.toLowerCase()]||tr(r)&&r.length>0)return!0;return!1})(e.schema,l,c||n.getRoot())||(s=n.create("br"),r.insertNode(s),r.setStartAfter(s),r.setEndAfter(s),a=!0)),s=n.create("br"),al(n,r,s),hA(e,s,a),e.undoManager.add()},fA=(e,t)=>{const o=yo.fromTag("br");pn(yo.fromDom(t),o),e.undoManager.add()},vA=(e,t)=>{bA(e.getBody(),t)||fn(yo.fromDom(t),yo.fromTag("br"));const o=yo.fromTag("br");fn(yo.fromDom(t),o),hA(e,o.dom,!1),e.undoManager.add()},bA=(e,t)=>{return o=rl.after(t),!!ir(o.getNode())||$m(e,rl.after(t)).map((e=>ir(e.getNode()))).getOr(!1);var o},yA=e=>e&&"A"===e.nodeName&&"href"in e,wA=e=>e.fold(I,yA,yA,I),xA=(e,t)=>{t.fold(E,N(fA,e),N(vA,e),E)},CA={insert:(e,t)=>{const o=(e=>{const t=N(lv,e),o=rl.fromRangeStart(e.selection.getRng());return Yk(t,e.getBody(),o).filter(wA)})(e);o.isSome()?o.each(N(xA,e)):pA(e,t)},fakeEventName:"insertLineBreak"},SA=(e,t)=>YD(e).filter((e=>t.length>0&&xo(yo.fromDom(e),t))).isSome(),kA=Al([{br:[]},{block:[]},{none:[]}]),_A=(e,t)=>(e=>SA(e,tc(e)))(e),EA=e=>(t,o)=>(e=>YD(e).filter((e=>Tr(yo.fromDom(e)))).isSome())(t)===e,TA=(e,t)=>(o,n)=>{const r=(e=>YD(e).fold(D(""),(e=>e.nodeName.toUpperCase())))(o)===e.toUpperCase();return r===t},OA=e=>{const t=KD(e.dom,e.selection.getStart());return x(t)},DA=e=>TA("pre",e),AA=e=>(t,o)=>Yl(t)===e,MA=(e,t)=>(e=>SA(e,ec(e)))(e),NA=(e,t)=>t,RA=e=>{const t=Xl(e),o=KD(e.dom,e.selection.getStart());return C(o)&&e.schema.isValidChild(o.nodeName,t)},BA=e=>{const t=e.selection.getRng(),o=yo.fromDom(t.startContainer),n=Ho(o,t.startOffset).map((e=>qt(e)&&!nn(e)));return t.collapsed&&n.getOr(!0)},LA=(e,t)=>(o,n)=>J(e,((e,t)=>e&&t(o,n)),!0)?F.some(t):F.none(),HA=(e,t,o)=>{t.selection.isCollapsed()||(e=>{e.execCommand("delete")})(t),C(o)&&ZD(t,e.fakeEventName).isDefaultPrevented()||(e.insert(t,o),C(o)&&VD(t,e.fakeEventName))},IA=(e,t)=>{const o=()=>HA(CA,e,t),n=()=>HA(gA,e,t),r=((e,t)=>zk([LA([_A],kA.none()),LA([DA(!0),OA],kA.none()),LA([TA("summary",!0)],kA.br()),LA([DA(!0),AA(!1),NA],kA.br()),LA([DA(!0),AA(!1)],kA.block()),LA([DA(!0),AA(!0),NA],kA.block()),LA([DA(!0),AA(!0)],kA.br()),LA([EA(!0),NA],kA.br()),LA([EA(!0)],kA.block()),LA([MA],kA.br()),LA([NA],kA.br()),LA([RA],kA.block()),LA([BA],kA.block())],[e,!(!t||!t.shiftKey)]).getOr(kA.none()))(e,t);switch(Ql(e)){case"linebreak":r.fold(o,o,E);break;case"block":r.fold(n,n,E);break;case"invert":r.fold(n,o,E);break;default:r.fold(o,n,E)}},PA=St(),FA=PA.os.isiOS()&&PA.browser.isSafari(),zA=(e,t)=>{var o;t.isDefaultPrevented()||(t.preventDefault(),(o=e.undoManager).typing&&(o.typing=!1,o.add()),e.undoManager.transact((()=>{IA(e,t)})))},VA=e=>{let t=F.none();e.on("keydown",(o=>{o.keyCode===Dg.ENTER&&(FA&&(e=>{if(!e.collapsed)return!1;const t=e.startContainer;if(tr(t)){const o=/^[\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]$/,n=t.data.charAt(e.startOffset-1);return o.test(n)}return!1})(e.selection.getRng())?(e=>{t=F.some(e.selection.getBookmark()),e.undoManager.add()})(e):zA(e,o))})),e.on("keyup",(o=>{o.keyCode===Dg.ENTER&&t.each((()=>((e,o)=>{e.undoManager.undo(),t.fold(E,(t=>e.selection.moveToBookmark(t))),zA(e,o),t=F.none()})(e,o)))}))},ZA=(e,t)=>{e.on("keydown",(o=>{o.isDefaultPrevented()||((e,t,o)=>{const n=At.os.isMacOS()||At.os.isiOS();lT([{keyCode:Dg.END,action:iT(YE,e,!0)},{keyCode:Dg.HOME,action:iT(YE,e,!1)},...n?[]:[{keyCode:Dg.HOME,action:iT(XE,e,!1),ctrlKey:!0,shiftKey:!0},{keyCode:Dg.END,action:iT(XE,e,!0),ctrlKey:!0,shiftKey:!0}],{keyCode:Dg.END,action:iT(uT,e,!0)},{keyCode:Dg.HOME,action:iT(uT,e,!1)},{keyCode:Dg.END,action:iT(J_,e,!0,t)},{keyCode:Dg.HOME,action:iT(J_,e,!1,t)}],o).each((e=>{o.preventDefault()}))})(e,t,o)}))},UA=e=>{e.on("input",(t=>{t.isComposing||(e=>{const t=yo.fromDom(e.getBody());e.selection.isCollapsed()&&$f(t,rl.fromRangeStart(e.selection.getRng()),e.schema).each((t=>{e.selection.setRng(t.toRange())}))})(e)}))},jA=St(),WA=e=>e.stopImmediatePropagation(),$A=e=>e.keyCode===Dg.PAGE_UP||e.keyCode===Dg.PAGE_DOWN,qA=(e,t,o)=>{o&&!e.get()?t.on("NodeChange",WA,!0):!o&&e.get()&&t.off("NodeChange",WA),e.set(o)},GA=(e,t)=>{if(jA.os.isMacOS())return;const o=Qa(!1);e.on("keydown",(t=>{$A(t)&&qA(o,e,!0)})),e.on("keyup",(n=>{n.isDefaultPrevented()||((e,t,o)=>{lT([{keyCode:Dg.PAGE_UP,action:iT(J_,e,!1,t)},{keyCode:Dg.PAGE_DOWN,action:iT(J_,e,!0,t)}],o)})(e,t,n),$A(n)&&o.get()&&(qA(o,e,!1),e.nodeChanged())}))},KA=(e,t)=>{const o=t.container(),n=t.offset();return tr(o)?(o.insertData(n,e),F.some(rl(o,n+e.length))):Sm(t).map((o=>{const n=yo.fromText(e);return t.isAtEnd()?fn(o,n):pn(o,n),rl(n.dom,e.length)}))},YA=N(KA,br),XA=N(KA," "),JA=e=>t=>{e.selection.setRng(t.toRange()),e.nodeChanged()},QA=e=>{const t=rl.fromRangeStart(e.selection.getRng()),o=yo.fromDom(e.getBody());if(e.selection.isCollapsed()){const n=N(lv,e),r=rl.fromRangeStart(e.selection.getRng());return Yk(n,e.getBody(),r).bind((e=>t=>t.fold((t=>qm(e.dom,rl.before(t))),(e=>Gm(e)),(e=>Km(e)),(t=>$m(e.dom,rl.after(t)))))(o)).map((n=>()=>((e,t,o)=>n=>If(e,n,o)?YA(t):XA(t))(o,t,e.schema)(n).each(JA(e))))}return F.none()},eM=e=>{return Pt(At.browser.isFirefox()&&e.selection.isEditable()&&(t=e.dom,o=e.selection.getRng().startContainer,t.isEditable(t.getParent(o,"summary"))),(()=>{const t=yo.fromDom(e.getBody());e.selection.isCollapsed()||e.getDoc().execCommand("Delete"),((e,t,o)=>If(e,t,o)?YA(t):XA(t))(t,rl.fromRangeStart(e.selection.getRng()),e.schema).each(JA(e))}));var t,o},tM=e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{cT([{keyCode:Dg.SPACEBAR,action:iT(QA,e)},{keyCode:Dg.SPACEBAR,action:iT(eM,e)}],t).each((o=>{t.preventDefault(),ZD(e,"insertText",{data:" "}).isDefaultPrevented()||(o(),VD(e,"insertText",{data:" "}))}))})(e,t)}))},oM=e=>Ad(e)?[{keyCode:Dg.TAB,action:iT(FT,e,!0)},{keyCode:Dg.TAB,shiftKey:!0,action:iT(FT,e,!1)}]:[],nM=e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{lT([...oM(e)],t).each((e=>{t.preventDefault()}))})(e,t)}))},rM=e=>{if(e.addShortcut("Meta+P","","mcePrint"),_D(e),fC(e))return Qa(null);{const t=K_(e);return(e=>{e.on("beforeinput",(t=>{e.selection.isEditable()&&!W(t.getTargetRanges(),(t=>!dp(e.dom,t)))||t.preventDefault()}))})(e),(e=>{e.on("keyup compositionstart",N(UE,e))})(e),zT(e,t),qD(e,t),VA(e),tM(e),UA(e),nM(e),ZA(e,t),GA(e,t),t}};class sM{constructor(e){let t;this.lastPath=[],this.editor=e;const o=this;"onselectionchange"in e.getDoc()||e.on("NodeChange click mouseup keyup focus",(o=>{const n=e.selection.getRng(),r={startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset};"nodechange"!==o.type&&th(r,t)||e.dispatch("SelectionChange"),t=r})),e.on("contextmenu",(()=>{e.dispatch("SelectionChange")})),e.on("SelectionChange",(()=>{const t=e.selection.getStart(!0);t&&_u(e)&&!o.isSameElementPath(t)&&e.dom.isChildOf(t,e.getBody())&&e.nodeChanged({selectionChange:!0})})),e.on("mouseup",(t=>{!t.isDefaultPrevented()&&_u(e)&&("IMG"===e.selection.getNode().nodeName?qh.setEditorTimeout(e,(()=>{e.nodeChanged()})):e.nodeChanged())}))}nodeChanged(e={}){const t=this.editor.selection;let o;if(this.editor.initialized&&t&&!Wc(this.editor)&&!this.editor.mode.isReadOnly()){const n=this.editor.getBody();o=t.getStart(!0)||n,o.ownerDocument===this.editor.getDoc()&&this.editor.dom.isChildOf(o,n)||(o=n);const r=[];this.editor.dom.getParent(o,(e=>e===n||(r.push(e),!1))),this.editor.dispatch("NodeChange",{...e,element:o,parents:r})}}isSameElementPath(e){let t;const o=this.editor,n=se(o.dom.getParents(e,P,o.getBody()));if(n.length===this.lastPath.length){for(t=n.length;t>=0&&n[t]===this.lastPath[t];t--);if(-1===t)return this.lastPath=n,!0}return this.lastPath=n,!1}}const aM=Ci("image"),iM=Ci("event"),lM=e=>t=>{t[iM]=e},cM=lM(0),dM=lM(2),mM=lM(1),uM=(gM=0,e=>{const t=e;return F.from(t[iM]).exists((e=>e===gM))});var gM;const hM=Ci("mode"),pM=e=>t=>{t[hM]=e},fM=(e,t)=>pM(t)(e),vM=pM(0),bM=pM(2),yM=pM(1),wM=e=>t=>{const o=t;return F.from(o[hM]).exists((t=>t===e))},xM=wM(0),CM=wM(1),SM=["none","copy","link","move"],kM=["none","copy","copyLink","copyMove","link","linkMove","move","all","uninitialized"],_M=()=>{const e=new window.DataTransfer;let t="move",o="all";const n={get dropEffect(){return t},set dropEffect(e){j(SM,e)&&(t=e)},get effectAllowed(){return o},set effectAllowed(e){uM(n)&&j(kM,e)&&(o=e)},get items(){return((e,t)=>({...t,get length(){return t.length},add:(o,n)=>{if(xM(e)){if(!h(o))return t.add(o);if(!w(n))return t.add(o,n)}return null},remove:o=>{xM(e)&&t.remove(o)},clear:()=>{xM(e)&&t.clear()}}))(n,e.items)},get files(){return CM(n)?Object.freeze({length:0,item:e=>null}):e.files},get types(){return e.types},setDragImage:(t,o,r)=>{var s;xM(n)&&(s={image:t,x:o,y:r},n[aM]=s,e.setDragImage(t,o,r))},getData:t=>CM(n)?"":e.getData(t),setData:(t,o)=>{xM(n)&&e.setData(t,o)},clearData:t=>{xM(n)&&e.clearData(t)}};return vM(n),n},EM=e=>{const t=_M(),o=(e=>{const t=e;return F.from(t[hM])})(e);return bM(e),cM(t),t.dropEffect=e.dropEffect,t.effectAllowed=e.effectAllowed,(e=>{const t=e;return F.from(t[aM])})(e).each((e=>t.setDragImage(e.image,e.x,e.y))),q(e.types,(o=>{"Files"!==o&&t.setData(o,e.getData(o))})),q(e.files,(e=>t.items.add(e))),(e=>{const t=e;return F.from(t[iM])})(e).each((e=>{((e,t)=>{lM(t)(e)})(t,e)})),o.each((o=>{fM(e,o),fM(t,o)})),t},TM=(e,t)=>e.setData("text/html",t),OM="x-tinymce/html",DM=D(OM),AM="\x3c!-- "+OM+" --\x3e",MM=e=>AM+e,NM=e=>-1!==e.indexOf(AM),RM=(e,t,o)=>{const n=e.split(/\n\n/),r=((e,t)=>{let o="<"+e;const n=Ce(t,((e,t)=>t+'="'+ia.encodeAllRaw(e)+'"'));return n.length&&(o+=" "+n.join(" ")),o+">"})(t,o),s="",a=$(n,(e=>e.split(/\n/).join("
    ")));return 1===a.length?a[0]:$(a,(e=>r+e+s)).join("")},BM="%MCEPASTEBIN%",LM=e=>e.dom.get("mcepastebin"),HM=e=>C(e)&&"mcepastebin"===e.id,IM=e=>e===BM,PM=e=>{const t=Qa(null);return{create:()=>((e,t)=>{const{dom:o,selection:n}=e,r=e.getBody();t.set(n.getRng());const s=o.add(e.getBody(),"div",{id:"mcepastebin",class:"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},BM);At.browser.isFirefox()&&o.setStyle(s,"left","rtl"===o.getStyle(r,"direction",!0)?65535:-65535),o.bind(s,"beforedeactivate focusin focusout",(e=>{e.stopPropagation()})),s.focus(),n.select(s,!0)})(e,t),remove:()=>((e,t)=>{const o=e.dom;if(LM(e)){let n;const r=t.get();for(;n=LM(e);)o.remove(n),o.unbind(n);r&&e.selection.setRng(r)}t.set(null)})(e,t),getEl:()=>LM(e),getHtml:()=>(e=>{const t=e.dom,o=(e,o)=>{e.appendChild(o),t.remove(o,!0)},[n,...r]=Y(e.getBody().childNodes,HM);q(r,(e=>{o(n,e)}));const s=t.select("div[id=mcepastebin]",n);for(let e=s.length-1;e>=0;e--){const r=t.create("div");n.insertBefore(r,s[e]),o(r,s[e])}return n?n.innerHTML:""})(e),getLastRng:t.get}},FM=(e,t)=>(Bt.each(t,(t=>{e=g(t,RegExp)?e.replace(t,""):e.replace(t[0],t[1])})),e),zM=e=>e=FM(e,[/^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/|/g,[/( ?)\u00a0<\/span>( ?)/g,(e,t,o)=>t||o?br:" "],/
    /g,/
    $/i]),VM=(e,t)=>({content:e,cancelled:t}),ZM=(e,t,o)=>{const n=((e,t,o)=>e.dispatch("PastePreProcess",{content:t,internal:o}))(e,t,o),r=((e,t)=>{const o=Mx({sanitize:Td(e),sandbox_iframes:Bd(e)},e.schema);o.addNodeFilter("meta",(e=>{Bt.each(e,(e=>{e.remove()}))}));const n=o.parse(t,{forced_root_block:!1,isRootContent:!0});return $p({validate:!0},e.schema).serialize(n)})(e,n.content);return e.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()?((e,t,o)=>{const n=e.dom.create("div",{style:"display:none"},t),r=((e,t,o)=>e.dispatch("PastePostProcess",{node:t,internal:o}))(e,n,o);return VM(r.node.innerHTML,r.isDefaultPrevented())})(e,r,o):VM(r,n.isDefaultPrevented())},UM=(e,t)=>(e.insertContent(t,{merge:pd(e),paste:!0}),!0),jM=e=>/^https?:\/\/[\w\-\/+=.,!;:&%@^~(){}?#]+$/i.test(e),WM=(e,t,o)=>!(e.selection.isCollapsed()||!jM(t))&&((e,t,o)=>(e.undoManager.extra((()=>{o(e,t)}),(()=>{e.execCommand("mceInsertLink",!1,t)})),!0))(e,t,o),$M=(e,t,o)=>!!((e,t)=>jM(t)&&W(Dd(e),(e=>We(t.toLowerCase(),`.${e.toLowerCase()}`))))(e,t)&&((e,t,o)=>(e.undoManager.extra((()=>{o(e,t)}),(()=>{e.insertContent('')})),!0))(e,t,o),qM=(e,t,o)=>{o||!fd(e)?UM(e,t):((e,t)=>{Bt.each([WM,$M,UM],(o=>!o(e,t,UM)))})(e,t)},GM=(e=>{let t=0;return()=>e+t++})("mceclip"),KM=e=>{const t=_M();return TM(t,e),bM(t),t},YM=(e,t,o,n,r)=>{const s=((e,t,o)=>ZM(e,t,o))(e,t,o);if(!s.cancelled){const t=s.content,o=()=>qM(e,t,n);r?ZD(e,"insertFromPaste",{dataTransfer:KM(t)}).isDefaultPrevented()||(o(),VD(e,"insertFromPaste")):o()}},XM=(e,t,o,n)=>{const r=o||NM(t);YM(e,(e=>e.replace(AM,""))(t),r,!1,n)},JM=(e,t,o)=>{const n=e.dom.encode(t).replace(/\r\n/g,"\n"),r=ds(n,bd(e)),s=RM(r,Xl(e),Jl(e));YM(e,s,!1,!0,o)},QM=e=>{const t={};if(e&&e.types)for(let o=0;ot in e&&e[t].length>0,tN=e=>eN(e,"text/html")||eN(e,"text/plain"),oN=(e,t,o,n)=>{const r=GM(),s=sc(e)&&C(o.name),a=s?((e,t)=>{const o=t.match(/([\s\S]+?)(?:\.[a-z0-9.]+)$/i);return C(o)?e.dom.encode(o[1]):void 0})(e,o.name):r,i=s?o.name:void 0,l=t.create(r,o,n,a,i);return t.add(l),l},nN=e=>{const t=Dd(e);return e=>je(e.type,"image/")&&W(t,(t=>(e=>{const t=e.toLowerCase(),o={jpg:"jpeg",jpe:"jpeg",jfi:"jpeg",jif:"jpeg",jfif:"jpeg",pjpeg:"jpeg",pjp:"jpeg",svg:"svg+xml"};return Bt.hasOwn(o,t)?"image/"+o[t]:"image/"+t})(t)===e.type))},rN=(e,t,o)=>{const n="paste"===t.type?t.clipboardData:t.dataTransfer;var r;if(cd(e)&&n){const s=((e,t)=>{const o=t.items?ne(ue(t.items),(e=>"file"===e.kind?[e.getAsFile()]:[])):[],n=t.files?ue(t.files):[];return Y(o.length>0?o:n,nN(e))})(e,n);if(s.length>0)return t.preventDefault(),(r=s,Promise.all($(r,(e=>aw(e).then((t=>({file:e,uri:t}))))))).then((t=>{o&&e.selection.setRng(o),q(t,(t=>{((e,t)=>{nw(t.uri).each((({data:o,type:n,base64Encoded:r})=>{const s=r?o:btoa(o),a=t.file,i=e.editorUpload.blobCache,l=i.getByData(s,n),c=null!=l?l:oN(e,i,a,s);XM(e,``,!1,!0)}))})(e,t)}))})),!0}return!1},sN=(e,t,o,n,r)=>{let s=zM(o);const a=eN(t,DM())||NM(o),i=!a&&(e=>!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e))(s),l=jM(s);(IM(s)||!s.length||i&&!l)&&(n=!0),(n||l)&&(s=eN(t,"text/plain")&&i?t["text/plain"]:(e=>{const t=ya(),o=Mx({},t);let n="";const r=t.getVoidElements(),s=Bt.makeMap("script noscript style textarea video audio iframe object"," "),a=t.getBlockElements(),i=e=>{const o=e.name,l=e;if("br"!==o){if("wbr"!==o)if(r[o]&&(n+=" "),s[o])n+=" ";else{if(3===e.type&&(n+=e.value),!(e.name in t.getVoidElements())){let t=e.firstChild;if(t)do{i(t)}while(t=t.next)}a[o]&&l.next&&(n+="\n","p"===o&&(n+="\n"))}}else n+="\n"};return e=FM(e,[//g]),i(o.parse(e)),n})(s)),IM(s)||(n?JM(e,s,r):XM(e,s,a,r))},aN=(e,t,o)=>{let n;e.on("keydown",(e=>{(e=>Dg.metaKeyPressed(e)&&86===e.keyCode||e.shiftKey&&45===e.keyCode)(e)&&!e.isDefaultPrevented()&&(n=e.shiftKey&&86===e.keyCode)})),e.on("paste",(r=>{if(r.isDefaultPrevented()||(e=>{var t,o;return At.os.isAndroid()&&0===(null===(o=null===(t=e.clipboardData)||void 0===t?void 0:t.items)||void 0===o?void 0:o.length)})(r))return;const s="text"===o.get()||n;n=!1;const a=QM(r.clipboardData);!tN(a)&&rN(e,r,t.getLastRng()||e.selection.getRng())||(eN(a,"text/html")?(r.preventDefault(),sN(e,a,a["text/html"],s,!0)):eN(a,"text/plain")&&eN(a,"text/uri-list")?(r.preventDefault(),sN(e,a,a["text/plain"],s,!0)):(t.create(),qh.setEditorTimeout(e,(()=>{const o=t.getHtml();t.remove(),sN(e,a,o,s,!1)}),0)))}))},iN=(e,t,o)=>{aN(e,t,o),(e=>{const t=e=>je(e,"webkit-fake-url"),o=e=>je(e,"data:");e.parser.addNodeFilter("img",((n,r,s)=>{if(!cd(e)&&(e=>{var t;return!0===(null===(t=e.data)||void 0===t?void 0:t.paste)})(s))for(const r of n){const n=r.attr("src");h(n)&&!r.attr("data-mce-object")&&n!==At.transparentSrc&&(t(n)||!yd(e)&&o(n))&&r.remove()}}))})(e)},lN=(e,t)=>{e.addCommand("mceTogglePlainTextPaste",(()=>{((e,t)=>{"text"===t.get()?(t.set("html"),Og(e,!1)):(t.set("text"),Og(e,!0)),e.focus()})(e,t)})),e.addCommand("mceInsertClipboardContent",((t,o)=>{o.html&&XM(e,o.html,o.internal,!1),o.text&&JM(e,o.text,!1)}))},cN=(e,t,o,n)=>{((e,t,o)=>{if(!e)return!1;try{return e.clearData(),e.setData("text/html",t),e.setData("text/plain",o),e.setData(DM(),t),!0}catch(e){return!1}})(e.clipboardData,t.html,t.text)?(e.preventDefault(),n()):o(t.html,n)},dN=e=>(t,o)=>{const{dom:n,selection:r}=e,s=n.create("div",{contenteditable:"false","data-mce-bogus":"all"}),a=n.create("div",{contenteditable:"true"},t);n.setStyles(s,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),s.appendChild(a),n.add(e.getBody(),s);const i=r.getRng();a.focus();const l=n.createRng();l.selectNodeContents(a),r.setRng(l),qh.setEditorTimeout(e,(()=>{r.setRng(i),n.remove(s),o()}),0)},mN=e=>({html:MM(e.selection.getContent({contextual:!0})),text:e.selection.getContent({format:"text"})}),uN=e=>!e.selection.isCollapsed()||(e=>!!e.dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody()))(e),gN=e=>{e.on("cut",(e=>t=>{!t.isDefaultPrevented()&&uN(e)&&e.selection.isEditable()&&cN(t,mN(e),dN(e),(()=>{if(At.browser.isChromium()||At.browser.isFirefox()){const t=e.selection.getRng();qh.setEditorTimeout(e,(()=>{e.selection.setRng(t),e.execCommand("Delete")}),0)}else e.execCommand("Delete")}))})(e)),e.on("copy",(e=>t=>{!t.isDefaultPrevented()&&uN(e)&&cN(t,mN(e),dN(e),E)})(e))},hN=(e,t)=>{var o,n;return mh.getCaretRangeFromPoint(null!==(o=t.clientX)&&void 0!==o?o:0,null!==(n=t.clientY)&&void 0!==n?n:0,e.getDoc())},pN=(e,t)=>{e.focus(),t&&e.selection.setRng(t)},fN=(e,t)=>{ld(e)&&e.on("dragend dragover draggesture dragdrop drop drag",(e=>{e.preventDefault(),e.stopPropagation()})),cd(e)||e.on("drop",(e=>{const t=e.dataTransfer;t&&(e=>W(e.files,(e=>/^image\//.test(e.type))))(t)&&e.preventDefault()})),e.on("drop",(o=>{if(o.isDefaultPrevented())return;const n=hN(e,o);if(x(n))return;const r=QM(o.dataTransfer),s=eN(r,DM());if((!tN(r)||(e=>{const t=e["text/plain"];return!!t&&0===t.indexOf("file://")})(r))&&rN(e,o,n))return;const a=r[DM()],i=a||r["text/html"]||r["text/plain"],l=((e,t,o,n)=>{const r=e.getParent(o,(e=>Ls(t,e)));if(!b(e.getParent(o,"summary")))return!0;if(r&&_e(n,"text/html")){const e=(new DOMParser).parseFromString(n["text/html"],"text/html").body;return!b(e.querySelector(r.nodeName.toLowerCase()))}return!1})(e.dom,e.schema,n.startContainer,r),c=t.get();c&&!l||i&&(o.preventDefault(),qh.setEditorTimeout(e,(()=>{e.undoManager.transact((()=>{(a||c&&l)&&e.execCommand("Delete"),pN(e,n);const t=zM(i);r["text/html"]?XM(e,t,s,!0):JM(e,t,!0)}))})))})),e.on("dragstart",(e=>{t.set(!0)})),e.on("dragover dragend",(o=>{cd(e)&&!t.get()&&(o.preventDefault(),pN(e,hN(e,o))),"dragend"===o.type&&t.set(!1)})),(e=>{e.on("input",(t=>{const o=e=>b(e.querySelector("summary"));if("deleteByDrag"===t.inputType){const t=Y(e.dom.select("details"),o);q(t,(t=>{ir(t.firstChild)&&t.firstChild.remove();const o=e.dom.create("summary");o.appendChild(Nr().dom),t.prepend(o)}))}}))})(e)},vN=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,bN=e=>Bt.trim(e).replace(vN,Da).toLowerCase(),yN=(e,t,o)=>{const n=gd(e);if(o||"all"===n||!hd(e))return t;const r=n?n.split(/[, ]/):[];if(r&&"none"!==n){const o=e.dom,n=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,((e,t,s,a)=>{const i=o.parseStyle(o.decode(s)),l={};for(let e=0;e]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,((e,t,o,n)=>t+' style="'+o+'"'+n)),t},wN=e=>{const t=Qa(!1),o=Qa(vd(e)?"text":"html"),n=PM(e);(e=>{(At.browser.isChromium()||At.browser.isSafari())&&((e,t)=>{e.on("PastePreProcess",(o=>{o.content=t(e,o.content,o.internal)}))})(e,yN)})(e),lN(e,o),(e=>{const t=t=>o=>{t(e,o)},o=dd(e);S(o)&&e.on("PastePreProcess",t(o));const n=md(e);S(n)&&e.on("PastePostProcess",t(n))})(e),e.on("PreInit",(()=>{gN(e),fN(e,t),iN(e,n,o)}))},xN=e=>{(e=>{e.on("click",(t=>{e.dom.getParent(t.target,"details")&&t.preventDefault()}))})(e),(e=>{e.parser.addNodeFilter("details",(t=>{const o=Md(e);q(t,(e=>{"expanded"===o?e.attr("open","open"):"collapsed"===o&&e.attr("open",null)}))})),e.serializer.addNodeFilter("details",(t=>{const o=Nd(e);q(t,(e=>{"expanded"===o?e.attr("open","open"):"collapsed"===o&&e.attr("open",null)}))}))})(e)},CN=ir,SN=tr,kN=e=>dr(e.dom),_N=e=>t=>So(yo.fromDom(e),t),EN=(e,t,o)=>Xo(yo.fromDom(e),(e=>(e=>cr(e.dom))(e)||o.isBlock(jt(e))),_N(t)).getOr(yo.fromDom(t)).dom,TN=(e,t)=>Xo(yo.fromDom(e),kN,_N(t)),ON=(e,t,o)=>{const n=new Zn(e,t),r=o?n.next.bind(n):n.prev.bind(n);let s=e;for(let t=o?e:r();t&&!CN(t);t=r())ns(t)&&(s=t);return s},DN=e=>{const t=((e,t,o)=>{const n=rl.fromRangeStart(e).getNode(),r=EN(n,t,o),s=ON(n,r,!1),a=ON(n,r,!0),i=document.createRange();return TN(s,r).fold((()=>{SN(s)?i.setStart(s,0):i.setStartBefore(s)}),(e=>i.setStartBefore(e.dom))),TN(a,r).fold((()=>{SN(a)?i.setEnd(a,a.data.length):i.setEndAfter(a)}),(e=>i.setEndAfter(e.dom))),i})(e.selection.getRng(),e.getBody(),e.schema);e.selection.setRng(vb(t))};var AN;!function(e){e.Before="before",e.After="after"}(AN||(AN={}));const MN=(e,t)=>Math.abs(e.left-t),NN=(e,t)=>Math.abs(e.right-t),RN=(e,t)=>{const o=((e,t)=>Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)))(e,t)/Math.min(e.height,t.height);return((e,t)=>e.topt.top)(e,t)&&o>.5},BN=(e,t)=>(e=>J(e,((e,t)=>e.fold((()=>F.some(t)),(e=>{const o=Math.min(t.left,e.left),n=Math.min(t.top,e.top),r=Math.max(t.right,e.right),s=Math.max(t.bottom,e.bottom);return F.some({top:n,right:r,bottom:s,left:o,width:r-o,height:s-n})}))),F.none()))(Y(e,(e=>{return(o=t)>=(n=e).top&&o<=n.bottom;var o,n}))).fold((()=>[[],e]),(t=>{const{pass:o,fail:n}=K(e,(e=>RN(e,t)));return[o,n]})),LN=(e,t,o)=>t>e.left&&t{const r=e=>ns(e.node)?F.some(e):Wn(e.node)?HN(ue(e.node.childNodes),t,o,!1):F.none(),s=(e,s)=>{const a=le(e,((e,n)=>s(e,t,o)-s(n,t,o)));return ge(a,r).map((e=>n&&!tr(e.node)&&a.length>1?((e,n,s)=>r(n).filter((n=>Math.abs(s(e,t,o)-s(n,t,o))<2&&tr(n.node))))(e,a[1],s).getOr(e):e))},[a,i]=BN(O_(e),o),{pass:l,fail:c}=K(i,(e=>e.tops(c,Li))).orThunk((()=>s(l,Li)))},IN=(e,t,o)=>{const n=yo.fromDom(e),r=Eo(n),s=yo.fromPoint(r,t,o).filter((e=>ko(n,e))).getOr(n);return((e,t,o,n)=>{const r=(t,s)=>{const a=Y(t.dom.childNodes,R((e=>Wn(e)&&e.classList.contains("mce-drag-container"))));return s.fold((()=>HN(a,o,n,!0)),(e=>{const t=Y(a,(t=>t!==e.dom));return HN(t,o,n,!0)})).orThunk((()=>(So(t,e)?F.none():Do(t)).bind((e=>r(e,F.some(t))))))};return r(t,F.none())})(n,s,t,o)},PN=(e,t,o)=>IN(e,t,o).filter((e=>Jd(e.node))).map((e=>((e,t)=>({node:e.node,position:MN(e,t){var t,o;const n=e.getBoundingClientRect(),r=e.ownerDocument,s=r.documentElement,a=r.defaultView;return{top:n.top+(null!==(t=null==a?void 0:a.scrollY)&&void 0!==t?t:0)-s.clientTop,left:n.left+(null!==(o=null==a?void 0:a.scrollX)&&void 0!==o?o:0)-s.clientLeft}},zN=(e,t)=>{return o=(e=>e.inline?FN(e.getBody()):{left:0,top:0})(e),n=(e=>{const t=e.getBody();return e.inline?{left:t.scrollLeft,top:t.scrollTop}:{left:0,top:0}})(e),r=((e,t)=>{if(t.target.ownerDocument!==e.getDoc()){const o=FN(e.getContentAreaContainer()),n=(e=>{const t=e.getBody(),o=e.getDoc().documentElement,n={left:t.scrollLeft,top:t.scrollTop},r={left:t.scrollLeft||o.scrollLeft,top:t.scrollTop||o.scrollTop};return e.inline?n:r})(e);return{left:t.pageX-o.left+n.left,top:t.pageY-o.top+n.top}}return{left:t.pageX,top:t.pageY}})(e,t),{pageX:r.left-o.left+n.left,pageY:r.top-o.top+n.top};var o,n,r},VN=e=>({target:e,srcElement:e}),ZN=(e,t,o,n)=>{const r=((e,t)=>{const o=EM(e);return"dragstart"===t?(cM(o),vM(o)):"drop"===t?(dM(o),bM(o)):(mM(o),yM(o)),o})(o,e);return w(n)?((e,t,o)=>{const n=B("Function not supported on simulated event.");return{bubbles:!0,cancelBubble:!1,cancelable:!0,composed:!1,currentTarget:null,defaultPrevented:!1,eventPhase:0,isTrusted:!0,returnValue:!1,timeStamp:0,type:e,composedPath:n,initEvent:n,preventDefault:E,stopImmediatePropagation:E,stopPropagation:E,AT_TARGET:window.Event.AT_TARGET,BUBBLING_PHASE:window.Event.BUBBLING_PHASE,CAPTURING_PHASE:window.Event.CAPTURING_PHASE,NONE:window.Event.NONE,altKey:!1,button:0,buttons:0,clientX:0,clientY:0,ctrlKey:!1,metaKey:!1,movementX:0,movementY:0,offsetX:0,offsetY:0,pageX:0,pageY:0,relatedTarget:null,screenX:0,screenY:0,shiftKey:!1,x:0,y:0,detail:0,view:null,which:0,initUIEvent:n,initMouseEvent:n,getModifierState:n,dataTransfer:o,...VN(t)}})(e,t,r):((e,t,o,n)=>({...t,dataTransfer:n,type:e,...VN(o)}))(e,n,t,r)},UN=dr,jN=((...e)=>t=>{for(let o=0;o{const r=e.dom,s=t.cloneNode(!0);r.setStyles(s,{width:o,height:n}),r.setAttrib(s,"data-mce-selected",null);const a=r.create("div",{class:"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return r.setStyles(a,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:o,height:n}),r.setStyles(s,{margin:0,boxSizing:"border-box"}),a.appendChild(s),a},$N=(e,t)=>o=>()=>{const n="left"===e?o.scrollX:o.scrollY;o.scroll({[e]:n+t,behavior:"smooth"})},qN=$N("left",-32),GN=$N("left",32),KN=$N("top",-32),YN=$N("top",32),XN=e=>{e&&e.parentNode&&e.parentNode.removeChild(e)},JN=(e,t)=>o=>{if((e=>0===e.button)(o)){const n=ee(t.dom.getParents(o.target),jN).getOr(null);if(C(n)&&((e,t,o)=>UN(o)&&o!==t&&e.isEditable(o.parentElement))(t.dom,t.getBody(),n)){const r=t.dom.getPos(n),s=t.getBody(),a=t.getDoc().documentElement;e.set({element:n,dataTransfer:_M(),dragging:!1,screenX:o.screenX,screenY:o.screenY,maxX:(t.inline?s.scrollWidth:a.offsetWidth)-2,maxY:(t.inline?s.scrollHeight:a.offsetHeight)-2,relX:o.pageX-r.x,relY:o.pageY-r.y,width:n.offsetWidth,height:n.offsetHeight,ghost:WN(t,n,n.offsetWidth,n.offsetHeight),intervalId:si(100)})}}},QN=(e,t,o,n,r)=>{"dragstart"===t&&TM(n,e.dom.getOuterHTML(o));const s=ZN(t,o,n,r);return e.dispatch(t,s)},eR=(e,t)=>{const o=ii(((e,o)=>((e,t,o)=>{e._selectionOverrides.hideFakeCaret(),PN(e.getBody(),t,o).fold((()=>e.selection.placeCaretAt(t,o)),(n=>{const r=e._selectionOverrides.showCaret(1,n.node,n.position===AN.Before,!1);r?e.selection.setRng(r):e.selection.placeCaretAt(t,o)}))})(t,e,o)),0);t.on("remove",o.cancel);const n=e;return r=>e.on((e=>{const s=Math.max(Math.abs(r.screenX-e.screenX),Math.abs(r.screenY-e.screenY));if(!e.dragging&&s>10){const o=QN(t,"dragstart",e.element,e.dataTransfer,r);if(C(o.dataTransfer)&&(e.dataTransfer=o.dataTransfer),o.isDefaultPrevented())return;e.dragging=!0,t.focus()}if(e.dragging){const s=r.currentTarget===t.getDoc().documentElement,l=((e,t)=>({pageX:t.pageX-e.relX,pageY:t.pageY+5}))(e,zN(t,r));a=e.ghost,i=t.getBody(),a.parentNode!==i&&i.appendChild(a),((e,t,o,n,r,s,a,i,l,c,d,m)=>{let u=0,g=0;e.style.left=t.pageX+"px",e.style.top=t.pageY+"px",t.pageX+o>r&&(u=t.pageX+o-r),t.pageY+n>s&&(g=t.pageY+n-s),e.style.width=o-u+"px",e.style.height=n-g+"px";const h=l.clientHeight,p=l.clientWidth,f=a+l.getBoundingClientRect().top,v=i+l.getBoundingClientRect().left;d.on((e=>{e.intervalId.clear(),e.dragging&&m&&(a+8>=h?e.intervalId.set(YN(c)):a-8<=0?e.intervalId.set(KN(c)):i+8>=p?e.intervalId.set(GN(c)):i-8<=0?e.intervalId.set(qN(c)):f+16>=window.innerHeight?e.intervalId.set(YN(window)):f-16<=0?e.intervalId.set(KN(window)):v+16>=window.innerWidth?e.intervalId.set(GN(window)):v-16<=0&&e.intervalId.set(qN(window)))}))})(e.ghost,l,e.width,e.height,e.maxX,e.maxY,r.clientY,r.clientX,t.getContentAreaContainer(),t.getWin(),n,s),o.throttle(r.clientX,r.clientY)}var a,i}))},tR=(e,t)=>o=>{e.on((e=>{var n;if(e.intervalId.clear(),e.dragging){if(((e,t,o)=>!x(t)&&t!==o&&!e.dom.isChildOf(t,o)&&e.dom.isEditable(t))(t,(e=>{const t=e.getSel();if(C(t)){const e=t.getRangeAt(0).startContainer;return tr(e)?e.parentNode:e}return null})(t.selection),e.element)){const r=null!==(n=t.getDoc().elementFromPoint(o.clientX,o.clientY))&&void 0!==n?n:t.getBody();QN(t,"drop",r,e.dataTransfer,o).isDefaultPrevented()||t.undoManager.transact((()=>{((e,t)=>{const o=e.getParent(t.parentNode,e.isBlock);XN(t),o&&o!==e.getRoot()&&e.isEmpty(o)&&Rr(yo.fromDom(o))})(t.dom,e.element),(e=>{const t=e.getData("text/html");return""===t?F.none():F.some(t)})(e.dataTransfer).each((e=>t.insertContent(e))),t._selectionOverrides.hideFakeCaret()}))}QN(t,"dragend",t.getBody(),e.dataTransfer,o)}})),nR(e)},oR=(e,t,o)=>{e.on((e=>{e.intervalId.clear(),e.dragging&&o.fold((()=>QN(t,"dragend",e.element,e.dataTransfer)),(o=>QN(t,"dragend",e.element,e.dataTransfer,o)))})),nR(e)},nR=e=>{e.on((e=>{e.intervalId.clear(),XN(e.ghost)})),e.clear()},rR=e=>{const t=ai(),o=Ya.DOM,n=document,r=JN(t,e),s=eR(t,e),a=tR(t,e),i=((e,t)=>o=>oR(e,t,F.some(o)))(t,e);e.on("mousedown",r),e.on("mousemove",s),e.on("mouseup",a),o.bind(n,"mousemove",s),o.bind(n,"mouseup",i),e.on("remove",(()=>{o.unbind(n,"mousemove",s),o.unbind(n,"mouseup",i)})),e.on("keydown",(o=>{o.keyCode===Dg.ESC&&oR(t,e,F.none())}))},sR=e=>{rR(e),Xc(e)&&(e=>{const t=t=>{if(!t.isDefaultPrevented()){const o=t.dataTransfer;o&&(j(o.types,"Files")||o.files.length>0)&&(t.preventDefault(),"drop"===t.type&&gS(e,"Dropped file type is not supported"))}},o=o=>{Jh(e,o.target)&&t(o)},n=()=>{const n=Ya.DOM,r=e.dom,s=document,a=e.inline?e.getBody():e.getDoc(),i=["drop","dragover"];q(i,(e=>{n.bind(s,e,o),r.bind(a,e,t)})),e.on("remove",(()=>{q(i,(e=>{n.unbind(s,e,o),r.unbind(a,e,t)}))}))};e.on("init",(()=>{qh.setEditorTimeout(e,n,0)}))})(e)},aR=dr,iR=(e,t)=>tb(e.getBody(),t),lR=e=>{const t=e.selection,o=e.dom,n=e.getBody(),r=Kd(e,n,o.isBlock,(()=>ap(e))),s="sel-"+o.uniqueId(),a="data-mce-selected";let i;const l=e=>e!==n&&(aR(e)||gr(e))&&o.isChildOf(e,n)&&o.isEditable(e.parentNode),c=(o,n,s,a=!0)=>e.dispatch("ShowCaret",{target:n,direction:o,before:s}).isDefaultPrevented()?null:(a&&t.scrollIntoView(n,-1===o),r.show(s,n)),d=()=>{e.on("click",(t=>{o.isEditable(t.target)||(t.preventDefault(),e.focus())})),e.on("blur NewBlock",f),e.on("ResizeWindow FullscreenStateChanged",r.reposition),e.on("tap",(t=>{const o=t.target,n=iR(e,o);aR(n)?(t.preventDefault(),uk(e,n).each(p)):l(o)&&uk(e,o).each(p)}),!0),e.on("mousedown",(r=>{const s=r.target;if(s!==n&&"HTML"!==s.nodeName&&!o.isChildOf(s,n))return;if(!aS(e,r.clientX,r.clientY))return;f(),v();const a=iR(e,s);aR(a)?(r.preventDefault(),uk(e,a).each(p)):PN(n,r.clientX,r.clientY).each((o=>{r.preventDefault(),(e=>{e&&t.setRng(e)})(c(1,o.node,o.position===AN.Before,!1)),$n(a)?a.focus():e.getBody().focus()}))})),e.on("keypress",(e=>{Dg.modifierPressed(e)||aR(t.getNode())&&e.preventDefault()})),e.on("GetSelectionRange",(e=>{let t=e.range;if(i){if(!i.parentNode)return void(i=null);t=t.cloneRange(),t.selectNode(i),e.range=t}})),e.on("SetSelectionRange",(e=>{e.range=g(e.range);const t=p(e.range,e.forward);t&&(e.range=t)})),e.on("AfterSetSelectionRange",(e=>{const t=e.range,n=t.startContainer.parentElement;var r;u(t)||Wn(r=n)&&"mcepastebin"===r.id||v(),(e=>C(e)&&o.hasClass(e,"mce-offscreen-selection"))(n)||f()})),sR(e),(e=>{const t=ii((()=>{if(!e.removed&&e.getBody().contains(document.activeElement)){const t=e.selection.getRng();if(t.collapsed){const o=gk(e,t,!1);e.selection.setRng(o)}}}),0);e.on("focus",(()=>{t.throttle()})),e.on("blur",(()=>{t.cancel()}))})(e),(e=>{e.on("init",(()=>{e.on("focusin",(t=>{const o=t.target;if(gr(o)){const t=tb(e.getBody(),o),n=dr(t)?t:o;e.selection.getNode()!==n&&uk(e,n).each((t=>e.selection.setRng(t)))}}))}))})(e)},m=e=>Vr(e)||Wr(e)||$r(e),u=e=>m(e.startContainer)||m(e.endContainer),g=t=>{const n=e.schema.getVoidElements(),r=o.createRng(),s=t.startContainer,a=t.startOffset,i=t.endContainer,l=t.endOffset;return _e(n,s.nodeName.toLowerCase())?0===a?r.setStartBefore(s):r.setStartAfter(s):r.setStart(s,a),_e(n,i.nodeName.toLowerCase())?0===l?r.setEndBefore(i):r.setEndAfter(i):r.setEnd(i,l),r},h=n=>{const r=n.cloneNode(!0),l=e.dispatch("ObjectSelected",{target:n,targetClone:r});if(l.isDefaultPrevented())return null;const c=((n,r)=>{const a=yo.fromDom(e.getBody()),i=e.getDoc(),l=tn(a,"#"+s).getOrThunk((()=>{const e=yo.fromHtml('
    ',i);return eo(e,"id",s),bn(a,e),e})),c=o.createRng();xn(l),wn(l,[yo.fromText(br,i),yo.fromDom(r),yo.fromText(br,i)]),c.setStart(l.dom.firstChild,1),c.setEnd(l.dom.lastChild,0),cn(l,{top:o.getPos(n,e.getBody()).y+"px"}),Bh(l);const d=t.getSel();return d&&(d.removeAllRanges(),d.addRange(c)),c})(n,l.targetClone),d=yo.fromDom(n);return q(zn(yo.fromDom(e.getBody()),`*[${a}]`),(e=>{So(d,e)||so(e,a)})),o.getAttrib(n,a)||n.setAttribute(a,"1"),i=n,v(),c},p=(e,t)=>{if(!e)return null;if(e.collapsed){if(!u(e)){const r=t?1:-1,s=Cm(r,n,e),a=s.getNode(!t);if(C(a)){if(Jd(a))return c(r,a,!!t&&!s.isAtEnd(),!1);if(zr(a)&&dr(a.nextSibling)){const e=o.createRng();return e.setStart(a,0),e.setEnd(a,0),e}}const i=s.getNode(t);if(C(i)){if(Jd(i))return c(r,i,!t&&!s.isAtEnd(),!1);if(zr(i)&&dr(i.previousSibling)){const e=o.createRng();return e.setStart(i,1),e.setEnd(i,1),e}}}return null}let r=e.startContainer,s=e.startOffset;const a=e.endOffset;if(tr(r)&&0===s&&aR(r.parentNode)&&(r=r.parentNode,s=o.nodeIndex(r),r=r.parentNode),!Wn(r))return null;if(a===s+1&&r===e.endContainer){const e=r.childNodes[s];if(l(e))return h(e)}return null},f=()=>{i&&i.removeAttribute(a),tn(yo.fromDom(e.getBody()),"#"+s).each(Cn),i=null},v=()=>{r.hide()};return fC(e)||d(),{showCaret:c,showBlockCaretContainer:e=>{e.hasAttribute("data-mce-caret")&&(qr(e),t.scrollIntoView(e))},hideFakeCaret:v,destroy:()=>{r.destroy(),i=null}}},cR=(e,t)=>{let o=t;for(let t=e.previousSibling;tr(t);t=t.previousSibling)o+=t.data.length;return o},dR=(e,t,o,n,r)=>{if(tr(o)&&(n<0||n>o.data.length))return[];const s=r&&tr(o)?[cR(o,n)]:[n];let a=o;for(;a!==t&&a.parentNode;)s.push(e.nodeIndex(a,r)),a=a.parentNode;return a===t?s.reverse():[]},mR=(e,t,o,n,r,s,a=!1)=>({start:dR(e,t,o,n,a),end:dR(e,t,r,s,a)}),uR=(e,t)=>{const o=t.slice(),n=o.pop();return k(n)?J(o,((e,t)=>e.bind((e=>F.from(e.childNodes[t])))),F.some(e)).bind((e=>tr(e)&&(n<0||n>e.data.length)?F.none():F.some({node:e,offset:n}))):F.none()},gR=(e,t)=>uR(e,t.start).bind((({node:o,offset:n})=>uR(e,t.end).map((({node:e,offset:t})=>{const r=document.createRange();return r.setStart(o,n),r.setEnd(e,t),r})))),hR=(e,t,o)=>{if(t&&e.isEmpty(t)&&!o(t)){const n=t.parentNode;e.remove(t,tr(t.firstChild)&&is(t.firstChild.data)),hR(e,n,o)}},pR=(e,t,o,n=!0)=>{const r=t.startContainer.parentNode,s=t.endContainer.parentNode;t.deleteContents(),n&&!o(t.startContainer)&&(tr(t.startContainer)&&0===t.startContainer.data.length&&e.remove(t.startContainer),tr(t.endContainer)&&0===t.endContainer.data.length&&e.remove(t.endContainer),hR(e,r,o),r!==s&&hR(e,s,o))},fR=(e,t)=>F.from(e.dom.getParent(t.startContainer,e.dom.isBlock)),vR=(e,t,o)=>{const n=e.dynamicPatternsLookup({text:o,block:t});return{...e,blockPatterns:Bl(n).concat(e.blockPatterns),inlinePatterns:Ll(n).concat(e.inlinePatterns)}},bR=(e,t,o,n)=>{const r=e.createRng();return r.setStart(t,0),r.setEnd(o,n),r.toString()},yR=(e,t,o)=>{const n=((e,t,o)=>{if(tr(e)&&t>=e.length)return F.some(VT(e,t));{const n=Oi(ZT);return F.from(n.forwards(e,t,UT(e),o)).map((e=>VT(e.container,0)))}})(t,0,t);n.each((n=>{const r=n.container;$T(r,o.start.length,t).each((o=>{const n=e.createRng();n.setStart(r,0),n.setEnd(o.container,o.offset),pR(e,n,(e=>e===t))}));const s=yo.fromDom(r),a=xr(s);/^\s[^\s]/.test(a)&&((e,t)=>{wr.set(e,t)})(s,a.slice(1))}))},wR=(e,t)=>{const o=e.dom,n=t.pattern,r=gR(o.getRoot(),t.range).getOrDie("Unable to resolve path range");return fR(e,r).each((t=>{"block-format"===n.type?((e,t)=>{const o=t.get(e);return v(o)&&de(o).exists((e=>_e(e,"block")))})(n.format,e.formatter)&&e.undoManager.transact((()=>{yR(e.dom,t,n),e.formatter.apply(n.format)})):"block-command"===n.type&&e.undoManager.transact((()=>{yR(e.dom,t,n),e.execCommand(n.cmd,!1,n.value)}))})),!0},xR=(e,t)=>{const o=(e=>le(e,((e,t)=>t.start.length-e.start.length)))(e),n=t.replace(br," ");return ee(o,(e=>0===t.indexOf(e.start)||0===n.indexOf(e.start)))},CR=(e,t)=>e.create("span",{"data-mce-type":"bookmark",id:t}),SR=(e,t)=>{const o=e.createRng();return o.setStartAfter(t.start),o.setEndBefore(t.end),o},kR=(e,t,o)=>{const n=gR(e.getRoot(),o).getOrDie("Unable to resolve path range"),r=n.startContainer,s=n.endContainer,a=0===n.endOffset?s:s.splitText(n.endOffset),i=0===n.startOffset?r:r.splitText(n.startOffset),l=i.parentNode;return{prefix:t,end:a.parentNode.insertBefore(CR(e,t+"-end"),a),start:l.insertBefore(CR(e,t+"-start"),i)}},_R=(e,t,o)=>{hR(e,e.get(t.prefix+"-end"),o),hR(e,e.get(t.prefix+"-start"),o)},ER=e=>0===e.start.length,TR=(e,t,o,n)=>{const r=t.start;var s;return qT(e,n.container,n.offset,(s=r,(e,t)=>{const o=e.data.substring(0,t),n=o.lastIndexOf(s.charAt(s.length-1)),r=o.lastIndexOf(s);return-1!==r?r+s.length:-1!==n?n+1:-1}),o).bind((n=>{var s,a;const i=null!==(a=null===(s=o.textContent)||void 0===s?void 0:s.indexOf(r))&&void 0!==a?a:-1;if(-1!==i&&n.offset>=i+r.length){const t=e.createRng();return t.setStart(n.container,n.offset-r.length),t.setEnd(n.container,n.offset),F.some(t)}{const s=n.offset-r.length;return WT(n.container,s,o).map((t=>{const o=e.createRng();return o.setStart(t.container,t.offset),o.setEnd(n.container,n.offset),o})).filter((e=>e.toString()===r)).orThunk((()=>TR(e,t,o,VT(n.container,0))))}}))},OR=(e,t,o,n)=>{const r=e.dom,s=r.getRoot(),a=o.pattern,i=o.position.container,l=o.position.offset;return WT(i,l-o.pattern.end.length,t).bind((c=>{const d=mR(r,s,c.container,c.offset,i,l,n);if(ER(a))return F.some({matches:[{pattern:a,startRng:d,endRng:d}],position:c});{const i=DR(e,o.remainingPatterns,c.container,c.offset,t,n),l=i.getOr({matches:[],position:c}),m=l.position,u=((e,t,o,n,r,s=!1)=>{if(0===t.start.length&&!s){const t=e.createRng();return t.setStart(o,n),t.setEnd(o,n),F.some(t)}return jT(o,n,r).bind((o=>TR(e,t,r,o).bind((e=>{var t;if(s){if(e.endContainer===o.container&&e.endOffset===o.offset)return F.none();if(0===o.offset&&(null===(t=e.endContainer.textContent)||void 0===t?void 0:t.length)===e.endOffset)return F.none()}return F.some(e)}))))})(r,a,m.container,m.offset,t,i.isNone());return u.map((e=>{const t=((e,t,o,n=!1)=>mR(e,t,o.startContainer,o.startOffset,o.endContainer,o.endOffset,n))(r,s,e,n);return{matches:l.matches.concat([{pattern:a,startRng:t,endRng:d}]),position:VT(e.startContainer,e.startOffset)}}))}}))},DR=(e,t,o,n,r,s)=>{const a=e.dom;return jT(o,n,a.getRoot()).bind((i=>{const l=bR(a,r,o,n);for(let a=0;a0)return DR(e,t,o,n-1,r,s);if(m.isSome())return m}return F.none()}))},AR=(e,t,o)=>{e.selection.setRng(o),"inline-format"===t.type?q(t.format,(t=>{e.formatter.apply(t)})):e.execCommand(t.cmd,!1,t.value)},MR=(e,t,o,n,r,s)=>{var a;return((e,t)=>{const o=re(e,(e=>W(t,(t=>e.pattern.start===t.pattern.start&&e.pattern.end===t.pattern.end))));return e.length===t.length?o?e:t:e.length>t.length?e:t})(DR(e,r.inlinePatterns,o,n,t,s).fold((()=>[]),(e=>e.matches)),DR(e,(a=r.inlinePatterns,le(a,((e,t)=>t.end.length-e.end.length))),o,n,t,s).fold((()=>[]),(e=>e.matches)))},NR=(e,t)=>{if(0===t.length)return;const o=e.dom,n=e.selection.getBookmark(),r=((e,t)=>{const o=Ci("mce_textpattern"),n=X(t,((t,n)=>{const r=kR(e,o+`_end${t.length}`,n.endRng);return t.concat([{...n,endMarker:r}])}),[]);return X(n,((t,r)=>{const s=n.length-t.length-1,a=ER(r.pattern)?r.endMarker:kR(e,o+`_start${s}`,r.startRng);return t.concat([{...r,startMarker:a}])}),[])})(o,t);q(r,(t=>{const n=o.getParent(t.startMarker.start,o.isBlock),r=e=>e===n;ER(t.pattern)?((e,t,o,n)=>{const r=SR(e.dom,o);pR(e.dom,r,n),AR(e,t,r)})(e,t.pattern,t.endMarker,r):((e,t,o,n,r)=>{const s=e.dom,a=SR(s,n),i=SR(s,o);pR(s,i,r),pR(s,a,r);const l={prefix:o.prefix,start:o.end,end:n.start},c=SR(s,l);AR(e,t,c)})(e,t.pattern,t.startMarker,t.endMarker,r),_R(o,t.endMarker,r),_R(o,t.startMarker,r)})),e.selection.moveToBookmark(n)},RR=(e,t)=>{const o=e.selection.getRng();return fR(e,o).map((n=>{var r;const s=Math.max(0,o.startOffset),a=vR(t,n,null!==(r=n.textContent)&&void 0!==r?r:""),i=MR(e,n,o.startContainer,s,a,!0),l=((e,t,o,n)=>{var r;const s=e.dom,a=Xl(e);if(!s.is(t,a))return[];const i=null!==(r=t.textContent)&&void 0!==r?r:"";return xR(o.blockPatterns,i).map((e=>Bt.trim(i).length===e.start.length?[]:[{pattern:e,range:mR(s,s.getRoot(),t,0,t,0,n)}])).getOr([])})(e,n,a,!0);return(l.length>0||i.length>0)&&(e.undoManager.add(),e.undoManager.extra((()=>{e.execCommand("mceInsertNewLine")}),(()=>{(e=>{e.insertContent(Br,{preserve_zwsp:!0})})(e),NR(e,i),((e,t)=>{if(0===t.length)return;const o=e.selection.getBookmark();q(t,(t=>wR(e,t))),e.selection.moveToBookmark(o)})(e,l);const t=e.selection.getRng(),o=jT(t.startContainer,t.startOffset,e.dom.getRoot());e.execCommand("mceInsertNewLine"),o.each((t=>{const o=t.container;o.data.charAt(t.offset-1)===vr&&(o.deleteData(t.offset-1,1),hR(e.dom,o.parentNode,(t=>t===e.dom.getRoot())))}))})),!0)})).getOr(!1)},BR=(e,t,o)=>{for(let n=0;n{const t=[",",".",";",":","!","?"],o=[32],n=()=>{return t=wd(e),o=xd(e),{inlinePatterns:Ll(t),blockPatterns:Bl(t),dynamicPatternsLookup:o};var t,o},r=()=>(e=>e.options.isSet("text_patterns_lookup"))(e);e.on("keydown",(t=>{if(13===t.keyCode&&!Dg.modifierPressed(t)&&e.selection.isCollapsed()){const o=n();(o.inlinePatterns.length>0||o.blockPatterns.length>0||r())&&RR(e,o)&&t.preventDefault()}}),!0);const s=()=>{if(e.selection.isCollapsed()){const t=n();(t.inlinePatterns.length>0||r())&&((e,t)=>{const o=e.selection.getRng();fR(e,o).map((n=>{const r=Math.max(0,o.startOffset-1),s=bR(e.dom,n,o.startContainer,r),a=vR(t,n,s),i=MR(e,n,o.startContainer,r,a,!1);i.length>0&&e.undoManager.transact((()=>{NR(e,i)}))}))})(e,t)}};e.on("keyup",(e=>{BR(o,e,((e,t)=>e===t.keyCode&&!Dg.modifierPressed(t)))&&s()})),e.on("keypress",(o=>{BR(t,o,((e,t)=>e.charCodeAt(0)===t.charCode))&&qh.setEditorTimeout(e,s)}))},HR=e=>{const t=Bt.each,o=Dg.BACKSPACE,n=Dg.DELETE,r=e.dom,s=e.selection,a=e.parser,i=At.browser,l=i.isFirefox(),c=i.isChromium()||i.isSafari(),d=At.deviceType.isiPhone()||At.deviceType.isiPad(),m=At.os.isMacOS()||At.os.isiOS(),u=(t,o)=>{try{e.getDoc().execCommand(t,!1,String(o))}catch(e){}},g=e=>e.isDefaultPrevented(),p=()=>{const t=e=>{const t=r.create("body"),o=e.cloneContents();return t.appendChild(o),s.serializer.serialize(t,{format:"html"})};e.on("keydown",(s=>{const a=s.keyCode;if(!g(s)&&(a===n||a===o)&&e.selection.isEditable()){const o=e.selection.isCollapsed(),n=e.getBody();if(o&&!ys(yo.fromDom(n)))return;if(!o&&!(o=>{const n=t(o),s=r.createRng();return s.selectNode(e.getBody()),n===t(s)})(e.selection.getRng()))return;s.preventDefault(),e.setContent(""),n.firstChild&&r.isBlock(n.firstChild)?e.selection.setCursorLocation(n.firstChild,0):e.selection.setCursorLocation(n,0),e.nodeChanged()}}))},f=()=>{e.shortcuts.add("meta+a",null,"SelectAll")},v=()=>{e.inline||r.bind(e.getDoc(),"mousedown mouseup",(t=>{let o;if(t.target===e.getDoc().documentElement)if(o=s.getRng(),e.getBody().focus(),"mousedown"===t.type){if(Vr(o.startContainer))return;s.placeCaretAt(t.clientX,t.clientY)}else s.setRng(o)}))},b=()=>{Range.prototype.getClientRects||e.on("mousedown",(t=>{if(!g(t)&&"HTML"===t.target.nodeName){const t=e.getBody();t.blur(),qh.setEditorTimeout(e,(()=>{t.focus()}))}}))},y=()=>{const t=ed(e);e.on("click",(o=>{const n=o.target;/^(IMG|HR)$/.test(n.nodeName)&&r.isEditable(n)&&(o.preventDefault(),e.selection.select(n),e.nodeChanged()),"A"===n.nodeName&&r.hasClass(n,t)&&0===n.childNodes.length&&r.isEditable(n.parentNode)&&(o.preventDefault(),s.select(n))}))},w=()=>{e.on("keydown",(e=>{if(!g(e)&&e.keyCode===o&&s.isCollapsed()&&0===s.getRng().startOffset){const t=s.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}return!0}))},x=()=>{const t=()=>{u("StyleWithCSS",!1),u("enableInlineTableEditing",!1),kc(e)||u("enableObjectResizing",!1)};$c(e)||e.on("BeforeExecCommand mousedown",t)},C=()=>{e.on("SetContent ExecCommand",(e=>{"setcontent"!==e.type&&"mceInsertLink"!==e.command||t(r.select("a:not([data-mce-block])"),(e=>{var t;let o=e.parentNode;const n=r.getRoot();if((null==o?void 0:o.lastChild)===e){for(;o&&!r.isBlock(o);){if((null===(t=o.parentNode)||void 0===t?void 0:t.lastChild)!==o||o===n)return;o=o.parentNode}r.add(o,"br",{"data-mce-bogus":1})}}))}))},S=()=>{e.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")},k=()=>{e.inline||e.on("keydown",(()=>{document.activeElement===document.body&&e.getWin().focus()}))},_=()=>{e.inline||(e.contentStyles.push("body {min-height: 150px}"),e.on("click",(t=>{let o;"HTML"===t.target.nodeName&&(o=e.selection.getRng(),e.getBody().focus(),e.selection.setRng(o),e.selection.normalize(),e.nodeChanged())})))},T=()=>{m&&e.on("keydown",(t=>{!Dg.metaKeyPressed(t)||t.shiftKey||37!==t.keyCode&&39!==t.keyCode||(t.preventDefault(),e.selection.getSel().modify("move",37===t.keyCode?"backward":"forward","lineboundary"))}))},O=()=>{e.on("click",(e=>{let t=e.target;do{if("A"===t.tagName)return void e.preventDefault()}while(t=t.parentNode)})),e.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")},D=()=>{e.on("init",(()=>{e.dom.bind(e.getBody(),"submit",(e=>{e.preventDefault()}))}))},A=E,M=()=>{e.on("keydown",(t=>{if(g(t)||t.keyCode!==Dg.BACKSPACE)return;let o=s.getRng();const n=o.startContainer,a=o.startOffset,i=r.getRoot();let l=n;if(o.collapsed&&0===a){for(;l.parentNode&&l.parentNode.firstChild===l&&l.parentNode!==i;)l=l.parentNode;"BLOCKQUOTE"===l.nodeName&&(e.formatter.toggle("blockquote",void 0,l),o=r.createRng(),o.setStart(n,0),o.setEnd(n,0),s.setRng(o))}})),p(),At.windowsPhone||e.on("keyup focusin mouseup",(t=>{Dg.modifierPressed(t)||(e=>{const t=e.getBody(),o=e.selection.getRng();return o.startContainer===o.endContainer&&o.startContainer===t&&0===o.startOffset&&o.endOffset===t.childNodes.length})(e)||s.normalize()}),!0),c&&(v(),y(),e.on("init",(()=>{u("DefaultParagraphSeparator",Xl(e))})),D(),w(),a.addNodeFilter("br",(e=>{let t=e.length;for(;t--;)"Apple-interchange-newline"===e[t].attr("class")&&e[t].remove()})),d?(k(),_(),O()):f()),l&&(e.on("keydown",(t=>{if(!g(t)&&t.keyCode===o){if(!e.getBody().getElementsByTagName("hr").length)return;if(s.isCollapsed()&&0===s.getRng().startOffset){const e=s.getNode(),o=e.previousSibling;if("HR"===e.nodeName)return r.remove(e),void t.preventDefault();o&&o.nodeName&&"hr"===o.nodeName.toLowerCase()&&(r.remove(o),t.preventDefault())}}})),b(),(()=>{const o=()=>{const o=r.getAttribs(s.getStart().cloneNode(!1));return()=>{const n=s.getStart();n!==e.getBody()&&(r.setAttrib(n,"style",null),t(o,(e=>{n.setAttributeNode(e.cloneNode(!0))})))}},n=()=>!s.isCollapsed()&&r.getParent(s.getStart(),r.isBlock)!==r.getParent(s.getEnd(),r.isBlock);e.on("keypress",(t=>{let r;return!(!(g(t)||8!==t.keyCode&&46!==t.keyCode)&&n()&&(r=o(),e.getDoc().execCommand("delete",!1),r(),t.preventDefault(),1))})),r.bind(e.getDoc(),"cut",(t=>{if(!g(t)&&n()){const t=o();qh.setEditorTimeout(e,(()=>{t()}))}}))})(),x(),C(),S(),T(),w(),e.on("drop",(t=>{var o;const n=null===(o=t.dataTransfer)||void 0===o?void 0:o.getData("text/html");h(n)&&/^]*>$/.test(n)&&e.dispatch("dragend",new window.DragEvent("dragend",t))})))};return fC(e)?(c&&(v(),y(),D(),f(),d&&(k(),_(),O())),l&&(b(),x(),S(),T())):M(),{refreshContentEditable:A,isHidden:()=>{if(!l||e.removed)return!1;const t=e.selection.getSel();return!t||!t.rangeCount||0===t.rangeCount}}},IR=Ya.DOM,PR=e=>e.inline?e.getElement().nodeName.toLowerCase():void 0,FR=e=>xe(e,(e=>!1===w(e))),zR=e=>{const t=e.options.get,o=e.editorUpload.blobCache;return FR({allow_conditional_comments:t("allow_conditional_comments"),allow_html_data_urls:t("allow_html_data_urls"),allow_svg_data_urls:t("allow_svg_data_urls"),allow_html_in_named_anchor:t("allow_html_in_named_anchor"),allow_script_urls:t("allow_script_urls"),allow_unsafe_link_target:t("allow_unsafe_link_target"),convert_unsafe_embeds:t("convert_unsafe_embeds"),convert_fonts_to_spans:t("convert_fonts_to_spans"),fix_list_elements:t("fix_list_elements"),font_size_legacy_values:t("font_size_legacy_values"),forced_root_block:t("forced_root_block"),forced_root_block_attrs:t("forced_root_block_attrs"),preserve_cdata:t("preserve_cdata"),inline_styles:t("inline_styles"),root_name:PR(e),sandbox_iframes:t("sandbox_iframes"),sanitize:t("xss_sanitization"),validate:!0,blob_cache:o,document:e.getDoc()})},VR=e=>{const t=e.options.get;return FR({custom_elements:t("custom_elements"),extended_valid_elements:t("extended_valid_elements"),invalid_elements:t("invalid_elements"),invalid_styles:t("invalid_styles"),schema:t("schema"),valid_children:t("valid_children"),valid_classes:t("valid_classes"),valid_elements:t("valid_elements"),valid_styles:t("valid_styles"),verify_html:t("verify_html"),padd_empty_block_inline_children:t("format_empty_lines")})},ZR=e=>{e.bindPendingEventDelegates(),e.initialized=!0,(e=>{e.dispatch("Init")})(e),e.focus(!0),(e=>{const t=e.dom.getRoot();e.inline||_u(e)&&e.selection.getStart(!0)!==t||Gm(t).each((t=>{const o=t.getNode(),n=Jn(o)?Gm(o).getOr(t):t;e.selection.setRng(n.toRange())}))})(e),e.nodeChanged({initial:!0});const t=nd(e);S(t)&&t.call(e,e),(e=>{const t=sd(e);t&&qh.setEditorTimeout(e,(()=>{let o;o=!0===t?e:e.editorManager.get(t),o&&!o.destroyed&&(o.focus(),o.selection.scrollIntoView())}),100)})(e)},UR=e=>e.inline?e.ui.styleSheetLoader:e.dom.styleSheetLoader,jR=e=>{const t=UR(e),o=xc(e),n=e.contentCSS,r=()=>{t.unloadAll(n),e.inline||e.ui.styleSheetLoader.unloadAll(o)},s=()=>{e.removed?r():e.on("remove",r)};if(e.contentStyles.length>0){let t="";Bt.each(e.contentStyles,(e=>{t+=e+"\r\n"})),e.dom.addStyle(t)}const a=Promise.all(((e,t,o)=>{const{pass:n,fail:r}=K(t,(e=>tinymce.Resource.has(vS(e)))),s=n.map((t=>{const o=tinymce.Resource.get(vS(t));return h(o)?Promise.resolve(UR(e).loadRawCss(t,o)):Promise.resolve()})),a=[...s,UR(e).loadAll(r)];return e.inline?a:a.concat([e.ui.styleSheetLoader.loadAll(o)])})(e,n,o)).then(s).catch(s),i=wc(e);return i&&((e,t)=>{const o=yo.fromDom(e.getBody()),n=jo(Uo(o)),r=yo.fromTag("style");eo(r,"type","text/css"),bn(r,yo.fromText(t)),bn(n,r),e.on("remove",(()=>{Cn(r)}))})(e,i),a},WR=e=>{!0!==e.removed&&((e=>{fC(e)||e.load({initial:!0,format:"html"}),e.startContent=e.getContent({format:"raw"})})(e),ZR(e))},$R=e=>{const t=e.getElement();let o=e.getDoc();e.inline&&(IR.addClass(t,"mce-content-body"),e.contentDocument=o=document,e.contentWindow=window,e.bodyElement=t,e.contentAreaContainer=t);const n=e.getBody();n.disabled=!0,e.readonly=$c(e),e._editableRoot=qc(e),!e.readonly&&e.hasEditableRoot()&&(e.inline&&"static"===IR.getStyle(n,"position",!0)&&(n.style.position="relative"),n.contentEditable="true"),n.disabled=!1,e.editorUpload=OS(e),e.schema=ya(VR(e)),e.dom=Ya(o,{keep_values:!0,url_converter:e.convertURL,url_converter_scope:e,update_styles:!0,root_element:e.inline?e.getBody():null,collect:e.inline,schema:e.schema,contentCssCors:gc(e),referrerPolicy:hc(e),onSetAttrib:t=>{e.dispatch("SetAttrib",t)},force_hex_color:Rd(e)}),e.parser=(e=>{const t=Mx(zR(e),e.schema);return t.addAttributeFilter("src,href,style,tabindex",((t,o)=>{const n=e.dom,r="data-mce-"+o;let s=t.length;for(;s--;){const a=t[s];let i=a.attr(o);if(i&&!a.attr(r)){if(0===i.indexOf("data:")||0===i.indexOf("blob:"))continue;"style"===o?(i=n.serializeStyle(n.parseStyle(i),a.name),i.length||(i=null),a.attr(r,i),a.attr(o,i)):"tabindex"===o?(a.attr(r,i),a.attr(o,null)):a.attr(r,e.convertURL(i,o,a.name))}}})),t.addNodeFilter("script",(e=>{let t=e.length;for(;t--;){const o=e[t],n=o.attr("type")||"no/type";0!==n.indexOf("mce-")&&o.attr("type","mce-"+n)}})),_d(e)&&t.addNodeFilter("#cdata",(t=>{var o;let n=t.length;for(;n--;){const r=t[n];r.type=8,r.name="#comment",r.value="[CDATA["+e.dom.encode(null!==(o=r.value)&&void 0!==o?o:"")+"]]"}})),t.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",(t=>{let o=t.length;const n=e.schema.getNonEmptyElements();for(;o--;){const e=t[o];e.isEmpty(n)&&0===e.getAll("br").length&&e.append(new Ep("br",1))}})),t})(e),e.serializer=RC((e=>{const t=e.options.get;return{...zR(e),...VR(e),...FR({remove_trailing_brs:t("remove_trailing_brs"),pad_empty_with_br:t("pad_empty_with_br"),url_converter:t("url_converter"),url_converter_scope:t("url_converter_scope"),element_format:t("element_format"),entities:t("entities"),entity_encoding:t("entity_encoding"),indent:t("indent"),indent_after:t("indent_after"),indent_before:t("indent_before")})}})(e),e),e.selection=OC(e.dom,e.getWin(),e.serializer,e),e.annotator=wg(e),e.formatter=zS(e),e.undoManager=ZS(e),e._nodeChangeDispatcher=new sM(e),e._selectionOverrides=lR(e),NE(e),xN(e),VE(e),fC(e)||((e=>{e.on("mousedown",(t=>{t.detail>=3&&(t.preventDefault(),DN(e))}))})(e),(e=>{LR(e)})(e));const r=rM(e);AE(e,r),(e=>{e.on("NodeChange",N(IE,e))})(e),qS(e),wN(e);const s=vC(e);(e=>{const t=e.getDoc(),o=e.getBody();(e=>{e.dispatch("PreInit")})(e),ad(e)||(t.body.spellcheck=!1,IR.setAttrib(o,"spellcheck","false")),e.quirks=HR(e),(e=>{e.dispatch("PostRender")})(e);const n=Cc(e);void 0!==n&&(o.dir=n);const r=id(e);r&&e.on("BeforeSetContent",(e=>{Bt.each(r,(t=>{e.content=e.content.replace(t,(e=>"\x3c!--mce:protected "+escape(e)+"--\x3e"))}))})),e.on("SetContent",(()=>{e.addVisual(e.getBody())})),e.on("compositionstart compositionend",(t=>{e.composing="compositionstart"===t.type}))})(e),s.fold((()=>{const t=(e=>{let t=!1;const o=setTimeout((()=>{t||e.setProgressState(!0)}),500);return()=>{clearTimeout(o),t=!0,e.setProgressState(!1)}})(e);jR(e).then((()=>{WR(e),t()}))}),(t=>{e.setProgressState(!0),jR(e).then((()=>{t().then((t=>{e.setProgressState(!1),WR(e),wC(e)}),(t=>{e.notificationManager.open({type:"error",text:String(t)}),WR(e),wC(e)}))}))}))},qR=P,GR=Ya.DOM,KR=(e,t)=>{const o=e.translate("Rich Text Area"),n=no(yo.fromDom(e.getElement()),"tabindex").bind(Je),r=((e,t,o,n)=>{const r=yo.fromTag("iframe");return n.each((e=>eo(r,"tabindex",e))),to(r,o),to(r,{id:e+"_ifr",frameBorder:"0",allowTransparency:"true",title:t}),go(r,"tox-edit-area__iframe"),r})(e.id,o,jl(e),n).dom;r.onload=()=>{r.onload=null,e.dispatch("load")},e.contentAreaContainer=t.iframeContainer,e.iframeElement=r,e.iframeHTML=(e=>{let t=Wl(e)+"";$l(e)!==e.documentBaseUrl&&(t+=''),t+='';const o=ql(e),n=Gl(e),r=e.translate(td(e));return Kl(e)&&(t+=''),t+=`
    `,t})(e),GR.add(t.iframeContainer,r)},YR=e=>{const t=e.iframeElement,o=()=>{e.contentDocument=t.contentDocument,$R(e)};if(Od(e)||At.browser.isFirefox()){const t=e.getDoc();t.open(),t.write(e.iframeHTML),t.close(),o()}else{const r=(n=yo.fromDom(t),On(n,"load",qR,(()=>{r.unbind(),o()})));t.srcdoc=e.iframeHTML}var n},XR=Ya.DOM,JR=(e,t,o)=>{const n=cS.get(o),r=cS.urls[o]||e.documentBaseUrl.replace(/\/$/,"");if(o=Bt.trim(o),n&&-1===Bt.inArray(t,o)){if(e.plugins[o])return;try{const s=n(e,r)||{};e.plugins[o]=s,S(s.init)&&(s.init(e,r),t.push(o))}catch(t){((e,t,o)=>{const n=ni.translate(["Failed to initialize plugin: {0}",t]);Sg(e,"PluginLoadError",{message:n}),fS(n,o),gS(e,n)})(e,o,t)}}},QR=(e,t)=>({editorContainer:e,iframeContainer:t,api:{}}),eB=e=>{const t=e.getElement();return e.inline?QR(null):(e=>{const t=XR.create("div");return XR.insertAfter(t,e),QR(t,t)})(t)},tB=e=>{const t=e.getElement();return e.orgDisplay=t.style.display,h(Dc(e))?(e=>{const t=e.theme.renderUI;return t?t():eB(e)})(e):S(Dc(e))?(e=>{const t=e.getElement(),o=Dc(e)(e,t);return o.editorContainer.nodeType&&(o.editorContainer.id=o.editorContainer.id||e.id+"_parent"),o.iframeContainer&&o.iframeContainer.nodeType&&(o.iframeContainer.id=o.iframeContainer.id||e.id+"_iframecontainer"),o.height=o.iframeHeight?o.iframeHeight:t.offsetHeight,o})(e):eB(e)},oB=async e=>{e.dispatch("ScriptsLoaded"),(e=>{const t=Bt.trim(ic(e)),o=e.ui.registry.getAll().icons,n={...JC.get("default").icons,...JC.get(t).icons};fe(n,((t,n)=>{_e(o,n)||e.ui.registry.addIcon(n,t)}))})(e),(e=>{const t=Dc(e);if(h(t)){const o=dS.get(t);e.theme=o(e,dS.urls[t])||{},S(e.theme.init)&&e.theme.init(e,dS.urls[t]||e.documentBaseUrl.replace(/\/$/,""))}else e.theme={}})(e),(e=>{const t=Mc(e),o=QC.get(t);e.model=o(e,QC.urls[t])})(e),(e=>{const t=[];q(Kc(e),(o=>{JR(e,t,(e=>e.replace(/^\-/,""))(o))}))})(e);const t=await tB(e);((e,t)=>{const o={show:F.from(t.show).getOr(E),hide:F.from(t.hide).getOr(E),isEnabled:F.from(t.isEnabled).getOr(P),setEnabled:o=>{e.mode.isReadOnly()||F.from(t.setEnabled).each((e=>e(o)))}};e.ui={...e.ui,...o}})(e,F.from(t.api).getOr({})),e.editorContainer=t.editorContainer,yS(e),e.inline?$R(e):((e,t)=>{KR(e,t),t.editorContainer&&(t.editorContainer.style.display=e.orgDisplay,e.hidden=GR.isHidden(t.editorContainer)),e.getElement().style.display="none",GR.setAttrib(e.id,"aria-hidden","true"),e.getElement().style.visibility=e.orgVisibility,YR(e)})(e,{editorContainer:t.editorContainer,iframeContainer:t.iframeContainer})},nB=Ya.DOM,rB=e=>"-"===e.charAt(0),sB=(e,t)=>{const o=pc(t),n=fc(t);if(!ni.hasCode(o)&&"en"!==o){const r=Ye(n)?n:`${t.editorManager.baseURL}/langs/${o}.js`;e.add(r).catch((()=>{((e,t,o)=>{hS(e,"LanguageLoadError",pS("language",t,o))})(t,r,o)}))}},aB=(e,t)=>{const o=Dc(e);if(h(o)&&!rB(o)&&!_e(dS.urls,o)){const n=Ac(e),r=n?e.documentBaseURI.toAbsolute(n):`themes/${o}/theme${t}.js`;dS.load(o,r).catch((()=>{((e,t,o)=>{hS(e,"ThemeLoadError",pS("theme",t,o))})(e,r,o)}))}},iB=(e,t)=>{const o=Mc(e);if("plugin"!==o&&!_e(QC.urls,o)){const n=Nc(e),r=h(n)?e.documentBaseURI.toAbsolute(n):`models/${o}/model${t}.js`;QC.load(o,r).catch((()=>{((e,t,o)=>{hS(e,"ModelLoadError",pS("model",t,o))})(e,r,o)}))}},lB=(e,t,o)=>F.from(t).filter((e=>Ye(e)&&!JC.has(e))).map((t=>({url:`${e.editorManager.baseURL}/icons/${t}/icons${o}.js`,name:F.some(t)}))),cB=(e,t,o)=>{const n=lB(t,"default",o),r=(e=>F.from(lc(e)).filter(Ye).map((e=>({url:e,name:F.none()}))))(t).orThunk((()=>lB(t,ic(t),"")));q((e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t{e.add(o.url).catch((()=>{((e,t,o)=>{hS(e,"IconsLoadError",pS("icons",t,o))})(t,o.url,o.name.getOrUndefined())}))}))},dB=(e,t)=>{const o=(t,o)=>{cS.load(t,o).catch((()=>{((e,t,o)=>{hS(e,"PluginLoadError",pS("plugin",t,o))})(e,o,t)}))};fe(Yc(e),((t,n)=>{o(n,t),e.options.set("plugins",Kc(e).concat(n))})),q(Kc(e),(e=>{!(e=Bt.trim(e))||cS.urls[e]||rB(e)||o(e,`plugins/${e}/plugin${t}.js`)}))},mB=(e,t)=>{const o=Ja.ScriptLoader,n=()=>{!e.removed&&(e=>{const t=Dc(e);return!h(t)||C(dS.get(t))})(e)&&(e=>{const t=Mc(e);return C(QC.get(t))})(e)&&oB(e)};aB(e,t),iB(e,t),sB(o,e),cB(o,e,t),dB(e,t),o.loadQueue().then(n,n)},uB=e=>{const t=e.id;ni.setCode(pc(e));const o=()=>{nB.unbind(window,"ready",o),e.render()};if(!za.Event.domLoaded)return void nB.bind(window,"ready",o);if(!e.getElement())return;const n=yo.fromDom(e.getElement()),r=ao(n);e.on("remove",(()=>{G(n.dom.attributes,(e=>so(n,e.name))),to(n,r)})),e.ui.styleSheetLoader=((e,t)=>Us.forElement(e,{contentCssCors:Gc(t),referrerPolicy:hc(t)}))(n,e),Fc(e)?e.inline=!0:(e.orgVisibility=e.getElement().style.visibility,e.getElement().style.visibility="hidden");const s=e.getElement().form||nB.getParent(t,"form");s&&(e.formElement=s,zc(e)&&!er(e.getElement())&&(nB.insertAfter(nB.create("input",{type:"hidden",name:t}),t),e.hasHiddenInput=!0),e.formEventDelegate=t=>{e.dispatch(t.type,t)},nB.bind(s,"submit reset",e.formEventDelegate),e.on("reset",(()=>{e.resetContent()})),!Vc(e)||s.submit.nodeType||s.submit.length||s._mceOldSubmit||(s._mceOldSubmit=s.submit,s.submit=()=>(e.editorManager.triggerSave(),e.setDirty(!1),s._mceOldSubmit(s)))),e.windowManager=mS(e),e.notificationManager=lS(e),(e=>"xml"===e.options.get("encoding"))(e)&&e.on("GetContent",(e=>{e.save&&(e.content=nB.encode(e.content))})),Zc(e)&&e.on("submit",(()=>{e.initialized&&e.save()})),Uc(e)&&(e._beforeUnload=()=>{!e.initialized||e.destroyed||e.isHidden()||e.save({format:"raw",no_events:!0,set_dirty:!1})},e.editorManager.on("BeforeUnload",e._beforeUnload)),e.editorManager.add(e),mB(e,e.suffix)},gB=St().deviceType,hB=gB.isPhone(),pB=gB.isTablet(),fB=e=>{if(x(e))return[];{const t=v(e)?e:e.split(/[ ,]/),o=$(t,qe);return Y(o,Ye)}},vB=(e,t)=>{const o=((e,t)=>{const o={},n={};return we(e,t,ye(o),ye(n)),{t:o,f:n}})(t,((t,o)=>j(e,o)));return n=o.t,r=o.f,{sections:D(n),options:D(r)};var n,r},bB=(e,t)=>_e(e.sections(),t),yB=(e,t)=>({table_grid:!1,object_resizing:!1,resize:!1,toolbar_mode:ke(e,"toolbar_mode").getOr("scrolling"),toolbar_sticky:!1,...t?{menubar:!1}:{}}),wB=(e,t)=>{var o;const n=null!==(o=t.external_plugins)&&void 0!==o?o:{};return e&&e.external_plugins?Bt.extend({},e.external_plugins,n):n},xB=(e,t,o,n)=>{const r=fB(o.forced_plugins),s=fB(n.plugins),a=((e,t)=>bB(e,t)?e.sections()[t]:{})(t,"mobile"),i=((e,t,o,n)=>e&&bB(t,"mobile")?n:o)(e,t,s,a.plugins?fB(a.plugins):s),l=((e,t)=>[...fB(e),...fB(t)])(r,i);return Bt.extend(n,{forced_plugins:r,plugins:l})},CB=(e,t,o,n,r)=>{var s;const a=e?{mobile:yB(null!==(s=r.mobile)&&void 0!==s?s:{},t)}:{},i=vB(["mobile"],xO(a,r)),l=Bt.extend(o,n,i.options(),((e,t)=>e&&bB(t,"mobile"))(e,i)?((e,t,o={})=>{const n=e.sections(),r=ke(n,t).getOr({});return Bt.extend({},o,r)})(i,"mobile"):{},{external_plugins:wB(n,i.options())});return xB(e,i,n,l)},SB=(e,t)=>((e,t)=>yC(e).editor.addVisual(t))(e,t),kB=e=>{const t=t=>()=>{q("left,center,right,justify".split(","),(o=>{t!==o&&e.formatter.remove("align"+o)})),"none"!==t&&((t,o)=>{e.formatter.toggle(t,o),e.nodeChanged()})("align"+t)};e.editorCommands.addCommands({JustifyLeft:t("left"),JustifyCenter:t("center"),JustifyRight:t("right"),JustifyFull:t("justify"),JustifyNone:t("none")})},_B=e=>{kB(e),(e=>{const t=t=>()=>{const o=e.selection,n=o.isCollapsed()?[e.dom.getParent(o.getNode(),e.dom.isBlock)]:o.getSelectedBlocks();return W(n,(o=>C(e.formatter.matchNode(o,t))))};e.editorCommands.addCommands({JustifyLeft:t("alignleft"),JustifyCenter:t("aligncenter"),JustifyRight:t("alignright"),JustifyFull:t("alignjustify")},"state")})(e)},EB=(e,t)=>{const o=e.selection,n=e.dom;return/^ | $/.test(t)?((e,t,o,n)=>{const r=yo.fromDom(e.getRoot());return o=Pf(r,rl.fromRangeStart(t),n)?o.replace(/^ /," "):o.replace(/^ /," "),Ff(r,rl.fromRangeEnd(t),n)?o.replace(/( | )()?$/," "):o.replace(/ ()?$/," ")})(n,o.getRng(),t,e.schema):t},TB=(e,t)=>{if(e.selection.isEditable()){const{content:o,details:n}=(e=>{if("string"!=typeof e){const t=Bt.extend({paste:e.paste,data:{paste:e.paste}},e);return{content:e.content,details:t}}return{content:e,details:{}}})(t);Lx(e,{...n,content:EB(e,o),format:"html",set:!1,selection:!0}).each((t=>{const o=((e,t,o)=>bC(e).editor.insertContent(t,o))(e,t.content,n);Hx(e,o,t),e.addVisual()}))}},OB={"font-size":"size","font-family":"face"},DB=Jt("font"),AB=(e,t,o)=>Hb(yo.fromDom(o),(t=>(t=>un(t,e).orThunk((()=>DB(t)?ke(OB,e).bind((e=>no(t,e))):F.none())))(t)),(e=>So(yo.fromDom(t),e))),MB=e=>(t,o)=>F.from(o).map(yo.fromDom).filter(Gt).bind((o=>AB(e,t,o.dom).or(((e,t)=>F.from(Ya.DOM.getStyle(t,e,!0)))(e,o.dom)))).getOr(""),NB=MB("font-size"),RB=T((e=>e.replace(/[\'\"\\]/g,"").replace(/,\s+/g,",")),MB("font-family")),BB=e=>Gm(e.getBody()).bind((e=>{const t=e.container();return F.from(tr(t)?t.parentNode:t)})),LB=(e,t)=>(e=>F.from(e.selection.getRng()).bind((t=>{const o=e.getBody();return t.startContainer===o&&0===t.startOffset?F.none():F.from(e.selection.getStart(!0))})))(e).orThunk(N(BB,e)).map(yo.fromDom).filter(Gt).bind(t),HB=(e,t)=>LB(e,O(F.some,t)),IB=(e,t)=>{if(/^[0-9.]+$/.test(t)){const o=parseInt(t,10);if(o>=1&&o<=7){const n=(e=>Bt.explode(e.options.get("font_size_style_values")))(e),r=(e=>Bt.explode(e.options.get("font_size_classes")))(e);return r.length>0?r[o-1]||t:n[o-1]||t}return t}return t},PB=e=>{const t=e.split(/\s*,\s*/);return $(t,(e=>-1===e.indexOf(" ")||je(e,'"')||je(e,"'")?e:`'${e}'`)).join(",")},FB=e=>{const t=(t,o)=>{e.formatter.toggle(t,o),e.nodeChanged()};e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>{t(e)},"ForeColor,HiliteColor":(e,o,n)=>{t(e,{value:n})},BackColor:(e,o,n)=>{t("hilitecolor",{value:n})},FontName:(t,o,n)=>{((e,t)=>{const o=IB(e,t);e.formatter.toggle("fontname",{value:PB(o)}),e.nodeChanged()})(e,n)},FontSize:(t,o,n)=>{((e,t)=>{e.formatter.toggle("fontsize",{value:IB(e,t)}),e.nodeChanged()})(e,n)},LineHeight:(t,o,n)=>{((e,t)=>{e.formatter.toggle("lineheight",{value:String(t)}),e.nodeChanged()})(e,n)},Lang:(e,o,n)=>{var r;t(e,{value:n.code,customValue:null!==(r=n.customCode)&&void 0!==r?r:null})},RemoveFormat:t=>{e.formatter.remove(t)},mceBlockQuote:()=>{t("blockquote")},FormatBlock:(e,o,n)=>{t(h(n)?n:"p")},mceToggleFormat:(e,o,n)=>{t(n)}})},zB=e=>{const t=t=>e.formatter.match(t);e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>t(e),mceBlockQuote:()=>t("blockquote")},"state"),e.editorCommands.addQueryValueHandler("FontName",(()=>(e=>HB(e,(t=>RB(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("FontSize",(()=>(e=>HB(e,(t=>NB(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("LineHeight",(()=>(e=>HB(e,(t=>{const o=yo.fromDom(e.getBody()),n=Hb(t,(e=>un(e,"line-height")),N(So,o));return n.getOrThunk((()=>{const e=parseFloat(dn(t,"line-height")),o=parseFloat(dn(t,"font-size"));return String(e/o)}))})).getOr(""))(e)))},VB=e=>{e.editorCommands.addCommands({Indent:()=>{(e=>{_E(e,"indent")})(e)},Outdent:()=>{EE(e)}}),e.editorCommands.addCommands({Outdent:()=>CE(e)},"state")},ZB=(e,t)=>{const o=e.dom,n=e.selection.getRng(),r=t?e.selection.getStart():e.selection.getEnd(),s=t?n.startContainer:n.endContainer,a=KD(o,s);if(!a||!a.isContentEditable)return;const i=t?pn:fn,l=Xl(e);((e,t,o,n)=>{const r=e.dom,s=e=>r.isBlock(e)&&e.parentElement===o,a=s(t)?t:r.getParent(n,s,o);return F.from(a).map(yo.fromDom)})(e,r,a,s).each((t=>{const o=QD(e,s,t.dom,a,!1,l);i(t,yo.fromDom(o)),e.selection.setCursorLocation(o,0),e.dispatch("NewBlock",{newBlock:o}),VD(e,"insertParagraph")}))},UB=e=>{e.editorCommands.addCommands({InsertNewBlockBefore:()=>{(e=>{ZB(e,!0)})(e)},InsertNewBlockAfter:()=>{(e=>{ZB(e,!1)})(e)}})},jB=e=>{_B(e),(e=>{e.editorCommands.addCommands({"Cut,Copy,Paste":t=>{const o=e.getDoc();let n;try{o.execCommand(t)}catch(e){n=!0}if("paste"!==t||o.queryCommandEnabled(t)||(n=!0),n||!o.queryCommandSupported(t)){let t=e.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");(At.os.isMacOS()||At.os.isiOS())&&(t=t.replace(/Ctrl\+/g,"⌘+")),e.notificationManager.open({text:t,type:"error"})}}})})(e),(e=>{e.editorCommands.addCommands({mceAddUndoLevel:()=>{e.undoManager.add()},mceEndUndoLevel:()=>{e.undoManager.add()},Undo:()=>{e.undoManager.undo()},Redo:()=>{e.undoManager.redo()}})})(e),(e=>{e.editorCommands.addCommands({mceSelectNodeDepth:(t,o,n)=>{let r=0;e.dom.getParent(e.selection.getNode(),(t=>!Wn(t)||r++!==n||(e.selection.select(t),!1)),e.getBody())},mceSelectNode:(t,o,n)=>{e.selection.select(n)},selectAll:()=>{const t=e.dom.getParent(e.selection.getStart(),cr);if(t){const o=e.dom.createRng();o.selectNodeContents(t),e.selection.setRng(o)}}})})(e),(e=>{e.editorCommands.addCommands({mceCleanup:()=>{const t=e.selection.getBookmark();e.setContent(e.getContent()),e.selection.moveToBookmark(t)},insertImage:(t,o,n)=>{TB(e,e.dom.createHTML("img",{src:n}))},insertHorizontalRule:()=>{e.execCommand("mceInsertContent",!1,"
    ")},insertText:(t,o,n)=>{TB(e,e.dom.encode(n))},insertHTML:(t,o,n)=>{TB(e,n)},mceInsertContent:(t,o,n)=>{TB(e,n)},mceSetContent:(t,o,n)=>{e.setContent(n)},mceReplaceContent:(t,o,n)=>{e.execCommand("mceInsertContent",!1,n.replace(/\{\$selection\}/g,e.selection.getContent({format:"text"})))},mceNewDocument:()=>{e.setContent(ud(e))}})})(e),(e=>{const t=(t,o,n)=>{const r=h(n)?{href:n}:n,s=e.dom.getParent(e.selection.getNode(),"a");p(r)&&h(r.href)&&(r.href=r.href.replace(/ /g,"%20"),s&&r.href||e.formatter.remove("link"),r.href&&e.formatter.apply("link",r,s))};e.editorCommands.addCommands({unlink:()=>{if(e.selection.isEditable()){if(e.selection.isCollapsed()){const t=e.dom.getParent(e.selection.getStart(),"a");return void(t&&e.dom.remove(t,!0))}e.formatter.remove("link")}},mceInsertLink:t,createLink:t})})(e),VB(e),UB(e),(e=>{e.editorCommands.addCommands({insertParagraph:()=>{HA(gA,e)},mceInsertNewLine:(t,o,n)=>{IA(e,n)},InsertLineBreak:(t,o,n)=>{HA(CA,e)}})})(e),(e=>{(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{e.getDoc().execCommand(t);const o=e.dom.getParent(e.selection.getNode(),"ol,ul");if(o){const t=o.parentNode;if(t&&/^(H[1-6]|P|ADDRESS|PRE)$/.test(t.nodeName)){const n=e.selection.getBookmark();e.dom.split(t,o),e.selection.moveToBookmark(n)}}}})})(e),(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{const o=e.dom.getParent(e.selection.getNode(),"ul,ol");return o&&("insertunorderedlist"===t&&"UL"===o.tagName||"insertorderedlist"===t&&"OL"===o.tagName)}},"state")})(e)})(e),(e=>{FB(e),zB(e)})(e),(e=>{e.editorCommands.addCommands({mceRemoveNode:(t,o,n)=>{const r=null!=n?n:e.selection.getNode();if(r!==e.getBody()){const t=e.selection.getBookmark();e.dom.remove(r,!0),e.selection.moveToBookmark(t)}},mcePrint:()=>{e.getWin().print()},mceFocus:(t,o,n)=>{cp(e,!0===n)},mceToggleVisualAid:()=>{e.hasVisual=!e.hasVisual,e.addVisual()}})})(e)},WB=["toggleview"],$B=e=>j(WB,e.toLowerCase());class qB{constructor(e){this.commands={state:{},exec:{},value:{}},this.editor=e}execCommand(e,t=!1,o,n){const r=this.editor,s=e.toLowerCase(),a=null==n?void 0:n.skip_focus;if(r.removed)return!1;if("mcefocus"!==s&&(/^(mceAddUndoLevel|mceEndUndoLevel)$/i.test(s)||a?(e=>{Wh(e).each((t=>e.selection.setRng(t)))})(r):r.focus()),r.dispatch("BeforeExecCommand",{command:e,ui:t,value:o}).isDefaultPrevented())return!1;const i=this.commands.exec[s];return!!S(i)&&(i(s,t,o),r.dispatch("ExecCommand",{command:e,ui:t,value:o}),!0)}queryCommandState(e){if(!$B(e)&&this.editor.quirks.isHidden()||this.editor.removed)return!1;const t=e.toLowerCase(),o=this.commands.state[t];return!!S(o)&&o(t)}queryCommandValue(e){if(!$B(e)&&this.editor.quirks.isHidden()||this.editor.removed)return"";const t=e.toLowerCase(),o=this.commands.value[t];return S(o)?o(t):""}addCommands(e,t="exec"){const o=this.commands;fe(e,((e,n)=>{q(n.toLowerCase().split(","),(n=>{o[t][n]=e}))}))}addCommand(e,t,o){const n=e.toLowerCase();this.commands.exec[n]=(e,n,r)=>t.call(null!=o?o:this.editor,n,r)}queryCommandSupported(e){const t=e.toLowerCase();return!!this.commands.exec[t]}addQueryStateHandler(e,t,o){this.commands.state[e.toLowerCase()]=()=>t.call(null!=o?o:this.editor)}addQueryValueHandler(e,t,o){this.commands.value[e.toLowerCase()]=()=>t.call(null!=o?o:this.editor)}}const GB="data-mce-contenteditable",KB=(e,t,o)=>{try{e.getDoc().execCommand(t,!1,String(o))}catch(e){}},YB=(e,t)=>{e.dom.contentEditable=t?"true":"false"},XB=(e,t)=>{const o=yo.fromDom(e.getBody());((e,t,o)=>{vo(e,t)&&!o?po(e,t):o&&go(e,t)})(o,"mce-content-readonly",t),t?(e.selection.controlSelection.hideResizeRect(),e._selectionOverrides.hideFakeCaret(),(e=>{F.from(e.selection.getNode()).each((e=>{e.removeAttribute("data-mce-selected")}))})(e),e.readonly=!0,YB(o,!1),q(zn(o,'*[contenteditable="true"]'),(e=>{eo(e,GB,"true"),YB(e,!1)}))):(e.readonly=!1,e.hasEditableRoot()&&YB(o,!0),(e=>{q(zn(e,`*[${GB}="true"]`),(e=>{so(e,GB),YB(e,!0)}))})(o),KB(e,"StyleWithCSS",!1),KB(e,"enableInlineTableEditing",!1),KB(e,"enableObjectResizing",!1),ip(e)&&e.focus(),(e=>{e.selection.setRng(e.selection.getRng())})(e),e.nodeChanged())},JB=e=>e.readonly,QB=e=>{e.parser.addAttributeFilter("contenteditable",(t=>{JB(e)&&q(t,(e=>{e.attr(GB,e.attr("contenteditable")),e.attr("contenteditable","false")}))})),e.serializer.addAttributeFilter(GB,(t=>{JB(e)&&q(t,(e=>{e.attr("contenteditable",e.attr(GB))}))})),e.serializer.addTempAttr(GB)},eL=["copy"],tL=(e,t)=>{if((e=>"click"===e.type)(t)&&!Dg.metaKeyPressed(t)){const o=yo.fromDom(t.target);((e,t)=>on(t,"a",(t=>So(t,yo.fromDom(e.getBody())))).bind((e=>no(e,"href"))))(e,o).each((o=>{if(t.preventDefault(),/^#/.test(o)){const t=e.dom.select(`${o},[name="${Ze(o,"#")}"]`);t.length&&e.selection.scrollIntoView(t[0],!0)}else window.open(o,"_blank","rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes")}))}else(e=>j(eL,e.type))(t)&&e.dispatch(t.type,t)},oL=Bt.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel"," ");class nL{static isNative(e){return!!oL[e.toLowerCase()]}constructor(e){this.bindings={},this.settings=e||{},this.scope=this.settings.scope||this,this.toggleEvent=this.settings.toggleEvent||I}fire(e,t){return this.dispatch(e,t)}dispatch(e,t){const o=e.toLowerCase(),n=Ba(o,null!=t?t:{},this.scope);this.settings.beforeFire&&this.settings.beforeFire(n);const r=this.bindings[o];if(r)for(let e=0,t=r.length;e{this.toggleEvent(t,!1),delete this.bindings[t]})),this;if(s){if(t){const e=K(s,(e=>e.func===t));s=e.fail,this.bindings[r]=s,q(e.pass,(e=>{e.removed=!0}))}else s.length=0;s.length||(this.toggleEvent(e,!1),delete this.bindings[r])}}}else fe(this.bindings,((e,t)=>{this.toggleEvent(t,!1)})),this.bindings={};return this}once(e,t,o){return this.on(e,t,o,{once:!0})}has(e){e=e.toLowerCase();const t=this.bindings[e];return!(!t||0===t.length)}}const rL=e=>(e._eventDispatcher||(e._eventDispatcher=new nL({scope:e,toggleEvent:(t,o)=>{nL.isNative(t)&&e.toggleNativeEvent&&e.toggleNativeEvent(t,o)}})),e._eventDispatcher),sL={fire(e,t,o){return this.dispatch(e,t,o)},dispatch(e,t,o){const n=this;if(n.removed&&"remove"!==e&&"detach"!==e)return Ba(e.toLowerCase(),null!=t?t:{},n);const r=rL(n).dispatch(e,t);if(!1!==o&&n.parent){let t=n.parent();for(;t&&!r.isPropagationStopped();)t.dispatch(e,r,!1),t=t.parent?t.parent():void 0}return r},on(e,t,o){return rL(this).on(e,t,o)},off(e,t){return rL(this).off(e,t)},once(e,t){return rL(this).once(e,t)},hasEventListeners(e){return rL(this).has(e)}},aL=Ya.DOM;let iL;const lL=(e,t)=>{if("selectionchange"===t)return e.getDoc();if(!e.inline&&/^(?:mouse|touch|click|contextmenu|drop|dragover|dragend)/.test(t))return e.getDoc().documentElement;const o=Tc(e);return o?(e.eventRoot||(e.eventRoot=aL.select(o)[0]),e.eventRoot):e.getBody()},cL=(e,t,o)=>{(e=>!e.hidden&&!JB(e))(e)?e.dispatch(t,o):JB(e)&&tL(e,o)},dL=(e,t)=>{if(e.delegates||(e.delegates={}),e.delegates[t]||e.removed)return;const o=lL(e,t);if(Tc(e)){if(iL||(iL={},e.editorManager.on("removeEditor",(()=>{e.editorManager.activeEditor||iL&&(fe(iL,((t,o)=>{e.dom.unbind(lL(e,o))})),iL=null)}))),iL[t])return;const n=o=>{const n=o.target,r=e.editorManager.get();let s=r.length;for(;s--;){const e=r[s].getBody();(e===n||aL.isChildOf(n,e))&&cL(r[s],t,o)}};iL[t]=n,aL.bind(o,t,n)}else{const n=o=>{cL(e,t,o)};aL.bind(o,t,n),e.delegates[t]=n}},mL={...sL,bindPendingEventDelegates(){const e=this;Bt.each(e._pendingNativeEvents,(t=>{dL(e,t)}))},toggleNativeEvent(e,t){const o=this;"focus"!==e&&"blur"!==e&&(o.removed||(t?o.initialized?dL(o,e):o._pendingNativeEvents?o._pendingNativeEvents.push(e):o._pendingNativeEvents=[e]:o.initialized&&o.delegates&&(o.dom.unbind(lL(o,e),e,o.delegates[e]),delete o.delegates[e])))},unbindAllNativeEvents(){const e=this,t=e.getBody(),o=e.dom;e.delegates&&(fe(e.delegates,((t,o)=>{e.dom.unbind(lL(e,o),o,t)})),delete e.delegates),!e.inline&&t&&o&&(t.onload=null,o.unbind(e.getWin()),o.unbind(e.getDoc())),o&&(o.unbind(t),o.unbind(e.getContainer()))}},uL=e=>h(e)?{value:e.split(/[ ,]/),valid:!0}:_(e,h)?{value:e,valid:!0}:{valid:!1,message:"The value must be a string[] or a comma/space separated string."},gL=(e,t)=>e+(Xe(t.message)?"":`. ${t.message}`),hL=e=>e.valid,pL=(e,t,o="")=>{const n=t(e);return y(n)?n?{value:e,valid:!0}:{valid:!1,message:o}:n},fL=(e,t)=>{const o={},n={},r=(e,t,o)=>{const r=pL(t,o);return hL(r)?(n[e]=r.value,!0):(console.warn(gL(`Invalid value passed for the ${e} option`,r)),!1)},s=e=>_e(o,e);return{register:(e,s)=>{const a=(e=>h(e.processor))(s)?(e=>{const t=(()=>{switch(e){case"array":return v;case"boolean":return y;case"function":return S;case"number":return k;case"object":return p;case"string":return h;case"string[]":return uL;case"object[]":return e=>_(e,p);case"regexp":return e=>g(e,RegExp);default:return P}})();return o=>pL(o,t,`The value must be a ${e}.`)})(s.processor):s.processor,i=((e,t,o)=>{if(!w(t)){const n=pL(t,o);if(hL(n))return n.value;console.error(gL(`Invalid default value passed for the "${e}" option`,n))}})(e,s.default,a);o[e]={...s,default:i,processor:a},ke(n,e).orThunk((()=>ke(t,e))).each((t=>r(e,t,a)))},isRegistered:s,get:e=>ke(n,e).orThunk((()=>ke(o,e).map((e=>e.default)))).getOrUndefined(),set:(e,t)=>{if(s(e)){const n=o[e];return n.immutable?(console.error(`"${e}" is an immutable option and cannot be updated`),!1):r(e,t,n.processor)}return console.warn(`"${e}" is not a registered option. Ensure the option has been registered before setting a value.`),!1},unset:e=>{const t=s(e);return t&&delete n[e],t},isSet:e=>_e(n,e)}},vL=["design","readonly"],bL=(e,t,o,n)=>{const r=o[t.get()],s=o[n];try{s.activate()}catch(e){return void console.error(`problem while activating editor mode ${n}:`,e)}r.deactivate(),r.editorReadOnly!==s.editorReadOnly&&XB(e,s.editorReadOnly),t.set(n),((e,t)=>{e.dispatch("SwitchMode",{mode:t})})(e,n)},yL=e=>{const t=Qa("design"),o=Qa({design:{activate:E,deactivate:E,editorReadOnly:!1},readonly:{activate:E,deactivate:E,editorReadOnly:!0}});return(e=>{e.serializer?QB(e):e.on("PreInit",(()=>{QB(e)}))})(e),(e=>{e.on("ShowCaret",(t=>{JB(e)&&t.preventDefault()})),e.on("ObjectSelected",(t=>{JB(e)&&t.preventDefault()}))})(e),{isReadOnly:()=>JB(e),set:n=>((e,t,o,n)=>{if(n!==o.get()){if(!_e(t,n))throw new Error(`Editor mode '${n}' is invalid`);e.initialized?bL(e,o,t,n):e.on("init",(()=>bL(e,o,t,n)))}})(e,o.get(),t,n),get:()=>t.get(),register:(e,t)=>{o.set(((e,t,o)=>{if(j(vL,t))throw new Error(`Cannot override default mode ${t}`);return{...e,[t]:{...o,deactivate:()=>{try{o.deactivate()}catch(e){console.error(`problem while deactivating editor mode ${t}:`,e)}}}}})(o.get(),e,t))}}},wL=Bt.each,xL=Bt.explode,CL={f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},SL=Bt.makeMap("alt,ctrl,shift,meta,access"),kL=e=>{const t={},o=At.os.isMacOS()||At.os.isiOS();wL(xL(e.toLowerCase(),"+"),(e=>{(e=>e in SL)(e)?t[e]=!0:/^[0-9]{2,}$/.test(e)?t.keyCode=parseInt(e,10):(t.charCode=e.charCodeAt(0),t.keyCode=CL[e]||e.toUpperCase().charCodeAt(0))}));const n=[t.keyCode];let r;for(r in SL)t[r]?n.push(r):t[r]=!1;return t.id=n.join(","),t.access&&(t.alt=!0,o?t.ctrl=!0:t.shift=!0),t.meta&&(o?t.meta=!0:(t.ctrl=!0,t.meta=!1)),t};class _L{constructor(e){this.shortcuts={},this.pendingPatterns=[],this.editor=e;const t=this;e.on("keyup keypress keydown",(e=>{!t.hasModifier(e)&&!t.isFunctionKey(e)||e.isDefaultPrevented()||(wL(t.shortcuts,(o=>{t.matchShortcut(e,o)&&(t.pendingPatterns=o.subpatterns.slice(0),"keydown"===e.type&&t.executeShortcutAction(o))})),t.matchShortcut(e,t.pendingPatterns[0])&&(1===t.pendingPatterns.length&&"keydown"===e.type&&t.executeShortcutAction(t.pendingPatterns[0]),t.pendingPatterns.shift()))}))}add(e,t,o,n){const r=this,s=r.normalizeCommandFunc(o);return wL(xL(Bt.trim(e)),(e=>{const o=r.createShortcut(e,t,s,n);r.shortcuts[o.id]=o})),!0}remove(e){const t=this.createShortcut(e);return!!this.shortcuts[t.id]&&(delete this.shortcuts[t.id],!0)}normalizeCommandFunc(e){const t=this,o=e;return"string"==typeof o?()=>{t.editor.execCommand(o,!1,null)}:Bt.isArray(o)?()=>{t.editor.execCommand(o[0],o[1],o[2])}:o}createShortcut(e,t,o,n){const r=Bt.map(xL(e,">"),kL);return r[r.length-1]=Bt.extend(r[r.length-1],{func:o,scope:n||this.editor}),Bt.extend(r[0],{desc:this.editor.translate(t),subpatterns:r.slice(1)})}hasModifier(e){return e.altKey||e.ctrlKey||e.metaKey}isFunctionKey(e){return"keydown"===e.type&&e.keyCode>=112&&e.keyCode<=123}matchShortcut(e,t){return!!t&&t.ctrl===e.ctrlKey&&t.meta===e.metaKey&&t.alt===e.altKey&&t.shift===e.shiftKey&&!!(e.keyCode===t.keyCode||e.charCode&&e.charCode===t.charCode)&&(e.preventDefault(),!0)}executeShortcutAction(e){return e.func?e.func.call(e.scope):null}}const EL=()=>{const e=(()=>{const e={},t={},o={},n={},r={},s={},a={},i={},l=(e,t)=>(o,n)=>{e[o.toLowerCase()]={...n,type:t}};return{addButton:l(e,"button"),addGroupToolbarButton:l(e,"grouptoolbarbutton"),addToggleButton:l(e,"togglebutton"),addMenuButton:l(e,"menubutton"),addSplitButton:l(e,"splitbutton"),addMenuItem:l(t,"menuitem"),addNestedMenuItem:l(t,"nestedmenuitem"),addToggleMenuItem:l(t,"togglemenuitem"),addAutocompleter:l(o,"autocompleter"),addContextMenu:l(r,"contextmenu"),addContextToolbar:l(s,"contexttoolbar"),addContextForm:l(s,"contextform"),addSidebar:l(a,"sidebar"),addView:l(i,"views"),addIcon:(e,t)=>n[e.toLowerCase()]=t,getAll:()=>({buttons:e,menuItems:t,icons:n,popups:o,contextMenus:r,contextToolbars:s,sidebars:a,views:i})}})();return{addAutocompleter:e.addAutocompleter,addButton:e.addButton,addContextForm:e.addContextForm,addContextMenu:e.addContextMenu,addContextToolbar:e.addContextToolbar,addIcon:e.addIcon,addMenuButton:e.addMenuButton,addMenuItem:e.addMenuItem,addNestedMenuItem:e.addNestedMenuItem,addSidebar:e.addSidebar,addSplitButton:e.addSplitButton,addToggleButton:e.addToggleButton,addGroupToolbarButton:e.addGroupToolbarButton,addToggleMenuItem:e.addToggleMenuItem,addView:e.addView,getAll:e.getAll}},TL=Ya.DOM,OL=Bt.extend,DL=Bt.each;class AL{constructor(e,t,o){this.plugins={},this.contentCSS=[],this.contentStyles=[],this.loadedCSS={},this.isNotDirty=!1,this.composing=!1,this.destroyed=!1,this.hasHiddenInput=!1,this.iframeElement=null,this.initialized=!1,this.readonly=!1,this.removed=!1,this.startContent="",this._pendingNativeEvents=[],this._skinLoaded=!1,this._editableRoot=!0,this.editorManager=o,this.documentBaseUrl=o.documentBaseURL,OL(this,mL);const n=this;this.id=e,this.hidden=!1;const r=((e,t)=>CB(hB||pB,hB,t,e,t))(o.defaultOptions,t);this.options=fL(0,r),(e=>{const t=e.options.register;t("id",{processor:"string",default:e.id}),t("selector",{processor:"string"}),t("target",{processor:"object"}),t("suffix",{processor:"string"}),t("cache_suffix",{processor:"string"}),t("base_url",{processor:"string"}),t("referrer_policy",{processor:"string",default:""}),t("language_load",{processor:"boolean",default:!0}),t("inline",{processor:"boolean",default:!1}),t("iframe_attrs",{processor:"object",default:{}}),t("doctype",{processor:"string",default:""}),t("document_base_url",{processor:"string",default:e.documentBaseUrl}),t("body_id",{processor:Ul(e,"tinymce"),default:"tinymce"}),t("body_class",{processor:Ul(e),default:""}),t("content_security_policy",{processor:"string",default:""}),t("br_in_pre",{processor:"boolean",default:!0}),t("forced_root_block",{processor:e=>{const t=h(e)&&Ye(e);return t?{value:e,valid:t}:{valid:!1,message:"Must be a non-empty string."}},default:"p"}),t("forced_root_block_attrs",{processor:"object",default:{}}),t("newline_behavior",{processor:e=>{const t=j(["block","linebreak","invert","default"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: block, linebreak, invert or default."}},default:"default"}),t("br_newline_selector",{processor:"string",default:".mce-toc h2,figcaption,caption"}),t("no_newline_selector",{processor:"string",default:""}),t("keep_styles",{processor:"boolean",default:!0}),t("end_container_on_empty_block",{processor:e=>y(e)||h(e)?{valid:!0,value:e}:{valid:!1,message:"Must be boolean or a string"},default:"blockquote"}),t("font_size_style_values",{processor:"string",default:"xx-small,x-small,small,medium,large,x-large,xx-large"}),t("font_size_legacy_values",{processor:"string",default:"xx-small,small,medium,large,x-large,xx-large,300%"}),t("font_size_classes",{processor:"string",default:""}),t("automatic_uploads",{processor:"boolean",default:!0}),t("images_reuse_filename",{processor:"boolean",default:!1}),t("images_replace_blob_uris",{processor:"boolean",default:!0}),t("icons",{processor:"string",default:""}),t("icons_url",{processor:"string",default:""}),t("images_upload_url",{processor:"string",default:""}),t("images_upload_base_path",{processor:"string",default:""}),t("images_upload_credentials",{processor:"boolean",default:!1}),t("images_upload_handler",{processor:"function"}),t("language",{processor:"string",default:"en"}),t("language_url",{processor:"string",default:""}),t("entity_encoding",{processor:"string",default:"named"}),t("indent",{processor:"boolean",default:!0}),t("indent_before",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_after",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_use_margin",{processor:"boolean",default:!1}),t("indentation",{processor:"string",default:"40px"}),t("content_css",{processor:e=>{const t=!1===e||h(e)||_(e,h);return t?h(e)?{value:$(e.split(","),qe),valid:t}:v(e)?{value:e,valid:t}:!1===e?{value:[],valid:t}:{value:e,valid:t}:{valid:!1,message:"Must be false, a string or an array of strings."}},default:Fc(e)?[]:["default"]}),t("content_style",{processor:"string"}),t("content_css_cors",{processor:"boolean",default:!1}),t("font_css",{processor:e=>{const t=h(e)||_(e,h);return t?{value:v(e)?e:$(e.split(","),qe),valid:t}:{valid:!1,message:"Must be a string or an array of strings."}},default:[]}),t("inline_boundaries",{processor:"boolean",default:!0}),t("inline_boundaries_selector",{processor:"string",default:"a[href],code,span.mce-annotation"}),t("object_resizing",{processor:e=>{const t=y(e)||h(e);return t?!1===e||Il.isiPhone()||Il.isiPad()?{value:"",valid:t}:{value:!0===e?"table,img,figure.image,div,video,iframe":e,valid:t}:{valid:!1,message:"Must be boolean or a string"}},default:!Pl}),t("resize_img_proportional",{processor:"boolean",default:!0}),t("event_root",{processor:"object"}),t("service_message",{processor:"string"}),t("theme",{processor:e=>!1===e||h(e)||S(e),default:"silver"}),t("theme_url",{processor:"string"}),t("formats",{processor:"object"}),t("format_empty_lines",{processor:"boolean",default:!1}),t("format_noneditable_selector",{processor:"string",default:""}),t("preview_styles",{processor:e=>{const t=!1===e||h(e);return t?{value:!1===e?"":e,valid:t}:{valid:!1,message:"Must be false or a string"}},default:"font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow"}),t("custom_ui_selector",{processor:"string",default:""}),t("hidden_input",{processor:"boolean",default:!0}),t("submit_patch",{processor:"boolean",default:!0}),t("encoding",{processor:"string"}),t("add_form_submit_trigger",{processor:"boolean",default:!0}),t("add_unload_trigger",{processor:"boolean",default:!0}),t("custom_undo_redo_levels",{processor:"number",default:0}),t("disable_nodechange",{processor:"boolean",default:!1}),t("readonly",{processor:"boolean",default:!1}),t("editable_root",{processor:"boolean",default:!0}),t("plugins",{processor:"string[]",default:[]}),t("external_plugins",{processor:"object"}),t("forced_plugins",{processor:"string[]"}),t("model",{processor:"string",default:e.hasPlugin("rtc")?"plugin":"dom"}),t("model_url",{processor:"string"}),t("block_unsupported_drop",{processor:"boolean",default:!0}),t("visual",{processor:"boolean",default:!0}),t("visual_table_class",{processor:"string",default:"mce-item-table"}),t("visual_anchor_class",{processor:"string",default:"mce-item-anchor"}),t("iframe_aria_text",{processor:"string",default:"Rich Text Area. Press ALT-0 for help."}),t("setup",{processor:"function"}),t("init_instance_callback",{processor:"function"}),t("url_converter",{processor:"function",default:e.convertURL}),t("url_converter_scope",{processor:"object",default:e}),t("urlconverter_callback",{processor:"function"}),t("allow_conditional_comments",{processor:"boolean",default:!1}),t("allow_html_data_urls",{processor:"boolean",default:!1}),t("allow_svg_data_urls",{processor:"boolean"}),t("allow_html_in_named_anchor",{processor:"boolean",default:!1}),t("allow_script_urls",{processor:"boolean",default:!1}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("convert_fonts_to_spans",{processor:"boolean",default:!0,deprecated:!0}),t("fix_list_elements",{processor:"boolean",default:!1}),t("preserve_cdata",{processor:"boolean",default:!1}),t("remove_trailing_brs",{processor:"boolean",default:!0}),t("pad_empty_with_br",{processor:"boolean",default:!1}),t("inline_styles",{processor:"boolean",default:!0,deprecated:!0}),t("element_format",{processor:"string",default:"html"}),t("entities",{processor:"string"}),t("schema",{processor:"string",default:"html5"}),t("convert_urls",{processor:"boolean",default:!0}),t("relative_urls",{processor:"boolean",default:!0}),t("remove_script_host",{processor:"boolean",default:!0}),t("custom_elements",{processor:"string"}),t("extended_valid_elements",{processor:"string"}),t("invalid_elements",{processor:"string"}),t("invalid_styles",{processor:Zl}),t("valid_children",{processor:"string"}),t("valid_classes",{processor:Zl}),t("valid_elements",{processor:"string"}),t("valid_styles",{processor:Zl}),t("verify_html",{processor:"boolean",default:!0}),t("auto_focus",{processor:e=>h(e)||!0===e}),t("browser_spellcheck",{processor:"boolean",default:!1}),t("protect",{processor:"array"}),t("images_file_types",{processor:"string",default:"jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp"}),t("deprecation_warnings",{processor:"boolean",default:!0}),t("a11y_advanced_options",{processor:"boolean",default:!1}),t("api_key",{processor:"string"}),t("paste_block_drop",{processor:"boolean",default:!1}),t("paste_data_images",{processor:"boolean",default:!0}),t("paste_preprocess",{processor:"function"}),t("paste_postprocess",{processor:"function"}),t("paste_webkit_styles",{processor:"string",default:"none"}),t("paste_remove_styles_if_webkit",{processor:"boolean",default:!0}),t("paste_merge_formats",{processor:"boolean",default:!0}),t("smart_paste",{processor:"boolean",default:!0}),t("paste_as_text",{processor:"boolean",default:!1}),t("paste_tab_spaces",{processor:"number",default:4}),t("text_patterns",{processor:e=>_(e,p)||!1===e?{value:Hl(!1===e?[]:e),valid:!0}:{valid:!1,message:"Must be an array of objects or false."},default:[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}]}),t("text_patterns_lookup",{processor:e=>{return S(e)?{value:(t=e,e=>{const o=t(e);return Hl(o)}),valid:!0}:{valid:!1,message:"Must be a single function"};var t},default:e=>[]}),t("noneditable_class",{processor:"string",default:"mceNonEditable"}),t("editable_class",{processor:"string",default:"mceEditable"}),t("noneditable_regexp",{processor:e=>_(e,zl)?{value:e,valid:!0}:zl(e)?{value:[e],valid:!0}:{valid:!1,message:"Must be a RegExp or an array of RegExp."},default:[]}),t("table_tab_navigation",{processor:"boolean",default:!0}),t("highlight_on_focus",{processor:"boolean",default:!1}),t("xss_sanitization",{processor:"boolean",default:!0}),t("details_initial_state",{processor:e=>{const t=j(["inherited","collapsed","expanded"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: inherited, collapsed, or expanded."}},default:"inherited"}),t("details_serialized_state",{processor:e=>{const t=j(["inherited","collapsed","expanded"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: inherited, collapsed, or expanded."}},default:"inherited"}),t("init_content_sync",{processor:"boolean",default:!1}),t("newdocument_content",{processor:"string",default:""}),t("force_hex_color",{processor:e=>{const t=["always","rgb_only","off"],o=j(t,e);return o?{value:e,valid:o}:{valid:!1,message:`Must be one of: ${t.join(", ")}.`}},default:"off"}),t("sandbox_iframes",{processor:"boolean",default:!1}),t("convert_unsafe_embeds",{processor:"boolean",default:!1}),e.on("ScriptsLoaded",(()=>{t("directionality",{processor:"string",default:ni.isRtl()?"rtl":void 0}),t("placeholder",{processor:"string",default:Fl.getAttrib(e.getElement(),"placeholder")})}))})(n);const s=this.options.get;s("deprecation_warnings")&&qC(t,r);const a=s("suffix");a&&(o.suffix=a),this.suffix=o.suffix;const i=s("base_url");i&&o._setBaseUrl(i),this.baseUri=o.baseURI;const l=hc(n);l&&(Ja.ScriptLoader._setReferrerPolicy(l),Ya.DOM.styleSheetLoader._setReferrerPolicy(l));const c=Gc(n);C(c)&&Ya.DOM.styleSheetLoader._setContentCssCors(c),ri.languageLoad=s("language_load"),ri.baseURL=o.baseURL,this.setDirty(!1),this.documentBaseURI=new px($l(n),{base_uri:this.baseUri}),this.baseURI=this.baseUri,this.inline=Fc(n),this.hasVisual=Jc(n),this.shortcuts=new _L(this),this.editorCommands=new qB(this),jB(this);const d=s("cache_suffix");d&&(At.cacheSuffix=d.replace(/^[\?\&]+/,"")),this.ui={registry:EL(),styleSheetLoader:void 0,show:E,hide:E,setEnabled:E,isEnabled:P},this.mode=yL(n),o.dispatch("SetupEditor",{editor:this});const m=od(n);S(m)&&m.call(n,n)}render(){uB(this)}focus(e){this.execCommand("mceFocus",!1,e)}hasFocus(){return ap(this)}translate(e){return ni.translate(e)}getParam(e,t,o){const n=this.options;return n.isRegistered(e)||(C(o)?n.register(e,{processor:o,default:t}):n.register(e,{processor:P,default:t})),n.isSet(e)||w(t)?n.get(e):t}hasPlugin(e,t){return!(!j(Kc(this),e)||t&&void 0===cS.get(e))}nodeChanged(e){this._nodeChangeDispatcher.nodeChanged(e)}addCommand(e,t,o){this.editorCommands.addCommand(e,t,o)}addQueryStateHandler(e,t,o){this.editorCommands.addQueryStateHandler(e,t,o)}addQueryValueHandler(e,t,o){this.editorCommands.addQueryValueHandler(e,t,o)}addShortcut(e,t,o,n){this.shortcuts.add(e,t,o,n)}execCommand(e,t,o,n){return this.editorCommands.execCommand(e,t,o,n)}queryCommandState(e){return this.editorCommands.queryCommandState(e)}queryCommandValue(e){return this.editorCommands.queryCommandValue(e)}queryCommandSupported(e){return this.editorCommands.queryCommandSupported(e)}show(){const e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable="true":(TL.show(e.getContainer()),TL.hide(e.id)),e.load(),e.dispatch("show"))}hide(){const e=this;e.hidden||(e.save(),e.inline?(e.getBody().contentEditable="false",e===e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(TL.hide(e.getContainer()),TL.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.dispatch("hide"))}isHidden(){return this.hidden}setProgressState(e,t){this.dispatch("ProgressState",{state:e,time:t})}load(e={}){const t=this,o=t.getElement();if(t.removed)return"";if(o){const n={...e,load:!0},r=er(o)?o.value:o.innerHTML,s=t.setContent(r,n);return n.no_events||t.dispatch("LoadContent",{...n,element:o}),s}return""}save(e={}){const t=this;let o=t.getElement();if(!o||!t.initialized||t.removed)return"";const n={...e,save:!0,element:o};let r=t.getContent(n);const s={...n,content:r};if(s.no_events||t.dispatch("SaveContent",s),"raw"===s.format&&t.dispatch("RawSaveContent",s),r=s.content,er(o))o.value=r;else{!e.is_removing&&t.inline||(o.innerHTML=r);const n=TL.getParent(t.id,"form");n&&DL(n.elements,(e=>e.name!==t.id||(e.value=r,!1)))}return s.element=n.element=o=null,!1!==s.set_dirty&&t.setDirty(!1),r}setContent(e,t){return LC(this,e,t)}getContent(e){return BC(this,e)}insertContent(e,t){t&&(e=OL({content:e},t)),this.execCommand("mceInsertContent",!1,e)}resetContent(e){void 0===e?LC(this,this.startContent,{format:"raw"}):LC(this,e),this.undoManager.reset(),this.setDirty(!1),this.nodeChanged()}isDirty(){return!this.isNotDirty}setDirty(e){const t=!this.isNotDirty;this.isNotDirty=!e,e&&e!==t&&this.dispatch("dirty")}getContainer(){const e=this;return e.container||(e.container=e.editorContainer||TL.get(e.id+"_parent")),e.container}getContentAreaContainer(){return this.contentAreaContainer}getElement(){return this.targetElm||(this.targetElm=TL.get(this.id)),this.targetElm}getWin(){const e=this;if(!e.contentWindow){const t=e.iframeElement;t&&(e.contentWindow=t.contentWindow)}return e.contentWindow}getDoc(){const e=this;if(!e.contentDocument){const t=e.getWin();t&&(e.contentDocument=t.document)}return e.contentDocument}getBody(){var e,t;const o=this.getDoc();return null!==(t=null!==(e=this.bodyElement)&&void 0!==e?e:null==o?void 0:o.body)&&void 0!==t?t:null}convertURL(e,t,o){const n=this,r=n.options.get,s=rd(n);if(S(s))return s.call(n,e,o,!0,t);if(!r("convert_urls")||"link"===o||p(o)&&"LINK"===o.nodeName||0===e.indexOf("file:")||0===e.length)return e;const a=new px(e);return"http"!==a.protocol&&"https"!==a.protocol&&""!==a.protocol?e:r("relative_urls")?n.documentBaseURI.toRelative(e):e=n.documentBaseURI.toAbsolute(e,r("remove_script_host"))}addVisual(e){SB(this,e)}setEditableRoot(e){((e,t)=>{e._editableRoot!==t&&(e._editableRoot=t,e.readonly||(e.getBody().contentEditable=String(e.hasEditableRoot()),e.nodeChanged()),((e,t)=>{e.dispatch("EditableRootStateChange",{state:t})})(e,t))})(this,e)}hasEditableRoot(){return this._editableRoot}remove(){YC(this)}destroy(e){XC(this,e)}uploadImages(){return this.editorUpload.uploadImages()}_scanForImages(){return this.editorUpload.scanForImages()}}const ML=Ya.DOM,NL=Bt.each;let RL,BL=!1,LL=[];const HL=e=>{const t=e.type;NL(zL.get(),(o=>{switch(t){case"scroll":o.dispatch("ScrollWindow",e);break;case"resize":o.dispatch("ResizeWindow",e)}}))},IL=e=>{if(e!==BL){const t=Ya.DOM;e?(t.bind(window,"resize",HL),t.bind(window,"scroll",HL)):(t.unbind(window,"resize",HL),t.unbind(window,"scroll",HL)),BL=e}},PL=e=>{const t=LL;return LL=Y(LL,(t=>e!==t)),zL.activeEditor===e&&(zL.activeEditor=LL.length>0?LL[0]:null),zL.focusedEditor===e&&(zL.focusedEditor=null),t.length!==LL.length},FL="CSS1Compat"!==document.compatMode,zL={...sL,baseURI:null,baseURL:null,defaultOptions:{},documentBaseURL:null,suffix:null,majorVersion:"6",minorVersion:"8.3",releaseDate:"2024-02-08",i18n:ni,activeEditor:null,focusedEditor:null,setup(){const e=this;let t="",o="",n=px.getDocumentBaseUrl(document.location);/^[^:]+:\/\/\/?[^\/]+\//.test(n)&&(n=n.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(n)||(n+="/"));const r=window.tinymce||window.tinyMCEPreInit;if(r)t=r.base||r.baseURL,o=r.suffix;else{const e=document.getElementsByTagName("script");for(let n=0;n{ri.PluginManager.urls[t]=e}))},init(e){const t=this;let o;const n=Bt.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu"," ");let r=e=>{o=e};const s=()=>{let o=0;const a=[];let i;ML.unbind(window,"ready",s),(o=>{const n=e[o];n&&n.apply(t,[])})("onpageload"),i=((e,t)=>{const o=[],n=S(t)?e=>W(o,(o=>t(o,e))):e=>j(o,e);for(let t=0,r=e.length;tAt.browser.isIE()||At.browser.isEdge()?(fS("TinyMCE does not support the browser you are using. For a list of supported browsers please see: https://www.tiny.cloud/docs/tinymce/6/support/#supportedwebbrowsers"),[]):FL?(fS("Failed to initialize the editor as the document is not in standards mode. TinyMCE requires standards mode."),[]):h(e.selector)?ML.select(e.selector):C(e.target)?[e.target]:[])(e)),Bt.each(i,(e=>{var o;(o=t.get(e.id))&&o.initialized&&!(o.getContainer()||o.getBody()).parentNode&&(PL(o),o.unbindAllNativeEvents(),o.destroy(!0),o.removed=!0)})),i=Bt.grep(i,(e=>!t.get(e.id))),0===i.length?r([]):NL(i,(s=>{((e,t)=>e.inline&&t.tagName.toLowerCase()in n)(e,s)?fS("Could not initialize inline editor on invalid inline target element",s):((e,n,s)=>{const l=new AL(e,n,t);a.push(l),l.on("init",(()=>{++o===i.length&&r(a)})),l.targetElm=l.targetElm||s,l.render()})((e=>{let t=e.id;return t||(t=ke(e,"name").filter((e=>!ML.get(e))).getOrThunk(ML.uniqueId),e.setAttribute("id",t)),t})(s),e,s)}))};return ML.bind(window,"ready",s),new Promise((e=>{o?e(o):r=t=>{e(t)}}))},get(e){return 0===arguments.length?LL.slice(0):h(e)?ee(LL,(t=>t.id===e)).getOr(null):k(e)&&LL[e]?LL[e]:null},add(e){const t=this,o=t.get(e.id);return o===e||(null===o&&LL.push(e),IL(!0),t.activeEditor=e,t.dispatch("AddEditor",{editor:e}),RL||(RL=e=>{const o=t.dispatch("BeforeUnload");if(o.returnValue)return e.preventDefault(),e.returnValue=o.returnValue,o.returnValue},window.addEventListener("beforeunload",RL))),e},createEditor(e,t){return this.add(new AL(e,t,this))},remove(e){const t=this;let o;if(e){if(!h(e))return o=e,b(t.get(o.id))?null:(PL(o)&&t.dispatch("RemoveEditor",{editor:o}),0===LL.length&&window.removeEventListener("beforeunload",RL),o.remove(),IL(LL.length>0),o);NL(ML.select(e),(e=>{o=t.get(e.id),o&&t.remove(o)}))}else for(let e=LL.length-1;e>=0;e--)t.remove(LL[e])},execCommand(e,t,o){var n;const r=this,s=p(o)?null!==(n=o.id)&&void 0!==n?n:o.index:o;switch(e){case"mceAddEditor":if(!r.get(s)){const e=o.options;new AL(s,e,r).render()}return!0;case"mceRemoveEditor":{const e=r.get(s);return e&&e.remove(),!0}case"mceToggleEditor":{const e=r.get(s);return e?(e.isHidden()?e.show():e.hide(),!0):(r.execCommand("mceAddEditor",!1,o),!0)}}return!!r.activeEditor&&r.activeEditor.execCommand(e,t,o)},triggerSave:()=>{NL(LL,(e=>{e.save()}))},addI18n:(e,t)=>{ni.add(e,t)},translate:e=>ni.translate(e),setActive(e){const t=this.activeEditor;this.activeEditor!==e&&(t&&t.dispatch("deactivate",{relatedTarget:e}),e.dispatch("activate",{relatedTarget:t})),this.activeEditor=e},_setBaseUrl(e){this.baseURL=new px(this.documentBaseURL).toAbsolute(e.replace(/\/+$/,"")),this.baseURI=new px(this.baseURL)}};zL.setup();const VL=(()=>{const e=ai();return{FakeClipboardItem:e=>({items:e,types:he(e),getType:t=>ke(e,t).getOrUndefined()}),write:t=>{e.set(t)},read:()=>e.get().getOrUndefined(),clear:e.clear}})(),ZL=Math.min,UL=Math.max,jL=Math.round,WL=(e,t,o)=>{let n=t.x,r=t.y;const s=e.w,a=e.h,i=t.w,l=t.h,c=(o||"").split("");return"b"===c[0]&&(r+=l),"r"===c[1]&&(n+=i),"c"===c[0]&&(r+=jL(l/2)),"c"===c[1]&&(n+=jL(i/2)),"b"===c[3]&&(r-=a),"r"===c[4]&&(n-=s),"c"===c[3]&&(r-=jL(a/2)),"c"===c[4]&&(n-=jL(s/2)),$L(n,r,s,a)},$L=(e,t,o,n)=>({x:e,y:t,w:o,h:n}),qL={inflate:(e,t,o)=>$L(e.x-t,e.y-o,e.w+2*t,e.h+2*o),relativePosition:WL,findBestRelativePosition:(e,t,o,n)=>{for(let r=0;r=o.x&&s.x+s.w<=o.w+o.x&&s.y>=o.y&&s.y+s.h<=o.h+o.y)return n[r]}return null},intersect:(e,t)=>{const o=UL(e.x,t.x),n=UL(e.y,t.y),r=ZL(e.x+e.w,t.x+t.w),s=ZL(e.y+e.h,t.y+t.h);return r-o<0||s-n<0?null:$L(o,n,r-o,s-n)},clamp:(e,t,o)=>{let n=e.x,r=e.y,s=e.x+e.w,a=e.y+e.h;const i=t.x+t.w,l=t.y+t.h,c=UL(0,t.x-n),d=UL(0,t.y-r),m=UL(0,s-i),u=UL(0,a-l);return n+=c,r+=d,o&&(s+=c,a+=d,n-=m,r-=u),s-=m,a-=u,$L(n,r,s-n,a-r)},create:$L,fromClientRect:e=>$L(e.left,e.top,e.width,e.height)},GL=(()=>{const e={},t={},o={};return{load:(o,n)=>{const r=`Script at URL "${n}" failed to load`,s=`Script at URL "${n}" did not call \`tinymce.Resource.add('${o}', data)\` within 1 second`;if(void 0!==e[o])return e[o];{const a=new Promise(((e,a)=>{const i=((e,t,o=1e3)=>{let n=!1,r=null;const s=e=>(...t)=>{n||(n=!0,null!==r&&(clearTimeout(r),r=null),e.apply(null,t))},a=s(e),i=s(t);return{start:(...e)=>{n||null!==r||(r=setTimeout((()=>i.apply(null,e)),o))},resolve:a,reject:i}})(e,a);t[o]=i.resolve,Ja.ScriptLoader.loadScript(n).then((()=>i.start(s)),(()=>i.reject(r)))}));return e[o]=a,a}},add:(n,r)=>{void 0!==t[n]&&(t[n](r),delete t[n]),e[n]=Promise.resolve(r),o[n]=r},has:e=>e in o,get:e=>o[e],unload:t=>{delete e[t]}}})();let KL;try{const e="__storage_test__";KL=window.localStorage,KL.setItem(e,e),KL.removeItem(e)}catch(e){KL=(()=>{let e={},t=[];const o={getItem:t=>e[t]||null,setItem:(o,n)=>{t.push(o),e[o]=String(n)},key:e=>t[e],removeItem:o=>{t=t.filter((e=>e===o)),delete e[o]},clear:()=>{t=[],e={}},length:0};return Object.defineProperty(o,"length",{get:()=>t.length,configurable:!1,enumerable:!1}),o})()}const YL={geom:{Rect:qL},util:{Delay:qh,Tools:Bt,VK:Dg,URI:px,EventDispatcher:nL,Observable:sL,I18n:ni,LocalStorage:KL,ImageUploader:e=>{const t=xS(),o=ES(e,t);return{upload:(t,n=!0)=>o.upload(t,n?_S(e):void 0)}}},dom:{EventUtils:za,TreeWalker:Zn,TextSeeker:Oi,DOMUtils:Ya,ScriptLoader:Ja,RangeUtils:mh,Serializer:RC,StyleSheetLoader:Zs,ControlSelection:Bg,BookmarkManager:xg,Selection:OC,Event:za.Event},html:{Styles:Aa,Entities:ia,Node:Ep,Schema:ya,DomParser:Mx,Writer:Wp,Serializer:$p},Env:At,AddOnManager:ri,Annotator:wg,Formatter:zS,UndoManager:ZS,EditorCommands:qB,WindowManager:mS,NotificationManager:lS,EditorObservable:mL,Shortcuts:_L,Editor:AL,FocusManager:$h,EditorManager:zL,DOM:Ya.DOM,ScriptLoader:Ja.ScriptLoader,PluginManager:cS,ThemeManager:dS,ModelManager:QC,IconManager:JC,Resource:GL,FakeClipboard:VL,trim:Bt.trim,isArray:Bt.isArray,is:Bt.is,toArray:Bt.toArray,makeMap:Bt.makeMap,each:Bt.each,map:Bt.map,grep:Bt.grep,inArray:Bt.inArray,extend:Bt.extend,walk:Bt.walk,resolve:Bt.resolve,explode:Bt.explode,_addCacheSuffix:Bt._addCacheSuffix},XL=Bt.extend(zL,YL);(e=>{window.tinymce=e,window.tinyMCE=e})(XL),(e=>{try{t.exports=e}catch(e){}})(XL)}();var n=e(o.exports);tinymce.IconManager.add("default",{icons:{"accessibility-check":'',"accordion-toggle":'',accordion:'',"action-next":'',"action-prev":'',addtag:'',"ai-prompt":'',ai:'',"align-center":'',"align-justify":'',"align-left":'',"align-none":'',"align-right":'',"arrow-left":'',"arrow-right":'',bold:'',bookmark:'',"border-style":'',"border-width":'',brightness:'',browse:'',cancel:'',"cell-background-color":'',"cell-border-color":'',"change-case":'',"character-count":'',"checklist-rtl":'',checklist:'',checkmark:'',"chevron-down":'',"chevron-left":'',"chevron-right":'',"chevron-up":'',close:'',"code-sample":'',"color-levels":'',"color-picker":'',"color-swatch-remove-color":'',"color-swatch":'',"comment-add":'',comment:'',contrast:'',copy:'',crop:'',"cut-column":'',"cut-row":'',cut:'',"document-properties":'',drag:'',"duplicate-column":'',"duplicate-row":'',duplicate:'',"edit-block":'',"edit-image":'',"embed-page":'',embed:'',emoji:'',export:'',fill:'',"flip-horizontally":'',"flip-vertically":'',footnote:'',"format-painter":'',format:'',fullscreen:'',gallery:'',gamma:'',help:'',"highlight-bg-color":'',home:'',"horizontal-rule":'',"image-options":'',image:'',indent:'',info:'',"insert-character":'',"insert-time":'',invert:'',italic:'',language:'',"line-height":'',line:'',link:'',"list-bull-circle":'',"list-bull-default":'',"list-bull-square":'',"list-num-default-rtl":'',"list-num-default":'',"list-num-lower-alpha-rtl":'',"list-num-lower-alpha":'',"list-num-lower-greek-rtl":'',"list-num-lower-greek":'',"list-num-lower-roman-rtl":'',"list-num-lower-roman":'',"list-num-upper-alpha-rtl":'',"list-num-upper-alpha":'',"list-num-upper-roman-rtl":'',"list-num-upper-roman":'',lock:'',ltr:'',minus:'',"more-drawer":'',"new-document":'',"new-tab":'',"non-breaking":'',notice:'',"ordered-list-rtl":'',"ordered-list":'',orientation:'',outdent:'',"page-break":'',paragraph:'',"paste-column-after":'',"paste-column-before":'',"paste-row-after":'',"paste-row-before":'',"paste-text":'',paste:'',"permanent-pen":'',plus:'',preferences:'',preview:'',print:'',quote:'',redo:'',reload:'',"remove-formatting":'',remove:'',"resize-handle":'',resize:'',"restore-draft":'',"rotate-left":'',"rotate-right":'',rtl:'',save:'',search:'',"select-all":'',selected:'',send:'',settings:'',sharpen:'',sourcecode:'',"spell-check":'',"strike-through":'',subscript:'',superscript:'',"table-caption":'',"table-cell-classes":'',"table-cell-properties":'',"table-cell-select-all":'',"table-cell-select-inner":'',"table-classes":'',"table-delete-column":'',"table-delete-row":'',"table-delete-table":'',"table-insert-column-after":'',"table-insert-column-before":'',"table-insert-row-above":'',"table-insert-row-after":'',"table-left-header":'',"table-merge-cells":'',"table-row-numbering-rtl":'',"table-row-numbering":'',"table-row-properties":'',"table-split-cells":'',"table-top-header":'',table:'',"template-add":'',template:'',"temporary-placeholder":'',"text-color":'',"text-size-decrease":'',"text-size-increase":'',toc:'',translate:'',typography:'',underline:'',undo:'',unlink:'',unlock:'',"unordered-list":'',unselected:'',upload:'',user:'',"vertical-align":'',visualblocks:'',visualchars:'',warning:'',"zoom-in":'',"zoom-out":''}}),function(){const e=Object.getPrototypeOf,t=(e,t,o)=>{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},o=e=>o=>(e=>{const o=typeof e;return null===e?"null":"object"===o&&Array.isArray(e)?"array":"object"===o&&t(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":o})(o)===e,n=e=>t=>typeof t===e,r=e=>t=>e===t,s=o("string"),a=o("object"),i=o=>((o,n)=>a(o)&&t(o,n,((t,o)=>e(t)===o)))(o,Object),l=o("array"),c=r(null),d=n("boolean"),m=r(void 0),u=e=>null==e,g=e=>!u(e),h=n("function"),p=n("number"),f=(e,t)=>{if(l(e)){for(let o=0,n=e.length;o{},b=e=>()=>e(),y=(e,t)=>(...o)=>e(t.apply(null,o)),w=e=>()=>e,x=e=>e,C=(e,t)=>e===t;function S(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const k=e=>t=>!e(t),_=e=>()=>{throw new Error(e)},E=e=>e(),T=w(!1),O=w(!0);class D{constructor(e,t){this.tag=e,this.value=t}static some(e){return new D(!0,e)}static none(){return D.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?D.some(e(this.value)):D.none()}bind(e){return this.tag?e(this.value):D.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:D.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return g(e)?D.some(e):D.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}D.singletonNone=new D(!1);const A=Array.prototype.slice,M=Array.prototype.indexOf,N=Array.prototype.push,R=(e,t)=>M.call(e,t),B=(e,t)=>{const o=R(e,t);return-1===o?D.none():D.some(o)},L=(e,t)=>R(e,t)>-1,H=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),j=(e,t,o)=>(z(e,((e,n)=>{o=t(o,e,n)})),o),W=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oq(F(e,t)),K=(e,t)=>{for(let o=0,n=e.length;o{const t=A.call(e,0);return t.reverse(),t},X=(e,t)=>Z(e,(e=>!L(t,e))),J=(e,t)=>{const o={};for(let n=0,r=e.length;n[e],ee=(e,t)=>{const o=A.call(e,0);return o.sort(t),o},te=(e,t)=>t>=0&&tte(e,0),ne=e=>te(e,e.length-1),re=h(Array.from)?Array.from:e=>A.call(e),se=(e,t)=>{for(let o=0;o{const o=ae(e);for(let n=0,r=o.length;nde(e,((e,o)=>({k:o,v:t(e,o)}))),de=(e,t)=>{const o={};return le(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},me=e=>(t,o)=>{e[o]=t},ue=(e,t,o,n)=>{le(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},ge=(e,t)=>{const o={};return ue(e,t,me(o),v),o},he=(e,t)=>{const o=[];return le(e,((e,n)=>{o.push(t(e,n))})),o},pe=(e,t)=>{const o=ae(e);for(let n=0,r=o.length;nhe(e,x),ve=(e,t)=>be(e,t)?D.from(e[t]):D.none(),be=(e,t)=>ie.call(e,t),ye=(e,t)=>be(e,t)&&void 0!==e[t]&&null!==e[t],we=(e,t,o=C)=>e.exists((e=>o(e,t))),xe=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te.isSome()&&t.isSome()?D.some(o(e.getOrDie(),t.getOrDie())):D.none(),Se=(e,t)=>null!=e?D.some(t(e)):D.none(),ke=(e,t)=>e?D.some(t):D.none(),_e=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Ee=(e,t)=>Oe(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Te=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!m(n)||r+t.length<=n)},Oe=(e,t)=>_e(e,t,0),De=(e,t)=>_e(e,t,e.length-t.length),Ae=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Me=e=>e.length>0,Ne=e=>!Me(e),Re=e=>void 0!==e.style&&h(e.style.getPropertyValue),Be=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Le={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Be(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return Be(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return Be(o)},fromDom:Be,fromPoint:(e,t,o)=>D.from(e.dom.elementFromPoint(t,o)).map(Be)},He="undefined"!=typeof window?window:Function("return this;")(),Ie=(e,t)=>((e,t)=>{let o=null!=t?t:He;for(let t=0;t{const o=((e,t)=>Ie(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},Fe=Object.getPrototypeOf,ze=e=>{const t=Ie("ownerDocument.defaultView",e);return a(e)&&((e=>Pe("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Fe(e).constructor.name))},Ve=e=>e.dom.nodeName.toLowerCase(),Ze=e=>t=>(e=>e.dom.nodeType)(t)===e,Ue=e=>je(e)&&ze(e.dom),je=Ze(1),We=Ze(3),$e=Ze(9),qe=Ze(11),Ge=e=>t=>je(t)&&Ve(t)===e,Ke=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Ye=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Xe=(e,t)=>e.dom===t.dom,Je=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Qe=e=>Le.fromDom(e.dom.ownerDocument),et=e=>$e(e)?e:Qe(e),tt=e=>Le.fromDom(et(e).dom.documentElement),ot=e=>Le.fromDom(et(e).dom.defaultView),nt=e=>D.from(e.dom.parentNode).map(Le.fromDom),rt=e=>D.from(e.dom.parentElement).map(Le.fromDom),st=e=>D.from(e.dom.offsetParent).map(Le.fromDom),at=e=>F(e.dom.childNodes,Le.fromDom),it=(e,t)=>{const o=e.dom.childNodes;return D.from(o[t]).map(Le.fromDom)},lt=e=>it(e,0),ct=(e,t)=>({element:e,offset:t}),dt=(e,t)=>{const o=at(e);return o.length>0&&tqe(e)&&g(e.dom.host),ut=h(Element.prototype.attachShadow)&&h(Node.prototype.getRootNode),gt=w(ut),ht=ut?e=>Le.fromDom(e.dom.getRootNode()):et,pt=e=>mt(e)?e:Le.fromDom(et(e).dom.body),ft=e=>{const t=ht(e);return mt(t)?D.some(t):D.none()},vt=e=>Le.fromDom(e.dom.host),bt=e=>g(e.dom.shadowRoot),yt=e=>{const t=We(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return ft(Le.fromDom(t)).fold((()=>o.body.contains(t)),(n=yt,r=vt,e=>n(r(e))));var n,r},wt=()=>xt(Le.fromDom(document)),xt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Le.fromDom(t)},Ct=(e,t,o)=>{if(!(s(o)||d(o)||p(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},St=(e,t,o)=>{Ct(e.dom,t,o)},kt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Ct(o,t,e)}))},_t=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Et=(e,t)=>D.from(_t(e,t)),Tt=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},Ot=(e,t)=>{e.dom.removeAttribute(t)},Dt=(e,t,o)=>{if(!s(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Re(e)&&e.style.setProperty(t,o)},At=(e,t)=>{Re(e)&&e.style.removeProperty(t)},Mt=(e,t,o)=>{const n=e.dom;Dt(n,t,o)},Nt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Dt(o,t,e)}))},Rt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{e.fold((()=>{At(o,t)}),(e=>{Dt(o,t,e)}))}))},Bt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||yt(e)?n:Lt(o,t)},Lt=(e,t)=>Re(e)?e.style.getPropertyValue(t):"",Ht=(e,t)=>{const o=e.dom,n=Lt(o,t);return D.from(n).filter((e=>e.length>0))},It=e=>{const t={},o=e.dom;if(Re(o))for(let e=0;e{const n=Le.fromTag(e);Mt(n,t,o);return Ht(n,t).isSome()},Ft=(e,t)=>{const o=e.dom;At(o,t),we(Et(e,"style").map(Ae),"")&&Ot(e,"style")},zt=e=>e.dom.offsetWidth,Vt=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Bt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>j(t,((t,o)=>{const n=Bt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!p(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Re(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Zt=Vt("height",(e=>{const t=e.dom;return yt(e)?t.getBoundingClientRect().height:t.offsetHeight})),Ut=e=>Zt.get(e),jt=e=>Zt.getOuter(e),Wt=(e,t)=>({left:e,top:t,translate:(o,n)=>Wt(e+o,t+n)}),$t=Wt,qt=(e,t)=>void 0!==e?e:void 0!==t?t:0,Gt=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return $t(o.offsetLeft,o.offsetTop);const s=qt(null==n?void 0:n.pageYOffset,r.scrollTop),a=qt(null==n?void 0:n.pageXOffset,r.scrollLeft),i=qt(r.clientTop,o.clientTop),l=qt(r.clientLeft,o.clientLeft);return Kt(e).translate(a-l,s-i)},Kt=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?$t(o.offsetLeft,o.offsetTop):yt(e)?(e=>{const t=e.getBoundingClientRect();return $t(t.left,t.top)})(t):$t(0,0)},Yt=Vt("width",(e=>e.dom.offsetWidth)),Xt=e=>Yt.get(e),Jt=e=>Yt.getOuter(e),Qt=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},eo=()=>to(0,0),to=(e,t)=>({major:e,minor:t}),oo={nu:to,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?eo():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return to(n(1),n(2))})(e,o)},unknown:eo},no=(e,t)=>{const o=String(t).toLowerCase();return W(e,(e=>e.search(o)))},ro=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,so=e=>t=>Te(t,e),ao=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Te(e,"edge/")&&Te(e,"chrome")&&Te(e,"safari")&&Te(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ro],search:e=>Te(e,"chrome")&&!Te(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Te(e,"msie")||Te(e,"trident")},{name:"Opera",versionRegexes:[ro,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:so("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:so("firefox")},{name:"Safari",versionRegexes:[ro,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Te(e,"safari")||Te(e,"mobile/"))&&Te(e,"applewebkit")}],io=[{name:"Windows",search:so("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Te(e,"iphone")||Te(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:so("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:so("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:so("linux"),versionRegexes:[]},{name:"Solaris",search:so("sunos"),versionRegexes:[]},{name:"FreeBSD",search:so("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:so("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],lo={browsers:w(ao),oses:w(io)},co="Edge",mo="Chromium",uo="Opera",go="Firefox",ho="Safari",po=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(co),isChromium:n(mo),isIE:n("IE"),isOpera:n(uo),isFirefox:n(go),isSafari:n(ho)}},fo={unknown:()=>po({current:void 0,version:oo.unknown()}),nu:po,edge:w(co),chromium:w(mo),ie:w("IE"),opera:w(uo),firefox:w(go),safari:w(ho)},vo="Windows",bo="Android",yo="Linux",wo="macOS",xo="Solaris",Co="FreeBSD",So="ChromeOS",ko=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(vo),isiOS:n("iOS"),isAndroid:n(bo),isMacOS:n(wo),isLinux:n(yo),isSolaris:n(xo),isFreeBSD:n(Co),isChromeOS:n(So)}},_o={unknown:()=>ko({current:void 0,version:oo.unknown()}),nu:ko,windows:w(vo),ios:w("iOS"),android:w(bo),linux:w(yo),macos:w(wo),solaris:w(xo),freebsd:w(Co),chromeos:w(So)},Eo=(e,t,o)=>{const n=lo.browsers(),r=lo.oses(),s=t.bind((e=>((e,t)=>se(t.brands,(t=>{const o=t.brand.toLowerCase();return W(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:oo.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>no(e,t).map((e=>{const o=oo.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(fo.unknown,fo.nu),a=((e,t)=>no(e,t).map((e=>{const o=oo.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(_o.unknown,_o.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:w(r),isiPhone:w(s),isTablet:w(l),isPhone:w(c),isTouch:w(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:w(d),isDesktop:w(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},To=e=>window.matchMedia(e).matches;let Oo=Qt((()=>Eo(navigator.userAgent,D.from(navigator.userAgentData),To)));const Do=()=>Oo(),Ao=e=>{const t=Le.fromDom((e=>{if(gt()&&g(e.target)){const t=Le.fromDom(e.target);if(je(t)&&bt(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return oe(t)}}return D.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=y(n,o);return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Mo=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Ao(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:S(No,e,t,s,r)}},No=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Ro=(e,t)=>{nt(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Bo=(e,t)=>{const o=(e=>D.from(e.dom.nextSibling).map(Le.fromDom))(e);o.fold((()=>{nt(e).each((e=>{Ho(e,t)}))}),(e=>{Ro(e,t)}))},Lo=(e,t)=>{lt(e).fold((()=>{Ho(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Ho=(e,t)=>{e.dom.appendChild(t.dom)},Io=(e,t)=>{z(t,(t=>{Ho(e,t)}))},Po=e=>{e.dom.textContent="",z(at(e),(e=>{Fo(e)}))},Fo=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},zo=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return $t(o,n)},Vo=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Zo=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Uo=e=>{const t=void 0===e?window:e,o=t.document,n=zo(Le.fromDom(o));return(e=>{const t=void 0===e?window:e;return Do().browser.isFirefox()?D.none():D.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return Zo(n.left,n.top,o,r)}),(e=>Zo(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},jo=()=>Le.fromDom(document),Wo=(e,t)=>e.view(t).fold(w([]),(t=>{const o=e.owner(t),n=Wo(e,o);return[t].concat(n)}));var $o=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?D.none():D.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(Le.fromDom)},owner:e=>Qe(e)});const qo=e=>{const t=jo(),o=zo(t),n=((e,t)=>{const o=t.owner(e),n=Wo(t,o);return D.some(n)})(e,$o);return n.fold(S(Gt,e),(t=>{const n=Kt(e),r=U(t,((e,t)=>{const o=Kt(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return $t(r.left+n.left+o.left,r.top+n.top+o.top)}))},Go=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Ko=e=>{const t=Gt(e),o=Jt(e),n=jt(e);return Go(t.left,t.top,o,n)},Yo=e=>{const t=qo(e),o=Jt(e),n=jt(e);return Go(t.left,t.top,o,n)},Xo=(e,t)=>{const o=Math.max(e.x,t.x),n=Math.max(e.y,t.y),r=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom);return Go(o,n,r-o,s-n)},Jo=()=>Uo(window);var Qo=tinymce.util.Tools.resolve("tinymce.ThemeManager");const en=e=>{const t=t=>t(e),o=w(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:O,isError:T,map:t=>on.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>D.some(e)};return r},tn=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:T,isError:O,map:t,mapError:t=>on.error(t(e)),bind:t,exists:T,forall:O,getOr:x,or:x,getOrThunk:E,orThunk:E,getOrDie:_(String(e)),each:v,toOptional:D.none};return o},on={value:en,error:tn,fromOption:(e,t)=>e.fold((()=>tn(t)),en)};var nn;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(nn||(nn={}));const rn=(e,t,o)=>e.stype===nn.Error?t(e.serror):o(e.svalue),sn=e=>({stype:nn.Value,svalue:e}),an=e=>({stype:nn.Error,serror:e}),ln=e=>e.fold(an,sn),cn=e=>rn(e,on.error,on.value),dn=sn,mn=e=>{const t=[],o=[];return z(e,(e=>{rn(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}},un=an,gn=(e,t)=>e.stype===nn.Value?t(e.svalue):e,hn=(e,t)=>e.stype===nn.Error?t(e.serror):e,pn=(e,t)=>e.stype===nn.Value?{stype:nn.Value,svalue:t(e.svalue)}:e,fn=(e,t)=>e.stype===nn.Error?{stype:nn.Error,serror:t(e.serror)}:e,vn=rn,bn=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),yn=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},wn=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;ni(e)&&i(t)?xn(e,t):t)),Cn=wn(((e,t)=>t)),Sn=e=>({tag:"defaultedThunk",process:e}),kn=e=>Sn(w(e)),_n=e=>({tag:"mergeWithThunk",process:e}),En=e=>y(un,q)(e),Tn=e=>{const t=mn(e);return t.errors.length>0?En(t.errors):dn(t.values)},On=e=>a(e)&&ae(e).length>100?" removed due to size":JSON.stringify(e,null,2),Dn=(e,t)=>un([{path:e,getErrorInfo:t}]),An=e=>({extract:(t,o)=>hn(e(o),(e=>((e,t)=>Dn(e,w(t)))(t,e))),toString:w("val")}),Mn=An(dn),Nn=(e,t,o,n)=>ve(t,o).fold((()=>((e,t,o)=>Dn(e,(()=>'Could not find valid *required* value for "'+t+'" in '+On(o))))(e,o,t)),n),Rn=(e,t,o,n)=>n(ve(e,t).getOrThunk((()=>o(e)))),Bn=(e,t,o,n,r)=>{const s=e=>r.extract(t.concat([n]),e),a=e=>e.fold((()=>dn(D.none())),(e=>{const o=r.extract(t.concat([n]),e);return pn(o,D.some)}));switch(e.tag){case"required":return Nn(t,o,n,s);case"defaultedThunk":return Rn(o,n,e.process,s);case"option":return((e,t,o)=>o(ve(e,t)))(o,n,a);case"defaultedOptionThunk":return((e,t,o,n)=>n(ve(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,a);case"mergeWithThunk":return Rn(o,n,w({}),(t=>{const n=xn(e.process(o),t);return s(n)}))}},Ln=e=>({extract:(t,o)=>e().extract(t,o),toString:()=>e().toString()}),Hn=e=>ae(ge(e,g)),In=e=>{const t=Pn(e),o=U(e,((e,t)=>yn(t,(t=>xn(e,{[t]:!0})),w(e))),{});return{extract:(e,n)=>{const r=d(n)?[]:Hn(n),s=Z(r,(e=>!ye(o,e)));return 0===s.length?t.extract(e,n):((e,t)=>Dn(e,(()=>"There are unsupported fields: ["+t.join(", ")+"] specified")))(e,s)},toString:t.toString}},Pn=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const s of o)yn(s,((o,s,a,i)=>{const l=Bn(a,e,t,o,i);vn(l,(e=>{r.push(...e)}),(e=>{n[s]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?un(r):dn(n)})(t,o,e),toString:()=>{const t=F(e,(e=>yn(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),Fn=e=>({extract:(t,o)=>{const n=F(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return Tn(n)},toString:()=>"array("+e.toString()+")"}),zn=(e,t)=>{const o=void 0!==t?t:x;return{extract:(t,n)=>{const r=[];for(const s of e){const e=s.extract(t,n);if(e.stype===nn.Value)return{stype:nn.Value,svalue:o(e.svalue)};r.push(e)}return Tn(r)},toString:()=>"oneOf("+F(e,(e=>e.toString())).join(", ")+")"}},Vn=(e,t)=>({extract:(o,n)=>{const r=ae(n),s=((t,o)=>Fn(An(e)).extract(t,o))(o,r);return gn(s,(e=>{const r=F(e,(e=>bn(e,e,{tag:"required",process:{}},t)));return Pn(r).extract(o,n)}))},toString:()=>"setOf("+t.toString()+")"}),Zn=y(Fn,Pn),Un=w(Mn),jn=(e,t)=>An((o=>{const n=typeof o;return e(o)?dn(o):un(`Expected type: ${t} but got: ${n}`)})),Wn=jn(p,"number"),$n=jn(s,"string"),qn=jn(d,"boolean"),Gn=jn(h,"function"),Kn=e=>{if(Object(e)!==e)return!0;switch({}.toString.call(e).slice(8,-1)){case"Boolean":case"Number":case"String":case"Date":case"RegExp":case"Blob":case"FileList":case"ImageData":case"ImageBitmap":case"ArrayBuffer":return!0;case"Array":case"Object":return Object.keys(e).every((t=>Kn(e[t])));default:return!1}},Yn=An((e=>Kn(e)?dn(e):un("Expected value to be acceptable for sending via postMessage"))),Xn=(e,t,o,n)=>ve(o,n).fold((()=>((e,t,o)=>Dn(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+On(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))),Jn=(e,t)=>({extract:(o,n)=>ve(n,e).fold((()=>((e,t)=>Dn(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>Xn(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+ae(t)}),Qn=e=>An((t=>e(t).fold(un,dn))),er=(e,t)=>Vn((t=>ln(e(t))),t),tr=(e,t,o)=>cn(((e,t,o)=>{const n=t.extract([e],o);return fn(n,(e=>({input:o,errors:e})))})(e,t,o)),or=e=>e.fold((e=>{throw new Error(rr(e))}),x),nr=(e,t,o)=>or(tr(e,t,o)),rr=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:w("... (only showing first ten failures)")}]):e;return F(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+On(e.input),sr=(e,t)=>Jn(e,ce(t,Pn)),ar=(e,t)=>((e,t)=>{const o=Qt(t);return{extract:(e,t)=>o().extract(e,t),toString:()=>o().toString()}})(0,t),ir=bn,lr=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),cr=e=>Qn((t=>L(e,t)?on.value(t):on.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`))),dr=e=>ir(e,e,{tag:"required",process:{}},Un()),mr=(e,t)=>ir(e,e,{tag:"required",process:{}},t),ur=e=>mr(e,Wn),gr=e=>mr(e,$n),hr=(e,t)=>ir(e,e,{tag:"required",process:{}},cr(t)),pr=e=>mr(e,Gn),fr=(e,t)=>ir(e,e,{tag:"required",process:{}},Pn(t)),vr=(e,t)=>ir(e,e,{tag:"required",process:{}},Zn(t)),br=(e,t)=>ir(e,e,{tag:"required",process:{}},Fn(t)),yr=e=>ir(e,e,{tag:"option",process:{}},Un()),wr=(e,t)=>ir(e,e,{tag:"option",process:{}},t),xr=e=>wr(e,Wn),Cr=e=>wr(e,$n),Sr=(e,t)=>wr(e,cr(t)),kr=e=>wr(e,Gn),_r=(e,t)=>wr(e,Fn(t)),Er=(e,t)=>wr(e,Pn(t)),Tr=(e,t)=>ir(e,e,kn(t),Un()),Or=(e,t,o)=>ir(e,e,kn(t),o),Dr=(e,t)=>Or(e,t,Wn),Ar=(e,t)=>Or(e,t,$n),Mr=(e,t,o)=>Or(e,t,cr(o)),Nr=(e,t)=>Or(e,t,qn),Rr=(e,t)=>Or(e,t,Gn),Br=(e,t,o)=>Or(e,t,Fn(o)),Lr=(e,t,o)=>Or(e,t,Pn(o)),Hr=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Ir=e=>{if(!l(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return z(e,((n,r)=>{const s=ae(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!l(i))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=ae(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!K(t,(e=>L(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o};Ir([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Pr=(e,t)=>((e,t)=>{const o={};return le(e,((e,n)=>{L(t,n)||(o[n]=e)})),o})(e,t),Fr=(e,t)=>((e,t)=>({[e]:t}))(e,t),zr=e=>(e=>{const t={};return z(e,(e=>{t[e.key]=e.value})),t})(e),Vr=(e,t)=>{const o=(e=>{const t=[],o=[];return z(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})(e);return o.errors.length>0?(n=o.errors,on.error(q(n))):((e,t)=>0===e.length?on.value(t):on.value(xn(t,Cn.apply(void 0,e))))(o.values,t);var n},Zr=e=>h(e)?e:T,Ur=(e,t,o)=>{let n=e.dom;const r=Zr(o);for(;n.parentNode;){n=n.parentNode;const e=Le.fromDom(n),o=t(e);if(o.isSome())return o;if(r(e))break}return D.none()},jr=(e,t,o)=>{const n=t(e),r=Zr(o);return n.orThunk((()=>r(e)?D.none():Ur(e,t,r)))},Wr=(e,t)=>Xe(e.element,t.event.target),$r={can:O,abort:T,run:v},qr=e=>{if(!ye(e,"can")&&!ye(e,"abort")&&!ye(e,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(e,null,2)+" does not have can, abort, or run!");return{...$r,...e}},Gr=e=>{const t=((e,t)=>(...o)=>j(e,((e,n)=>e&&t(n).apply(void 0,o)),!0))(e,(e=>e.can)),o=((e,t)=>(...o)=>j(e,((e,n)=>e||t(n).apply(void 0,o)),!1))(e,(e=>e.abort));return{can:t,abort:o,run:(...t)=>{z(e,(e=>{e.run.apply(void 0,t)}))}}},Kr=w,Yr=Kr("touchstart"),Xr=Kr("touchmove"),Jr=Kr("touchend"),Qr=Kr("touchcancel"),es=Kr("mousedown"),ts=Kr("mousemove"),os=Kr("mouseout"),ns=Kr("mouseup"),rs=Kr("mouseover"),ss=Kr("focusin"),as=Kr("focusout"),is=Kr("keydown"),ls=Kr("keyup"),cs=Kr("input"),ds=Kr("change"),ms=Kr("click"),us=Kr("transitioncancel"),gs=Kr("transitionend"),hs=Kr("transitionstart"),ps=Kr("selectstart"),fs=e=>w("alloy."+e),vs={tap:fs("tap")},bs=fs("focus"),ys=fs("blur.post"),ws=fs("paste.post"),xs=fs("receive"),Cs=fs("execute"),Ss=fs("focus.item"),ks=vs.tap,_s=fs("longpress"),Es=fs("sandbox.close"),Ts=fs("typeahead.cancel"),Os=fs("system.init"),Ds=fs("system.touchmove"),As=fs("system.touchend"),Ms=fs("system.scroll"),Ns=fs("system.resize"),Rs=fs("system.attached"),Bs=fs("system.detached"),Ls=fs("system.dismissRequested"),Hs=fs("system.repositionRequested"),Is=fs("focusmanager.shifted"),Ps=fs("slotcontainer.visibility"),Fs=fs("system.external.element.scroll"),zs=fs("change.tab"),Vs=fs("dismiss.tab"),Zs=fs("highlight"),Us=fs("dehighlight"),js=(e,t)=>{Gs(e,e.element,t,{})},Ws=(e,t,o)=>{Gs(e,e.element,t,o)},$s=e=>{js(e,Cs())},qs=(e,t,o)=>{Gs(e,t,o,{})},Gs=(e,t,o,n)=>{const r={target:t,...n};e.getSystem().triggerEvent(o,t,r)},Ks=(e,t,o,n)=>{e.getSystem().triggerEvent(o,t,n.event)},Ys=e=>zr(e),Xs=(e,t)=>({key:e,value:qr({abort:t})}),Js=e=>({key:e,value:qr({run:(e,t)=>{t.event.prevent()}})}),Qs=(e,t)=>({key:e,value:qr({run:t})}),ea=(e,t,o)=>({key:e,value:qr({run:(e,n)=>{t.apply(void 0,[e,n].concat(o))}})}),ta=e=>t=>({key:e,value:qr({run:(e,o)=>{Wr(e,o)&&t(e,o)}})}),oa=(e,t,o)=>((e,t)=>Qs(e,((o,n)=>{o.getSystem().getByUid(t).each((t=>{Ks(t,t.element,e,n)}))})))(e,t.partUids[o]),na=(e,t)=>Qs(e,((e,o)=>{const n=o.event,r=e.getSystem().getByDom(n.target).getOrThunk((()=>jr(n.target,(t=>e.getSystem().getByDom(t).toOptional()),T).getOr(e)));t(e,r,o)})),ra=e=>Qs(e,((e,t)=>{t.cut()})),sa=e=>Qs(e,((e,t)=>{t.stop()})),aa=(e,t)=>ta(e)(t),ia=ta(Rs()),la=ta(Bs()),ca=ta(Os()),da=(e=>t=>Qs(e,t))(Cs()),ma=e=>e.dom.innerHTML,ua=(e,t)=>{const o=Qe(e).dom,n=Le.fromDom(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,at(Le.fromDom(o))})(t,o);Io(n,r),Po(e),Ho(e,n)},ga=(e,t)=>Le.fromDom(e.dom.cloneNode(t)),ha=e=>{if(mt(e))return"#shadow-root";{const t=(e=>ga(e,!1))(e);return(e=>{const t=Le.fromTag("div"),o=Le.fromDom(e.dom.cloneNode(!0));return Ho(t,o),ma(t)})(t)}},pa=e=>ha(e),fa=Ys([((e,t)=>({key:e,value:qr({can:t})}))(bs(),((e,t)=>{const o=t.event,n=o.originator,r=o.target;return!((e,t,o)=>Xe(t,e.element)&&!Xe(t,o))(e,n,r)||(console.warn(bs()+" did not get interpreted by the desired target. \nOriginator: "+pa(n)+"\nTarget: "+pa(r)+"\nCheck the "+bs()+" event handlers"),!1)}))]);var va=Object.freeze({__proto__:null,events:fa});let ba=0;const ya=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return ba++,e+"_"+o+ba+String(t)},wa=w("alloy-id-"),xa=w("data-alloy-id"),Ca=wa(),Sa=xa(),ka=(e,t)=>{Object.defineProperty(e.dom,Sa,{value:t,writable:!0})},_a=e=>{const t=je(e)?e.dom[Sa]:null;return D.from(t)},Ea=e=>ya(e),Ta=x,Oa=e=>{const t=t=>`The component must be in a context to execute: ${t}`+(e?"\n"+pa(e().element)+" is not in context.":""),o=e=>()=>{throw new Error(t(e))},n=e=>()=>{console.warn(t(e))};return{debugInfo:w("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),build:o("build"),buildOrPatch:o("buildOrPatch"),addToWorld:o("addToWorld"),removeFromWorld:o("removeFromWorld"),addToGui:o("addToGui"),removeFromGui:o("removeFromGui"),getByUid:o("getByUid"),getByDom:o("getByDom"),isConnected:T}},Da=Oa(),Aa=e=>F(e,(e=>De(e,"/*")?e.substring(0,e.length-2):e)),Ma=(e,t)=>{const o=e.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:Aa(s)}),e},Na=ya("alloy-premade"),Ra=e=>(Object.defineProperty(e.element.dom,Na,{value:e.uid,writable:!0}),Fr(Na,e)),Ba=e=>ve(e,Na),La=e=>((e,t)=>{const o=t.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:"OVERRIDE",parameters:Aa(s.slice(1))}),e})(((t,...o)=>e(t.getApis(),t,...o)),e),Ha={init:()=>Ia({readState:w("No State required")})},Ia=e=>e,Pa=(e,t)=>{const o={};return le(e,((e,n)=>{le(e,((e,r)=>{const s=ve(o,r).getOr([]);o[r]=s.concat([t(n,e)])}))})),o},Fa=e=>({classes:m(e.classes)?[]:e.classes,attributes:m(e.attributes)?{}:e.attributes,styles:m(e.styles)?{}:e.styles}),za=e=>e.cHandler,Va=(e,t)=>({name:e,handler:t}),Za=(e,t)=>{const o={};return z(e,(e=>{o[e.name()]=e.handlers(t)})),o},Ua=(e,t,o,n)=>{const r=((e,t,o)=>{const n={...o,...Za(t,e)};return Pa(n,Va)})(e,o,n);return $a(r,t)},ja=e=>{const t=(e=>h(e)?{can:O,abort:T,run:e}:e)(e);return(e,o,...n)=>{const r=[e,o].concat(n);t.abort.apply(void 0,r)?o.stop():t.can.apply(void 0,r)&&t.run.apply(void 0,r)}},Wa=(e,t,o)=>{const n=t[o];return n?((e,t,o,n)=>{try{const r=ee(o,((o,r)=>{const s=o[t],a=r[t],i=n.indexOf(s),l=n.indexOf(a);if(-1===i)throw new Error("The ordering for "+e+" does not have an entry for "+s+".\nOrder specified: "+JSON.stringify(n,null,2));if(-1===l)throw new Error("The ordering for "+e+" does not have an entry for "+a+".\nOrder specified: "+JSON.stringify(n,null,2));return i{const t=F(e,(e=>e.handler));return Gr(t)})):((e,t)=>on.error(["The event ("+e+') 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: '+JSON.stringify(F(t,(e=>e.name)),null,2)]))(o,e)},$a=(e,t)=>{const o=he(e,((e,o)=>(1===e.length?on.value(e[0].handler):Wa(e,t,o)).map((n=>{const r=ja(n),s=e.length>1?Z(t[o],(t=>H(e,(e=>e.name===t)))).join(" > "):e[0].name;return Fr(o,((e,t)=>({handler:e,purpose:t}))(r,s))}))));return Vr(o,{})},qa="alloy.base.behaviour",Ga=Pn([ir("dom","dom",{tag:"required",process:{}},Pn([dr("tag"),Tr("styles",{}),Tr("classes",[]),Tr("attributes",{}),yr("value"),yr("innerHtml")])),dr("components"),dr("uid"),Tr("events",{}),Tr("apis",{}),ir("eventOrder","eventOrder",(e=>_n(w(e)))({[Cs()]:["disabling",qa,"toggling","typeaheadevents"],[bs()]:[qa,"focusing","keying"],[Os()]:[qa,"disabling","toggling","representing"],[cs()]:[qa,"representing","streaming","invalidating"],[Bs()]:[qa,"representing","item-events","tooltipping"],[es()]:["focusing",qa,"item-type-events"],[Yr()]:["focusing",qa,"item-type-events"],[rs()]:["item-type-events","tooltipping"],[xs()]:["receiving","reflecting","tooltipping"]}),Un()),yr("domModification")]),Ka=e=>e.events,Ya=(e,t)=>{const o=_t(e,t);return void 0===o||""===o?[]:o.split(" ")},Xa=e=>void 0!==e.dom.classList,Ja=e=>Ya(e,"class"),Qa=(e,t)=>((e,t,o)=>{const n=Ya(e,t).concat([o]);return St(e,t,n.join(" ")),!0})(e,"class",t),ei=(e,t)=>((e,t,o)=>{const n=Z(Ya(e,t),(e=>e!==o));return n.length>0?St(e,t,n.join(" ")):Ot(e,t),!1})(e,"class",t),ti=(e,t)=>{Xa(e)?e.dom.classList.add(t):Qa(e,t)},oi=e=>{0===(Xa(e)?e.dom.classList:Ja(e)).length&&Ot(e,"class")},ni=(e,t)=>{if(Xa(e)){e.dom.classList.remove(t)}else ei(e,t);oi(e)},ri=(e,t)=>{const o=Xa(e)?e.dom.classList.toggle(t):((e,t)=>L(Ja(e),t)?ei(e,t):Qa(e,t))(e,t);return oi(e),o},si=(e,t)=>Xa(e)&&e.dom.classList.contains(t),ai=(e,t)=>{z(t,(t=>{ti(e,t)}))},ii=(e,t)=>{z(t,(t=>{ni(e,t)}))},li=e=>Xa(e)?(e=>{const t=e.dom.classList,o=new Array(t.length);for(let e=0;ee.dom.value,di=(e,t)=>{if(void 0===t)throw new Error("Value.set was undefined");e.dom.value=t},mi=(e,t,o)=>{o.fold((()=>Ho(e,t)),(e=>{Xe(e,t)||(Ro(e,t),Fo(e))}))},ui=(e,t,o)=>{const n=F(t,o),r=at(e);return z(r.slice(n.length),Fo),n},gi=(e,t,o,n)=>{const r=it(e,t),s=n(o,r),a=((e,t,o)=>it(e,t).map((e=>{if(o.exists((t=>!Xe(t,e)))){const t=o.map(Ve).getOr("span"),n=Le.fromTag(t);return Ro(e,n),n}return e})))(e,t,r);return mi(e,s.element,a),s},hi=(e,t)=>{const o=ae(e),n=ae(t),r=X(n,o),s=((e,t)=>{const o={},n={};return ue(e,t,me(o),me(n)),{t:o,f:n}})(e,((e,o)=>!be(t,o)||e!==t[o])).t;return{toRemove:r,toSet:s}},pi=(e,t)=>{const{class:o,style:n,...r}=(e=>j(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))(t),{toSet:s,toRemove:a}=hi(e.attributes,r),i=It(t),{toSet:l,toRemove:c}=hi(e.styles,i),d=li(t),m=X(d,e.classes),u=X(e.classes,d);return z(a,(e=>Ot(t,e))),kt(t,s),ai(t,u),ii(t,m),z(c,(e=>Ft(t,e))),Nt(t,l),e.innerHtml.fold((()=>{const o=e.domChildren;((e,t)=>{ui(e,t,((t,o)=>{const n=it(e,o);return mi(e,t,n),t}))})(t,o)}),(e=>{ua(t,e)})),(()=>{const o=t,n=e.value.getOrUndefined();n!==ci(o)&&di(o,null!=n?n:"")})(),t},fi=(e,t)=>{const o=t.filter((t=>Ve(t)===e.tag&&!(e=>e.innerHtml.isSome()&&e.domChildren.length>0)(e)&&!(e=>be(e.dom,Na))(t))).bind((t=>((e,t)=>{try{const o=pi(e,t);return D.some(o)}catch(e){return D.none()}})(e,t))).getOrThunk((()=>(e=>{const t=Le.fromTag(e.tag);kt(t,e.attributes),ai(t,e.classes),Nt(t,e.styles),e.innerHtml.each((e=>ua(t,e)));const o=e.domChildren;return Io(t,o),e.value.each((e=>{di(t,e)})),t})(e)));return ka(o,e.uid),o},vi=(e,t)=>((e,t)=>{const o=F(t,(e=>Er(e.name(),[dr("config"),Tr("state",Ha)]))),n=tr("component.behaviours",Pn(o),e.behaviours).fold((t=>{throw new Error(rr(t)+"\nComplete spec:\n"+JSON.stringify(e,null,2))}),x);return{list:t,data:ce(n,(e=>{const t=e.map((e=>({config:e.config,state:e.state.init(e.config)})));return w(t)}))}})(e,t),bi=e=>{const t=(e=>{const t=ve(e,"behaviours").getOr({});return G(ae(t),(e=>{const o=t[e];return g(o)?[o.me]:[]}))})(e);return vi(e,t)},yi=(e,t,o)=>{const n={...(r=e).dom,uid:r.uid,domChildren:F(r.components,(e=>e.element))};var r;const s=(e=>e.domModification.fold((()=>Fa({})),Fa))(e),a={"alloy.base.modification":s},i=t.length>0?((e,t,o,n)=>{const r={...t};z(o,(t=>{r[t.name()]=t.exhibit(e,n)}));const s=Pa(r,((e,t)=>({name:e,modification:t}))),a=e=>U(e,((e,t)=>({...t.modification,...e})),{}),i=U(s.classes,((e,t)=>t.modification.concat(e)),[]),l=a(s.attributes),c=a(s.styles);return Fa({classes:i,attributes:l,styles:c})})(o,a,t,n):s;return l=n,c=i,{...l,attributes:{...l.attributes,...c.attributes},styles:{...l.styles,...c.styles},classes:l.classes.concat(c.classes)};var l,c},wi=(e,t)=>{const o=()=>u,n=Hr(Da),r=or((e=>tr("custom.definition",Ga,e))(e)),s=bi(e),a=(e=>e.list)(s),i=(e=>e.data)(s),l=yi(r,a,i),c=fi(l,t),d=((e,t,o)=>{const n={"alloy.base.behaviour":Ka(e)};return Ua(o,e.eventOrder,t,n).getOrDie()})(r,a,i),m=Hr(r.components),u={uid:e.uid,getSystem:n.get,config:t=>{const o=i;return(h(o[t.name()])?o[t.name()]:()=>{throw new Error("Could not find "+t.name()+" in "+JSON.stringify(e,null,2))})()},hasConfigured:e=>h(i[e.name()]),spec:e,readState:e=>i[e]().map((e=>e.state.readState())).getOr("not enabled"),getApis:()=>r.apis,connect:e=>{n.set(e)},disconnect:()=>{n.set(Oa(o))},element:c,syncComponents:()=>{const e=at(c),t=G(e,(e=>n.get().getByDom(e).fold((()=>[]),Q)));m.set(t)},components:m.get,events:d};return u},xi=(e,t)=>{const{events:o,...n}=Ta(e),r=((e,t)=>{const o=ve(e,"components").getOr([]);return t.fold((()=>F(o,Ei)),(e=>F(o,((t,o)=>_i(t,it(e,o))))))})(n,t),s={...n,events:{...va,...o},components:r};return on.value(wi(s,t))},Ci=e=>{const t=Le.fromText(e);return Si({element:t})},Si=e=>{const t=nr("external.component",In([dr("element"),yr("uid")]),e),o=Hr(Oa()),n=t.uid.getOrThunk((()=>Ea("external")));ka(t.element,n);const r={uid:n,getSystem:o.get,config:D.none,hasConfigured:T,connect:e=>{o.set(e)},disconnect:()=>{o.set(Oa((()=>r)))},getApis:()=>({}),element:t.element,spec:e,readState:w("No state"),syncComponents:v,components:w([]),events:{}};return Ra(r)},ki=Ea,_i=(e,t)=>Ba(e).getOrThunk((()=>{const o=(e=>be(e,"uid"))(e)?e:{uid:ki(""),...e};return xi(o,t).getOrDie()})),Ei=e=>_i(e,D.none()),Ti=Ra;var Oi=(e,t,o,n,r)=>e(o,n)?D.some(o):h(r)&&r(o)?D.none():t(o,n,r);const Di=(e,t,o)=>{let n=e.dom;const r=h(o)?o:T;for(;n.parentNode;){n=n.parentNode;const e=Le.fromDom(n);if(t(e))return D.some(e);if(r(e))break}return D.none()},Ai=(e,t,o)=>Oi(((e,t)=>t(e)),Di,e,t,o),Mi=(e,t,o)=>Ai(e,t,o).isSome(),Ni=(e,t,o)=>Di(e,(e=>Ke(e,t)),o),Ri=(e,t)=>((e,t)=>W(e.dom.childNodes,(e=>t(Le.fromDom(e)))).map(Le.fromDom))(e,(e=>Ke(e,t))),Bi=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ye(o)?D.none():D.from(o.querySelector(e)).map(Le.fromDom)})(t,e),Li=(e,t,o)=>Oi(((e,t)=>Ke(e,t)),Ni,e,t,o),Hi="aria-controls",Ii=()=>{const e=ya(Hi);return{id:e,link:t=>{St(t,Hi,e)},unlink:e=>{Ot(e,Hi)}}},Pi=(e,t)=>(e=>Ai(e,(e=>{if(!je(e))return!1;const t=_t(e,"id");return void 0!==t&&t.indexOf(Hi)>-1})).bind((e=>{const t=_t(e,"id"),o=ht(e);return Bi(o,`[${Hi}="${t}"]`)})))(t).exists((t=>Fi(e,t))),Fi=(e,t)=>Mi(t,(t=>Xe(t,e.element)),T)||Pi(e,t),zi="unknown";var Vi;!function(e){e[e.STOP=0]="STOP",e[e.NORMAL=1]="NORMAL",e[e.LOGGING=2]="LOGGING"}(Vi||(Vi={}));const Zi=Hr({}),Ui=(e,t,o)=>{switch(ve(Zi.get(),e).orThunk((()=>{const t=ae(Zi.get());return se(t,(t=>e.indexOf(t)>-1?D.some(Zi.get()[t]):D.none()))})).getOr(Vi.NORMAL)){case Vi.NORMAL:return o($i());case Vi.LOGGING:{const n=((e,t)=>{const o=[],n=(new Date).getTime();return{logEventCut:(e,t,n)=>{o.push({outcome:"cut",target:t,purpose:n})},logEventStopped:(e,t,n)=>{o.push({outcome:"stopped",target:t,purpose:n})},logNoParent:(e,t,n)=>{o.push({outcome:"no-parent",target:t,purpose:n})},logEventNoHandlers:(e,t)=>{o.push({outcome:"no-handlers-left",target:t})},logEventResponse:(e,t,n)=>{o.push({outcome:"response",purpose:n,target:t})},write:()=>{const r=(new Date).getTime();L(["mousemove","mouseover","mouseout",Os()],e)||console.log(e,{event:e,time:r-n,target:t.dom,sequence:F(o,(e=>L(["cut","stopped","response"],e.outcome)?"{"+e.purpose+"} "+e.outcome+" at ("+pa(e.target)+")":e.outcome))})}}})(e,t),r=o(n);return n.write(),r}case Vi.STOP:return!0}},ji=["alloy/data/Fields","alloy/debugging/Debugging"],Wi=(e,t,o)=>Ui(e,t,o),$i=w({logEventCut:v,logEventStopped:v,logNoParent:v,logEventNoHandlers:v,logEventResponse:v,write:v}),qi=w([dr("menu"),dr("selectedMenu")]),Gi=w([dr("item"),dr("selectedItem")]);w(Pn(Gi().concat(qi())));const Ki=w(Pn(Gi())),Yi=fr("initSize",[dr("numColumns"),dr("numRows")]),Xi=()=>fr("markers",[dr("backgroundMenu")].concat(qi()).concat(Gi())),Ji=e=>fr("markers",F(e,dr)),Qi=(e,t,o)=>((()=>{const e=new Error;if(void 0!==e.stack){const t=e.stack.split("\n");return W(t,(e=>e.indexOf("alloy")>0&&!H(ji,(t=>e.indexOf(t)>-1)))).getOr(zi)}})(),ir(t,t,o,Qn((e=>on.value(((...t)=>e.apply(void 0,t))))))),el=e=>Qi(0,e,kn(v)),tl=e=>Qi(0,e,kn(D.none)),ol=e=>Qi(0,e,{tag:"required",process:{}}),nl=e=>Qi(0,e,{tag:"required",process:{}}),rl=(e,t)=>lr(e,w(t)),sl=e=>lr(e,x),al=w(Yi),il=(e,t,o,n,r,s,a,i=!1)=>({x:e,y:t,bubble:o,direction:n,placement:r,restriction:s,label:`${a}-${r}`,alwaysFit:i}),ll=Ir([{southeast:[]},{southwest:[]},{northeast:[]},{northwest:[]},{south:[]},{north:[]},{east:[]},{west:[]}]),cl=ll.southeast,dl=ll.southwest,ml=ll.northeast,ul=ll.northwest,gl=ll.south,hl=ll.north,pl=ll.east,fl=ll.west,vl=(e,t,o,n)=>{const r=e+t;return r>n?o:rMath.min(Math.max(e,t),o),yl=(e,t)=>J(["left","right","top","bottom"],(o=>ve(t,o).map((t=>((e,t)=>{switch(t){case 1:return e.x;case 0:return e.x+e.width;case 2:return e.y;case 3:return e.y+e.height}})(e,t))))),wl="layout",xl=e=>e.x,Cl=(e,t)=>e.x+e.width/2-t.width/2,Sl=(e,t)=>e.x+e.width-t.width,kl=(e,t)=>e.y-t.height,_l=e=>e.y+e.height,El=(e,t)=>e.y+e.height/2-t.height/2,Tl=(e,t,o)=>il(xl(e),_l(e),o.southeast(),cl(),"southeast",yl(e,{left:1,top:3}),wl),Ol=(e,t,o)=>il(Sl(e,t),_l(e),o.southwest(),dl(),"southwest",yl(e,{right:0,top:3}),wl),Dl=(e,t,o)=>il(xl(e),kl(e,t),o.northeast(),ml(),"northeast",yl(e,{left:1,bottom:2}),wl),Al=(e,t,o)=>il(Sl(e,t),kl(e,t),o.northwest(),ul(),"northwest",yl(e,{right:0,bottom:2}),wl),Ml=(e,t,o)=>il(Cl(e,t),kl(e,t),o.north(),hl(),"north",yl(e,{bottom:2}),wl),Nl=(e,t,o)=>il(Cl(e,t),_l(e),o.south(),gl(),"south",yl(e,{top:3}),wl),Rl=(e,t,o)=>il((e=>e.x+e.width)(e),El(e,t),o.east(),pl(),"east",yl(e,{left:0}),wl),Bl=(e,t,o)=>il(((e,t)=>e.x-t.width)(e,t),El(e,t),o.west(),fl(),"west",yl(e,{right:1}),wl),Ll=()=>[Tl,Ol,Dl,Al,Nl,Ml,Rl,Bl],Hl=()=>[Ol,Tl,Al,Dl,Nl,Ml,Rl,Bl],Il=()=>[Dl,Al,Tl,Ol,Ml,Nl],Pl=()=>[Al,Dl,Ol,Tl,Ml,Nl],Fl=()=>[Tl,Ol,Dl,Al,Nl,Ml],zl=()=>[Ol,Tl,Al,Dl,Nl,Ml];var Vl=Object.freeze({__proto__:null,events:e=>Ys([Qs(xs(),((t,o)=>{const n=e.channels,r=ae(n),s=o,a=((e,t)=>t.universal?e:Z(e,(e=>L(t.channels,e))))(r,s);z(a,(e=>{const o=n[e],r=o.schema,a=nr("channel["+e+"] data\nReceiver: "+pa(t.element),r,s.data);o.onReceive(t,a)}))}))])}),Zl=[mr("channels",er(on.value,In([ol("onReceive"),Tr("schema",Un())])))];const Ul=(e,t,o)=>ca(((n,r)=>{o(n,e,t)})),jl=(e,t,o)=>((e,t,o)=>{const n=o.toString(),r=n.indexOf(")")+1,s=n.indexOf("("),a=n.substring(s+1,r-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:Aa(a.slice(0,1).concat(a.slice(3)))}),e})(((n,...r)=>{const s=[n].concat(r);return n.config({name:w(e)}).fold((()=>{throw new Error("We could not find any behaviour configuration for: "+e+". Using API: "+o)}),(e=>{const o=Array.prototype.slice.call(s,1);return t.apply(void 0,[n,e.config,e.state].concat(o))}))}),o,t),Wl=e=>({key:e,value:void 0}),$l=(e,t,o,n,r,s,a)=>{const i=e=>ye(e,o)?e[o]():D.none(),l=ce(r,((e,t)=>jl(o,e,t))),c={...ce(s,((e,t)=>Ma(e,t))),...l,revoke:S(Wl,o),config:t=>{const n=nr(o+"-config",e,t);return{key:o,value:{config:n,me:c,configAsRaw:Qt((()=>nr(o+"-config",e,t))),initialConfig:t,state:a}}},schema:w(t),exhibit:(e,t)=>Ce(i(e),ve(n,"exhibit"),((e,o)=>o(t,e.config,e.state))).getOrThunk((()=>Fa({}))),name:w(o),handlers:e=>i(e).map((e=>ve(n,"events").getOr((()=>({})))(e.config,e.state))).getOr({})};return c},ql=e=>zr(e),Gl=In([dr("fields"),dr("name"),Tr("active",{}),Tr("apis",{}),Tr("state",Ha),Tr("extra",{})]),Kl=e=>{const t=nr("Creating behaviour: "+e.name,Gl,e);return((e,t,o,n,r,s)=>{const a=In(e),i=Er(t,[(l="config",c=e,wr(l,In(c)))]);var l,c;return $l(a,i,t,o,n,r,s)})(t.fields,t.name,t.active,t.apis,t.extra,t.state)},Yl=In([dr("branchKey"),dr("branches"),dr("name"),Tr("active",{}),Tr("apis",{}),Tr("state",Ha),Tr("extra",{})]),Xl=e=>{const t=nr("Creating behaviour: "+e.name,Yl,e);return((e,t,o,n,r,s)=>{const a=e,i=Er(t,[wr("config",e)]);return $l(a,i,t,o,n,r,s)})(sr(t.branchKey,t.branches),t.name,t.active,t.apis,t.extra,t.state)},Jl=w(void 0),Ql=Kl({fields:Zl,name:"receiving",active:Vl});var ec=Object.freeze({__proto__:null,exhibit:(e,t)=>Fa({classes:[],styles:t.useFixed()?{}:{position:"relative"}})});const tc=(e,t=!1)=>e.dom.focus({preventScroll:t}),oc=e=>e.dom.blur(),nc=e=>{const t=ht(e).dom;return e.dom===t.activeElement},rc=(e=jo())=>D.from(e.dom.activeElement).map(Le.fromDom),sc=e=>rc(ht(e)).filter((t=>e.dom.contains(t.dom))),ac=(e,t)=>{const o=ht(t),n=rc(o).bind((e=>{const o=t=>Xe(e,t);return o(t)?D.some(t):((e,t)=>{const o=e=>{for(let n=0;n{rc(o).filter((t=>Xe(t,e))).fold((()=>{tc(e)}),v)})),r},ic=(e,t,o,n,r)=>{const s=e=>e+"px";return{position:e,left:t.map(s),top:o.map(s),right:n.map(s),bottom:r.map(s)}},lc=(e,t)=>{Rt(e,(e=>({...e,position:D.some(e.position)}))(t))},cc=Ir([{none:[]},{relative:["x","y","width","height"]},{fixed:["x","y","width","height"]}]),dc=(e,t,o,n,r,s)=>{const a=t.rect,i=a.x-o,l=a.y-n,c=r-(i+a.width),d=s-(l+a.height),m=D.some(i),u=D.some(l),g=D.some(c),h=D.some(d),p=D.none();return((e,t,o,n,r,s,a,i,l)=>e.fold(t,o,n,r,s,a,i,l))(t.direction,(()=>ic(e,m,u,p,p)),(()=>ic(e,p,u,g,p)),(()=>ic(e,m,p,p,h)),(()=>ic(e,p,p,g,h)),(()=>ic(e,m,u,p,p)),(()=>ic(e,m,p,p,h)),(()=>ic(e,m,u,p,p)),(()=>ic(e,p,u,g,p)))},mc=(e,t)=>e.fold((()=>{const e=t.rect;return ic("absolute",D.some(e.x),D.some(e.y),D.none(),D.none())}),((e,o,n,r)=>dc("absolute",t,e,o,n,r)),((e,o,n,r)=>dc("fixed",t,e,o,n,r))),uc=(e,t)=>{const o=S(qo,t),n=e.fold(o,o,(()=>{const e=zo();return qo(t).translate(-e.left,-e.top)})),r=Jt(t),s=jt(t);return Go(n.left,n.top,r,s)},gc=(e,t)=>t.fold((()=>e.fold(Jo,Jo,Go)),(t=>e.fold(w(t),w(t),(()=>{const o=hc(e,t.x,t.y);return Go(o.left,o.top,t.width,t.height)})))),hc=(e,t,o)=>{const n=$t(t,o);return e.fold(w(n),w(n),(()=>{const e=zo();return n.translate(-e.left,-e.top)}))};cc.none;const pc=cc.relative,fc=cc.fixed,vc=(e,t)=>((e,t)=>({anchorBox:e,origin:t}))(e,t),bc="data-alloy-placement",yc=e=>Et(e,bc),wc=Ir([{fit:["reposition"]},{nofit:["reposition","visibleW","visibleH","isVisible"]}]),xc=(e,t,o,n)=>{const r=e.bubble,s=r.offset,a=((e,t,o)=>{const n=(n,r)=>t[n].map((t=>{const s="top"===n||"bottom"===n,a=s?o.top:o.left,i=("left"===n||"top"===n?Math.max:Math.min)(t,r)+a;return s?bl(i,e.y,e.bottom):bl(i,e.x,e.right)})).getOr(r),r=n("left",e.x),s=n("top",e.y),a=n("right",e.right),i=n("bottom",e.bottom);return Go(r,s,a-r,i-s)})(n,e.restriction,s),i=e.x+s.left,l=e.y+s.top,c=Go(i,l,t,o),{originInBounds:d,sizeInBounds:m,visibleW:u,visibleH:g}=((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,right:l,bottom:c,width:d,height:m}=e;return{originInBounds:a>=o&&a<=r&&i>=n&&i<=s,sizeInBounds:l<=r&&l>=o&&c<=s&&c>=n,visibleW:Math.min(d,a>=o?r-a:l-o),visibleH:Math.min(m,i>=n?s-i:c-n)}})(c,a),h=d&&m,p=h?c:((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,width:l,height:c}=e,d=Math.max(o,r-l),m=Math.max(n,s-c),u=bl(a,o,d),g=bl(i,n,m),h=Math.min(u+l,r)-u,p=Math.min(g+c,s)-g;return Go(u,g,h,p)})(c,a),f=p.width>0&&p.height>0,{maxWidth:v,maxHeight:b}=((e,t,o)=>{const n=w(t.bottom-o.y),r=w(o.bottom-t.y),s=((e,t,o,n)=>e.fold(t,t,n,n,t,n,o,o))(e,r,r,n),a=w(t.right-o.x),i=w(o.right-t.x),l=((e,t,o,n)=>e.fold(t,n,t,n,o,o,t,n))(e,i,i,a);return{maxWidth:l,maxHeight:s}})(e.direction,p,n),y={rect:p,maxHeight:b,maxWidth:v,direction:e.direction,placement:e.placement,classes:{on:r.classesOn,off:r.classesOff},layout:e.label,testY:l};return h||e.alwaysFit?wc.fit(y):wc.nofit(y,u,g,f)},Cc=e=>{const t=Hr(D.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(D.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(D.some(e))}}},Sc=()=>Cc((e=>e.unbind())),kc=()=>{const e=Cc(v);return{...e,on:t=>e.get().each(t)}},_c=O,Ec=(e,t,o)=>((e,t,o,n)=>Mo(e,t,o,n,!1))(e,t,_c,o),Tc=(e,t,o)=>((e,t,o,n)=>Mo(e,t,o,n,!0))(e,t,_c,o),Oc=Ao,Dc=["top","bottom","right","left"],Ac="data-alloy-transition-timer",Mc=(e,t)=>((e,t)=>K(t,(t=>si(e,t))))(e,t.classes),Nc=(e,t)=>{const o=e=>parseFloat(e).toFixed(3);return pe(t,((t,n)=>!((e,t,o=C)=>Ce(e,t,o).getOr(e.isNone()&&t.isNone()))(e[n].map(o),t.map(o)))).isSome()},Rc=(e,t)=>{const o=Sc(),n=Sc();let r;const a=t=>{var o;const n=null!==(o=t.raw.pseudoElement)&&void 0!==o?o:"";return Xe(t.target,e)&&Ne(n)&&L(Dc,t.raw.propertyName)},i=s=>{if(u(s)||a(s)){o.clear(),n.clear();const a=null==s?void 0:s.raw.type;(u(a)||a===gs())&&(clearTimeout(r),Ot(e,Ac),ii(e,t.classes))}},l=Ec(e,hs(),(t=>{a(t)&&(l.unbind(),o.set(Ec(e,gs(),i)),n.set(Ec(e,us(),i)))})),c=(e=>{const t=t=>{const o=Bt(e,t).split(/\s*,\s*/);return Z(o,Me)},o=e=>{if(s(e)&&/^[\d.]+/.test(e)){const t=parseFloat(e);return De(e,"ms")?t:1e3*t}return 0},n=t("transition-delay"),r=t("transition-duration");return j(r,((e,t,r)=>{const s=o(n[r])+o(t);return Math.max(e,s)}),0)})(e);requestAnimationFrame((()=>{r=setTimeout(i,c+17),St(e,Ac,r)}))},Bc=(e,t,o,n,r,s)=>{const a=((e,t,o)=>o.exists((o=>{const n=e.mode;return"all"===n||o[n]!==t[n]})))(n,r,s);if(a||Mc(e,n)){Mt(e,"position",o.position);const s=uc(t,e),i=mc(t,{...r,rect:s}),l=J(Dc,(e=>i[e]));Nc(o,l)&&(Rt(e,l),a&&((e,t)=>{ai(e,t.classes),Et(e,Ac).each((t=>{clearTimeout(parseInt(t,10)),Ot(e,Ac)})),Rc(e,t)})(e,n),zt(e))}else ii(e,n.classes)},Lc=(e,t,o,n)=>{Ft(t,"max-height"),Ft(t,"max-width");const r={width:Jt(s=t),height:jt(s)};var s;return((e,t,o,n,r,s)=>{const a=n.width,i=n.height,l=(t,l,c,d,m)=>{const u=t(o,n,r,e,s),g=xc(u,a,i,s);return g.fold(w(g),((e,t,o,n)=>(m===n?o>d||t>c:!m&&n)?g:wc.nofit(l,c,d,m)))},c=j(t,((e,t)=>{const o=S(l,t);return e.fold(w(e),o)}),wc.nofit({rect:o,maxHeight:n.height,maxWidth:n.width,direction:cl(),placement:"southeast",classes:{on:[],off:[]},layout:"none",testY:o.y},-1,-1,!1));return c.fold(x,x)})(t,n.preference,e,r,o,n.bounds)},Hc=(e,t)=>{((e,t)=>{St(e,bc,t)})(e,t.placement)},Ic=(e,t)=>{((e,t)=>{const o=Zt.max(e,t,["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"]);Mt(e,"max-height",o+"px")})(e,Math.floor(t))},Pc=w(((e,t)=>{Ic(e,t),Nt(e,{"overflow-x":"hidden","overflow-y":"auto"})})),Fc=w(((e,t)=>{Ic(e,t)})),zc=(e,t,o)=>void 0===e[t]?o:e[t],Vc=(e,t,o,n)=>{const r=Lc(e,t,o,n);return((e,t,o)=>{const n=mc(o.origin,t);o.transition.each((r=>{Bc(e,o.origin,n,r,t,o.lastPlacement)})),lc(e,n)})(t,r,n),Hc(t,r),((e,t)=>{const o=t.classes;ii(e,o.off),ai(e,o.on)})(t,r),((e,t,o)=>{(0,o.maxHeightFunction)(e,t.maxHeight)})(t,r,n),((e,t,o)=>{(0,o.maxWidthFunction)(e,t.maxWidth)})(t,r,n),{layout:r.layout,placement:r.placement}},Zc=["valignCentre","alignLeft","alignRight","alignCentre","top","bottom","left","right","inset"],Uc=(e,t,o,n=1)=>{const r=e*n,s=t*n,a=e=>ve(o,e).getOr([]),i=(e,t,o)=>{const n=X(Zc,o);return{offset:$t(e,t),classesOn:G(o,a),classesOff:G(n,a)}};return{southeast:()=>i(-e,t,["top","alignLeft"]),southwest:()=>i(e,t,["top","alignRight"]),south:()=>i(-e/2,t,["top","alignCentre"]),northeast:()=>i(-e,-t,["bottom","alignLeft"]),northwest:()=>i(e,-t,["bottom","alignRight"]),north:()=>i(-e/2,-t,["bottom","alignCentre"]),east:()=>i(e,-t/2,["valignCentre","left"]),west:()=>i(-e,-t/2,["valignCentre","right"]),insetNortheast:()=>i(r,s,["top","alignLeft","inset"]),insetNorthwest:()=>i(-r,s,["top","alignRight","inset"]),insetNorth:()=>i(-r/2,s,["top","alignCentre","inset"]),insetSoutheast:()=>i(r,-s,["bottom","alignLeft","inset"]),insetSouthwest:()=>i(-r,-s,["bottom","alignRight","inset"]),insetSouth:()=>i(-r/2,-s,["bottom","alignCentre","inset"]),insetEast:()=>i(-r,-s/2,["valignCentre","right","inset"]),insetWest:()=>i(r,-s/2,["valignCentre","left","inset"])}},jc=()=>Uc(0,0,{}),Wc=x,$c=(e,t)=>o=>"rtl"===qc(o)?t:e,qc=e=>"rtl"===Bt(e,"direction")?"rtl":"ltr";var Gc;!function(e){e.TopToBottom="toptobottom",e.BottomToTop="bottomtotop"}(Gc||(Gc={}));const Kc="data-alloy-vertical-dir",Yc=e=>Mi(e,(e=>je(e)&&_t(e,"data-alloy-vertical-dir")===Gc.BottomToTop)),Xc=()=>Er("layouts",[dr("onLtr"),dr("onRtl"),yr("onBottomLtr"),yr("onBottomRtl")]),Jc=(e,t,o,n,r,s,a)=>{const i=a.map(Yc).getOr(!1),l=t.layouts.map((t=>t.onLtr(e))),c=t.layouts.map((t=>t.onRtl(e))),d=i?t.layouts.bind((t=>t.onBottomLtr.map((t=>t(e))))).or(l).getOr(r):l.getOr(o),m=i?t.layouts.bind((t=>t.onBottomRtl.map((t=>t(e))))).or(c).getOr(s):c.getOr(n);return $c(d,m)(e)};var Qc=[dr("hotspot"),yr("bubble"),Tr("overrides",{}),Xc(),rl("placement",((e,t,o)=>{const n=t.hotspot,r=uc(o,n.element),s=Jc(e.element,t,Fl(),zl(),Il(),Pl(),D.some(t.hotspot.element));return D.some(Wc({anchorBox:r,bubble:t.bubble.getOr(jc()),overrides:t.overrides,layouts:s}))}))];var ed=[dr("x"),dr("y"),Tr("height",0),Tr("width",0),Tr("bubble",jc()),Tr("overrides",{}),Xc(),rl("placement",((e,t,o)=>{const n=hc(o,t.x,t.y),r=Go(n.left,n.top,t.width,t.height),s=Jc(e.element,t,Ll(),Hl(),Ll(),Hl(),D.none());return D.some(Wc({anchorBox:r,bubble:t.bubble,overrides:t.overrides,layouts:s}))}))];const td=Ir([{screen:["point"]},{absolute:["point","scrollLeft","scrollTop"]}]),od=e=>e.fold(x,((e,t,o)=>e.translate(-t,-o))),nd=e=>e.fold(x,x),rd=e=>j(e,((e,t)=>e.translate(t.left,t.top)),$t(0,0)),sd=e=>{const t=F(e,nd);return rd(t)},ad=td.screen,id=td.absolute,ld=(e,t,o)=>{const n=Qe(e.element),r=zo(n),s=((e,t,o)=>{const n=ot(o.root).dom;return D.from(n.frameElement).map(Le.fromDom).filter((t=>{const o=Qe(t),n=Qe(e.element);return Xe(o,n)})).map(Gt)})(e,0,o).getOr(r);return id(s,r.left,r.top)},cd=(e,t,o,n)=>{const r=ad($t(e,t));return D.some(((e,t,o)=>({point:e,width:t,height:o}))(r,o,n))},dd=(e,t,o,n,r)=>e.map((e=>{const s=[t,e.point],a=(i=()=>sd(s),l=()=>sd(s),c=()=>(e=>{const t=F(e,od);return rd(t)})(s),n.fold(i,l,c));var i,l,c;const d=((e,t,o,n)=>({x:e,y:t,width:o,height:n}))(a.left,a.top,e.width,e.height),m=o.showAbove?Il():Fl(),u=o.showAbove?Pl():zl(),g=Jc(r,o,m,u,m,u,D.none());return Wc({anchorBox:d,bubble:o.bubble.getOr(jc()),overrides:o.overrides,layouts:g})}));var md=[dr("node"),dr("root"),yr("bubble"),Xc(),Tr("overrides",{}),Tr("showAbove",!1),rl("placement",((e,t,o)=>{const n=ld(e,0,t);return t.node.filter(yt).bind((r=>{const s=r.dom.getBoundingClientRect(),a=cd(s.left,s.top,s.width,s.height),i=t.node.getOr(e.element);return dd(a,n,t,o,i)}))}))];const ud=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),gd=Ir([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),hd=(gd.before,gd.on,gd.after,e=>e.fold(x,x,x)),pd=Ir([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),fd={domRange:pd.domRange,relative:pd.relative,exact:pd.exact,exactFromRange:e=>pd.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Le.fromDom(e.startContainer),relative:(e,t)=>hd(e),exact:(e,t,o,n)=>e}))(e);return ot(t)},range:ud},vd=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},bd=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},yd=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),wd=Ir([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),xd=(e,t,o)=>t(Le.fromDom(o.startContainer),o.startOffset,Le.fromDom(o.endContainer),o.endOffset),Cd=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:w(e),rtl:D.none}),relative:(t,o)=>({ltr:Qt((()=>vd(e,t,o))),rtl:Qt((()=>D.some(vd(e,o,t))))}),exact:(t,o,n,r)=>({ltr:Qt((()=>bd(e,t,o,n,r))),rtl:Qt((()=>D.some(bd(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();if(o.collapsed)return t.rtl().filter((e=>!1===e.collapsed)).map((e=>wd.rtl(Le.fromDom(e.endContainer),e.endOffset,Le.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>xd(0,wd.ltr,o)));return xd(0,wd.ltr,o)})(0,o)},Sd=(e,t)=>Cd(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});wd.ltr,wd.rtl;const kd=(e,t,o)=>Z(((e,t)=>{const o=h(t)?t:T;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Le.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r})(e,o),t),_d=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ye(o)?[]:F(o.querySelectorAll(e),Le.fromDom)})(t,e),Ed=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Qe(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Xe(e,o)&&t===n;return r.collapsed&&!s},Td=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return D.some(ud(Le.fromDom(t.startContainer),t.startOffset,Le.fromDom(o.endContainer),o.endOffset))}return D.none()},Od=e=>{if(null===e.anchorNode||null===e.focusNode)return Td(e);{const t=Le.fromDom(e.anchorNode),o=Le.fromDom(e.focusNode);return Ed(t,e.anchorOffset,o,e.focusOffset)?D.some(ud(t,e.anchorOffset,o,e.focusOffset)):Td(e)}},Dd=e=>(e=>D.from(e.getSelection()))(e).filter((e=>e.rangeCount>0)).bind(Od),Ad=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?D.some(o).map(yd):D.none()})(Sd(e,t)),Md=(e,t)=>(e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0?D.some(t).map(yd):D.none()})(Sd(e,t)),Nd=((e,t)=>{const o=t=>e(t)?D.from(t.dom.nodeValue):D.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(We,"text"),Rd=(e,t)=>({element:e,offset:t}),Bd=(e,t)=>{const o=at(e);if(0===o.length)return Rd(e,t);if(tNd.get(e))(e).length:at(e).length;return Rd(e,t)}},Ld=(e,t)=>We(e)?Rd(e,t):Bd(e,t),Hd=e=>void 0!==e.foffset,Id=(e,t)=>t.getSelection.getOrThunk((()=>()=>Dd(e)))().map((e=>{if(Hd(e)){const t=Ld(e.start,e.soffset),o=Ld(e.finish,e.foffset);return fd.range(t.element,t.offset,o.element,o.offset)}return e}));var Pd=[yr("getSelection"),dr("root"),yr("bubble"),Xc(),Tr("overrides",{}),Tr("showAbove",!1),rl("placement",((e,t,o)=>{const n=ot(t.root).dom,r=ld(e,0,t),s=Id(n,t).bind((e=>{if(Hd(e)){const t=Md(n,fd.exactFromRange(e)).orThunk((()=>{const t=Le.fromText("\ufeff");Ro(e.start,t);const o=Ad(n,fd.exact(t,0,t,1));return Fo(t),o}));return t.bind((e=>cd(e.left,e.top,e.width,e.height)))}{const t=ce(e,(e=>e.dom.getBoundingClientRect())),o={left:Math.min(t.firstCell.left,t.lastCell.left),right:Math.max(t.firstCell.right,t.lastCell.right),top:Math.min(t.firstCell.top,t.lastCell.top),bottom:Math.max(t.firstCell.bottom,t.lastCell.bottom)};return cd(o.left,o.top,o.right-o.left,o.bottom-o.top)}})),a=Id(n,t).bind((e=>Hd(e)?je(e.start)?D.some(e.start):rt(e.start):D.some(e.firstCell))).getOr(e.element);return dd(s,r,t,o,a)}))];const Fd="link-layout",zd=e=>e.x+e.width,Vd=(e,t)=>e.x-t.width,Zd=(e,t)=>e.y-t.height+e.height,Ud=e=>e.y,jd=(e,t,o)=>il(zd(e),Ud(e),o.southeast(),cl(),"southeast",yl(e,{left:0,top:2}),Fd),Wd=(e,t,o)=>il(Vd(e,t),Ud(e),o.southwest(),dl(),"southwest",yl(e,{right:1,top:2}),Fd),$d=(e,t,o)=>il(zd(e),Zd(e,t),o.northeast(),ml(),"northeast",yl(e,{left:0,bottom:3}),Fd),qd=(e,t,o)=>il(Vd(e,t),Zd(e,t),o.northwest(),ul(),"northwest",yl(e,{right:1,bottom:3}),Fd),Gd=()=>[jd,Wd,$d,qd],Kd=()=>[Wd,jd,qd,$d];var Yd=[dr("item"),Xc(),Tr("overrides",{}),rl("placement",((e,t,o)=>{const n=uc(o,t.item.element),r=Jc(e.element,t,Gd(),Kd(),Gd(),Kd(),D.none());return D.some(Wc({anchorBox:n,bubble:jc(),overrides:t.overrides,layouts:r}))}))],Xd=sr("type",{selection:Pd,node:md,hotspot:Qc,submenu:Yd,makeshift:ed});const Jd=[br("classes",$n),Mr("mode","all",["all","layout","placement"])],Qd=[Tr("useFixed",T),yr("getBounds")],em=[mr("anchor",Xd),Er("transition",Jd)],tm=(e,t,o,n,r,s)=>((e,t,o,n,r,s,a,i)=>{const l=zc(a,"maxHeightFunction",Pc()),c=zc(a,"maxWidthFunction",v),d=e.anchorBox,m=e.origin,u={bounds:gc(m,s),origin:m,preference:n,maxHeightFunction:l,maxWidthFunction:c,lastPlacement:r,transition:i};return Vc(d,t,o,u)})(vc(t.anchorBox,e),n.element,t.bubble,t.layouts,r,o,t.overrides,s),om=(e,t,o,n,r,s)=>{const a=nr("placement.info",Pn(em),r),i=a.anchor,l=n.element,c=o.get(n.uid);ac((()=>{Mt(l,"position","fixed");const r=Ht(l,"visibility");Mt(l,"visibility","hidden");const d=t.useFixed()?(()=>{const e=document.documentElement;return fc(0,0,e.clientWidth,e.clientHeight)})():(e=>{const t=Gt(e.element),o=e.element.dom.getBoundingClientRect();return pc(t.left,t.top,o.width,o.height)})(e);i.placement(e,i,d).each((e=>{const r=s.orThunk((()=>t.getBounds.map(E))),i=tm(d,e,r,n,c,a.transition);o.set(n.uid,i)})),r.fold((()=>{Ft(l,"visibility")}),(e=>{Mt(l,"visibility",e)})),Ht(l,"left").isNone()&&Ht(l,"top").isNone()&&Ht(l,"right").isNone()&&Ht(l,"bottom").isNone()&&we(Ht(l,"position"),"fixed")&&Ft(l,"position")}),l)};var nm=Object.freeze({__proto__:null,position:(e,t,o,n,r)=>{const s=D.none();om(e,t,o,n,r,s)},positionWithinBounds:om,getMode:(e,t,o)=>t.useFixed()?"fixed":"absolute",reset:(e,t,o,n)=>{const r=n.element;z(["position","left","right","top","bottom"],(e=>Ft(r,e))),(e=>{Ot(e,bc)})(r),o.clear(n.uid)}});const rm=Kl({fields:Qd,name:"positioning",active:ec,apis:nm,state:Object.freeze({__proto__:null,init:()=>{let e={};return Ia({readState:()=>e,clear:t=>{g(t)?delete e[t]:e={}},set:(t,o)=>{e[t]=o},get:t=>ve(e,t)})}})}),sm=e=>e.getSystem().isConnected(),am=e=>{js(e,Bs());const t=e.components();z(t,am)},im=e=>{const t=e.components();z(t,im),js(e,Rs())},lm=(e,t)=>{e.getSystem().addToWorld(t),yt(e.element)&&im(t)},cm=e=>{am(e),e.getSystem().removeFromWorld(e)},dm=(e,t)=>{Ho(e.element,t.element)},mm=(e,t,o)=>{const n=e.components();(e=>{z(e.components(),(e=>Fo(e.element))),Po(e.element),e.syncComponents()})(e);const r=o(t),s=X(n,r);z(s,(t=>{am(t),e.getSystem().removeFromWorld(t)})),z(r,(t=>{sm(t)?dm(e,t):(e.getSystem().addToWorld(t),dm(e,t),yt(e.element)&&im(t))})),e.syncComponents()},um=(e,t)=>{gm(e,t,Ho)},gm=(e,t,o)=>{e.getSystem().addToWorld(t),o(e.element,t.element),yt(e.element)&&im(t),e.syncComponents()},hm=e=>{am(e),Fo(e.element),e.getSystem().removeFromWorld(e)},pm=e=>{const t=nt(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()));hm(e),t.each((e=>{e.syncComponents()}))},fm=e=>{const t=e.components();z(t,hm),Po(e.element),e.syncComponents()},vm=(e,t)=>{ym(e,t,Ho)},bm=(e,t)=>{ym(e,t,Bo)},ym=(e,t,o)=>{o(e,t.element);const n=at(t.element);z(n,(e=>{t.getByDom(e).each(im)}))},wm=e=>{const t=at(e.element);z(t,(t=>{e.getByDom(t).each(am)})),Fo(e.element)},xm=(e,t,o,n)=>{o.get().each((t=>{fm(e)}));const r=t.getAttachPoint(e);um(r,e);const s=e.getSystem().build(n);return um(e,s),o.set(s),s},Cm=(e,t,o,n)=>{const r=xm(e,t,o,n);return t.onOpen(e,r),r},Sm=(e,t,o)=>{o.get().each((n=>{fm(e),pm(e),t.onClose(e,n),o.clear()}))},km=(e,t,o)=>o.isOpen(),_m=(e,t,o)=>{const n=t.getAttachPoint(e);Mt(e.element,"position",rm.getMode(n)),((e,t,o,n)=>{Ht(e.element,t).fold((()=>{Ot(e.element,o)}),(t=>{St(e.element,o,t)})),Mt(e.element,t,n)})(e,"visibility",t.cloakVisibilityAttr,"hidden")},Em=(e,t,o)=>{(e=>H(["top","left","right","bottom"],(t=>Ht(e,t).isSome())))(e.element)||Ft(e.element,"position"),((e,t,o)=>{Et(e.element,o).fold((()=>Ft(e.element,t)),(o=>Mt(e.element,t,o)))})(e,"visibility",t.cloakVisibilityAttr)};var Tm=Object.freeze({__proto__:null,cloak:_m,decloak:Em,open:Cm,openWhileCloaked:(e,t,o,n,r)=>{_m(e,t),Cm(e,t,o,n),r(),Em(e,t)},close:Sm,isOpen:km,isPartOf:(e,t,o,n)=>km(0,0,o)&&o.get().exists((o=>t.isPartOf(e,o,n))),getState:(e,t,o)=>o.get(),setContent:(e,t,o,n)=>o.get().map((()=>xm(e,t,o,n)))});var Om=Object.freeze({__proto__:null,events:(e,t)=>Ys([Qs(Es(),((o,n)=>{Sm(o,e,t)}))])}),Dm=[el("onOpen"),el("onClose"),dr("isPartOf"),dr("getAttachPoint"),Tr("cloakVisibilityAttr","data-precloak-visibility")];var Am=Object.freeze({__proto__:null,init:()=>{const e=kc(),t=w("not-implemented");return Ia({readState:t,isOpen:e.isSet,clear:e.clear,set:e.set,get:e.get})}});const Mm=Kl({fields:Dm,name:"sandboxing",active:Om,apis:Tm,state:Am}),Nm=w("dismiss.popups"),Rm=w("reposition.popups"),Bm=w("mouse.released"),Lm=In([Tr("isExtraPart",T),Er("fireEventInstead",[Tr("event",Ls())])]),Hm=e=>{const t=nr("Dismissal",Lm,e);return{[Nm()]:{schema:In([dr("target")]),onReceive:(e,o)=>{if(Mm.isOpen(e)){Mm.isPartOf(e,o.target)||t.isExtraPart(e,o.target)||t.fireEventInstead.fold((()=>Mm.close(e)),(t=>js(e,t.event)))}}}}},Im=In([Er("fireEventInstead",[Tr("event",Hs())]),pr("doReposition")]),Pm=e=>{const t=nr("Reposition",Im,e);return{[Rm()]:{onReceive:e=>{Mm.isOpen(e)&&t.fireEventInstead.fold((()=>t.doReposition(e)),(t=>js(e,t.event)))}}}},Fm=(e,t,o)=>{t.store.manager.onLoad(e,t,o)},zm=(e,t,o)=>{t.store.manager.onUnload(e,t,o)};var Vm=Object.freeze({__proto__:null,onLoad:Fm,onUnload:zm,setValue:(e,t,o,n)=>{t.store.manager.setValue(e,t,o,n)},getValue:(e,t,o)=>t.store.manager.getValue(e,t,o),getState:(e,t,o)=>o});var Zm=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.resetOnDom?[ia(((o,n)=>{Fm(o,e,t)})),la(((o,n)=>{zm(o,e,t)}))]:[Ul(e,t,Fm)];return Ys(o)}});const Um=()=>{const e=Hr(null);return Ia({set:e.set,get:e.get,isNotSet:()=>null===e.get(),clear:()=>{e.set(null)},readState:()=>({mode:"memory",value:e.get()})})},jm=()=>{const e=Hr({}),t=Hr({});return Ia({readState:()=>({mode:"dataset",dataByValue:e.get(),dataByText:t.get()}),lookup:o=>ve(e.get(),o).orThunk((()=>ve(t.get(),o))),update:o=>{const n=e.get(),r=t.get(),s={},a={};z(o,(e=>{s[e.value]=e,ve(e,"meta").each((t=>{ve(t,"text").each((t=>{a[t]=e}))}))})),e.set({...n,...s}),t.set({...r,...a})},clear:()=>{e.set({}),t.set({})}})};var Wm=Object.freeze({__proto__:null,memory:Um,dataset:jm,manual:()=>Ia({readState:v}),init:e=>e.store.manager.state(e)});const $m=(e,t,o,n)=>{const r=t.store;o.update([n]),r.setValue(e,n),t.onSetValue(e,n)};var qm=[yr("initialValue"),dr("getFallbackEntry"),dr("getDataKey"),dr("setValue"),rl("manager",{setValue:$m,getValue:(e,t,o)=>{const n=t.store,r=n.getDataKey(e);return o.lookup(r).getOrThunk((()=>n.getFallbackEntry(r)))},onLoad:(e,t,o)=>{t.store.initialValue.each((n=>{$m(e,t,o,n)}))},onUnload:(e,t,o)=>{o.clear()},state:jm})];var Gm=[dr("getValue"),Tr("setValue",v),yr("initialValue"),rl("manager",{setValue:(e,t,o,n)=>{t.store.setValue(e,n),t.onSetValue(e,n)},getValue:(e,t,o)=>t.store.getValue(e),onLoad:(e,t,o)=>{t.store.initialValue.each((o=>{t.store.setValue(e,o)}))},onUnload:v,state:Ha.init})];var Km=[yr("initialValue"),rl("manager",{setValue:(e,t,o,n)=>{o.set(n),t.onSetValue(e,n)},getValue:(e,t,o)=>o.get(),onLoad:(e,t,o)=>{t.store.initialValue.each((e=>{o.isNotSet()&&o.set(e)}))},onUnload:(e,t,o)=>{o.clear()},state:Um})],Ym=[Or("store",{mode:"memory"},sr("mode",{memory:Km,manual:Gm,dataset:qm})),el("onSetValue"),Tr("resetOnDom",!1)];const Xm=Kl({fields:Ym,name:"representing",active:Zm,apis:Vm,extra:{setValueFrom:(e,t)=>{const o=Xm.getValue(t);Xm.setValue(e,o)}},state:Wm}),Jm=(e,t)=>Lr(e,{},F(t,(t=>{return o=t.name(),n="Cannot configure "+t.name()+" for "+e,ir(o,o,{tag:"option",process:{}},An((e=>un("The field: "+o+" is forbidden. "+n))));var o,n})).concat([lr("dump",x)])),Qm=e=>e.dump,eu=(e,t)=>({...ql(t),...e.dump}),tu=Jm,ou=eu,nu="placeholder",ru=Ir([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),su=e=>be(e,"uiType"),au=(e,t,o,n)=>su(o)&&o.uiType===nu?((e,t,o,n)=>e.exists((e=>e!==o.owner))?ru.single(!0,w(o)):ve(n,o.name).fold((()=>{throw new Error("Unknown placeholder component: "+o.name+"\nKnown: ["+ae(n)+"]\nNamespace: "+e.getOr("none")+"\nSpec: "+JSON.stringify(o,null,2))}),(e=>e.replace())))(e,0,o,n):ru.single(!1,w(o)),iu=(e,t,o,n)=>au(e,0,o,n).fold(((r,s)=>{const a=su(o)?s(t,o.config,o.validated):s(t),i=ve(a,"components").getOr([]),l=G(i,(o=>iu(e,t,o,n)));return[{...a,components:l}]}),((e,n)=>{if(su(o)){const e=n(t,o.config,o.validated);return o.validated.preprocess.getOr(x)(e)}return n(t)})),lu=(e,t,o,n)=>{const r=ce(n,((e,t)=>((e,t)=>{let o=!1;return{name:w(e),required:()=>t.fold(((e,t)=>e),((e,t)=>e)),used:()=>o,replace:()=>{if(o)throw new Error("Trying to use the same placeholder more than once: "+e);return o=!0,t}}})(t,e))),s=((e,t,o,n)=>G(o,(o=>iu(e,t,o,n))))(e,t,o,r);return le(r,(o=>{if(!1===o.used()&&o.required())throw new Error("Placeholder: "+o.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+JSON.stringify(t.components,null,2))})),s},cu=ru.single,du=ru.multiple,mu=w(nu),uu=Ir([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),gu=Tr("factory",{sketch:x}),hu=Tr("schema",[]),pu=dr("name"),fu=ir("pname","pname",Sn((e=>"")),Un()),vu=lr("schema",(()=>[yr("preprocess")])),bu=Tr("defaults",w({})),yu=Tr("overrides",w({})),wu=Pn([gu,hu,pu,fu,bu,yu]),xu=Pn([gu,hu,pu,bu,yu]),Cu=Pn([gu,hu,pu,fu,bu,yu]),Su=Pn([gu,vu,pu,dr("unit"),fu,bu,yu]),ku=e=>e.fold(D.some,D.none,D.some,D.some),_u=e=>{const t=e=>e.name;return e.fold(t,t,t,t)},Eu=(e,t)=>o=>{const n=nr("Converting part type",t,o);return e(n)},Tu=Eu(uu.required,wu),Ou=Eu(uu.external,xu),Du=Eu(uu.optional,Cu),Au=Eu(uu.group,Su),Mu=w("entirety");var Nu=Object.freeze({__proto__:null,required:Tu,external:Ou,optional:Du,group:Au,asNamedPart:ku,name:_u,asCommon:e=>e.fold(x,x,x,x),original:Mu});const Ru=(e,t,o,n)=>xn(t.defaults(e,o,n),o,{uid:e.partUids[t.name]},t.overrides(e,o,n)),Bu=(e,t)=>{const o={};return z(t,(t=>{ku(t).each((t=>{const n=Lu(e,t.pname);o[t.name]=o=>{const r=nr("Part: "+t.name+" in "+e,Pn(t.schema),o);return{...n,config:o,validated:r}}}))})),o},Lu=(e,t)=>({uiType:mu(),owner:e,name:t}),Hu=(e,t,o)=>({uiType:mu(),owner:e,name:t,config:o,validated:{}}),Iu=e=>G(e,(e=>e.fold(D.none,D.some,D.none,D.none).map((e=>fr(e.name,e.schema.concat([sl(Mu())])))).toArray())),Pu=e=>F(e,_u),Fu=(e,t,o)=>((e,t,o)=>{const n={},r={};return z(o,(e=>{e.fold((e=>{n[e.pname]=cu(!0,((t,o,n)=>e.factory.sketch(Ru(t,e,o,n))))}),(e=>{const o=t.parts[e.name];r[e.name]=w(e.factory.sketch(Ru(t,e,o[Mu()]),o))}),(e=>{n[e.pname]=cu(!1,((t,o,n)=>e.factory.sketch(Ru(t,e,o,n))))}),(e=>{n[e.pname]=du(!0,((t,o,n)=>{const r=t[e.name];return F(r,(o=>e.factory.sketch(xn(e.defaults(t,o,n),o,e.overrides(t,o)))))}))}))})),{internals:w(n),externals:w(r)}})(0,t,o),zu=(e,t,o)=>lu(D.some(e),t,t.components,o),Vu=(e,t,o)=>{const n=t.partUids[o];return e.getSystem().getByUid(n).toOptional()},Zu=(e,t,o)=>Vu(e,t,o).getOrDie("Could not find part: "+o),Uu=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return z(o,(e=>{n[e]=w(s.getByUid(r[e]))})),n},ju=(e,t)=>{const o=e.getSystem();return ce(t.partUids,((e,t)=>w(o.getByUid(e))))},Wu=e=>ae(e.partUids),$u=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return z(o,(e=>{n[e]=w(s.getByUid(r[e]).getOrDie())})),n},qu=(e,t)=>{const o=Pu(t);return zr(F(o,(t=>({key:t,value:e+"-"+t}))))},Gu=e=>ir("partUids","partUids",_n((t=>qu(t.uid,e))),Un());var Ku=Object.freeze({__proto__:null,generate:Bu,generateOne:Hu,schemas:Iu,names:Pu,substitutes:Fu,components:zu,defaultUids:qu,defaultUidsSchema:Gu,getAllParts:ju,getAllPartNames:Wu,getPart:Vu,getPartOrDie:Zu,getParts:Uu,getPartsOrDie:$u});const Yu=(e,t,o,n,r)=>{const s=((e,t)=>(e.length>0?[fr("parts",e)]:[]).concat([dr("uid"),Tr("dom",{}),Tr("components",[]),sl("originalSpec"),Tr("debug.sketcher",{})]).concat(t))(n,r);return nr(e+" [SpecSchema]",In(s.concat(t)),o)},Xu=(e,t,o,n,r)=>{const s=Ju(r),a=Iu(o),i=Gu(o),l=Yu(e,t,s,a,[i]),c=Fu(0,l,o);return n(l,zu(e,l,c.internals()),s,c.externals())},Ju=e=>(e=>be(e,"uid"))(e)?e:{...e,uid:Ea("uid")},Qu=In([dr("name"),dr("factory"),dr("configFields"),Tr("apis",{}),Tr("extraApis",{})]),eg=In([dr("name"),dr("factory"),dr("configFields"),dr("partFields"),Tr("apis",{}),Tr("extraApis",{})]),tg=e=>{const t=nr("Sketcher for "+e.name,Qu,e),o=ce(t.apis,La),n=ce(t.extraApis,((e,t)=>Ma(e,t)));return{name:t.name,configFields:t.configFields,sketch:e=>((e,t,o,n)=>{const r=Ju(n);return o(Yu(e,t,r,[],[]),r)})(t.name,t.configFields,t.factory,e),...o,...n}},og=e=>{const t=nr("Sketcher for "+e.name,eg,e),o=Bu(t.name,t.partFields),n=ce(t.apis,La),r=ce(t.extraApis,((e,t)=>Ma(e,t)));return{name:t.name,partFields:t.partFields,configFields:t.configFields,sketch:e=>Xu(t.name,t.configFields,t.partFields,t.factory,e),parts:o,...n,...r}},ng=e=>Ge("input")(e)&&"radio"!==_t(e,"type")||Ge("textarea")(e);var rg=Object.freeze({__proto__:null,getCurrent:(e,t,o)=>t.find(e)});const sg=[dr("find")],ag=Kl({fields:sg,name:"composing",apis:rg}),ig=["input","button","textarea","select"],lg=(e,t,o)=>{(t.disabled()?hg:pg)(e,t)},cg=(e,t)=>!0===t.useNative&&L(ig,Ve(e.element)),dg=e=>{St(e.element,"disabled","disabled")},mg=e=>{Ot(e.element,"disabled")},ug=e=>{St(e.element,"aria-disabled","true")},gg=e=>{St(e.element,"aria-disabled","false")},hg=(e,t,o)=>{t.disableClass.each((t=>{ti(e.element,t)}));(cg(e,t)?dg:ug)(e),t.onDisabled(e)},pg=(e,t,o)=>{t.disableClass.each((t=>{ni(e.element,t)}));(cg(e,t)?mg:gg)(e),t.onEnabled(e)},fg=(e,t)=>cg(e,t)?(e=>Tt(e.element,"disabled"))(e):(e=>"true"===_t(e.element,"aria-disabled"))(e);var vg=Object.freeze({__proto__:null,enable:pg,disable:hg,isDisabled:fg,onLoad:lg,set:(e,t,o,n)=>{(n?hg:pg)(e,t)}});var bg=Object.freeze({__proto__:null,exhibit:(e,t)=>Fa({classes:t.disabled()?t.disableClass.toArray():[]}),events:(e,t)=>Ys([Xs(Cs(),((t,o)=>fg(t,e))),Ul(e,t,lg)])}),yg=[Rr("disabled",T),Tr("useNative",!0),yr("disableClass"),el("onDisabled"),el("onEnabled")];const wg=Kl({fields:yg,name:"disabling",active:bg,apis:vg}),xg=(e,t,o,n)=>{const r=_d(e.element,"."+t.highlightClass);z(r,(o=>{H(n,(e=>Xe(e.element,o)))||(ni(o,t.highlightClass),e.getSystem().getByDom(o).each((o=>{t.onDehighlight(e,o),js(o,Us())})))}))},Cg=(e,t,o,n)=>{xg(e,t,0,[n]),Sg(e,t,o,n)||(ti(n.element,t.highlightClass),t.onHighlight(e,n),js(n,Zs()))},Sg=(e,t,o,n)=>si(n.element,t.highlightClass),kg=(e,t,o,n)=>{const r=_d(e.element,"."+t.itemClass);return D.from(r[n]).fold((()=>on.error(new Error("No element found with index "+n))),e.getSystem().getByDom)},_g=(e,t,o)=>Bi(e.element,"."+t.itemClass).bind((t=>e.getSystem().getByDom(t).toOptional())),Eg=(e,t,o)=>{const n=_d(e.element,"."+t.itemClass);return(n.length>0?D.some(n[n.length-1]):D.none()).bind((t=>e.getSystem().getByDom(t).toOptional()))},Tg=(e,t,o,n)=>{const r=_d(e.element,"."+t.itemClass),s=$(r,(e=>si(e,t.highlightClass)));return s.bind((t=>{const o=vl(t,n,0,r.length-1);return e.getSystem().getByDom(r[o]).toOptional()}))},Og=(e,t,o)=>{const n=_d(e.element,"."+t.itemClass);return xe(F(n,(t=>e.getSystem().getByDom(t).toOptional())))};var Dg=Object.freeze({__proto__:null,dehighlightAll:(e,t,o)=>xg(e,t,0,[]),dehighlight:(e,t,o,n)=>{Sg(e,t,o,n)&&(ni(n.element,t.highlightClass),t.onDehighlight(e,n),js(n,Us()))},highlight:Cg,highlightFirst:(e,t,o)=>{_g(e,t).each((n=>{Cg(e,t,o,n)}))},highlightLast:(e,t,o)=>{Eg(e,t).each((n=>{Cg(e,t,o,n)}))},highlightAt:(e,t,o,n)=>{kg(e,t,o,n).fold((e=>{throw e}),(n=>{Cg(e,t,o,n)}))},highlightBy:(e,t,o,n)=>{const r=Og(e,t);W(r,n).each((n=>{Cg(e,t,o,n)}))},isHighlighted:Sg,getHighlighted:(e,t,o)=>Bi(e.element,"."+t.highlightClass).bind((t=>e.getSystem().getByDom(t).toOptional())),getFirst:_g,getLast:Eg,getPrevious:(e,t,o)=>Tg(e,t,0,-1),getNext:(e,t,o)=>Tg(e,t,0,1),getCandidates:Og}),Ag=[dr("highlightClass"),dr("itemClass"),el("onHighlight"),el("onDehighlight")];const Mg=Kl({fields:Ag,name:"highlighting",apis:Dg}),Ng=[8],Rg=[9],Bg=[13],Lg=[27],Hg=[32],Ig=[37],Pg=[38],Fg=[39],zg=[40],Vg=(e,t,o)=>{const n=Y(e.slice(0,t)),r=Y(e.slice(t+1));return W(n.concat(r),o)},Zg=(e,t,o)=>{const n=Y(e.slice(0,t));return W(n,o)},Ug=(e,t,o)=>{const n=e.slice(0,t),r=e.slice(t+1);return W(r.concat(n),o)},jg=(e,t,o)=>{const n=e.slice(t+1);return W(n,o)},Wg=e=>t=>{const o=t.raw;return L(e,o.which)},$g=e=>t=>K(e,(e=>e(t))),qg=e=>!0===e.raw.shiftKey,Gg=e=>!0===e.raw.ctrlKey,Kg=k(qg),Yg=(e,t)=>({matches:e,classification:t}),Xg=(e,t,o)=>{t.exists((e=>o.exists((t=>Xe(t,e)))))||Ws(e,Is(),{prevFocus:t,newFocus:o})},Jg=()=>{const e=e=>sc(e.element);return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().triggerFocus(o,t.element);const r=e(t);Xg(t,n,r)}}},Qg=()=>{const e=e=>Mg.getHighlighted(e).map((e=>e.element));return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().getByDom(o).fold(v,(e=>{Mg.highlight(t,e)}));const r=e(t);Xg(t,n,r)}}};var eh;!function(e){e.OnFocusMode="onFocus",e.OnEnterOrSpaceMode="onEnterOrSpace",e.OnApiMode="onApi"}(eh||(eh={}));const th=(e,t,o,n,r)=>{const s=(e,t,o,n,r)=>((e,t)=>{const o=W(e,(e=>e.matches(t)));return o.map((e=>e.classification))})(o(e,t,n,r),t.event).bind((o=>o(e,t,n,r))),a={schema:()=>e.concat([Tr("focusManager",Jg()),Or("focusInside","onFocus",Qn((e=>L(["onFocus","onEnterOrSpace","onApi"],e)?on.value(e):on.error("Invalid value for focusInside")))),rl("handler",a),rl("state",t),rl("sendFocusIn",r)]),processKey:s,toEvents:(e,t)=>{const a=e.focusInside!==eh.OnFocusMode?D.none():r(e).map((o=>Qs(bs(),((n,r)=>{o(n,e,t),r.stop()})))),i=[Qs(is(),((n,a)=>{s(n,a,o,e,t).fold((()=>{((o,n)=>{const s=Wg(Hg.concat(Bg))(n.event);e.focusInside===eh.OnEnterOrSpaceMode&&s&&Wr(o,n)&&r(e).each((r=>{r(o,e,t),n.stop()}))})(n,a)}),(e=>{a.stop()}))})),Qs(ls(),((o,r)=>{s(o,r,n,e,t).each((e=>{r.stop()}))}))];return Ys(a.toArray().concat(i))}};return a},oh=e=>{const t=[yr("onEscape"),yr("onEnter"),Tr("selector",'[data-alloy-tabstop="true"]:not(:disabled)'),Tr("firstTabstop",0),Tr("useTabstopAt",O),yr("visibilitySelector")].concat([e]),o=(e,t)=>{const o=e.visibilitySelector.bind((e=>Li(t,e))).getOr(t);return Ut(o)>0},n=(e,t)=>t.focusManager.get(e).bind((e=>Li(e,t.selector))),r=(e,t,n)=>{((e,t)=>{const n=_d(e.element,t.selector),r=Z(n,(e=>o(t,e)));return D.from(r[t.firstTabstop])})(e,t).each((o=>{t.focusManager.set(e,o)}))},s=(e,t,n,r,s)=>s(t,n,(e=>((e,t)=>o(e,t)&&e.useTabstopAt(t))(r,e))).fold((()=>r.cyclic?D.some(!0):D.none()),(t=>(r.focusManager.set(e,t),D.some(!0)))),a=(e,t,o,r)=>{const a=_d(e.element,o.selector);return n(e,o).bind((t=>$(a,S(Xe,t)).bind((t=>s(e,a,t,o,r)))))},i=(e,t,o)=>{const n=o.cyclic?Vg:Zg;return a(e,0,o,n)},l=(e,t,o)=>{const n=o.cyclic?Ug:jg;return a(e,0,o,n)},c=e=>(e=>nt(e))(e).bind(lt).exists((t=>Xe(t,e))),d=w([Yg($g([qg,Wg(Rg)]),i),Yg(Wg(Rg),l),Yg($g([Kg,Wg(Bg)]),((e,t,o)=>o.onEnter.bind((o=>o(e,t)))))]),m=w([Yg(Wg(Lg),((e,t,o)=>o.onEscape.bind((o=>o(e,t))))),Yg(Wg(Rg),((e,t,o)=>n(e,o).filter((e=>!o.useTabstopAt(e))).bind((n=>(c(n)?i:l)(e,t,o)))))]);return th(t,Ha.init,d,m,(()=>D.some(r)))};var nh=oh(lr("cyclic",T)),rh=oh(lr("cyclic",O));const sh=(e,t,o)=>ng(o)&&Wg(Hg)(t.event)?D.none():((e,t,o)=>(qs(e,o,Cs()),D.some(!0)))(e,0,o),ah=(e,t)=>D.some(!0),ih=[Tr("execute",sh),Tr("useSpace",!1),Tr("useEnter",!0),Tr("useControlEnter",!1),Tr("useDown",!1)],lh=(e,t,o)=>o.execute(e,t,e.element);var ch=th(ih,Ha.init,((e,t,o,n)=>{const r=o.useSpace&&!ng(e.element)?Hg:[],s=o.useEnter?Bg:[],a=o.useDown?zg:[],i=r.concat(s).concat(a);return[Yg(Wg(i),lh)].concat(o.useControlEnter?[Yg($g([Gg,Wg(Bg)]),lh)]:[])}),((e,t,o,n)=>o.useSpace&&!ng(e.element)?[Yg(Wg(Hg),ah)]:[]),(()=>D.none()));const dh=()=>{const e=kc();return Ia({readState:()=>e.get().map((e=>({numRows:String(e.numRows),numColumns:String(e.numColumns)}))).getOr({numRows:"?",numColumns:"?"}),setGridSize:(t,o)=>{e.set({numRows:t,numColumns:o})},getNumRows:()=>e.get().map((e=>e.numRows)),getNumColumns:()=>e.get().map((e=>e.numColumns))})};var mh=Object.freeze({__proto__:null,flatgrid:dh,init:e=>e.state(e)});const uh=e=>(t,o,n,r)=>{const s=e(t.element);return fh(s,t,o,n,r)},gh=(e,t)=>{const o=$c(e,t);return uh(o)},hh=(e,t)=>{const o=$c(t,e);return uh(o)},ph=e=>(t,o,n,r)=>fh(e,t,o,n,r),fh=(e,t,o,n,r)=>n.focusManager.get(t).bind((o=>e(t.element,o,n,r))).map((e=>(n.focusManager.set(t,e),!0))),vh=ph,bh=ph,yh=ph,wh=e=>!(e=>e.offsetWidth<=0&&e.offsetHeight<=0)(e.dom),xh=(e,t,o)=>{const n=_d(e,o);return((e,t)=>$(e,t).map((t=>({index:t,candidates:e}))))(Z(n,wh),(e=>Xe(e,t)))},Ch=(e,t)=>$(e,(e=>Xe(t,e))),Sh=(e,t,o,n)=>n(Math.floor(t/o),t%o).bind((t=>{const n=t.row*o+t.column;return n>=0&&nSh(e,t,n,((t,s)=>{const a=t===o-1?e.length-t*n:n,i=vl(s,r,0,a-1);return D.some({row:t,column:i})})),_h=(e,t,o,n,r)=>Sh(e,t,n,((t,s)=>{const a=vl(t,r,0,o-1),i=a===o-1?e.length-a*n:n,l=bl(s,0,i-1);return D.some({row:a,column:l})})),Eh=[dr("selector"),Tr("execute",sh),tl("onEscape"),Tr("captureTab",!1),al()],Th=(e,t,o)=>{Bi(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},Oh=e=>(t,o,n,r)=>xh(t,o,n.selector).bind((t=>e(t.candidates,t.index,r.getNumRows().getOr(n.initSize.numRows),r.getNumColumns().getOr(n.initSize.numColumns)))),Dh=(e,t,o)=>o.captureTab?D.some(!0):D.none(),Ah=Oh(((e,t,o,n)=>kh(e,t,o,n,-1))),Mh=Oh(((e,t,o,n)=>kh(e,t,o,n,1))),Nh=Oh(((e,t,o,n)=>_h(e,t,o,n,-1))),Rh=Oh(((e,t,o,n)=>_h(e,t,o,n,1))),Bh=w([Yg(Wg(Ig),gh(Ah,Mh)),Yg(Wg(Fg),hh(Ah,Mh)),Yg(Wg(Pg),vh(Nh)),Yg(Wg(zg),bh(Rh)),Yg($g([qg,Wg(Rg)]),Dh),Yg($g([Kg,Wg(Rg)]),Dh),Yg(Wg(Hg.concat(Bg)),((e,t,o,n)=>((e,t)=>t.focusManager.get(e).bind((e=>Li(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n)))))]),Lh=w([Yg(Wg(Lg),((e,t,o)=>o.onEscape(e,t))),Yg(Wg(Hg),ah)]);var Hh=th(Eh,dh,Bh,Lh,(()=>D.some(Th)));const Ih=(e,t,o,n,r)=>{const s=(e,t,o)=>r(e,t,n,0,o.length-1,o[t],(t=>{return n=o[t],"button"===Ve(n)&&"disabled"===_t(n,"disabled")?s(e,t,o):D.from(o[t]);var n}));return xh(e,o,t).bind((e=>{const t=e.index,o=e.candidates;return s(t,t,o)}))},Ph=(e,t,o,n)=>Ih(e,t,o,n,((e,t,o,n,r,s,a)=>{const i=bl(t+o,n,r);return i===e?D.from(s):a(i)})),Fh=(e,t,o,n)=>Ih(e,t,o,n,((e,t,o,n,r,s,a)=>{const i=vl(t,o,n,r);return i===e?D.none():a(i)})),zh=[dr("selector"),Tr("getInitial",D.none),Tr("execute",sh),tl("onEscape"),Tr("executeOnMove",!1),Tr("allowVertical",!0),Tr("allowHorizontal",!0),Tr("cycles",!0)],Vh=(e,t,o)=>((e,t)=>t.focusManager.get(e).bind((e=>Li(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n))),Zh=(e,t,o)=>{t.getInitial(e).orThunk((()=>Bi(e.element,t.selector))).each((o=>{t.focusManager.set(e,o)}))},Uh=(e,t,o)=>(o.cycles?Fh:Ph)(e,o.selector,t,-1),jh=(e,t,o)=>(o.cycles?Fh:Ph)(e,o.selector,t,1),Wh=e=>(t,o,n,r)=>e(t,o,n,r).bind((()=>n.executeOnMove?Vh(t,o,n):D.some(!0))),$h=w([Yg(Wg(Hg),ah),Yg(Wg(Lg),((e,t,o)=>o.onEscape(e,t)))]);var qh=th(zh,Ha.init,((e,t,o,n)=>{const r=[...o.allowHorizontal?Ig:[]].concat(o.allowVertical?Pg:[]),s=[...o.allowHorizontal?Fg:[]].concat(o.allowVertical?zg:[]);return[Yg(Wg(r),Wh(gh(Uh,jh))),Yg(Wg(s),Wh(hh(Uh,jh))),Yg(Wg(Bg),Vh),Yg(Wg(Hg),Vh)]}),$h,(()=>D.some(Zh)));const Gh=(e,t,o)=>D.from(e[t]).bind((e=>D.from(e[o]).map((e=>({rowIndex:t,columnIndex:o,cell:e}))))),Kh=(e,t,o,n)=>{const r=e[t].length,s=vl(o,n,0,r-1);return Gh(e,t,s)},Yh=(e,t,o,n)=>{const r=vl(o,n,0,e.length-1),s=e[r].length,a=bl(t,0,s-1);return Gh(e,r,a)},Xh=(e,t,o,n)=>{const r=e[t].length,s=bl(o+n,0,r-1);return Gh(e,t,s)},Jh=(e,t,o,n)=>{const r=bl(o+n,0,e.length-1),s=e[r].length,a=bl(t,0,s-1);return Gh(e,r,a)},Qh=[fr("selectors",[dr("row"),dr("cell")]),Tr("cycles",!0),Tr("previousSelector",D.none),Tr("execute",sh)],ep=(e,t,o)=>{t.previousSelector(e).orThunk((()=>{const o=t.selectors;return Bi(e.element,o.cell)})).each((o=>{t.focusManager.set(e,o)}))},tp=(e,t)=>(o,n,r)=>{const s=r.cycles?e:t;return Li(n,r.selectors.row).bind((e=>{const t=_d(e,r.selectors.cell);return Ch(t,n).bind((t=>{const n=_d(o,r.selectors.row);return Ch(n,e).bind((e=>{const o=((e,t)=>F(e,(e=>_d(e,t.selectors.cell))))(n,r);return s(o,e,t).map((e=>e.cell))}))}))}))},op=tp(((e,t,o)=>Kh(e,t,o,-1)),((e,t,o)=>Xh(e,t,o,-1))),np=tp(((e,t,o)=>Kh(e,t,o,1)),((e,t,o)=>Xh(e,t,o,1))),rp=tp(((e,t,o)=>Yh(e,o,t,-1)),((e,t,o)=>Jh(e,o,t,-1))),sp=tp(((e,t,o)=>Yh(e,o,t,1)),((e,t,o)=>Jh(e,o,t,1))),ap=w([Yg(Wg(Ig),gh(op,np)),Yg(Wg(Fg),hh(op,np)),Yg(Wg(Pg),vh(rp)),Yg(Wg(zg),bh(sp)),Yg(Wg(Hg.concat(Bg)),((e,t,o)=>sc(e.element).bind((n=>o.execute(e,t,n)))))]),ip=w([Yg(Wg(Hg),ah)]);var lp=th(Qh,Ha.init,ap,ip,(()=>D.some(ep)));const cp=[dr("selector"),Tr("execute",sh),Tr("moveOnTab",!1)],dp=(e,t,o)=>o.focusManager.get(e).bind((n=>o.execute(e,t,n))),mp=(e,t,o)=>{Bi(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},up=(e,t,o)=>Fh(e,o.selector,t,-1),gp=(e,t,o)=>Fh(e,o.selector,t,1),hp=w([Yg(Wg(Pg),yh(up)),Yg(Wg(zg),yh(gp)),Yg($g([qg,Wg(Rg)]),((e,t,o,n)=>o.moveOnTab?yh(up)(e,t,o,n):D.none())),Yg($g([Kg,Wg(Rg)]),((e,t,o,n)=>o.moveOnTab?yh(gp)(e,t,o,n):D.none())),Yg(Wg(Bg),dp),Yg(Wg(Hg),dp)]),pp=w([Yg(Wg(Hg),ah)]);var fp=th(cp,Ha.init,hp,pp,(()=>D.some(mp)));const vp=[tl("onSpace"),tl("onEnter"),tl("onShiftEnter"),tl("onLeft"),tl("onRight"),tl("onTab"),tl("onShiftTab"),tl("onUp"),tl("onDown"),tl("onEscape"),Tr("stopSpaceKeyup",!1),yr("focusIn")];var bp=th(vp,Ha.init,((e,t,o)=>[Yg(Wg(Hg),o.onSpace),Yg($g([Kg,Wg(Bg)]),o.onEnter),Yg($g([qg,Wg(Bg)]),o.onShiftEnter),Yg($g([qg,Wg(Rg)]),o.onShiftTab),Yg($g([Kg,Wg(Rg)]),o.onTab),Yg(Wg(Pg),o.onUp),Yg(Wg(zg),o.onDown),Yg(Wg(Ig),o.onLeft),Yg(Wg(Fg),o.onRight),Yg(Wg(Hg),o.onSpace)]),((e,t,o)=>[...o.stopSpaceKeyup?[Yg(Wg(Hg),ah)]:[],Yg(Wg(Lg),o.onEscape)]),(e=>e.focusIn));const yp=nh.schema(),wp=rh.schema(),xp=qh.schema(),Cp=Hh.schema(),Sp=lp.schema(),kp=ch.schema(),_p=fp.schema(),Ep=bp.schema();const Tp=Xl({branchKey:"mode",branches:Object.freeze({__proto__:null,acyclic:yp,cyclic:wp,flow:xp,flatgrid:Cp,matrix:Sp,execution:kp,menu:_p,special:Ep}),name:"keying",active:{events:(e,t)=>e.handler.toEvents(e,t)},apis:{focusIn:(e,t,o)=>{t.sendFocusIn(t).fold((()=>{e.getSystem().triggerFocus(e.element,e.element)}),(n=>{n(e,t,o)}))},setGridSize:(e,t,o,n,r)=>{(e=>ye(e,"setGridSize"))(o)?o.setGridSize(n,r):console.error("Layout does not support setGridSize")}},state:mh}),Op=(e,t)=>{ac((()=>{mm(e,t,(()=>F(t,e.getSystem().build)))}),e.element)},Dp=(e,t)=>{ac((()=>{((e,t,o)=>{const n=e.components(),r=G(t,(e=>Ba(e).toArray()));z(n,(e=>{L(r,e)||cm(e)}));const s=o(t),a=X(n,s);z(a,(e=>{sm(e)&&cm(e)})),z(s,(t=>{sm(t)||lm(e,t)})),e.syncComponents()})(e,t,(()=>((e,t,o)=>ui(e,t,((t,n)=>gi(e,n,t,o))))(e.element,t,e.getSystem().buildOrPatch)))}),e.element)},Ap=(e,t,o,n)=>{cm(t);const r=gi(e.element,o,n,e.getSystem().buildOrPatch);lm(e,r),e.syncComponents()},Mp=(e,t,o)=>{const n=e.getSystem().build(o);gm(e,n,t)},Np=(e,t,o,n)=>{pm(t),Mp(e,((e,t)=>((e,t,o)=>{it(e,o).fold((()=>{Ho(e,t)}),(e=>{Ro(e,t)}))})(e,t,o)),n)},Rp=(e,t)=>e.components(),Bp=(e,t,o,n,r)=>{const s=Rp(e);return D.from(s[n]).map((o=>(r.fold((()=>pm(o)),(r=>{(t.reuseDom?Ap:Np)(e,o,n,r)})),o)))};var Lp=Object.freeze({__proto__:null,append:(e,t,o,n)=>{Mp(e,Ho,n)},prepend:(e,t,o,n)=>{Mp(e,Lo,n)},remove:(e,t,o,n)=>{const r=Rp(e),s=W(r,(e=>Xe(n.element,e.element)));s.each(pm)},replaceAt:Bp,replaceBy:(e,t,o,n,r)=>{const s=Rp(e);return $(s,n).bind((o=>Bp(e,t,0,o,r)))},set:(e,t,o,n)=>(t.reuseDom?Dp:Op)(e,n),contents:Rp});const Hp=Kl({fields:[Nr("reuseDom",!0)],name:"replacing",apis:Lp}),Ip=(e,t)=>{const o=((e,t)=>{const o=Ys(t);return Kl({fields:[dr("enabled")],name:e,active:{events:w(o)}})})(e,t);return{key:e,value:{config:{},me:o,configAsRaw:w({}),initialConfig:{},state:Ha}}},Pp=(e,t)=>{t.ignore||(tc(e.element),t.onFocus(e))};var Fp=Object.freeze({__proto__:null,focus:Pp,blur:(e,t)=>{t.ignore||oc(e.element)},isFocused:e=>nc(e.element)});var zp=Object.freeze({__proto__:null,exhibit:(e,t)=>{const o=t.ignore?{}:{attributes:{tabindex:"-1"}};return Fa(o)},events:e=>Ys([Qs(bs(),((t,o)=>{Pp(t,e),o.stop()}))].concat(e.stopMousedown?[Qs(es(),((e,t)=>{t.event.prevent()}))]:[]))}),Vp=[el("onFocus"),Tr("stopMousedown",!1),Tr("ignore",!1)];const Zp=Kl({fields:Vp,name:"focusing",active:zp,apis:Fp}),Up=(e,t,o,n)=>{const r=o.get();o.set(n),((e,t,o)=>{t.toggleClass.each((t=>{o.get()?ti(e.element,t):ni(e.element,t)}))})(e,t,o),((e,t,o)=>{const n=t.aria;n.update(e,n,o.get())})(e,t,o),r!==n&&t.onToggled(e,n)},jp=(e,t,o)=>{Up(e,t,o,!o.get())},Wp=(e,t,o)=>{Up(e,t,o,t.selected)};var $p=Object.freeze({__proto__:null,onLoad:Wp,toggle:jp,isOn:(e,t,o)=>o.get(),on:(e,t,o)=>{Up(e,t,o,!0)},off:(e,t,o)=>{Up(e,t,o,!1)},set:Up});var qp=Object.freeze({__proto__:null,exhibit:()=>Fa({}),events:(e,t)=>{const o=(n=e,r=t,s=jp,da((e=>{s(e,n,r)})));var n,r,s;const a=Ul(e,t,Wp);return Ys(q([e.toggleOnExecute?[o]:[],[a]]))}});const Gp=(e,t,o)=>{St(e.element,"aria-expanded",o)};var Kp=[Tr("selected",!1),yr("toggleClass"),Tr("toggleOnExecute",!0),el("onToggled"),Or("aria",{mode:"none"},sr("mode",{pressed:[Tr("syncWithExpanded",!1),rl("update",((e,t,o)=>{St(e.element,"aria-pressed",o),t.syncWithExpanded&&Gp(e,t,o)}))],checked:[rl("update",((e,t,o)=>{St(e.element,"aria-checked",o)}))],expanded:[rl("update",Gp)],selected:[rl("update",((e,t,o)=>{St(e.element,"aria-selected",o)}))],none:[rl("update",v)]}))];const Yp=Kl({fields:Kp,name:"toggling",active:qp,apis:$p,state:(Xp=!1,{init:()=>{const e=Hr(Xp);return{get:()=>e.get(),set:t=>e.set(t),clear:()=>e.set(Xp),readState:()=>e.get()}}})});var Xp;const Jp=()=>{const e=(e,t)=>{t.stop(),$s(e)};return[Qs(ms(),e),Qs(ks(),e),ra(Yr()),ra(es())]},Qp=e=>Ys(q([e.map((e=>da(((t,o)=>{e(t),o.stop()})))).toArray(),Jp()])),ef="alloy.item-hover",tf="alloy.item-focus",of="alloy.item-toggled",nf=e=>{(sc(e.element).isNone()||Zp.isFocused(e))&&(Zp.isFocused(e)||Zp.focus(e),Ws(e,ef,{item:e}))},rf=e=>{Ws(e,tf,{item:e})},sf=w(ef),af=w(tf),lf=w(of),cf=e=>e.toggling.map((e=>e.exclusive?"menuitemradio":"menuitemcheckbox")).getOr("menuitem"),df=e=>({aria:{mode:"checked"},...ge(e,((e,t)=>"exclusive"!==t)),onToggled:(t,o)=>{h(e.onToggled)&&e.onToggled(t,o),((e,t)=>{Ws(e,of,{item:e,state:t})})(t,o)}}),mf=[dr("data"),dr("components"),dr("dom"),Tr("hasSubmenu",!1),yr("toggling"),tu("itemBehaviours",[Yp,Zp,Tp,Xm]),Tr("ignoreFocus",!1),Tr("domModification",{}),rl("builder",(e=>({dom:e.dom,domModification:{...e.domModification,attributes:{role:cf(e),...e.domModification.attributes,"aria-haspopup":e.hasSubmenu,...e.hasSubmenu?{"aria-expanded":!1}:{}}},behaviours:ou(e.itemBehaviours,[e.toggling.fold(Yp.revoke,(e=>Yp.config(df(e)))),Zp.config({ignore:e.ignoreFocus,stopMousedown:e.ignoreFocus,onFocus:e=>{rf(e)}}),Tp.config({mode:"execution"}),Xm.config({store:{mode:"memory",initialValue:e.data}}),Ip("item-type-events",[...Jp(),Qs(rs(),nf),Qs(Ss(),Zp.focus)])]),components:e.components,eventOrder:e.eventOrder}))),Tr("eventOrder",{})],uf=[dr("dom"),dr("components"),rl("builder",(e=>({dom:e.dom,components:e.components,events:Ys([sa(Ss())])})))],gf=w("item-widget"),hf=w([Tu({name:"widget",overrides:e=>({behaviours:ql([Xm.config({store:{mode:"manual",getValue:t=>e.data,setValue:v}})])})})]),pf=[dr("uid"),dr("data"),dr("components"),dr("dom"),Tr("autofocus",!1),Tr("ignoreFocus",!1),tu("widgetBehaviours",[Xm,Zp,Tp]),Tr("domModification",{}),Gu(hf()),rl("builder",(e=>{const t=Fu(gf(),e,hf()),o=zu(gf(),e,t.internals()),n=t=>Vu(t,e,"widget").map((e=>(Tp.focusIn(e),e))),r=(t,o)=>ng(o.event.target)?D.none():e.autofocus?(o.setSource(t.element),D.none()):D.none();return{dom:e.dom,components:o,domModification:e.domModification,events:Ys([da(((e,t)=>{n(e).each((e=>{t.stop()}))})),Qs(rs(),nf),Qs(Ss(),((t,o)=>{e.autofocus?n(t):Zp.focus(t)}))]),behaviours:ou(e.widgetBehaviours,[Xm.config({store:{mode:"memory",initialValue:e.data}}),Zp.config({ignore:e.ignoreFocus,onFocus:e=>{rf(e)}}),Tp.config({mode:"special",focusIn:e.autofocus?e=>{n(e)}:Jl(),onLeft:r,onRight:r,onEscape:(t,o)=>Zp.isFocused(t)||e.autofocus?e.autofocus?(o.setSource(t.element),D.none()):D.none():(Zp.focus(t),D.some(!0))})])}}))],ff=sr("type",{widget:pf,item:mf,separator:uf}),vf=w([Au({factory:{sketch:e=>{const t=nr("menu.spec item",ff,e);return t.builder(t)}},name:"items",unit:"item",defaults:(e,t)=>be(t,"uid")?t:{...t,uid:Ea("item")},overrides:(e,t)=>({type:t.type,ignoreFocus:e.fakeFocus,domModification:{classes:[e.markers.item]}})})]),bf=w([dr("value"),dr("items"),dr("dom"),dr("components"),Tr("eventOrder",{}),Jm("menuBehaviours",[Mg,Xm,ag,Tp]),Or("movement",{mode:"menu",moveOnTab:!0},sr("mode",{grid:[al(),rl("config",((e,t)=>({mode:"flatgrid",selector:"."+e.markers.item,initSize:{numColumns:t.initSize.numColumns,numRows:t.initSize.numRows},focusManager:e.focusManager})))],matrix:[rl("config",((e,t)=>({mode:"matrix",selectors:{row:t.rowSelector,cell:"."+e.markers.item},previousSelector:t.previousSelector,focusManager:e.focusManager}))),dr("rowSelector"),Tr("previousSelector",D.none)],menu:[Tr("moveOnTab",!0),rl("config",((e,t)=>({mode:"menu",selector:"."+e.markers.item,moveOnTab:t.moveOnTab,focusManager:e.focusManager})))]})),mr("markers",Ki()),Tr("fakeFocus",!1),Tr("focusManager",Jg()),el("onHighlight"),el("onDehighlight")]),yf=w("alloy.menu-focus"),wf=og({name:"Menu",configFields:bf(),partFields:vf(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,markers:e.markers,behaviours:eu(e.menuBehaviours,[Mg.config({highlightClass:e.markers.selectedItem,itemClass:e.markers.item,onHighlight:e.onHighlight,onDehighlight:e.onDehighlight}),Xm.config({store:{mode:"memory",initialValue:e.value}}),ag.config({find:D.some}),Tp.config(e.movement.config(e,e.movement))]),events:Ys([Qs(af(),((e,t)=>{const o=t.event;e.getSystem().getByDom(o.target).each((o=>{Mg.highlight(e,o),t.stop(),Ws(e,yf(),{menu:e,item:o})}))})),Qs(sf(),((e,t)=>{const o=t.event.item;Mg.highlight(e,o)})),Qs(lf(),((e,t)=>{const{item:o,state:n}=t.event;n&&"menuitemradio"===_t(o.element,"role")&&((e,t)=>{const o=_d(e.element,'[role="menuitemradio"][aria-checked="true"]');z(o,(o=>{Xe(o,t.element)||e.getSystem().getByDom(o).each((e=>{Yp.off(e)}))}))})(e,o)}))]),components:t,eventOrder:e.eventOrder,domModification:{attributes:{role:"menu"}}})}),xf=(e,t,o,n)=>ve(o,n).bind((n=>ve(e,n).bind((n=>{const r=xf(e,t,o,n);return D.some([n].concat(r))})))).getOr([]),Cf=(e,t)=>{const o={};le(e,((e,t)=>{z(e,(e=>{o[e]=t}))}));const n=t,r=de(t,((e,t)=>({k:e,v:t})));const s=ce(r,((e,t)=>[t].concat(xf(o,n,r,t))));return ce(o,(e=>ve(s,e).getOr([e])))},Sf=e=>"prepared"===e.type?D.some(e.menu):D.none(),kf={init:()=>{const e=Hr({}),t=Hr({}),o=Hr({}),n=kc(),r=Hr({}),s=(t,o,n)=>a(t).bind((r=>(t=>pe(e.get(),((e,o)=>e===t)))(t).bind((e=>o(e).map((e=>({triggeredMenu:r,triggeringItem:e,triggeringPath:n}))))))),a=e=>i(e).bind(Sf),i=e=>ve(t.get(),e),l=t=>ve(e.get(),t);return{setMenuBuilt:(e,o)=>{t.set({...t.get(),[e]:{type:"prepared",menu:o}})},setContents:(s,a,i,l)=>{n.set(s),e.set(i),t.set(a),r.set(l);const c=Cf(l,i);o.set(c)},expand:t=>ve(e.get(),t).map((e=>{const n=ve(o.get(),t).getOr([]);return[e].concat(n)})),refresh:e=>ve(o.get(),e),collapse:e=>ve(o.get(),e).bind((e=>e.length>1?D.some(e.slice(1)):D.none())),lookupMenu:i,lookupItem:l,otherMenus:e=>{const t=r.get();return X(ae(t),e)},getPrimary:()=>n.get().bind(a),getMenus:()=>t.get(),clear:()=>{e.set({}),t.set({}),o.set({}),n.clear()},isClear:()=>n.get().isNone(),getTriggeringPath:(e,t)=>{const r=Z(l(e).toArray(),(e=>a(e).isSome()));return ve(o.get(),e).bind((e=>{const o=Y(r.concat(e));return(e=>{const t=[];for(let o=0;os(e,t,o.slice(0,r+1)).fold((()=>we(n.get(),e)?[]:[D.none()]),(e=>[D.some(e)])))))}))}}},extractPreparedMenu:Sf},_f=ya("tiered-menu-item-highlight"),Ef=ya("tiered-menu-item-dehighlight");var Tf;!function(e){e[e.HighlightMenuAndItem=0]="HighlightMenuAndItem",e[e.HighlightJustMenu=1]="HighlightJustMenu",e[e.HighlightNone=2]="HighlightNone"}(Tf||(Tf={}));const Of=w("collapse-item"),Df=tg({name:"TieredMenu",configFields:[nl("onExecute"),nl("onEscape"),ol("onOpenMenu"),ol("onOpenSubmenu"),el("onRepositionMenu"),el("onCollapseMenu"),Tr("highlightOnOpen",Tf.HighlightMenuAndItem),fr("data",[dr("primary"),dr("menus"),dr("expansions")]),Tr("fakeFocus",!1),el("onHighlightItem"),el("onDehighlightItem"),el("onHover"),Xi(),dr("dom"),Tr("navigateOnHover",!0),Tr("stayInDom",!1),Jm("tmenuBehaviours",[Tp,Mg,ag,Hp]),Tr("eventOrder",{})],apis:{collapseMenu:(e,t)=>{e.collapseMenu(t)},highlightPrimary:(e,t)=>{e.highlightPrimary(t)},repositionMenus:(e,t)=>{e.repositionMenus(t)}},factory:(e,t)=>{const o=kc(),n=kf.init(),r=t=>{const o=((t,o,n)=>ce(n,((n,r)=>{const s=()=>wf.sketch({...n,value:r,markers:e.markers,fakeFocus:e.fakeFocus,onHighlight:(e,t)=>{Ws(e,_f,{menuComp:e,itemComp:t})},onDehighlight:(e,t)=>{Ws(e,Ef,{menuComp:e,itemComp:t})},focusManager:e.fakeFocus?Qg():Jg()});return r===o?{type:"prepared",menu:t.getSystem().build(s())}:{type:"notbuilt",nbMenu:s}})))(t,e.data.primary,e.data.menus),r=a();return n.setContents(e.data.primary,o,e.data.expansions,r),n.getPrimary()},s=e=>Xm.getValue(e).value,a=t=>ce(e.data.menus,((e,t)=>G(e.items,(e=>"separator"===e.type?[]:[e.data.value])))),i=Mg.highlight,l=(t,o)=>{i(t,o),Mg.getHighlighted(o).orThunk((()=>Mg.getFirst(o))).each((n=>{e.fakeFocus?Mg.highlight(o,n):qs(t,n.element,Ss())}))},c=(e,t)=>xe(F(t,(t=>e.lookupMenu(t).bind((e=>"prepared"===e.type?D.some(e.menu):D.none()))))),d=(t,o,n)=>{const r=c(o,o.otherMenus(n));z(r,(o=>{ii(o.element,[e.markers.backgroundMenu]),e.stayInDom||Hp.remove(t,o)}))},m=(t,n)=>{const r=(t=>o.get().getOrThunk((()=>{const n={},r=_d(t.element,`.${e.markers.item}`),a=Z(r,(e=>"true"===_t(e,"aria-haspopup")));return z(a,(e=>{t.getSystem().getByDom(e).each((e=>{const t=s(e);n[t]=e}))})),o.set(n),n})))(t);le(r,((e,t)=>{const o=L(n,t);St(e.element,"aria-expanded",o)}))},u=(t,o,n)=>D.from(n[0]).bind((r=>o.lookupMenu(r).bind((r=>{if("notbuilt"===r.type)return D.none();{const s=r.menu,a=c(o,n.slice(1));return z(a,(t=>{ti(t.element,e.markers.backgroundMenu)})),yt(s.element)||Hp.append(t,Ti(s)),ii(s.element,[e.markers.backgroundMenu]),l(t,s),d(t,o,n),D.some(s)}}))));let g;!function(e){e[e.HighlightSubmenu=0]="HighlightSubmenu",e[e.HighlightParent=1]="HighlightParent"}(g||(g={}));const h=(t,o,r=g.HighlightSubmenu)=>{if(o.hasConfigured(wg)&&wg.isDisabled(o))return D.some(o);{const a=s(o);return n.expand(a).bind((s=>(m(t,s),D.from(s[0]).bind((a=>n.lookupMenu(a).bind((i=>{const l=((e,t,o)=>{if("notbuilt"===o.type){const r=e.getSystem().build(o.nbMenu());return n.setMenuBuilt(t,r),r}return o.menu})(t,a,i);return yt(l.element)||Hp.append(t,Ti(l)),e.onOpenSubmenu(t,o,l,Y(s)),r===g.HighlightSubmenu?(Mg.highlightFirst(l),u(t,n,s)):(Mg.dehighlightAll(l),D.some(o))})))))))}},p=(t,o)=>{const r=s(o);return n.collapse(r).bind((r=>(m(t,r),u(t,n,r).map((n=>(e.onCollapseMenu(t,o,n),n))))))},f=t=>(o,n)=>Li(n.getSource(),`.${e.markers.item}`).bind((e=>o.getSystem().getByDom(e).toOptional().bind((e=>t(o,e).map(O))))),b=Ys([Qs(yf(),((e,t)=>{const o=t.event.item;n.lookupItem(s(o)).each((()=>{const o=t.event.menu;Mg.highlight(e,o);const r=s(t.event.item);n.refresh(r).each((t=>d(e,n,t)))}))})),da(((t,o)=>{const n=o.event.target;t.getSystem().getByDom(n).each((o=>{0===s(o).indexOf("collapse-item")&&p(t,o),h(t,o,g.HighlightSubmenu).fold((()=>{e.onExecute(t,o)}),v)}))})),ia(((t,o)=>{r(t).each((o=>{Hp.append(t,Ti(o)),e.onOpenMenu(t,o),e.highlightOnOpen===Tf.HighlightMenuAndItem?l(t,o):e.highlightOnOpen===Tf.HighlightJustMenu&&i(t,o)}))})),Qs(_f,((t,o)=>{e.onHighlightItem(t,o.event.menuComp,o.event.itemComp)})),Qs(Ef,((t,o)=>{e.onDehighlightItem(t,o.event.menuComp,o.event.itemComp)})),...e.navigateOnHover?[Qs(sf(),((t,o)=>{const r=o.event.item;((e,t)=>{const o=s(t);n.refresh(o).bind((t=>(m(e,t),u(e,n,t))))})(t,r),h(t,r,g.HighlightParent),e.onHover(t,r)}))]:[]]),y=e=>Mg.getHighlighted(e).bind(Mg.getHighlighted),w={collapseMenu:e=>{y(e).each((t=>{p(e,t)}))},highlightPrimary:e=>{n.getPrimary().each((t=>{l(e,t)}))},repositionMenus:t=>{const o=n.getPrimary().bind((e=>y(t).bind((e=>{const t=s(e),o=fe(n.getMenus()),r=xe(F(o,kf.extractPreparedMenu));return n.getTriggeringPath(t,(e=>((e,t,o)=>se(t,(e=>{if(!e.getSystem().isConnected())return D.none();const t=Mg.getCandidates(e);return W(t,(e=>s(e)===o))})))(0,r,e)))})).map((t=>({primary:e,triggeringPath:t})))));o.fold((()=>{(e=>D.from(e.components()[0]).filter((e=>"menu"===_t(e.element,"role"))))(t).each((o=>{e.onRepositionMenu(t,o,[])}))}),(({primary:o,triggeringPath:n})=>{e.onRepositionMenu(t,o,n)}))}};return{uid:e.uid,dom:e.dom,markers:e.markers,behaviours:eu(e.tmenuBehaviours,[Tp.config({mode:"special",onRight:f(((e,t)=>ng(t.element)?D.none():h(e,t,g.HighlightSubmenu))),onLeft:f(((e,t)=>ng(t.element)?D.none():p(e,t))),onEscape:f(((t,o)=>p(t,o).orThunk((()=>e.onEscape(t,o).map((()=>t)))))),focusIn:(e,t)=>{n.getPrimary().each((t=>{qs(e,t.element,Ss())}))}}),Mg.config({highlightClass:e.markers.selectedMenu,itemClass:e.markers.menu}),ag.config({find:e=>Mg.getHighlighted(e)}),Hp.config({})]),eventOrder:e.eventOrder,apis:w,events:b}},extraApis:{tieredData:(e,t,o)=>({primary:e,menus:t,expansions:o}),singleData:(e,t)=>({primary:e,menus:Fr(e,t),expansions:{}}),collapseItem:e=>({value:ya(Of()),meta:{text:e}})}}),Af=tg({name:"InlineView",configFields:[dr("lazySink"),el("onShow"),el("onHide"),kr("onEscape"),Jm("inlineBehaviours",[Mm,Xm,Ql]),Er("fireDismissalEventInstead",[Tr("event",Ls())]),Er("fireRepositionEventInstead",[Tr("event",Hs())]),Tr("getRelated",D.none),Tr("isExtraPart",T),Tr("eventOrder",D.none)],factory:(e,t)=>{const o=(t,o,n,r)=>{const s=e.lazySink(t).getOrDie();Mm.openWhileCloaked(t,o,(()=>rm.positionWithinBounds(s,t,n,r()))),Xm.setValue(t,D.some({mode:"position",config:n,getBounds:r}))},n=(t,o,n,r)=>{const s=((e,t,o,n,r)=>{const s=()=>e.lazySink(t),a="horizontal"===n.type?{layouts:{onLtr:()=>Fl(),onRtl:()=>zl()}}:{},i=e=>(e=>2===e.length)(e)?a:{};return Df.sketch({dom:{tag:"div"},data:n.data,markers:n.menu.markers,highlightOnOpen:n.menu.highlightOnOpen,fakeFocus:n.menu.fakeFocus,onEscape:()=>(Mm.close(t),e.onEscape.map((e=>e(t))),D.some(!0)),onExecute:()=>D.some(!0),onOpenMenu:(e,t)=>{rm.positionWithinBounds(s().getOrDie(),t,o,r())},onOpenSubmenu:(e,t,o,n)=>{const r=s().getOrDie();rm.position(r,o,{anchor:{type:"submenu",item:t,...i(n)}})},onRepositionMenu:(e,t,n)=>{const a=s().getOrDie();rm.positionWithinBounds(a,t,o,r()),z(n,(e=>{const t=i(e.triggeringPath);rm.position(a,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem,...t}})}))}})})(e,t,o,n,r);Mm.open(t,s),Xm.setValue(t,D.some({mode:"menu",menu:s}))},r=t=>{Mm.isOpen(t)&&Xm.getValue(t).each((o=>{switch(o.mode){case"menu":Mm.getState(t).each(Df.repositionMenus);break;case"position":const n=e.lazySink(t).getOrDie();rm.positionWithinBounds(n,t,o.config,o.getBounds())}}))},s={setContent:(e,t)=>{Mm.setContent(e,t)},showAt:(e,t,n)=>{const r=D.none;o(e,t,n,r)},showWithinBounds:o,showMenuAt:(e,t,o)=>{n(e,t,o,D.none)},showMenuWithinBounds:n,hide:e=>{Mm.isOpen(e)&&(Xm.setValue(e,D.none()),Mm.close(e))},getContent:e=>Mm.getState(e),reposition:r,isOpen:Mm.isOpen};return{uid:e.uid,dom:e.dom,behaviours:eu(e.inlineBehaviours,[Mm.config({isPartOf:(t,o,n)=>Fi(o,n)||((t,o)=>e.getRelated(t).exists((e=>Fi(e,o))))(t,n),getAttachPoint:t=>e.lazySink(t).getOrDie(),onOpen:t=>{e.onShow(t)},onClose:t=>{e.onHide(t)}}),Xm.config({store:{mode:"memory",initialValue:D.none()}}),Ql.config({channels:{...Hm({isExtraPart:t.isExtraPart,...e.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Pm({...e.fireRepositionEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({}),doReposition:r})}})]),eventOrder:e.eventOrder,apis:s}},apis:{showAt:(e,t,o,n)=>{e.showAt(t,o,n)},showWithinBounds:(e,t,o,n,r)=>{e.showWithinBounds(t,o,n,r)},showMenuAt:(e,t,o,n)=>{e.showMenuAt(t,o,n)},showMenuWithinBounds:(e,t,o,n,r)=>{e.showMenuWithinBounds(t,o,n,r)},hide:(e,t)=>{e.hide(t)},isOpen:(e,t)=>e.isOpen(t),getContent:(e,t)=>e.getContent(t),setContent:(e,t,o)=>{e.setContent(t,o)},reposition:(e,t)=>{e.reposition(t)}}});var Mf=tinymce.util.Tools.resolve("tinymce.util.Delay");const Nf=tg({name:"Button",factory:e=>{const t=Qp(e.action),o=e.dom.tag,n=t=>ve(e.dom,"attributes").bind((e=>ve(e,t)));return{uid:e.uid,dom:e.dom,components:e.components,events:t,behaviours:ou(e.buttonBehaviours,[Zp.config({}),Tp.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:(()=>{if("button"===o){return{type:n("type").getOr("button"),...n("role").map((e=>({role:e}))).getOr({})}}return{role:e.role.getOr(n("role").getOr("button"))}})()},eventOrder:e.eventOrder}},configFields:[Tr("uid",void 0),dr("dom"),Tr("components",[]),tu("buttonBehaviours",[Zp,Tp]),yr("action"),yr("role"),Tr("eventOrder",{})]}),Rf=e=>{const t=Le.fromHtml(e),o=at(t),n=(e=>{const t=void 0!==e.dom.attributes?e.dom.attributes:[];return j(t,((e,t)=>"class"===t.name?e:{...e,[t.name]:t.value}),{})})(t),r=(e=>Array.prototype.slice.call(e.dom.classList,0))(t),s=0===o.length?{}:{innerHtml:ma(t)};return{tag:Ve(t),classes:r,attributes:n,...s}},Bf=e=>{const t=(e=>void 0!==e.uid)(e)&&ye(e,"uid")?e.uid:Ea("memento");return{get:e=>e.getSystem().getByUid(t).getOrDie(),getOpt:e=>e.getSystem().getByUid(t).toOptional(),asSpec:()=>({...e,uid:t})}},{entries:Lf,setPrototypeOf:Hf,isFrozen:If,getPrototypeOf:Pf,getOwnPropertyDescriptor:Ff}=Object;let{freeze:zf,seal:Vf,create:Zf}=Object,{apply:Uf,construct:jf}="undefined"!=typeof Reflect&&Reflect;Uf||(Uf=function(e,t,o){return e.apply(t,o)}),zf||(zf=function(e){return e}),Vf||(Vf=function(e){return e}),jf||(jf=function(e,t){return new e(...t)});const Wf=nv(Array.prototype.forEach),$f=nv(Array.prototype.pop),qf=nv(Array.prototype.push),Gf=nv(String.prototype.toLowerCase),Kf=nv(String.prototype.toString),Yf=nv(String.prototype.match),Xf=nv(String.prototype.replace),Jf=nv(String.prototype.indexOf),Qf=nv(String.prototype.trim),ev=nv(RegExp.prototype.test),tv=(ov=TypeError,function(){for(var e=arguments.length,t=new Array(e),o=0;o1?o-1:0),r=1;r/gm),wv=Vf(/\${[\w\W]*}/gm),xv=Vf(/^data-[\-\w.\u00B7-\uFFFF]/),Cv=Vf(/^aria-[\-\w]+$/),Sv=Vf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kv=Vf(/^(?:\w+script|data):/i),_v=Vf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ev=Vf(/^html$/i);var Tv=Object.freeze({__proto__:null,MUSTACHE_EXPR:bv,ERB_EXPR:yv,TMPLIT_EXPR:wv,DATA_ATTR:xv,ARIA_ATTR:Cv,IS_ALLOWED_URI:Sv,IS_SCRIPT_OR_DATA:kv,ATTR_WHITESPACE:_v,DOCTYPE_NAME:Ev});const Ov=()=>"undefined"==typeof window?null:window;var Dv=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ov();const o=t=>e(t);if(o.version="3.0.5",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;const n=t.document,r=n.currentScript;let{document:s}=t;const{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:m=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:h}=t,p=c.prototype,f=av(p,"cloneNode"),v=av(p,"nextSibling"),b=av(p,"childNodes"),y=av(p,"parentNode");if("function"==typeof i){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let w,x="";const{implementation:C,createNodeIterator:S,createDocumentFragment:k,getElementsByTagName:_}=s,{importNode:E}=n;let T={};o.isSupported="function"==typeof Lf&&"function"==typeof y&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:D,TMPLIT_EXPR:A,DATA_ATTR:M,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:R,ATTR_WHITESPACE:B}=Tv;let{IS_ALLOWED_URI:L}=Tv,H=null;const I=rv({},[...iv,...lv,...cv,...mv,...gv]);let P=null;const F=rv({},[...hv,...pv,...fv,...vv]);let z=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,Z=null,U=!0,j=!0,W=!1,$=!0,q=!1,G=!1,K=!1,Y=!1,X=!1,J=!1,Q=!1,ee=!0,te=!1,oe=!0,ne=!1,re={},se=null;const ae=rv({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ie=null;const le=rv({},["audio","video","img","source","image","track"]);let ce=null;const de=rv({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),me="http://www.w3.org/1998/Math/MathML",ue="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml";let he=ge,pe=!1,fe=null;const ve=rv({},[me,ue,ge],Kf);let be;const ye=["application/xhtml+xml","text/html"];let we,xe=null;const Ce=s.createElement("form"),Se=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){if(!xe||xe!==e){if(e&&"object"==typeof e||(e={}),e=sv(e),be=be=-1===ye.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,we="application/xhtml+xml"===be?Kf:Gf,H="ALLOWED_TAGS"in e?rv({},e.ALLOWED_TAGS,we):I,P="ALLOWED_ATTR"in e?rv({},e.ALLOWED_ATTR,we):F,fe="ALLOWED_NAMESPACES"in e?rv({},e.ALLOWED_NAMESPACES,Kf):ve,ce="ADD_URI_SAFE_ATTR"in e?rv(sv(de),e.ADD_URI_SAFE_ATTR,we):de,ie="ADD_DATA_URI_TAGS"in e?rv(sv(le),e.ADD_DATA_URI_TAGS,we):le,se="FORBID_CONTENTS"in e?rv({},e.FORBID_CONTENTS,we):ae,V="FORBID_TAGS"in e?rv({},e.FORBID_TAGS,we):{},Z="FORBID_ATTR"in e?rv({},e.FORBID_ATTR,we):{},re="USE_PROFILES"in e&&e.USE_PROFILES,U=!1!==e.ALLOW_ARIA_ATTR,j=!1!==e.ALLOW_DATA_ATTR,W=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,q=e.SAFE_FOR_TEMPLATES||!1,G=e.WHOLE_DOCUMENT||!1,X=e.RETURN_DOM||!1,J=e.RETURN_DOM_FRAGMENT||!1,Q=e.RETURN_TRUSTED_TYPE||!1,Y=e.FORCE_BODY||!1,ee=!1!==e.SANITIZE_DOM,te=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,ne=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||Sv,he=e.NAMESPACE||ge,z=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(j=!1),J&&(X=!0),re&&(H=rv({},[...gv]),P=[],!0===re.html&&(rv(H,iv),rv(P,hv)),!0===re.svg&&(rv(H,lv),rv(P,pv),rv(P,vv)),!0===re.svgFilters&&(rv(H,cv),rv(P,pv),rv(P,vv)),!0===re.mathMl&&(rv(H,mv),rv(P,fv),rv(P,vv))),e.ADD_TAGS&&(H===I&&(H=sv(H)),rv(H,e.ADD_TAGS,we)),e.ADD_ATTR&&(P===F&&(P=sv(P)),rv(P,e.ADD_ATTR,we)),e.ADD_URI_SAFE_ATTR&&rv(ce,e.ADD_URI_SAFE_ATTR,we),e.FORBID_CONTENTS&&(se===ae&&(se=sv(se)),rv(se,e.FORBID_CONTENTS,we)),oe&&(H["#text"]=!0),G&&rv(H,["html","head","body"]),H.table&&(rv(H,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw tv('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw tv('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,x=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let o=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(o=t.getAttribute(n));const r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,r)),null!==w&&"string"==typeof x&&(x=w.createHTML(""));zf&&zf(e),xe=e}},_e=rv({},["mi","mo","mn","ms","mtext"]),Ee=rv({},["foreignobject","desc","title","annotation-xml"]),Te=rv({},["title","style","font","a","script"]),Oe=rv({},lv);rv(Oe,cv),rv(Oe,dv);const De=rv({},mv);rv(De,uv);const Ae=function(e){qf(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},Me=function(e,t){try{qf(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){qf(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!P[e])if(X||J)try{Ae(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ne=function(e){let t,o;if(Y)e=""+e;else{const t=Yf(e,/^[\r\n\t ]+/);o=t&&t[0]}"application/xhtml+xml"===be&&he===ge&&(e=''+e+"");const n=w?w.createHTML(e):e;if(he===ge)try{t=(new g).parseFromString(n,be)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(he,"template",null);try{t.documentElement.innerHTML=pe?x:n}catch(e){}}const r=t.body||t.documentElement;return e&&o&&r.insertBefore(s.createTextNode(o),r.childNodes[0]||null),he===ge?_.call(t,G?"html":"body")[0]:G?t.documentElement:r},Re=function(e){return S.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Be=function(e){return"object"==typeof l?e instanceof l:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Le=function(e,t,n){T[e]&&Wf(T[e],(e=>{e.call(o,t,n,xe)}))},He=function(e){let t;if(Le("beforeSanitizeElements",e,null),(n=e)instanceof u&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof m)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore||"function"!=typeof n.hasChildNodes))return Ae(e),!0;var n;const r=we(e.nodeName);if(Le("uponSanitizeElement",e,{tagName:r,allowedTags:H}),e.hasChildNodes()&&!Be(e.firstElementChild)&&(!Be(e.content)||!Be(e.content.firstElementChild))&&ev(/<[/\w]/g,e.innerHTML)&&ev(/<[/\w]/g,e.textContent))return Ae(e),!0;if(!H[r]||V[r]){if(!V[r]&&Pe(r)){if(z.tagNameCheck instanceof RegExp&&ev(z.tagNameCheck,r))return!1;if(z.tagNameCheck instanceof Function&&z.tagNameCheck(r))return!1}if(oe&&!se[r]){const t=y(e)||e.parentNode,o=b(e)||e.childNodes;if(o&&t){for(let n=o.length-1;n>=0;--n)t.insertBefore(f(o[n],!0),v(e))}}return Ae(e),!0}return e instanceof c&&!function(e){let t=y(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});const o=Gf(e.tagName),n=Gf(t.tagName);return!!fe[e.namespaceURI]&&(e.namespaceURI===ue?t.namespaceURI===ge?"svg"===o:t.namespaceURI===me?"svg"===o&&("annotation-xml"===n||_e[n]):Boolean(Oe[o]):e.namespaceURI===me?t.namespaceURI===ge?"math"===o:t.namespaceURI===ue?"math"===o&&Ee[n]:Boolean(De[o]):e.namespaceURI===ge?!(t.namespaceURI===ue&&!Ee[n])&&!(t.namespaceURI===me&&!_e[n])&&!De[o]&&(Te[o]||!Oe[o]):!("application/xhtml+xml"!==be||!fe[e.namespaceURI]))}(e)?(Ae(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!ev(/<\/no(script|embed|frames)/i,e.innerHTML)?(q&&3===e.nodeType&&(t=e.textContent,t=Xf(t,O," "),t=Xf(t,D," "),t=Xf(t,A," "),e.textContent!==t&&(qf(o.removed,{element:e.cloneNode()}),e.textContent=t)),Le("afterSanitizeElements",e,null),!1):(Ae(e),!0)},Ie=function(e,t,o){if(ee&&("id"===t||"name"===t)&&(o in s||o in Ce))return!1;if(j&&!Z[t]&&ev(M,t));else if(U&&ev(N,t));else if(!P[t]||Z[t]){if(!(Pe(e)&&(z.tagNameCheck instanceof RegExp&&ev(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&ev(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t))||"is"===t&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ev(z.tagNameCheck,o)||z.tagNameCheck instanceof Function&&z.tagNameCheck(o))))return!1}else if(ce[t]);else if(ev(L,Xf(o,B,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Jf(o,"data:")||!ie[e]){if(W&&!ev(R,Xf(o,B,"")));else if(o)return!1}else;return!0},Pe=function(e){return e.indexOf("-")>0},Fe=function(e){let t,o,n,r;Le("beforeSanitizeAttributes",e,null);const{attributes:s}=e;if(!s)return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P};for(r=s.length;r--;){t=s[r];const{name:i,namespaceURI:l}=t;o="value"===i?t.value:Qf(t.value);const c=o;if(n=we(i),a.attrName=n,a.attrValue=o,a.keepAttr=!0,a.forceKeepAttr=void 0,Le("uponSanitizeAttribute",e,a),o=a.attrValue,a.forceKeepAttr)continue;if(!a.keepAttr){Me(i,e);continue}if(!$&&ev(/\/>/i,o)){Me(i,e);continue}q&&(o=Xf(o,O," "),o=Xf(o,D," "),o=Xf(o,A," "));const d=we(e.nodeName);if(Ie(d,n,o)){if(!te||"id"!==n&&"name"!==n||(Me(i,e),o="user-content-"+o),w&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(l);else switch(h.getAttributeType(d,n)){case"TrustedHTML":o=w.createHTML(o);break;case"TrustedScriptURL":o=w.createScriptURL(o)}if(o!==c)try{l?e.setAttributeNS(l,i,o):e.setAttribute(i,o)}catch(t){Me(i,e)}}else Me(i,e)}Le("afterSanitizeAttributes",e,null)},ze=function e(t){let o;const n=Re(t);for(Le("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Le("uponSanitizeShadowNode",o,null),He(o)||(o.content instanceof a&&e(o.content),Fe(o));Le("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t,r,s,i,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(pe=!e,pe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Be(e)){if("function"!=typeof e.toString)throw tv("toString is not a function");if("string"!=typeof(e=e.toString()))throw tv("dirty is not a string, aborting")}if(!o.isSupported)return e;if(K||ke(c),o.removed=[],"string"==typeof e&&(ne=!1),ne){if(e.nodeName){const t=we(e.nodeName);if(!H[t]||V[t])throw tv("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)t=Ne("\x3c!----\x3e"),r=t.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?t=r:t.appendChild(r);else{if(!X&&!q&&!G&&-1===e.indexOf("<"))return w&&Q?w.createHTML(e):e;if(t=Ne(e),!t)return X?null:Q?x:""}t&&Y&&Ae(t.firstChild);const d=Re(ne?e:t);for(;s=d.nextNode();)He(s)||(s.content instanceof a&&ze(s.content),Fe(s));if(ne)return e;if(X){if(J)for(i=k.call(t.ownerDocument);t.firstChild;)i.appendChild(t.firstChild);else i=t;return(P.shadowroot||P.shadowrootmode)&&(i=E.call(n,i,!0)),i}let m=G?t.outerHTML:t.innerHTML;return G&&H["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&ev(Ev,t.ownerDocument.doctype.name)&&(m="\n"+m),q&&(m=Xf(m,O," "),m=Xf(m,D," "),m=Xf(m,A," ")),w&&Q?w.createHTML(m):m},o.setConfig=function(e){ke(e),K=!0},o.clearConfig=function(){xe=null,K=!1},o.isValidAttribute=function(e,t,o){xe||ke({});const n=we(e),r=we(t);return Ie(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(T[e]=T[e]||[],qf(T[e],t))},o.removeHook=function(e){if(T[e])return $f(T[e])},o.removeHooks=function(e){T[e]&&(T[e]=[])},o.removeAllHooks=function(){T={}},o}();const Av=e=>Dv().sanitize(e);var Mv=tinymce.util.Tools.resolve("tinymce.util.I18n");const Nv={indent:!0,outdent:!0,"table-insert-column-after":!0,"table-insert-column-before":!0,"paste-column-after":!0,"paste-column-before":!0,"unordered-list":!0,"list-bull-circle":!0,"list-bull-default":!0,"list-bull-square":!0},Rv="temporary-placeholder",Bv=e=>()=>ve(e,Rv).getOr("!not found!"),Lv=(e,t)=>{const o=e.toLowerCase();if(Mv.isRtl()){const e=((e,t)=>De(e,t)?e:((e,t)=>e+t)(e,t))(o,"-rtl");return be(t,e)?e:o}return o},Hv=(e,t)=>ve(t,Lv(e,t)),Iv=(e,t)=>{const o=t();return Hv(e,o).getOrThunk(Bv(o))},Pv=()=>Ip("add-focusable",[ia((e=>{Ri(e.element,"svg").each((e=>St(e,"focusable","false")))}))]),Fv=(e,t,o,n)=>{var r,s;const a=(e=>!!Mv.isRtl()&&be(Nv,e))(t)?["tox-icon--flip"]:[],i=ve(o,Lv(t,o)).or(n).getOrThunk(Bv(o));return{dom:{tag:e.tag,attributes:null!==(r=e.attributes)&&void 0!==r?r:{},classes:e.classes.concat(a),innerHtml:i},behaviours:ql([...null!==(s=e.behaviours)&&void 0!==s?s:[],Pv()])}},zv=(e,t,o,n=D.none())=>Fv(t,e,o(),n),Vv={success:"checkmark",error:"warning",err:"error",warning:"warning",warn:"warning",info:"info"},Zv=tg({name:"Notification",factory:e=>{const t=Bf({dom:Rf(`

    ${Av(e.translationProvider(e.text))}

    `),behaviours:ql([Hp.config({})])}),o=e=>({dom:{tag:"div",classes:["tox-bar"],styles:{width:`${e}%`}}}),n=e=>({dom:{tag:"div",classes:["tox-text"],innerHtml:`${e}%`}}),r=Bf({dom:{tag:"div",classes:e.progress?["tox-progress-bar","tox-progress-indicator"]:["tox-progress-bar"]},components:[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(0)]},n(0)],behaviours:ql([Hp.config({})])}),s={updateProgress:(e,t)=>{e.getSystem().isConnected()&&r.getOpt(e).each((e=>{Hp.set(e,[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(t)]},n(t)])}))},updateText:(e,o)=>{if(e.getSystem().isConnected()){const n=t.get(e);Hp.set(n,[Ci(o)])}}},a=q([e.icon.toArray(),e.level.toArray(),e.level.bind((e=>D.from(Vv[e]))).toArray()]),i=Bf(Nf.sketch({dom:{tag:"button",classes:["tox-notification__dismiss","tox-button","tox-button--naked","tox-button--icon"]},components:[zv("close",{tag:"span",classes:["tox-icon"],attributes:{"aria-label":e.translationProvider("Close")}},e.iconProvider)],action:t=>{e.onAction(t)}})),l=((e,t,o)=>{const n=o(),r=W(e,(e=>be(n,Lv(e,n))));return Fv(t,r.getOr(Rv),n,D.none())})(a,{tag:"div",classes:["tox-notification__icon"]},e.iconProvider),c=[l,{dom:{tag:"div",classes:["tox-notification__body"]},components:[t.asSpec()],behaviours:ql([Hp.config({})])}];return{uid:e.uid,dom:{tag:"div",attributes:{role:"alert"},classes:e.level.map((e=>["tox-notification","tox-notification--in",`tox-notification--${e}`])).getOr(["tox-notification","tox-notification--in"])},behaviours:ql([Zp.config({}),Ip("notification-events",[Qs(ss(),(e=>{i.getOpt(e).each(Zp.focus)}))])]),components:c.concat(e.progress?[r.asSpec()]:[]).concat(e.closeButton?[i.asSpec()]:[]),apis:s}},configFields:[yr("level"),dr("progress"),yr("icon"),dr("onAction"),dr("text"),dr("iconProvider"),dr("translationProvider"),Nr("closeButton",!0)],apis:{updateProgress:(e,t,o)=>{e.updateProgress(t,o)},updateText:(e,t,o)=>{e.updateText(t,o)}}});var Uv,jv,Wv=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),$v=tinymce.util.Tools.resolve("tinymce.EditorManager"),qv=tinymce.util.Tools.resolve("tinymce.Env");!function(e){e.default="wrap",e.floating="floating",e.sliding="sliding",e.scrolling="scrolling"}(Uv||(Uv={})),function(e){e.auto="auto",e.top="top",e.bottom="bottom"}(jv||(jv={}));const Gv=e=>t=>t.options.get(e),Kv=e=>t=>D.from(e(t)),Yv=e=>{const t=qv.deviceType.isPhone(),o=qv.deviceType.isTablet()||t,n=e.options.register,r=e=>s(e)||!1===e,a=e=>s(e)||p(e);n("skin",{processor:e=>s(e)||!1===e,default:"oxide"}),n("skin_url",{processor:"string"}),n("height",{processor:a,default:Math.max(e.getElement().offsetHeight,400)}),n("width",{processor:a,default:Wv.DOM.getStyle(e.getElement(),"width")}),n("min_height",{processor:"number",default:100}),n("min_width",{processor:"number"}),n("max_height",{processor:"number"}),n("max_width",{processor:"number"}),n("style_formats",{processor:"object[]"}),n("style_formats_merge",{processor:"boolean",default:!1}),n("style_formats_autohide",{processor:"boolean",default:!1}),n("line_height_formats",{processor:"string",default:"1 1.1 1.2 1.3 1.4 1.5 2"}),n("font_family_formats",{processor:"string",default:"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats"}),n("font_size_formats",{processor:"string",default:"8pt 10pt 12pt 14pt 18pt 24pt 36pt"}),n("font_size_input_default_unit",{processor:"string",default:"pt"}),n("block_formats",{processor:"string",default:"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre"}),n("content_langs",{processor:"object[]"}),n("removed_menuitems",{processor:"string",default:""}),n("menubar",{processor:e=>s(e)||d(e),default:!t}),n("menu",{processor:"object",default:{}}),n("toolbar",{processor:e=>d(e)||s(e)||l(e)?{value:e,valid:!0}:{valid:!1,message:"Must be a boolean, string or array."},default:!0}),I(9,(e=>{n("toolbar"+(e+1),{processor:"string"})})),n("toolbar_mode",{processor:"string",default:o?"scrolling":"floating"}),n("toolbar_groups",{processor:"object",default:{}}),n("toolbar_location",{processor:"string",default:jv.auto}),n("toolbar_persist",{processor:"boolean",default:!1}),n("toolbar_sticky",{processor:"boolean",default:e.inline}),n("toolbar_sticky_offset",{processor:"number",default:0}),n("fixed_toolbar_container",{processor:"string",default:""}),n("fixed_toolbar_container_target",{processor:"object"}),n("ui_mode",{processor:"string",default:"combined"}),n("file_picker_callback",{processor:"function"}),n("file_picker_validator_handler",{processor:"function"}),n("file_picker_types",{processor:"string"}),n("typeahead_urls",{processor:"boolean",default:!0}),n("anchor_top",{processor:r,default:"#top"}),n("anchor_bottom",{processor:r,default:"#bottom"}),n("draggable_modal",{processor:"boolean",default:!1}),n("statusbar",{processor:"boolean",default:!0}),n("elementpath",{processor:"boolean",default:!0}),n("branding",{processor:"boolean",default:!0}),n("promotion",{processor:"boolean",default:!0}),n("resize",{processor:e=>"both"===e||d(e),default:!qv.deviceType.isTouch()}),n("sidebar_show",{processor:"string"}),n("help_accessibility",{processor:"boolean",default:e.hasPlugin("help")}),n("default_font_stack",{processor:"string[]",default:[]})},Xv=Gv("readonly"),Jv=Gv("height"),Qv=Gv("width"),eb=Kv(Gv("min_width")),tb=Kv(Gv("min_height")),ob=Kv(Gv("max_width")),nb=Kv(Gv("max_height")),rb=Kv(Gv("style_formats")),sb=Gv("style_formats_merge"),ab=Gv("style_formats_autohide"),ib=Gv("content_langs"),lb=Gv("removed_menuitems"),cb=Gv("toolbar_mode"),db=Gv("toolbar_groups"),mb=Gv("toolbar_location"),ub=Gv("fixed_toolbar_container"),gb=Gv("fixed_toolbar_container_target"),hb=Gv("toolbar_persist"),pb=Gv("toolbar_sticky_offset"),fb=Gv("menubar"),vb=Gv("toolbar"),bb=Gv("file_picker_callback"),yb=Gv("file_picker_validator_handler"),wb=Gv("font_size_input_default_unit"),xb=Gv("file_picker_types"),Cb=Gv("typeahead_urls"),Sb=Gv("anchor_top"),kb=Gv("anchor_bottom"),_b=Gv("draggable_modal"),Eb=Gv("statusbar"),Tb=Gv("elementpath"),Ob=Gv("branding"),Db=Gv("resize"),Ab=Gv("paste_as_text"),Mb=Gv("sidebar_show"),Nb=Gv("promotion"),Rb=Gv("help_accessibility"),Bb=Gv("default_font_stack"),Lb=e=>!1===e.options.get("skin"),Hb=e=>!1!==e.options.get("menubar"),Ib=e=>{const t=e.options.get("skin_url");if(Lb(e))return t;if(t)return e.documentBaseURI.toAbsolute(t);{const t=e.options.get("skin");return $v.baseURL+"/skins/ui/"+t}},Pb=e=>D.from(e.options.get("skin_url")),Fb=e=>e.options.get("line_height_formats").split(" "),zb=e=>{const t=vb(e),o=s(t),n=l(t)&&t.length>0;return!Zb(e)&&(n||o||!0===t)},Vb=e=>{const t=I(9,(t=>e.options.get("toolbar"+(t+1)))),o=Z(t,s);return ke(o.length>0,o)},Zb=e=>Vb(e).fold((()=>{const t=vb(e);return f(t,s)&&t.length>0}),O),Ub=e=>mb(e)===jv.bottom,jb=e=>{var t;if(!e.inline)return D.none();const o=null!==(t=ub(e))&&void 0!==t?t:"";if(o.length>0)return Bi(wt(),o);const n=gb(e);return g(n)?D.some(Le.fromDom(n)):D.none()},Wb=e=>e.inline&&jb(e).isSome(),$b=e=>jb(e).getOrThunk((()=>pt(ht(Le.fromDom(e.getElement()))))),qb=e=>e.inline&&!Hb(e)&&!zb(e)&&!Zb(e),Gb=e=>(e.options.get("toolbar_sticky")||e.inline)&&!Wb(e)&&!qb(e),Kb=e=>!Wb(e)&&"split"===e.options.get("ui_mode"),Yb=e=>{const t=e.options.get("menu");return ce(t,(e=>({...e,items:e.items})))};var Xb=Object.freeze({__proto__:null,get ToolbarMode(){return Uv},get ToolbarLocation(){return jv},register:Yv,getSkinUrl:Ib,getSkinUrlOption:Pb,isReadOnly:Xv,isSkinDisabled:Lb,getHeightOption:Jv,getWidthOption:Qv,getMinWidthOption:eb,getMinHeightOption:tb,getMaxWidthOption:ob,getMaxHeightOption:nb,getUserStyleFormats:rb,shouldMergeStyleFormats:sb,shouldAutoHideStyleFormats:ab,getLineHeightFormats:Fb,getContentLanguages:ib,getRemovedMenuItems:lb,isMenubarEnabled:Hb,isMultipleToolbars:Zb,isToolbarEnabled:zb,isToolbarPersist:hb,getMultipleToolbarsOption:Vb,getUiContainer:$b,useFixedContainer:Wb,isSplitUiMode:Kb,getToolbarMode:cb,isDraggableModal:_b,isDistractionFree:qb,isStickyToolbar:Gb,getStickyToolbarOffset:pb,getToolbarLocation:mb,isToolbarLocationBottom:Ub,getToolbarGroups:db,getMenus:Yb,getMenubar:fb,getToolbar:vb,getFilePickerCallback:bb,getFilePickerTypes:xb,useTypeaheadUrls:Cb,getAnchorTop:Sb,getAnchorBottom:kb,getFilePickerValidatorHandler:yb,getFontSizeInputDefaultUnit:wb,useStatusBar:Eb,useElementPath:Tb,promotionEnabled:Nb,useBranding:Ob,getResize:Db,getPasteAsText:Ab,getSidebarShow:Mb,useHelpAccessibility:Rb,getDefaultFontStack:Bb});const Jb="[data-mce-autocompleter]",Qb=e=>Li(e,Jb),ey=(e,t)=>{const o=(e,t)=>{Ws(e,is(),{raw:t})},n=()=>e.getMenu().bind(Mg.getHighlighted);t.on("keydown",(t=>{const r=t.which;e.isActive()&&(e.isMenuOpen()?13===r?(n().each($s),t.preventDefault()):40===r?(n().fold((()=>{e.getMenu().each(Mg.highlightFirst)}),(e=>{o(e,t)})),t.preventDefault(),t.stopImmediatePropagation()):37!==r&&38!==r&&39!==r||n().each((e=>{o(e,t),t.preventDefault(),t.stopImmediatePropagation()})):13!==r&&38!==r&&40!==r||e.cancelIfNecessary())})),t.on("NodeChange",(t=>{e.isActive()&&!e.isProcessingAction()&&Qb(Le.fromDom(t.element)).isNone()&&e.cancelIfNecessary()}))};var ty;!function(e){e[e.CLOSE_ON_EXECUTE=0]="CLOSE_ON_EXECUTE",e[e.BUBBLE_TO_SANDBOX=1]="BUBBLE_TO_SANDBOX"}(ty||(ty={}));var oy=ty;const ny="tox-menu-nav__js",ry="tox-collection__item",sy="tox-swatch",ay={normal:ny,color:sy},iy="tox-collection__item--enabled",ly="tox-collection__item-icon",cy="tox-collection__item-label",dy="tox-collection__item-caret",my="tox-collection__item--active",uy="tox-collection__item-container",gy="tox-collection__item-container--row",hy=e=>ve(ay,e).getOr(ny),py=e=>"color"===e?"tox-swatches":"tox-menu",fy=e=>({backgroundMenu:"tox-background-menu",selectedMenu:"tox-selected-menu",selectedItem:"tox-collection__item--active",hasIcons:"tox-menu--has-icons",menu:py(e),tieredMenu:"tox-tiered-menu"}),vy=e=>{const t=fy(e);return{backgroundMenu:t.backgroundMenu,selectedMenu:t.selectedMenu,menu:t.menu,selectedItem:t.selectedItem,item:hy(e)}},by=(e,t,o)=>{const n=fy(o);return{tag:"div",classes:q([[n.menu,`tox-menu-${t}-column`],e?[n.hasIcons]:[]])}},yy=[wf.parts.items({})],wy=(e,t,o)=>{const n=fy(o);return{dom:{tag:"div",classes:q([[n.tieredMenu]])},markers:vy(o)}},xy=w([yr("data"),Tr("inputAttributes",{}),Tr("inputStyles",{}),Tr("tag","input"),Tr("inputClasses",[]),el("onSetValue"),Tr("styles",{}),Tr("eventOrder",{}),Jm("inputBehaviours",[Xm,Zp]),Tr("selectOnFocus",!0)]),Cy=e=>ql([Zp.config({onFocus:e.selectOnFocus?e=>{const t=e.element,o=ci(t);t.dom.setSelectionRange(0,o.length)}:v})]),Sy=e=>({...Cy(e),...eu(e.inputBehaviours,[Xm.config({store:{mode:"manual",...e.data.map((e=>({initialValue:e}))).getOr({}),getValue:e=>ci(e.element),setValue:(e,t)=>{ci(e.element)!==t&&di(e.element,t)}},onSetValue:e.onSetValue})])}),ky=e=>({tag:e.tag,attributes:{type:"text",...e.inputAttributes},styles:e.inputStyles,classes:e.inputClasses}),_y=tg({name:"Input",configFields:xy(),factory:(e,t)=>({uid:e.uid,dom:ky(e),components:[],behaviours:Sy(e),eventOrder:e.eventOrder})}),Ey=ya("refetch-trigger-event"),Ty=ya("redirect-menu-item-interaction"),Oy="tox-menu__searcher",Dy=e=>Bi(e.element,`.${Oy}`).bind((t=>e.getSystem().getByDom(t).toOptional())),Ay=Dy,My=e=>({fetchPattern:Xm.getValue(e),selectionStart:e.element.dom.selectionStart,selectionEnd:e.element.dom.selectionEnd}),Ny=e=>{const t=(e,t)=>(t.cut(),D.none()),o=(e,t)=>{const o={interactionEvent:t.event,eventType:t.event.raw.type};return Ws(e,Ty,o),D.some(!0)},n="searcher-events";return{dom:{tag:"div",classes:[ry]},components:[_y.sketch({inputClasses:[Oy,"tox-textfield"],inputAttributes:{...e.placeholder.map((t=>({placeholder:e.i18n(t)}))).getOr({}),type:"search","aria-autocomplete":"list"},inputBehaviours:ql([Ip(n,[Qs(cs(),(e=>{js(e,Ey)})),Qs(is(),((e,t)=>{"Escape"===t.event.raw.key&&t.stop()}))]),Tp.config({mode:"special",onLeft:t,onRight:t,onSpace:t,onEnter:o,onEscape:o,onUp:o,onDown:o})]),eventOrder:{keydown:[n,Tp.name()]}})]}},Ry="tox-collection--results__js",By=e=>{var t;return e.dom?{...e,dom:{...e.dom,attributes:{...null!==(t=e.dom.attributes)&&void 0!==t?t:{},id:ya("aria-item-search-result-id"),"aria-selected":"false"}}}:e},Ly=(e,t)=>o=>{const n=P(o,t);return F(n,(t=>({dom:e,components:t})))},Hy=(e,t)=>{const o=[];let n=[];return z(e,((e,r)=>{t(e,r)?(n.length>0&&o.push(n),n=[],(be(e.dom,"innerHtml")||e.components&&e.components.length>0)&&n.push(e)):n.push(e)})),n.length>0&&o.push(n),F(o,(e=>({dom:{tag:"div",classes:["tox-collection__group"]},components:e})))},Iy=(e,t,o)=>wf.parts.items({preprocess:n=>{const r=F(n,o);return"auto"!==e&&e>1?Ly({tag:"div",classes:["tox-collection__group"]},e)(r):Hy(r,((e,o)=>"separator"===t[o].type))}}),Py=(e,t,o=!0)=>({dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Iy(e,t,x)]}),Fy=e=>H(e,(e=>"icon"in e&&void 0!==e.icon)),zy=e=>(console.error(rr(e)),console.log(e),D.none()),Vy=(e,t,o,n,r)=>{const s=(a=o,{dom:{tag:"div",classes:["tox-collection","tox-collection--horizontal"]},components:[wf.parts.items({preprocess:e=>Hy(e,((e,t)=>"separator"===a[t].type))})]});var a;return{value:e,dom:s.dom,components:s.components,items:o}},Zy=(e,t,o,n,r)=>{const s=()=>"searchable"!==r.menuType?Py(n,o):"search-with-field"===r.searchMode.searchMode?((e,t,o)=>{const n=ya("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Ny({i18n:Mv.translate,placeholder:o.placeholder}),{dom:{tag:"div",classes:[...1===e?["tox-collection--list"]:["tox-collection--grid"],Ry],attributes:{id:n}},components:[Iy(e,t,By)]}]}})(n,o,r.searchMode):((e,t,o=!0)=>{const n=ya("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection",Ry].concat(1===e?["tox-collection--list"]:["tox-collection--grid"]),attributes:{id:n}},components:[Iy(e,t,By)]}})(n,o);if("color"===r.menuType){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-swatches-menu"]},components:[{dom:{tag:"div",classes:["tox-swatches"]},components:[wf.parts.items({preprocess:"auto"!==e?Ly({tag:"div",classes:["tox-swatches__row"]},e):x})]}]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType&&"auto"===n){const t=Py(n,o);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType||"searchable"===r.menuType){const t=s();return{value:e,dom:t.dom,components:t.components,items:o}}if("listpreview"===r.menuType&&"auto"!==n){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-collection","tox-collection--toolbar","tox-collection--toolbar-lg"]},components:[wf.parts.items({preprocess:Ly({tag:"div",classes:["tox-collection__group"]},e)})]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}return{value:e,dom:by(t,n,r.menuType),components:yy,items:o}},Uy=gr("type"),jy=gr("name"),Wy=gr("label"),$y=gr("text"),qy=gr("title"),Gy=gr("icon"),Ky=gr("value"),Yy=pr("fetch"),Xy=pr("getSubmenuItems"),Jy=pr("onAction"),Qy=pr("onItemAction"),ew=Rr("onSetup",(()=>v)),tw=Cr("name"),ow=Cr("text"),nw=Cr("icon"),rw=Cr("tooltip"),sw=Cr("label"),aw=Cr("shortcut"),iw=kr("select"),lw=Nr("active",!1),cw=Nr("borderless",!1),dw=Nr("enabled",!0),mw=Nr("primary",!1),uw=e=>Tr("columns",e),gw=Tr("meta",{}),hw=Rr("onAction",v),pw=e=>Ar("type",e),fw=e=>ir("name","name",Sn((()=>ya(`${e}-name`))),$n),vw=Pn([Uy,ow]),bw=Pn([pw("autocompleteitem"),lw,dw,gw,Ky,ow,nw]),yw=[dw,rw,nw,ow,ew],ww=Pn([Uy,Jy].concat(yw)),xw=e=>tr("toolbarbutton",ww,e),Cw=[lw].concat(yw),Sw=Pn(Cw.concat([Uy,Jy])),kw=e=>tr("ToggleButton",Sw,e),_w=[Rr("predicate",T),Mr("scope","node",["node","editor"]),Mr("position","selection",["node","selection","line"])],Ew=yw.concat([pw("contextformbutton"),mw,Jy,lr("original",x)]),Tw=Cw.concat([pw("contextformbutton"),mw,Jy,lr("original",x)]),Ow=yw.concat([pw("contextformbutton")]),Dw=Cw.concat([pw("contextformtogglebutton")]),Aw=sr("type",{contextformbutton:Ew,contextformtogglebutton:Tw}),Mw=Pn([pw("contextform"),Rr("initValue",w("")),sw,br("commands",Aw),wr("launch",sr("type",{contextformbutton:Ow,contextformtogglebutton:Dw}))].concat(_w)),Nw=Pn([pw("contexttoolbar"),gr("items")].concat(_w)),Rw=[Uy,gr("src"),Cr("alt"),Br("classes",[],$n)],Bw=Pn(Rw),Lw=[Uy,$y,tw,Br("classes",["tox-collection__item-label"],$n)],Hw=Pn(Lw),Iw=Ln((()=>Jn("type",{cardimage:Bw,cardtext:Hw,cardcontainer:Pw}))),Pw=Pn([Uy,Ar("direction","horizontal"),Ar("align","left"),Ar("valign","middle"),br("items",Iw)]),Fw=[dw,ow,aw,(zw="menuitem",ir("value","value",Sn((()=>ya(`${zw}-value`))),Un())),gw];var zw;const Vw=Pn([Uy,sw,br("items",Iw),ew,hw].concat(Fw)),Zw=Pn([Uy,lw,nw].concat(Fw)),Uw=[Uy,gr("fancytype"),hw],jw=[Tr("initData",{})].concat(Uw),Ww=[kr("select"),Lr("initData",{},[Nr("allowCustomColors",!0),Ar("storageKey","default"),_r("colors",Un())])].concat(Uw),$w=sr("fancytype",{inserttable:jw,colorswatch:Ww}),qw=Pn([Uy,ew,hw,nw].concat(Fw)),Gw=Pn([Uy,Xy,ew,nw].concat(Fw)),Kw=Pn([Uy,nw,lw,ew,Jy].concat(Fw)),Yw=(e,t,o)=>{const n=_d(e.element,"."+o);if(n.length>0){const e=$(n,(e=>{const o=e.dom.getBoundingClientRect().top,r=n[0].dom.getBoundingClientRect().top;return Math.abs(o-r)>t})).getOr(n.length);return D.some({numColumns:e,numRows:Math.ceil(n.length/e)})}return D.none()},Xw=(e,t)=>ql([Ip(e,t)]),Jw=e=>Xw(ya("unnamed-events"),e),Qw=ya("tooltip.exclusive"),ex=ya("tooltip.show"),tx=ya("tooltip.hide"),ox=(e,t,o)=>{e.getSystem().broadcastOn([Qw],{})};var nx=Object.freeze({__proto__:null,hideAllExclusive:ox,setComponents:(e,t,o,n)=>{o.getTooltip().each((e=>{e.getSystem().isConnected()&&Hp.set(e,n)}))}});var rx=Object.freeze({__proto__:null,events:(e,t)=>{const o=o=>{t.getTooltip().each((n=>{pm(n),e.onHide(o,n),t.clearTooltip()})),t.clearTimer()};return Ys(q([[Qs(ex,(o=>{t.resetTimer((()=>{(o=>{if(!t.isShowing()){ox(o);const n=e.lazySink(o).getOrDie(),r=o.getSystem().build({dom:e.tooltipDom,components:e.tooltipComponents,events:Ys("normal"===e.mode?[Qs(rs(),(e=>{js(o,ex)})),Qs(os(),(e=>{js(o,tx)}))]:[]),behaviours:ql([Hp.config({})])});t.setTooltip(r),um(n,r),e.onShow(o,r),rm.position(n,r,{anchor:e.anchor(o)})}})(o)}),e.delay)})),Qs(tx,(n=>{t.resetTimer((()=>{o(n)}),e.delay)})),Qs(xs(),((e,t)=>{const n=t;n.universal||L(n.channels,Qw)&&o(e)})),la((e=>{o(e)}))],"normal"===e.mode?[Qs(ss(),(e=>{js(e,ex)})),Qs(ys(),(e=>{js(e,tx)})),Qs(rs(),(e=>{js(e,ex)})),Qs(os(),(e=>{js(e,tx)}))]:[Qs(Zs(),((e,t)=>{js(e,ex)})),Qs(Us(),(e=>{js(e,tx)}))]]))}}),sx=[dr("lazySink"),dr("tooltipDom"),Tr("exclusive",!0),Tr("tooltipComponents",[]),Tr("delay",300),Mr("mode","normal",["normal","follow-highlight"]),Tr("anchor",(e=>({type:"hotspot",hotspot:e,layouts:{onLtr:w([Nl,Ml,Tl,Dl,Ol,Al]),onRtl:w([Nl,Ml,Tl,Dl,Ol,Al])}}))),el("onHide"),el("onShow")];var ax=Object.freeze({__proto__:null,init:()=>{const e=kc(),t=kc(),o=()=>{e.on(clearTimeout)},n=w("not-implemented");return Ia({getTooltip:t.get,isShowing:t.isSet,setTooltip:t.set,clearTooltip:t.clear,clearTimer:o,resetTimer:(t,n)=>{o(),e.set(setTimeout(t,n))},readState:n})}});const ix=Kl({fields:sx,name:"tooltipping",active:rx,state:ax,apis:nx}),lx="silver.readonly",cx=Pn([(dx="readonly",mr(dx,qn))]);var dx;const mx=(e,t)=>{const o=e.mainUi.outerContainer.element,n=[e.mainUi.mothership,...e.uiMotherships];t&&z(n,(e=>{e.broadcastOn([Nm()],{target:o})})),z(n,(e=>{e.broadcastOn([lx],{readonly:t})}))},ux=(e,t)=>{e.on("init",(()=>{e.mode.isReadOnly()&&mx(t,!0)})),e.on("SwitchMode",(()=>mx(t,e.mode.isReadOnly()))),Xv(e)&&e.mode.set("readonly")},gx=()=>Ql.config({channels:{[lx]:{schema:cx,onReceive:(e,t)=>{wg.set(e,t.readonly)}}}}),hx=e=>wg.config({disabled:e,disableClass:"tox-collection__item--state-disabled"}),px=e=>wg.config({disabled:e}),fx=e=>wg.config({disabled:e,disableClass:"tox-tbtn--disabled"}),vx=e=>wg.config({disabled:e,disableClass:"tox-tbtn--disabled",useNative:!1}),bx=(e,t)=>{const o=e.getApi(t);return e=>{e(o)}},yx=(e,t)=>ia((o=>{bx(e,o)((o=>{const n=e.onSetup(o);h(n)&&t.set(n)}))})),wx=(e,t)=>la((o=>bx(e,o)(t.get()))),xx=(e,t)=>da(((o,n)=>{bx(e,o)(e.onAction),e.triggersSubmenu||t!==oy.CLOSE_ON_EXECUTE||(o.getSystem().isConnected()&&js(o,Es()),n.stop())})),Cx={[Cs()]:["disabling","alloy.base.behaviour","toggling","item-events"]},Sx=xe,kx=(e,t,o,n)=>{const r=Hr(v);return{type:"item",dom:t.dom,components:Sx(t.optComponents),data:e.data,eventOrder:Cx,hasSubmenu:e.triggersSubmenu,itemBehaviours:ql([Ip("item-events",[xx(e,o),yx(e,r),wx(e,r)]),hx((()=>!e.enabled||n.isDisabled())),gx(),Hp.config({})].concat(e.itemBehaviours))}},_x=e=>({value:e.value,meta:{text:e.text.getOr(""),...e.meta}}),Ex=e=>{const t=qv.os.isMacOS()||qv.os.isiOS(),o=t?{alt:"⌥",ctrl:"⌃",shift:"⇧",meta:"⌘",access:"⌃⌥"}:{meta:"Ctrl",access:"Shift+Alt"},n=e.split("+"),r=F(n,(e=>{const t=e.toLowerCase().trim();return be(o,t)?o[t]:e}));return t?r.join(""):r.join("+")},Tx=(e,t,o=[ly])=>zv(e,{tag:"div",classes:o},t),Ox=e=>({dom:{tag:"div",classes:[cy]},components:[Ci(Mv.translate(e))]}),Dx=(e,t)=>({dom:{tag:"div",classes:t,innerHtml:e}}),Ax=(e,t)=>({dom:{tag:"div",classes:[cy]},components:[{dom:{tag:e.tag,styles:e.styles},components:[Ci(Mv.translate(t))]}]}),Mx=e=>({dom:{tag:"div",classes:["tox-collection__item-accessory"]},components:[Ci(Ex(e))]}),Nx=e=>Tx("checkmark",e,["tox-collection__item-checkmark"]),Rx=(e,t,o)=>{const n=e.ariaLabel,r=e.value,s=e.iconContent.map((e=>((e,t,o)=>{const n=t();return Hv(e,n).or(o).getOrThunk(Bv(n))})(e,t.icons,o)));return{dom:(()=>{const e=sy,o=s.getOr(""),a=n.map((e=>({title:t.translate(e)}))).getOr({}),i={tag:"div",attributes:a,classes:[e]};return"custom"===r?{...i,tag:"button",classes:[...i.classes,"tox-swatches__picker-btn"],innerHtml:o}:"remove"===r?{...i,classes:[...i.classes,"tox-swatch--remove"],innerHtml:o}:g(r)?{...i,attributes:{...i.attributes,"data-mce-color":r},styles:{"background-color":r},innerHtml:o}:i})(),optComponents:[]}},Bx=e=>{const t=e.map((e=>({attributes:{title:Mv.translate(e),id:ya("menu-item")}}))).getOr({});return{tag:"div",classes:[ny,ry],...t}},Lx=(e,t,o,n=D.none())=>"color"===e.presets?Rx(e,t,n):((e,t,o,n)=>{const r={tag:"div",classes:[ly]},s=o?e.iconContent.map((e=>zv(e,r,t.icons,n))).orThunk((()=>D.some({dom:r}))):D.none(),a=e.checkMark,i=D.from(e.meta).fold((()=>Ox),(e=>be(e,"style")?S(Ax,e.style):Ox)),l=e.htmlContent.fold((()=>e.textContent.map(i)),(e=>D.some(Dx(e,[cy]))));return{dom:Bx(e.ariaLabel),optComponents:[s,l,e.shortcutContent.map(Mx),a,e.caret]}})(e,t,o,n),Hx=(e,t)=>ve(e,"tooltipWorker").map((e=>[ix.config({lazySink:t.getSink,tooltipDom:{tag:"div",classes:["tox-tooltip-worker-container"]},tooltipComponents:[],anchor:e=>({type:"submenu",item:e,overrides:{maxHeightFunction:Fc}}),mode:"follow-highlight",onShow:(t,o)=>{e((e=>{ix.setComponents(t,[Si({element:Le.fromDom(e)})])}))}})])).getOr([]),Ix=(e,t)=>{const o=(e=>Wv.DOM.encode(e))(Mv.translate(e));if(t.length>0){const e=new RegExp((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(t),"gi");return o.replace(e,(e=>`${e}`))}return o},Px=(e,t)=>F(e,(e=>{switch(e.type){case"cardcontainer":return((e,t)=>{const o="vertical"===e.direction?"tox-collection__item-container--column":gy,n="left"===e.align?"tox-collection__item-container--align-left":"tox-collection__item-container--align-right";return{dom:{tag:"div",classes:[uy,o,n,(()=>{switch(e.valign){case"top":return"tox-collection__item-container--valign-top";case"middle":return"tox-collection__item-container--valign-middle";case"bottom":return"tox-collection__item-container--valign-bottom"}})()]},components:t}})(e,Px(e.items,t));case"cardimage":return((e,t,o)=>({dom:{tag:"img",classes:t,attributes:{src:e,alt:o.getOr("")}}}))(e.src,e.classes,e.alt);case"cardtext":const o=e.name.exists((e=>L(t.cardText.highlightOn,e))),n=o?D.from(t.cardText.matchText).getOr(""):"";return Dx(Ix(e.text,n),e.classes)}})),Fx=Bu(gf(),hf()),zx=e=>({value:jx(e)}),Vx=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Zx=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Ux=e=>Vx.test(e)||Zx.test(e),jx=e=>Ee(e,"#").toUpperCase(),Wx=e=>{const t=(e=>{const t=e.value.replace(Vx,((e,t,o,n)=>t+t+o+o+n+n));return{value:t}})(e),o=Zx.exec(t.value);return null===o?["FFFFFF","FF","FF","FF"]:o},$x=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},qx=e=>{const t=$x(e.red)+$x(e.green)+$x(e.blue);return zx(t)},Gx=Math.min,Kx=Math.max,Yx=Math.round,Xx=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,Jx=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,Qx=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),eC=e=>{const t=parseInt(e,10);return t.toString()===e&&t>=0&&t<=255},tC=e=>{let t,o,n;const r=(e.hue||0)%360;let s=e.saturation/100,a=e.value/100;if(s=Kx(0,Gx(s,1)),a=Kx(0,Gx(a,1)),0===s)return t=o=n=Yx(255*a),Qx(t,o,n,1);const i=r/60,l=a*s,c=l*(1-Math.abs(i%2-1)),d=a-l;switch(Math.floor(i)){case 0:t=l,o=c,n=0;break;case 1:t=c,o=l,n=0;break;case 2:t=0,o=l,n=c;break;case 3:t=0,o=c,n=l;break;case 4:t=c,o=0,n=l;break;case 5:t=l,o=0,n=c;break;default:t=o=n=0}return t=Yx(255*(t+d)),o=Yx(255*(o+d)),n=Yx(255*(n+d)),Qx(t,o,n,1)},oC=e=>{const t=Wx(e),o=parseInt(t[1],16),n=parseInt(t[2],16),r=parseInt(t[3],16);return Qx(o,n,r,1)},nC=(e,t,o,n)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(o,10),i=parseFloat(n);return Qx(r,s,a,i)},rC=e=>{if("transparent"===e)return D.some(Qx(0,0,0,0));const t=Xx.exec(e);if(null!==t)return D.some(nC(t[1],t[2],t[3],"1"));const o=Jx.exec(e);return null!==o?D.some(nC(o[1],o[2],o[3],o[4])):D.none()},sC=e=>`rgba(${e.red},${e.green},${e.blue},${e.alpha})`,aC=Qx(255,0,0,1),iC=(e,t)=>{e.dispatch("ResizeContent",t)},lC=(e,t)=>{e.dispatch("TextColorChange",t)},cC=(e,t)=>e.dispatch("ResolveName",{name:t.nodeName.toLowerCase(),target:t}),dC=(e,t)=>()=>{e(),t()},mC=e=>gC(e,"NodeChange",(t=>{t.setEnabled(e.selection.isEditable())})),uC=(e,t)=>o=>{const n=mC(e)(o),r=((e,t)=>o=>{const n=Sc(),r=()=>{o.setActive(e.formatter.match(t));const r=e.formatter.formatChanged(t,o.setActive);n.set(r)};return e.initialized?r():e.once("init",r),()=>{e.off("init",r),n.clear()}})(e,t)(o);return()=>{n(),r()}},gC=(e,t,o)=>n=>{const r=()=>o(n),s=()=>{o(n),e.on(t,r)};return e.initialized?s():e.once("init",s),()=>{e.off("init",s),e.off(t,r)}},hC=e=>t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("mceToggleFormat",!1,t.format)}))},pC=(e,t)=>()=>e.execCommand(t);var fC=tinymce.util.Tools.resolve("tinymce.util.LocalStorage");const vC={},bC=e=>ve(vC,e).getOrThunk((()=>{const t=`tinymce-custom-colors-${e}`,o=fC.getItem(t);if(u(o)){const e=fC.getItem("tinymce-custom-colors");fC.setItem(t,g(e)?e:"[]")}const n=((e,t=10)=>{const o=fC.getItem(e),n=s(o)?JSON.parse(o):[],r=t-(a=n).length<0?a.slice(0,t):a;var a;const i=e=>{r.splice(e,1)};return{add:o=>{B(r,o).each(i),r.unshift(o),r.length>t&&r.pop(),fC.setItem(e,JSON.stringify(r))},state:()=>r.slice(0)}})(t,10);return vC[e]=n,n})),yC=(e,t)=>{bC(e).add(t)},wC=(e,t,o)=>({hue:e,saturation:t,value:o}),xC=e=>{let t=0,o=0,n=0;const r=e.red/255,s=e.green/255,a=e.blue/255,i=Math.min(r,Math.min(s,a)),l=Math.max(r,Math.max(s,a));if(i===l)return n=i,wC(0,0,100*n);return t=r===i?3:a===i?1:5,t=60*(t-(r===i?s-a:a===i?r-s:a-r)/(l-i)),o=(l-i)/l,n=l,wC(Math.round(t),Math.round(100*o),Math.round(100*n))},CC=e=>qx(tC(e)),SC=e=>{return(t=e,Ux(t)?D.some({value:jx(t)}):D.none()).orThunk((()=>rC(e).map(qx))).getOrThunk((()=>{const t=document.createElement("canvas");t.height=1,t.width=1;const o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),o.fillStyle="#FFFFFF",o.fillStyle=e,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data,r=n[0],s=n[1],a=n[2],i=n[3];return qx(Qx(r,s,a,i))}));var t},kC="forecolor",_C="hilitecolor",EC=e=>{const t=[];for(let o=0;ot=>t.options.get(e),OC="#000000",DC=(e,t)=>t===kC&&e.options.isSet("color_map_foreground")?TC("color_map_foreground")(e):t===_C&&e.options.isSet("color_map_background")?TC("color_map_background")(e):TC("color_map")(e),AC=(e,t="default")=>Math.max(5,Math.ceil(Math.sqrt(DC(e,t).length))),MC=(e,t)=>{const o=TC("color_cols")(e),n=AC(e,t);return o===AC(e)?n:o},NC=(e,t="default")=>Math.round(t===kC?TC("color_cols_foreground")(e):t===_C?TC("color_cols_background")(e):TC("color_cols")(e)),RC=TC("custom_colors"),BC=TC("color_default_foreground"),LC=TC("color_default_background"),HC=e=>jr(e,(e=>{if(je(e)){const t=Bt(e,"background-color");return ke((e=>rC(e).exists((e=>0!==e.alpha)))(t),t)}return D.none()})).getOr("rgba(0, 0, 0, 0)"),IC=(e,t)=>{const o=Le.fromDom(e.selection.getStart()),n="hilitecolor"===t?HC(o):Bt(o,"color");return rC(n).map((e=>"#"+qx(e).value))},PC=e=>{const t="choiceitem",o={type:t,text:"Remove color",icon:"color-swatch-remove-color",value:"remove"};return e?[o,{type:t,text:"Custom color",icon:"color-picker",value:"custom"}]:[o]},FC=(e,t,o,n)=>{if("custom"===o){GC(e)((o=>{o.each((o=>{yC(t,o),e.execCommand("mceApplyTextcolor",t,o),n(o)}))}),IC(e,t).getOr(OC))}else"remove"===o?(n(""),e.execCommand("mceRemoveTextcolor",t)):(n(o),e.execCommand("mceApplyTextcolor",t,o))},zC=(e,t,o)=>e.concat((e=>F(bC(e).state(),(e=>({type:"choiceitem",text:e,icon:"checkmark",value:e}))))(t).concat(PC(o))),VC=(e,t,o)=>n=>{n(zC(e,t,o))},ZC=(e,t,o)=>{const n="forecolor"===t?"tox-icon-text-color__color":"tox-icon-highlight-bg-color__color";e.setIconFill(n,o)},UC=(e,t)=>{e.setTooltip(t)},jC=(e,t)=>o=>{const n=IC(e,t);return we(n,o.toUpperCase())},WC=(e,t,o)=>{if(Ne(o))return"forecolor"===t?"Text color":"Background color";const n="forecolor"===t?"Text color {0}":"Background color {0}",r=zC(DC(e,t),t,!1),s=W(r,(e=>e.value===o)).getOr({text:""}).text;return e.translate([n,e.translate(s)])},$C=(e,t,o,n)=>{e.ui.registry.addSplitButton(t,{tooltip:WC(e,o,n.get()),presets:"color",icon:"forecolor"===t?"text-color":"highlight-bg-color",select:jC(e,o),columns:NC(e,o),fetch:VC(DC(e,o),o,RC(e)),onAction:t=>{FC(e,o,n.get(),v)},onItemAction:(r,s)=>{FC(e,o,s,(o=>{n.set(o),lC(e,{name:t,color:o})}))},onSetup:r=>{ZC(r,t,n.get());const s=n=>{n.name===t&&(ZC(r,n.name,n.color),UC(r,WC(e,o,n.color)))};return e.on("TextColorChange",s),dC(mC(e)(r),(()=>{e.off("TextColorChange",s)}))}})},qC=(e,t,o,n,r)=>{e.ui.registry.addNestedMenuItem(t,{text:n,icon:"forecolor"===t?"text-color":"highlight-bg-color",onSetup:n=>(UC(n,WC(e,o,r.get())),ZC(n,t,r.get()),mC(e)(n)),getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"colorswatch",select:jC(e,o),initData:{storageKey:o},onAction:n=>{FC(e,o,n.value,(o=>{r.set(o),lC(e,{name:t,color:o})}))}}]})},GC=e=>(t,o)=>{let n=!1;const r={colorpicker:o};e.windowManager.open({title:"Color Picker",size:"normal",body:{type:"panel",items:[{type:"colorpicker",name:"colorpicker",label:"Color"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:r,onAction:(e,t)=>{"hex-valid"===t.name&&(n=t.value)},onSubmit:o=>{const r=o.getData().colorpicker;n?(t(D.from(r)),o.close()):e.windowManager.alert(e.translate(["Invalid hex color code: {0}",r]))},onClose:v,onCancel:()=>{t(D.none())}})},KC=(e,t,o,n,r,s,a,i)=>{const l=Fy(t),c=YC(t,o,n,"color"!==r?"normal":"color",s,a,i);return Zy(e,l,c,n,{menuType:r})},YC=(e,t,o,n,r,s,a)=>xe(F(e,(i=>{return"choiceitem"===i.type?(l=i,tr("choicemenuitem",Zw,l)).fold(zy,(i=>D.some(((e,t,o,n,r,s,a,i=!0)=>{const l=Lx({presets:o,textContent:t?e.text:D.none(),htmlContent:D.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:t?e.shortcut:D.none(),checkMark:t?D.some(Nx(a.icons)):D.none(),caret:D.none(),value:e.value},a,i);return xn(kx({data:_x(e),enabled:e.enabled,getApi:e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t)}),onAction:t=>n(e.value),onSetup:e=>(e.setActive(r),v),triggersSubmenu:!1,itemBehaviours:[]},l,s,a),{toggling:{toggleClass:iy,toggleOnExecute:!1,selected:e.active,exclusive:!0}})})(i,1===o,n,t,s(i.value),r,a,Fy(e))))):D.none();var l}))),XC=(e,t)=>{const o=vy(t);if(1===e)return{mode:"menu",moveOnTab:!0};if("auto"===e)return{mode:"grid",selector:"."+o.item,initSize:{numColumns:1,numRows:1}};return{mode:"matrix",rowSelector:"."+("color"===t?"tox-swatches__row":"tox-collection__group"),previousSelector:e=>"color"===t?Bi(e.element,"[aria-checked=true]"):D.none()}},JC=(e,t)=>{const o=e.initData.allowCustomColors&&t.colorinput.hasCustomColors();return e.initData.colors.fold((()=>zC(t.colorinput.getColors(e.initData.storageKey),e.initData.storageKey,o)),(e=>e.concat(PC(o))))},QC=ya("cell-over"),eS=ya("cell-execute"),tS=(e,t,o)=>{const n=o=>Ws(o,eS,{row:e,col:t}),r=(e,t)=>{t.stop(),n(e)};return Ei({dom:{tag:"div",attributes:{role:"button","aria-label":o}},behaviours:ql([Ip("insert-table-picker-cell",[Qs(rs(),Zp.focus),Qs(Cs(),n),Qs(ms(),r),Qs(ks(),r)]),Yp.config({toggleClass:"tox-insert-table-picker__selected",toggleOnExecute:!1}),Zp.config({onFocus:o=>Ws(o,QC,{row:e,col:t})})])})},oS=e=>G(e,(e=>F(e,Ti))),nS=(e,t)=>Ci(`${t}x${e}`),rS={inserttable:(e,t)=>{const o=(e=>(t,o)=>e.shared.providers.translate(["{0} columns, {1} rows",o,t]))(t),n=((e,t,o)=>{const n=[];for(let r=0;r{Hp.set(s.get(e),[r])})),na(QC,((e,t,o)=>{const{row:r,col:a}=o.event;((e,t,o,n,r)=>{for(let s=0;s{const{row:r,col:s}=n.event;e.onAction({numRows:r+1,numColumns:s+1}),js(t,Es())}))]),Tp.config({initSize:{numRows:10,numColumns:10},mode:"flatgrid",selector:'[role="button"]'})])})]}},colorswatch:(e,t)=>{const o=JC(e,t),n=t.colorinput.getColorCols(e.initData.storageKey),r="color",s=KC(ya("menu-value"),o,(t=>{e.onAction({value:t})}),n,r,oy.CLOSE_ON_EXECUTE,e.select.getOr(T),t.shared.providers),a={...s,markers:vy(r),movement:XC(n,r)};return{type:"widget",data:{value:ya("widget-id")},dom:{tag:"div",classes:["tox-fancymenuitem"]},autofocus:!0,components:[Fx.widget(wf.sketch(a))]}}},sS=(e,t,o,n,r,s,a,i=!0)=>{const l=Lx({presets:n,textContent:D.none(),htmlContent:o?e.text.map((e=>Ix(e,t))):D.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:D.none(),checkMark:D.none(),caret:D.none(),value:e.value},a.providers,i,e.icon);return kx({data:_x(e),enabled:e.enabled,getApi:w({}),onAction:t=>r(e.value,e.meta),onSetup:w(v),triggersSubmenu:!1,itemBehaviours:Hx(e.meta,a)},l,s,a.providers)},aS=e=>({type:"separator",dom:{tag:"div",classes:[ry,"tox-collection__group-heading"]},components:e.text.map(Ci).toArray()}),iS=(e,t,o,n=!0)=>{const r=Lx({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:D.none(),ariaLabel:e.text,caret:D.none(),checkMark:D.none(),shortcutContent:e.shortcut},o,n);return kx({data:_x(e),getApi:e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t)}),enabled:e.enabled,onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o)},lS=(e,t,o,n=!0,r=!1)=>{const s=r?(a=o.icons,Tx("chevron-down",a,[dy])):(e=>Tx("chevron-right",e,[dy]))(o.icons);var a;const i=Lx({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:D.none(),ariaLabel:e.text,caret:D.some(s),checkMark:D.none(),shortcutContent:e.shortcut},o,n);return kx({data:_x(e),getApi:e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setIconFill:(t,o)=>{Bi(e.element,`svg path[class="${t}"], rect[class="${t}"]`).each((e=>{St(e,"fill",o)}))},setTooltip:t=>{const n=o.translate(t);kt(e.element,{"aria-label":n,title:n})}}),enabled:e.enabled,onAction:v,onSetup:e.onSetup,triggersSubmenu:!0,itemBehaviours:[]},i,t,o)},cS=(e,t,o,n=!0)=>{const r=Lx({iconContent:e.icon,textContent:e.text,htmlContent:D.none(),ariaLabel:e.text,checkMark:D.some(Nx(o.icons)),caret:D.none(),shortcutContent:e.shortcut,presets:"normal",meta:e.meta},o,n);return xn(kx({data:_x(e),enabled:e.enabled,getApi:e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t)}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o),{toggling:{toggleClass:iy,toggleOnExecute:!1,selected:e.active}})},dS=(e,t)=>ve(rS,e.fancytype).map((o=>o(e,t))),mS=(e,t,o,n)=>{const r={dom:Bx(e.label),optComponents:[D.some({dom:{tag:"div",classes:[uy,gy]},components:Px(e.items,n)})]};return kx({data:_x({text:D.none(),...e}),enabled:e.enabled,getApi:e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>{wg.set(e,!t),z(_d(e.element,"*"),(o=>{e.getSystem().getByDom(o).each((e=>{e.hasConfigured(wg)&&wg.set(e,!t)}))}))}}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:D.from(n.itemBehaviours).getOr([])},r,t,o.providers)};var uS=Object.freeze({__proto__:null,getCoupled:(e,t,o,n)=>o.getOrCreate(e,t,n),getExistingCoupled:(e,t,o,n)=>o.getExisting(e,t,n)}),gS=[mr("others",er(on.value,Un()))];var hS=Object.freeze({__proto__:null,init:()=>{const e={},t=(t,o)=>{if(0===ae(t.others).length)throw new Error("Cannot find any known coupled components");return ve(e,o)},o=w({});return Ia({readState:o,getExisting:(e,o,n)=>t(o,n).orThunk((()=>(ve(o.others,n).getOrDie("No information found for coupled component: "+n),D.none()))),getOrCreate:(o,n,r)=>t(n,r).getOrThunk((()=>{const t=ve(n.others,r).getOrDie("No information found for coupled component: "+r)(o),s=o.getSystem().build(t);return e[r]=s,s}))})}});const pS=Kl({fields:gS,name:"coupling",apis:uS,state:hS}),fS=e=>{let t=D.none(),o=[];const n=e=>{r()?a(e):o.push(e)},r=()=>t.isSome(),s=e=>{z(e,a)},a=e=>{t.each((t=>{setTimeout((()=>{e(t)}),0)}))};return e((e=>{r()||(t=D.some(e),s(o),o=[])})),{get:n,map:e=>fS((t=>{n((o=>{t(e(o))}))})),isReady:r}},vS={nu:fS,pure:e=>fS((t=>{t(e)}))},bS=e=>{setTimeout((()=>{throw e}),0)},yS=e=>{const t=t=>{e().then(t,bS)};return{map:t=>yS((()=>e().then(t))),bind:t=>yS((()=>e().then((e=>t(e).toPromise())))),anonBind:t=>yS((()=>e().then((()=>t.toPromise())))),toLazy:()=>vS.nu(t),toCached:()=>{let t=null;return yS((()=>(null===t&&(t=e()),t)))},toPromise:e,get:t}},wS=e=>yS((()=>new Promise(e))),xS=e=>yS((()=>Promise.resolve(e))),CS=w("sink"),SS=w(Du({name:CS(),overrides:w({dom:{tag:"div"},behaviours:ql([rm.config({useFixed:O})]),events:Ys([ra(is()),ra(es()),ra(ms())])})})),kS=(e,t)=>{const o=e.getHotspot(t).getOr(t),n="hotspot",r=e.getAnchorOverrides();return e.layouts.fold((()=>({type:n,hotspot:o,overrides:r})),(e=>({type:n,hotspot:o,overrides:r,layouts:e})))},_S=(e,t,o,n,r,s,a)=>{const i=((e,t,o,n,r,s,a)=>{const i=((e,t,o)=>(0,e.fetch)(o).map(t))(e,t,n),l=DS(n,e);return i.map((e=>e.bind((e=>D.from(Df.sketch({...s.menu(),uid:Ea(""),data:e,highlightOnOpen:a,onOpenMenu:(e,t)=>{const n=l().getOrDie();rm.position(n,t,{anchor:o}),Mm.decloak(r)},onOpenSubmenu:(e,t,o)=>{const n=l().getOrDie();rm.position(n,o,{anchor:{type:"submenu",item:t}}),Mm.decloak(r)},onRepositionMenu:(e,t,n)=>{const r=l().getOrDie();rm.position(r,t,{anchor:o}),z(n,(e=>{rm.position(r,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem}})}))},onEscape:()=>(Zp.focus(n),Mm.close(r),D.some(!0))}))))))})(e,t,kS(e,o),o,n,r,a);return i.map((e=>(e.fold((()=>{Mm.isOpen(n)&&Mm.close(n)}),(e=>{Mm.cloak(n),Mm.open(n,e),s(n)})),n)))},ES=(e,t,o,n,r,s,a)=>(Mm.close(n),xS(n)),TS=(e,t,o,n,r,s)=>{const a=pS.getCoupled(o,"sandbox");return(Mm.isOpen(a)?ES:_S)(e,t,o,a,n,r,s)},OS=(e,t,o)=>{const n=ag.getCurrent(t).getOr(t),r=Xt(e.element);o?Mt(n.element,"min-width",r+"px"):((e,t)=>{Yt.set(e,t)})(n.element,r)},DS=(e,t)=>e.getSystem().getByUid(t.uid+"-"+CS()).map((e=>()=>on.value(e))).getOrThunk((()=>t.lazySink.fold((()=>()=>on.error(new Error("No internal sink is specified, nor could an external sink be found"))),(t=>()=>t(e))))),AS=e=>{Mm.getState(e).each((e=>{Df.repositionMenus(e)}))},MS=(e,t,o)=>{const n=Ii(),r=DS(t,e);return{dom:{tag:"div",classes:e.sandboxClasses,attributes:{id:n.id,role:"listbox"}},behaviours:ou(e.sandboxBehaviours,[Xm.config({store:{mode:"memory",initialValue:t}}),Mm.config({onOpen:(r,s)=>{const a=kS(e,t);n.link(t.element),e.matchWidth&&OS(a.hotspot,s,e.useMinWidth),e.onOpen(a,r,s),void 0!==o&&void 0!==o.onOpen&&o.onOpen(r,s)},onClose:(e,r)=>{n.unlink(t.element),void 0!==o&&void 0!==o.onClose&&o.onClose(e,r)},isPartOf:(e,o,n)=>Fi(o,n)||Fi(t,n),getAttachPoint:()=>r().getOrDie()}),ag.config({find:e=>Mm.getState(e).bind((e=>ag.getCurrent(e)))}),Ql.config({channels:{...Hm({isExtraPart:T}),...Pm({doReposition:AS})}})])}},NS=e=>{const t=pS.getCoupled(e,"sandbox");AS(t)},RS=()=>[Tr("sandboxClasses",[]),tu("sandboxBehaviours",[ag,Ql,Mm,Xm])],BS=w([dr("dom"),dr("fetch"),el("onOpen"),tl("onExecute"),Tr("getHotspot",D.some),Tr("getAnchorOverrides",w({})),Xc(),Jm("dropdownBehaviours",[Yp,pS,Tp,Zp]),dr("toggleClass"),Tr("eventOrder",{}),yr("lazySink"),Tr("matchWidth",!1),Tr("useMinWidth",!1),yr("role")].concat(RS())),LS=w([Ou({schema:[Xi(),Tr("fakeFocus",!1)],name:"menu",defaults:e=>({onExecute:e.onExecute})}),SS()]),HS=og({name:"Dropdown",configFields:BS(),partFields:LS(),factory:(e,t,o,n)=>{const r=e=>{Mm.getState(e).each((e=>{Df.highlightPrimary(e)}))},s=(t,o,r)=>TS(e,x,t,n,o,r),a={expand:e=>{Yp.isOn(e)||s(e,v,Tf.HighlightNone).get(v)},open:e=>{Yp.isOn(e)||s(e,v,Tf.HighlightMenuAndItem).get(v)},refetch:t=>pS.getExistingCoupled(t,"sandbox").fold((()=>s(t,v,Tf.HighlightMenuAndItem).map(v)),(o=>_S(e,x,t,o,n,v,Tf.HighlightMenuAndItem).map(v))),isOpen:Yp.isOn,close:e=>{Yp.isOn(e)&&s(e,v,Tf.HighlightMenuAndItem).get(v)},repositionMenus:e=>{Yp.isOn(e)&&NS(e)}},i=(e,t)=>($s(e),D.some(!0));return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.dropdownBehaviours,[Yp.config({toggleClass:e.toggleClass,aria:{mode:"expanded"}}),pS.config({others:{sandbox:t=>MS(e,t,{onOpen:()=>Yp.on(t),onClose:()=>Yp.off(t)})}}),Tp.config({mode:"special",onSpace:i,onEnter:i,onDown:(e,t)=>{if(HS.isOpen(e)){const t=pS.getCoupled(e,"sandbox");r(t)}else HS.open(e);return D.some(!0)},onEscape:(e,t)=>HS.isOpen(e)?(HS.close(e),D.some(!0)):D.none()}),Zp.config({})]),events:Qp(D.some((e=>{s(e,r,Tf.HighlightMenuAndItem).get(v)}))),eventOrder:{...e.eventOrder,[Cs()]:["disabling","toggling","alloy.base.behaviour"]},apis:a,domModification:{attributes:{"aria-haspopup":"true",...e.role.fold((()=>({})),(e=>({role:e}))),..."button"===e.dom.tag?{type:(l="type",ve(e.dom,"attributes").bind((e=>ve(e,l)))).getOr("button")}:{}}}};var l},apis:{open:(e,t)=>e.open(t),refetch:(e,t)=>e.refetch(t),expand:(e,t)=>e.expand(t),close:(e,t)=>e.close(t),isOpen:(e,t)=>e.isOpen(t),repositionMenus:(e,t)=>e.repositionMenus(t)}}),IS=e=>{const t=Xm.getValue(e),o=Dy(e).map(My);HS.refetch(t).get((()=>{const e=pS.getCoupled(t,"sandbox");o.each((t=>Dy(e).each((e=>((e,t)=>{Xm.setValue(e,t.fetchPattern),e.element.dom.selectionStart=t.selectionStart,e.element.dom.selectionEnd=t.selectionEnd})(e,t)))))}))},PS=e=>Mm.getState(e).bind(Mg.getHighlighted).bind(Mg.getHighlighted),FS=(e,t,o)=>{Ay(e).each((e=>{((e,t)=>{Et(t.element,"id").each((t=>St(e.element,"aria-activedescendant",t)))})(e,o);var n;(si((n=t).element,Ry)?D.some(n.element):Bi(n.element,"."+Ry)).each((t=>{Et(t,"id").each((t=>St(e.element,"aria-controls",t)))}))})),St(o.element,"aria-selected","true")},zS=(e,t,o)=>{St(o.element,"aria-selected","false")},VS=e=>pS.getExistingCoupled(e,"sandbox").bind(Dy).map(My).map((e=>e.fetchPattern)).getOr("");var ZS;!function(e){e[e.ContentFocus=0]="ContentFocus",e[e.UiFocus=1]="UiFocus"}(ZS||(ZS={}));const US=(e,t,o,n,r)=>{const s=o.shared.providers,a=e=>r?{...e,shortcut:D.none(),icon:e.text.isSome()?D.none():e.icon}:e;switch(e.type){case"menuitem":return(i=e,tr("menuitem",qw,i)).fold(zy,(e=>D.some(iS(a(e),t,s,n))));case"nestedmenuitem":return(e=>tr("nestedmenuitem",Gw,e))(e).fold(zy,(e=>D.some(lS(a(e),t,s,n,r))));case"togglemenuitem":return(e=>tr("togglemenuitem",Kw,e))(e).fold(zy,(e=>D.some(cS(a(e),t,s,n))));case"separator":return(e=>tr("separatormenuitem",vw,e))(e).fold(zy,(e=>D.some(aS(e))));case"fancymenuitem":return(e=>tr("fancymenuitem",$w,e))(e).fold(zy,(e=>dS(e,o)));default:return console.error("Unknown item in general menu",e),D.none()}var i},jS=(e,t,o,n,r,s,a)=>{const i=1===n,l=!i||Fy(e);return xe(F(e,(e=>{switch(e.type){case"separator":return(n=e,tr("Autocompleter.Separator",vw,n)).fold(zy,(e=>D.some(aS(e))));case"cardmenuitem":return(e=>tr("cardmenuitem",Vw,e))(e).fold(zy,(e=>D.some(mS({...e,onAction:t=>{e.onAction(t),o(e.value,e.meta)}},r,s,{itemBehaviours:Hx(e.meta,s),cardText:{matchText:t,highlightOn:a}}))));default:return(e=>tr("Autocompleter.Item",bw,e))(e).fold(zy,(e=>D.some(sS(e,t,i,"normal",o,r,s,l))))}var n})))},WS=(e,t,o,n,r,s)=>{const a=Fy(t),i=xe(F(t,(e=>{const t=e=>US(e,o,n,(e=>r?!be(e,"text"):a)(e),r);return"nestedmenuitem"===e.type&&e.getSubmenuItems().length<=0?t({...e,enabled:!1}):t(e)}))),l=(e=>"no-search"===e.searchMode?{menuType:"normal"}:{menuType:"searchable",searchMode:e})(s);return(r?Vy:Zy)(e,a,i,1,l)},$S=e=>Df.singleData(e.value,e),qS=(e,t)=>{const o=ya("autocompleter"),n=Hr(!1),r=Hr(!1),s=Ei(Af.sketch({dom:{tag:"div",classes:["tox-autocompleter"],attributes:{id:o}},components:[],fireDismissalEventInstead:{},inlineBehaviours:ql([Ip("dismissAutocompleter",[Qs(Ls(),(()=>d())),Qs(Zs(),((t,o)=>{Et(o.event.target,"id").each((t=>St(Le.fromDom(e.getBody()),"aria-activedescendant",t)))}))])]),lazySink:t.getSink})),a=()=>Af.isOpen(s),i=r.get,l=()=>{if(a()){Af.hide(s),e.dom.remove(o,!1);const t=Le.fromDom(e.getBody());Et(t,"aria-owns").filter((e=>e===o)).each((()=>{Ot(t,"aria-owns"),Ot(t,"aria-activedescendant")}))}},c=()=>Af.getContent(s).bind((e=>te(e.components(),0))),d=()=>e.execCommand("mceAutocompleterClose"),m=o=>{const r=se(o,(e=>D.from(e.columns))).getOr(1);return G(o,(o=>{const s=o.items;return jS(s,o.matchText,((t,r)=>{const s=e.selection.getRng();((e,t)=>Qb(Le.fromDom(t.startContainer)).map((t=>{const o=e.createRng();return o.selectNode(t.dom),o})))(e.dom,s).each((s=>{const a={hide:()=>d(),reload:t=>{l(),e.execCommand("mceAutocompleterReload",!1,{fetchOptions:t})}};n.set(!0),o.onAction(a,s,t,r),n.set(!1)}))}),r,oy.BUBBLE_TO_SANDBOX,t,o.highlightOn)}))},u=(t,o)=>{var n;(n=Le.fromDom(e.getBody()),Bi(n,Jb)).each((n=>{const r=se(t,(e=>D.from(e.columns))).getOr(1);Af.showMenuAt(s,{anchor:{type:"node",root:Le.fromDom(e.getBody()),node:D.from(n)}},((e,t,o,n)=>{const r=XC(t,n),s=vy(n);return{data:$S({...e,movement:r,menuBehaviours:Jw("auto"!==t?[]:[ia(((e,t)=>{Yw(e,4,s.item).each((({numColumns:t,numRows:o})=>{Tp.setGridSize(e,o,t)}))}))])}),menu:{markers:vy(n),fakeFocus:o===ZS.ContentFocus}}})(Zy("autocompleter-value",!0,o,r,{menuType:"normal"}),r,ZS.ContentFocus,"normal"))})),c().each(Mg.highlightFirst)},g=t=>{const n=m(t);n.length>0?(u(t,n),St(Le.fromDom(e.getBody()),"aria-owns",o),e.inline||h()):l()},h=()=>{e.dom.get(o)&&e.dom.remove(o,!1);const t=e.getDoc().documentElement,n=e.selection.getNode(),r=(e=>ga(e,!0))(s.element);Nt(r,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",top:`${n.offsetTop}px`,left:`${n.offsetLeft}px`}),e.dom.add(t,r.dom),Bi(r,'[role="menu"]').each((e=>{Ft(e,"position"),Ft(e,"max-height")}))};e.on("AutocompleterStart",(({lookupData:e})=>{r.set(!0),n.set(!1),g(e)})),e.on("AutocompleterUpdate",(({lookupData:e})=>g(e))),e.on("AutocompleterEnd",(()=>{l(),r.set(!1),n.set(!1)}));const p={cancelIfNecessary:d,isMenuOpen:a,isActive:i,isProcessingAction:n.get,getMenu:c};ey(p,e)},GS=["visible","hidden","clip"],KS=e=>Ae(e).length>0&&!L(GS,e),YS=e=>{if(Ue(e)){const t=Bt(e,"overflow-x"),o=Bt(e,"overflow-y");return KS(t)||KS(o)}return!1},XS=(e,t)=>Kb(e)?(e=>{const t=kd(e,YS),o=0===t.length?ft(e).map(vt).map((e=>kd(e,YS))).getOr([]):t;return oe(o).map((e=>({element:e,others:o.slice(1)})))})(t):D.none(),JS=e=>{const t=[...F(e.others,Ko),Jo()];return((e,t)=>j(t,((e,t)=>Xo(e,t)),e))(Ko(e.element),t)},QS=(e,t,o)=>Li(e,t,o).isSome(),ek=(e,t)=>{let o=null;return{cancel:()=>{null!==o&&(clearTimeout(o),o=null)},schedule:(...n)=>{o=setTimeout((()=>{e.apply(null,n),o=null}),t)}}},tk=e=>{const t=e.raw;return void 0===t.touches||1!==t.touches.length?D.none():D.some(t.touches[0])},ok=e=>{const t=kc(),o=Hr(!1),n=ek((t=>{e.triggerEvent(_s(),t),o.set(!0)}),400),r=zr([{key:Yr(),value:e=>(tk(e).each((r=>{n.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};n.schedule(e),o.set(!1),t.set(s)})),D.none())},{key:Xr(),value:e=>(n.cancel(),tk(e).each((e=>{t.on((o=>{((e,t)=>{const o=Math.abs(e.clientX-t.x),n=Math.abs(e.clientY-t.y);return o>5||n>5})(e,o)&&t.clear()}))})),D.none())},{key:Jr(),value:r=>{n.cancel();return t.get().filter((e=>Xe(e.target,r.target))).map((t=>o.get()?(r.prevent(),!1):e.triggerEvent(ks(),r)))}}]);return{fireIfReady:(e,t)=>ve(r,t).bind((t=>t(e)))}},nk=(e,t)=>{const o={stopBackspace:!0,...t},n=ok(o),r=F(["touchstart","touchmove","touchend","touchcancel","gesturestart","mousedown","mouseup","mouseover","mousemove","mouseout","click"].concat(["selectstart","input","contextmenu","change","transitionend","transitioncancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","keyup"]),(t=>Ec(e,t,(e=>{n.fireIfReady(e,t).each((t=>{t&&e.kill()}));o.triggerEvent(t,e)&&e.kill()})))),s=kc(),a=Ec(e,"paste",(e=>{n.fireIfReady(e,"paste").each((t=>{t&&e.kill()}));o.triggerEvent("paste",e)&&e.kill(),s.set(setTimeout((()=>{o.triggerEvent(ws(),e)}),0))})),i=Ec(e,"keydown",(e=>{o.triggerEvent("keydown",e)?e.kill():o.stopBackspace&&(e=>e.raw.which===Ng[0]&&!L(["input","textarea"],Ve(e.target))&&!QS(e.target,'[contenteditable="true"]'))(e)&&e.prevent()})),l=Ec(e,"focusin",(e=>{o.triggerEvent("focusin",e)&&e.kill()})),c=kc(),d=Ec(e,"focusout",(e=>{o.triggerEvent("focusout",e)&&e.kill(),c.set(setTimeout((()=>{o.triggerEvent(ys(),e)}),0))}));return{unbind:()=>{z(r,(e=>{e.unbind()})),i.unbind(),l.unbind(),d.unbind(),a.unbind(),s.on(clearTimeout),c.on(clearTimeout)}}},rk=(e,t)=>{const o=ve(e,"target").getOr(t);return Hr(o)},sk=Ir([{stopped:[]},{resume:["element"]},{complete:[]}]),ak=(e,t,o,n,r,s)=>{const a=e(t,n),i=((e,t)=>{const o=Hr(!1),n=Hr(!1);return{stop:()=>{o.set(!0)},cut:()=>{n.set(!0)},isStopped:o.get,isCut:n.get,event:e,setSource:t.set,getSource:t.get}})(o,r);return a.fold((()=>(s.logEventNoHandlers(t,n),sk.complete())),(e=>{const o=e.descHandler;return za(o)(i),i.isStopped()?(s.logEventStopped(t,e.element,o.purpose),sk.stopped()):i.isCut()?(s.logEventCut(t,e.element,o.purpose),sk.complete()):nt(e.element).fold((()=>(s.logNoParent(t,e.element,o.purpose),sk.complete())),(n=>(s.logEventResponse(t,e.element,o.purpose),sk.resume(n))))}))},ik=(e,t,o,n,r,s)=>ak(e,t,o,n,r,s).fold(O,(n=>ik(e,t,o,n,r,s)),T),lk=(e,t,o)=>{const n=(e=>{const t=Hr(!1);return{stop:()=>{t.set(!0)},cut:v,isStopped:t.get,isCut:T,event:e,setSource:_("Cannot set source of a broadcasted event"),getSource:_("Cannot get source of a broadcasted event")}})(t);return z(e,(e=>{const t=e.descHandler;za(t)(n)})),n.isStopped()},ck=(e,t,o,n,r)=>{const s=rk(o,n);return ik(e,t,o,n,s,r)},dk=()=>{const e={};return{registerId:(t,o,n)=>{le(n,((n,r)=>{const s=void 0!==e[r]?e[r]:{};s[o]=((e,t)=>{return o=S.apply(void 0,[e.handler].concat(t)),n=e.purpose,{cHandler:o,purpose:n};var o,n})(n,t),e[r]=s}))},unregisterId:t=>{le(e,((e,o)=>{be(e,t)&&delete e[t]}))},filterByType:t=>ve(e,t).map((e=>he(e,((e,t)=>((e,t)=>({id:e,descHandler:t}))(t,e))))).getOr([]),find:(t,o,n)=>ve(e,o).bind((e=>jr(n,(t=>((e,t)=>_a(t).bind((t=>ve(e,t))).map((e=>((e,t)=>({element:e,descHandler:t}))(t,e))))(e,t)),t)))}},mk=()=>{const e=dk(),t={},o=e=>{const t=e.element;return _a(t).getOrThunk((()=>((e,t)=>{const o=ya(Ca+e);return ka(t,o),o})("uid-",e.element)))},n=o=>{_a(o.element).each((o=>{delete t[o],e.unregisterId(o)}))};return{find:(t,o,n)=>e.find(t,o,n),filter:t=>e.filterByType(t),register:r=>{const s=o(r);ye(t,s)&&((e,o)=>{const r=t[o];if(r!==e)throw new Error('The tagId "'+o+'" is already used by: '+pa(r.element)+"\nCannot use it for: "+pa(e.element)+"\nThe conflicting element is"+(yt(r.element)?" ":" not ")+"already in the DOM");n(e)})(r,s);const a=[r];e.registerId(a,s,r.events),t[s]=r},unregister:n,getById:e=>ve(t,e)}},uk=tg({name:"Container",factory:e=>{const{attributes:t,...o}=e.dom;return{uid:e.uid,dom:{tag:"div",attributes:{role:"presentation",...t},...o},components:e.components,behaviours:Qm(e.containerBehaviours),events:e.events,domModification:e.domModification,eventOrder:e.eventOrder}},configFields:[Tr("components",[]),Jm("containerBehaviours",[]),Tr("events",{}),Tr("domModification",{}),Tr("eventOrder",{})]}),gk=e=>{const t=t=>nt(e.element).fold(O,(e=>Xe(t,e))),o=mk(),n=(e,n)=>o.find(t,e,n),r=nk(e.element,{triggerEvent:(e,t)=>Wi(e,t.target,(o=>((e,t,o,n)=>ck(e,t,o,o.target,n))(n,e,t,o)))}),s={debugInfo:w("real"),triggerEvent:(e,t,o)=>{Wi(e,t,(r=>ck(n,e,o,t,r)))},triggerFocus:(e,t)=>{_a(e).fold((()=>{tc(e)}),(o=>{Wi(bs(),e,(o=>(((e,t,o,n,r)=>{const s=rk(o,n);ak(e,t,o,n,s,r)})(n,bs(),{originator:t,kill:v,prevent:v,target:e},e,o),!1)))}))},triggerEscape:(e,t)=>{s.triggerEvent("keydown",e.element,t.event)},getByUid:e=>h(e),getByDom:e=>p(e),build:Ei,buildOrPatch:_i,addToGui:e=>{l(e)},removeFromGui:e=>{c(e)},addToWorld:e=>{a(e)},removeFromWorld:e=>{i(e)},broadcast:e=>{m(e)},broadcastOn:(e,t)=>{u(e,t)},broadcastEvent:(e,t)=>{g(e,t)},isConnected:O},a=e=>{e.connect(s),We(e.element)||(o.register(e),z(e.components(),a),s.triggerEvent(Os(),e.element,{target:e.element}))},i=e=>{We(e.element)||(z(e.components(),i),o.unregister(e)),e.disconnect()},l=t=>{um(e,t)},c=e=>{pm(e)},d=e=>{const t=o.filter(xs());z(t,(t=>{const o=t.descHandler;za(o)(e)}))},m=e=>{d({universal:!0,data:e})},u=(e,t)=>{d({universal:!1,channels:e,data:t})},g=(e,t)=>{const n=o.filter(e);return lk(n,t)},h=e=>o.getById(e).fold((()=>on.error(new Error('Could not find component with uid: "'+e+'" in system.'))),on.value),p=e=>{const t=_a(e).getOr("not found");return h(t)};return a(e),{root:e,element:e.element,destroy:()=>{r.unbind(),Fo(e.element)},add:l,remove:c,getByUid:h,getByDom:p,addToWorld:a,removeFromWorld:i,broadcast:m,broadcastOn:u,broadcastEvent:g}},hk=w([Tr("prefix","form-field"),Jm("fieldBehaviours",[ag,Xm])]),pk=w([Du({schema:[dr("dom")],name:"label"}),Du({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[dr("text")],name:"aria-descriptor"}),Tu({factory:{sketch:e=>{const t=Pr(e,["factory"]);return e.factory.sketch(t)}},schema:[dr("factory")],name:"field"})]),fk=og({name:"FormField",configFields:hk(),partFields:pk(),factory:(e,t,o,n)=>{const r=eu(e.fieldBehaviours,[ag.config({find:t=>Vu(t,e,"field")}),Xm.config({store:{mode:"manual",getValue:e=>ag.getCurrent(e).bind(Xm.getValue),setValue:(e,t)=>{ag.getCurrent(e).each((e=>{Xm.setValue(e,t)}))}}})]),s=Ys([ia(((t,o)=>{const n=Uu(t,e,["label","field","aria-descriptor"]);n.field().each((t=>{const o=ya(e.prefix);n.label().each((e=>{St(e.element,"for",o),St(t.element,"id",o)})),n["aria-descriptor"]().each((o=>{const n=ya(e.prefix);St(o.element,"id",n),St(t.element,"aria-describedby",n)}))}))}))]),a={getField:t=>Vu(t,e,"field"),getLabel:t=>Vu(t,e,"label")};return{uid:e.uid,dom:e.dom,components:t,behaviours:r,events:s,apis:a}},apis:{getField:(e,t)=>e.getField(t),getLabel:(e,t)=>e.getLabel(t)}});var vk=Object.freeze({__proto__:null,exhibit:(e,t)=>Fa({attributes:zr([{key:t.tabAttr,value:"true"}])})}),bk=[Tr("tabAttr","data-alloy-tabstop")];const yk=Kl({fields:bk,name:"tabstopping",active:vk});var wk=tinymce.util.Tools.resolve("tinymce.html.Entities");const xk=(e,t,o,n)=>{const r=Ck(e,t,o,n);return fk.sketch(r)},Ck=(e,t,o,n)=>({dom:Sk(o),components:e.toArray().concat([t]),fieldBehaviours:ql(n)}),Sk=e=>({tag:"div",classes:["tox-form__group"].concat(e)}),kk=(e,t)=>fk.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[Ci(t.translate(e))]}),_k=ya("form-component-change"),Ek=ya("form-close"),Tk=ya("form-cancel"),Ok=ya("form-action"),Dk=ya("form-submit"),Ak=ya("form-block"),Mk=ya("form-unblock"),Nk=ya("form-tabchange"),Rk=ya("form-resize"),Bk=(e,t,o)=>{const n=e.label.map((e=>kk(e,t))),r=t.icons(),s=e=>(t,o)=>{Li(o.event.target,"[data-collection-item-value]").each((n=>{e(t,o,n,_t(n,"data-collection-item-value"))}))},a=(o,n)=>{const s=F(n,(o=>{const n=Mv.translate(o.text),s=1===e.columns?`
    ${n}
    `:"",a=`
    ${(e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})(o.icon)}
    `,i={_:" "," - ":" ","-":" "},l=n.replace(/\_| \- |\-/g,(e=>i[e]));return`
    ${a}${s}
    `})),a="auto"!==e.columns&&e.columns>1?P(s,e.columns):[s],i=F(a,(e=>`
    ${e.join("")}
    `));ua(o.element,i.join(""))},i=s(((o,n,r,s)=>{n.stop(),t.isDisabled()||Ws(o,Ok,{name:e.name,value:s})})),l=[Qs(rs(),s(((e,t,o)=>{tc(o)}))),Qs(ms(),i),Qs(ks(),i),Qs(ss(),s(((e,t,o)=>{Bi(e.element,"."+my).each((e=>{ni(e,my)})),ti(o,my)}))),Qs(as(),s((e=>{Bi(e.element,"."+my).each((e=>{ni(e,my)}))}))),da(s(((t,o,n,r)=>{Ws(t,Ok,{name:e.name,value:r})})))],c=(e,t)=>F(_d(e.element,".tox-collection__item"),t),d=fk.parts.field({dom:{tag:"div",classes:["tox-collection"].concat(1!==e.columns?["tox-collection--grid"]:["tox-collection--list"])},components:[],factory:{sketch:x},behaviours:ql([wg.config({disabled:t.isDisabled,onDisabled:e=>{c(e,(e=>{ti(e,"tox-collection__item--state-disabled"),St(e,"aria-disabled",!0)}))},onEnabled:e=>{c(e,(e=>{ni(e,"tox-collection__item--state-disabled"),Ot(e,"aria-disabled")}))}}),gx(),Hp.config({}),Xm.config({store:{mode:"memory",initialValue:o.getOr([])},onSetValue:(t,o)=>{a(t,o),"auto"===e.columns&&Yw(t,5,"tox-collection__item").each((({numRows:e,numColumns:o})=>{Tp.setGridSize(t,e,o)})),js(t,Rk)}}),yk.config({}),Tp.config((m=e.columns,u="normal",1===m?{mode:"menu",moveOnTab:!1,selector:".tox-collection__item"}:"auto"===m?{mode:"flatgrid",selector:".tox-collection__item",initSize:{numColumns:1,numRows:1}}:{mode:"matrix",selectors:{row:"color"===u?".tox-swatches__row":".tox-collection__group",cell:"color"===u?`.${sy}`:`.${ry}`}})),Ip("collection-events",l)]),eventOrder:{[Cs()]:["disabling","alloy.base.behaviour","collection-events"]}});var m,u;return xk(n,d,["tox-form__group--collection"],[])},Lk=["input","textarea"],Hk=e=>{const t=Ve(e);return L(Lk,t)},Ik=(e,t)=>{const o=t.getRoot(e).getOr(e.element);ni(o,t.invalidClass),t.notify.each((t=>{Hk(e.element)&&St(e.element,"aria-invalid",!1),t.getContainer(e).each((e=>{ua(e,t.validHtml)})),t.onValid(e)}))},Pk=(e,t,o,n)=>{const r=t.getRoot(e).getOr(e.element);ti(r,t.invalidClass),t.notify.each((t=>{Hk(e.element)&&St(e.element,"aria-invalid",!0),t.getContainer(e).each((e=>{ua(e,n)})),t.onInvalid(e,n)}))},Fk=(e,t,o)=>t.validator.fold((()=>xS(on.value(!0))),(t=>t.validate(e))),zk=(e,t,o)=>(t.notify.each((t=>{t.onValidate(e)})),Fk(e,t).map((o=>e.getSystem().isConnected()?o.fold((o=>(Pk(e,t,0,o),on.error(o))),(o=>(Ik(e,t),on.value(o)))):on.error("No longer in system"))));var Vk=Object.freeze({__proto__:null,markValid:Ik,markInvalid:Pk,query:Fk,run:zk,isInvalid:(e,t)=>{const o=t.getRoot(e).getOr(e.element);return si(o,t.invalidClass)}});var Zk=Object.freeze({__proto__:null,events:(e,t)=>e.validator.map((t=>Ys([Qs(t.onEvent,(t=>{zk(t,e).get(x)}))].concat(t.validateOnLoad?[ia((t=>{zk(t,e).get(v)}))]:[])))).getOr({})}),Uk=[dr("invalidClass"),Tr("getRoot",D.none),Er("notify",[Tr("aria","alert"),Tr("getContainer",D.none),Tr("validHtml",""),el("onValid"),el("onInvalid"),el("onValidate")]),Er("validator",[dr("validate"),Tr("onEvent","input"),Tr("validateOnLoad",!0)])];const jk=Kl({fields:Uk,name:"invalidating",active:Zk,apis:Vk,extra:{validation:e=>t=>{const o=Xm.getValue(t);return xS(e(o))}}});const Wk=Kl({fields:[],name:"unselecting",active:Object.freeze({__proto__:null,events:()=>Ys([Xs(ps(),O)]),exhibit:()=>Fa({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})})}),$k=ya("color-input-change"),qk=ya("color-swatch-change"),Gk=ya("color-picker-cancel"),Kk=(e,t,o,n)=>{const r=fk.parts.field({factory:_y,inputClasses:["tox-textfield"],data:n,onSetValue:e=>jk.run(e).get(v),inputBehaviours:ql([wg.config({disabled:t.providers.isDisabled}),gx(),yk.config({}),jk.config({invalidClass:"tox-textbox-field-invalid",getRoot:e=>rt(e.element),notify:{onValid:e=>{const t=Xm.getValue(e);Ws(e,$k,{color:t})}},validator:{validateOnLoad:!1,validate:e=>{const t=Xm.getValue(e);if(0===t.length)return xS(on.value(!0));{const e=Le.fromTag("span");Mt(e,"background-color",t);const o=Ht(e,"background-color").fold((()=>on.error("blah")),(e=>on.value(t)));return xS(o)}}}})]),selectOnFocus:!1}),s=e.label.map((e=>kk(e,t.providers))),a=(e,t)=>{Ws(e,qk,{value:t})},i=Bf(((e,t)=>HS.sketch({dom:e.dom,components:e.components,toggleClass:"mce-active",dropdownBehaviours:ql([px(t.providers.isDisabled),gx(),Wk.config({}),yk.config({})]),layouts:e.layouts,sandboxClasses:["tox-dialog__popups"],lazySink:t.getSink,fetch:o=>wS((t=>e.fetch(t))).map((n=>D.from($S(xn(KC(ya("menu-value"),n,(t=>{e.onItemAction(o,t)}),e.columns,e.presets,oy.CLOSE_ON_EXECUTE,T,t.providers),{movement:XC(e.columns,e.presets)}))))),parts:{menu:wy(0,0,e.presets)}}))({dom:{tag:"span",attributes:{"aria-label":t.providers.translate("Color swatch")}},layouts:{onRtl:()=>[Ol,Tl,Nl],onLtr:()=>[Tl,Ol,Nl]},components:[],fetch:VC(o.getColors(e.storageKey),e.storageKey,o.hasCustomColors()),columns:o.getColorCols(e.storageKey),presets:"color",onItemAction:(t,n)=>{i.getOpt(t).each((t=>{"custom"===n?o.colorPicker((o=>{o.fold((()=>js(t,Gk)),(o=>{a(t,o),yC(e.storageKey,o)}))}),"#ffffff"):a(t,"remove"===n?"":n)}))}},t));return fk.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:s.toArray().concat([{dom:{tag:"div",classes:["tox-color-input"]},components:[r,i.asSpec()]}]),fieldBehaviours:ql([Ip("form-field-events",[Qs($k,((t,o)=>{i.getOpt(t).each((e=>{Mt(e.element,"background-color",o.event.color)})),Ws(t,_k,{name:e.name})})),Qs(qk,((e,t)=>{fk.getField(e).each((o=>{Xm.setValue(o,t.event.value),ag.getCurrent(e).each(Zp.focus)}))})),Qs(Gk,((e,t)=>{fk.getField(e).each((t=>{ag.getCurrent(e).each(Zp.focus)}))}))])])})},Yk=Du({schema:[dr("dom")],name:"label"}),Xk=e=>Du({name:e+"-edge",overrides:t=>t.model.manager.edgeActions[e].fold((()=>({})),(e=>({events:Ys([ea(Yr(),((t,o,n)=>e(t,n)),[t]),ea(es(),((t,o,n)=>e(t,n)),[t]),ea(ts(),((t,o,n)=>{n.mouseIsDown.get()&&e(t,n)}),[t])])})))}),Jk=Xk("top-left"),Qk=Xk("top"),e_=Xk("top-right"),t_=Xk("right"),o_=Xk("bottom-right"),n_=Xk("bottom"),r_=Xk("bottom-left"),s_=Xk("left"),a_=Tu({name:"thumb",defaults:w({dom:{styles:{position:"absolute"}}}),overrides:e=>({events:Ys([oa(Yr(),e,"spectrum"),oa(Xr(),e,"spectrum"),oa(Jr(),e,"spectrum"),oa(es(),e,"spectrum"),oa(ts(),e,"spectrum"),oa(ns(),e,"spectrum")])})}),i_=e=>qg(e.event),l_=Tu({schema:[lr("mouseIsDown",(()=>Hr(!1)))],name:"spectrum",overrides:e=>{const t=e.model.manager,o=(o,n)=>t.getValueFromEvent(n).map((n=>t.setValueFrom(o,e,n)));return{behaviours:ql([Tp.config({mode:"special",onLeft:(o,n)=>t.onLeft(o,e,i_(n)),onRight:(o,n)=>t.onRight(o,e,i_(n)),onUp:(o,n)=>t.onUp(o,e,i_(n)),onDown:(o,n)=>t.onDown(o,e,i_(n))}),yk.config({}),Zp.config({})]),events:Ys([Qs(Yr(),o),Qs(Xr(),o),Qs(es(),o),Qs(ts(),((t,n)=>{e.mouseIsDown.get()&&o(t,n)}))])}}});var c_=[Yk,s_,t_,Qk,n_,Jk,e_,r_,o_,a_,l_];const d_=w("slider.change.value"),m_=e=>{const t=e.event.raw;if((e=>-1!==e.type.indexOf("touch"))(t)){const e=t;return void 0!==e.touches&&1===e.touches.length?D.some(e.touches[0]).map((e=>$t(e.clientX,e.clientY))):D.none()}{const e=t;return void 0!==e.clientX?D.some(e).map((e=>$t(e.clientX,e.clientY))):D.none()}},u_=e=>e.model.minX,g_=e=>e.model.minY,h_=e=>e.model.minX-1,p_=e=>e.model.minY-1,f_=e=>e.model.maxX,v_=e=>e.model.maxY,b_=e=>e.model.maxX+1,y_=e=>e.model.maxY+1,w_=(e,t,o)=>t(e)-o(e),x_=e=>w_(e,f_,u_),C_=e=>w_(e,v_,g_),S_=e=>x_(e)/2,k_=e=>C_(e)/2,__=(e,t)=>t?e.stepSize*e.speedMultiplier:e.stepSize,E_=e=>e.snapToGrid,T_=e=>e.snapStart,O_=e=>e.rounded,D_=(e,t)=>void 0!==e[t+"-edge"],A_=e=>D_(e,"left"),M_=e=>D_(e,"right"),N_=e=>D_(e,"top"),R_=e=>D_(e,"bottom"),B_=e=>e.model.value.get(),L_=(e,t)=>({x:e,y:t}),H_=(e,t)=>{Ws(e,d_(),{value:t})},I_=(e,t,o,n)=>eo?o:e===t?t-1:Math.max(t,e-n),P_=(e,t,o,n)=>e>o?e:eMath.max(t,Math.min(o,e)),z_=e=>{const{min:t,max:o,range:n,value:r,step:s,snap:a,snapStart:i,rounded:l,hasMinEdge:c,hasMaxEdge:d,minBound:m,maxBound:u,screenRange:g}=e,h=c?t-1:t,p=d?o+1:o;if(ru)return p;{const e=((e,t,o)=>Math.min(o,Math.max(e,t))-t)(r,m,u),c=F_(e/g*n+t,h,p);return a&&c>=t&&c<=o?((e,t,o,n,r)=>r.fold((()=>{const r=e-t,s=Math.round(r/n)*n;return F_(t+s,t-1,o+1)}),(t=>{const r=(e-t)%n,s=Math.round(r/n),a=Math.floor((e-t)/n),i=Math.floor((o-t)/n),l=t+Math.min(i,a+s)*n;return Math.max(t,l)})))(c,t,o,s,i):l?Math.round(c):c}},V_=e=>{const{min:t,max:o,range:n,value:r,hasMinEdge:s,hasMaxEdge:a,maxBound:i,maxOffset:l,centerMinEdge:c,centerMaxEdge:d}=e;return ro?a?i:d:(r-t)/n*l},Z_="top",U_="right",j_="bottom",W_="left",$_=e=>e.element.dom.getBoundingClientRect(),q_=(e,t)=>e[t],G_=e=>{const t=$_(e);return q_(t,W_)},K_=e=>{const t=$_(e);return q_(t,U_)},Y_=e=>{const t=$_(e);return q_(t,Z_)},X_=e=>{const t=$_(e);return q_(t,j_)},J_=e=>{const t=$_(e);return q_(t,"width")},Q_=e=>{const t=$_(e);return q_(t,"height")},eE=(e,t,o)=>(e+t)/2-o,tE=(e,t)=>{const o=$_(e),n=$_(t),r=q_(o,W_),s=q_(o,U_),a=q_(n,W_);return eE(r,s,a)},oE=(e,t)=>{const o=$_(e),n=$_(t),r=q_(o,Z_),s=q_(o,j_),a=q_(n,Z_);return eE(r,s,a)},nE=(e,t)=>{Ws(e,d_(),{value:t})},rE=(e,t,o)=>{const n={min:u_(t),max:f_(t),range:x_(t),value:o,step:__(t),snap:E_(t),snapStart:T_(t),rounded:O_(t),hasMinEdge:A_(t),hasMaxEdge:M_(t),minBound:G_(e),maxBound:K_(e),screenRange:J_(e)};return z_(n)},sE=e=>(t,o,n)=>((e,t,o,n)=>{const r=(e>0?P_:I_)(B_(o),u_(o),f_(o),__(o,n));return nE(t,r),D.some(r)})(e,t,o,n).map(O),aE=(e,t,o,n,r,s)=>{const a=((e,t,o,n,r)=>{const s=J_(e),a=n.bind((t=>D.some(tE(t,e)))).getOr(0),i=r.bind((t=>D.some(tE(t,e)))).getOr(s),l={min:u_(t),max:f_(t),range:x_(t),value:o,hasMinEdge:A_(t),hasMaxEdge:M_(t),minBound:G_(e),minOffset:0,maxBound:K_(e),maxOffset:s,centerMinEdge:a,centerMaxEdge:i};return V_(l)})(t,s,o,n,r);return G_(t)-G_(e)+a},iE=sE(-1),lE=sE(1),cE=D.none,dE=D.none,mE={"top-left":D.none(),top:D.none(),"top-right":D.none(),right:D.some(((e,t)=>{H_(e,b_(t))})),"bottom-right":D.none(),bottom:D.none(),"bottom-left":D.none(),left:D.some(((e,t)=>{H_(e,h_(t))}))};var uE=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=rE(e,t,o);return nE(e,n),n},setToMin:(e,t)=>{const o=u_(t);nE(e,o)},setToMax:(e,t)=>{const o=f_(t);nE(e,o)},findValueOfOffset:rE,getValueFromEvent:e=>m_(e).map((e=>e.left)),findPositionOfValue:aE,setPositionFromValue:(e,t,o,n)=>{const r=B_(o),s=aE(e,n.getSpectrum(e),r,n.getLeftEdge(e),n.getRightEdge(e),o),a=Xt(t.element)/2;Mt(t.element,"left",s-a+"px")},onLeft:iE,onRight:lE,onUp:cE,onDown:dE,edgeActions:mE});const gE=(e,t)=>{Ws(e,d_(),{value:t})},hE=(e,t,o)=>{const n={min:g_(t),max:v_(t),range:C_(t),value:o,step:__(t),snap:E_(t),snapStart:T_(t),rounded:O_(t),hasMinEdge:N_(t),hasMaxEdge:R_(t),minBound:Y_(e),maxBound:X_(e),screenRange:Q_(e)};return z_(n)},pE=e=>(t,o,n)=>((e,t,o,n)=>{const r=(e>0?P_:I_)(B_(o),g_(o),v_(o),__(o,n));return gE(t,r),D.some(r)})(e,t,o,n).map(O),fE=(e,t,o,n,r,s)=>{const a=((e,t,o,n,r)=>{const s=Q_(e),a=n.bind((t=>D.some(oE(t,e)))).getOr(0),i=r.bind((t=>D.some(oE(t,e)))).getOr(s),l={min:g_(t),max:v_(t),range:C_(t),value:o,hasMinEdge:N_(t),hasMaxEdge:R_(t),minBound:Y_(e),minOffset:0,maxBound:X_(e),maxOffset:s,centerMinEdge:a,centerMaxEdge:i};return V_(l)})(t,s,o,n,r);return Y_(t)-Y_(e)+a},vE=D.none,bE=D.none,yE=pE(-1),wE=pE(1),xE={"top-left":D.none(),top:D.some(((e,t)=>{H_(e,p_(t))})),"top-right":D.none(),right:D.none(),"bottom-right":D.none(),bottom:D.some(((e,t)=>{H_(e,y_(t))})),"bottom-left":D.none(),left:D.none()};var CE=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=hE(e,t,o);return gE(e,n),n},setToMin:(e,t)=>{const o=g_(t);gE(e,o)},setToMax:(e,t)=>{const o=v_(t);gE(e,o)},findValueOfOffset:hE,getValueFromEvent:e=>m_(e).map((e=>e.top)),findPositionOfValue:fE,setPositionFromValue:(e,t,o,n)=>{const r=B_(o),s=fE(e,n.getSpectrum(e),r,n.getTopEdge(e),n.getBottomEdge(e),o),a=Ut(t.element)/2;Mt(t.element,"top",s-a+"px")},onLeft:vE,onRight:bE,onUp:yE,onDown:wE,edgeActions:xE});const SE=(e,t)=>{Ws(e,d_(),{value:t})},kE=(e,t)=>({x:e,y:t}),_E=(e,t)=>(o,n,r)=>((e,t,o,n,r)=>{const s=e>0?P_:I_,a=t?B_(n).x:s(B_(n).x,u_(n),f_(n),__(n,r)),i=t?s(B_(n).y,g_(n),v_(n),__(n,r)):B_(n).y;return SE(o,kE(a,i)),D.some(a)})(e,t,o,n,r).map(O),EE=_E(-1,!1),TE=_E(1,!1),OE=_E(-1,!0),DE=_E(1,!0),AE={"top-left":D.some(((e,t)=>{H_(e,L_(h_(t),p_(t)))})),top:D.some(((e,t)=>{H_(e,L_(S_(t),p_(t)))})),"top-right":D.some(((e,t)=>{H_(e,L_(b_(t),p_(t)))})),right:D.some(((e,t)=>{H_(e,L_(b_(t),k_(t)))})),"bottom-right":D.some(((e,t)=>{H_(e,L_(b_(t),y_(t)))})),bottom:D.some(((e,t)=>{H_(e,L_(S_(t),y_(t)))})),"bottom-left":D.some(((e,t)=>{H_(e,L_(h_(t),y_(t)))})),left:D.some(((e,t)=>{H_(e,L_(h_(t),k_(t)))}))};var ME=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=rE(e,t,o.left),r=hE(e,t,o.top),s=kE(n,r);return SE(e,s),s},setToMin:(e,t)=>{const o=u_(t),n=g_(t);SE(e,kE(o,n))},setToMax:(e,t)=>{const o=f_(t),n=v_(t);SE(e,kE(o,n))},getValueFromEvent:e=>m_(e),setPositionFromValue:(e,t,o,n)=>{const r=B_(o),s=aE(e,n.getSpectrum(e),r.x,n.getLeftEdge(e),n.getRightEdge(e),o),a=fE(e,n.getSpectrum(e),r.y,n.getTopEdge(e),n.getBottomEdge(e),o),i=Xt(t.element)/2,l=Ut(t.element)/2;Mt(t.element,"left",s-i+"px"),Mt(t.element,"top",a-l+"px")},onLeft:EE,onRight:TE,onUp:OE,onDown:DE,edgeActions:AE});const NE=og({name:"Slider",configFields:[Tr("stepSize",1),Tr("speedMultiplier",10),Tr("onChange",v),Tr("onChoose",v),Tr("onInit",v),Tr("onDragStart",v),Tr("onDragEnd",v),Tr("snapToGrid",!1),Tr("rounded",!0),yr("snapStart"),mr("model",sr("mode",{x:[Tr("minX",0),Tr("maxX",100),lr("value",(e=>Hr(e.mode.minX))),dr("getInitialValue"),rl("manager",uE)],y:[Tr("minY",0),Tr("maxY",100),lr("value",(e=>Hr(e.mode.minY))),dr("getInitialValue"),rl("manager",CE)],xy:[Tr("minX",0),Tr("maxX",100),Tr("minY",0),Tr("maxY",100),lr("value",(e=>Hr({x:e.mode.minX,y:e.mode.minY}))),dr("getInitialValue"),rl("manager",ME)]})),Jm("sliderBehaviours",[Tp,Xm]),lr("mouseIsDown",(()=>Hr(!1)))],partFields:c_,factory:(e,t,o,n)=>{const r=t=>Zu(t,e,"thumb"),s=t=>Zu(t,e,"spectrum"),a=t=>Vu(t,e,"left-edge"),i=t=>Vu(t,e,"right-edge"),l=t=>Vu(t,e,"top-edge"),c=t=>Vu(t,e,"bottom-edge"),d=e.model,m=d.manager,u=(t,o)=>{m.setPositionFromValue(t,o,e,{getLeftEdge:a,getRightEdge:i,getTopEdge:l,getBottomEdge:c,getSpectrum:s})},g=(e,t)=>{d.value.set(t);const o=r(e);u(e,o)},h=t=>{const o=e.mouseIsDown.get();e.mouseIsDown.set(!1),o&&Vu(t,e,"thumb").each((o=>{const n=d.value.get();e.onChoose(t,o,n)}))},p=(t,o)=>{o.stop(),e.mouseIsDown.set(!0),e.onDragStart(t,r(t))},f=(t,o)=>{o.stop(),e.onDragEnd(t,r(t)),h(t)},v=t=>{Vu(t,e,"spectrum").map(Tp.focusIn)};return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.sliderBehaviours,[Tp.config({mode:"special",focusIn:v}),Xm.config({store:{mode:"manual",getValue:e=>d.value.get(),setValue:g}}),Ql.config({channels:{[Bm()]:{onReceive:h}}})]),events:Ys([Qs(d_(),((t,o)=>{((t,o)=>{g(t,o);const n=r(t);e.onChange(t,n,o),D.some(!0)})(t,o.event.value)})),ia(((t,o)=>{const n=d.getInitialValue();d.value.set(n);const a=r(t);u(t,a);const i=s(t);e.onInit(t,a,i,d.value.get())})),Qs(Yr(),p),Qs(Jr(),f),Qs(es(),((e,t)=>{v(e),p(e,t)})),Qs(ns(),f)]),apis:{resetToMin:t=>{m.setToMin(t,e)},resetToMax:t=>{m.setToMax(t,e)},setValue:g,refresh:u},domModification:{styles:{position:"relative"}}}},apis:{setValue:(e,t,o)=>{e.setValue(t,o)},resetToMin:(e,t)=>{e.resetToMin(t)},resetToMax:(e,t)=>{e.resetToMax(t)},refresh:(e,t)=>{e.refresh(t)}}}),RE=ya("rgb-hex-update"),BE=ya("slider-update"),LE=ya("palette-update"),HE="form",IE=[Jm("formBehaviours",[Xm])],PE=e=>"",FE=(e,t)=>({uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.formBehaviours,[Xm.config({store:{mode:"manual",getValue:t=>{const o=ju(t,e);return ce(o,((e,t)=>e().bind((e=>{const o=ag.getCurrent(e);return n=o,r=new Error(`Cannot find a current component to extract the value from for form part '${t}': `+pa(e.element)),n.fold((()=>on.error(r)),on.value);var n,r})).map(Xm.getValue)))},setValue:(t,o)=>{le(o,((o,n)=>{Vu(t,e,n).each((e=>{ag.getCurrent(e).each((e=>{Xm.setValue(e,o)}))}))}))}}})]),apis:{getField:(t,o)=>Vu(t,e,o).bind(ag.getCurrent)}}),zE={getField:La(((e,t,o)=>e.getField(t,o))),sketch:e=>{const t=(()=>{const e=[];return{field:(t,o)=>(e.push(t),Hu(HE,PE(t),o)),record:w(e)}})(),o=e(t),n=t.record(),r=F(n,(e=>Tu({name:e,pname:PE(e)})));return Xu(HE,IE,r,FE,o)}},VE=ya("valid-input"),ZE=ya("invalid-input"),UE=ya("validating-input"),jE="colorcustom.rgb.",WE=(e,t,o,n)=>{const r=(o,n)=>jk.config({invalidClass:t("invalid"),notify:{onValidate:e=>{Ws(e,UE,{type:o})},onValid:e=>{Ws(e,VE,{type:o,value:Xm.getValue(e)})},onInvalid:e=>{Ws(e,ZE,{type:o,value:Xm.getValue(e)})}},validator:{validate:t=>{const o=Xm.getValue(t),r=n(o)?on.value(!0):on.error(e("aria.input.invalid"));return xS(r)},validateOnLoad:!1}}),s=(o,n,s,a,i)=>{const l=e(jE+"range"),c=fk.parts.label({dom:{tag:"label",attributes:{"aria-label":a}},components:[Ci(s)]}),d=fk.parts.field({data:i,factory:_y,inputAttributes:{type:"text",..."hex"===n?{"aria-live":"polite"}:{}},inputClasses:[t("textfield")],inputBehaviours:ql([r(n,o),yk.config({})]),onSetValue:e=>{if(jk.isInvalid(e)){jk.run(e).get(v)}}}),m=[c,d],u="hex"!==n?[fk.parts["aria-descriptor"]({text:l})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:m.concat(u)}},a=(e,t)=>{const o=t.red,n=t.green,r=t.blue;Xm.setValue(e,{red:o,green:n,blue:r})},i=Bf({dom:{tag:"div",classes:[t("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),l=(e,t)=>{i.getOpt(e).each((e=>{Mt(e.element,"background-color","#"+t.value)}))},c=tg({factory:()=>{const r={red:Hr(D.some(255)),green:Hr(D.some(255)),blue:Hr(D.some(255)),hex:Hr(D.some("ffffff"))},c=e=>r[e].get(),d=(e,t)=>{r[e].set(t)},m=e=>{const t=e.red,o=e.green,n=e.blue;d("red",D.some(t)),d("green",D.some(o)),d("blue",D.some(n))},u=(e,t)=>{const o=t.event;"hex"!==o.type?d(o.type,D.none()):n(e)},g=(e,t,o)=>{const n=parseInt(o,10);d(t,D.some(n)),c("red").bind((e=>c("green").bind((t=>c("blue").map((o=>Qx(e,t,o,1))))))).each((t=>{const o=((e,t)=>{const o=qx(t);return zE.getField(e,"hex").each((t=>{Zp.isFocused(t)||Xm.setValue(e,{hex:o.value})})),o})(e,t);Ws(e,RE,{hex:o}),l(e,o)}))},h=(e,t)=>{const n=t.event;(e=>"hex"===e.type)(n)?((e,t)=>{o(e);const n=zx(t);d("hex",D.some(n.value));const r=oC(n);a(e,r),m(r),Ws(e,RE,{hex:n}),l(e,n)})(e,n.value):g(e,n.type,n.value)},p=t=>({label:e(jE+t+".label"),description:e(jE+t+".description")}),f=p("red"),v=p("green"),b=p("blue"),y=p("hex");return xn(zE.sketch((o=>({dom:{tag:"form",classes:[t("rgb-form")],attributes:{"aria-label":e("aria.color.picker")}},components:[o.field("red",fk.sketch(s(eC,"red",f.label,f.description,255))),o.field("green",fk.sketch(s(eC,"green",v.label,v.description,255))),o.field("blue",fk.sketch(s(eC,"blue",b.label,b.description,255))),o.field("hex",fk.sketch(s(Ux,"hex",y.label,y.description,"ffffff"))),i.asSpec()],formBehaviours:ql([jk.config({invalidClass:t("form-invalid")}),Ip("rgb-form-events",[Qs(VE,h),Qs(ZE,u),Qs(UE,u)])])}))),{apis:{updateHex:(e,t)=>{Xm.setValue(e,{hex:t.value}),((e,t)=>{const o=oC(t);a(e,o),m(o)})(e,t),l(e,t)}}})},name:"RgbForm",configFields:[],apis:{updateHex:(e,t,o)=>{e.updateHex(t,o)}},extraApis:{}});return c},$E=(e,t)=>{const o=NE.parts.spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[t("sv-palette-spectrum")]}}),n=NE.parts.thumb({dom:{tag:"div",attributes:{role:"presentation"},classes:[t("sv-palette-thumb")],innerHtml:``}}),r=(e,t)=>{const{width:o,height:n}=e,r=e.getContext("2d");if(null===r)return;r.fillStyle=t,r.fillRect(0,0,o,n);const s=r.createLinearGradient(0,0,o,0);s.addColorStop(0,"rgba(255,255,255,1)"),s.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=s,r.fillRect(0,0,o,n);const a=r.createLinearGradient(0,0,0,n);a.addColorStop(0,"rgba(0,0,0,0)"),a.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=a,r.fillRect(0,0,o,n)},s=tg({factory:s=>{const a=w({x:0,y:0}),i=ql([ag.config({find:D.some}),Zp.config({})]);return NE.sketch({dom:{tag:"div",attributes:{role:"slider","aria-valuetext":e(["Saturation {0}%, Brightness {1}%",0,0])},classes:[t("sv-palette")]},model:{mode:"xy",getInitialValue:a},rounded:!1,components:[o,n],onChange:(t,o,n)=>{p(n)||St(t.element,"aria-valuetext",e(["Saturation {0}%, Brightness {1}%",Math.floor(n.x),Math.floor(100-n.y)])),Ws(t,LE,{value:n})},onInit:(e,t,o,n)=>{r(o.element.dom,sC(aC))},sliderBehaviours:i})},name:"SaturationBrightnessPalette",configFields:[],apis:{setHue:(e,t,o)=>{((e,t)=>{const o=e.components()[0].element.dom,n=wC(t,100,100),s=tC(n);r(o,sC(s))})(t,o)},setThumb:(t,o,n)=>{((t,o)=>{const n=xC(oC(o));NE.setValue(t,{x:n.saturation,y:100-n.value}),St(t.element,"aria-valuetext",e(["Saturation {0}%, Brightness {1}%",n.saturation,n.value]))})(o,n)}},extraApis:{}});return s},qE=(e,t)=>{const o=tg({name:"ColourPicker",configFields:[dr("dom"),Tr("onValidHex",v),Tr("onInvalidHex",v)],factory:o=>{const n=WE(e,t,o.onValidHex,o.onInvalidHex),r=$E(e,t),s={paletteRgba:Hr(aC),paletteHue:Hr(0)},a=Bf(((e,t)=>{const o=NE.parts.spectrum({dom:{tag:"div",classes:[t("hue-slider-spectrum")],attributes:{role:"presentation"}}}),n=NE.parts.thumb({dom:{tag:"div",classes:[t("hue-slider-thumb")],attributes:{role:"presentation"}}});return NE.sketch({dom:{tag:"div",classes:[t("hue-slider")],attributes:{role:"slider","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":120}},rounded:!1,model:{mode:"y",getInitialValue:w(0)},components:[o,n],sliderBehaviours:ql([Zp.config({})]),onChange:(e,t,o)=>{St(e.element,"aria-valuenow",Math.floor(360-3.6*o)),Ws(e,BE,{value:o})}})})(0,t)),i=Bf(r.sketch({})),l=Bf(n.sketch({})),c=(e,t,o)=>{i.getOpt(e).each((e=>{r.setHue(e,o)}))},d=(e,t)=>{l.getOpt(e).each((e=>{n.updateHex(e,t)}))},m=(e,t,o)=>{a.getOpt(e).each((e=>{NE.setValue(e,(e=>100-e/360*100)(o))}))},u=(e,t)=>{i.getOpt(e).each((e=>{r.setThumb(e,t)}))},g=(e,t,o,n)=>{((e,t)=>{const o=oC(e);s.paletteRgba.set(o),s.paletteHue.set(t)})(t,o),z(n,(n=>{n(e,t,o)}))};return{uid:o.uid,dom:o.dom,components:[i.asSpec(),a.asSpec(),l.asSpec()],behaviours:ql([Ip("colour-picker-events",[Qs(RE,(()=>{const e=[c,m,u];return(t,o)=>{const n=o.event.hex,r=(e=>xC(oC(e)))(n);g(t,n,r.hue,e)}})()),Qs(LE,(()=>{const e=[d];return(t,o)=>{const n=o.event.value,r=s.paletteHue.get(),a=wC(r,n.x,100-n.y),i=CC(a);g(t,i,r,e)}})()),Qs(BE,(()=>{const e=[c,d];return(t,o)=>{const n=(e=>(100-e)/100*360)(o.event.value),r=s.paletteRgba.get(),a=xC(r),i=wC(n,a.saturation,a.value),l=CC(i);g(t,l,n,e)}})())]),ag.config({find:e=>l.getOpt(e)}),Tp.config({mode:"acyclic"})])}}});return o},GE=()=>ag.config({find:D.some}),KE=e=>ag.config({find:e.getOpt}),YE=e=>ag.config({find:t=>it(t.element,e).bind((e=>t.getSystem().getByDom(e).toOptional()))}),XE=Pn([Tr("preprocess",x),Tr("postprocess",x)]),JE=(e,t)=>{const o=nr("RepresentingConfigs.memento processors",XE,t);return Xm.config({store:{mode:"manual",getValue:t=>{const n=e.get(t),r=Xm.getValue(n);return o.postprocess(r)},setValue:(t,n)=>{const r=o.preprocess(n),s=e.get(t);Xm.setValue(s,r)}}})},QE=(e,t,o)=>Xm.config({store:{mode:"manual",...e.map((e=>({initialValue:e}))).getOr({}),getValue:t,setValue:o}}),eT=(e,t,o)=>QE(e,(e=>t(e.element)),((e,t)=>o(e.element,t))),tT=e=>Xm.config({store:{mode:"memory",initialValue:e}}),oT={"colorcustom.rgb.red.label":"R","colorcustom.rgb.red.description":"Red component","colorcustom.rgb.green.label":"G","colorcustom.rgb.green.description":"Green component","colorcustom.rgb.blue.label":"B","colorcustom.rgb.blue.description":"Blue component","colorcustom.rgb.hex.label":"#","colorcustom.rgb.hex.description":"Hex color code","colorcustom.rgb.range":"Range 0 to 255","aria.color.picker":"Color Picker","aria.input.invalid":"Invalid input"},nT=(e,t,o)=>{const n=e=>"tox-"+e,r=qE((e=>t=>s(t)?e.translate(oT[t]):e.translate(t))(t),n),a=Bf(r.sketch({dom:{tag:"div",classes:[n("color-picker-container")],attributes:{role:"presentation"}},onValidHex:e=>{Ws(e,Ok,{name:"hex-valid",value:!0})},onInvalidHex:e=>{Ws(e,Ok,{name:"hex-valid",value:!1})}}));return{dom:{tag:"div"},components:[a.asSpec()],behaviours:ql([QE(o,(e=>{const t=a.get(e);return ag.getCurrent(t).bind((e=>Xm.getValue(e).hex)).map((e=>"#"+Ee(e,"#"))).getOr("")}),((e,t)=>{const o=D.from(/^#([a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?)/.exec(t)).bind((e=>te(e,1))),n=a.get(e);ag.getCurrent(n).fold((()=>{console.log("Can not find form")}),(e=>{Xm.setValue(e,{hex:o.getOr("")}),zE.getField(e,"hex").each((e=>{js(e,cs())}))}))})),GE()])}};var rT=tinymce.util.Tools.resolve("tinymce.Resource");var sT=tinymce.util.Tools.resolve("tinymce.util.Tools");const aT=(e,t,o)=>{const n=(e,t)=>{t.stop()},r=e=>(t,o)=>{z(e,(e=>{e(t,o)}))},s=(e,t)=>{var o;if(!wg.isDisabled(e)){const n=t.event.raw;i(e,null===(o=n.dataTransfer)||void 0===o?void 0:o.files)}},a=(e,t)=>{const o=t.event.raw.target;i(e,o.files)},i=(o,n)=>{n&&(Xm.setValue(o,((e,t)=>{const o=sT.explode(t.getOption("images_file_types"));return Z(re(e),(e=>H(o,(t=>De(e.name.toLowerCase(),`.${t.toLowerCase()}`)))))})(n,t)),Ws(o,_k,{name:e.name}))},l=Bf({dom:{tag:"input",attributes:{type:"file",accept:"image/*"},styles:{display:"none"}},behaviours:ql([Ip("input-file-events",[ra(ms()),ra(ks())])])}),c=e.label.map((e=>kk(e,t))),d=fk.parts.field({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-dropzone-container"]},behaviours:ql([tT(o.getOr([])),GE(),wg.config({}),Yp.config({toggleClass:"dragenter",toggleOnExecute:!1}),Ip("dropzone-events",[Qs("dragenter",r([n,Yp.toggle])),Qs("dragleave",r([n,Yp.toggle])),Qs("dragover",n),Qs("drop",r([n,s])),Qs(ds(),a)])]),components:[{dom:{tag:"div",classes:["tox-dropzone"],styles:{}},components:[{dom:{tag:"p"},components:[Ci(t.translate("Drop an image here"))]},Nf.sketch({dom:{tag:"button",styles:{position:"relative"},classes:["tox-button","tox-button--secondary"]},components:[Ci(t.translate("Browse for an image")),l.asSpec()],action:e=>{l.get(e).element.dom.click()},buttonBehaviours:ql([yk.config({}),px(t.isDisabled),gx()])})]}]})}});return xk(c,d,["tox-form__group--stretched"],[])},iT=(e,t)=>{let o=null;const n=()=>{c(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},lT=ya("alloy-fake-before-tabstop"),cT=ya("alloy-fake-after-tabstop"),dT=e=>({dom:{tag:"div",styles:{width:"1px",height:"1px",outline:"none"},attributes:{tabindex:"0"},classes:e},behaviours:ql([Zp.config({ignore:!0}),yk.config({})])}),mT=(e,t)=>({dom:{tag:"div",classes:["tox-navobj",...e.getOr([])]},components:[dT([lT]),t,dT([cT])],behaviours:ql([YE(1)])}),uT=(e,t)=>{Ws(e,is(),{raw:{which:9,shiftKey:t}})},gT=(e,t)=>{const o=t.element;si(o,lT)?uT(e,!0):si(o,cT)&&uT(e,!1)},hT=e=>QS(e,["."+lT,"."+cT].join(","),T),pT=ya("update-dialog"),fT=ya("update-title"),vT=ya("update-body"),bT=ya("update-footer"),yT=ya("body-send-message"),wT=ya("dialog-focus-shifted"),xT=Do().browser,CT=xT.isSafari(),ST=xT.isFirefox(),kT=CT||ST,_T=xT.isChromium(),ET=({scrollTop:e,scrollHeight:t,clientHeight:o})=>Math.ceil(e)+o>=t,TT=(e,t)=>e.scrollTo(0,"bottom"===t?99999999:t),OT=(e,t,o)=>{const n=e.dom;D.from(n.contentDocument).fold(o,(e=>{let o=0;const r=((e,t)=>{const o=e.body;return D.from(!/^1))?o:e.documentElement)})(e,t).map((e=>(o=e.scrollTop,e))).forall(ET),s=()=>{const e=n.contentWindow;g(e)&&(r?TT(e,"bottom"):!r&&kT&&0!==o&&TT(e,o))};CT&&n.addEventListener("load",s,{once:!0}),e.open(),e.write(t),e.close(),CT||s()}))},DT=ke(kT,CT?500:200).map((e=>((e,t)=>{let o=null,n=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null,n=null)},throttle:(...r)=>{n=r,c(o)&&(o=setTimeout((()=>{const t=n;o=null,n=null,e.apply(null,t)}),t))}}})(OT,e))),AT=(e,t,o)=>{const n="tox-dialog__iframe",r=e.transparent?[]:[`${n}--opaque`],s=e.border?["tox-navobj-bordered"]:[],a={...e.label.map((e=>({title:e}))).getOr({}),...o.map((e=>({srcdoc:e}))).getOr({}),...e.sandboxed?{sandbox:"allow-scripts allow-same-origin"}:{}},i=((e,t)=>{const o=Hr(e.getOr(""));return{getValue:e=>o.get(),setValue:(e,n)=>{if(o.get()!==n){const o=e.element,r=()=>St(o,"srcdoc",n);t?DT.fold(w(OT),(e=>e.throttle))(o,n,r):r()}o.set(n)}}})(o,e.streamContent),l=e.label.map((e=>kk(e,t))),c=fk.parts.field({factory:{sketch:e=>mT(D.from(s),{uid:e.uid,dom:{tag:"iframe",attributes:a,classes:[n,...r]},behaviours:ql([yk.config({}),Zp.config({}),QE(o,i.getValue,i.setValue),Ql.config({channels:{[wT]:{onReceive:(e,t)=>{t.newFocus.each((t=>{rt(e.element).each((o=>{(Xe(e.element,t)?ti:ni)(o,"tox-navobj-bordered-focus")}))}))}}}})])})}});return xk(l,c,["tox-form__group--stretched"],[])},MT=(e,t)=>{const o=Hr(t.getOr({url:""})),n=Bf({dom:{tag:"img",classes:["tox-imagepreview__image"],attributes:t.map((e=>({src:e.url}))).getOr({})}}),r=Bf({dom:{tag:"div",classes:["tox-imagepreview__container"],attributes:{role:"presentation"}},components:[n.asSpec()]}),s={};e.height.each((e=>s.height=e));const a=t.map((e=>({url:e.url,zoom:D.from(e.zoom),cachedWidth:D.from(e.cachedWidth),cachedHeight:D.from(e.cachedHeight)})));return{dom:{tag:"div",classes:["tox-imagepreview"],styles:s,attributes:{role:"presentation"}},components:[r.asSpec()],behaviours:ql([GE(),QE(a,(()=>o.get()),((e,t)=>{const s={url:t.url};t.zoom.each((e=>s.zoom=e)),t.cachedWidth.each((e=>s.cachedWidth=e)),t.cachedHeight.each((e=>s.cachedHeight=e)),o.set(s);const a=()=>{const{cachedWidth:t,cachedHeight:o,zoom:n}=s;if(!m(t)&&!m(o)){if(m(n)){const n=((e,t,o)=>{const n=Xt(e),r=Ut(e);return Math.min(n/t,r/o,1)})(e.element,t,o);s.zoom=n}const a=((e,t,o,n,r)=>{const s=o*r,a=n*r,i=Math.max(0,e/2-s/2),l=Math.max(0,t/2-a/2);return{left:i.toString()+"px",top:l.toString()+"px",width:s.toString()+"px",height:a.toString()+"px"}})(Xt(e.element),Ut(e.element),t,o,s.zoom);r.getOpt(e).each((e=>{Nt(e.element,a)}))}};n.getOpt(e).each((o=>{const n=o.element;t.url!==_t(n,"src")&&(St(n,"src",t.url),ni(e.element,"tox-imagepreview__loaded")),a(),(e=>new Promise(((t,o)=>{const n=()=>{s(),t(e)},r=[Ec(e,"load",n),Ec(e,"error",(()=>{s(),o("Unable to load data from image: "+e.dom.src)}))],s=()=>z(r,(e=>e.unbind()));e.dom.complete&&n()})))(n).then((t=>{e.getSystem().isConnected()&&(ti(e.element,"tox-imagepreview__loaded"),s.cachedWidth=t.dom.naturalWidth,s.cachedHeight=t.dom.naturalHeight,a())}))}))}))])}},NT=ya("toolbar.button.execute"),RT=ya("common-button-display-events"),BT={[Cs()]:["disabling","alloy.base.behaviour","toggling","toolbar-button-events"],[Rs()]:["toolbar-button-events",RT],[es()]:["focusing","alloy.base.behaviour",RT]},LT=e=>Mt(e.element,"width",Bt(e.element,"width")),HT=(e,t,o)=>zv(e,{tag:"span",classes:["tox-icon","tox-tbtn__icon-wrap"],behaviours:o},t),IT=(e,t)=>HT(e,t,[]),PT=(e,t)=>HT(e,t,[Hp.config({})]),FT=(e,t,o)=>({dom:{tag:"span",classes:[`${t}__select-label`]},components:[Ci(o.translate(e))],behaviours:ql([Hp.config({})])}),zT=ya("update-menu-text"),VT=ya("update-menu-icon"),ZT=(e,t,o)=>{const n=Hr(v),r=e.text.map((e=>Bf(FT(e,t,o.providers)))),s=e.icon.map((e=>Bf(PT(e,o.providers.icons)))),a=(e,t)=>{const o=Xm.getValue(e);return Zp.focus(o),Ws(o,"keydown",{raw:t.event.raw}),HS.close(o),D.some(!0)},i=e.role.fold((()=>({})),(e=>({role:e}))),l=e.tooltip.fold((()=>({})),(e=>{const t=o.providers.translate(e);return{title:t,"aria-label":t}})),c=zv("chevron-down",{tag:"div",classes:[`${t}__select-chevron`]},o.providers.icons),d=ya("common-button-display-events"),m=Bf(HS.sketch({...e.uid?{uid:e.uid}:{},...i,dom:{tag:"button",classes:[t,`${t}--select`].concat(F(e.classes,(e=>`${t}--${e}`))),attributes:{...l}},components:Sx([s.map((e=>e.asSpec())),r.map((e=>e.asSpec())),D.some(c)]),matchWidth:!0,useMinWidth:!0,onOpen:(t,o,n)=>{e.searchable&&(e=>{Ay(e).each((e=>Zp.focus(e)))})(n)},dropdownBehaviours:ql([...e.dropdownBehaviours,px((()=>e.disabled||o.providers.isDisabled())),gx(),Wk.config({}),Hp.config({}),Ip("dropdown-events",[yx(e,n),wx(e,n)]),Ip(d,[ia(((e,t)=>LT(e)))]),Ip("menubutton-update-display-text",[Qs(zT,((e,t)=>{r.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[Ci(o.providers.translate(t.event.text))])}))})),Qs(VT,((e,t)=>{s.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[PT(t.event.icon,o.providers.icons)])}))}))])]),eventOrder:xn(BT,{mousedown:["focusing","alloy.base.behaviour","item-type-events","normal-dropdown-events"],[Rs()]:["toolbar-button-events","dropdown-events",d]}),sandboxBehaviours:ql([Tp.config({mode:"special",onLeft:a,onRight:a}),Ip("dropdown-sandbox-events",[Qs(Ey,((e,t)=>{IS(e),t.stop()})),Qs(Ty,((e,t)=>{((e,t)=>{PS(e).each((o=>{((e,t,o,n)=>{const r={...n,target:t};e.getSystem().triggerEvent(o,t,r)})(e,o.element,t.event.eventType,t.event.interactionEvent)}))})(e,t),t.stop()}))])]),lazySink:o.getSink,toggleClass:`${t}--active`,parts:{menu:{...wy(0,e.columns,e.presets),fakeFocus:e.searchable,onHighlightItem:FS,onCollapseMenu:(e,t,o)=>{Mg.getHighlighted(o).each((t=>{FS(e,o,t)}))},onDehighlightItem:zS}},getAnchorOverrides:()=>({maxHeightFunction:(e,t)=>{Pc()(e,t-10)}}),fetch:t=>wS(S(e.fetch,t))}));return m.asSpec()},UT=e=>"separator"===e.type,jT={type:"separator"},WT=(e,t)=>{const o=j(e,((e,o)=>(e=>s(e))(o)?""===o?e:"|"===o?e.length>0&&!UT(e[e.length-1])?e.concat([jT]):e:be(t,o.toLowerCase())?e.concat([t[o.toLowerCase()]]):e:e.concat([o])),[]);return o.length>0&&UT(o[o.length-1])&&o.pop(),o},$T=(e,t)=>{const o=WT(s(e)?e.split(" "):e,t);return U(o,((e,o)=>{if((e=>be(e,"getSubmenuItems"))(o)){const n=(e=>{const t=ve(e,"value").getOrThunk((()=>ya("generated-menu-item")));return xn({value:t},e)})(o),r=((e,t)=>{const o=e.getSubmenuItems(),n=$T(o,t);return{item:e,menus:xn(n.menus,{[e.value]:n.items}),expansions:xn(n.expansions,{[e.value]:e.value})}})(n,t);return{menus:xn(e.menus,r.menus),items:[r.item,...e.items],expansions:xn(e.expansions,r.expansions)}}return{...e,items:[o,...e.items]}}),{menus:{},expansions:{},items:[]})},qT=(e,t,o,n)=>{const r=ya("primary-menu"),s=$T(e,o.shared.providers.menuItems());if(0===s.items.length)return D.none();const a=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-field",placeholder:e.placeholder}))))(n),i=WS(r,s.items,t,o,n.isHorizontalMenu,a),l=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-results"}))))(n),c=ce(s.menus,((e,n)=>WS(n,e,t,o,!1,l))),d=xn(c,Fr(r,i));return D.from(Df.tieredData(r,d,s.expansions))},GT=e=>!be(e,"items"),KT="data-value",YT=(e,t,o,n)=>F(o,(o=>GT(o)?{type:"togglemenuitem",text:o.text,value:o.value,active:o.value===n,onAction:()=>{Xm.setValue(e,o.value),Ws(e,_k,{name:t}),Zp.focus(e)}}:{type:"nestedmenuitem",text:o.text,getSubmenuItems:()=>YT(e,t,o.items,n)})),XT=(e,t)=>se(e,(e=>GT(e)?ke(e.value===t,e):XT(e.items,t))),JT=tg({name:"HtmlSelect",configFields:[dr("options"),Jm("selectBehaviours",[Zp,Xm]),Tr("selectClasses",[]),Tr("selectAttributes",{}),yr("data")],factory:(e,t)=>{const o=F(e.options,(e=>({dom:{tag:"option",value:e.value,innerHtml:e.text}}))),n=e.data.map((e=>Fr("initialValue",e))).getOr({});return{uid:e.uid,dom:{tag:"select",classes:e.selectClasses,attributes:e.selectAttributes},components:o,behaviours:eu(e.selectBehaviours,[Zp.config({}),Xm.config({store:{mode:"manual",getValue:e=>ci(e.element),setValue:(t,o)=>{const n=oe(e.options);W(e.options,(e=>e.value===o)).isSome()?di(t.element,o):-1===t.element.dom.selectedIndex&&""===o&&n.each((e=>di(t.element,e.value)))},...n}})])}}}),QT=w([Tr("field1Name","field1"),Tr("field2Name","field2"),ol("onLockedChange"),Ji(["lockClass"]),Tr("locked",!1),tu("coupledFieldBehaviours",[ag,Xm])]),eO=(e,t)=>Tu({factory:fk,name:e,overrides:e=>({fieldBehaviours:ql([Ip("coupled-input-behaviour",[Qs(cs(),(o=>{((e,t,o)=>Vu(e,t,o).bind(ag.getCurrent))(o,e,t).each((t=>{Vu(o,e,"lock").each((n=>{Yp.isOn(n)&&e.onLockedChange(o,t,n)}))}))}))])])})}),tO=w([eO("field1","field2"),eO("field2","field1"),Tu({factory:Nf,schema:[dr("dom")],name:"lock",overrides:e=>({buttonBehaviours:ql([Yp.config({selected:e.locked,toggleClass:e.markers.lockClass,aria:{mode:"pressed"}})])})})]),oO=og({name:"FormCoupledInputs",configFields:QT(),partFields:tO(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:ou(e.coupledFieldBehaviours,[ag.config({find:D.some}),Xm.config({store:{mode:"manual",getValue:t=>{const o=$u(t,e,["field1","field2"]);return{[e.field1Name]:Xm.getValue(o.field1()),[e.field2Name]:Xm.getValue(o.field2())}},setValue:(t,o)=>{const n=$u(t,e,["field1","field2"]);ye(o,e.field1Name)&&Xm.setValue(n.field1(),o[e.field1Name]),ye(o,e.field2Name)&&Xm.setValue(n.field2(),o[e.field2Name])}}})]),apis:{getField1:t=>Vu(t,e,"field1"),getField2:t=>Vu(t,e,"field2"),getLock:t=>Vu(t,e,"lock")}}),apis:{getField1:(e,t)=>e.getField1(t),getField2:(e,t)=>e.getField2(t),getLock:(e,t)=>e.getLock(t)}}),nO=e=>{const t=/^\s*(\d+(?:\.\d+)?)\s*(|cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)\s*$/.exec(e);if(null!==t){const e=parseFloat(t[1]),o=t[2];return on.value({value:e,unit:o})}return on.error(e)},rO=(e,t)=>{const o={"":96,px:96,pt:72,cm:2.54,pc:12,mm:25.4,in:1},n=e=>be(o,e);return e.unit===t?D.some(e.value):n(e.unit)&&n(t)?o[e.unit]===o[t]?D.some(e.value):D.some(e.value/o[e.unit]*o[t]):D.none()},sO=e=>D.none(),aO=(e,t)=>{const o=nO(e).toOptional(),n=nO(t).toOptional();return Ce(o,n,((e,t)=>rO(e,t.unit).map((e=>t.value/e)).map((e=>{return o=e,n=t.unit,e=>rO(e,n).map((e=>({value:e*o,unit:n})));var o,n})).getOr(sO))).getOr(sO)},iO=(e,t)=>{const o=e.label.map((e=>kk(e,t))),n=[wg.config({disabled:()=>e.disabled||t.isDisabled()}),gx(),Tp.config({mode:"execution",useEnter:!0!==e.multiline,useControlEnter:!0===e.multiline,execute:e=>(js(e,Dk),D.some(!0))}),Ip("textfield-change",[Qs(cs(),((t,o)=>{Ws(t,_k,{name:e.name})})),Qs(ws(),((t,o)=>{Ws(t,_k,{name:e.name})}))]),yk.config({})],r=e.validation.map((e=>jk.config({getRoot:e=>rt(e.element),invalidClass:"tox-invalid",validator:{validate:t=>{const o=Xm.getValue(t),n=e.validator(o);return xS(!0===n?on.value(o):on.error(n))},validateOnLoad:e.validateOnLoad}}))).toArray(),s={...e.placeholder.fold(w({}),(e=>({placeholder:t.translate(e)}))),...e.inputMode.fold(w({}),(e=>({inputmode:e})))},a=fk.parts.field({tag:!0===e.multiline?"textarea":"input",...e.data.map((e=>({data:e}))).getOr({}),inputAttributes:s,inputClasses:[e.classname],inputBehaviours:ql(q([n,r])),selectOnFocus:!1,factory:_y}),i=e.multiline?{dom:{tag:"div",classes:["tox-textarea-wrap"]},components:[a]}:a,l=(e.flex?["tox-form__group--stretched"]:[]).concat(e.maximized?["tox-form-group--maximize"]:[]),c=[wg.config({disabled:()=>e.disabled||t.isDisabled(),onDisabled:e=>{fk.getField(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable)}}),gx()];return xk(o,i,l,c)},lO=(e,t)=>t.getAnimationRoot.fold((()=>e.element),(t=>t(e))),cO=e=>e.dimension.property,dO=(e,t)=>e.dimension.getDimension(t),mO=(e,t)=>{const o=lO(e,t);ii(o,[t.shrinkingClass,t.growingClass])},uO=(e,t)=>{ni(e.element,t.openClass),ti(e.element,t.closedClass),Mt(e.element,cO(t),"0px"),zt(e.element)},gO=(e,t)=>{ni(e.element,t.closedClass),ti(e.element,t.openClass),Ft(e.element,cO(t))},hO=(e,t,o,n)=>{o.setCollapsed(),Mt(e.element,cO(t),dO(t,e.element)),mO(e,t),uO(e,t),t.onStartShrink(e),t.onShrunk(e)},pO=(e,t,o,n)=>{const r=n.getOrThunk((()=>dO(t,e.element)));o.setCollapsed(),Mt(e.element,cO(t),r),zt(e.element);const s=lO(e,t);ni(s,t.growingClass),ti(s,t.shrinkingClass),uO(e,t),t.onStartShrink(e)},fO=(e,t,o)=>{const n=dO(t,e.element);("0px"===n?hO:pO)(e,t,o,D.some(n))},vO=(e,t,o)=>{const n=lO(e,t),r=si(n,t.shrinkingClass),s=dO(t,e.element);gO(e,t);const a=dO(t,e.element);(r?()=>{Mt(e.element,cO(t),s),zt(e.element)}:()=>{uO(e,t)})(),ni(n,t.shrinkingClass),ti(n,t.growingClass),gO(e,t),Mt(e.element,cO(t),a),o.setExpanded(),t.onStartGrow(e)},bO=(e,t,o)=>{const n=lO(e,t);return!0===si(n,t.growingClass)},yO=(e,t,o)=>{const n=lO(e,t);return!0===si(n,t.shrinkingClass)};var wO=Object.freeze({__proto__:null,refresh:(e,t,o)=>{if(o.isExpanded()){Ft(e.element,cO(t));const o=dO(t,e.element);Mt(e.element,cO(t),o)}},grow:(e,t,o)=>{o.isExpanded()||vO(e,t,o)},shrink:(e,t,o)=>{o.isExpanded()&&fO(e,t,o)},immediateShrink:(e,t,o)=>{o.isExpanded()&&hO(e,t,o)},hasGrown:(e,t,o)=>o.isExpanded(),hasShrunk:(e,t,o)=>o.isCollapsed(),isGrowing:bO,isShrinking:yO,isTransitioning:(e,t,o)=>bO(e,t)||yO(e,t),toggleGrow:(e,t,o)=>{(o.isExpanded()?fO:vO)(e,t,o)},disableTransitions:mO,immediateGrow:(e,t,o)=>{o.isExpanded()||(gO(e,t),Mt(e.element,cO(t),dO(t,e.element)),mO(e,t),o.setExpanded(),t.onStartGrow(e),t.onGrown(e))}});var xO=Object.freeze({__proto__:null,exhibit:(e,t,o)=>{const n=t.expanded;return Fa(n?{classes:[t.openClass],styles:{}}:{classes:[t.closedClass],styles:Fr(t.dimension.property,"0px")})},events:(e,t)=>Ys([aa(gs(),((o,n)=>{if(n.event.raw.propertyName===e.dimension.property){mO(o,e),t.isExpanded()&&Ft(o.element,e.dimension.property);(t.isExpanded()?e.onGrown:e.onShrunk)(o)}}))])}),CO=[dr("closedClass"),dr("openClass"),dr("shrinkingClass"),dr("growingClass"),yr("getAnimationRoot"),el("onShrunk"),el("onStartShrink"),el("onGrown"),el("onStartGrow"),Tr("expanded",!1),mr("dimension",sr("property",{width:[rl("property","width"),rl("getDimension",(e=>Xt(e)+"px"))],height:[rl("property","height"),rl("getDimension",(e=>Ut(e)+"px"))]}))];const SO=Kl({fields:CO,name:"sliding",active:xO,apis:wO,state:Object.freeze({__proto__:null,init:e=>{const t=Hr(e.expanded);return Ia({isExpanded:()=>!0===t.get(),isCollapsed:()=>!1===t.get(),setCollapsed:S(t.set,!1),setExpanded:S(t.set,!0),readState:()=>"expanded: "+t.get()})}})}),kO=e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setActive:t=>{const o=e.element;t?(ti(o,"tox-tbtn--enabled"),St(o,"aria-pressed",!0)):(ni(o,"tox-tbtn--enabled"),Ot(o,"aria-pressed"))},isActive:()=>si(e.element,"tox-tbtn--enabled"),setText:t=>{Ws(e,zT,{text:t})},setIcon:t=>Ws(e,VT,{icon:t})}),_O=(e,t,o,n,r=!0)=>ZT({text:e.text,icon:e.icon,tooltip:e.tooltip,searchable:e.search.isSome(),role:n,fetch:(t,n)=>{const r={pattern:e.search.isSome()?VS(t):""};e.fetch((t=>{n(qT(t,oy.CLOSE_ON_EXECUTE,o,{isHorizontalMenu:!1,search:e.search}))}),r,kO(t))},onSetup:e.onSetup,getApi:kO,columns:1,presets:"normal",classes:[],dropdownBehaviours:[...r?[yk.config({})]:[]]},t,o.shared),EO=(e,t,o)=>{const n=e=>n=>{const r=!n.isActive();n.setActive(r),e.storage.set(r),o.shared.getSink().each((o=>{t().getOpt(o).each((t=>{tc(t.element),Ws(t,Ok,{name:e.name,value:e.storage.get()})}))}))},r=e=>t=>{t.setActive(e.storage.get())};return t=>{t(F(e,(e=>{const t=e.text.fold((()=>({})),(e=>({text:e})));return{type:e.type,active:!1,...t,onAction:n(e),onSetup:r(e)}})))}},TO=e=>({dom:{tag:"span",classes:["tox-tree__label"],attributes:{title:e,"aria-label":e}},components:[Ci(e)]}),OO=ya("leaf-label-event-id"),DO=({leaf:e,onLeafAction:t,visible:o,treeId:n,selectedId:r,backstage:s})=>{const a=e.menu.map((e=>_O(e,"tox-mbtn",s,D.none(),o))),i=[TO(e.title)];return a.each((e=>i.push(e))),Nf.sketch({dom:{tag:"div",classes:["tox-tree--leaf__label","tox-trbtn"].concat(o?["tox-tree--leaf__label--visible"]:[])},components:i,role:"treeitem",action:o=>{t(e.id),o.getSystem().broadcastOn([`update-active-item-${n}`],{value:e.id})},eventOrder:{[is()]:[OO,"keying"]},buttonBehaviours:ql([...o?[yk.config({})]:[],Yp.config({toggleClass:"tox-trbtn--enabled",toggleOnExecute:!1,aria:{mode:"selected"}}),Ql.config({channels:{[`update-active-item-${n}`]:{onReceive:(t,o)=>{(o.value===e.id?Yp.on:Yp.off)(t)}}}}),Ip(OO,[ia(((t,o)=>{r.each((o=>{(o===e.id?Yp.on:Yp.off)(t)}))})),Qs(is(),((e,t)=>{const o="ArrowLeft"===t.event.raw.code,n="ArrowRight"===t.event.raw.code;o?(Ni(e.element,".tox-tree--directory").each((t=>{e.getSystem().getByDom(t).each((e=>{Ri(t,".tox-tree--directory__label").each((t=>{e.getSystem().getByDom(t).each(Zp.focus)}))}))})),t.stop()):n&&t.stop()}))])])})},AO=(e,t)=>((e,t,o)=>zv(e,{tag:"span",classes:["tox-tree__icon-wrap","tox-icon"],behaviours:o},t))(e,t,[]),MO=ya("directory-label-event-id"),NO=({directory:e,visible:t,noChildren:o,backstage:n})=>{const r=e.menu.map((e=>_O(e,"tox-mbtn",n,D.none()))),s=[{dom:{tag:"div",classes:["tox-chevron"]},components:[AO("chevron-right",n.shared.providers.icons)]},TO(e.title)];r.each((e=>{s.push(e)}));const a=t=>{Ni(t.element,".tox-tree--directory").each((o=>{t.getSystem().getByDom(o).each((o=>{const n=!Yp.isOn(o);Yp.toggle(o),Ws(t,"expand-tree-node",{expanded:n,node:e.id})}))}))};return Nf.sketch({dom:{tag:"div",classes:["tox-tree--directory__label","tox-trbtn"].concat(t?["tox-tree--directory__label--visible"]:[])},components:s,action:a,eventOrder:{[is()]:[MO,"keying"]},buttonBehaviours:ql([...t?[yk.config({})]:[],Ip(MO,[Qs(is(),((e,t)=>{const n="ArrowRight"===t.event.raw.code,r="ArrowLeft"===t.event.raw.code;n&&o&&t.stop(),(n||r)&&Ni(e.element,".tox-tree--directory").each((o=>{e.getSystem().getByDom(o).each((o=>{!Yp.isOn(o)&&n||Yp.isOn(o)&&r?(a(e),t.stop()):r&&!Yp.isOn(o)&&(Ni(o.element,".tox-tree--directory").each((e=>{Ri(e,".tox-tree--directory__label").each((e=>{o.getSystem().getByDom(e).each(Zp.focus)}))})),t.stop())}))}))}))])])})},RO=({children:e,onLeafAction:t,visible:o,treeId:n,expandedIds:r,selectedId:s,backstage:a})=>({dom:{tag:"div",classes:["tox-tree--directory__children"]},components:e.map((e=>"leaf"===e.type?DO({leaf:e,selectedId:s,onLeafAction:t,visible:o,treeId:n,backstage:a}):LO({directory:e,expandedIds:r,selectedId:s,onLeafAction:t,labelTabstopping:o,treeId:n,backstage:a}))),behaviours:ql([SO.config({dimension:{property:"height"},closedClass:"tox-tree--directory__children--closed",openClass:"tox-tree--directory__children--open",growingClass:"tox-tree--directory__children--growing",shrinkingClass:"tox-tree--directory__children--shrinking",expanded:o}),Hp.config({})])}),BO=ya("directory-event-id"),LO=({directory:e,onLeafAction:t,labelTabstopping:o,treeId:n,backstage:r,expandedIds:s,selectedId:a})=>{const{children:i}=e,l=Hr(s),c=s.includes(e.id);return{dom:{tag:"div",classes:["tox-tree--directory"],attributes:{role:"treeitem"}},components:[NO({directory:e,visible:o,noChildren:0===e.children.length,backstage:r}),RO({children:i,expandedIds:s,selectedId:a,onLeafAction:t,visible:c,treeId:n,backstage:r})],behaviours:ql([Ip(BO,[ia(((e,t)=>{Yp.set(e,c)})),Qs("expand-tree-node",((e,t)=>{const{expanded:o,node:n}=t.event;l.set(o?[...l.get(),n]:l.get().filter((e=>e!==n)))}))]),Yp.config({...e.children.length>0?{aria:{mode:"expanded"}}:{},toggleClass:"tox-tree--directory--expanded",onToggled:(e,o)=>{const s=e.components()[1],c=(d=o,i.map((e=>"leaf"===e.type?DO({leaf:e,selectedId:a,onLeafAction:t,visible:d,treeId:n,backstage:r}):LO({directory:e,expandedIds:l.get(),selectedId:a,onLeafAction:t,labelTabstopping:d,treeId:n,backstage:r}))));var d;o?SO.grow(s):SO.shrink(s),Hp.set(s,c)}})])}},HO=ya("tree-event-id");var IO=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.stream.streams.setup(e,t);return Ys([Qs(e.event,o),la((()=>t.cancel()))].concat(e.cancelEvent.map((e=>[Qs(e,(()=>t.cancel()))])).getOr([])))}});const PO=e=>{const t=Hr(null);return Ia({readState:()=>({timer:null!==t.get()?"set":"unset"}),setTimer:e=>{t.set(e)},cancel:()=>{const e=t.get();null!==e&&e.cancel()}})};var FO=Object.freeze({__proto__:null,throttle:PO,init:e=>e.stream.streams.state(e)});var zO=[mr("stream",sr("mode",{throttle:[dr("delay"),Tr("stopEvent",!0),rl("streams",{setup:(e,t)=>{const o=e.stream,n=iT(e.onStream,o.delay);return t.setTimer(n),(e,t)=>{n.throttle(e,t),o.stopEvent&&t.stop()}},state:PO})]})),Tr("event","input"),yr("cancelEvent"),ol("onStream")];const VO=Kl({fields:zO,name:"streaming",active:IO,state:FO}),ZO=(e,t,o)=>{const n=Xm.getValue(o);Xm.setValue(t,n),jO(t)},UO=(e,t)=>{const o=e.element,n=ci(o),r=o.dom;"number"!==_t(o,"type")&&t(r,n)},jO=e=>{UO(e,((e,t)=>e.setSelectionRange(t.length,t.length)))},WO=(e,t,o)=>{if(e.selectsOver){const n=Xm.getValue(t),r=e.getDisplayText(n),s=Xm.getValue(o);return 0===e.getDisplayText(s).indexOf(r)?D.some((()=>{ZO(0,t,o),((e,t)=>{UO(e,((e,o)=>e.setSelectionRange(t,o.length)))})(t,r.length)})):D.none()}return D.none()},$O=w("alloy.typeahead.itemexecute"),qO=w([yr("lazySink"),dr("fetch"),Tr("minChars",5),Tr("responseTime",1e3),el("onOpen"),Tr("getHotspot",D.some),Tr("getAnchorOverrides",w({})),Tr("layouts",D.none()),Tr("eventOrder",{}),Lr("model",{},[Tr("getDisplayText",(e=>void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.value)),Tr("selectsOver",!0),Tr("populateFromBrowse",!0)]),el("onSetValue"),tl("onExecute"),el("onItemExecute"),Tr("inputClasses",[]),Tr("inputAttributes",{}),Tr("inputStyles",{}),Tr("matchWidth",!0),Tr("useMinWidth",!1),Tr("dismissOnBlur",!0),Ji(["openClass"]),yr("initialData"),Jm("typeaheadBehaviours",[Zp,Xm,VO,Tp,Yp,pS]),lr("lazyTypeaheadComp",(()=>Hr(D.none))),lr("previewing",(()=>Hr(!0)))].concat(xy()).concat(RS())),GO=w([Ou({schema:[Xi()],name:"menu",overrides:e=>({fakeFocus:!0,onHighlightItem:(t,o,n)=>{e.previewing.get()?e.lazyTypeaheadComp.get().each((t=>{WO(e.model,t,n).fold((()=>{e.model.selectsOver?(Mg.dehighlight(o,n),e.previewing.set(!0)):e.previewing.set(!1)}),(t=>{t(),e.previewing.set(!1)}))})):e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&ZO(e.model,t,n),Et(n.element,"id").each((e=>St(t.element,"aria-activedescendant",e)))}))},onExecute:(t,o)=>e.lazyTypeaheadComp.get().map((e=>(Ws(e,$O(),{item:o}),!0))),onHover:(t,o)=>{e.previewing.set(!1),e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&ZO(e.model,t,o)}))}})})]),KO=og({name:"Typeahead",configFields:qO(),partFields:GO(),factory:(e,t,o,n)=>{const r=(t,o,r)=>{e.previewing.set(!1);const s=pS.getCoupled(t,"sandbox");if(Mm.isOpen(s))ag.getCurrent(s).each((e=>{Mg.getHighlighted(e).fold((()=>{r(e)}),(()=>{Ks(s,e.element,"keydown",o)}))}));else{const o=e=>{ag.getCurrent(e).each(r)};_S(e,a(t),t,s,n,o,Tf.HighlightMenuAndItem).get(v)}},s=Cy(e),a=e=>t=>t.map((t=>{const o=fe(t.menus),n=G(o,(e=>Z(e.items,(e=>"item"===e.type))));return Xm.getState(e).update(F(n,(e=>e.data))),t})),i=e=>ag.getCurrent(e),l="typeaheadevents",c=[Zp.config({}),Xm.config({onSetValue:e.onSetValue,store:{mode:"dataset",getDataKey:e=>ci(e.element),getFallbackEntry:e=>({value:e,meta:{}}),setValue:(t,o)=>{di(t.element,e.model.getDisplayText(o))},...e.initialData.map((e=>Fr("initialValue",e))).getOr({})}}),VO.config({stream:{mode:"throttle",delay:e.responseTime,stopEvent:!1},onStream:(t,o)=>{const r=pS.getCoupled(t,"sandbox");if(Zp.isFocused(t)&&ci(t.element).length>=e.minChars){const o=i(r).bind((e=>Mg.getHighlighted(e).map(Xm.getValue)));e.previewing.set(!0);const s=t=>{i(r).each((t=>{o.fold((()=>{e.model.selectsOver&&Mg.highlightFirst(t)}),(e=>{Mg.highlightBy(t,(t=>Xm.getValue(t).value===e.value)),Mg.getHighlighted(t).orThunk((()=>(Mg.highlightFirst(t),D.none())))}))}))};_S(e,a(t),t,r,n,s,Tf.HighlightJustMenu).get(v)}},cancelEvent:Ts()}),Tp.config({mode:"special",onDown:(e,t)=>(r(e,t,Mg.highlightFirst),D.some(!0)),onEscape:e=>{const t=pS.getCoupled(e,"sandbox");return Mm.isOpen(t)?(Mm.close(t),D.some(!0)):D.none()},onUp:(e,t)=>(r(e,t,Mg.highlightLast),D.some(!0)),onEnter:t=>{const o=pS.getCoupled(t,"sandbox"),n=Mm.isOpen(o);if(n&&!e.previewing.get())return i(o).bind((e=>Mg.getHighlighted(e))).map((e=>(Ws(t,$O(),{item:e}),!0)));{const r=Xm.getValue(t);return js(t,Ts()),e.onExecute(o,t,r),n&&Mm.close(o),D.some(!0)}}}),Yp.config({toggleClass:e.markers.openClass,aria:{mode:"expanded"}}),pS.config({others:{sandbox:t=>MS(e,t,{onOpen:()=>Yp.on(t),onClose:()=>{e.lazyTypeaheadComp.get().each((e=>Ot(e.element,"aria-activedescendant"))),Yp.off(t)}})}}),Ip(l,[ia((t=>{e.lazyTypeaheadComp.set(D.some(t))})),la((t=>{e.lazyTypeaheadComp.set(D.none())})),da((t=>{const o=v;TS(e,a(t),t,n,o,Tf.HighlightMenuAndItem).get(v)})),Qs($O(),((t,o)=>{const n=pS.getCoupled(t,"sandbox");ZO(e.model,t,o.event.item),js(t,Ts()),e.onItemExecute(t,n,o.event.item,Xm.getValue(t)),Mm.close(n),jO(t)}))].concat(e.dismissOnBlur?[Qs(ys(),(e=>{const t=pS.getCoupled(e,"sandbox");sc(t.element).isNone()&&Mm.close(t)}))]:[]))],d={[Bs()]:[Xm.name(),VO.name(),l],...e.eventOrder};return{uid:e.uid,dom:ky(xn(e,{inputAttributes:{role:"combobox","aria-autocomplete":"list","aria-haspopup":"true"}})),behaviours:{...s,...eu(e.typeaheadBehaviours,c)},eventOrder:d}}}),YO=e=>({...e,toCached:()=>YO(e.toCached()),bindFuture:t=>YO(e.bind((e=>e.fold((e=>xS(on.error(e))),(e=>t(e)))))),bindResult:t=>YO(e.map((e=>e.bind(t)))),mapResult:t=>YO(e.map((e=>e.map(t)))),mapError:t=>YO(e.map((e=>e.mapError(t)))),foldResult:(t,o)=>e.map((e=>e.fold(t,o))),withTimeout:(t,o)=>YO(wS((n=>{let r=!1;const s=setTimeout((()=>{r=!0,n(on.error(o()))}),t);e.get((e=>{r||(clearTimeout(s),n(e))}))})))}),XO=e=>YO(wS(e)),JO=XO,QO=(e,t,o=[],n,r,s)=>{const a=t.fold((()=>({})),(e=>({action:e}))),i={buttonBehaviours:ql([px((()=>!e.enabled||s.isDisabled())),gx(),yk.config({}),Ip("button press",[Js("click"),Js("mousedown")])].concat(o)),eventOrder:{click:["button press","alloy.base.behaviour"],mousedown:["button press","alloy.base.behaviour"]},...a},l=xn(i,{dom:n});return xn(l,{components:r})},eD=(e,t,o,n=[])=>{const r={tag:"button",classes:["tox-tbtn"],attributes:e.tooltip.map((e=>({"aria-label":o.translate(e),title:o.translate(e)}))).getOr({})},s=e.icon.map((e=>IT(e,o.icons))),a=Sx([s]);return QO(e,t,n,r,a,o)},tD=e=>{switch(e){case"primary":return["tox-button"];case"toolbar":return["tox-tbtn"];default:return["tox-button","tox-button--secondary"]}},oD=(e,t,o,n=[],r=[])=>{const s=o.translate(e.text),a=e.icon.map((e=>IT(e,o.icons))),i=[a.getOrThunk((()=>Ci(s)))],l=e.buttonType.getOr(e.primary||e.borderless?"primary":"secondary"),c=[...tD(l),...a.isSome()?["tox-button--icon"]:[],...e.borderless?["tox-button--naked"]:[],...r];return QO(e,t,n,{tag:"button",classes:c,attributes:{title:s}},i,o)},nD=(e,t,o,n=[],r=[])=>{const s=oD(e,D.some(t),o,n,r);return Nf.sketch(s)},rD=(e,t)=>o=>{"custom"===t?Ws(o,Ok,{name:e,value:{}}):"submit"===t?js(o,Dk):"cancel"===t?js(o,Tk):console.error("Unknown button type: ",t)},sD=(e,t,o)=>{if(((e,t)=>"menu"===t)(0,t)){const t=()=>s,n=e,r={...e,type:"menubutton",search:D.none(),onSetup:t=>(t.setEnabled(e.enabled),v),fetch:EO(n.items,t,o)},s=Bf(_O(r,"tox-tbtn",o,D.none()));return s.asSpec()}if(((e,t)=>"custom"===t||"cancel"===t||"submit"===t)(0,t)){const n=rD(e.name,t),r={...e,borderless:!1};return nD(r,n,o.shared.providers,[])}if(((e,t)=>"togglebutton"===t)(0,t))return((e,t)=>{var o,n;const r=e.icon.map((e=>PT(e,t.icons))).map(Bf),s=e.buttonType.getOr(e.primary?"primary":"secondary"),a={...e,name:null!==(o=e.name)&&void 0!==o?o:"",primary:"primary"===s,tooltip:D.from(e.tooltip),enabled:null!==(n=e.enabled)&&void 0!==n&&n,borderless:!1},i=a.tooltip.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),l=tD(null!=s?s:"secondary"),c=e.icon.isSome()&&e.text.isSome(),d={tag:"button",classes:[...l.concat(e.icon.isSome()?["tox-button--icon"]:[]),...e.active?["tox-button--enabled"]:[],...c?["tox-button--icon-and-text"]:[]],attributes:i},m=t.translate(e.text.getOr("")),u=Ci(m),g=[...Sx([r.map((e=>e.asSpec()))]),...e.text.isSome()?[u]:[]],h=QO(a,D.some((o=>{Ws(o,Ok,{name:e.name,value:{setIcon:e=>{r.map((n=>n.getOpt(o).each((o=>{Hp.set(o,[PT(e,t.icons)])}))))}}})})),[],d,g,t);return Nf.sketch(h)})(e,o.shared.providers);throw console.error("Unknown footer button type: ",t),new Error("Unknown footer button type")},aD=(e,t)=>{const o=rD(e.name,"custom");return n=D.none(),r=fk.parts.field({factory:Nf,...oD(e,D.some(o),t,[tT(""),GE()])}),xk(n,r,[],[]);var n,r},iD={type:"separator"},lD=e=>({type:"menuitem",value:e.url,text:e.title,meta:{attach:e.attach},onAction:v}),cD=(e,t)=>({type:"menuitem",value:t,text:e,meta:{attach:void 0},onAction:v}),dD=(e,t)=>(e=>F(e,lD))(((e,t)=>Z(t,(t=>t.type===e)))(e,t)),mD=e=>dD("header",e.targets),uD=e=>dD("anchor",e.targets),gD=e=>D.from(e.anchorTop).map((e=>cD("",e))).toArray(),hD=e=>D.from(e.anchorBottom).map((e=>cD("",e))).toArray(),pD=(e,t)=>{const o=e.toLowerCase();return Z(t,(e=>{var t;const n=void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.text,r=null!==(t=e.value)&&void 0!==t?t:"";return Te(n.toLowerCase(),o)||Te(r.toLowerCase(),o)}))},fD=(e,t,o)=>{var n,r;const s=Xm.getValue(t),a=null!==(r=null===(n=null==s?void 0:s.meta)||void 0===n?void 0:n.text)&&void 0!==r?r:s.value;return o.getLinkInformation().fold((()=>[]),(t=>{const n=pD(a,(e=>F(e,(e=>cD(e,e))))(o.getHistory(e)));return"file"===e?(r=[n,pD(a,mD(t)),pD(a,q([gD(t),uD(t),hD(t)]))],j(r,((e,t)=>0===e.length||0===t.length?e.concat(t):e.concat(iD,t)),[])):n;var r}))},vD=ya("aria-invalid"),bD=(e,t)=>{e.dom.checked=t},yD=e=>e.dom.checked,wD=e=>(t,o,n,r)=>ve(o,"name").fold((()=>e(o,r,D.none())),(s=>t.field(s,e(o,r,ve(n,s))))),xD={bar:wD(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-bar","tox-form__controls-h-stack"]},components:F(e.items,t.interpreter)}))(e,t.shared))),collection:wD(((e,t,o)=>Bk(e,t.shared.providers,o))),alertbanner:wD(((e,t)=>((e,t)=>{const o=Iv(e.icon,t.icons);return uk.sketch({dom:{tag:"div",attributes:{role:"alert"},classes:["tox-notification","tox-notification--in",`tox-notification--${e.level}`]},components:[{dom:{tag:"div",classes:["tox-notification__icon"],innerHtml:e.url?void 0:o},components:e.url?[Nf.sketch({dom:{tag:"button",classes:["tox-button","tox-button--naked","tox-button--icon"],innerHtml:o,attributes:{title:t.translate(e.iconTooltip)}},action:t=>Ws(t,Ok,{name:"alert-banner",value:e.url}),buttonBehaviours:ql([Pv()])})]:void 0},{dom:{tag:"div",classes:["tox-notification__body"],innerHtml:t.translate(e.text)}}]})})(e,t.shared.providers))),input:wD(((e,t,o)=>((e,t,o)=>iO({name:e.name,multiline:!1,label:e.label,inputMode:e.inputMode,placeholder:e.placeholder,flex:!1,disabled:!e.enabled,classname:"tox-textfield",validation:D.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),textarea:wD(((e,t,o)=>((e,t,o)=>iO({name:e.name,multiline:!0,label:e.label,inputMode:D.none(),placeholder:e.placeholder,flex:!0,disabled:!e.enabled,classname:"tox-textarea",validation:D.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),label:wD(((e,t)=>((e,t)=>{const o="tox-label";return{dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"label",classes:[o,..."center"===e.align?[`${o}--center`]:[],..."end"===e.align?[`${o}--end`]:[]]},components:[Ci(t.providers.translate(e.label))]},...F(e.items,t.interpreter)],behaviours:ql([GE(),Hp.config({}),(n=D.none(),eT(n,ma,ua)),Tp.config({mode:"acyclic"})])};var n})(e,t.shared))),iframe:(e=>(t,o,n,r)=>{const s=xn(o,{source:"dynamic"});return wD(e)(t,s,n,r)})(((e,t,o)=>AT(e,t.shared.providers,o))),button:wD(((e,t)=>aD(e,t.shared.providers))),checkbox:wD(((e,t,o)=>((e,t,o)=>{const n=e=>(e.element.dom.click(),D.some(!0)),r=fk.parts.field({factory:{sketch:x},dom:{tag:"input",classes:["tox-checkbox__input"],attributes:{type:"checkbox"}},behaviours:ql([GE(),wg.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{rt(e.element).each((e=>ti(e,"tox-checkbox--disabled")))},onEnabled:e=>{rt(e.element).each((e=>ni(e,"tox-checkbox--disabled")))}}),yk.config({}),Zp.config({}),eT(o,yD,bD),Tp.config({mode:"special",onEnter:n,onSpace:n,stopSpaceKeyup:!0}),Ip("checkbox-events",[Qs(ds(),((t,o)=>{Ws(t,_k,{name:e.name})}))])])}),s=fk.parts.label({dom:{tag:"span",classes:["tox-checkbox__label"]},components:[Ci(t.translate(e.label))],behaviours:ql([Wk.config({})])}),a=e=>zv("checked"===e?"selected":"unselected",{tag:"span",classes:["tox-icon","tox-checkbox-icon__"+e]},t.icons),i=Bf({dom:{tag:"div",classes:["tox-checkbox__icons"]},components:[a("checked"),a("unchecked")]});return fk.sketch({dom:{tag:"label",classes:["tox-checkbox"]},components:[r,i.asSpec(),s],fieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),gx()])})})(e,t.shared.providers,o))),colorinput:wD(((e,t,o)=>Kk(e,t.shared,t.colorinput,o))),colorpicker:wD(((e,t,o)=>nT(0,t.shared.providers,o))),dropzone:wD(((e,t,o)=>aT(e,t.shared.providers,o))),grid:wD(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-form__grid",`tox-form__grid--${e.columns}col`]},components:F(e.items,t.interpreter)}))(e,t.shared))),listbox:wD(((e,t,o)=>((e,t,o)=>{const n=t.shared.providers,r=o.bind((t=>XT(e.items,t))).orThunk((()=>oe(e.items).filter(GT))),s=e.label.map((e=>kk(e,n))),a=fk.parts.field({dom:{},factory:{sketch:o=>ZT({uid:o.uid,text:r.map((e=>e.text)),icon:D.none(),tooltip:e.label,role:D.none(),fetch:(o,n)=>{const r=YT(o,e.name,e.items,Xm.getValue(o));n(qT(r,oy.CLOSE_ON_EXECUTE,t,{isHorizontalMenu:!1,search:D.none()}))},onSetup:w(v),getApi:w({}),columns:1,presets:"normal",classes:[],dropdownBehaviours:[yk.config({}),QE(r.map((e=>e.value)),(e=>_t(e.element,KT)),((t,o)=>{XT(e.items,o).each((e=>{St(t.element,KT,e.value),Ws(t,zT,{text:e.text})}))}))]},"tox-listbox",t.shared)}}),i={dom:{tag:"div",classes:["tox-listboxfield"]},components:[a]};return fk.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([s.toArray(),[i]]),fieldBehaviours:ql([wg.config({disabled:w(!e.enabled),onDisabled:e=>{fk.getField(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable)}})])})})(e,t,o))),selectbox:wD(((e,t,o)=>((e,t,o)=>{const n=F(e.items,(e=>({text:t.translate(e.text),value:e.value}))),r=e.label.map((e=>kk(e,t))),s=fk.parts.field({dom:{},...o.map((e=>({data:e}))).getOr({}),selectAttributes:{size:e.size},options:n,factory:JT,selectBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),yk.config({}),Ip("selectbox-change",[Qs(ds(),((t,o)=>{Ws(t,_k,{name:e.name})}))])])}),a=e.size>1?D.none():D.some(zv("chevron-down",{tag:"div",classes:["tox-selectfield__icon-js"]},t.icons)),i={dom:{tag:"div",classes:["tox-selectfield"]},components:q([[s],a.toArray()])};return fk.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([r.toArray(),[i]]),fieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{fk.getField(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable)}}),gx()])})})(e,t.shared.providers,o))),sizeinput:wD(((e,t)=>((e,t)=>{let o=sO;const n=ya("ratio-event"),r=e=>zv(e,{tag:"span",classes:["tox-icon","tox-lock-icon__"+e]},t.icons),s=oO.parts.lock({dom:{tag:"button",classes:["tox-lock","tox-button","tox-button--naked","tox-button--icon"],attributes:{title:t.translate(e.label.getOr("Constrain proportions"))}},components:[r("lock"),r("unlock")],buttonBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),gx(),yk.config({})])}),a=e=>({dom:{tag:"div",classes:["tox-form__group"]},components:e}),i=o=>fk.parts.field({factory:_y,inputClasses:["tox-textfield"],inputBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled()}),gx(),yk.config({}),Ip("size-input-events",[Qs(ss(),((e,t)=>{Ws(e,n,{isField1:o})})),Qs(ds(),((t,o)=>{Ws(t,_k,{name:e.name})}))])]),selectOnFocus:!1}),l=e=>({dom:{tag:"label",classes:["tox-label"]},components:[Ci(t.translate(e))]}),c=oO.parts.field1(a([fk.parts.label(l("Width")),i(!0)])),d=oO.parts.field2(a([fk.parts.label(l("Height")),i(!1)]));return oO.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:[c,d,a([l(" "),s])]}],field1Name:"width",field2Name:"height",locked:!0,markers:{lockClass:"tox-locked"},onLockedChange:(e,t,n)=>{nO(Xm.getValue(e)).each((e=>{o(e).each((e=>{Xm.setValue(t,(e=>{const t={"":0,px:0,pt:1,mm:1,pc:2,ex:2,em:2,ch:2,rem:2,cm:3,in:4,"%":4};let o=e.value.toFixed((n=e.unit)in t?t[n]:1);var n;return-1!==o.indexOf(".")&&(o=o.replace(/\.?0*$/,"")),o+e.unit})(e))}))}))},coupledFieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{oO.getField1(e).bind(fk.getField).each(wg.disable),oO.getField2(e).bind(fk.getField).each(wg.disable),oO.getLock(e).each(wg.disable)},onEnabled:e=>{oO.getField1(e).bind(fk.getField).each(wg.enable),oO.getField2(e).bind(fk.getField).each(wg.enable),oO.getLock(e).each(wg.enable)}}),gx(),Ip("size-input-events2",[Qs(n,((e,t)=>{const n=t.event.isField1,r=n?oO.getField1(e):oO.getField2(e),s=n?oO.getField2(e):oO.getField1(e),a=r.map(Xm.getValue).getOr(""),i=s.map(Xm.getValue).getOr("");o=aO(a,i)}))])])})})(e,t.shared.providers))),slider:wD(((e,t,o)=>((e,t,o)=>{const n=NE.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[Ci(t.translate(e.label))]}),r=NE.parts.spectrum({dom:{tag:"div",classes:["tox-slider__rail"],attributes:{role:"presentation"}}}),s=NE.parts.thumb({dom:{tag:"div",classes:["tox-slider__handle"],attributes:{role:"presentation"}}});return NE.sketch({dom:{tag:"div",classes:["tox-slider"],attributes:{role:"presentation"}},model:{mode:"x",minX:e.min,maxX:e.max,getInitialValue:w(o.getOrThunk((()=>(Math.abs(e.max)-Math.abs(e.min))/2)))},components:[n,r,s],sliderBehaviours:ql([GE(),Zp.config({})]),onChoose:(t,o,n)=>{Ws(t,_k,{name:e.name,value:n})}})})(e,t.shared.providers,o))),urlinput:wD(((e,t,o)=>((e,t,o,n)=>{const r=t.shared.providers,s=t=>{const n=Xm.getValue(t);o.addToHistory(n.value,e.filetype)},a={...n.map((e=>({initialData:e}))).getOr({}),dismissOnBlur:!0,inputClasses:["tox-textfield"],sandboxClasses:["tox-dialog__popups"],inputAttributes:{"aria-errormessage":vD,type:"url"},minChars:0,responseTime:0,fetch:n=>{const r=fD(e.filetype,n,o),s=qT(r,oy.BUBBLE_TO_SANDBOX,t,{isHorizontalMenu:!1,search:D.none()});return xS(s)},getHotspot:e=>g.getOpt(e),onSetValue:(e,t)=>{e.hasConfigured(jk)&&jk.run(e).get(v)},typeaheadBehaviours:ql([...o.getValidationHandler().map((t=>jk.config({getRoot:e=>rt(e.element),invalidClass:"tox-control-wrap--status-invalid",notify:{onInvalid:(e,t)=>{c.getOpt(e).each((e=>{St(e.element,"title",r.translate(t))}))}},validator:{validate:o=>{const n=Xm.getValue(o);return JO((o=>{t({type:e.filetype,url:n.value},(e=>{if("invalid"===e.status){const t=on.error(e.message);o(t)}else{const t=on.value(e.message);o(t)}}))}))},validateOnLoad:!1}}))).toArray(),wg.config({disabled:()=>!e.enabled||r.isDisabled()}),yk.config({}),Ip("urlinput-events",[Qs(cs(),(t=>{const o=ci(t.element),n=o.trim();n!==o&&di(t.element,n),"file"===e.filetype&&Ws(t,_k,{name:e.name})})),Qs(ds(),(t=>{Ws(t,_k,{name:e.name}),s(t)})),Qs(ws(),(t=>{Ws(t,_k,{name:e.name}),s(t)}))])]),eventOrder:{[cs()]:["streaming","urlinput-events","invalidating"]},model:{getDisplayText:e=>e.value,selectsOver:!1,populateFromBrowse:!1},markers:{openClass:"tox-textfield--popup-open"},lazySink:t.shared.getSink,parts:{menu:wy(0,0,"normal")},onExecute:(e,t,o)=>{Ws(t,Dk,{})},onItemExecute:(t,o,n,r)=>{s(t),Ws(t,_k,{name:e.name})}},i=fk.parts.field({...a,factory:KO}),l=e.label.map((e=>kk(e,r))),c=Bf(((e,t,o=e,n=e)=>zv(o,{tag:"div",classes:["tox-icon","tox-control-wrap__status-icon-"+e],attributes:{title:r.translate(n),"aria-live":"polite",...t.fold((()=>({})),(e=>({id:e})))}},r.icons))("invalid",D.some(vD),"warning")),d=Bf({dom:{tag:"div",classes:["tox-control-wrap__status-icon-wrap"]},components:[c.asSpec()]}),m=o.getUrlPicker(e.filetype),u=ya("browser.url.event"),g=Bf({dom:{tag:"div",classes:["tox-control-wrap"]},components:[i,d.asSpec()],behaviours:ql([wg.config({disabled:()=>!e.enabled||r.isDisabled()})])}),h=Bf(nD({name:e.name,icon:D.some("browse"),text:e.picker_text.or(e.label).getOr(""),enabled:e.enabled,primary:!1,buttonType:D.none(),borderless:!0},(e=>js(e,u)),r,[],["tox-browse-url"]));return fk.sketch({dom:Sk([]),components:l.toArray().concat([{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:q([[g.asSpec()],m.map((()=>h.asSpec())).toArray()])}]),fieldBehaviours:ql([wg.config({disabled:()=>!e.enabled||r.isDisabled(),onDisabled:e=>{fk.getField(e).each(wg.disable),h.getOpt(e).each(wg.disable)},onEnabled:e=>{fk.getField(e).each(wg.enable),h.getOpt(e).each(wg.enable)}}),gx(),Ip("url-input-events",[Qs(u,(t=>{ag.getCurrent(t).each((o=>{const n=Xm.getValue(o),r={fieldname:e.name,...n};m.each((n=>{n(r).get((n=>{Xm.setValue(o,n),Ws(t,_k,{name:e.name})}))}))}))}))])])})})(e,t,t.urlinput,o))),customeditor:wD((e=>{const t=kc(),o=Bf({dom:{tag:e.tag}}),n=kc();return{dom:{tag:"div",classes:["tox-custom-editor"]},behaviours:ql([Ip("custom-editor-events",[ia((r=>{o.getOpt(r).each((o=>{((e=>be(e,"init"))(e)?e.init(o.element.dom):rT.load(e.scriptId,e.scriptUrl).then((t=>t(o.element.dom,e.settings)))).then((e=>{n.on((t=>{e.setValue(t)})),n.clear(),t.set(e)}))}))}))]),QE(D.none(),(()=>t.get().fold((()=>n.get().getOr("")),(e=>e.getValue()))),((e,o)=>{t.get().fold((()=>n.set(o)),(e=>e.setValue(o)))})),GE()]),components:[o.asSpec()]}})),htmlpanel:wD((e=>"presentation"===e.presets?uk.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html}}):uk.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html,attributes:{role:"document"}},containerBehaviours:ql([yk.config({}),Zp.config({})])}))),imagepreview:wD(((e,t,o)=>MT(e,o))),table:wD(((e,t)=>((e,t)=>{const o=e=>({dom:{tag:"th",innerHtml:t.translate(e)}}),n=e=>({dom:{tag:"td",innerHtml:t.translate(e)}}),r=e=>({dom:{tag:"tr"},components:F(e,n)});return{dom:{tag:"table",classes:["tox-dialog__table"]},components:[(a=e.header,{dom:{tag:"thead"},components:[{dom:{tag:"tr"},components:F(a,o)}]}),(s=e.cells,{dom:{tag:"tbody"},components:F(s,r)})],behaviours:ql([yk.config({}),Zp.config({})])};var s,a})(e,t.shared.providers))),tree:wD(((e,t)=>((e,t)=>{const o=e.onLeafAction.getOr(v),n=e.onToggleExpand.getOr(v),r=e.defaultExpandedIds,s=Hr(r),a=Hr(e.defaultSelectedId),i=ya("tree-id"),l=(n,r)=>e.items.map((e=>"leaf"===e.type?DO({leaf:e,selectedId:n,onLeafAction:o,visible:!0,treeId:i,backstage:t}):LO({directory:e,selectedId:n,onLeafAction:o,expandedIds:r,labelTabstopping:!0,treeId:i,backstage:t})));return{dom:{tag:"div",classes:["tox-tree"],attributes:{role:"tree"}},components:l(a.get(),s.get()),behaviours:ql([Tp.config({mode:"flow",selector:".tox-tree--leaf__label--visible, .tox-tree--directory__label--visible",cycles:!1}),Ip(HO,[Qs("expand-tree-node",((e,t)=>{const{expanded:o,node:r}=t.event;s.set(o?[...s.get(),r]:s.get().filter((e=>e!==r))),n(s.get(),{expanded:o,node:r})}))]),Ql.config({channels:{[`update-active-item-${i}`]:{onReceive:(e,t)=>{a.set(D.some(t.value)),Hp.set(e,l(D.some(t.value),s.get()))}}}}),Hp.config({})])}})(e,t))),panel:wD(((e,t)=>((e,t)=>({dom:{tag:"div",classes:e.classes},components:F(e.items,t.shared.interpreter)}))(e,t)))},CD={field:(e,t)=>t,record:w([])},SD=(e,t,o,n)=>{const r=xn(n,{shared:{interpreter:t=>kD(e,t,o,r)}});return kD(e,t,o,r)},kD=(e,t,o,n)=>ve(xD,t.type).fold((()=>(console.error(`Unknown factory type "${t.type}", defaulting to container: `,t),t)),(r=>r(e,t,o,n))),_D=(e,t,o)=>kD(CD,e,t,o),ED="layout-inset",TD=e=>e.x,OD=(e,t)=>e.x+e.width/2-t.width/2,DD=(e,t)=>e.x+e.width-t.width,AD=e=>e.y,MD=(e,t)=>e.y+e.height-t.height,ND=(e,t)=>e.y+e.height/2-t.height/2,RD=(e,t,o)=>il(DD(e,t),MD(e,t),o.insetSouthwest(),ul(),"southwest",yl(e,{right:0,bottom:3}),ED),BD=(e,t,o)=>il(TD(e),MD(e,t),o.insetSoutheast(),ml(),"southeast",yl(e,{left:1,bottom:3}),ED),LD=(e,t,o)=>il(DD(e,t),AD(e),o.insetNorthwest(),dl(),"northwest",yl(e,{right:0,top:2}),ED),HD=(e,t,o)=>il(TD(e),AD(e),o.insetNortheast(),cl(),"northeast",yl(e,{left:1,top:2}),ED),ID=(e,t,o)=>il(OD(e,t),AD(e),o.insetNorth(),gl(),"north",yl(e,{top:2}),ED),PD=(e,t,o)=>il(OD(e,t),MD(e,t),o.insetSouth(),hl(),"south",yl(e,{bottom:3}),ED),FD=(e,t,o)=>il(DD(e,t),ND(e,t),o.insetEast(),fl(),"east",yl(e,{right:0}),ED),zD=(e,t,o)=>il(TD(e),ND(e,t),o.insetWest(),pl(),"west",yl(e,{left:1}),ED),VD=e=>{switch(e){case"north":return ID;case"northeast":return HD;case"northwest":return LD;case"south":return PD;case"southeast":return BD;case"southwest":return RD;case"east":return FD;case"west":return zD}},ZD=(e,t,o,n,r)=>yc(n).map(VD).getOr(ID)(e,t,o,n,r),UD=e=>{switch(e){case"north":return PD;case"northeast":return BD;case"northwest":return RD;case"south":return ID;case"southeast":return HD;case"southwest":return LD;case"east":return zD;case"west":return FD}},jD=(e,t,o,n,r)=>yc(n).map(UD).getOr(ID)(e,t,o,n,r),WD={valignCentre:[],alignCentre:[],alignLeft:[],alignRight:[],right:[],left:[],bottom:[],top:[]},$D=(e,t,o)=>{const n={maxHeightFunction:Fc()};return()=>o()?{type:"node",root:pt(ht(e())),node:D.from(e()),bubble:Uc(12,12,WD),layouts:{onRtl:()=>[HD],onLtr:()=>[LD]},overrides:n}:{type:"hotspot",hotspot:t(),bubble:Uc(-12,12,WD),layouts:{onRtl:()=>[Tl,Ol,Nl],onLtr:()=>[Ol,Tl,Nl]},overrides:n}},qD=(e,t,o,n)=>{const r={maxHeightFunction:Fc()};return()=>n()?{type:"node",root:pt(ht(t())),node:D.from(t()),bubble:Uc(12,12,WD),layouts:{onRtl:()=>[ID],onLtr:()=>[ID]},overrides:r}:e?{type:"node",root:pt(ht(t())),node:D.from(t()),bubble:Uc(0,-jt(t()),WD),layouts:{onRtl:()=>[Ml],onLtr:()=>[Ml]},overrides:r}:{type:"hotspot",hotspot:o(),bubble:Uc(0,0,WD),layouts:{onRtl:()=>[Ml],onLtr:()=>[Ml]},overrides:r}},GD=(e,t,o)=>()=>o()?{type:"node",root:pt(ht(e())),node:D.from(e()),layouts:{onRtl:()=>[ID],onLtr:()=>[ID]}}:{type:"hotspot",hotspot:t(),layouts:{onRtl:()=>[Nl],onLtr:()=>[Nl]}},KD=(e,t)=>()=>({type:"selection",root:t(),getSelection:()=>{const t=e.selection.getRng(),o=e.model.table.getSelectedCells();if(o.length>1){const e=o[0],t=o[o.length-1],n={firstCell:Le.fromDom(e),lastCell:Le.fromDom(t)};return D.some(n)}return D.some(fd.range(Le.fromDom(t.startContainer),t.startOffset,Le.fromDom(t.endContainer),t.endOffset))}}),YD=e=>t=>({type:"node",root:e(),node:t}),XD=(e,t,o,n)=>{const r=Wb(e),s=()=>Le.fromDom(e.getBody()),a=()=>Le.fromDom(e.getContentAreaContainer()),i=()=>r||!n();return{inlineDialog:$D(a,t,i),inlineBottomDialog:qD(e.inline,a,o,i),banner:GD(a,t,i),cursor:KD(e,s),node:YD(s)}},JD=e=>(t,o)=>{GC(e)(t,o)},QD=e=>()=>RC(e),eA=e=>t=>DC(e,t),tA=e=>t=>NC(e,t),oA=e=>()=>_b(e),nA=e=>ye(e,"items"),rA=e=>ye(e,"format"),sA=[{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",format:"bold"},{title:"Italic",format:"italic"},{title:"Underline",format:"underline"},{title:"Strikethrough",format:"strikethrough"},{title:"Superscript",format:"superscript"},{title:"Subscript",format:"subscript"},{title:"Code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Align",items:[{title:"Left",format:"alignleft"},{title:"Center",format:"aligncenter"},{title:"Right",format:"alignright"},{title:"Justify",format:"alignjustify"}]}],aA=e=>j(e,((e,t)=>{if(be(t,"items")){const o=aA(t.items);return{customFormats:e.customFormats.concat(o.customFormats),formats:e.formats.concat([{title:t.title,items:o.formats}])}}if((e=>be(e,"inline"))(t)||(e=>be(e,"block"))(t)||(e=>be(e,"selector"))(t)){const o=`custom-${s(t.name)?t.name:t.title.toLowerCase()}`;return{customFormats:e.customFormats.concat([{name:o,format:t}]),formats:e.formats.concat([{title:t.title,format:o,icon:t.icon}])}}return{...e,formats:e.formats.concat(t)}}),{customFormats:[],formats:[]}),iA=e=>rb(e).map((t=>{const o=((e,t)=>{const o=aA(t),n=t=>{z(t,(t=>{e.formatter.has(t.name)||e.formatter.register(t.name,t.format)}))};return e.formatter?n(o.customFormats):e.on("init",(()=>{n(o.customFormats)})),o.formats})(e,t);return sb(e)?sA.concat(o):o})).getOr(sA),lA=(e,t,o)=>({...e,type:"formatter",isSelected:t(e.format),getStylePreview:o(e.format)}),cA=(e,t,o,n)=>{const r=t=>F(t,(t=>nA(t)?(e=>{const t=r(e.items);return{...e,type:"submenu",getStyleItems:w(t)}})(t):rA(t)?(e=>lA(e,o,n))(t):(e=>{const t=ae(e);return 1===t.length&&L(t,"title")})(t)?{...t,type:"separator"}:(t=>{const r=s(t.name)?t.name:ya(t.title),a=`custom-${r}`,i={...t,type:"formatter",format:a,isSelected:o(a),getStylePreview:n(a)};return e.formatter.register(r,i),i})(t)));return r(t)},dA=sT.trim,mA=e=>t=>{if((e=>g(e)&&1===e.nodeType)(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},uA=mA("true"),gA=mA("false"),hA=(e,t,o,n,r)=>({type:e,title:t,url:o,level:n,attach:r}),pA=e=>e.innerText||e.textContent,fA=e=>(e=>e&&"A"===e.nodeName&&void 0!==(e.id||e.name))(e)&&bA(e),vA=e=>e&&/^(H[1-6])$/.test(e.nodeName),bA=e=>(e=>{let t=e;for(;t=t.parentNode;){const e=t.contentEditable;if(e&&"inherit"!==e)return uA(t)}return!1})(e)&&!gA(e),yA=e=>vA(e)&&bA(e),wA=e=>{var t;const o=(e=>e.id?e.id:ya("h"))(e);return hA("header",null!==(t=pA(e))&&void 0!==t?t:"","#"+o,(e=>vA(e)?parseInt(e.nodeName.substr(1),10):0)(e),(()=>{e.id=o}))},xA=e=>{const t=e.id||e.name,o=pA(e);return hA("anchor",o||"#"+t,"#"+t,0,v)},CA=e=>{const t=(o="h1,h2,h3,h4,h5,h6,a:not([href])",n=e,F(_d(Le.fromDom(n),o),(e=>e.dom)));var o,n;return t},SA=e=>dA(e.title).length>0,kA=e=>{const t=CA(e);return Z((e=>F(Z(e,yA),wA))(t).concat((e=>F(Z(e,fA),xA))(t)),SA)},_A="tinymce-url-history",EA=e=>s(e)&&/^https?/.test(e),TA=e=>a(e)&&pe(e,(e=>{return!(l(t=e)&&t.length<=5&&K(t,EA));var t})).isNone(),OA=()=>{const e=fC.getItem(_A);if(null===e)return{};let t;try{t=JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return console.log("Local storage "+_A+" was not valid JSON",e),{};throw e}return TA(t)?t:(console.log("Local storage "+_A+" was not valid format",t),{})},DA=e=>{const t=OA();return ve(t,e).getOr([])},AA=(e,t)=>{if(!EA(e))return;const o=OA(),n=ve(o,t).getOr([]),r=Z(n,(t=>t!==e));o[t]=[e].concat(r).slice(0,5),(e=>{if(!TA(e))throw new Error("Bad format for history:\n"+JSON.stringify(e));fC.setItem(_A,JSON.stringify(e))})(o)},MA=e=>!!e,NA=e=>ce(sT.makeMap(e,/[, ]/),MA),RA=e=>D.from(bb(e)),BA=(e,t)=>{const o=(e=>{const t=D.from(xb(e)).filter(MA).map(NA);return RA(e).fold(T,(e=>t.fold(O,(e=>ae(e).length>0&&e))))})(e);return d(o)?o?RA(e):D.none():o[t]?RA(e):D.none()},LA=e=>D.from(e).filter(s).getOrUndefined(),HA=e=>({getHistory:DA,addToHistory:AA,getLinkInformation:()=>(e=>Cb(e)?D.some({targets:kA(e.getBody()),anchorTop:LA(Sb(e)),anchorBottom:LA(kb(e))}):D.none())(e),getValidationHandler:()=>(e=>D.from(yb(e)))(e),getUrlPicker:t=>((e,t)=>BA(e,t).map((o=>n=>wS((r=>{const i={filetype:t,fieldname:n.fieldname,...D.from(n.meta).getOr({})};o.call(e,((e,t)=>{if(!s(e))throw new Error("Expected value to be string");if(void 0!==t&&!a(t))throw new Error("Expected meta to be a object");r({value:e,meta:t})}),n.value,i)})))))(e,t)}),IA=(e,t,o,n)=>{const r=Hr(!1),s=(e=>{const t=Hr(Ub(e)?"bottom":"top");return{isPositionedAtTop:()=>"top"===t.get(),getDockingMode:t.get,setDockingMode:t.set}})(t),a={icons:()=>t.ui.registry.getAll().icons,menuItems:()=>t.ui.registry.getAll().menuItems,translate:Mv.translate,isDisabled:()=>t.mode.isReadOnly()||!t.ui.isEnabled(),getOption:t.options.get},i=HA(t),l=(e=>{const t=t=>()=>e.formatter.match(t),o=t=>()=>{const o=e.formatter.get(t);return void 0!==o?D.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):D.none()},n=Hr([]),r=Hr([]),s=Hr(!1);return e.on("PreInit",(r=>{const s=iA(e),a=cA(e,s,t,o);n.set(a)})),e.on("addStyleModifications",(n=>{const a=cA(e,n.items,t,o);r.set(a),s.set(n.replace)})),{getData:()=>{const e=s.get()?[]:n.get(),t=r.get();return e.concat(t)}}})(t),c=(e=>({colorPicker:JD(e),hasCustomColors:QD(e),getColors:eA(e),getColorCols:tA(e)}))(t),d=(e=>({isDraggableModal:oA(e)}))(t),m={shared:{providers:a,anchors:XD(t,o,n,s.isPositionedAtTop),header:s},urlinput:i,styles:l,colorinput:c,dialog:d,isContextMenuOpen:()=>r.get(),setContextMenuState:e=>r.set(e)},u={...m,shared:{...m.shared,interpreter:e=>_D(e,{},u),getSink:e.popup}},g={...m,shared:{...m.shared,interpreter:e=>_D(e,{},g),getSink:e.dialog}};return{popup:u,dialog:g}},PA=Ku,FA=Nu,zA=w([Tr("shell",!1),dr("makeItem"),Tr("setupItem",v),tu("listBehaviours",[Hp])]),VA=Du({name:"items",overrides:()=>({behaviours:ql([Hp.config({})])})}),ZA=w([VA]),UA=og({name:w("CustomList")(),configFields:zA(),partFields:ZA(),factory:(e,t,o,n)=>{const r=e.shell?{behaviours:[Hp.config({})],components:[]}:{behaviours:[],components:t},s=t=>e.shell?D.some(t):Vu(t,e,"items");return{uid:e.uid,dom:e.dom,components:r.components,behaviours:eu(e.listBehaviours,r.behaviours),apis:{setItems:(t,o)=>{s(t).fold((()=>{throw console.error("Custom List was defined to not be a shell, but no item container was specified in components"),new Error("Custom List was defined to not be a shell, but no item container was specified in components")}),(n=>{const r=Hp.contents(n),s=o.length,a=s-r.length,i=a>0?I(a,(()=>e.makeItem())):[],l=r.slice(s);z(l,(e=>Hp.remove(n,e))),z(i,(e=>Hp.append(n,e)));const c=Hp.contents(n);z(c,((n,r)=>{e.setupItem(t,n,o[r],r)}))}))}}}},apis:{setItems:(e,t,o)=>{e.setItems(t,o)}}}),jA=w([dr("dom"),Tr("shell",!0),Jm("toolbarBehaviours",[Hp])]),WA=w([Du({name:"groups",overrides:()=>({behaviours:ql([Hp.config({})])})})]),$A=og({name:"Toolbar",configFields:jA(),partFields:WA(),factory:(e,t,o,n)=>{const r=t=>e.shell?D.some(t):Vu(t,e,"groups"),s=e.shell?{behaviours:[Hp.config({})],components:[]}:{behaviours:[],components:t};return{uid:e.uid,dom:e.dom,components:s.components,behaviours:eu(e.toolbarBehaviours,s.behaviours),apis:{setGroups:(e,t)=>{r(e).fold((()=>{throw console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")}),(e=>{Hp.set(e,t)}))},refresh:v},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)}}}),qA=v,GA=T,KA=w([]);var YA=Object.freeze({__proto__:null,setup:qA,isDocked:GA,getBehaviours:KA});const XA=e=>(we(Ht(e,"position"),"fixed")?D.none():st(e)).orThunk((()=>{const t=Le.fromTag("span");return nt(e).bind((e=>{Ho(e,t);const o=st(t);return Fo(t),o}))})),JA=e=>XA(e).map(Gt).getOrThunk((()=>$t(0,0))),QA=(e,t)=>{const o=e.element;ti(o,t.transitionClass),ni(o,t.fadeOutClass),ti(o,t.fadeInClass),t.onShow(e)},eM=(e,t)=>{const o=e.element;ti(o,t.transitionClass),ni(o,t.fadeInClass),ti(o,t.fadeOutClass),t.onHide(e)},tM=(e,t)=>e.y>=t.y,oM=(e,t)=>e.bottom<=t.bottom,nM=(e,t,o)=>({location:"top",leftX:t,topY:o.bounds.y-e.y}),rM=(e,t,o)=>({location:"bottom",leftX:t,bottomY:e.bottom-o.bounds.bottom}),sM=e=>e.box.x-e.win.x,aM=(e,t,o)=>o.getInitialPos().map((o=>{const n=((e,t)=>{const o=t.optScrollEnv.fold(w(e.bounds.y),(t=>t.scrollElmTop+(e.bounds.y-t.currentScrollTop)));return $t(e.bounds.x,o)})(o,t);return{box:Go(n.left,n.top,Xt(e),Ut(e)),location:o.location}})),iM=(e,t,o,n,r)=>{const s=((e,t)=>{const o=t.optScrollEnv.fold(w(e.y),(t=>e.y+t.currentScrollTop-t.scrollElmTop));return $t(e.x,o)})(t,o),a=Go(s.left,s.top,t.width,t.height);n.setInitialPos({style:It(e),position:Bt(e,"position")||"static",bounds:a,location:r.location})},lM=(e,t,o)=>o.getInitialPos().bind((n=>{var r;switch(o.clearInitialPos(),n.position){case"static":return D.some({morph:"static"});case"absolute":const o=XA(e).getOr(wt()),s=Ko(o),a=null!==(r=o.dom.scrollTop)&&void 0!==r?r:0;return D.some({morph:"absolute",positionCss:ic("absolute",ve(n.style,"left").map((e=>t.x-s.x)),ve(n.style,"top").map((e=>t.y-s.y+a)),ve(n.style,"right").map((e=>s.right-t.right)),ve(n.style,"bottom").map((e=>s.bottom-t.bottom)))});default:return D.none()}})),cM=(e,t,o)=>aM(e,t,o).filter((({box:e})=>((e,t,o)=>K(e,(e=>{switch(e){case"bottom":return oM(t,o.bounds);case"top":return tM(t,o.bounds)}})))(o.getModes(),e,t))).bind((({box:t})=>lM(e,t,o))),dM=e=>{switch(e.location){case"top":return D.some({morph:"fixed",positionCss:ic("fixed",D.some(e.leftX),D.some(e.topY),D.none(),D.none())});case"bottom":return D.some({morph:"fixed",positionCss:ic("fixed",D.some(e.leftX),D.none(),D.none(),D.some(e.bottomY))});default:return D.none()}},mM=(e,t,o)=>{const n=Ko(e),r=Jo(),s=((e,t,o)=>{const n=t.win,r=t.box,s=sM(t);return se(e,(e=>{switch(e){case"bottom":return oM(r,o.bounds)?D.none():D.some(rM(n,s,o));case"top":return tM(r,o.bounds)?D.none():D.some(nM(n,s,o));default:return D.none()}})).getOr({location:"no-dock"})})(o.getModes(),{win:r,box:n},t);return"top"===s.location||"bottom"===s.location?(iM(e,n,t,o,s),dM(s)):D.none()},uM=(e,t,o)=>{const n=e.element;return we(Ht(n,"position"),"fixed")?((e,t,o)=>cM(e,t,o).orThunk((()=>t.optScrollEnv.bind((n=>aM(e,t,o))).bind((({box:e,location:o})=>{const n=Jo(),r=sM({win:n,box:e}),s="top"===o?nM(n,r,t):rM(n,r,t);return dM(s)})))))(n,t,o):mM(n,t,o)},gM=(e,t,o,n)=>{const r=Ko(e),s=Jo(),a=n(s,sM({win:s,box:r}),t);return"bottom"===a.location||"top"===a.location?(((e,t,o,n,r)=>{n.getInitialPos().fold((()=>iM(e,t,o,n,r)),(()=>v))})(e,r,t,o,a),dM(a)):D.none()},hM=(e,t,o)=>{o.setDocked(!1),z(["left","right","top","bottom","position"],(t=>Ft(e.element,t))),t.onUndocked(e)},pM=(e,t,o,n)=>{const r="fixed"===n.position;o.setDocked(r),lc(e.element,n);(r?t.onDocked:t.onUndocked)(e)},fM=(e,t,o,n,r=!1)=>{t.contextual.each((t=>{t.lazyContext(e).each((s=>{const a=((e,t)=>e.yt.y)(s,n.bounds);if(a!==o.isVisible())if(o.setVisible(a),r&&!a)ai(e.element,[t.fadeOutClass]),t.onHide(e);else{(a?QA:eM)(e,t)}}))}))},vM=(e,t,o,n,r)=>{fM(e,t,o,n,!0),pM(e,t,o,r.positionCss)},bM=(e,t,o)=>{const n=t.lazyViewport(e);fM(e,t,o,n),uM(e,n,o).each((r=>{((e,t,o,n,r)=>{switch(r.morph){case"static":return hM(e,t,o);case"absolute":return pM(e,t,o,r.positionCss);case"fixed":vM(e,t,o,n,r)}})(e,t,o,n,r)}))},yM=(e,t,o)=>{const n=e.element;o.setDocked(!1);const r=t.lazyViewport(e);((e,t,o)=>{const n=e.element;return aM(n,t,o).bind((({box:e})=>lM(n,e,o)))})(e,r,o).each((n=>{switch(n.morph){case"static":hM(e,t,o);break;case"absolute":pM(e,t,o,n.positionCss)}})),o.setVisible(!0),t.contextual.each((t=>{ii(n,[t.fadeInClass,t.fadeOutClass,t.transitionClass]),t.onShow(e)})),wM(e,t,o)},wM=(e,t,o)=>{e.getSystem().isConnected()&&bM(e,t,o)},xM=(e,t,o)=>{o.isDocked()&&yM(e,t,o)},CM=e=>(t,o,n)=>{const r=o.lazyViewport(t);gM(t.element,r,n,e).each((e=>{vM(t,o,n,r,e)}))},SM=CM(nM),kM=CM(rM);var _M=Object.freeze({__proto__:null,refresh:wM,reset:xM,isDocked:(e,t,o)=>o.isDocked(),getModes:(e,t,o)=>o.getModes(),setModes:(e,t,o,n)=>o.setModes(n),forceDockToTop:SM,forceDockToBottom:kM});var EM=Object.freeze({__proto__:null,events:(e,t)=>Ys([aa(gs(),((o,n)=>{e.contextual.each((e=>{if(si(o.element,e.transitionClass)){ii(o.element,[e.transitionClass,e.fadeInClass]);(t.isVisible()?e.onShown:e.onHidden)(o)}n.stop()}))})),Qs(Ms(),((o,n)=>{wM(o,e,t)})),Qs(Fs(),((o,n)=>{wM(o,e,t)})),Qs(Ns(),((o,n)=>{xM(o,e,t)}))])}),TM=[Er("contextual",[gr("fadeInClass"),gr("fadeOutClass"),gr("transitionClass"),pr("lazyContext"),el("onShow"),el("onShown"),el("onHide"),el("onHidden")]),Rr("lazyViewport",(()=>({bounds:Jo(),optScrollEnv:D.none()}))),Br("modes",["top","bottom"],$n),el("onDocked"),el("onUndocked")];const OM=Kl({fields:TM,name:"docking",active:EM,apis:_M,state:Object.freeze({__proto__:null,init:e=>{const t=Hr(!1),o=Hr(!0),n=kc(),r=Hr(e.modes);return Ia({isDocked:t.get,setDocked:t.set,getInitialPos:n.get,setInitialPos:n.set,clearInitialPos:n.clear,isVisible:o.get,setVisible:o.set,getModes:r.get,setModes:r.set,readState:()=>`docked: ${t.get()}, visible: ${o.get()}, modes: ${r.get().join(",")}`})}})}),DM=w(ya("toolbar-height-change")),AM={fadeInClass:"tox-editor-dock-fadein",fadeOutClass:"tox-editor-dock-fadeout",transitionClass:"tox-editor-dock-transition"},MM="tox-tinymce--toolbar-sticky-on",NM="tox-tinymce--toolbar-sticky-off",RM=(e,t)=>L(OM.getModes(e),t),BM=e=>{const t=e.element;rt(t).each((o=>{const n="padding-"+OM.getModes(e)[0];if(OM.isDocked(e)){const e=Xt(o);Mt(t,"width",e+"px"),Mt(o,n,(e=>jt(e)+(parseInt(Bt(e,"margin-top"),10)||0)+(parseInt(Bt(e,"margin-bottom"),10)||0))(t)+"px")}else Ft(t,"width"),Ft(o,n)}))},LM=(e,t)=>{t?(ni(e,AM.fadeOutClass),ai(e,[AM.transitionClass,AM.fadeInClass])):(ni(e,AM.fadeInClass),ai(e,[AM.fadeOutClass,AM.transitionClass]))},HM=(e,t)=>{const o=Le.fromDom(e.getContainer());t?(ti(o,MM),ni(o,NM)):(ti(o,NM),ni(o,MM))},IM=(e,t)=>{const o=kc(),n=t.getSink,r=e=>{n().each((t=>e(t.element)))},s=t=>{e.inline||BM(t),HM(e,OM.isDocked(t)),t.getSystem().broadcastOn([Rm()],{}),n().each((e=>e.getSystem().broadcastOn([Rm()],{})))},a=e.inline?[]:[Ql.config({channels:{[DM()]:{onReceive:BM}}})];return[Zp.config({}),OM.config({contextual:{lazyContext:t=>{const o=jt(t.element),n=e.inline?e.getContentAreaContainer():e.getContainer();return D.from(n).map((n=>{const r=Ko(Le.fromDom(n));return XS(e,t.element).fold((()=>{const e=r.height-o,n=r.y+(RM(t,"top")?0:o);return Go(r.x,n,r.width,e)}),(e=>{const n=Xo(r,JS(e)),s=RM(t,"top")?n.y:n.y+o;return Go(n.x,s,n.width,n.height-o)}))}))},onShow:()=>{r((e=>LM(e,!0)))},onShown:e=>{r((e=>ii(e,[AM.transitionClass,AM.fadeInClass]))),o.get().each((t=>{((e,t)=>{const o=Qe(t);rc(o).filter((e=>!Xe(t,e))).filter((t=>Xe(t,Le.fromDom(o.dom.body))||Je(e,t))).each((()=>tc(t)))})(e.element,t),o.clear()}))},onHide:e=>{((e,t)=>sc(e).orThunk((()=>t().toOptional().bind((e=>sc(e.element))))))(e.element,n).fold(o.clear,o.set),r((e=>LM(e,!1)))},onHidden:()=>{r((e=>ii(e,[AM.transitionClass])))},...AM},lazyViewport:t=>XS(e,t.element).fold((()=>{const o=Jo(),n=pb(e),r=o.y+(RM(t,"top")?n:0),s=o.height-(RM(t,"bottom")?n:0);return{bounds:Go(o.x,r,o.width,s),optScrollEnv:D.none()}}),(e=>({bounds:JS(e),optScrollEnv:D.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))),modes:[t.header.getDockingMode()],onDocked:s,onUndocked:s}),...a]};var PM=Object.freeze({__proto__:null,setup:(e,t,o)=>{e.inline||(t.header.isPositionedAtTop()||e.on("ResizeEditor",(()=>{o().each(OM.reset)})),e.on("ResizeWindow ResizeEditor",(()=>{o().each(BM)})),e.on("SkinLoaded",(()=>{o().each((e=>{OM.isDocked(e)?OM.reset(e):OM.refresh(e)}))})),e.on("FullscreenStateChanged",(()=>{o().each(OM.reset)}))),e.on("AfterScrollIntoView",(e=>{o().each((t=>{OM.refresh(t);const o=t.element;wh(o)&&((e,t)=>{const o=Qe(t),n=ot(t).dom.innerHeight,r=zo(o),s=Le.fromDom(e.elm),a=Yo(s),i=Ut(s),l=a.y,c=l+i,d=Gt(t),m=Ut(t),u=d.top,g=u+m,h=Math.abs(u-r.top)<2,p=Math.abs(g-(r.top+n))<2;if(h&&lu){const e=l-n+i+m;Vo(r.left,e,o)}})(e,o)}))})),e.on("PostRender",(()=>{HM(e,!1)}))},isDocked:e=>e().map(OM.isDocked).getOr(!1),getBehaviours:IM});const FM=Pn([Uy,mr("items",zn([Zn([jy,br("items",$n)]),$n]))].concat(yw)),zM=[Cr("text"),Cr("tooltip"),Cr("icon"),Or("search",!1,zn([qn,Pn([Cr("placeholder")])],(e=>d(e)?e?D.some({placeholder:D.none()}):D.none():D.some(e)))),pr("fetch"),Rr("onSetup",(()=>v))],VM=Pn([Uy,...zM]),ZM=e=>tr("menubutton",VM,e),UM=Pn([Uy,rw,nw,ow,iw,Yy,ew,Mr("presets","normal",["normal","color","listpreview"]),uw(1),Jy,Qy]);var jM=tg({factory:(e,t)=>{const o={focus:Tp.focusIn,setMenus:(e,o)=>{const n=F(o,(e=>{const o={type:"menubutton",text:e.text,fetch:t=>{t(e.getItems())}},n=ZM(o).mapError((e=>rr(e))).getOrDie();return _O(n,"tox-mbtn",t.backstage,D.some("menuitem"))}));Hp.set(e,n)}};return{uid:e.uid,dom:e.dom,components:[],behaviours:ql([Hp.config({}),Ip("menubar-events",[ia((t=>{e.onSetup(t)})),Qs(rs(),((e,t)=>{Bi(e.element,".tox-mbtn--active").each((o=>{Li(t.event.target,".tox-mbtn").each((t=>{Xe(o,t)||e.getSystem().getByDom(o).each((o=>{e.getSystem().getByDom(t).each((e=>{HS.expand(e),HS.close(o),Zp.focus(e)}))}))}))}))})),Qs(Is(),((e,t)=>{t.event.prevFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((o=>{t.event.newFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((e=>{HS.isOpen(o)&&(HS.expand(e),HS.close(o))}))}))}))]),Tp.config({mode:"flow",selector:".tox-mbtn",onEscape:t=>(e.onEscape(t),D.some(!0))}),yk.config({})]),apis:o,domModification:{attributes:{role:"menubar"}}}},name:"silver.Menubar",configFields:[dr("dom"),dr("uid"),dr("onEscape"),dr("backstage"),Tr("onSetup",v)],apis:{focus:(e,t)=>{e.focus(t)},setMenus:(e,t,o)=>{e.setMenus(t,o)}}});const WM="container",$M=[Jm("slotBehaviours",[])],qM=e=>"",GM=(e,t)=>{const o=t=>Wu(e),n=(t,o)=>(n,r)=>Vu(n,e,r).map((e=>t(e,r))).getOr(o),r=(e,t)=>"true"!==_t(e.element,"aria-hidden"),s=n(r,!1),a=n(((e,t)=>{if(r(e)){const o=e.element;Mt(o,"display","none"),St(o,"aria-hidden","true"),Ws(e,Ps(),{name:t,visible:!1})}})),i=(e=>(t,o)=>{z(o,(o=>e(t,o)))})(a),l=n(((e,t)=>{if(!r(e)){const o=e.element;Ft(o,"display"),Ot(o,"aria-hidden"),Ws(e,Ps(),{name:t,visible:!0})}})),c={getSlotNames:o,getSlot:(t,o)=>Vu(t,e,o),isShowing:s,hideSlot:a,hideAllSlots:e=>i(e,o()),showSlot:l};return{uid:e.uid,dom:e.dom,components:t,behaviours:Qm(e.slotBehaviours),apis:c}},KM=ce({getSlotNames:(e,t)=>e.getSlotNames(t),getSlot:(e,t,o)=>e.getSlot(t,o),isShowing:(e,t,o)=>e.isShowing(t,o),hideSlot:(e,t,o)=>e.hideSlot(t,o),hideAllSlots:(e,t)=>e.hideAllSlots(t),showSlot:(e,t,o)=>e.showSlot(t,o)},(e=>La(e))),YM={...KM,sketch:e=>{const t=(()=>{const e=[];return{slot:(t,o)=>(e.push(t),Hu(WM,qM(t),o)),record:w(e)}})(),o=e(t),n=t.record(),r=F(n,(e=>Tu({name:e,pname:qM(e)})));return Xu(WM,$M,r,GM,o)}},XM=Pn([nw,rw,Rr("onShow",v),Rr("onHide",v),ew]),JM=e=>({element:()=>e.element.dom}),QM=(e,t)=>{const o=F(ae(t),(e=>{const o=t[e],n=or((e=>tr("sidebar",XM,e))(o));return{name:e,getApi:JM,onSetup:n.onSetup,onShow:n.onShow,onHide:n.onHide}}));return F(o,(t=>{const n=Hr(v);return e.slot(t.name,{dom:{tag:"div",classes:["tox-sidebar__pane"]},behaviours:Jw([yx(t,n),wx(t,n),Qs(Ps(),((e,t)=>{const n=t.event,r=W(o,(e=>e.name===n.name));r.each((t=>{(n.visible?t.onShow:t.onHide)(t.getApi(e))}))}))])})}))},eN=e=>YM.sketch((t=>({dom:{tag:"div",classes:["tox-sidebar__pane-container"]},components:QM(t,e),slotBehaviours:Jw([ia((e=>YM.hideAllSlots(e)))])}))),tN=(e,t)=>{St(e,"role",t)},oN=e=>ag.getCurrent(e).bind((e=>{if(SO.isGrowing(e)||SO.hasGrown(e)){return ag.getCurrent(e).bind((e=>W(YM.getSlotNames(e),(t=>YM.isShowing(e,t)))))}return D.none()})),nN=ya("FixSizeEvent"),rN=ya("AutoSizeEvent");var sN=Object.freeze({__proto__:null,block:(e,t,o,n)=>{St(e.element,"aria-busy",!0);const r=t.getRoot(e).getOr(e),s=ql([Tp.config({mode:"special",onTab:()=>D.some(!0),onShiftTab:()=>D.some(!0)}),Zp.config({})]),a=n(r,s),i=r.getSystem().build(a);Hp.append(r,Ti(i)),i.hasConfigured(Tp)&&t.focus&&Tp.focusIn(i),o.isBlocked()||t.onBlock(e),o.blockWith((()=>Hp.remove(r,i)))},unblock:(e,t,o)=>{Ot(e.element,"aria-busy"),o.isBlocked()&&t.onUnblock(e),o.clear()},isBlocked:(e,t,o)=>o.isBlocked()}),aN=[Rr("getRoot",D.none),Nr("focus",!0),el("onBlock"),el("onUnblock")];const iN=Kl({fields:aN,name:"blocking",apis:sN,state:Object.freeze({__proto__:null,init:()=>{const e=Cc((e=>e.destroy()));return Ia({readState:e.isSet,blockWith:t=>{e.set({destroy:t})},clear:e.clear,isBlocked:e.isSet})}})}),lN=e=>ag.getCurrent(e).each((e=>tc(e.element,!0))),cN=(e,t,o,n)=>{const r=t.element;if(((e,t)=>{const o="tabindex",n=`data-mce-${o}`;D.from(e.iframeElement).map(Le.fromDom).each((e=>{t?(Et(e,o).each((t=>St(e,n,t))),St(e,o,-1)):(Ot(e,o),Et(e,n).each((t=>{St(e,o,t),Ot(e,n)})))}))})(e,o),o)iN.block(t,(e=>(t,o)=>({dom:{tag:"div",attributes:{"aria-label":e.translate("Loading..."),tabindex:"0"},classes:["tox-throbber__busy-spinner"]},components:[{dom:Rf('
    ')}]}))(n)),Ft(r,"display"),Ot(r,"aria-hidden"),e.hasFocus()&&lN(t);else{const o=ag.getCurrent(t).exists((e=>nc(e.element)));iN.unblock(t),Mt(r,"display","none"),St(r,"aria-hidden","true"),o&&e.focus()}},dN=(e,t,o)=>{const n=Hr(!1),r=kc(),s=o=>{n.get()&&!(e=>{if((e=>"focusin"===e.type)(e))return(e.composed?oe(e.composedPath()):D.from(e.target)).map(Le.fromDom).filter(je).exists((e=>si(e,"mce-pastebin")));return!1})(o)&&(o.preventDefault(),lN(t()),e.editorManager.setActive(e))};e.inline||e.on("PreInit",(()=>{e.dom.bind(e.getWin(),"focusin",s),e.on("BeforeExecCommand",(e=>{"mcefocus"===e.command.toLowerCase()&&!0!==e.value&&s(e)}))}));const a=r=>{r!==n.get()&&(n.set(r),cN(e,t(),r,o.providers),((e,t)=>{e.dispatch("AfterProgressState",{state:t})})(e,r))};e.on("ProgressState",(t=>{if(r.on(clearTimeout),p(t.time)){const o=Mf.setEditorTimeout(e,(()=>a(t.state)),t.time);r.set(o)}else a(t.state),r.clear()}))},mN=(e,t,o)=>({within:e,extra:t,withinWidth:o}),uN=(e,t,o)=>{const n=((e,t)=>{const o=j(e,((e,o)=>t(o,e.len).fold(w(e),(t=>({len:t.finish,list:e.list.concat([t])})))),{len:0,list:[]});return o.list})(e,((e,t)=>{const n=o(e);return D.some({element:e,start:t,finish:t+n,width:n})})),r=Z(n,(e=>e.finish<=t)),s=U(r,((e,t)=>e+t.width),0);return{within:r,extra:n.slice(r.length),withinWidth:s}},gN=e=>F(e,(e=>e.element)),hN=(e,t,o,n)=>{const r=((e,t,o)=>{const n=uN(t,e,o);return 0===n.extra.length?D.some(n):D.none()})(e,t,o).getOrThunk((()=>uN(t,e-o(n),o))),s=r.within,a=r.extra,i=r.withinWidth;return 1===a.length&&a[0].width<=o(n)?((e,t,o)=>{const n=gN(e.concat(t));return mN(n,[],o)})(s,a,i):a.length>=1?((e,t,o,n)=>{const r=gN(e).concat([o]);return mN(r,gN(t),n)})(s,a,n,i):((e,t,o)=>mN(gN(e),[],o))(s,0,i)},pN=(e,t)=>{const o=F(t,(e=>Ti(e)));$A.setGroups(e,o)},fN=(e,t,o)=>{const n=t.builtGroups.get();if(0===n.length)return;const r=Zu(e,t,"primary"),s=pS.getCoupled(e,"overflowGroup");Mt(r.element,"visibility","hidden");const a=n.concat([s]),i=se(a,(e=>sc(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()))));o([]),pN(r,a);const l=Xt(r.element),c=hN(l,t.builtGroups.get(),(e=>Xt(e.element)),s);0===c.extra.length?(Hp.remove(r,s),o([])):(pN(r,c.within),o(c.extra)),Ft(r.element,"visibility"),zt(r.element),i.each(Zp.focus)},vN=w([Jm("splitToolbarBehaviours",[pS]),lr("builtGroups",(()=>Hr([])))]),bN=w([Ji(["overflowToggledClass"]),kr("getOverflowBounds"),dr("lazySink"),lr("overflowGroups",(()=>Hr([]))),el("onOpened"),el("onClosed")].concat(vN())),yN=w([Tu({factory:$A,schema:jA(),name:"primary"}),Ou({schema:jA(),name:"overflow"}),Ou({name:"overflow-button"}),Ou({name:"overflow-group"})]),wN=w(((e,t)=>{((e,t)=>{const o=Yt.max(e,t,["margin-left","border-left-width","padding-left","padding-right","border-right-width","margin-right"]);Mt(e,"max-width",o+"px")})(e,Math.floor(t))})),xN=w([Ji(["toggledClass"]),dr("lazySink"),pr("fetch"),kr("getBounds"),Er("fireDismissalEventInstead",[Tr("event",Ls())]),Xc(),el("onToggled")]),CN=w([Ou({name:"button",overrides:e=>({dom:{attributes:{"aria-haspopup":"true"}},buttonBehaviours:ql([Yp.config({toggleClass:e.markers.toggledClass,aria:{mode:"expanded"},toggleOnExecute:!1,onToggled:e.onToggled})])})}),Ou({factory:$A,schema:jA(),name:"toolbar",overrides:e=>({toolbarBehaviours:ql([Tp.config({mode:"cyclic",onEscape:t=>(Vu(t,e,"button").each(Zp.focus),D.none())})])})})]),SN=kc(),kN=(e,t)=>{const o=pS.getCoupled(e,"toolbarSandbox");Mm.isOpen(o)?Mm.close(o):Mm.open(o,t.toolbar())},_N=(e,t,o,n)=>{const r=o.getBounds.map((e=>e())),s=o.lazySink(e).getOrDie();rm.positionWithinBounds(s,t,{anchor:{type:"hotspot",hotspot:e,layouts:n,overrides:{maxWidthFunction:wN()}}},r)},EN=(e,t,o,n,r)=>{$A.setGroups(t,r),_N(e,t,o,n),Yp.on(e)},TN=og({name:"FloatingToolbarButton",factory:(e,t,o,n)=>({...Nf.sketch({...n.button(),action:e=>{kN(e,n)},buttonBehaviours:ou({dump:n.button().buttonBehaviours},[pS.config({others:{toolbarSandbox:t=>((e,t,o)=>{const n=Ii();return{dom:{tag:"div",attributes:{id:n.id}},behaviours:ql([Tp.config({mode:"special",onEscape:e=>(Mm.close(e),D.some(!0))}),Mm.config({onOpen:(r,s)=>{const a=SN.get().getOr(!1);o.fetch().get((r=>{EN(e,s,o,t.layouts,r),n.link(e.element),a||Tp.focusIn(s)}))},onClose:()=>{Yp.off(e),SN.get().getOr(!1)||Zp.focus(e),n.unlink(e.element)},isPartOf:(t,o,n)=>Fi(o,n)||Fi(e,n),getAttachPoint:()=>o.lazySink(e).getOrDie()}),Ql.config({channels:{...Hm({isExtraPart:T,...o.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Pm({doReposition:()=>{Mm.getState(pS.getCoupled(e,"toolbarSandbox")).each((n=>{_N(e,n,o,t.layouts)}))}})}})])}})(t,o,e)}})])}),apis:{setGroups:(t,n)=>{Mm.getState(pS.getCoupled(t,"toolbarSandbox")).each((r=>{EN(t,r,e,o.layouts,n)}))},reposition:t=>{Mm.getState(pS.getCoupled(t,"toolbarSandbox")).each((n=>{_N(t,n,e,o.layouts)}))},toggle:e=>{kN(e,n)},toggleWithoutFocusing:e=>{((e,t)=>{SN.set(!0),kN(e,t),SN.clear()})(e,n)},getToolbar:e=>Mm.getState(pS.getCoupled(e,"toolbarSandbox")),isOpen:e=>Mm.isOpen(pS.getCoupled(e,"toolbarSandbox"))}}),configFields:xN(),partFields:CN(),apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},toggleWithoutFocusing:(e,t)=>{e.toggleWithoutFocusing(t)},getToolbar:(e,t)=>e.getToolbar(t),isOpen:(e,t)=>e.isOpen(t)}}),ON=w([dr("items"),Ji(["itemSelector"]),Jm("tgroupBehaviours",[Tp])]),DN=w([Au({name:"items",unit:"item"})]),AN=og({name:"ToolbarGroup",configFields:ON(),partFields:DN(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.tgroupBehaviours,[Tp.config({mode:"flow",selector:e.markers.itemSelector})]),domModification:{attributes:{role:"toolbar"}}})}),MN=e=>F(e,(e=>Ti(e))),NN=(e,t,o)=>{fN(e,o,(n=>{o.overflowGroups.set(n),t.getOpt(e).each((e=>{TN.setGroups(e,MN(n))}))}))},RN=og({name:"SplitFloatingToolbar",configFields:bN(),partFields:yN(),factory:(e,t,o,n)=>{const r=Bf(TN.sketch({fetch:()=>wS((t=>{t(MN(e.overflowGroups.get()))})),layouts:{onLtr:()=>[Ol,Tl],onRtl:()=>[Tl,Ol],onBottomLtr:()=>[Al,Dl],onBottomRtl:()=>[Dl,Al]},getBounds:o.getOverflowBounds,lazySink:e.lazySink,fireDismissalEventInstead:{},markers:{toggledClass:e.markers.overflowToggledClass},parts:{button:n["overflow-button"](),toolbar:n.overflow()},onToggled:(t,o)=>e[o?"onOpened":"onClosed"](t)}));return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.splitToolbarBehaviours,[pS.config({others:{overflowGroup:()=>AN.sketch({...n["overflow-group"](),items:[r.asSpec()]})}})]),apis:{setGroups:(t,o)=>{e.builtGroups.set(F(o,t.getSystem().build)),NN(t,r,e)},refresh:t=>NN(t,r,e),toggle:e=>{r.getOpt(e).each((e=>{TN.toggle(e)}))},toggleWithoutFocusing:e=>{r.getOpt(e).each(TN.toggleWithoutFocusing)},isOpen:e=>r.getOpt(e).map(TN.isOpen).getOr(!1),reposition:e=>{r.getOpt(e).each((e=>{TN.reposition(e)}))},getOverflow:e=>r.getOpt(e).bind(TN.getToolbar)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},toggleWithoutFocusing:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t),getOverflow:(e,t)=>e.getOverflow(t)}}),BN=w([Ji(["closedClass","openClass","shrinkingClass","growingClass","overflowToggledClass"]),el("onOpened"),el("onClosed")].concat(vN())),LN=w([Tu({factory:$A,schema:jA(),name:"primary"}),Tu({factory:$A,schema:jA(),name:"overflow",overrides:e=>({toolbarBehaviours:ql([SO.config({dimension:{property:"height"},closedClass:e.markers.closedClass,openClass:e.markers.openClass,shrinkingClass:e.markers.shrinkingClass,growingClass:e.markers.growingClass,onShrunk:t=>{Vu(t,e,"overflow-button").each((e=>{Yp.off(e),Zp.focus(e)})),e.onClosed(t)},onGrown:t=>{Tp.focusIn(t),e.onOpened(t)},onStartGrow:t=>{Vu(t,e,"overflow-button").each(Yp.on)}}),Tp.config({mode:"acyclic",onEscape:t=>(Vu(t,e,"overflow-button").each(Zp.focus),D.some(!0))})])})}),Ou({name:"overflow-button",overrides:e=>({buttonBehaviours:ql([Yp.config({toggleClass:e.markers.overflowToggledClass,aria:{mode:"pressed"},toggleOnExecute:!1})])})}),Ou({name:"overflow-group"})]),HN=(e,t)=>{Vu(e,t,"overflow-button").bind((()=>Vu(e,t,"overflow"))).each((o=>{IN(e,t),SO.toggleGrow(o)}))},IN=(e,t)=>{Vu(e,t,"overflow").each((o=>{fN(e,t,(e=>{const t=F(e,(e=>Ti(e)));$A.setGroups(o,t)})),Vu(e,t,"overflow-button").each((e=>{SO.hasGrown(o)&&Yp.on(e)})),SO.refresh(o)}))},PN=og({name:"SplitSlidingToolbar",configFields:BN(),partFields:LN(),factory:(e,t,o,n)=>{const r="alloy.toolbar.toggle";return{uid:e.uid,dom:e.dom,components:t,behaviours:eu(e.splitToolbarBehaviours,[pS.config({others:{overflowGroup:e=>AN.sketch({...n["overflow-group"](),items:[Nf.sketch({...n["overflow-button"](),action:t=>{js(e,r)}})]})}}),Ip("toolbar-toggle-events",[Qs(r,(t=>{HN(t,e)}))])]),apis:{setGroups:(t,o)=>{((t,o)=>{const n=F(o,t.getSystem().build);e.builtGroups.set(n)})(t,o),IN(t,e)},refresh:t=>IN(t,e),toggle:t=>HN(t,e),isOpen:t=>((e,t)=>Vu(e,t,"overflow").map(SO.hasGrown).getOr(!1))(t,e)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},toggle:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t)}}),FN=e=>{const t=e.title.fold((()=>({})),(e=>({attributes:{title:e}})));return{dom:{tag:"div",classes:["tox-toolbar__group"],...t},components:[AN.parts.items({})],items:e.items,markers:{itemSelector:"*:not(.tox-split-button) > .tox-tbtn:not([disabled]), .tox-split-button:not([disabled]), .tox-toolbar-nav-js:not([disabled]), .tox-number-input:not([disabled])"},tgroupBehaviours:ql([yk.config({}),Zp.config({})])}},zN=e=>AN.sketch(FN(e)),VN=(e,t)=>{const o=ia((t=>{const o=F(e.initGroups,zN);$A.setGroups(t,o)}));return ql([vx(e.providers.isDisabled),gx(),Tp.config({mode:t,onEscape:e.onEscape,selector:".tox-toolbar__group"}),Ip("toolbar-events",[o])])},ZN=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return{uid:e.uid,dom:{tag:"div",classes:["tox-toolbar-overlord"]},parts:{"overflow-group":FN({title:D.none(),items:[]}),"overflow-button":eD({name:"more",icon:D.some("more-drawer"),enabled:!0,tooltip:D.some("Reveal or hide additional toolbar items"),primary:!1,buttonType:D.none(),borderless:!1},D.none(),e.providers)},splitToolbarBehaviours:VN(e,t)}},UN=e=>{const t=ZN(e),o=RN.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}});return RN.sketch({...t,lazySink:e.getSink,getOverflowBounds:()=>{const t=e.moreDrawerData.lazyHeader().element,o=Yo(t),n=tt(t),r=Yo(n),s=Math.max(n.dom.scrollHeight,r.height);return Go(o.x+4,r.y,o.width-8,s)},parts:{...t.parts,overflow:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:e.attributes}}},components:[o],markers:{overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>e.onToggled(t,!0),onClosed:t=>e.onToggled(t,!1)})},jN=e=>{const t=PN.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}}),o=PN.parts.overflow({dom:{tag:"div",classes:["tox-toolbar__overflow"]}}),n=ZN(e);return PN.sketch({...n,components:[t,o],markers:{openClass:"tox-toolbar__overflow--open",closedClass:"tox-toolbar__overflow--closed",growingClass:"tox-toolbar__overflow--growing",shrinkingClass:"tox-toolbar__overflow--shrinking",overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>{t.getSystem().broadcastOn([DM()],{type:"opened"}),e.onToggled(t,!0)},onClosed:t=>{t.getSystem().broadcastOn([DM()],{type:"closed"}),e.onToggled(t,!1)}})},WN=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return $A.sketch({uid:e.uid,dom:{tag:"div",classes:["tox-toolbar"].concat(e.type===Uv.scrolling?["tox-toolbar--scrolling"]:[])},components:[$A.parts.groups({})],toolbarBehaviours:VN(e,t)})},$N=[ow,nw,Cr("tooltip"),Mr("buttonType","secondary",["primary","secondary"]),Nr("borderless",!1),pr("onAction")],qN={button:[...$N,$y,hr("type",["button"])],togglebutton:[...$N,Nr("active",!1),hr("type",["togglebutton"])]},GN=[hr("type",["group"]),Br("buttons",[],sr("type",qN))],KN=sr("type",{...qN,group:GN}),YN=Pn([Br("buttons",[],KN),pr("onShow"),pr("onHide")]),XN=(e,t)=>((e,t)=>{var o,n;const r="togglebutton"===e.type,s=e.icon.map((e=>PT(e,t.icons))).map(Bf),a=o=>{const n=e=>{s.map((n=>n.getOpt(o).each((o=>{Hp.set(o,[PT(e,t.icons)])}))))},a=e=>{const t=o.element;e?(ti(t,"tox-button--enabled"),St(t,"aria-pressed",!0)):(ni(t,"tox-button--enabled"),Ot(t,"aria-pressed"))},i=()=>si(o.element,"tox-button--enabled");return r?e.onAction({setIcon:n,setActive:a,isActive:i}):"button"===e.type?e.onAction({setIcon:n}):void 0},i={...e,name:r?e.text.getOr(e.icon.getOr("")):null!==(o=e.text)&&void 0!==o?o:e.icon.getOr(""),primary:"primary"===e.buttonType,buttonType:D.from(e.buttonType),tooltip:e.tooltip,icon:e.icon,enabled:!0,borderless:e.borderless},l=tD(null!==(n=e.buttonType)&&void 0!==n?n:"secondary"),c=r?e.text.map(t.translate):D.some(t.translate(e.text)),d=c.map(Ci),m=i.tooltip.or(c).map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),u=s.map((e=>e.asSpec())),g=Sx([u,d]),h=e.icon.isSome()&&d.isSome(),p={tag:"button",classes:l.concat(...e.icon.isSome()&&!h?["tox-button--icon"]:[]).concat(...h?["tox-button--icon-and-text"]:[]).concat(...e.borderless?["tox-button--naked"]:[]).concat(..."togglebutton"===e.type&&e.active?["tox-button--enabled"]:[]),attributes:m},f=QO(i,D.some(a),[],p,g,t);return Nf.sketch(f)})(e,t),JN=Do().deviceType,QN=JN.isPhone(),eR=JN.isTablet();var tR=og({name:"silver.View",configFields:[dr("viewConfig")],partFields:[Du({factory:{sketch:e=>{let t=!1;const o=F(e.buttons,(o=>"group"===o.type?(t=!0,((e,t)=>({dom:{tag:"div",classes:["tox-view__toolbar__group"]},components:F(e.buttons,(e=>XN(e,t)))}))(o,e.providers)):XN(o,e.providers)));return{uid:e.uid,dom:{tag:"div",classes:[t?"tox-view__toolbar":"tox-view__header",...QN||eR?["tox-view--mobile","tox-view--scrolling"]:[]]},behaviours:ql([Zp.config({}),Tp.config({mode:"flow",selector:"button, .tox-button",focusInside:eh.OnEnterOrSpaceMode})]),components:t?o:[uk.sketch({dom:{tag:"div",classes:["tox-view__header-start"]},components:[]}),uk.sketch({dom:{tag:"div",classes:["tox-view__header-end"]},components:o})]}}},schema:[dr("buttons"),dr("providers")],name:"header"}),Du({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-view__pane"]}})},schema:[],name:"pane"})],factory:(e,t,o,n)=>{const r={getPane:t=>PA.getPart(t,e,"pane"),getOnShow:t=>e.viewConfig.onShow,getOnHide:t=>e.viewConfig.onHide};return{uid:e.uid,dom:e.dom,components:t,apis:r}},apis:{getPane:(e,t)=>e.getPane(t),getOnShow:(e,t)=>e.getOnShow(t),getOnHide:(e,t)=>e.getOnHide(t)}});const oR=(e,t,o)=>he(t,((t,n)=>{const r=or(tr("view",YN,t));return e.slot(n,tR.sketch({dom:{tag:"div",classes:["tox-view"]},viewConfig:r,components:[...r.buttons.length>0?[tR.parts.header({buttons:r.buttons,providers:o})]:[],tR.parts.pane({})]}))})),nR=(e,t)=>YM.sketch((o=>({dom:{tag:"div",classes:["tox-view-wrap__slot-container"]},components:oR(o,e,t),slotBehaviours:Jw([ia((e=>YM.hideAllSlots(e)))])}))),rR=e=>W(YM.getSlotNames(e),(t=>YM.isShowing(e,t))),sR=(e,t,o)=>{YM.getSlot(e,t).each((e=>{tR.getPane(e).each((t=>{var n;o(e)((n=t.element.dom,{getContainer:w(n)}))}))}))};var aR=tg({factory:(e,t)=>{const o={setViews:(e,o)=>{Hp.set(e,[nR(o,t.backstage.shared.providers)])},whichView:e=>ag.getCurrent(e).bind(rR),toggleView:(e,t,o,n)=>ag.getCurrent(e).exists((r=>{const s=rR(r),a=s.exists((e=>n===e)),i=YM.getSlot(r,n).isSome();return i&&(YM.hideAllSlots(r),a?((e=>{const t=e.element;Mt(t,"display","none"),St(t,"aria-hidden","true")})(e),t()):(o(),(e=>{const t=e.element;Ft(t,"display"),Ot(t,"aria-hidden")})(e),YM.showSlot(r,n),((e,t)=>{sR(e,t,tR.getOnShow)})(r,n)),s.each((e=>((e,t)=>sR(e,t,tR.getOnHide))(r,e)))),i}))};return{uid:e.uid,dom:{tag:"div",classes:["tox-view-wrap"],attributes:{"aria-hidden":"true"},styles:{display:"none"}},components:[],behaviours:ql([Hp.config({}),ag.config({find:e=>{const t=Hp.contents(e);return oe(t)}})]),apis:o}},name:"silver.ViewWrapper",configFields:[dr("backstage")],apis:{setViews:(e,t,o)=>e.setViews(t,o),toggleView:(e,t,o,n,r)=>e.toggleView(t,o,n,r),whichView:(e,t)=>e.whichView(t)}});const iR=FA.optional({factory:jM,name:"menubar",schema:[dr("backstage")]}),lR=FA.optional({factory:{sketch:e=>UA.sketch({uid:e.uid,dom:e.dom,listBehaviours:ql([Tp.config({mode:"acyclic",selector:".tox-toolbar"})]),makeItem:()=>WN({type:e.type,uid:ya("multiple-toolbar-item"),cyclicKeying:!1,initGroups:[],providers:e.providers,onEscape:()=>(e.onEscape(),D.some(!0))}),setupItem:(e,t,o,n)=>{$A.setGroups(t,o)},shell:!0})},name:"multiple-toolbar",schema:[dr("dom"),dr("onEscape")]}),cR=FA.optional({factory:{sketch:e=>{const t=(e=>e.type===Uv.sliding?jN:e.type===Uv.floating?UN:WN)(e);return t({type:e.type,uid:e.uid,onEscape:()=>(e.onEscape(),D.some(!0)),onToggled:(t,o)=>e.onToolbarToggled(o),cyclicKeying:!1,initGroups:[],getSink:e.getSink,providers:e.providers,moreDrawerData:{lazyToolbar:e.lazyToolbar,lazyMoreButton:e.lazyMoreButton,lazyHeader:e.lazyHeader},attributes:e.attributes})}},name:"toolbar",schema:[dr("dom"),dr("onEscape"),dr("getSink")]}),dR=FA.optional({factory:{sketch:e=>{const t=e.editor,o=e.sticky?IM:KA;return{uid:e.uid,dom:e.dom,components:e.components,behaviours:ql(o(t,e.sharedBackstage))}}},name:"header",schema:[dr("dom")]}),mR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:e.dom,components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/tinymce-self-hosted-premium-features/?utm_campaign=self_hosted_upgrade_promo&utm_source=tiny&utm_medium=referral",rel:"noopener",target:"_blank","aria-hidden":"true"},classes:["tox-promotion-link"],innerHtml:"⚡️Upgrade"}}]})},name:"promotion",schema:[dr("dom")]}),uR=FA.optional({name:"socket",schema:[dr("dom")]}),gR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-sidebar"],attributes:{role:"presentation"}},components:[{dom:{tag:"div",classes:["tox-sidebar__slider"]},components:[],behaviours:ql([yk.config({}),Zp.config({}),SO.config({dimension:{property:"width"},closedClass:"tox-sidebar--sliding-closed",openClass:"tox-sidebar--sliding-open",shrinkingClass:"tox-sidebar--sliding-shrinking",growingClass:"tox-sidebar--sliding-growing",onShrunk:e=>{ag.getCurrent(e).each(YM.hideAllSlots),js(e,rN)},onGrown:e=>{js(e,rN)},onStartGrow:e=>{Ws(e,nN,{width:Ht(e.element,"width").getOr("")})},onStartShrink:e=>{Ws(e,nN,{width:Xt(e.element)+"px"})}}),Hp.config({}),ag.config({find:e=>{const t=Hp.contents(e);return oe(t)}})])}],behaviours:ql([YE(0),Ip("sidebar-sliding-events",[Qs(nN,((e,t)=>{Mt(e.element,"width",t.event.width)})),Qs(rN,((e,t)=>{Ft(e.element,"width")}))])])})},name:"sidebar",schema:[dr("dom")]}),hR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",attributes:{"aria-hidden":"true"},classes:["tox-throbber"],styles:{display:"none"}},behaviours:ql([Hp.config({}),iN.config({focus:!1}),ag.config({find:e=>oe(e.components())})]),components:[]})},name:"throbber",schema:[dr("dom")]}),pR=FA.optional({factory:aR,name:"viewWrapper",schema:[dr("backstage")]}),fR=FA.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-editor-container"]},components:e.components})},name:"editorContainer",schema:[]});var vR=og({name:"OuterContainer",factory:(e,t,o)=>{let n=!1;const r={getSocket:t=>PA.getPart(t,e,"socket"),setSidebar:(t,o,n)=>{PA.getPart(t,e,"sidebar").each((e=>((e,t,o)=>{ag.getCurrent(e).each((n=>{Hp.set(n,[eN(t)]);const r=null==o?void 0:o.toLowerCase();s(r)&&be(t,r)&&ag.getCurrent(n).each((t=>{YM.showSlot(t,r),SO.immediateGrow(n),Ft(n.element,"width"),tN(e.element,"region")}))}))})(e,o,n)))},toggleSidebar:(t,o)=>{PA.getPart(t,e,"sidebar").each((e=>((e,t)=>{ag.getCurrent(e).each((o=>{ag.getCurrent(o).each((n=>{SO.hasGrown(o)?YM.isShowing(n,t)?(SO.shrink(o),tN(e.element,"presentation")):(YM.hideAllSlots(n),YM.showSlot(n,t),tN(e.element,"region")):(YM.hideAllSlots(n),YM.showSlot(n,t),SO.grow(o),tN(e.element,"region"))}))}))})(e,o)))},whichSidebar:t=>PA.getPart(t,e,"sidebar").bind(oN).getOrNull(),getHeader:t=>PA.getPart(t,e,"header"),getToolbar:t=>PA.getPart(t,e,"toolbar"),setToolbar:(t,o)=>{PA.getPart(t,e,"toolbar").each((e=>{const t=F(o,zN);e.getApis().setGroups(e,t)}))},setToolbars:(t,o)=>{PA.getPart(t,e,"multiple-toolbar").each((e=>{const t=F(o,(e=>F(e,zN)));UA.setItems(e,t)}))},refreshToolbar:t=>{PA.getPart(t,e,"toolbar").each((e=>e.getApis().refresh(e)))},toggleToolbarDrawer:t=>{PA.getPart(t,e,"toolbar").each((e=>{Se(e.getApis().toggle,(t=>t(e)))}))},toggleToolbarDrawerWithoutFocusing:t=>{PA.getPart(t,e,"toolbar").each((e=>{Se(e.getApis().toggleWithoutFocusing,(t=>t(e)))}))},isToolbarDrawerToggled:t=>PA.getPart(t,e,"toolbar").bind((e=>D.from(e.getApis().isOpen).map((t=>t(e))))).getOr(!1),getThrobber:t=>PA.getPart(t,e,"throbber"),focusToolbar:t=>{PA.getPart(t,e,"toolbar").orThunk((()=>PA.getPart(t,e,"multiple-toolbar"))).each((e=>{Tp.focusIn(e)}))},setMenubar:(t,o)=>{PA.getPart(t,e,"menubar").each((e=>{jM.setMenus(e,o)}))},focusMenubar:t=>{PA.getPart(t,e,"menubar").each((e=>{jM.focus(e)}))},setViews:(t,o)=>{PA.getPart(t,e,"viewWrapper").each((e=>{aR.setViews(e,o)}))},toggleView:(t,o)=>PA.getPart(t,e,"viewWrapper").exists((e=>aR.toggleView(e,(()=>r.showMainView(t)),(()=>r.hideMainView(t)),o))),whichView:t=>PA.getPart(t,e,"viewWrapper").bind(aR.whichView).getOrNull(),hideMainView:t=>{n=r.isToolbarDrawerToggled(t),n&&r.toggleToolbarDrawer(t),PA.getPart(t,e,"editorContainer").each((e=>{const t=e.element;Mt(t,"display","none"),St(t,"aria-hidden","true")}))},showMainView:t=>{n&&r.toggleToolbarDrawer(t),PA.getPart(t,e,"editorContainer").each((e=>{const t=e.element;Ft(t,"display"),Ot(t,"aria-hidden")}))}};return{uid:e.uid,dom:e.dom,components:t,apis:r,behaviours:e.behaviours}},configFields:[dr("dom"),dr("behaviours")],partFields:[dR,iR,cR,lR,uR,gR,mR,hR,pR,fR],apis:{getSocket:(e,t)=>e.getSocket(t),setSidebar:(e,t,o,n)=>{e.setSidebar(t,o,n)},toggleSidebar:(e,t,o)=>{e.toggleSidebar(t,o)},whichSidebar:(e,t)=>e.whichSidebar(t),getHeader:(e,t)=>e.getHeader(t),getToolbar:(e,t)=>e.getToolbar(t),setToolbar:(e,t,o)=>{e.setToolbar(t,o)},setToolbars:(e,t,o)=>{e.setToolbars(t,o)},refreshToolbar:(e,t)=>e.refreshToolbar(t),toggleToolbarDrawer:(e,t)=>{e.toggleToolbarDrawer(t)},toggleToolbarDrawerWithoutFocusing:(e,t)=>{e.toggleToolbarDrawerWithoutFocusing(t)},isToolbarDrawerToggled:(e,t)=>e.isToolbarDrawerToggled(t),getThrobber:(e,t)=>e.getThrobber(t),setMenubar:(e,t,o)=>{e.setMenubar(t,o)},focusMenubar:(e,t)=>{e.focusMenubar(t)},focusToolbar:(e,t)=>{e.focusToolbar(t)},setViews:(e,t,o)=>{e.setViews(t,o)},toggleView:(e,t,o)=>e.toggleView(t,o),whichView:(e,t)=>e.whichView(t)}});const bR={file:{title:"File",items:"newdocument restoredraft | preview | export print | deleteallconversations"},edit:{title:"Edit",items:"undo redo | cut copy paste pastetext | selectall | searchreplace"},view:{title:"View",items:"code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments"},insert:{title:"Insert",items:"image link media addcomment pageembed template inserttemplate codesample inserttable accordion | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents footnotes | mergetags | insertdatetime"},format:{title:"Format",items:"bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat"},tools:{title:"Tools",items:"aidialog aishortcuts | spellchecker spellcheckerlanguage | autocorrect capitalization | a11ycheck code typography wordcount addtemplate"},table:{title:"Table",items:"inserttable | cell row column | advtablesort | tableprops deletetable"},help:{title:"Help",items:"help"}},yR=e=>e.split(" "),wR=(e,t)=>{const o={...bR,...t.menus},n=ae(t.menus).length>0,r=void 0===t.menubar||!0===t.menubar?yR("file edit view insert format tools table help"):yR(!1===t.menubar?"":t.menubar),a=Z(r,(e=>{const o=be(bR,e);return n?o||ve(t.menus,e).exists((e=>be(e,"items"))):o})),i=F(a,(n=>{const r=o[n];return((e,t,o)=>{const n=lb(o).split(/[ ,]/);return{text:e.title,getItems:()=>G(e.items,(e=>{const o=e.toLowerCase();return 0===o.trim().length||H(n,(e=>e===o))?[]:"separator"===o||"|"===o?[{type:"separator"}]:t.menuItems[o]?[t.menuItems[o]]:[]}))}})({title:r.title,items:yR(r.items)},t,e)}));return Z(i,(e=>e.getItems().length>0&&H(e.getItems(),(e=>s(e)||"separator"!==e.type))))},xR=(e,t,o)=>(e.on("remove",(()=>o.unload(t))),o.load(t)),CR=(e,t,o,n)=>(e.on("remove",(()=>n.unloadRawCss(t))),n.loadRawCss(t,o)),SR=async(e,t)=>{const o="ui/"+Pb(e).getOr("default")+"/skin.css",n=tinymce.Resource.get(o);if(s(n))return Promise.resolve(CR(e,o,n,e.ui.styleSheetLoader));return xR(e,t+"/skin.min.css",e.ui.styleSheetLoader)},kR=async(e,t)=>{var o;if(o=Le.fromDom(e.getElement()),ft(o).isSome()){const o="ui/"+Pb(e).getOr("default")+"/skin.shadowdom.css",n=tinymce.Resource.get(o);if(s(n))return CR(e,o,n,Wv.DOM.styleSheetLoader),Promise.resolve();return xR(e,t+"/skin.shadowdom.min.css",Wv.DOM.styleSheetLoader)}},_R=(e,t)=>(async(e,t)=>{Pb(t).fold((()=>{const o=Ib(t);o&&t.contentCSS.push(o+(e?"/content.inline":"/content")+".min.css")}),(o=>{const n="ui/"+o+(e?"/content.inline":"/content")+".css",r=tinymce.Resource.get(n);if(s(r))CR(t,n,r,t.ui.styleSheetLoader);else{const o=Ib(t);o&&t.contentCSS.push(o+(e?"/content.inline":"/content")+".min.css")}}));const o=Ib(t);if(!Lb(t)&&s(o))return Promise.all([SR(t,o),kR(t,o)]).then()})(e,t).then((e=>{const t=()=>{e._skinLoaded=!0,(e=>{e.dispatch("SkinLoaded")})(e)};return()=>{e.initialized?t():e.on("init",t)}})(t),((e,t)=>()=>((e,t)=>{e.dispatch("SkinLoadError",t)})(e,{message:t}))(t,"Skin could not be loaded")),ER=S(_R,!1),TR=S(_R,!0),OR=(e,t,o)=>e.translate([t,e.translate(o)]),DR=(e,t)=>{const o=(o,r,s,a)=>{const i=e.shared.providers.translate(o.title);if("separator"===o.type)return D.some({type:"separator",text:i});if("submenu"===o.type){const e=G(o.getStyleItems(),(e=>n(e,r,a)));return 0===r&&e.length<=0?D.none():D.some({type:"nestedmenuitem",text:i,enabled:e.length>0,getSubmenuItems:()=>G(o.getStyleItems(),(e=>n(e,r,a)))})}return D.some({type:"togglemenuitem",text:i,icon:o.icon,active:o.isSelected(a),enabled:!s,onAction:t.onAction(o),...o.getStylePreview().fold((()=>({})),(e=>({meta:{style:e}})))})},n=(e,n,r)=>{const s="formatter"===e.type&&t.isInvalid(e);return 0===n?s?[]:o(e,n,!1,r).toArray():o(e,n,s,r).toArray()},r=e=>{const o=t.getCurrentValue(),r=t.shouldHide?0:1;return G(e,(e=>n(e,r,o)))};return{validateItems:r,getFetch:(e,t)=>(o,n)=>{const s=t(),a=r(s);n(qT(a,oy.CLOSE_ON_EXECUTE,e,{isHorizontalMenu:!1,search:D.none()}))}}},AR=(e,t,o)=>{const n=o.dataset,r="basic"===n.type?()=>F(n.data,(e=>lA(e,o.isSelectedFor,o.getPreviewFor))):n.getData;return{items:DR(t,o),getStyleItems:r}},MR=(e,t,o,n,r)=>{const{items:s,getStyleItems:a}=AR(0,t,o);return ZT({text:o.icon.isSome()?D.none():o.text,icon:o.icon,tooltip:D.from(o.tooltip),role:D.none(),fetch:s.getFetch(t,a),onSetup:t=>{const s=o=>t.setTooltip(OR(e,n,o.value));return e.on(r,s),dC(gC(e,"NodeChange",(t=>{const n=t.getComponent();o.updateText(n),wg.set(t.getComponent(),!e.selection.isEditable())}))(t),(()=>e.off(r,s)))},getApi:e=>({getComponent:w(e),setTooltip:o=>{const n=t.shared.providers.translate(o);kt(e.element,{"aria-label":n,title:n})}}),columns:1,presets:"normal",classes:o.icon.isSome()?[]:["bespoke"],dropdownBehaviours:[]},"tox-tbtn",t.shared)};var NR;!function(e){e[e.SemiColon=0]="SemiColon",e[e.Space=1]="Space"}(NR||(NR={}));const RR=(e,t,o)=>{const n=(e=>F(e,(e=>{let t=e,o=e;const n=e.split("=");return n.length>1&&(t=n[0],o=n[1]),{title:t,format:o}})))(((e,t)=>t===NR.SemiColon?e.replace(/;$/,"").split(";"):e.split(" "))(e.options.get(t),o));return{type:"basic",data:n}},BR="Alignment {0}",LR="left",HR=[{title:"Left",icon:"align-left",format:"alignleft",command:"JustifyLeft"},{title:"Center",icon:"align-center",format:"aligncenter",command:"JustifyCenter"},{title:"Right",icon:"align-right",format:"alignright",command:"JustifyRight"},{title:"Justify",icon:"align-justify",format:"alignjustify",command:"JustifyFull"}],IR=e=>{const t={type:"basic",data:HR};return{tooltip:OR(e,BR,LR),text:D.none(),icon:D.some("align-left"),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:D.none,getPreviewFor:e=>D.none,onAction:t=>()=>W(HR,(e=>e.format===t.format)).each((t=>e.execCommand(t.command))),updateText:t=>{const o=W(HR,(t=>e.formatter.match(t.format))),n=o.fold(w(LR),(e=>e.title.toLowerCase()));Ws(t,VT,{icon:`align-${n}`}),((e,t)=>{e.dispatch("AlignTextUpdate",t)})(e,{value:n})},dataset:t,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},PR=(e,t)=>{const o=t(),n=F(o,(e=>e.format));return D.from(e.formatter.closest(n)).bind((e=>W(o,(t=>t.format===e)))).orThunk((()=>ke(e.formatter.match("p"),{title:"Paragraph",format:"p"})))},FR="Block {0}",zR="Paragraph",VR=e=>{const t=RR(e,"block_formats",NR.SemiColon);return{tooltip:OR(e,FR,zR),text:D.some(zR),icon:D.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:D.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return o?D.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):D.none()},onAction:hC(e),updateText:o=>{const n=PR(e,(()=>t.data)).fold(w(zR),(e=>e.title));Ws(o,zT,{text:n}),((e,t)=>{e.dispatch("BlocksTextUpdate",t)})(e,{value:n})},dataset:t,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},ZR="Font {0}",UR="System Font",jR=["-apple-system","Segoe UI","Roboto","Helvetica Neue","sans-serif"],WR=e=>{const t=e.split(/\s*,\s*/);return F(t,(e=>e.replace(/^['"]+|['"]+$/g,"")))},$R=(e,t)=>t.length>0&&K(t,(t=>e.indexOf(t.toLowerCase())>-1)),qR=e=>{const t=()=>{const t=e=>e?WR(e)[0]:"",n=e.queryCommandValue("FontName"),r=o.data,s=n?n.toLowerCase():"",a=Bb(e),i=W(r,(e=>{const o=e.format;return o.toLowerCase()===s||t(o).toLowerCase()===t(s).toLowerCase()})).orThunk((()=>ke(((e,t)=>{if(0===e.indexOf("-apple-system")||t.length>0){const o=WR(e.toLowerCase());return $R(o,jR)||$R(o,t)}return!1})(s,a),{title:UR,format:s})));return{matchOpt:i,font:n}},o=RR(e,"font_family_formats",NR.SemiColon);return{tooltip:OR(e,ZR,UR),text:D.some(UR),icon:D.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getCurrentValue:()=>{const{matchOpt:e}=t();return e},getPreviewFor:e=>()=>D.some({tag:"div",styles:-1===e.indexOf("dings")?{"font-family":e}:{}}),onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontName",!1,t.format)}))},updateText:o=>{const{matchOpt:n,font:r}=t(),s=n.fold(w(r),(e=>e.title));Ws(o,zT,{text:s}),((e,t)=>{e.dispatch("FontFamilyTextUpdate",t)})(e,{value:s})},dataset:o,shouldHide:!1,isInvalid:T}},GR={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},KR=(()=>{const e="[0-9]+",t="[eE]"+("[+-]?"+e),o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^(${`[+-]?(?:${n})`})(.*)$`)})(),YR=(e,t)=>D.from(KR.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>H(t,(t=>H(GR[t],(t=>e===t)))))(n,t)?D.some({value:o,unit:n}):D.none()})),XR={tab:w(9),escape:w(27),enter:w(13),backspace:w(8),delete:w(46),left:w(37),up:w(38),right:w(39),down:w(40),space:w(32),home:w(36),end:w(35),pageUp:w(33),pageDown:w(34)},JR=(e,t,o)=>{let n=D.none();const r=gC(e,"NodeChange SwitchMode",(t=>{const r=t.getComponent();n=D.some(r),o.updateInputValue(r),wg.set(r,!e.selection.isEditable())})),s=e=>({getComponent:w(e)}),a=Hr(v),i=ya("custom-number-input-events"),l=(e,t,r)=>{const s=n.map((e=>Xm.getValue(e))).getOr("");const a=o.getNewValue(s,e),i=s.length-`${a}`.length,l=n.map((e=>e.element.dom.selectionStart-i)),c=n.map((e=>e.element.dom.selectionEnd-i));o.onAction(a,r),n.each((e=>{Xm.setValue(e,a),t&&(l.each((t=>e.element.dom.selectionStart=t)),c.each((t=>e.element.dom.selectionEnd=t)))}))},c=(e,t)=>l(((e,t)=>e-t),e,t),d=(e,t)=>l(((e,t)=>e+t),e,t),m=e=>rt(e.element).fold(D.none,(e=>(tc(e),D.some(!0)))),u=e=>nc(e.element)?(lt(e.element).each((e=>tc(e))),D.some(!0)):D.none(),g=(o,n,r,a)=>{const i=Hr(v),l=t.shared.providers.translate(r),c=ya("altExecuting"),d=gC(e,"NodeChange SwitchMode",(t=>{wg.set(t.getComponent(),!e.selection.isEditable())})),m=e=>{wg.isDisabled(e)||o(!0)};return Nf.sketch({dom:{tag:"button",attributes:{title:l,"aria-label":l},classes:a.concat(n)},components:[IT(n,t.shared.providers.icons)],buttonBehaviours:ql([wg.config({}),Ip(c,[yx({onSetup:d,getApi:s},i),wx({getApi:s},i),Qs(is(),((e,t)=>{t.event.raw.keyCode!==XR.space()&&t.event.raw.keyCode!==XR.enter()||wg.isDisabled(e)||o(!1)})),Qs(ms(),m),Qs(Jr(),m)])]),eventOrder:{[is()]:[c,"keying"],[ms()]:[c,"alloy.base.behaviour"],[Jr()]:[c,"alloy.base.behaviour"]}})},h=Bf(g((e=>c(!1,e)),"minus","Decrease font size",[])),p=Bf(g((e=>d(!1,e)),"plus","Increase font size",[])),f=Bf({dom:{tag:"div",classes:["tox-input-wrapper"]},components:[_y.sketch({inputBehaviours:ql([wg.config({}),Ip(i,[yx({onSetup:r,getApi:s},a),wx({getApi:s},a)]),Ip("input-update-display-text",[Qs(zT,((e,t)=>{Xm.setValue(e,t.event.text)})),Qs(as(),(e=>{o.onAction(Xm.getValue(e))})),Qs(ds(),(e=>{o.onAction(Xm.getValue(e))}))]),Tp.config({mode:"special",onEnter:e=>(l(x,!0,!0),D.some(!0)),onEscape:m,onUp:e=>(d(!0,!1),D.some(!0)),onDown:e=>(c(!0,!1),D.some(!0)),onLeft:(e,t)=>(t.cut(),D.none()),onRight:(e,t)=>(t.cut(),D.none())})])})],behaviours:ql([Zp.config({}),Tp.config({mode:"special",onEnter:u,onSpace:u,onEscape:m}),Ip("input-wrapper-events",[Qs(rs(),(e=>{z([h,p],(t=>{const o=Le.fromDom(t.get(e).element.dom);nc(o)&&oc(o)}))}))])])});return{dom:{tag:"div",classes:["tox-number-input"]},components:[h.asSpec(),f.asSpec(),p.asSpec()],behaviours:ql([Zp.config({}),Tp.config({mode:"flow",focusInside:eh.OnEnterOrSpaceMode,cycles:!1,selector:"button, .tox-input-wrapper",onEscape:e=>nc(e.element)?D.none():(tc(e.element),D.some(!0))})])}},QR="Font size {0}",eB="12pt",tB={"8pt":"1","10pt":"2","12pt":"3","14pt":"4","18pt":"5","24pt":"6","36pt":"7"},oB={"xx-small":"7pt","x-small":"8pt",small:"10pt",medium:"12pt",large:"14pt","x-large":"18pt","xx-large":"24pt"},nB=(e,t)=>/[0-9.]+px$/.test(e)?((e,t)=>{const o=Math.pow(10,t);return Math.round(e*o)/o})(72*parseInt(e,10)/96,t||0)+"pt":ve(oB,e).getOr(e),rB=e=>ve(tB,e).getOr(""),sB=e=>{const t=()=>{let t=D.none();const o=n.data,r=e.queryCommandValue("FontSize");if(r)for(let e=3;t.isNone()&&e>=0;e--){const n=nB(r,e),s=rB(n);t=W(o,(e=>e.format===r||e.format===n||e.format===s))}return{matchOpt:t,size:r}},o=w(D.none),n=RR(e,"font_size_formats",NR.Space);return{tooltip:OR(e,QR,eB),text:D.some(eB),icon:D.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getPreviewFor:o,getCurrentValue:()=>{const{matchOpt:e}=t();return e},onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontSize",!1,t.format)}))},updateText:o=>{const{matchOpt:n,size:r}=t(),s=n.fold(w(r),(e=>e.title));Ws(o,zT,{text:s}),((e,t)=>{e.dispatch("FontSizeTextUpdate",t)})(e,{value:s})},dataset:n,shouldHide:!1,isInvalid:T}},aB="Format {0}",iB=(e,t)=>{const o="Paragraph";return{tooltip:OR(e,aB,o),text:D.some(o),icon:D.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:D.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return void 0!==o?D.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):D.none()},onAction:hC(e),updateText:t=>{const n=e=>nA(e)?G(e.items,n):rA(e)?[{title:e.title,format:e.format}]:[],r=G(iA(e),n),s=PR(e,w(r)).fold(w(o),(e=>e.title));Ws(t,zT,{text:s}),((e,t)=>{e.dispatch("StylesTextUpdate",t)})(e,{value:s})},shouldHide:ab(e),isInvalid:t=>!e.formatter.canApply(t.format),dataset:t}},lB=w([dr("toggleClass"),dr("fetch"),ol("onExecute"),Tr("getHotspot",D.some),Tr("getAnchorOverrides",w({})),Xc(),ol("onItemExecute"),yr("lazySink"),dr("dom"),el("onOpen"),Jm("splitDropdownBehaviours",[pS,Tp,Zp]),Tr("matchWidth",!1),Tr("useMinWidth",!1),Tr("eventOrder",{}),yr("role")].concat(RS())),cB=Tu({factory:Nf,schema:[dr("dom")],name:"arrow",defaults:()=>({buttonBehaviours:ql([Zp.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each($s)},buttonBehaviours:ql([Yp.config({toggleOnExecute:!1,toggleClass:e.toggleClass})])})}),dB=Tu({factory:Nf,schema:[dr("dom")],name:"button",defaults:()=>({buttonBehaviours:ql([Zp.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each((o=>{e.onExecute(o,t)}))}})}),mB=w([cB,dB,Du({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[dr("text")],name:"aria-descriptor"}),Ou({schema:[Xi()],name:"menu",defaults:e=>({onExecute:(t,o)=>{t.getSystem().getByUid(e.uid).each((n=>{e.onItemExecute(n,t,o)}))}})}),SS()]),uB=og({name:"SplitDropdown",configFields:lB(),partFields:mB(),factory:(e,t,o,n)=>{const r=e=>{ag.getCurrent(e).each((e=>{Mg.highlightFirst(e),Tp.focusIn(e)}))},s=t=>{TS(e,x,t,n,r,Tf.HighlightMenuAndItem).get(v)},a=t=>{const o=Zu(t,e,"button");return $s(o),D.some(!0)},i={...Ys([ia(((t,o)=>{Vu(t,e,"aria-descriptor").each((e=>{const o=ya("aria");St(e.element,"id",o),St(t.element,"aria-describedby",o)}))}))]),...Qp(D.some(s))},l={repositionMenus:e=>{Yp.isOn(e)&&NS(e)}};return{uid:e.uid,dom:e.dom,components:t,apis:l,eventOrder:{...e.eventOrder,[Cs()]:["disabling","toggling","alloy.base.behaviour"]},events:i,behaviours:eu(e.splitDropdownBehaviours,[pS.config({others:{sandbox:t=>{const o=Zu(t,e,"arrow");return MS(e,t,{onOpen:()=>{Yp.on(o),Yp.on(t)},onClose:()=>{Yp.off(o),Yp.off(t)}})}}}),Tp.config({mode:"special",onSpace:a,onEnter:a,onDown:e=>(s(e),D.some(!0))}),Zp.config({}),Yp.config({toggleOnExecute:!1,aria:{mode:"expanded"}})]),domModification:{attributes:{role:e.role.getOr("button"),"aria-haspopup":!0}}}},apis:{repositionMenus:(e,t)=>e.repositionMenus(t)}}),gB=e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setText:t=>Ws(e,zT,{text:t}),setIcon:t=>Ws(e,VT,{icon:t})}),hB=e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setText:t=>Ws(e,zT,{text:t}),setIcon:t=>Ws(e,VT,{icon:t})}),pB=(e,t)=>e.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),fB=ya("focus-button"),vB=(e,t,o,n,r)=>{const s=t.map((e=>Bf(FT(e,"tox-tbtn",r)))),a=e.map((e=>Bf(PT(e,r.icons))));return{dom:{tag:"button",classes:["tox-tbtn"].concat(t.isSome()?["tox-tbtn--select"]:[]),attributes:pB(o,r)},components:Sx([a.map((e=>e.asSpec())),s.map((e=>e.asSpec()))]),eventOrder:{[es()]:["focusing","alloy.base.behaviour",RT],[Rs()]:[RT,"toolbar-group-button-events"]},buttonBehaviours:ql([vx(r.isDisabled),gx(),Ip(RT,[ia(((e,t)=>LT(e))),Qs(zT,((e,t)=>{s.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[Ci(r.translate(t.event.text))])}))})),Qs(VT,((e,t)=>{a.bind((t=>t.getOpt(e))).each((e=>{Hp.set(e,[PT(t.event.icon,r.icons)])}))})),Qs(es(),((e,t)=>{t.event.prevent(),js(e,fB)}))])].concat(n.getOr([])))}},bB=(e,t,o)=>{var n;const r=Hr(v),s=vB(e.icon,e.text,e.tooltip,D.none(),o);return Nf.sketch({dom:s.dom,components:s.components,eventOrder:BT,buttonBehaviours:{...ql([Ip("toolbar-button-events",[(a={onAction:e.onAction,getApi:t.getApi},da(((e,t)=>{bx(a,e)((t=>{Ws(e,NT,{buttonApi:t}),a.onAction(t)}))}))),yx(t,r),wx(t,r)]),vx((()=>!e.enabled||o.isDisabled())),gx()].concat(t.toolbarButtonBehaviours)),[RT]:null===(n=s.buttonBehaviours)||void 0===n?void 0:n[RT]}});var a},yB=(e,t,o)=>bB(e,{toolbarButtonBehaviours:o.length>0?[Ip("toolbarButtonWith",o)]:[],getApi:gB,onSetup:e.onSetup},t),wB=(e,t,o)=>bB(e,{toolbarButtonBehaviours:[Hp.config({}),Yp.config({toggleClass:"tox-tbtn--enabled",aria:{mode:"pressed"},toggleOnExecute:!1})].concat(o.length>0?[Ip("toolbarToggleButtonWith",o)]:[]),getApi:hB,onSetup:e.onSetup},t),xB=(e,t,o)=>n=>wS((e=>t.fetch(e))).map((r=>D.from($S(xn(KC(ya("menu-value"),r,(o=>{t.onItemAction(e(n),o)}),t.columns,t.presets,oy.CLOSE_ON_EXECUTE,t.select.getOr(T),o),{movement:XC(t.columns,t.presets),menuBehaviours:Jw("auto"!==t.columns?[]:[ia(((e,o)=>{Yw(e,4,hy(t.presets)).each((({numRows:t,numColumns:o})=>{Tp.setGridSize(e,t,o)}))}))])}))))),CB=[{name:"history",items:["undo","redo"]},{name:"ai",items:["aidialog","aishortcuts"]},{name:"styles",items:["styles"]},{name:"formatting",items:["bold","italic"]},{name:"alignment",items:["alignleft","aligncenter","alignright","alignjustify"]},{name:"indentation",items:["outdent","indent"]},{name:"permanent pen",items:["permanentpen"]},{name:"comments",items:["addcomment"]}],SB=(e,t)=>(o,n,r)=>{const s=e(o).mapError((e=>rr(e))).getOrDie();return t(s,n,r)},kB={button:SB(xw,((e,t)=>{return o=e,n=t.shared.providers,yB(o,n,[]);var o,n})),togglebutton:SB(kw,((e,t)=>{return o=e,n=t.shared.providers,wB(o,n,[]);var o,n})),menubutton:SB(ZM,((e,t)=>_O(e,"tox-tbtn",t,D.none(),!1))),splitbutton:SB((e=>tr("SplitButton",UM,e)),((e,t)=>((e,t)=>{const o=e=>({isEnabled:()=>!wg.isDisabled(e),setEnabled:t=>wg.set(e,!t),setIconFill:(t,o)=>{Bi(e.element,`svg path[class="${t}"], rect[class="${t}"]`).each((e=>{St(e,"fill",o)}))},setActive:t=>{St(e.element,"aria-pressed",t),Bi(e.element,"span").each((o=>{e.getSystem().getByDom(o).each((e=>Yp.set(e,t)))}))},isActive:()=>Bi(e.element,"span").exists((t=>e.getSystem().getByDom(t).exists(Yp.isOn))),setText:t=>Bi(e.element,"span").each((o=>e.getSystem().getByDom(o).each((e=>Ws(e,zT,{text:t}))))),setIcon:t=>Bi(e.element,"span").each((o=>e.getSystem().getByDom(o).each((e=>Ws(e,VT,{icon:t}))))),setTooltip:o=>{const n=t.providers.translate(o);kt(e.element,{"aria-label":n,title:n})}}),n=Hr(v),r={getApi:o,onSetup:e.onSetup};return uB.sketch({dom:{tag:"div",classes:["tox-split-button"],attributes:{"aria-pressed":!1,...pB(e.tooltip,t.providers)}},onExecute:t=>{const n=o(t);n.isEnabled()&&e.onAction(n)},onItemExecute:(e,t,o)=>{},splitDropdownBehaviours:ql([fx(t.providers.isDisabled),gx(),Ip("split-dropdown-events",[ia(((e,t)=>LT(e))),Qs(fB,Zp.focus),yx(r,n),wx(r,n)]),Wk.config({})]),eventOrder:{[Rs()]:["alloy.base.behaviour","split-dropdown-events"]},toggleClass:"tox-tbtn--enabled",lazySink:t.getSink,fetch:xB(o,e,t.providers),parts:{menu:wy(0,e.columns,e.presets)},components:[uB.parts.button(vB(e.icon,e.text,D.none(),D.some([Yp.config({toggleClass:"tox-tbtn--enabled",toggleOnExecute:!1})]),t.providers)),uB.parts.arrow({dom:{tag:"button",classes:["tox-tbtn","tox-split-button__chevron"],innerHtml:Iv("chevron-down",t.providers.icons)},buttonBehaviours:ql([fx(t.providers.isDisabled),gx(),Pv()])}),uB.parts["aria-descriptor"]({text:t.providers.translate("To open the popup, press Shift+Enter")})]})})(e,t.shared))),grouptoolbarbutton:SB((e=>tr("GroupToolbarButton",FM,e)),((e,t,o)=>{const n=o.ui.registry.getAll().buttons,r=e=>OB(o,{buttons:n,toolbar:e,allowToolbarGroups:!1},t,D.none()),s={[Kc]:t.shared.header.isPositionedAtTop()?Gc.TopToBottom:Gc.BottomToTop};if(cb(o)===Uv.floating)return((e,t,o,n)=>{const r=t.shared,s=Hr(v),a={toolbarButtonBehaviours:[],getApi:gB,onSetup:e.onSetup},i=[Ip("toolbar-group-button-events",[yx(a,s),wx(a,s)])];return TN.sketch({lazySink:r.getSink,fetch:()=>wS((t=>{t(F(o(e.items),zN))})),markers:{toggledClass:"tox-tbtn--enabled"},parts:{button:vB(e.icon,e.text,e.tooltip,D.some(i),r.providers),toolbar:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:n}}}})})(e,t,r,s);throw new Error("Toolbar groups are only supported when using floating toolbar mode")}))},_B={styles:(e,t)=>{const o={type:"advanced",...t.styles};return MR(e,t,iB(e,o),aB,"StylesTextUpdate")},fontsize:(e,t)=>MR(e,t,sB(e),QR,"FontSizeTextUpdate"),fontsizeinput:(e,t)=>JR(e,t,(e=>{const t=()=>e.queryCommandValue("FontSize");return{updateInputValue:e=>Ws(e,zT,{text:t()}),onAction:(t,o)=>e.execCommand("FontSize",!1,t,{skip_focus:!o}),getNewValue:(o,n)=>{YR(o,["unsupportedLength","empty"]);const r=t(),s=YR(o,["unsupportedLength","empty"]).or(YR(r,["unsupportedLength","empty"])),a=s.map((e=>e.value)).getOr(16),i=wb(e),l=s.map((e=>e.unit)).filter((e=>""!==e)).getOr(i),c=n(a,(e=>{var t;return null!==(t={em:{step:.1},cm:{step:.1},in:{step:.1},pc:{step:.1},ch:{step:.1},rem:{step:.1}}[e])&&void 0!==t?t:{step:1}})(l).step),d=`${(e=>e>=0)(c)?c:a}${l}`;return d!==r&&((e,t)=>{e.dispatch("FontSizeInputTextUpdate",t)})(e,{value:d}),d}}})(e)),fontfamily:(e,t)=>MR(e,t,qR(e),ZR,"FontFamilyTextUpdate"),blocks:(e,t)=>MR(e,t,VR(e),FR,"BlocksTextUpdate"),align:(e,t)=>MR(e,t,IR(e),BR,"AlignTextUpdate")},EB=e=>{const t=e.toolbar,o=e.buttons;return!1===t?[]:void 0===t||!0===t?(e=>{const t=F(CB,(t=>{const o=Z(t.items,(t=>be(e,t)||be(_B,t)));return{name:t.name,items:o}}));return Z(t,(e=>e.items.length>0))})(o):s(t)?(e=>{const t=e.split("|");return F(t,(e=>({items:e.trim().split(" ")})))})(t):(e=>f(e,(e=>be(e,"name")&&be(e,"items"))))(t)?t:(console.error("Toolbar type should be string, string[], boolean or ToolbarGroup[]"),[])},TB=(e,t,o,n,r,s)=>ve(t,o.toLowerCase()).orThunk((()=>s.bind((e=>se(e,(e=>ve(t,e+o.toLowerCase()))))))).fold((()=>ve(_B,o.toLowerCase()).map((t=>t(e,r)))),(t=>"grouptoolbarbutton"!==t.type||n?((e,t,o)=>ve(kB,e.type).fold((()=>(console.error("skipping button defined by",e),D.none())),(n=>D.some(n(e,t,o)))))(t,r,e):(console.warn(`Ignoring the '${o}' toolbar button. Group toolbar buttons are only supported when using floating toolbar mode and cannot be nested.`),D.none()))),OB=(e,t,o,n)=>{const r=EB(t),s=F(r,(r=>{const s=G(r.items,(r=>0===r.trim().length?[]:TB(e,t.buttons,r,t.allowToolbarGroups,o,n).toArray()));return{title:D.from(e.translate(r.name)),items:s}}));return Z(s,(e=>e.items.length>0))},DB=(e,t,o,n)=>{const r=t.mainUi.outerContainer,a=o.toolbar,i=o.buttons;if(f(a,s)){const t=a.map((t=>{const r={toolbar:t,buttons:i,allowToolbarGroups:o.allowToolbarGroups};return OB(e,r,n,D.none())}));vR.setToolbars(r,t)}else vR.setToolbar(r,OB(e,o,n,D.none()))},AB=Do(),MB=AB.os.isiOS()&&AB.os.version.major<=12;var NB=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:s,uiMotherships:a}=t,i=Hr(0),l=s.outerContainer;ER(e);const d=Le.fromDom(r.targetNode),m=pt(ht(d));bm(d,s.mothership),((e,t,o)=>{Kb(e)&&bm(o.mainUi.mothership.element,o.popupUi.mothership),vm(t,o.dialogUi.mothership)})(e,m,t),e.on("SkinLoaded",(()=>{vR.setSidebar(l,o.sidebar,Mb(e)),DB(e,t,o,n),i.set(e.getWin().innerWidth),vR.setMenubar(l,wR(e,o)),vR.setViews(l,o.views),((e,t)=>{const{uiMotherships:o}=t,n=e.dom;let r=e.getWin();const s=e.getDoc().documentElement,a=Hr($t(r.innerWidth,r.innerHeight)),i=Hr($t(s.offsetWidth,s.offsetHeight)),l=()=>{const t=a.get();t.left===r.innerWidth&&t.top===r.innerHeight||(a.set($t(r.innerWidth,r.innerHeight)),iC(e))},c=()=>{const t=e.getDoc().documentElement,o=i.get();o.left===t.offsetWidth&&o.top===t.offsetHeight||(i.set($t(t.offsetWidth,t.offsetHeight)),iC(e))},d=t=>{((e,t)=>{e.dispatch("ScrollContent",t)})(e,t)};n.bind(r,"resize",l),n.bind(r,"scroll",d);const m=Tc(Le.fromDom(e.getBody()),"load",c);e.on("hide",(()=>{z(o,(e=>{Mt(e.element,"display","none")}))})),e.on("show",(()=>{z(o,(e=>{Ft(e.element,"display")}))})),e.on("NodeChange",c),e.on("remove",(()=>{m.unbind(),n.unbind(r,"resize",l),n.unbind(r,"scroll",d),r=null}))})(e,t)}));const u=vR.getSocket(l).getOrDie("Could not find expected socket element");if(MB){Nt(u.element,{overflow:"scroll","-webkit-overflow-scrolling":"touch"});const t=((e,t)=>{let o=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{c(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}})((()=>{e.dispatch("ScrollContent")}),20),o=Ec(u.element,"scroll",t.throttle);e.on("remove",o.unbind)}ux(e,t),e.addCommand("ToggleSidebar",((t,o)=>{vR.toggleSidebar(l,o),e.dispatch("ToggleSidebar")})),e.addQueryValueHandler("ToggleSidebar",(()=>{var e;return null!==(e=vR.whichSidebar(l))&&void 0!==e?e:""})),e.addCommand("ToggleView",((t,o)=>{if(vR.toggleView(l,o)){const t=l.element;s.mothership.broadcastOn([Nm()],{target:t}),z(a,(e=>{e.broadcastOn([Nm()],{target:t})})),c(vR.whichView(l))&&(e.focus(),e.nodeChanged(),vR.refreshToolbar(l))}})),e.addQueryValueHandler("ToggleView",(()=>{var e;return null!==(e=vR.whichView(l))&&void 0!==e?e:""}));const g=cb(e);g!==Uv.sliding&&g!==Uv.floating||e.on("ResizeWindow ResizeEditor ResizeContent",(()=>{const o=e.getWin().innerWidth;o!==i.get()&&(vR.refreshToolbar(t.mainUi.outerContainer),i.set(o))}));const h={setEnabled:e=>{mx(t,!e)},isEnabled:()=>!wg.isDisabled(l)};return{iframeContainer:u.element.dom,editorContainer:l.element.dom,api:h}}});const RB=e=>/^[0-9\.]+(|px)$/i.test(""+e)?D.some(parseInt(""+e,10)):D.none(),BB=e=>p(e)?e+"px":e,LB=(e,t,o)=>{const n=t.filter((t=>ee>t));return n.or(r).getOr(e)},HB=e=>{const t=(e=>{const t=Jv(e),o=tb(e),n=nb(e);return RB(t).map((e=>LB(e,o,n)))})(e);return t.getOr(Jv(e))},IB=e=>{const t=Qv(e),o=eb(e),n=ob(e);return RB(t).map((e=>LB(e,o,n)))},{ToolbarLocation:PB,ToolbarMode:FB}=Xb,zB=(e,t,o,n,r)=>{const{mainUi:s,uiMotherships:a}=o,i=Wv.DOM,l=Wb(e),c=Gb(e),d=ob(e).or(IB(e)),m=n.shared.header,u=m.isPositionedAtTop,g=cb(e),h=g===FB.sliding||g===FB.floating,p=Hr(!1),f=()=>p.get()&&!e.removed,v=e=>h?e.fold(w(0),(e=>e.components().length>1?Ut(e.components()[1].element):0)):0,b=(e,t)=>Kb(e)?XA(t):D.none(),y=()=>{z(a,(e=>{e.broadcastOn([Rm()],{})}))},x=o=>{if(!f())return;l||r.on((e=>{const o=d.getOrThunk((()=>{const e=RB(Bt(wt(),"margin-left")).getOr(0);return Xt(wt())-Gt(t).left+e}));Mt(e.element,"max-width",o+"px")}));const n=l?D.none():(()=>{if(l)return D.none();if(Gt(s.outerContainer.element).left+Jt(s.outerContainer.element)>=window.innerWidth-40||Ht(s.outerContainer.element,"width").isSome()){Mt(s.outerContainer.element,"position","absolute"),Mt(s.outerContainer.element,"left","0px"),Ft(s.outerContainer.element,"width");const e=Jt(s.outerContainer.element);return D.some(e)}return D.none()})();h&&vR.refreshToolbar(s.outerContainer),l||(o=>{r.on((n=>{const r=vR.getToolbar(s.outerContainer),a=v(r),i=Ko(t),{top:l,left:c}=b(e,s.outerContainer.element).fold((()=>({top:u()?Math.max(i.y-Ut(n.element)+a,0):i.bottom,left:i.x})),(e=>{var t;const o=Ko(e),r=null!==(t=e.dom.scrollTop)&&void 0!==t?t:0,s=Xe(e,wt()),l=s?Math.max(i.y-Ut(n.element)+a,0):i.y-o.y+r-Ut(n.element)+a;return{top:u()?l:i.bottom,left:s?i.x:i.x-o.x}})),d={position:"absolute",left:Math.round(c)+"px",top:Math.round(l)+"px"},m=o.map((e=>{const t=zo(),o=window.innerWidth-(c-t.left);return{width:Math.max(Math.min(e,o),150)+"px"}})).getOr({});Nt(s.outerContainer.element,{...d,...m})}))})(n),c&&r.on(o),y()},C=()=>!(l||!c||!f())&&r.get().exists((o=>{const n=m.getDockingMode(),a=(o=>{switch(mb(e)){case PB.auto:const e=vR.getToolbar(s.outerContainer),n=v(e),r=Ut(o.element)-n,a=Ko(t);if(a.y>r)return"top";{const e=tt(t),o=Math.max(e.dom.scrollHeight,Ut(e));return a.bottom{OM.setModes(e,[i]),m.setDockingMode(i);const t=u()?Gc.TopToBottom:Gc.BottomToTop;St(e.element,Kc,t)})),!0);var i}));return{isVisible:f,isPositionedAtTop:u,show:()=>{p.set(!0),Mt(s.outerContainer.element,"display","flex"),i.addClass(e.getBody(),"mce-edit-focus"),z(a,(e=>{Ft(e.element,"display")})),C(),Kb(e)?x((e=>OM.isDocked(e)?OM.reset(e):OM.refresh(e))):x(OM.refresh)},hide:()=>{p.set(!1),Mt(s.outerContainer.element,"display","none"),i.removeClass(e.getBody(),"mce-edit-focus"),z(a,(e=>{Mt(e.element,"display","none")}))},update:x,updateMode:()=>{C()&&x(OM.reset)},repositionPopups:y}},VB=(e,t)=>{const o=Ko(e);return{pos:t?o.y:o.bottom,bounds:o}};var ZB=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:s}=t,a=kc(),i=Le.fromDom(r.targetNode),l=zB(e,i,t,n,a),c=hb(e);TR(e);const d=()=>{if(a.isSet())return void l.show();a.set(vR.getHeader(s.outerContainer).getOrDie());const r=$b(e);Kb(e)?(bm(i,s.mothership),bm(i,t.popupUi.mothership)):vm(r,s.mothership),vm(r,t.dialogUi.mothership),DB(e,t,o,n),vR.setMenubar(s.outerContainer,wR(e,o)),l.show(),((e,t,o,n)=>{const r=Hr(VB(t,o.isPositionedAtTop())),s=n=>{const{pos:s,bounds:a}=VB(t,o.isPositionedAtTop()),{pos:i,bounds:l}=r.get(),c=a.height!==l.height||a.width!==l.width;r.set({pos:s,bounds:a}),c&&iC(e,n),o.isVisible()&&(i!==s?o.update(OM.reset):c&&(o.updateMode(),o.repositionPopups()))};n||(e.on("activate",o.show),e.on("deactivate",o.hide)),e.on("SkinLoaded ResizeWindow",(()=>o.update(OM.reset))),e.on("NodeChange keydown",(e=>{requestAnimationFrame((()=>s(e)))}));let a=0;const i=iT((()=>o.update(OM.refresh)),33);e.on("ScrollWindow",(()=>{const e=zo().left;e!==a&&(a=e,i.throttle()),o.updateMode()})),Kb(e)&&e.on("ElementScroll",(e=>{o.update(OM.refresh)}));const l=Sc();l.set(Tc(Le.fromDom(e.getBody()),"load",(e=>s(e.raw)))),e.on("remove",(()=>{l.clear()}))})(e,i,l,c),e.nodeChanged()};e.on("show",d),e.on("hide",l.hide),c||(e.on("focus",d),e.on("blur",l.hide)),e.on("init",(()=>{(e.hasFocus()||c)&&d()})),ux(e,t);const m={show:d,hide:l.hide,setEnabled:e=>{mx(t,!e)},isEnabled:()=>!wg.isDisabled(s.outerContainer)};return{editorContainer:s.outerContainer.element.dom,api:m}}});const UB="contexttoolbar-hide",jB=(e,t)=>Qs(NT,((o,n)=>{const r=(e=>({hide:()=>js(e,Es()),getValue:()=>Xm.getValue(e)}))(e.get(o));t.onAction(r,n.event.buttonApi)})),WB=(e,t,o)=>(e=>"contextformtogglebutton"===e.type)(t)?((e,t,o)=>{const{primary:n,...r}=t.original,s=or(kw({...r,type:"togglebutton",onAction:v}));return wB(s,o,[jB(e,t)])})(e,t,o):((e,t,o)=>{const{primary:n,...r}=t.original,s=or(xw({...r,type:"button",onAction:v}));return yB(s,o,[jB(e,t)])})(e,t,o),$B=(e,t)=>{const o=e.label.fold((()=>({})),(e=>({"aria-label":e}))),n=Bf(_y.sketch({inputClasses:["tox-toolbar-textfield","tox-toolbar-nav-js"],data:e.initValue(),inputAttributes:o,selectOnFocus:!0,inputBehaviours:ql([Tp.config({mode:"special",onEnter:e=>r.findPrimary(e).map((e=>($s(e),!0))),onLeft:(e,t)=>(t.cut(),D.none()),onRight:(e,t)=>(t.cut(),D.none())})])})),r=((e,t,o)=>{const n=F(t,(t=>Bf(WB(e,t,o))));return{asSpecs:()=>F(n,(e=>e.asSpec())),findPrimary:e=>se(t,((t,o)=>t.primary?D.from(n[o]).bind((t=>t.getOpt(e))).filter(k(wg.isDisabled)):D.none()))}})(n,e.commands,t);return[{title:D.none(),items:[n.asSpec()]},{title:D.none(),items:r.asSpecs()}]},qB=$B,GB=(e,t,o)=>t.bottom-e.y>=o&&e.bottom-t.y>=o,KB=e=>{const t=(e=>{const t=e.getBoundingClientRect();if(t.height<=0&&t.width<=0){const o=dt(Le.fromDom(e.startContainer),e.startOffset).element;return(We(o)?nt(o):D.some(o)).filter(je).map((e=>e.dom.getBoundingClientRect())).getOr(t)}return t})(e.selection.getRng());if(e.inline){const e=zo();return Go(e.left+t.left,e.top+t.top,t.width,t.height)}{const o=Yo(Le.fromDom(e.getBody()));return Go(o.x+t.left,o.y+t.top,t.width,t.height)}},YB=(e,t,o,n=0)=>{const r=Uo(window),s=Ko(Le.fromDom(e.getContentAreaContainer())),a=Hb(e)||zb(e)||Zb(e),{x:i,width:l}=((e,t,o)=>{const n=Math.max(e.x+o,t.x);return{x:n,width:Math.min(e.right-o,t.right)-n}})(s,r,n);if(e.inline&&!a)return Go(i,r.y,l,r.height);{const a=t.header.isPositionedAtTop(),{y:c,bottom:d}=((e,t,o,n,r,s)=>{const a=Le.fromDom(e.getContainer()),i=Bi(a,".tox-editor-header").getOr(a),l=Ko(i),c=l.y>=t.bottom,d=n&&!c;if(e.inline&&d)return{y:Math.max(l.bottom+s,o.y),bottom:o.bottom};if(e.inline&&!d)return{y:o.y,bottom:Math.min(l.y-s,o.bottom)};const m="line"===r?Ko(a):t;return d?{y:Math.max(l.bottom+s,o.y),bottom:Math.min(m.bottom-s,o.bottom)}:{y:Math.max(m.y+s,o.y),bottom:Math.min(l.y-s,o.bottom)}})(e,s,r,a,o,n);return Go(i,c,l,d-c)}},XB={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"],inset:["tox-pop--inset"]},JB={maxHeightFunction:Fc(),maxWidthFunction:wN()},QB=e=>"node"===e,eL=(e,t,o,n,r)=>{const s=KB(e),a=n.lastElement().exists((e=>Xe(o,e)));if(((e,t)=>{const o=e.selection.getRng(),n=dt(Le.fromDom(o.startContainer),o.startOffset);return o.startContainer===o.endContainer&&o.startOffset===o.endOffset-1&&Xe(n.element,t)})(e,o))return a?ZD:ID;if(a)return((e,t,o)=>{const n=Ht(e,"position");Mt(e,"position",t);const r=o(e);return n.each((t=>Mt(e,"position",t))),r})(t,n.getMode(),(()=>GB(s,Ko(t),-20)&&!n.isReposition()?jD:ZD));return("fixed"===n.getMode()?r.y+zo().top:r.y)+(Ut(t)+12)<=s.y?ID:PD},tL=(e,t,o,n)=>{const r=t=>(n,r,s,a,i)=>({...eL(e,a,t,o,i)({...n,y:i.y,height:i.height},r,s,a,i),alwaysFit:!0}),s=e=>QB(n)?[r(e)]:[];return t?{onLtr:e=>[Nl,Tl,Ol,Dl,Al,Ml].concat(s(e)),onRtl:e=>[Nl,Ol,Tl,Al,Dl,Ml].concat(s(e))}:{onLtr:e=>[Ml,Nl,Dl,Tl,Al,Ol].concat(s(e)),onRtl:e=>[Ml,Nl,Al,Ol,Dl,Tl].concat(s(e))}},oL=(e,t)=>{const o=Z(t,(t=>t.predicate(e.dom))),{pass:n,fail:r}=V(o,(e=>"contexttoolbar"===e.type));return{contextToolbars:n,contextForms:r}},nL=(e,t,o)=>{const n=oL(e,t);if(n.contextForms.length>0)return D.some({elem:e,toolbars:[n.contextForms[0]]});{const t=oL(e,o);if(t.contextForms.length>0)return D.some({elem:e,toolbars:[t.contextForms[0]]});if(n.contextToolbars.length>0||t.contextToolbars.length>0){const o=(e=>{if(e.length<=1)return e;{const t=t=>H(e,(e=>e.position===t)),o=t=>Z(e,(e=>e.position===t)),n=t("selection"),r=t("node");if(n||r){if(r&&n){const e=o("node"),t=F(o("selection"),(e=>({...e,position:"node"})));return e.concat(t)}return o(n?"selection":"node")}return o("line")}})(n.contextToolbars.concat(t.contextToolbars));return D.some({elem:e,toolbars:o})}return D.none()}},rL=(e,t,o)=>e(t)?D.none():Ur(t,(e=>{if(je(e)){const{contextToolbars:t,contextForms:n}=oL(e,o.inNodeScope),r=n.length>0?n:(e=>{if(e.length<=1)return e;{const t=t=>W(e,(e=>e.position===t)),o=t("selection").orThunk((()=>t("node"))).orThunk((()=>t("line"))).map((e=>e.position));return o.fold((()=>[]),(t=>Z(e,(e=>e.position===t))))}})(t);return r.length>0?D.some({elem:e,toolbars:r}):D.none()}return D.none()}),e),sL=(e,t)=>{const o={},n=[],r=[],s={},a={},i=(e,i)=>{const l=or(tr("ContextForm",Mw,i));o[e]=l,l.launch.map((o=>{s["form:"+e]={...i.launch,type:"contextformtogglebutton"===o.type?"togglebutton":"button",onAction:()=>{t(l)}}})),"editor"===l.scope?r.push(l):n.push(l),a[e]=l},l=(e,t)=>{var o;(o=t,tr("ContextToolbar",Nw,o)).each((o=>{"editor"===t.scope?r.push(o):n.push(o),a[e]=o}))},c=ae(e);return z(c,(t=>{const o=e[t];"contextform"===o.type?i(t,o):"contexttoolbar"===o.type&&l(t,o)})),{forms:o,inNodeScope:n,inEditorScope:r,lookupTable:a,formNavigators:s}},aL=ya("forward-slide"),iL=ya("backward-slide"),lL=ya("change-slide-event"),cL="tox-pop--resizing",dL="tox-pop--transition",mL=(e,t,o,n)=>{const r=n.backstage,s=r.shared,a=Do().deviceType.isTouch,i=kc(),l=kc(),c=kc(),d=Ei((e=>{const t=Hr([]);return Af.sketch({dom:{tag:"div",classes:["tox-pop"]},fireDismissalEventInstead:{event:"doNotDismissYet"},onShow:e=>{t.set([]),Af.getContent(e).each((e=>{Ft(e.element,"visibility")})),ni(e.element,cL),Ft(e.element,"width")},inlineBehaviours:ql([Ip("context-toolbar-events",[aa(gs(),((e,t)=>{"width"===t.event.raw.propertyName&&(ni(e.element,cL),Ft(e.element,"width"))})),Qs(lL,((e,t)=>{const o=e.element;Ft(o,"width");const n=Xt(o);Af.setContent(e,t.event.contents),ti(o,cL);const r=Xt(o);Mt(o,"width",n+"px"),Af.getContent(e).each((e=>{t.event.focus.bind((e=>(tc(e),sc(o)))).orThunk((()=>(Tp.focusIn(e),rc(ht(o)))))})),setTimeout((()=>{Mt(e.element,"width",r+"px")}),0)})),Qs(aL,((e,o)=>{Af.getContent(e).each((o=>{t.set(t.get().concat([{bar:o,focus:rc(ht(e.element))}]))})),Ws(e,lL,{contents:o.event.forwardContents,focus:D.none()})})),Qs(iL,((e,o)=>{ne(t.get()).each((o=>{t.set(t.get().slice(0,t.get().length-1)),Ws(e,lL,{contents:Ti(o.bar),focus:o.focus})}))}))]),Tp.config({mode:"special",onEscape:o=>ne(t.get()).fold((()=>e.onEscape()),(e=>(js(o,iL),D.some(!0))))})]),lazySink:()=>on.value(e.sink)})})({sink:o,onEscape:()=>(e.focus(),D.some(!0))})),m=()=>{const t=c.get().getOr("node"),o=QB(t)?1:0;return YB(e,s,t,o)},u=()=>!(e.removed||a()&&r.isContextMenuOpen()),g=()=>{if(u()){const t=m(),o=we(c.get(),"node")?((e,t)=>t.filter((e=>yt(e)&&Ue(e))).map(Yo).getOrThunk((()=>KB(e))))(e,i.get()):KB(e);return t.height<=0||!GB(o,t,.01)}return!0},h=()=>{i.clear(),l.clear(),c.clear(),Af.hide(d)},p=()=>{if(Af.isOpen(d)){const e=d.element;Ft(e,"display"),g()?Mt(e,"display","none"):(l.set(0),Af.reposition(d))}},f=t=>({dom:{tag:"div",classes:["tox-pop__dialog"]},components:[t],behaviours:ql([Tp.config({mode:"acyclic"}),Ip("pop-dialog-wrap-events",[ia((t=>{e.shortcuts.add("ctrl+F9","focus statusbar",(()=>Tp.focusIn(t)))})),la((t=>{e.shortcuts.remove("ctrl+F9")}))])])}),b=Qt((()=>sL(t,(e=>{const t=y([e]);Ws(d,aL,{forwardContents:f(t)})})))),y=t=>{const{buttons:o}=e.ui.registry.getAll(),r={...o,...b().formNavigators},a=cb(e)===Uv.scrolling?Uv.scrolling:Uv.default,i=q(F(t,(t=>"contexttoolbar"===t.type?((t,o)=>OB(e,{buttons:t,toolbar:o.items,allowToolbarGroups:!1},n.backstage,D.some(["form:"])))(r,t):((e,t)=>qB(e,t))(t,s.providers))));return WN({type:a,uid:ya("context-toolbar"),initGroups:i,onEscape:D.none,cyclicKeying:!0,providers:s.providers})},w=(t,n)=>{const r="node"===t?s.anchors.node(n):s.anchors.cursor(),c=((e,t,o,n)=>"line"===t?{bubble:Uc(12,0,XB),layouts:{onLtr:()=>[Rl],onRtl:()=>[Bl]},overrides:JB}:{bubble:Uc(0,12,XB,1/12),layouts:tL(e,o,n,t),overrides:JB})(e,t,a(),{lastElement:i.get,isReposition:()=>we(l.get(),0),getMode:()=>rm.getMode(o)});return xn(r,c)},x=(e,t)=>{if(S.cancel(),!u())return;const n=y(e),r=e[0].position,s=w(r,t);c.set(r),l.set(1);const a=d.element;Ft(a,"display"),(e=>we(Ce(e,i.get(),Xe),!0))(t)||(ni(a,dL),rm.reset(o,d)),Af.showWithinBounds(d,f(n),{anchor:s,transition:{classes:[dL],mode:"placement"}},(()=>D.some(m()))),t.fold(i.clear,i.set),g()&&Mt(a,"display","none")};let C=!1;const S=iT((()=>{if(e.hasFocus()&&!e.removed&&!C)if(si(d.element,dL))S.throttle();else{((e,t)=>{const o=Le.fromDom(t.getBody()),n=e=>Xe(e,o),r=Le.fromDom(t.selection.getNode());return(e=>!n(e)&&!Je(o,e))(r)?D.none():nL(r,e.inNodeScope,e.inEditorScope).orThunk((()=>rL(n,r,e)))})(b(),e).fold(h,(e=>{x(e.toolbars,D.some(e.elem))}))}}),17);e.on("init",(()=>{e.on("remove",h),e.on("ScrollContent ScrollWindow ObjectResized ResizeEditor longpress",p),e.on("click keyup focus SetContent",S.throttle),e.on(UB,h),e.on("contexttoolbar-show",(t=>{const o=b();ve(o.lookupTable,t.toolbarKey).each((o=>{x([o],ke(t.target!==e,t.target)),Af.getContent(d).each(Tp.focusIn)}))})),e.on("focusout",(t=>{Mf.setEditorTimeout(e,(()=>{sc(o.element).isNone()&&sc(d.element).isNone()&&h()}),0)})),e.on("SwitchMode",(()=>{e.mode.isReadOnly()&&h()})),e.on("AfterProgressState",(t=>{t.state?h():e.hasFocus()&&S.throttle()})),e.on("dragstart",(()=>{C=!0})),e.on("dragend drop",(()=>{C=!1})),e.on("NodeChange",(e=>{sc(d.element).fold(S.throttle,v)}))}))},uL=(e,t)=>{const o=()=>{const o=t.getOptions(e),n=t.getCurrent(e).map(t.hash),r=kc();return F(o,(o=>({type:"togglemenuitem",text:t.display(o),onSetup:s=>{const a=e=>{e&&(r.on((e=>e.setActive(!1))),r.set(s)),s.setActive(e)};a(we(n,t.hash(o)));const i=t.watcher(e,o,a);return()=>{r.clear(),i()}},onAction:()=>t.setCurrent(e,o)})))};e.ui.registry.addMenuButton(t.name,{tooltip:t.text,icon:t.icon,fetch:e=>e(o()),onSetup:t.onToolbarSetup}),e.ui.registry.addNestedMenuItem(t.name,{type:"nestedmenuitem",text:t.text,getSubmenuItems:o,onSetup:t.onMenuSetup})},gL=e=>({name:"lineheight",text:"Line height",icon:"line-height",getOptions:Fb,hash:e=>((e,t)=>YR(e,t).map((({value:e,unit:t})=>e+t)))(e,["fixed","relative","empty"]).getOr(e),display:x,watcher:(e,t,o)=>e.formatter.formatChanged("lineheight",o,!1,{value:t}).unbind,getCurrent:e=>D.from(e.queryCommandValue("LineHeight")),setCurrent:(e,t)=>e.execCommand("LineHeight",!1,t),onToolbarSetup:mC(e),onMenuSetup:mC(e)}),hL=e=>{uL(e,gL(e)),(e=>D.from(ib(e)).map((t=>({name:"language",text:"Language",icon:"language",getOptions:w(t),hash:e=>m(e.customCode)?e.code:`${e.code}/${e.customCode}`,display:e=>e.title,watcher:(e,t,o)=>{var n;return e.formatter.formatChanged("lang",o,!1,{value:t.code,customValue:null!==(n=t.customCode)&&void 0!==n?n:null}).unbind},getCurrent:e=>{const t=Le.fromDom(e.selection.getNode());return jr(t,(e=>D.some(e).filter(je).bind((e=>Et(e,"lang").map((t=>({code:t,customCode:Et(e,"data-mce-lang").getOrUndefined(),title:""})))))))},setCurrent:(e,t)=>e.execCommand("Lang",!1,t),onToolbarSetup:t=>{const o=Sc();return t.setActive(e.formatter.match("lang",{},void 0,!0)),o.set(e.formatter.formatChanged("lang",t.setActive,!0)),dC(o.clear,mC(e)(t))},onMenuSetup:mC(e)}))))(e).each((t=>uL(e,t)))},pL=(e,t)=>{((e,t)=>{const o=AR(0,t,IR(e));e.ui.registry.addNestedMenuItem("align",{text:t.shared.providers.translate("Align"),onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=AR(0,t,qR(e));e.ui.registry.addNestedMenuItem("fontfamily",{text:t.shared.providers.translate("Fonts"),onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o={type:"advanced",...t.styles},n=AR(0,t,iB(e,o));e.ui.registry.addNestedMenuItem("styles",{text:"Formats",onSetup:mC(e),getSubmenuItems:()=>n.items.validateItems(n.getStyleItems())})})(e,t),((e,t)=>{const o=AR(0,t,VR(e));e.ui.registry.addNestedMenuItem("blocks",{text:"Blocks",onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=AR(0,t,sB(e));e.ui.registry.addNestedMenuItem("fontsize",{text:"Font sizes",onSetup:mC(e),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t)},fL=e=>gC(e,"NodeChange",(t=>{t.setEnabled(e.queryCommandState("outdent")&&e.selection.isEditable())})),vL=e=>{(e=>{e.ui.registry.addButton("outdent",{tooltip:"Decrease indent",icon:"outdent",onSetup:fL(e),onAction:pC(e,"outdent")}),e.ui.registry.addButton("indent",{tooltip:"Increase indent",icon:"indent",onSetup:mC(e),onAction:pC(e,"indent")})})(e)},bL=(e,t)=>o=>{o.setActive(t.get());const n=e=>{t.set(e.state),o.setActive(e.state)};return e.on("PastePlainTextToggle",n),dC((()=>e.off("PastePlainTextToggle",n)),mC(e)(o))},yL=(e,t)=>()=>{e.execCommand("mceToggleFormat",!1,t)},wL=e=>{(e=>{sT.each([{name:"bold",text:"Bold",icon:"bold"},{name:"italic",text:"Italic",icon:"italic"},{name:"underline",text:"Underline",icon:"underline"},{name:"strikethrough",text:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",icon:"superscript"}],((t,o)=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:uC(e,t.name),onAction:yL(e,t.name)})}));for(let t=1;t<=6;t++){const o="h"+t;e.ui.registry.addToggleButton(o,{text:o.toUpperCase(),tooltip:"Heading "+t,onSetup:uC(e,o),onAction:yL(e,o)})}})(e),(e=>{sT.each([{name:"copy",text:"Copy",action:"Copy",icon:"copy"},{name:"help",text:"Help",action:"mceHelp",icon:"help"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all"},{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"print",text:"Print",action:"mcePrint",icon:"print"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onAction:pC(e,t.action)})})),sT.each([{name:"cut",text:"Cut",action:"Cut",icon:"cut"},{name:"paste",text:"Paste",action:"Paste",icon:"paste"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"remove",text:"Remove",action:"Delete",icon:"remove"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:mC(e),onAction:pC(e,t.action)})}))})(e),(e=>{sT.each([{name:"blockquote",text:"Blockquote",action:"mceBlockQuote",icon:"quote"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:pC(e,t.action),onSetup:uC(e,t.name)})}))})(e)},xL=e=>{wL(e),(e=>{sT.each([{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"copy",text:"Copy",action:"Copy",icon:"copy",shortcut:"Meta+C"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all",shortcut:"Meta+A"},{name:"print",text:"Print...",action:"mcePrint",icon:"print",shortcut:"Meta+P"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onAction:pC(e,t.action)})})),sT.each([{name:"bold",text:"Bold",action:"Bold",icon:"bold",shortcut:"Meta+B"},{name:"italic",text:"Italic",action:"Italic",icon:"italic",shortcut:"Meta+I"},{name:"underline",text:"Underline",action:"Underline",icon:"underline",shortcut:"Meta+U"},{name:"strikethrough",text:"Strikethrough",action:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",action:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",action:"Superscript",icon:"superscript"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"cut",text:"Cut",action:"Cut",icon:"cut",shortcut:"Meta+X"},{name:"paste",text:"Paste",action:"Paste",icon:"paste",shortcut:"Meta+V"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onSetup:mC(e),onAction:pC(e,t.action)})})),e.ui.registry.addMenuItem("codeformat",{text:"Code",icon:"sourcecode",onSetup:mC(e),onAction:yL(e,"code")})})(e)},CL=(e,t)=>gC(e,"Undo Redo AddUndo TypingUndo ClearUndos SwitchMode",(o=>{o.setEnabled(!e.mode.isReadOnly()&&e.undoManager[t]())})),SL=e=>{(e=>{e.ui.registry.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onSetup:CL(e,"hasUndo"),onAction:pC(e,"undo")}),e.ui.registry.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onSetup:CL(e,"hasRedo"),onAction:pC(e,"redo")})})(e),(e=>{e.ui.registry.addButton("undo",{tooltip:"Undo",icon:"undo",enabled:!1,onSetup:CL(e,"hasUndo"),onAction:pC(e,"undo")}),e.ui.registry.addButton("redo",{tooltip:"Redo",icon:"redo",enabled:!1,onSetup:CL(e,"hasRedo"),onAction:pC(e,"redo")})})(e)},kL=e=>gC(e,"VisualAid",(t=>{t.setActive(e.hasVisual)})),_L=e=>{(e=>{e.ui.registry.addButton("visualaid",{tooltip:"Visual aids",text:"Visual aids",onAction:pC(e,"mceToggleVisualAid")})})(e),(e=>{e.ui.registry.addToggleMenuItem("visualaid",{text:"Visual aids",onSetup:kL(e),onAction:pC(e,"mceToggleVisualAid")})})(e)},EL=(e,t)=>{(e=>{z([{name:"alignleft",text:"Align left",cmd:"JustifyLeft",icon:"align-left"},{name:"aligncenter",text:"Align center",cmd:"JustifyCenter",icon:"align-center"},{name:"alignright",text:"Align right",cmd:"JustifyRight",icon:"align-right"},{name:"alignjustify",text:"Justify",cmd:"JustifyFull",icon:"align-justify"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:pC(e,t.cmd),onSetup:uC(e,t.name)})})),e.ui.registry.addButton("alignnone",{tooltip:"No alignment",icon:"align-none",onSetup:mC(e),onAction:pC(e,"JustifyNone")})})(e),xL(e),pL(e,t),SL(e),(e=>{(e=>{e.addCommand("mceApplyTextcolor",((t,o)=>{((e,t,o)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.apply(t,{value:o}),e.nodeChanged()}))})(e,t,o)})),e.addCommand("mceRemoveTextcolor",(t=>{((e,t)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.remove(t,{value:null},void 0,!0),e.nodeChanged()}))})(e,t)}))})(e);const t=BC(e),o=LC(e),n=Hr(t),r=Hr(o);$C(e,"forecolor","forecolor",n),$C(e,"backcolor","hilitecolor",r),qC(e,"forecolor","forecolor","Text color",n),qC(e,"backcolor","hilitecolor","Background color",r)})(e),_L(e),vL(e),hL(e),(e=>{const t=Hr(Ab(e)),o=()=>e.execCommand("mceTogglePlainTextPaste");e.ui.registry.addToggleButton("pastetext",{active:!1,icon:"paste-text",tooltip:"Paste as text",onAction:o,onSetup:bL(e,t)}),e.ui.registry.addToggleMenuItem("pastetext",{text:"Paste as text",icon:"paste-text",onAction:o,onSetup:bL(e,t)})})(e)},TL=e=>s(e)?e.split(/[ ,]/):e,OL=e=>t=>t.options.get(e),DL=OL("contextmenu_never_use_native"),AL=OL("contextmenu_avoid_overlap"),ML=e=>{const t=e.ui.registry.getAll().contextMenus,o=e.options.get("contextmenu");return e.options.isSet("contextmenu")?o:Z(o,(e=>be(t,e)))},NL=(e,t)=>({type:"makeshift",x:e,y:t}),RL=e=>"longpress"===e.type||0===e.type.indexOf("touch"),BL=(e,t)=>{const o=Wv.DOM.getPos(e);return((e,t,o)=>NL(e.x+t,e.y+o))(t,o.x,o.y)},LL=(e,t)=>"contextmenu"===t.type||"longpress"===t.type?e.inline?(e=>{if(RL(e)){const t=e.touches[0];return NL(t.pageX,t.pageY)}return NL(e.pageX,e.pageY)})(t):BL(e.getContentAreaContainer(),(e=>{if(RL(e)){const t=e.touches[0];return NL(t.clientX,t.clientY)}return NL(e.clientX,e.clientY)})(t)):HL(e),HL=e=>({type:"selection",root:Le.fromDom(e.selection.getNode())}),IL=(e,t,o)=>{switch(o){case"node":return(e=>({type:"node",node:D.some(Le.fromDom(e.selection.getNode())),root:Le.fromDom(e.getBody())}))(e);case"point":return LL(e,t);case"selection":return HL(e)}},PL=(e,t,o,n,r,s)=>{const a=o(),i=IL(e,t,s);qT(a,oy.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!1,search:D.none()}).map((e=>{t.preventDefault(),Af.showMenuAt(r,{anchor:i},{menu:{markers:vy("normal")},data:e})}))},FL={onLtr:()=>[Nl,Tl,Ol,Dl,Al,Ml,ID,PD,HD,BD,LD,RD],onRtl:()=>[Nl,Ol,Tl,Al,Dl,Ml,ID,PD,LD,RD,HD,BD]},zL={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"]},VL=(e,t,o,n,r,s,a)=>{const i=((e,t,o)=>{const n=IL(e,t,o);return{bubble:Uc(0,"point"===o?12:0,zL),layouts:FL,overrides:{maxWidthFunction:wN(),maxHeightFunction:Fc()},...n}})(e,t,s);qT(o,oy.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!0,search:D.none()}).map((o=>{t.preventDefault();const l=a?Tf.HighlightMenuAndItem:Tf.HighlightNone;Af.showMenuWithinBounds(r,{anchor:i},{menu:{markers:vy("normal"),highlightOnOpen:l},data:o,type:"horizontal"},(()=>D.some(YB(e,n.shared,"node"===s?"node":"selection")))),e.dispatch(UB)}))},ZL=(e,t,o,n,r,s)=>{const a=Do(),i=a.os.isiOS(),l=a.os.isMacOS(),c=a.os.isAndroid(),d=a.deviceType.isTouch(),m=()=>{const a=o();VL(e,t,a,n,r,s,!(c||i||l&&d))};if((l||i)&&"node"!==s){const o=()=>{(e=>{const t=e.selection.getRng(),o=()=>{Mf.setEditorTimeout(e,(()=>{e.selection.setRng(t)}),10),s()};e.once("touchend",o);const n=e=>{e.preventDefault(),e.stopImmediatePropagation()};e.on("mousedown",n,!0);const r=()=>s();e.once("longpresscancel",r);const s=()=>{e.off("touchend",o),e.off("longpresscancel",r),e.off("mousedown",n)}})(e),m()};((e,t)=>{const o=e.selection;if(o.isCollapsed()||t.touches.length<1)return!1;{const n=t.touches[0],r=o.getRng();return Ad(e.getWin(),fd.domRange(r)).exists((e=>e.left<=n.clientX&&e.right>=n.clientX&&e.top<=n.clientY&&e.bottom>=n.clientY))}})(e,t)?o():(e.once("selectionchange",o),e.once("touchend",(()=>e.off("selectionchange",o))))}else m()},UL=e=>s(e)?"|"===e:"separator"===e.type,jL={type:"separator"},WL=e=>{const t=e=>({text:e.text,icon:e.icon,enabled:e.enabled,shortcut:e.shortcut});if(s(e))return e;switch(e.type){case"separator":return jL;case"submenu":return{type:"nestedmenuitem",...t(e),getSubmenuItems:()=>{const t=e.getSubmenuItems();return s(t)?t:F(t,WL)}};default:const o=e;return{type:"menuitem",...t(o),onAction:b(o.onAction)}}},$L=(e,t)=>{if(0===t.length)return e;const o=ne(e).filter((e=>!UL(e))),n=o.fold((()=>[]),(e=>[jL]));return e.concat(n).concat(t).concat([jL])},qL=(e,t)=>!(e=>"longpress"===e.type||be(e,"touches"))(t)&&(2!==t.button||t.target===e.getBody()&&""===t.pointerType),GL=(e,t)=>qL(e,t)?e.selection.getStart(!0):t.target,KL=(e,t,o)=>{const n=Do().deviceType.isTouch,r=Ei(Af.sketch({dom:{tag:"div"},lazySink:t,onEscape:()=>e.focus(),onShow:()=>o.setContextMenuState(!0),onHide:()=>o.setContextMenuState(!1),fireDismissalEventInstead:{},inlineBehaviours:ql([Ip("dismissContextMenu",[Qs(Ls(),((t,o)=>{Mm.close(t),e.focus()}))])])})),a=()=>Af.hide(r),i=t=>{if(DL(e)&&t.preventDefault(),((e,t)=>t.ctrlKey&&!DL(e))(e,t)||(e=>0===ML(e).length)(e))return;const a=((e,t)=>{const o=AL(e),n=qL(e,t)?"selection":"point";if(Me(o)){const r=GL(e,t);return QS(Le.fromDom(r),o)?"node":n}return n})(e,t);(n()?ZL:PL)(e,t,(()=>{const o=GL(e,t),n=e.ui.registry.getAll(),r=ML(e);return((e,t,o)=>{const n=j(t,((t,n)=>ve(e,n.toLowerCase()).map((e=>{const n=e.update(o);if(s(n)&&Me(Ae(n)))return $L(t,n.split(" "));if(l(n)&&n.length>0){const e=F(n,WL);return $L(t,e)}return t})).getOrThunk((()=>t.concat([n])))),[]);return n.length>0&&UL(n[n.length-1])&&n.pop(),n})(n.contextMenus,r,o)}),o,r,a)};e.on("init",(()=>{const t="ResizeEditor ScrollContent ScrollWindow longpresscancel"+(n()?"":" ResizeWindow");e.on(t,a),e.on("longpress contextmenu",i)}))},YL=Ir([{offset:["x","y"]},{absolute:["x","y"]},{fixed:["x","y"]}]),XL=e=>t=>t.translate(-e.left,-e.top),JL=e=>t=>t.translate(e.left,e.top),QL=e=>(t,o)=>j(e,((e,t)=>t(e)),$t(t,o)),eH=(e,t,o)=>e.fold(QL([JL(o),XL(t)]),QL([XL(t)]),QL([])),tH=(e,t,o)=>e.fold(QL([JL(o)]),QL([]),QL([JL(t)])),oH=(e,t,o)=>e.fold(QL([]),QL([XL(o)]),QL([JL(t),XL(o)])),nH=(e,t,o)=>{const n=e.fold(((e,t)=>({position:D.some("absolute"),left:D.some(e+"px"),top:D.some(t+"px")})),((e,t)=>({position:D.some("absolute"),left:D.some(e-o.left+"px"),top:D.some(t-o.top+"px")})),((e,t)=>({position:D.some("fixed"),left:D.some(e+"px"),top:D.some(t+"px")})));return{right:D.none(),bottom:D.none(),...n}},rH=(e,t,o,n)=>{const r=(e,r)=>(s,a)=>{const i=e(t,o,n);return r(s.getOr(i.left),a.getOr(i.top))};return e.fold(r(oH,sH),r(tH,aH),r(eH,iH))},sH=YL.offset,aH=YL.absolute,iH=YL.fixed,lH=(e,t)=>{const o=_t(e,t);return m(o)?NaN:parseInt(o,10)},cH=(e,t,o,n)=>((e,t)=>{const o=e.element,n=lH(o,t.leftAttr),r=lH(o,t.topAttr);return isNaN(n)||isNaN(r)?D.none():D.some($t(n,r))})(e,t).fold((()=>o),(e=>iH(e.left+n.left,e.top+n.top))),dH=(e,t,o,n,r,s)=>{const a=cH(e,t,o,n),i=t.mustSnap?gH(e,t,a,r,s):hH(e,t,a,r,s),l=eH(a,r,s);return((e,t,o)=>{const n=e.element;St(n,t.leftAttr,o.left+"px"),St(n,t.topAttr,o.top+"px")})(e,t,l),i.fold((()=>({coord:iH(l.left,l.top),extra:D.none()})),(e=>({coord:e.output,extra:e.extra})))},mH=(e,t)=>{((e,t)=>{const o=e.element;Ot(o,t.leftAttr),Ot(o,t.topAttr)})(e,t)},uH=(e,t,o,n)=>se(e,(e=>{const r=e.sensor,s=((e,t,o,n,r,s)=>{const a=tH(e,r,s),i=tH(t,r,s);return Math.abs(a.left-i.left)<=o&&Math.abs(a.top-i.top)<=n})(t,r,e.range.left,e.range.top,o,n);return s?D.some({output:rH(e.output,t,o,n),extra:e.extra}):D.none()})),gH=(e,t,o,n,r)=>{const s=t.getSnapPoints(e);return uH(s,o,n,r).orThunk((()=>{const e=j(s,((e,t)=>{const s=t.sensor,a=((e,t,o,n,r,s)=>{const a=tH(e,r,s),i=tH(t,r,s),l=Math.abs(a.left-i.left),c=Math.abs(a.top-i.top);return $t(l,c)})(o,s,t.range.left,t.range.top,n,r);return e.deltas.fold((()=>({deltas:D.some(a),snap:D.some(t)})),(o=>(a.left+a.top)/2<=(o.left+o.top)/2?{deltas:D.some(a),snap:D.some(t)}:e))}),{deltas:D.none(),snap:D.none()});return e.snap.map((e=>({output:rH(e.output,o,n,r),extra:e.extra})))}))},hH=(e,t,o,n,r)=>{const s=t.getSnapPoints(e);return uH(s,o,n,r)};var pH=Object.freeze({__proto__:null,snapTo:(e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const t=Qe(e.element),o=zo(t),s=JA(r),a=((e,t,o)=>({coord:rH(e.output,e.output,t,o),extra:e.extra}))(n,o,s),i=nH(a.coord,0,s);Rt(r,i)}}});const fH="data-initial-z-index",vH=(e,t)=>{e.getSystem().addToGui(t),(e=>{nt(e.element).filter(je).each((t=>{Ht(t,"z-index").each((e=>{St(t,fH,e)})),Mt(t,"z-index",Bt(e.element,"z-index"))}))})(t)},bH=e=>{(e=>{nt(e.element).filter(je).each((e=>{Et(e,fH).fold((()=>Ft(e,"z-index")),(t=>Mt(e,"z-index",t))),Ot(e,fH)}))})(e),e.getSystem().removeFromGui(e)},yH=(e,t,o)=>e.getSystem().build(uk.sketch({dom:{styles:{left:"0px",top:"0px",width:"100%",height:"100%",position:"fixed","z-index":"1000000000000000"},classes:[t]},events:o}));var wH=Er("snaps",[dr("getSnapPoints"),el("onSensor"),dr("leftAttr"),dr("topAttr"),Tr("lazyViewport",Jo),Tr("mustSnap",!1)]);const xH=[Tr("useFixed",T),dr("blockerClass"),Tr("getTarget",x),Tr("onDrag",v),Tr("repositionTarget",!0),Tr("onDrop",v),Rr("getBounds",Jo),wH],CH=e=>((e,t,o,n)=>e.isSome()&&t.isSome()&&o.isSome()?D.some(n(e.getOrDie(),t.getOrDie(),o.getOrDie())):D.none())(Ht(e,"left"),Ht(e,"top"),Ht(e,"position"),((e,t,o)=>("fixed"===o?iH:sH)(parseInt(e,10),parseInt(t,10)))).getOrThunk((()=>{const t=Gt(e);return aH(t.left,t.top)})),SH=(e,t,o,n,r,s,a)=>((e,t,o,n,r)=>{const s=r.bounds,a=tH(t,o,n),i=bl(a.left,s.x,s.x+s.width-r.width),l=bl(a.top,s.y,s.y+s.height-r.height),c=aH(i,l);return t.fold((()=>{const e=oH(c,o,n);return sH(e.left,e.top)}),w(c),(()=>{const e=eH(c,o,n);return iH(e.left,e.top)}))})(0,t.fold((()=>{const e=(t=o,a=s.left,i=s.top,t.fold(((e,t)=>sH(e+a,t+i)),((e,t)=>aH(e+a,t+i)),((e,t)=>iH(e+a,t+i))));var t,a,i;const l=eH(e,n,r);return iH(l.left,l.top)}),(t=>{const a=dH(e,t,o,s,n,r);return a.extra.each((o=>{t.onSensor(e,o)})),a.coord})),n,r,a),kH=(e,t)=>({bounds:e.getBounds(),height:jt(t.element),width:Jt(t.element)}),_H=(e,t,o,n,r)=>{const s=o.update(n,r),a=o.getStartData().getOrThunk((()=>kH(t,e)));s.each((o=>{((e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const s=Qe(e.element),a=zo(s),i=JA(r),l=CH(r),c=SH(e,t.snaps,l,a,i,n,o),d=nH(c,0,i);Rt(r,d)}t.onDrag(e,r,n)})(e,t,a,o)}))},EH=(e,t,o,n)=>{t.each(bH),o.snaps.each((t=>{mH(e,t)}));const r=o.getTarget(e.element);n.reset(),o.onDrop(e,r)},TH=e=>(t,o)=>{const n=e=>{o.setStartData(kH(t,e))};return Ys([Qs(Ms(),(e=>{o.getStartData().each((()=>n(e)))})),...e(t,o,n)])};var OH=Object.freeze({__proto__:null,getData:e=>D.from($t(e.x,e.y)),getDelta:(e,t)=>$t(t.left-e.left,t.top-e.top)});const DH=(e,t,o)=>[Qs(es(),((n,r)=>{if(0!==r.event.raw.button)return;r.stop();const s=()=>EH(n,D.some(l),e,t),a=ek(s,200),i={drop:s,delayDrop:a.schedule,forceDrop:s,move:o=>{a.cancel(),_H(n,e,t,OH,o)}},l=yH(n,e.blockerClass,(e=>Ys([Qs(es(),e.forceDrop),Qs(ns(),e.drop),Qs(ts(),((t,o)=>{e.move(o.event)})),Qs(os(),e.delayDrop)]))(i));o(n),vH(n,l)}))],AH=[...xH,rl("dragger",{handlers:TH(DH)})];var MH=Object.freeze({__proto__:null,getData:e=>{const t=e.raw.touches;return 1===t.length?(e=>{const t=e[0];return D.some($t(t.clientX,t.clientY))})(t):D.none()},getDelta:(e,t)=>$t(t.left-e.left,t.top-e.top)});const NH=(e,t,o)=>{const n=kc(),r=o=>{EH(o,n.get(),e,t),n.clear()};return[Qs(Yr(),((s,a)=>{a.stop();const i=()=>r(s),l={drop:i,delayDrop:v,forceDrop:i,move:o=>{_H(s,e,t,MH,o)}},c=yH(s,e.blockerClass,(e=>Ys([Qs(Yr(),e.forceDrop),Qs(Jr(),e.drop),Qs(Qr(),e.drop),Qs(Xr(),((t,o)=>{e.move(o.event)}))]))(l));n.set(c);o(s),vH(s,c)})),Qs(Xr(),((o,n)=>{n.stop(),_H(o,e,t,MH,n.event)})),Qs(Jr(),((e,t)=>{t.stop(),r(e)})),Qs(Qr(),r)]},RH=AH,BH=[...xH,rl("dragger",{handlers:TH(NH)})],LH=[...xH,rl("dragger",{handlers:TH(((e,t,o)=>[...DH(e,t,o),...NH(e,t,o)]))})];var HH=Object.freeze({__proto__:null,mouse:RH,touch:BH,mouseOrTouch:LH});var IH=Object.freeze({__proto__:null,init:()=>{let e=D.none(),t=D.none();const o=w({});return Ia({readState:o,reset:()=>{e=D.none(),t=D.none()},update:(t,o)=>t.getData(o).bind((o=>((t,o)=>{const n=e.map((e=>t.getDelta(e,o)));return e=D.some(o),n})(t,o))),getStartData:()=>t,setStartData:e=>{t=D.some(e)}})}});const PH=Xl({branchKey:"mode",branches:HH,name:"dragging",active:{events:(e,t)=>e.dragger.handlers(e,t)},extra:{snap:e=>({sensor:e.sensor,range:e.range,output:e.output,extra:D.from(e.extra)})},state:IH,apis:pH}),FH=(e,t,o,n,r,s)=>e.fold((()=>PH.snap({sensor:aH(o-20,n-20),range:$t(r,s),output:aH(D.some(o),D.some(n)),extra:{td:t}})),(e=>{const r=o-20,s=n-20,a=e.element.dom.getBoundingClientRect();return PH.snap({sensor:aH(r,s),range:$t(40,40),output:aH(D.some(o-a.width/2),D.some(n-a.height/2)),extra:{td:t}})})),zH=(e,t,o)=>({getSnapPoints:e,leftAttr:"data-drag-left",topAttr:"data-drag-top",onSensor:(e,n)=>{const r=n.td;((e,t)=>e.exists((e=>Xe(e,t))))(t.get(),r)||(t.set(r),o(r))},mustSnap:!0}),VH=e=>Bf(Nf.sketch({dom:{tag:"div",classes:["tox-selector"]},buttonBehaviours:ql([PH.config({mode:"mouseOrTouch",blockerClass:"blocker",snaps:e}),Wk.config({})]),eventOrder:{mousedown:["dragging","alloy.base.behaviour"],touchstart:["dragging","alloy.base.behaviour"]}})),ZH=(e,t)=>{const o=Hr([]),n=Hr([]),r=Hr(!1),s=kc(),a=kc(),i=e=>{const o=Yo(e);return FH(m.getOpt(t),e,o.x,o.y,o.width,o.height)},l=e=>{const o=Yo(e);return FH(u.getOpt(t),e,o.right,o.bottom,o.width,o.height)},c=zH((()=>F(o.get(),(e=>i(e)))),s,(t=>{a.get().each((o=>{e.dispatch("TableSelectorChange",{start:t,finish:o})}))})),d=zH((()=>F(n.get(),(e=>l(e)))),a,(t=>{s.get().each((o=>{e.dispatch("TableSelectorChange",{start:o,finish:t})}))})),m=VH(c),u=VH(d),g=Ei(m.asSpec()),h=Ei(u.asSpec()),p=(t,o,n,r)=>{const s=n(o);PH.snapTo(t,s);((t,o,n,r)=>{const s=o.dom.getBoundingClientRect();Ft(t.element,"display");const a=ot(Le.fromDom(e.getBody())).dom.innerHeight,i=n(s),l=r(s,a);(i||l)&&Mt(t.element,"display","none")})(t,o,(e=>e[r]<0),((e,t)=>e[r]>t))},f=e=>p(g,e,i,"top"),v=e=>p(h,e,l,"bottom");Do().deviceType.isTouch()&&(e.on("TableSelectionChange",(e=>{r.get()||(um(t,g),um(t,h),r.set(!0)),s.set(e.start),a.set(e.finish),e.otherCells.each((t=>{o.set(t.upOrLeftCells),n.set(t.downOrRightCells),f(e.start),v(e.finish)}))})),e.on("ResizeEditor ResizeWindow ScrollContent",(()=>{s.get().each(f),a.get().each(v)})),e.on("TableSelectionClear",(()=>{r.get()&&(pm(g),pm(h),r.set(!1)),s.clear(),a.clear()})))};const UH=(e,t,o)=>{var n;const r=null!==(n=t.delimiter)&&void 0!==n?n:"›",s=t=>j(t,((t,n,s)=>{const a=((t,n,r)=>Nf.sketch({dom:{tag:"div",classes:["tox-statusbar__path-item"],attributes:{"data-index":r,"aria-level":r+1}},components:[Ci(t)],action:t=>{e.focus(),e.selection.select(n),e.nodeChanged()},buttonBehaviours:ql([px(o.isDisabled),gx()])}))(n.name,n.element,s);return 0===s?t.concat([a]):t.concat([{dom:{tag:"div",classes:["tox-statusbar__path-divider"],attributes:{"aria-hidden":!0}},components:[Ci(` ${r} `)]},a])}),[]);return{dom:{tag:"div",classes:["tox-statusbar__path"],attributes:{role:"navigation"}},behaviours:ql([Tp.config({mode:"flow",selector:"div[role=button]"}),wg.config({disabled:o.isDisabled}),gx(),yk.config({}),Hp.config({}),Ip("elementPathEvents",[ia(((t,o)=>{e.shortcuts.add("alt+F11","focus statusbar elementpath",(()=>Tp.focusIn(t))),e.on("NodeChange",(o=>{const n=(t=>{const o=[];let n=t.length;for(;n-- >0;){const s=t[n];if(1===s.nodeType&&"BR"!==(r=s).nodeName&&!r.getAttribute("data-mce-bogus")&&"bookmark"!==r.getAttribute("data-mce-type")){const t=cC(e,s);if(t.isDefaultPrevented()||o.push({name:t.name,element:s}),t.isPropagationStopped())break}}var r;return o})(o.parents),r=n.length>0?s(n):[];Hp.set(t,r)}))}))])]),components:[]}};var jH;!function(e){e[e.None=0]="None",e[e.Both=1]="Both",e[e.Vertical=2]="Vertical"}(jH||(jH={}));const WH=(e,t,o)=>{const n=Le.fromDom(e.getContainer()),r=((e,t,o,n,r)=>{const s={height:LB(n+t.top,tb(e),nb(e))};return o===jH.Both&&(s.width=LB(r+t.left,eb(e),ob(e))),s})(e,t,o,Ut(n),Xt(n));le(r,((e,t)=>{p(e)&&Mt(n,t,BB(e))})),(e=>{e.dispatch("ResizeEditor")})(e)},$H=(e,t,o,n)=>{const r=$t(20*o,20*n);return WH(e,r,t),D.some(!0)},qH=(e,t)=>{const o=(e=>{const t=Db(e);return!1===t?jH.None:"both"===t?jH.Both:jH.Vertical})(e);if(o===jH.None)return D.none();const n=o===jH.Both?"Press the arrow keys to resize the editor.":"Press the Up and Down arrow keys to resize the editor.";return D.some(zv("resize-handle",{tag:"div",classes:["tox-statusbar__resize-handle"],attributes:{title:t.translate("Resize"),"aria-label":t.translate(n)},behaviours:[PH.config({mode:"mouse",repositionTarget:!1,onDrag:(t,n,r)=>WH(e,r,o),blockerClass:"tox-blocker"}),Tp.config({mode:"special",onLeft:()=>$H(e,o,-1,0),onRight:()=>$H(e,o,1,0),onUp:()=>$H(e,o,0,-1),onDown:()=>$H(e,o,0,1)}),yk.config({}),Zp.config({})]},t.icons))},GH=(e,t)=>{const o=()=>{const o=[];return e.hasPlugin("wordcount")&&o.push(((e,t)=>{const o=(e,o,n)=>Hp.set(e,[Ci(t.translate(["{0} "+n,o[n]]))]);return Nf.sketch({dom:{tag:"button",classes:["tox-statusbar__wordcount"]},components:[],buttonBehaviours:ql([px(t.isDisabled),gx(),yk.config({}),Hp.config({}),Xm.config({store:{mode:"memory",initialValue:{mode:"words",count:{words:0,characters:0}}}}),Ip("wordcount-events",[da((e=>{const t=Xm.getValue(e),n="words"===t.mode?"characters":"words";Xm.setValue(e,{mode:n,count:t.count}),o(e,t.count,n)})),ia((t=>{e.on("wordCountUpdate",(e=>{const{mode:n}=Xm.getValue(t);Xm.setValue(t,{mode:n,count:e.wordCount}),o(t,e.wordCount,n)}))}))])]),eventOrder:{[Cs()]:["disabling","alloy.base.behaviour","wordcount-events"]}})})(e,t)),Ob(e)&&o.push({dom:{tag:"span",classes:["tox-statusbar__branding"]},components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/powered-by-tiny?utm_campaign=poweredby&utm_source=tiny&utm_medium=referral&utm_content=v6",rel:"noopener",target:"_blank","aria-label":Mv.translate(["Powered by {0}","Tiny"])},innerHtml:'\n \n\n'.trim()},behaviours:ql([Zp.config({})])}]}),{dom:{tag:"div",classes:["tox-statusbar__right-container"]},components:o}},n=()=>{const n=[],r=Rb(e),s=Tb(e),a=Ob(e)||e.hasPlugin("wordcount"),i=()=>{const e="tox-statusbar__text-container--flex-start",t="tox-statusbar__text-container--flex-end";if(r){const o="tox-statusbar__text-container-3-cols";return a||s?a&&!s?[o,t]:[o,e]:[o,"tox-statusbar__text-container--space-around"]}return[a&&!s?t:e]};return s&&n.push(UH(e,{},t)),r&&n.push((()=>{const e=Ex("Alt+0");return{dom:{tag:"div",classes:["tox-statusbar__help-text"]},components:[Ci(Mv.translate(["Press {0} for help",e]))]}})()),a&&n.push(o()),n.length>0?[{dom:{tag:"div",classes:["tox-statusbar__text-container",...i()]},components:n}]:[]};return{dom:{tag:"div",classes:["tox-statusbar"]},components:(()=>{const o=n(),r=qH(e,t);return o.concat(r.toArray())})()}},KH=(e,t)=>t.get().getOrDie(`UI for ${e} has not been rendered`),YH=(e,t)=>{const o=e.inline,n=o?ZB:NB,r=Gb(e)?PM:YA,s=(()=>{const e=kc(),t=kc(),o=kc();return{dialogUi:e,popupUi:t,mainUi:o,getUiMotherships:()=>{const o=e.get().map((e=>e.mothership)),n=t.get().map((e=>e.mothership));return o.fold((()=>n.toArray()),(e=>n.fold((()=>[e]),(t=>Xe(e.element,t.element)?[e]:[e,t]))))},lazyGetInOuterOrDie:(e,t)=>()=>o.get().bind((e=>t(e.outerContainer))).getOrDie(`Could not find ${e} element in OuterContainer`)}})(),a=kc(),i=kc(),l=kc(),c=Do().deviceType.isTouch()?["tox-platform-touch"]:[],d=Ub(e),m=cb(e),u=Bf({dom:{tag:"div",classes:["tox-anchorbar"]}}),g=Bf({dom:{tag:"div",classes:["tox-bottom-anchorbar"]}}),h=()=>s.mainUi.get().map((e=>e.outerContainer)).bind(vR.getHeader),p=s.lazyGetInOuterOrDie("anchor bar",u.getOpt),f=s.lazyGetInOuterOrDie("bottom anchor bar",g.getOpt),v=s.lazyGetInOuterOrDie("toolbar",vR.getToolbar),b=s.lazyGetInOuterOrDie("throbber",vR.getThrobber),y=IA({popup:()=>on.fromOption(s.popupUi.get().map((e=>e.sink)),"(popup) UI has not been rendered"),dialog:()=>on.fromOption(s.dialogUi.get().map((e=>e.sink)),"UI has not been rendered")},e,p,f),w=()=>vR.parts.promotion({dom:{tag:"div",classes:["tox-promotion"]}}),x=()=>{const t=(()=>{const t={attributes:{[Kc]:d?Gc.BottomToTop:Gc.TopToBottom}},o=vR.parts.menubar({dom:{tag:"div",classes:["tox-menubar"]},backstage:y.popup,onEscape:()=>{e.focus()}}),n=vR.parts.toolbar({dom:{tag:"div",classes:["tox-toolbar"]},getSink:y.popup.shared.getSink,providers:y.popup.shared.providers,onEscape:()=>{e.focus()},onToolbarToggled:t=>{((e,t)=>{e.dispatch("ToggleToolbarDrawer",{state:t})})(e,t)},type:m,lazyToolbar:v,lazyHeader:()=>h().getOrDie("Could not find header element"),...t}),r=vR.parts["multiple-toolbar"]({dom:{tag:"div",classes:["tox-toolbar-overlord"]},providers:y.popup.shared.providers,onEscape:()=>{e.focus()},type:m}),s=Zb(e),a=zb(e),i=Hb(e),l=Nb(e),c=w(),g=s||a||i,p=l?[c,o]:[o];return vR.parts.header({dom:{tag:"div",classes:["tox-editor-header"].concat(g?[]:["tox-editor-header--empty"]),...t},components:q([i?p:[],s?[r]:a?[n]:[],Wb(e)?[]:[u.asSpec()]]),sticky:Gb(e),editor:e,sharedBackstage:y.popup.shared})})(),n={dom:{tag:"div",classes:["tox-sidebar-wrap"]},components:[vR.parts.socket({dom:{tag:"div",classes:["tox-edit-area"]}}),vR.parts.sidebar({dom:{tag:"div",classes:["tox-sidebar"]}})]},r=vR.parts.throbber({dom:{tag:"div",classes:["tox-throbber"]},backstage:y.popup}),s=vR.parts.viewWrapper({backstage:y.popup}),i=Eb(e)&&!o?D.some(GH(e,y.popup.shared.providers)):D.none(),l=q([d?[]:[t],o?[]:[n],d?[t]:[]]),p=vR.parts.editorContainer({components:q([l,o?[]:[g.asSpec(),...i.toArray()]])}),f=qb(e),b={role:"application",...Mv.isRtl()?{dir:"rtl"}:{},...f?{"aria-hidden":"true"}:{}},x=Ei(vR.sketch({dom:{tag:"div",classes:["tox","tox-tinymce"].concat(o?["tox-tinymce-inline"]:[]).concat(d?["tox-tinymce--toolbar-bottom"]:[]).concat(c),styles:{visibility:"hidden",...f?{opacity:"0",border:"0"}:{}},attributes:b},components:[p,...o?[]:[s],r],behaviours:ql([gx(),wg.config({disableClass:"tox-tinymce--disabled"}),Tp.config({mode:"cyclic",selector:".tox-menubar, .tox-toolbar, .tox-toolbar__primary, .tox-toolbar__overflow--open, .tox-sidebar__overflow--open, .tox-statusbar__path, .tox-statusbar__wordcount, .tox-statusbar__branding a, .tox-statusbar__resize-handle"})])})),C=gk(x);return a.set(C),{mothership:C,outerContainer:x}},C=t=>{const o=BB(HB(e)),n=BB((e=>IB(e).getOr(Qv(e)))(e));return e.inline||(Pt("div","width",n)&&Mt(t.element,"width",n),Pt("div","height",o)?Mt(t.element,"height",o):Mt(t.element,"height","400px")),o},S=t=>{const{mainUi:o,popupUi:s,uiMotherships:a}=t;ce(db(e),((t,o)=>{e.ui.registry.addGroupToolbarButton(o,t)}));const{buttons:i,menuItems:l,contextToolbars:c,sidebars:d,views:u}=e.ui.registry.getAll(),g=Vb(e),p={menuItems:l,menus:Yb(e),menubar:fb(e),toolbar:g.getOrThunk((()=>vb(e))),allowToolbarGroups:m===Uv.floating,buttons:i,sidebar:d,views:u};var f;f=o.outerContainer,e.addShortcut("alt+F9","focus menubar",(()=>{vR.focusMenubar(f)})),e.addShortcut("alt+F10","focus toolbar",(()=>{vR.focusToolbar(f)})),e.addCommand("ToggleToolbarDrawer",((e,t)=>{(null==t?void 0:t.skipFocus)?vR.toggleToolbarDrawerWithoutFocusing(f):vR.toggleToolbarDrawer(f)})),e.addQueryStateHandler("ToggleToolbarDrawer",(()=>vR.isToolbarDrawerToggled(f))),((e,t,o)=>{const n=(e,n)=>{z([t,...o],(t=>{t.broadcastEvent(e,n)}))},r=(e,n)=>{z([t,...o],(t=>{t.broadcastOn([e],n)}))},s=e=>r(Nm(),{target:e.target}),a=jo(),i=Ec(a,"touchstart",s),l=Ec(a,"touchmove",(e=>n(Ds(),e))),c=Ec(a,"touchend",(e=>n(As(),e))),d=Ec(a,"mousedown",s),m=Ec(a,"mouseup",(e=>{0===e.raw.button&&r(Bm(),{target:e.target})})),u=e=>r(Nm(),{target:Le.fromDom(e.target)}),g=e=>{0===e.button&&r(Bm(),{target:Le.fromDom(e.target)})},h=()=>{z(e.editorManager.get(),(t=>{e!==t&&t.dispatch("DismissPopups",{relatedTarget:e})}))},p=e=>n(Ms(),Oc(e)),f=e=>{r(Rm(),{}),n(Ns(),Oc(e))},v=ht(Le.fromDom(e.getElement())),b=Tc(v,"scroll",(o=>{requestAnimationFrame((()=>{if(null!=e.getContainer()){const r=XS(e,t.element).map((e=>[e.element,...e.others])).getOr([]);H(r,(e=>Xe(e,o.target)))&&(e.dispatch("ElementScroll",{target:o.target.dom}),n(Fs(),o))}}))})),y=()=>r(Rm(),{}),w=t=>{t.state&&r(Nm(),{target:Le.fromDom(e.getContainer())})},x=e=>{r(Nm(),{target:Le.fromDom(e.relatedTarget.getContainer())})};e.on("PostRender",(()=>{e.on("click",u),e.on("tap",u),e.on("mouseup",g),e.on("mousedown",h),e.on("ScrollWindow",p),e.on("ResizeWindow",f),e.on("ResizeEditor",y),e.on("AfterProgressState",w),e.on("DismissPopups",x)})),e.on("remove",(()=>{e.off("click",u),e.off("tap",u),e.off("mouseup",g),e.off("mousedown",h),e.off("ScrollWindow",p),e.off("ResizeWindow",f),e.off("ResizeEditor",y),e.off("AfterProgressState",w),e.off("DismissPopups",x),d.unbind(),i.unbind(),l.unbind(),c.unbind(),m.unbind(),b.unbind()})),e.on("detach",(()=>{z([t,...o],wm),z([t,...o],(e=>e.destroy()))}))})(e,o.mothership,a),r.setup(e,y.popup.shared,h),EL(e,y.popup),KL(e,y.popup.shared.getSink,y.popup),(e=>{const{sidebars:t}=e.ui.registry.getAll();z(ae(t),(o=>{const n=t[o],r=()=>we(D.from(e.queryCommandValue("ToggleSidebar")),o);e.ui.registry.addToggleButton(o,{icon:n.icon,tooltip:n.tooltip,onAction:t=>{e.execCommand("ToggleSidebar",!1,o),t.setActive(r())},onSetup:t=>{t.setActive(r());const o=()=>t.setActive(r());return e.on("ToggleSidebar",o),()=>{e.off("ToggleSidebar",o)}}})}))})(e),dN(e,b,y.popup.shared),mL(e,c,s.sink,{backstage:y.popup}),ZH(e,s.sink);const v={targetNode:e.getElement(),height:C(o.outerContainer)};return n.render(e,t,p,y.popup,v)};return{popups:{backstage:y.popup,getMothership:()=>KH("popups",l)},dialogs:{backstage:y.dialog,getMothership:()=>KH("dialogs",i)},renderUI:()=>{const o=x(),n=(()=>{const t=$b(e),o=Xe(wt(),t)&&"grid"===Bt(t,"display"),n={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-tinymce-aux"].concat(c),attributes:{...Mv.isRtl()?{dir:"rtl"}:{}}},behaviours:ql([rm.config({useFixed:()=>r.isDocked(h)})])},s={dom:{styles:{width:document.body.clientWidth+"px"}},events:Ys([Qs(Ns(),(e=>{Mt(e.element,"width",document.body.clientWidth+"px")}))])},a=Ei(xn(n,o?s:{})),l=gk(a);return i.set(l),{sink:a,mothership:l}})(),a=Kb(e)?(()=>{const e={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-silver-popup-sink","tox-tinymce-aux"].concat(c),attributes:{...Mv.isRtl()?{dir:"rtl"}:{}}},behaviours:ql([rm.config({useFixed:()=>r.isDocked(h),getBounds:()=>t.getPopupSinkBounds()})])},o=Ei(e),n=gk(o);return l.set(n),{sink:o,mothership:n}})():(e=>(l.set(e.mothership),e))(n);s.dialogUi.set(n),s.popupUi.set(a),s.mainUi.set(o);const d={popupUi:a,dialogUi:n,mainUi:o,uiMotherships:s.getUiMotherships()};return S(d)}}},XH=w([dr("lazySink"),yr("dragBlockClass"),Rr("getBounds",Jo),Tr("useTabstopAt",O),Tr("firstTabstop",0),Tr("eventOrder",{}),Jm("modalBehaviours",[Tp]),tl("onExecute"),nl("onEscape")]),JH={sketch:x},QH=w([Du({name:"draghandle",overrides:(e,t)=>({behaviours:ql([PH.config({mode:"mouse",getTarget:e=>Ni(e,'[role="dialog"]').getOr(e),blockerClass:e.dragBlockClass.getOrDie(new Error("The drag blocker class was not specified for a dialog with a drag handle: \n"+JSON.stringify(t,null,2)).message),getBounds:e.getDragBounds})])})}),Tu({schema:[dr("dom")],name:"title"}),Tu({factory:JH,schema:[dr("dom")],name:"close"}),Tu({factory:JH,schema:[dr("dom")],name:"body"}),Du({factory:JH,schema:[dr("dom")],name:"footer"}),Ou({factory:{sketch:(e,t)=>({...e,dom:t.dom,components:t.components})},schema:[Tr("dom",{tag:"div",styles:{position:"fixed",left:"0px",top:"0px",right:"0px",bottom:"0px"}}),Tr("components",[])],name:"blocker"})]),eI=og({name:"ModalDialog",configFields:XH(),partFields:QH(),factory:(e,t,o,n)=>{const r=kc(),s=ya("modal-events"),a={...e.eventOrder,[Rs()]:[s].concat(e.eventOrder["alloy.system.attached"]||[])};return{uid:e.uid,dom:e.dom,components:t,apis:{show:t=>{r.set(t);const o=e.lazySink(t).getOrDie(),s=n.blocker(),a=o.getSystem().build({...s,components:s.components.concat([Ti(t)]),behaviours:ql([Zp.config({}),Ip("dialog-blocker-events",[aa(ss(),(()=>{iN.isBlocked(t)||Tp.focusIn(t)}))])])});um(o,a),Tp.focusIn(t)},hide:e=>{r.clear(),nt(e.element).each((t=>{e.getSystem().getByDom(t).each((e=>{pm(e)}))}))},getBody:t=>Zu(t,e,"body"),getFooter:t=>Vu(t,e,"footer"),setIdle:e=>{iN.unblock(e)},setBusy:(e,t)=>{iN.block(e,t)}},eventOrder:a,domModification:{attributes:{role:"dialog","aria-modal":"true"}},behaviours:eu(e.modalBehaviours,[Hp.config({}),Tp.config({mode:"cyclic",onEnter:e.onExecute,onEscape:e.onEscape,useTabstopAt:e.useTabstopAt,firstTabstop:e.firstTabstop}),iN.config({getRoot:r.get}),Ip(s,[ia((t=>{((e,t)=>{const o=Et(e,"id").fold((()=>{const e=ya("dialog-label");return St(t,"id",e),e}),x);St(e,"aria-labelledby",o)})(t.element,Zu(t,e,"title").element)}))])])}},apis:{show:(e,t)=>{e.show(t)},hide:(e,t)=>{e.hide(t)},getBody:(e,t)=>e.getBody(t),getFooter:(e,t)=>e.getFooter(t),setBusy:(e,t,o)=>{e.setBusy(t,o)},setIdle:(e,t)=>{e.setIdle(t)}}}),tI=Pn([Uy,jy].concat(Fw)),oI=qn,nI=[fw("button"),nw,Mr("align","end",["start","end"]),mw,dw,Sr("buttonType",["primary","secondary"])],rI=[...nI,$y],sI=[hr("type",["submit","cancel","custom"]),...rI],aI=[hr("type",["menu"]),ow,rw,nw,br("items",tI),...nI],iI=[...nI,hr("type",["togglebutton"]),gr("tooltip"),nw,ow,Nr("active",!1)],lI=sr("type",{submit:sI,cancel:sI,custom:sI,menu:aI,togglebutton:iI}),cI=[Uy,$y,hr("level",["info","warn","error","success"]),Gy,Tr("url","")],dI=Pn(cI),mI=[Uy,$y,dw,fw("button"),nw,cw,Sr("buttonType",["primary","secondary","toolbar"]),mw],uI=Pn(mI),gI=[Uy,jy],hI=gI.concat([sw]),pI=gI.concat([Wy,dw]),fI=Pn(pI),vI=qn,bI=hI.concat([uw("auto")]),yI=Pn(bI),wI=Zn([Ky,$y,Gy]),xI=hI.concat([Ar("storageKey","default")]),CI=Pn(xI),SI=$n,kI=Pn(hI),_I=$n,EI=gI.concat([Ar("tag","textarea"),gr("scriptId"),gr("scriptUrl"),((e,t)=>Or(e,t,Yn))("settings",void 0)]),TI=gI.concat([Ar("tag","textarea"),pr("init")]),OI=Qn((e=>tr("customeditor.old",In(TI),e).orThunk((()=>tr("customeditor.new",In(EI),e))))),DI=$n,AI=Pn(hI),MI=Fn(Mn),NI=e=>[Uy,ur("columns"),e],RI=[Uy,gr("html"),Mr("presets","presentation",["presentation","document"])],BI=Pn(RI),LI=hI.concat([Nr("border",!1),Nr("sandboxed",!0),Nr("streamContent",!1),Nr("transparent",!0)]),HI=Pn(LI),II=$n,PI=Pn(gI.concat([Cr("height")])),FI=Pn([gr("url"),xr("zoom"),xr("cachedWidth"),xr("cachedHeight")]),zI=hI.concat([Cr("inputMode"),Cr("placeholder"),Nr("maximized",!1),dw]),VI=Pn(zI),ZI=$n,UI=e=>[Uy,Wy,e,Mr("align","start",["start","center","end"])],jI=[$y,Ky],WI=[$y,br("items",ar(0,(()=>$I)))],$I=zn([Pn(jI),Pn(WI)]),qI=hI.concat([br("items",$I),dw]),GI=Pn(qI),KI=$n,YI=hI.concat([vr("items",[$y,Ky]),Dr("size",1),dw]),XI=Pn(YI),JI=$n,QI=hI.concat([Nr("constrain",!0),dw]),eP=Pn(QI),tP=Pn([gr("width"),gr("height")]),oP=gI.concat([Wy,Dr("min",0),Dr("max",0)]),nP=Pn(oP),rP=Wn,sP=[Uy,br("header",$n),br("cells",Fn($n))],aP=Pn(sP),iP=hI.concat([Cr("placeholder"),Nr("maximized",!1),dw]),lP=Pn(iP),cP=$n,dP=[hr("type",["directory","leaf"]),qy,gr("id"),wr("menu",VM)],mP=Pn(dP),uP=dP.concat([br("children",ar(0,(()=>Jn("type",{directory:gP,leaf:mP}))))]),gP=Pn(uP),hP=Jn("type",{directory:gP,leaf:mP}),pP=[Uy,br("items",hP),kr("onLeafAction"),kr("onToggleExpand"),Br("defaultExpandedIds",[],$n),Cr("defaultSelectedId")],fP=Pn(pP),vP=hI.concat([Mr("filetype","file",["image","media","file"]),dw,Cr("picker_text")]),bP=Pn(vP),yP=Pn([Ky,gw]),wP=e=>ir("items","items",{tag:"required",process:{}},Fn(Qn((t=>tr(`Checking item of ${e}`,xP,t).fold((e=>on.error(rr(e))),(e=>on.value(e))))))),xP=Ln((()=>{return Jn("type",{alertbanner:dI,bar:Pn((e=wP("bar"),[Uy,e])),button:uI,checkbox:fI,colorinput:CI,colorpicker:kI,dropzone:AI,grid:Pn(NI(wP("grid"))),iframe:HI,input:VI,listbox:GI,selectbox:XI,sizeinput:eP,slider:nP,textarea:lP,urlinput:bP,customeditor:OI,htmlpanel:BI,imagepreview:PI,collection:yI,label:Pn(UI(wP("label"))),table:aP,tree:fP,panel:SP});var e})),CP=[Uy,Tr("classes",[]),br("items",xP)],SP=Pn(CP),kP=[fw("tab"),qy,br("items",xP)],_P=[Uy,vr("tabs",kP)],EP=Pn(_P),TP=rI,OP=lI,DP=Pn([gr("title"),mr("body",Jn("type",{panel:SP,tabpanel:EP})),Ar("size","normal"),Br("buttons",[],OP),Tr("initialData",{}),Rr("onAction",v),Rr("onChange",v),Rr("onSubmit",v),Rr("onClose",v),Rr("onCancel",v),Rr("onTabChange",v)]),AP=Pn([hr("type",["cancel","custom"]),...TP]),MP=Pn([gr("title"),gr("url"),xr("height"),xr("width"),_r("buttons",AP),Rr("onAction",v),Rr("onCancel",v),Rr("onClose",v),Rr("onMessage",v)]),NP=e=>a(e)?[e].concat(G(fe(e),NP)):l(e)?G(e,NP):[],RP=e=>s(e.type)&&s(e.name),BP={checkbox:vI,colorinput:SI,colorpicker:_I,dropzone:MI,input:ZI,iframe:II,imagepreview:FI,selectbox:JI,sizeinput:tP,slider:rP,listbox:KI,size:tP,textarea:cP,urlinput:yP,customeditor:DI,collection:wI,togglemenuitem:oI},LP=e=>{const t=(e=>Z(NP(e),RP))(e),o=G(t,(e=>(e=>D.from(BP[e.type]))(e).fold((()=>[]),(t=>[mr(e.name,t)]))));return Pn(o)},HP=e=>{var t;return{internalDialog:or(tr("dialog",DP,e)),dataValidator:LP(e),initialData:null!==(t=e.initialData)&&void 0!==t?t:{}}},IP={open:(e,t)=>{const o=HP(t);return e(o.internalDialog,o.initialData,o.dataValidator)},openUrl:(e,t)=>e(or(tr("dialog",MP,t))),redial:e=>HP(e)};var PP=Object.freeze({__proto__:null,events:(e,t)=>{const o=(o,n)=>{e.updateState.each((e=>{const r=e(o,n);t.set(r)})),e.renderComponents.each((r=>{const s=r(n,t.get());(e.reuseDom?Dp:Op)(o,s)}))};return Ys([Qs(xs(),((t,n)=>{const r=n;if(!r.universal){const n=e.channel;L(r.channels,n)&&o(t,r.data)}})),ia(((t,n)=>{e.initialData.each((e=>{o(t,e)}))}))])}});var FP=Object.freeze({__proto__:null,getState:(e,t,o)=>o}),zP=[dr("channel"),yr("renderComponents"),yr("updateState"),yr("initialData"),Nr("reuseDom",!0)];const VP=Kl({fields:zP,name:"reflecting",active:PP,apis:FP,state:Object.freeze({__proto__:null,init:()=>{const e=Hr(D.none());return{readState:()=>e.get().getOr("none"),get:e.get,set:e.set,clear:()=>e.set(D.none())}}})}),ZP=e=>{const t=[],o={};return le(e,((e,n)=>{e.fold((()=>{t.push(n)}),(e=>{o[n]=e}))})),t.length>0?on.error(t):on.value(o)},UP=(e,t,o)=>{const n=Bf(zE.sketch((n=>({dom:{tag:"div",classes:["tox-form"].concat(e.classes)},components:F(e.items,(e=>SD(n,e,t,o)))}))));return{dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[n.asSpec()]}],behaviours:ql([Tp.config({mode:"acyclic",useTabstopAt:k(hT)}),KE(n),JE(n,{postprocess:e=>ZP(e).fold((e=>(console.error(e),{})),x)}),Ip("dialog-body-panel",[Qs(ss(),((e,t)=>{e.getSystem().broadcastOn([wT],{newFocus:D.some(t.event.target)})}))])])}},jP=tg({name:"TabButton",configFields:[Tr("uid",void 0),dr("value"),ir("dom","dom",_n((()=>({attributes:{role:"tab",id:ya("aria"),"aria-selected":"false"}}))),Un()),yr("action"),Tr("domModification",{}),Jm("tabButtonBehaviours",[Zp,Tp,Xm]),dr("view")],factory:(e,t)=>({uid:e.uid,dom:e.dom,components:e.components,events:Qp(e.action),behaviours:eu(e.tabButtonBehaviours,[Zp.config({}),Tp.config({mode:"execution",useSpace:!0,useEnter:!0}),Xm.config({store:{mode:"memory",initialValue:e.value}})]),domModification:e.domModification})}),WP=w([dr("tabs"),dr("dom"),Tr("clickToDismiss",!1),Jm("tabbarBehaviours",[Mg,Tp]),Ji(["tabClass","selectedClass"])]),$P=Au({factory:jP,name:"tabs",unit:"tab",overrides:e=>{const t=(e,t)=>{Mg.dehighlight(e,t),Ws(e,Vs(),{tabbar:e,button:t})},o=(e,t)=>{Mg.highlight(e,t),Ws(e,zs(),{tabbar:e,button:t})};return{action:n=>{const r=n.getSystem().getByUid(e.uid).getOrDie(),s=Mg.isHighlighted(r,n);(s&&e.clickToDismiss?t:s?v:o)(r,n)},domModification:{classes:[e.markers.tabClass]}}}}),qP=w([$P]),GP=og({name:"Tabbar",configFields:WP(),partFields:qP(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,"debug.sketcher":"Tabbar",domModification:{attributes:{role:"tablist"}},behaviours:eu(e.tabbarBehaviours,[Mg.config({highlightClass:e.markers.selectedClass,itemClass:e.markers.tabClass,onHighlight:(e,t)=>{St(t.element,"aria-selected","true")},onDehighlight:(e,t)=>{St(t.element,"aria-selected","false")}}),Tp.config({mode:"flow",getInitial:e=>Mg.getHighlighted(e).map((e=>e.element)),selector:"."+e.markers.tabClass,executeOnMove:!0})])})}),KP=tg({name:"Tabview",configFields:[Jm("tabviewBehaviours",[Hp])],factory:(e,t)=>({uid:e.uid,dom:e.dom,behaviours:eu(e.tabviewBehaviours,[Hp.config({})]),domModification:{attributes:{role:"tabpanel"}}})}),YP=w([Tr("selectFirst",!0),el("onChangeTab"),el("onDismissTab"),Tr("tabs",[]),Jm("tabSectionBehaviours",[])]),XP=Tu({factory:GP,schema:[dr("dom"),fr("markers",[dr("tabClass"),dr("selectedClass")])],name:"tabbar",defaults:e=>({tabs:e.tabs})}),JP=Tu({factory:KP,name:"tabview"}),QP=w([XP,JP]),eF=og({name:"TabSection",configFields:YP(),partFields:QP(),factory:(e,t,o,n)=>{const r=(t,o)=>{Vu(t,e,"tabbar").each((e=>{o(e).each($s)}))};return{uid:e.uid,dom:e.dom,components:t,behaviours:Qm(e.tabSectionBehaviours),events:Ys(q([e.selectFirst?[ia(((e,t)=>{r(e,Mg.getFirst)}))]:[],[Qs(zs(),((t,o)=>{(t=>{const o=Xm.getValue(t);Vu(t,e,"tabview").each((n=>{const r=W(e.tabs,(e=>e.value===o));r.each((o=>{const r=o.view();Et(t.element,"id").each((e=>{St(n.element,"aria-labelledby",e)})),Hp.set(n,r),e.onChangeTab(n,t,r)}))}))})(o.event.button)})),Qs(Vs(),((t,o)=>{const n=o.event.button;e.onDismissTab(t,n)}))]])),apis:{getViewItems:t=>Vu(t,e,"tabview").map((e=>Hp.contents(e))).getOr([]),showTab:(e,t)=>{r(e,(e=>{const o=Mg.getCandidates(e);return W(o,(e=>Xm.getValue(e)===t)).filter((t=>!Mg.isHighlighted(e,t)))}))}}}},apis:{getViewItems:(e,t)=>e.getViewItems(t),showTab:(e,t,o)=>{e.showTab(t,o)}}}),tF=(e,t)=>{Mt(e,"height",t+"px"),Mt(e,"flex-basis",t+"px")},oF=(e,t,o)=>{Ni(e,'[role="dialog"]').each((e=>{Bi(e,'[role="tablist"]').each((n=>{o.get().map((o=>(Mt(t,"height","0"),Mt(t,"flex-basis","0"),Math.min(o,((e,t,o)=>{const n=tt(e).dom,r=Ni(e,".tox-dialog-wrap").getOr(e);let s;s="fixed"===Bt(r,"position")?Math.max(n.clientHeight,window.innerHeight):Math.max(n.offsetHeight,n.scrollHeight);const a=Ut(t),i=t.dom.offsetLeft>=o.dom.offsetLeft+Xt(o)?Math.max(Ut(o),a):a,l=parseInt(Bt(e,"margin-top"),10)||0,c=parseInt(Bt(e,"margin-bottom"),10)||0;return s-(Ut(e)+l+c-i)})(e,t,n))))).each((e=>{tF(t,e)}))}))}))},nF=e=>Bi(e,'[role="tabpanel"]'),rF=e=>{const t=kc(),o=[ia((o=>{const n=o.element;nF(n).each((r=>{Mt(r,"visibility","hidden"),o.getSystem().getByDom(r).toOptional().each((o=>{const n=((e,t,o)=>F(e,((n,r)=>{Hp.set(o,e[r].view());const s=t.dom.getBoundingClientRect();return Hp.set(o,[]),s.height})))(e,r,o),s=(e=>oe(ee(e,((e,t)=>e>t?-1:e{oe(e).each((e=>eF.showTab(t,e.value)))})(e,o),requestAnimationFrame((()=>{oF(n,r,t)}))}))})),Qs(Ns(),(e=>{const o=e.element;nF(o).each((e=>{oF(o,e,t)}))})),Qs(Rk,((e,o)=>{const n=e.element;nF(n).each((e=>{const o=rc(ht(e));Mt(e,"visibility","hidden");const r=Ht(e,"height").map((e=>parseInt(e,10)));Ft(e,"height"),Ft(e,"flex-basis");const s=e.dom.getBoundingClientRect().height;r.forall((e=>s>e))?(t.set(s),oF(n,e,t)):r.each((t=>{tF(e,t)})),Ft(e,"visibility"),o.each(tc)}))}))];return{extraEvents:o,selectFirst:!1}},sF="send-data-to-section",aF="send-data-to-view",iF=(e,t,o)=>{const n=Hr({}),r=e=>{const t=Xm.getValue(e),o=ZP(t).getOr({}),r=n.get(),s=xn(r,o);n.set(s)},s=e=>{const t=n.get();Xm.setValue(e,t)},a=Hr(null),i=F(e.tabs,(e=>({value:e.name,dom:{tag:"div",classes:["tox-dialog__body-nav-item"]},components:[Ci(o.shared.providers.translate(e.title))],view:()=>[zE.sketch((n=>({dom:{tag:"div",classes:["tox-form"]},components:F(e.items,(e=>SD(n,e,t,o))),formBehaviours:ql([Tp.config({mode:"acyclic",useTabstopAt:k(hT)}),Ip("TabView.form.events",[ia(s),la(r)]),Ql.config({channels:zr([{key:sF,value:{onReceive:r}},{key:aF,value:{onReceive:s}}])})])})))]}))),l=rF(i);return eF.sketch({dom:{tag:"div",classes:["tox-dialog__body"]},onChangeTab:(e,t,o)=>{const n=Xm.getValue(t);Ws(e,Nk,{name:n,oldName:a.get()}),a.set(n)},tabs:i,components:[eF.parts.tabbar({dom:{tag:"div",classes:["tox-dialog__body-nav"]},components:[GP.parts.tabs({})],markers:{tabClass:"tox-tab",selectedClass:"tox-dialog__body-nav-item--active"},tabbarBehaviours:ql([yk.config({})])}),eF.parts.tabview({dom:{tag:"div",classes:["tox-dialog__body-content"]}})],selectFirst:l.selectFirst,tabSectionBehaviours:ql([Ip("tabpanel",l.extraEvents),Tp.config({mode:"acyclic"}),ag.config({find:e=>oe(eF.getViewItems(e))}),QE(D.none(),(e=>(e.getSystem().broadcastOn([sF],{}),n.get())),((e,t)=>{n.set(t),e.getSystem().broadcastOn([aF],{})}))])})},lF=(e,t,o,n,r)=>({dom:{tag:"div",classes:["tox-dialog__content-js"],attributes:{...o.map((e=>({id:e}))).getOr({}),...r?{"aria-live":"polite"}:{}}},components:[],behaviours:ql([YE(0),VP.config({channel:`${vT}-${t}`,updateState:(e,t)=>D.some({isTabPanel:()=>"tabpanel"===t.body.type}),renderComponents:e=>{const t=e.body;return"tabpanel"===t.type?[iF(t,e.initialData,n)]:[UP(t,e.initialData,n)]},initialData:e})])}),cF=qv.deviceType.isTouch(),dF=(e,t)=>({dom:{tag:"div",styles:{display:"none"},classes:["tox-dialog__header"]},components:[e,t]}),mF=(e,t)=>eI.parts.close(Nf.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":t.translate("Close")}},action:e,buttonBehaviours:ql([yk.config({})])})),uF=()=>eI.parts.title({dom:{tag:"div",classes:["tox-dialog__title"],innerHtml:"",styles:{display:"none"}}}),gF=(e,t)=>eI.parts.body({dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[{dom:Rf(`

    ${Av(t.translate(e))}

    `)}]}]}),hF=e=>eI.parts.footer({dom:{tag:"div",classes:["tox-dialog__footer"]},components:e}),pF=(e,t)=>[uk.sketch({dom:{tag:"div",classes:["tox-dialog__footer-start"]},components:e}),uk.sketch({dom:{tag:"div",classes:["tox-dialog__footer-end"]},components:t})],fF=e=>{const t="tox-dialog",o=t+"-wrap",n=o+"__backdrop",r=t+"__disable-scroll";return eI.sketch({lazySink:e.lazySink,onEscape:t=>(e.onEscape(t),D.some(!0)),useTabstopAt:e=>!hT(e),firstTabstop:e.firstTabstop,dom:{tag:"div",classes:[t].concat(e.extraClasses),styles:{position:"relative",...e.extraStyles}},components:[e.header,e.body,...e.footer.toArray()],parts:{blocker:{dom:Rf(`
    `),components:[{dom:{tag:"div",classes:cF?[n,n+"--opaque"]:[n]}}]}},dragBlockClass:o,modalBehaviours:ql([Zp.config({}),Ip("dialog-events",e.dialogEvents.concat([aa(ss(),((e,t)=>{iN.isBlocked(e)||Tp.focusIn(e)})),Qs(Is(),((e,t)=>{e.getSystem().broadcastOn([wT],{newFocus:t.event.newFocus})}))])),Ip("scroll-lock",[ia((()=>{ti(wt(),r)})),la((()=>{ni(wt(),r)}))]),...e.extraBehaviours]),eventOrder:{[Cs()]:["dialog-events"],[Rs()]:["scroll-lock","dialog-events","alloy.base.behaviour"],[Bs()]:["alloy.base.behaviour","dialog-events","scroll-lock"],...e.eventOrder}})},vF=e=>Nf.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":e.translate("Close"),title:e.translate("Close")}},buttonBehaviours:ql([yk.config({})]),components:[zv("close",{tag:"span",classes:["tox-icon"]},e.icons)],action:e=>{js(e,Tk)}}),bF=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__title"],attributes:{...o.map((e=>({id:e}))).getOr({})}},components:[],behaviours:ql([VP.config({channel:`${fT}-${t}`,initialData:e,renderComponents:e=>[Ci(n.translate(e.title))]})])}),yF=()=>({dom:Rf('
    ')}),wF=(e,t,o)=>((e,t,o)=>{const n=eI.parts.title(bF(e,t,D.none(),o)),r=eI.parts.draghandle(yF()),s=eI.parts.close(vF(o)),a=[n].concat(e.draggable?[r]:[]).concat([s]);return uk.sketch({dom:Rf('
    '),components:a})})({title:o.shared.providers.translate(e),draggable:o.dialog.isDraggableModal()},t,o.shared.providers),xF=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__busy-spinner"],attributes:{"aria-label":o.translate(e)},styles:{left:"0px",right:"0px",bottom:"0px",top:`${n.getOr(0)}px`,position:"absolute"}},behaviours:t,components:[{dom:Rf('
    ')}]}),CF=(e,t,o)=>({onClose:()=>o.closeWindow(),onBlock:o=>{const n=Bi(e().element,".tox-dialog__header").map((e=>Ut(e)));eI.setBusy(e(),((e,r)=>xF(o.message,r,t,n)))},onUnblock:()=>{eI.setIdle(e())}}),SF="tox-dialog--fullscreen",kF="tox-dialog--width-lg",_F="tox-dialog--width-md",EF=e=>{switch(e){case"large":return D.some(kF);case"medium":return D.some(_F);default:return D.none()}},TF=(e,t)=>{const o=Le.fromDom(t.element.dom);si(o,SF)||(ii(o,[kF,_F]),EF(e).each((e=>ti(o,e))))},OF=(e,t)=>{const o=Le.fromDom(e.element.dom),n=li(o),r=W(n,(e=>e===kF||e===_F)).or(EF(t));((e,t)=>{z(t,(t=>{ri(e,t)}))})(o,[SF,...r.toArray()])},DF=(e,t,o)=>Ei(fF({...e,firstTabstop:1,lazySink:o.shared.getSink,extraBehaviours:[tT({}),...e.extraBehaviours],onEscape:e=>{js(e,Tk)},dialogEvents:t,eventOrder:{[xs()]:[VP.name(),Ql.name()],[Rs()]:["scroll-lock",VP.name(),"messages","dialog-events","alloy.base.behaviour"],[Bs()]:["alloy.base.behaviour","dialog-events","messages",VP.name(),"scroll-lock"]}})),AF=(e,t={})=>F(e,(e=>"menu"===e.type?(e=>{const o=F(e.items,(e=>{const o=ve(t,e.name).getOr(Hr(!1));return{...e,storage:o}}));return{...e,items:o}})(e):e)),MF=e=>j(e,((e,t)=>{if("menu"===t.type){return j(t.items,((e,t)=>(e[t.name]=t.storage,e)),e)}return e}),{}),NF=(e,t)=>[na(ss(),gT),e(Ek,((e,o,n,r)=>{rc(ht(r.element)).fold(v,oc),t.onClose(),o.onClose()})),e(Tk,((e,t,o,n)=>{t.onCancel(e),js(n,Ek)})),Qs(Mk,((e,o)=>t.onUnblock())),Qs(Ak,((e,o)=>t.onBlock(o.event)))],RF=(e,t,o)=>{const n=(t,o)=>Qs(t,((t,n)=>{r(t,((r,s)=>{o(e(),r,n.event,t)}))})),r=(e,t)=>{VP.getState(e).get().each((o=>{t(o.internalDialog,e)}))};return[...NF(n,t),n(Dk,((e,t)=>t.onSubmit(e))),n(_k,((e,t,o)=>{t.onChange(e,{name:o.name})})),n(Ok,((e,t,n,r)=>{const s=()=>r.getSystem().isConnected()?Tp.focusIn(r):void 0,a=e=>Tt(e,"disabled")||Et(e,"aria-disabled").exists((e=>"true"===e)),i=ht(r.element),l=rc(i);t.onAction(e,{name:n.name,value:n.value}),rc(i).fold(s,(e=>{a(e)||l.exists((t=>Je(e,t)&&a(t)))?s():o().toOptional().filter((t=>!Je(t.element,e))).each(s)}))})),n(Nk,((e,t,o)=>{t.onTabChange(e,{newTabName:o.name,oldTabName:o.oldName})})),la((t=>{const o=e();Xm.setValue(t,o.getData())}))]},BF=(e,t)=>{const o=t.map((e=>e.footerButtons)).getOr([]),n=V(o,(e=>"start"===e.align)),r=(e,t)=>uk.sketch({dom:{tag:"div",classes:[`tox-dialog__footer-${e}`]},components:F(t,(e=>e.memento.asSpec()))});return[r("start",n.pass),r("end",n.fail)]},LF=(e,t,o)=>({dom:Rf(''),components:[],behaviours:ql([VP.config({channel:`${bT}-${t}`,initialData:e,updateState:(e,t)=>{const n=F(t.buttons,(e=>{const t=Bf(((e,t)=>sD(e,e.type,t))(e,o));return{name:e.name,align:e.align,memento:t}}));return D.some({lookupByName:t=>((e,t,o)=>W(t,(e=>e.name===o)).bind((t=>t.memento.getOpt(e))))(e,n,t),footerButtons:n})},renderComponents:BF})])}),HF=(e,t,o)=>eI.parts.footer(LF(e,t,o)),IF=(e,t)=>{if(e.getRoot().getSystem().isConnected()){const o=ag.getCurrent(e.getFormWrapper()).getOr(e.getFormWrapper());return zE.getField(o,t).orThunk((()=>{const o=e.getFooter().bind((e=>VP.getState(e).get()));return o.bind((e=>e.lookupByName(t)))}))}return D.none()},PF=(e,t,o)=>{const n=t=>{const o=e.getRoot();o.getSystem().isConnected()&&t(o)},r={getData:()=>{const t=e.getRoot(),n=t.getSystem().isConnected()?e.getFormWrapper():t;return{...Xm.getValue(n),...ce(o,(e=>e.get()))}},setData:t=>{n((n=>{const s=r.getData(),a=xn(s,t),i=((e,t)=>{const o=e.getRoot();return VP.getState(o).get().map((e=>or(tr("data",e.dataValidator,t)))).getOr(t)})(e,a),l=e.getFormWrapper();Xm.setValue(l,i),le(o,((e,t)=>{be(a,t)&&e.set(a[t])}))}))},setEnabled:(t,o)=>{IF(e,t).each(o?wg.enable:wg.disable)},focus:t=>{IF(e,t).each(Zp.focus)},block:e=>{if(!s(e))throw new Error("The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument");n((t=>{Ws(t,Ak,{message:e})}))},unblock:()=>{n((e=>{js(e,Mk)}))},showTab:t=>{n((o=>{const n=e.getBody();VP.getState(n).get().exists((e=>e.isTabPanel()))&&ag.getCurrent(n).each((e=>{eF.showTab(e,t)}))}))},redial:s=>{n((n=>{const a=e.getId(),i=t(s),l=AF(i.internalDialog.buttons,o);n.getSystem().broadcastOn([`${pT}-${a}`],i),n.getSystem().broadcastOn([`${fT}-${a}`],i.internalDialog),n.getSystem().broadcastOn([`${vT}-${a}`],i.internalDialog),n.getSystem().broadcastOn([`${bT}-${a}`],{...i.internalDialog,buttons:l}),r.setData(i.initialData)}))},close:()=>{n((e=>{js(e,Ek)}))},toggleFullscreen:e.toggleFullscreen};return r},FF=(e,t,o)=>{const n=ya("dialog"),r=e.internalDialog,s=wF(r.title,n,o),a=Hr(r.size),i=EF(a.get()).toArray(),l=((e,t,o)=>{const n=lF(e,t,D.none(),o,!1);return eI.parts.body(n)})({body:r.body,initialData:r.initialData},n,o),c=AF(r.buttons),d=MF(c),m=ke(0!==c.length,HF({buttons:c},n,o)),u=RF((()=>f),CF((()=>h),o.shared.providers,t),o.shared.getSink),g={id:n,header:s,body:l,footer:m,extraClasses:i,extraBehaviours:[VP.config({channel:`${pT}-${n}`,updateState:(e,t)=>(a.set(t.internalDialog.size),TF(t.internalDialog.size,e),D.some(t)),initialData:e})],extraStyles:{}},h=DF(g,u,o),p={getId:w(n),getRoot:w(h),getBody:()=>eI.getBody(h),getFooter:()=>eI.getFooter(h),getFormWrapper:()=>{const e=eI.getBody(h);return ag.getCurrent(e).getOr(e)},toggleFullscreen:()=>{OF(h,a.get())}},f=PF(p,t.redial,d);return{dialog:h,instanceApi:f}},zF=(e,t,o,n=!1,r)=>{const s=ya("dialog"),a=ya("dialog-label"),i=ya("dialog-content"),l=e.internalDialog,c=Hr(l.size),d=EF(c.get()).toArray(),m=Bf(((e,t,o,n)=>uk.sketch({dom:Rf('
    '),components:[bF(e,t,D.some(o),n),yF(),vF(n)],containerBehaviours:ql([PH.config({mode:"mouse",blockerClass:"blocker",getTarget:e=>Li(e,'[role="dialog"]').getOrDie(),snaps:{getSnapPoints:()=>[],leftAttr:"data-drag-left",topAttr:"data-drag-top"}})])}))({title:l.title,draggable:!0},s,a,o.shared.providers)),u=Bf(((e,t,o,n,r)=>lF(e,t,D.some(o),n,r))({body:l.body,initialData:l.initialData},s,i,o,n)),g=AF(l.buttons),h=MF(g),p=ke(0!==g.length,Bf(((e,t,o)=>LF(e,t,o))({buttons:g},s,o))),f=RF((()=>b),{onBlock:e=>{iN.block(v,((t,n)=>{const r=m.getOpt(v).map((e=>Ut(e.element)));return xF(e.message,n,o.shared.providers,r)}))},onUnblock:()=>{iN.unblock(v)},onClose:()=>t.closeWindow()},o.shared.getSink),v=Ei({dom:{tag:"div",classes:["tox-dialog","tox-dialog-inline",...d],attributes:{role:"dialog","aria-labelledby":a}},eventOrder:{[xs()]:[VP.name(),Ql.name()],[Cs()]:["execute-on-form"],[Rs()]:["reflecting","execute-on-form"]},behaviours:ql([Tp.config({mode:"cyclic",onEscape:e=>(js(e,Ek),D.some(!0)),useTabstopAt:e=>!hT(e)&&("button"!==Ve(e)||"disabled"!==_t(e,"disabled")),firstTabstop:1}),VP.config({channel:`${pT}-${s}`,updateState:(e,t)=>(c.set(t.internalDialog.size),TF(t.internalDialog.size,e),r(),D.some(t)),initialData:e}),Zp.config({}),Ip("execute-on-form",f.concat([aa(ss(),((e,t)=>{Tp.focusIn(e)})),Qs(Is(),((e,t)=>{e.getSystem().broadcastOn([wT],{newFocus:t.event.newFocus})}))])),iN.config({getRoot:()=>D.some(v)}),Hp.config({}),tT({})]),components:[m.asSpec(),u.asSpec(),...p.map((e=>e.asSpec())).toArray()]}),b=PF({getId:w(s),getRoot:w(v),getFooter:()=>p.map((e=>e.get(v))),getBody:()=>u.get(v),getFormWrapper:()=>{const e=u.get(v);return ag.getCurrent(e).getOr(e)},toggleFullscreen:()=>{OF(v,c.get())}},t.redial,h);return{dialog:v,instanceApi:b}};var VF=tinymce.util.Tools.resolve("tinymce.util.URI");const ZF=["insertContent","setContent","execCommand","close","block","unblock"],UF=e=>a(e)&&-1!==ZF.indexOf(e.mceAction),jF=(e,t,o,n)=>{const r=ya("dialog"),i=wF(e.title,r,n),l=(e=>{const t={dom:{tag:"div",classes:["tox-dialog__content-js"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-iframe"]},components:[mT(D.none(),{dom:{tag:"iframe",attributes:{src:e.url}},behaviours:ql([yk.config({}),Zp.config({})])})]}],behaviours:ql([Tp.config({mode:"acyclic",useTabstopAt:k(hT)})])};return eI.parts.body(t)})(e),c=e.buttons.bind((e=>0===e.length?D.none():D.some(HF({buttons:e},r,n)))),m=((e,t)=>{const o=(t,o)=>Qs(t,((t,r)=>{n(t,((n,s)=>{o(e(),n,r.event,t)}))})),n=(e,t)=>{VP.getState(e).get().each((o=>{t(o,e)}))};return[...NF(o,t),o(Ok,((e,t,o)=>{t.onAction(e,{name:o.name})}))]})((()=>w),CF((()=>y),n.shared.providers,t)),u={...e.height.fold((()=>({})),(e=>({height:e+"px","max-height":e+"px"}))),...e.width.fold((()=>({})),(e=>({width:e+"px","max-width":e+"px"})))},h=e.width.isNone()&&e.height.isNone()?["tox-dialog--width-lg"]:[],p=new VF(e.url,{base_uri:new VF(window.location.href)}),f=`${p.protocol}://${p.host}${p.port?":"+p.port:""}`,v=Sc(),b=[VP.config({channel:`${pT}-${r}`,updateState:(e,t)=>D.some(t),initialData:e}),Ip("messages",[ia((()=>{const t=Ec(Le.fromDom(window),"message",(t=>{if(p.isSameOrigin(new VF(t.raw.origin))){const n=t.raw.data;UF(n)?((e,t,o)=>{switch(o.mceAction){case"insertContent":e.insertContent(o.content);break;case"setContent":e.setContent(o.content);break;case"execCommand":const n=!!d(o.ui)&&o.ui;e.execCommand(o.cmd,n,o.value);break;case"close":t.close();break;case"block":t.block(o.message);break;case"unblock":t.unblock()}})(o,w,n):(e=>!UF(e)&&a(e)&&be(e,"mceAction"))(n)&&e.onMessage(w,n)}}));v.set(t)})),la(v.clear)]),Ql.config({channels:{[yT]:{onReceive:(e,t)=>{Bi(e.element,"iframe").each((e=>{const o=e.dom.contentWindow;g(o)&&o.postMessage(t,f)}))}}}})],y=DF({id:r,header:i,body:l,footer:c,extraClasses:h,extraBehaviours:b,extraStyles:u},m,n),w=(e=>{const t=t=>{e.getSystem().isConnected()&&t(e)};return{block:e=>{if(!s(e))throw new Error("The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument");t((t=>{Ws(t,Ak,{message:e})}))},unblock:()=>{t((e=>{js(e,Mk)}))},close:()=>{t((e=>{js(e,Ek)}))},sendMessage:e=>{t((t=>{t.getSystem().broadcastOn([yT],e)}))}}})(y);return{dialog:y,instanceApi:w}},WF=(e,t)=>or(tr("data",t,e)),$F=e=>QS(e,".tox-alert-dialog")||QS(e,".tox-confirm-dialog"),qF=(e,t,o)=>t&&o?[]:[OM.config({contextual:{lazyContext:()=>D.some(Ko(Le.fromDom(e.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top"],lazyViewport:t=>XS(e,t.element).map((e=>({bounds:JS(e),optScrollEnv:D.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))).getOrThunk((()=>({bounds:Jo(),optScrollEnv:D.none()})))})],GF=e=>{const t=e.editor,o=Gb(t),n=(e=>{const t=e.shared;return{open:(o,n)=>{const r=()=>{eI.hide(l),n()},s=Bf(sD({name:"close-alert",text:"OK",primary:!0,buttonType:D.some("primary"),align:"end",enabled:!0,icon:D.none()},"cancel",e)),a=uF(),i=mF(r,t.providers),l=Ei(fF({lazySink:()=>t.getSink(),header:dF(a,i),body:gF(o,t.providers),footer:D.some(hF(pF([],[s.asSpec()]))),onEscape:r,extraClasses:["tox-alert-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Qs(Tk,r)],eventOrder:{}}));eI.show(l);const c=s.get(l);Zp.focus(c)}}})(e.backstages.dialog),r=(e=>{const t=e.shared;return{open:(o,n)=>{const r=e=>{eI.hide(c),n(e)},s=Bf(sD({name:"yes",text:"Yes",primary:!0,buttonType:D.some("primary"),align:"end",enabled:!0,icon:D.none()},"submit",e)),a=sD({name:"no",text:"No",primary:!1,buttonType:D.some("secondary"),align:"end",enabled:!0,icon:D.none()},"cancel",e),i=uF(),l=mF((()=>r(!1)),t.providers),c=Ei(fF({lazySink:()=>t.getSink(),header:dF(i,l),body:gF(o,t.providers),footer:D.some(hF(pF([],[a,s.asSpec()]))),onEscape:()=>r(!1),extraClasses:["tox-confirm-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Qs(Tk,(()=>r(!1))),Qs(Dk,(()=>r(!0)))],eventOrder:{}}));eI.show(c);const d=s.get(c);Zp.focus(d)}}})(e.backstages.dialog),s=(o,n)=>IP.openUrl((o=>{const r=jF(o,{closeWindow:()=>{eI.hide(r.dialog),n(r.instanceApi)}},t,e.backstages.dialog);return eI.show(r.dialog),r.instanceApi}),o),a=(t,o)=>IP.open(((t,n,r)=>{const s=n,a=FF({dataValidator:r,initialData:s,internalDialog:t},{redial:IP.redial,closeWindow:()=>{eI.hide(a.dialog),o(a.instanceApi)}},e.backstages.dialog);return eI.show(a.dialog),a.instanceApi.setData(s),a.instanceApi}),t),i=(n,r,s,a)=>IP.open(((n,i,l)=>{const c=WF(i,l),d=kc(),m=e.backstages.popup.shared.header.isPositionedAtTop(),u=()=>d.on((e=>{Af.reposition(e),o&&m||OM.refresh(e)})),g=zF({dataValidator:l,initialData:c,internalDialog:n},{redial:IP.redial,closeWindow:()=>{d.on(Af.hide),t.off("ResizeEditor",u),d.clear(),s(g.instanceApi)}},e.backstages.popup,a.ariaAttrs,u),h=Ei(Af.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:a.persistent?{event:"doNotDismissYet"}:{},...m?{}:{fireRepositionEventInstead:{}},inlineBehaviours:ql([Ip("window-manager-inline-events",[Qs(Ls(),((e,t)=>{js(g.dialog,Tk)}))]),...qF(t,o,m)]),isExtraPart:(e,t)=>$F(t)}));d.set(h);return Af.showWithinBounds(h,Ti(g.dialog),{anchor:r},(()=>{const e=t.inline?wt():Le.fromDom(t.getContainer()),o=Ko(e);return D.some(o)})),o&&m||(OM.refresh(h),t.on("ResizeEditor",u)),g.instanceApi.setData(c),Tp.focusIn(g.dialog),g.instanceApi}),n),l=(o,n,r,s)=>IP.open(((o,a,i)=>{const l=WF(a,i),c=kc(),d=e.backstages.popup.shared.header.isPositionedAtTop(),m=()=>c.on((e=>{Af.reposition(e),OM.refresh(e)})),u=zF({dataValidator:i,initialData:l,internalDialog:o},{redial:IP.redial,closeWindow:()=>{c.on(Af.hide),t.off("ResizeEditor ScrollWindow ElementScroll",m),c.clear(),r(u.instanceApi)}},e.backstages.popup,s.ariaAttrs,m),g=Ei(Af.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:s.persistent?{event:"doNotDismissYet"}:{},...d?{}:{fireRepositionEventInstead:{}},inlineBehaviours:ql([Ip("window-manager-inline-events",[Qs(Ls(),((e,t)=>{js(u.dialog,Tk)}))]),OM.config({contextual:{lazyContext:()=>D.some(Ko(Le.fromDom(t.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top","bottom"],lazyViewport:e=>XS(t,e.element).map((e=>({bounds:JS(e),optScrollEnv:D.some({currentScrollTop:e.element.dom.scrollTop,scrollElmTop:Gt(e.element).top})}))).getOrThunk((()=>({bounds:Jo(),optScrollEnv:D.none()})))})]),isExtraPart:(e,t)=>$F(t)}));c.set(g);return Af.showWithinBounds(g,Ti(u.dialog),{anchor:n},(()=>e.backstages.popup.shared.getSink().toOptional().bind((e=>{const o=XS(t,e.element).map((e=>JS(e))).getOr(Jo()),n=Ko(Le.fromDom(t.getContentAreaContainer())),r=Xo(n,o);return D.some(Go(r.x,r.y,r.width,r.height-15))})))),OM.refresh(g),t.on("ResizeEditor ScrollWindow ElementScroll ResizeWindow",m),u.instanceApi.setData(l),Tp.focusIn(u.dialog),u.instanceApi}),o);return{open:(t,o,n)=>{if(!m(o)){if("toolbar"===o.inline)return i(t,e.backstages.popup.shared.anchors.inlineDialog(),n,o);if("bottom"===o.inline)return l(t,e.backstages.popup.shared.anchors.inlineBottomDialog(),n,o);if("cursor"===o.inline)return i(t,e.backstages.popup.shared.anchors.cursor(),n,o)}return a(t,n)},openUrl:(e,t)=>s(e,t),alert:(e,t)=>{n.open(e,t)},close:e=>{e.close()},confirm:(e,t)=>{r.open(e,t)}}},KF=e=>{Yv(e),(e=>{const t=e.options.register,o=e=>f(e,s)?{value:EC(e),valid:!0}:{valid:!1,message:"Must be an array of strings."},n=e=>p(e)&&e>0?{value:e,valid:!0}:{valid:!1,message:"Must be a positive number."};t("color_map",{processor:o,default:["#BFEDD2","Light Green","#FBEEB8","Light Yellow","#F8CAC6","Light Red","#ECCAFA","Light Purple","#C2E0F4","Light Blue","#2DC26B","Green","#F1C40F","Yellow","#E03E2D","Red","#B96AD9","Purple","#3598DB","Blue","#169179","Dark Turquoise","#E67E23","Orange","#BA372A","Dark Red","#843FA1","Dark Purple","#236FA1","Dark Blue","#ECF0F1","Light Gray","#CED4D9","Medium Gray","#95A5A6","Gray","#7E8C8D","Dark Gray","#34495E","Navy Blue","#000000","Black","#ffffff","White"]}),t("color_map_background",{processor:o}),t("color_map_foreground",{processor:o}),t("color_cols",{processor:n,default:AC(e)}),t("color_cols_foreground",{processor:n,default:MC(e,kC)}),t("color_cols_background",{processor:n,default:MC(e,_C)}),t("custom_colors",{processor:"boolean",default:!0}),t("color_default_foreground",{processor:"string",default:OC}),t("color_default_background",{processor:"string",default:OC})})(e),(e=>{const t=e.options.register;t("contextmenu_avoid_overlap",{processor:"string",default:""}),t("contextmenu_never_use_native",{processor:"boolean",default:!1}),t("contextmenu",{processor:e=>!1===e?{value:[],valid:!0}:s(e)||f(e,s)?{value:TL(e),valid:!0}:{valid:!1,message:"Must be false or a string."},default:"link linkchecker image editimage table spellchecker configurepermanentpen"})})(e)};Qo.add("silver",(e=>{KF(e);let t=()=>Jo();const{dialogs:o,popups:n,renderUI:r}=YH(e,{getPopupSinkBounds:()=>t()});qS(e,n.backstage.shared);const s=GF({editor:e,backstages:{popup:n.backstage,dialog:o.backstage}});return{renderUI:()=>{const o=r();return XS(e,n.getMothership().element).each((e=>{t=()=>JS(e)})),o},getWindowManagerImpl:w(s),getNotificationManagerImpl:()=>((e,t,o)=>{const n=t.backstage.shared,r=()=>{const t=Ko(Le.fromDom(e.getContentAreaContainer())),o=Jo(),n=bl(o.x,t.x,t.right),r=bl(o.y,t.y,t.bottom),s=Math.max(t.right,o.right),a=Math.max(t.bottom,o.bottom);return D.some(Go(n,r,s-n,a-r))};return{open:(t,s)=>{const a=()=>{s(),Af.hide(l)},i=Ei(Zv.sketch({text:t.text,level:L(["success","error","warning","warn","info"],t.type)?t.type:void 0,progress:!0===t.progressBar,icon:t.icon,closeButton:t.closeButton,onAction:a,iconProvider:n.providers.icons,translationProvider:n.providers.translate})),l=Ei(Af.sketch({dom:{tag:"div",classes:["tox-notifications-container"]},lazySink:n.getSink,fireDismissalEventInstead:{},...n.header.isPositionedAtTop()?{}:{fireRepositionEventInstead:{}}}));o.add(l),p(t.timeout)&&t.timeout>0&&Mf.setEditorTimeout(e,(()=>{a()}),t.timeout);const c={close:a,reposition:()=>{const t=Ti(i),o={maxHeightFunction:Fc()},s=e.notificationManager.getNotifications();if(s[0]===c){const e={...n.anchors.banner(),overrides:o};Af.showWithinBounds(l,t,{anchor:e},r)}else B(s,c).each((e=>{const n=s[e-1].getEl(),a={type:"node",root:wt(),node:D.some(Le.fromDom(n)),overrides:o,layouts:{onRtl:()=>[Nl],onLtr:()=>[Nl]}};Af.showWithinBounds(l,t,{anchor:a},r)}))},text:e=>{Zv.updateText(i,e)},settings:t,getEl:()=>i.element.dom,progressBar:{value:e=>{Zv.updateProgress(i,e)}}};return c},close:e=>{e.close()},getArgs:e=>e.settings}})(e,{backstage:n.backstage},n.getMothership())}}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.ModelManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=e=>t=>e===t,r=t("string"),s=t("object"),a=t("array"),i=n(null),l=o("boolean"),c=n(void 0),d=e=>!(e=>null==e)(e),m=o("function"),u=o("number"),g=()=>{},h=e=>()=>e,p=e=>e,f=(e,t)=>e===t;function v(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const b=e=>t=>!e(t),y=e=>e(),w=h(!1),x=h(!0);class C{constructor(e,t){this.tag=e,this.value=t}static some(e){return new C(!0,e)}static none(){return C.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?C.some(e(this.value)):C.none()}bind(e){return this.tag?e(this.value):C.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:C.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return d(e)?C.some(e):C.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}C.singletonNone=new C(!1);const S=Array.prototype.slice,k=Array.prototype.indexOf,_=Array.prototype.push,E=(e,t)=>{return o=e,n=t,k.call(o,n)>-1;var o,n},T=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),B=(e,t,o)=>(A(e,((e,n)=>{o=t(o,e,n)})),o),L=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oI(D(e,t)),F=(e,t)=>{for(let o=0,n=e.length;o{const o={};for(let n=0,r=e.length;nt>=0&&tV(e,0),U=e=>V(e,e.length-1),j=(e,t)=>{for(let o=0;o{const o=W(e);for(let n=0,r=o.length;nK(e,((e,o)=>({k:o,v:t(e,o)}))),K=(e,t)=>{const o={};return q(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},Y=(e,t)=>{const o={};return((e,t,o,n)=>{q(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(e=>(t,o)=>{e[o]=t})(o),g),o},X=(e,t)=>{const o=[];return q(e,((e,n)=>{o.push(t(e,n))})),o},J=e=>X(e,p),Q=(e,t)=>$.call(e,t),ee="undefined"!=typeof window?window:Function("return this;")(),te=(e,t)=>((e,t)=>{let o=null!=t?t:ee;for(let t=0;t{const o=((e,t)=>te(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},ne=Object.getPrototypeOf,re=e=>{const t=te("ownerDocument.defaultView",e);return s(e)&&((e=>oe("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(ne(e).constructor.name))},se=e=>e.dom.nodeName.toLowerCase(),ae=e=>e.dom.nodeType,ie=e=>t=>ae(t)===e,le=e=>8===ae(e)||"#comment"===se(e),ce=e=>de(e)&&re(e.dom),de=ie(1),me=ie(3),ue=ie(9),ge=ie(11),he=e=>t=>de(t)&&se(t)===e,pe=(e,t,o)=>{if(!(r(o)||l(o)||u(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},fe=(e,t,o)=>{pe(e.dom,t,o)},ve=(e,t)=>{const o=e.dom;q(t,((e,t)=>{pe(o,t,e)}))},be=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},ye=(e,t)=>C.from(be(e,t)),we=(e,t)=>{e.dom.removeAttribute(t)},xe=e=>B(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Ce=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Se={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Ce(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return Ce(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return Ce(o)},fromDom:Ce,fromPoint:(e,t,o)=>C.from(e.dom.elementFromPoint(t,o)).map(Ce)},ke=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},_e=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Ee=(e,t)=>{const o=void 0===t?document:t.dom;return _e(o)?C.none():C.from(o.querySelector(e)).map(Se.fromDom)},Te=(e,t)=>e.dom===t.dom,Oe=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},De=ke,Ae=e=>Se.fromDom(e.dom.ownerDocument),Me=e=>ue(e)?e:Ae(e),Ne=e=>C.from(e.dom.parentNode).map(Se.fromDom),Re=e=>C.from(e.dom.parentElement).map(Se.fromDom),Be=(e,t)=>{const o=m(t)?t:w;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Se.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Le=e=>C.from(e.dom.previousSibling).map(Se.fromDom),He=e=>C.from(e.dom.nextSibling).map(Se.fromDom),Ie=e=>D(e.dom.childNodes,Se.fromDom),Pe=(e,t)=>{const o=e.dom.childNodes;return C.from(o[t]).map(Se.fromDom)},Fe=(e,t)=>{Ne(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},ze=(e,t)=>{He(e).fold((()=>{Ne(e).each((e=>{Ze(e,t)}))}),(e=>{Fe(e,t)}))},Ve=(e,t)=>{const o=(e=>Pe(e,0))(e);o.fold((()=>{Ze(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Ze=(e,t)=>{e.dom.appendChild(t.dom)},Ue=(e,t)=>{Fe(e,t),Ze(t,e)},je=(e,t)=>{A(t,((o,n)=>{const r=0===n?e:t[n-1];ze(r,o)}))},We=(e,t)=>{A(t,(t=>{Ze(e,t)}))},$e=e=>{e.dom.textContent="",A(Ie(e),(e=>{qe(e)}))},qe=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Ge=e=>{const t=Ie(e);t.length>0&&je(e,t),qe(e)},Ke=(e,t)=>Se.fromDom(e.dom.cloneNode(t)),Ye=e=>Ke(e,!1),Xe=e=>Ke(e,!0),Je=(e,t)=>{const o=Se.fromTag(t),n=xe(e);return ve(o,n),o},Qe=["tfoot","thead","tbody","colgroup"],et=(e,t,o)=>({element:e,rowspan:t,colspan:o}),tt=(e,t,o)=>({element:e,cells:t,section:o}),ot=(e,t,o)=>({element:e,isNew:t,isLocked:o}),nt=(e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}),rt=m(Element.prototype.attachShadow)&&m(Node.prototype.getRootNode),st=h(rt),at=rt?e=>Se.fromDom(e.dom.getRootNode()):Me,it=e=>{const t=at(e);return ge(o=t)&&d(o.dom.host)?C.some(t):C.none();var o},lt=e=>Se.fromDom(e.dom.host),ct=e=>d(e.dom.shadowRoot),dt=e=>{const t=me(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return it(Se.fromDom(t)).fold((()=>o.body.contains(t)),(n=dt,r=lt,e=>n(r(e))));var n,r},mt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Se.fromDom(t)},ut=(e,t)=>{let o=[];return A(Ie(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(ut(e,t))})),o},gt=(e,t,o)=>((e,t,o)=>N(Be(e,o),t))(e,(e=>ke(e,t)),o),ht=(e,t)=>((e,t)=>N(Ie(e),t))(e,(e=>ke(e,t))),pt=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return _e(o)?[]:D(o.querySelectorAll(e),Se.fromDom)})(t,e);var ft=(e,t,o,n,r)=>e(o,n)?C.some(o):m(r)&&r(o)?C.none():t(o,n,r);const vt=(e,t,o)=>{let n=e.dom;const r=m(o)?o:w;for(;n.parentNode;){n=n.parentNode;const e=Se.fromDom(n);if(t(e))return C.some(e);if(r(e))break}return C.none()},bt=(e,t,o)=>ft(((e,t)=>t(e)),vt,e,t,o),yt=(e,t,o)=>vt(e,(e=>ke(e,t)),o),wt=(e,t)=>((e,t)=>L(e.dom.childNodes,(e=>t(Se.fromDom(e)))).map(Se.fromDom))(e,(e=>ke(e,t))),xt=(e,t)=>Ee(t,e),Ct=(e,t,o)=>ft(((e,t)=>ke(e,t)),yt,e,t,o),St=(e,t,o=f)=>e.exists((e=>o(e,t))),kt=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?C.some(t):C.none(),Et=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Tt=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!c(n)||r+t.length<=n)},Ot=(e,t)=>Et(e,t,0),Dt=(e,t)=>Et(e,t,e.length-t.length),At=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Mt=e=>e.length>0,Nt=e=>void 0!==e.style&&m(e.style.getPropertyValue),Rt=(e,t,o)=>{if(!r(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Nt(e)&&e.style.setProperty(t,o)},Bt=(e,t,o)=>{const n=e.dom;Rt(n,t,o)},Lt=(e,t)=>{const o=e.dom;q(t,((e,t)=>{Rt(o,t,e)}))},Ht=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||dt(e)?n:It(o,t)},It=(e,t)=>Nt(e)?e.style.getPropertyValue(t):"",Pt=(e,t)=>{const o=e.dom,n=It(o,t);return C.from(n).filter((e=>e.length>0))},Ft=(e,t)=>{((e,t)=>{Nt(e)&&e.style.removeProperty(t)})(e.dom,t),St(ye(e,"style").map(At),"")&&we(e,"style")},zt=(e,t,o=0)=>ye(e,t).map((e=>parseInt(e,10))).getOr(o),Vt=(e,t)=>zt(e,t,1),Zt=e=>he("col")(e)?zt(e,"span",1)>1:Vt(e,"colspan")>1,Ut=e=>Vt(e,"rowspan")>1,jt=(e,t)=>parseInt(Ht(e,t),10),Wt=h(10),$t=h(10),qt=(e,t)=>Gt(e,t,x),Gt=(e,t,o)=>P(Ie(e),(e=>ke(e,t)?o(e)?[e]:[]:Gt(e,t,o))),Kt=(e,t)=>((e,t,o=w)=>o(t)?C.none():E(e,se(t))?C.some(t):yt(t,e.join(","),(e=>ke(e,"table")||o(e))))(["td","th"],e,t),Yt=e=>qt(e,"th,td"),Xt=e=>ke(e,"colgroup")?ht(e,"col"):P(eo(e),(e=>ht(e,"col"))),Jt=(e,t)=>Ct(e,"table",t),Qt=e=>qt(e,"tr"),eo=e=>Jt(e).fold(h([]),(e=>ht(e,"colgroup"))),to=(e,t)=>D(e,(e=>{if("colgroup"===se(e)){const t=D(Xt(e),(e=>{const t=zt(e,"span",1);return et(e,1,t)}));return tt(e,t,"colgroup")}{const o=D(Yt(e),(e=>{const t=zt(e,"rowspan",1),o=zt(e,"colspan",1);return et(e,t,o)}));return tt(e,o,t(e))}})),oo=e=>Ne(e).map((e=>{const t=se(e);return(e=>E(Qe,e))(t)?t:"tbody"})).getOr("tbody"),no=e=>{const t=Qt(e),o=[...eo(e),...t];return to(o,oo)},ro=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},so=()=>ao(0,0),ao=(e,t)=>({major:e,minor:t}),io={nu:ao,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?so():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return ao(n(1),n(2))})(e,o)},unknown:so},lo=(e,t)=>{const o=String(t).toLowerCase();return L(e,(e=>e.search(o)))},co=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,mo=e=>t=>Tt(t,e),uo=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Tt(e,"edge/")&&Tt(e,"chrome")&&Tt(e,"safari")&&Tt(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,co],search:e=>Tt(e,"chrome")&&!Tt(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Tt(e,"msie")||Tt(e,"trident")},{name:"Opera",versionRegexes:[co,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:mo("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:mo("firefox")},{name:"Safari",versionRegexes:[co,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Tt(e,"safari")||Tt(e,"mobile/"))&&Tt(e,"applewebkit")}],go=[{name:"Windows",search:mo("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Tt(e,"iphone")||Tt(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:mo("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:mo("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:mo("linux"),versionRegexes:[]},{name:"Solaris",search:mo("sunos"),versionRegexes:[]},{name:"FreeBSD",search:mo("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:mo("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],ho={browsers:h(uo),oses:h(go)},po="Edge",fo="Chromium",vo="Opera",bo="Firefox",yo="Safari",wo=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(po),isChromium:n(fo),isIE:n("IE"),isOpera:n(vo),isFirefox:n(bo),isSafari:n(yo)}},xo={unknown:()=>wo({current:void 0,version:io.unknown()}),nu:wo,edge:h(po),chromium:h(fo),ie:h("IE"),opera:h(vo),firefox:h(bo),safari:h(yo)},Co="Windows",So="Android",ko="Linux",_o="macOS",Eo="Solaris",To="FreeBSD",Oo="ChromeOS",Do=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(Co),isiOS:n("iOS"),isAndroid:n(So),isMacOS:n(_o),isLinux:n(ko),isSolaris:n(Eo),isFreeBSD:n(To),isChromeOS:n(Oo)}},Ao={unknown:()=>Do({current:void 0,version:io.unknown()}),nu:Do,windows:h(Co),ios:h("iOS"),android:h(So),linux:h(ko),macos:h(_o),solaris:h(Eo),freebsd:h(To),chromeos:h(Oo)},Mo=(e,t,o)=>{const n=ho.browsers(),r=ho.oses(),s=t.bind((e=>((e,t)=>j(t.brands,(t=>{const o=t.brand.toLowerCase();return L(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:io.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>lo(e,t).map((e=>{const o=io.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(xo.unknown,xo.nu),a=((e,t)=>lo(e,t).map((e=>{const o=io.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(Ao.unknown,Ao.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:h(r),isiPhone:h(s),isTablet:h(l),isPhone:h(c),isTouch:h(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:h(d),isDesktop:h(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},No=e=>window.matchMedia(e).matches;let Ro=ro((()=>Mo(navigator.userAgent,C.from(navigator.userAgentData),No)));const Bo=()=>Ro(),Lo=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Ht(o,e);return parseFloat(t)||0}return n},n=(e,t)=>B(t,((t,o)=>{const n=Ht(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!u(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Nt(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Ho=(e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?C.none():C.some(t)})(e).getOr(t),Io=(e,t,o)=>Ho(Ht(e,t),o),Po=(e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-Io(e,`padding-${o}`,0)-Io(e,`padding-${n}`,0)-Io(e,`border-${o}-width`,0)-Io(e,`border-${n}-width`,0))(e,n,"left","right")},Fo=Lo("width",(e=>e.dom.offsetWidth)),zo=e=>Fo.get(e),Vo=e=>Fo.getOuter(e),Zo=e=>Po(e,"content-box"),Uo=e=>Io(e,"width",e.dom.offsetWidth),jo=(e,t,o)=>{const n=e.cells,r=n.slice(0,t),s=n.slice(t),a=r.concat(o).concat(s);return qo(e,a)},Wo=(e,t,o)=>jo(e,t,[o]),$o=(e,t,o)=>{e.cells[t]=o},qo=(e,t)=>nt(e.element,t,e.section,e.isNew),Go=(e,t)=>e.cells[t],Ko=(e,t)=>Go(e,t).element,Yo=e=>e.cells.length,Xo=e=>{const t=M(e,(e=>"colgroup"===e.section));return{rows:t.fail,cols:t.pass}},Jo=(e,t,o)=>{const n=D(e.cells,o);return nt(t(e.element),n,e.section,!0)},Qo="data-snooker-locked-cols",en=e=>ye(e,Qo).bind((e=>C.from(e.match(/\d+/g)))).map((e=>z(e,x))),tn=e=>{const t=B(Xo(e).rows,((e,t)=>(A(t.cells,((t,o)=>{t.isLocked&&(e[o]=!0)})),e)),{}),o=X(t,((e,t)=>parseInt(t,10)));return((e,t)=>{const o=S.call(e,0);return o.sort(t),o})(o)},on=(e,t)=>e+","+t,nn=(e,t)=>{const o=P(e.all,(e=>e.cells));return N(o,t)},rn=e=>{const t={},o=[],n=Z(e).map((e=>e.element)).bind(Jt).bind(en).getOr({});let r=0,s=0,a=0;const{pass:i,fail:l}=M(e,(e=>"colgroup"===e.section));A(l,(e=>{const i=[];A(e.cells,(e=>{let o=0;for(;void 0!==t[on(a,o)];)o++;const r=((e,t)=>Q(e,t)&&void 0!==e[t]&&null!==e[t])(n,o.toString()),l=((e,t,o,n,r,s)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:s}))(e.element,e.rowspan,e.colspan,a,o,r);for(let n=0;n{const t=(e=>{const t={};let o=0;return A(e.cells,(e=>{const n=e.colspan;O(n,(r=>{const s=o+r;t[s]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,n,s)})),o+=n})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,J(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),m=((e,t)=>({rows:e,columns:t}))(r,s);return{grid:m,access:t,all:o,columns:c,colgroups:d}},sn={fromTable:e=>{const t=no(e);return rn(t)},generate:rn,getAt:(e,t,o)=>C.from(e.access[on(t,o)]),findItem:(e,t,o)=>{const n=nn(e,(e=>o(t,e.element)));return n.length>0?C.some(n[0]):C.none()},filterItems:nn,justCells:e=>P(e.all,(e=>e.cells)),justColumns:e=>J(e.columns),hasColumns:e=>W(e.columns).length>0,getColumnAt:(e,t)=>C.from(e.columns[t])},an=(e,t=x)=>{const o=e.grid,n=O(o.columns,p),r=O(o.rows,p);return D(n,(o=>ln((()=>P(r,(t=>sn.getAt(e,t,o).filter((e=>e.column===o)).toArray()))),(e=>1===e.colspan&&t(e.element)),(()=>sn.getAt(e,0,o)))))},ln=(e,t,o)=>{const n=e();return L(n,t).orThunk((()=>C.from(n[0]).orThunk(o))).map((e=>e.element))},cn=e=>{const t=e.grid,o=O(t.rows,p),n=O(t.columns,p);return D(o,(t=>ln((()=>P(n,(o=>sn.getAt(e,t,o).filter((e=>e.row===t)).fold(h([]),(e=>[e]))))),(e=>1===e.rowspan),(()=>sn.getAt(e,t,0)))))},dn=(e,t)=>{if(t<0||t>=e.length-1)return C.none();const o=e[t].fold((()=>{const o=(e=>{const t=S.call(e,0);return t.reverse(),t})(e.slice(0,t));return j(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:0}))),n=e[t+1].fold((()=>{const o=e.slice(t+1);return j(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:1})));return o.bind((e=>n.map((t=>{const o=t.delta+e.delta;return Math.abs(t.value-e.value)/o}))))},mn=(e,t)=>o=>"rtl"===un(o)?t:e,un=e=>"rtl"===Ht(e,"direction")?"rtl":"ltr",gn=Lo("height",(e=>{const t=e.dom;return dt(e)?t.getBoundingClientRect().height:t.offsetHeight})),hn=e=>gn.get(e),pn=e=>gn.getOuter(e),fn=e=>Io(e,"height",e.dom.offsetHeight),vn=(e,t)=>({left:e,top:t,translate:(o,n)=>vn(e+o,t+n)}),bn=vn,yn=(e,t)=>void 0!==e?e:void 0!==t?t:0,wn=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return bn(o.offsetLeft,o.offsetTop);const s=yn(null==n?void 0:n.pageYOffset,r.scrollTop),a=yn(null==n?void 0:n.pageXOffset,r.scrollLeft),i=yn(r.clientTop,o.clientTop),l=yn(r.clientLeft,o.clientLeft);return xn(e).translate(a-l,s-i)},xn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?bn(o.offsetLeft,o.offsetTop):dt(e)?(e=>{const t=e.getBoundingClientRect();return bn(t.left,t.top)})(t):bn(0,0)},Cn=(e,t)=>({row:e,y:t}),Sn=(e,t)=>({col:e,x:t}),kn=e=>wn(e).left+Vo(e),_n=e=>wn(e).left,En=(e,t)=>Sn(e,_n(t)),Tn=(e,t)=>Sn(e,kn(t)),On=e=>wn(e).top,Dn=(e,t)=>Cn(e,On(t)),An=(e,t)=>Cn(e,On(t)+pn(t)),Mn=(e,t,o)=>{if(0===o.length)return[];const n=D(o.slice(1),((t,o)=>t.map((t=>e(o,t))))),r=o[o.length-1].map((e=>t(o.length-1,e)));return n.concat([r])},Nn={delta:p,positions:e=>Mn(Dn,An,e),edge:On},Rn=mn({delta:p,edge:_n,positions:e=>Mn(En,Tn,e)},{delta:e=>-e,edge:kn,positions:e=>Mn(Tn,En,e)}),Bn={delta:(e,t)=>Rn(t).delta(e,t),positions:(e,t)=>Rn(t).positions(e,t),edge:e=>Rn(e).edge(e)},Ln={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},Hn=(()=>{const e="[0-9]+",t="[eE]"+("[+-]?"+e),o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^(${`[+-]?(?:${n})`})(.*)$`)})(),In=(e,t)=>C.from(Hn.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>T(t,(t=>T(Ln[t],(t=>e===t)))))(n,t)?C.some({value:o,unit:n}):C.none()})),Pn=/(\d+(\.\d+)?)%/,Fn=/(\d+(\.\d+)?)px|em/,zn=he("col"),Vn=(e,t,o)=>{const n=Re(e).getOrThunk((()=>mt(Ae(e))));return t(e)/o(n)*100},Zn=(e,t)=>{Bt(e,"width",t+"px")},Un=(e,t)=>{Bt(e,"width",t+"%")},jn=(e,t)=>{Bt(e,"height",t+"px")},Wn=(e,t,o,n)=>{const r=parseFloat(e);return Dt(e,"%")&&"table"!==se(t)?((e,t,o,n)=>{const r=Jt(e).map((e=>{const n=o(e);return Math.floor(t/100*n)})).getOr(t);return n(e,r),r})(t,r,o,n):r},$n=e=>{const t=(e=>fn(e)+"px")(e);return t?Wn(t,e,hn,jn):hn(e)},qn=(e,t)=>Pt(e,t).orThunk((()=>ye(e,t).map((e=>e+"px")))),Gn=e=>qn(e,"width"),Kn=e=>Vn(e,zo,Zo),Yn=e=>zn(e)?zo(e):Uo(e),Xn=e=>((e,t,o)=>o(e)/Vt(e,t))(e,"rowspan",$n),Jn=(e,t,o)=>{Bt(e,"width",t+o)},Qn=e=>Vn(e,zo,Zo)+"%",er=h(Pn),tr=he("col"),or=e=>Gn(e).getOrThunk((()=>Yn(e)+"px")),nr=e=>{return(t=e,qn(t,"height")).getOrThunk((()=>Xn(e)+"px"));var t},rr=(e,t,o,n,r,s)=>e.filter(n).fold((()=>s(dn(o,t))),(e=>r(e))),sr=(e,t,o,n)=>{const r=an(e),s=sn.hasColumns(e)?(e=>D(sn.justColumns(e),(e=>C.from(e.element))))(e):r,a=[C.some(Bn.edge(t))].concat(D(Bn.positions(r,t),(e=>e.map((e=>e.x))))),i=b(Zt);return D(s,((e,t)=>rr(e,t,a,i,(e=>{if((e=>{const t=Bo().browser,o=t.isChromium()||t.isFirefox();return!tr(e)||o})(e))return o(e);{const e=(s=r[t],l=p,null!=s?l(s):C.none());return rr(e,t,a,i,(e=>n(C.some(zo(e)))),n)}var s,l}),n)))},ar=e=>e.map((e=>e+"px")).getOr(""),ir=(e,t,o)=>sr(e,t,Yn,(e=>e.getOrThunk(o.minCellWidth))),lr=(e,t,o,n,r)=>{const s=cn(e),a=[C.some(o.edge(t))].concat(D(o.positions(s,t),(e=>e.map((e=>e.y)))));return D(s,((e,t)=>rr(e,t,a,b(Ut),n,r)))},cr=(e,t)=>()=>dt(e)?t(e):parseFloat(Pt(e,"width").getOr("0")),dr=e=>{const t=cr(e,zo),o=h(0);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:o,singleColumnWidth:h([0]),minCellWidth:o,setElementWidth:g,adjustTableWidth:g,isRelative:!0,label:"none"}},mr=e=>{const t=cr(e,(e=>parseFloat(Qn(e)))),o=cr(e,zo);return{width:t,pixelWidth:o,getWidths:(t,o)=>((e,t,o)=>sr(e,t,Kn,(e=>e.fold((()=>o.minCellWidth()),(e=>e/o.pixelWidth()*100)))))(t,e,o),getCellDelta:e=>e/o()*100,singleColumnWidth:(e,t)=>[100-e],minCellWidth:()=>Wt()/o()*100,setElementWidth:Un,adjustTableWidth:o=>{const n=t();Un(e,n+o/100*n)},isRelative:!0,label:"percent"}},ur=e=>{const t=cr(e,zo);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:p,singleColumnWidth:(e,t)=>[Math.max(Wt(),e+t)-e],minCellWidth:Wt,setElementWidth:Zn,adjustTableWidth:o=>{const n=t()+o;Zn(e,n)},isRelative:!1,label:"pixel"}},gr=e=>Gn(e).fold((()=>dr(e)),(t=>((e,t)=>null!==er().exec(t)?mr(e):ur(e))(e,t))),hr=ur,pr=mr,fr=(e,t,o)=>{const n=e[o].element,r=Se.fromTag("td");Ze(r,Se.fromTag("br"));(t?Ze:Ve)(n,r)},vr=(e,t)=>{const o=e=>ke(e.element,t),n=Xe(e),r=no(n),s=gr(e),a=sn.generate(r),i=((e,t)=>{const o=e.grid.columns;let n=e.grid.rows,r=o,s=0,a=0;const i=[],l=[];return q(e.access,(e=>{if(i.push(e),t(e)){l.push(e);const t=e.row,o=t+e.rowspan-1,i=e.column,c=i+e.colspan-1;ts&&(s=o),ia&&(a=c)}})),((e,t,o,n,r,s)=>({minRow:e,minCol:t,maxRow:o,maxCol:n,allCells:r,selectedCells:s}))(n,r,s,a,i,l)})(a,o),l="th:not("+t+"),td:not("+t+")",c=Gt(n,"th,td",(e=>ke(e,l)));A(c,qe),((e,t,o,n)=>{const r=N(e,(e=>"colgroup"!==e.section)),s=t.grid.columns,a=t.grid.rows;for(let e=0;eo.maxRow||io.maxCol||(sn.getAt(t,e,i).filter(n).isNone()?fr(r,a,e):a=!0)}})(r,a,i,o);const d=((e,t,o,n)=>{if(0===n.minCol&&t.grid.columns===n.maxCol+1)return 0;const r=ir(t,e,o),s=B(r,((e,t)=>e+t),0),a=B(r.slice(n.minCol,n.maxCol+1),((e,t)=>e+t),0),i=a/s*o.pixelWidth()-o.pixelWidth();return o.getCellDelta(i)})(e,sn.fromTable(e),s,i);return((e,t,o,n)=>{q(o.columns,(e=>{(e.columnt.maxCol)&&qe(e.element)}));const r=N(qt(e,"tr"),(e=>0===e.dom.childElementCount));A(r,qe),t.minCol!==t.maxCol&&t.minRow!==t.maxRow||A(qt(e,"th,td"),(e=>{we(e,"rowspan"),we(e,"colspan")})),we(e,Qo),we(e,"data-snooker-col-series"),gr(e).adjustTableWidth(n)})(n,i,a,d),n},br=((e,t)=>{const o=t=>e(t)?C.from(t.dom.nodeValue):C.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(me,"text"),yr=e=>br.get(e),wr=e=>br.getOption(e),xr=(e,t)=>br.set(e,t),Cr=e=>"img"===se(e)?1:wr(e).fold((()=>Ie(e).length),(e=>e.length)),Sr=["img","br"],kr=e=>wr(e).filter((e=>0!==e.trim().length||e.indexOf(" ")>-1)).isSome()||E(Sr,se(e))||(e=>ce(e)&&"false"===be(e,"contenteditable"))(e),_r=e=>((e,t)=>{const o=e=>{for(let n=0;nTr(e,kr),Tr=(e,t)=>{const o=e=>{const n=Ie(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return C.some(r);const s=o(r);if(s.isSome())return s}return C.none()};return o(e)},Or={scope:["row","col"]},Dr=e=>()=>{const t=Se.fromTag("td",e.dom);return Ze(t,Se.fromTag("br",e.dom)),t},Ar=e=>()=>Se.fromTag("col",e.dom),Mr=e=>()=>Se.fromTag("colgroup",e.dom),Nr=e=>()=>Se.fromTag("tr",e.dom),Rr=(e,t,o)=>{const n=((e,t)=>{const o=Je(e,t),n=Ie(Xe(e));return We(o,n),o})(e,t);return q(o,((e,t)=>{null===e?we(n,t):fe(n,t,e)})),n},Br=e=>e,Lr=(e,t,o)=>{const n=(e,t)=>{((e,t)=>{const o=e.dom,n=t.dom;Nt(o)&&Nt(n)&&(n.style.cssText=o.style.cssText)})(e.element,t),Ft(t,"height"),1!==e.colspan&&Ft(t,"width")};return{col:o=>{const r=Se.fromTag(se(o.element),t.dom);return n(o,r),e(o.element,r),r},colgroup:Mr(t),row:Nr(t),cell:r=>{const s=Se.fromTag(se(r.element),t.dom),a=o.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),i=a.length>0?((e,t,o)=>_r(e).map((n=>{const r=o.join(","),s=gt(n,r,(t=>Te(t,e)));return R(s,((e,t)=>{const o=Ye(t);return Ze(e,o),o}),t)})).getOr(t))(r.element,s,a):s;return Ze(i,Se.fromTag("br")),n(r,s),((e,t)=>{q(Or,((o,n)=>ye(e,n).filter((e=>E(o,e))).each((e=>fe(t,n,e)))))})(r.element,s),e(r.element,s),s},replace:Rr,colGap:Ar(t),gap:Dr(t)}},Hr=e=>({col:Ar(e),colgroup:Mr(e),row:Nr(e),cell:Dr(e),replace:Br,colGap:Ar(e),gap:Dr(e)}),Ir=e=>t=>t.options.get(e),Pr="100%",Fr=e=>{var t;const o=e.dom,n=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return Zo(Se.fromDom(n))+"px"},zr=e=>C.from(e.options.get("table_clone_elements")),Vr=Ir("table_header_type"),Zr=Ir("table_column_resizing"),Ur=e=>"preservetable"===Zr(e),jr=e=>"resizetable"===Zr(e),Wr=Ir("table_sizing_mode"),$r=e=>"relative"===Wr(e),qr=e=>"fixed"===Wr(e),Gr=e=>"responsive"===Wr(e),Kr=Ir("table_resize_bars"),Yr=Ir("table_style_by_css"),Xr=Ir("table_merge_content_on_paste"),Jr=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Gr(e)||Yr(e)?t:qr(e)?{...t,width:Fr(e)}:{...t,width:Pr})(e,o)},Qr=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Gr(e)||!Yr(e)?t:qr(e)?{...t,width:Fr(e)}:{...t,width:Pr})(e,o)},es=Ir("table_use_colgroups"),ts=e=>Ct(e,"[contenteditable]"),os=(e,t=!1)=>dt(e)?e.dom.isContentEditable:ts(e).fold(h(t),(e=>"true"===ns(e))),ns=e=>e.dom.contentEditable,rs=e=>Se.fromDom(e.getBody()),ss=e=>t=>Te(t,rs(e)),as=e=>{we(e,"data-mce-style");const t=e=>we(e,"data-mce-style");A(Yt(e),t),A(Xt(e),t),A(Qt(e),t)},is=e=>Se.fromDom(e.selection.getStart()),ls=e=>e.getBoundingClientRect().width,cs=e=>e.getBoundingClientRect().height,ds=e=>bt(e,he("table")).exists(os),ms=(e,t)=>{const o=t.column,n=t.column+t.colspan-1,r=t.row,s=t.row+t.rowspan-1;return o<=e.finishCol&&n>=e.startCol&&r<=e.finishRow&&s>=e.startRow},us=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,gs=(e,t,o)=>{const n=sn.findItem(e,t,Te),r=sn.findItem(e,o,Te);return n.bind((e=>r.map((t=>{return o=e,n=t,r=Math.min(o.row,n.row),s=Math.min(o.column,n.column),a=Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),i=Math.max(o.column+o.colspan-1,n.column+n.colspan-1),{startRow:r,startCol:s,finishRow:a,finishCol:i};var o,n,r,s,a,i}))))},hs=(e,t,o)=>gs(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=v(us,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let s=t.startCol;s<=t.finishCol;s++)o=o&&sn.getAt(e,r,s).exists(n);return o?C.some(t):C.none()})(e,t))),ps=(e,t,o)=>gs(e,t,o).map((t=>{const o=sn.filterItems(e,v(ms,t));return D(o,(e=>e.element))})),fs=(e,t)=>sn.findItem(e,t,((e,t)=>Oe(t,e))).map((e=>e.element)),vs=(e,t,o)=>Jt(e).bind((n=>((e,t,o,n)=>sn.findItem(e,t,Te).bind((t=>{const r=o>0?t.row+t.rowspan-1:t.row,s=n>0?t.column+t.colspan-1:t.column;return sn.getAt(e,r+o,s+n).map((e=>e.element))})))(ws(n),e,t,o))),bs=(e,t,o)=>{const n=ws(e);return ps(n,t,o)},ys=(e,t,o,n,r)=>{const s=ws(e),a=Te(e,o)?C.some(t):fs(s,t),i=Te(e,r)?C.some(n):fs(s,n);return a.bind((e=>i.bind((t=>ps(s,e,t)))))},ws=sn.fromTable;var xs=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Cs=()=>({up:h({selector:yt,closest:Ct,predicate:vt,all:Be}),down:h({selector:pt,predicate:ut}),styles:h({get:Ht,getRaw:Pt,set:Bt,remove:Ft}),attrs:h({get:be,set:fe,remove:we,copyTo:(e,t)=>{const o=xe(e);ve(t,o)}}),insert:h({before:Fe,after:ze,afterAll:je,append:Ze,appendAll:We,prepend:Ve,wrap:Ue}),remove:h({unwrap:Ge,remove:qe}),create:h({nu:Se.fromTag,clone:e=>Se.fromDom(e.dom.cloneNode(!1)),text:Se.fromText}),query:h({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:Le,nextSibling:He}),property:h({children:Ie,name:se,parent:Ne,document:e=>Me(e).dom,isText:me,isComment:le,isElement:de,isSpecial:e=>{const t=se(e);return E(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>de(e)?ye(e,"lang"):C.none(),getText:yr,setText:xr,isBoundary:e=>!!de(e)&&("body"===se(e)||E(xs,se(e))),isEmptyTag:e=>!!de(e)&&E(["br","img","hr","input"],se(e)),isNonEditable:e=>de(e)&&"false"===be(e,"contenteditable")}),eq:Te,is:De});const Ss=(e,t,o,n)=>{const r=t(e,o);return R(n,((o,n)=>{const r=t(e,n);return ks(e,o,r)}),r)},ks=(e,t,o)=>t.bind((t=>o.filter(v(e.eq,t)))),_s=(e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,Ss):C.none(),Es=(e,t,o,n=w)=>{const r=[t].concat(e.up().all(t)),s=[o].concat(e.up().all(o)),a=e=>H(e,n).fold((()=>e),(t=>e.slice(0,t+1))),i=a(r),l=a(s),c=L(i,(t=>T(l,((e,t)=>v(e.eq,t))(e,t))));return{firstpath:i,secondpath:l,shared:c}},Ts=Cs(),Os=(e,t)=>_s(Ts,((t,o)=>e(o)),t),Ds=e=>yt(e,"table"),As=(e,t,o)=>{const n=e=>t=>void 0!==o&&o(t)||Te(t,e);return Te(e,t)?C.some({boxes:C.some([e]),start:e,finish:t}):Ds(e).bind((r=>Ds(t).bind((s=>{if(Te(r,s))return C.some({boxes:bs(r,e,t),start:e,finish:t});if(Oe(r,s)){const o=gt(t,"td,th",n(r)),a=o.length>0?o[o.length-1]:t;return C.some({boxes:ys(r,e,r,t,s),start:e,finish:a})}if(Oe(s,r)){const o=gt(e,"td,th",n(s)),a=o.length>0?o[o.length-1]:e;return C.some({boxes:ys(s,e,r,t,s),start:e,finish:a})}return((e,t,o)=>Es(Ts,e,t,o))(e,t).shared.bind((a=>Ct(a,"table",o).bind((o=>{const a=gt(t,"td,th",n(o)),i=a.length>0?a[a.length-1]:t,l=gt(e,"td,th",n(o)),c=l.length>0?l[l.length-1]:e;return C.some({boxes:ys(o,e,r,t,s),start:c,finish:i})}))))}))))},Ms=(e,t)=>{const o=pt(e,t);return o.length>0?C.some(o):C.none()},Ns=(e,t,o)=>xt(e,t).bind((t=>xt(e,o).bind((e=>Os(Ds,[t,e]).map((o=>({first:t,last:e,table:o}))))))),Rs=(e,t,o,n,r)=>((e,t)=>L(e,(e=>ke(e,t))))(e,r).bind((e=>vs(e,t,o).bind((e=>((e,t)=>yt(e,"table").bind((o=>xt(o,t).bind((t=>As(t,e).bind((e=>e.boxes.map((t=>({boxes:t,start:e.start,finish:e.finish}))))))))))(e,n))))),Bs=(e,t)=>Ms(e,t),Ls=(e,t,o)=>Ns(e,t,o).bind((t=>{const o=t=>Te(e,t),n="thead,tfoot,tbody,table",r=yt(t.first,n,o),s=yt(t.last,n,o);return r.bind((e=>s.bind((o=>Te(e,o)?((e,t,o)=>{const n=ws(e);return hs(n,t,o)})(t.table,t.first,t.last):C.none()))))})),Hs=p,Is=e=>{const t=(e,t)=>ye(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&F(e,(e=>t(e,"rowspan")||t(e,"colspan")))?C.some(e):C.none()},Ps=(e,t,o)=>t.length<=1?C.none():Ls(e,o.firstSelectedSelector,o.lastSelectedSelector).map((e=>({bounds:e,cells:t}))),Fs="data-mce-selected",zs="td["+Fs+"],th["+Fs+"]",Vs="["+Fs+"]",Zs="data-mce-first-selected",Us="td["+Zs+"],th["+Zs+"]",js="data-mce-last-selected",Ws="td["+js+"],th["+js+"]",$s=Vs,qs={selected:Fs,selectedSelector:zs,firstSelected:Zs,firstSelectedSelector:Us,lastSelected:js,lastSelectedSelector:Ws},Gs=(e,t,o)=>({element:o,mergable:Ps(t,e,qs),unmergable:Is(e),selection:Hs(e)}),Ks=e=>(t,o)=>{const n=se(t),r="col"===n||"colgroup"===n?Jt(s=t).bind((e=>Bs(e,qs.firstSelectedSelector))).fold(h(s),(e=>e[0])):t;var s;return Ct(r,e,o)},Ys=Ks("th,td,caption"),Xs=Ks("th,td"),Js=e=>{return t=e.model.table.getSelectedCells(),D(t,Se.fromDom);var t},Qs=(e,t)=>{e.on("BeforeGetContent",(t=>{const o=o=>{t.preventDefault(),(e=>Jt(e[0]).map((e=>{const t=vr(e,$s);return as(t),[t]})))(o).each((o=>{t.content="text"===t.format?(e=>D(e,(e=>e.dom.innerText)).join(""))(o):((e,t)=>D(t,(t=>e.selection.serializer.serialize(t.dom,{}))).join(""))(e,o)}))};if(!0===t.selection){const t=(e=>N(Js(e),(e=>ke(e,qs.selectedSelector))))(e);t.length>=1&&o(t)}})),e.on("BeforeSetContent",(o=>{if(!0===o.selection&&!0===o.paste){const n=Js(e);Z(n).each((n=>{Jt(n).each((r=>{const s=N(((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Ie(Se.fromDom(o))})(o.content),(e=>"meta"!==se(e))),a=he("table");if(Xr(e)&&1===s.length&&a(s[0])){o.preventDefault();const a=Se.fromDom(e.getDoc()),i=Hr(a),l=((e,t,o)=>({element:e,clipboard:t,generators:o}))(n,s[0],i);t.pasteCells(r,l).each((()=>{e.focus()}))}}))}))}}))},ea=(e,t)=>({element:e,offset:t}),ta=(e,t,o)=>e.property().isText(t)&&0===e.property().getText(t).trim().length||e.property().isComment(t)?o(t).bind((t=>ta(e,t,o).orThunk((()=>C.some(t))))):C.none(),oa=(e,t)=>{if(e.property().isText(t))return e.property().getText(t).length;return e.property().children(t).length},na=(e,t)=>{const o=ta(e,t,e.query().prevSibling).getOr(t);if(e.property().isText(o))return ea(o,oa(e,o));const n=e.property().children(o);return n.length>0?na(e,n[n.length-1]):ea(o,oa(e,o))},ra=na,sa=Cs(),aa=(e,t)=>{if(!Zt(e)){const o=(e=>Gn(e).bind((e=>In(e,["fixed","relative","empty"]))))(e);o.each((o=>{const n=o.value/2;Jn(e,n,o.unit),Jn(t,n,o.unit)}))}},ia=e=>D(e,h(0)),la=(e,t,o,n,r)=>r(e.slice(0,t)).concat(n).concat(r(e.slice(o))),ca=e=>(t,o,n,r)=>{if(e(n)){const e=Math.max(r,t[o]-Math.abs(n)),s=Math.abs(e-t[o]);return n>=0?s:-s}return n},da=ca((e=>e<0)),ma=ca(x),ua=()=>{const e=(e,t,o,n)=>{const r=(100+o)/100,s=Math.max(n,(e[t]+o)/r);return D(e,((e,o)=>(o===t?s:e/r)-e))},t=(t,o,n,r,s,a)=>a?e(t,o,r,s):((e,t,o,n,r)=>{const s=da(e,t,n,r);return la(e,t,o+1,[s,0],ia)})(t,o,n,r,s);return{resizeTable:(e,t)=>e(t),clampTableDelta:da,calcLeftEdgeDeltas:t,calcMiddleDeltas:(e,o,n,r,s,a,i)=>t(e,n,r,s,a,i),calcRightEdgeDeltas:(t,o,n,r,s,a)=>{if(a)return e(t,n,r,s);{const e=da(t,n,r,s);return ia(t.slice(0,n)).concat([e])}},calcRedestributedWidths:(e,t,o,n)=>{if(n){const n=(t+o)/t,r=D(e,(e=>e/n));return{delta:100*n-100,newSizes:r}}return{delta:o,newSizes:e}}}},ga=()=>{const e=(e,t,o,n,r)=>{const s=ma(e,n>=0?o:t,n,r);return la(e,t,o+1,[s,-s],ia)};return{resizeTable:(e,t,o)=>{o&&e(t)},clampTableDelta:(e,t,o,n,r)=>{if(r){if(o>=0)return o;{const t=B(e,((e,t)=>e+t-n),0);return Math.max(-t,o)}}return da(e,t,o,n)},calcLeftEdgeDeltas:e,calcMiddleDeltas:(t,o,n,r,s,a)=>e(t,n,r,s,a),calcRightEdgeDeltas:(e,t,o,n,r,s)=>{if(s)return ia(e);{const t=n/e.length;return D(e,h(t))}},calcRedestributedWidths:(e,t,o,n)=>({delta:0,newSizes:e})}},ha=e=>sn.fromTable(e).grid,pa=he("th"),fa=e=>F(e,(e=>pa(e.element))),va=(e,t)=>e&&t?"sectionCells":e?"section":"cells",ba=e=>{const t="thead"===e.section,o=St(ya(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:va(t,o)}:{type:"body"}},ya=e=>{const t=N(e,(e=>pa(e.element)));return 0===t.length?C.some("td"):t.length===e.length?C.some("th"):C.none()},wa=(e,t,o)=>ot(o(e.element,t),!0,e.isLocked),xa=(e,t)=>e.section!==t?nt(e.element,e.cells,t,e.isNew):e,Ca=()=>({transformRow:xa,transformCell:(e,t,o)=>{const n=o(e.element,t),r="td"!==se(n)?((e,t)=>{const o=Je(e,t);ze(e,o);const n=Ie(e);return We(o,n),qe(e),o})(n,"td"):n;return ot(r,e.isNew,e.isLocked)}}),Sa=()=>({transformRow:xa,transformCell:wa}),ka=()=>({transformRow:(e,t)=>xa(e,"thead"===t?"tbody":t),transformCell:wa}),_a=(e,t)=>{const o=(e=>j(e.all,(e=>{const t=ba(e);return"header"===t.type?C.from(t.subType):C.none()})))(sn.fromTable(e)).getOr(t);switch(o){case"section":return Ca();case"sectionCells":return Sa();case"cells":return ka()}},Ea=Ca,Ta=Sa,Oa=ka,Da=()=>({transformRow:p,transformCell:wa}),Aa=(e,t,o,n)=>{o===n?we(e,t):fe(e,t,o)},Ma=(e,t,o)=>{U(ht(e,t)).fold((()=>Ve(e,o)),(e=>ze(e,o)))},Na=(e,t)=>{const o=[],n=[],r=e=>D(e,(e=>{e.isNew&&o.push(e.element);const t=e.element;return $e(t),A(e.cells,(e=>{e.isNew&&n.push(e.element),Aa(e.element,"colspan",e.colspan,1),Aa(e.element,"rowspan",e.rowspan,1),Ze(t,e.element)})),t})),s=e=>P(e,(e=>D(e.cells,(e=>(Aa(e.element,"span",e.colspan,1),e.element))))),a=(t,o)=>{const n=((e,t)=>{const o=wt(e,t).getOrThunk((()=>{const o=Se.fromTag(t,Ae(e).dom);return"thead"===t?Ma(e,"caption,colgroup",o):"colgroup"===t?Ma(e,"caption",o):Ze(e,o),o}));return $e(o),o})(e,o),a=("colgroup"===o?s:r)(t);We(n,a)},i=(t,o)=>{t.length>0?a(t,o):(t=>{wt(e,t).each(qe)})(o)},l=[],c=[],d=[],m=[];return A(t,(e=>{switch(e.section){case"thead":l.push(e);break;case"tbody":c.push(e);break;case"tfoot":d.push(e);break;case"colgroup":m.push(e)}})),i(m,"colgroup"),i(l,"thead"),i(c,"tbody"),i(d,"tfoot"),{newRows:o,newCells:n}},Ra=(e,t)=>{if(0===e.length)return 0;const o=e[0];return H(e,(e=>!t(o.element,e.element))).getOr(e.length)},Ba=(e,t,o,n)=>{const r=((e,t)=>e[t])(e,t),s="colgroup"===r.section,a=Ra(r.cells.slice(o),n),i=s?1:Ra(((e,t)=>D(e,(e=>Go(e,t))))(e.slice(t),o),n);return{colspan:a,rowspan:i}},La=(e,t)=>{const o=D(e,(e=>D(e.cells,w)));return D(e,((n,r)=>{const s=P(n.cells,((n,s)=>{if(!1===o[r][s]){const d=Ba(e,r,s,t);return((e,t,n,r)=>{for(let s=e;s({element:e,cells:t,section:o,isNew:n}))(n.element,s,n.section,n.isNew)}))},Ha=(e,t,o)=>{const n=[];A(e.colgroups,(r=>{const s=[];for(let n=0;not(e.element,o,!1))).getOrThunk((()=>ot(t.colGap(),!0,!1)));s.push(r)}n.push(nt(r.element,s,"colgroup",o))}));for(let r=0;rot(e.element,o,e.isLocked))).getOrThunk((()=>ot(t.gap(),!0,!1)));s.push(a)}const a=e.all[r],i=nt(a.element,s,a.section,o);n.push(i)}return n},Ia=e=>La(e,Te),Pa=(e,t)=>j(e.all,(e=>L(e.cells,(e=>Te(t,e.element))))),Fa=(e,t,o)=>{const n=D(t.selection,(t=>Kt(t).bind((t=>Pa(e,t))).filter(o))),r=kt(n);return _t(r.length>0,r)},za=(e,t,o,n,r)=>(s,a,i,l)=>{const c=sn.fromTable(s),d=C.from(null==l?void 0:l.section).getOrThunk(Da);return t(c,a).map((t=>{const o=((e,t)=>Ha(e,t,!1))(c,i),n=e(o,t,Te,r(i),d),s=tn(n.grid);return{info:t,grid:Ia(n.grid),cursor:n.cursor,lockedColumns:s}})).bind((e=>{const t=Na(s,e.grid),r=C.from(null==l?void 0:l.sizing).getOrThunk((()=>gr(s))),a=C.from(null==l?void 0:l.resize).getOrThunk(ga);return o(s,e.grid,e.info,{sizing:r,resize:a,section:d}),n(s),we(s,Qo),e.lockedColumns.length>0&&fe(s,Qo,e.lockedColumns.join(",")),C.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})}))},Va=(e,t)=>Fa(e,t,x).map((e=>({cells:e,generators:t.generators,clipboard:t.clipboard}))),Za=(e,t)=>Fa(e,t,x),Ua=(e,t)=>Fa(e,t,(e=>!e.isLocked)),ja=(e,t)=>F(t,(t=>((e,t)=>Pa(e,t).exists((e=>!e.isLocked)))(e,t))),Wa=(e,t,o,n)=>{const r=Xo(e).rows;let s=!0;for(let e=0;e{const r=Xo(e).rows;if(t>0&&tB(e,((e,o)=>T(e,(e=>t(e.element,o.element)))?e:e.concat([o])),[]))(r[t-1].cells,o);A(e,(e=>{let s=C.none();for(let a=t;a{$o(i,t,ot(e,!0,l.isLocked))})))}}))}return e},qa=e=>{const t=t=>t(e),o=h(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:x,isError:w,map:t=>Ka.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>C.some(e)};return r},Ga=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:w,isError:x,map:t,mapError:t=>Ka.error(t(e)),bind:t,exists:w,forall:x,getOr:p,or:p,getOrThunk:y,orThunk:y,getOrDie:(n=String(e),()=>{throw new Error(n)}),each:g,toOptional:C.none};var n;return o},Ka={value:qa,error:Ga,fromOption:(e,t)=>e.fold((()=>Ga(t)),qa)},Ya=(e,t)=>({rowDelta:0,colDelta:Yo(e[0])-Yo(t[0])}),Xa=(e,t)=>({rowDelta:e.length-t.length,colDelta:0}),Ja=(e,t,o,n)=>{const r="colgroup"===t.section?o.col:o.cell;return O(e,(e=>ot(r(),!0,n(e))))},Qa=(e,t,o,n)=>{const r=e[e.length-1];return e.concat(O(t,(()=>{const e="colgroup"===r.section?o.colgroup:o.row,t=Jo(r,e,p),s=Ja(t.cells.length,t,o,(e=>Q(n,e.toString())));return qo(t,s)})))},ei=(e,t,o,n)=>D(e,(e=>{const r=Ja(t,e,o,w);return jo(e,n,r)})),ti=(e,t,o)=>{const n=t.colDelta<0?ei:p,r=t.rowDelta<0?Qa:p,s=tn(e),a=Yo(e[0]),i=T(s,(e=>e===a-1)),l=n(e,Math.abs(t.colDelta),o,i?a-1:a),c=tn(l);return r(l,Math.abs(t.rowDelta),o,z(c,x))},oi=(e,t,o,n)=>{const r=v(n,Go(e[t],o).element),s=e[t];return e.length>1&&Yo(s)>1&&(o>0&&r(Ko(s,o-1))||o0&&r(Ko(e[t-1],o))||tN(o,(o=>o>=e.column&&o<=Yo(t[0])+e.column)),ri=(e,t,o,n,r)=>{const s=tn(t),a=((e,t,o)=>{const n=Yo(t[0]),r=Xo(t).cols.length+e.row,s=O(n-e.column,(t=>t+e.column)),a=L(s,(e=>F(o,(t=>t!==e)))).getOr(n-1);return{row:r,column:a}})(e,t,s),i=Xo(o).rows,l=ni(a,i,s),c=((e,t,o)=>{if(e.row>=t.length||e.column>Yo(t[0]))return Ka.error("invalid start address out of table bounds, row: "+e.row+", column: "+e.column);const n=t.slice(e.row),r=n[0].cells.slice(e.column),s=Yo(o[0]),a=o.length;return Ka.value({rowDelta:n.length-a,colDelta:r.length-s})})(a,t,i);return c.map((e=>{const o={...e,colDelta:e.colDelta-l.length},s=ti(t,o,n),c=tn(s),d=ni(a,i,c);return((e,t,o,n,r,s)=>{const a=e.row,i=e.column,l=a+o.length,c=i+Yo(o[0])+s.length,d=z(s,x);for(let e=a;e{((e,t,o,n)=>{t>0&&t{const r=e.cells[t-1];let s=0;const a=n();for(;e.cells.length>t+s&&o(r.element,e.cells[t+s].element);)$o(e,t+s,ot(a,!0,e.cells[t+s].isLocked)),s++}))})(t,e,r,n.cell);const s=Xa(o,t),a=ti(o,s,n),i=Xa(t,a),l=ti(t,i,n);return D(l,((t,o)=>jo(t,e,a[o].cells)))},ai=(e,t,o,n,r)=>{$a(t,e,r,n.cell);const s=tn(t),a=Ya(t,o),i={...a,colDelta:a.colDelta-s.length},l=ti(t,i,n),{cols:c,rows:d}=Xo(l),m=tn(l),u=Ya(o,t),g={...u,colDelta:u.colDelta+m.length},h=((e,t,o)=>D(e,(e=>B(o,((o,n)=>{const r=Ja(1,e,t,x)[0];return Wo(o,n,r)}),e))))(o,n,m),p=ti(h,g,n);return[...c,...d.slice(0,e),...p,...d.slice(e,d.length)]},ii=(e,t,o,n,r)=>{const{rows:s,cols:a}=Xo(e),i=s.slice(0,t),l=s.slice(t),c=((e,t,o,n)=>Jo(e,(e=>n(e,o)),t))(s[o],((e,o)=>t>0&&tD(e,(e=>{const s=t>0&&t{if("colgroup"!==o&&n)return Go(e,t);{const t=Go(e,r);return ot(a(t.element,s),!0,!1)}})(e,t,e.section,s,o,n,r);return Wo(e,t,a)})),ci=(e,t,o,n)=>((e,t,o,n)=>void 0!==Ko(e[t],o)&&t>0&&n(Ko(e[t-1],o),Ko(e[t],o)))(e,t,o,n)||((e,t,o)=>t>0&&o(Ko(e,t-1),Ko(e,t)))(e[t],o,n),di=(e,t,o,n)=>{const r=e=>(e=>"row"===e?Ut(t):Zt(t))(e)?`${e}group`:e;if(e)return pa(t)?r(o):null;if(n&&pa(t)){return r("row"===o?"col":"row")}return null},mi=(e,t,o)=>ot(o(e.element,t),!0,e.isLocked),ui=(e,t,o,n,r,s,a)=>D(e,((e,i)=>((e,t)=>{const o=e.cells,n=D(o,t);return nt(e.element,n,e.section,e.isNew)})(e,((e,l)=>{if((e=>T(t,(t=>o(e.element,t.element))))(e)){const t=a(e,i,l)?r(e,o,n):e;return s(t,i,l).each((e=>{var o,n;o=t.element,n={scope:C.from(e)},q(n,((e,t)=>{e.fold((()=>{we(o,t)}),(e=>{pe(o.dom,t,e)}))}))})),t}return e})))),gi=(e,t,o)=>P(e,((n,r)=>ci(e,r,t,o)?[]:[Go(n,t)])),hi=(e,t,o,n,r)=>{const s=Xo(e).rows,a=P(t,(e=>gi(s,e,n))),i=D(s,(e=>fa(e.cells))),l=((e,t)=>F(t,p)&&fa(e)?x:(e,o,n)=>!("th"===se(e.element)&&t[o]))(a,i),c=((e,t)=>(o,n)=>C.some(di(e,o.element,"row",t[n])))(o,i);return ui(e,a,n,r,mi,c,l)},pi=(e,t,o,n,r,s,a)=>{const{cols:i,rows:l}=Xo(e),c=l[t[0]],d=P(t,(e=>((e,t,o)=>{const n=e[t];return P(n.cells,((n,r)=>ci(e,t,r,o)?[]:[n]))})(l,e,r))),m=D(c.cells,((e,t)=>fa(gi(l,t,r)))),u=[...l];A(t,(e=>{u[e]=a.transformRow(l[e],o)}));const g=[...i,...u],h=((e,t)=>F(t,p)&&fa(e.cells)?x:(e,o,n)=>!("th"===se(e.element)&&t[n]))(c,m),f=((e,t)=>(o,n,r)=>C.some(di(e,o.element,"col",t[r])))(n,m);return ui(g,d,r,s,a.transformCell,f,h)},fi=(e,t,o,n)=>{const r=Xo(e).rows,s=D(t,(e=>Go(r[e.row],e.column)));return ui(e,s,o,n,mi,C.none,x)},vi=e=>{if(!a(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return A(e,((n,r)=>{const s=W(n);if(1!==s.length)throw new Error("one and only one name per case");const i=s[0],l=n[i];if(void 0!==o[i])throw new Error("duplicate key detected:"+i);if("cata"===i)throw new Error("cannot have a case named cata (sorry)");if(!a(l))throw new Error("case arguments must be an array");t.push(i),o[i]=(...o)=>{const n=o.length;if(n!==l.length)throw new Error("Wrong number of arguments to case "+i+". Expected "+l.length+" ("+l+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=W(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!F(t,(e=>E(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[i].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:i,params:o})}}}})),o},bi={...vi([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}])},yi=(e,t,o,n,r)=>{const s=e.slice(0),a=((e,t)=>0===e.length?bi.none():1===e.length?bi.only(0):0===t?bi.left(0,1):t===e.length-1?bi.right(t-1,t):t>0&&tn.singleColumnWidth(s[e],o)),((e,t)=>r.calcLeftEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)),((e,t,a)=>r.calcMiddleDeltas(s,e,t,a,o,n.minCellWidth(),n.isRelative)),((e,t)=>r.calcRightEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)))},wi=(e,t,o)=>{let n=0;for(let r=e;r{const o=sn.justCells(e);return D(o,(e=>{const o=wi(e.row,e.row+e.rowspan,t);return{element:e.element,height:o,rowspan:e.rowspan}}))},Ci=(e,t)=>sn.hasColumns(e)?((e,t)=>{const o=sn.justColumns(e);return D(o,((e,o)=>({element:e.element,width:t[o],colspan:e.colspan})))})(e,t):((e,t)=>{const o=sn.justCells(e);return D(o,(e=>{const o=wi(e.column,e.column+e.colspan,t);return{element:e.element,width:o,colspan:e.colspan}}))})(e,t),Si=(e,t,o)=>{const n=Ci(e,t);A(n,(e=>{o.setElementWidth(e.element,e.width)}))},ki=(e,t,o,n,r)=>{const s=sn.fromTable(e),a=r.getCellDelta(t),i=r.getWidths(s,r),l=o===s.grid.columns-1,c=n.clampTableDelta(i,o,a,r.minCellWidth(),l),d=yi(i,o,c,r,n),m=D(d,((e,t)=>e+i[t]));Si(s,m,r),n.resizeTable(r.adjustTableWidth,c,l)},_i=(e,t,o,n)=>{const r=sn.fromTable(e),s=((e,t,o)=>lr(e,t,o,Xn,(e=>e.getOrThunk($t))))(r,e,n),a=D(s,((e,n)=>o===n?Math.max(t+e,$t()):e)),i=xi(r,a),l=((e,t)=>D(e.all,((e,o)=>({element:e.element,height:t[o]}))))(r,a);A(l,(e=>{jn(e.element,e.height)})),A(i,(e=>{jn(e.element,e.height)}));const c=R(a,((e,t)=>e+t),0);jn(e,c)},Ei=e=>B(e,((e,t)=>T(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),Ti=he("col"),Oi=he("colgroup"),Di=e=>"tr"===se(e)||Oi(e),Ai=e=>({element:e,colspan:zt(e,"colspan",1),rowspan:zt(e,"rowspan",1)}),Mi=e=>ye(e,"scope").map((e=>e.substr(0,3))),Ni=(e,t=Ai)=>{const o=o=>{if(Di(o))return Oi((r={element:o}).element)?e.colgroup(r):e.row(r);{const r=o,s=(t=>Ti(t.element)?e.col(t):e.cell(t))(t(r));return n=C.some({item:r,replacement:s}),s}var r};let n=C.none();return{getOrInit:(e,t)=>n.fold((()=>o(e)),(n=>t(e,n.item)?n.replacement:o(e)))}},Ri=e=>t=>{const o=[],n=n=>{const r="td"===e?{scope:null}:{},s=t.replace(n,e,r);return o.push({item:n,sub:s}),s};return{replaceOrInit:(e,t)=>{if(Di(e)||Ti(e))return e;{const r=e;return((e,t)=>L(o,(o=>t(o.item,e))))(r,t).fold((()=>n(r)),(o=>t(e,o.item)?o.sub:n(r)))}}}},Bi=e=>({unmerge:t=>{const o=Mi(t);return o.each((e=>fe(t,"scope",e))),()=>{const n=e.cell({element:t,colspan:1,rowspan:1});return Ft(n,"width"),Ft(t,"width"),o.each((e=>fe(n,"scope",e))),n}},merge:e=>(Ft(e[0],"width"),(()=>{const t=kt(D(e,Mi));if(0===t.length)return C.none();{const e=t[0],o=["row","col"];return T(t,(t=>t!==e&&E(o,t)))?C.none():C.from(e)}})().fold((()=>we(e[0],"scope")),(t=>fe(e[0],"scope",t+"group"))),h(e[0]))}),Li=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Hi=Cs(),Ii=e=>((e,t)=>{const o=e.property().name(t);return E(Li,o)})(Hi,e),Pi=e=>((e,t)=>{const o=e.property().name(t);return E(["ol","ul"],o)})(Hi,e),Fi=e=>((e,t)=>E(["br","img","hr","input"],e.property().name(t)))(Hi,e),zi=e=>{const t=he("br"),o=e=>Er(e).bind((o=>{const n=He(o).map((e=>!!Ii(e)||!!Fi(e)&&"img"!==se(e))).getOr(!1);return Ne(o).map((r=>!0===n||(e=>"li"===se(e)||vt(e,Pi).isSome())(r)||t(o)||Ii(r)&&!Te(e,r)?[]:[Se.fromTag("br")]))})).getOr([]),n=(()=>{const n=P(e,(e=>{const n=Ie(e);return(e=>F(e,(e=>t(e)||me(e)&&0===yr(e).trim().length)))(n)?[]:n.concat(o(e))}));return 0===n.length?[Se.fromTag("br")]:n})();$e(e[0]),We(e[0],n)},Vi=e=>os(e,!0),Zi=e=>{0===Yt(e).length&&qe(e)},Ui=(e,t)=>({grid:e,cursor:t}),ji=(e,t,o)=>{var n,r;const s=Xo(e).rows;return C.from(null===(r=null===(n=s[t])||void 0===n?void 0:n.cells[o])||void 0===r?void 0:r.element).filter(Vi).orThunk((()=>(e=>j(e,(e=>j(e.cells,(e=>{const t=e.element;return _t(Vi(t),t)})))))(s)))},Wi=(e,t,o)=>{const n=ji(e,t,o);return Ui(e,n)},$i=e=>B(e,((e,t)=>T(e,(e=>e.row===t.row))?e:e.concat([t])),[]).sort(((e,t)=>e.row-t.row)),qi=(e,t)=>(o,n,r,s,a)=>{const i=$i(n),l=D(i,(e=>e.row)),c=pi(o,l,e,t,r,s.replaceOrInit,a);return Wi(c,n[0].row,n[0].column)},Gi=qi("thead",!0),Ki=qi("tbody",!1),Yi=qi("tfoot",!1),Xi=(e,t,o)=>{const n=((e,t)=>to(e,(()=>t)))(e,o.section),r=sn.generate(n);return Ha(r,t,!0)},Ji=(e,t,o,n)=>((e,t,o,n)=>{const r=sn.generate(t),s=n.getWidths(r,n);Si(r,s,n)})(0,t,0,n.sizing),Qi=(e,t,o,n)=>((e,t,o,n,r)=>{const s=sn.generate(t),a=n.getWidths(s,n),i=n.pixelWidth(),{newSizes:l,delta:c}=r.calcRedestributedWidths(a,i,o.pixelDelta,n.isRelative);Si(s,l,n),n.adjustTableWidth(c)})(0,t,o,n.sizing,n.resize),el=(e,t)=>T(t,(e=>0===e.column&&e.isLocked)),tl=(e,t)=>T(t,(t=>t.column+t.colspan>=e.grid.columns&&t.isLocked)),ol=(e,t)=>{const o=an(e),n=Ei(t);return B(n,((e,t)=>e+o[t.column].map(Vo).getOr(0)),0)},nl=e=>(t,o)=>Za(t,o).filter((o=>!(e?el:tl)(t,o))).map((e=>({details:e,pixelDelta:ol(t,e)}))),rl=e=>(t,o)=>Va(t,o).filter((o=>!(e?el:tl)(t,o.cells))),sl=Ri("th"),al=Ri("td"),il=za(((e,t,o,n)=>{const r=t[0].row,s=$i(t),a=R(s,((e,t)=>({grid:ii(e.grid,r,t.row+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return Wi(a,r,t[0].column)}),Za,g,g,Ni),ll=za(((e,t,o,n)=>{const r=$i(t),s=r[r.length-1],a=s.row+s.rowspan,i=R(r,((e,t)=>ii(e,a,t.row,o,n.getOrInit)),e);return Wi(i,a,t[0].column)}),Za,g,g,Ni),cl=za(((e,t,o,n)=>{const r=t.details,s=Ei(r),a=s[0].column,i=R(s,((e,t)=>({grid:li(e.grid,a,t.column+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return Wi(i,r[0].row,a)}),nl(!0),Qi,g,Ni),dl=za(((e,t,o,n)=>{const r=t.details,s=r[r.length-1],a=s.column+s.colspan,i=Ei(r),l=R(i,((e,t)=>li(e,a,t.column,o,n.getOrInit)),e);return Wi(l,r[0].row,a)}),nl(!1),Qi,g,Ni),ml=za(((e,t,o,n)=>{const r=Ei(t.details),s=((e,t)=>P(e,(e=>{const o=e.cells,n=R(t,((e,t)=>t>=0&&t0?[nt(e.element,n,e.section,e.isNew)]:[]})))(e,D(r,(e=>e.column))),a=s.length>0?s[0].cells.length-1:0;return Wi(s,r[0].row,Math.min(r[0].column,a))}),((e,t)=>Ua(e,t).map((t=>({details:t,pixelDelta:-ol(e,t)})))),Qi,Zi,Ni),ul=za(((e,t,o,n)=>{const r=$i(t),s=((e,t,o)=>{const{rows:n,cols:r}=Xo(e);return[...r,...n.slice(0,t),...n.slice(o+1)]})(e,r[0].row,r[r.length-1].row),a=s.length>0?s.length-1:0;return Wi(s,Math.min(t[0].row,a),t[0].column)}),Za,g,Zi,Ni),gl=za(((e,t,o,n)=>{const r=Ei(t),s=D(r,(e=>e.column)),a=hi(e,s,!0,o,n.replaceOrInit);return Wi(a,t[0].row,t[0].column)}),Ua,g,g,sl),hl=za(((e,t,o,n)=>{const r=Ei(t),s=D(r,(e=>e.column)),a=hi(e,s,!1,o,n.replaceOrInit);return Wi(a,t[0].row,t[0].column)}),Ua,g,g,al),pl=za(Gi,Ua,g,g,sl),fl=za(Ki,Ua,g,g,al),vl=za(Yi,Ua,g,g,al),bl=za(((e,t,o,n)=>{const r=fi(e,t,o,n.replaceOrInit);return Wi(r,t[0].row,t[0].column)}),Ua,g,g,sl),yl=za(((e,t,o,n)=>{const r=fi(e,t,o,n.replaceOrInit);return Wi(r,t[0].row,t[0].column)}),Ua,g,g,al),wl=za(((e,t,o,n)=>{const r=t.cells;zi(r);const s=((e,t,o,n)=>{const r=Xo(e).rows;if(0===r.length)return e;for(let e=t.startRow;e<=t.finishRow;e++)for(let o=t.startCol;o<=t.finishCol;o++){const t=r[e],s=Go(t,o).isLocked;$o(t,o,ot(n(),!1,s))}return e})(e,t.bounds,0,n.merge(r));return Ui(s,C.from(r[0]))}),((e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>ja(e,t.cells)))),Ji,g,Bi),xl=za(((e,t,o,n)=>{const r=R(t,((e,t)=>Wa(e,t,o,n.unmerge(t))),e);return Ui(r,C.from(t[0]))}),((e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>ja(e,t)))),Ji,g,Bi),Cl=za(((e,t,o,n)=>{const r=((e,t)=>{const o=sn.fromTable(e);return Ha(o,t,!0)})(t.clipboard,t.generators),s=((e,t)=>({row:e,column:t}))(t.row,t.column);return ri(s,e,r,t.generators,o).fold((()=>Ui(e,C.some(t.element))),(e=>Wi(e,t.row,t.column)))}),((e,t)=>Kt(t.element).bind((o=>Pa(e,o).map((e=>({...e,generators:t.generators,clipboard:t.clipboard})))))),Ji,g,Ni),Sl=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[0].column,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=si(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),rl(!0),g,g,Ni),kl=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[t.cells.length-1].column+t.cells[t.cells.length-1].colspan,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=si(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),rl(!1),g,g,Ni),_l=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[0].row,a=r[s],i=Xi(t.clipboard,t.generators,a),l=ai(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),Va,g,g,Ni),El=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[t.cells.length-1].row+t.cells[t.cells.length-1].rowspan,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=ai(s,e,i,t.generators,o);return Wi(l,t.cells[0].row,t.cells[0].column)}),Va,g,g,Ni),Tl=(e,t)=>{const o=sn.fromTable(e);return Za(o,t).bind((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=I(D(o.all,(e=>N(e.cells,(e=>e.column>=n&&e.column{const o=sn.fromTable(e);return Za(o,t).bind(ya).getOr("")},Dl=(e,t)=>{const o=sn.fromTable(e);return Za(o,t).bind((e=>{const t=e[e.length-1],n=e[0].row,r=t.row+t.rowspan;return(e=>{const t=D(e,(e=>ba(e).type)),o=E(t,"header"),n=E(t,"footer");if(o||n){const e=E(t,"body");return!o||e||n?o||e||!n?C.none():C.some("footer"):C.some("header")}return C.some("body")})(o.all.slice(n,r))})).getOr("")},Al=(e,t)=>e.dispatch("NewRow",{node:t}),Ml=(e,t)=>e.dispatch("NewCell",{node:t}),Nl=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},Rl={structure:!1,style:!0},Bl={structure:!0,style:!1},Ll={structure:!0,style:!0},Hl=(e,t)=>$r(e)?pr(t):qr(e)?hr(t):gr(t),Il=(e,t,o)=>{const n=e=>"table"===se(rs(e)),r=zr(e),s=jr(e)?g:aa,a=t=>{switch(Vr(e)){case"section":return Ea();case"sectionCells":return Ta();case"cells":return Oa();default:return _a(t,"section")}},i=(t,n)=>n.cursor.fold((()=>{const n=Yt(t);return Z(n).filter(dt).map((n=>{o.clearSelectedCells(t.dom);const r=e.dom.createRng();return r.selectNode(n.dom),e.selection.setRng(r),fe(n,"data-mce-selected","1"),r}))}),(n=>{const r=ra(sa,n);const s=e.dom.createRng();return s.setStart(r.element.dom,r.offset),s.setEnd(r.element.dom,r.offset),e.selection.setRng(s),o.clearSelectedCells(t.dom),C.some(s)})),l=(o,n,s,l)=>(c,d,m=!1)=>{as(c);const u=Se.fromDom(e.getDoc()),g=Lr(s,u,r),h={sizing:Hl(e,c),resize:jr(e)?ua():ga(),section:a(c)};return n(c)?o(c,d,g,h).bind((o=>{t.refresh(c.dom),A(o.newRows,(t=>{Al(e,t.dom)})),A(o.newCells,(t=>{Ml(e,t.dom)}));const n=i(c,o);return dt(c)&&(as(c),m||Nl(e,c.dom,l)),n.map((e=>({rng:e,effect:l})))})):C.none()},c=l(ul,(t=>!n(e)||ha(t).rows>1),g,Bl),d=l(ml,(t=>!n(e)||ha(t).columns>1),g,Bl);return{deleteRow:c,deleteColumn:d,insertRowsBefore:l(il,x,g,Bl),insertRowsAfter:l(ll,x,g,Bl),insertColumnsBefore:l(cl,x,s,Bl),insertColumnsAfter:l(dl,x,s,Bl),mergeCells:l(wl,x,g,Bl),unmergeCells:l(xl,x,g,Bl),pasteColsBefore:l(Sl,x,g,Bl),pasteColsAfter:l(kl,x,g,Bl),pasteRowsBefore:l(_l,x,g,Bl),pasteRowsAfter:l(El,x,g,Bl),pasteCells:l(Cl,x,g,Ll),makeCellsHeader:l(bl,x,g,Bl),unmakeCellsHeader:l(yl,x,g,Bl),makeColumnsHeader:l(gl,x,g,Bl),unmakeColumnsHeader:l(hl,x,g,Bl),makeRowsHeader:l(pl,x,g,Bl),makeRowsBody:l(fl,x,g,Bl),makeRowsFooter:l(vl,x,g,Bl),getTableRowType:Dl,getTableCellType:Ol,getTableColType:Tl}},Pl=(e,t,o)=>{const n=zt(e,t,1);1===o||n<=1?we(e,t):fe(e,t,Math.min(o,n))},Fl=(e,t)=>o=>{const n=o.column+o.colspan-1,r=o.column;return n>=e&&r{const o=sn.fromTable(e);return Ua(o,t).map((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=((e,t,o)=>{if(sn.hasColumns(e)){const n=N(sn.justColumns(e),Fl(t,o)),r=D(n,(e=>{const n=Xe(e.element);return Pl(n,"span",o-t),n})),s=Se.fromTag("colgroup");return We(s,r),[s]}return[]})(o,n,r),a=((e,t,o)=>D(e.all,(e=>{const n=N(e.cells,Fl(t,o)),r=D(n,(e=>{const n=Xe(e.element);return Pl(n,"colspan",o-t),n})),s=Se.fromTag("tr");return We(s,r),s})))(o,n,r);return[...s,...a]}))},Vl=(e,t,o)=>{const n=sn.fromTable(e);return Za(n,t).bind((e=>{const t=Ha(n,o,!1),r=Xo(t).rows.slice(e[0].row,e[e.length-1].row+e[e.length-1].rowspan),s=P(r,(e=>{const t=N(e.cells,(e=>!e.isLocked));return t.length>0?[{...e,cells:t}]:[]})),a=Ia(s);return _t(a.length>0,a)})).map((e=>(e=>D(e,(e=>{const t=Ye(e.element);return A(e.cells,(e=>{const o=Xe(e.element);Aa(o,"colspan",e.colspan,1),Aa(o,"rowspan",e.rowspan,1),Ze(t,o)})),t})))(e)))},Zl=vi([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),Ul=(e,t,o)=>{const n=o.substring(0,o.length-e.length),r=parseFloat(n);return n===r.toString()?t(r):Zl.invalid(o)},jl={...Zl,from:e=>Dt(e,"%")?Ul("%",Zl.percent,e):Dt(e,"px")?Ul("px",Zl.pixels,e):Zl.invalid(e)},Wl=(e,t,o)=>e.fold((()=>t),(e=>((e,t,o)=>{const n=o/t;return D(e,(e=>jl.from(e).fold((()=>e),(e=>e*n+"px"),(e=>e/100*o+"px"))))})(t,o,e)),(e=>((e,t)=>D(e,(e=>jl.from(e).fold((()=>e),(e=>e/t*100+"%"),(e=>e+"%")))))(t,o))),$l=(e,t,o)=>{const n=jl.from(o),r=F(e,(e=>"0px"===e))?((e,t)=>{const o=e.fold((()=>h("")),(e=>h(e/t+"px")),(()=>h(100/t+"%")));return O(t,o)})(n,e.length):Wl(n,e,t);return Kl(r)},ql=(e,t)=>0===e.length?t:R(e,((e,t)=>jl.from(t).fold(h(0),p,p)+e),0),Gl=(e,t)=>jl.from(e).fold(h(e),(e=>e+t+"px"),(e=>e+t+"%")),Kl=e=>{if(0===e.length)return e;const t=R(e,((e,t)=>{const o=jl.from(t).fold((()=>({value:t,remainder:0})),(e=>((e,t)=>{const o=Math.floor(e);return{value:o+t,remainder:e-o}})(e,"px")),(e=>({value:e+"%",remainder:0})));return{output:[o.value].concat(e.output),remainder:e.remainder+o.remainder}}),{output:[],remainder:0}),o=t.output;return o.slice(0,o.length-1).concat([Gl(o[o.length-1],Math.round(t.remainder))])},Yl=jl.from,Xl=e=>Yl(e).fold(h("px"),h("px"),h("%")),Jl=(e,t,o)=>{const n=sn.fromTable(e),r=n.all,s=sn.justCells(n),a=sn.justColumns(n);t.each((t=>{const o=Xl(t),r=zo(e),i=((e,t)=>sr(e,t,or,ar))(n,e),l=$l(i,r,t);sn.hasColumns(n)?((e,t,o)=>{A(t,((t,n)=>{const r=ql([e[n]],Wt());Bt(t.element,"width",r+o)}))})(l,a,o):((e,t,o)=>{A(t,(t=>{const n=e.slice(t.column,t.colspan+t.column),r=ql(n,Wt());Bt(t.element,"width",r+o)}))})(l,s,o),Bt(e,"width",t)})),o.each((t=>{const o=Xl(t),a=hn(e),i=((e,t,o)=>lr(e,t,o,nr,ar))(n,e,Nn);((e,t,o,n)=>{A(o,(t=>{const o=e.slice(t.row,t.rowspan+t.row),r=ql(o,$t());Bt(t.element,"height",r+n)})),A(t,((t,o)=>{Bt(t.element,"height",e[o])}))})($l(i,a,t),r,s,o),Bt(e,"height",t)}))},Ql=e=>Gn(e).exists((e=>Pn.test(e))),ec=e=>Gn(e).exists((e=>Fn.test(e))),tc=e=>Gn(e).isNone(),oc=e=>{we(e,"width")},nc=e=>{const t=Qn(e);Jl(e,C.some(t),C.none()),oc(e)},rc=e=>{const t=(e=>zo(e)+"px")(e);Jl(e,C.some(t),C.none()),oc(e)},sc=e=>{Ft(e,"width");const t=Xt(e),o=t.length>0?t:Yt(e);A(o,(e=>{Ft(e,"width"),oc(e)})),oc(e)},ac={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},colGroups:!1},ic=e=>{const t=Se.fromTag("colgroup");return O(e,(()=>Ze(t,Se.fromTag("col")))),t},lc=(e,t,o,n)=>O(e,(e=>((e,t,o,n)=>{const r=Se.fromTag("tr");for(let s=0;s{e.selection.select(t.dom,!0),e.selection.collapse(!0)},dc=(e,t,o,n,s)=>{const a=Qr(e),i={styles:a,attributes:Jr(e),colGroups:es(e)};return e.undoManager.ignore((()=>{const r=((e,t,o,n,r,s=ac)=>{const a=Se.fromTag("table"),i="cells"!==r;Lt(a,s.styles),ve(a,s.attributes),s.colGroups&&Ze(a,ic(t));const l=Math.min(e,o);if(i&&o>0){const e=Se.fromTag("thead");Ze(a,e);const s=lc(o,t,"sectionCells"===r?l:0,n);We(e,s)}const c=Se.fromTag("tbody");Ze(a,c);const d=lc(i?e-l:e,t,i?0:o,n);return We(c,d),a})(o,t,s,n,Vr(e),i);fe(r,"data-mce-id","__mce");const a=(e=>{const t=Se.fromTag("div"),o=Se.fromDom(e.dom.cloneNode(!0));return Ze(t,o),(e=>e.dom.innerHTML)(t)})(r);e.insertContent(a),e.addVisual()})),xt(rs(e),'table[data-mce-id="__mce"]').map((t=>(qr(e)?rc(t):Gr(e)?sc(t):($r(e)||(e=>r(e)&&-1!==e.indexOf("%"))(a.width))&&nc(t),as(t),we(t,"data-mce-id"),((e,t)=>{A(pt(t,"tr"),(t=>{Al(e,t.dom),A(pt(t,"th,td"),(t=>{Ml(e,t.dom)}))}))})(e,t),((e,t)=>{xt(t,"td,th").each(v(cc,e))})(e,t),t.dom))).getOrNull()};var mc=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const uc="x-tinymce/dom-table-",gc=uc+"rows",hc=uc+"columns",pc=e=>{const t=mc.FakeClipboardItem(e);mc.write([t])},fc=e=>{var t;const o=null!==(t=mc.read())&&void 0!==t?t:[];return j(o,(t=>C.from(t.getType(e))))},vc=e=>{fc(e).isSome()&&mc.clear()},bc=e=>{e.fold(wc,(e=>pc({[gc]:e})))},yc=()=>fc(gc),wc=()=>vc(gc),xc=e=>{e.fold(Sc,(e=>pc({[hc]:e})))},Cc=()=>fc(hc),Sc=()=>vc(hc),kc=e=>Ys(is(e),ss(e)).filter(ds),_c=(e,t)=>{const o=ss(e),n=e=>Jt(e,o),a=t=>(e=>Xs(is(e),ss(e)).filter(ds))(e).bind((e=>n(e).map((o=>t(o,e))))),i=t=>{e.focus()},l=(t,o=!1)=>a(((n,r)=>{const s=Gs(Js(e),n,r);t(n,s,o).each(i)})),c=()=>a(((t,o)=>{const n=Gs(Js(e),t,o),r=Lr(g,Se.fromDom(e.getDoc()),C.none());return Vl(t,n,r)})),d=()=>a(((t,o)=>{const n=Gs(Js(e),t,o);return zl(t,n)})),m=(t,o)=>o().each((o=>{const n=D(o,(e=>Xe(e)));a(((o,r)=>{const s=Hr(Se.fromDom(e.getDoc())),a=((e,t,o,n)=>({selection:Hs(e),clipboard:o,generators:n}))(Js(e),0,n,s);t(o,a).each(i)}))})),h=e=>(t,o)=>((e,t)=>Q(e,t)?C.from(e[t]):C.none())(o,"type").each((t=>{l(e(t),o.no_events)}));q({mceTableSplitCells:()=>l(t.unmergeCells),mceTableMergeCells:()=>l(t.mergeCells),mceTableInsertRowBefore:()=>l(t.insertRowsBefore),mceTableInsertRowAfter:()=>l(t.insertRowsAfter),mceTableInsertColBefore:()=>l(t.insertColumnsBefore),mceTableInsertColAfter:()=>l(t.insertColumnsAfter),mceTableDeleteCol:()=>l(t.deleteColumn),mceTableDeleteRow:()=>l(t.deleteRow),mceTableCutCol:()=>d().each((e=>{xc(e),l(t.deleteColumn)})),mceTableCutRow:()=>c().each((e=>{bc(e),l(t.deleteRow)})),mceTableCopyCol:()=>d().each((e=>xc(e))),mceTableCopyRow:()=>c().each((e=>bc(e))),mceTablePasteColBefore:()=>m(t.pasteColsBefore,Cc),mceTablePasteColAfter:()=>m(t.pasteColsAfter,Cc),mceTablePasteRowBefore:()=>m(t.pasteRowsBefore,yc),mceTablePasteRowAfter:()=>m(t.pasteRowsAfter,yc),mceTableDelete:()=>kc(e).each((t=>{Jt(t,o).filter(b(o)).each((t=>{const o=Se.fromText("");if(ze(t,o),qe(t),e.dom.isEmpty(e.getBody()))e.setContent(""),e.selection.setCursorLocation();else{const t=e.dom.createRng();t.setStart(o.dom,0),t.setEnd(o.dom,0),e.selection.setRng(t),e.nodeChanged()}}))})),mceTableCellToggleClass:(t,o)=>{a((t=>{const n=Js(e),r=F(n,(t=>e.formatter.match("tablecellclass",{value:o},t.dom))),s=r?e.formatter.remove:e.formatter.apply;A(n,(e=>s("tablecellclass",{value:o},e.dom))),Nl(e,t.dom,Rl)}))},mceTableToggleClass:(t,o)=>{a((t=>{e.formatter.toggle("tableclass",{value:o},t.dom),Nl(e,t.dom,Rl)}))},mceTableToggleCaption:()=>{kc(e).each((t=>{Jt(t,o).each((o=>{wt(o,"caption").fold((()=>{const t=Se.fromTag("caption");Ze(t,Se.fromText("Caption")),((e,t,o)=>{Pe(e,o).fold((()=>{Ze(e,t)}),(e=>{Fe(e,t)}))})(o,t,0),e.selection.setCursorLocation(t.dom,0)}),(n=>{he("caption")(t)&&Ee("td",o).each((t=>e.selection.setCursorLocation(t.dom,0))),qe(n)})),Nl(e,o.dom,Bl)}))}))},mceTableSizingMode:(t,n)=>(t=>kc(e).each((n=>{Gr(e)||qr(e)||$r(e)||Jt(n,o).each((o=>{"relative"!==t||Ql(o)?"fixed"!==t||ec(o)?"responsive"!==t||tc(o)||sc(o):rc(o):nc(o),as(o),Nl(e,o.dom,Bl)}))})))(n),mceTableCellType:h((e=>"th"===e?t.makeCellsHeader:t.unmakeCellsHeader)),mceTableColType:h((e=>"th"===e?t.makeColumnsHeader:t.unmakeColumnsHeader)),mceTableRowType:h((e=>{switch(e){case"header":return t.makeRowsHeader;case"footer":return t.makeRowsFooter;default:return t.makeRowsBody}}))},((t,o)=>e.addCommand(o,t))),e.addCommand("mceInsertTable",((t,o)=>{((e,t,o,n={})=>{const r=e=>u(e)&&e>0;if(r(t)&&r(o)){const r=n.headerRows||0,s=n.headerColumns||0;return dc(e,o,t,s,r)}console.error("Invalid values for mceInsertTable - rows and columns values are required to insert a table.")})(e,o.rows,o.columns,o.options)})),e.addCommand("mceTableApplyCellStyle",((t,o)=>{const a=e=>"tablecell"+e.toLowerCase().replace("-","");if(!s(o))return;const i=N(Js(e),ds);if(0===i.length)return;const l=Y(o,((t,o)=>e.formatter.has(a(o))&&r(t)));(e=>{for(const t in e)if($.call(e,t))return!1;return!0})(l)||(q(l,((t,o)=>{const n=a(o);A(i,(o=>{""===t?e.formatter.remove(n,{value:null},o.dom,!0):e.formatter.apply(n,{value:t},o.dom)}))})),n(i[0]).each((t=>Nl(e,t.dom,Rl))))}))},Ec=vi([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Tc={before:Ec.before,on:Ec.on,after:Ec.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(p,p,p)},Oc=(e,t)=>({selection:e,kill:t}),Dc=(e,t)=>{const o=e.document.createRange();return o.selectNode(t.dom),o},Ac=(e,t)=>{const o=e.document.createRange();return Mc(o,t),o},Mc=(e,t)=>e.selectNodeContents(t.dom),Nc=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Rc=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Bc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),Lc=vi([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Hc=(e,t,o)=>t(Se.fromDom(o.startContainer),o.startOffset,Se.fromDom(o.endContainer),o.endOffset),Ic=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:h(e),rtl:C.none}),relative:(t,o)=>({ltr:ro((()=>Nc(e,t,o))),rtl:ro((()=>C.some(Nc(e,o,t))))}),exact:(t,o,n,r)=>({ltr:ro((()=>Rc(e,t,o,n,r))),rtl:ro((()=>C.some(Rc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();if(o.collapsed)return t.rtl().filter((e=>!1===e.collapsed)).map((e=>Lc.rtl(Se.fromDom(e.endContainer),e.endOffset,Se.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>Hc(0,Lc.ltr,o)));return Hc(0,Lc.ltr,o)})(0,o)},Pc=(e,t)=>Ic(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});Lc.ltr,Lc.rtl;const Fc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),zc=(e,t,o,n)=>({start:Tc.on(e,t),finish:Tc.on(o,n)}),Vc=(e,t)=>{const o=Pc(e,t);return Fc(Se.fromDom(o.startContainer),o.startOffset,Se.fromDom(o.endContainer),o.endOffset)},Zc=zc,Uc=(e,t,o,n,r)=>Te(o,n)?C.none():As(o,n,t).bind((t=>{const n=t.boxes.getOr([]);return n.length>1?(r(e,n,t.start,t.finish),C.some(Oc(C.some(Zc(o,0,o,Cr(o))),!0))):C.none()})),jc=(e,t)=>({item:e,mode:t}),Wc=(e,t,o,n=$c)=>e.property().parent(t).map((e=>jc(e,n))),$c=(e,t,o,n=qc)=>o.sibling(e,t).map((e=>jc(e,n))),qc=(e,t,o,n=qc)=>{const r=e.property().children(t);return o.first(r).map((e=>jc(e,n)))},Gc=[{current:Wc,next:$c,fallback:C.none()},{current:$c,next:qc,fallback:C.some(Wc)},{current:qc,next:qc,fallback:C.some($c)}],Kc=(e,t,o,n,r=Gc)=>L(r,(e=>e.current===o)).bind((o=>o.current(e,t,n,o.next).orThunk((()=>o.fallback.bind((o=>Kc(e,t,o,n))))))),Yc=()=>({sibling:(e,t)=>e.query().prevSibling(t),first:e=>e.length>0?C.some(e[e.length-1]):C.none()}),Xc=()=>({sibling:(e,t)=>e.query().nextSibling(t),first:e=>e.length>0?C.some(e[0]):C.none()}),Jc=(e,t,o,n,r,s)=>Kc(e,t,n,r).bind((t=>s(t.item)?C.none():o(t.item)?C.some(t.item):Jc(e,t.item,o,t.mode,r,s))),Qc=e=>t=>0===e.property().children(t).length,ed=(e,t,o,n)=>Jc(e,t,o,$c,Yc(),n),td=(e,t,o,n)=>Jc(e,t,o,$c,Xc(),n),od=Cs(),nd=(e,t)=>((e,t,o)=>ed(e,t,Qc(e),o))(od,e,t),rd=(e,t)=>((e,t,o)=>td(e,t,Qc(e),o))(od,e,t),sd=vi([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),ad=e=>Ct(e,"tr"),id={...sd,verify:(e,t,o,n,r,s,a)=>Ct(n,"td,th",a).bind((o=>Ct(t,"td,th",a).map((t=>Te(o,t)?Te(n,o)&&Cr(o)===r?s(t):sd.none("in same cell"):Os(ad,[o,t]).fold((()=>((e,t,o)=>{const n=e.getRect(t),r=e.getRect(o);return r.right>n.left&&r.lefts(t))))))).getOr(sd.none("default")),cata:(e,t,o,n,r)=>e.fold(t,o,n,r)},ld=(e,t)=>H(e,v(Te,t)),cd=he("br"),dd=(e,t,o)=>t(e,o).bind((e=>me(e)&&0===yr(e).trim().length?dd(e,t,o):C.some(e))),md=(e,t,o,n)=>((e,t)=>Pe(e,t).filter(cd).orThunk((()=>Pe(e,t-1).filter(cd))))(t,o).bind((t=>n.traverse(t).fold((()=>dd(t,n.gather,e).map(n.relative)),(e=>(e=>Ne(e).bind((t=>{const o=Ie(t);return ld(o,e).map((n=>((e,t,o,n)=>({parent:e,children:t,element:o,index:n}))(t,o,e,n)))})))(e).map((e=>Tc.on(e.parent,e.index))))))),ud=(e,t,o,n)=>{const r=cd(t)?((e,t,o)=>o.traverse(t).orThunk((()=>dd(t,o.gather,e))).map(o.relative))(e,t,n):md(e,t,o,n);return r.map((e=>({start:e,finish:e})))},gd=(e,t)=>({left:e.left,top:e.top+t,right:e.right,bottom:e.bottom+t}),hd=(e,t)=>({left:e.left,top:e.top-t,right:e.right,bottom:e.bottom-t}),pd=(e,t,o)=>({left:e.left+t,top:e.top+o,right:e.right+t,bottom:e.bottom+o}),fd=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom}),vd=(e,t)=>C.some(e.getRect(t)),bd=(e,t,o)=>de(t)?vd(e,t).map(fd):me(t)?((e,t,o)=>o>=0&&o0?e.getRangedRect(t,o-1,t,o):C.none())(e,t,o).map(fd):C.none(),yd=(e,t)=>de(t)?vd(e,t).map(fd):me(t)?e.getRangedRect(t,0,t,Cr(t)).map(fd):C.none(),wd=vi([{none:[]},{retry:["caret"]}]),xd=(e,t,o)=>bt(t,Ii).fold(w,(t=>yd(e,t).exists((e=>((e,t)=>e.leftt.right)(o,e))))),Cd={point:e=>e.bottom,adjuster:(e,t,o,n,r)=>{const s=gd(r,5);return Math.abs(o.bottom-n.bottom)<1||o.top>r.bottom?wd.retry(s):o.top===r.bottom?wd.retry(gd(r,1)):xd(e,t,r)?wd.retry(pd(s,5,0)):wd.none()},move:gd,gather:rd},Sd=(e,t,o,n,r)=>0===r?C.some(n):((e,t,o)=>e.elementFromPoint(t,o).filter((e=>"table"===se(e))).isSome())(e,n.left,t.point(n))?((e,t,o,n,r)=>Sd(e,t,o,t.move(n,5),r))(e,t,o,n,r-1):e.situsFromPoint(n.left,t.point(n)).bind((s=>s.start.fold(C.none,(s=>yd(e,s).bind((a=>t.adjuster(e,s,a,o,n).fold(C.none,(n=>Sd(e,t,o,n,r-1))))).orThunk((()=>C.some(n)))),C.none))),kd=(e,t,o)=>{const n=e.move(o,5),r=Sd(t,e,o,n,100).getOr(n);return((e,t,o)=>e.point(t)>o.getInnerHeight()?C.some(e.point(t)-o.getInnerHeight()):e.point(t)<0?C.some(-e.point(t)):C.none())(e,r,t).fold((()=>t.situsFromPoint(r.left,e.point(r))),(o=>(t.scrollBy(0,o),t.situsFromPoint(r.left,e.point(r)-o))))},_d={tryUp:v(kd,{point:e=>e.top,adjuster:(e,t,o,n,r)=>{const s=hd(r,5);return Math.abs(o.top-n.top)<1||o.bottome.getSelection().bind((n=>ud(t,n.finish,n.foffset,o).fold((()=>C.some(ea(n.finish,n.foffset))),(r=>{const s=e.fromSitus(r);return(e=>id.cata(e,(e=>C.none()),(()=>C.none()),(e=>C.some(ea(e,0))),(e=>C.some(ea(e,Cr(e))))))(id.verify(e,n.finish,n.foffset,s.finish,s.foffset,o.failure,t))})))),Td=(e,t,o,n,r,s)=>0===s?C.none():Ad(e,t,o,n,r).bind((a=>{const i=e.fromSitus(a),l=id.verify(e,o,n,i.finish,i.foffset,r.failure,t);return id.cata(l,(()=>C.none()),(()=>C.some(a)),(a=>Te(o,a)&&0===n?Od(e,o,n,hd,r):Td(e,t,a,0,r,s-1)),(a=>Te(o,a)&&n===Cr(a)?Od(e,o,n,gd,r):Td(e,t,a,Cr(a),r,s-1)))})),Od=(e,t,o,n,r)=>bd(e,t,o).bind((t=>Dd(e,r,n(t,_d.getJumpSize())))),Dd=(e,t,o)=>{const n=Bo().browser;return n.isChromium()||n.isSafari()||n.isFirefox()?t.retry(e,o):C.none()},Ad=(e,t,o,n,r)=>bd(e,o,n).bind((t=>Dd(e,r,t))),Md=(e,t)=>{return vt(e,(e=>Ne(e).exists((e=>Te(e,t)))),o).isSome();var o},Nd=(e,t,o,n,r)=>Ct(n,"td,th",t).bind((n=>Ct(n,"table",t).bind((s=>Md(r,s)?((e,t,o)=>Ed(e,t,o).bind((n=>Td(e,t,n.element,n.offset,o,20).map(e.fromSitus))))(e,t,o).bind((e=>Ct(e.finish,"td,th",t).map((t=>({start:n,finish:t,range:e}))))):C.none())))),Rd=(e,t,o,n,r,s)=>s(n,t).orThunk((()=>Nd(e,t,o,n,r).map((e=>{const t=e.range;return Oc(C.some(Zc(t.start,t.soffset,t.finish,t.foffset)),!0)})))),Bd=(e,t)=>Ct(e,"tr",t).bind((e=>Ct(e,"table",t).bind((o=>{const n=pt(o,"tr");return Te(e,n[0])?((e,t,o)=>ed(od,e,t,o))(o,(e=>Er(e).isSome()),t).map((e=>{const t=Cr(e);return Oc(C.some(Zc(e,t,e,t)),!0)})):C.none()})))),Ld=(e,t)=>Ct(e,"tr",t).bind((e=>Ct(e,"table",t).bind((o=>{const n=pt(o,"tr");return Te(e,n[n.length-1])?((e,t,o)=>td(od,e,t,o))(o,(e=>_r(e).isSome()),t).map((e=>Oc(C.some(Zc(e,0,e,0)),!0))):C.none()})))),Hd=(e,t,o,n,r,s,a)=>Nd(e,o,n,r,s).bind((e=>Uc(t,o,e.start,e.finish,a))),Id=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Pd=()=>{const e=(e=>{const t=Id(C.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(C.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(C.some(e))}}})(g);return{...e,on:t=>e.get().each(t)}},Fd=(e,t)=>Ct(e,"td,th",t),zd=e=>Re(e).exists(os),Vd={traverse:He,gather:rd,relative:Tc.before,retry:_d.tryDown,failure:id.failedDown},Zd={traverse:Le,gather:nd,relative:Tc.before,retry:_d.tryUp,failure:id.failedUp},Ud=e=>t=>t===e,jd=Ud(38),Wd=Ud(40),$d=e=>e>=37&&e<=40,qd={isBackward:Ud(37),isForward:Ud(39)},Gd={isBackward:Ud(39),isForward:Ud(37)},Kd=vi([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Yd={domRange:Kd.domRange,relative:Kd.relative,exact:Kd.exact,exactFromRange:e=>Kd.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Se.fromDom(e.startContainer),relative:(e,t)=>Tc.getStart(e),exact:(e,t,o,n)=>e}))(e);return o=t,Se.fromDom(Me(o).dom.defaultView);var o},range:Fc},Xd=(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return C.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),C.some(o)}))},Jd=(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))},Qd=document.caretPositionFromPoint?Xd:document.caretRangeFromPoint?Jd:C.none,em=(e,t)=>{const o=se(e);return"input"===o?Tc.after(e):E(["br","img"],o)?0===t?Tc.before(e):Tc.after(e):Tc.on(e,t)},tm=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Ae(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Te(e,o)&&t===n;return r.collapsed&&!s},om=e=>C.from(e.getSelection()),nm=(e,t)=>{om(e).each((e=>{e.removeAllRanges(),e.addRange(t)}))},rm=(e,t,o,n,r)=>{const s=Rc(e,t,o,n,r);nm(e,s)},sm=(e,t)=>Ic(e,t).match({ltr:(t,o,n,r)=>{rm(e,t,o,n,r)},rtl:(t,o,n,r)=>{om(e).each((s=>{if(s.setBaseAndExtent)s.setBaseAndExtent(t.dom,o,n.dom,r);else if(s.extend)try{((e,t,o,n,r,s)=>{t.collapse(o.dom,n),t.extend(r.dom,s)})(0,s,t,o,n,r)}catch(s){rm(e,n,r,t,o)}else rm(e,n,r,t,o)}))}}),am=(e,t,o,n,r)=>{const s=((e,t,o,n)=>{const r=em(e,t),s=em(o,n);return Yd.relative(r,s)})(t,o,n,r);sm(e,s)},im=(e,t,o)=>{const n=((e,t)=>{const o=e.fold(Tc.before,em,Tc.after),n=t.fold(Tc.before,em,Tc.after);return Yd.relative(o,n)})(t,o);sm(e,n)},lm=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return C.some(Fc(Se.fromDom(t.startContainer),t.startOffset,Se.fromDom(o.endContainer),o.endOffset))}return C.none()},cm=e=>{if(null===e.anchorNode||null===e.focusNode)return lm(e);{const t=Se.fromDom(e.anchorNode),o=Se.fromDom(e.focusNode);return tm(t,e.anchorOffset,o,e.focusOffset)?C.some(Fc(t,e.anchorOffset,o,e.focusOffset)):lm(e)}},dm=(e,t,o=!0)=>{const n=(o?Ac:Dc)(e,t);nm(e,n)},mm=e=>(e=>om(e).filter((e=>e.rangeCount>0)).bind(cm))(e).map((e=>Yd.exact(e.start,e.soffset,e.finish,e.foffset))),um=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?C.some(o).map(Bc):C.none()})(Pc(e,t)),gm=(e,t,o)=>((e,t,o)=>{const n=Se.fromDom(e.document);return Qd(n,t,o).map((e=>Fc(Se.fromDom(e.startContainer),e.startOffset,Se.fromDom(e.endContainer),e.endOffset)))})(e,t,o),hm=e=>({elementFromPoint:(t,o)=>Se.fromPoint(Se.fromDom(e.document),t,o),getRect:e=>e.dom.getBoundingClientRect(),getRangedRect:(t,o,n,r)=>{const s=Yd.exact(t,o,n,r);return um(e,s)},getSelection:()=>mm(e).map((t=>Vc(e,t))),fromSitus:t=>{const o=Yd.relative(t.start,t.finish);return Vc(e,o)},situsFromPoint:(t,o)=>gm(e,t,o).map((e=>zc(e.start,e.soffset,e.finish,e.foffset))),clearSelection:()=>{(e=>{om(e).each((e=>e.removeAllRanges()))})(e)},collapseSelection:(t=!1)=>{mm(e).each((o=>o.fold((e=>e.collapse(t)),((o,n)=>{const r=t?o:n;im(e,r,r)}),((o,n,r,s)=>{const a=t?o:r,i=t?n:s;am(e,a,i,a,i)}))))},setSelection:t=>{am(e,t.start,t.soffset,t.finish,t.foffset)},setRelativeSelection:(t,o)=>{im(e,t,o)},selectNode:t=>{dm(e,t,!1)},selectContents:t=>{dm(e,t)},getInnerHeight:()=>e.innerHeight,getScrollY:()=>(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return bn(o,n)})(Se.fromDom(e.document)).top,scrollBy:(t,o)=>{((e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollBy(e,t)})(t,o,Se.fromDom(e.document))}}),pm=(e,t)=>({rows:e,cols:t}),fm=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Pd(),s=r.clear,a=s=>{r.on((r=>{n.clearBeforeUpdate(t),Fd(s.target,o).each((a=>{As(r,a,o).each((o=>{const r=o.boxes.getOr([]);if(1===r.length){const o=r[0],a="false"===ns(o),i=St(ts(s.target),o,Te);a&&i&&(n.selectRange(t,r,o,o),e.selectContents(o))}else r.length>1&&(n.selectRange(t,r,o.start,o.finish),e.selectContents(a))}))}))}))};return{clearstate:s,mousedown:e=>{n.clear(t),Fd(e.target,o).filter(zd).each(r.set)},mouseover:e=>{a(e)},mouseup:e=>{a(e),s()}}})(hm(e),t,o,n);return{clearstate:r.clearstate,mousedown:r.mousedown,mouseover:r.mouseover,mouseup:r.mouseup}},vm=e=>bt(e,ce).exists(os),bm=(e,t)=>vm(e)||vm(t),ym=(e,t,o,n)=>{const r=hm(e),s=()=>(n.clear(t),C.none());return{keydown:(e,a,i,l,c,d)=>{const m=e.raw,u=m.which,g=!0===m.shiftKey,h=Ms(t,n.selectedSelector).fold((()=>($d(u)&&!g&&n.clearBeforeUpdate(t),$d(u)&&g&&!bm(a,l)?C.none:Wd(u)&&g?v(Hd,r,t,o,Vd,l,a,n.selectRange):jd(u)&&g?v(Hd,r,t,o,Zd,l,a,n.selectRange):Wd(u)?v(Rd,r,o,Vd,l,a,Ld):jd(u)?v(Rd,r,o,Zd,l,a,Bd):C.none)),(e=>{const o=o=>()=>{const s=j(o,(o=>((e,t,o,n,r)=>Rs(n,e,t,r.firstSelectedSelector,r.lastSelectedSelector).map((e=>(r.clearBeforeUpdate(o),r.selectRange(o,e.boxes,e.start,e.finish),e.boxes))))(o.rows,o.cols,t,e,n)));return s.fold((()=>Ns(t,n.firstSelectedSelector,n.lastSelectedSelector).map((e=>{const o=Wd(u)||d.isForward(u)?Tc.after:Tc.before;return r.setRelativeSelection(Tc.on(e.first,0),o(e.table)),n.clear(t),Oc(C.none(),!0)}))),(e=>C.some(Oc(C.none(),!0))))};return $d(u)&&g&&!bm(a,l)?C.none:Wd(u)&&g?o([pm(1,0)]):jd(u)&&g?o([pm(-1,0)]):d.isBackward(u)&&g?o([pm(0,-1),pm(-1,0)]):d.isForward(u)&&g?o([pm(0,1),pm(1,0)]):$d(u)&&!g?s:C.none}));return h()},keyup:(e,r,s,a,i)=>Ms(t,n.selectedSelector).fold((()=>{const l=e.raw,c=l.which;return!0===l.shiftKey&&$d(c)&&bm(r,a)?((e,t,o,n,r,s,a)=>Te(o,r)&&n===s?C.none():Ct(o,"td,th",t).bind((o=>Ct(r,"td,th",t).bind((n=>Uc(e,t,o,n,a))))))(t,o,r,s,a,i,n.selectRange):C.none()}),C.none)}},wm=(e,t)=>{const o=be(e,t);return void 0===o||""===o?[]:o.split(" ")},xm=e=>void 0!==e.dom.classList,Cm=(e,t)=>((e,t,o)=>{const n=wm(e,t).concat([o]);return fe(e,t,n.join(" ")),!0})(e,"class",t),Sm=(e,t)=>{xm(e)?e.dom.classList.add(t):Cm(e,t)},km=(e,t)=>xm(e)&&e.dom.classList.contains(t),_m=(e,t,o)=>{const n=t=>{we(t,e.selected),we(t,e.firstSelected),we(t,e.lastSelected)},r=t=>{fe(t,e.selected,"1")},s=e=>{a(e),o()},a=t=>{const o=pt(t,`${e.selectedSelector},${e.firstSelectedSelector},${e.lastSelectedSelector}`);A(o,n)};return{clearBeforeUpdate:a,clear:s,selectRange:(o,n,a,i)=>{s(o),A(n,r),fe(a,e.firstSelected,"1"),fe(i,e.lastSelected,"1"),t(n,a,i)},selectedSelector:e.selectedSelector,firstSelectedSelector:e.firstSelectedSelector,lastSelectedSelector:e.lastSelectedSelector}},Em=()=>({tag:"none"}),Tm=e=>({tag:"multiple",elements:e}),Om=e=>({tag:"single",element:e}),Dm=(e,t,o)=>{const n=sn.fromTable(e);return Za(n,t).map((e=>{const t=Ha(n,o,!1),{rows:r}=Xo(t),s=((e,t)=>{const o=e.slice(0,t[t.length-1].row+1),n=Ia(o);return P(n,(e=>{const o=e.cells.slice(0,t[t.length-1].column+1);return D(o,(e=>e.element))}))})(r,e),a=((e,t)=>{const o=e.slice(t[0].row+t[0].rowspan-1,e.length),n=Ia(o);return P(n,(e=>{const o=e.cells.slice(t[0].column+t[0].colspan-1,e.cells.length);return D(o,(e=>e.element))}))})(r,e);return{upOrLeftCells:s,downOrRightCells:a}}))},Am=e=>{const t=Se.fromDom((e=>{if(st()&&d(e.target)){const t=Se.fromDom(e.target);if(de(t)&&ct(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return Z(t)}}return C.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(s=n,a=o,(...e)=>s(a.apply(null,e)));var s,a;return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Mm=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Am(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:v(Nm,e,t,s,r)}},Nm=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Rm=x,Bm=(e,t,o)=>((e,t,o,n)=>Mm(e,t,o,n,!1))(e,t,Rm,o),Lm=Am,Hm=e=>!km(Se.fromDom(e.target),"ephox-snooker-resizer-bar"),Im=(e,t)=>{const o=((e,t,o)=>({get:()=>Bs(e(),o).fold((()=>t().fold(Em,Om)),Tm)}))((()=>Se.fromDom(e.getBody())),(()=>Xs(is(e),ss(e))),qs.selectedSelector),n=_m(qs,((t,o,n)=>{Jt(o).each((r=>{const s=zr(e),a=Lr(g,Se.fromDom(e.getDoc()),s),i=Js(e),l=Dm(r,{selection:i},a);((e,t,o,n,r)=>{e.dispatch("TableSelectionChange",{cells:t,start:o,finish:n,otherCells:r})})(e,t,o,n,l)}))}),(()=>(e=>{e.dispatch("TableSelectionClear")})(e)));e.on("init",(o=>{const r=e.getWin(),s=rs(e),a=ss(e),i=fm(r,s,a,n),l=ym(r,s,a,n),c=((e,t,o,n)=>{const r=hm(e);return(e,s)=>{n.clearBeforeUpdate(t),As(e,s,o).each((e=>{const o=e.boxes.getOr([]);n.selectRange(t,o,e.start,e.finish),r.selectContents(s),r.collapseSelection()}))}})(r,s,a,n);e.on("TableSelectorChange",(e=>c(e.start,e.finish)));const d=(t,o)=>{(e=>!0===e.raw.shiftKey)(t)&&(o.kill&&t.kill(),o.selection.each((t=>{const o=Yd.relative(t.start,t.finish),n=Pc(r,o);e.selection.setRng(n)})))},m=e=>0===e.button,u=(()=>{const e=Id(Se.fromDom(s)),t=Id(0);return{touchEnd:o=>{const n=Se.fromDom(o.target);if(he("td")(n)||he("th")(n)){const r=e.get(),s=t.get();Te(r,n)&&o.timeStamp-s<300&&(o.preventDefault(),c(n,n))}e.set(n),t.set(o.timeStamp)}}})();e.on("dragstart",(e=>{i.clearstate()})),e.on("mousedown",(e=>{m(e)&&Hm(e)&&i.mousedown(Lm(e))})),e.on("mouseover",(e=>{var t;void 0!==(t=e).buttons&&0==(1&t.buttons)||!Hm(e)||i.mouseover(Lm(e))})),e.on("mouseup",(e=>{m(e)&&Hm(e)&&i.mouseup(Lm(e))})),e.on("touchend",u.touchEnd),e.on("keyup",(t=>{const o=Lm(t);if(o.raw.shiftKey&&$d(o.raw.which)){const t=e.selection.getRng(),n=Se.fromDom(t.startContainer),r=Se.fromDom(t.endContainer);l.keyup(o,n,t.startOffset,r,t.endOffset).each((e=>{d(o,e)}))}})),e.on("keydown",(o=>{const n=Lm(o);t.hide();const r=e.selection.getRng(),s=Se.fromDom(r.startContainer),a=Se.fromDom(r.endContainer),i=mn(qd,Gd)(Se.fromDom(e.selection.getStart()));l.keydown(n,s,r.startOffset,a,r.endOffset,i).each((e=>{d(n,e)})),t.show()})),e.on("NodeChange",(()=>{const t=e.selection,o=Se.fromDom(t.getStart()),r=Se.fromDom(t.getEnd());Os(Jt,[o,r]).fold((()=>n.clear(s)),g)}))})),e.on("PreInit",(()=>{e.serializer.addTempAttr(qs.firstSelected),e.serializer.addTempAttr(qs.lastSelected)}));return{getSelectedCells:()=>((e,t,o,n)=>{switch(e.tag){case"none":return t();case"single":return n(e.element);case"multiple":return o(e.elements)}})(o.get(),h([]),(e=>D(e,(e=>e.dom))),(e=>[e.dom])),clearSelectedCells:e=>n.clear(Se.fromDom(e))}},Pm=e=>{let t=[];return{bind:e=>{if(void 0===e)throw new Error("Event bind error: undefined handler");t.push(e)},unbind:e=>{t=N(t,(t=>t!==e))},trigger:(...o)=>{const n={};A(e,((e,t)=>{n[e]=o[t]})),A(t,(e=>{e(n)}))}}},Fm=e=>({registry:G(e,(e=>({bind:e.bind,unbind:e.unbind}))),trigger:G(e,(e=>e.trigger))}),zm=e=>e.slice(0).sort(),Vm=(e,t,o)=>{if(0===t.length)throw new Error("You must specify at least one required field.");return((e,t)=>{if(!a(t))throw new Error("The "+e+" fields must be an array. Was: "+t+".");A(t,(t=>{if(!r(t))throw new Error("The value "+t+" in the "+e+" fields was not a string.")}))})("required",t),(e=>{const t=zm(e);L(t,((e,o)=>o{throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+t.join(", ")+"].")}))})(t),n=>{const r=W(n);F(t,(e=>E(r,e)))||((e,t)=>{throw new Error("All required keys ("+zm(e).join(", ")+") were not specified. Specified keys were: "+zm(t).join(", ")+".")})(t,r),e(t,r);const s=N(t,(e=>!o.validate(n[e],e)));return s.length>0&&((e,t)=>{throw new Error("All values need to be of type: "+t+". Keys ("+zm(e).join(", ")+") were not.")})(s,o.label),n}},Zm=(e,t)=>{const o=N(t,(t=>!E(e,t)));o.length>0&&(e=>{throw new Error("Unsupported keys for object: "+zm(e).join(", "))})(o)},Um=e=>((e,t)=>Vm(e,t,{validate:m,label:"function"}))(Zm,e),jm=Um(["compare","extract","mutate","sink"]),Wm=Um(["element","start","stop","destroy"]),$m=Um(["forceDrop","drop","move","delayDrop"]),qm=()=>{let e=C.none();const t=Fm({move:Pm(["info"])});return{onEvent:(o,n)=>{n.extract(o).each((o=>{const r=((t,o)=>{const n=e.map((e=>t.compare(e,o)));return e=C.some(o),n})(n,o);r.each((e=>{t.trigger.move(e)}))}))},reset:()=>{e=C.none()},events:t.registry}},Gm=()=>{const e=(()=>{const e=Fm({move:Pm(["info"])});return{onEvent:g,reset:g,events:e.registry}})(),t=qm();let o=e;return{on:()=>{o.reset(),o=t},off:()=>{o.reset(),o=e},isOn:()=>o===t,onEvent:(e,t)=>{o.onEvent(e,t)},events:t.events}},Km=(e,t,o)=>{let n=!1;const r=Fm({start:Pm([]),stop:Pm([])}),s=Gm(),a=()=>{d.stop(),s.isOn()&&(s.off(),r.trigger.stop())},l=((e,t)=>{let o=null;const n=()=>{i(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}})(a,200);s.events.move.bind((o=>{t.mutate(e,o.info)}));const c=e=>(...t)=>{n&&e.apply(null,t)},d=t.sink($m({forceDrop:a,drop:c(a),move:c((e=>{l.cancel(),s.onEvent(e,t)})),delayDrop:c(l.throttle)}),o);return{element:d.element,go:e=>{d.start(e),s.on(),r.trigger.start()},on:()=>{n=!0},off:()=>{n=!1},isActive:()=>n,destroy:()=>{d.destroy()},events:r.registry}},Ym=e=>{const t=e.replace(/\./g,"-");return{resolve:e=>t+"-"+e}},Xm=Ym("ephox-dragster").resolve;var Jm=jm({compare:(e,t)=>bn(t.left-e.left,t.top-e.top),extract:e=>C.some(bn(e.x,e.y)),sink:(e,t)=>{const o=(e=>{const t={layerClass:Xm("blocker"),...e},o=Se.fromTag("div");return fe(o,"role","presentation"),Lt(o,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),Sm(o,Xm("blocker")),Sm(o,t.layerClass),{element:h(o),destroy:()=>{qe(o)}}})(t),n=Bm(o.element(),"mousedown",e.forceDrop),r=Bm(o.element(),"mouseup",e.drop),s=Bm(o.element(),"mousemove",e.move),a=Bm(o.element(),"mouseout",e.delayDrop);return Wm({element:o.element,start:e=>{Ze(e,o.element())},stop:()=>{qe(o.element())},destroy:()=>{o.destroy(),r.unbind(),s.unbind(),a.unbind(),n.unbind()}})},mutate:(e,t)=>{e.mutate(t.left,t.top)}});const Qm=Ym("ephox-snooker").resolve,eu=()=>{const e=Fm({drag:Pm(["xDelta","yDelta","target"])});let t=C.none();const o=(()=>{const e=Fm({drag:Pm(["xDelta","yDelta"])});return{mutate:(t,o)=>{e.trigger.drag(t,o)},events:e.registry}})();o.events.drag.bind((o=>{t.each((t=>{e.trigger.drag(o.xDelta,o.yDelta,t)}))}));return{assign:e=>{t=C.some(e)},get:()=>t,mutate:o.mutate,events:e.registry}},tu=Qm("resizer-bar"),ou=Qm("resizer-rows"),nu=Qm("resizer-cols"),ru=e=>{const t=pt(e.parent(),"."+tu);A(t,qe)},su=(e,t,o)=>{const n=e.origin();A(t,(t=>{t.each((t=>{const r=o(n,t);Sm(r,tu),Ze(e.parent(),r)}))}))},au=(e,t,o,n)=>{su(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=Se.fromTag("div");return Lt(s,{position:"absolute",left:t-n/2+"px",top:o+"px",height:r+"px",width:n+"px"}),ve(s,{"data-column":e,role:"presentation"}),s})(t.col,t.x-e.left,o.top-e.top,7,n);return Sm(r,nu),r}))},iu=(e,t,o,n)=>{su(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=Se.fromTag("div");return Lt(s,{position:"absolute",left:t+"px",top:o-r/2+"px",height:r+"px",width:n+"px"}),ve(s,{"data-row":e,role:"presentation"}),s})(t.row,o.left-e.left,t.y-e.top,n,7);return Sm(r,ou),r}))},lu=(e,t,o,n,r)=>{const s=wn(o),a=t.isResizable,i=n.length>0?Nn.positions(n,o):[],l=i.length>0?((e,t)=>P(e.all,((e,o)=>t(e.element)?[o]:[])))(e,a):[],c=N(i,((e,t)=>T(l,(e=>t===e))));iu(t,c,s,Vo(o));const d=r.length>0?Bn.positions(r,o):[],m=d.length>0?((e,t)=>{const o=[];return O(e.grid.columns,(n=>{const r=sn.getColumnAt(e,n).map((e=>e.element));r.forall(t)&&o.push(n)})),N(o,(o=>{const n=sn.filterItems(e,(e=>e.column===o));return F(n,(e=>t(e.element)))}))})(e,a):[],u=N(d,((e,t)=>T(m,(e=>t===e))));au(t,u,s,pn(o))},cu=(e,t)=>{if(ru(e),e.isResizable(t)){const o=sn.fromTable(t),n=cn(o),r=an(o);lu(o,e,t,n,r)}},du=(e,t)=>{const o=pt(e.parent(),"."+tu);A(o,t)},mu=e=>{du(e,(e=>{Bt(e,"display","none")}))},uu=e=>{du(e,(e=>{Bt(e,"display","block")}))},gu=Qm("resizer-bar-dragging"),hu=e=>{const t=eu(),o=((e,t={})=>{var o;const n=null!==(o=t.mode)&&void 0!==o?o:Jm;return Km(e,n,t)})(t,{});let n=C.none();const r=(e,t)=>C.from(be(e,t));t.events.drag.bind((e=>{r(e.target,"data-row").each((t=>{const o=jt(e.target,"top");Bt(e.target,"top",o+e.yDelta+"px")})),r(e.target,"data-column").each((t=>{const o=jt(e.target,"left");Bt(e.target,"left",o+e.xDelta+"px")}))}));const s=(e,t)=>jt(e,t)-zt(e,"data-initial-"+t,0);o.events.stop.bind((()=>{t.get().each((t=>{n.each((o=>{r(t,"data-row").each((e=>{const n=s(t,"top");we(t,"data-initial-top"),d.trigger.adjustHeight(o,n,parseInt(e,10))})),r(t,"data-column").each((e=>{const n=s(t,"left");we(t,"data-initial-left"),d.trigger.adjustWidth(o,n,parseInt(e,10))})),cu(e,o)}))}))}));const a=(n,r)=>{d.trigger.startAdjust(),t.assign(n),fe(n,"data-initial-"+r,jt(n,r)),Sm(n,gu),Bt(n,"opacity","0.2"),o.go(e.parent())},i=Bm(e.parent(),"mousedown",(e=>{var t;t=e.target,km(t,ou)&&a(e.target,"top"),(e=>km(e,nu))(e.target)&&a(e.target,"left")})),l=t=>Te(t,e.view()),c=Bm(e.view(),"mouseover",(t=>{var r;(r=t.target,Ct(r,"table",l).filter(os)).fold((()=>{dt(t.target)&&ru(e)}),(t=>{o.isActive()&&(n=C.some(t),cu(e,t))}))})),d=Fm({adjustHeight:Pm(["table","delta","row"]),adjustWidth:Pm(["table","delta","column"]),startAdjust:Pm([])});return{destroy:()=>{i.unbind(),c.unbind(),o.destroy(),ru(e)},refresh:t=>{cu(e,t)},on:o.on,off:o.off,hideBars:v(mu,e),showBars:v(uu,e),events:d.registry}},pu=(e,t,o)=>{const n=Nn,r=Bn,s=hu(e),a=Fm({beforeResize:Pm(["table","type"]),afterResize:Pm(["table","type"]),startDrag:Pm([])});return s.events.adjustHeight.bind((e=>{const t=e.table;a.trigger.beforeResize(t,"row");const o=n.delta(e.delta,t);_i(t,o,e.row,n),a.trigger.afterResize(t,"row")})),s.events.startAdjust.bind((e=>{a.trigger.startDrag()})),s.events.adjustWidth.bind((e=>{const n=e.table;a.trigger.beforeResize(n,"col");const s=r.delta(e.delta,n),i=o(n);ki(n,s,e.column,t,i),a.trigger.afterResize(n,"col")})),{on:s.on,off:s.off,refreshBars:s.refresh,hideBars:s.hideBars,showBars:s.showBars,destroy:s.destroy,events:a.registry}},fu=(e,t)=>{const o=ue(e)?(e=>Se.fromDom(Me(e).dom.documentElement))(e):e;return{parent:h(o),view:h(e),origin:h(bn(0,0)),isResizable:t}},vu=(e,t,o)=>({parent:h(t),view:h(e),origin:h(bn(0,0)),isResizable:o}),bu=()=>{const e=Se.fromTag("div");return Lt(e,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),Ze(mt(Se.fromDom(document)),e),e},yu=e=>d(e)&&"TABLE"===e.nodeName,wu="bar-",xu=e=>"false"!==be(e,"data-mce-resize"),Cu=e=>{const t=Pd(),o=Pd(),n=Pd();let r,s;const a=t=>Hl(e,t),i=()=>Ur(e)?ga():ua(),l=(t,o,n)=>{const l=Dt(o,"e");if(""===s&&nc(t),n!==r&&""!==s){Bt(t,"width",s);const o=i(),c=a(t),d=Ur(e)||l?(e=>ha(e).columns)(t)-1:0;ki(t,n-r,d,o,c)}else if((e=>/^(\d+(\.\d+)?)%$/.test(e))(s)){const e=parseFloat(s.replace("%",""));Bt(t,"width",n*e/r+"%")}(e=>/^(\d+(\.\d+)?)px$/.test(e))(s)&&(e=>{const t=sn.fromTable(e);sn.hasColumns(t)||A(Yt(e),(e=>{const t=Ht(e,"width");Bt(e,"width",t),we(e,"width")}))})(t)},c=()=>{o.on((e=>{e.destroy()})),n.on((t=>{((e,t)=>{e.inline&&qe(t.parent())})(e,t)}))};e.on("init",(()=>{const r=((e,t)=>e.inline?vu(Se.fromDom(e.getBody()),bu(),t):fu(Se.fromDom(e.getDoc()),t))(e,xu);if(n.set(r),(e=>{const t=e.options.get("object_resizing");return E(t.split(","),"table")})(e)&&Kr(e)){const n=i(),s=pu(r,n,a);s.on(),s.events.startDrag.bind((o=>{t.set(e.selection.getRng())})),s.events.beforeResize.bind((t=>{const o=t.table.dom;((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(e,o,ls(o),cs(o),wu+t.type)})),s.events.afterResize.bind((o=>{const n=o.table,r=n.dom;as(n),t.on((t=>{e.selection.setRng(t),e.focus()})),((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(e,r,ls(r),cs(r),wu+o.type),e.undoManager.add()})),o.set(s)}})),e.on("ObjectResizeStart",(t=>{const o=t.target;if(yu(o)){const n=Se.fromDom(o);A(e.dom.select(".mce-clonedresizable"),(t=>{e.dom.addClass(t,"mce-"+Zr(e)+"-columns")})),!ec(n)&&qr(e)?rc(n):!Ql(n)&&$r(e)&&nc(n),tc(n)&&Ot(t.origin,wu)&&nc(n),r=t.width,s=Gr(e)?"":((e,t)=>{const o=e.dom.getStyle(t,"width")||e.dom.getAttrib(t,"width");return C.from(o).filter(Mt)})(e,o).getOr("")}})),e.on("ObjectResized",(t=>{const o=t.target;if(yu(o)){const n=Se.fromDom(o),r=t.origin;Ot(r,"corner-")&&l(n,r,t.width),as(n),Nl(e,n.dom,Rl)}})),e.on("SwitchMode",(()=>{o.on((t=>{e.mode.isReadOnly()?t.hideBars():t.showBars()}))})),e.on("dragstart dragend",(e=>{o.on((t=>{"dragstart"===e.type?(t.hideBars(),t.off()):(t.on(),t.showBars())}))})),e.on("remove",(()=>{c()}));return{refresh:e=>{o.on((t=>t.refreshBars(Se.fromDom(e))))},hide:()=>{o.on((e=>e.hideBars()))},show:()=>{o.on((e=>e.showBars()))}}},Su=e=>{(e=>{const t=e.options.register;t("table_clone_elements",{processor:"string[]"}),t("table_use_colgroups",{processor:"boolean",default:!0}),t("table_header_type",{processor:e=>{const t=E(["section","cells","sectionCells","auto"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: section, cells, sectionCells or auto."}},default:"section"}),t("table_sizing_mode",{processor:"string",default:"auto"}),t("table_default_attributes",{processor:"object",default:{border:"1"}}),t("table_default_styles",{processor:"object",default:{"border-collapse":"collapse"}}),t("table_column_resizing",{processor:e=>{const t=E(["preservetable","resizetable"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be preservetable, or resizetable."}},default:"preservetable"}),t("table_resize_bars",{processor:"boolean",default:!0}),t("table_style_by_css",{processor:"boolean",default:!0}),t("table_merge_content_on_paste",{processor:"boolean",default:!0})})(e);const t=Cu(e),o=Im(e,t),n=Il(e,t,o);return _c(e,n),((e,t)=>{const o=ss(e),n=t=>Xs(is(e)).bind((n=>Jt(n,o).map((o=>{const r=Gs(Js(e),o,n);return t(o,r)})))).getOr("");q({mceTableRowType:()=>n(t.getTableRowType),mceTableCellType:()=>n(t.getTableCellType),mceTableColType:()=>n(t.getTableColType)},((t,o)=>e.addQueryValueHandler(o,t)))})(e,n),Qs(e,n),{getSelectedCells:o.getSelectedCells,clearSelectedCells:o.clearSelectedCells}},ku=e=>({table:Su(e)});e.add("dom",ku)}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),o=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=(r="allow_html_in_named_anchor",e=>e.options.get(r));var r;const s="a:not([href])",a=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),c=e=>{const n=e.dom;t(n).walk(e.selection.getRng(),(e=>{o.each(e,(e=>{var t;l(t=e)&&!t.firstChild&&n.remove(e,!1)}))}))},d=e=>e.dom.getParent(e.selection.getStart(),s),m=(e,t)=>{const o=d(e);o?((e,t,o)=>{o.removeAttribute("name"),o.id=t,e.addVisual(),e.undoManager.add()})(e,t,o):((e,t)=>{e.undoManager.transact((()=>{n(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:t})):(c(e),e.formatter.remove("namedAnchor",void 0,void 0,!0),e.formatter.apply("namedAnchor",{value:t}),e.addVisual())}))})(e,t),e.focus()},u=e=>{const t=(e=>{const t=d(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)?(m(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1))(e,t.getData().id)&&t.close()}})},g=e=>(e=>a(e.attr("href"))&&!a(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,h=e=>t=>{for(let o=0;ot=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("anchor",(e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("a",h("false")),e.serializer.addNodeFilter("a",h(null))}))})(e),(e=>{e.addCommand("mceAnchor",(()=>{u(e)}))})(e),(e=>{const t=()=>e.execCommand("mceAnchor");e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:t,onSetup:t=>{const o=e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind,n=p(e)(t);return()=>{o(),n()}}}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:t,onSetup:p(e)})})(e),e.on("PreInit",(()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:s,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,o)=>l(e)})})(e)}))}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(e,t)=>{const o=((e,t)=>e.dispatch("insertCustomChar",{chr:t}))(e,t).chr;e.execCommand("mceInsertContent",!1,o)},o=e=>t=>e===t,n=(r="array",e=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(s=n.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var o,n,r,s})(e)===r);var r;const s=o(null),a=o(void 0),i=(e=>t=>typeof t===e)("function"),l=(c=!1,()=>c);var c;class d{constructor(e,t){this.tag=e,this.value=t}static some(e){return new d(!0,e)}static none(){return d.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?d.some(e(this.value)):d.none()}bind(e){return this.tag?e(this.value):d.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:d.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return(e=>null==e)(e)?d.none():d.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}d.singletonNone=new d(!1);const m=Array.prototype.push,u=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r((e,t,o)=>{for(let n=0,r=e.length;n(e=>{const t=[];for(let o=0,r=e.length;ot=>t.options.get(e),v=f("charmap"),b=f("charmap_append"),y=p.isArray,w="User Defined",x=e=>{return y(e)?(t=e,p.grep(t,(e=>y(e)&&2===e.length))):"function"==typeof e?e():[];var t},C=e=>{const t=((e,t)=>{const o=v(e);o&&(t=[{name:w,characters:x(o)}]);const n=b(e);if(n){const e=p.grep(t,(e=>e.name===w));return e.length?(e[0].characters=[...e[0].characters,...x(n)],t):t.concat({name:w,characters:x(n)})}return t})(e,[{name:"Currency",characters:[[36,"dollar sign"],[162,"cent sign"],[8364,"euro sign"],[163,"pound sign"],[165,"yen sign"],[164,"currency sign"],[8352,"euro-currency sign"],[8353,"colon sign"],[8354,"cruzeiro sign"],[8355,"french franc sign"],[8356,"lira sign"],[8357,"mill sign"],[8358,"naira sign"],[8359,"peseta sign"],[8360,"rupee sign"],[8361,"won sign"],[8362,"new sheqel sign"],[8363,"dong sign"],[8365,"kip sign"],[8366,"tugrik sign"],[8367,"drachma sign"],[8368,"german penny symbol"],[8369,"peso sign"],[8370,"guarani sign"],[8371,"austral sign"],[8372,"hryvnia sign"],[8373,"cedi sign"],[8374,"livre tournois sign"],[8375,"spesmilo sign"],[8376,"tenge sign"],[8377,"indian rupee sign"],[8378,"turkish lira sign"],[8379,"nordic mark sign"],[8380,"manat sign"],[8381,"ruble sign"],[20870,"yen character"],[20803,"yuan character"],[22291,"yuan character, in hong kong and taiwan"],[22278,"yen/yuan character variant one"]]},{name:"Text",characters:[[169,"copyright sign"],[174,"registered sign"],[8482,"trade mark sign"],[8240,"per mille sign"],[181,"micro sign"],[183,"middle dot"],[8226,"bullet"],[8230,"three dot leader"],[8242,"minutes / feet"],[8243,"seconds / inches"],[167,"section sign"],[182,"paragraph sign"],[223,"sharp s / ess-zed"]]},{name:"Quotations",characters:[[8249,"single left-pointing angle quotation mark"],[8250,"single right-pointing angle quotation mark"],[171,"left pointing guillemet"],[187,"right pointing guillemet"],[8216,"left single quotation mark"],[8217,"right single quotation mark"],[8220,"left double quotation mark"],[8221,"right double quotation mark"],[8218,"single low-9 quotation mark"],[8222,"double low-9 quotation mark"],[60,"less-than sign"],[62,"greater-than sign"],[8804,"less-than or equal to"],[8805,"greater-than or equal to"],[8211,"en dash"],[8212,"em dash"],[175,"macron"],[8254,"overline"],[164,"currency sign"],[166,"broken bar"],[168,"diaeresis"],[161,"inverted exclamation mark"],[191,"turned question mark"],[710,"circumflex accent"],[732,"small tilde"],[176,"degree sign"],[8722,"minus sign"],[177,"plus-minus sign"],[247,"division sign"],[8260,"fraction slash"],[215,"multiplication sign"],[185,"superscript one"],[178,"superscript two"],[179,"superscript three"],[188,"fraction one quarter"],[189,"fraction one half"],[190,"fraction three quarters"]]},{name:"Mathematical",characters:[[402,"function / florin"],[8747,"integral"],[8721,"n-ary sumation"],[8734,"infinity"],[8730,"square root"],[8764,"similar to"],[8773,"approximately equal to"],[8776,"almost equal to"],[8800,"not equal to"],[8801,"identical to"],[8712,"element of"],[8713,"not an element of"],[8715,"contains as member"],[8719,"n-ary product"],[8743,"logical and"],[8744,"logical or"],[172,"not sign"],[8745,"intersection"],[8746,"union"],[8706,"partial differential"],[8704,"for all"],[8707,"there exists"],[8709,"diameter"],[8711,"backward difference"],[8727,"asterisk operator"],[8733,"proportional to"],[8736,"angle"]]},{name:"Extended Latin",characters:[[192,"A - grave"],[193,"A - acute"],[194,"A - circumflex"],[195,"A - tilde"],[196,"A - diaeresis"],[197,"A - ring above"],[256,"A - macron"],[198,"ligature AE"],[199,"C - cedilla"],[200,"E - grave"],[201,"E - acute"],[202,"E - circumflex"],[203,"E - diaeresis"],[274,"E - macron"],[204,"I - grave"],[205,"I - acute"],[206,"I - circumflex"],[207,"I - diaeresis"],[298,"I - macron"],[208,"ETH"],[209,"N - tilde"],[210,"O - grave"],[211,"O - acute"],[212,"O - circumflex"],[213,"O - tilde"],[214,"O - diaeresis"],[216,"O - slash"],[332,"O - macron"],[338,"ligature OE"],[352,"S - caron"],[217,"U - grave"],[218,"U - acute"],[219,"U - circumflex"],[220,"U - diaeresis"],[362,"U - macron"],[221,"Y - acute"],[376,"Y - diaeresis"],[562,"Y - macron"],[222,"THORN"],[224,"a - grave"],[225,"a - acute"],[226,"a - circumflex"],[227,"a - tilde"],[228,"a - diaeresis"],[229,"a - ring above"],[257,"a - macron"],[230,"ligature ae"],[231,"c - cedilla"],[232,"e - grave"],[233,"e - acute"],[234,"e - circumflex"],[235,"e - diaeresis"],[275,"e - macron"],[236,"i - grave"],[237,"i - acute"],[238,"i - circumflex"],[239,"i - diaeresis"],[299,"i - macron"],[240,"eth"],[241,"n - tilde"],[242,"o - grave"],[243,"o - acute"],[244,"o - circumflex"],[245,"o - tilde"],[246,"o - diaeresis"],[248,"o slash"],[333,"o macron"],[339,"ligature oe"],[353,"s - caron"],[249,"u - grave"],[250,"u - acute"],[251,"u - circumflex"],[252,"u - diaeresis"],[363,"u - macron"],[253,"y - acute"],[254,"thorn"],[255,"y - diaeresis"],[563,"y - macron"],[913,"Alpha"],[914,"Beta"],[915,"Gamma"],[916,"Delta"],[917,"Epsilon"],[918,"Zeta"],[919,"Eta"],[920,"Theta"],[921,"Iota"],[922,"Kappa"],[923,"Lambda"],[924,"Mu"],[925,"Nu"],[926,"Xi"],[927,"Omicron"],[928,"Pi"],[929,"Rho"],[931,"Sigma"],[932,"Tau"],[933,"Upsilon"],[934,"Phi"],[935,"Chi"],[936,"Psi"],[937,"Omega"],[945,"alpha"],[946,"beta"],[947,"gamma"],[948,"delta"],[949,"epsilon"],[950,"zeta"],[951,"eta"],[952,"theta"],[953,"iota"],[954,"kappa"],[955,"lambda"],[956,"mu"],[957,"nu"],[958,"xi"],[959,"omicron"],[960,"pi"],[961,"rho"],[962,"final sigma"],[963,"sigma"],[964,"tau"],[965,"upsilon"],[966,"phi"],[967,"chi"],[968,"psi"],[969,"omega"]]},{name:"Symbols",characters:[[8501,"alef symbol"],[982,"pi symbol"],[8476,"real part symbol"],[978,"upsilon - hook symbol"],[8472,"Weierstrass p"],[8465,"imaginary part"]]},{name:"Arrows",characters:[[8592,"leftwards arrow"],[8593,"upwards arrow"],[8594,"rightwards arrow"],[8595,"downwards arrow"],[8596,"left right arrow"],[8629,"carriage return"],[8656,"leftwards double arrow"],[8657,"upwards double arrow"],[8658,"rightwards double arrow"],[8659,"downwards double arrow"],[8660,"left right double arrow"],[8756,"therefore"],[8834,"subset of"],[8835,"superset of"],[8836,"not a subset of"],[8838,"subset of or equal to"],[8839,"superset of or equal to"],[8853,"circled plus"],[8855,"circled times"],[8869,"perpendicular"],[8901,"dot operator"],[8968,"left ceiling"],[8969,"right ceiling"],[8970,"left floor"],[8971,"right floor"],[9001,"left-pointing angle bracket"],[9002,"right-pointing angle bracket"],[9674,"lozenge"],[9824,"black spade suit"],[9827,"black club suit"],[9829,"black heart suit"],[9830,"black diamond suit"],[8194,"en space"],[8195,"em space"],[8201,"thin space"],[8204,"zero width non-joiner"],[8205,"zero width joiner"],[8206,"left-to-right mark"],[8207,"right-to-left mark"]]}]);return t.length>1?[{name:"All",characters:h(t,(e=>e.characters))}].concat(t):t},S=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},k=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!a(n)||r+t.length<=n)},_=String.fromCodePoint,E=(e,t)=>{const o=[],n=t.toLowerCase();return((e,t)=>{for(let o=0,n=e.length;o{((e,t,o)=>!!k(_(e).toLowerCase(),o)||k(t.toLowerCase(),o)||k(t.toLowerCase().replace(/\s+/g,""),o))(e[0],e[1],n)&&o.push(e)})),u(o,(e=>({text:e[1],value:_(e[0]),icon:_(e[0])})))},T="pattern",O=(e,o)=>{const n=()=>[{label:"Search",type:"input",name:T},{type:"collection",name:"results"}],r=1===o.length?S(w):S("All"),a=((e,t)=>{let o=null;const n=()=>{s(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}})((e=>{const t=e.getData().pattern;((e,t)=>{g(o,(e=>e.name===r.get())).each((o=>{const n=E(o,t);e.setData({results:n})}))})(e,t)}),40),i={title:"Special Character",size:"normal",body:1===o.length?{type:"panel",items:n()}:{type:"tabpanel",tabs:u(o,(e=>({title:e.name,name:e.name,items:n()})))},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{pattern:"",results:E(o[0],"")},onAction:(o,n)=>{"results"===n.name&&(t(e,n.value),o.close())},onTabChange:(e,t)=>{r.set(t.newTabName),a.throttle(e)},onChange:(e,t)=>{t.name===T&&a.throttle(e)}};e.windowManager.open(i).focus(T)},D=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("charmap",(e=>{(e=>{const t=e.options.register,o=e=>i(e)||n(e);t("charmap",{processor:o}),t("charmap_append",{processor:o})})(e);const o=C(e);return((e,t)=>{e.addCommand("mceShowCharmap",(()=>{O(e,t)}))})(e,o),(e=>{const t=()=>e.execCommand("mceShowCharmap");e.ui.registry.addButton("charmap",{icon:"insert-character",tooltip:"Special character",onAction:t,onSetup:D(e)}),e.ui.registry.addMenuItem("charmap",{icon:"insert-character",text:"Special character...",onAction:t,onSetup:D(e)})})(e),((e,t)=>{e.ui.registry.addAutocompleter("charmap",{trigger:":",columns:"auto",minChars:2,fetch:(e,o)=>new Promise(((o,n)=>{o(E(t,e))})),onAction:(t,o,n)=>{e.selection.setRng(o),e.insertContent(n),t.hide()}})})(e,o[0]),(e=>({getCharMap:()=>C(e),insertChar:o=>{t(e,o)}}))(e)}))}(),tinymce.util.Tools.resolve("tinymce.PluginManager").add("code",(e=>((e=>{e.addCommand("mceCodeEditor",(()=>{(e=>{const t=(e=>e.getContent({source_view:!0}))(e);e.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:t},onSubmit:t=>{((e,t)=>{e.focus(),e.undoManager.transact((()=>{e.setContent(t)})),e.selection.setCursorLocation(),e.nodeChanged()})(e,t.getData().code),t.close()}})})(e)}))})(e),(e=>{const t=()=>e.execCommand("mceCodeEditor");e.ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:t}),e.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:t})})(e),{}))),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>typeof t===e,o=(e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e)("string"),n=t("boolean"),r=e=>!(e=>null==e)(e),s=t("function"),a=t("number"),i=(l=!1,()=>l);var l;class c{constructor(e,t){this.tag=e,this.value=t}static some(e){return new c(!0,e)}static none(){return c.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?c.some(e(this.value)):c.none()}bind(e){return this.tag?e(this.value):c.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:c.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return r(e)?c.some(e):c.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}c.singletonNone=new c(!1);const d=(e,t)=>{for(let o=0,n=e.length;o{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},u={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return m(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return m(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return m(o)},fromDom:m,fromPoint:(e,t,o)=>c.from(e.dom.elementFromPoint(t,o)).map(m)},g=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}};"undefined"!=typeof window?window:Function("return this;")();const h=e=>t=>(e=>e.dom.nodeType)(t)===e,p=h(1),f=h(3),v=h(9),b=h(11),y=e=>((e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{((e,t,r)=>{if(!(o(r)||n(r)||a(r)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",r,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,r+"")})(e.dom,t,r)},x=(e,t)=>{e.dom.removeAttribute(t)},C=s(Element.prototype.attachShadow)&&s(Node.prototype.getRootNode)?e=>u.fromDom(e.dom.getRootNode()):e=>{return v(e)?e:(t=e,u.fromDom(t.dom.ownerDocument));var t},S=e=>{const t=C(e);return b(o=t)&&r(o.dom.host)?c.some(t):c.none();var o},k=e=>u.fromDom(e.dom.host),_=e=>{const t=f(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return S(u.fromDom(t)).fold((()=>o.body.contains(t)),(n=_,r=k,e=>n(r(e))));var n,r},E=(e,t,o)=>((e,t,o)=>{let n=e.dom;const r=s(o)?o:i;for(;n.parentNode;){n=n.parentNode;const e=u.fromDom(n);if(t(e))return c.some(e);if(r(e))break}return c.none()})(e,(e=>g(e,t)),o),T=(e,t)=>(e=>void 0!==e.style&&s(e.style.getPropertyValue))(e)?e.style.getPropertyValue(t):"",O=e=>"rtl"===((e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||_(e)?n:T(o,t)})(e,"direction")?"rtl":"ltr",D=(e,t)=>((e,t)=>((e,t)=>{const o=[];for(let n=0,r=e.length;ng(e,t))),A=e=>(e=>c.from(e.dom.parentNode).map(u.fromDom))(e).filter(p),M=(N="li",e=>p(e)&&e.dom.nodeName.toLowerCase()===N);var N;const R=(e,t,o)=>{d(t,(t=>{const n=u.fromDom(t),r=M(n),s=((e,t)=>(t?E(e,"ol,ul"):c.some(e)).getOr(e))(n,r);A(s).each((t=>{e.setStyle(s.dom,"direction",null);if(O(t)===o?x(s,"dir"):w(s,"dir",o),O(s)!==o&&e.setStyle(s.dom,"direction",o),r){const t=D(s,"li[dir],li[style]");d(t,(t=>{x(t,"dir"),e.setStyle(t.dom,"direction",null)}))}}))}))},B=(e,t)=>{e.selection.isEditable()&&(R(e.dom,e.selection.getSelectedBlocks(),t),e.nodeChanged())},L=(e,t)=>o=>{const n=n=>{const r=u.fromDom(n.element);o.setActive(O(r)===t),o.setEnabled(e.selection.isEditable())};return e.on("NodeChange",n),o.setEnabled(e.selection.isEditable()),()=>e.off("NodeChange",n)};e.add("directionality",(e=>{(e=>{e.addCommand("mceDirectionLTR",(()=>{B(e,"ltr")})),e.addCommand("mceDirectionRTL",(()=>{B(e,"rtl")}))})(e),(e=>{e.ui.registry.addToggleButton("ltr",{tooltip:"Left to right",icon:"ltr",onAction:()=>e.execCommand("mceDirectionLTR"),onSetup:L(e,"ltr")}),e.ui.registry.addToggleButton("rtl",{tooltip:"Right to left",icon:"rtl",onAction:()=>e.execCommand("mceDirectionRTL"),onSetup:L(e,"rtl")})})(e)}))}(),function(){const e=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}};var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const o=e=>({isFullscreen:()=>null!==e.get()}),n=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,r=e=>t=>typeof t===e,s=e=>t=>e===t,a=n("string"),i=n("object"),l=n("array"),c=s(null),d=r("boolean"),m=s(void 0),u=e=>!(e=>null==e)(e),g=r("function"),h=r("number"),p=()=>{},f=e=>()=>e;function v(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const b=f(!1),y=f(!0);class w{constructor(e,t){this.tag=e,this.value=t}static some(e){return new w(!0,e)}static none(){return w.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?w.some(e(this.value)):w.none()}bind(e){return this.tag?e(this.value):w.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:w.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return u(e)?w.some(e):w.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}w.singletonNone=new w(!1);const x=Array.prototype.push,C=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n((e,t,o)=>{for(let n=0,r=e.length;n(e=>{const t=[];for(let o=0,n=e.length;o((e,t)=>t>=0&&t{const o=e(w.none()),n=()=>o.get().each(t);return{clear:()=>{n(),o.set(w.none())},isSet:()=>o.get().isSome(),get:()=>o.get(),set:e=>{n(),o.set(w.some(e))}}},D=()=>O((e=>e.unbind())),A=Object.keys,M="undefined"!=typeof window?window:Function("return this;")(),N=(e,t)=>((e,t)=>{let o=null!=t?t:M;for(let t=0;t{const o=((e,t)=>N(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},B=Object.getPrototypeOf,L=e=>{const t=N("ownerDocument.defaultView",e);return i(e)&&((e=>R("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(B(e).constructor.name))},H=e=>t=>(e=>e.dom.nodeType)(t)===e,I=H(1),P=H(3),F=H(9),z=H(11),V=(e,t,o)=>{((e,t,o)=>{if(!(a(o)||d(o)||h(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(e.dom,t,o)},Z=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},U=(e,t)=>{e.dom.removeAttribute(t)},j=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!m(n)||r+t.length<=n)},W=e=>void 0!==e.style&&g(e.style.getPropertyValue),$=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},q={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return $(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return $(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return $(o)},fromDom:$,fromPoint:(e,t,o)=>w.from(e.dom.elementFromPoint(t,o)).map($)},G=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},K=e=>q.fromDom(e.dom.ownerDocument),Y=e=>(e=>w.from(e.dom.parentNode).map(q.fromDom))(e).map(X).map((t=>k(t,(t=>{return o=t,!(e.dom===o.dom);var o})))).getOr([]),X=e=>C(e.dom.childNodes,q.fromDom),J=g(Element.prototype.attachShadow)&&g(Node.prototype.getRootNode),Q=f(J),ee=J?e=>q.fromDom(e.dom.getRootNode()):e=>F(e)?e:K(e),te=e=>{const t=ee(e);return z(o=t)&&u(o.dom.host)?w.some(t):w.none();var o},oe=e=>q.fromDom(e.dom.host),ne=e=>u(e.dom.shadowRoot),re=e=>{const t=P(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return te(q.fromDom(t)).fold((()=>o.body.contains(t)),(n=re,r=oe,e=>n(r(e))));var n,r},se=(e,t,o)=>{if(!a(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);W(e)&&e.style.setProperty(t,o)},ae=(e,t,o)=>{const n=e.dom;se(n,t,o)},ie=(e,t)=>{const o=e.dom;((e,t)=>{const o=A(e);for(let n=0,r=o.length;n{se(o,t,e)}))},le=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||re(e)?n:ce(o,t)},ce=(e,t)=>W(e)?e.style.getPropertyValue(t):"",de=e=>{const t=q.fromDom((e=>{if(Q()&&u(e.target)){const t=q.fromDom(e.target);if(I(t)&&ne(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return T(t)}}return w.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(s=n,a=o,(...e)=>s(a.apply(null,e)));var s,a;return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},me=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(de(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:v(ue,e,t,s,r)}},ue=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},ge=y,he=(e,t,o)=>((e,t,o,n)=>me(e,t,o,n,!1))(e,t,ge,o),pe=()=>fe(0,0),fe=(e,t)=>({major:e,minor:t}),ve={nu:fe,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?pe():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return fe(n(1),n(2))})(e,o)},unknown:pe},be=(e,t)=>((e,t)=>{for(let o=0;o{const o=t.brand.toLowerCase();return _(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:ve.nu(parseInt(t.version,10),0)})))})),ye=(e,t)=>{const o=String(t).toLowerCase();return _(e,(e=>e.search(o)))},we=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,xe=e=>t=>j(t,e),Ce=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>j(e,"edge/")&&j(e,"chrome")&&j(e,"safari")&&j(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,we],search:e=>j(e,"chrome")&&!j(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>j(e,"msie")||j(e,"trident")},{name:"Opera",versionRegexes:[we,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:xe("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:xe("firefox")},{name:"Safari",versionRegexes:[we,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(j(e,"safari")||j(e,"mobile/"))&&j(e,"applewebkit")}],Se=[{name:"Windows",search:xe("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>j(e,"iphone")||j(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:xe("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:xe("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:xe("linux"),versionRegexes:[]},{name:"Solaris",search:xe("sunos"),versionRegexes:[]},{name:"FreeBSD",search:xe("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:xe("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],ke={browsers:f(Ce),oses:f(Se)},_e="Edge",Ee="Chromium",Te="Opera",Oe="Firefox",De="Safari",Ae=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(_e),isChromium:n(Ee),isIE:n("IE"),isOpera:n(Te),isFirefox:n(Oe),isSafari:n(De)}},Me={unknown:()=>Ae({current:void 0,version:ve.unknown()}),nu:Ae,edge:f(_e),chromium:f(Ee),ie:f("IE"),opera:f(Te),firefox:f(Oe),safari:f(De)},Ne="Windows",Re="Android",Be="Linux",Le="macOS",He="Solaris",Ie="FreeBSD",Pe="ChromeOS",Fe=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(Ne),isiOS:n("iOS"),isAndroid:n(Re),isMacOS:n(Le),isLinux:n(Be),isSolaris:n(He),isFreeBSD:n(Ie),isChromeOS:n(Pe)}},ze={unknown:()=>Fe({current:void 0,version:ve.unknown()}),nu:Fe,windows:f(Ne),ios:f("iOS"),android:f(Re),linux:f(Be),macos:f(Le),solaris:f(He),freebsd:f(Ie),chromeos:f(Pe)},Ve=(e,t,o)=>{const n=ke.browsers(),r=ke.oses(),s=t.bind((e=>be(n,e))).orThunk((()=>((e,t)=>ye(e,t).map((e=>{const o=ve.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(Me.unknown,Me.nu),a=((e,t)=>ye(e,t).map((e=>{const o=ve.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(ze.unknown,ze.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:f(r),isiPhone:f(s),isTablet:f(l),isPhone:f(c),isTouch:f(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:f(d),isDesktop:f(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},Ze=e=>window.matchMedia(e).matches;let Ue=(e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)})((()=>Ve(navigator.userAgent,w.from(navigator.userAgentData),Ze)));const je=(e,t)=>({left:e,top:t,translate:(o,n)=>je(e+o,t+n)}),We=je,$e=e=>{const t=void 0===e?window:e;return Ue().browser.isFirefox()?w.none():w.from(t.visualViewport)},qe=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Ge=e=>{const t=void 0===e?window:e,o=t.document,n=(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return We(o,n)})(q.fromDom(o));return $e(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return qe(n.left,n.top,o,r)}),(e=>qe(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Ke=(e,t,o)=>$e(o).map((o=>{const n=e=>t(de(e));return o.addEventListener(e,n),{unbind:()=>o.removeEventListener(e,n)}})).getOrThunk((()=>({unbind:p})));var Ye=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),Xe=tinymce.util.Tools.resolve("tinymce.Env");const Je=(e,t)=>{e.dispatch("FullscreenStateChanged",{state:t}),e.dispatch("ResizeEditor")},Qe=(et="fullscreen_native",e=>e.options.get(et));var et;const tt=e=>{const t=q.fromDom(e.getElement());return te(t).map(oe).getOrThunk((()=>(e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return q.fromDom(t)})(K(t))))},ot=e=>{return e.dom===(void 0!==(t=K(e).dom).fullscreenElement?t.fullscreenElement:void 0!==t.msFullscreenElement?t.msFullscreenElement:void 0!==t.webkitFullscreenElement?t.webkitFullscreenElement:null);var t},nt=(e,t,o)=>k(((e,t)=>{const o=g(t)?t:b;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=q.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r})(e,o),t),rt=e=>((e,t)=>{const o=void 0===t?document:t.dom;return 1!==(n=o).nodeType&&9!==n.nodeType&&11!==n.nodeType||0===n.childElementCount?[]:C(o.querySelectorAll(e),q.fromDom);var n})(e),st=(e,t,o)=>nt(e,(e=>G(e,t)),o),at=(e,t)=>((e,t)=>k(Y(e),t))(e,(e=>G(e,t))),it="data-ephox-mobile-fullscreen-style",lt="position:absolute!important;",ct="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",dt=Xe.os.isAndroid(),mt=(e,t,o)=>{const n=t=>o=>{const n=Z(o,"style"),r=void 0===n?"no-styles":n.trim();r!==t&&(V(o,it,r),ie(o,e.parseStyle(t)))},r=st(t,"*"),s=E(r,(e=>at(e,"*:not(.tox-silver-sink)"))),a=(e=>{const t=le(e,"background-color");return void 0!==t&&""!==t?"background-color:"+t+"!important":"background-color:rgb(255,255,255)!important;"})(o);S(s,n("display:none!important;")),S(r,n(lt+ct+a));n((!0===dt?"":lt)+ct+a)(t)},ut=Ye.DOM,gt=$e().fold((()=>({bind:p,unbind:p})),(e=>{const t=(()=>{const e=O(p);return{...e,on:t=>e.get().each(t)}})(),o=D(),n=D(),r=((e,t)=>{let o=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null)},throttle:(...n)=>{c(o)&&(o=setTimeout((()=>{o=null,e.apply(null,n)}),t))}}})((()=>{document.body.scrollTop=0,document.documentElement.scrollTop=0,window.requestAnimationFrame((()=>{t.on((t=>ie(t,{top:e.offsetTop+"px",left:e.offsetLeft+"px",height:e.height+"px",width:e.width+"px"})))}))}),50);return{bind:e=>{t.set(e),r.throttle(),o.set(Ke("resize",r.throttle)),n.set(Ke("scroll",r.throttle))},unbind:()=>{t.on((()=>{o.clear(),n.clear()})),t.clear()}}})),ht=(e,t)=>{const o=document.body,n=document.documentElement,r=e.getContainer(),s=q.fromDom(r),a=(i=s,w.from(i.dom.nextSibling).map(q.fromDom)).filter((e=>(e=>I(e)&&L(e.dom))(e)&&((e,t)=>(e=>void 0!==e.dom.classList)(e)&&e.dom.classList.contains(t))(e,"tox-silver-sink")));var i;const l=tt(e),c=t.get(),d=q.fromDom(e.getBody()),m=Xe.deviceType.isTouch(),u=r.style,g=e.iframeElement,h=null==g?void 0:g.style,p=e=>{e(o,"tox-fullscreen"),e(n,"tox-fullscreen"),e(r,"tox-fullscreen"),te(s).map((e=>oe(e).dom)).each((t=>{e(t,"tox-fullscreen"),e(t,"tox-shadowhost")}))},f=()=>{m&&(e=>{const t=rt("["+it+"]");S(t,(t=>{const o=Z(t,it);o&&"no-styles"!==o?ie(t,e.parseStyle(o)):U(t,"style"),U(t,it)}))})(e.dom),p(ut.removeClass),gt.unbind(),w.from(t.get()).each((e=>e.fullscreenChangeHandler.unbind()))};if(c)c.fullscreenChangeHandler.unbind(),Qe(e)&&ot(l)&&(e=>{const t=e.dom;t.exitFullscreen?t.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.webkitCancelFullScreen&&t.webkitCancelFullScreen()})(K(l)),h.width=c.iframeWidth,h.height=c.iframeHeight,u.width=c.containerWidth,u.height=c.containerHeight,u.top=c.containerTop,u.left=c.containerLeft,b=a,y=c.sinkCssPosition,x=(e,t)=>{ae(e,"position",t)},b.isSome()&&y.isSome()?w.some(x(b.getOrDie(),y.getOrDie())):w.none(),f(),v=c.scrollPos,window.scrollTo(v.x,v.y),t.set(null),Je(e,!1),e.off("remove",f);else{const o=he(K(l),void 0!==document.fullscreenElement?"fullscreenchange":void 0!==document.msFullscreenElement?"MSFullscreenChange":void 0!==document.webkitFullscreenElement?"webkitfullscreenchange":"fullscreenchange",(o=>{Qe(e)&&(ot(l)||null===t.get()||ht(e,t))})),n={scrollPos:Ge(window),containerWidth:u.width,containerHeight:u.height,containerTop:u.top,containerLeft:u.left,iframeWidth:h.width,iframeHeight:h.height,fullscreenChangeHandler:o,sinkCssPosition:a.map((e=>le(e,"position")))};m&&mt(e.dom,s,d),h.width=h.height="100%",u.width=u.height="",p(ut.addClass),a.each((e=>{ae(e,"position","fixed")})),gt.bind(s),e.on("remove",f),t.set(n),Qe(e)&&(e=>{const t=e.dom;t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.webkitRequestFullScreen&&t.webkitRequestFullScreen()})(l),Je(e,!0)}var v,b,y,x},pt=(e,t)=>o=>{o.setActive(null!==t.get());const n=e=>o.setActive(e.state);return e.on("FullscreenStateChanged",n),()=>e.off("FullscreenStateChanged",n)};t.add("fullscreen",(t=>{const n=e(null);return t.inline||((e=>{(0,e.options.register)("fullscreen_native",{processor:"boolean",default:!1})})(t),((e,t)=>{e.addCommand("mceFullScreen",(()=>{ht(e,t)}))})(t,n),((e,t)=>{const o=()=>e.execCommand("mceFullScreen");e.ui.registry.addToggleMenuItem("fullscreen",{text:"Fullscreen",icon:"fullscreen",shortcut:"Meta+Shift+F",onAction:o,onSetup:pt(e,t)}),e.ui.registry.addToggleButton("fullscreen",{tooltip:"Fullscreen",icon:"fullscreen",onAction:o,onSetup:pt(e,t)})})(t,n),t.addShortcut("Meta+Shift+F","","mceFullScreen")),o(n)}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),s=t("array"),a=(i=null,e=>i===e);var i;const l=o("boolean"),c=e=>!(e=>null==e)(e),d=o("function"),m=(e,t)=>{if(s(e)){for(let o=0,n=e.length;o{},g=(e,t)=>e===t;class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return c(e)?h.some(e):h.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1);const p=Array.prototype.indexOf,f=Array.prototype.push,v=(e,t)=>((e,t)=>p.call(e,t))(e,t)>-1,b=e=>{const t=[];for(let o=0,n=e.length;ob(((e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0;oe.exists((e=>o(e,t))),C=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?h.some(t):h.none(),k=e=>t=>t.options.get(e),_=k("link_assume_external_targets"),E=k("link_context_toolbar"),T=k("link_list"),O=k("link_default_target"),D=k("link_default_protocol"),A=k("link_target_list"),M=k("link_rel_list"),N=k("link_class_list"),R=k("link_title"),B=k("allow_unsafe_link_target"),L=k("link_quicklink");var H=tinymce.util.Tools.resolve("tinymce.util.Tools");const I=e=>n(e.value)?e.value:"",P=(e,t)=>{const o=[];return H.each(e,(e=>{const r=(e=>n(e.text)?e.text:n(e.title)?e.title:"")(e);if(void 0!==e.menu){const n=P(e.menu,t);o.push({text:r,items:n})}else{const n=t(e);o.push({text:r,value:n})}})),o},F=(e=I)=>t=>h.from(t).map((t=>P(t,e))),z={sanitize:e=>F(I)(e),sanitizeWith:F,createUi:(e,t)=>o=>({name:e,type:"listbox",label:t,items:o}),getValue:I},V=Object.keys,Z=Object.hasOwnProperty,U=(e,t,o,n)=>{((e,t)=>{const o=V(e);for(let n=0,r=o.length;n{(t(e,r)?o:n)(e,r)}))},j=(e,t)=>Z.call(e,t);var W=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),$=tinymce.util.Tools.resolve("tinymce.util.URI");const q=e=>c(e)&&"a"===e.nodeName.toLowerCase(),G=e=>q(e)&&!!X(e),K=(e,t)=>{if(e.collapsed)return[];{const o=e.cloneContents(),n=o.firstChild,r=new W(n,o),s=[];let a=n;do{t(a)&&s.push(a)}while(a=r.next());return s}},Y=e=>/^\w+:/i.test(e),X=e=>{var t,o;return null!==(o=null!==(t=e.getAttribute("data-mce-href"))&&void 0!==t?t:e.getAttribute("href"))&&void 0!==o?o:""},J=(e,t)=>{const o=["noopener"],n=e?e.split(/\s+/):[],r=e=>e.filter((e=>-1===H.inArray(o,e))),s=t?(e=>(e=r(e)).length>0?e.concat(o):o)(n):r(n);return s.length>0?(e=>H.trim(e.sort().join(" ")))(s):""},Q=(e,t)=>(t=t||oe(e.selection.getRng())[0]||e.selection.getNode(),ae(t)?h.from(e.dom.select("a[href]",t)[0]):h.from(e.dom.getParent(t,"a[href]"))),ee=(e,t)=>Q(e,t).isSome(),te=(e,t)=>(e=>e.replace(/\uFEFF/g,""))(t.fold((()=>e.getContent({format:"text"})),(e=>e.innerText||e.textContent||""))),oe=e=>K(e,G),ne=e=>H.grep(e,G),re=e=>ne(e).length>0,se=e=>{const t=e.schema.getTextInlineElements(),o=e=>1===e.nodeType&&!q(e)&&!j(t,e.nodeName.toLowerCase());if(Q(e).exists((e=>e.hasAttribute("data-mce-block"))))return!1;const n=e.selection.getRng();if(n.collapsed)return!0;return 0===K(n,o).length},ae=e=>c(e)&&"FIGURE"===e.nodeName&&/\bimage\b/i.test(e.className),ie=(e,t)=>{const o={...t};if(0===M(e).length&&!B(e)){const e=J(o.rel,"_blank"===o.target);o.rel=e||null}return h.from(o.target).isNone()&&!1===A(e)&&(o.target=O(e)),o.href=((e,t)=>"http"!==t&&"https"!==t||Y(e)?e:t+"://"+e)(o.href,_(e)),o},le=(e,t,o)=>{const n=e.selection.getNode(),r=Q(e,n),s=ie(e,(e=>{return t=["title","rel","class","target"],o=(t,o)=>(e[o].each((e=>{t[o]=e.length>0?e:null})),t),n={href:e.href},((e,t)=>{for(let o=0,n=e.length;o{n=o(n,e,t)})),n;var t,o,n})(o));e.undoManager.transact((()=>{o.href===t.href&&t.attach(),r.fold((()=>{((e,t,o,n)=>{const r=e.dom;ae(t)?ge(r,t,n):o.fold((()=>{e.execCommand("mceInsertLink",!1,n)}),(t=>{e.insertContent(r.createHTML("a",n,r.encode(t)))}))})(e,n,o.text,s)}),(t=>{e.focus(),((e,t,o,n)=>{o.each((e=>{j(t,"innerText")?t.innerText=e:t.textContent=e})),e.dom.setAttribs(t,n),e.selection.select(t)})(e,t,o.text,s)}))}))},ce=e=>{const{class:t,href:o,rel:n,target:r,text:s,title:i}=e;return((e,t)=>{const o={};var n;return U(e,t,(n=o,(e,t)=>{n[t]=e}),u),o})({class:t.getOrNull(),href:o,rel:n.getOrNull(),target:r.getOrNull(),text:s.getOrNull(),title:i.getOrNull()},((e,t)=>!1===a(e)))},de=(e,t,o)=>{const n=((e,t)=>{const o=e.options.get,n={allow_html_data_urls:o("allow_html_data_urls"),allow_script_urls:o("allow_script_urls"),allow_svg_data_urls:o("allow_svg_data_urls")},r=t.href;return{...t,href:$.isDomSafe(r,"a",n)?r:""}})(e,o);e.hasPlugin("rtc",!0)?e.execCommand("createlink",!1,ce(n)):le(e,t,n)},me=e=>{e.hasPlugin("rtc",!0)?e.execCommand("unlink"):(e=>{e.undoManager.transact((()=>{const t=e.selection.getNode();ae(t)?ue(e,t):(e=>{const t=e.dom,o=e.selection,n=o.getBookmark(),r=o.getRng().cloneRange(),s=t.getParent(r.startContainer,"a[href]",e.getBody()),a=t.getParent(r.endContainer,"a[href]",e.getBody());s&&r.setStartBefore(s),a&&r.setEndAfter(a),o.setRng(r),e.execCommand("unlink"),o.moveToBookmark(n)})(e),e.focus()}))})(e)},ue=(e,t)=>{var o;const n=e.dom.select("img",t)[0];if(n){const r=e.dom.getParents(n,"a[href]",t)[0];r&&(null===(o=r.parentNode)||void 0===o||o.insertBefore(n,r),e.dom.remove(r))}},ge=(e,t,o)=>{var n;const r=e.select("img",t)[0];if(r){const t=e.create("a",o);null===(n=r.parentNode)||void 0===n||n.insertBefore(t,r),t.appendChild(r)}},he=e=>{return j(t=e,o="items")&&void 0!==t[o]&&null!==t[o];var t,o},pe=(e,t)=>w(t,(t=>he(t)?pe(e,t.items):S(t.value===e,t))),fe=(e,t,o,n)=>{const r=n[t],s=e.length>0;return void 0!==r?pe(r,o).map((t=>({url:{value:t.value,meta:{text:s?e:t.text,attach:u}},text:s?e:t.text}))):h.none()},ve=(e,t)=>{const o={text:e.text,title:e.title},n=e=>{const t=(n=e.url,S(o.text.length<=0,h.from(null===(r=n.meta)||void 0===r?void 0:r.text).getOr(n.value)));var n,r;const s=(e=>{var t;return S(o.title.length<=0,h.from(null===(t=e.meta)||void 0===t?void 0:t.title).getOr(""))})(e.url);return t.isSome()||s.isSome()?h.some({...t.map((e=>({text:e}))).getOr({}),...s.map((e=>({title:e}))).getOr({})}):h.none()},r=(e,n)=>{const r=(s=t,a=n,"link"===a?s.link:"anchor"===a?s.anchor:h.none()).getOr([]);var s,a;return fe(o.text,n,r,e)};return{onChange:(e,t)=>{const s=t.name;return"url"===s?n(e()):v(["anchor","link"],s)?r(e(),s):"text"===s||"title"===s?(o[s]=e()[s],h.none()):h.none()}}};var be=tinymce.util.Tools.resolve("tinymce.util.Delay");const ye=e=>{const t=e.href;return t.indexOf("@")>0&&-1===t.indexOf("/")&&-1===t.indexOf("mailto:")?h.some({message:"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",preprocess:e=>({...e,href:"mailto:"+t})}):h.none()},we=(e,t)=>o=>{const n=o.href;return 1===e&&!Y(n)||0===e&&/^\s*www(\.|\d\.)/i.test(n)?h.some({message:`The URL you entered seems to be an external link. Do you want to add the required ${t}:// prefix?`,preprocess:e=>({...e,href:t+"://"+n})}):h.none()},xe=(e,t)=>w([ye,we(_(e),D(e))],(e=>e(t))).fold((()=>Promise.resolve(t)),(o=>new Promise((n=>{((e,t,o)=>{const n=e.selection.getRng();be.setEditorTimeout(e,(()=>{e.windowManager.confirm(t,(t=>{e.selection.setRng(n),o(t)}))}))})(e,o.message,(e=>{n(e?o.preprocess(t):t)}))})))),Ce=e=>{const t=e.dom.select("a:not([href])"),o=y(t,(e=>{const t=e.name||e.id;return t?[{text:t,value:"#"+t}]:[]}));return o.length>0?h.some([{text:"None",value:""}].concat(o)):h.none()},Se=e=>{const t=N(e);return t.length>0?z.sanitize(t):h.none()},ke=e=>{try{return h.some(JSON.parse(e))}catch(e){return h.none()}},_e=e=>{const t=t=>e.convertURL(t.value||t.url||"","href"),o=T(e);return new Promise((e=>{n(o)?fetch(o).then((e=>e.ok?e.text().then(ke):Promise.reject())).then(e,(()=>e(h.none()))):d(o)?o((t=>e(h.some(t)))):e(h.from(o))})).then((e=>e.bind(z.sanitizeWith(t)).map((e=>{if(e.length>0){return[{text:"None",value:""}].concat(e)}return e}))))},Ee=(e,t)=>{const o=M(e);if(o.length>0){const n=x(t,"_blank"),r=e=>J(z.getValue(e),n);return(!1===B(e)?z.sanitizeWith(r):z.sanitize)(o)}return h.none()},Te=[{text:"Current window",value:""},{text:"New window",value:"_blank"}],Oe=e=>{const t=A(e);return s(t)?z.sanitize(t).orThunk((()=>h.some(Te))):!1===t?h.none():h.some(Te)},De=(e,t,o)=>{const n=e.getAttrib(t,o);return null!==n&&n.length>0?h.some(n):h.none()},Ae=(e,t)=>_e(e).then((o=>{const n=((e,t)=>{const o=e.dom,n=se(e)?h.some(te(e.selection,t)):h.none(),r=t.bind((e=>h.from(o.getAttrib(e,"href")))),s=t.bind((e=>h.from(o.getAttrib(e,"target")))),a=t.bind((e=>De(o,e,"rel"))),i=t.bind((e=>De(o,e,"class")));return{url:r,text:n,title:t.bind((e=>De(o,e,"title"))),target:s,rel:a,linkClass:i}})(e,t);return{anchor:n,catalogs:{targets:Oe(e),rels:Ee(e,n.target),classes:Se(e),anchor:Ce(e),link:o},optNode:t,flags:{titleEnabled:R(e)}}})),Me=e=>{const t=(e=>{const t=Q(e);return Ae(e,t)})(e);t.then((t=>{const o=((e,t)=>o=>{const n=o.getData();if(!n.url.value)return me(e),void o.close();const r=e=>h.from(n[e]).filter((o=>!x(t.anchor[e],o))),s={href:n.url.value,text:r("text"),target:r("target"),rel:r("rel"),class:r("linkClass"),title:r("title")},a={href:n.url.value,attach:void 0!==n.url.meta&&n.url.meta.attach?n.url.meta.attach:u};xe(e,s).then((t=>{de(e,a,t)})),o.close()})(e,t);return((e,t,o)=>{const n=e.anchor.text.map((()=>({name:"text",type:"input",label:"Text to display"}))).toArray(),r=e.flags.titleEnabled?[{name:"title",type:"input",label:"Title"}]:[],s=((e,t)=>{const o=e.anchor,n=o.url.getOr("");return{url:{value:n,meta:{original:{value:n}}},text:o.text.getOr(""),title:o.title.getOr(""),anchor:n,link:n,rel:o.rel.getOr(""),target:o.target.or(t).getOr(""),linkClass:o.linkClass.getOr("")}})(e,h.from(O(o))),a=e.catalogs,i=ve(s,a);return{title:"Insert/Edit Link",size:"normal",body:{type:"panel",items:b([[{name:"url",type:"urlinput",filetype:"file",label:"URL",picker_text:"Browse links"}],n,r,C([a.anchor.map(z.createUi("anchor","Anchors")),a.rels.map(z.createUi("rel","Rel")),a.targets.map(z.createUi("target","Open link in...")),a.link.map(z.createUi("link","Link list")),a.classes.map(z.createUi("linkClass","Class"))])])},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:s,onChange:(e,{name:t})=>{i.onChange(e.getData,{name:t}).each((t=>{e.setData(t)}))},onSubmit:t}})(t,o,e)})).then((t=>{e.windowManager.open(t)}))};var Ne=tinymce.util.Tools.resolve("tinymce.util.VK");const Re=e=>{const t=document.createElement("a");t.target="_blank",t.href=e,t.rel="noreferrer noopener";const o=document.createEvent("MouseEvents");o.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),((e,t)=>{document.body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)})(t,o)},Be=(e,t)=>e.dom.getParent(t,"a[href]"),Le=e=>Be(e,e.selection.getStart()),He=(e,t)=>{if(t){const o=X(t);if(/^#/.test(o)){const t=e.dom.select(o);t.length&&e.selection.scrollIntoView(t[0],!0)}else Re(t.href)}},Ie=e=>()=>{e.execCommand("mceLink",!1,{dialog:!0})},Pe=e=>()=>{He(e,Le(e))},Fe=(e,t)=>(e.on("NodeChange",t),()=>e.off("NodeChange",t)),ze=e=>t=>{const o=()=>{t.setActive(!e.mode.isReadOnly()&&ee(e,e.selection.getNode())),t.setEnabled(e.selection.isEditable())};return o(),Fe(e,o)},Ve=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return o(),Fe(e,o)},Ze=e=>t=>{const o=()=>t.setEnabled((e=>1===(e.selection.isCollapsed()?ne(e.dom.getParents(e.selection.getStart())):oe(e.selection.getRng())).length)(e));return o(),Fe(e,o)},Ue=e=>t=>{const o=t=>{return re(t)||(o=e.selection.getRng(),oe(o).length>0);var o},n=e.dom.getParents(e.selection.getStart()),r=n=>{t.setEnabled(o(n)&&e.selection.isEditable())};return r(n),Fe(e,(e=>r(e.parents)))},je=e=>{const t=t=>{const o=e.selection.getNode();return t.setEnabled(ee(e,o)),u};e.ui.registry.addContextForm("quicklink",{launch:{type:"contextformtogglebutton",icon:"link",tooltip:"Link",onSetup:ze(e)},label:"Link",predicate:t=>E(e)&&ee(e,t),initValue:()=>{return Q(e).fold((t="",()=>t),X);var t},commands:[{type:"contextformtogglebutton",icon:"link",tooltip:"Link",primary:!0,onSetup:t=>{const o=e.selection.getNode();return t.setActive(ee(e,o)),ze(e)(t)},onAction:t=>{const o=t.getValue(),n=(t=>{const o=Q(e),n=se(e);if(o.isNone()&&n){const n=te(e.selection,o);return S(0===n.length,t)}return h.none()})(o);de(e,{href:o,attach:u},{href:o,text:n,title:h.none(),rel:h.none(),target:h.none(),class:h.none()}),(e=>{e.selection.collapse(!1)})(e),t.hide()}},{type:"contextformbutton",icon:"unlink",tooltip:"Remove link",onSetup:t,onAction:t=>{me(e),t.hide()}},{type:"contextformbutton",icon:"new-tab",tooltip:"Open link",onSetup:t,onAction:t=>{Pe(e)(),t.hide()}}]})};e.add("link",(e=>{(e=>{const t=e.options.register;t("link_assume_external_targets",{processor:e=>{const t=n(e)||l(e);return t?!0===e?{value:1,valid:t}:"http"===e||"https"===e?{value:e,valid:t}:{value:0,valid:t}:{valid:!1,message:"Must be a string or a boolean."}},default:!1}),t("link_context_toolbar",{processor:"boolean",default:!1}),t("link_list",{processor:e=>n(e)||d(e)||m(e,r)}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"}),t("link_target_list",{processor:e=>l(e)||m(e,r),default:!0}),t("link_rel_list",{processor:"object[]",default:[]}),t("link_class_list",{processor:"object[]",default:[]}),t("link_title",{processor:"boolean",default:!0}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("link_quicklink",{processor:"boolean",default:!1})})(e),(e=>{e.ui.registry.addToggleButton("link",{icon:"link",tooltip:"Insert/edit link",onAction:Ie(e),onSetup:ze(e)}),e.ui.registry.addButton("openlink",{icon:"new-tab",tooltip:"Open link",onAction:Pe(e),onSetup:Ze(e)}),e.ui.registry.addButton("unlink",{icon:"unlink",tooltip:"Remove link",onAction:()=>me(e),onSetup:Ue(e)})})(e),(e=>{e.ui.registry.addMenuItem("openlink",{text:"Open link",icon:"new-tab",onAction:Pe(e),onSetup:Ze(e)}),e.ui.registry.addMenuItem("link",{icon:"link",text:"Link...",shortcut:"Meta+K",onSetup:Ve(e),onAction:Ie(e)}),e.ui.registry.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onAction:()=>me(e),onSetup:Ue(e)})})(e),(e=>{e.ui.registry.addContextMenu("link",{update:t=>e.dom.isEditable(t)?re(e.dom.getParents(t,"a"))?"link unlink openlink":"link":""})})(e),je(e),(e=>{e.on("click",(t=>{const o=Be(e,t.target);o&&Ne.metaKeyPressed(t)&&(t.preventDefault(),He(e,o))})),e.on("keydown",(t=>{if(!t.isDefaultPrevented()&&13===t.keyCode&&(e=>!0===e.altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey)(t)){const o=Le(e);o&&(t.preventDefault(),He(e,o))}}))})(e),(e=>{e.addCommand("mceLink",((t,o)=>{!0!==(null==o?void 0:o.dialog)&&L(e)?e.dispatch("contexttoolbar-show",{toolbarKey:"quicklink"}):Me(e)}))})(e),(e=>{e.addShortcut("Meta+K","",(()=>{e.execCommand("mceLink")}))})(e)}))}(),function(){var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),s=t("array"),a=o("boolean"),i=e=>!(e=>null==e)(e),l=o("function"),c=o("number"),d=()=>{},m=e=>()=>e,u=(e,t)=>e===t;const g=e=>t=>!e(t),h=m(!1);class p{constructor(e,t){this.tag=e,this.value=t}static some(e){return new p(!0,e)}static none(){return p.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?p.some(e(this.value)):p.none()}bind(e){return this.tag?e(this.value):p.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:p.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return i(e)?p.some(e):p.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}p.singletonNone=new p(!1);const f=Array.prototype.slice,v=Array.prototype.indexOf,b=Array.prototype.push,y=(e,t)=>{return o=e,n=t,v.call(o,n)>-1;var o,n},w=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n(C(e,((e,n)=>{o=t(o,e,n)})),o),_=(e,t,o)=>{for(let n=0,r=e.length;n_(e,t,h),T=(e,t)=>(e=>{const t=[];for(let o=0,n=e.length;o{const t=f.call(e,0);return t.reverse(),t},D=(e,t)=>t>=0&&tD(e,0),M=e=>D(e,e.length-1),N=(e,t)=>{const o=[],n=l(t)?e=>w(o,(o=>t(o,e))):e=>y(o,e);for(let t=0,r=e.length;te.exists((e=>o(e,t))),B=(e,t,o)=>e.isSome()&&t.isSome()?p.some(o(e.getOrDie(),t.getOrDie())):p.none(),L=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},H={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return L(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return L(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return L(o)},fromDom:L,fromPoint:(e,t,o)=>p.from(e.dom.elementFromPoint(t,o)).map(L)},I=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},P=(e,t)=>e.dom===t.dom,F=I,z="undefined"!=typeof window?window:Function("return this;")(),V=(e,t)=>((e,t)=>{let o=null!=t?t:z;for(let t=0;t{const o=((e,t)=>V(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},U=Object.getPrototypeOf,j=e=>{const t=V("ownerDocument.defaultView",e);return r(e)&&((e=>Z("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(U(e).constructor.name))},W=e=>e.dom.nodeName.toLowerCase(),$=e=>e.dom.nodeType,q=e=>t=>$(t)===e,G=e=>K(e)&&j(e.dom),K=q(1),Y=q(3),X=q(9),J=q(11),Q=e=>t=>K(t)&&W(t)===e,ee=e=>p.from(e.dom.parentNode).map(H.fromDom),te=e=>x(e.dom.childNodes,H.fromDom),oe=(e,t)=>{const o=e.dom.childNodes;return p.from(o[t]).map(H.fromDom)},ne=e=>oe(e,0),re=e=>oe(e,e.dom.childNodes.length-1),se=l(Element.prototype.attachShadow)&&l(Node.prototype.getRootNode)?e=>H.fromDom(e.dom.getRootNode()):e=>{return X(e)?e:(t=e,H.fromDom(t.dom.ownerDocument));var t},ae=e=>{const t=se(e);return J(o=t)&&i(o.dom.host)?p.some(t):p.none();var o},ie=e=>H.fromDom(e.dom.host),le=e=>{const t=Y(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return ae(H.fromDom(t)).fold((()=>o.body.contains(t)),(n=le,r=ie,e=>n(r(e))));var n,r};var ce=(e,t,o,n,r)=>e(o,n)?p.some(o):l(r)&&r(o)?p.none():t(o,n,r);const de=(e,t,o)=>{let n=e.dom;const r=l(o)?o:h;for(;n.parentNode;){n=n.parentNode;const e=H.fromDom(n);if(t(e))return p.some(e);if(r(e))break}return p.none()},me=(e,t,o)=>ce(((e,t)=>t(e)),de,e,t,o),ue=(e,t,o)=>de(e,(e=>I(e,t)),o),ge=e=>{return ce(((e,t)=>I(e,t)),ue,e,"[contenteditable]",t);var t},he=e=>e.dom.contentEditable,pe=(e,t)=>{ee(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},fe=(e,t)=>{const o=(e=>p.from(e.dom.nextSibling).map(H.fromDom))(e);o.fold((()=>{ee(e).each((e=>{ve(e,t)}))}),(e=>{pe(e,t)}))},ve=(e,t)=>{e.dom.appendChild(t.dom)},be=(e,t)=>{C(t,(t=>{ve(e,t)}))},ye=e=>{e.dom.textContent="",C(te(e),(e=>{we(e)}))},we=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)};var xe=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),Ce=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),Se=tinymce.util.Tools.resolve("tinymce.util.VK");const ke=e=>x(e,H.fromDom),_e=Object.keys,Ee=(e,t)=>{const o=_e(e);for(let n=0,r=o.length;n{const o={};var n;return((e,t,o,n)=>{Ee(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(n=o,(e,t)=>{n[t]=e}),d),o},Oe=(e,t)=>{const o=e.dom;Ee(t,((e,t)=>{((e,t,o)=>{if(!(n(o)||a(o)||c(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(o,t,e)}))},De=e=>k(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Ae=e=>((e,t)=>H.fromDom(e.dom.cloneNode(t)))(e,!0),Me=(e,t)=>{const o=((e,t)=>{const o=H.fromTag(t),n=De(e);return Oe(o,n),o})(e,t);fe(e,o);const n=te(e);return be(o,n),we(e),o};var Ne=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),Re=tinymce.util.Tools.resolve("tinymce.util.Tools");const Be=e=>t=>i(t)&&t.nodeName.toLowerCase()===e,Le=e=>t=>i(t)&&e.test(t.nodeName),He=e=>i(e)&&3===e.nodeType,Ie=e=>i(e)&&1===e.nodeType,Pe=Le(/^(OL|UL|DL)$/),Fe=Le(/^(OL|UL)$/),ze=Be("ol"),Ve=Le(/^(LI|DT|DD)$/),Ze=Le(/^(DT|DD)$/),Ue=Le(/^(TH|TD)$/),je=Be("br"),We=(e,t)=>i(t)&&t.nodeName in e.schema.getTextBlockElements(),$e=(e,t)=>i(e)&&e.nodeName in t,qe=(e,t)=>i(t)&&t.nodeName in e.schema.getVoidElements(),Ge=(e,t,o)=>{const n=e.isEmpty(t);return!(o&&e.select("span[data-mce-type=bookmark]",t).length>0)&&n},Ke=(e,t)=>e.isChildOf(t,e.getRoot()),Ye=e=>t=>t.options.get(e),Xe=Ye("lists_indent_on_tab"),Je=Ye("forced_root_block"),Qe=Ye("forced_root_block_attrs"),et=(e,t)=>{const o=e.dom,n=e.schema.getBlockElements(),r=o.createFragment(),s=Je(e),a=Qe(e);let i,l,c=!1;for(l=o.create(s,a),$e(t.firstChild,n)||r.appendChild(l);i=t.firstChild;){const e=i.nodeName;c||"SPAN"===e&&"bookmark"===i.getAttribute("data-mce-type")||(c=!0),$e(i,n)?(r.appendChild(i),l=null):(l||(l=o.create(s,a),r.appendChild(l)),l.appendChild(i))}return!c&&l&&l.appendChild(o.create("br",{"data-mce-bogus":"1"})),r},tt=Ne.DOM,ot=(e,t,o)=>{const n=tt.select('span[data-mce-type="bookmark"]',t),r=et(e,o),s=tt.createRng();s.setStartAfter(o),s.setEndAfter(t);const a=s.extractContents();for(let t=a.firstChild;t;t=t.firstChild)if("LI"===t.nodeName&&e.dom.isEmpty(t)){tt.remove(t);break}e.dom.isEmpty(a)||tt.insertAfter(a,t),tt.insertAfter(r,t);const i=o.parentElement;i&&Ge(e.dom,i)&&(e=>{const t=e.parentNode;t&&Re.each(n,(e=>{t.insertBefore(e,o.parentNode)})),tt.remove(e)})(i),tt.remove(o),Ge(e.dom,t)&&tt.remove(t)},nt=Q("dd"),rt=Q("dt"),st=(e,t)=>{var o;nt(t)?Me(t,"dt"):rt(t)&&(o=t,p.from(o.dom.parentElement).map(H.fromDom)).each((o=>ot(e,o.dom,t.dom)))},at=e=>{rt(e)&&Me(e,"dd")},it=(e,t)=>{if(He(e))return{container:e,offset:t};const o=xe.getNode(e,t);return He(o)?{container:o,offset:t>=e.childNodes.length?o.data.length:0}:o.previousSibling&&He(o.previousSibling)?{container:o.previousSibling,offset:o.previousSibling.data.length}:o.nextSibling&&He(o.nextSibling)?{container:o.nextSibling,offset:0}:{container:e,offset:t}},lt=e=>{const t=e.cloneRange(),o=it(e.startContainer,e.startOffset);t.setStart(o.container,o.offset);const n=it(e.endContainer,e.endOffset);return t.setEnd(n.container,n.offset),t},ct=["OL","UL","DL"],dt=ct.join(","),mt=(e,t)=>{const o=t||e.selection.getStart(!0);return e.dom.getParent(o,dt,pt(e,o))},ut=e=>{const t=mt(e),o=e.selection.getSelectedBlocks();return((e,t)=>i(e)&&1===t.length&&t[0]===e)(t,o)?(e=>S(e.querySelectorAll(dt),Pe))(t):S(o,(e=>Pe(e)&&t!==e))},gt=e=>{const t=e.selection.getSelectedBlocks();return S(((e,t)=>{const o=Re.map(t,(t=>e.dom.getParent(t,"li,dd,dt",pt(e,t))||t));return N(o)})(e,t),Ve)},ht=(e,t)=>{const o=e.dom.getParents(t,"TD,TH");return o.length>0?o[0]:e.getBody()},pt=(e,t)=>{const o=e.dom.getParents(t,e.dom.isBlock),n=E(o,(t=>{return o=e.schema,!Pe(n=t)&&!Ve(n)&&w(ct,(e=>o.isValidChild(n.nodeName,e)));var o,n}));return n.getOr(e.getBody())},ft=(e,t)=>{const o=e.dom.getParents(t,"ol,ul",pt(e,t));return M(o)},vt=e=>{const t=(e=>{const t=ft(e,e.selection.getStart()),o=S(e.selection.getSelectedBlocks(),Fe);return t.toArray().concat(o)})(e),o=(e=>{const t=e.selection.getStart();return e.dom.getParents(t,"ol,ul",pt(e,t))})(e);return E(o,(e=>{return t=H.fromDom(e),ee(t).exists((e=>Ve(e.dom)&&ne(e).exists((e=>!Pe(e.dom)))&&re(e).exists((e=>!Pe(e.dom)))));var t})).fold((()=>bt(e,t)),(e=>[e]))},bt=(e,t)=>{const o=x(t,(t=>ft(e,t).getOr(t)));return N(o)},yt=e=>/\btox\-/.test(e.className),wt=(e,t)=>_(e,Pe,Ue).exists((e=>e.nodeName===t&&!yt(e))),xt=(e,t)=>null!==t&&!e.dom.isEditable(t),Ct=(e,t)=>{const o=e.dom.getParent(t,"ol,ul,dl");return xt(e,o)},St=(e,t)=>{const o=e.selection.getNode();return t({parents:e.dom.getParents(o),element:o}),e.on("NodeChange",t),()=>e.off("NodeChange",t)},kt=(e,t)=>{const o=(t||document).createDocumentFragment();return C(e,(e=>{o.appendChild(e.dom)})),H.fromDom(o)},_t=(e,t,o)=>e.dispatch("ListMutation",{action:t,element:o}),Et=(Tt=/^\s+|\s+$/g,e=>e.replace(Tt,""));var Tt;const Ot=(e,t,o)=>{if(!n(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);(e=>void 0!==e.style&&l(e.style.getPropertyValue))(e)&&e.style.setProperty(t,o)},Dt=(e,t,o)=>{const n=e.dom;Ot(n,t,o)},At=e=>F(e,"OL,UL"),Mt=e=>ne(e).exists(At),Nt=e=>"listAttributes"in e,Rt=e=>"isComment"in e,Bt=e=>e.depth>0,Lt=e=>e.isSelected,Ht=e=>{const t=te(e),o=re(e).exists(At)?t.slice(0,-1):t;return x(o,Ae)},It=(e,t)=>{ve(e.item,t.list)},Pt=(e,t)=>{const o={list:H.fromTag(t,e),item:H.fromTag("li",e)};return ve(o.list,o.item),o},Ft=(e,t,o)=>{const n=t.slice(0,o.depth);return M(n).each((t=>{if(Nt(o)){const n=((e,t,o)=>{const n=H.fromTag("li",e);return Oe(n,t),be(n,o),n})(e,o.itemAttributes,o.content);((e,t)=>{ve(e.list,t),e.item=t})(t,n),((e,t)=>{W(e.list)!==t.listType&&(e.list=Me(e.list,t.listType)),Oe(e.list,t.listAttributes)})(t,o)}else if((e=>"isFragment"in e)(o))be(t.item,o.content);else{const e=H.fromHtml(`\x3c!--${o.content}--\x3e`);ve(t.list,e)}})),n},zt=(e,t,o)=>{const n=((e,t,o)=>{const n=[];for(let r=0;r{for(let t=1;t{for(let t=0;t{Nt(t)&&(Oe(e.list,t.listAttributes),Oe(e.item,t.itemAttributes)),be(e.item,t.content)}))})(n,o),r=n,B(M(t),A(r),It),t.concat(n)},Vt=(e,t)=>{let o=p.none();const n=k(t,((t,n,r)=>Rt(n)?0===r?(o=p.some(n),t):Ft(e,t,n):n.depth>t.length?zt(e,t,n):Ft(e,t,n)),[]);return o.each((e=>{const t=H.fromHtml(`\x3c!--${e.content}--\x3e`);A(n).each((e=>{((e,t)=>{ne(e).fold((()=>{ve(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))})(e.list,t)}))})),A(n).map((e=>e.list))},Zt=e=>(C(e,((t,o)=>{((e,t)=>{const o=e[t].depth,n=e=>e.depth===o&&!e.dirty,r=e=>e.depth_(e.slice(t+1),n,r)))})(e,o).fold((()=>{t.dirty&&Nt(t)&&(e=>{e.listAttributes=Te(e.listAttributes,((e,t)=>"start"!==t))})(t)}),(e=>{return n=e,void(Nt(o=t)&&Nt(n)&&(o.listType=n.listType,o.listAttributes={...n.listAttributes}));var o,n}))})),e),Ut=(e,t,o,n)=>{var r,s;if(8===$(s=n)||"#comment"===W(s))return[{depth:e+1,content:null!==(r=n.dom.nodeValue)&&void 0!==r?r:"",dirty:!1,isSelected:!1,isComment:!0}];t.each((e=>{P(e.start,n)&&o.set(!0)}));const a=((e,t,o)=>ee(e).filter(K).map((n=>({depth:t,dirty:!1,isSelected:o,content:Ht(e),itemAttributes:De(e),listAttributes:De(n),listType:W(n),isInPreviousLi:!1}))))(n,e,o.get());t.each((e=>{P(e.end,n)&&o.set(!1)}));const i=re(n).filter(At).map((n=>Wt(e,t,o,n))).getOr([]);return a.toArray().concat(i)},jt=(e,t,o,n)=>ne(n).filter(At).fold((()=>Ut(e,t,o,n)),(r=>{const s=k(te(n),((n,s,a)=>{if(0===a)return n;if(F(s,"LI"))return n.concat(Ut(e,t,o,s));{const t={isFragment:!0,depth:e,content:[s],isSelected:!1,dirty:!1,parentListType:W(r)};return n.concat(t)}}),[]);return Wt(e,t,o,r).concat(s)})),Wt=(e,t,o,n)=>T(te(n),(n=>(At(n)?Wt:jt)(e+1,t,o,n))),$t=(e,t)=>T(((e,t)=>{if(0===e.length)return[];{let o=t(e[0]);const n=[];let r=[];for(let s=0,a=e.length;sA(t).exists(Bt)?((e,t)=>{const o=Zt(t);return Vt(e.contentDocument,o).toArray()})(e,t):((e,t)=>{const o=Zt(t);return x(o,(t=>{const o=Rt(t)?kt([H.fromHtml(`\x3c!--${t.content}--\x3e`)]):kt(t.content);return H.fromDom(et(e,o.dom))}))})(e,t))),qt=(e,t,o)=>{const n=((e,t)=>{const o=(e=>{let t=!1;return{get:()=>t,set:e=>{t=e}}})();return x(e,(e=>({sourceList:e,entries:Wt(0,t,o,e)})))})(t,(e=>{const t=x(gt(e),H.fromDom);return B(E(t,g(Mt)),E(O(t),g(Mt)),((e,t)=>({start:e,end:t})))})(e));C(n,(t=>{((e,t)=>{C(S(e,Lt),(e=>((e,t)=>{switch(e){case"Indent":t.depth++;break;case"Outdent":t.depth--;break;case"Flatten":t.depth=0}t.dirty=!0})(t,e)))})(t.entries,o);const n=$t(e,t.entries);var r;C(n,(t=>{_t(e,"Indent"===o?"IndentList":"OutdentList",t.dom)})),r=t.sourceList,C(n,(e=>{pe(r,e)})),we(t.sourceList)}))},Gt=(e,t)=>{const o=ke(vt(e)),n=ke((e=>S(gt(e),Ze))(e));let r=!1;if(o.length||n.length){const s=e.selection.getBookmark();qt(e,o,t),((e,t,o)=>{C(o,"Indent"===t?at:t=>st(e,t))})(e,t,n),e.selection.moveToBookmark(s),e.selection.setRng(lt(e.selection.getRng())),e.nodeChanged(),r=!0}return r},Kt=(e,t)=>!(e=>{const t=mt(e);return xt(e,t)})(e)&&Gt(e,t),Yt=e=>Kt(e,"Indent"),Xt=e=>Kt(e,"Outdent"),Jt=e=>Kt(e,"Flatten"),Qt=e=>"\ufeff"===e,eo=(e,t)=>{return o=e,n=function(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}(P,t),de(o,n,r).isSome();var o,n,r};var to=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager");const oo=Ne.DOM,no=e=>{const t={},o=o=>{let n=e[o?"startContainer":"endContainer"],r=e[o?"startOffset":"endOffset"];if(Ie(n)){const e=oo.create("span",{"data-mce-type":"bookmark"});n.hasChildNodes()?(r=Math.min(r,n.childNodes.length-1),o?n.insertBefore(e,n.childNodes[r]):oo.insertAfter(e,n.childNodes[r])):n.appendChild(e),n=e,r=0}t[o?"startContainer":"endContainer"]=n,t[o?"startOffset":"endOffset"]=r};return o(!0),e.collapsed||o(),t},ro=e=>{const t=t=>{let o=e[t?"startContainer":"endContainer"],n=e[t?"startOffset":"endOffset"];if(o){if(Ie(o)&&o.parentNode){const e=o;n=(e=>{var t;let o=null===(t=e.parentNode)||void 0===t?void 0:t.firstChild,n=0;for(;o;){if(o===e)return n;Ie(o)&&"bookmark"===o.getAttribute("data-mce-type")||n++,o=o.nextSibling}return-1})(o),o=o.parentNode,oo.remove(e),!o.hasChildNodes()&&oo.isBlock(o)&&o.appendChild(oo.create("br"))}e[t?"startContainer":"endContainer"]=o,e[t?"startOffset":"endOffset"]=n}};t(!0),t();const o=oo.createRng();return o.setStart(e.startContainer,e.startOffset),e.endContainer&&o.setEnd(e.endContainer,e.endOffset),lt(o)},so=e=>{switch(e){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},ao=(e,t)=>{Re.each(t,((t,o)=>{e.setAttribute(o,t)}))},io=(e,t,o)=>{((e,t,o)=>{const n=o["list-style-type"]?o["list-style-type"]:null;e.setStyle(t,"list-style-type",n)})(e,t,o),((e,t,o)=>{ao(t,o["list-attributes"]),Re.each(e.select("li",t),(e=>{ao(e,o["list-item-attributes"])}))})(e,t,o)},lo=(e,t)=>i(t)&&!$e(t,e.schema.getBlockElements()),co=(e,t,o,n)=>{let r=t[o?"startContainer":"endContainer"];const s=t[o?"startOffset":"endOffset"];Ie(r)&&(r=r.childNodes[Math.min(s,r.childNodes.length-1)]||r),!o&&je(r.nextSibling)&&(r=r.nextSibling);const a=(t,o)=>{var r;const s=new Ce(t,(t=>{for(;!e.dom.isBlock(t)&&t.parentNode&&n!==t;)t=t.parentNode;return t})(t)),a=o?"next":"prev";let i;for(;i=s[a]();)if(!qe(e,i)&&!Qt(i.textContent)&&0!==(null===(r=i.textContent)||void 0===r?void 0:r.length))return p.some(i);return p.none()};if(o&&He(r))if(Qt(r.textContent))r=a(r,!1).getOr(r);else for(null!==r.parentNode&&lo(e,r.parentNode)&&(r=r.parentNode);null!==r.previousSibling&&(lo(e,r.previousSibling)||He(r.previousSibling));)r=r.previousSibling;if(!o&&He(r))if(Qt(r.textContent))r=a(r,!0).getOr(r);else for(null!==r.parentNode&&lo(e,r.parentNode)&&(r=r.parentNode);null!==r.nextSibling&&(lo(e,r.nextSibling)||He(r.nextSibling));)r=r.nextSibling;for(;r.parentNode!==n;){const t=r.parentNode;if(We(e,r))return r;if(/^(TD|TH)$/.test(t.nodeName))return r;r=t}return r},mo=(e,t,o)=>{const n=e.selection.getRng();let r="LI";const s=pt(e,((e,t)=>{const o=e.selection.getStart(!0),n=co(e,t,!0,e.getBody());return eo(H.fromDom(n),H.fromDom(t.commonAncestorContainer))?t.commonAncestorContainer:o})(e,n)),a=e.dom;if("false"===a.getContentEditable(e.selection.getNode()))return;"DL"===(t=t.toUpperCase())&&(r="DT");const i=no(n),l=S(((e,t,o)=>{const n=[],r=e.dom,s=co(e,t,!0,o),a=co(e,t,!1,o);let i;const l=[];for(let e=s;e&&(l.push(e),e!==a);e=e.nextSibling);return Re.each(l,(t=>{var s;if(We(e,t))return n.push(t),void(i=null);if(r.isBlock(t)||je(t))return je(t)&&r.remove(t),void(i=null);const a=t.nextSibling;to.isBookmarkNode(t)&&(Pe(a)||We(e,a)||!a&&t.parentNode===o)?i=null:(i||(i=r.create("p"),null===(s=t.parentNode)||void 0===s||s.insertBefore(i,t),n.push(i)),i.appendChild(t))})),n})(e,n,s),e.dom.isEditable);Re.each(l,(n=>{let s;const i=n.previousSibling,l=n.parentNode;Ve(l)||(i&&Pe(i)&&i.nodeName===t&&((e,t,o)=>{const n=e.getStyle(t,"list-style-type");let r=o?o["list-style-type"]:"";return r=null===r?"":r,n===r})(a,i,o)?(s=i,n=a.rename(n,r),i.appendChild(n)):(s=a.create(t),l.insertBefore(s,n),s.appendChild(n),n=a.rename(n,r)),((e,t,o)=>{Re.each(o,(o=>e.setStyle(t,o,"")))})(a,n,["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"]),io(a,s,o),go(e.dom,s))})),e.selection.setRng(ro(i))},uo=(e,t,o)=>{return((e,t)=>Pe(e)&&e.nodeName===(null==t?void 0:t.nodeName))(t,o)&&((e,t,o)=>e.getStyle(t,"list-style-type",!0)===e.getStyle(o,"list-style-type",!0))(e,t,o)&&(n=o,t.className===n.className);var n},go=(e,t)=>{let o,n=t.nextSibling;if(uo(e,t,n)){const r=n;for(;o=r.firstChild;)t.appendChild(o);e.remove(r)}if(n=t.previousSibling,uo(e,t,n)){const r=n;for(;o=r.lastChild;)t.insertBefore(o,t.firstChild);e.remove(r)}},ho=(e,t,o,n)=>{if(t.nodeName!==o){const r=e.dom.rename(t,o);io(e.dom,r,n),_t(e,so(o),r)}else io(e.dom,t,n),_t(e,so(o),t)},po=(e,t,o,n)=>{if(t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),t.nodeName!==o){const r=e.dom.rename(t,o);io(e.dom,r,n),_t(e,so(o),r)}else io(e.dom,t,n),_t(e,so(o),t)},fo=e=>"list-style-type"in e,vo=(e,t,o)=>{const n=mt(e);if(Ct(e,n))return;const s=ut(e),a=r(o)?o:{};s.length>0?((e,t,o,n,r)=>{const s=Pe(t);if(!s||t.nodeName!==n||fo(r)||yt(t)){mo(e,n,r);const a=no(e.selection.getRng()),i=s?[t,...o]:o,l=s&&yt(t)?po:ho;Re.each(i,(t=>{l(e,t,n,r)})),e.selection.setRng(ro(a))}else Jt(e)})(e,n,s,t,a):((e,t,o,n)=>{if(t!==e.getBody())if(t)if(t.nodeName!==o||fo(n)||yt(t)){const r=no(e.selection.getRng());yt(t)&&t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),io(e.dom,t,n);const s=e.dom.rename(t,o);go(e.dom,s),e.selection.setRng(ro(r)),mo(e,o,n),_t(e,so(o),s)}else Jt(e);else mo(e,o,n),_t(e,so(o),t)})(e,n,t,a)},bo=Ne.DOM,yo=(e,t)=>{const o=Re.grep(e.select("ol,ul",t));Re.each(o,(t=>{((e,t)=>{const o=t.parentElement;if(o&&"LI"===o.nodeName&&o.firstChild===t){const n=o.previousSibling;n&&"LI"===n.nodeName?(n.appendChild(t),Ge(e,o)&&bo.remove(o)):bo.setStyle(o,"listStyleType","none")}if(Pe(o)){const e=o.previousSibling;e&&"LI"===e.nodeName&&e.appendChild(t)}})(e,t)}))},wo=(e,t,o,n)=>{let r=t.startContainer;const s=t.startOffset;if(He(r)&&(o?s0))return r;const a=e.schema.getNonEmptyElements();Ie(r)&&(r=xe.getNode(r,s));const i=new Ce(r,n);o&&((e,t)=>!!je(t)&&e.isBlock(t.nextSibling)&&!je(t.previousSibling))(e.dom,r)&&i.next();const l=o?i.next.bind(i):i.prev2.bind(i);for(;r=l();){if("LI"===r.nodeName&&!r.hasChildNodes())return r;if(a[r.nodeName])return r;if(He(r)&&r.data.length>0)return r}return null},xo=(e,t)=>{const o=t.childNodes;return 1===o.length&&!Pe(o[0])&&e.isBlock(o[0])},Co=e=>p.from(e).map(H.fromDom).filter(G).exists((e=>((e,t=!1)=>le(e)?e.dom.isContentEditable:ge(e).fold(m(t),(e=>"true"===he(e))))(e)&&!y(["details"],W(e)))),So=(e,t,o)=>{let n;const r=xo(e,o)?o.firstChild:o;if(((e,t)=>{xo(e,t)&&Co(t.firstChild)&&e.remove(t.firstChild,!0)})(e,t),!Ge(e,t,!0))for(;n=t.firstChild;)r.appendChild(n)},ko=(e,t,o)=>{let n;const r=t.parentNode;if(!Ke(e,t)||!Ke(e,o))return;Pe(o.lastChild)&&(n=o.lastChild),r===o.lastChild&&je(r.previousSibling)&&e.remove(r.previousSibling);const s=o.lastChild;s&&je(s)&&t.hasChildNodes()&&e.remove(s),Ge(e,o,!0)&&ye(H.fromDom(o)),So(e,t,o),n&&o.appendChild(n);const a=((e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)})(H.fromDom(o),H.fromDom(t))?e.getParents(t,Pe,o):[];e.remove(t),C(a,(t=>{Ge(e,t)&&t!==e.getRoot()&&e.remove(t)}))},_o=(e,t,o,n)=>{const r=e.dom;if(r.isEmpty(n))((e,t,o)=>{ye(H.fromDom(o)),ko(e.dom,t,o),e.selection.setCursorLocation(o,0)})(e,o,n);else{const s=no(t);ko(r,o,n),e.selection.setRng(ro(s))}},Eo=(e,t)=>{const o=e.dom,n=e.selection,r=n.getStart(),s=ht(e,r),a=o.getParent(n.getStart(),"LI",s);if(a){const r=a.parentElement;if(r===e.getBody()&&Ge(o,r))return!0;const i=lt(n.getRng()),l=o.getParent(wo(e,i,t,s),"LI",s),c=l&&(t?o.isChildOf(a,l):o.isChildOf(l,a));if(l&&l!==a&&!c)return e.undoManager.transact((()=>{var o,n;t?_o(e,i,l,a):(null===(n=(o=a).parentNode)||void 0===n?void 0:n.firstChild)===o?Xt(e):((e,t,o,n)=>{const r=no(t);ko(e.dom,o,n);const s=ro(r);e.selection.setRng(s)})(e,i,a,l)})),!0;if(c&&!t&&l!==a)return e.undoManager.transact((()=>{if(i.commonAncestorContainer.parentElement){const t=no(i),n=i.commonAncestorContainer.parentElement;So(o,i.commonAncestorContainer.parentElement,l),n.remove();const r=ro(t);e.selection.setRng(r)}})),!0;if(!l&&!t&&0===i.startOffset&&0===i.endOffset)return e.undoManager.transact((()=>{Jt(e)})),!0}return!1},To=(e,t)=>{const o=e.dom,n=e.selection.getStart(),r=ht(e,n),s=o.getParent(n,o.isBlock,r);if(s&&o.isEmpty(s)){const n=lt(e.selection.getRng()),a=o.getParent(wo(e,n,t,r),"LI",r);if(a){const i=e=>y(["td","th","caption"],W(e)),l=e=>e.dom===r;return!!((e,t,o=u)=>B(e,t,o).getOr(e.isNone()&&t.isNone()))(me(H.fromDom(a),i,l),me(H.fromDom(n.startContainer),i,l),P)&&(e.undoManager.transact((()=>{const n=a.parentNode;((e,t,o)=>{const n=e.getParent(t.parentNode,e.isBlock,o);e.remove(t),n&&e.isEmpty(n)&&e.remove(n)})(o,s,r),go(o,n),e.selection.select(a,!0),e.selection.collapse(t)})),!0)}}return!1},Oo=e=>{const t=e.selection.getStart(),o=ht(e,t);return e.dom.getParent(t,"LI,DT,DD",o)||gt(e).length>0},Do=(e,t)=>{const o=e.selection;return!Ct(e,o.getNode())&&(o.isCollapsed()?((e,t)=>Eo(e,t)||To(e,t))(e,t):(e=>!!Oo(e)&&(e.undoManager.transact((()=>{e.execCommand("Delete"),yo(e.dom,e.getBody())})),!0))(e))},Ao=e=>{const t=O(Et(e).split("")),o=x(t,((e,t)=>{const o=e.toUpperCase().charCodeAt(0)-"A".charCodeAt(0)+1;return Math.pow(26,t)*o}));return k(o,((e,t)=>e+t),0)},Mo=e=>{if(--e<0)return"";{const t=e%26,o=Math.floor(e/26);return Mo(o)+String.fromCharCode("A".charCodeAt(0)+t)}},No=e=>{const t=parseInt(e.start,10);return R(e.listStyleType,"upper-alpha")?Mo(t):R(e.listStyleType,"lower-alpha")?Mo(t).toLowerCase():e.start},Ro=e=>{const t=mt(e);ze(t)&&!Ct(e,t)&&e.windowManager.open({title:"List Properties",body:{type:"panel",items:[{type:"input",name:"start",label:"Start list at number",inputMode:"numeric"}]},initialData:{start:No({start:e.dom.getAttrib(t,"start","1"),listStyleType:p.from(e.dom.getStyle(t,"list-style-type"))})},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{(e=>{switch((e=>/^[0-9]+$/.test(e)?2:/^[A-Z]+$/.test(e)?0:(e=>/^[a-z]+$/.test(e))(e)?1:e.length>0?4:3)(e)){case 2:return p.some({listStyleType:p.none(),start:e});case 0:return p.some({listStyleType:p.some("upper-alpha"),start:Ao(e).toString()});case 1:return p.some({listStyleType:p.some("lower-alpha"),start:Ao(e).toString()});case 3:return p.some({listStyleType:p.none(),start:""});case 4:return p.none()}})(t.getData().start).each((t=>{e.execCommand("mceListUpdate",!1,{attrs:{start:"1"===t.start?"":t.start},styles:{"list-style-type":t.listStyleType.getOr("")}})})),t.close()}})},Bo=(e,t)=>()=>{const o=mt(e);return i(o)&&o.nodeName===t},Lo=e=>{e.addCommand("mceListProps",(()=>{Ro(e)}))},Ho=e=>{e.on("BeforeExecCommand",(t=>{const o=t.command.toLowerCase();"indent"===o?Yt(e):"outdent"===o&&Xt(e)})),e.addCommand("InsertUnorderedList",((t,o)=>{vo(e,"UL",o)})),e.addCommand("InsertOrderedList",((t,o)=>{vo(e,"OL",o)})),e.addCommand("InsertDefinitionList",((t,o)=>{vo(e,"DL",o)})),e.addCommand("RemoveList",(()=>{Jt(e)})),Lo(e),e.addCommand("mceListUpdate",((t,o)=>{r(o)&&((e,t)=>{const o=mt(e);null===o||Ct(e,o)||e.undoManager.transact((()=>{r(t.styles)&&e.dom.setStyles(o,t.styles),r(t.attrs)&&Ee(t.attrs,((t,n)=>e.dom.setAttrib(o,n,t)))}))})(e,o)})),e.addQueryStateHandler("InsertUnorderedList",Bo(e,"UL")),e.addQueryStateHandler("InsertOrderedList",Bo(e,"OL")),e.addQueryStateHandler("InsertDefinitionList",Bo(e,"DL"))};var Io=tinymce.util.Tools.resolve("tinymce.html.Node");const Po=e=>3===e.type,Fo=e=>0===e.length,zo=e=>{const t=(t,o)=>{const n=Io.create("li");C(t,(e=>n.append(e))),o?e.insert(n,o,!0):e.append(n)},o=k(e.children(),((e,o)=>Po(o)?[...e,o]:Fo(e)||Po(o)?e:(t(e,o),[])),[]);Fo(o)||t(o)},Vo=e=>{Xe(e)&&(e=>{e.on("keydown",(t=>{t.keyCode!==Se.TAB||Se.metaKeyPressed(t)||e.undoManager.transact((()=>{(t.shiftKey?Xt(e):Yt(e))&&t.preventDefault()}))}))})(e),(e=>{e.on("ExecCommand",(t=>{const o=t.command.toLowerCase();"delete"!==o&&"forwarddelete"!==o||!Oo(e)||yo(e.dom,e.getBody())})),e.on("keydown",(t=>{t.keyCode===Se.BACKSPACE?Do(e,!1)&&t.preventDefault():t.keyCode===Se.DELETE&&Do(e,!0)&&t.preventDefault()}))})(e)},Zo=(e,t)=>o=>(o.setEnabled(e.selection.isEditable()),St(e,(n=>{o.setActive(wt(n.parents,t)),o.setEnabled(!Ct(e,n.element)&&e.selection.isEditable())}))),Uo=(e,t)=>o=>St(e,(n=>o.setEnabled(wt(n.parents,t)&&!Ct(e,n.element))));e.add("lists",(e=>((e=>{(0,e.options.register)("lists_indent_on_tab",{processor:"boolean",default:!0})})(e),(e=>{e.on("PreInit",(()=>{const{parser:t}=e;t.addNodeFilter("ul,ol",(e=>C(e,zo)))}))})(e),e.hasPlugin("rtc",!0)?Lo(e):(Vo(e),Ho(e)),(e=>{const t=t=>()=>e.execCommand(t);e.hasPlugin("advlist")||(e.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:t("InsertOrderedList"),onSetup:Zo(e,"OL")}),e.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:t("InsertUnorderedList"),onSetup:Zo(e,"UL")}))})(e),(e=>{const t={text:"List properties...",icon:"ordered-list",onAction:()=>e.execCommand("mceListProps"),onSetup:Uo(e,"OL")};e.ui.registry.addMenuItem("listprops",t),e.ui.registry.addContextMenu("lists",{update:t=>{const o=mt(e,t);return ze(o)?["listprops"]:[]}})})(e),(e=>({backspaceDelete:t=>{Do(e,t)}}))(e))))}();export{n as default};