/** * TinyMCE version 6.0.2 (2022-04-27) */ !function(){"use strict";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=l=e,(n=String).prototype.isPrototypeOf(o)||(null===(r=l.constructor)||void 0===r?void 0:r.name)===n.name)?"string":t;var o,l,n,r})(t)===e,o=e=>t=>typeof t===e,l=t("string"),n=t("array"),r=o("boolean"),a=(void 0,e=>undefined===e);const s=e=>!(e=>null==e)(e),c=o("function"),i=o("number"),m=()=>{},d=e=>()=>e,u=e=>e,p=(e,t)=>e===t;function b(e,...t){return(...o)=>{const l=t.concat(o);return e.apply(null,l)}}const g=d(!1),h=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 s(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 y=Object.keys,w=Object.hasOwnProperty,S=(e,t)=>{const o=y(e);for(let l=0,n=o.length;l{const o={};var l;return((e,t,o,l)=>{S(e,((e,n)=>{(t(e,n)?o:l)(e,n)}))})(e,t,(l=o,(e,t)=>{l[t]=e}),m),o},v=e=>y(e).length,T=(e,t)=>x(e,t)?f.from(e[t]):f.none(),x=(e,t)=>w.call(e,t),A=(e,t)=>x(e,t)&&void 0!==e[t]&&null!==e[t],R=Array.prototype.indexOf,_=Array.prototype.push,O=(e,t)=>((e,t)=>R.call(e,t))(e,t)>-1,D=(e,t)=>{for(let o=0,l=e.length;o{const o=[];for(let l=0;l{const o=e.length,l=new Array(o);for(let n=0;n{for(let o=0,l=e.length;o{const o=[];for(let l=0,n=e.length;l(N(e,((e,l)=>{o=t(o,e,l)})),o),B=(e,t)=>((e,t,o)=>{for(let l=0,n=e.length;l(e=>{const t=[];for(let o=0,l=e.length;o{for(let o=0,l=e.length;ot>=0&&t{for(let o=0;o{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},j={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 H(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return H(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return H(o)},fromDom:H,fromPoint:(e,t,o)=>f.from(e.dom.elementFromPoint(t,o)).map(H)};"undefined"!=typeof window?window:Function("return this;")();const V=e=>e.dom.nodeName.toLowerCase(),z=e=>e.dom.nodeType,W=e=>t=>z(t)===e,$=W(1),U=W(3),G=W(9),K=W(11),J=e=>t=>$(t)&&V(t)===e,Q=(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")}},X=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Y=(e,t)=>e.dom===t.dom,Z=Q,ee=e=>G(e)?e:j.fromDom(e.dom.ownerDocument),te=e=>f.from(e.dom.parentNode).map(j.fromDom),oe=e=>f.from(e.dom.nextSibling).map(j.fromDom),le=e=>M(e.dom.childNodes,j.fromDom),ne=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>j.fromDom(e.dom.getRootNode()):ee,re=e=>j.fromDom(e.dom.host),ae=e=>{const t=U(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=ne(e);return K(o=t)&&s(o.dom.host)?f.some(t):f.none();var o})(j.fromDom(t)).fold((()=>o.body.contains(t)),(l=ae,n=re,e=>l(n(e))));var l,n},se=(e,t)=>{let o=[];return N(le(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(se(e,t))})),o},ce=(e,t)=>((e,o)=>P(le(e),(e=>Q(e,t))))(e),ie=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return X(o)?[]:M(o.querySelectorAll(e),j.fromDom)})(t,e),me=(e,t,o)=>{let l=e.dom;const n=c(o)?o:g;for(;l.parentNode;){l=l.parentNode;const e=j.fromDom(l);if(t(e))return f.some(e);if(n(e))break}return f.none()},de=(e,t,o)=>me(e,(e=>Q(e,t)),o),ue=(e,t)=>((e,o)=>B(e.dom.childNodes,(e=>{return o=j.fromDom(e),Q(o,t);var o})).map(j.fromDom))(e),pe=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return X(o)?f.none():f.from(o.querySelector(e)).map(j.fromDom)})(t,e),be=(e,t,o)=>((e,t,o,l,n)=>((e,t)=>Q(e,t))(o,l)?f.some(o):c(n)&&n(o)?f.none():t(o,l,n))(0,de,e,t,o),ge=(e,t,o)=>{if(!(l(o)||r(o)||i(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+"")},he=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},fe=(e,t)=>f.from(he(e,t)),ye=(e,t)=>{e.dom.removeAttribute(t)},we=(e,t,o=p)=>e.exists((e=>o(e,t))),Se=(e,t,o)=>e.isSome()&&t.isSome()?f.some(o(e.getOrDie(),t.getOrDie())):f.none(),Ce=(e,t)=>((e,t,o)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),ve=(Te=/^\s+|\s+$/g,e=>e.replace(Te,""));var Te;const xe=e=>e.length>0,Ae=e=>void 0!==e.style&&c(e.style.getPropertyValue),Re=(e,t)=>{const o=e.dom,l=window.getComputedStyle(o).getPropertyValue(t);return""!==l||ae(e)?l:_e(o,t)},_e=(e,t)=>Ae(e)?e.style.getPropertyValue(t):"",Oe=(e,t)=>{const o=e.dom,l=_e(o,t);return f.from(l).filter((e=>e.length>0))},De=(e,t,o=0)=>fe(e,t).map((e=>parseInt(e,10))).getOr(o),Ie=(e,t)=>Me(e,t,h),Me=(e,t,o)=>E(le(e),(e=>Q(e,t)?o(e)?[e]:[]:Me(e,t,o))),Ne=["tfoot","thead","tbody","colgroup"],Pe=(e,t,o)=>({element:e,rowspan:t,colspan:o}),ke=(e,t,o)=>({element:e,cells:t,section:o}),Be=(e,t)=>be(e,"table",t),Ee=e=>Ie(e,"tr"),Fe=e=>Be(e).fold(d([]),(e=>ce(e,"colgroup"))),qe=e=>te(e).map((e=>{const t=V(e);return(e=>O(Ne,e))(t)?t:"tbody"})).getOr("tbody"),Le=e=>fe(e,"data-snooker-locked-cols").bind((e=>f.from(e.match(/\d+/g)))).map((e=>((e,t)=>{const o={};for(let l=0,n=e.length;le+","+t,je=e=>{const t={},o=[];var l;const n=(l=e,q(l,0)).map((e=>e.element)).bind(Be).bind(Le).getOr({});let r=0,a=0,s=0;const{pass:c,fail:i}=((e,t)=>{const o=[],l=[];for(let t=0,r=e.length;t{const l=[];N(e.cells,(e=>{let o=0;for(;void 0!==t[He(s,o)];)o++;const r=A(n,o.toString()),c=((e,t,o,l,n,r)=>({element:e,rowspan:t,colspan:o,row:l,column:n,isLocked:r}))(e.element,e.rowspan,e.colspan,s,o,r);for(let l=0;lq(e,e.length-1))(c).map((e=>{const t=(e=>{const t={};let o=0;return N(e.cells,(e=>{const l=e.colspan;I(l,(n=>{const r=o+n;t[r]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,l,r)})),o+=l})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,((e,t)=>{const o=[];return S(e,((e,l)=>{o.push(t(e,l))})),o})(t,u));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),p=((e,t)=>({rows:e,columns:t}))(r,a);return{grid:p,access:t,all:o,columns:m,colgroups:d}},Ve=e=>{const t=(e=>{const t=Ee(e);return((e,t)=>M(e,(e=>{if("colgroup"===V(e)){const t=M((e=>Q(e,"colgroup")?ce(e,"col"):E(Fe(e),(e=>ce(e,"col"))))(e),(e=>{const t=De(e,"span",1);return Pe(e,1,t)}));return ke(e,t,"colgroup")}{const o=M((e=>Ie(e,"th,td"))(e),(e=>{const t=De(e,"rowspan",1),o=De(e,"colspan",1);return Pe(e,t,o)}));return ke(e,o,t(e))}})))([...Fe(e),...t],qe)})(e);return je(t)},ze=(e,t,o)=>f.from(e.access[He(t,o)]),We=(e,t,o)=>{const l=((e,t)=>{const o=E(e.all,(e=>e.cells));return P(o,t)})(e,(e=>o(t,e.element)));return l.length>0?f.some(l[0]):f.none()},$e=(e,t)=>f.from(e.columns[t]);var Ue=tinymce.util.Tools.resolve("tinymce.util.Tools");const Ge=(e,t,o)=>((t,l)=>{for(let n=0;n{o&&e.formatter.apply("align"+o,{},t)},Je=(e,t)=>{Ue.each("left center right".split(" "),(o=>{e.formatter.remove("align"+o,{},t)}))},Qe=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},Xe=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?f.none():f.some(t)})(e).getOr(t))(Re(e,t),o),Ye=e=>((e,t)=>{const o=e.dom,l=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?l:((e,t,o,l)=>t-Xe(e,"padding-left",0)-Xe(e,"padding-right",0)-Xe(e,"border-left-width",0)-Xe(e,"border-right-width",0))(e,l)})(e,"content-box");var Ze=tinymce.util.Tools.resolve("tinymce.Env");const et=I(5,(e=>{const t=`${e+1}px`;return{title:t,value:t}})),tt=M(["Solid","Dotted","Dashed","Double","Groove","Ridge","Inset","Outset","None","Hidden"],(e=>({title:e,value:e.toLowerCase()}))),ot=e=>t=>t.options.get(e),lt=ot("table_sizing_mode"),nt=ot("table_border_widths"),rt=ot("table_border_styles"),at=ot("table_default_attributes"),st=ot("table_cell_advtab"),ct=ot("table_row_advtab"),it=ot("table_advtab"),mt=ot("table_appearance_options"),dt=ot("table_grid"),ut=ot("table_style_by_css"),pt=ot("table_cell_class_list"),bt=ot("table_row_class_list"),gt=ot("table_class_list"),ht=ot("table_toolbar"),ft=ot("table_background_color_map"),yt=ot("table_border_color_map"),wt=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>{var o;if((e=>"fixed"===lt(e))(e)){const l=e.dom,n=null!==(o=l.getParent(e.selection.getStart(),l.isBlock))&&void 0!==o?o:e.getBody(),r=Ye(j.fromDom(n));return{...t,width:r+"px"}}return(e=>"responsive"===lt(e))(e)?C(t,((e,t)=>"width"!==t)):t})(e,o)},St=e=>t=>Y(t,(e=>j.fromDom(e.getBody()))(e)),Ct=e=>/^\d+(\.\d+)?$/.test(e)?e+"px":e,vt=e=>j.fromDom(e.selection.getStart()),Tt=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,xt=(e,t,o)=>((e,t,o)=>{const l=We(e,t,Y),n=We(e,o,Y);return l.bind((e=>n.map((t=>{return o=e,l=t,{startRow:Math.min(o.row,l.row),startCol:Math.min(o.column,l.column),finishRow:Math.max(o.row+o.rowspan-1,l.row+l.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,l.column+l.colspan-1)};var o,l}))))})(e,t,o).bind((t=>((e,t)=>{let o=!0;const l=b(Tt,t);for(let n=t.startRow;n<=t.finishRow;n++)for(let r=t.startCol;r<=t.finishCol;r++)o=o&&ze(e,n,r).exists(l);return o?f.some(t):f.none()})(e,t))),At=Ve,Rt=(e,t)=>{te(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},_t=(e,t)=>{oe(e).fold((()=>{te(e).each((e=>{Ot(e,t)}))}),(e=>{Rt(e,t)}))},Ot=(e,t)=>{e.dom.appendChild(t.dom)},Dt=(e,t)=>{N(t,((o,l)=>{const n=0===l?e:t[l-1];_t(n,o)}))},It=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Mt=((e,t)=>{const o=t=>e(t)?f.from(t.dom.nodeValue):f.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(U);var Nt=["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"];const Pt=(e,t,o,l)=>{const n=t(e,o);return r=(o,l)=>{const n=t(e,l);return kt(e,o,n)},a=n,((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(l,((e,t)=>{a=r(a,e)})),a;var r,a},kt=(e,t,o)=>t.bind((t=>o.filter(b(e.eq,t)))),Bt={up:d({selector:de,closest:be,predicate:me,all:(e,t)=>{const o=c(t)?t:g;let l=e.dom;const n=[];for(;null!==l.parentNode&&void 0!==l.parentNode;){const e=l.parentNode,t=j.fromDom(e);if(n.push(t),!0===o(t))break;l=e}return n}}),down:d({selector:ie,predicate:se}),styles:d({get:Re,getRaw:Oe,set:(e,t,o)=>{((e,t,o)=>{if(!l(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Ae(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},remove:(e,t)=>{((e,t)=>{Ae(e)&&e.style.removeProperty(t)})(e.dom,t),we(fe(e,"style").map(ve),"")&&ye(e,"style")}}),attrs:d({get:he,set:(e,t,o)=>{ge(e.dom,t,o)},remove:ye,copyTo:(e,t)=>{((e,t)=>{const o=e.dom;S(t,((e,t)=>{ge(o,t,e)}))})(t,k(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))}}),insert:d({before:Rt,after:_t,afterAll:Dt,append:Ot,appendAll:(e,t)=>{N(t,(t=>{Ot(e,t)}))},prepend:(e,t)=>{(e=>((e,t)=>{const o=e.dom.childNodes;return f.from(o[0]).map(j.fromDom)})(e))(e).fold((()=>{Ot(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},wrap:(e,t)=>{Rt(e,t),Ot(t,e)}}),remove:d({unwrap:e=>{const t=le(e);t.length>0&&Dt(e,t),It(e)},remove:It}),create:d({nu:j.fromTag,clone:e=>j.fromDom(e.dom.cloneNode(!1)),text:j.fromText}),query:d({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:e=>f.from(e.dom.previousSibling).map(j.fromDom),nextSibling:oe}),property:d({children:le,name:V,parent:te,document:e=>ee(e).dom,isText:U,isComment:e=>8===z(e)||"#comment"===V(e),isElement:$,isSpecial:e=>{const t=V(e);return O(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>$(e)?fe(e,"lang"):f.none(),getText:e=>Mt.get(e),setText:(e,t)=>Mt.set(e,t),isBoundary:e=>!!$(e)&&("body"===V(e)||O(Nt,V(e))),isEmptyTag:e=>!!$(e)&&O(["br","img","hr","input"],V(e)),isNonEditable:e=>$(e)&&"false"===he(e,"contenteditable")}),eq:Y,is:Z},Et=e=>de(e,"table"),Ft=(e,t,o)=>pe(e,t).bind((t=>pe(e,o).bind((e=>{return(o=Et,l=[t,e],((e,t,o)=>o.length>0?((e,t,o,l)=>l(e,t,o[0],o.slice(1)))(e,t,o,Pt):f.none())(Bt,((e,t)=>o(t)),l)).map((o=>({first:t,last:e,table:o})));var o,l})))),qt=e=>M(e,j.fromDom),Lt={selected:"data-mce-selected",selectedSelector:"td[data-mce-selected],th[data-mce-selected]",firstSelected:"data-mce-first-selected",firstSelectedSelector:"td[data-mce-first-selected],th[data-mce-first-selected]",lastSelected:"data-mce-last-selected",lastSelectedSelector:"td[data-mce-last-selected],th[data-mce-last-selected]"},Ht=e=>(t,o)=>{const l=V(t),n="col"===l||"colgroup"===l?Be(r=t).bind((e=>((e,t)=>((e,t)=>{const o=ie(e,t);return o.length>0?f.some(o):f.none()})(e,t))(e,Lt.firstSelectedSelector))).fold(d(r),(e=>e[0])):t;var r;return be(n,e,o)},jt=Ht("th,td,caption"),Vt=Ht("th,td"),zt=e=>qt(e.model.table.getSelectedCells()),Wt=(e,t)=>{const o=Vt(e),l=o.bind((e=>Be(e))).map((e=>Ee(e)));return Se(o,l,((e,o)=>P(o,(o=>D(qt(o.dom.cells),(o=>"1"===he(o,t)||Y(o,e))))))).getOr([])},$t=[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}],Ut=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Gt=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Kt=e=>{return(t=e,"#",Ce(t,"#")?((e,t)=>e.substring(t))(t,"#".length):t).toUpperCase();var t},Jt=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Qt=e=>({value:Jt(e.red)+Jt(e.green)+Jt(e.blue)}),Xt=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,Yt=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,Zt=(e,t,o,l)=>({red:e,green:t,blue:o,alpha:l}),eo=(e,t,o,l)=>{const n=parseInt(e,10),r=parseInt(t,10),a=parseInt(o,10),s=parseFloat(l);return Zt(n,r,a,s)},to=e=>{if("transparent"===e)return f.some(Zt(0,0,0,0));const t=Xt.exec(e);if(null!==t)return f.some(eo(t[1],t[2],t[3],"1"));const o=Yt.exec(e);return null!==o?f.some(eo(o[1],o[2],o[3],o[4])):f.none()},oo=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},lo=(e,t,o)=>l=>{const n=(e=>{const t=oo(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=>e.unbind())),r=!xe(o),a=()=>{const a=zt(e),s=l=>e.formatter.match(t,{value:o},l.dom,r);r?(l.setActive(!D(a,s)),n.set(e.formatter.formatChanged(t,(e=>l.setActive(!e)),!0))):(l.setActive(F(a,s)),n.set(e.formatter.formatChanged(t,l.setActive,!1,{value:o})))};return e.initialized?a():e.on("init",a),n.clear},no=e=>A(e,"menu"),ro=e=>M(e,(e=>{const t=e.text||e.title;return no(e)?{text:t,items:ro(e.menu)}:{text:t,value:e.value}})),ao=(e,t,o,l)=>M(t,(t=>{const n=t.text||t.title;return no(t)?{type:"nestedmenuitem",text:n,getSubmenuItems:()=>ao(e,t.menu,o,l)}:{text:n,type:"togglemenuitem",onAction:()=>l(t.value),onSetup:lo(e,o,t.value)}})),so=(e,t)=>o=>{e.execCommand("mceTableApplyCellStyle",!1,{[t]:o})},co=e=>E(e,(e=>no(e)?[{...e,menu:co(e.menu)}]:xe(e.value)?[e]:[])),io=(e,t,o,l)=>n=>n(ao(e,t,o,l)),mo=(e,t,o)=>{const l=M(t,(e=>{return{text:e.title,value:"#"+(o=e.value,(t=o,(e=>Ut.test(e)||Gt.test(e))(t)?f.some({value:Kt(t)}):f.none()).orThunk((()=>to(o).map(Qt))).getOrThunk((()=>{const e=document.createElement("canvas");e.height=1,e.width=1;const t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),t.fillStyle="#FFFFFF",t.fillStyle=o,t.fillRect(0,0,1,1);const l=t.getImageData(0,0,1,1).data,n=l[0],r=l[1],a=l[2],s=l[3];return Qt(Zt(n,r,a,s))}))).value,type:"choiceitem"};var t,o}));return[{type:"fancymenuitem",fancytype:"colorswatch",initData:{colors:l.length>0?l:void 0,allowCustomColors:!1},onAction:t=>{const l="remove"===t.value?"":t.value;e.execCommand("mceTableApplyCellStyle",!1,{[o]:l})}}]},uo=e=>()=>{const t="header"===e.queryCommandValue("mceTableRowType")?"body":"header";e.execCommand("mceTableRowType",!1,{type:t})},po=e=>()=>{const t="th"===e.queryCommandValue("mceTableColType")?"td":"th";e.execCommand("mceTableColType",!1,{type:t})},bo=[{name:"width",type:"input",label:"Width"},{name:"height",type:"input",label:"Height"},{name:"celltype",type:"listbox",label:"Cell type",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"listbox",label:"Scope",items:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{name:"halign",type:"listbox",label:"Horizontal align",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"listbox",label:"Vertical align",items:$t}],go=e=>bo.concat((e=>{const t=ro(pt(e));return t.length>0?f.some({name:"class",type:"listbox",label:"Class",items:t}):f.none()})(e).toArray()),ho=(e,t)=>{const o=[{name:"borderstyle",type:"listbox",label:"Border style",items:[{text:"Select...",value:""}].concat(ro(rt(e)))},{name:"bordercolor",type:"colorinput",label:"Border color"},{name:"backgroundcolor",type:"colorinput",label:"Background color"}];return{title:"Advanced",name:"advanced",items:"cell"===t?[{name:"borderwidth",type:"input",label:"Border width"}].concat(o):o}},fo=e=>(t,o)=>{const l=t.dom;return{setAttrib:(t,n)=>{e&&!n||l.setAttrib(o,t,n)},setStyle:(t,n)=>{e&&!n||l.setStyle(o,t,n)},setFormat:(l,n)=>{e&&!n||(""===n?t.formatter.remove(l,{value:null},o,!0):t.formatter.apply(l,{value:n},o))}}},yo={normal:fo(!1),ifTruthy:fo(!0)},wo=J("th"),So=(e,t)=>e&&t?"sectionCells":e?"section":"cells",Co=e=>{const t=M(e,(e=>(e=>{const t="thead"===e.section,o=we((e=>{const t=P(e,(e=>wo(e.element)));return 0===t.length?f.some("td"):t.length===e.length?f.some("th"):f.none()})(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:So(t,o)}:{type:"body"}})(e).type)),o=O(t,"header"),l=O(t,"footer");if(o||l){const e=O(t,"body");return!o||e||l?o||e||!l?f.none():f.some("footer"):f.some("header")}return f.some("body")},vo=(e,t)=>L(e.all,(e=>B(e.cells,(e=>Y(t,e.element))))),To=(e,t,o)=>{const l=(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t{return(l=t,((e,t,o=g)=>o(t)?f.none():O(e,V(t))?f.some(t):de(t,e.join(","),(e=>Q(e,"table")||o(e))))(["td","th"],l,n)).bind((t=>vo(e,t))).filter(o);var l,n})));return n=l,l.length>0?f.some(n):f.none();var n},xo=(e,t)=>To(e,t,h),Ao=(e,t)=>F(t,(t=>((e,t)=>vo(e,t).exists((e=>!e.isLocked)))(e,t))),Ro=(e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>Ao(e,t.cells))),_o=(e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>Ao(e,t))),Oo=((e=>{if(!n(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={};N(e,((l,r)=>{const a=y(l);if(1!==a.length)throw new Error("one and only one name per case");const s=a[0],c=l[s];if(void 0!==o[s])throw new Error("duplicate key detected:"+s);if("cata"===s)throw new Error("cannot have a case named cata (sorry)");if(!n(c))throw new Error("case arguments must be an array");t.push(s),o[s]=(...o)=>{const l=o.length;if(l!==c.length)throw new Error("Wrong number of arguments to case "+s+". Expected "+c.length+" ("+c+"), got "+l);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 l=y(e);if(t.length!==l.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+l.join(","));if(!F(t,(e=>O(l,e))))throw new Error("Not all branches were specified when using match. Specified: "+l.join(", ")+"\nRequired: "+t.join(", "));return e[s].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:s,params:o})}}}}))})([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}]),(e,t)=>{const o=Ve(e);return xo(o,t).bind((e=>{const t=e[e.length-1],l=e[0].row,n=t.row+t.rowspan,r=o.all.slice(l,n);return Co(r)})).getOr("")}),Do=e=>{return Ce(e,"rgb")?to(t=e).map(Qt).map((e=>"#"+e.value)).getOr(t):e;var t},Io=e=>{const t=j.fromDom(e);return{borderwidth:Oe(t,"border-width").getOr(""),borderstyle:Oe(t,"border-style").getOr(""),bordercolor:Oe(t,"border-color").map(Do).getOr(""),backgroundcolor:Oe(t,"background-color").map(Do).getOr("")}},Mo=e=>{const t=e[0],o=e.slice(1);return N(o,(e=>{N(y(t),(o=>{S(e,((e,l)=>{const n=t[o];""!==n&&o===l&&n!==e&&(t[o]="")}))}))})),t},No=(e,t,o,l)=>B(e,(e=>!a(o.formatter.matchNode(l,t+e)))).getOr(""),Po=b(No,["left","center","right"],"align"),ko=b(No,["top","middle","bottom"],"valign"),Bo=e=>Be(j.fromDom(e)).map((t=>{const o={selection:qt(e.cells)};return Oo(t,o)})).getOr(""),Eo=(e,t)=>{const o=Ve(e),l=(e=>E(e.all,(e=>e.cells)))(o),n=P(l,(e=>D(t,(t=>Y(e.element,t)))));return M(n,(e=>({element:e.element.dom,column:$e(o,e.column).map((e=>e.element.dom))})))},Fo=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact((()=>{((e,t,o,l)=>{const n=C(l,((e,t)=>o[t]!==e));v(n)>0&&t.length>=1&&Be(t[0]).each((o=>{const r=Eo(o,t),a=v(C(n,((e,t)=>"scope"!==t&&"celltype"!==t)))>0,s=x(n,"celltype");(a||x(n,"scope"))&&((e,t,o)=>{const l=1===t.length;N(t,(t=>{const n=t.element,r=l?yo.normal(e,n):yo.ifTruthy(e,n);((e,t,o)=>{e.setAttrib("scope",o.scope),e.setAttrib("class",o.class),e.setStyle("height",Ct(o.height)),t.setStyle("width",Ct(o.width))})(r,t.column.map((t=>l?yo.normal(e,t):yo.ifTruthy(e,t))).getOr(r),o),st(e)&&((e,t)=>{e.setFormat("tablecellbackgroundcolor",t.backgroundcolor),e.setFormat("tablecellbordercolor",t.bordercolor),e.setFormat("tablecellborderstyle",t.borderstyle),e.setFormat("tablecellborderwidth",Ct(t.borderwidth))})(r,o),l&&(Je(e,n),((e,t)=>{Ue.each("top middle bottom".split(" "),(o=>{e.formatter.remove("valign"+o,{},t)}))})(e,n)),o.halign&&Ke(e,n,o.halign),o.valign&&((e,t,o)=>{o&&e.formatter.apply("valign"+o,{},t)})(e,n,o.valign)}))})(e,r,l),s&&((e,t)=>{e.execCommand("mceTableCellType",!1,{type:t.celltype,no_events:!0})})(e,l),Qe(e,o.dom,{structure:s,style:a})}))})(e,t,o,n),e.focus()}))},qo=e=>{const t=zt(e);if(0===t.length)return;const o=((e,t)=>{const o=Be(t[0]).map((o=>M(Eo(o,t),(t=>((e,t,o,l)=>{const n=e.dom,r=(e,t)=>n.getStyle(e,t)||n.getAttrib(e,t);return{width:r(l.getOr(t),"width"),height:r(t,"height"),scope:n.getAttrib(t,"scope"),celltype:(a=t,a.nodeName.toLowerCase()),class:n.getAttrib(t,"class",""),halign:Po(e,t),valign:ko(e,t),...o?Io(t):{}};var a})(e,t.element,st(e),t.column)))));return Mo(o.getOrDie())})(e,t),l={type:"tabpanel",tabs:[{title:"General",name:"general",items:go(e)},ho(e,"cell")]},n={type:"panel",items:[{type:"grid",columns:2,items:go(e)}]};e.windowManager.open({title:"Cell Properties",size:"normal",body:st(e)?l:n,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o,onSubmit:b(Fo,e,t,o)})},Lo=[{type:"listbox",name:"type",label:"Row type",items:[{text:"Header",value:"header"},{text:"Body",value:"body"},{text:"Footer",value:"footer"}]},{type:"listbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height",type:"input"}],Ho=e=>Lo.concat((e=>{const t=ro(bt(e));return t.length>0?f.some({name:"class",type:"listbox",label:"Class",items:t}):f.none()})(e).toArray()),jo=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact((()=>{((e,t,o,l)=>{const n=C(l,((e,t)=>o[t]!==e));if(v(n)>0){const r=x(n,"type"),a=!r||v(n)>1;a&&((e,t,o,l)=>{const n=1===t.length;N(t,(t=>{const r=n?yo.normal(e,t):yo.ifTruthy(e,t);((e,t)=>{e.setAttrib("class",t.class),e.setStyle("height",Ct(t.height))})(r,o),ct(e)&&((e,t)=>{e.setStyle("background-color",t.backgroundcolor),e.setStyle("border-color",t.bordercolor),e.setStyle("border-style",t.borderstyle)})(r,o),o.align!==l.align&&(Je(e,t),Ke(e,t,o.align))}))})(e,t,l,o),r&&((e,t)=>{e.execCommand("mceTableRowType",!1,{type:t.type,no_events:!0})})(e,l),Be(j.fromDom(t[0])).each((t=>Qe(e,t.dom,{structure:r,style:a})))}})(e,t,o,n),e.focus()}))},Vo=e=>{const t=Wt(vt(e),Lt.selected);if(0===t.length)return;const o=M(t,(t=>((e,t,o)=>{const l=e.dom;return{height:l.getStyle(t,"height")||l.getAttrib(t,"height"),class:l.getAttrib(t,"class",""),type:Bo(t),align:Po(e,t),...o?Io(t):{}}})(e,t.dom,ct(e)))),l=Mo(o),n={type:"tabpanel",tabs:[{title:"General",name:"general",items:Ho(e)},ho(e,"row")]},r={type:"panel",items:[{type:"grid",columns:2,items:Ho(e)}]};e.windowManager.open({title:"Row Properties",size:"normal",body:ct(e)?n:r,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:l,onSubmit:b(jo,e,M(t,(e=>e.dom)),l)})},zo=(e,t,o)=>{const l=o?[{type:"input",name:"cols",label:"Cols",inputMode:"numeric"},{type:"input",name:"rows",label:"Rows",inputMode:"numeric"}]:[],n=mt(e)?[{type:"input",name:"cellspacing",label:"Cell spacing",inputMode:"numeric"},{type:"input",name:"cellpadding",label:"Cell padding",inputMode:"numeric"},{type:"input",name:"border",label:"Border width"},{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[],r=t.length>0?[{type:"listbox",name:"class",label:"Class",items:t}]:[];return l.concat([{type:"input",name:"width",label:"Width"},{type:"input",name:"height",label:"Height"}]).concat(n).concat([{type:"listbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]).concat(r)},Wo=(e,t,o,n)=>{if("TD"===t.tagName||"TH"===t.tagName)l(o)?e.setStyle(t,o,n):e.setStyles(t,o);else if(t.children)for(let l=0;l{const n=e.dom,r=l.getData(),a=C(r,((e,t)=>o[t]!==e));l.close(),""===r.class&&delete r.class,e.undoManager.transact((()=>{if(!t){const o=parseInt(r.cols,10)||1,l=parseInt(r.rows,10)||1;e.execCommand("mceInsertTable",!1,{rows:l,columns:o}),t=Vt(vt(e),St(e)).bind((t=>Be(t,St(e)))).map((e=>e.dom)).getOrUndefined()}if(v(a)>0){((e,t,o)=>{const l=e.dom,n={},r={};if(n.class=o.class,r.height=Ct(o.height),l.getAttrib(t,"width")&&!ut(e)?n.width=(e=>e?e.replace(/px$/,""):"")(o.width):r.width=Ct(o.width),ut(e)?(r["border-width"]=Ct(o.border),r["border-spacing"]=Ct(o.cellspacing)):(n.border=o.border,n.cellpadding=o.cellpadding,n.cellspacing=o.cellspacing),ut(e)&&t.children)for(let n=0;n0){const o=x(a,"caption"),l=!o||v(a)>1;Qe(e,t,{structure:o,style:l})}}))},Uo=(e,t)=>{const o=e.dom;let l,n=((e,t)=>{const o=wt(e),l=at(e),n=t?{borderstyle:T(o,"border-style").getOr(""),bordercolor:Do(T(o,"border-color").getOr("")),backgroundcolor:Do(T(o,"background-color").getOr(""))}:{};return{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,class:"",align:"",border:"",...o,...l,...n,...(()=>{const t=o["border-width"];return ut(e)&&t?{border:t}:T(l,"border").fold((()=>({})),(e=>({border:e})))})(),...{...T(o,"border-spacing").or(T(l,"cellspacing")).fold((()=>({})),(e=>({cellspacing:e}))),...T(o,"border-padding").or(T(l,"cellpadding")).fold((()=>({})),(e=>({cellpadding:e})))}}})(e,it(e));!1===t?(l=o.getParent(e.selection.getStart(),"table",e.getBody()),l?n=((e,t,o)=>{const l=e.dom,n=ut(e)?l.getStyle(t,"border-spacing")||l.getAttrib(t,"cellspacing"):l.getAttrib(t,"cellspacing")||l.getStyle(t,"border-spacing"),r=ut(e)?Ge(l,t,"padding")||l.getAttrib(t,"cellpadding"):l.getAttrib(t,"cellpadding")||Ge(l,t,"padding");return{width:l.getStyle(t,"width")||l.getAttrib(t,"width"),height:l.getStyle(t,"height")||l.getAttrib(t,"height"),cellspacing:n,cellpadding:r,border:((t,o)=>{const l=Oe(j.fromDom(o),"border-width");return ut(e)&&l.isSome()?l.getOr(""):t.getAttrib(o,"border")||Ge(e.dom,o,"border-width")||Ge(e.dom,o,"border")})(l,t),caption:!!l.select("caption",t)[0],class:l.getAttrib(t,"class",""),align:Po(e,t),...o?Io(t):{}}})(e,l,it(e)):it(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor="")):(n.cols="1",n.rows="1",it(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor=""));const r=ro(gt(e));r.length>0&&n.class&&(n.class=n.class.replace(/\s*mce\-item\-table\s*/g,""));const a={type:"grid",columns:2,items:zo(e,r,t)},s=it(e)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[a]},ho(e,"table")]}:{type:"panel",items:[a]};e.windowManager.open({title:"Table Properties",size:"normal",body:s,onSubmit:b($o,e,l,n),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:n})},Go=u,Ko=e=>{const t=(e,t)=>fe(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&F(e,(e=>t(e,"rowspan")||t(e,"colspan")))?f.some(e):f.none()},Jo=(e,t,o)=>{return t.length<=1?f.none():(l=e,n=o.firstSelectedSelector,r=o.lastSelectedSelector,Ft(l,n,r).bind((e=>{const t=e=>Y(l,e),o="thead,tfoot,tbody,table",n=de(e.first,o,t),r=de(e.last,o,t);return n.bind((t=>r.bind((o=>Y(t,o)?((e,t,o)=>{const l=At(e);return xt(l,t,o)})(e.table,e.first,e.last):f.none()))))}))).map((e=>({bounds:e,cells:t})));var l,n,r},Qo=e=>{const t=oo(f.none()),o=oo([]);let l=f.none();const n=J("caption"),r=e=>l.forall((t=>!t[e])),a=()=>jt(vt(e),St(e)).bind((t=>{return o=Se(Be(t),jt((e=>j.fromDom(e.selection.getEnd()))(e),St(e)).bind(Be),((o,l)=>Y(o,l)?n(t)?f.some((e=>({element:e,mergable:f.none(),unmergable:f.none(),selection:[e]}))(t)):f.some(((e,t,o)=>({element:o,mergable:Jo(t,e,Lt),unmergable:Ko(e),selection:Go(e)}))(zt(e),o,t)):f.none())),o.bind(u);var o})),s=e=>Be(e.element).map((t=>{const o=Ve(t),l=xo(o,e).getOr([]),n=k(l,((e,t)=>(t.isLocked&&(e.onAny=!0,0===t.column?e.onFirst=!0:t.column+t.colspan>=o.grid.columns&&(e.onLast=!0)),e)),{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:Ro(o,e).isSome(),unmergeable:_o(o,e).isSome(),locked:n}})),c=()=>{t.set((e=>{let t,o=!1;return(...l)=>(o||(o=!0,t=e.apply(null,l)),t)})(a)()),l=t.get().bind(s),N(o.get(),(e=>e()))},i=e=>(e(),o.set(o.get().concat([e])),()=>{o.set(P(o.get(),(t=>t!==e)))}),m=(e,o)=>i((()=>t.get().fold((()=>{e.setEnabled(!1)}),(t=>{e.setEnabled(!o(t))})))),d=(e,o,l)=>i((()=>t.get().fold((()=>{e.setEnabled(!1),e.setActive(!1)}),(t=>{e.setEnabled(!o(t)),e.setActive(l(t))})))),p=e=>l.exists((t=>t.locked[e])),b=(t,o)=>l=>d(l,(e=>n(e.element)),(()=>e.queryCommandValue(t)===o)),h=b("mceTableRowType","header"),y=b("mceTableColType","th");return e.on("NodeChange ExecCommand TableSelectorChange",c),{onSetupTable:e=>m(e,(e=>!1)),onSetupCellOrRow:e=>m(e,(e=>n(e.element))),onSetupColumn:e=>t=>m(t,(t=>n(t.element)||p(e))),onSetupPasteable:e=>t=>m(t,(t=>n(t.element)||e().isNone())),onSetupPasteableColumn:(e,t)=>o=>m(o,(o=>n(o.element)||e().isNone()||p(t))),onSetupMergeable:e=>m(e,(e=>r("mergeable"))),onSetupUnmergeable:e=>m(e,(e=>r("unmergeable"))),resetTargets:c,onSetupTableWithCaption:t=>d(t,g,(t=>Be(t.element,St(e)).exists((e=>ue(e,"caption").isSome())))),onSetupTableRowHeaders:h,onSetupTableColumnHeaders:y,targets:t.get}};var Xo=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const Yo=e=>{var t;const o=null!==(t=Xo.read())&&void 0!==t?t:[];return L(o,(t=>f.from(t.getType(e))))},Zo=()=>Yo("x-tinymce/dom-table-rows"),el=()=>Yo("x-tinymce/dom-table-columns");e.add("table",(e=>{const t=Qo(e);(e=>{const t=e.options.register;t("table_border_widths",{processor:"object[]",default:et}),t("table_border_styles",{processor:"object[]",default:tt}),t("table_cell_advtab",{processor:"boolean",default:!0}),t("table_row_advtab",{processor:"boolean",default:!0}),t("table_advtab",{processor:"boolean",default:!0}),t("table_appearance_options",{processor:"boolean",default:!0}),t("table_grid",{processor:"boolean",default:!Ze.deviceType.isTouch()}),t("table_style_by_css",{processor:"boolean",default:!0}),t("table_cell_class_list",{processor:"object[]",default:[]}),t("table_row_class_list",{processor:"object[]",default:[]}),t("table_class_list",{processor:"object[]",default:[]}),t("table_toolbar",{processor:"string",default:"tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"}),t("table_background_color_map",{processor:"object[]",default:[]}),t("table_border_color_map",{processor:"object[]",default:[]})})(e),(e=>{S({mceTableProps:b(Uo,e,!1),mceTableRowProps:b(Vo,e),mceTableCellProps:b(qo,e)},((t,o)=>e.addCommand(o,(()=>t())))),e.addCommand("mceInsertTableDialog",(t=>{Uo(e,!0)}))})(e),((e,t)=>{const o=t=>()=>e.execCommand(t),l=(t,l)=>!!e.queryCommandSupported(l.command)&&(e.ui.registry.addMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)}),!0),n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},r=t=>{e.execCommand("mceInsertTable",!1,{rows:t.numRows,columns:t.numColumns})},a=[l("tableinsertrowbefore",{text:"Insert row before",icon:"table-insert-row-above",command:"mceTableInsertRowBefore",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",command:"mceTableInsertRowAfter",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{text:"Delete row",icon:"table-delete-row",command:"mceTableDeleteRow",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{text:"Row properties",icon:"table-row-properties",command:"mceTableRowProps",onSetup:t.onSetupCellOrRow}),l("tablecutrow",{text:"Cut row",icon:"cut-row",command:"mceTableCutRow",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{text:"Copy row",icon:"duplicate-row",command:"mceTableCopyRow",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",command:"mceTablePasteRowBefore",onSetup:t.onSetupPasteable(Zo)}),l("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",command:"mceTablePasteRowAfter",onSetup:t.onSetupPasteable(Zo)})],s=[l("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",command:"mceTableInsertColBefore",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",command:"mceTableInsertColAfter",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",command:"mceTableDeleteCol",onSetup:t.onSetupColumn("onAny")}),l("tablecutcolumn",{text:"Cut column",icon:"cut-column",command:"mceTableCutCol",onSetup:t.onSetupColumn("onAny")}),l("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",command:"mceTableCopyCol",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolumnbefore",{text:"Paste column before",icon:"paste-column-before",command:"mceTablePasteColBefore",onSetup:t.onSetupPasteableColumn(el,"onFirst")}),l("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",command:"mceTablePasteColAfter",onSetup:t.onSetupPasteableColumn(el,"onLast")})],i=[l("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",command:"mceTableCellProps",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",command:"mceTableMergeCells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{text:"Split cell",icon:"table-split-cells",command:"mceTableSplitCells",onSetup:t.onSetupUnmergeable})];dt(e)?e.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"inserttable",onAction:r}]}):e.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:o("mceInsertTableDialog")}),e.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:o("mceInsertTableDialog")}),l("tableprops",{text:"Table properties",onSetup:t.onSetupTable,command:"mceTableProps"}),l("deletetable",{text:"Delete table",icon:"table-delete-table",onSetup:t.onSetupTable,command:"mceTableDelete"}),O(a,!0)&&e.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:d("tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter")}),O(s,!0)&&e.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:d("tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter")}),O(i,!0)&&e.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:d("tablecellprops tablemergecells tablesplitcells")}),e.ui.registry.addContextMenu("table",{update:()=>(t.resetTargets(),t.targets().fold(d(""),(e=>"caption"===V(e.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable")))});const m=co(gt(e));0!==m.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addNestedMenuItem("tableclass",{icon:"table-classes",text:"Table styles",getSubmenuItems:()=>ao(e,m,"tableclass",(t=>e.execCommand("mceTableToggleClass",!1,t))),onSetup:t.onSetupTable});const u=co(pt(e));0!==u.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addNestedMenuItem("tablecellclass",{icon:"table-cell-classes",text:"Cell styles",getSubmenuItems:()=>ao(e,u,"tablecellclass",(t=>e.execCommand("mceTableCellToggleClass",!1,t))),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addNestedMenuItem("tablecellvalign",{icon:"vertical-align",text:"Vertical align",getSubmenuItems:()=>ao(e,$t,"tablecellverticalalign",so(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderwidth",{icon:"border-width",text:"Border width",getSubmenuItems:()=>ao(e,nt(e),"tablecellborderwidth",so(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderstyle",{icon:"border-style",text:"Border style",getSubmenuItems:()=>ao(e,rt(e),"tablecellborderstyle",so(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbackgroundcolor",{icon:"cell-background-color",text:"Background color",getSubmenuItems:()=>mo(e,ft(e),"background-color"),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbordercolor",{icon:"cell-border-color",text:"Border color",getSubmenuItems:()=>mo(e,yt(e),"border-color"),onSetup:t.onSetupCellOrRow})),n("tablecaption",{icon:"table-caption",text:"Table caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{text:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:uo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{text:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:po(e),onSetup:t.onSetupTableRowHeaders})})(e,t),((e,t)=>{e.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",fetch:e=>e("inserttable | cell row column | advtablesort | tableprops deletetable")});const o=t=>()=>e.execCommand(t),l=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})};l("tableprops",{tooltip:"Table properties",command:"mceTableProps",icon:"table",onSetup:t.onSetupTable}),l("tabledelete",{tooltip:"Delete table",command:"mceTableDelete",icon:"table-delete-table",onSetup:t.onSetupTable}),l("tablecellprops",{tooltip:"Cell properties",command:"mceTableCellProps",icon:"table-cell-properties",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{tooltip:"Merge cells",command:"mceTableMergeCells",icon:"table-merge-cells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{tooltip:"Split cell",command:"mceTableSplitCells",icon:"table-split-cells",onSetup:t.onSetupUnmergeable}),l("tableinsertrowbefore",{tooltip:"Insert row before",command:"mceTableInsertRowBefore",icon:"table-insert-row-above",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{tooltip:"Insert row after",command:"mceTableInsertRowAfter",icon:"table-insert-row-after",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{tooltip:"Delete row",command:"mceTableDeleteRow",icon:"table-delete-row",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{tooltip:"Row properties",command:"mceTableRowProps",icon:"table-row-properties",onSetup:t.onSetupCellOrRow}),l("tableinsertcolbefore",{tooltip:"Insert column before",command:"mceTableInsertColBefore",icon:"table-insert-column-before",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolafter",{tooltip:"Insert column after",command:"mceTableInsertColAfter",icon:"table-insert-column-after",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecol",{tooltip:"Delete column",command:"mceTableDeleteCol",icon:"table-delete-column",onSetup:t.onSetupColumn("onAny")}),l("tablecutrow",{tooltip:"Cut row",command:"mceTableCutRow",icon:"cut-row",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{tooltip:"Copy row",command:"mceTableCopyRow",icon:"duplicate-row",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{tooltip:"Paste row before",command:"mceTablePasteRowBefore",icon:"paste-row-before",onSetup:t.onSetupPasteable(Zo)}),l("tablepasterowafter",{tooltip:"Paste row after",command:"mceTablePasteRowAfter",icon:"paste-row-after",onSetup:t.onSetupPasteable(Zo)}),l("tablecutcol",{tooltip:"Cut column",command:"mceTableCutCol",icon:"cut-column",onSetup:t.onSetupColumn("onAny")}),l("tablecopycol",{tooltip:"Copy column",command:"mceTableCopyCol",icon:"duplicate-column",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolbefore",{tooltip:"Paste column before",command:"mceTablePasteColBefore",icon:"paste-column-before",onSetup:t.onSetupPasteableColumn(el,"onFirst")}),l("tablepastecolafter",{tooltip:"Paste column after",command:"mceTablePasteColAfter",icon:"paste-column-after",onSetup:t.onSetupPasteableColumn(el,"onLast")}),l("tableinsertdialog",{tooltip:"Insert table",command:"mceInsertTableDialog",icon:"table"});const r=co(gt(e));0!==r.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addMenuButton("tableclass",{icon:"table-classes",tooltip:"Table styles",fetch:io(e,r,"tableclass",(t=>e.execCommand("mceTableToggleClass",!1,t))),onSetup:t.onSetupTable});const a=co(pt(e));0!==a.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addMenuButton("tablecellclass",{icon:"table-cell-classes",tooltip:"Cell styles",fetch:io(e,a,"tablecellclass",(t=>e.execCommand("mceTableCellToggleClass",!1,t))),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addMenuButton("tablecellvalign",{icon:"vertical-align",tooltip:"Vertical align",fetch:io(e,$t,"tablecellverticalalign",so(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderwidth",{icon:"border-width",tooltip:"Border width",fetch:io(e,nt(e),"tablecellborderwidth",so(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderstyle",{icon:"border-style",tooltip:"Border style",fetch:io(e,rt(e),"tablecellborderstyle",so(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbackgroundcolor",{icon:"cell-background-color",tooltip:"Background color",fetch:t=>t(mo(e,ft(e),"background-color")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbordercolor",{icon:"cell-border-color",tooltip:"Border color",fetch:t=>t(mo(e,yt(e),"border-color")),onSetup:t.onSetupCellOrRow})),n("tablecaption",{tooltip:"Table caption",icon:"table-caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{tooltip:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:uo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{tooltip:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:po(e),onSetup:t.onSetupTableColumnHeaders})})(e,t),(e=>{const t=ht(e);t.length>0&&e.ui.registry.addContextToolbar("table",{predicate:t=>e.dom.is(t,"table")&&e.getBody().contains(t),items:t,scope:"node",position:"node"})})(e)}))}();