@ncino/web-components 9.2.0-preview.4 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/gator/base/accordion.gator.js +1 -1
- package/dist/components/accordion/gator/group/accordion-group.gator.js +1 -1
- package/dist/components/alert/gator/base/alert.gator.js +1 -1
- package/dist/components/banner/gator/banner.gator.js +1 -1
- package/dist/components/button/gator/button.gator.js +1 -1
- package/dist/components/display-card/gator/display-card.gator.js +1 -1
- package/dist/components/headline-card/gator/headline-card.gator.js +1 -1
- package/dist/components/icon/gator/icon.gator.js +2 -2
- package/dist/components/icon/gator/index.js +1 -1
- package/dist/components/icon/gator/templates/arrows-down-up.js +8 -0
- package/dist/components/icon/gator/templates/index.js +1 -1
- package/dist/components/image-card/gator/image-card.gator.js +1 -1
- package/dist/components/input/base/input-base.gator.js +1 -1
- package/dist/components/input/gator/dropdown/input-dropdown.gator.js +1 -1
- package/dist/components/input/gator/help-text/help-text.gator.js +1 -1
- package/dist/components/input/gator/input-file/file-uploaded-preview/file-upload-preview.gator.js +1 -1
- package/dist/components/input/gator/input-file/input-file.gator.js +1 -1
- package/dist/components/input/gator/input-textarea/input-textarea.gator.js +1 -1
- package/dist/components/input/gator/input-time/input-time.gator.js +1 -1
- package/dist/components/input-rich-text/ckeditor-config.js +1 -1
- package/dist/components/input-rich-text/input-rich-text.slds.js +2 -2
- package/dist/components/list/gator/list-item/list-item.gator.js +1 -1
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/selection-box/selection-box.gator.js +1 -1
- package/dist/components/table/gator/table-pagination/table-pagination.gator.js +1 -1
- package/dist/components/table/gator/table.gator.js +135 -45
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-alignment@47.5.0 → @ckeditor_ckeditor5-alignment@47.6.0}/node_modules/@ckeditor/ckeditor5-alignment/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-autoformat@47.5.0 → @ckeditor_ckeditor5-autoformat@47.6.0}/node_modules/@ckeditor/ckeditor5-autoformat/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-autosave@47.5.0 → @ckeditor_ckeditor5-autosave@47.6.0}/node_modules/@ckeditor/ckeditor5-autosave/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-basic-styles@47.5.0 → @ckeditor_ckeditor5-basic-styles@47.6.0}/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-block-quote@47.5.0 → @ckeditor_ckeditor5-block-quote@47.6.0}/node_modules/@ckeditor/ckeditor5-block-quote/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-clipboard@47.5.0 → @ckeditor_ckeditor5-clipboard@47.6.0}/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-cloud-services@47.5.0 → @ckeditor_ckeditor5-cloud-services@47.6.0}/node_modules/@ckeditor/ckeditor5-cloud-services/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-code-block@47.5.0 → @ckeditor_ckeditor5-code-block@47.6.0}/node_modules/@ckeditor/ckeditor5-code-block/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-core@47.5.0 → @ckeditor_ckeditor5-core@47.6.0}/node_modules/@ckeditor/ckeditor5-core/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-editor-classic@47.5.0 → @ckeditor_ckeditor5-editor-classic@47.6.0}/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-engine@47.5.0 → @ckeditor_ckeditor5-engine@47.6.0}/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-enter@47.5.0 → @ckeditor_ckeditor5-enter@47.6.0}/node_modules/@ckeditor/ckeditor5-enter/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-essentials@47.5.0 → @ckeditor_ckeditor5-essentials@47.6.0}/node_modules/@ckeditor/ckeditor5-essentials/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-find-and-replace@47.5.0 → @ckeditor_ckeditor5-find-and-replace@47.6.0}/node_modules/@ckeditor/ckeditor5-find-and-replace/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-font@47.5.0 → @ckeditor_ckeditor5-font@47.6.0}/node_modules/@ckeditor/ckeditor5-font/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-heading@47.5.0 → @ckeditor_ckeditor5-heading@47.6.0}/node_modules/@ckeditor/ckeditor5-heading/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-highlight@47.5.0 → @ckeditor_ckeditor5-highlight@47.6.0}/node_modules/@ckeditor/ckeditor5-highlight/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-horizontal-line@47.5.0 → @ckeditor_ckeditor5-horizontal-line@47.6.0}/node_modules/@ckeditor/ckeditor5-horizontal-line/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-html-embed@47.5.0 → @ckeditor_ckeditor5-html-embed@47.6.0}/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@47.6.0/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +3 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-icons@47.5.0 → @ckeditor_ckeditor5-icons@47.6.0}/node_modules/@ckeditor/ckeditor5-icons/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-image@47.5.0 → @ckeditor_ckeditor5-image@47.6.0}/node_modules/@ckeditor/ckeditor5-image/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@47.6.0/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-language@47.5.0 → @ckeditor_ckeditor5-language@47.6.0}/node_modules/@ckeditor/ckeditor5-language/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@47.6.0/node_modules/@ckeditor/ckeditor5-link/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@47.6.0/node_modules/@ckeditor/ckeditor5-list/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-markdown-gfm@47.5.0 → @ckeditor_ckeditor5-markdown-gfm@47.6.0}/node_modules/@ckeditor/ckeditor5-markdown-gfm/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-media-embed@47.5.0 → @ckeditor_ckeditor5-media-embed@47.6.0}/node_modules/@ckeditor/ckeditor5-media-embed/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-mention@47.5.0 → @ckeditor_ckeditor5-mention@47.6.0}/node_modules/@ckeditor/ckeditor5-mention/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-page-break@47.5.0 → @ckeditor_ckeditor5-page-break@47.6.0}/node_modules/@ckeditor/ckeditor5-page-break/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-paragraph@47.5.0 → @ckeditor_ckeditor5-paragraph@47.6.0}/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@47.6.0/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-remove-format@47.5.0 → @ckeditor_ckeditor5-remove-format@47.6.0}/node_modules/@ckeditor/ckeditor5-remove-format/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-select-all@47.5.0 → @ckeditor_ckeditor5-select-all@47.6.0}/node_modules/@ckeditor/ckeditor5-select-all/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-show-blocks@47.5.0 → @ckeditor_ckeditor5-show-blocks@47.6.0}/node_modules/@ckeditor/ckeditor5-show-blocks/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-source-editing@47.5.0 → @ckeditor_ckeditor5-source-editing@47.6.0}/node_modules/@ckeditor/ckeditor5-source-editing/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-special-characters@47.5.0 → @ckeditor_ckeditor5-special-characters@47.6.0}/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-style@47.5.0 → @ckeditor_ckeditor5-style@47.6.0}/node_modules/@ckeditor/ckeditor5-style/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@47.6.0/node_modules/@ckeditor/ckeditor5-table/dist/index.js +1 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-typing@47.5.0 → @ckeditor_ckeditor5-typing@47.6.0}/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-ui@47.5.0 → @ckeditor_ckeditor5-ui@47.6.0}/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-undo@47.5.0 → @ckeditor_ckeditor5-undo@47.6.0}/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-upload@47.5.0 → @ckeditor_ckeditor5-upload@47.6.0}/node_modules/@ckeditor/ckeditor5-upload/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@47.6.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +8 -0
- package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-widget@47.5.0 → @ckeditor_ckeditor5-widget@47.6.0}/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/pick.js +1 -0
- package/dist/node_modules/.pnpm/es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isNil.js +1 -0
- package/dist/packages/web-components/src/components/popover/gator/popover.gator.scss.js +1 -1
- package/dist/packages/web-components/src/components/table/gator/table.gator.scss.js +1 -1
- package/dist/types/components/icon/gator/templates/arrows-down-up.d.ts +1 -0
- package/dist/types/components/icon/gator/templates/index.d.ts +1 -0
- package/dist/types/components/popover/popover.d.ts +2 -0
- package/dist/types/components/table/gator/table.gator.d.ts +27 -0
- package/dist/types/components/table/table-column-definition.d.ts +8 -0
- package/package.json +5 -5
- package/web-types.json +35 -5
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@47.5.0/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +0 -3
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@47.5.0/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@47.5.0/node_modules/@ckeditor/ckeditor5-link/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@47.5.0/node_modules/@ckeditor/ckeditor5-list/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@47.5.0/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@47.5.0/node_modules/@ckeditor/ckeditor5-table/dist/index.js +0 -1
- package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@47.5.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +0 -8
- /package/dist/assets/node_modules/.pnpm/{ckeditor5@47.5.0 → ckeditor5@47.6.0}/node_modules/ckeditor5/dist/ckeditor5.css +0 -0
- /package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-watchdog@47.5.0 → @ckeditor_ckeditor5-watchdog@47.6.0}/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Plugin as T}from"../../../../../@ckeditor_ckeditor5-core@47.5.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{ClipboardPipeline as M}from"../../../../../@ckeditor_ckeditor5-clipboard@47.5.0/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js";import{UpcastWriter as b,ViewDocument as A,ViewDomConverter as C,Matcher as y}from"../../../../../@ckeditor_ckeditor5-engine@47.5.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";function R(t,e){const s=[];for(const i of e.createRangeIn(t)){const n=i.item;n.is("element","a")&&!n.hasAttribute("href")&&(n.hasAttribute("id")||n.hasAttribute("name"))&&s.push(n)}for(const i of s){const n=i.parent.getChildIndex(i)+1,r=i.getChildren();e.insertChild(n,r,i.parent)}}function E(t){const e=parseFloat(t);return t.endsWith("pt")?h(e*96/72):t.endsWith("pc")?h(e*12*96/72):t.endsWith("in")?h(e*96):t.endsWith("cm")?h(e*96/2.54):t.endsWith("mm")?h(e/10*96/2.54):t}function S(t){return t!==void 0&&t.endsWith("px")}function h(t){return Math.round(t)+"px"}function k(t,e,s){if(!t.childCount)return;const i=new b(t.document),n=B(t,i);if(!n.length)return;const r={},l=[];for(const o of n)if(o.indent!==void 0){W(o)||(l.length=0);const c=`${o.id}:${o.indent}`,a=Math.min(o.indent-1,l.length);if(a<l.length&&l[a].id!==o.id&&(l.length=a),a<l.length-1)l.length=a+1;else{const f=D(o,e);if(a>l.length-1||l[a].listElement.name!=f.type){a==0&&f.type=="ol"&&o.id!==void 0&&r[c]&&(f.startIndex=r[c]);const d=_(f,i,s);if(S(o.marginLeft)&&(a==0||S(l[a-1].marginLeft))){let u=o.marginLeft;a>0&&(u=h(parseFloat(u)-parseFloat(l[a-1].marginLeft))),i.setStyle("padding-left",u,d)}if(l.length==0){const u=o.element.parent,g=u.getChildIndex(o.element)+1;i.insertChild(g,d,u)}else{const u=l[a-1].listItemElements;i.appendChild(d,u[u.length-1])}l[a]={...o,listElement:d,listItemElements:[]},a==0&&o.id!==void 0&&(r[c]=f.startIndex||1)}}const m=o.element.name=="li"?o.element:i.createElement("li");i.appendChild(m,l[a].listElement),l[a].listItemElements.push(m),a==0&&o.id!==void 0&&r[c]++,o.element!=m&&i.appendChild(o.element,m),z(o.element,i),i.removeStyle("text-indent",o.element),i.removeStyle("margin-left",o.element)}else{const c=l.find(a=>a.marginLeft==o.marginLeft);if(c){const a=c.listItemElements;i.appendChild(o.element,a[a.length-1]),i.removeStyle("margin-left",o.element)}else l.length=0}}function O(t,e){for(const s of e.createRangeIn(t)){const i=s.item;if(i.is("element","li")){const n=i.getChild(0);n&&n.is("element","p")&&e.unwrapElement(n)}}}function B(t,e){const s=e.createRangeIn(t),i=[],n=new Set;for(const r of s.getItems()){if(!r.is("element")||!r.name.match(/^(p|h\d+|li|div)$/))continue;let l=V(r);if(l!==void 0&&parseFloat(l)==0&&!Array.from(r.getClassNames()).find(o=>o.startsWith("MsoList"))&&(l=void 0),r.hasStyle("mso-list")&&r.getStyle("mso-list")!=="none"||l!==void 0&&n.has(l)){const o=$(r);i.push({element:r,id:o.id,order:o.order,indent:o.indent,marginLeft:l}),l!==void 0&&n.add(l)}else n.clear()}return i}function W(t){const e=t.element.previousSibling;if(!e){const s=t.element.parent;return x(s)&&(!s.previousSibling||x(s.previousSibling))}return x(e)}function x(t){return t.is("element","ol")||t.is("element","ul")}function D(t,e){const s=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,n=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=new RegExp(`@list\\s+l${t.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),l=new RegExp(`@list l${t.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),o=r.exec(e),c=l.exec(e),a=o&&!c,m=s.exec(e);let f="decimal",d="ol",u=null;if(m&&m[1]){const g=i.exec(m[1]);if(g&&g[1]&&(f=g[1].trim(),d=f!=="bullet"&&f!=="image"?"ol":"ul"),f==="bullet"){const p=w(t.element);p&&(f=p)}else{const p=n.exec(m[1]);p&&p[1]&&(u=parseInt(p[1]))}a&&(d="ol")}return{type:d,startIndex:u,style:F(f),isLegalStyleList:a}}function w(t){if(t.name=="li"&&t.parent.name=="ul"&&t.parent.hasAttribute("type"))return t.parent.getAttribute("type");const e=N(t);if(!e)return null;const s=e._data;return s==="o"?"circle":s==="·"?"disc":s==="§"?"square":null}function N(t){if(t.getChild(0).is("$text"))return null;for(const e of t.getChildren()){if(!e.is("element","span"))continue;const s=e.getChild(0);if(s)return s.is("$text")?s:s.getChild(0)}return null}function F(t){if(t.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(t){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return t;default:return null}}function _(t,e,s){const i=e.createElement(t.type);return t.style&&e.setStyle("list-style-type",t.style,i),t.startIndex&&t.startIndex>1&&e.setAttribute("start",t.startIndex,i),t.isLegalStyleList&&s&&e.addClass("legal-list",i),i}function $(t){const e=t.getStyle("mso-list");if(e===void 0)return{};const s=e.match(/(^|\s{1,100})l(\d+)/i),i=e.match(/\s{0,100}lfo(\d+)/i),n=e.match(/\s{0,100}level(\d+)/i);return s&&i&&n?{id:s[2],order:i[1],indent:parseInt(n[1])}:{indent:1}}function z(t,e){const s=new y({name:"span",styles:{"mso-list":"Ignore"}}),i=e.createRangeIn(t);for(const n of i)n.type==="elementStart"&&s.match(n.item)&&e.remove(n.item)}function V(t){const e=t.getStyle("margin-left");return e===void 0||e.endsWith("px")?e:E(e)}function j(t,e){if(!t.childCount)return;const s=new b(t.document),i=H(t,s);q(i,t,s),X(i,t,s),U(t,s);const n=J(t,s);n.length&&Q(n,K(e),s)}function G(t){return btoa(t.match(/\w{2}/g).map(e=>String.fromCharCode(parseInt(e,16))).join(""))}function H(t,e){const s=e.createRangeIn(t),i=new y({name:/v:(.+)/}),n=[];for(const r of s){if(r.type!="elementStart")continue;const l=r.item,o=l.previousSibling,c=o&&o.is("element")?o.name:null,a=["Chart"],m=i.match(l),f=l.getAttribute("o:gfxdata"),d=c==="v:shapetype",u=f&&a.some(g=>l.getAttribute("id").includes(g));m&&f&&!d&&!u&&n.push(r.item.getAttribute("id"))}return n}function q(t,e,s){const i=s.createRangeIn(e),n=new y({name:"img"}),r=[];for(const l of i)if(l.item.is("element")&&n.match(l.item)){const o=l.item,c=o.getAttribute("v:shapes")?o.getAttribute("v:shapes").split(" "):[];c.length&&c.every(a=>t.indexOf(a)>-1)?r.push(o):o.getAttribute("src")||r.push(o)}for(const l of r)s.remove(l)}function U(t,e){const s=e.createRangeIn(t),i=new y({name:/v:(.+)/}),n=[];for(const r of s)r.type=="elementStart"&&i.match(r.item)&&n.push(r.item);for(const r of n)e.remove(r)}function X(t,e,s){const i=s.createRangeIn(e),n=[];for(const o of i)if(o.type=="elementStart"&&o.item.is("element","v:shape")){const c=o.item.getAttribute("id");if(t.includes(c))continue;r(o.item.parent.getChildren(),c)||n.push(o.item)}for(const o of n){const c={src:l(o)};o.hasAttribute("alt")&&(c.alt=o.getAttribute("alt"));const a=s.createElement("img",c);s.insertChild(o.index+1,a,o.parent)}function r(o,c){for(const a of o){if(a.is("element")&&(a.name=="img"&&a.getAttribute("v:shapes")==c||r(a.getChildren(),c)))return!0}return!1}function l(o){for(const c of o.getChildren()){if(c.is("element")&&c.getAttribute("src"))return c.getAttribute("src")}}}function J(t,e){const s=e.createRangeIn(t),i=new y({name:"img"}),n=[];let r=0;for(const l of s)l.item.is("element")&&i.match(l.item)&&(l.item.getAttribute("src").startsWith("file://")&&n.push({element:l.item,imageIndex:r}),r++);return n}function K(t){if(!t)return[];const e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,s=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),i=t.match(s),n=[];if(i)for(const r of i){let l=!1;r.includes("\\pngblip")?l="image/png":r.includes("\\jpegblip")&&(l="image/jpeg"),l&&n.push({hex:r.replace(e,"").replace(/[^\da-fA-F]/g,""),type:l})}return n}function Q(t,e,s){for(let i=0;i<t.length;i++){const{element:n,imageIndex:r}=t[i],l=e[r];if(l){const o=`data:${l.type};base64,${G(l.hex)}`;s.setAttribute("src",o,n)}}}function Y(t){const e=[],s=new b(t.document);for(const{item:i}of s.createRangeIn(t))if(i.is("element")){for(const n of i.getClassNames())/\bmso/gi.exec(n)&&s.removeClass(n,i);for(const n of i.getStyleNames())/\bmso/gi.exec(n)&&s.removeStyle(n,i);(i.is("element","w:sdt")||i.is("element","w:sdtpr")&&i.isEmpty||i.is("element","o:p")&&i.isEmpty)&&e.push(i)}for(const i of e){const n=i.parent,r=n.getChildIndex(i);s.insertChild(r,i.getChildren(),n),s.remove(i)}}function Z(t,e,s=!1,i=!1){for(const n of e.createRangeIn(t).getItems()){if(!n.is("element","table")&&!n.is("element","td")&&!n.is("element","th"))continue;if(s&&i&&n.is("element","table")){const o=n.parent?.is("element","div")?n.parent:null,c=n.parent?.parent?.is("element","div")?n.parent.parent:null,a=o??c;a&&a.getAttribute("align")==="center"&&!n.getAttribute("align")?(e.setStyle("margin-left","auto",n),e.setStyle("margin-right","auto",n)):a&&a.getAttribute("align")==="right"&&!n.getAttribute("align")?(e.setStyle("margin-left","auto",n),e.setStyle("margin-right","0",n)):!a&&!n.getAttribute("align")&&(e.setStyle("margin-left","0",n),e.setStyle("margin-right","auto",n))}const r=["left","top","right","bottom"];if(r.every(o=>!n.hasStyle(`border-${o}-style`)))e.setStyle("border-style","none",n);else for(const o of r)n.hasStyle(`border-${o}-style`)||e.setStyle(`border-${o}-style`,"none",n);const l=["width","height",...r.map(o=>`border-${o}-width`),...r.map(o=>`padding-${o}`)];for(const o of l)n.hasStyle(o)&&e.setStyle(o,E(n.getStyle(o)),n)}}function L(t,e){for(const s of e.createRangeIn(t).getItems())s.is("element","table")&&(s.getStyle("width")==="0px"&&e.removeStyle("width",s),s.getAttribute("width")==="0"&&e.removeAttribute("width",s))}function ee(t,e){const s=new Map,i=new Map;let n=null;for(const{item:l}of e.createRangeIn(t))if(l.is("element")){if(l.getStyle("mso-element")==="footnote-list"){n=l;continue}if(l.hasStyle("mso-footnote-id")){const o=l.findAncestor("element",c=>c.getStyle("mso-element")==="footnote");if(o){const c=o.getAttribute("id");i.set(c,o)}else{const c=l.getStyle("mso-footnote-id");s.set(c,l)}continue}}if(!s.size||!n)return;const r=ne(e);e.replace(n,r);for(const[l,o]of s){const c=i.get(l);if(!c)continue;e.replace(o,se(e,l));const a=ie(e,l);te(e,c);for(const m of c.getChildren()){let f=m;m.is("element")&&(f=e.clone(m,!0)),e.appendChild(f,a.content)}e.appendChild(a.listItem,r)}}function te(t,e){const s=[],i=[];for(const{item:n}of t.createRangeIn(e))if(n.is("element")&&n.getStyle("mso-footnote-id")){s.unshift(n);const{nextSibling:r}=n;r?.is("$text")&&r.data.startsWith(" ")&&i.unshift(r)}for(const n of s)t.remove(n);for(const n of i){const r=n.data.substring(1);if(r.length>0){const l=n.parent,o=l.getChildIndex(n),c=t.createText(r);t.remove(n),t.insertChild(o,c,l)}else t.remove(n)}return e}function ne(t){return t.createElement("ol",{class:"footnotes"})}function se(t,e){const s=t.createElement("sup",{class:"footnote"}),i=t.createElement("a",{id:`ref-${e}`,href:`#${e}`});return t.appendChild(i,s),s}function ie(t,e){const s=t.createElement("li",{id:e,class:"footnote-definition"}),i=t.createElement("a",{href:`#ref-${e}`,class:"footnote-backlink"}),n=t.createElement("div",{class:"footnote-content"});return t.appendChild(t.createText("^"),i),t.appendChild(i,s),t.appendChild(n,s),{listItem:s,content:n}}const oe=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,le=/xmlns:o="urn:schemas-microsoft-com/i;class re{document;hasMultiLevelListPlugin;hasTablePropertiesPlugin;hasExtendedTableBlockAlignment;constructor(e,s=!1,i=!1,n=!1){this.document=e,this.hasMultiLevelListPlugin=s,this.hasTablePropertiesPlugin=i,this.hasExtendedTableBlockAlignment=n}isActive(e){return oe.test(e)||le.test(e)}execute(e){const s=new b(this.document),{body:i,stylesString:n}=e._parsedData;R(i,s),k(i,n,this.hasMultiLevelListPlugin),j(i,e.dataTransfer.getData("text/rtf")),Z(i,s,this.hasTablePropertiesPlugin,this.hasExtendedTableBlockAlignment),L(i,s),ee(i,s),Y(i),e.content=i}}function ae(t,e){for(const s of t.getChildren())if(s.is("element","b")&&s.getStyle("font-weight")==="normal"){const i=t.getChildIndex(s);e.remove(s),e.insertChild(i,s.getChildren(),t)}}function ce(t,e){const s=new A(e.document.stylesProcessor),i=new C(s,{renderingMode:"data"}),n=i.blockElements,r=i.inlineObjectElements,l=[];for(const o of e.createRangeIn(t)){const c=o.item;if(c.is("element","br")){const a=v(c,"forward",e,{blockElements:n,inlineObjectElements:r}),m=v(c,"backward",e,{blockElements:n,inlineObjectElements:r}),f=I(a,n);(I(m,n)||f)&&l.push(c)}}for(const o of l)o.hasClass("Apple-interchange-newline")?e.remove(o):e.replace(o,e.createElement("p"))}function v(t,e,s,{blockElements:i,inlineObjectElements:n}){let r=s.createPositionAt(t,e=="forward"?"after":"before");return r=r.getLastMatchingPosition(({item:l})=>l.is("element")&&!i.includes(l.name)&&!n.includes(l.name),{direction:e}),e=="forward"?r.nodeAfter:r.nodeBefore}function I(t,e){return!!t&&t.is("element")&&e.includes(t.name)}function fe(t,e,s){const i=new Set;for(const n of e.createRangeIn(t).getItems())!n.is("view:$textProxy")||!n.data.includes(" ")||me(n.parent)&&i.add(n.textNode);for(const n of i)ue(n,e,s)}function me(t){let e=t;for(;e;){if(e.is("element")&&e.getStyle?.("white-space")==="pre-wrap")return!0;e=e.parent}return!1}function ue(t,e,s){const{parent:i,data:n}=t,r=n.replaceAll(" "," ".repeat(s)),l=i.getChildIndex(t);e.remove(t),e.insertChild(l,e.createText(r),i)}const de=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class ge{document;constructor(e){this.document=e}isActive(e){return de.test(e)}execute(e){const s=new b(this.document),{body:i}=e._parsedData;ae(i,s),O(i,s),ce(i,s),fe(i,s,8),e.content=i}}function pe(t,e){for(const s of t.getChildren())s.is("element","table")&&s.hasAttribute("xmlns")&&e.removeAttribute("xmlns",s)}function he(t,e){for(const s of t.getChildren())if(s.is("element","google-sheets-html-origin")){const i=t.getChildIndex(s);e.remove(s),e.insertChild(i,s.getChildren(),t)}}function be(t,e){for(const s of Array.from(t.getChildren()))s.is("element","style")&&e.remove(s)}const ye=/<google-sheets-html-origin/i;class xe{document;constructor(e){this.document=e}isActive(e){return ye.test(e)}execute(e){const s=new b(this.document),{body:i}=e._parsedData;he(i,s),pe(i,s),L(i,s),be(i,s),e.content=i}}function Se(t){return P(P(t)).replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g,"").replace(/(<span\s+style=['"]letter-spacing:[^'"]+?['"]>)[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," </").replace(/ <o:p><\/o:p>/g," <o:p></o:p>").replace(/<o:p>( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)</g,"><")}function ve(t){t.querySelectorAll("span[style*=spacerun]").forEach(e=>{const s=e,i=s.innerText.length||0;s.innerText=Array(i+1).join(" ").substr(0,i)})}function P(t){return t.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,s)=>s.length===1?" ":Array(s.length+1).join(" ").substr(0,s.length))}function Ie(t,e){const s=new DOMParser;t=t.replace(/<!--\[if gte vml 1]>/g,""),t=t.replace(/<o:SmartTagType(?:\s+[^\s>=]+(?:="[^"]*")?)*\s*\/?>/gi,"");const i=Se(Ce(t)),n=s.parseFromString(i,"text/html");ve(n);const r=n.body.innerHTML,l=Pe(n,e),o=Ae(n);return{body:l,bodyString:r,styles:o.styles,stylesString:o.stylesString}}function Pe(t,e){const s=new A(e),i=new C(s,{renderingMode:"data"}),n=t.createDocumentFragment(),r=t.body.childNodes;for(;r.length>0;)n.appendChild(r[0]);return i.domToView(n,{skipComments:!0})}function Ae(t){const e=[],s=[],i=Array.from(t.getElementsByTagName("style"));for(const n of i)n.sheet&&n.sheet.cssRules&&n.sheet.cssRules.length&&(e.push(n.sheet),s.push(n.innerHTML));return{styles:e,stylesString:s.join(" ")}}function Ce(t){const e="</body>",s="</html>",i=t.indexOf(e);if(i<0)return t;const n=t.indexOf(s,i+e.length);return t.substring(0,i+e.length)+(n>=0?t.substring(n):"")}class Me extends T{static get pluginName(){return"PasteFromOffice"}static get licenseFeatureCode(){return"PFO"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[M]}init(){const e=this.editor,s=e.plugins.get("ClipboardPipeline"),i=e.editing.view.document,n=[],r=this.editor.plugins.has("MultiLevelListEditing"),l=this.editor.plugins.has("TablePropertiesEditing"),o=!!this.editor.config.get("experimentalFlags.useExtendedTableBlockAlignment");n.push(new re(i,r,l,o)),n.push(new ge(i)),n.push(new xe(i)),s.on("inputTransformation",(c,a)=>{if(a._isTransformedWithPasteFromOffice||e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const f=a.dataTransfer.getData("text/html"),d=n.find(u=>u.isActive(f));d&&(a._parsedData||(a._parsedData=Ie(f,i.stylesProcessor)),d.execute(a),a._isTransformedWithPasteFromOffice=!0)},{priority:"high"})}}export{Me as PasteFromOffice,ge as PasteFromOfficeGoogleDocsNormalizer,xe as PasteFromOfficeGoogleSheetsNormalizer,re as PasteFromOfficeMSWordNormalizer,G as _convertHexToBase64,E as _convertPasteOfficeCssLengthToPx,S as _isPasteOfficePxValue,ve as _normalizePasteOfficeSpaceRunSpans,Se as _normalizePasteOfficeSpacing,he as _removePasteGoogleOfficeSheetsTag,Y as _removePasteMSOfficeAttributes,ae as _removePasteOfficeBoldWrapper,L as _removePasteOfficeInvalidTableWidths,be as _removePasteOfficeStyleBlock,pe as _removePasteOfficeXmlnsAttributes,j as _replacePasteOfficeImagesSourceWithBase64,h as _toPasteOfficePxValue,ce as _transformPasteOfficeBlockBrsToParagraphs,R as _transformPasteOfficeBookmarks,k as _transformPasteOfficeListItemLikeElementsIntoLists,Z as _transformPasteOfficeTables,O as _unwrapPasteOfficeParagraphInListItem,Ie as parsePasteOfficeHtml};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Plugin as A,Command as R}from"../../../../../@ckeditor_ckeditor5-core@47.5.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js";import{Widget as bn,WidgetToolbarRepository as Ze,toWidgetEditable as Rt,isWidget as fn,toWidget as pn}from"../../../../../@ckeditor_ckeditor5-widget@47.5.0/node_modules/@ckeditor/ckeditor5-widget/dist/index.js";import{Collection as kt,first as we,getLocalizedArrowKeyCodeDirection as Cn,DomEmitterMixin as wn,global as ue,Rect as de,CKEditorError as Ye,KeystrokeHandler as Te,FocusTracker as ye,priorities as Tn,toUnit as yn}from"../../../../../@ckeditor_ckeditor5-utils@47.5.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{IconTable as Qe,IconTableColumn as _n,IconTableRow as An,IconTableMergeCell as vn,IconCaption as Sn,IconTableCellProperties as Rn,IconTableProperties as kn,IconCheck as It,IconCancel as xt,IconObjectInlineRight as In,IconObjectCenter as xn,IconObjectInlineLeft as Pn,IconAlignBottom as En,IconAlignMiddle as Vn,IconAlignTop as Ln,IconAlignJustify as Nn,IconAlignRight as Wn,IconAlignCenter as Bn,IconAlignLeft as Fn}from"../../../../../@ckeditor_ckeditor5-icons@47.5.0/node_modules/@ckeditor/ckeditor5-icons/dist/index.js";import{createDropdown as se,MenuBarMenuView as Dn,SwitchButtonView as On,addListToDropdown as He,ButtonView as W,ContextualBalloon as me,normalizeColorOptions as he,getLocalizedColorOptions as ge,clickOutsideHandler as Pt,SplitButtonView as Mn,View as z,addKeyboardHandlingForGrid as Hn,UIModel as Et,ViewCollection as ze,FocusCycler as Ue,FormHeaderView as Vt,FormRowView as x,submitHandler as Lt,LabelView as D,LabeledFieldView as P,createLabeledDropdown as Nt,createLabeledInputText as H,ToolbarView as Ie,BalloonPanelView as M,InputTextView as zn,ColorSelectorView as Un}from"../../../../../@ckeditor_ckeditor5-ui@47.5.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js";import{ClipboardMarkersUtils as Se,ClipboardPipeline as et}from"../../../../../@ckeditor_ckeditor5-clipboard@47.5.0/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js";import{enableViewPlaceholder as $n,ModelElement as jn,addBorderStylesRules as Wt,addPaddingStylesRules as Gn,addBackgroundStylesRules as Bt,addMarginStylesRules as Kn,DomEventObserver as qn,isColorStyleValue as Xn,isLengthStyleValue as Ft,isPercentageStyleValue as Jn}from"../../../../../@ckeditor_ckeditor5-engine@47.5.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js";import{debounce as Dt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/function/debounce.js";import{isEqual as tt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/predicate/isEqual.js";import{throttle as Zn}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/function/throttle.js";import{isObject as Yn}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isObject.js";const Qn=/^(left|center|right)$/,eo=/^(left|none|right)$/;function $e(i,e){const{modelAttribute:t,styleName:n,attributeName:o,attributeType:l,viewElement:s,defaultValue:r,shouldUpcast:c=()=>!0,reduceBoxSides:a=!1}=e;i.for("upcast").attributeToAttribute({view:{name:s,styles:{[n]:/[\s\S]+/}},model:{key:t,value:(u,d,m)=>{if(!c(u))return;const h=E(r,"",m),g=u.getNormalizedStyle(n),b=a?ae(g):g;if(h!==b)return b;d.consumable.consume(u,{styles:n})}}}),o&&i.for("upcast").attributeToAttribute({view:{name:s,attributes:{[o]:/.+/}},model:{key:t,value:(u,d,m)=>{if(u.name=="figure"||u.hasStyle(n)||u.name=="table"&&u.parent.name=="figure"&&u.parent.hasStyle(n))return;const h=E(r,"",m);let g=u.getAttribute(o);if(g&&l=="length"){const b=parseFloat(g);isNaN(b)?g=h:g=b+(g.includes("%")?"%":"px")}if(h!==g)return g;d.consumable.consume(u,{attributes:o})}}})}function xe(i,e,t,n){const{conversion:o}=i;o.for("upcast").add(l=>l.on("element:"+e,(s,r,c)=>{if(!r.modelRange)return;const a=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter(f=>r.viewItem.hasStyle(f));if(!a.length)return;const u={styles:a};if(!c.consumable.test(r.viewItem,u))return;const d=[...r.modelRange.getItems({shallow:!0})].pop(),m=d.findAncestor("table",{includeSelf:!0});let h=n;m&&m.getAttribute("tableType")=="layout"&&(h={style:"none",color:"",width:""}),c.consumable.consume(r.viewItem,u);const g={style:r.viewItem.getNormalizedStyle("border-style"),color:r.viewItem.getNormalizedStyle("border-color"),width:r.viewItem.getNormalizedStyle("border-width")},b={style:ae(g.style),color:ae(g.color),width:ae(g.width)};b.style!==h.style&&c.writer.setAttribute(t.style,b.style,d),b.color!==h.color&&c.writer.setAttribute(t.color,b.color,d),b.width!==h.width&&c.writer.setAttribute(t.width,b.width,d)})),i.config.get("experimentalFlags.upcastTableBorderZeroAttributes")&&o.for("upcast").add(l=>{l.on(`element:${e}`,(s,r,c)=>{const{modelRange:a,viewItem:u}=r,d=u.is("element","table")?u:u.findAncestor("table");if(!c.consumable.test(d,{attributes:"border"})||d.getAttribute("border")!=="0")return;const m=a?.start?.nodeAfter;!m||Object.values(t).some(h=>m.hasAttribute(h))||(c.writer.setAttribute(t.style,"none",m),u.is("element","table")&&c.consumable.consume(u,{attributes:"border"}))})})}function X(i,e){const{modelElement:t,modelAttribute:n,styleName:o}=e;i.for("downcast").attributeToAttribute({model:{name:t,key:n},view:l=>({key:"style",value:{[o]:l}})})}function re(i,e){const{modelAttribute:t,styleName:n}=e;i.for("downcast").add(o=>o.on(`attribute:${t}:table`,(l,s,r)=>{const{item:c,attributeNewValue:a}=s,{mapper:u,writer:d}=r;if(!r.consumable.consume(s.item,l.name))return;const m=[...u.toViewElement(c).getChildren()].find(h=>h.is("element","table"));a?d.setStyle(n,a,m):d.removeStyle(n,m)}))}function E(i,e,t){const n=t.modelRange&&we(t.modelRange.getItems({shallow:!0})),o=n&&n.is("element")&&n.findAncestor("table",{includeSelf:!0});return o&&o.getAttribute("tableType")==="layout"?e:i}function ae(i){if(!i)return;const e=["top","right","bottom","left"];if(!e.every(l=>i[l]))return i;const n=i.top;return e.every(l=>i[l]===n)?n:i}const S={left:{className:"table-style-align-left"},center:{className:"table-style-align-center"},right:{className:"table-style-align-right"},blockLeft:{className:"table-style-block-align-left"},blockRight:{className:"table-style-block-align-right"}},to=[{view:{name:/^(table|figure)$/,styles:{float:eo}},getAlign:i=>{let e=i.getStyle("float");return e==="none"&&(e="center"),e},getConsumables(i){const e=i.getStyle("float"),t=["float"];return e==="left"&&i.hasStyle("margin-right")?t.push("margin-right"):e==="right"&&i.hasStyle("margin-left")&&t.push("margin-left"),{styles:t}}},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},getAlign:()=>"center",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,key:"class",value:"table-style-align-left"},getAlign:()=>"left",getConsumables(){return{classes:S.left.className}}},{view:{name:/^(table|figure)$/,key:"class",value:S.right.className},getAlign:()=>"right",getConsumables(){return{classes:S.right.className}}},{view:{name:/^(table|figure)$/,key:"class",value:S.center.className},getAlign:()=>"center",getConsumables(){return{classes:S.center.className}}},{view:{name:/^(table|figure)$/,key:"class",value:S.blockLeft.className},getAlign:()=>"blockLeft",getConsumables(){return{classes:S.blockLeft.className}}},{view:{name:/^(table|figure)$/,key:"class",value:S.blockRight.className},getAlign:()=>"blockRight",getConsumables(){return{classes:S.blockRight.className}}},{view:{name:/^(table|figure)$/,styles:{"margin-left":"0","margin-right":"auto"}},getAlign:()=>"blockLeft",getConsumables(){return{styles:["margin-left","margin-right"]}}},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"0"}},getAlign:()=>"blockRight",getConsumables(){return{styles:["margin-left","margin-right"]}}},{view:{name:"table",attributes:{align:Qn}},getAlign:i=>i.getAttribute("align"),getConsumables(){return{attributes:"align"}}}],te={center:{align:"center",style:"margin-left: auto; margin-right: auto;",className:"table-style-align-center"},left:{align:"left",style:"float: left;",className:"table-style-align-left"},right:{align:"right",style:"float: right;",className:"table-style-align-right"},blockLeft:{align:void 0,style:"margin-left: 0; margin-right: auto;",className:S.blockLeft.className},blockRight:{align:void 0,style:"margin-left: auto; margin-right: 0;",className:S.blockRight.className}};class w{_table;_startRow;_endRow;_startColumn;_endColumn;_includeAllSlots;_skipRows;_row;_rowIndex;_column;_cellIndex;_spannedCells;_nextCellAtColumn;_jumpedToStartRow=!1;constructor(e,t={}){this._table=e,this._startRow=t.row!==void 0?t.row:t.startRow||0,this._endRow=t.row!==void 0?t.row:t.endRow,this._startColumn=t.column!==void 0?t.column:t.startColumn||0,this._endColumn=t.column!==void 0?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const n=this._getSpanned();if(n)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(n.cell,n.row,n.column));else{const o=e.getChild(this._cellIndex);if(!o)return this._advanceToNextRow();const l=parseInt(o.getAttribute("colspan")||"1"),s=parseInt(o.getAttribute("rowspan")||"1");(l>1||s>1)&&this._recordSpans(o,s,l),this._shouldSkipSlot()||(t=this._formatOutValue(o)),this._nextCellAtColumn=this._column+l}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return this._endRow!==void 0&&this._row>this._endRow}_isOverEndColumn(){return this._endColumn!==void 0&&this._column>this._endColumn}_formatOutValue(e,t=this._row,n=this._column){return{done:!1,value:new no(this,e,t,n)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,n=this._column<this._startColumn,o=this._endColumn!==void 0&&this._column>this._endColumn;return e||t||n||o}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,n){const o={cell:e,row:this._row,column:this._column};for(let l=this._row;l<this._row+t;l++)for(let s=this._column;s<this._column+n;s++)(l!=this._row||s!=this._column)&&this._markSpannedCell(l,s,o)}_markSpannedCell(e,t,n){this._spannedCells.has(e)||this._spannedCells.set(e,new Map),this._spannedCells.get(e).set(t,n)}_canJumpToStartRow(){return!!this._startRow&&this._startRow>0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const e=this._getRowLength(0);for(let t=this._startRow;!this._jumpedToStartRow;t--)e===this._getRowLength(t)&&(this._row=t,this._rowIndex=t,this._jumpedToStartRow=!0)}_getRowLength(e){return[...this._table.getChild(e).getChildren()].reduce((n,o)=>n+parseInt(o.getAttribute("colspan")||"1"),0)}}class no{cell;row;column;cellAnchorRow;cellAnchorColumn;_cellIndex;_rowIndex;_table;constructor(e,t,n,o){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=n,this.cellAnchorColumn=o,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}function _(i,e,t,n,o=1){e!=null&&o!==void 0&&o!==null&&e>o?n.setAttribute(i,e,t):n.removeAttribute(i,t)}function U(i,e,t={}){const n=i.createElement("tableCell",t);return i.insertElement("paragraph",n),i.insert(n,e),n}function Pe(i,e){const t=e.parent.parent,n=parseInt(t.getAttribute("headingColumns")||"0"),{column:o}=i.getCellLocation(e);return!!n&&o<n}function ce(i,e,t){const{modelAttribute:n}=t;i.extend("tableCell",{allowAttributes:[n]}),i.setAttributeProperties(n,{isFormatting:!0}),$e(e,{viewElement:/^(td|th)$/,...t}),X(e,{modelElement:"tableCell",...t})}function N(i){const e=i.getSelectedElement();return e&&e.is("element","table")?e:i.getFirstPosition().findAncestor("table")}function oo(i){const e=new Map;for(const t of i){const n=t.findAncestor("table");e.has(n)||e.set(n,[]),e.get(n).push(t)}return e}function K({table:i,row:e,column:t}){const n=new w(i,{row:e,column:t});for(const{cell:o}of n)if(o.getAttribute("tableCellType")!=="header")return!1;return!0}function L(i){const{model:e,config:t}=i;return e.schema.checkAttribute("tableCell","tableCellType")&&t.get("experimentalFlags.tableCellTypeSupport")===!0}function Ot(i,e,t){const{startRow:n,startColumn:o,endRow:l,endColumn:s}=e,r=t.createElement("table"),c=i.getAttribute("tableType");c&&t.setAttribute("tableType",c,r);const a=l-n+1;for(let d=0;d<a;d++)t.insertElement("tableRow",r,"end");const u=[...new w(i,{startRow:n,endRow:l,startColumn:o,endColumn:s,includeAllSlots:!0})];for(const{row:d,column:m,cell:h,isAnchor:g,cellAnchorRow:b,cellAnchorColumn:f}of u){const p=d-n,C=r.getChild(p);if(!g)(b<n||f<o)&&U(t,t.createPositionAt(C,"end"));else{const T=t.cloneElement(h);t.append(T,C),$t(T,d,m,l,s,t)}}return lo(r,i,n,o,t),r}function Mt(i,e,t=0){const n=[],o=new w(i,{startRow:t,endRow:e-1});for(const l of o){const{row:s,cellHeight:r}=l,c=s+r-1;s<e&&e<=c&&n.push(l)}return n}function Ht(i,e,t){const n=i.parent,o=n.parent,l=n.index,s=parseInt(i.getAttribute("rowspan")),r=e-l,c={},a=s-r;a>1&&(c.rowspan=a);const u=parseInt(i.getAttribute("colspan")||"1");u>1&&(c.colspan=u);const d=l,m=d+r,h=[...new w(o,{startRow:d,endRow:m,includeAllSlots:!0})];let g=null,b;for(const f of h){const{row:p,column:C,cell:T}=f;T===i&&b===void 0&&(b=C),b!==void 0&&b===C&&p===m&&(g=U(t,f.getPositionBefore(),c))}return _("rowspan",r,i,t),g}function zt(i,e){const t=[],n=new w(i);for(const o of n){const{column:l,cellWidth:s}=o,r=l+s-1;l<e&&e<=r&&t.push(o)}return t}function Ut(i,e,t,n){const o=parseInt(i.getAttribute("colspan")),l=t-e,s={},r=o-l;r>1&&(s.colspan=r);const c=parseInt(i.getAttribute("rowspan")||"1");c>1&&(s.rowspan=c);const a=U(n,n.createPositionAfter(i),s);return _("colspan",l,i,n),a}function $t(i,e,t,n,o,l){const s=parseInt(i.getAttribute("colspan")||"1"),r=parseInt(i.getAttribute("rowspan")||"1");if(t+s-1>o){const u=o-t+1;_("colspan",u,i,l,1)}if(e+r-1>n){const u=n-e+1;_("rowspan",u,i,l,1)}}function lo(i,e,t,n,o){const l=parseInt(e.getAttribute("headingRows")||"0");if(l>0){const r=l-t;_("headingRows",r,i,o,0)}const s=parseInt(e.getAttribute("headingColumns")||"0");if(s>0){const r=s-n;_("headingColumns",r,i,o,0)}}function Ee(i,e){const t=e.getColumns(i),n=new Array(t).fill(0);for(const{column:l}of new w(i))n[l]++;const o=n.reduce((l,s,r)=>s?l:[...l,r],[]);if(o.length>0){const l=o[o.length-1];return e.removeColumns(i,{at:l}),!0}return!1}function Ve(i,e){const t=[],n=e.getRows(i);for(let o=0;o<n;o++)i.getChild(o).isEmpty&&t.push(o);if(t.length>0){const o=t[t.length-1];return e.removeRows(i,{at:o}),!0}return!1}function je(i,e){Ee(i,e)||Ve(i,e)}function jt(i,e){const t=Array.from(new w(i,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(t.every(({cellHeight:l})=>l===1))return e.lastRow;const o=t[0].cellHeight-1;return e.lastRow+o}function Gt(i,e){const t=Array.from(new w(i,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(t.every(({cellWidth:l})=>l===1))return e.lastColumn;const o=t[0].cellWidth-1;return e.lastColumn+o}function Kt(i){for(const e of i.getChildren())if(e.is("element","table"))return e}function io(){return i=>{i.on("element:figure",(e,t,n)=>{if(!n.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const o=Kt(t.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(t.viewItem,{name:!0,classes:"table"});const l=n.convertItem(o,t.modelCursor),s=we(l.modelRange.getItems());if(!s||!s.is("element","table")){n.consumable.revert(t.viewItem,{name:!0,classes:"table"}),l.modelRange&&!l.modelRange.isCollapsed&&(t.modelRange=l.modelRange,t.modelCursor=l.modelCursor);return}n.convertChildren(t.viewItem,n.writer.createPositionAt(s,"end")),n.updateConversionResult(s,t)})}}function so(){return i=>{i.on("element:table",(e,t,n)=>{const o=t.viewItem;if(!n.consumable.test(o,{name:!0}))return;const{rows:l,headingRows:s,headingColumns:r}=ao(o),c={};r&&(c.headingColumns=r),s&&(c.headingRows=s);const a=n.writer.createElement("table",c);if(n.safeInsert(a,t.modelCursor)){if(n.consumable.consume(o,{name:!0}),l.forEach(u=>n.convertItem(u,n.writer.createPositionAt(a,"end"))),n.convertChildren(o,n.writer.createPositionAt(a,"end")),a.isEmpty){const u=n.writer.createElement("tableRow");n.writer.insert(u,n.writer.createPositionAt(a,"end")),U(n.writer,n.writer.createPositionAt(u,"end"))}n.updateConversionResult(a,t)}})}}function ro(){return i=>{i.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&t.modelCursor.index==0&&e.stop()},{priority:"high"})}}function nt(i){return e=>{e.on(`element:${i}`,(t,n,{writer:o})=>{if(!n.modelRange)return;const l=n.modelRange.start.nodeAfter,s=o.createPositionAt(l,0);if(n.viewItem.isEmpty){o.insertElement("paragraph",s);return}const r=Array.from(l.getChildren());if(r.every(c=>c.is("element","$marker"))){const c=o.createElement("paragraph");o.insert(c,o.createPositionAt(l,0));for(const a of r)o.move(o.createRangeOn(a),o.createPositionAt(c,"end"))}},{priority:"low"})}}function ao(i){let e,t=!0;const n=[],o=[];let l;for(const r of Array.from(i.getChildren())){if(r.name!=="tbody"&&r.name!=="thead"&&r.name!=="tfoot")continue;r.name==="thead"&&!l&&(t=!0,l=r);const c=Array.from(r.getChildren()).filter(u=>u.is("element","tr"));let a=null;for(const u of c){const d=Array.from(u.getChildren()).filter(m=>m.is("element","td")||m.is("element","th"));l&&r===l||r.name==="tbody"&&d.length>0&&(a===null||d.length===a)&&d.every(m=>m.is("element","th"))&&t?(n.push(u),t=!0):(o.push(u),t=!1),a=Math.max(a||0,d.length)}}const s=co(o);for(const r of s){let c=0;for(;c<r.length&&r[c]?.name==="th";)c+=1;(e===void 0||c<e)&&(e=c)}return{headingRows:n.length,headingColumns:e||0,rows:[...n,...o]}}function co(i){let e=new Map,t=0;const n=i.map(o=>{const l=[],s=Array.from(o.getChildren()).filter(c=>c.name==="th"||c.name==="td"),r=new Map;for(;s.length||l.length<t;){const c=e.get(l.length);if(c&&c.remaining>0)l.push(c.cell);else{const a=s.shift();if(a){const u=parseInt(a.getAttribute("colspan")||"1"),d=parseInt(a.getAttribute("rowspan")||"1");for(let m=0;m<u;m++)d>1&&r.set(l.length,{cell:a,remaining:d-1}),l.push(a)}else{l.push(null);continue}}}for(const[c,a]of e.entries())a.remaining-=1,a.remaining>0&&!r.has(c)&&r.set(c,a);return e=r,t=Math.max(t,l.length),l});for(const o of n)for(;o.length<t;)o.push(null);return n}function $(i){if(!i||!Yn(i))return i;const{top:e,right:t,bottom:n,left:o}=i;if(e==t&&t==n&&n==o)return e}function j(i,e){const t=parseFloat(i);return Number.isNaN(t)||String(t)!==String(i)?i:`${t}${e}`}function _e(i,e={}){const t={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...i};return e.includeAlignmentProperty&&!t.alignment&&(t.alignment="center"),e.includePaddingProperty&&!t.padding&&(t.padding=""),e.includeVerticalAlignmentProperty&&!t.verticalAlignment&&(t.verticalAlignment="middle"),e.includeHorizontalAlignmentProperty&&!t.horizontalAlignment&&(t.horizontalAlignment=e.isRightToLeftContent?"right":"left"),t}function Ge(i,e){return _e({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...i},e)}function Ke(i,e){return _e({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...i},e)}function ot(i,e){return(t,{writer:n})=>{const o=t.getAttribute("headingRows")||0,l=n.createContainerElement("table",null,[]),s=n.createContainerElement("figure",{class:"table"},l);o>0&&n.insert(n.createPositionAt(l,"end"),n.createContainerElement("thead",null,n.createSlot(r=>r.is("element","tableRow")&&r.index<o))),o<i.getRows(t)&&n.insert(n.createPositionAt(l,"end"),n.createContainerElement("tbody",null,n.createSlot(r=>r.is("element","tableRow")&&r.index>=o)));for(const{positionOffset:r,filter:c}of e.additionalSlots)n.insert(n.createPositionAt(l,r),n.createSlot(c));return n.insert(n.createPositionAt(l,"after"),n.createSlot(r=>r.is("element","tableRow")?!1:!e.additionalSlots.some(({filter:c})=>c(r)))),e.asWidget?mo(s,n):s}}function uo(){return(i,{writer:e})=>i.isEmpty?e.createEmptyElement("tr"):e.createContainerElement("tr")}function lt(i){return(t,{writer:n})=>{if(i.cellTypeEnabled?.()){const d=t.getAttribute("tableCellType")==="header"?"th":"td";return e(n,d)}const o=t.parent,l=o.parent,s=l.getChildIndex(o),r=new w(l,{row:s}),c=l.getAttribute("headingRows")||0,a=l.getAttribute("headingColumns")||0;let u=null;for(const d of r)if(d.cell==t){const m=d.row<c||d.column<a;u=e(n,m?"th":"td");break}return u};function e(t,n){return i.asWidget?Rt(t.createEditableElement(n),t,{withAriaRole:!1}):t.createContainerElement(n)}}function it(i={}){return(e,{writer:t})=>{if(!e.parent.is("element","tableCell")||!qt(e))return null;if(i.asWidget)return t.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const n=t.createContainerElement("p");return t.setCustomProperty("dataPipeline:transparentRendering",!0,n),n}}}function qt(i){return i.parent.childCount==1&&!ho(i)}function mo(i,e){return e.setCustomProperty("table",!0,i),pn(i,e,{hasSelectionHandle:!0})}function ho(i){for(const e of i.getAttributeKeys())if(!(e.startsWith("selection:")||e=="htmlEmptyBlock"))return!0;return!1}function go(i){return(e,t)=>{const n=i.plugins.has("PlainTableOutput"),o=t.options.isClipboardPipeline,l=i.config.get("experimentalFlags.useExtendedTableBlockAlignment");return!n&&!(l&&o)?null:fo(e,t,i)}}function bo(i){return(e,{writer:t,options:n})=>{const o=i.plugins.has("PlainTableOutput"),l=n.isClipboardPipeline,s=i.config.get("experimentalFlags.useExtendedTableBlockAlignment");return!o&&!(s&&l)?null:e.parent.name==="table"?t.createContainerElement("caption"):null}}function fo(i,e,t){const n=e.writer,o=i.getAttribute("headingRows")||0,l=n.createSlot(m=>m.is("element","tableRow")&&m.index<o),s=n.createSlot(m=>m.is("element","tableRow")&&m.index>=o),r=n.createSlot(m=>!m.is("element","tableRow")),c=n.createContainerElement("thead",null,l),a=n.createContainerElement("tbody",null,s),u=[];o&&u.push(c),o<i.childCount&&u.push(a);const d={class:"table"};if(t.plugins.has("TablePropertiesEditing")&&e.options.isClipboardPipeline){const m=Ge(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),h=i.getAttribute("tableAlignment");let g=m.alignment;i.getAttribute("tableType")==="layout"&&(g="");const b=h||g;b&&(d.class+=" "+te[b].className,d.style=te[b].style,te[b].align!==void 0&&(d.align=te[b].align))}return n.createContainerElement("table",d,[r,...u])}function po(i){const e={"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"};for(const[t,n]of Object.entries(e))i.conversion.for("dataDowncast").add(o=>o.on(`attribute:${n}:table`,(l,s,r)=>{const{item:c,attributeNewValue:a}=s,{mapper:u,writer:d}=r,m=i.plugins.has("PlainTableOutput"),h=r.options.isClipboardPipeline,g=i.config.get("experimentalFlags.useExtendedTableBlockAlignment");if(!m&&!(g&&h)||!r.consumable.consume(c,l.name))return;const b=u.toViewElement(c);a?d.setStyle(t,a,b):d.removeStyle(t,b)},{priority:"high"}))}class Co extends R{refresh(){const e=this.editor.model,t=e.document.selection,n=e.schema;this.isEnabled=wo(t,n)}execute(e={}){const t=this.editor,n=t.model,o=t.plugins.get("TableUtils"),l=t.config.get("table.defaultHeadings.rows"),s=t.config.get("table.defaultHeadings.columns");e.headingRows===void 0&&l&&(e.headingRows=l),e.headingColumns===void 0&&s&&(e.headingColumns=s),n.change(r=>{const c=o.createTable(r,e);n.insertObject(c,null,null,{findOptimalPosition:"auto"}),r.setSelection(r.createPositionAt(c.getNodeByPath([0,0,0]),0))})}}function wo(i,e){const t=i.getFirstPosition().parent,n=t===t.root?t:t.parent;return e.checkChild(n,"table")}class st extends R{order;constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,n=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=n}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),o=this.order==="above",l=n.getSelectionAffectedTableCells(t),s=n.getRowIndexes(l),r=o?s.first:s.last,c=l[0].findAncestor("table");n.insertRows(c,{at:o?r:r+1,copyStructureFromAbove:!o})}}class rt extends R{order;constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,n=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=n}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),o=this.order==="left",l=n.getSelectionAffectedTableCells(t),s=n.getColumnIndexes(l),r=o?s.first:s.last,c=l[0].findAncestor("table");n.insertColumns(c,{columns:1,at:o?r:r+1})}}class at extends R{direction;constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length===1}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];this.direction==="horizontally"?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}class ne extends R{direction;isHorizontal;constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal=this.direction=="right"||this.direction=="left"}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,o=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],l=this.value,s=this.direction;e.change(r=>{const c=s=="right"||s=="down",a=c?o:l,u=c?l:o,d=u.parent;_o(u,a,r);const m=this.isHorizontal?"colspan":"rowspan",h=parseInt(o.getAttribute(m)||"1"),g=parseInt(l.getAttribute(m)||"1");r.setAttribute(m,h+g,a),r.setSelection(r.createRangeIn(a));const b=this.editor.plugins.get("TableUtils"),f=d.findAncestor("table");je(f,b)})}_getMergeableCell(){const t=this.editor.model.document,n=this.editor.plugins.get("TableUtils"),o=n.getTableCellsContainingSelection(t.selection)[0];if(!o)return;const l=this.isHorizontal?To(o,this.direction,n):yo(o,this.direction,n);if(!l)return;const s=this.isHorizontal?"rowspan":"colspan",r=parseInt(o.getAttribute(s)||"1");if(parseInt(l.getAttribute(s)||"1")===r)return l}}function To(i,e,t){const o=i.parent.parent,l=e=="right"?i.nextSibling:i.previousSibling,s=(o.getAttribute("headingColumns")||0)>0;if(!l)return;const r=e=="right"?i:l,c=e=="right"?l:i,{column:a}=t.getCellLocation(r),{column:u}=t.getCellLocation(c),d=parseInt(r.getAttribute("colspan")||"1"),m=Pe(t,r),h=Pe(t,c);return s&&m!=h?void 0:a+d===u?l:void 0}function yo(i,e,t){const n=i.parent,o=n.parent,l=o.getChildIndex(n);if(e=="down"&&l===t.getRows(o)-1||e=="up"&&l===0)return null;const s=parseInt(i.getAttribute("rowspan")||"1"),r=o.getAttribute("headingRows")||0,c=e=="down"&&l+s===r,a=e=="up"&&l===r;if(r&&(c||a))return null;const u=parseInt(i.getAttribute("rowspan")||"1"),d=e=="down"?l+u:l,m=[...new w(o,{endRow:d})],g=m.find(f=>f.cell===i).column,b=m.find(({row:f,cellHeight:p,column:C})=>C!==g?!1:e=="down"?f===d:d===f+p);return b&&b.cell?b.cell:null}function _o(i,e,t){ct(i)||(ct(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(i),t.createPositionAt(e,"end"))),t.remove(i)}function ct(i){const e=i.getChild(0);return i.childCount==1&&e.is("element","paragraph")&&e.isEmpty}class Ao extends R{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const o=n.findAncestor("table"),s=e.getRows(o)-1,r=e.getRowIndexes(t),c=r.first===0&&r.last===s;this.isEnabled=!c}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),o=t.getRowIndexes(n),l=n[0],s=l.findAncestor("table"),r=t.getCellLocation(l).column;e.change(c=>{const a=o.last-o.first+1;t.removeRows(s,{at:o.first,rows:a});const u=vo(s,o.first,r,t.getRows(s));c.setSelection(c.createPositionAt(u,0))})}}function vo(i,e,t,n){const o=i.getChild(Math.min(e,n-1));let l=o.getChild(0),s=0;for(const r of o.getChildren()){if(s>t)return l;l=r,s+=parseInt(r.getAttribute("colspan")||"1")}return l}class So extends R{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const o=n.findAncestor("table"),l=e.getColumns(o),{first:s,last:r}=e.getColumnIndexes(t);this.isEnabled=r-s<l-1}else this.isEnabled=!1}execute(){const e=this.editor.plugins.get("TableUtils"),[t,n]=ko(this.editor.model.document.selection,e),o=t.parent.parent,l=[...new w(o)],s={first:l.find(c=>c.cell===t).column,last:l.find(c=>c.cell===n).column},r=Ro(l,t,n,s);this.editor.model.change(c=>{const a=s.last-s.first+1;e.removeColumns(o,{at:s.first,columns:a}),c.setSelection(c.createPositionAt(r,0))})}}function Ro(i,e,t,n){return parseInt(t.getAttribute("colspan")||"1")>1?t:e.previousSibling||t.nextSibling?t.nextSibling||e.previousSibling:n.first?i.reverse().find(({column:l})=>l<n.first).cell:i.reverse().find(({column:l})=>l>n.last).cell}function ko(i,e){const t=e.getSelectionAffectedTableCells(i),n=t[0],o=t.pop(),l=[n,o];return n.isBefore(o)?l:l.reverse()}class Io extends R{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection);if(n.length===0){this.isEnabled=!1,this.value=!1;return}const o=n[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(o,"headingRows"),this.value=n.every(l=>this._isInHeading(l,l.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,o=t.getSelectionAffectedTableCells(n.document.selection),l=o[0].findAncestor("table"),{first:s,last:r}=t.getRowIndexes(o),c=this.value?s:r+1,a=l.getAttribute("headingRows")||0;n.change(u=>{if(c){const d=c>a?a:0,m=Mt(l,c,d);for(const{cell:h}of m)Ht(h,c,u)}t.setHeadingRowsCount(u,l,c)})}_isInHeading(e,t){const n=parseInt(t.getAttribute("headingRows")||"0");return!!n&&e.parent.index<n}}class xo extends R{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection);if(n.length===0){this.isEnabled=!1,this.value=!1;return}const o=n[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(o,"headingColumns"),this.value=n.every(l=>Pe(e,l))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,o=t.getSelectionAffectedTableCells(n.document.selection),l=o[0].findAncestor("table"),{first:s,last:r}=t.getColumnIndexes(o),c=this.value?s:r+1;n.change(a=>{if(c){const u=zt(l,c);for(const{cell:d,column:m}of u)Ut(d,m,c,a)}t.setHeadingColumnsCount(a,l,c)})}}const Po=5,Le=40,Eo=2,Vo=3;function Lo(i){const e=new Set;for(const t of i.document.differ.getChanges()){let n=null;switch(t.type){case"insert":n=["table","tableRow","tableCell"].includes(t.name)?t.position:null;break;case"remove":n=["tableRow","tableCell"].includes(t.name)?t.position:null;break;case"attribute":t.range.start.nodeAfter&&(n=["table","tableRow","tableCell"].includes(t.range.start.nodeAfter.name)?t.range.start:null);break}if(!n)continue;const o=n.nodeAfter&&n.nodeAfter.is("element","table")?n.nodeAfter:n.findAncestor("table");for(const l of i.createRangeOn(o).getItems())l.is("element","table")&&Y(l)&&e.add(l)}return e}function No(i,e){return Le*100/Xt(i,e)}function Xt(i,e){const t=ut(i,"tbody",e)||ut(i,"thead",e),n=e.editing.view.domConverter.mapViewToDom(t);return Ne(n)}function ut(i,e,t){return[...[...t.editing.mapper.toViewElement(i).getChildren()].find(l=>l.is("element","table")).getChildren()].find(l=>l.is("element",e))}function Ne(i){const e=ue.window.getComputedStyle(i);return e.boxSizing==="border-box"?parseFloat(e.width)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth):parseFloat(e.width)}function Wo(i,e){const t=e.getCellLocation(i).column,n=i.getAttribute("colspan")||1;return{leftEdge:t,rightEdge:t+n-1}}function I(i){const e=Math.pow(10,Eo),t=typeof i=="number"?i:parseFloat(i);return Math.round(t*e)/e}function Bo(i,e,t){return i<=e?I(e):i>=t?I(t):I(i)}function Fo(i,e){return Array(i).fill(e)}function Z(i){return i.map(e=>typeof e=="number"?e:parseFloat(e)).filter(e=>!Number.isNaN(e)).reduce((e,t)=>e+t,0)}function qe(i){const e=i.map(o=>o==="auto"||o===void 0?"auto":parseFloat(o.replace("%","")));let t=Do(e);const n=Z(t);return n!==100&&(t=t.map(o=>I(o*100/n)).map((o,l,s)=>{if(!(l===s.length-1))return o;const c=Z(s);return I(o+100-c)})),t.map(o=>o+"%")}function Do(i){const e=i.filter(o=>o==="auto").length;if(e===0)return i.map(o=>I(o));const t=Z(i),n=Math.max((100-t)/e,Po);return i.map(o=>o==="auto"?n:o).map(o=>I(o))}function Oo(i){const e=ue.window.getComputedStyle(i);return e.boxSizing==="border-box"?parseInt(e.width):parseFloat(e.width)+parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderWidth)}function Jt(i,e,t,n){for(let o=0;o<Math.max(t.length,i.length);o++){const l=i[o],s=t[o];s?l?n.setAttribute("columnWidth",s,l):n.appendElement("tableColumn",{columnWidth:s},e):n.remove(l)}}function Y(i){if(i.is("element","tableColumnGroup"))return i;const e=i.getChildren();return Array.from(e).find(t=>t.is("element","tableColumnGroup"))}function Q(i){const e=Y(i);return e?Array.from(e.getChildren()):[]}function Mo(i){return Q(i).map(e=>e.getAttribute("columnWidth"))}function Ho(i,e){return Q(i).reduce((n,o)=>{const l=o.getAttribute("columnWidth"),s=o.getAttribute("colSpan");if(!s)return n.push(l),n;for(let r=0;r<s;r++)n.push(l);return e.removeAttribute("colSpan",o),n},[])}class v extends A{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,n=t.parent,o=n.getChildIndex(t),l=new w(n,{row:o});for(const{cell:s,row:r,column:c}of l)if(s===e)return{row:r,column:c};}createTable(e,t){const n=e.createElement("table"),o=t.rows||2,l=t.columns||2;return Re(e,n,0,o,l),t.headingRows&&this.setHeadingRowsCount(e,n,Math.min(t.headingRows,o)),t.headingColumns&&this.setHeadingColumnsCount(e,n,Math.min(t.headingColumns,l)),n}insertRows(e,t={}){const n=this.editor.model,o=t.at||0,l=t.rows||1,s=t.copyStructureFromAbove!==void 0,r=t.copyStructureFromAbove?o-1:o,c=L(this.editor),a=this.getRows(e),u=this.getColumns(e);if(o>a)throw new Ye("tableutils-insertrows-insert-out-of-range",this,{options:t});n.change(d=>{let m=e.getAttribute("headingRows")||0;const h=e.getAttribute("headingColumns")||0;if(m>o&&(m+=l,this.setHeadingRowsCount(d,e,m,{shallow:!0})),!s&&(o===0||o===a)){const p=Re(d,e,o,l,u);if(c)for(let C=0;C<p.length;C++){const T=p[C];for(let y=0;y<u;y++){const k=T[y];(o+C<m||y<h)&&d.setAttribute("tableCellType","header",k)}}return}const g=s?Math.max(o,r):o,b=new w(e,{endRow:g}),f=new Array(u).fill(1);for(const{row:p,column:C,cellHeight:T,cellWidth:y,cell:k}of b){const B=p+T-1,F=p<o&&o<=B,ve=p<=r&&r<=B;F?(d.setAttribute("rowspan",T+l,k),f[C]=-y):s&&ve&&(f[C]=y)}for(let p=0;p<l;p++){const C=d.createElement("tableRow");d.insert(C,e,o);for(let T=0;T<f.length;T++){const y=f[T],k=d.createPositionAt(C,"end");if(y>0){const B=U(d,k,y>1?{colspan:y}:void 0);c&&(o+p<m||T<h)&&d.setAttribute("tableCellType","header",B)}T+=Math.abs(y)-1}}})}insertColumns(e,t={}){const n=this.editor.model,o=t.at||0,l=t.columns||1,s=L(this.editor);n.change(r=>{const c=e.getAttribute("headingRows")||0;let a=e.getAttribute("headingColumns");o<a&&(a+=l,this.setHeadingColumnsCount(r,e,a,{shallow:!0}));const u=this.getColumns(e);if(o===0||u===o){let m=0;for(const h of e.getChildren()){if(!h.is("element","tableRow"))continue;const g=q(l,r,r.createPositionAt(h,o?"end":0));if(s)for(let b=0;b<g.length;b++)(o+b<a||m<c)&&r.setAttribute("tableCellType","header",g[b]);m++}return}const d=new w(e,{column:o,includeAllSlots:!0});for(const m of d){const{row:h,cell:g,cellAnchorColumn:b,cellAnchorRow:f,cellWidth:p,cellHeight:C}=m;if(b<o){r.setAttribute("colspan",p+l,g);const T=f+C-1;for(let y=h;y<=T;y++)d.skipRow(y)}else{const T=q(l,r,m.getPositionBefore());if(s)for(let y=0;y<T.length;y++)(o+y<a||h<c)&&r.setAttribute("tableCellType","header",T[y])}}})}removeRows(e,t){const n=this.editor.model,o=t.rows||1,l=this.getRows(e),s=t.at,r=s+o-1;if(r>l-1)throw new Ye("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});n.change(c=>{const a={first:s,last:r},{cellsToMove:u,cellsToTrim:d}=$o(e,a);if(u.size){const m=r+1;jo(e,m,u,c)}for(let m=r;m>=s;m--)c.remove(e.getChild(m));for(const{rowspan:m,cell:h}of d)_("rowspan",m,h,c);if(Uo(e,a,c),Ee(e,this)||Ve(e,this),L(this.editor)){let m=e.getAttribute("headingRows")||0;const h=this.getRows(e);for(;m<h&&K({table:e,row:m});)m++;this.setHeadingRowsCount(c,e,m,{shallow:!0})}})}removeColumns(e,t){const n=this.editor.model,o=t.at,l=t.columns||1,s=t.at+l-1;n.change(r=>{zo(e,{first:o,last:s},r);const c=Q(e);for(let a=s;a>=o;a--){for(const{cell:u,column:d,cellWidth:m}of[...new w(e)])d<=a&&m>1&&d+m>a?_("colspan",m-1,u,r):d===a&&r.remove(u);if(c[a]){const u=a===0?c[1]:c[a-1],d=parseFloat(c[a].getAttribute("columnWidth")),m=parseFloat(u.getAttribute("columnWidth"));r.remove(c[a]),r.setAttribute("columnWidth",d+m+"%",u)}}if(Ve(e,this)||Ee(e,this),L(this.editor)){let a=e.getAttribute("headingColumns")||0;const u=this.getColumns(e);for(;a<u&&K({table:e,column:a});)a++;this.setHeadingColumnsCount(r,e,a,{shallow:!0})}})}splitCellVertically(e,t=2){const n=this.editor.model,l=e.parent.parent,s=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");n.change(c=>{if(r>1){const{newCellsSpan:a,updatedSpan:u}=dt(r,t);_("colspan",u,e,c);const d={};a>1&&(d.colspan=a),s>1&&(d.rowspan=s);const m=r>t?t-1:r-1;q(m,c,c.createPositionAfter(e),d)}if(r<t){const a=t-r,u=[...new w(l)],{column:d}=u.find(({cell:b})=>b===e),m=u.filter(({cell:b,cellWidth:f,column:p})=>{const C=b!==e&&p===d,T=p<d&&p+f>d;return C||T});for(const{cell:b,cellWidth:f}of m)c.setAttribute("colspan",f+a,b);const h={};s>1&&(h.rowspan=s),q(a,c,c.createPositionAfter(e),h);const g=l.getAttribute("headingColumns")||0;g>d&&_("headingColumns",g+a,l,c)}})}splitCellHorizontally(e,t=2){const n=this.editor.model,o=e.parent,l=o.parent,s=l.getChildIndex(o),r=parseInt(e.getAttribute("rowspan")||"1"),c=parseInt(e.getAttribute("colspan")||"1");n.change(a=>{if(r>1){const u=[...new w(l,{startRow:s,endRow:s+r-1,includeAllSlots:!0})],{newCellsSpan:d,updatedSpan:m}=dt(r,t);_("rowspan",m,e,a);const{column:h}=u.find(({cell:f})=>f===e),g={};d>1&&(g.rowspan=d),c>1&&(g.colspan=c);let b=0;for(const f of u){const{column:p,row:C}=f,T=C>=s+m,y=p===h;b>=d&&y&&(b=0),T&&y&&(b||q(1,a,f.getPositionBefore(),g),b++)}}if(r<t){const u=t-r,d=[...new w(l,{startRow:0,endRow:s})];for(const{cell:g,cellHeight:b,row:f}of d)if(g!==e&&f+b>s){const p=b+u;a.setAttribute("rowspan",p,g)}const m={};c>1&&(m.colspan=c),Re(a,l,s+1,u,1,m);const h=l.getAttribute("headingRows")||0;h>s&&_("headingRows",h+u,l,a)}})}getColumns(e){return[...e.getChild(0).getChildren()].filter(n=>n.is("element","tableCell")).reduce((n,o)=>{const l=parseInt(o.getAttribute("colspan")||"1");return n+l},0)}getRows(e){return Array.from(e.getChildren()).reduce((t,n)=>n.is("element","tableRow")?t+1:t,0)}createTableWalker(e,t={}){return new w(e,t)}getSelectedTableCells(e){const t=[];for(const n of this.sortRanges(e.getRanges())){const o=n.getContainedElement();o&&o.is("element","tableCell")&&t.push(o)}return t}setHeadingRowsCount(e,t,n,o={}){const{shallow:l,resetFormerHeadingCells:s=!0,autoExpand:r=!0}=o,c=t.getAttribute("headingRows")||0;if(n!==c&&(_("headingRows",n,t,e,0),!(l||!L(this.editor)))){for(const{cell:a,row:u,column:d}of new w(t,{endRow:n-1}))oe({table:t,writer:e,cell:a,row:u,column:d});if(s&&n<c)for(let a=n;a<c&&K({table:t,row:a});a++)for(const{cell:u,row:d,column:m}of new w(t,{row:a}))oe({table:t,writer:e,cell:u,row:d,column:m});if(r&&n>c){const a=this.getRows(t);for(;n<a&&K({table:t,row:n});)n++;_("headingRows",n,t,e,0)}}}setHeadingColumnsCount(e,t,n,o={}){const{shallow:l,resetFormerHeadingCells:s=!0,autoExpand:r=!0}=o,c=t.getAttribute("headingColumns")||0;if(n!==c&&(_("headingColumns",n,t,e,0),!(l||!L(this.editor)))){for(const{cell:a,row:u,column:d}of new w(t,{endColumn:n-1}))oe({table:t,writer:e,cell:a,row:u,column:d});if(s&&n<c)for(let a=n;a<c&&K({table:t,column:a});a++)for(const{cell:u,row:d,column:m}of new w(t,{column:a}))oe({table:t,writer:e,cell:u,row:d,column:m});if(r&&n>c){const a=this.getColumns(t);for(;n<a&&K({table:t,column:n});)n++;_("headingColumns",n,t,e,0)}}}getTableCellsContainingSelection(e){const t=[];for(const n of e.getRanges()){const o=n.start.findAncestor("tableCell");o&&t.push(o)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map(n=>n.parent.index);return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),o=[...new w(t)].filter(l=>e.includes(l.cell)).map(l=>l.column);return this._getFirstLastIndexesObject(o)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,n=new Set;let o=0;for(const s of e){const{row:r,column:c}=this.getCellLocation(s),a=parseInt(s.getAttribute("rowspan"))||1,u=parseInt(s.getAttribute("colspan"))||1;t.add(r),n.add(c),a>1&&t.add(r+a-1),u>1&&n.add(c+u-1),o+=a*u}return Ko(t,n)==o}sortRanges(e){return Array.from(e).sort(Go)}_getFirstLastIndexesObject(e){const t=e.sort((l,s)=>l-s),n=t[0],o=t[t.length-1];return{first:n,last:o}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),n=this.getRowIndexes(e),o=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(n,o))return!1;const l=this.getColumnIndexes(e),s=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(l,s)}_areIndexesInSameSection({first:e,last:t},n){const o=e<n,l=t<n;return o===l}}function Re(i,e,t,n,o,l={}){const s=[];for(let r=0;r<n;r++){const c=i.createElement("tableRow");i.insert(c,e,t),s.push(q(o,i,i.createPositionAt(c,"end"),l))}return s}function q(i,e,t,n={}){const o=[];let l=t;for(let s=0;s<i;s++){const r=U(e,l,n);o.push(r),l=e.createPositionAfter(r)}return o}function dt(i,e){if(i<e)return{newCellsSpan:1,updatedSpan:1};const t=Math.floor(i/e),n=i-t*e+t;return{newCellsSpan:t,updatedSpan:n}}function zo(i,e,t){const n=i.getAttribute("headingColumns")||0;if(n&&e.first<n){const o=Math.min(n-1,e.last)-e.first+1;t.setAttribute("headingColumns",n-o,i)}}function Uo(i,{first:e,last:t},n){const o=i.getAttribute("headingRows")||0;if(e<o){const l=t<o?o-(t-e+1):e;_("headingRows",l,i,n,0)}}function $o(i,{first:e,last:t}){const n=new Map,o=[];for(const{row:l,column:s,cellHeight:r,cell:c}of new w(i,{endRow:t})){const a=l+r-1;if(l>=e&&l<=t&&a>t){const m=t-l+1,h=r-m;n.set(s,{cell:c,rowspan:h})}if(l<e&&a>=e){let m;a>=t?m=t-e+1:m=a-e+1,o.push({cell:c,rowspan:r-m})}}return{cellsToMove:n,cellsToTrim:o}}function jo(i,e,t,n){const l=[...new w(i,{includeAllSlots:!0,row:e})],s=i.getChild(e);let r;for(const{column:c,cell:a,isAnchor:u}of l)if(t.has(c)){const{cell:d,rowspan:m}=t.get(c),h=r?n.createPositionAfter(r):n.createPositionAt(s,0);n.move(n.createRangeOn(d),h),_("rowspan",m,d,n),r=d}else u&&(r=a)}function Go(i,e){const t=i.start,n=e.start;return t.isBefore(n)?-1:1}function Ko(i,e){const t=Array.from(i.values()),n=Array.from(e.values()),o=Math.max(...t),l=Math.min(...t),s=Math.max(...n),r=Math.min(...n);return(o-l+1)*(s-r+1)}function oe({writer:i,table:e,row:t,column:n,cell:o}){const l=e.getAttribute("headingRows")||0,s=e.getAttribute("headingColumns")||0;t>=l&&n>=s?i.removeAttribute("tableCellType",o):i.setAttribute("tableCellType","header",o)}class qo extends R{refresh(){const e=this.editor.plugins.get(v),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(v);e.change(n=>{const o=t.getSelectedTableCells(e.document.selection),l=o.shift(),{mergeWidth:s,mergeHeight:r}=Jo(l,o,t);_("colspan",s,l,n),_("rowspan",r,l,n);for(const a of o)Xo(a,l,n);const c=l.findAncestor("table");je(c,t),n.setSelection(l,"in")})}}function Xo(i,e,t){mt(i)||(mt(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(i),t.createPositionAt(e,"end"))),t.remove(i)}function mt(i){const e=i.getChild(0);return i.childCount==1&&e.is("element","paragraph")&&e.isEmpty}function Jo(i,e,t){let n=0,o=0;for(const a of e){const{row:u,column:d}=t.getCellLocation(a);n=ht(a,d,n,"colspan"),o=ht(a,u,o,"rowspan")}const{row:l,column:s}=t.getCellLocation(i),r=n-s,c=o-l;return{mergeWidth:r,mergeHeight:c}}function ht(i,e,t,n){const o=parseInt(i.getAttribute(n)||"1");return Math.max(t,e+o)}class Zo extends R{constructor(e){super(e),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),o=t.getRowIndexes(n),l=n[0].findAncestor("table"),s=[];for(let r=o.first;r<=o.last;r++)for(const c of l.getChild(r).getChildren())s.push(e.createRangeOn(c));e.change(r=>{r.setSelection(s)})}}class Yo extends R{constructor(e){super(e),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),o=n[0],l=n.pop(),s=o.findAncestor("table"),r=e.getCellLocation(o),c=e.getCellLocation(l),a=Math.min(r.column,c.column),u=Math.max(r.column,c.column),d=[];for(const m of new w(s,{startColumn:a,endColumn:u}))d.push(t.createRangeOn(m.cell));t.change(m=>{m.setSelection(d)})}}function Qo(i){i.document.registerPostFixer(e=>el(e,i))}function el(i,e){const t=e.document.differ.getChanges();let n=!1;const o=new Set;for(const l of t){let s=null;l.type=="insert"&&l.name=="table"&&(s=l.position.nodeAfter),(l.type=="insert"||l.type=="remove")&&(l.name=="tableRow"||l.name=="tableCell")&&(s=l.position.findAncestor("table")),il(l)&&(s=l.range.start.findAncestor("table")),s&&!o.has(s)&&(n=tl(s,i)||n,n=nl(s,i)||n,o.add(s))}return n}function tl(i,e){let t=!1;const n=ol(i);if(n.length){t=!0;for(const o of n)_("rowspan",o.rowspan,o.cell,e,1)}return t}function nl(i,e){let t=!1;const n=ll(i),o=[];for(const[c,a]of n.entries())!a&&i.getChild(c).is("element","tableRow")&&o.push(c);if(o.length){t=!0;for(const c of o.reverse())e.remove(i.getChild(c)),n.splice(c,1)}const l=n.filter((c,a)=>i.getChild(a).is("element","tableRow")),s=l[0];if(!l.every(c=>c===s)){const c=l.reduce((a,u)=>u>a?u:a,0);for(const[a,u]of l.entries()){const d=c-u;if(d){for(let m=0;m<d;m++)U(e,e.createPositionAt(i.getChild(a),"end"));t=!0}}}return t}function ol(i){const e=parseInt(i.getAttribute("headingRows")||"0"),t=Array.from(i.getChildren()).reduce((o,l)=>l.is("element","tableRow")?o+1:o,0),n=[];for(const{row:o,cell:l,cellHeight:s}of new w(i)){if(s<2)continue;const c=o<e?e:t;if(o+s>c){const a=c-o;n.push({cell:l,rowspan:a})}}return n}function ll(i){const e=new Array(i.childCount).fill(0);for(const{rowIndex:t}of new w(i,{includeAllSlots:!0}))e[t]++;return e}function il(i){if(i.type!=="attribute")return!1;const e=i.attributeKey;return e==="headingRows"||e==="colspan"||e==="rowspan"}function sl(i){i.document.registerPostFixer(e=>rl(e,i))}function rl(i,e){const t=e.document.differ.getChanges();let n=!1;for(const o of t)o.type=="insert"&&o.name=="table"&&(n=al(o.position.nodeAfter,i)||n),o.type=="insert"&&o.name=="tableRow"&&(n=Zt(o.position.nodeAfter,i)||n),o.type=="insert"&&o.name=="tableCell"&&(n=We(o.position.nodeAfter,i)||n),(o.type=="remove"||o.type=="insert")&&cl(o)&&(n=We(o.position.parent,i)||n);return n}function al(i,e){let t=!1;for(const n of i.getChildren())n.is("element","tableRow")&&(t=Zt(n,e)||t);return t}function Zt(i,e){let t=!1;for(const n of i.getChildren())t=We(n,e)||t;return t}function We(i,e){if(i.childCount==0)return e.insertElement("paragraph",i),!0;const t=Array.from(i.getChildren()).filter(n=>n.is("$text"));for(const n of t)e.wrap(e.createRangeOn(n),"paragraph");return!!t.length}function cl(i){return i.position.parent.is("element","tableCell")?i.type=="insert"&&i.name=="$text"||i.type=="remove":!1}function ul(i,e){const t=i.document.differ;for(const n of t.getChanges()){let o,l=!1;if(n.type=="attribute"){const a=n.range.start.nodeAfter;if(!a||!a.is("element","table")||n.attributeKey!="headingRows"&&n.attributeKey!="headingColumns")continue;o=a,l=n.attributeKey=="headingRows"}else(n.name=="tableRow"||n.name=="tableCell")&&(o=n.position.findAncestor("table"),l=n.name=="tableRow");if(!o)continue;const s=o.getAttribute("headingRows")||0,r=o.getAttribute("headingColumns")||0,c=new w(o);for(const a of c){const d=a.row<s||a.column<r?"th":"td",m=e.mapper.toViewElement(a.cell);m&&m.is("element")&&m.name!=d&&e.reconvertItem(l?a.cell.parent:a.cell)}}}function dl(i,e){const t=i.document.differ,n=new Set;for(const o of t.getChanges()){const l=o.type=="attribute"?o.range.start.parent:o.position.parent;l.is("element","tableCell")&&n.add(l)}for(const o of n.values()){const l=Array.from(o.getChildren()).filter(s=>ml(s,e.mapper));for(const s of l)e.reconvertItem(s)}}function ml(i,e){if(!i.is("element","paragraph"))return!1;const t=e.toViewElement(i);return t?qt(i)!==t.is("element","span"):!1}class ee extends A{_additionalSlots;static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[v]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,n=t.schema,o=e.conversion,l=e.plugins.get(v);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),o.for("upcast").add(io()),o.for("upcast").add(so()),o.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:ot(l,{asWidget:!0,additionalSlots:this._additionalSlots})}),o.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:ot(l,{additionalSlots:this._additionalSlots})}),o.for("upcast").elementToElement({model:"tableRow",view:"tr"}),o.for("upcast").add(ro()),o.for("downcast").elementToElement({model:"tableRow",view:uo()}),o.for("upcast").elementToElement({model:"tableCell",view:"td"}),o.for("upcast").elementToElement({model:"tableCell",view:"th"}),o.for("upcast").add(nt("td")),o.for("upcast").add(nt("th")),o.for("editingDowncast").elementToElement({model:"tableCell",view:lt({asWidget:!0,cellTypeEnabled:()=>L(this.editor)})}),o.for("dataDowncast").elementToElement({model:"tableCell",view:lt({cellTypeEnabled:()=>L(this.editor)})}),o.for("editingDowncast").elementToElement({model:"paragraph",view:it({asWidget:!0}),converterPriority:"high"}),o.for("dataDowncast").elementToElement({model:"paragraph",view:it(),converterPriority:"high"}),o.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),o.for("upcast").attributeToAttribute({model:{key:"colspan",value:gt("colspan")},view:"colspan"}),o.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),o.for("upcast").attributeToAttribute({model:{key:"rowspan",value:gt("rowspan")},view:"rowspan"}),this._addPlainTableOutputConverters(),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.config.define("table.showHiddenBorders",!0),e.config.get("table.showHiddenBorders")&&e.editing.view.change(s=>{for(const r of e.editing.view.document.roots)s.addClass("ck-table-show-hidden-borders",r)}),e.commands.add("insertTable",new Co(e)),e.commands.add("insertTableRowAbove",new st(e,{order:"above"})),e.commands.add("insertTableRowBelow",new st(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new rt(e,{order:"left"})),e.commands.add("insertTableColumnRight",new rt(e,{order:"right"})),e.commands.add("removeTableRow",new Ao(e)),e.commands.add("removeTableColumn",new So(e)),e.commands.add("splitTableCellVertically",new at(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new at(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new qo(e)),e.commands.add("mergeTableCellRight",new ne(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new ne(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new ne(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new ne(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new xo(e)),e.commands.add("setTableRowHeader",new Io(e)),e.commands.add("selectTableRow",new Zo(e)),e.commands.add("selectTableColumn",new Yo(e)),Qo(t),sl(t),this.listenTo(t.document,"change:data",()=>{L(e)||ul(t,e.editing),dl(t,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}_addPlainTableOutputConverters(){const e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:go(e),converterPriority:"high"}),e.plugins.has("TableCaptionEditing")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:bo(e),converterPriority:"high"}),e.plugins.has("TablePropertiesEditing")&&po(e)}}function gt(i){return e=>{const t=parseInt(e.getAttribute(i));return Number.isNaN(t)||t<=0?null:t}}class bt extends z{items;keystrokes;focusTracker;constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new Te,this.focusTracker=new ye,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(n,o)=>`${o} × ${n}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to(n=>{n.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(n,o)=>{const{row:l,column:s}=o.target.dataset;this.items.get((parseInt(l,10)-1)*10+(parseInt(s,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(n,o,l)=>{if(!l)return;const{row:s,column:r}=l.dataset;this.set({rows:parseInt(s),columns:parseInt(r)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){super.render(),Hn({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((n,o)=>{const l=Math.floor(o/10),s=o%10,r=l<e&&s<t;n.set("isOn",r)})}_createGridButton(e,t,n,o){const l=new W(e);return l.set({label:o,class:"ck-insert-table-dropdown-grid-box"}),l.extendTemplate({attributes:{"data-row":t,"data-column":n}}),l}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const n=Math.floor(t/10),o=t%10,l=`${n+1} × ${o+1}`;e.push(this._createGridButton(this.locale,n+1,o+1,l))}return this.createCollection(e)}}class hl extends A{static get pluginName(){return"TableUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t,o=e.locale.contentLanguageDirection==="ltr";e.ui.componentFactory.add("insertTable",l=>{const s=e.commands.get("insertTable"),r=se(l);r.bind("isEnabled").to(s),r.buttonView.set({icon:Qe,label:t("Insert table"),tooltip:!0});let c;return r.on("change:isOpen",()=>{c||(c=new bt(l),r.panelView.children.add(c),c.delegate("execute").to(r),r.on("execute",()=>{e.execute("insertTable",{rows:c.rows,columns:c.columns}),e.editing.view.focus()}))}),r}),e.ui.componentFactory.add("menuBar:insertTable",l=>{const s=e.commands.get("insertTable"),r=new Dn(l),c=new bt(l);return c.delegate("execute").to(r),r.on("change:isOpen",(a,u,d)=>{d||c.reset()}),c.on("execute",()=>{e.execute("insertTable",{rows:c.rows,columns:c.columns}),e.editing.view.focus()}),r.buttonView.set({label:t("Table"),icon:Qe}),r.panelView.children.add(c),r.bind("isEnabled").to(s),r}),e.ui.componentFactory.add("tableColumn",l=>{const s=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:o?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:o?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),_n,s,l)}),e.ui.componentFactory.add("tableRow",l=>{const s=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),An,s,l)}),e.ui.componentFactory.add("mergeTableCells",l=>{const s=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:o?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:o?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),vn,s,l)})}_prepareDropdown(e,t,n,o){const l=this.editor,s=se(o),r=this._fillDropdownWithListOptions(s,n);return s.buttonView.set({label:e,icon:t,tooltip:!0}),s.bind("isEnabled").toMany(r,"isEnabled",(...c)=>c.some(a=>a)),this.listenTo(s,"execute",c=>{l.execute(c.source.commandName),c.source instanceof On||l.editing.view.focus()}),s}_prepareMergeSplitButtonDropdown(e,t,n,o){const l=this.editor,s=se(o,Mn),r="mergeTableCells",c=l.commands.get(r),a=this._fillDropdownWithListOptions(s,n);return s.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),s.bind("isEnabled").toMany([c,...a],"isEnabled",(...u)=>u.some(d=>d)),this.listenTo(s.buttonView,"execute",()=>{l.execute(r),l.editing.view.focus()}),this.listenTo(s,"execute",u=>{l.execute(u.source.commandName),l.editing.view.focus()}),s}_fillDropdownWithListOptions(e,t){const n=this.editor,o=[],l=new kt;for(const s of t)gl(s,n,o,l);return He(e,l),o}}function gl(i,e,t,n){if(i.type==="button"||i.type==="switchbutton"){const o=i.model=new Et(i.model),{commandName:l,bindIsOn:s}=i.model,r=e.commands.get(l);t.push(r),o.set({commandName:l}),o.bind("isEnabled").to(r),s&&o.bind("isOn").to(r,"value"),o.set({withText:!0})}n.add(i)}class O extends A{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[v,v]}init(){const e=this.editor,t=e.model,n=e.editing.view;this.listenTo(t,"deleteContent",(o,l)=>this._handleDeleteContent(o,l),{priority:"high"}),this.listenTo(n.document,"insertText",(o,l)=>this._handleInsertTextEvent(o,l),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(v),t=this.editor.model.document.selection,n=e.getSelectedTableCells(t);return n.length==0?null:n}getSelectionAsFragment(){const e=this.editor.plugins.get(v),t=this.getSelectedTableCells();return t?this.editor.model.change(n=>{const o=n.createDocumentFragment(),{first:l,last:s}=e.getColumnIndexes(t),{first:r,last:c}=e.getRowIndexes(t),a=t[0].findAncestor("table");let u=c,d=s;if(e.isSelectionRectangular(t)){const g={firstColumn:l,lastColumn:s,firstRow:r,lastRow:c};u=jt(a,g),d=Gt(a,g)}const h=Ot(a,{startRow:r,startColumn:l,endRow:u,endColumn:d},n);return n.insert(h,o,0),o}):null}setCellSelection(e,t){const n=this._getCellsToSelect(e,t);this.editor.model.change(o=>{o.setSelection(n.cells.map(l=>o.createRangeOn(l)),{backward:n.backward})})}getFocusCell(){const n=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return n&&n.is("element","tableCell")?n:null}getAnchorCell(){const e=this.editor.model.document.selection,n=we(e.getRanges()).getContainedElement();return n&&n.is("element","tableCell")?n:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(o=>o.on("selection",(l,s,r)=>{const c=r.writer;n(c);const a=this.getSelectedTableCells();if(!a)return;for(const d of a){const m=r.mapper.toViewElement(d);c.addClass("ck-editor__editable_selected",m),t.add(m)}const u=r.mapper.toViewElement(a[a.length-1]);c.setSelection(u,0)},{priority:"lowest"}));function n(o){for(const l of t)o.removeClass("ck-editor__editable_selected",l);t.clear()}}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(n=>{const o=n.createPositionAt(t[0],0),l=e.model.schema.getNearestSelectionRange(o);n.setSelection(l)})}})}_handleDeleteContent(e,t){const n=this.editor.plugins.get(v),o=t[0],l=t[1],s=this.editor.model,r=!l||l.direction=="backward",c=n.getSelectedTableCells(o);c.length&&(e.stop(),s.change(a=>{const u=c[r?c.length-1:0];s.change(m=>{for(const h of c)s.deleteContent(m.createSelection(h,"in"))});const d=s.schema.getNearestSelectionRange(a.createPositionAt(u,0));o.is("documentSelection")?a.setSelection(d):o.setTo(d)}))}_handleInsertTextEvent(e,t){const n=this.editor,o=this.getSelectedTableCells();if(!o)return;const l=n.editing.view,s=n.editing.mapper,r=o.map(c=>l.createRangeOn(s.toViewElement(c)));t.selection=l.createSelection(r),t.preventDefault()}_getCellsToSelect(e,t){const n=this.editor.plugins.get("TableUtils"),o=n.getCellLocation(e),l=n.getCellLocation(t),s=Math.min(o.row,l.row),r=Math.max(o.row,l.row),c=Math.min(o.column,l.column),a=parseInt(t.getAttribute("colspan")||"1")-1,u=Math.max(o.column,l.column+a),d=new Array(r-s+1).fill(null).map(()=>[]),m={startRow:s,endRow:r,startColumn:c,endColumn:u};for(const{row:b,cell:f}of new w(e.findAncestor("table"),m))d[b-s].push(f);const h=l.row<o.row,g=l.column<o.column;return h&&d.reverse(),g&&d.forEach(b=>b.reverse()),{cells:d.flat(),backward:h||g}}}class bl extends A{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Se,et,O,v]}init(){const t=this.editor.editing.view.document;this.listenTo(t,"copy",(n,o)=>this._onCopyCut(n,o)),this.listenTo(t,"cut",(n,o)=>this._onCopyCut(n,o)),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){const{editor:e}=this,t=e.plugins.get(et),n=e.plugins.get(O);let o=!1;t.on("contentInsertion",(l,s)=>{o=s.method==="paste"}),this.listenTo(e.model,"insertContent",(l,[s,r])=>{(o||n.getSelectedTableCells()!==null)&&this._onInsertContent(l,s,r)},{priority:"high"}),t.on("contentInsertion",()=>{o=!1},{priority:"lowest"})}_onCopyCut(e,t){const n=this.editor.editing.view,o=this.editor.plugins.get(O),l=this.editor.plugins.get(Se);o.getSelectedTableCells()&&(e.name=="cut"&&!this.editor.model.canEditAt(this.editor.model.document.selection)||(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:e.name==="cut"},()=>{const s=l._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,()=>o.getSelectionAsFragment());n.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(s),method:e.name})})))}_onInsertContent(e,t,n){if(n&&!n.is("documentSelection"))return;const o=this.editor.model,l=this.editor.plugins.get(v),s=this.editor.plugins.get(Se),r=this.getTableIfOnlyTableInContent(t,o);if(!r)return;const c=l.getSelectionAffectedTableCells(o.document.selection);if(!c.length){je(r,l);return}e.stop(),t.is("documentFragment")?s._pasteMarkersIntoTransformedElement(t.markers,a=>this._replaceSelectedCells(r,c,a)):this.editor.model.change(a=>{this._replaceSelectedCells(r,c,a)})}_replaceSelectedCells(e,t,n){const o=this.editor.plugins.get(v),l={width:o.getColumns(e),height:o.getRows(e)},s=fl(t,l,n,o),r=s.lastRow-s.firstRow+1,c=s.lastColumn-s.firstColumn+1,a={startRow:0,startColumn:0,endRow:Math.min(r,l.height)-1,endColumn:Math.min(c,l.width)-1};e=Ot(e,a,n);const u=t[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(e,l,u,s,n);if(this.editor.plugins.get("TableSelection").isEnabled){const m=o.sortRanges(d.map(h=>n.createRangeOn(h)));n.setSelection(m)}else n.setSelection(d[0],0);return u}_replaceSelectedCellsWithPasted(e,t,n,o,l){const{width:s,height:r}=t,c=Cl(e,s,r),a=[...new w(n,{startRow:o.firstRow,endRow:o.lastRow,startColumn:o.firstColumn,endColumn:o.lastColumn,includeAllSlots:!0})],u=[];let d;for(const f of a){const{row:p,column:C}=f;C===o.firstColumn&&(d=f.getPositionBefore());const T=p-o.firstRow,y=C-o.firstColumn,k=c[T%r][y%s],B=k?l.cloneElement(k):null,F=this._replaceTableSlotCell(f,B,d,l);F&&($t(F,p,C,o.lastRow,o.lastColumn,l),u.push(F),d=l.createPositionAfter(F))}const m=parseInt(n.getAttribute("headingRows")||"0"),h=parseInt(n.getAttribute("headingColumns")||"0"),g=o.firstRow<m&&m<=o.lastRow,b=o.firstColumn<h&&h<=o.lastColumn;if(g){const f={first:o.firstColumn,last:o.lastColumn},p=Be(n,m,f,l,o.firstRow);u.push(...p)}if(b){const f={first:o.firstRow,last:o.lastRow},p=Fe(n,h,f,l);u.push(...p)}return u}_replaceTableSlotCell(e,t,n,o){const{cell:l,isAnchor:s}=e;return s&&o.remove(l),t?(o.insert(t,n),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(e.childCount==1&&e.getChild(0).is("element","table"))return e.getChild(0);const n=t.createRangeIn(e);for(const o of n.getItems())if(o.is("element","table")){const l=t.createRange(n.start,t.createPositionBefore(o));if(t.hasContent(l,{ignoreWhitespaces:!0}))return null;const s=t.createRange(t.createPositionAfter(o),n.end);return t.hasContent(s,{ignoreWhitespaces:!0})?null:o}return null}}function fl(i,e,t,n){const o=i[0].findAncestor("table"),l=n.getColumnIndexes(i),s=n.getRowIndexes(i),r={firstColumn:l.first,lastColumn:l.last,firstRow:s.first,lastRow:s.last},c=i.length===1;return c&&(r.lastRow+=e.height-1,r.lastColumn+=e.width-1,pl(o,r.lastRow+1,r.lastColumn+1,n)),c||!n.isSelectionRectangular(i)?wl(o,r,t):(r.lastRow=jt(o,r),r.lastColumn=Gt(o,r)),r}function pl(i,e,t,n){const o=n.getColumns(i),l=n.getRows(i);t>o&&n.insertColumns(i,{at:o,columns:t-o}),e>l&&n.insertRows(i,{at:l,rows:e-l})}function Cl(i,e,t){const n=new Array(t).fill(null).map(()=>new Array(e).fill(null));for(const{column:o,row:l,cell:s}of new w(i))n[l][o]=s;return n}function wl(i,e,t){const{firstRow:n,lastRow:o,firstColumn:l,lastColumn:s}=e,r={first:n,last:o},c={first:l,last:s};Fe(i,l,r,t),Fe(i,s+1,r,t),Be(i,n,c,t),Be(i,o+1,c,t,n)}function Be(i,e,t,n,o=0){return e<1?void 0:Mt(i,e,o).filter(({column:r,cellWidth:c})=>Yt(r,c,t)).map(({cell:r})=>Ht(r,e,n))}function Fe(i,e,t,n){return e<1?void 0:zt(i,e).filter(({row:s,cellHeight:r})=>Yt(s,r,t)).map(({cell:s,column:r})=>Ut(s,r,e,n))}function Yt(i,e,t){const n=i+e-1,{first:o,last:l}=t,s=i>=o&&i<=l,r=i<o&&n>=o;return s||r}class Tl extends A{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[O,v]}init(){const e=this.editor,n=e.editing.view.document,o=e.t;this.listenTo(n,"arrowKey",(...l)=>this._onArrowKey(...l),{context:"table"}),this.listenTo(n,"tab",(...l)=>this._handleTabOnSelectedTable(...l),{context:"figure"}),this.listenTo(n,"tab",(...l)=>this._handleTab(...l),{context:["th","td"]}),e.accessibility.addKeystrokeInfoGroup({id:"table",label:o("Keystrokes that can be used in a table cell"),keystrokes:[{label:o("Move the selection to the next cell"),keystroke:"Tab"},{label:o("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:o("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:o("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(e,t){const l=this.editor.model.document.selection.getSelectedElement();!l||!l.is("element","table")||t.stopPropagation()}_handleTab(e,t){const n=this.editor,o=this.editor.plugins.get(v),l=this.editor.plugins.get("TableSelection"),s=n.model.document.selection,r=!t.shiftKey;let c=o.getTableCellsContainingSelection(s)[0];if(c||(c=l.getFocusCell()),!c)return;t.stopPropagation();const a=c.parent,u=a.parent,d=u.getChildIndex(a),h=a.getChildIndex(c)===a.childCount-1,g=d===o.getRows(u)-1;r&&g&&h&&n.execute("insertTableRowBelow")}_onArrowKey(e,t){const n=this.editor,o=t.keyCode,l=Cn(o,n.locale.contentLanguageDirection);this._handleArrowKeys(l,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const n=this.editor.plugins.get(v),o=this.editor.plugins.get("TableSelection"),l=this.editor.model,s=l.document.selection,r=["right","down"].includes(e),c=n.getSelectedTableCells(s);if(c.length){let u;return t?u=o.getFocusCell():u=r?c[c.length-1]:c[0],this._navigateFromCellInDirection(u,e,t),!0}const a=s.focus.findAncestor("tableCell");if(!a)return!1;if(!s.isCollapsed)if(t){if(s.isBackward==r&&!s.containsEntireContent(a))return!1}else{const u=s.getSelectedElement();if(!u||!l.schema.isObject(u))return!1}return this._isSelectionAtCellEdge(s,a,r)?(this._navigateFromCellInDirection(a,e,t),!0):!1}_isSelectionAtCellEdge(e,t,n){const o=this.editor.model,l=this.editor.model.schema,s=n?e.getLastPosition():e.getFirstPosition();if(!l.getLimitElement(s).is("element","tableCell"))return o.createPositionAt(t,n?"end":0).isTouching(s);const r=o.createSelection(s);return o.modifySelection(r,{direction:n?"forward":"backward"}),s.isEqual(r.focus)}_navigateFromCellInDirection(e,t,n=!1){const o=this.editor.model,l=e.findAncestor("table"),s=[...new w(l,{includeAllSlots:!0})],{row:r,column:c}=s[s.length-1],a=s.find(({cell:C})=>C==e);let{row:u,column:d}=a;switch(t){case"left":d--;break;case"up":u--;break;case"right":d+=a.cellWidth;break;case"down":u+=a.cellHeight;break}const m=u<0||u>r,h=d<0&&u<=0,g=d>c&&u>=r;if(m||h||g){o.change(C=>{C.setSelection(C.createRangeOn(l))});return}d<0?(d=n?0:c,u--):d>c&&(d=n?c:0,u++);const b=s.find(C=>C.row==u&&C.column==d).cell,f=["right","down"].includes(t),p=this.editor.plugins.get("TableSelection");if(n&&p.isEnabled){const C=p.getAnchorCell()||e;p.setCellSelection(C,b)}else{const C=o.createPositionAt(b,f?0:"end");o.change(T=>{T.setSelection(C)})}}}class Qt extends qn{domEventType=["mousemove","mouseleave"];onDomEvent(e){this.fire(e.type,e)}}class yl extends A{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[O,v]}init(){this.editor.editing.view.addObserver(Qt),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(v);let n=!1;const o=e.plugins.get(O);this.listenTo(e.editing.view.document,"mousedown",(l,s)=>{const r=e.model.document.selection;if(!this.isEnabled||!o.isEnabled||!s.domEvent.shiftKey)return;const c=o.getAnchorCell()||t.getTableCellsContainingSelection(r)[0];if(!c)return;const a=this._getModelTableCellFromDomEvent(s);a&&ft(c,a)&&(n=!0,o.setCellSelection(c,a),s.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1}),this.listenTo(e.editing.view.document,"selectionChange",l=>{n&&l.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,n,o=!1,l=!1;const s=e.plugins.get(O);this.listenTo(e.editing.view.document,"mousedown",(r,c)=>{!this.isEnabled||!s.isEnabled||c.domEvent.shiftKey||c.domEvent.ctrlKey||c.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(c))}),this.listenTo(e.editing.view.document,"mousemove",(r,c)=>{if(!c.domEvent.buttons||!t)return;const a=this._getModelTableCellFromDomEvent(c);a&&ft(t,a)&&(n=a,!o&&n!=t&&(o=!0)),o&&(l=!0,s.setCellSelection(t,n),c.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{o=!1,l=!1,t=null,n=null}),this.listenTo(e.editing.view.document,"selectionChange",r=>{l&&r.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,n=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function ft(i,e){return i.parent.parent==e.parent.parent}class Ei extends A{static get requires(){return[ee,hl,O,yl,Tl,bl,bn]}static get pluginName(){return"Table"}static get isOfficialPlugin(){return!0}}function be(i){const e=en(i);return e||Ae(i)}function en(i){const e=i.getSelectedElement();return e&&tn(e)?e:null}function Ae(i){const e=i.getFirstPosition();if(!e)return null;let t=e.parent;for(;t;){if(t.is("element")&&tn(t))return t;t=t.parent}return null}function tn(i){return i.is("element")&&!!i.getCustomProperty("table")&&fn(i)}class Vi extends A{static get requires(){return[Ze]}static get pluginName(){return"TableToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(Ze),o=e.config.get("table.contentToolbar"),l=e.config.get("table.tableToolbar");o&&n.register("tableContent",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:Ae}),l&&n.register("table",{ariaLabel:t("Table toolbar"),items:l,getRelatedElement:en})}}class _l extends z{options;focusTracker;focusCycler;_focusables;dropdownView;inputView;keystrokes;_stillTyping;constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new ye,this._focusables=new ze,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new Te,this._stillTyping=!1,this.focusCycler=new Ue({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",(n,o,l)=>this._setInputValue(l))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach(e=>{this.focusTracker.add(e.element),this._focusables.add(e)}),this.keystrokes.listenTo(this.element)}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,n=this.bindTemplate,o=this._createColorSelector(e),l=se(e),s=new z;return s.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:n.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",n.if("value","ck-hidden",r=>r!="")]}}]}),l.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),l.buttonView.children.add(s),l.buttonView.label=t("Color picker"),l.buttonView.tooltip=!0,l.panelPosition=e.uiLanguageDirection==="rtl"?"se":"sw",l.panelView.children.add(o),l.bind("isEnabled").to(this,"isReadOnly",r=>!r),l.on("change:isOpen",(r,c,a)=>{a&&(o.updateSelectedColors(),o.showColorGridsFragment())}),l}_createInputTextView(){const e=this.locale,t=new zn(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",()=>{const n=t.element.value,o=this.options.colorDefinitions.find(l=>n===l.label);this._stillTyping=!0,this.value=o&&o.color||n}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,n=this.options.defaultColorValue||"",o=t(n?"Restore default":"Remove color"),l=new Un(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:o,colorPickerLabel:t("Color picker"),colorPickerViewConfig:this.options.colorPickerConfig===!1?!1:{...this.options.colorPickerConfig,hideInput:!0}});l.appendUI(),l.on("execute",(r,c)=>{if(c.source==="colorPickerSaveButton"){this.dropdownView.isOpen=!1;return}this.value=c.value||n,this.fire("input"),c.source!=="colorPicker"&&(this.dropdownView.isOpen=!1)});let s=this.value;return l.on("colorPicker:cancel",()=>{this.value=s,this.fire("input"),this.dropdownView.isOpen=!1}),l.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{s=this.value}),l.bind("selectedColor").to(this,"value"),l}_setInputValue(e){if(!this._stillTyping){const t=pt(e),n=this.options.colorDefinitions.find(o=>t===pt(o.color));n?this.inputView.value=n.label:this.inputView.value=e||""}}}function pt(i){return i.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const Xe=i=>i==="";function Je(i){return{none:i("None"),solid:i("Solid"),dotted:i("Dotted"),dashed:i("Dashed"),double:i("Double"),groove:i("Groove"),ridge:i("Ridge"),inset:i("Inset"),outset:i("Outset")}}function nn(i){return i('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function on(i){return i('The value is invalid. Try "10px" or "2em" or simply "2".')}function fe(i){return i=i.trim().toLowerCase(),Xe(i)||Xn(i)}function J(i){return i=i.trim(),Xe(i)||rn(i)||Ft(i)||Jn(i)}function ln(i){return i=i.trim(),Xe(i)||rn(i)||Ft(i)}function sn(i,e){const t=new kt,n=Je(i.t);for(const o in n){const l={type:"button",model:new Et({_borderStyleValue:o,label:n[o],role:"menuitemradio",withText:!0})};o==="none"?l.model.bind("isOn").to(i,"borderStyle",s=>e==="none"?!s:s===o):l.model.bind("isOn").to(i,"borderStyle",s=>s===o),t.add(l)}return t}function De(i){const{view:e,icons:t,toolbar:n,labels:o,propertyName:l,nameToValue:s,defaultValue:r}=i;for(const c in o){const a=new W(e.locale);a.set({role:"radio",isToggleable:!0,label:o[c],icon:t[c],tooltip:o[c]});const u=s?s(c):c;a.bind("isOn").to(e,l,d=>{let m=d;return d===""&&r&&(m=r),u===m}),a.on("execute",()=>{!r&&u&&e[l]===u?e[l]=void 0:e[l]=u}),n.items.add(a)}}const pe=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function Ce(i){return(e,t,n)=>{const o=new _l(e.locale,{colorDefinitions:Al(i.colorConfig),columns:i.columns,defaultColorValue:i.defaultColorValue,colorPickerConfig:i.colorPickerConfig});return o.inputView.set({id:t,ariaDescribedById:n}),o.bind("isReadOnly").to(e,"isEnabled",l=>!l),o.bind("hasError").to(e,"errorText",l=>!!l),o.on("input",()=>{e.errorText=null}),e.bind("isEmpty","isFocused").to(o),o}}function rn(i){const e=parseFloat(i);return!Number.isNaN(e)&&i===String(e)}function Al(i){return i.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))}class vl extends z{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:l,borderRowLabel:s}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:c}=this._createBackgroundFields(),{widthInput:a,operatorLabel:u,heightInput:d,dimensionsLabel:m}=this._createDimensionFields(),{horizontalAlignmentToolbar:h,verticalAlignmentToolbar:g,alignmentLabel:b}=this._createAlignmentFields();this.focusTracker=new ye,this.keystrokes=new Te,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=l,this.backgroundInput=c,this.paddingInput=this._createPaddingField(),this.widthInput=a,this.heightInput=d,this.horizontalAlignmentToolbar=h,this.verticalAlignmentToolbar=g;const{saveButtonView:f,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=p,this._focusables=new ze,this._focusCycler=new Ue({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Vt(e,{label:this.t("Cell properties")})),this.children.add(new x(e,{labelView:s,children:[s,n,l,o],class:"ck-table-form__border-row"})),this.children.add(new x(e,{labelView:r,children:[r,c],class:"ck-table-form__background-row"})),this.children.add(new x(e,{children:[new x(e,{labelView:m,children:[m,a,u,d],class:"ck-table-form__dimensions-row"}),new x(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new x(e,{labelView:b,children:[b,h,g],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new x(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Lt({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},n=Ce({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),o=this.locale,l=this.t,s=l("Style"),r=new D(o);r.text=l("Border");const c=Je(l),a=new P(o,Nt);a.set({label:s,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",m=>c[m||"none"]),a.fieldView.on("execute",m=>{this.borderStyle=m.source._borderStyleValue}),a.bind("isEmpty").to(this,"borderStyle",m=>!m),He(a.fieldView,sn(this,t.style),{role:"menu",ariaLabel:s});const u=new P(o,H);u.set({label:l("Width"),class:"ck-table-form__border-width"}),u.fieldView.bind("value").to(this,"borderWidth"),u.bind("isEnabled").to(this,"borderStyle",le),u.fieldView.on("input",()=>{this.borderWidth=u.fieldView.element.value});const d=new P(o,n);return d.set({label:l("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",le),d.fieldView.on("input",()=>{this.borderColor=d.fieldView.value}),this.on("change:borderStyle",(m,h,g,b)=>{le(g)||(this.borderColor="",this.borderWidth=""),le(b)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:d,borderWidthInput:u}}_createBackgroundFields(){const e=this.locale,t=this.t,n=new D(e);n.text=t("Background");const o=Ce({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),l=new P(e,o);return l.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),l.fieldView.bind("value").to(this,"backgroundColor"),l.fieldView.on("input",()=>{this.backgroundColor=l.fieldView.value}),{backgroundRowLabel:n,backgroundInput:l}}_createDimensionFields(){const e=this.locale,t=this.t,n=new D(e);n.text=t("Dimensions");const o=new P(e,H);o.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",()=>{this.width=o.fieldView.element.value});const l=new z(e);l.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const s=new P(e,H);return s.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),s.fieldView.bind("value").to(this,"height"),s.fieldView.on("input",()=>{this.height=s.fieldView.element.value}),{dimensionsLabel:n,widthInput:o,operatorLabel:l,heightInput:s}}_createPaddingField(){const e=this.locale,t=this.t,n=new P(e,H);return n.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),n.fieldView.bind("value").to(this,"padding"),n.fieldView.on("input",()=>{this.padding=n.fieldView.element.value}),n}_createAlignmentFields(){const e=this.locale,t=this.t,n=new D(e),o={left:Fn,center:Bn,right:Wn,justify:Nn,top:Ln,middle:Vn,bottom:En};n.text=t("Table cell text alignment");const l=new Ie(e),s=e.contentLanguageDirection==="rtl";l.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar")}),De({view:this,icons:o,toolbar:l,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:c=>{if(s){if(c==="left")return"right";if(c==="right")return"left"}return c},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new Ie(e);return r.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar")}),De({view:this,icons:o,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:l,verticalAlignmentToolbar:r,alignmentLabel:n}}_createActionButtons(){const e=this.locale,t=this.t,n=new W(e),o=new W(e),l=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:t("Save"),icon:It,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(l,"errorText",(...s)=>s.every(r=>!r)),o.set({label:t("Cancel"),icon:xt,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,n=t("Align cell text to the left"),o=t("Align cell text to the center"),l=t("Align cell text to the right"),s=t("Justify cell text");return e.uiLanguageDirection==="rtl"?{right:l,center:o,left:n,justify:s}:{left:n,center:o,right:l,justify:s}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function le(i){return i!=="none"}const Oe=[M.defaultPositions.northArrowSouth,M.defaultPositions.northArrowSouthWest,M.defaultPositions.northArrowSouthEast,M.defaultPositions.southArrowNorth,M.defaultPositions.southArrowNorthWest,M.defaultPositions.southArrowNorthEast,M.defaultPositions.viewportStickyNorth];function an(i,e){const t=i.plugins.get("ContextualBalloon"),n=i.editing.view.document.selection;let o;e==="cell"?Ae(n)&&(o=un(i)):be(n)&&(o=cn(i)),o&&t.updatePosition(o)}function cn(i){const e=i.model.document.selection,t=N(e),n=i.editing.mapper.toViewElement(t);return{target:i.editing.view.domConverter.mapViewToDom(n),positions:Oe}}function un(i){const e=i.editing.mapper,t=i.editing.view.domConverter,n=i.model.document.selection;if(n.rangeCount>1)return{target:()=>Sl(n.getRanges(),i),positions:Oe};const o=dn(n.getFirstPosition()),l=e.toViewElement(o);return{target:t.mapViewToDom(l),positions:Oe}}function dn(i){return i.nodeAfter&&i.nodeAfter.is("element","tableCell")?i.nodeAfter:i.findAncestor("tableCell")}function Sl(i,e){const t=e.editing.mapper,n=e.editing.view.domConverter,o=Array.from(i).map(l=>{const s=dn(l.start),r=t.toViewElement(s);return new de(n.mapViewToDom(r))});return de.getBoundingRect(o)}const Rl=500,Ct={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class kl extends A{_defaultContentTableCellProperties;_defaultLayoutTableCellProperties;_balloon;view;_viewWithContentTableDefaults;_viewWithLayoutTableDefaults;_undoStepBatch;_isReady;static get requires(){return[me]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:pe,backgroundColors:pe})}init(){const e=this.editor,t=e.t;this._defaultContentTableCellProperties=Ke(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._defaultLayoutTableCellProperties=_e(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._balloon=e.plugins.get(me),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",n=>{const o=new W(n);o.set({label:t("Cell properties"),icon:Rn,tooltip:!0}),this.listenTo(o,"execute",()=>this._showView());const l=Object.values(Ct).map(s=>e.commands.get(s));return o.bind("isEnabled").toMany(l,"isEnabled",(...s)=>s.some(r=>r)),o})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,n=t.config.get("table.tableCellProperties"),o=he(n.borderColors),l=ge(t.locale,o),s=he(n.backgroundColors),r=ge(t.locale,s),c=n.colorPicker!==!1,a=new vl(t.locale,{borderColors:l,backgroundColors:r,defaultTableCellProperties:e,colorPickerConfig:c?n.colorPicker||{}:!1}),u=t.t;a.render(),this.listenTo(a,"submit",()=>{this._hideView()}),this.listenTo(a,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),a.keystrokes.set("Esc",(h,g)=>{this._hideView(),g()}),Pt({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const d=nn(u),m=on(u);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:d,validator:fe})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:m,validator:ln})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:m,validator:J})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:m,validator:J})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:m,validator:J})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:d,validator:fe})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(Ct).map(([n,o])=>{const l=n,s=this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[l]||"":this._defaultLayoutTableCellProperties[l]||"";return[n,e.get(o).value||s]}).forEach(([n,o])=>{(n==="borderColor"||n==="borderWidth")&&t.value==="none"||this.view.set(n,o)}),this._isReady=!0}_showView(){const e=this.editor,t=be(e.editing.view.document.selection),n=t&&e.editing.mapper.toModelElement(t),o=!n||n.getAttribute("tableType")!=="layout";o&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):!o&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=o?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:un(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor,t=e.editing.view.document;Ae(t.selection)?this._isViewVisible&&an(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,n,o)=>{this._isReady&&this.editor.execute(e,{value:o,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:n,validator:o,errorText:l}=e,s=Dt(()=>{n.errorText=l},Rl);return(r,c,a)=>{s.cancel(),this._isReady&&(o(a)?(this.editor.execute(t,{value:a,batch:this._undoStepBatch}),n.errorText=null):s())}}}class V extends R{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,n){switch(super(e),this.attributeName=t,this._defaultContentTableValue=n,t){case"tableCellType":this._defaultLayoutTableValue="data";break;case"tableCellBorderStyle":this._defaultLayoutTableValue="none";break;case"tableCellHorizontalAlignment":this._defaultLayoutTableValue="left";break;case"tableCellVerticalAlignment":this._defaultLayoutTableValue="middle";break;default:this._defaultLayoutTableValue=void 0}}refresh(){const t=this.editor.model.document.selection,o=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(t),l=N(t);this._defaultValue=!l||l.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!o.length,this.value=this._getSingleValue(o)}execute(e={}){const{value:t,batch:n}=e,o=this.editor.model,s=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(o.document.selection),r=this._getValueToSet(t);o.enqueueChange(n,c=>{r?s.forEach(a=>c.setAttribute(this.attributeName,r,a)):s.forEach(a=>c.removeAttribute(this.attributeName,a)),this.fire("afterExecute",{writer:c,tableCells:s,valueToSet:r})})}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(o=>this._getAttribute(o)===t)?t:void 0}}class Il extends V{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if(e=j(e,"px"),e!==this._defaultValue)return e}}class mn extends A{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[ee]}init(){const e=this.editor,t=Ke(e.config.get("table.tableCellProperties.defaultProperties"));ce(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:t.width}),e.commands.add("tableCellWidth",new Il(e,t.width))}}class xl extends V{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=j(e,"px");if(t!==this._defaultValue)return t}}class Pl extends V{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=j(e,"px");if(t!==this._defaultValue)return t}}class El extends V{constructor(e,t){super(e,"tableCellBackgroundColor",t)}}class Vl extends V{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class Ll extends V{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class Nl extends V{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class Wl extends V{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class Bl extends V{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=j(e,"px");if(t!==this._defaultValue)return t}}class Fl extends V{constructor(e){super(e,"tableCellType","data"),this.on("afterExecute",(t,n)=>{const{writer:o,tableCells:l}=n,s=this.editor.plugins.get(v),r=oo(l);hn(s,o,r.keys())})}refresh(){super.refresh();const e=N(this.editor.model.document.selection);this.isEnabled&&e&&e.getAttribute("tableType")==="layout"&&(this.isEnabled=!1)}_getAttribute(e){return e?.getAttribute(this.attributeName)||"data"}}function hn(i,e,t){let n=!1;for(const o of t){let l=o.getAttribute("headingRows")||0,s=o.getAttribute("headingColumns")||0;const r=s>l;if(r){const a=ke(i,o,"column",s,l);a!==s&&(i.setHeadingColumnsCount(e,o,a,{shallow:!0}),s=a,n=!0)}const c=ke(i,o,"row",l,s);if(c!==l&&(i.setHeadingRowsCount(e,o,c,{shallow:!0}),l=c,n=!0),!r){const a=ke(i,o,"column",s,l);a!==s&&(i.setHeadingColumnsCount(e,o,a,{shallow:!0}),n=!0)}}return n}function ke(i,e,t,n,o){const l=t==="row"?i.getRows(e):i.getColumns(e);let s=n;for(let r=0;r<l;r++){const c=new w(e,{[t]:r});let a=!0,u=!1;for(const{cell:d,row:m,column:h}of c){if(d.getAttribute("tableCellType")!=="header"){a=!1;break}(t==="row"?h:m)>=o&&(u=!0)}if(!a)return Math.min(s,r);u&&(s=Math.max(s,r+1))}return Math.min(s,l)}const wt=/^(top|middle|bottom)$/,Tt=/^(left|center|right|justify)$/;class Dl extends A{static get pluginName(){return"TableCellPropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[ee,mn]}init(){const e=this.editor,t=e.model.schema,n=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const o=Ke(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"});e.data.addStyleProcessorRules(Wt),Ol(e,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),e.commands.add("tableCellBorderStyle",new Nl(e,o.borderStyle)),e.commands.add("tableCellBorderColor",new Wl(e,o.borderColor)),e.commands.add("tableCellBorderWidth",new Bl(e,o.borderWidth)),ce(t,n,{modelAttribute:"tableCellHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:o.height}),e.commands.add("tableCellHeight",new Pl(e,o.height)),e.data.addStyleProcessorRules(Gn),ce(t,n,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:o.padding}),e.commands.add("tableCellPadding",new xl(e,o.padding)),e.data.addStyleProcessorRules(Bt),ce(t,n,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:o.backgroundColor}),e.commands.add("tableCellBackgroundColor",new El(e,o.backgroundColor)),Ml(t,n,o.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new Ll(e,o.horizontalAlignment)),Hl(t,n,o.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new Vl(e,o.verticalAlignment)),e.config.get("experimentalFlags.tableCellTypeSupport")&&(zl(e),e.commands.add("tableCellType",new Fl(e)))}}function Ol(i,e){const{conversion:t}=i,{schema:n}=i.model,o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};n.extend("tableCell",{allowAttributes:Object.values(o)});for(const l of Object.values(o))n.setAttributeProperties(l,{isFormatting:!0});xe(i,"td",o,e),xe(i,"th",o,e),X(t,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),X(t,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),X(t,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}function Ml(i,e,t){i.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),i.setAttributeProperties("tableCellHorizontalAlignment",{isFormatting:!0}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:n=>({key:"style",value:{"text-align":n}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":Tt}},model:{key:"tableCellHorizontalAlignment",value:(n,o,l)=>{const s=E(t,"left",l),r=n.getStyle("text-align");if(r!==s)return r;o.consumable.consume(n,{styles:"text-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:Tt}},model:{key:"tableCellHorizontalAlignment",value:(n,o,l)=>{const s=E(t,"left",l),r=n.getAttribute("align");if(r!==s)return r;o.consumable.consume(n,{attributes:"align"})}}})}function Hl(i,e,t){i.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),i.setAttributeProperties("tableCellVerticalAlignment",{isFormatting:!0}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:n=>({key:"style",value:{"vertical-align":n}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":wt}},model:{key:"tableCellVerticalAlignment",value:(n,o,l)=>{const s=E(t,"middle",l),r=n.getStyle("vertical-align");if(r!==s)return r;o.consumable.consume(n,{styles:"vertical-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:wt}},model:{key:"tableCellVerticalAlignment",value:(n,o,l)=>{const s=E(t,"middle",l),r=n.getAttribute("valign");if(r!==s)return r;o.consumable.consume(n,{attributes:"valign"})}}})}function zl(i){const{model:e,conversion:t,editing:n}=i,{schema:o}=e,l=i.plugins.get(v);o.extend("tableCell",{allowAttributes:["tableCellType"]}),o.setAttributeProperties("tableCellType",{isFormatting:!0}),o.addAttributeCheck(s=>{if(Array.from(s).reverse().find(c=>c.name==="table")?.getAttribute("tableType")==="layout")return!1},"tableCellType"),t.for("upcast").add(s=>{s.on("element:th",(r,c,a)=>{const{writer:u}=a,{modelRange:d}=c,m=d?.start.nodeAfter;m?.is("element","tableCell")&&u.setAttribute("tableCellType","header",m)}),s.on("element:table",(r,c,a)=>{const{writer:u}=a,{modelRange:d}=c,m=d?.start.nodeAfter;if(m?.is("element","table")&&m.getAttribute("tableType")==="layout"){for(const{cell:h}of new w(m))if(h.getAttribute("tableCellType")==="header"){u.setAttribute("tableType","content",m);break}}},{priority:Tn.low-1})}),e.document.registerPostFixer(s=>{const r=e.document.differ.getChanges(),c=new Set;for(const a of r){if(a.type==="attribute"&&(a.attributeKey==="headingRows"||a.attributeKey==="headingColumns")){const u=a.range.start.nodeAfter;u?.is("element","table")&&u.root.rootName!=="$graveyard"&&c.add(u)}if(a.type==="attribute"&&a.attributeKey==="tableCellType"){const u=a.range.start.nodeAfter;if(u?.is("element","tableCell")&&u.root.rootName!=="$graveyard"){const d=u.findAncestor("table");d&&c.add(d)}}if(a.type==="insert"&&a.position.nodeAfter){for(const{item:u}of e.createRangeOn(a.position.nodeAfter))if(u.is("element","tableCell")&&u.getAttribute("tableCellType")&&u.root.rootName!=="$graveyard"){const d=u.findAncestor("table");d&&c.add(d)}}}return hn(l,s,c)}),e.document.on("change:data",()=>{const{differ:s}=e.document,r=new Set;for(const c of s.getChanges())if(c.type==="attribute"&&c.attributeKey==="tableCellType"){const a=c.range.start.nodeAfter;a.is("element","tableCell")&&r.add(a)}for(const c of r){const a=n.mapper.toViewElement(c),d=c.getAttribute("tableCellType")==="header"?"th":"td";a?.name!==d&&n.reconvertItem(c)}})}class Li extends A{static get pluginName(){return"TableCellProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[Dl,kl]}}class Ul extends R{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:n}=this.editor;let{table:o=t.document.selection.getSelectedElement(),columnWidths:l,tableWidth:s}=e;l&&(l=Array.isArray(l)?l:l.split(",")),t.change(r=>{s?r.setAttribute("tableWidth",s,o):r.removeAttribute("tableWidth",o);const c=n.get("TableColumnResizeEditing").getColumnGroupElement(o);if(!l&&!c)return;if(!l)return r.remove(c);const a=qe(l);if(c)Array.from(c.getChildren()).forEach((u,d)=>r.setAttribute("columnWidth",a[d],u));else{const u=r.createElement("tableColumnGroup");a.forEach(d=>r.appendElement("tableColumn",{columnWidth:d},u)),r.append(u,o)}})}}function $l(i){return e=>e.on("element:colgroup",(t,n,o)=>{const l=n.modelCursor.findAncestor("table"),s=Y(l);if(!s)return;const r=Q(s),c=i.getColumns(l);let a=Ho(s,o.writer);a=Array.from({length:c},(u,d)=>a[d]||"auto"),(a.length!=r.length||a.includes("auto"))&&Jt(r,s,qe(a),o.writer)},{priority:"low"})}function jl(){return i=>i.on("insert:table",(e,t,n)=>{const o=n.writer,l=t.item,s=n.mapper.toViewElement(l),r=s.is("element","table")?s:Array.from(s.getChildren()).find(a=>a.is("element","table"));Y(l)?o.addClass("ck-table-resized",r):o.removeClass("ck-table-resized",r)},{priority:"low"})}function Gl(){return i=>{i.on("element:table",(e,t,n)=>{n.consumable.consume(t.viewItem,{classes:"ck-table-resized"})})}}const yt=yn("px");class Kl extends A{_isResizingActive;_resizingData;_domEmitter;_tableUtilsPlugin;_initialMouseEventData=null;static get requires(){return[ee,v]}static get pluginName(){return"TableColumnResizeEditing"}static get licenseFeatureCode(){return"TCR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(wn()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",(t,n,o)=>{const l=o?"removeClass":"addClass";e.editing.view.change(s=>{for(const r of e.editing.view.document.roots)s[l]("ck-column-resize_disabled",e.editing.view.document.getRoot(r.rootName))})})}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:l=>l.is("element","tableColumnGroup"),positionOffset:0});const o=new Ul(e);e.commands.add("resizeTableWidth",o),e.commands.add("resizeColumnWidths",o),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",o,"isEnabled",(l,s,r)=>!l&&s&&r)}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return Y(e)}getTableColumnElements(e){return Q(e)}getTableColumnsWidths(e){return Mo(e)}_extendSchema(){const e=this.editor.model.schema;e.extend("table",{allowAttributes:["tableWidth"]}),e.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),e.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0}),e.setAttributeProperties("columnWidth",{isFormatting:!0})}_registerPostFixer(){const t=this.editor.model;t.document.registerPostFixer(l=>{let s=!1;for(const r of Lo(t)){const c=this.getColumnGroupElement(r),a=this.getTableColumnElements(c),u=this.getTableColumnsWidths(c);let d=qe(u);d=n(d,r,this),!tt(u,d)&&(Jt(a,c,d,l),s=!0)}return s});function n(l,s,r){const c=r._tableUtilsPlugin.getColumns(s);if(c-l.length===0)return l;const u=l.map(m=>Number(m.replace("%",""))),d=o(r.editor.model.document.differ,s);for(const m of d){const h=c-u.length;if(h===0)continue;const g=h>0,b=r._tableUtilsPlugin.getCellLocation(m).column;if(g){const f=No(s,r.editor),p=Fo(h,f);u.splice(b,0,...p)}else{const f=u.splice(b,Math.abs(h));u[b]+=Z(f)}}return u.map(m=>m+"%")}function o(l,s){const r=new Set;for(const c of l.getChanges())if(c.type=="insert"&&c.position.nodeAfter&&c.position.nodeAfter.name=="tableCell"&&c.position.nodeAfter.getAncestors().includes(s))r.add(c.position.nodeAfter);else if(c.type=="remove"){const a=c.position.nodeBefore||c.position.nodeAfter;a.name=="tableCell"&&a.getAncestors().includes(s)&&r.add(a)}return r}}_registerConverters(){const t=this.editor.conversion;t.for("upcast").attributeToAttribute({view:{name:/^(figure|table)$/,styles:{width:/[\s\S]+/}},model:{key:"tableWidth",value:n=>{if(!n.parent.is("element","figure"))return n.getStyle("width")}}}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:n=>({name:"figure",key:"style",value:{width:n}})}),t.elementToElement({model:"tableColumnGroup",view:"colgroup"}),t.elementToElement({model:"tableColumn",view:"col"}),t.for("downcast").add(jl()),t.for("upcast").add(Gl()),t.for("upcast").add($l(this._tableUtilsPlugin)),t.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:n=>{const o=n.getStyle("width");return!o||!o.endsWith("%")&&!o.endsWith("pt")?"auto":o}}}),t.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),t.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:n=>({key:"style",value:{width:n}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(Qt),e.document.on("mouseover",this._onMouseOverHandler.bind(this),{priority:"high"}),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),e.document.on("mouseout",this._onMouseOutHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(ue.window.document,"mousemove",Zn(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(ue.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_recalculateResizerElement(e){const t=this.editor,n=t.editing.view.domConverter,o=n.mapViewToDom(e.findAncestor("table")),l=n.mapViewToDom(e.findAncestor(u=>["td","th"].includes(u.name))),s=new de(o),r=new de(l),c=yt(Number((s.top-r.top).toFixed(4))),a=yt(Number((r.bottom-s.bottom).toFixed(4)));t.editing.view.change(u=>{u.setStyle("top",c,e),u.setStyle("bottom",a,e)})}_resetResizerStyles(e){this.editor.editing.view.change(t=>{t.removeStyle("top",e),t.removeStyle("bottom",e)})}_onMouseOverHandler(e,t){const n=t.target;n.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&this._recalculateResizerElement(n)}_onMouseOutHandler(e,t){const n=t.target;n.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&(this._isResizingActive||this._resetResizerStyles(n))}_onMouseDownHandler(e,t){const n=t.target;if(!n.hasClass("ck-table-column-resizer")||!this._isResizingAllowed)return;const o=this.editor,l=o.editing.mapper.toModelElement(n.findAncestor("figure"));o.model.canEditAt(l)&&(t.preventDefault(),e.stop(),this._initialMouseEventData=t)}_startResizingAfterThreshold(){const e=this._initialMouseEventData,{target:t}=e,n=this.editor.editing.mapper.toModelElement(t.findAncestor("figure")),o=t.findAncestor("table"),l=s(n,this._tableUtilsPlugin,this.editor);Array.from(o.getChildren()).find(a=>a.is("element","colgroup"))||this.editor.editing.view.change(a=>{r(a,l,o)}),this._isResizingActive=!0,this._resizingData=this._getResizingData(e,l),this.editor.editing.view.change(a=>c(a,o,this._resizingData));function s(a,u,d){const m=Array(u.getColumns(a)),h=new w(a);for(const g of h){const b=d.editing.mapper.toViewElement(g.cell),f=d.editing.view.domConverter.mapViewToDom(b),p=Oo(f);(!m[g.column]||p<m[g.column])&&(m[g.column]=I(p))}return m}function r(a,u,d){const m=a.createContainerElement("colgroup");for(let h=0;h<u.length;h++){const g=a.createEmptyElement("col"),b=`${I(u[h]/Z(u)*100)}%`;a.setStyle("width",b,g),a.insert(a.createPositionAt(m,"end"),g)}a.insert(a.createPositionAt(d,0),m)}function c(a,u,d){const m=d.widths.viewFigureWidth/d.widths.viewFigureParentWidth;a.addClass("ck-table-resized",u),a.addClass("ck-table-column-resizer__active",d.elements.viewResizer),a.setStyle("width",`${I(m*100)}%`,u.findAncestor("figure"))}}_onMouseMoveHandler(e,t){if(this._initialMouseEventData){const T=this._initialMouseEventData.domEvent;if(Math.abs(t.clientX-T.clientX)>=Vo)this._startResizingAfterThreshold(),this._initialMouseEventData=null;else return}if(!this._isResizingActive)return;if(!this._isResizingAllowed){this._onMouseUpHandler();return}const{columnPosition:n,flags:{isRightEdge:o,isTableCentered:l,isLtrContent:s},elements:{viewFigure:r,viewLeftColumn:c,viewRightColumn:a,viewResizer:u},widths:{viewFigureParentWidth:d,tableWidth:m,leftColumnWidth:h,rightColumnWidth:g}}=this._resizingData,b=-h+Le,f=o?d-m:g-Le,p=(s?1:-1)*(o&&l?2:1),C=Bo((t.clientX-n)*p,Math.min(b,0),Math.max(f,0));C!==0&&(this.editor.editing.view.change(T=>{const y=I((h+C)*100/m);if(T.setStyle("width",`${y}%`,c),o){const k=I((m+C)*100/d);T.setStyle("width",`${k}%`,r)}else{const k=I((g-C)*100/m);T.setStyle("width",`${k}%`,a)}}),this._recalculateResizerElement(u))}_onMouseUpHandler(){if(this._initialMouseEventData=null,!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:n,viewColgroup:o}=this._resizingData.elements,l=this.editor,s=l.editing.view,r=this.getColumnGroupElement(t),c=Array.from(o.getChildren()).filter(f=>f.is("view:element")),a=r?this.getTableColumnsWidths(r):null,u=c.map(f=>f.getStyle("width")),d=!tt(a,u),m=t.getAttribute("tableWidth"),h=n.getStyle("width"),g=m!==h;(d||g)&&(this._isResizingAllowed?l.execute("resizeTableWidth",{table:t,tableWidth:`${I(h)}%`,columnWidths:u}):s.change(f=>{if(a)for(const p of c)f.setStyle("width",a.shift(),p);else f.remove(o);g&&(m?f.setStyle("width",m,n):f.removeStyle("width",n)),!a&&!m&&f.removeClass("ck-table-resized",[...n.getChildren()].find(p=>p.name==="table"))})),s.change(f=>{f.removeClass("ck-table-column-resizer__active",e)}),s.domConverter.mapViewToDom(e).matches(":hover")||this._resetResizerStyles(e),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const n=this.editor,o=e.domEvent.clientX,l=e.target,s=l.findAncestor("td")||l.findAncestor("th"),r=n.editing.mapper.toModelElement(s),c=r.findAncestor("table"),a=Wo(r,this._tableUtilsPlugin).rightEdge,u=this._tableUtilsPlugin.getColumns(c)-1;let d=c.getAttribute("tableAlignment");c.getAttribute("tableType")!=="layout"&&(d||=n.config.get("table.tableProperties.defaultProperties.alignment"),d||="center");const m=a===u,h=n.locale.contentLanguageDirection!=="rtl",g=d==="center",b=s.findAncestor("table"),f=b.findAncestor("figure"),p=[...b.getChildren()].find(gn=>gn.is("element","colgroup")),C=p.getChild(a),T=m?void 0:p.getChild(a+1),y=Ne(n.editing.view.domConverter.mapViewToDom(f.parent)),k=Ne(n.editing.view.domConverter.mapViewToDom(f)),B=Xt(c,n),F=t[a],ve=m?void 0:t[a+1];return{columnPosition:o,flags:{isRightEdge:m,isTableCentered:g,isLtrContent:h},elements:{viewResizer:l,modelTable:c,viewFigure:f,viewColgroup:p,viewLeftColumn:C,viewRightColumn:T},widths:{viewFigureParentWidth:y,viewFigureWidth:k,tableWidth:B,leftColumnWidth:F,rightColumnWidth:ve}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add(e=>{e.on("insert:tableCell",(t,n,o)=>{const l=n.item,s=o.mapper.toViewElement(l),r=o.writer;r.insert(r.createPositionAt(s,"end"),r.createUIElement("div",{class:"ck-table-column-resizer"}))},{priority:"lowest"})})}}class Ni extends A{static get requires(){return[Kl,mn]}static get pluginName(){return"TableColumnResize"}static get isOfficialPlugin(){return!0}}class G extends R{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,n){super(e),this.attributeName=t,this._defaultContentTableValue=n,this._defaultLayoutTableValue=t==="tableBorderStyle"?"none":void 0}refresh(){const t=this.editor.model.document.selection,n=N(t);this._defaultValue=!n||n.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!n,this.value=this._getValue(n)}execute(e={}){const t=this.editor.model,n=t.document.selection,{value:o,batch:l}=e,s=N(n),r=this._getValueToSet(o);t.enqueueChange(l,c=>{r?c.setAttribute(this.attributeName,r,s):c.removeAttribute(this.attributeName,s)})}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}}class ql extends G{constructor(e,t){super(e,"tableBackgroundColor",t)}}class Xl extends G{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class Jl extends G{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class Zl extends G{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=$(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=j(e,"px");if(t!==this._defaultValue)return t}}class Yl extends G{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if(e=j(e,"px"),e!==this._defaultValue)return e}}class Ql extends G{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if(e=j(e,"px"),e!==this._defaultValue)return e}}class ei extends G{constructor(e,t){super(e,"tableAlignment",t)}}class ti extends A{static get pluginName(){return"TablePropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[ee]}init(){const e=this.editor,t=e.model.schema,n=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const o=Ge(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),l=e.config.get("table.tableProperties.alignment.useInlineStyles")!==!1;if(e.data.addStyleProcessorRules(Kn),e.data.addStyleProcessorRules(Wt),oi(e,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),e.commands.add("tableBorderColor",new Xl(e,o.borderColor)),e.commands.add("tableBorderStyle",new Jl(e,o.borderStyle)),e.commands.add("tableBorderWidth",new Zl(e,o.borderWidth)),e.config.get("experimentalFlags.useExtendedTableBlockAlignment")?li(t,n,o.alignment,l):ii(t,n,o.alignment),e.commands.add("tableAlignment",new ei(e,o.alignment)),At(t,n,{modelAttribute:"tableWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:o.width}),e.commands.add("tableWidth",new Yl(e,o.width)),At(t,n,{modelAttribute:"tableHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:o.height}),e.commands.add("tableHeight",new Ql(e,o.height)),e.data.addStyleProcessorRules(Bt),ai(t,n,{modelAttribute:"tableBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:o.backgroundColor}),e.commands.add("tableBackgroundColor",new ql(e,o.backgroundColor)),e.config.get("experimentalFlags.useExtendedTableBlockAlignment")){const s=e.editing.view.document;this.listenTo(s,"clipboardOutput",(r,c)=>{e.editing.view.change(a=>{for(const{item:u}of a.createRangeIn(c.content))ni(u,a);c.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(c.content))})},{priority:"lowest"})}}}function ni(i,e){if(!i.is("element","table"))return;const t=i.getAttribute("align"),n=i.getStyle("float"),o=i.getStyle("margin-left"),l=i.getStyle("margin-right");if(t&&t==="center"||n&&n==="right"&&t&&t==="right"){_t(e,t,i);return}n===void 0&&o==="auto"&&l==="0"&&_t(e,"right",i)}function _t(i,e,t){const n=i.createPositionBefore(t),o=i.createContainerElement("div",{align:e},t);i.insert(n,o)}function oi(i,e){const{conversion:t}=i,{schema:n}=i.model,o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};n.extend("table",{allowAttributes:Object.values(o)});for(const l of Object.values(o))n.setAttributeProperties(l,{isFormatting:!0});xe(i,"table",o,e),re(t,{modelAttribute:o.color,styleName:"border-color"}),re(t,{modelAttribute:o.style,styleName:"border-style"}),re(t,{modelAttribute:o.width,styleName:"border-width"})}function li(i,e,t,n){i.extend("table",{allowAttributes:["tableAlignment"]}),i.setAttributeProperties("tableAlignment",{isFormatting:!0}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right","blockLeft","blockRight"]},view:{left:n?{key:"style",value:{float:"left","margin-right":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:S.left.className},right:n?{key:"style",value:{float:"right","margin-left":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:S.right.className},center:n?{key:"style",value:{"margin-left":"auto","margin-right":"auto"}}:{key:"class",value:S.center.className},blockLeft:n?{key:"style",value:{"margin-left":"0","margin-right":"auto"}}:{key:"class",value:S.blockLeft.className},blockRight:n?{key:"style",value:{"margin-left":"auto","margin-right":"0"}}:{key:"class",value:S.blockRight.className}},converterPriority:"high"}),to.forEach(o=>{e.for("upcast").attributeToAttribute({view:o.view,model:{key:"tableAlignment",value:(l,s,r)=>{if(ci(l))return;const c=E(t,"",r),a=o.getAlign(l),u=o.getConsumables(l);if(s.consumable.consume(l,u),a!==c)return a}}})}),e.for("upcast").add(si(t))}function ii(i,e,t){const n=/^(left|center|right)$/,o=/^(left|none|right)$/;i.extend("table",{allowAttributes:["tableAlignment"]}),i.setAttributeProperties("tableAlignment",{isFormatting:!0}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}},center:(l,s,r)=>({key:"style",value:r.item.getAttribute("tableType")!=="layout"?{float:"none"}:{"margin-left":"auto","margin-right":"auto"}})},converterPriority:"high"}),e.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:o}},model:{key:"tableAlignment",value:(l,s,r)=>{if(l.name=="figure"&&!l.hasClass("table"))return;const c=E(t,"",r);let a=l.getStyle("float");if(a==="none"&&(a="center"),a!==c)return a;s.consumable.consume(l,{styles:"float"})}}}).attributeToAttribute({view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},model:{key:"tableAlignment",value:(l,s,r)=>{if(l.name=="figure"&&!l.hasClass("table"))return;const c=E(t,"",r),a="center";if(a!==c)return a;s.consumable.consume(l,{styles:["margin-left","margin-right"]})}}}).attributeToAttribute({view:{name:"table",attributes:{align:n}},model:{key:"tableAlignment",value:(l,s,r)=>{const c=E(t,"",r),a=l.getAttribute("align");if(a!==c)return a;s.consumable.consume(l,{attributes:"align"})}}})}function si(i){return e=>{e.on("element:div",(t,n,o)=>{if(!o.consumable.test(n.viewItem,{name:!0,attributes:"align"}))return;const l=Kt(n.viewItem);if(!l||!o.consumable.test(l,{name:!0}))return;o.consumable.consume(n.viewItem,{name:!0,attributes:"align"});const s=o.convertItem(l,n.modelCursor),r=we(s.modelRange.getItems());if(!r||!r.is("element","table")){o.consumable.revert(n.viewItem,{name:!0,attributes:"align"}),s.modelRange&&!s.modelRange.isCollapsed&&(n.modelRange=s.modelRange,n.modelCursor=s.modelCursor);return}const c=n.viewItem.getAttribute("align"),a=l.getAttribute("align"),u=E(i,"",n),d=ri(c,a,u);d&&o.writer.setAttribute("tableAlignment",d,r),o.convertChildren(n.viewItem,o.writer.createPositionAt(r,"end")),o.updateConversionResult(r,n)})}}function ri(i,e,t){if(i)switch(i){case"right":return e==="right"?"right":e==="left"?"left":"blockRight";case"center":return"center";case"left":return e===void 0?"blockLeft":"left";default:return t}}function ai(i,e,t){const{modelAttribute:n}=t;i.extend("table",{allowAttributes:[n]}),i.setAttributeProperties(n,{isFormatting:!0}),$e(e,{viewElement:"table",...t}),re(e,t)}function At(i,e,t){const{modelAttribute:n}=t;i.extend("table",{allowAttributes:[n]}),i.setAttributeProperties(n,{isFormatting:!0}),$e(e,{viewElement:/^(table|figure)$/,shouldUpcast:o=>!(o.name=="table"&&o.parent.name=="figure"||o.name=="figure"&&!o.hasClass("table")),...t}),X(e,{modelElement:"table",...t})}function ci(i){return i.name=="figure"&&!i.hasClass("table")}class ui extends z{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:l,borderRowLabel:s}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:c}=this._createBackgroundFields(),{widthInput:a,operatorLabel:u,heightInput:d,dimensionsLabel:m}=this._createDimensionFields(),{alignmentToolbar:h,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new ye,this.keystrokes=new Te,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=l,this.backgroundInput=c,this.widthInput=a,this.heightInput=d,this.alignmentToolbar=h;const{saveButtonView:b,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=b,this.cancelButtonView=f,this._focusables=new ze,this._focusCycler=new Ue({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Vt(e,{label:this.t("Table properties")})),this.children.add(new x(e,{labelView:s,children:[s,n,l,o],class:"ck-table-form__border-row"})),this.children.add(new x(e,{labelView:r,children:[r,c],class:"ck-table-form__background-row"})),this.children.add(new x(e,{children:[new x(e,{labelView:m,children:[m,a,u,d],class:"ck-table-form__dimensions-row"}),new x(e,{labelView:g,children:[g,h],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new x(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Lt({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},n=Ce({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),o=this.locale,l=this.t,s=l("Style"),r=new D(o);r.text=l("Border");const c=Je(l),a=new P(o,Nt);a.set({label:s,class:"ck-table-form__border-style"}),a.fieldView.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),a.fieldView.buttonView.bind("label").to(this,"borderStyle",m=>c[m||"none"]),a.fieldView.on("execute",m=>{this.borderStyle=m.source._borderStyleValue}),a.bind("isEmpty").to(this,"borderStyle",m=>!m),He(a.fieldView,sn(this,t.style),{role:"menu",ariaLabel:s});const u=new P(o,H);u.set({label:l("Width"),class:"ck-table-form__border-width"}),u.fieldView.bind("value").to(this,"borderWidth"),u.bind("isEnabled").to(this,"borderStyle",ie),u.fieldView.on("input",()=>{this.borderWidth=u.fieldView.element.value});const d=new P(o,n);return d.set({label:l("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",ie),d.fieldView.on("input",()=>{this.borderColor=d.fieldView.value}),this.on("change:borderStyle",(m,h,g,b)=>{ie(g)||(this.borderColor="",this.borderWidth=""),ie(b)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:a,borderColorInput:d,borderWidthInput:u}}_createBackgroundFields(){const e=this.locale,t=this.t,n=new D(e);n.text=t("Background");const o=Ce({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),l=new P(e,o);return l.set({label:t("Color"),class:"ck-table-properties-form__background"}),l.fieldView.bind("value").to(this,"backgroundColor"),l.fieldView.on("input",()=>{this.backgroundColor=l.fieldView.value}),{backgroundRowLabel:n,backgroundInput:l}}_createDimensionFields(){const e=this.locale,t=this.t,n=new D(e);n.text=t("Dimensions");const o=new P(e,H);o.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",()=>{this.width=o.fieldView.element.value});const l=new z(e);l.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const s=new P(e,H);return s.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),s.fieldView.bind("value").to(this,"height"),s.fieldView.on("input",()=>{this.height=s.fieldView.element.value}),{dimensionsLabel:n,widthInput:o,operatorLabel:l,heightInput:s}}_createAlignmentFields(){const e=this.locale,t=this.t,n=new D(e);n.text=t("Alignment");const o=new Ie(e);return o.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),De({view:this,icons:{left:Pn,center:xn,right:In},toolbar:o,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:n,alignmentToolbar:o}}_createActionButtons(){const e=this.locale,t=this.t,n=new W(e),o=new W(e),l=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:t("Save"),icon:It,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(l,"errorText",(...s)=>s.every(r=>!r)),o.set({label:t("Cancel"),icon:xt,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _alignmentLabels(){const e=this.locale,t=this.t,n=t("Align table to the left"),o=t("Center table"),l=t("Align table to the right");return e.uiLanguageDirection==="rtl"?{right:l,center:o,left:n}:{left:n,center:o,right:l}}}function ie(i){return i!=="none"}const di=500,vt={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class mi extends A{_defaultContentTableProperties;_defaultLayoutTableProperties;_balloon;view=null;_viewWithContentTableDefaults=null;_viewWithLayoutTableDefaults=null;_undoStepBatch;_isReady;static get requires(){return[me]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:pe,backgroundColors:pe})}init(){const e=this.editor;this._defaultContentTableProperties=Ge(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=_e(),this._balloon=e.plugins.get(me),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){const e=this.editor,t=e.t,n=new W(e.locale);n.set({label:t("Table properties"),icon:kn,tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const o=Object.values(vt).map(l=>e.commands.get(l));return n.bind("isEnabled").toMany(o,"isEnabled",(...l)=>l.some(s=>s)),n}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,n=t.config.get("table.tableProperties"),o=he(n.borderColors),l=ge(t.locale,o),s=he(n.backgroundColors),r=ge(t.locale,s),c=n.colorPicker!==!1,a=new ui(t.locale,{borderColors:l,backgroundColors:r,defaultTableProperties:e,colorPickerConfig:c?n.colorPicker||{}:!1}),u=t.t;a.render(),this.listenTo(a,"submit",()=>{this._hideView()}),this.listenTo(a,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),a.keystrokes.set("Esc",(h,g)=>{this._hideView(),g()}),Pt({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const d=nn(u),m=on(u);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableBorderColor",errorText:d,validator:fe})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableBorderWidth",errorText:m,validator:ln})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableBackgroundColor",errorText:d,validator:fe})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableWidth",errorText:m,validator:J})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableHeight",errorText:m,validator:J})),a.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(vt).map(([n,o])=>{const l=n,s=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[l]||"":this._defaultLayoutTableProperties[l]||"";return[l,e.get(o).value||s]}).forEach(([n,o])=>{(n==="borderColor"||n==="borderWidth")&&t.value==="none"||this.view.set(n,o)}),this._isReady=!0}_showView(){const e=this.editor,t=be(e.editing.view.document.selection),n=t&&e.editing.mapper.toModelElement(t),o=!n||n.getAttribute("tableType")!=="layout";o&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):!o&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=o?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:cn(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor,t=e.editing.view.document;be(t.selection)?this._isViewVisible&&an(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,n,o)=>{this._isReady&&this.editor.execute(e,{value:o,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:n,validator:o,errorText:l}=e,s=Dt(()=>{n.errorText=l},di);return(r,c,a)=>{s.cancel(),this._isReady&&(o(a)?(this.editor.execute(t,{value:a,batch:this._undoStepBatch}),n.errorText=null):s())}}}class Wi extends A{static get pluginName(){return"TableProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[ti,mi]}}function hi(i){i.document.registerPostFixer(e=>gi(e,i))}function gi(i,e){const t=e.document.differ.getChanges();let n=!1;for(const o of t){if(o.type!="insert")continue;const l=o.position.parent;if(l.is("element","table")||o.name=="table"){const s=o.name=="table"?o.position.nodeAfter:l,r=Array.from(s.getChildren()).filter(a=>a.is("element","caption")),c=r.shift();if(!c)continue;for(const a of r)i.move(i.createRangeIn(a),c,"end"),i.remove(a);c.nextSibling&&(i.move(i.createRangeOn(c),s,"end"),n=!0),n=!!r.length||n}}return n}function St(i){return!!i&&i.is("element","table")}function Me(i){for(const e of i.getChildren())if(e.is("element","caption"))return e;return null}function bi(i){const e=N(i);return e?Me(e):null}function fi(i){const e=i.parent;return i.name=="figcaption"&&e&&e.is("element","figure")&&e.hasClass("table")?{name:!0}:i.name=="caption"&&e&&e.is("element","table")?{name:!0}:null}class pi extends R{refresh(){const e=this.editor,t=N(e.model.document.selection);this.isEnabled=!!t&&e.model.schema.checkChild(t,"caption"),this.isEnabled?this.value=!!Me(t):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change(t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)})}_showTableCaption(e,t){const n=this.editor.model,o=N(n.document.selection),r=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(o)||e.createElement("caption");n.insertContent(r,o,"end"),t&&e.setSelection(r,"in")}_hideTableCaption(e){const t=this.editor.model,n=N(t.document.selection),o=this.editor.plugins.get("TableCaptionEditing"),l=Me(n);o._saveCaption(n,l),t.deleteContent(e.createSelection(l,"on"))}}class Ci extends A{_savedCaptionsMap=new WeakMap;static get pluginName(){return"TableCaptionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,n=e.editing.view,o=e.t,l=e.config.get("table.tableCaption.useCaptionElement");t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new pi(this.editor)),l&&e.plugins.get("TableEditing").registerAdditionalSlot({filter:r=>r.is("element","caption"),positionOffset:"end"}),e.conversion.for("upcast").elementToElement({view:fi,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(s,{writer:r})=>St(s.parent)?r.createContainerElement(l?"caption":"figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(s,{writer:r})=>{if(!St(s.parent))return null;const c=r.createEditableElement(l?"caption":"figcaption");return r.setCustomProperty("tableCaption",!0,c),c.placeholder=o("Enter table caption"),$n({view:n,element:c,keepOnFocus:!0}),Rt(c,r)}}),hi(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?jn.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class wi extends A{static get pluginName(){return"TableCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,n=e.t;e.ui.componentFactory.add("toggleTableCaption",o=>{const l=e.commands.get("toggleTableCaption"),s=new W(o);return s.set({icon:Sn,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(l,"value","isEnabled"),s.bind("label").to(l,"value",r=>n(r?"Toggle caption off":"Toggle caption on")),this.listenTo(s,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),l.value){const r=bi(e.model.document.selection),c=e.editing.mapper.toViewElement(r);if(!c)return;t.scrollToTheSelection(),t.change(a=>{a.addClass("table__caption_highlighted",c)})}e.editing.view.focus()}),s})}}class Bi extends A{static get pluginName(){return"TableCaption"}static get isOfficialPlugin(){return!0}static get requires(){return[Ci,wi]}}export{rt as InsertColumnCommand,st as InsertRowCommand,Co as InsertTableCommand,ne as MergeCellCommand,qo as MergeCellsCommand,So as RemoveColumnCommand,Ao as RemoveRowCommand,Yo as SelectColumnCommand,Zo as SelectRowCommand,xo as SetHeaderColumnCommand,Io as SetHeaderRowCommand,at as SplitCellCommand,Ei as Table,ei as TableAlignmentCommand,ql as TableBackgroundColorCommand,Xl as TableBorderColorCommand,Jl as TableBorderStyleCommand,Zl as TableBorderWidthCommand,Bi as TableCaption,Ci as TableCaptionEditing,wi as TableCaptionUI,El as TableCellBackgroundColorCommand,Wl as TableCellBorderColorCommand,Nl as TableCellBorderStyleCommand,Bl as TableCellBorderWidthCommand,Pl as TableCellHeightCommand,Ll as TableCellHorizontalAlignmentCommand,xl as TableCellPaddingCommand,Li as TableCellProperties,Dl as TableCellPropertiesEditing,kl as TableCellPropertiesUI,vl as TableCellPropertiesView,V as TableCellPropertyCommand,Fl as TableCellTypeCommand,Vl as TableCellVerticalAlignmentCommand,Il as TableCellWidthCommand,mn as TableCellWidthEditing,bl as TableClipboard,Ni as TableColumnResize,Kl as TableColumnResizeEditing,ee as TableEditing,Ql as TableHeightCommand,Tl as TableKeyboard,yl as TableMouse,Wi as TableProperties,ti as TablePropertiesEditing,mi as TablePropertiesUI,ui as TablePropertiesView,G as TablePropertyCommand,O as TableSelection,Vi as TableToolbar,hl as TableUI,v as TableUtils,w as TableWalker,Yl as TableWidthCommand,Ul as TableWidthsCommand,pi as ToggleTableCaptionCommand,bt as _InsertTableView,Po as _TABLE_COLUMN_MIN_WIDTH_AS_PERCENTAGE,Le as _TABLE_COLUMN_MIN_WIDTH_IN_PIXELS,Vo as _TABLE_COLUMN_RESIZE_DISTANCE_THRESHOLD,Eo as _TABLE_COLUMN_WIDTH_PRECISION,pe as _TABLE_DEFAULT_COLORS,_l as _TableColorInputView,Qt as _TableMouseEventsObserver,j as _addDefaultUnitToNumericValue,Gt as _adjustLastTableColumnIndex,jt as _adjustLastTableRowIndex,Bo as _clamp,fe as _colorTableFieldValidator,it as _convertParagraphInTableCell,U as _createEmptyTableCell,Fo as _createFilledArray,Ot as _cropTableToDimensions,ot as _downcastTable,re as _downcastTableAttribute,X as _downcastTableAttributeToStyle,lt as _downcastTableCell,jl as _downcastTableResizedClass,uo as _downcastTableRow,ce as _enableTableCellProperty,nt as _ensureParagraphInTableCell,De as _fillTableOrCellToolbar,un as _getBalloonTableCellPositionData,cn as _getBalloonTablePositionData,Je as _getBorderTableStyleLabels,Lo as _getChangedResizedTables,E as _getDefaultTableValueAdjusted,Oo as _getDomTableCellOuterWidth,Ne as _getElementWidthInPixels,zt as _getHorizontallyOverlappingTableCells,Ce as _getLabeledTableColorInputCreator,nn as _getLocalizedTableColorErrorText,on as _getLocalizedTableLengthErrorText,_e as _getNormalizedDefaultTableBaseProperties,Ke as _getNormalizedDefaultTableCellProperties,Ge as _getNormalizedDefaultTableProperties,en as _getSelectedTableWidget,N as _getSelectionAffectedTable,be as _getSelectionAffectedTableWidget,$ as _getTableBorderBoxSingleValue,Me as _getTableCaptionFromModelElement,bi as _getTableCaptionFromModelSelection,Wo as _getTableColumnEdgesIndexes,Q as _getTableColumnElements,Y as _getTableColumnGroupElement,No as _getTableColumnMinWidthAsPercentage,Mo as _getTableColumnsWidths,sn as _getTableOrCellBorderStyleDefinitions,Ae as _getTableWidgetAncestor,Xt as _getTableWidthInPixels,Mt as _getVerticallyOverlappingTableCells,hi as _injectTableCaptionPostFixer,sl as _injectTableCellParagraphPostFixer,Qo as _injectTableLayoutPostFixer,qt as _isSingleTableParagraphWithoutAttributes,Pe as _isTableHeadingColumnCell,St as _isTableModelElement,J as _lengthTableFieldValidator,ln as _lineWidthTableFieldValidator,fi as _matchTableCaptionViewElement,qe as _normalizeTableColumnWidths,Ee as _removeEmptyTableColumns,Ve as _removeEmptyTableRows,je as _removeEmptyTableRowsColumns,an as _repositionTableContextualBalloon,ro as _skipEmptyTableRow,Ht as _splitTableCellHorizontally,Ut as _splitTableCellVertically,Z as _sumArray,dl as _tableCellRefreshHandler,ul as _tableHeadingsRefreshHandler,I as _toPrecision,Ho as _translateTableColspanAttribute,$t as _trimTableCellIfNeeded,$e as _upcastNormalizedTableStyleToAttribute,so as _upcastTable,xe as _upcastTableBorderStyles,$l as _upcastTableColgroupElement,io as _upcastTableFigure,Jt as _updateTableColumnElements,_ as _updateTableNumericAttribute};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{isObject as Wt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isObject.js";import{isString as nt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isString.js";import{isFunction as it}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isFunction.js";import{isElement as Et}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isElement.js";import{isPlainObject as M}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js";import{cloneDeepWith as Kt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js";import{merge as Ut}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/merge.js";let _;try{_={window,document}}catch{_={window:{},document:{}}}function $t(){try{return navigator.userAgent.toLowerCase()}catch{return""}}const T=$t(),C={isMac:Tt(T),isWindows:Ht(T),isGecko:Gt(T),isSafari:qt(T),isiOS:Yt(T),isAndroid:Xt(T),isBlink:Jt(T),get isMediaForcedColors(){return Qt()}};function Tt(e){return e.indexOf("macintosh")>-1}function Ht(e){return e.indexOf("windows")>-1}function Gt(e){return!!e.match(/gecko\/\d+/)}function qt(e){return e.indexOf(" applewebkit/")>-1&&e.indexOf("chrome")===-1}function Yt(e){return!!e.match(/iphone|ipad/i)||Tt(e)&&navigator.maxTouchPoints>0}function Xt(e){return e.indexOf("android")>-1}function Jt(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}function Qt(){return _.window.matchMedia?_.window.matchMedia("(forced-colors: active)").matches:!1}function Zt(e,t,n,i){n=n||function(c,a){return c===a};const s=Array.isArray(e)?e:Array.prototype.slice.call(e),o=Array.isArray(t)?t:Array.prototype.slice.call(t),r=zt(s,o,n);return i?ee(r,o.length):te(o,r)}function zt(e,t,n){const i=st(e,t,n);if(i===-1)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=ot(e,i),o=ot(t,i),r=st(s,o,n),l=e.length-r,c=t.length-r;return{firstIndex:i,lastIndexOld:l,lastIndexNew:c}}function st(e,t,n){for(let i=0;i<Math.max(e.length,t.length);i++)if(e[i]===void 0||t[i]===void 0||!n(e[i],t[i]))return i;return-1}function ot(e,t){return e.slice(t).reverse()}function te(e,t){const n=[],{firstIndex:i,lastIndexOld:s,lastIndexNew:o}=t;return o-i>0&&n.push({index:i,type:"insert",values:e.slice(i,o)}),s-i>0&&n.push({index:i+(o-i),type:"delete",howMany:s-i}),n}function ee(e,t){const{firstIndex:n,lastIndexOld:i,lastIndexNew:s}=e;if(n===-1)return Array(t).fill("equal");let o=[];return n>0&&(o=o.concat(Array(n).fill("equal"))),s-n>0&&(o=o.concat(Array(s-n).fill("insert"))),i-n>0&&(o=o.concat(Array(i-n).fill("delete"))),s<t&&(o=o.concat(Array(t-s).fill("equal"))),o}function xt(e,t,n){n=n||function(p,k){return p===k};const i=e.length,s=t.length;if(i>200||s>200||i+s>300)return xt.fastDiff(e,t,n,!0);let o,r;if(s<i){const p=e;e=t,t=p,o="delete",r="insert"}else o="insert",r="delete";const l=e.length,c=t.length,a=c-l,f={},u={};function w(p){const k=(u[p-1]!==void 0?u[p-1]:-1)+1,D=u[p+1]!==void 0?u[p+1]:-1,et=k>D?-1:1;f[p+et]&&(f[p]=f[p+et].slice(0)),f[p]||(f[p]=[]),f[p].push(k>D?o:r);let F=Math.max(k,D),j=F-p;for(;j<l&&F<c&&n(e[j],t[F]);)j++,F++,f[p].push("equal");return F}let L=0,y;do{for(y=-L;y<a;y++)u[y]=w(y);for(y=a+L;y>a;y--)u[y]=w(y);u[a]=w(a),L++}while(u[a]!==c);return f[a].slice(1)}xt.fastDiff=Zt;function rt(){return function e(){e.called=!0}}class ${source;name;path;stop;off;return;constructor(t,n){this.source=t,this.name=n,this.path=[],this.stop=rt(),this.off=rt()}}const b=new Array(256).fill("").map((e,t)=>("0"+t.toString(16)).slice(-2));function X(){const[e,t,n,i]=crypto.getRandomValues(new Uint32Array(4));return"e"+b[e>>0&255]+b[e>>8&255]+b[e>>16&255]+b[e>>24&255]+b[t>>0&255]+b[t>>8&255]+b[t>>16&255]+b[t>>24&255]+b[n>>0&255]+b[n>>8&255]+b[n>>16&255]+b[n>>24&255]+b[i>>0&255]+b[i>>8&255]+b[i>>16&255]+b[i>>24&255]}const H={get(e="normal"){return typeof e!="number"?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function ne(e,t){const n=H.get(t.priority);let i=0,s=e.length;for(;i<s;){const o=i+s>>1;H.get(e[o].priority)<n?s=o:i=o+1}e.splice(i,0,t)}const ie="https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html";class d extends Error{context;data;constructor(t,n,i,s){super(se(t,i,s)),this.name="CKEditorError",this.context=n,this.data=i,s&&(this.stack=s.stack)}is(t){return t==="CKEditorError"}static rethrowUnexpectedError(t,n){throw t.is&&t.is("CKEditorError")?t:new d("unexpected-error",n,void 0,t)}}function gn(e,t){console.warn(...At(e,t))}function mn(e,t){console.error(...At(e,t))}function It(e){return`
|
|
2
|
-
Read more: ${ie}#error-${e}`}function se(e,t,n){const i=new WeakSet,o=t?` ${JSON.stringify(t,(c,a)=>{if(typeof a=="object"&&a!==null){if(i.has(a))return`[object ${a.constructor.name}]`;i.add(a)}return a})}`:"",r=It(e),l=n?`
|
|
3
|
-
Original error: ${n.name}: ${n.message}`:"";return e+o+r+l}function At(e,t){const n=It(e);return t?[e,t,n]:[e,n]}const oe="47.5.0",bn=new Date(2026,1,11);if(globalThis.CKEDITOR_VERSION)throw new d("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION=oe;const A=Symbol("listeningTo"),G=Symbol("emitterId"),E=Symbol("delegations"),re=I(Object);function I(e){if(!e)return re;class t extends e{on(i,s,o){this.listenTo(this,i,s,o)}once(i,s,o){let r=!1;const l=(c,...a)=>{r||(r=!0,c.off(),s.call(this,c,...a))};this.listenTo(this,i,l,o)}off(i,s){this.stopListening(this,i,s)}listenTo(i,s,o,r={}){let l,c;this[A]||(this[A]={});const a=this[A];O(i)||Ct(i);const f=O(i);(l=a[f])||(l=a[f]={emitter:i,callbacks:{}}),(c=l.callbacks[s])||(c=l.callbacks[s]=[]),c.push(o),ue(this,i,s,o,r)}stopListening(i,s,o){const r=this[A];let l=i&&O(i);const c=r&&l?r[l]:void 0,a=c&&s?c.callbacks[s]:void 0;if(!(!r||i&&!c||s&&!a))if(o)W(this,i,s,o),a.indexOf(o)!==-1&&(a.length===1?delete c.callbacks[s]:W(this,i,s,o));else if(a){for(;o=a.pop();)W(this,i,s,o);delete c.callbacks[s]}else if(c){for(s in c.callbacks)this.stopListening(i,s);delete r[l]}else{for(l in r)this.stopListening(r[l].emitter);delete this[A]}}fire(i,...s){try{const o=i instanceof $?i:new $(this,i),r=o.name;let l=fe(this,r);if(o.path.push(this),l){l=l.slice();for(let a=0;a<l.length;a++){const f=l[a].callback;if(f.call(this,o,...s),o.off.called&&(delete o.off.called,this._removeEventListener(r,f)),o.stop.called)break}}const c=this[E];if(c){const a=c.get(r),f=c.get("*");a&<(a,o,s),f&<(f,o,s)}return o.return}catch(o){d.rethrowUnexpectedError(o,this)}}delegate(...i){return{to:(s,o)=>{this[E]||(this[E]=new Map),i.forEach(r=>{const l=this[E].get(r);l?l.set(s,o):this[E].set(r,new Map([[s,o]]))})}}}stopDelegating(i,s){if(this[E])if(!i)this[E].clear();else if(!s)this[E].delete(i);else{const o=this[E].get(i);o&&o.delete(s)}}_addEventListener(i,s,o){ae(this,i);const r=q(this,i),l=H.get(o.priority),c={callback:s,priority:l};for(const a of r)ne(a,c)}_removeEventListener(i,s){const o=q(this,i);for(const r of o)for(let l=0;l<r.length;l++)r[l].callback==s&&(r.splice(l,1),l--)}}return t}function le(e,t){const n=e[A];return n&&n[t]?n[t].emitter:null}function Ct(e,t){e[G]||(e[G]=t||X())}function O(e){return e[G]}function Lt(e){return e._events||Object.defineProperty(e,"_events",{value:{}}),e._events}function ce(){return{callbacks:[],childEvents:[]}}function ae(e,t){const n=Lt(e);if(n[t])return;let i=t,s=null;const o=[];for(;i!==""&&!n[i];)n[i]=ce(),o.push(n[i]),s&&n[i].childEvents.push(s),s=i,i=i.substr(0,i.lastIndexOf(":"));if(i!==""){for(const r of o)r.callbacks=n[i].callbacks.slice();n[i].childEvents.push(s)}}function q(e,t){const n=Lt(e)[t];if(!n)return[];let i=[n.callbacks];for(let s=0;s<n.childEvents.length;s++){const o=q(e,n.childEvents[s]);i=i.concat(o)}return i}function fe(e,t){if(!e._events)return null;let n=t;do{const i=e._events[n];if(i&&i.callbacks&&i.callbacks.length)return i.callbacks;const s=n.lastIndexOf(":");n=s>-1?n.substring(0,s):""}while(n);return null}function lt(e,t,n){for(let[i,s]of e){s?typeof s=="function"&&(s=s(t.name)):s=t.name;const o=new $(t.source,s);o.path=[...t.path],i.fire(o,...n)}}function ue(e,t,n,i,s){t._addEventListener?t._addEventListener(n,i,s):e._addEventListener.call(t,n,i,s)}function W(e,t,n,i){t._removeEventListener?t._removeEventListener(n,i):e._removeEventListener.call(t,n,i)}const S=Symbol("observableProperties"),V=Symbol("boundObservables"),R=Symbol("boundProperties"),x=Symbol("decoratedMethods"),ct=Symbol("decoratedOriginal"),de=kt(I());function kt(e){if(!e)return de;class t extends e{set(i,s){if(Wt(i)){Object.keys(i).forEach(r=>{this.set(r,i[r])},this);return}K(this);const o=this[S];if(i in this&&!o.has(i))throw new d("observable-set-cannot-override",this);Object.defineProperty(this,i,{enumerable:!0,configurable:!0,get(){return o.get(i)},set(r){const l=o.get(i);let c=this.fire(`set:${i}`,i,r,l);c===void 0&&(c=r),(l!==c||!o.has(i))&&(o.set(i,c),this.fire(`change:${i}`,i,c,l))}}),this[i]=s}bind(...i){if(!i.length||!at(i))throw new d("observable-bind-wrong-properties",this);if(new Set(i).size!==i.length)throw new d("observable-bind-duplicate-properties",this);K(this);const s=this[R];i.forEach(r=>{if(s.has(r))throw new d("observable-bind-rebind",this)});const o=new Map;return i.forEach(r=>{const l={property:r,to:[]};s.set(r,l),o.set(r,l)}),{to:he,toMany:pe,_observable:this,_bindProperties:i,_to:[],_bindings:o}}unbind(...i){if(!this[S])return;const s=this[R],o=this[V];if(i.length){if(!at(i))throw new d("observable-unbind-wrong-properties",this);i.forEach(r=>{const l=s.get(r);l&&(l.to.forEach(([c,a])=>{const f=o.get(c),u=f[a];u.delete(l),u.size||delete f[a],Object.keys(f).length||(o.delete(c),this.stopListening(c,"change"))}),s.delete(r))})}else o.forEach((r,l)=>{this.stopListening(l,"change")}),o.clear(),s.clear()}decorate(i){K(this);const s=this[i];if(!s)throw new d("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:i});this.on(i,(o,r)=>{o.return=s.apply(this,r)}),this[i]=function(...o){return this.fire(i,o)},this[i][ct]=s,this[x]||(this[x]=[]),this[x].push(i)}stopListening(i,s,o){if(!i&&this[x]){for(const r of this[x])this[r]=this[r][ct];delete this[x]}super.stopListening(i,s,o)}[S];[x];[R];[V]}return t}function K(e){e[S]||(Object.defineProperty(e,S,{value:new Map}),Object.defineProperty(e,V,{value:new Map}),Object.defineProperty(e,R,{value:new Map}))}function he(...e){const t=me(...e),n=Array.from(this._bindings.keys()),i=n.length;if(!t.callback&&t.to.length>1)throw new d("observable-bind-to-no-callback",this);if(i>1&&t.callback)throw new d("observable-bind-to-extra-callback",this);t.to.forEach(s=>{if(s.properties.length&&s.properties.length!==i)throw new d("observable-bind-to-properties-length",this);s.properties.length||(s.properties=this._bindProperties)}),this._to=t.to,t.callback&&(this._bindings.get(n[0]).callback=t.callback),we(this._observable,this._to),_e(this),this._bindProperties.forEach(s=>{Ft(this._observable,s)})}function pe(e,t,n){if(this._bindings.size>1)throw new d("observable-bind-to-many-not-one-binding",this);this.to(...ge(e,t),n)}function ge(e,t){const n=e.map(i=>[i,t]);return Array.prototype.concat.apply([],n)}function at(e){return e.every(t=>typeof t=="string")}function me(...e){if(!e.length)throw new d("observable-bind-to-parse-error",null);const t={to:[]};let n;return typeof e[e.length-1]=="function"&&(t.callback=e.pop()),e.forEach(i=>{if(typeof i=="string")n.properties.push(i);else if(typeof i=="object")n={observable:i,properties:[]},t.to.push(n);else throw new d("observable-bind-to-parse-error",null)}),t}function be(e,t,n,i){const s=e[V],o=s.get(n),r=o||{};r[i]||(r[i]=new Set),r[i].add(t),o||s.set(n,r)}function _e(e){let t;e._bindings.forEach((n,i)=>{e._to.forEach(s=>{t=s.properties[n.callback?0:e._bindProperties.indexOf(i)],n.to.push([s.observable,t]),be(e._observable,n,s.observable,t)})})}function Ft(e,t){const i=e[R].get(t);let s;i.callback?s=i.callback.apply(e,i.to.map(o=>o[0][o[1]])):(s=i.to[0],s=s[0][s[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=s:e.set(t,s)}function we(e,t){t.forEach(n=>{const i=e[V];let s;i.get(n.observable)||e.listenTo(n.observable,"change",(o,r)=>{s=i.get(n.observable)[r],s&&s.forEach(l=>{Ft(e,l.property)})})})}class _n{_replacedElements;constructor(){this._replacedElements=[]}replace(t,n){this._replacedElements.push({element:t,newElement:n}),t.style.display="none",n&&t.parentNode.insertBefore(n,t.nextSibling)}restore(){this._replacedElements.forEach(({element:t,newElement:n})=>{t.style.display="",n&&n.remove()}),this._replacedElements=[]}}function wn(e){let t=0;for(const n of e)t++;return t}function yn(e,t){const n=Math.min(e.length,t.length);for(let i=0;i<n;i++)if(e[i]!=t[i])return i;return e.length==t.length?"same":e.length<t.length?"prefix":"extension"}function J(e){return!!(e&&e[Symbol.iterator])}function En(e,t,n={},i=[]){const s=n&&n.xmlns,o=s?e.createElementNS(s,t):e.createElement(t);for(const r in n)o.setAttribute(r,n[r]);(nt(i)||!J(i))&&(i=[i]);for(let r of i)nt(r)&&(r=e.createTextNode(r)),o.appendChild(r);return o}class Tn{_config;constructor(t,n){this._config=Object.create(null),n&&this.define(ft(n)),t&&this._setObjectToTarget(this._config,t)}set(t,n){this._setToTarget(this._config,t,n)}define(t,n){this._setToTarget(this._config,t,n,!0)}get(t){return this._getFromSource(this._config,t)}*names(){for(const t of Object.keys(this._config))yield t}_setToTarget(t,n,i,s=!1){if(M(n)){this._setObjectToTarget(t,n,s);return}const o=n.split(".");n=o.pop();for(const r of o)M(t[r])||(t[r]=Object.create(null)),t=t[r];if(M(i)){M(t[n])||(t[n]=Object.create(null)),t=t[n],this._setObjectToTarget(t,i,s);return}s&&typeof t[n]<"u"||(t[n]=i)}_getFromSource(t,n){const i=n.split(".");n=i.pop();for(const s of i){if(!M(t[s])){t=null;break}t=t[s]}return t?ft(t[n]):void 0}_setObjectToTarget(t,n,i){Object.keys(n).forEach(s=>{this._setToTarget(t,s,n[s],i)})}}function ft(e){return Kt(e,ye)}function ye(e){return Et(e)||typeof e=="function"?e:void 0}function ut(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}function N(e){const t=Object.prototype.toString.apply(e);return t=="[object Window]"||t=="[object global]"}const Ee=Q(I());function Q(e){if(!e)return Ee;class t extends e{listenTo(i,s,o,r={}){if(ut(i)||N(i)||i instanceof _.window.EventTarget){const l={capture:!!r.useCapture,passive:!!r.usePassive},c=this._getProxyEmitter(i,l)||new Te(i,l);this.listenTo(c,s,o,r)}else super.listenTo(i,s,o,r)}stopListening(i,s,o){if(ut(i)||N(i)||i instanceof _.window.EventTarget){const r=this._getAllProxyEmitters(i);for(const l of r)this.stopListening(l,s,o)}else super.stopListening(i,s,o)}_getProxyEmitter(i,s){return le(this,Mt(i,s))}_getAllProxyEmitters(i){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map(s=>this._getProxyEmitter(i,s)).filter(s=>!!s)}}return t}class Te extends I(){_domNode;_options;constructor(t,n){super(),Ct(this,Mt(t,n)),this._domNode=t,this._options=n}_domListeners;attach(t){if(this._domListeners&&this._domListeners[t])return;const n=this._createDomListener(t);this._domNode.addEventListener(t,n,this._options),this._domListeners||(this._domListeners={}),this._domListeners[t]=n}detach(t){let n;this._domListeners[t]&&(!(n=this._events[t])||!n.callbacks.length)&&this._domListeners[t].removeListener()}_addEventListener(t,n,i){this.attach(t),I().prototype._addEventListener.call(this,t,n,i)}_removeEventListener(t,n){I().prototype._removeEventListener.call(this,t,n),this.detach(t)}_createDomListener(t){const n=i=>{this.fire(t,i)};return n.removeListener=()=>{this._domNode.removeEventListener(t,n,this._options),delete this._domListeners[t]},n}}function xe(e){return e["data-ck-expando"]||(e["data-ck-expando"]=X())}function Mt(e,t){let n=xe(e);for(const i of Object.keys(t).sort())t[i]&&(n+="-"+i);return n}function xn(e){const t=[];let n=e;for(;n&&n.nodeType!=Node.DOCUMENT_NODE;)t.unshift(n),n=n.parentNode;return t}function In(e){return e instanceof HTMLTextAreaElement?e.value:e.innerHTML}function St(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}function An(e){if(!e.target)return null;const t=e.target.ownerDocument,n=e.clientX,i=e.clientY;let s=null;return t.caretRangeFromPoint&&t.caretRangeFromPoint(n,i)?s=t.caretRangeFromPoint(n,i):e.rangeParent&&(s=t.createRange(),s.setStart(e.rangeParent,e.rangeOffset),s.collapse(!0)),s}function Rt(e){return!e||!e.parentNode||e.offsetParent===_.document.body?null:e.offsetParent}function Z(e){return Object.prototype.toString.call(e)=="[object Text]"}function z(e){return Object.prototype.toString.apply(e)=="[object Range]"}const Vt=["top","right","bottom","left","width","height"],Ie=new Set(["relative","absolute","fixed","sticky"]);class m{top;right;bottom;left;width;height;_source;constructor(t){const n=z(t);if(Object.defineProperty(this,"_source",{value:t._source||t,writable:!0,enumerable:!1}),Y(t)||n)if(n){const i=m.getDomRangeRects(t);v(this,m.getBoundingRect(i))}else v(this,t.getBoundingClientRect());else if(N(t)){const{innerWidth:i,innerHeight:s}=t;v(this,{top:0,right:i,bottom:s,left:0,width:i,height:s})}else v(this,t)}clone(){return new m(this)}moveTo(t,n){return this.top=n,this.right=t+this.width,this.bottom=n+this.height,this.left=t,this}moveBy(t,n){return this.top+=n,this.right+=t,this.left+=t,this.bottom+=n,this}getIntersection(t){const n={top:Math.max(this.top,t.top),right:Math.min(this.right,t.right),bottom:Math.min(this.bottom,t.bottom),left:Math.max(this.left,t.left),width:0,height:0};if(n.width=n.right-n.left,n.height=n.bottom-n.top,n.width<0||n.height<0)return null;{const i=new m(n);return i._source=this._source,i}}getIntersectionArea(t){const n=this.getIntersection(t);return n?n.getArea():0}getArea(){return this.width*this.height}getVisible(){const t=this._source;let n=this.clone();if(dt(t))return n;let i=t,s=t.parentNode||t.commonAncestorContainer,o;for(;s&&!dt(s);){const r=Ae(s)==="visible";if(ht(i)&&(o=i),r||o&&vt(o)==="absolute"&&!ht(s)){i=s,s=s.parentNode;continue}const l=new m(s),c=n.getIntersection(l);if(c)c.getArea()<n.getArea()&&(n=c);else return null;i=s,s=s.parentNode}return n}isEqual(t){for(const n of Vt)if(this[n]!==t[n])return!1;return!0}contains(t){const n=this.getIntersection(t);return!!(n&&n.isEqual(t))}toAbsoluteRect(){const{scrollX:t,scrollY:n}=_.window,i=this.clone().moveBy(t,n);if(Y(i._source)){const s=Rt(i._source);s&&Ce(i,s)}return i}excludeScrollbarsAndBorders(){const t=this._source;let n,i,s;if(N(t))n=t.innerWidth-t.document.documentElement.clientWidth,i=t.innerHeight-t.document.documentElement.clientHeight,s=t.getComputedStyle(t.document.documentElement).direction;else{const o=St(t);n=t.offsetWidth-t.clientWidth-o.left-o.right,i=t.offsetHeight-t.clientHeight-o.top-o.bottom,s=t.ownerDocument.defaultView.getComputedStyle(t).direction,this.left+=o.left,this.top+=o.top,this.right-=o.right,this.bottom-=o.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=n,s==="ltr"?this.right-=n:this.left+=n,this.height-=i,this.bottom-=i,this}static getDomRangeRects(t){const n=[],i=Array.from(t.getClientRects());if(i.length)for(const s of i){const o=new m(s);o._source=t,n.push(o)}else{let s=t.startContainer;Z(s)&&(s=s.parentNode);const o=new m(s.getBoundingClientRect());o.right=o.left,o.width=0,n.push(o)}return n}static getBoundingRect(t){const n={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const s of t)i++,n.left=Math.min(n.left,s.left),n.top=Math.min(n.top,s.top),n.right=Math.max(n.right,s.right),n.bottom=Math.max(n.bottom,s.bottom);return i==0?null:(n.width=n.right-n.left,n.height=n.bottom-n.top,new m(n))}}function v(e,t){for(const n of Vt)e[n]=t[n]}function dt(e){return Y(e)?e===e.ownerDocument.body:!1}function Y(e){return e!==null&&typeof e=="object"&&e.nodeType===1&&typeof e.getBoundingClientRect=="function"}function vt(e){return e.ownerDocument.defaultView.getComputedStyle(e).position}function Ae(e){return e instanceof HTMLElement?e.ownerDocument.defaultView.getComputedStyle(e).overflow:"visible"}function ht(e){return e instanceof HTMLElement&&Ie.has(vt(e))}function Ce(e,t){const n=new m(t),i=St(t);let s=0,o=0;s-=n.left,o-=n.top,s+=t.scrollLeft,o+=t.scrollTop,s-=i.left,o-=i.top,e.moveBy(s,o)}class h{_element;_callback;static _observerInstance=null;static _elementCallbacks=null;constructor(t,n){h._observerInstance||h._createObserver(),this._element=t,this._callback=n,h._addElementCallback(t,n),h._observerInstance.observe(t)}get element(){return this._element}destroy(){h._deleteElementCallback(this._element,this._callback)}static _addElementCallback(t,n){h._elementCallbacks||(h._elementCallbacks=new Map);let i=h._elementCallbacks.get(t);i||(i=new Set,h._elementCallbacks.set(t,i)),i.add(n)}static _deleteElementCallback(t,n){const i=h._getElementCallbacks(t);i&&(i.delete(n),i.size||(h._elementCallbacks.delete(t),h._observerInstance.unobserve(t))),h._elementCallbacks&&!h._elementCallbacks.size&&(h._observerInstance=null,h._elementCallbacks=null)}static _getElementCallbacks(t){return h._elementCallbacks?h._elementCallbacks.get(t):null}static _createObserver(){h._observerInstance=new _.window.ResizeObserver(t=>{for(const n of t){const i=h._getElementCallbacks(n.target);if(i)for(const s of i)s(n)}})}}function Cn(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function Ln(e){return t=>t+e}function kn(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Fn(e,t,n){e.insertBefore(n,e.childNodes[t]||null)}function Mn(e){return e&&e.nodeType===Node.COMMENT_NODE}function Sn(e){try{_.document.createAttribute(e)}catch{return!1}return!0}function Le(e){return e?Z(e)?Le(e.parentElement):e.getClientRects?!!e.getClientRects().length:!1:!1}function Rn({element:e,target:t,positions:n,limiter:i,fitInViewport:s,viewportOffsetConfig:o}){it(t)&&(t=t()),it(i)&&(i=i());const r=Rt(e),l=ke(o),c=new m(e),a=pt(t,l);let f;if(!a||!l.getIntersection(a))return null;const u={targetRect:a,elementRect:c,positionedElementAncestor:r,viewportRect:l};if(!i&&!s)f=new Pt(n[0],u);else{if(i){const w=pt(i,l);w&&(u.limiterRect=w)}f=Fe(n,u)}return f}function pt(e,t){const n=new m(e).getVisible();return n?n.getIntersection(t):null}function ke(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new m(_.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t.left+=e.left,t.right-=e.right,t.width-=e.left+e.right,t}function Fe(e,t){const{elementRect:n}=t,i=n.getArea(),s=e.map(l=>new Pt(l,t)).filter(l=>!!l.name);let o=0,r=null;for(const l of s){const{limiterIntersectionArea:c,viewportIntersectionArea:a}=l;if(c===i)return l;const f=a**2+c**2;f>o&&(o=f,r=l)}return r}class Pt{name;config;_positioningFunctionCoordinates;_options;_cachedRect;_cachedAbsoluteRect;constructor(t,n){const i=t(n.targetRect,n.elementRect,n.viewportRect,n.limiterRect);if(!i)return;const{left:s,top:o,name:r,config:l}=i;this.name=r,this.config=l,this._positioningFunctionCoordinates={left:s,top:o},this._options=n}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const t=this._options.limiterRect;return t?t.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect?this._cachedRect:(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top),this._cachedRect)}get _absoluteRect(){return this._cachedAbsoluteRect?this._cachedAbsoluteRect:(this._cachedAbsoluteRect=this._rect.toAbsoluteRect(),this._cachedAbsoluteRect)}}function Vn(e){const t=e.parentNode;t&&t.removeChild(e)}function vn(){const e=_.window.visualViewport;if(!e||!(C.isiOS||C.isSafari))return{left:0,top:0};const t=Math.max(Math.round(e.offsetLeft),0),n=Math.max(Math.round(e.offsetTop),0);return{left:t,top:n}}function Pn({target:e,viewportOffset:t=0,ancestorOffset:n=0,alignToTop:i,forceScroll:s}){const o=tt(e);let r=o,l=null;for(t=Re(t);r;){let c;r==o?c=gt(e):c=gt(l),Se({parent:c,getRect:()=>U(e,r),alignToTop:i,ancestorOffset:n,forceScroll:s});let a=U(e,r);const f=U(c,r);if(a.height>f.height){const u=a.getIntersection(f);u&&(a=u)}if(Me({window:r,rect:a,viewportOffset:t,alignToTop:i,forceScroll:s}),r.parent!=r){if(l=r.frameElement,r=r.parent,!l)return}else r=null}}function Me({window:e,rect:t,alignToTop:n,forceScroll:i,viewportOffset:s}){const o=t.clone().moveBy(0,s.bottom),r=t.clone().moveBy(0,-s.top),l=new m(e).excludeScrollbarsAndBorders(),c=[r,o],a=n&&i,f=c.every(p=>l.contains(p));let{scrollX:u,scrollY:w}=e;const L=u,y=w;a?w-=l.top-t.top+s.top:f||(Bt(r,l)?w-=l.top-t.top+s.top:Nt(o,l)&&(n?w+=t.top-l.top-s.top:w+=t.bottom-l.bottom+s.bottom)),f||(Dt(t,l)?u-=l.left-t.left+s.left:jt(t,l)&&(u+=t.right-l.right+s.right)),(u!=L||w!==y)&&e.scrollTo(u,w)}function Se({parent:e,getRect:t,alignToTop:n,forceScroll:i,ancestorOffset:s=0,limiterElement:o}){const r=tt(e),l=n&&i;let c,a,f;const u=o||r.document.body;for(;e!=u;)a=t(),c=new m(e).excludeScrollbarsAndBorders(),f=c.contains(a),l?e.scrollTop-=c.top-a.top+s:f||(Bt(a,c)?e.scrollTop-=c.top-a.top+s:Nt(a,c)&&(n?e.scrollTop+=a.top-c.top-s:e.scrollTop+=a.bottom-c.bottom+s)),f||(Dt(a,c)?e.scrollLeft-=c.left-a.left+s:jt(a,c)&&(e.scrollLeft+=a.right-c.right+s)),e=e.parentNode}function Nt(e,t){return e.bottom>t.bottom}function Bt(e,t){return e.top<t.top}function Dt(e,t){return e.left<t.left}function jt(e,t){return e.right>t.right}function tt(e){return z(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function gt(e){if(z(e)){let t=e.commonAncestorContainer;return Z(t)&&(t=t.parentNode),t}else return e.parentNode}function U(e,t){const n=tt(e),i=new m(e);if(n===t)return i;{let s=n;for(;s!=t;){const o=s.frameElement,r=new m(o).excludeScrollbarsAndBorders();i.moveBy(r.left,r.top),s=s.parent}}return i}function Re(e){return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:e}const Ve={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},ve={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},mt={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},g=De(),Pe=Object.fromEntries(Object.entries(g).map(([e,t])=>{let n;return t in mt?n=mt[t]:n=e.charAt(0).toUpperCase()+e.slice(1),[t,n]}));function B(e){let t;if(typeof e=="string"){if(t=g[e.toLowerCase()],!t)throw new d("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?g.alt:0)+(e.ctrlKey?g.ctrl:0)+(e.shiftKey?g.shift:0)+(e.metaKey?g.cmd:0);return t}function Ot(e){return typeof e=="string"&&(e=je(e)),e.map(t=>typeof t=="string"?Be(t):t).reduce((t,n)=>n+t,0)}function Nn(e,t){let n=Ot(e);const i=C.isMac||C.isiOS;return Object.entries(i?Ve:ve).reduce((r,[l,c])=>((n&g[l])!=0&&(n&=~g[l],r+=c),r),"")+(n?Pe[n]:"")}function Bn(e){return e==g.arrowright||e==g.arrowleft||e==g.arrowup||e==g.arrowdown}function Ne(e,t){const n=t==="ltr";switch(e){case g.arrowleft:return n?"left":"right";case g.arrowright:return n?"right":"left";case g.arrowup:return"up";case g.arrowdown:return"down"}}function Be(e){if(e.endsWith("!"))return B(e.slice(0,-1));const t=B(e);return(C.isMac||C.isiOS)&&t==g.ctrl?g.cmd:t}function Dn(e,t){const n=Ne(e,t);return n==="down"||n==="right"}function De(){const e={pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){const n=String.fromCharCode(t);e[n.toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return Object.assign(e,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),e}function je(e){return e.split("+").map(t=>t.trim())}const Oe=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig","ur","urd"];function bt(e){return Oe.includes(e)?"rtl":"ltr"}function We(e){return Array.isArray(e)?e:[e]}_.window.CKEDITOR_TRANSLATIONS||(_.window.CKEDITOR_TRANSLATIONS={});function Ke(e,t,n=1,i){if(typeof n!="number")throw new d("translation-service-quantity-not-a-number",null,{quantity:n});const s=i||_.window.CKEDITOR_TRANSLATIONS,o=He(s);o===1&&(e=Object.keys(s)[0]);const r=t.id||t.string;if(o===0||!$e(e,r,s))return n!==1?t.plural:t.string;const l=s[e].dictionary,c=s[e].getPluralForm||(u=>u===1?0:1),a=l[r];if(typeof a=="string")return a;const f=Number(c(n));return a[f]}function Ue(e){return Array.isArray(e)?e.reduce((t,n)=>Ut(t,n)):e}function $e(e,t,n){return!!n[e]&&!!n[e].dictionary[t]}function He(e){return Object.keys(e).length}class jn{uiLanguage;uiLanguageDirection;contentLanguage;contentLanguageDirection;t;translations;constructor({uiLanguage:t="en",contentLanguage:n,translations:i}={}){this.uiLanguage=t,this.contentLanguage=n||this.uiLanguage,this.uiLanguageDirection=bt(this.uiLanguage),this.contentLanguageDirection=bt(this.contentLanguage),this.translations=Ue(i),this.t=(s,o)=>this._t(s,o)}_t(t,n=[]){n=We(n),typeof t=="string"&&(t={string:t});const s=!!t.plural?n[0]:1,o=Ke(this.uiLanguage,t,s,this.translations);return Ge(o,n)}}function Ge(e,t){return e.replace(/%(\d+)/g,(n,i)=>i<t.length?t[i]:n)}class On extends I(){_items;_itemMap;_idProperty;_bindToCollection;_bindToExternalToInternalMap;_bindToInternalToExternalMap;_skippedIndexesFromExternal;constructor(t={},n={}){super();const i=J(t);if(i||(n=t),this._items=[],this._itemMap=new Map,this._idProperty=n.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],i)for(const s of t)this._items.push(s),this._itemMap.set(this._getItemIdBeforeAdding(s),s)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(t,n){return this.addMany([t],n)}addMany(t,n){if(n===void 0)n=this._items.length;else if(n>this._items.length||n<0)throw new d("collection-add-item-invalid-index",this);let i=0;for(const s of t){const o=this._getItemIdBeforeAdding(s),r=n+i;this._items.splice(r,0,s),this._itemMap.set(o,s),this.fire("add",s,r),i++}return this.fire("change",{added:t,removed:[],index:n}),this}get(t){let n;if(typeof t=="string")n=this._itemMap.get(t);else if(typeof t=="number")n=this._items[t];else throw new d("collection-get-invalid-arg",this);return n||null}has(t){if(typeof t=="string")return this._itemMap.has(t);{const n=this._idProperty,i=t[n];return i&&this._itemMap.has(i)}}getIndex(t){let n;return typeof t=="string"?n=this._itemMap.get(t):n=t,n?this._items.indexOf(n):-1}remove(t){const[n,i]=this._remove(t);return this.fire("change",{added:[],removed:[n],index:i}),n}map(t,n){return this._items.map(t,n)}forEach(t,n){this._items.forEach(t,n)}find(t,n){return this._items.find(t,n)}filter(t,n){return this._items.filter(t,n)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const t=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:t,index:0})}bindTo(t){if(this._bindToCollection)throw new d("collection-bind-to-rebind",this);return this._bindToCollection=t,{as:n=>{this._setUpBindToBinding(i=>new n(i))},using:n=>{typeof n=="function"?this._setUpBindToBinding(n):this._setUpBindToBinding(i=>i[n])}}}_setUpBindToBinding(t){const n=this._bindToCollection,i=(s,o,r)=>{const l=n._bindToCollection==this,c=n._bindToInternalToExternalMap.get(o);if(l&&c)this._bindToExternalToInternalMap.set(o,c),this._bindToInternalToExternalMap.set(c,o);else{const a=t(o);if(!a){this._skippedIndexesFromExternal.push(r);return}let f=r;for(const u of this._skippedIndexesFromExternal)r>u&&f--;for(const u of n._skippedIndexesFromExternal)f>=u&&f++;this._bindToExternalToInternalMap.set(o,a),this._bindToInternalToExternalMap.set(a,o),this.add(a,f);for(let u=0;u<n._skippedIndexesFromExternal.length;u++)f<=n._skippedIndexesFromExternal[u]&&n._skippedIndexesFromExternal[u]++}};for(const s of n)i(null,s,n.getIndex(s));this.listenTo(n,"add",i),this.listenTo(n,"remove",(s,o,r)=>{const l=this._bindToExternalToInternalMap.get(o);l&&this.remove(l),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((c,a)=>(r<a&&c.push(a-1),r>a&&c.push(a),c),[])})}_getItemIdBeforeAdding(t){const n=this._idProperty;let i;if(n in t){if(i=t[n],typeof i!="string")throw new d("collection-add-invalid-id",this);if(this.get(i))throw new d("collection-add-item-already-exists",this)}else t[n]=i=X();return i}_remove(t){let n,i,s,o=!1;const r=this._idProperty;if(typeof t=="string"?(i=t,s=this._itemMap.get(i),o=!s,s&&(n=this._items.indexOf(s))):typeof t=="number"?(n=t,s=this._items[n],o=!s,s&&(i=s[r])):(s=t,i=s[r],n=this._items.indexOf(s),o=n==-1||!this._itemMap.get(i)),o)throw new d("collection-remove-404",this);this._items.splice(n,1),this._itemMap.delete(i);const l=this._bindToInternalToExternalMap.get(s);return this._bindToInternalToExternalMap.delete(s),this._bindToExternalToInternalMap.delete(l),this.fire("remove",s,n),[s,n]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function Wn(e){const t=e.next();return t.done?null:t.value}class qe extends Q(kt()){_elements=new Set;_externalViews=new Set;_blurTimeout=null;constructor(){super(),this.set("isFocused",!1),this.set("focusedElement",null)}get elements(){return Array.from(this._elements.values())}get externalViews(){return Array.from(this._externalViews.values())}add(t){if(wt(t))this._addElement(t);else if(_t(t))this._addView(t);else{if(!t.element)throw new d("focustracker-add-view-missing-element",{focusTracker:this,view:t});this._addElement(t.element)}}remove(t){wt(t)?this._removeElement(t):_t(t)?this._removeView(t):this._removeElement(t.element)}_addElement(t){if(this._elements.has(t))throw new d("focustracker-add-element-already-exist",this);this.listenTo(t,"focus",()=>{const n=this.externalViews.find(i=>Ye(t,i));n?this._focus(n.element):this._focus(t)},{useCapture:!0}),this.listenTo(t,"blur",()=>{this._blur()},{useCapture:!0}),this._elements.add(t)}_removeElement(t){this._elements.has(t)&&(this.stopListening(t),this._elements.delete(t)),t===this.focusedElement&&this._blur()}_addView(t){t.element&&this._addElement(t.element),this.listenTo(t.focusTracker,"change:focusedElement",()=>{t.focusTracker.focusedElement?t.element&&this._focus(t.element):this._blur()}),this._externalViews.add(t)}_removeView(t){t.element&&this._removeElement(t.element),this.stopListening(t.focusTracker),this._externalViews.delete(t)}destroy(){this.stopListening(),this._elements.clear(),this._externalViews.clear(),this.isFocused=!1,this.focusedElement=null}_focus(t){this._clearBlurTimeout(),this.focusedElement=t,this.isFocused=!0}_blur(){this.elements.find(i=>i.contains(document.activeElement))||this.externalViews.find(i=>i.focusTracker.isFocused&&!i.focusTracker._blurTimeout)||(this._clearBlurTimeout(),this._blurTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0))}_clearBlurTimeout(){clearTimeout(this._blurTimeout),this._blurTimeout=null}}function _t(e){return"focusTracker"in e&&e.focusTracker instanceof qe}function wt(e){return Et(e)}function Ye(e,t){return yt(e,t)?!0:!!t.focusTracker.externalViews.find(n=>yt(e,n))}function yt(e,t){return!!t.element&&t.element.contains(document.activeElement)&&e.contains(t.element)}class Kn{_listener;constructor(){this._listener=new(Q())}listenTo(t){this._listener.listenTo(t,"keydown",(n,i)=>{this._listener.fire("_keydown:"+B(i),i)})}set(t,n,i={}){const s=Ot(t),o=i.priority;this._listener.listenTo(this._listener,"_keydown:"+s,(r,l)=>{i.filter&&!i.filter(l)||(n(l,()=>{l.preventDefault(),l.stopPropagation(),r.stop()}),r.return=!0)},{priority:o})}press(t){return!!this._listener.fire("_keydown:"+B(t),t)}stopListening(t){this._listener.stopListening(t)}destroy(){this.stopListening()}}function Xe(e){const t=new Map;for(const n in e)t.set(n,e[n]);return t}function Un(e){return J(e)?new Map(e):Xe(e)}function $n(e,t,n){const i=e.length,s=t.length;for(let o=i-1;o>=n;o--)e[o+s]=e[o];for(let o=0;o<s;o++)e[n+o]=t[o]}function Hn(e,t){let n;function i(...s){i.cancel(),n=setTimeout(()=>e(...s),t)}return i.cancel=()=>{clearTimeout(n)},i}function Je(e){try{if(!e.startsWith("ey"))return null;const t=atob(e.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(t)}catch{return null}}function Qe(){const e=[];for(let t=0;t<256;t++){let n=t;for(let i=0;i<8;i++)n&1?n=3988292384^n>>>1:n=n>>>1;e[t]=n}return e}function Gn(e){const t=Array.isArray(e)?e:[e],n=Qe();let i=-1;const s=t.map(o=>Array.isArray(o)?o.join(""):String(o)).join("");for(let o=0;o<s.length;o++){const r=s.charCodeAt(o);i=i>>>8^n[(i^r)&255]}return i=(i^-1)>>>0,i.toString(16).padStart(8,"0")}function qn(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],n=t.map(r=>r.name).join("|"),i=e.replace(new RegExp(`</?(${n})( .*?)?>`,"g"),`
|
|
4
|
-
$&
|
|
5
|
-
`).replace(/<br[^>]*>/g,`$&
|
|
6
|
-
`).split(`
|
|
7
|
-
`);let s=0,o=!1;return i.map(r=>(o=tn(r,o),!r.length&&!o?"":Ze(r,t)?P(r,s++):ze(r,t)?P(r,--s):o==="middle"||o==="last"?P(r,0):P(r,s))).join("").trimEnd()}function Ze(e,t){return t.some(n=>!(n.isVoid||!new RegExp(`<${n.name}( .*?)?>`).test(e)))}function ze(e,t){return t.some(n=>new RegExp(`</${n.name}>`).test(e))}function P(e,t,n=" "){return`${n.repeat(Math.max(0,t))}${e}
|
|
8
|
-
`}function tn(e,t){const n=/<pre( .*?)?>/.test(e),i=/<\/pre>/.test(e);return n&&i?!1:n?"first":i?"last":t==="first"||t==="middle"?"middle":!1}function en(e){return!!e&&e.length==1&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(e)}function nn(e){return!!e&&e.length==1&&/[\ud800-\udbff]/.test(e)}function sn(e){return!!e&&e.length==1&&/[\udc00-\udfff]/.test(e)}function Yn(e,t){return nn(e.charAt(t-1))&&sn(e.charAt(t))}function Xn(e,t){return en(e.charAt(t))}const on=rn();function Jn(e,t){const n=String(e).matchAll(on);return Array.from(n).some(i=>i.index<t&&t<i.index+i[0].length)}function rn(){const e=[new RegExp("\\p{Emoji}[\\u{E0020}-\\u{E007E}]+\\u{E007F}","u"),new RegExp("\\p{Emoji}\\u{FE0F}?\\u{20E3}","u"),new RegExp("\\p{Emoji}\\u{FE0F}","u"),new RegExp("(?=\\p{General_Category=Other_Symbol})\\p{Emoji}\\p{Emoji_Modifier}*","u")],t=new RegExp("\\p{Regional_Indicator}{2}","u").source,n="(?:"+e.map(s=>s.source).join("|")+")",i=`${t}|${n}(?:${n})*`;return new RegExp(i,"ug")}function Qn(e){if(!e)return null;const t=ln(e);return t?Je(t):null}function ln(e){const t=e.split(".");return t.length!=3?null:t[1]}function Zn(e,t){return(e.removeFeatures||[]).includes(t)}export{d as CKEditorError,On as Collection,Tn as Config,ie as DOCUMENTATION_URL,Q as DomEmitterMixin,_n as ElementReplacer,I as EmitterMixin,$ as EventInfo,qe as FocusTracker,Kn as KeystrokeHandler,jn as Locale,kt as ObservableMixin,m as Rect,h as ResizeObserver,O as _getEmitterId,le as _getEmitterListenedTo,$t as _getUserAgent,Xt as _isAndroid,Jt as _isBlink,Gt as _isGecko,Tt as _isMac,Qt as _isMediaForcedColors,qt as _isSafari,Ht as _isWindows,Yt as _isiOS,Ct as _setEmitterId,Ke as _translate,Ue as _unifyTranslations,yn as compareArrays,wn as count,Gn as crc32,En as createElement,Qn as decodeLicenseKey,Hn as delay,xt as diff,C as env,Zt as fastDiff,Wn as first,qn as formatHtml,xn as getAncestors,St as getBorderWidths,B as getCode,ke as getConstrainedViewportRect,In as getDataFromElement,Nn as getEnvKeystrokeText,bt as getLanguageDirection,Ne as getLocalizedArrowKeyCodeDirection,Rn as getOptimalPosition,Rt as getPositionedAncestor,An as getRangeFromMouseEvent,vn as getVisualViewportOffset,_ as global,kn as indexOf,Fn as insertAt,ne as insertToPriorityArray,Bn as isArrowKeyCode,en as isCombiningMark,Mn as isComment,Zn as isFeatureBlockedByLicenseKey,Dn as isForwardArrowKeyCode,nn as isHighSurrogateHalf,Xn as isInsideCombinedSymbol,Jn as isInsideEmojiSequence,Yn as isInsideSurrogatePair,J as isIterable,sn as isLowSurrogateHalf,ut as isNode,z as isRange,Z as isText,Sn as isValidAttributeName,_t as isViewWithFocusTracker,Le as isVisible,N as isWindow,g as keyCodes,mn as logError,gn as logWarning,Xe as objectToMap,Je as parseBase64EncodedObject,Ot as parseKeystroke,H as priorities,bn as releaseDate,Vn as remove,Pn as scrollViewportToShowTarget,Cn as setDataInElement,$n as spliceArray,rt as spy,We as toArray,Un as toMap,Ln as toUnit,X as uid,oe as version};
|
|
File without changes
|