diff --git a/plugins/a11ychecker/plugin.min.js b/plugins/a11ychecker/plugin.min.js new file mode 100644 index 0000000..38c0250 --- /dev/null +++ b/plugins/a11ychecker/plugin.min.js @@ -0,0 +1,10 @@ +/* ! + * Tiny Accessibility Checker Plugin + * + * Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc. + * Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/ + * + * Version: 3.2.1-70 + */ + +!function(){"use strict";const e=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=o=e,(a=String).prototype.isPrototypeOf(r)||(null===(n=o.constructor)||void 0===n?void 0:n.name)===a.name)?"string":t;var r,o,a,n})(t)===e,r=e=>t=>typeof t===e,o=t("string"),a=t("object"),n=t("array"),i=r("boolean"),s=(void 0,e=>undefined===e);const l=e=>!(e=>null==e)(e),c=r("function"),u=r("number"),d=()=>{},p=e=>()=>e,h=e=>e,m=(e,t)=>e===t,y=e=>e(),g=p(!1),v=p(!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 l(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 b=e=>parseInt(e,10),f=(e,t)=>{const r=e-t;return 0===r?0:r>0?1:-1},k=(e,t,r)=>({major:e,minor:t,patch:r}),x=e=>{const t=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(e);return t?k(b(t[1]),b(t[2]),b(t[3])):k(0,0,0)},A=Array.prototype.slice,C=Array.prototype.indexOf,T=Array.prototype.push,D=(e,t)=>((e,t)=>C.call(e,t))(e,t)>-1,I=(e,t)=>{for(let r=0,o=e.length;r{const r=e.length,o=new Array(r);for(let a=0;a{for(let r=0,o=e.length;r{const r=[];for(let o=0,a=e.length;o(N(e,((e,o)=>{r=t(r,e,o)})),r),O=(e,t,r)=>{for(let o=0,a=e.length;oO(e,t,g),R=(e,t)=>(e=>{const t=[];for(let r=0,o=e.length;r{const t=A.call(e,0);return t.reverse(),t},H=p("html4"),q=p("html5"),$=p("a"),G=p("aa"),P=p("aaa"),L=e=>t=>t.options.get(e),j=L("a11ychecker_css_url"),B=L("a11ychecker_level"),V=L("a11ychecker_html_version"),F=L("a11ychecker_issue_url_callback"),z=L("a11ychecker_filter_issue"),U=e=>{var t;return null!==(t=e.options.get("a11ychecker_allow_decorative_images"))&&void 0!==t?t:e.options.get("a11y_advanced_options")},K=tinymce.util.I18n,J={"a11y.d1.description":"This paragraph looks like a heading. If it is a heading, please select a heading level.","a11y.d1.repair.block.h1":"Heading 1","a11y.d1.repair.block.h2":"Heading 2","a11y.d1.repair.block.h3":"Heading 3","a11y.d1.repair.block.h4":"Heading 4","a11y.d1.repair.block.h5":"Heading 5","a11y.d1.repair.block.h6":"Heading 6","a11y.d1.repair.info":"Select a heading level:","a11y.d2.description":"Headings must be applied in sequential order. For example: Heading 1 should be followed by Heading 2, not Heading 3.","a11y.d3.description":"Adjacent links with the same URL should be merged into one link","a11y.d4.description":"The selected text appears to be a list. Lists should be formatted using a list tag.","a11y.d5a.description":"Large text must have a contrast ratio of at least 3:1","a11y.d5b.description":"Text must have a contrast ratio of at least 4.5:1","a11y.d5c.description":"Text must have a contrast ratio of at least 7:1","a11y.h93.description":"ID attribute must be unique","a11y.h93.repair.info":"Make ID unique","a11y.h93.repair.deduplicate.others":"Keep this ID and remove all others","a11y.h93.repair.deduplicate.this":"Remove this ID","a11y.h93.repair.deduplicate.all":"Remove all IDs","a11y.i1.description.decorativeAllowed":"Images must be marked as decorative or have an alternative text description","a11y.i1.description.decorativeNotAllowed":"Images must have an alternative text description. Decorative images are not allowed.","a11y.i1.repair.errors.duplicate":"Alternative text cannot be the same as the filename","a11y.i1.repair.errors.empty":"Alternative text cannot be empty","a11y.i1.repair.info.decorativeAllowed":"Or provide alternative text:","a11y.i1.repair.info.decorativeNotAllowed":"Provide alternative text:","a11y.i1.repair.checkboxlabel":"Make image decorative:","a11y.i1.repair.checkboxtext":"Image is decorative","a11y.i2.description":"Alternative text must not be the same as the image filename","a11y.i2.repair.info":"Provide alternative text:","a11y.i3.description":"Image alternative text should be less than 100 characters","a11y.i3.repair.error":"Alternative text is {0} characters","a11y.t1.description":"Tables must have captions","a11y.t1.repair.errors.duplicate":"Table caption cannot be the same as the table summary","a11y.t1.repair.errors.empty":"Caption cannot be empty","a11y.t1.repair.info":"Provide caption:","a11y.t2.description":"Complex tables should have summaries","a11y.t2.repair.errors.duplicate":"Table summary cannot be the same as the table caption","a11y.t2.repair.errors.empty":"Summary cannot be empty","a11y.t2.repair.info":"Provide table summary:","a11y.t3.description":"Table caption and summary cannot have the same value","a11y.t4a.description":"Table elements must contain TR and TD tags","a11y.t4b.description":"Tables must have at least one header cell","a11y.t4b.repair.info":"Choose table header:","a11y.t4c.description":"Table headers must be applied to a row or a column","a11y.t4c.repair.header.col":"Header column","a11y.t4c.repair.header.row":"Header row","a11y.t4c.repair.info":"Select header scope:","a11y.t4c.repair.scope.col":"Column","a11y.t4c.repair.scope.colgroup":"Column group","a11y.t4c.repair.scope.row":"Row","a11y.t4c.repair.scope.rowgroup":"Row group","a11y.widget.counter":"Issue {0} of {1}","a11y.widget.ignore":"Ignore","a11y.widget.issue.none":"No accessibility issues detected","a11y.widget.next":"Next issue","a11y.widget.previous":"Previous issue","a11y.widget.legacyrepair":"Repair issue","a11y.widget.repair":"Repair","a11y.widget.title":"Accessibility Checker","a11y.widget.help.title":"Click for more info","a11y.control.tooltip":"Accessibility checker","a11y.control.menutext":"Accessibility checker...",error:"Error",warning:"Warning",info:"Info",success:"Success"},Q=e=>J[e],X=e=>Array.isArray(e)?K.translate([Q(e[0]),...e.slice(1)]):K.translate(Q(e)),Y=Object.keys,Z=Object.hasOwnProperty,ee=(e,t)=>{const r=Y(e);for(let o=0,a=r.length;o(t,r)=>{e[r]=t},re=(e,t)=>Z.call(e,t),oe="undefined"!=typeof window?window:Function("return this;")(),ae=(e,t)=>((e,t)=>{let r=null!=t?t:oe;for(let t=0;t{const t=ae("ownerDocument.defaultView",e);return a(e)&&((e=>((e,t)=>{const r=((e,t)=>ae(e,t))(e,t);if(null==r)throw new Error(e+" not available on this browser");return r})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(ne(e).constructor.name))},se=e=>t=>(e=>e.dom.nodeType)(t)===e,le=e=>ce(e)&&ie(e.dom),ce=se(1),ue=se(3),de=se(9),pe=se(11),he=e=>t=>ce(t)&&t.dom.nodeName.toLowerCase()===e,me=(e,t,r)=>{((e,t,r)=>{if(!(o(r)||i(r)||u(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)},ye=(e,t)=>{const r=e.dom.getAttribute(t);return null===r?void 0:r},ge=(e,t)=>w.from(ye(e,t)),ve=(e,t)=>{e.dom.removeAttribute(t)},we=(e=>{const t="ephox-foam".replace(/\./g,"-");return{resolve:e=>t+"-"+e}})().resolve,be=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},fe=(e,t)=>{const r=(t||document).createElement(e);return be(r)},ke=be,xe=(e,t)=>{const r=e.dom;if(1!==r.nodeType)return!1;{const e=r;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")}},Ae=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Ce=(e,t)=>e.dom===t.dom,Te=e=>ke(e.dom.ownerDocument),De=e=>w.from(e.dom.parentNode).map(ke),Ie=e=>w.from(e.dom.previousSibling).map(ke),_e=e=>W(((e,t)=>{const r=[],o=e=>(r.push(e),t(e));let a=t(e);do{a=a.bind(o)}while(a.isSome());return r})(e,Ie)),Ne=e=>_(e.dom.childNodes,ke),Se=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>ke(e.dom.getRootNode()):e=>de(e)?e:Te(e),Me=e=>ke(e.dom.host),Oe=e=>{const t=ue(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const r=t.ownerDocument;return(e=>{const t=Se(e);return pe(r=t)&&l(r.dom.host)?w.some(t):w.none();var r})(ke(t)).fold((()=>r.body.contains(t)),(o=Oe,a=Me,e=>o(a(e))));var o,a},Ee=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return ke(t)},Re=(e,t)=>((e,r)=>S(Ne(e),(e=>xe(e,t))))(e),We=(e,t)=>((e,t)=>{const r=void 0===t?document:t.dom;return Ae(r)?[]:_(r.querySelectorAll(e),ke)})(t,e),He=(e,t,r)=>{me(e,t,r)},qe=(e,t,r)=>{ve(e,t),ve(e,r)},$e=e=>{const t=e.editor;return{start:t=>{((e,t,r,o,a,n)=>{N(e,(e=>{const r=((e,t,r,o)=>{switch(e){case"info":return w.some(t);case"warning":return w.some(r);case"error":return w.some(o);default:return w.none()}})(e.severity,o,a,n).toArray().concat([t]);N(r,(t=>{me(e.element,t,1)}))})),w.from(e[0]).each((e=>{He(e.element,r,e.severity)}))})(t,e.violation,e.current,e.info,e.warn,e.error)},moveTo:(r,o)=>{((e,t,r,o)=>{const a=We(e,"["+t+"]");N(a,(e=>{ve(e,t)})),He(r,t,o)})(ke(t.getBody()),e.current,r,o)},stop:()=>{((e,t,r,o,a,n)=>{const i=We(e,"["+t+"]");N(i,(e=>{N([t,r,o,a,n],(t=>{ve(e,t)})),qe(e,t,r)}))})(ke(t.getBody()),e.violation,e.current,e.info,e.warn,e.error)},exclude:t=>{qe(t,e.violation,e.current)}}},Ge="data-"+we("a11y-current-violation"),Pe="data-"+we("a11y-violation"),Le="data-"+we("a11y-severity-info"),je="data-"+we("a11y-severity-warn"),Be="data-"+we("a11y-severity-error"),Ve="data-"+we("accessibility-ignore"),Fe=p(Ve),ze=(e,t,r)=>{let o=e.dom;const a=c(r)?r:g;for(;o.parentNode;){o=o.parentNode;const e=ke(o);if(t(e))return w.some(e);if(a(e))break}return w.none()},Ue=(e,t)=>E(e.dom.childNodes,(e=>t(ke(e)))).map(ke),Ke=(e,t,r)=>ze(e,(e=>xe(e,t)),r),Je=(e,t)=>Ue(e,(e=>xe(e,t))),Qe=(e,t)=>((e,t)=>{const r=void 0===t?document:t.dom;return Ae(r)?w.none():w.from(r.querySelector(e)).map(ke)})(t,e),Xe=(e,t,r)=>((e,t,r,o,a)=>((e,t)=>xe(e,t))(r,o)?w.some(r):c(a)&&a(r)?w.none():t(r,o,a))(0,Ke,e,t,r),Ye=(e,t=!1)=>{return Oe(e)?e.dom.isContentEditable:(r=e,Xe(r,"[contenteditable]")).fold(p(t),(e=>"true"===Ze(e)));var r},Ze=e=>e.dom.contentEditable,et=e=>{const t=(e=>ze(e,le).exists(Ye))(e);return t&&le(e)&&Ye(e)},tt=(e,t)=>S(e.querySelectorAll(t),(e=>et(ke(e)))),rt=(e,t,r)=>R(t,(t=>"I1"===t.id?t.check(e,r)?[{rule:t,element:e}]:[]:t.check(e)?[{rule:t,element:e}]:[])),ot=(e,t)=>{let r=[];const o=((e,t)=>{const r=[],o=[];for(let t=0,n=e.length;txe(t,e)))&&le(t)&&et(t)){const o=rt(t.dom,n,e.allowDecorativeImages);r=r.concat(o)}}const c=((e,t)=>R(t,(t=>_(t.check(e),(e=>({rule:t,element:e}))))))(t,i);return r=r.concat(c),r.sort(((e,t)=>((e,t)=>e===t?0:((e,t)=>((e,t,r)=>0!=(e.compareDocumentPosition(t)&r))(e,t,Node.DOCUMENT_POSITION_PRECEDING))(e,t)?1:-1)(e.element,t.element))),r},at=(e,t)=>Qe(e,t).isSome(),nt=p("error"),it=p("warning"),st=(e,t)=>{const r=e;return r.matches?r.matches(t):r.webkitMatchesSelector?r.webkitMatchesSelector(t):r.mozMatchesSelector?r.mozMatchesSelector(t):!!r.msMatchesSelector&&r.msMatchesSelector(t)},lt=e=>e.length>0,ct=((e,t)=>{const r=t=>e(t)?w.from(t.dom.nodeValue):w.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return r(t).getOr("")},getOption:r,set:(t,r)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=r}}})(ue),ut=e=>ct.get(e),dt=e=>pt(e).isSome(),pt=e=>Ue(e,(e=>ue(e)&<(ut(e).trim()))),ht="strong,b",mt=(e,t)=>pt(e).fold((()=>((e,t)=>{for(let r=0,o=e.length;rmt(e,t)))),(e=>((e,t)=>Ke(e,ht,(e=>Ce(e,t))).isSome())(e,t))),yt={id:"D1",wcag:"1.3.1",severity:it(),desckey:"a11y.d1.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H42.html",walkable:!0,check:e=>{const t=ke(e);return!(!st(e,"p")||!at(t,ht))&&mt(t,t)},levels:[$(),G(),P()],htmlversions:[H(),q()]},gt={id:"D2",wcag:"1.3.1",severity:nt(),desckey:"a11y.d2.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/general/G141.html",walkable:!1,check:e=>{const t=tt(e,"h1,h2,h3,h4,h5,h6");let r;const o=[];return N(t,(e=>{const t=parseInt(e.tagName.slice(1),10);r&&t-r>1&&o.push(e),r=t})),o},levels:[$(),G(),P()],htmlversions:[H(),q()]},vt={id:"D3",wcag:"2.4.4",severity:nt(),desckey:"a11y.d3.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H2.html",walkable:!1,check:e=>{const t=ke(e),r=We(t,"a + a"),o=S(r,(e=>{const t=W(_e(e));return O(t,he("a"),(e=>{return!(ue(t=e)&&(r=ut(t).replace(/[\u200B-\u200D\uFEFF]/g,""),!lt(r)));var t,r})).exists((t=>t.dom.href===e.dom.href))&&et(e)}));return _(o,(e=>e.dom))},levels:[$(),G(),P()],htmlversions:[H(),q()]},wt=(e,t)=>{const r=e.nodeName,o=((e,t)=>{let r=e.nextSibling;for(;null!==r&&(t&&"#text"===r.nodeName||"BR"===r.nodeName);)r=r.nextSibling;return r})(e,t);return null!==o&&o.nodeName===r&&o},bt=(e,t,r)=>{const o=[];if(t(e)){o.push(e);let a=wt(e,r);for(;!1!==a&&t(a);)o.push(a),a=wt(a,r)}return o},ft=(e,t)=>{let r=-1;for(let o=0;o{const r=tt(e,"p,h1,h2,h3,h4,h5,h6"),o=[];let a=0;for(;a1){o.push(e);const t=n[n.length-1],i=ft(r,t);a=-1===i?a+1:i}else l(e.firstChild)?(bt(e.firstChild,t,!1).length>1&&o.push(e),a++):a++}return o},xt=e=>{var t;return l(null===(t=e.textContent)||void 0===t?void 0:t.match(/^\s{0,}([a-z1-9]|i+)\s{0,}[.)-]/gim))},At={id:"D4o",wcag:"1.3.1",severity:nt(),desckey:"a11y.d4.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H48.html",walkable:!1,check:e=>kt(e,xt),levels:[$(),G(),P()],htmlversions:[H(),q()]},Ct=e=>{var t;return l(null===(t=e.textContent)||void 0===t?void 0:t.match(/^\s{0,}(\*|-)\s{0,}/gim))},Tt={id:"D4u",wcag:"1.3.1",severity:nt(),desckey:"a11y.d4.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H48.html",walkable:!1,check:e=>kt(e,Ct),levels:[$(),G(),P()],htmlversions:[H(),q()]},Dt=(e,t)=>{const r=e.dom,o=window.getComputedStyle(r).getPropertyValue(t);return""!==o||Oe(e)?o:It(r,t)},It=(e,t)=>(e=>void 0!==e.style&&c(e.style.getPropertyValue))(e)?e.style.getPropertyValue(t):"",_t=(e,t,r,o)=>({red:e,green:t,blue:r,alpha:o}),Nt=e=>{const t=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4),r=e.red/255,o=e.green/255,a=e.blue/255;return.2126*t(r)+.7152*t(o)+.0722*t(a)},St=(e,t)=>{const r=e.alpha+t.alpha*(1-e.alpha),o=(e.red*e.alpha+t.red*t.alpha*(1-e.alpha))/r,a=(e.green*e.alpha+t.green*t.alpha*(1-e.alpha))/r,n=(e.blue*e.alpha+t.blue*t.alpha*(1-e.alpha))/r;return _t(Math.ceil(o),Math.ceil(a),Math.ceil(n),r)},Mt=e=>{const t=(e,t,r,o)=>{const a=parseInt(e,10),n=parseInt(t,10),i=parseInt(r,10),s=parseFloat(o);return w.some(_t(a,n,i,s))};if("transparent"===e)return t("0","0","0","0");const r=/^rgb\((\d+),\s*(\d+),\s*(\d+)\)/.exec(e);if(null!==r)return t(r[1],r[2],r[3],"1");const o=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d?(?:\.\d+)?)\)/.exec(e);return null!==o?t(o[1],o[2],o[3],o[4]):w.none()},Ot=(e,t)=>{const r=parseFloat(Dt(e,"opacity"));return r<1?_t(t.red,t.green,t.blue,t.alpha*r):t},Et=(e,t)=>Rt(e).filter((e=>e{const t=(e=>{const t=Te(e),r=Ee(t),o=[e].concat(((e,t)=>{const r=c(t)?t:g;let o=e.dom;const a=[];for(;null!==o.parentNode&&void 0!==o.parentNode;){const e=o.parentNode,t=ke(e);if(a.push(t),!0===r(t))break;o=e}return a})(e,(e=>Ce(e,r)))),a=M(o,((e,t)=>{if(1===e.alpha)return e;const r=Dt(t,"background-color");return Mt(r).bind((r=>{const o=Ot(t,r);return o.alpha>0?w.some(St(e,o)):w.none()})).getOr(e)}),_t(0,0,0,0));return a.alpha<1?St(a,_t(255,255,255,1)):a})(e);return((e,t)=>{const r=Dt(e,"color");return Mt(r).bind((r=>{const o=Ot(e,r),a=o.alpha<1?St(o,t):o;return w.some(a)}))})(e,t).map((e=>{const r=Nt(t);return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(Nt(e),r)}))},Wt={id:"D5c",wcag:"1.4.3",severity:nt(),desckey:"a11y.d5c.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/general/G17.html",walkable:!0,check:e=>{const t=ke(e);return dt(t)&&Et(t,7)},levels:[P()],htmlversions:[H(),q()]},Ht=e=>{const t=Dt(e,"font-size"),r=new RegExp(".*px").test(t),o=/(\d*\.?\d*)(.*)/.exec(t);return r&&null!==o?w.some(Number(o[1])):w.none()},qt=e=>{const t=(e=>{const t=Dt(e,"font-weight");return!("bold"!==t&&"bolder"!==t)||!!/^[0-9]*$/.test(r=t)&&parseInt(r,10)>=700;var r})(e),r=Te(e),o=Ee(r),a=Ht(o);return Ht(e).fold(g,(e=>a.fold((()=>e>=24||t&&e>=19),(r=>e>=1.5*r||t&&e>=1.2*r))))},$t={id:"D5a",wcag:"1.4.3",severity:nt(),desckey:"a11y.d5a.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/general/G145.html",walkable:!0,check:e=>{const t=ke(e);return dt(t)&&qt(t)&&Et(t,3)},levels:[G()],htmlversions:[H(),q()]},Gt={id:"D5b",wcag:"1.4.3",severity:nt(),desckey:"a11y.d5b.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/general/G18.html",walkable:!0,check:e=>{const t=ke(e);return dt(t)&&!qt(t)&&Et(t,4.5)},levels:[G()],htmlversions:[H(),q()]},Pt={id:"H93",wcag:"4.1.1",severity:nt(),desckey:"a11y.h93.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H93.html",walkable:!1,check:e=>{const t=ke(e),r=We(t,"*[id]"),o=M(r,((e,t)=>{const r=ye(t,"id");if(void 0!==r&&et(t)){if(re(e.problems,r))return e;if(re(e.ids,r)){const t=e.ids[r];return{...e,problems:{...e.problems,[r]:t}}}return{...e,ids:{...e.ids,[r]:t.dom}}}return e}),{ids:{},problems:{}});return((e,t)=>{const r=[];return ee(e,((e,o)=>{r.push(t(e,o))})),r})(o.problems,h)},levels:[$(),G(),P()],htmlversions:[H(),q()]},Lt=he("img"),jt={id:"I1",wcag:"1.1.1",severity:nt(),desckey:"a11y.i1.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/general/G95.html",walkable:!0,check:(e,t)=>{const r=ke(e);if(!Lt(r))return!1;const o=ge(r,"alt"),a=o.isSome(),n=o.exists((e=>""===e.trim())),i=((e,t,r=m)=>e.exists((e=>r(e,t))))(ge(r,"role"),"presentation");return!a||(t?a&&n&&!i||a&&!n&&i:n||i)},levels:[$(),G(),P()],htmlversions:[H(),q()]},Bt={id:"I2",wcag:"1.1.1",severity:nt(),desckey:"a11y.i2.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/general/G95.html",walkable:!0,check:e=>(e=>st(e,"img[alt][src]"))(e)&&e.src.split("/").pop()===e.alt.split("/").pop(),levels:[$(),G(),P()],htmlversions:[H(),q()]},Vt={id:"I3",wcag:"N/A",severity:it(),desckey:"a11y.i3.description",url:"",walkable:!0,check:e=>{const t=ke(e);return!!Lt(t)&&ge(t,"alt").exists((e=>e.length>100))},levels:[$(),G(),P()],htmlversions:[H(),q()]},Ft={id:"T1",wcag:"1.3.1",severity:nt(),desckey:"a11y.t1.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H39.html",walkable:!0,check:e=>{if(st(e,"table")){const t=e.querySelector("caption");return!t||st(t,":empty")}return!1},levels:[$(),G(),P()],htmlversions:[H(),q()]},zt={id:"T2",wcag:"1.3.1",severity:it(),desckey:"a11y.t2.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H73.html",walkable:!0,check:e=>st(e,"table")&&l(e.querySelector("[rowspan]")||e.querySelector("[colspan]"))&&!e.hasAttribute("summary"),levels:[$(),G(),P()],htmlversions:[H()]},Ut={id:"T3",wcag:"1.3.1",severity:nt(),desckey:"a11y.t3.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H73.html",walkable:!0,check:e=>{if(st(e,"table")&&e.hasAttribute("summary")){const t=e.querySelectorAll("caption");return t.length>0&&e.getAttribute("summary")===t[0].innerHTML}return!1},levels:[$(),G(),P()],htmlversions:[H(),q()]},Kt={id:"T4b",wcag:"1.3.1",severity:nt(),desckey:"a11y.t4b.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H51.html",walkable:!0,check:e=>"table"===e.nodeName.toLowerCase()&&0===e.querySelectorAll("th").length,levels:[$(),G(),P()],htmlversions:[H(),q()]},Jt={id:"T4c",wcag:"1.3.1",severity:nt(),desckey:"a11y.t4c.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H63.html",walkable:!0,check:e=>{return!("th"!==e.nodeName.toLowerCase()||(t=e).hasAttribute("scope")&&/row|col|rowgroup|colgroup/i.test(t.getAttribute("scope")));var t},levels:[$(),G(),P()],htmlversions:[H(),q()]},Qt=(e,t)=>0===e.querySelectorAll(t).length,Xt={id:"T4a",wcag:"1.3.1",severity:nt(),desckey:"a11y.t4a.description",url:"https://www.w3.org/WAI/WCAG21/Techniques/html/H51.html",walkable:!0,check:e=>{return"table"===e.nodeName.toLowerCase()&&(Qt(t=e,"tr")||Qt(t,"td"));var t},levels:[$(),G(),P()],htmlversions:[H(),q()]},Yt=e=>({id:e.id.toUpperCase(),severity:e.severity,url:e.url,description:X(e.description),element:e.element.dom}),Zt=t=>{const r=(e=>{const t=(e=>{const t=e.options.get("a11ychecker_ignored_rules");return R(tinymce.explode(t),(e=>e.length>0?[e.toUpperCase()]:[]))})(e),r=B(e),o=V(e);return{rules:S([yt,gt,vt,At,Tt,$t,Gt,Wt,Pt,jt,Bt,Vt,Ft,zt,Ut,Jt,Xt,Kt],(e=>!D(t,e.id.toUpperCase())&&D(e.levels,r)&&D(e.htmlversions,o))),allowDecorativeImages:U(e),ignoreSelectors:["img[data-mce-placeholder]","[data-mce-bogus=all] *","[data-mce-bogus]","[data-mce-mergetag-affix]"]}})(t);(e=>{e.on("init",(()=>{N([Ve,Pe,Le,je,Be,Ge],(t=>{e.serializer.addTempAttr(t)}))}))})(t);const o=e(!1),a=(e=>$e({editor:e,violation:Pe,current:Ge,info:Le,warn:je,error:Be}))(t),n=Fe();let i=[],s=0;const l=()=>{const e=ot(r,t.getBody()),o=((e,t)=>_(t,(t=>{const r=t.rule;return{id:r.id.toUpperCase(),description:"I1"!==r.id?r.desckey:U(e)?`${r.desckey}.decorativeAllowed`:`${r.desckey}.decorativeNotAllowed`,element:ke(t.element),url:r.url,severity:r.severity}})))(t,e);return S(o,(e=>{const r=(a=e.element,ge(a,n).map((e=>e.split(" "))).getOr([])),o=z(t);var a;return!D(r,e.id)&&o(Yt(e))}))},c=e=>(s+=e,s=s<0?s+i.length:s%i.length,a.moveTo(i[s].element,i[s].severity),t.selection.scrollIntoView(i[s].element.dom),{summaryLabel:X(["a11y.widget.counter",s+1,i.length]),issue:i[s],index:s+1}),u=()=>i.length>0?w.some(c(0)):w.none(),d=()=>{o.set(!0),i=l(),s=0},p=()=>{a.stop(),o.set(!1),s=0,i=[]};return{scan:()=>(d(),a.start(i),u()),stepIssue:c,getIssues:()=>i.slice(0),getCurrent:u,getReport:()=>{const e=o.get();try{return e||d(),_(i,Yt)}finally{e||p()}},resolveCurrent:e=>(e&&((e,t,r)=>{const o=ge(e,t).map((e=>e.concat(" ",r))).getOr(r);me(e,t,o)})(i[s].element,n,i[s].id),i=l(),u()),clear:p,isAuditing:()=>o.get()}},er=(e,t)=>{const r=t.ui.registry.getAll().icons;return w.from(r[e]).orThunk((()=>w.from(r["temporary-placeholder"]))).getOr("!not found!")},tr={success:"checkmark",info:"info",warning:"notice",error:"warning"},rr=(e,t,r,o,a)=>{const n=X(r),i=X(t);return`
${er(tr[r],e)}

${n}

${i}

`+((e,t,r)=>{const o=`
${er(e,t)}
`;return"help"===e?o:`
${er(e,t)}
`})(o,e,a)+"
"},or=(e,t,r,o)=>({type:"listbox",label:t,name:e,items:_(r,(e=>({text:o(e.text),value:e.value})))}),ar=(e,t)=>({type:"input",name:e,label:t}),nr=(e,t,r)=>({type:"label",label:t,items:[{type:"checkbox",name:e,label:r}]}),ir=(e,t)=>({title:X("a11y.widget.title"),body:{type:"panel",items:[{type:"panel",classes:["tox-accessibility-issue","accessibility-issue--success"],items:[{type:"htmlpanel",html:rr(e,"a11y.widget.issue.none","success","checkmark"),presets:"presentation"}]}]},buttons:[{type:"submit",name:"ok",text:"OK",primary:!0}],onSubmit:e=>e.close(),onClose:t}),sr=(e,t,r)=>{e.redial(t),e.focus(r)};var lr;!function(e){e.Next="next",e.Prev="prev",e.Ignore="ignore",e.Ok="ok",e.Repair="repair"}(lr||(lr={}));const cr=({issue:e,summaryLabel:t},r,o,a,n,i)=>{const s=F(n),l=e=>cr(e,r,o,w.none(),n,i),c=a=>(s,{name:c})=>{if(c===lr.Next||c===lr.Prev){const e=r.stepIssue(c===lr.Next?1:-1);sr(s,l(e),c)}else c===lr.Ignore?r.resolveCurrent(!0).fold((()=>sr(s,ir(n,i),lr.Ok)),(e=>sr(s,l(e),lr.Ignore))):c===lr.Repair&&((a,s)=>{const c=s=>{sr(a,cr({issue:e,summaryLabel:t},r,o,w.some(s),n,i),lr.Repair)},u=()=>r.resolveCurrent(!1).fold((()=>r.scan().fold((()=>sr(a,ir(n,i),lr.Ok)),(e=>sr(a,l(e),lr.Ignore)))),(e=>sr(a,l(e),lr.Ignore)));s.each((t=>{t.repair(e.element,e.id,((e,t)=>{const r={},o={};return((e,t,r,o)=>{ee(e,((e,a)=>{(t(e,a)?r:o)(e,a)}))})(e,t,te(r),te(o)),{t:r,f:o}})(a.getData(),((t,r)=>{return o=r,""===(a=e.id)||o.length>=a.length&&o.substr(0,0+a.length)===a;var o,a})).t,(e=>e.fold(c,u)))}))})(s,a)},u=t=>r=>t.each((t=>{t.onChange.each((t=>t(r,r.getData(),e))),t.shouldDisableRepair.each((t=>{const o=t(r.getData(),e);r.setEnabled(lr.Repair,!o)}))})),d=(r,o,a)=>{const l="warning"===(d=e.severity)?"warn":d;var d;const p=o.map((()=>({type:"panel",classes:["accessibility-issue__repair"],items:o.map((e=>e.items)).getOr([])}))).toArray();return{title:X("a11y.widget.title"),body:{type:"panel",classes:["tox-accessibility-issue",`accessibility-issue--${l}`],items:[{type:"panel",classes:["accessibility-issue__header"],items:[{type:"htmlpanel",html:`

${t}

`,presets:"presentation"},{type:"button",name:lr.Prev,text:X("a11y.widget.previous"),icon:"action-prev",borderless:!0},{type:"button",name:lr.Next,text:X("a11y.widget.next"),icon:"action-next",borderless:!0}]},{type:"htmlpanel",html:rr(n,e.description,e.severity,"help",s(e.id)),presets:"presentation"},...p]},buttons:[{type:"custom",name:lr.Ignore,text:X("a11y.widget.ignore")},{type:"custom",name:lr.Repair,text:X("a11y.widget.repair"),enabled:!a,primary:!0}],initialData:{...o.map((e=>e.initialData)).getOr({})},onAction:c(r),onChange:u(r),onClose:i}};return o(e.id).fold((()=>d(w.none(),w.none(),!0)),(t=>{const r=((e,t,r)=>{const o=t.element;return r.fold((()=>e.ui.map((e=>e(t.id,o)))),(r=>e.ui.map((e=>{const a=e(t.id,o);return{items:a.items.concat([(n=r.errorMessage,{type:"htmlpanel",html:`
${n}
`})]),initialData:{...a.initialData,...r.repairErrorData}};var n}))))})(t,e,a),o=t.shouldDisableRepair.bind((t=>r.map((r=>t(r.initialData,e))))).getOr(!1);return d(w.some(t),r,o)}))},ur=(e,t)=>{De(e).each((r=>{r.dom.insertBefore(t.dom,e.dom)}))},dr=(e,t)=>{const r=(e=>w.from(e.dom.nextSibling).map(ke))(e);r.fold((()=>{De(e).each((e=>{pr(e,t)}))}),(e=>{ur(e,t)}))},pr=(e,t)=>{e.dom.appendChild(t.dom)},hr=(e,t)=>{N(t,(t=>{pr(e,t)}))},mr=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},yr=e=>{const t=Ne(e);var r,o;t.length>0&&(r=e,N(o=t,((e,t)=>{const a=0===t?r:o[t-1];dr(a,e)}))),mr(e)},gr=e=>e.dom.innerHTML,vr=e=>{const t=t=>t(e),r=p(e),o=()=>a,a={tag:!0,inner:e,fold:(t,r)=>r(e),isValue:v,isError:g,map:t=>br.value(t(e)),mapError:o,bind:t,exists:t,forall:t,getOr:r,or:o,getOrThunk:r,orThunk:o,getOrDie:r,each:t=>{t(e)},toOptional:()=>w.some(e)};return a},wr=e=>{const t=()=>r,r={tag:!1,inner:e,fold:(t,r)=>t(e),isValue:g,isError:v,map:t,mapError:t=>br.error(t(e)),bind:t,exists:g,forall:v,getOr:h,or:h,getOrThunk:y,orThunk:y,getOrDie:(o=String(e),()=>{throw new Error(o)}),each:d,toOptional:w.none};var o;return r},br={value:vr,error:wr,fromOption:(e,t)=>e.fold((()=>wr(t)),vr)},fr=e=>((e,t)=>ke(e.dom.cloneNode(!0)))(e),kr=(e,t,r)=>br.error({errorMessage:t(e),repairErrorData:r}),xr=(e,t,r,o,a,n)=>0===t.length?kr(o,n,{}):Ar(e,t,r,a,n),Ar=(e,t,r,o,a)=>t===r?kr(o,a,{}):br.value(e),Cr=e=>{const t=e.split("/");return w.from(t.pop())},Tr=(e,t,r,o,a,n)=>{const i=ge(e,"src").bind(Cr).getOr(""),s=r[`${t}_textinput`];return r[`${t}_checkbox`]?(e=>(me(e,"alt",""),me(e,"role","presentation"),br.value(e)))(e):xr(e,s,i,o,a,n).map((e=>(me(e,"alt",s),"presentation"===ye(e,"role")&&ve(e,"role"),e)))},Dr=e=>e.dom.textContent,Ir=(e,t,r,o,a,n)=>{const i=ye(e,"summary");return xr(e,r[t],i,o,a,n).map((o=>{const a=Je(e,"caption").fold((()=>fe("caption")),(e=>{var t;return(t=e).dom.textContent="",N(Ne(t),(e=>{mr(e)})),e}));return((e,t)=>{e.dom.textContent=t})(a,r[t]),((e,t)=>{(e=>((e,t)=>{const r=e.dom.childNodes;return w.from(r[0]).map(ke)})(e))(e).fold((()=>{pr(e,t)}),(r=>{e.dom.insertBefore(t.dom,r.dom)}))})(o,a),o}))},_r=e=>`${e}_checkbox`,Nr=e=>`${e}_textinput`,Sr=(e,t)=>{const r=t.id,o=!0===e[_r(r)],a=e[Nr(r)].length>0;return!o&&!a},Mr=(e,t,r)=>{const o=r.id,a=_r(o),n=Nr(o);!0===t[a]?(e.setEnabled(n,!1),e.setEnabled(lr.Repair,!0)):(e.setEnabled(n,!0),t[n].length>0?(e.setEnabled(lr.Repair,!0),e.setEnabled(a,!0)):(e.setEnabled(a,!0),e.setEnabled(lr.Repair,!1)))},Or=(e,t)=>{const r=ar(Nr(t),X((o="a11y.i1.repair.info",e?`${o}.decorativeAllowed`:`${o}.decorativeNotAllowed`)));var o;return e?[nr(_r(t),X("a11y.i1.repair.checkboxlabel"),X("a11y.i1.repair.checkboxtext")),r]:[r]},Er=(e,t,r)=>{const o=ye(e,"alt"),a=t?{[_r(r)]:!1}:{};return{[Nr(r)]:o||"",...a}},Rr=e=>{const t=U(e),r={H93:w.some({ui:w.some(((e,t)=>({items:[or(e,X("a11y.h93.repair.info"),[{text:"a11y.h93.repair.deduplicate.others",value:"others"},{text:"a11y.h93.repair.deduplicate.this",value:"this"},{text:"a11y.h93.repair.deduplicate.all",value:"all"}],X)],initialData:{[e]:""}}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(((e,t,r,o)=>{const a=r[t],n="all"===a||"this"===a;if("all"===a||"others"===a){const t=ye(e,"id"),r=o.getBody(),a=ke(r),n=We(a,`*[id="${t}"]`),i=S(n,(t=>!Ce(t,e)));N(i,(e=>{ve(e,"id")}))}return n&&ve(e,"id"),br.value(e)})(t,r,o,e))}))},shouldDisableRepair:w.none(),onChange:w.none()}),I1:w.some({ui:w.some(((e,r)=>({items:Or(t,e),initialData:Er(r,t,e)}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(Tr(t,r,o,"a11y.i1.repair.errors.empty","a11y.i1.repair.errors.duplicate",X))}))},shouldDisableRepair:t?w.some(Sr):w.none(),onChange:t?w.some(Mr):w.none()}),I2:w.some({ui:w.some(((e,r)=>({items:Or(t,e),initialData:Er(r,t,e)}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(Tr(t,r,o,"a11y.i1.repair.errors.empty","a11y.i1.repair.errors.duplicate",X))}))},shouldDisableRepair:t?w.some(Sr):w.none(),onChange:t?w.some(Mr):w.none()}),I3:w.some({ui:w.some(((e,t)=>({items:Or(!1,e),initialData:Er(t,!1,e)}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(((e,t,r,o,a)=>{const n=r[`${t}_textinput`];return((e,t,r,o,a,n=100)=>{const i=`${t}_textinput`;return r.length>n?kr([o,r.length],a,{[i]:r}):br.value(e)})(e,t,n,o,a,100).map((e=>(me(e,"alt",n),e)))})(t,r,o,"a11y.i3.repair.error",X))}))},shouldDisableRepair:w.none(),onChange:w.none()}),T1:w.some({ui:w.some(((e,t)=>({items:[ar(e,X("a11y.t1.repair.info"))],initialData:{[e]:""}}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(Ir(t,r,o,"a11y.t1.repair.errors.empty","a11y.t1.repair.errors.duplicate",X))}))},shouldDisableRepair:w.none(),onChange:w.none()}),T2:w.some({ui:w.some(((e,t)=>({items:[ar(e,X("a11y.t2.repair.info"))],initialData:{[e]:""}}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(((e,t,r,o,a,n)=>{const i=Qe(e,"caption").filter(le).map(Dr).getOr("");return xr(e,r[t],i,"a11y.t2.repair.errors.empty","a11y.t2.repair.errors.duplicate",n).map((o=>(me(e,"summary",r[t]),o)))})(t,r,o,0,0,X))}))},shouldDisableRepair:w.none(),onChange:w.none()}),T3:w.some({ui:w.some(((e,t)=>{const r=Je(t,"caption").fold(p(""),gr);return{items:[ar(e,X("a11y.t1.repair.info"))],initialData:{[e]:r}}})),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(Ir(t,r,o,"a11y.t1.repair.errors.empty","a11y.t1.repair.errors.duplicate",X))}))},shouldDisableRepair:w.none(),onChange:w.none()}),T4A:w.none(),T4B:w.some({ui:w.some(((e,t)=>({items:[or(e,X("a11y.t4b.repair.info"),[{text:"a11y.t4c.repair.header.row",value:"row"},{text:"a11y.t4c.repair.header.col",value:"col"}],X)],initialData:{[e]:""}}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(((e,t,r)=>{let o=[];if("row"===r[t]){const t=ke(e.dom.rows[0]);o=Re(t,"td")}else"col"===r[t]&&N(e.dom.rows,(e=>{Je(ke(e),"td").each((e=>{o.push(e)}))}));return N(o,(e=>{const t=fe("th");N(e.dom.attributes,(r=>{ge(e,r.name).each((e=>me(t,r.name,e)))})),t.dom.innerHTML=e.dom.innerHTML,dr(e,t),mr(e)})),br.value(e)})(t,r,o))}))},shouldDisableRepair:w.some(((e,t)=>!at(t.element,"td"))),onChange:w.none()}),T4C:w.some({ui:w.some(((e,t)=>({items:[or(e,X("a11y.t4c.repair.info"),[{text:"a11y.t4c.repair.scope.row",value:"row"},{text:"a11y.t4c.repair.scope.col",value:"col"},{text:"a11y.t4c.repair.scope.rowgroup",value:"rowgroup"},{text:"a11y.t4c.repair.scope.colgroup",value:"colgroup"}],X)],initialData:{[e]:""}}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(((e,t,r)=>(me(e,"scope",r[t]),br.value(e)))(t,r,o))}))},shouldDisableRepair:w.none(),onChange:w.none()}),D1:w.some({ui:w.some(((e,t)=>({items:[or(e,X("a11y.d1.repair.info"),[{text:"a11y.d1.repair.block.h1",value:"h1"},{text:"a11y.d1.repair.block.h2",value:"h2"},{text:"a11y.d1.repair.block.h3",value:"h3"},{text:"a11y.d1.repair.block.h4",value:"h4"},{text:"a11y.d1.repair.block.h5",value:"h5"},{text:"a11y.d1.repair.block.h6",value:"h6"}],X)],initialData:{[e]:""}}))),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a(((e,t,r)=>{const o=Te(e),a=fe(r[t],o.dom),n=Ne(e),i=_(n,fr);hr(a,i);const s=We(a,"b,strong");return N(s,yr),ur(e,a),mr(e),br.value(a)})(t,r,o))}))},shouldDisableRepair:w.none(),onChange:w.none()}),D2:w.none(),D3:w.some({ui:w.none(),repair:(t,r,o,a)=>{e.undoManager.transact((()=>{a((e=>{const t=W(_e(e));return E(t,he("a")).fold((()=>br.error({errorMessage:"Failed to find previous link",repairErrorData:{}})),(r=>{for(const e of t){if(Ce(e,r))break;ue(e)&&mr(e)}const o=Ne(e);return hr(r,o),mr(e),br.value(r)}))})(t))}))},shouldDisableRepair:w.none(),onChange:w.none()})};return e=>r.hasOwnProperty(e)?r[e]:w.none()},Wr=(t,r)=>{const o=(()=>{const t=(t=>{const r=e(w.none()),o=()=>r.get().each(t);return{clear:()=>{o(),r.set(w.none())},isSet:()=>r.get().isSome(),get:()=>r.get(),set:e=>{o(),r.set(w.some(e))}}})(d);return{...t,on:e=>t.get().each(e)}})(),a=()=>{o.clear(),r.clear()},n=()=>{const e=((e,t,r,o,a)=>t.scan().fold((()=>e(ir(o,a))),(n=>e(cr(n,t,r,w.none(),o,a)))))((e=>t.windowManager.open(e,{inline:"toolbar",ariaAttrs:!0})),r,Rr(t),t,a);o.set(e)},i=e=>e.close();return t.ui.registry.addButton("a11ycheck",{tooltip:X("a11y.control.tooltip"),icon:"accessibility-check",onAction:n}),t.ui.registry.addMenuItem("a11ycheck",{icon:"accessibility-check",text:X("a11y.control.menutext"),onAction:n}),()=>o.get().fold(n,i)};tinymce.PluginManager.requireLangPack("a11ychecker","ar,bg_BG,ca,cs,da,de,el,es,eu,fa,fi,fr_FR,he_IL,hi,hr,hu_HU,id,it,ja,kk,ko_KR,ms,nb_NO,nl,pl,pt_PT,pt_BR,ro,ru,sk,sl_SI,sv_SE,th_TH,tr,uk,vi,zh_TW,zh_CN"),tinymce.PluginManager.add("a11ychecker",((e,t)=>{if(((e,t)=>!!e&&-1===((e,t)=>{const r=f(e.major,t.major);if(0!==r)return r;const o=f(e.minor,t.minor);if(0!==o)return o;const a=f(e.patch,t.patch);return 0!==a?a:0})((e=>x((e=>[e.majorVersion,e.minorVersion].join(".").split(".").slice(0,3).join("."))(e)))(e),x(t)))(tinymce,"6.3.0"))return console.error('The "a11ychecker" plugin requires at least version 6.3.0 of TinyMCE.'),{};((e,t)=>{const r=e.options.register;r("a11ychecker_css_url",{processor:"string",default:t+"/css/annotations.css"}),r("a11ychecker_allow_decorative_images",{processor:"boolean"});const a=[$(),G(),P()];r("a11ychecker_level",{processor:e=>o(e)&&D(a,e),default:G()});const n=[H(),q()];r("a11ychecker_html_version",{processor:e=>o(e)&&D(n,e),default:q()}),r("a11ychecker_issue_url_callback",{processor:"function",default:e=>`https://www.tiny.cloud/docs/tinymce/${tinymce.majorVersion}/a11ychecker/#${e}`}),r("a11ychecker_ignored_rules",{processor:"string",default:""}),r("a11ychecker_filter_issue",{processor:"function",default:v})})(e,t);const r=Zt(e),a=j(e),n=Wr(e,r);return e.on("init",(()=>{e.dom.loadCSS(a)})),{getReport:r.getReport,toggleaudit:n}}))}(); \ No newline at end of file diff --git a/plugins/advcode/plugin.min.js b/plugins/advcode/plugin.min.js index cd19b16..93eff2d 100644 --- a/plugins/advcode/plugin.min.js +++ b/plugins/advcode/plugin.min.js @@ -4,7 +4,7 @@ * Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc. * Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/ * - * Version: 3.3.2-rc.20231006103534208.sha10dda0d-103 + * Version: 3.3.1-98 */ !function(){"use strict";const e=e=>parseInt(e,10),t=(e,t)=>{const o=e-t;return 0===o?0:o>0?1:-1},o=(e,t,o)=>({major:e,minor:t,patch:o}),n=t=>{const n=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return n?o(e(n[1]),e(n[2]),e(n[3])):o(0,0,0)},r=e=>t=>typeof t===e,i=e=>"string"===(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===(i=n.constructor)||void 0===i?void 0:i.name)===r.name)?"string":t;var o,n,r,i})(e),s=r("boolean"),c=e=>!(e=>null==e)(e),a=r("function"),d=r("number");class l{constructor(e,t){this.tag=e,this.value=t}static some(e){return new l(!0,e)}static none(){return l.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?l.some(e(this.value)):l.none()}bind(e){return this.tag?e(this.value):l.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:l.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)?l.some(e):l.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()"}}l.singletonNone=new l(!1);let u=0;const m=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return u++,e+"_"+o+u+String(t)},g=e=>t=>t.options.get(e),p=g("codemirror_script"),h=g("codemirror_css"),v=g("codemirror_linewrapping"),f=g("codemirror_linenumbers"),y=g("codemirror_foldgutter"),b=g("codemirror_gutter"),w=g("codemirror_theme"),C=e=>"rtl"===e.getBody().dir?"rtl":"ltr",S=g("advcode_headless"),_=g("advcode_inline"),k=(e,t,o)=>({customEditorScriptUrl:t+"/customeditor.min.js",codeMirrorScriptUrl:p(e),codeMirrorCssUrl:h(e),lineWrapping:v(e),lineNumbers:f(e),foldGutter:y(e),theme:w(e),direction:C(e),gutter:b(e),editorId:e.id,advcodeInstanceId:m("advcode_instance"),currentAdvStatus:o}),x=()=>{},z=()=>!1,I=(e,t)=>{for(let o=0,n=e.length;oT.call(e,t);"undefined"!=typeof window?window:Function("return this;")();const E=e=>t=>(e=>e.dom.nodeType)(t)===e,M=E(1),N=E(3),O=E(9),D=E(11),L=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},P=(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])},V=(e,t)=>{const o=(t||document).createElement(e);return L(o)},F=L,j=e=>O(e)?e:F(e.dom.ownerDocument),B=(e,t)=>{e.dom.appendChild(t.dom)},R=e=>D(e)&&c(e.dom.host),$=a(Element.prototype.attachShadow)&&a(Node.prototype.getRootNode)?e=>F(e.dom.getRootNode()):j,W=e=>F(e.dom.host),U=e=>{const t=N(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=$(e);return R(t)?l.some(t):l.none()})(F(t)).fold((()=>o.body.contains(t)),(n=U,r=W,e=>n(r(e))));var n,r},G=()=>H(F(document)),H=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return F(t)},q=(e,t,o)=>{let n=e.dom;const r=a(o)?o:z;for(;n.parentNode;){n=n.parentNode;const e=F(n);if(t(e))return l.some(e);if(r(e))break}return l.none()},K=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Q="\x3c!--mce_cursor--\x3e",J=(e,t)=>{const o=e.dom,n=e.selection,r=n.getBookmark(),i=(e=>A(e,"name"))(r)?o.select(r.name)[r.index]:o.select(`#${r.id}_start`)[0],s=l.from(i).map((t=>{const o=F(e.getBody());return((e,t)=>{const n=P(Q),r=F(e),i=((e,t,o)=>((e,t,o,n,r)=>n(o)?l.some(o):a(r)&&r(o)?l.none():t(o,n,r))(0,q,e,t,o))(r,(e=>((e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute("data-mce-bogus")})(e)),(e=>{return t=o,e.dom===t.dom;var t})).getOr(r);return((e,t)=>{const o=(e=>l.from(e.dom.parentNode).map(F))(e);o.each((o=>{o.dom.insertBefore(t.dom,e.dom)}))})(i,n),n})(t)})),c=t();return s.each(K),n.moveToBookmark(r),c},X=e=>{const t=(e=>{const t=e.split(/\r?\n/);return((e,t)=>{for(let o=0;o{const n=e.indexOf(Q);return(r=-1!==n,i=n,r?l.some(i):l.none()).map((n=>e===Q?0===o?{line:o,ch:0}:{line:o-1,ch:t[o-1].length}:{line:o,ch:n}));var r,i})).getOr({line:0,ch:0})})(J(e,(()=>e.getContent({source_view:!0}))));return{content:e.getContent({source_view:!0}),cursor:t}},Y=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Z=()=>{const e=(e=>{const t=Y(l.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(l.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(l.some(e))}}})(x);return{...e,on:t=>e.get().each(t)}},ee=(e,t)=>{e.focus(),e.undoManager.transact((()=>{e.setContent(t)})),e.selection.setCursorLocation(),e.nodeChanged()},te=e=>{return(t=tinymce,"get",A(t,"get")?l.from(t.get):l.none()).bind((t=>l.from(t.call(tinymce,e))));var t},oe=(e,t)=>te(e).bind((e=>l.from(e.plugins.advcode))).map((e=>(e[t]||(e[t]=Z()),e[t]))),ne=(e,t)=>{te(e).bind((e=>l.from(e.plugins.advcode))).each((e=>{e[t]&&delete e[t]}))},re=(e,t)=>((e,t,o)=>{const n=((e,t)=>{const o=((e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o})(e,t);return void 0===o||""===o?[]:o.split(" ")})(e,t);return((e,t,o)=>{((e,t,o)=>{if(!(i(o)||s(o)||d(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)})(e,t,n.concat([o]).join(" ")),!0})(e,"class",t),ie={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:[""]},se=(()=>{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}))(.*)$`)})(),ce=(e,t,o,n="",r)=>{const i=(e=>{const t=te(e).map((e=>{const t=$(F(e.getElement()));return R(o=t)?o:F(j(o).dom.body);var o})).getOrThunk(G);if(M(t))return{element:t,destroy:x};{const e=V("div");return B(t,e),{element:e,destroy:()=>K(e)}}})(o.editorId),s=((e,t)=>{const o=(o,n)=>(n&&!n()||setTimeout((()=>{o.state.completionActive||o.showHint({completeSingle:!1,container:t})}),100),e.Pass);return{completeAfter:o,completeIfAfterLt:t=>o(t,(()=>{const o=t.getCursor();return"<"===t.getRange(e.Pos(o.line,o.ch-1),o)})),completeIfInTag:t=>o(t,(()=>{const o=t.getTokenAt(t.getCursor());return!!("string"!==o.type||/['"]/.test(o.string.charAt(o.string.length-1))&&1!==o.string.length)&&e.innerMode(t.getMode(),o.state).state.tagName}))}})(e,i.element.dom),c="dracula",d={lineWrapping:o.lineWrapping,lineNumbers:o.lineNumbers,foldGutter:o.foldGutter,theme:r.dark?c:o.theme,direction:o.direction,matchTags:{bothTags:!0},keyMap:"sublime",gutters:o.gutter?["CodeMirror-linenumbers","CodeMirror-foldgutter"]:[],extraKeys:{"Alt-F":"findPersistent","Ctrl-J":"toMatchingTag","Ctrl-B":"selectNextOccurrence","'<'":s.completeAfter,"'/'":s.completeIfAfterLt,"' '":s.completeIfInTag,"'='":s.completeIfInTag,"Ctrl-Q":e=>{e.foldCode(e.getCursor())}},mode:"text/html",value:n},u=e(t,d),m=e=>{27!==e.keyCode&&e.stopPropagation()};t.addEventListener("keyup",m),t.addEventListener("keydown",m),t.addEventListener("keypress",m),setTimeout((()=>{u.focus(),o.cursor&&u.doc.setCursor(o.cursor)}),0),setTimeout((()=>u.refresh()),200);const g=e=>{const t=u.getWrapperElement();e.fold((()=>{var e,o;t.classList.remove("inherit-font-size"),null===(o=null===(e=t.parentElement)||void 0===e?void 0:e.style)||void 0===o||o.removeProperty("font-size")}),(e=>{var o,n;t.classList.add("inherit-font-size"),null===(n=null===(o=t.parentElement)||void 0===o?void 0:o.style)||void 0===n||n.setProperty("font-size",e)})),u.refresh()},p={getValue:()=>u.doc.getValue(),setValue:e=>u.doc.setValue(e),setDarkMode:e=>{e?u.setOption("theme",c):u.setOption("theme",o.theme)},copyCode:()=>new Promise(((e,t)=>window.isSecureContext?e(navigator.clipboard.writeText(u.getValue())):t("context is not secure"))),setFontSize:g,changeFontSize:e=>{const t=u.getWrapperElement(),o=(d=F(t),m=".CodeMirror-scroll",((e,t)=>{const o=void 0===t?document:t.dom;return 1!==(n=o).nodeType&&9!==n.nodeType&&11!==n.nodeType||0===n.childElementCount?l.none():l.from(o.querySelector(e)).map(F);var n})(m,d)).map((e=>((e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||U(e)?n:((e,t)=>(e=>void 0!==e.style&&a(e.style.getPropertyValue))(e)?e.style.getPropertyValue(t):"")(o,t)})(e,"font-size"))).getOr("0px"),n=(s=o,c=["unsupportedLength"],l.from(se.exec(s)).bind((e=>{const t=Number(e[1]),o=e[2];return((e,t)=>I(t,(t=>I(ie[t],(t=>e===t)))))(o,c)?l.some({value:t,unit:o}):l.none()}))),r=n.map((e=>e.value)).getOr(0),i=n.map((e=>e.unit)).getOr("");var s,c,d,m;let p=l.none();return"increase"===e&&(p=l.some(`${r+1}${i}`)),"decrease"===e&&(p=l.some(`${r>5?r-1:r}${i}`)),g(p),p},destroy:()=>{t.removeEventListener("keyup",m),t.removeEventListener("keydown",m),t.removeEventListener("keypress",m),ne(o.editorId,o.advcodeInstanceId),i.destroy()}};return p},ae={},de=(e,t)=>{if(ae[t])return Promise.resolve();{const r=te(t),i=r.bind((e=>{var t;return l.from(null===(t=e.ui)||void 0===t?void 0:t.styleSheetLoader)})).getOr(tinymce.DOM.styleSheetLoader);return r.each((o=>{o.on("remove",(()=>{i.unload(e),delete ae[t]}))})),ae[t]=!0,o=e,(null!=(n=i)?n:tinymce.DOM.styleSheetLoader).load(o)}var o,n},le=e=>({name:"codeview",type:"customeditor",tag:"div",scriptId:"tinymce.plugins.advcode.customeditor",scriptUrl:e.customEditorScriptUrl,settings:e}),ue=(e,t)=>{const o={dark:!1,fullscreen:!1,fontSize:l.none()};e.addCommand("mceCodeEditor",(()=>{_(e)&&!e.inline?"code"===e.mode.get()?e.mode.set("design"):e.mode.set("code"):(()=>{const n=k(e,t,o);((e,t)=>{const o=X(e),n={...t,cursor:o.cursor},r=t.currentAdvStatus,i=oe(t.editorId,t.advcodeInstanceId),s=()=>{let e=[{type:"togglebutton",name:"dark_theme_toggle",text:"Dark/light mode",tooltip:"Dark/light mode",active:r.dark,align:"start"},{type:"custom",name:"increase_font_size",text:"Increase font size",icon:"text-size-increase",align:"start"},{type:"custom",name:"decrease_font_size",text:"Decrease font size",icon:"text-size-decrease",align:"start"},{type:"cancel",name:"cancel",text:"Cancel",align:"end"},{type:"submit",name:"save",text:"Save",primary:!0,align:"end"}];return window.isSecureContext?e=[{type:"custom",name:"copy_code",text:"Copy code",align:"start"}].concat(e):console.warn("Copy code is not allowed since window.isSecureContext is false"),e},c=o=>({title:"Source Code",size:"large",body:{type:"panel",items:[le(n)]},buttons:s(),initialData:{codeview:o},onSubmit:o=>{ee(e,o.getData().codeview),ne(t.editorId,t.advcodeInstanceId),o.close()},onClose:()=>{ne(t.editorId,t.advcodeInstanceId)},onAction:(e,t)=>{"copy_code"===t.name&&i.each((t=>t.get().each((t=>{(async()=>{const o=setTimeout((()=>{e.block("copying")}),150);await t.copyCode(),clearTimeout(o),e.unblock()})()})))),"increase_font_size"===t.name&&i.each((e=>e.get().each((e=>{r.fontSize=e.changeFontSize("increase")})))),"decrease_font_size"===t.name&&i.each((e=>e.get().each((e=>{r.fontSize=e.changeFontSize("decrease")})))),"dark_theme_toggle"===t.name&&i.each((t=>t.get().each((t=>{t.setDarkMode(!r.dark),r.dark=!r.dark,e.redial(c(e.getData().codeview))}))))}});e.windowManager.open(c(o.content))})(e,n)})()}))},me=e=>e.plugins.fullscreen&&e.plugins.fullscreen.isFullscreen(),ge=(e,t,o)=>{const n=Y({dark:!1,fullscreen:!1,fontSize:l.none()}),r=Y(me(e)),i=Z(),s=Y(l.none()),c={dark:!1,fullscreen:!1,fontSize:l.none()},a=()=>s.get().bind((t=>oe(e.id,t))),d=()=>{i.get().each((({destroy:t})=>{t(),n.get().fullscreen!==r.get()&&e.execCommand("mceFullScreen")})),i.clear()};e.ui.registry.addView("code",{buttons:1===o?[{type:"group",buttons:[...e.hasPlugin("fullscreen")?[{type:"togglebutton",icon:"fullscreen",tooltip:"Fullsceen",onAction:t=>{e.execCommand("mceFullScreen",void 0,void 0,{skip_focus:!0});const o=!t.isActive();n.set({...n.get(),fullscreen:o}),t.setActive(o)}}]:[],{type:"togglebutton",icon:"copy",text:"Copy code",onAction:e=>a().each((e=>e.get().each((e=>{(async()=>{await e.copyCode()})()}))))}]},{type:"group",buttons:[{type:"togglebutton",text:"Dark/light mode",tooltip:"Dark/light mode",onAction:e=>{a().each((t=>t.get().each((t=>{n.set({...n.get(),dark:!e.isActive()}),e.setActive(n.get().dark),t.setDarkMode(n.get().dark)}))))}},{type:"togglebutton",icon:"text-size-increase",tooltip:"Increase font size",onAction:e=>a().each((e=>e.get().each((e=>n.set({...n.get(),fontSize:e.changeFontSize("increase")})))))},{type:"togglebutton",icon:"text-size-decrease",tooltip:"Decrease font size",onAction:e=>a().each((e=>e.get().each((e=>n.set({...n.get(),fontSize:e.changeFontSize("decrease")})))))}]},{type:"group",buttons:[{type:"button",text:"Cancel",onAction:()=>{i.get().each((()=>{d(),e.mode.set("design")}))}},{type:"button",text:"Save code",buttonType:"primary",onAction:()=>{i.get().each((({syncWithEditor:t})=>{t(),d(),e.mode.set("design")}))}}]}]:[],onShow:a=>{const d=a.getContainer(),u=k(e,t,c);s.set(l.some(u.advcodeInstanceId)),r.set(me(e)),e.setProgressState(!0),n.get().fullscreen!==me(e)&&e.execCommand("mceFullScreen"),((e,t,o,n)=>{return Promise.all([de(t,o),("tinymce.plugins.advcode.CodeMirror",r=e,tinymce.Resource.load("tinymce.plugins.advcode.CodeMirror",r))]).then((([e,t])=>(e,o,r)=>ce(t(),e,o,r,n)));var r})(p(e),h(e),e.id,n.get()).then((t=>{e.setProgressState(!1),i.set(((e,t,o,n,r,i)=>{const s=X(o),c={...r,cursor:s.cursor},a=V("div");var d;d=a,((e,t)=>{for(let t=0,n=e.length;t{(e=>void 0!==e.dom.classList)(e)?e.dom.classList.add(t):re(e,t)})(d,o);var o})(0===t?["tox-inline-headless-codemirror","mce-codemirror"]:["tox-custom-editor","tox-inline-codemirror","mce-codemirror"]),B(F(e),a);const{getValue:l,destroy:u,copyCode:m,changeFontSize:g,setDarkMode:p,setFontSize:h}=n(a.dom,c,s.content,i);oe(r.editorId,r.advcodeInstanceId).each((e=>e.set({copyCode:m,changeFontSize:g,setDarkMode:p,setFontSize:h}))),h(i.fontSize);const v=()=>ee(o,l());return 0===t&&o.on("BeforeGetContent",v),{syncWithEditor:v,destroy:()=>{0===t&&(o.off("BeforeGetContent",v),v()),K(a),u()}}})(d,o,e,t,u,n.get()))}))},onHide:d})};tinymce.PluginManager.requireLangPack("advcode","ar,bg_BG,ca,cs,da,de,el,es,eu,fa,fi,fr_FR,he_IL,hi,hr,hu_HU,id,it,ja,kk,ko_KR,ms,nb_NO,nl,pl,pt_BR,pt_PT,ro,ru,sk,sl_SI,sv_SE,th_TH,tr,uk,vi,zh_CN,zh_TW"),tinymce.PluginManager.add("advcode",((e,o)=>{((e,o)=>!!e&&-1===((e,o)=>{const n=t(e.major,o.major);if(0!==n)return n;const r=t(e.minor,o.minor);if(0!==r)return r;const i=t(e.patch,o.patch);return 0!==i?i:0})((e=>n((e=>[e.majorVersion,e.minorVersion].join(".").split(".").slice(0,3).join("."))(e)))(e),n(o)))(tinymce,"6.3.0")?console.error("The advcode plugin requires at least version 6.3.0 of TinyMCE."):((e,t)=>{((e,t)=>{const o=e.options.register;o("codemirror_script",{processor:"string",default:t+"/codemirror.min.js"}),o("codemirror_css",{processor:"string",default:t+"/codemirror.min.css"}),o("codemirror_linewrapping",{processor:"boolean",default:!0}),o("codemirror_linenumbers",{processor:"boolean",default:!0}),o("codemirror_foldgutter",{processor:"boolean",default:!0}),o("codemirror_gutter",{processor:"boolean",default:!0}),o("codemirror_theme",{processor:"string",default:"default"}),o("advcode_headless",{processor:"boolean",default:!1}),o("advcode_inline",{processor:"boolean",default:!1})})(e,t),ue(e,t),(e=>{const t="sourcecode",o=()=>e.execCommand("mceCodeEditor");e.ui.registry.addButton("code",{icon:t,tooltip:"Source code",onAction:o}),e.ui.registry.addMenuItem("code",{icon:t,text:"Source code",onAction:o})})(e),((e,t)=>{ge(e,t,S(e)?0:1)})(e,t),(e=>{e.mode.register("code",{activate:()=>{"code"!==e.queryCommandValue("ToggleView")&&e.execCommand("ToggleView",!1,"code")},deactivate:()=>{"code"===e.queryCommandValue("ToggleView")&&e.execCommand("ToggleView",!1,"code")},editorReadOnly:!1})})(e)})(e,o)}))}(); \ No newline at end of file diff --git a/plugins/advtable/plugin.min.js b/plugins/advtable/plugin.min.js new file mode 100644 index 0000000..4d18486 --- /dev/null +++ b/plugins/advtable/plugin.min.js @@ -0,0 +1,10 @@ +/*! + * Tiny Advanced Tables plugin + * + * Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc. + * Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/ + * + * Version: 2.1.0-81 + */ + +!function(){"use strict";const e=e=>parseInt(e,10),t=(e,t)=>{const o=e-t;return 0===o?0:o>0?1:-1},o=(e,t,o)=>({major:e,minor:t,patch:o}),n=t=>{const n=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return n?o(e(n[1]),e(n[2]),e(n[3])):o(0,0,0)},r=e=>t=>(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})(t)===e,s=e=>t=>typeof t===e,l=e=>t=>e===t,c=r("string"),i=r("object"),a=r("array"),m=l(null),u=s("boolean"),d=l(void 0),h=e=>null==e,p=e=>!h(e),g=s("function"),f=s("number");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 p(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 b=()=>{},v=e=>()=>e,y=e=>e,C=(e,t)=>e===t;function x(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const S=v(!1),T=v(!0),R=Array.prototype.slice,D=Array.prototype.indexOf,O=Array.prototype.push,A=(e,t)=>{return o=e,n=t,D.call(o,n)>-1;var o,n},E=(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{if(0===e.length)return[];{let o=t(e[0]);const n=[];let r=[];for(let s=0,l=e.length;s(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),I=(e,t,o)=>(W(e,((e,n)=>{o=t(o,e,n)})),o),P=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n(e=>{const t=[];for(let o=0,n=e.length;o{for(let o=0,n=e.length;o{const o=R.call(e,0);return o.sort(t),o},$=(e,t)=>t>=0&&t$(e,0),G=e=>$(e,e.length-1),q=(e,t)=>{for(let o=0;oe.exists((e=>o(e,t))),U=(e,t,o)=>e.isSome()&&t.isSome()?w.some(o(e.getOrDie(),t.getOrDie())):w.none(),K=e=>e.bind(y),Q=(e,t)=>e?w.some(t):w.none(),X=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Y={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 X(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return X(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return X(o)},fromDom:X,fromPoint:(e,t,o)=>w.from(e.dom.elementFromPoint(t,o)).map(X)},J="undefined"!=typeof window?window:Function("return this;")(),Z=(e,t)=>((e,t)=>{let o=null!=t?t:J;for(let t=0;t{const t=Z("ownerDocument.defaultView",e);return i(e)&&((e=>((e,t)=>{const o=((e,t)=>Z(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(ee(e).constructor.name))},oe=e=>e.dom.nodeName.toLowerCase(),ne=e=>e.dom.nodeType,re=e=>t=>ne(t)===e,se=e=>8===ne(e)||"#comment"===oe(e),le=re(1),ce=re(3),ie=re(9),ae=re(11),me=e=>t=>le(t)&&oe(t)===e,ue=(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")}},de=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,he=(e,t)=>e.dom===t.dom,pe=ue,ge=e=>Y.fromDom(e.dom.ownerDocument),fe=e=>ie(e)?e:ge(e),we=e=>w.from(e.dom.parentNode).map(Y.fromDom),be=(e,t)=>{const o=g(t)?t:S;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Y.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},ve=e=>w.from(e.dom.previousSibling).map(Y.fromDom),ye=e=>w.from(e.dom.nextSibling).map(Y.fromDom),Ce=e=>N(e.dom.childNodes,Y.fromDom),xe=g(Element.prototype.attachShadow)&&g(Node.prototype.getRootNode)?e=>Y.fromDom(e.dom.getRootNode()):fe,Se=e=>Y.fromDom(e.dom.host),Te=e=>{const t=ce(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=xe(e);return ae(o=t)&&p(o.dom.host)?w.some(t):w.none();var o})(Y.fromDom(t)).fold((()=>o.body.contains(t)),(n=Te,r=Se,e=>n(r(e))));var n,r},Re=(e,t)=>{let o=[];return W(Ce(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(Re(e,t))})),o},De=(e,t,o)=>((e,o,n)=>M(be(e,n),(e=>ue(e,t))))(e,0,o),Oe=(e,t)=>((e,o)=>M(Ce(e),(e=>ue(e,t))))(e),Ae=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return de(o)?[]:N(o.querySelectorAll(e),Y.fromDom)})(t,e),Ee=(e,t,o)=>{let n=e.dom;const r=g(o)?o:S;for(;n.parentNode;){n=n.parentNode;const e=Y.fromDom(n);if(t(e))return w.some(e);if(r(e))break}return w.none()},ke=(e,t,o)=>Ee(e,(e=>ue(e,t)),o),Ne=(e,t)=>((e,o)=>P(e.dom.childNodes,(e=>{return o=Y.fromDom(e),ue(o,t);var o})).map(Y.fromDom))(e),We=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return de(o)?w.none():w.from(o.querySelector(e)).map(Y.fromDom)})(t,e),Le=(e,t,o)=>((e,t,o,n,r)=>((e,t)=>ue(e,t))(o,n)?w.some(o):g(r)&&r(o)?w.none():t(o,n,r))(0,ke,e,t,o),Me=Object.keys,je=Object.hasOwnProperty,Be=(e,t)=>{const o=Me(e);for(let n=0,r=o.length;n{const o=[];return Be(e,((e,n)=>{o.push(t(e,n))})),o},Pe=e=>Ie(e,y),ze=e=>Me(e).length,_e=(e,t)=>Fe(e,t)?w.from(e[t]):w.none(),Fe=(e,t)=>je.call(e,t),$e=e=>{for(const t in e)if(je.call(e,t))return!1;return!0},Ve=(e,t,o)=>{if(!(c(o)||u(o)||f(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+"")},Ge=(e,t,o)=>{Ve(e.dom,t,o)},qe=(e,t)=>{const o=e.dom;Be(t,((e,t)=>{Ve(o,t,e)}))},He=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Ue=(e,t)=>w.from(He(e,t)),Ke=(e,t)=>{e.dom.removeAttribute(t)},Qe=e=>I(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Xe=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!d(n)||r+t.length<=n)},Ye=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Je=e=>!(e=>e.length>0)(e),Ze=e=>void 0!==e.style&&g(e.style.getPropertyValue),et=(e,t,o)=>{((e,t,o)=>{if(!c(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Ze(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},tt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||Te(e)?n:ot(o,t)},ot=(e,t)=>Ze(e)?e.style.getPropertyValue(t):"",nt=(e,t)=>{const o=e.dom,n=ot(o,t);return w.from(n).filter((e=>e.length>0))},rt=(e,t)=>{((e,t)=>{Ze(e)&&e.style.removeProperty(t)})(e.dom,t),H(Ue(e,"style").map(Ye),"")&&Ke(e,"style")},st=(e,t,o=0)=>Ue(e,t).map((e=>parseInt(e,10))).getOr(o),lt=e=>me("col")(e)?st(e,"span",1)>1:((e,t)=>st(e,"colspan",1))(e)>1,ct=v(10),it=(e,t)=>at(e,t,T),at=(e,t,o)=>z(Ce(e),(e=>ue(e,t)?o(e)?[e]:[]:at(e,t,o))),mt=["tfoot","thead","tbody","colgroup"],ut=(e,t,o)=>({element:e,rowspan:t,colspan:o}),dt=(e,t,o)=>({element:e,cells:t,section:o}),ht=(e,t,o)=>({element:e,isNew:t,isLocked:o}),pt=(e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}),gt=(e,t)=>((e,t,o=S)=>o(t)?w.none():A(e,oe(t))?w.some(t):ke(t,e.join(","),(e=>ue(e,"table")||o(e))))(["td","th"],e,t),ft=e=>it(e,"th,td"),wt=e=>ue(e,"colgroup")?Oe(e,"col"):z(yt(e),(e=>Oe(e,"col"))),bt=(e,t)=>Le(e,"table",t),vt=e=>it(e,"tr"),yt=e=>bt(e).fold(v([]),(e=>Oe(e,"colgroup"))),Ct=e=>we(e).map((e=>{const t=oe(e);return(e=>A(mt,e))(t)?t:"tbody"})).getOr("tbody"),xt=(e,t)=>pt(e.element,t,e.section,e.isNew),St=(e,t)=>e.cells[t],Tt=(e,t)=>St(e,t).element,Rt=e=>{const t=L(e,(e=>"colgroup"===e.section));return{rows:t.fail,cols:t.pass}},Dt="data-snooker-locked-cols",Ot=e=>Ue(e,Dt).bind((e=>w.from(e.match(/\d+/g)))).map((e=>((e,t)=>{const o={};for(let n=0,r=e.length;ne+","+t,Et=e=>{const t={},o=[],n=V(e).map((e=>e.element)).bind(bt).bind(Ot).getOr({});let r=0,s=0,l=0;const{pass:c,fail:i}=L(e,(e=>"colgroup"===e.section));W(i,(e=>{const c=[];W(e.cells,(e=>{let o=0;for(;void 0!==t[At(l,o)];)o++;const r=((e,t)=>Fe(e,t)&&void 0!==e[t]&&null!==e[t])(n,o.toString()),i=((e,t,o,n,r,s)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:s}))(e.element,e.rowspan,e.colspan,l,o,r);for(let n=0;n{const t=(e=>{const t={};let o=0;return W(e.cells,(e=>{const n=e.colspan;k(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,Pe(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),u=((e,t)=>({rows:e,columns:t}))(r,s);return{grid:u,access:t,all:o,columns:a,colgroups:m}},kt=e=>{const t=(e=>{const t=vt(e);return o=[...yt(e),...t],n=Ct,N(o,(e=>{if("colgroup"===oe(e)){const t=N(wt(e),(e=>{const t=st(e,"span",1);return ut(e,1,t)}));return dt(e,t,"colgroup")}{const t=N(ft(e),(e=>{const t=st(e,"rowspan",1),o=st(e,"colspan",1);return ut(e,t,o)}));return dt(e,t,n(e))}}));var o,n})(e);return Et(t)},Nt=Et,Wt=(e,t,o)=>w.from(e.access[At(t,o)]),Lt=(e,t,o)=>{const n=((e,t)=>{const o=z(e.all,(e=>e.cells));return M(o,t)})(e,(e=>o(t,e.element)));return n.length>0?w.some(n[0]):w.none()},Mt=e=>Pe(e.columns),jt=e=>Me(e.columns).length>0,Bt=(e,t)=>w.from(e.columns[t]),It=e=>Y.fromDom(e.getBody()),Pt=e=>t=>he(t,It(e)),zt=e=>Y.fromDom(e.selection.getStart()),_t=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,Ft=(e,t,o)=>((e,t,o)=>{const n=Lt(e,t,he),r=Lt(e,o,he);return n.bind((e=>r.map((t=>{return o=e,n=t,{startRow:Math.min(o.row,n.row),startCol:Math.min(o.column,n.column),finishRow:Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,n.column+n.colspan-1)};var o,n}))))})(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=x(_t,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let s=t.startCol;s<=t.finishCol;s++)o=o&&Wt(e,r,s).exists(n);return o?w.some(t):w.none()})(e,t))),$t=(e,t,o)=>{const n=Vt(e);return Ft(n,t,o)},Vt=kt,Gt=(e,t)=>{we(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},qt=(e,t)=>{ye(e).fold((()=>{we(e).each((e=>{Ut(e,t)}))}),(e=>{Gt(e,t)}))},Ht=(e,t)=>{(e=>((e,t)=>{const o=e.dom.childNodes;return w.from(o[0]).map(Y.fromDom)})(e))(e).fold((()=>{Ut(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Ut=(e,t)=>{e.dom.appendChild(t.dom)},Kt=(e,t)=>{Gt(e,t),Ut(t,e)},Qt=(e,t)=>{W(t,((o,n)=>{const r=0===n?e:t[n-1];qt(r,o)}))},Xt=(e,t)=>{W(t,(t=>{Ut(e,t)}))},Yt=e=>{e.dom.textContent="",W(Ce(e),(e=>{Jt(e)}))},Jt=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Zt=e=>{const t=Ce(e);t.length>0&&Qt(e,t),Jt(e)},eo=((e,t)=>{const o=t=>e(t)?w.from(t.dom.nodeValue):w.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}}})(ce),to=e=>eo.get(e),oo=(e,t)=>eo.set(e,t);var no=["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"],ro=()=>({up:v({selector:ke,closest:Le,predicate:Ee,all:be}),down:v({selector:Ae,predicate:Re}),styles:v({get:tt,getRaw:nt,set:et,remove:rt}),attrs:v({get:He,set:Ge,remove:Ke,copyTo:(e,t)=>{const o=Qe(e);qe(t,o)}}),insert:v({before:Gt,after:qt,afterAll:Qt,append:Ut,appendAll:Xt,prepend:Ht,wrap:Kt}),remove:v({unwrap:Zt,remove:Jt}),create:v({nu:Y.fromTag,clone:e=>Y.fromDom(e.dom.cloneNode(!1)),text:Y.fromText}),query:v({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:ve,nextSibling:ye}),property:v({children:Ce,name:oe,parent:we,document:e=>fe(e).dom,isText:ce,isComment:se,isElement:le,isSpecial:e=>{const t=oe(e);return A(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>le(e)?Ue(e,"lang"):w.none(),getText:to,setText:oo,isBoundary:e=>!!le(e)&&("body"===oe(e)||A(no,oe(e))),isEmptyTag:e=>!!le(e)&&A(["br","img","hr","input"],oe(e)),isNonEditable:e=>le(e)&&"false"===He(e,"contenteditable")}),eq:he,is:pe});const so=(e,t,o,n)=>{const r=t(e,o);return B(n,((o,n)=>{const r=t(e,n);return lo(e,o,r)}),r)},lo=(e,t,o)=>t.bind((t=>o.filter(x(e.eq,t)))),co=ro(),io=e=>ke(e,"table"),ao=(e,t,o)=>We(e,t).bind((t=>We(e,o).bind((e=>{return(o=io,n=[t,e],((e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,so):w.none())(co,((e,t)=>o(t)),n)).map((o=>({first:t,last:e,table:o})));var o,n})))),mo=y,uo=e=>{const t=(e,t)=>Ue(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&_(e,(e=>t(e,"rowspan")||t(e,"colspan")))?w.some(e):w.none()},ho=(e,t,o)=>{return t.length<=1?w.none():(n=e,r=o.firstSelectedSelector,s=o.lastSelectedSelector,ao(n,r,s).bind((e=>{const t=e=>he(n,e),o="thead,tfoot,tbody,table",r=ke(e.first,o,t),s=ke(e.last,o,t);return r.bind((t=>s.bind((o=>he(t,o)?$t(e.table,e.first,e.last):w.none()))))}))).map((e=>({bounds:e,cells:t})));var n,r,s},po="data-mce-selected",go="data-mce-first-selected",fo="data-mce-last-selected",wo={selected:po,selectedSelector:"td["+po+"],th["+po+"]",firstSelected:go,firstSelectedSelector:"td["+go+"],th["+go+"]",lastSelected:fo,lastSelectedSelector:"td["+fo+"],th["+fo+"]"},bo=e=>({element:e,mergable:w.none(),unmergable:w.none(),selection:[e]}),vo=(e,t,o)=>({element:o,mergable:ho(t,e,wo),unmergable:uo(e),selection:mo(e)}),yo=e=>(t,o)=>{const n=oe(t),r="col"===n||"colgroup"===n?bt(s=t).bind((e=>((e,t)=>((e,t)=>{const o=Ae(e,t);return o.length>0?w.some(o):w.none()})(e,t))(e,wo.firstSelectedSelector))).fold(v(s),(e=>e[0])):t;var s;return Le(r,e,o)},Co=yo("th,td,caption"),xo=yo("th,td"),So=e=>{return t=e.model.table.getSelectedCells(),N(t,Y.fromDom);var t},To=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Ro=(e,t)=>({element:e,offset:t}),Do=(e,t,o)=>e.property().isText(t)&&0===e.property().getText(t).trim().length||e.property().isComment(t)?o(t).bind((t=>Do(e,t,o).orThunk((()=>w.some(t))))):w.none(),Oo=(e,t)=>e.property().isText(t)?e.property().getText(t).length:e.property().children(t).length,Ao=(e,t)=>{const o=Do(e,t,e.query().prevSibling).getOr(t);if(e.property().isText(o))return Ro(o,Oo(e,o));const n=e.property().children(o);return n.length>0?Ao(e,n[n.length-1]):Ro(o,Oo(e,o))},Eo=Ao,ko=ro(),No={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:[""]},Wo=(()=>{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}))(.*)$`)})(),Lo=(e,t)=>w.from(Wo.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>E(t,(t=>E(No[t],(t=>e===t)))))(n,t)?w.some({value:o,unit:n}):w.none()})),Mo=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?w.none():w.some(t)})(e).getOr(t))(tt(e,t),o),jo=((e,t)=>{const o=t=>{const o=(e=>e.dom.offsetWidth)(t);if(o<=0||null===o){const o=tt(t,e);return parseFloat(o)||0}return o},n=(e,t)=>I(t,((t,o)=>{const n=tt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!f(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Ze(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}}})("width"),Bo=e=>jo.get(e),Io=e=>jo.getOuter(e),Po=e=>((e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-Mo(e,`padding-${o}`,0)-Mo(e,`padding-${n}`,0)-Mo(e,`border-${o}-width`,0)-Mo(e,`border-${n}-width`,0))(e,n,"left","right")})(e,"content-box"),zo=me("col"),_o=(e,t,o)=>{const n=(r=e,w.from(r.dom.parentElement).map(Y.fromDom)).getOrThunk((()=>(e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Y.fromDom(t)})(ge(e))));var r;return t(e)/o(n)*100},Fo=(e,t)=>{et(e,"width",t+"px")},$o=(e,t)=>{et(e,"width",t+"%")},Vo=e=>((e,t)=>nt(e,t).orThunk((()=>Ue(e,t).map((e=>e+"px")))))(e,"width"),Go=e=>_o(e,Bo,Po),qo=e=>{return zo(e)?Bo(e):Mo(t=e,"width",t.dom.offsetWidth);var t},Ho=(e,t,o)=>{et(e,"width",t+o)},Uo=v(/(\d+(\.\d+)?)%/),Ko=(e,t)=>{if(!lt(e)){const o=(e=>Vo(e).bind((e=>Lo(e,["fixed","relative","empty"]))))(e);o.each((o=>{const n=o.value/2;Ho(e,n,o.unit),Ho(t,n,o.unit)}))}},Qo=me("col"),Xo=me("colgroup"),Yo=e=>({element:e,colspan:st(e,"colspan",1),rowspan:st(e,"rowspan",1)}),Jo=(e,t=Yo)=>{const o=o=>{if((e=>"tr"===oe(e)||Xo(e))(o))return Xo((r={element:o}).element)?e.colgroup(r):e.row(r);{const r=o,s=(t=>Qo(t.element)?e.col(t):e.cell(t))(t(r));return n=w.some({item:r,replacement:s}),s}var r};let n=w.none();return{getOrInit:(e,t)=>n.fold((()=>o(e)),(n=>t(e,n.item)?n.replacement:o(e)))}},Zo=e=>N(e,v(0)),en=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},tn=en((e=>e<0)),on=en(T),nn=()=>{const e=(e,t,o,n,r)=>{const s=on(e,n>=0?o:t,n,r);return((e,t,o,n,r)=>r(e.slice(0,t)).concat(n).concat(r(e.slice(o))))(e,t,o+1,[s,-s],Zo)};return{resizeTable:(e,t,o)=>{o&&e(t)},clampTableDelta:(e,t,o,n,r)=>{if(r){if(o>=0)return o;{const t=I(e,((e,t)=>e+t-n),0);return Math.max(-t,o)}}return tn(e,t,o,n)},calcLeftEdgeDeltas:e,calcMiddleDeltas:(t,o,n,r,s,l)=>e(t,n,r,s,l),calcRightEdgeDeltas:(e,t,o,n,r,s)=>{if(s)return Zo(e);{const t=n/e.length;return N(e,v(t))}},calcRedestributedWidths:(e,t,o,n)=>({delta:0,newSizes:e})}},rn=(e,t)=>Y.fromDom(e.dom.cloneNode(t)),sn=(e,t)=>{const o=((e,t)=>{const o=Y.fromTag(t),n=Qe(e);return qe(o,n),o})(e,t),n=Ce((e=>rn(e,!0))(e));return Xt(o,n),o},ln=(me("th"),(e,t,o)=>ht(o(e.element,t),!0,e.isLocked)),cn=()=>({transformRow:y,transformCell:ln}),an=()=>mn(0,0),mn=(e,t)=>({major:e,minor:t}),un={nu:mn,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?an():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return mn(n(1),n(2))})(e,o)},unknown:an},dn=(e,t)=>{const o=String(t).toLowerCase();return P(e,(e=>e.search(o)))},hn=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,pn=e=>t=>Xe(t,e),gn=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Xe(e,"edge/")&&Xe(e,"chrome")&&Xe(e,"safari")&&Xe(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,hn],search:e=>Xe(e,"chrome")&&!Xe(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Xe(e,"msie")||Xe(e,"trident")},{name:"Opera",versionRegexes:[hn,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:pn("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:pn("firefox")},{name:"Safari",versionRegexes:[hn,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Xe(e,"safari")||Xe(e,"mobile/"))&&Xe(e,"applewebkit")}],fn=[{name:"Windows",search:pn("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Xe(e,"iphone")||Xe(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:pn("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:pn("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:pn("linux"),versionRegexes:[]},{name:"Solaris",search:pn("sunos"),versionRegexes:[]},{name:"FreeBSD",search:pn("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:pn("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],wn={browsers:v(gn),oses:v(fn)},bn="Edge",vn="Chromium",yn="Opera",Cn="Firefox",xn="Safari",Sn=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(bn),isChromium:n(vn),isIE:n("IE"),isOpera:n(yn),isFirefox:n(Cn),isSafari:n(xn)}},Tn=()=>Sn({current:void 0,version:un.unknown()}),Rn=Sn,Dn=(v(bn),v(vn),v("IE"),v(yn),v(Cn),v(xn),"Windows"),On="Android",An="Linux",En="macOS",kn="Solaris",Nn="FreeBSD",Wn="ChromeOS",Ln=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(Dn),isiOS:n("iOS"),isAndroid:n(On),isMacOS:n(En),isLinux:n(An),isSolaris:n(kn),isFreeBSD:n(Nn),isChromeOS:n(Wn)}},Mn=()=>Ln({current:void 0,version:un.unknown()}),jn=Ln,Bn=(v(Dn),v("iOS"),v(On),v(An),v(En),v(kn),v(Nn),v(Wn),e=>window.matchMedia(e).matches);let In=To((()=>((e,t,o)=>{const n=wn.browsers(),r=wn.oses(),s=t.bind((e=>((e,t)=>q(t.brands,(t=>{const o=t.brand.toLowerCase();return P(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:un.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>dn(e,t).map((e=>{const o=un.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(Tn,Rn),l=((e,t)=>dn(e,t).map((e=>{const o=un.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(Mn,jn),c=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,l=e.isiOS()||e.isAndroid(),c=l||n("(pointer:coarse)"),i=r||!s&&l&&n("(min-device-width:768px)"),a=s||l&&!i,m=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),u=!a&&!i&&!m;return{isiPad:v(r),isiPhone:v(s),isTablet:v(i),isPhone:v(a),isTouch:v(c),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:v(m),isDesktop:v(u)}})(l,s,e,o);return{browser:s,os:l,deviceType:c}})(navigator.userAgent,w.from(navigator.userAgentData),Bn)));const Pn=(e,t=T)=>{const o=e.grid,n=k(o.columns,y),r=k(o.rows,y);return N(n,(o=>zn((()=>z(r,(t=>Wt(e,t,o).filter((e=>e.column===o)).toArray()))),(e=>1===e.colspan&&t(e.element)),(()=>Wt(e,0,o)))))},zn=(e,t,o)=>{const n=e();return P(n,t).orThunk((()=>w.from(n[0]).orThunk(o))).map((e=>e.element))},_n=(e,t)=>({left:e,top:t,translate:(o,n)=>_n(e+o,t+n)}),Fn=_n,$n=(e,t)=>void 0!==e?e:void 0!==t?t:0,Vn=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return Fn(o.offsetLeft,o.offsetTop);const s=$n(null==n?void 0:n.pageYOffset,r.scrollTop),l=$n(null==n?void 0:n.pageXOffset,r.scrollLeft),c=$n(r.clientTop,o.clientTop),i=$n(r.clientLeft,o.clientLeft);return Gn(e).translate(l-i,s-c)},Gn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?Fn(o.offsetLeft,o.offsetTop):Te(e)?(e=>{const t=e.getBoundingClientRect();return Fn(t.left,t.top)})(t):Fn(0,0)},qn=(e,t)=>({col:e,x:t}),Hn=e=>Vn(e).left+Io(e),Un=e=>Vn(e).left,Kn=(e,t)=>qn(e,Un(t)),Qn=(e,t)=>qn(e,Hn(t)),Xn=(e,t,o)=>{if(0===o.length)return[];const n=N(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])},Yn=(Jn={delta:y,edge:Un,positions:e=>Xn(Kn,Qn,e)},Zn={delta:e=>-e,edge:Hn,positions:e=>Xn(Qn,Kn,e)},e=>"rtl"===(e=>"rtl"===tt(e,"direction")?"rtl":"ltr")(e)?Zn:Jn);var Jn,Zn;const er=e=>Yn(e).edge(e),tr=me("col"),or=(e,t,o,n,r,s)=>e.filter(n).fold((()=>s(((e,t)=>{if(t<0||t>=e.length-1)return w.none();const o=e[t].fold((()=>{const o=(e=>{const t=R.call(e,0);return t.reverse(),t})(e.slice(0,t));return q(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>w.some({value:e,delta:0}))),n=e[t+1].fold((()=>{const o=e.slice(t+1);return q(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>w.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}))))})(o,t))),(e=>r(e))),nr=(e,t,o,n)=>{const r=Pn(e),s=jt(e)?(e=>N(Mt(e),(e=>w.from(e.element))))(e):r,l=[w.some(er(t))].concat(N(((e,t)=>Yn(t).positions(e,t))(r,t),(e=>e.map((e=>e.x))))),c=(i=lt,e=>!i(e));var i;return N(s,((e,t)=>or(e,t,l,c,(e=>{if((e=>{const t=In().browser,o=t.isChromium()||t.isFirefox();return!tr(e)||o})(e))return o(e);{const e=((e,t)=>null!=e?t(e):w.none())(r[t],y);return or(e,t,l,c,(e=>n(w.some(Bo(e)))),n)}}),n)))},rr=(e,t,o)=>nr(e,t,qo,(e=>e.getOrThunk(o.minCellWidth))),sr=(e,t)=>()=>Te(e)?t(e):parseFloat(nt(e,"width").getOr("0")),lr=e=>Vo(e).fold((()=>(e=>{const t=sr(e,Bo),o=v(0);return{width:t,pixelWidth:t,getWidths:(t,o)=>rr(t,e,o),getCellDelta:o,singleColumnWidth:v([0]),minCellWidth:o,setElementWidth:b,adjustTableWidth:b,isRelative:!0,label:"none"}})(e)),(t=>{return o=e,n=t,null!==Uo().exec(n)?(e=>{const t=sr(e,(e=>parseFloat((e=>_o(e,Bo,Po)+"%")(e)))),o=sr(e,Bo);return{width:t,pixelWidth:o,getWidths:(t,o)=>((e,t,o)=>nr(e,t,Go,(e=>e.fold((()=>o.minCellWidth()),(e=>e/o.pixelWidth()*100)))))(t,e,o),getCellDelta:e=>e/o()*100,singleColumnWidth:(e,t)=>[100-e],minCellWidth:()=>ct()/o()*100,setElementWidth:$o,adjustTableWidth:o=>{const n=t();$o(e,n+o/100*n)},isRelative:!0,label:"percent"}})(o):(e=>{const t=sr(e,Bo);return{width:t,pixelWidth:t,getWidths:(t,o)=>rr(t,e,o),getCellDelta:y,singleColumnWidth:(e,t)=>[Math.max(ct(),e+t)-e],minCellWidth:ct,setElementWidth:Fo,adjustTableWidth:o=>{const n=t()+o;Fo(e,n)},isRelative:!1,label:"pixel"}})(o);var o,n})),cr=(e,t,o,n)=>{o===n?Ke(e,t):Ge(e,t,o)},ir=(e,t,o)=>{G(Oe(e,t)).fold((()=>Ht(e,o)),(e=>qt(e,o)))},ar=(e,t)=>{const o=[],n=[],r=e=>N(e,(e=>{e.isNew&&o.push(e.element);const t=e.element;return Yt(t),W(e.cells,(e=>{e.isNew&&n.push(e.element),cr(e.element,"colspan",e.colspan,1),cr(e.element,"rowspan",e.rowspan,1),Ut(t,e.element)})),t})),s=e=>z(e,(e=>N(e.cells,(e=>(cr(e.element,"span",e.colspan,1),e.element))))),l=(t,o)=>{const n=((e,t)=>{const o=Ne(e,t).getOrThunk((()=>{const o=Y.fromTag(t,ge(e).dom);return"thead"===t?ir(e,"caption,colgroup",o):"colgroup"===t?ir(e,"caption",o):Ut(e,o),o}));return Yt(o),o})(e,o),l=("colgroup"===o?s:r)(t);Xt(n,l)},c=(t,o)=>{t.length>0?l(t,o):(t=>{Ne(e,t).each(Jt)})(o)},i=[],a=[],m=[],u=[];return W(t,(e=>{switch(e.section){case"thead":i.push(e);break;case"tbody":a.push(e);break;case"tfoot":m.push(e);break;case"colgroup":u.push(e)}})),c(u,"colgroup"),c(i,"thead"),c(a,"tbody"),c(m,"tfoot"),{newRows:o,newCells:n}},mr=(e,t)=>{if(0===e.length)return 0;const o=e[0],n=((e,n)=>{for(let n=0,s=e.length;n{const o=N(e,(e=>N(e.cells,S)));return N(e,((n,r)=>{const s=z(n.cells,((n,s)=>{if(!1===o[r][s]){const m=((e,t,o,n)=>{const r=((e,t)=>e[t])(e,t),s="colgroup"===r.section,l=mr(r.cells.slice(o),n),c=s?1:mr(((e,t)=>N(e,(e=>St(e,t))))(e.slice(t),o),n);return{colspan:l,rowspan:c}})(e,r,s,t);return((e,t,n,r)=>{for(let s=e;sq(e.all,(e=>P(e.cells,(e=>he(t,e.element))))),hr=(e,t,o)=>{const n=(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;tgt(t).bind((t=>dr(e,t))).filter(o))));return Q(n.length>0,n)},pr=(e,t,o,n,r)=>(s,l,c,i)=>{const a=kt(s),m=w.from(null==i?void 0:i.section).getOrThunk(cn),u=t(a,l).map((t=>{const o=((e,t)=>((e,t,o)=>{const n=[];W(e.colgroups,(r=>{const s=[];for(let n=0;nht(e.element,o,!1))).getOrThunk((()=>ht(t.colGap(),!0,!1)));s.push(r)}n.push(pt(r.element,s,"colgroup",o))}));for(let r=0;rht(e.element,o,e.isLocked))).getOrThunk((()=>ht(t.gap(),!0,!1)));s.push(l)}const l=e.all[r],c=pt(l.element,s,l.section,o);n.push(c)}return n})(e,t,!1))(a,c),n=e(o,t,he,r(c),m),s=(e=>{const t=I(Rt(e).rows,((e,t)=>(W(t.cells,((t,o)=>{t.isLocked&&(e[o]=!0)})),e)),{}),o=Ie(t,((e,t)=>parseInt(t,10)));return F(o)})(n.grid);return{info:t,grid:(l=n.grid,ur(l,he)),cursor:n.cursor,lockedColumns:s};var l}));return u.bind((e=>{const t=ar(s,e.grid),r=w.from(null==i?void 0:i.sizing).getOrThunk((()=>lr(s))),l=w.from(null==i?void 0:i.resize).getOrThunk(nn);return o(s,e.grid,e.info,{sizing:r,resize:l,section:m}),n(s),Ke(s,Dt),e.lockedColumns.length>0&&Ge(s,Dt,e.lockedColumns.join(",")),w.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})}))},gr=(e,t)=>gt(t.element).bind((t=>dr(e,t))),fr=(e,t)=>hr(e,t,T),wr=(e,t)=>_(t,(t=>((e,t)=>dr(e,t).exists((e=>!e.isLocked)))(e,t))),br=(e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>wr(e,t.cells))),vr=(e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>wr(e,t))),yr=["img","br"],Cr=e=>{return(t=e,eo.getOption(t)).filter((e=>0!==e.trim().length||e.indexOf("\xa0")>-1)).isSome()||A(yr,oe(e))||(e=>{return le(t=e)&&te(t.dom)&&"false"===He(e,"contenteditable");var t})(e);var t},xr={scope:["row","col"]},Sr=e=>()=>{const t=Y.fromTag("td",e.dom);return Ut(t,Y.fromTag("br",e.dom)),t},Tr=e=>()=>Y.fromTag("col",e.dom),Rr=e=>()=>Y.fromTag("colgroup",e.dom),Dr=e=>()=>Y.fromTag("tr",e.dom),Or=(e,t,o)=>{const n=sn(e,t);return Be(o,((e,t)=>{null===e?Ke(n,t):Ge(n,t,e)})),n},Ar=(e,t,o)=>{return(n=e,((e,t)=>{const o=e=>{for(let n=0;n{const r=o.join(","),s=De(n,r,(t=>he(t,e)));return B(s,((e,t)=>{const o=rn(t,!1);return Ut(e,o),o}),t)})).getOr(t);var n},Er=(e,t,o)=>{const n=(e,t)=>{((e,t)=>{const o=e.dom,n=t.dom;Ze(o)&&Ze(n)&&(n.style.cssText=o.style.cssText)})(e.element,t),rt(t,"height"),1!==e.colspan&&rt(t,"width")};return{col:o=>{const r=Y.fromTag(oe(o.element),t.dom);return n(o,r),e(o.element,r),r},colgroup:Rr(t),row:Dr(t),cell:r=>{const s=Y.fromTag(oe(r.element),t.dom),l=o.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),c=l.length>0?Ar(r.element,s,l):s;return Ut(c,Y.fromTag("br")),n(r,s),((e,t)=>{Be(xr,((o,n)=>Ue(e,n).filter((e=>A(o,e))).each((e=>Ge(t,n,e)))))})(r.element,s),e(r.element,s),s},replace:Or,colGap:Tr(t),gap:Sr(t)}},kr=e=>kt(e).grid,Nr=(e,t=!1)=>{return Te(e)?e.dom.isContentEditable:(o=e,Le(o,"[contenteditable]")).fold(v(t),(e=>"true"===Wr(e)));var o},Wr=e=>e.dom.contentEditable,Lr=(e,t,o,n,r)=>N(e,(e=>{const s=t>0&&t{if("colgroup"!==o&&n)return St(e,t);{const t=St(e,r);return ht(l(t.element,s),!0,!1)}})(e,t,e.section,s,o,n,r);return((e,t,o)=>((e,t,o)=>{const n=e.cells,r=n.slice(0,t),s=n.slice(t),l=r.concat(o).concat(s);return xt(e,l)})(e,t,[o]))(e,t,l)})),Mr={...(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 W(e,((n,r)=>{const s=Me(n);if(1!==s.length)throw new Error("one and only one name per case");const l=s[0],c=n[l];if(void 0!==o[l])throw new Error("duplicate key detected:"+l);if("cata"===l)throw new Error("cannot have a case named cata (sorry)");if(!a(c))throw new Error("case arguments must be an array");t.push(l),o[l]=(...o)=>{const n=o.length;if(n!==c.length)throw new Error("Wrong number of arguments to case "+l+". Expected "+c.length+" ("+c+"), 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=Me(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!_(t,(e=>A(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[l].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:l,params:o})}}}})),o})([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}])},jr=(e,t)=>jt(e)?((e,t)=>{const o=Mt(e);return N(o,((e,o)=>({element:e.element,width:t[o],colspan:e.colspan})))})(e,t):((e,t)=>{const o=(e=>z(e.all,(e=>e.cells)))(e);return N(o,(e=>{const o=((e,t,o)=>{let n=0;for(let r=e;r{const n=jr(e,t);W(n,(e=>{o.setElementWidth(e.element,e.width)}))},Ir=e=>I(e,((e,t)=>E(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),Pr=e=>Nr(e,!0),zr=(e,t,o)=>((e,t)=>({grid:e,cursor:t}))(e,((e,t,o)=>{var n,r;const s=Rt(e).rows;return w.from(null===(r=null===(n=s[t])||void 0===n?void 0:n.cells[o])||void 0===r?void 0:r.element).filter(Pr).orThunk((()=>(e=>q(e,(e=>q(e.cells,(e=>{const t=e.element;return Q(Pr(t),t)})))))(s)))})(e,t,o)),_r=(e,t,o,n)=>((e,t,o,n,r)=>{const s=Nt(t),l=n.getWidths(s,n),c=n.pixelWidth(),{newSizes:i,delta:a}=r.calcRedestributedWidths(l,c,o.pixelDelta,n.isRelative);Br(s,i,n),n.adjustTableWidth(a)})(0,t,o,n.sizing,n.resize),Fr=(e,t)=>{const o=Pn(e),n=Ir(t);return I(n,((e,t)=>e+o[t.column].map(Io).getOr(0)),0)},$r=pr(((e,t,o,n)=>{const r=t.detail,s=r.column,l=r.column,c=Lr(e,l,s,o,n.getOrInit);return zr(c,r.row,l)}),((e,t)=>gr(e,t).filter((e=>!E([e],(e=>0===e.column&&e.isLocked)))).map((t=>({detail:t,pixelDelta:Fr(e,[t])})))),_r,b,Jo),Vr=pr(((e,t,o,n)=>{const r=Ir(t.details),s=((e,t)=>z(e,(e=>{const o=e.cells,n=B(t,((e,t)=>t>=0&&t0?[pt(e.element,n,e.section,e.isNew)]:[]})))(e,N(r,(e=>e.column))),l=s.length>0?s[0].cells.length-1:0;return zr(s,r[0].row,Math.min(r[0].column,l))}),((e,t)=>((e,t)=>hr(e,t,(e=>!e.isLocked)))(e,t).map((t=>({details:t,pixelDelta:-Fr(e,t)})))),_r,(e=>{0===ft(e).length&&Jt(e)}),Jo),Gr=(e,t)=>{const o=He(e,t);return void 0===o||""===o?[]:o.split(" ")},qr=e=>void 0!==e.dom.classList,Hr=e=>e.dom.textContent,Ur=me("th"),Kr=(e,t)=>e&&t?"sectionCells":e?"section":"cells",Qr=e=>{const t=M(e,(e=>Ur(e.element)));return 0===t.length?w.some("td"):t.length===e.length?w.some("th"):w.none()},Xr=e=>{const t=N(e,(e=>(e=>{const t="thead"===e.section,o=H(Qr(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:Kr(t,o)}:{type:"body"}})(e).type)),o=A(t,"header"),n=A(t,"footer");if(o||n){const e=A(t,"body");return!o||e||n?o||e||!n?w.none():w.some("footer"):w.some("header")}return w.some("body")},Yr={structure:!1,style:!0},Jr={structure:!0,style:!1},Zr=(e,t,o)=>({value:t+1}),es=(e,t,o)=>{const n="A".charCodeAt(0),r=[];let s=t;for(;s>=0;)r.push(String.fromCharCode(n+s%26)),s=Math.floor(s/26)-1;return{value:r.reverse().join("")}},ts=e=>e.options.get("advtable_value_series"),os=e=>{const t=parseFloat(e);return isNaN(t)?w.none():w.some(t)},ns=(e,t)=>et?1:0,rs=(e,t)=>U(os(e),os(t),ns).getOrThunk((()=>((e,t)=>e.localeCompare(t))(e,t))),ss=e=>{const t=(e=>w.from(e.options.get("table_clone_elements")))(e),o=(o,r,s,l)=>(c,i,a,m,u=!1)=>{const d=Y.fromDom(e.getDoc()),h=Er(s,d,t);return r(c)?o(c,i,h).bind((t=>{W(t.newRows,(t=>{((e,t)=>{e.dispatch("NewRow",{node:t})})(e,t.dom)})),W(t.newCells,(t=>{((e,t)=>{e.dispatch("NewCell",{node:t})})(e,t.dom)}));const o=((t,o,r,s)=>{const l=r.filter((e=>Te(e)&&n(e))).or(o.cursor);return l.fold((()=>{const o=ft(t);return V(o).filter(Te).map((o=>{const n=e.dom.createRng();return n.selectNode(o.dom),s&&(e.model.table.clearSelectedCells(t.dom),e.selection.setRng(n),Ge(o,"data-mce-selected","1")),n}))}),(o=>{const n=e.dom.createRng(),r=Eo(ko,o);return n.setStart(r.element.dom,r.offset),n.setEnd(r.element.dom,r.offset),s&&(e.model.table.clearSelectedCells(t.dom),e.selection.setRng(n)),w.some(n)}))})(c,t,a,m);return Te(c)&&((e=>{Ke(e,"data-mce-style");const t=e=>Ke(e,"data-mce-style");W(ft(e),t),W(wt(e),t),W(vt(e),t)})(c),u||((e,t,o)=>{e.dispatch("TableModified",{...o,table:t})})(e,c.dom,l)),o.map((e=>({rng:e,effect:l})))})):w.none()},n=e=>Nr(e,!0),r=(e,t,o)=>((e,t)=>({grid:e,cursor:t}))(e,((e,t,o)=>{var r,s;const l=Rt(e).rows;return w.from(null===(s=null===(r=l[t])||void 0===r?void 0:r.cells[o])||void 0===s?void 0:s.element).filter(n).orThunk((()=>(e=>q(e,(e=>q(e.cells,(e=>{const t=e.element;return Q(n(t),t)})))))(l)))})(e,t,o)),s=(e,t,o,n)=>{const{cols:r,rows:s}=Rt(e),l=j(s,(e=>e.section)),c=N(l,(e=>j(e,(e=>{const o=St(e,t).element;return oe(o)})))),i=z(c,(e=>z(e,(e=>{const r=St(e[0],t).element;return"th"===oe(r)?e:(e=>{const r=N(e,(e=>{const o=St(e,t).element;return{row:e,text:w.from(Hr(o)).getOr("")}})),s=F(r,((e,t)=>{const r=o(e.text,t.text);return n?r:-1*r}));return N(s,(e=>e.row))})(e)}))));return[...r,...i]},l=(e,t,o,n)=>{const{cols:r,rows:s}=Rt(e),l=s[t].cells,c=N(l,(e=>{const t=e.element;return w.from(Hr(t)).getOr("")})),i=me("th"),a=N(s,(e=>{const t=N(e.cells,((e,t)=>({cell:e,column:t,reference:l[t],referenceText:c[t]})));return{...e,zippedCells:t}})),m=N(a,(e=>{const t=j(e.zippedCells,(e=>{const t=e.reference.element;return oe(t)})),r=z(t,(e=>{const t=e[0].reference.element;if(i(t))return N(e,(e=>e.cell));{const{pass:t,fail:r}=L(e,(e=>e.cell.isLocked)),s=F(r,((e,t)=>{const r=o(e.referenceText,t.referenceText);return n?r:-1*r})),l=I(t,((e,t)=>{const o=t.column,n=e.slice(0,o),r=e.slice(o);return n.concat([t]).concat(r)}),s);return N(l,(e=>e.cell))}}));return pt(e.element,r,e.section,e.isNew)}));return[...r,...m]},u=s,d=l,h=(e,t,o,n,r)=>{const{cols:s,rows:l}=Rt(e),c=l.slice(0,t),i=[...s,...l.slice(t,o+1)];return{beforeRows:c,afterRows:l.slice(o+1,e.length),selectionGridBefore:i.map((e=>({...e,cells:e.cells.slice(0,n)}))),selectionGrid:i.map((e=>({...e,cells:e.cells.slice(n,r+1)}))),selectionGridAfter:i.map((e=>({...e,cells:e.cells.slice(r+1,e.cells.length)})))}},p=(e,t)=>{const o=N(t,((t,o)=>{const n=e.selectionGridBefore[o].cells,r=e.selectionGridAfter[o].cells;return{...t,cells:n.concat(t.cells).concat(r)}})),{cols:n,rows:r}=Rt(o);return[...n,...e.beforeRows,...r,...e.afterRows]},g=(e,t,o,n,r,l,c,i)=>{const a=h(e,o,n,r,l),m=s(a.selectionGrid,t-r,c,i);return p(a,m)},C=(e,t,o,n,r,s,c,i)=>{const a=h(e,o,n,r,s),m=l(a.selectionGrid,t-o,c,i);return p(a,m)},x=e=>I(e,((e,t)=>E(e,(e=>e.row===t.row))?e:e.concat([t])),[]).sort(((e,t)=>e.row-t.row)),S=e=>I(e,((e,t)=>E(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),R=e=>I(e,((e,t)=>E(e,(e=>he(e.element,t.element)))?e:e.concat([t])),[]),D=e=>{const t=i(e.attributes)?Ie(e.attributes,((e,t)=>m(e)?e=>Ke(e,t):o=>Ge(o,t,e))):[];return[...t,...((e,t)=>{if(a(e)){for(let o=0,n=e.length;ot=>((e,t)=>{qr(e)?e.dom.classList.add(t):((e,t)=>{((e,t,o)=>{const n=Gr(e,t).concat([o]);Ge(e,t,n.join(" "))})(e,"class",t)})(e,t)})(t,e))):[],t=>{const o=Hr(t)||"",n=(r=e.value,f(r)?String(r):c(r)?r:void 0);var r;const s=c(n)?n:o;Je(s)?((e,t)=>{const o=ge(e).dom,n=Y.fromDom(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Ce(Y.fromDom(o))})(t,o);Xt(n,r),Yt(e),Ut(e,n)})(t,"
"):((e,t)=>{e.dom.textContent=t})(t,s)}]},O=(e,t,o,n,r,s,l,c)=>{let i;W(t,((t,a)=>{const m=t.element,u={sectionType:s(a),cellType:oe(m),getRowType:l(a),getColType:c(a),classes:(p=m,qr(p)?(e=>{const t=e.dom.classList,o=new Array(t.length);for(let e=0;eGr(e,"class"))(p)),prev:null==i?void 0:i.raw,direction:o},d=e(u,n(a),r(a)),h=D(d);var p;W(h,(e=>e(m))),i=d}))},A=(e,t,o,n,s)=>{const l=g(e,s,0,e.length,s,s,o,n);return r(l,t[0].row,t[0].column)},k=(e,t,o,n,s)=>{const l=x(t),c=S(t),i=g(e,s,l[0].row,l[l.length-1].row,c[0].column,c[c.length-1].column,o,n);return r(i,t[0].row,t[0].column)},M=(e,t,o,n,s)=>{const l=u(e,s,o,n);return r(l,t.row,t.column)},B=(e,t,o,n,s)=>{const l=C(e,s,s,s,0,e[t[0].row].cells.length,o,n);return r(l,t[0].row,t[0].column)},P=(e,t,o,n,s)=>{const l=x(t),c=S(t),i=C(e,s,l[0].row,l[l.length-1].row,c[0].column,c[c.length-1].column,o,n);return r(i,t[0].row,t[0].column)},_=(e,t,o,n,s)=>{const l=d(e,s,o,n);return r(l,t.row,t.column)},$=(e,t,o,n)=>{const s=Rt(e).rows,l=N(s,(e=>St(e,n))),c=R(l),i=To((()=>Qr(c).getOr("")));return O(o,c,"column",y,v(n),(e=>s[e].section),(e=>To((()=>{const t=s[e];return Xr([{cells:t.cells,section:t.section}]).getOr("")}))),(e=>i)),r(e,t.row,t.column)},G=(e,t,o,n)=>{const s=Rt(e).rows,l=s[n],c=R(l.cells),i=To((()=>Xr([{cells:l.cells,section:l.section}]).getOr("")));return O(o,c,"row",v(n),y,(e=>l.section),(e=>i),(e=>To((()=>{const t=N(s,(t=>St(t,e)));return Qr(t).getOr("")})))),r(e,t.row,t.column)},H=(e,t,o,n,r)=>(s,l,c)=>{const i=pr(((r,s)=>e(r,s,t,o,n)),r,b,b,Jo);return i(s,l,c)},U=(e,t,o,n)=>(r,s,l)=>{const c=pr(((n,r)=>e(n,r,t,o)),n,b,b,Jo);return c(r,s,l)},K=o($r,T,Ko,Jr),X=o(Vr,(t=>0==("table"===oe(It(e)))||kr(t).columns>1),b,Jr);return{sortColumnRowsAsc:e=>o(H(A,rs,!0,e,fr),T,b,Jr),sortColumnRowsDesc:e=>o(H(A,rs,!1,e,fr),T,b,Jr),sortSelectionRowsAsc:e=>o(H(k,rs,!0,e,fr),T,b,Jr),sortSelectionRowsDesc:e=>o(H(k,rs,!1,e,fr),T,b,Jr),sortTableRowsAsc:e=>o(H(M,rs,!0,e,gr),T,b,Jr),sortTableRowsDesc:e=>o(H(M,rs,!1,e,gr),T,b,Jr),sortRowColumnsAsc:e=>o(H(B,rs,!0,e,fr),T,b,Jr),sortRowColumnsDesc:e=>o(H(B,rs,!1,e,fr),T,b,Jr),sortSelectionColumnsAsc:e=>o(H(P,rs,!0,e,fr),T,b,Jr),sortSelectionColumnsDesc:e=>o(H(P,rs,!1,e,fr),T,b,Jr),sortTableColumnsAsc:e=>o(H(_,rs,!0,e,gr),T,b,Jr),sortTableColumnsDesc:e=>o(H(_,rs,!1,e,gr),T,b,Jr),insertColumnBefore:K,deleteColumn:X,populateColumn:(e,t)=>o(U($,t,e,gr),T,b,Yr),populateRow:(e,t)=>o(U(G,t,e,gr),T,b,Yr)}},ls="data-snooker-locked-cols",cs=e=>Ue(e,ls).map((e=>z(e.split(","),(e=>{const t=parseInt(e,10);return isNaN(t)?[]:[t]})))).getOr([]),is=(e,t)=>Ge(e,ls,F(t).join(",")),as=(e,t)=>{const o=cs(e);A(o,t)||is(e,o.concat([t]))},ms=(e,t)=>{const o=cs(e);is(e,M(o,(e=>t!==e)))},us="data-snooker-col-series",ds=e=>Ue(e,us),hs=(e,t)=>H(ds(e).map((e=>e.toLowerCase())),t.toLowerCase()),ps=e=>((e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)})(e,us),gs=e=>{const t=lr(e),o=kt(e),n=Wt(o,0,0).bind((e=>{const t=e.element;return Lo(tt(t,"width"),["fixed"])})).map((e=>28-e.value)).getOr(0);((e,t,o,n,r)=>{const s=kt(e),l=r.getCellDelta(t),c=r.getWidths(s,r),i=0==s.grid.columns-1,a=n.clampTableDelta(c,0,l,r.minCellWidth(),i),m=((e,t,o,n,r)=>{const s=e.slice(0),l=((e,t)=>0===e.length?Mr.none():1===e.length?Mr.only(0):0===t?Mr.left(0,1):t===e.length-1?Mr.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,l)=>r.calcMiddleDeltas(s,e,t,l,o,n.minCellWidth(),n.isRelative)),((e,t)=>r.calcRightEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)))})(c,0,a,r,n),u=N(m,((e,t)=>e+c[t]));Br(s,u,r),n.resizeTable(r.adjustTableWidth,a,i)})(e,n,0,nn(),t)},fs=(e,t,o,n,r)=>{((e,t)=>{const o=E(cs(e),(e=>0===e));o&&ms(e,0),t(),o&&as(e,1)})(e,(()=>{o.column(0,t.insertColumnBefore,!0,!0),gs(e),ws(e,t,o,n,r)}))},ws=(e,t,o,n,r)=>{o.table(e,0,0,t.populateColumn(0,((e,t,o)=>{const n=r.generator(e,t,o);return{raw:n,value:n.value,classes:n.classes,attributes:{contenteditable:"false",...n.attributes,"data-mce-resize":!1===r.resizable?"false":null}}})),!0,!0),((e,t)=>{Ge(e,us,t)})(e,n),as(e,0)},bs=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},vs=e=>bt(zt(e),Pt(e)),ys=(e,t)=>{e.execCommand("mceTableToggleSeries",!1,t)},Cs=(e,t,o)=>t.onSetupCellOrRowToggle((()=>((e,t)=>vs(e).exists((e=>Je(t)?!ps(e):hs(e,t))))(e,o))),xs=(e,t)=>({type:"togglemenuitem",text:"None",onAction:()=>{(e=>vs(e).bind(ds))(e).each((t=>{ys(e,{name:t})}))},onSetup:Cs(e,t,"")}),Ss=(e,t,o,n,r)=>({type:"togglemenuitem",text:o,value:n,icon:r,onAction:()=>ys(e,{name:n}),onSetup:Cs(e,t,n)}),Ts=(e,t,o)=>Ie(o,((o,n)=>{const r=w.from(o.title).getOrThunk((()=>{return""===(e=n)?"":e.charAt(0).toUpperCase()+e.substring(1);var e}));return Ss(e,t,r,n)})),Rs=e=>t=>{const o=t.getData();t.close(),e.undoManager.transact((()=>{e.execCommand("mceSortTableAdvanced",!1,o),e.focus(),e.addVisual()}))},Ds=e=>{const t={type:"listbox",name:"sortby",label:"Sort by",items:[{text:"Column",value:"column"},{text:"Row",value:"row"}]},o=bs(w.none()),n=t=>({type:"listbox",name:"roworcol",label:"column"===t?"Column":"Row",items:"column"===t?(()=>{const t=o.get().getOrDie("state must be present"),n=t.limit?t.finishCol+1-t.startCol:t.columns;return k(n,(o=>{const n=t.limit?t.startCol:0,r=(e=>{let t=e,o="";for(;Math.floor(t)>0;)--t,o+=String.fromCharCode("A".charCodeAt(0)+t%26),t/=26;return o.split("").reverse().join("")})(o+n+1);return{text:e.translate(["Column {0}",r]),value:`${o+n}`}}))})():(()=>{const t=o.get().getOrDie("state must be present"),n=t.limit?t.finishRow+1-t.startRow:t.rows;return k(n,(o=>{const n=t.limit?t.startRow:0,r=(o+n+1).toString();return{text:e.translate(["Row {0}",r]),value:`${o+n}`}}))})()}),r=e=>({type:"listbox",name:"sort",label:"Sort",items:["column"===e?{text:"Column",value:"column"}:{text:"Row",value:"row"},{text:"Selection",value:"selection"},{text:"Table",value:"table"}]}),s={type:"listbox",name:"order",label:"Order",items:[{text:"Ascending",value:"ascending"},{text:"Descending",value:"descending"}]},l=e=>({type:"panel",items:[{type:"grid",columns:2,items:[t,n(e),r(e),s]}]}),c=e=>({title:"Advanced Sort",size:"normal",body:l(e),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"sort",text:"Sort",primary:!0}]}),i=()=>{o.set(w.none())},a=(t,n)=>{if("sortby"===n.name){const n=t.getData(),l=(r=n,s=o.get().getOrDie("state must be present"),"column"===r.sortby?{sortby:"column",roworcol:`${s.startCol}`,sort:"row"===r.sort?"column":r.sort,order:r.order}:{sortby:"row",roworcol:`${s.startRow}`,sort:"column"===r.sort?"row":r.sort,order:r.order}),m={...c(n.sortby),onChange:a,onClose:i,onSubmit:Rs(e),initialData:l};t.redial(m),t.focus("sortby")}var r,s};xo(zt(e)).each((t=>{bt(t,Pt(e)).each((n=>{const r=vo(So(e),n,t),s=t=>{o.set(w.some(t));const n={sortby:"column",roworcol:`${t.startCol}`,sort:"column",order:"ascending"},r={...c("column"),onChange:a,onClose:i,onSubmit:Rs(e),initialData:n};e.windowManager.open(r)},l=kr(n);r.mergable.fold((()=>{$t(n,t,t).each((e=>{const t={...e,...l,limit:!1};s(t)}))}),(e=>{const t={...e.bounds,...l,limit:!0};s(t)}))}))}))},Os=(e,t,o,n)=>{const r=e=>"selection"===e,s=e=>"ascending"===e,l=t=>bt(t,Pt(e)),i=()=>xo(zt(e),Pt(e)).bind((e=>l(e).bind((t=>$t(t,e,e))))),a=()=>i().map((e=>e.startCol)),m=()=>i().map((e=>e.startRow));e.addCommand("mceSortTableByColumnAsc",(()=>{a().each((e=>{o.selection(t.sortTableRowsAsc(e))}))})),e.addCommand("mceSortTableByColumnDesc",(()=>{a().each((e=>{o.selection(t.sortTableRowsDesc(e))}))})),e.addCommand("mceSortTableByRowAsc",(()=>{m().each((e=>{o.selection(t.sortTableColumnsAsc(e))}))})),e.addCommand("mceSortTableByRowDesc",(()=>{m().each((e=>{o.selection(t.sortTableColumnsDesc(e))}))})),e.addCommand("mceSortTableAdvanced",((e,n)=>(e=>{const n=parseInt(e.roworcol,10);"column"===e.sortby?((e,n)=>{(e=>"column"===e)(e.sort)?s(e.order)?o.selection(t.sortColumnRowsAsc(n)):o.selection(t.sortColumnRowsDesc(n)):r(e.sort)?s(e.order)?o.selection(t.sortSelectionRowsAsc(n)):o.selection(t.sortSelectionRowsDesc(n)):s(e.order)?o.selection(t.sortTableRowsAsc(n)):o.selection(t.sortTableRowsDesc(n))})(e,n):((e,n)=>{(e=>"row"===e)(e.sort)?s(e.order)?o.selection(t.sortRowColumnsAsc(n)):o.selection(t.sortRowColumnsDesc(n)):r(e.sort)?s(e.order)?o.selection(t.sortSelectionColumnsAsc(n)):o.selection(t.sortSelectionColumnsDesc(n)):s(e.order)?o.selection(t.sortTableColumnsAsc(n)):o.selection(t.sortTableColumnsDesc(n))})(e,n)})(n))),e.addCommand("mceAdvancedTableSort",(()=>Ds(e))),e.addCommand("mceTableToggleSeries",((r,s)=>{const i=w.from(s.name).filter(c),a=l(zt(e));U(i,a,((e,r)=>{hs(r,e)?((e,t,o)=>{ms(e,0),(e=>{Ke(e,us)})(e),o.column(0,t.deleteColumn,!0,!0)})(r,t,o):_e(n,e).each((n=>{(ps(r)?ws:fs)(r,t,o,e,n)}))}))}))},As=e=>{const t=bs(w.none()),o=bs([]);let n=w.none();const r=me("caption"),s=()=>Co(zt(e),Pt(e)).bind((t=>K(U(bt(t),Co((e=>Y.fromDom(e.selection.getEnd()))(e),Pt(e)).bind(bt),((o,n)=>he(o,n)?r(t)?w.some(bo(t)):w.some(vo(So(e),o,t)):w.none()))))),l=e=>bt(e.element).map((t=>{const o=kt(t),n=fr(o,e).getOr([]),r=I(n,((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:br(o,e).isSome(),unmergeable:vr(o,e).isSome(),locked:r}})),c=()=>{t.set(To(s)()),n=t.get().bind(l),W(o.get(),(e=>e()))},i=e=>(e(),o.set(o.get().concat([e])),()=>{o.set(M(o.get(),(t=>t!==e)))}),a=(e,o)=>i((()=>t.get().fold((()=>{e.setEnabled(!1)}),(t=>{e.setEnabled(!o(t))}))));return e.on("NodeChange ExecCommand TableSelectorChange",c),{onSetupTable:e=>a(e,(e=>!1)),onSetupCellOrRow:e=>a(e,(e=>r(e.element))),onSetupColumn:e=>t=>a(t,(t=>r(t.element)||(e=>n.exists((t=>t.locked[e])))(e))),onSetupCellOrRowToggle:e=>o=>((e,o,n)=>i((()=>t.get().fold((()=>{e.setEnabled(!1),e.setActive(!1)}),(t=>{e.setEnabled(!(e=>r(e.element))(t)),e.setActive(n(t))})))))(o,0,e),resetTargets:c,targets:()=>t.get()}};tinymce.PluginManager.requireLangPack("advtable","ar,bg_BG,ca,cs,da,de,el,es,eu,fa,fi,fr_FR,he_IL,hi,hr,hu_HU,id,it,ja,kk,ko_KR,ms,nb_NO,nl,pl,pt_BR,pt_PT,ro,ru,sk,sl_SI,sv_SE,th_TH,tr,uk,vi,zh_CN,zh_TW"),tinymce.PluginManager.add("advtable",(e=>{if(((e,o)=>!!e&&-1===((e,o)=>{const n=t(e.major,o.major);if(0!==n)return n;const r=t(e.minor,o.minor);if(0!==r)return r;const s=t(e.patch,o.patch);return 0!==s?s:0})((e=>n((e=>[e.majorVersion,e.minorVersion].join(".").split(".").slice(0,3).join("."))(e)))(e),n(o)))(tinymce,"6.0.0"))return console.error("Please use Advanced Tables with TinyMCE 6.0.0 or later."),{};(e=>{(0,e.options.register)("advtable_value_series",{processor:"object",default:{numeric:{title:"Numeric",update:!0,resizable:!1,generator:Zr},alpha:{title:"Alpha",update:!0,resizable:!1,generator:es}}})})(e);const o=ss(e),r=As(e),s=(e=>{const t=t=>{e.focus()},o=t=>bt(t,Pt(e)),n=(n,r,s,l,c)=>{xo(zt(e)).each((e=>{o(e).each((o=>{const i=kt(o),a=(e,t)=>Lt(i,e,he).map((e=>e[t])),m=n.orThunk((()=>a(e,"row"))),u=r.orThunk((()=>a(e,"column"))),d=K(U(m,u,((e,t)=>Wt(i,e,t).map((e=>e.element)))));d.bind((t=>{const n=bo(t);return s(o,n,Q(l,e),!0,c)})).each(t)}))}))};return{selection:(n,r)=>{xo(zt(e)).each((s=>{o(s).each((o=>{const l=vo(So(e),o,s);n(o,l,w.none(),!0,r).each(t)}))}))},row:(e,t,o,r)=>n(w.some(e),w.none(),t,o,r),column:(e,t,o,r)=>n(w.none(),w.some(e),t,o,r),table:(o,n,r,s,l,c)=>{const i=kt(o),a=Wt(i,n,r).map((e=>e.element)),m=xo(zt(e)),u=m.bind((e=>Lt(i,e,he))).isSome(),d=a.bind((e=>{const t=bo(e),n=u&&l?m:w.none();return s(o,t,n,u,c)}));d.each(t)}}})(e),l=ts(e);return Os(e,o,s,l),((e,t,o,n)=>{const r=()=>bt(zt(e),Pt(e)),s=(s,l=T)=>{const c=ds(s),i=c.bind((e=>_e(n,e)));U(c,i,((n,c)=>{1===kt(s).grid.columns?r().exists((e=>he(s,e)))?e.execCommand("mceTableDelete"):e.undoManager.transact((()=>{Jt(s)})):!0===c.update&&l()&&ws(s,t,o,n,c)}))};e.on("TableModified",(e=>{const t=Y.fromDom(e.table);s(t,(()=>!1!==e.structure))})),e.on("PreInit",(()=>{((e,t)=>{const o=e=>{const t=[];return h(e)?t:((e=>"thead"===e.name||"tbody"===e.name||"tfoot"===e.name)(e)?t.push(...o(e.firstChild)):"tr"===e.name&&t.push(e),t.concat(o(e.next)))},n=e=>o(e.firstChild);e.parser.addAttributeFilter(us,(e=>{var o;for(const r of e)if("table"===r.name){const e=r.attr(us);if(!1===(null===(o=t[e])||void 0===o?void 0:o.resizable)){const e=n(r);for(const t of e)p(t.firstChild)&&t.firstChild.attr("data-mce-resize","false")}}}))})(e,n)})),e.on("init",(()=>{const t=()=>{const t=xo(zt(e),Pt(e));return e.selection.isCollapsed()&&t.exists((t=>e.dom.isEmpty(t.dom)))};e.on("ExecCommand",(e=>{const o=e.command.toLowerCase();"delete"!==o&&"forwarddelete"!==o||!t()||r().each(s)}),!0),e.on("keyup",(e=>{const o=e.keyCode;8!==o&&46!==o||!t()||r().each(s)}))}))})(e,o,s,l),e.hasPlugin("table")&&(((e,t)=>{const o=(t,o)=>()=>e.execCommand(t,!1,o),n=t.onSetupCellOrRow,r=[{type:"menuitem",text:"Sort table by column ascending",onAction:o("mceSortTableByColumnAsc"),onSetup:n},{type:"menuitem",text:"Sort table by column descending",onAction:o("mceSortTableByColumnDesc"),onSetup:n},{type:"separator"},{type:"menuitem",text:"Advanced sort...",onAction:()=>Ds(e),onSetup:n}];e.ui.registry.addNestedMenuItem("advtablesort",{type:"nestedmenuitem",text:"Sort",getSubmenuItems:v(r)});const s=ts(e);if(1===ze(s)){const o=Me(s)[0];e.ui.registry.addToggleMenuItem("advtablerownumbering",Ss(e,t,"Row numbering",o,"table-row-numbering"))}else $e(s)||e.ui.registry.addNestedMenuItem("advtablerownumbering",{type:"nestedmenuitem",text:"Row numbering",icon:"table-row-numbering",getSubmenuItems:()=>{const o=xs(e,t),n=Ts(e,t,s);return[o].concat(n)}})})(e,r),((e,t)=>{const o=ts(e);if(1===ze(o)){const n=Me(o)[0];e.ui.registry.addToggleButton("advtablerownumbering",{type:"togglebutton",tooltip:"Row numbering",icon:"table-row-numbering",onAction:()=>ys(e,{name:n}),onSetup:Cs(e,t,n)})}else $e(o)||e.ui.registry.addMenuButton("advtablerownumbering",{type:"menubutton",icon:"table-row-numbering",tooltip:"Row numbering",fetch:n=>{const r=xs(e,t),s=Ts(e,t,o);return n([r].concat(s))},onSetup:t.onSetupCellOrRow})})(e,r)),{}}))}(); \ No newline at end of file diff --git a/plugins/advtemplate/plugin.min.js b/plugins/advtemplate/plugin.min.js new file mode 100644 index 0000000..2c68275 --- /dev/null +++ b/plugins/advtemplate/plugin.min.js @@ -0,0 +1,10 @@ +/*! + * Tiny Advanced Template plugin + * + * Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc. + * Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/ + * + * Version: 1.3.0-38 + */ + +!function(){"use strict";const e=e=>parseInt(e,10),t=(e,t)=>{const n=e-t;return 0===n?0:n>0?1:-1},n=(e,t,n)=>({major:e,minor:t,patch:n}),a=t=>{const a=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return a?n(e(a[1]),e(a[2]),e(a[3])):n(0,0,0)},r=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=a=e,(r=String).prototype.isPrototypeOf(n)||(null===(o=a.constructor)||void 0===o?void 0:o.name)===r.name)?"string":t;var n,a,r,o})(t)===e,o=e=>t=>typeof t===e,i=r("string"),l=r("object"),s=r("array"),c=o("boolean"),m=(void 0,e=>undefined===e);const d=e=>null==e,p=e=>!d(e),u=o("function"),g=o("number"),y=()=>{},v=e=>()=>e,h=e=>e,f=e=>e(),_=v(!1),b=v(!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 p(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.slice,C=Array.prototype.indexOf,S=Array.prototype.push,A=(e,t)=>((e,t)=>C.call(e,t))(e,t)>-1,T=(e,t)=>{const n=e.length,a=new Array(n);for(let r=0;r{for(let n=0,a=e.length;n(e=>{const t=[];for(let n=0,a=e.length;n{for(let n=0,a=e.length;n((e,t)=>0{const t=t=>t(e),n=v(e),a=()=>r,r={tag:!0,inner:e,fold:(t,n)=>n(e),isValue:b,isError:_,map:t=>j.value(t(e)),mapError:a,bind:t,exists:t,forall:t,getOr:n,or:a,getOrThunk:n,orThunk:a,getOrDie:n,each:t=>{t(e)},toOptional:()=>w.some(e)};return r},N=e=>{const t=()=>n,n={tag:!1,inner:e,fold:(t,n)=>t(e),isValue:_,isError:b,map:t,mapError:t=>j.error(t(e)),bind:t,exists:_,forall:b,getOr:h,or:h,getOrThunk:f,orThunk:f,getOrDie:(a=String(e),()=>{throw new Error(a)}),each:y,toOptional:w.none};var a;return n},j={value:I,error:N,fromOption:(e,t)=>e.fold((()=>N(t)),I)},k=Object.keys,$=Object.hasOwnProperty,R=(e,t)=>$.call(e,t),B=e=>i(e)&&e.length>0,L=e=>B(e),z=e=>R(e,"id")&&L(e.id),U=e=>R(e,"title")&&B(e.title),V=e=>R(e,"content")&&B(e.content),K=e=>l(e)&&z(e)&&U(e)&&R(e,"items")&&F(e.items),q=e=>l(e)&&z(e)&&U(e)&&(e=>!R(e,"items")||F(e.items))(e),F=e=>s(e)&&O(e,q),H=e=>R(e,"items")&&W(e.items),G=e=>l(e)&&U(e)&&((e=>V(e))(e)||H(e)),W=e=>s(e)&&O(e,G),Y=(e,t)=>n=>e(n)?j.value(n):j.error(t),J=Y((e=>l(e)&&(e=>{for(const t in e)if($.call(e,t))return!1;return!0})(e)),"response should contain empty object"),Q=Y((e=>l(e)&&z(e)),"response should contain id"),X=Y((e=>l(e)&&z(e)&&U(e)&&V(e)),"response contains invalid template data"),Z=e=>F(e)?(e=>{const t=e=>D(e,(e=>K(e)?[e.id,...t(e.items)]:[e.id])),n=t(e);return n.length===[...new Set(n)].length})(e)?j.value(e):j.error("response contains duplicated ids"):j.error("response contains invalid data"),ee=e=>t=>t.options.get(e),te=e=>{const t=(t,n)=>{var a,r;a=t,r=(e,t)=>(...a)=>((e,t,n)=>{return l(a=n)&&u(a.then)&&u(a.catch)?n.then((n=>t(n).fold((t=>Promise.reject(new P(`${e} ${t}`))),(e=>Promise.resolve(e))))):Promise.reject(new P(`${e} should return a Promise`));var a})(e,n,t(...a)),e.options.register(a,{processor:e=>u(e)?{valid:!0,value:r(a,e)}:{valid:!1,message:"Must be a function returning promise"},default:()=>Promise.reject(new P(`${a} option is not configured`))})};t("advtemplate_create_category",Q),t("advtemplate_rename_category",J),t("advtemplate_move_category_items",J),t("advtemplate_delete_category",J),t("advtemplate_create_template",Q),t("advtemplate_rename_template",J),t("advtemplate_update_template",J),t("advtemplate_move_template",J),t("advtemplate_get_template",X),t("advtemplate_delete_template",J),t("advtemplate_delete_all",J),t("advtemplate_list",Z),e.options.register("advtemplate_templates",{processor:W})},ne=ee("advtemplate_create_category"),ae=ee("advtemplate_rename_category"),re=ee("advtemplate_move_category_items"),oe=ee("advtemplate_delete_category"),ie=ee("advtemplate_create_template"),le=ee("advtemplate_rename_template"),se=ee("advtemplate_move_template"),ce=ee("advtemplate_get_template"),me=ee("advtemplate_delete_template"),de=ee("advtemplate_list"),pe=ee("advtemplate_templates"),ue=ee("content_style"),ge=ee("body_class"),ye=ee("content_css_cors"),ve=(e,t)=>e?w.some(t):w.none();let he=0;const fe=()=>{const e=(e=>{const t=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})(w.none()),n=()=>t.get().each(e);return{clear:()=>{n(),t.set(w.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{n(),t.set(w.some(e))}}})(y);return{...e,on:t=>e.get().each(t)}},_e=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},be=(e,t)=>{const n=(t||document).createElement(e);return _e(n)},we=_e;"undefined"!=typeof window?window:Function("return this;")();const xe="{{mce-cursor}}",Ce=(e,t)=>{((e,t)=>ve(-1!==t.indexOf(xe),t).bind((t=>{const n=tinymce.html.DomParser(void 0,e.schema),a=fe();var r;n.addNodeFilter("#text",(r=a,e=>{((e,t)=>{for(let n=0;nw.from(e.value).map((t=>({node:e,textContent:t,index:t.indexOf(xe)}))).filter((({index:e})=>-1!==e)))).each((({node:e,textContent:t,index:n})=>{const a=tinymce.html.Node.create("span");if(n>0){const e=tinymce.html.Node.create("#text");e.value=t.substring(0,n),a.append(e)}const o=(e=>{const t=(new Date).getTime(),n=Math.floor(1e9*Math.random());return he++,"advtemplate-cursor-marker_"+n+he+String(t)})();r.set(o);const i=tinymce.html.Node.create("span",{"data-mce-id":o,"data-mce-cursor-marker":"true"}),l=tinymce.html.Node.create("#text");if(l.value="\ufeff",i.append(l),a.append(i),t.length>n+14){const e=tinymce.html.Node.create("#text");e.value=t.substring(n+14,t.length),a.append(e)}e.replace(a),a.unwrap()}))}));const o=n.parse(t,{insert:!0});return ve(a.isSet(),{content:tinymce.html.Serializer({validate:!0},e.schema).serialize(o),cursorMarkerId:a.get().getOrDie()})})))(e,t).fold((()=>e.insertContent(t)),(({cursorMarkerId:t,content:n})=>{e.undoManager.transact((()=>{e.insertContent(n),((e,t)=>{const n=we(e.getBody());var a,r;(a=n,r=`span[data-mce-id="${t}"]`,((e,t)=>{const n=void 0===t?document:t.dom;return 1!==(a=n).nodeType&&9!==a.nodeType&&11!==a.nodeType||0===a.childElementCount?w.none():w.from(n.querySelector(e)).map(we);var a})(r,a)).each((t=>{const n=e.dom.createRng();n.setStartAfter(t.dom),n.setEndAfter(t.dom),e.selection.setRng(n),e.selection.scrollIntoView(),(e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)})(t)}))})(e,t)}))}))},Se=(e,t)=>ce(e)(t).then((t=>{Ce(e,t.content)})),Ae={text:"Uncategorized",value:""},Te=(e,t)=>{const n=((e,n)=>{const a=[];for(let n=0,o=e.length;n({text:t,value:e})))]},Ee=(e,t)=>{return(n=t,a=t=>K(t)&&A(T(t.items,(({id:e})=>e)),e),((e,t,n)=>{for(let a=0,r=e.length;ae.id)).getOr(Ae.value);var n,a},De=e=>ve(e!==Ae.value,e).getOrUndefined(),Oe=(e,t,n)=>e.options.isSet(t)?[n]:[],Me=(e,t,n)=>{const a=e=>{const a=[...Oe(n,"advtemplate_rename_category",{type:"menuitem",text:"Rename...",onAction:t.renameCategory(e)}),...Oe(n,"advtemplate_move_category_items",{type:"menuitem",text:"Move all items...",enabled:e.items.length>0,onAction:t.moveCategoryItems(e.id)}),...Oe(n,"advtemplate_delete_category",{type:"separator"}),...Oe(n,"advtemplate_delete_category",{type:"menuitem",icon:"remove",text:"Delete all",onAction:t.deleteCategory(e.id)})];return a.length>0?{menu:{type:"menubutton",icon:"image-options",fetch:e=>e(a)}}:{}},r=e=>{const a=[...Oe(n,"advtemplate_rename_template",{type:"menuitem",text:"Rename...",onAction:t.renameTemplate(e)}),...Oe(n,"advtemplate_move_template",{type:"menuitem",text:"Move to...",onAction:t.moveTemplate(e.id)}),...Oe(n,"advtemplate_delete_template",{type:"separator"}),...Oe(n,"advtemplate_delete_template",{type:"menuitem",icon:"remove",text:"Delete",onAction:t.deleteTemplate(e.id)})];return a.length>0?{menu:{type:"menubutton",icon:"image-options",fetch:e=>e(a)}}:{}};return T(e,(e=>K(e)?(e=>({type:"directory",id:e.id,title:e.title,children:Me(e.items,t,n),...a(e)}))(e):(e=>({type:"leaf",id:e.id,title:e.title,...r(e)}))(e)))},Pe=e=>t=>{w.from(t.message).bind((e=>(console.error(e),ve(!(e=>e instanceof P)(t),e)))).or(w.some("Operation failed")).each(e.windowManager.alert)},Ie=(e,t)=>((e,t,n)=>{const a=((e,t)=>{const n=((e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n})(e,t);return void 0===n||""===n?[]:n.split(" ")})(e,t);return((e,t,n)=>{((e,t,n)=>{if(!(i(n)||c(n)||g(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")})(e.dom,t,n)})(e,t,a.concat([n]).join(" ")),!0})(e,"class",t),Ne=(e=>{let t,n=!1;return(...a)=>(n||(n=!0,t=e.apply(null,a)),t)})((()=>{const e=tinymce.Env.os.isMacOS()||tinymce.Env.os.isiOS()?e=>e.metaKey:e=>e.ctrlKey&&!e.altKey;return`