@ckeditor/ckeditor5-table 29.2.0 → 30.0.0

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/build/table.js CHANGED
@@ -2,4 +2,4 @@
2
2
  * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
- !function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"Align cell text to the bottom":"Align cell text to the bottom","Align cell text to the center":"Align cell text to the center","Align cell text to the left":"Align cell text to the left","Align cell text to the middle":"Align cell text to the middle","Align cell text to the right":"Align cell text to the right","Align cell text to the top":"Align cell text to the top","Align table to the left":"Align table to the left","Align table to the right":"Align table to the right",Alignment:"Alignment",Background:"Background",Border:"Border","Cell properties":"Cell properties","Center table":"Center table",Color:"Color","Color picker":"Color picker",Column:"Column",Dashed:"Dashed","Delete column":"Delete column","Delete row":"Delete row",Dimensions:"Dimensions",Dotted:"Dotted",Double:"Double","Enter table caption":"Enter table caption",Groove:"Groove","Header column":"Header column","Header row":"Header row",Height:"Height","Horizontal text alignment toolbar":"Horizontal text alignment toolbar","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert row above":"Insert row above","Insert row below":"Insert row below","Insert table":"Insert table",Inset:"Inset","Justify cell text":"Justify cell text","Merge cell down":"Merge cell down","Merge cell left":"Merge cell left","Merge cell right":"Merge cell right","Merge cell up":"Merge cell up","Merge cells":"Merge cells",None:"None",Outset:"Outset",Padding:"Padding",Ridge:"Ridge",Row:"Row","Select column":"Select column","Select row":"Select row",Solid:"Solid","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Style:"Style","Table alignment toolbar":"Table alignment toolbar","Table cell text alignment":"Table cell text alignment","Table properties":"Table properties","Table toolbar":"Table toolbar",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".','The value is invalid. Try "10px" or "2em" or simply "2".':'The value is invalid. Try "10px" or "2em" or simply "2".',"Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on","Vertical text alignment toolbar":"Vertical text alignment toolbar",Width:"Width"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),window.CKEditor5=window.CKEditor5||{},window.CKEditor5.table=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=32)}([function(e,t,o){e.exports=o(6)("./src/ui.js")},function(e,t,o){e.exports=o(6)("./src/core.js")},function(e,t,o){e.exports=o(6)("./src/utils.js")},function(e,t,o){e.exports=o(6)("./src/widget.js")},function(e,t,o){e.exports=o(6)("./src/engine.js")},function(e,t,o){"use strict";var n,i=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var e={};return function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}e[t]=o}return e[t]}}(),l=[];function s(e){for(var t=-1,o=0;o<l.length;o++)if(l[o].identifier===e){t=o;break}return t}function a(e,t){for(var o={},n=[],i=0;i<e.length;i++){var r=e[i],a=t.base?r[0]+t.base:r[0],c=o[a]||0,d="".concat(a," ").concat(c);o[a]=c+1;var u=s(d),h={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(l[u].references++,l[u].updater(h)):l.push({identifier:d,updater:p(h,t),references:1}),n.push(d)}return n}function c(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var i=o.nc;i&&(n.nonce=i)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var l=r(e.insert||"head");if(!l)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");l.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function h(e,t,o,n){var i=o?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=u(t,i);else{var r=document.createTextNode(i),l=e.childNodes;l[t]&&e.removeChild(l[t]),l.length?e.insertBefore(r,l[t]):e.appendChild(r)}}function b(e,t,o){var n=o.css,i=o.media,r=o.sourceMap;if(i?e.setAttribute("media",i):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var m=null,g=0;function p(e,t){var o,n,i;if(t.singleton){var r=g++;o=m||(m=c(t)),n=h.bind(null,o,r,!1),i=h.bind(null,o,r,!0)}else o=c(t),n=b.bind(null,o,t),i=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(o)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else i()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=i());var o=a(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<o.length;n++){var i=s(o[n]);l[i].references--}for(var r=a(e,t),c=0;c<o.length;c++){var d=s(o[c]);0===l[d].references&&(l[d].updater(),l.splice(d,1))}o=r}}}},function(e,t){e.exports=CKEditor5.dll},,function(e,t,o){var n=o(5),i=o(23);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t,o){var n=o(5),i=o(24);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t,o){"use strict";(function(e){var o="object"==typeof e&&e&&e.Object===Object&&e;t.a=o}).call(this,o(27))},function(e,t,o){var n=o(5),i=o(12);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=":root{--ck-color-table-focused-cell-background:rgba(158,207,250,0.3)}.ck-widget.table td.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table td.ck-editor__nested-editable:focus,.ck-widget.table th.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table th.ck-editor__nested-editable:focus{background:var(--ck-color-table-focused-cell-background);border-style:none;outline:1px solid var(--ck-color-focus-border);outline-offset:-1px}"},function(e,t,o){var n=o(5),i=o(14);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck .ck-insert-table-dropdown__grid{display:flex;flex-direction:row;flex-wrap:wrap}:root{--ck-insert-table-dropdown-padding:10px;--ck-insert-table-dropdown-box-height:11px;--ck-insert-table-dropdown-box-width:12px;--ck-insert-table-dropdown-box-margin:1px}.ck .ck-insert-table-dropdown__grid{width:calc(var(--ck-insert-table-dropdown-box-width)*10 + var(--ck-insert-table-dropdown-box-margin)*20 + var(--ck-insert-table-dropdown-padding)*2);padding:var(--ck-insert-table-dropdown-padding) var(--ck-insert-table-dropdown-padding) 0}.ck .ck-insert-table-dropdown__label{text-align:center}.ck .ck-insert-table-dropdown-grid-box{width:var(--ck-insert-table-dropdown-box-width);height:var(--ck-insert-table-dropdown-box-height);margin:var(--ck-insert-table-dropdown-box-margin);border:1px solid var(--ck-color-base-border);border-radius:1px}.ck .ck-insert-table-dropdown-grid-box.ck-on{border-color:var(--ck-color-focus-border);background:var(--ck-color-focus-outer-shadow)}"},function(e,t,o){var n=o(5),i=o(16);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=':root{--ck-table-selected-cell-background:rgba(158,207,250,0.3)}.ck.ck-editor__editable .table table td.ck-editor__editable_selected,.ck.ck-editor__editable .table table th.ck-editor__editable_selected{position:relative;caret-color:transparent;outline:unset;box-shadow:unset}.ck.ck-editor__editable .table table td.ck-editor__editable_selected:after,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:after{content:"";pointer-events:none;background-color:var(--ck-table-selected-cell-background);position:absolute;top:0;left:0;right:0;bottom:0}.ck.ck-editor__editable .table table td.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table td.ck-editor__editable_selected:focus,.ck.ck-editor__editable .table table th.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:focus{background-color:transparent}.ck.ck-editor__editable .table table td.ck-editor__editable_selected .ck-widget_selected,.ck.ck-editor__editable .table table th.ck-editor__editable_selected .ck-widget_selected{outline:unset}'},function(e,t,o){var n=o(5),i=o(18);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck-content .table{margin:.9em auto;display:table}.ck-content .table table{border-collapse:collapse;border-spacing:0;width:100%;height:100%;border:1px double #b3b3b3}.ck-content .table table td,.ck-content .table table th{min-width:2em;padding:.4em;border:1px solid #bfbfbf}.ck-content .table table th{font-weight:700;background:hsla(0,0%,0%,5%)}.ck-content[dir=rtl] .table th{text-align:right}.ck-content[dir=ltr] .table th{text-align:left}.ck-editor__editable .ck-table-bogus-paragraph{display:inline-block;width:100%}"},function(e,t,o){var n=o(5),i=o(20);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-input-color{width:100%;display:flex;flex-direction:row-reverse}.ck.ck-input-color>input.ck.ck-input-text{min-width:auto;flex-grow:1}.ck.ck-input-color>div.ck.ck-dropdown{min-width:auto}.ck.ck-input-color>div.ck.ck-dropdown>.ck-input-color__button .ck-dropdown__arrow{display:none}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview{position:relative;overflow:hidden}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{position:absolute;display:block}[dir=ltr] .ck.ck-input-color>.ck.ck-input-text{border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-input-text{border-top-left-radius:0;border-bottom-left-radius:0}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{padding:0}[dir=ltr] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-left-width:0;border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-right-width:0;border-top-right-radius:0;border-bottom-right-radius:0}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button.ck-disabled{background:var(--ck-color-input-disabled-background)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{border-radius:0}.ck-rounded-corners .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview,.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{width:20px;height:20px;border:1px solid var(--ck-color-input-border)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{top:-30%;left:50%;height:150%;width:8%;background:red;border-radius:2px;transform:rotate(45deg);transform-origin:50%}.ck.ck-input-color .ck.ck-input-color__remove-color{width:100%;border-bottom:1px solid var(--ck-color-input-border);padding:calc(var(--ck-spacing-standard)/2) var(--ck-spacing-standard);border-bottom-left-radius:0;border-bottom-right-radius:0}[dir=ltr] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-right-radius:0}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-left-radius:0}.ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-right:0;margin-left:var(--ck-spacing-standard)}"},function(e,t,o){var n=o(5),i=o(22);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-form__row{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.ck.ck-form__row>:not(.ck-label){flex-grow:1}.ck.ck-form__row.ck-table-form__action-row .ck-button-cancel,.ck.ck-form__row.ck-table-form__action-row .ck-button-save{justify-content:center}.ck.ck-form__row{padding:var(--ck-spacing-standard) var(--ck-spacing-large) 0}[dir=ltr] .ck.ck-form__row>:not(.ck-label)+*{margin-left:var(--ck-spacing-large)}[dir=rtl] .ck.ck-form__row>:not(.ck-label)+*{margin-right:var(--ck-spacing-large)}.ck.ck-form__row>.ck-label{width:100%;min-width:100%}.ck.ck-form__row.ck-table-form__action-row{margin-top:var(--ck-spacing-large)}.ck.ck-form__row.ck-table-form__action-row .ck-button .ck-button__label{color:var(--ck-color-text)}"},function(e,t){e.exports=".ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}"},function(e,t){e.exports='.ck.ck-table-form .ck-form__row.ck-table-form__background-row,.ck.ck-table-form .ck-form__row.ck-table-form__border-row{flex-wrap:wrap}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{flex-wrap:wrap;align-items:center}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view{display:flex;flex-direction:column-reverse;align-items:center}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view .ck.ck-dropdown,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{flex-grow:0}.ck.ck-table-form .ck.ck-labeled-field-view{position:relative}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{position:absolute;left:50%;bottom:calc(var(--ck-table-properties-error-arrow-size)*-1);transform:translate(-50%,100%);z-index:1}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{content:"";position:absolute;top:calc(var(--ck-table-properties-error-arrow-size)*-1);left:50%;transform:translateX(-50%)}:root{--ck-table-properties-error-arrow-size:6px;--ck-table-properties-min-error-width:150px}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-labeled-field-view>.ck-label{font-size:var(--ck-font-size-tiny);text-align:center}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-style,.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-width{width:80px;min-width:80px;max-width:80px}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{padding:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__height,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__width{margin:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{align-self:flex-end;display:inline-block;height:var(--ck-ui-component-min-height);line-height:var(--ck-ui-component-min-height);margin:0 var(--ck-spacing-small)}.ck.ck-table-form .ck.ck-labeled-field-view{padding-top:var(--ck-spacing-standard)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{border-radius:0}.ck-rounded-corners .ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status,.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{background:var(--ck-color-base-error);color:var(--ck-color-base-background);padding:var(--ck-spacing-small) var(--ck-spacing-medium);min-width:var(--ck-table-properties-min-error-width);text-align:center}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{border-left:var(--ck-table-properties-error-arrow-size) solid transparent;border-bottom:var(--ck-table-properties-error-arrow-size) solid var(--ck-color-base-error);border-right:var(--ck-table-properties-error-arrow-size) solid transparent;border-top:0 solid transparent}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{animation:ck-table-form-labeled-view-status-appear .15s ease both}.ck.ck-table-form .ck.ck-labeled-field-view .ck-input.ck-error:not(:focus)+.ck.ck-labeled-field-view__status{display:none}@keyframes ck-table-form-labeled-view-status-appear{0%{opacity:0}to{opacity:1}}'},function(e,t,o){var n=o(5),i=o(26);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row{flex-wrap:wrap}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:first-of-type{flex-grow:0.57}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:last-of-type{flex-grow:0.43}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar .ck-button{flex-grow:1}.ck.ck-table-cell-properties-form{width:320px}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__padding-row{align-self:flex-end;padding:0;width:25%}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}"},function(e,t){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch(e){"object"==typeof window&&(o=window)}e.exports=o},function(e,t,o){var n=o(5),i=o(29);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{flex-wrap:wrap;flex-basis:0;align-content:baseline}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items{flex-wrap:nowrap}.ck.ck-table-properties-form{width:320px}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{align-self:flex-end;padding:0}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items>*{width:40px}"},function(e,t,o){var n=o(5),i=o(31);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=":root{--ck-color-table-caption-background:#f7f7f7;--ck-color-table-caption-text:#333;--ck-color-table-caption-highlighted-background:#fd0}.ck-content .table>figcaption{display:table-caption;caption-side:top;word-break:break-word;text-align:center;color:var(--ck-color-table-caption-text);background-color:var(--ck-color-table-caption-background);padding:.6em;font-size:.75em;outline-offset:-1px}.ck.ck-editor__editable .table>figcaption.table__caption_highlighted{animation:ck-table-caption-highlight .6s ease-out}.ck.ck-editor__editable .table>figcaption.ck-placeholder:before{padding-left:inherit;padding-right:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes ck-table-caption-highlight{0%{background-color:var(--ck-color-table-caption-highlighted-background)}to{background-color:var(--ck-color-table-caption-background)}}"},function(e,t,o){"use strict";o.r(t),o.d(t,"Table",(function(){return Fe})),o.d(t,"TableEditing",(function(){return ye})),o.d(t,"TableUI",(function(){return Se})),o.d(t,"TableToolbar",(function(){return Ue})),o.d(t,"TableCellProperties",(function(){return po})),o.d(t,"TableCellPropertiesEditing",(function(){return mo})),o.d(t,"TableCellPropertiesUI",(function(){return Jt})),o.d(t,"TableProperties",(function(){return Oo})),o.d(t,"TablePropertiesEditing",(function(){return Vo})),o.d(t,"TablePropertiesUI",(function(){return Bo})),o.d(t,"TableCaption",(function(){return jo})),o.d(t,"TableCaptionEditing",(function(){return Do})),o.d(t,"TableCaptionUI",(function(){return Wo})),o.d(t,"TableClipboard",(function(){return Pe})),o.d(t,"TableMouse",(function(){return Me})),o.d(t,"TableKeyboard",(function(){return Le})),o.d(t,"TableSelection",(function(){return Ie})),o.d(t,"TableUtils",(function(){return te}));var n=o(1),i=o(3);function r(e,t,o,n,i=1){t>i?n.setAttribute(e,t,o):n.removeAttribute(e,o)}function l(e,t,o={}){const n=e.createElement("tableCell",o);return e.insertElement("paragraph",n),e.insert(n,t),n}function s(e,t){const o=t.parent.parent,n=parseInt(o.getAttribute("headingColumns")||0),{column:i}=e.getCellLocation(t);return!!n&&i<n}var a=o(2);function c(){return e=>{e.on("element:table",(e,t,o)=>{const n=t.viewItem;if(!o.consumable.test(n,{name:!0}))return;const{rows:i,headingRows:r,headingColumns:s}=function(e){const t={headingRows:0,headingColumns:0},o=[],n=[];let i;for(const r of Array.from(e.getChildren()))if("tbody"===r.name||"thead"===r.name||"tfoot"===r.name){"thead"!==r.name||i||(i=r);const e=Array.from(r.getChildren()).filter(e=>e.is("element","tr"));for(const r of e)if("thead"===r.parent.name&&r.parent===i)t.headingRows++,o.push(r);else{n.push(r);const e=u(r);e>t.headingColumns&&(t.headingColumns=e)}}return t.rows=[...o,...n],t}(n),a={};s&&(a.headingColumns=s),r&&(a.headingRows=r);const c=o.writer.createElement("table",a);if(o.safeInsert(c,t.modelCursor)){if(o.consumable.consume(n,{name:!0}),i.forEach(e=>o.convertItem(e,o.writer.createPositionAt(c,"end"))),o.convertChildren(n,o.writer.createPositionAt(c,"end")),c.isEmpty){const e=o.writer.createElement("tableRow");o.writer.insert(e,o.writer.createPositionAt(c,"end")),l(o.writer,o.writer.createPositionAt(e,"end"))}o.updateConversionResult(c,t)}})}}function d(e){return t=>{t.on("element:"+e,(e,t,o)=>{if(t.modelRange&&t.viewItem.isEmpty){const e=t.modelRange.start.nodeAfter,n=o.writer.createPositionAt(e,0);o.writer.insertElement("paragraph",n)}},{priority:"low"})}}function u(e){let t=0,o=0;const n=Array.from(e.getChildren()).filter(e=>"th"===e.name||"td"===e.name);for(;o<n.length&&"th"===n[o].name;){const e=n[o];t+=parseInt(e.getAttribute("colspan")||1),o++}return t}class h{constructor(e,t={}){this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?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(){const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const o=this._getSpanned();if(o)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(o.cell,o.row,o.column));else{const o=e.getChild(this._cellIndex);if(!o)return this._advanceToNextRow();const n=parseInt(o.getAttribute("colspan")||1),i=parseInt(o.getAttribute("rowspan")||1);(n>1||i>1)&&this._recordSpans(o,i,n),this._shouldSkipSlot()||(t=this._formatOutValue(o)),this._nextCellAtColumn=this._column+n}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 void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,o=this._column){return{done:!1,value:new b(this,e,t,o)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,o=this._column<this._startColumn,n=void 0!==this._endColumn&&this._column>this._endColumn;return e||t||o||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,o){const n={cell:e,row:this._row,column:this._column};for(let e=this._row;e<this._row+t;e++)for(let t=this._column;t<this._column+o;t++)e==this._row&&t==this._column||this._markSpannedCell(e,t,n)}_markSpannedCell(e,t,o){this._spannedCells.has(e)||this._spannedCells.set(e,new Map);this._spannedCells.get(e).set(t,o)}}class b{constructor(e,t,o,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=o,this.cellAnchorColumn=n,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 m(e={}){return t=>t.on("insert:table",(t,o,n)=>{const r=o.item;if(!n.consumable.consume(r,"insert"))return;n.consumable.consume(r,"attribute:headingRows:table"),n.consumable.consume(r,"attribute:headingColumns:table");const l=e&&e.asWidget,s=n.writer.createContainerElement("figure",{class:"table"}),a=n.writer.createContainerElement("table");let c;var d,u;n.writer.insert(n.writer.createPositionAt(s,0),a),l&&(d=s,(u=n.writer).setCustomProperty("table",!0,d),c=Object(i.toWidget)(d,u,{hasSelectionHandle:!0}));const b=new h(r),m={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0},g=new Map;for(const t of b){const{row:o,cell:i}=t,l=r.getChild(o),s=g.get(o)||_(a,l,o,m,n);g.set(o,s),n.consumable.consume(i,"insert");w(t,m,n.writer.createPositionAt(s,"end"),n,e)}for(const e of r.getChildren()){const t=e.index;e.is("element","tableRow")&&!g.has(t)&&g.set(t,_(a,e,t,m,n))}const p=n.mapper.toViewPosition(o.range.start);n.mapper.bindElements(r,l?c:s),n.writer.insert(p,l?c:s)})}function g(e,t){const{writer:o}=t;if(e.parent.is("element","tableCell"))return p(e)?o.createContainerElement("span",{class:"ck-table-bogus-paragraph"}):o.createContainerElement("p")}function p(e){return 1===e.parent.childCount&&!y(e)}function f(e,t,o){const{cell:n}=e,r=k(e,t),l=o.mapper.toViewElement(n);l&&l.name!==r&&function(e,t,o){const n=o.writer,r=o.mapper.toViewElement(e),l=n.createEditableElement(t,r.getAttributes()),s=Object(i.toWidgetEditable)(l,n);Object(i.setHighlightHandling)(s,n,(e,t,o)=>o.addClass(Object(a.toArray)(t.classes),e),(e,t,o)=>o.removeClass(Object(a.toArray)(t.classes),e)),n.insert(n.createPositionAfter(r),s),n.move(n.createRangeIn(r),n.createPositionAt(s,0)),n.remove(n.createRangeOn(r)),o.mapper.unbindViewElement(r),o.mapper.bindElements(e,s)}(n,r,o)}function w(e,t,o,n,r){const l=r&&r.asWidget,s=k(e,t),c=l?Object(i.toWidgetEditable)(n.writer.createEditableElement(s),n.writer):n.writer.createContainerElement(s);l&&Object(i.setHighlightHandling)(c,n.writer,(e,t,o)=>o.addClass(Object(a.toArray)(t.classes),e),(e,t,o)=>o.removeClass(Object(a.toArray)(t.classes),e));const d=e.cell,u=d.getChild(0),h=1===d.childCount&&"paragraph"===u.name;if(n.writer.insert(o,c),n.mapper.bindElements(d,c),!l&&h&&!y(u)){const e=d.getChild(0);n.consumable.consume(e,"insert"),n.mapper.bindElements(e,c)}}function _(e,t,o,n,i){i.consumable.consume(t,"insert");const r=t.isEmpty?i.writer.createEmptyElement("tr"):i.writer.createContainerElement("tr");i.mapper.bindElements(t,r);const l=n.headingRows,s=function(e,t,o){const n=v(e,t);return n||function(e,t,o){const n=o.writer.createContainerElement(e),i=o.writer.createPositionAt(t,"tbody"==e?"end":0);return o.writer.insert(i,n),n}(e,t,o)}(function(e,t){return e<t.headingRows?"thead":"tbody"}(o,n),e,i),a=l>0&&o>=l?o-l:o,c=i.writer.createPositionAt(s,a);return i.writer.insert(c,r),r}function k(e,t){const{row:o,column:n}=e,{headingColumns:i,headingRows:r}=t;if(r&&r>o)return"th";return i&&i>n?"th":"td"}function v(e,t){for(const o of t.getChildren())if(o.name==e)return o}function C(e,t,o){const n=v(e,t);n&&0===n.childCount&&o.writer.remove(o.writer.createRangeOn(n))}function y(e){return!![...e.getAttributeKeys()].length}class T extends n.Command{refresh(){const e=this.editor.model,t=e.document.selection,o=e.schema;this.isEnabled=function(e,t){const o=e.getFirstPosition().parent,n=o===o.root?o:o.parent;return t.checkChild(n,"table")}(t,o)}execute(e={}){const t=this.editor.model,o=t.document.selection,n=this.editor.plugins.get("TableUtils"),r=this.editor.config.get("table"),l=Object(i.findOptimalInsertionRange)(o,t),s=r.defaultHeadings.rows,a=r.defaultHeadings.columns;void 0===e.headingRows&&s&&(e.headingRows=s),void 0===e.headingColumns&&a&&(e.headingColumns=a),t.change(o=>{const i=n.createTable(o,e);t.insertContent(i,l),o.setSelection(o.createPositionAt(i.getNodeByPath([0,0,0]),0))})}}function x(e){const t=[];for(const o of P(e.getRanges())){const e=o.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}function A(e){const t=[];for(const o of e.getRanges()){const e=o.start.findAncestor("tableCell");e&&t.push(e)}return t}function V(e){const t=x(e);return t.length?t:A(e)}function S(e){return E(e.map(e=>e.parent.index))}function R(e){const t=e[0].findAncestor("table");return E([...new h(t)].filter(t=>e.includes(t.cell)).map(e=>e.column))}function I(e,t){if(e.length<2||!function(e){const t=e[0].findAncestor("table"),o=S(e),n=parseInt(t.getAttribute("headingRows")||0);if(!O(o,n))return!1;const i=parseInt(t.getAttribute("headingColumns")||0);return O(R(e),i)}(e))return!1;const o=new Set,n=new Set;let i=0;for(const r of e){const{row:e,column:l}=t.getCellLocation(r),s=parseInt(r.getAttribute("rowspan")||1),a=parseInt(r.getAttribute("colspan")||1);o.add(e),n.add(l),s>1&&o.add(e+s-1),a>1&&n.add(l+a-1),i+=s*a}return function(e,t){const o=Array.from(e.values()),n=Array.from(t.values()),i=Math.max(...o),r=Math.min(...o),l=Math.max(...n),s=Math.min(...n);return(i-r+1)*(l-s+1)}(o,n)==i}function P(e){return Array.from(e).sort(B)}function E(e){const t=e.sort((e,t)=>e-t);return{first:t[0],last:t[t.length-1]}}function B(e,t){const o=e.start,n=t.start;return o.isBefore(n)?-1:1}function O({first:e,last:t},o){return e<o===t<o}class L extends n.Command{constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=!!V(this.editor.model.document.selection).length;this.isEnabled=e}execute(){const e=this.editor,t=e.model.document.selection,o=e.plugins.get("TableUtils"),n="above"===this.order,i=V(t),r=S(i),l=n?r.first:r.last,s=i[0].findAncestor("table");o.insertRows(s,{at:n?l:l+1,copyStructureFromAbove:!n})}}class N extends n.Command{constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=!!V(this.editor.model.document.selection).length;this.isEnabled=e}execute(){const e=this.editor,t=e.model.document.selection,o=e.plugins.get("TableUtils"),n="left"===this.order,i=V(t),r=R(i),l=n?r.first:r.last,s=i[0].findAncestor("table");o.insertColumns(s,{columns:1,at:n?l:l+1})}}class z extends n.Command{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=V(this.editor.model.document.selection)[0],t="horizontally"===this.direction,o=this.editor.plugins.get("TableUtils");t?o.splitCellHorizontally(e,2):o.splitCellVertically(e,2)}}function M(e,t,o){const{startRow:n,startColumn:i,endRow:s,endColumn:a}=t,c=o.createElement("table"),d=s-n+1;for(let e=0;e<d;e++)o.insertElement("tableRow",c,"end");const u=[...new h(e,{startRow:n,endRow:s,startColumn:i,endColumn:a,includeAllSlots:!0})];for(const{row:e,column:t,cell:r,isAnchor:d,cellAnchorRow:h,cellAnchorColumn:b}of u){const u=e-n,m=c.getChild(u);if(d){const n=o.cloneElement(r);o.append(n,m),j(n,e,t,s,a,o)}else(h<n||b<i)&&l(o,o.createPositionAt(m,"end"))}return function(e,t,o,n,i){const l=parseInt(t.getAttribute("headingRows")||0);if(l>0){r("headingRows",l-o,e,i,0)}const s=parseInt(t.getAttribute("headingColumns")||0);if(s>0){r("headingColumns",s-n,e,i,0)}}(c,e,n,i,o),c}function H(e,t,o=0){const n=[],i=new h(e,{startRow:o,endRow:t-1});for(const e of i){const{row:o,cellHeight:i}=e,r=o+i-1;o<t&&t<=r&&n.push(e)}return n}function F(e,t,o){const n=e.parent,i=n.parent,s=n.index,a=t-s,c={},d=parseInt(e.getAttribute("rowspan"))-a;d>1&&(c.rowspan=d);const u=parseInt(e.getAttribute("colspan")||1);u>1&&(c.colspan=u);const b=s+a,m=[...new h(i,{startRow:s,endRow:b,includeAllSlots:!0})];let g,p=null;for(const t of m){const{row:n,column:i,cell:r}=t;r===e&&void 0===g&&(g=i),void 0!==g&&g===i&&n===b&&(p=l(o,t.getPositionBefore(),c))}return r("rowspan",a,e,o),p}function D(e,t){const o=[],n=new h(e);for(const e of n){const{column:n,cellWidth:i}=e,r=n+i-1;n<t&&t<=r&&o.push(e)}return o}function W(e,t,o,n){const i=o-t,s={},a=parseInt(e.getAttribute("colspan"))-i;a>1&&(s.colspan=a);const c=parseInt(e.getAttribute("rowspan")||1);c>1&&(s.rowspan=c);const d=l(n,n.createPositionAfter(e),s);return r("colspan",i,e,n),d}function j(e,t,o,n,i,l){const s=parseInt(e.getAttribute("colspan")||1),a=parseInt(e.getAttribute("rowspan")||1);if(o+s-1>i){r("colspan",i-o+1,e,l,1)}if(t+a-1>n){r("rowspan",n-t+1,e,l,1)}}function U(e,t){const o=t.getColumns(e),n=new Array(o).fill(0);for(const{column:t}of new h(e))n[t]++;const i=n.reduce((e,t,o)=>t?e:[...e,o],[]);if(i.length>0){const o=i[i.length-1];return t.removeColumns(e,{at:o}),!0}return!1}function K(e,t){const o=[],n=t.getRows(e);for(let t=0;t<n;t++){e.getChild(t).isEmpty&&o.push(t)}if(o.length>0){const n=o[o.length-1];return t.removeRows(e,{at:n}),!0}return!1}function $(e,t){U(e,t)||K(e,t)}function q(e,t){const o=Array.from(new h(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(o.every(({cellHeight:e})=>1===e))return t.lastRow;const n=o[0].cellHeight-1;return t.lastRow+n}function G(e,t){const o=Array.from(new h(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(o.every(({cellWidth:e})=>1===e))return t.lastColumn;const n=o[0].cellWidth-1;return t.lastColumn+n}class J extends n.Command{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=A(e.document.selection)[0],o=this.value,n=this.direction;e.change(e=>{const i="right"==n||"down"==n,r=i?t:o,l=i?o:t,s=l.parent;!function(e,t,o){X(e)||(X(t)&&o.remove(o.createRangeIn(t)),o.move(o.createRangeIn(e),o.createPositionAt(t,"end")));o.remove(e)}(l,r,e);const a=this.isHorizontal?"colspan":"rowspan",c=parseInt(t.getAttribute(a)||1),d=parseInt(o.getAttribute(a)||1);e.setAttribute(a,c+d,r),e.setSelection(e.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");$(s.findAncestor("table"),u)})}_getMergeableCell(){const e=A(this.editor.model.document.selection)[0];if(!e)return;const t=this.editor.plugins.get("TableUtils"),o=this.isHorizontal?function(e,t,o){const n=e.parent.parent,i="right"==t?e.nextSibling:e.previousSibling,r=(n.getAttribute("headingColumns")||0)>0;if(!i)return;const l="right"==t?e:i,a="right"==t?i:e,{column:c}=o.getCellLocation(l),{column:d}=o.getCellLocation(a),u=parseInt(l.getAttribute("colspan")||1),h=s(o,l),b=s(o,a);if(r&&h!=b)return;return c+u===d?i:void 0}(e,this.direction,t):function(e,t,o){const n=e.parent,i=n.parent,r=i.getChildIndex(n);if("down"==t&&r===o.getRows(i)-1||"up"==t&&0===r)return;const l=parseInt(e.getAttribute("rowspan")||1),s=i.getAttribute("headingRows")||0,a="down"==t&&r+l===s,c="up"==t&&r===s;if(s&&(a||c))return;const d=parseInt(e.getAttribute("rowspan")||1),u="down"==t?r+d:r,b=[...new h(i,{endRow:u})],m=b.find(t=>t.cell===e).column,g=b.find(({row:e,cellHeight:o,column:n})=>n===m&&("down"==t?e===u:u===e+o));return g&&g.cell}(e,this.direction,t);if(!o)return;const n=this.isHorizontal?"rowspan":"colspan",i=parseInt(e.getAttribute(n)||1);return parseInt(o.getAttribute(n)||1)===i?o:void 0}}function X(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}class Y extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=e[0];if(t){const o=t.findAncestor("table"),n=this.editor.plugins.get("TableUtils").getRows(o)-1,i=S(e),r=0===i.first&&i.last===n;this.isEnabled=!r}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),o=V(e.document.selection),n=S(o),i=o[0],r=i.findAncestor("table"),l=t.getCellLocation(i).column;e.change(e=>{const o=n.last-n.first+1;t.removeRows(r,{at:n.first,rows:o});const i=function(e,t,o,n){const i=e.getChild(Math.min(t,n-1));let r=i.getChild(0),l=0;for(const e of i.getChildren()){if(l>o)return r;r=e,l+=parseInt(e.getAttribute("colspan")||1)}return r}(r,n.first,l,t.getRows(r));e.setSelection(e.createPositionAt(i,0))})}}class Q extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=e[0];if(t){const o=t.findAncestor("table"),n=this.editor.plugins.get("TableUtils").getColumns(o),{first:i,last:r}=R(e);this.isEnabled=r-i<n-1}else this.isEnabled=!1}execute(){const[e,t]=function(e){const t=V(e),o=t[0],n=t.pop(),i=[o,n];return o.isBefore(n)?i:i.reverse()}(this.editor.model.document.selection),o=e.parent.parent,n=[...new h(o)],i={first:n.find(t=>t.cell===e).column,last:n.find(e=>e.cell===t).column},r=function(e,t,o,n){return parseInt(o.getAttribute("colspan")||1)>1?o:t.previousSibling||o.nextSibling?o.nextSibling||t.previousSibling:n.first?e.reverse().find(({column:e})=>e<n.first).cell:e.reverse().find(({column:e})=>e>n.last).cell}(n,e,t,i);this.editor.model.change(e=>{const t=i.last-i.first+1;this.editor.plugins.get("TableUtils").removeColumns(o,{at:i.first,columns:t}),e.setSelection(e.createPositionAt(r,0))})}}class Z extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=e.length>0;this.isEnabled=t,this.value=t&&e.every(e=>this._isInHeading(e,e.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.model,o=V(t.document.selection),n=o[0].findAncestor("table"),{first:i,last:l}=S(o),s=this.value?i:l+1,a=n.getAttribute("headingRows")||0;t.change(e=>{if(s){const t=H(n,s,s>a?a:0);for(const{cell:o}of t)F(o,s,e)}r("headingRows",s,n,e,0)})}_isInHeading(e,t){const o=parseInt(t.getAttribute("headingRows")||0);return!!o&&e.parent.index<o}}class ee extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=this.editor.plugins.get("TableUtils"),o=e.length>0;this.isEnabled=o,this.value=o&&e.every(e=>s(t,e))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.model,o=V(t.document.selection),n=o[0].findAncestor("table"),{first:i,last:l}=R(o),s=this.value?i:l+1;t.change(e=>{if(s){const t=D(n,s);for(const{cell:o,column:n}of t)W(o,n,s,e)}r("headingColumns",s,n,e,0)})}}class te extends n.Plugin{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,o=t.parent,n=o.getChildIndex(t),i=new h(o,{row:n});for(const{cell:t,row:o,column:n}of i)if(t===e)return{row:o,column:n}}createTable(e,t){const o=e.createElement("table"),n=parseInt(t.rows)||2,i=parseInt(t.columns)||2;return oe(e,o,0,n,i),t.headingRows&&r("headingRows",Math.min(t.headingRows,n),o,e,0),t.headingColumns&&r("headingColumns",Math.min(t.headingColumns,i),o,e,0),o}insertRows(e,t={}){const o=this.editor.model,n=t.at||0,i=t.rows||1,s=void 0!==t.copyStructureFromAbove,c=t.copyStructureFromAbove?n-1:n,d=this.getRows(e),u=this.getColumns(e);if(n>d)throw new a.CKEditorError("tableutils-insertrows-insert-out-of-range",this,{options:t});o.change(t=>{const o=e.getAttribute("headingRows")||0;if(o>n&&r("headingRows",o+i,e,t,0),!s&&(0===n||n===d))return void oe(t,e,n,i,u);const a=s?Math.max(n,c):n,b=new h(e,{endRow:a}),m=new Array(u).fill(1);for(const{row:e,column:o,cellHeight:r,cellWidth:l,cell:a}of b){const d=e+r-1,u=e<=c&&c<=d;e<n&&n<=d?(t.setAttribute("rowspan",r+i,a),m[o]=-l):s&&u&&(m[o]=l)}for(let o=0;o<i;o++){const o=t.createElement("tableRow");t.insert(o,e,n);for(let e=0;e<m.length;e++){const n=m[e],i=t.createPositionAt(o,"end");n>0&&l(t,i,n>1?{colspan:n}:null),e+=Math.abs(n)-1}}})}insertColumns(e,t={}){const o=this.editor.model,n=t.at||0,i=t.columns||1;o.change(t=>{const o=e.getAttribute("headingColumns");n<o&&t.setAttribute("headingColumns",o+i,e);const r=this.getColumns(e);if(0===n||r===n){for(const o of e.getChildren())o.is("element","tableRow")&&ne(i,t,t.createPositionAt(o,n?"end":0));return}const l=new h(e,{column:n,includeAllSlots:!0});for(const e of l){const{row:o,cell:r,cellAnchorColumn:s,cellAnchorRow:a,cellWidth:c,cellHeight:d}=e;if(s<n){t.setAttribute("colspan",c+i,r);const e=a+d-1;for(let t=o;t<=e;t++)l.skipRow(t)}else ne(i,t,e.getPositionBefore())}})}removeRows(e,t){const o=this.editor.model,n=t.rows||1,i=this.getRows(e),l=t.at,s=l+n-1;if(s>i-1)throw new a.CKEditorError("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});o.change(t=>{const{cellsToMove:o,cellsToTrim:n}=function(e,t,o){const n=new Map,i=[];for(const{row:r,column:l,cellHeight:s,cell:a}of new h(e,{endRow:o})){const e=r+s-1;if(r>=t&&r<=o&&e>o){const e=s-(o-r+1);n.set(l,{cell:a,rowspan:e})}if(r<t&&e>=t){let n;n=e>=o?o-t+1:e-t+1,i.push({cell:a,rowspan:s-n})}}return{cellsToMove:n,cellsToTrim:i}}(e,l,s);if(o.size){!function(e,t,o,n){const i=[...new h(e,{includeAllSlots:!0,row:t})],l=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:a}of i)if(o.has(e)){const{cell:t,rowspan:i}=o.get(e),a=s?n.createPositionAfter(s):n.createPositionAt(l,0);n.move(n.createRangeOn(t),a),r("rowspan",i,t,n),s=t}else a&&(s=t)}(e,s+1,o,t)}for(let o=s;o>=l;o--)t.remove(e.getChild(o));for(const{rowspan:e,cell:o}of n)r("rowspan",e,o,t);!function(e,t,o,n){const i=e.getAttribute("headingRows")||0;if(t<i){r("headingRows",o<i?i-(o-t+1):t,e,n,0)}}(e,l,s,t),U(e,this)||K(e,this)})}removeColumns(e,t){const o=this.editor.model,n=t.at,i=t.columns||1,l=t.at+i-1;o.change(t=>{!function(e,t,o){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const i=Math.min(n-1,t.last)-t.first+1;o.setAttribute("headingColumns",n-i,e)}}(e,{first:n,last:l},t);for(let o=l;o>=n;o--)for(const{cell:n,column:i,cellWidth:l}of[...new h(e)])i<=o&&l>1&&i+l>o?r("colspan",l-1,n,t):i===o&&t.remove(n);K(e,this)||U(e,this)})}splitCellVertically(e,t=2){const o=this.editor.model,n=e.parent.parent,i=parseInt(e.getAttribute("rowspan")||1),l=parseInt(e.getAttribute("colspan")||1);o.change(o=>{if(l>1){const{newCellsSpan:n,updatedSpan:s}=ie(l,t);r("colspan",s,e,o);const a={};n>1&&(a.colspan=n),i>1&&(a.rowspan=i);ne(l>t?t-1:l-1,o,o.createPositionAfter(e),a)}if(l<t){const s=t-l,a=[...new h(n)],{column:c}=a.find(({cell:t})=>t===e),d=a.filter(({cell:t,cellWidth:o,column:n})=>t!==e&&n===c||n<c&&n+o>c);for(const{cell:e,cellWidth:t}of d)o.setAttribute("colspan",t+s,e);const u={};i>1&&(u.rowspan=i),ne(s,o,o.createPositionAfter(e),u);const b=n.getAttribute("headingColumns")||0;b>c&&r("headingColumns",b+s,n,o)}})}splitCellHorizontally(e,t=2){const o=this.editor.model,n=e.parent,i=n.parent,l=i.getChildIndex(n),s=parseInt(e.getAttribute("rowspan")||1),a=parseInt(e.getAttribute("colspan")||1);o.change(o=>{if(s>1){const n=[...new h(i,{startRow:l,endRow:l+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:d}=ie(s,t);r("rowspan",d,e,o);const{column:u}=n.find(({cell:t})=>t===e),b={};c>1&&(b.rowspan=c),a>1&&(b.colspan=a);for(const e of n){const{column:t,row:n}=e,i=t===u,r=(n+l+d)%c==0;n>=l+d&&i&&r&&ne(1,o,e.getPositionBefore(),b)}}if(s<t){const n=t-s,c=[...new h(i,{startRow:0,endRow:l})];for(const{cell:t,cellHeight:i,row:r}of c)if(t!==e&&r+i>l){const e=i+n;o.setAttribute("rowspan",e,t)}const d={};a>1&&(d.colspan=a),oe(o,i,l+1,n,1,d);const u=i.getAttribute("headingRows")||0;u>l&&r("headingRows",u+n,i,o)}})}getColumns(e){return[...e.getChild(0).getChildren()].reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||1),0)}getRows(e){return Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0)}}function oe(e,t,o,n,i,r={}){for(let l=0;l<n;l++){const n=e.createElement("tableRow");e.insert(n,t,o),ne(i,e,e.createPositionAt(n,"end"),r)}}function ne(e,t,o,n={}){for(let i=0;i<e;i++)l(t,o,n)}function ie(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const o=Math.floor(e/t);return{newCellsSpan:o,updatedSpan:e-o*t+o}}class re extends n.Command{refresh(){const e=x(this.editor.model.document.selection);this.isEnabled=I(e,this.editor.plugins.get(te))}execute(){const e=this.editor.model,t=this.editor.plugins.get(te);e.change(o=>{const n=x(e.document.selection),i=n.shift(),{mergeWidth:l,mergeHeight:s}=function(e,t,o){let n=0,i=0;for(const e of t){const{row:t,column:r}=o.getCellLocation(e);n=ae(e,r,n,"colspan"),i=ae(e,t,i,"rowspan")}const{row:r,column:l}=o.getCellLocation(e);return{mergeWidth:n-l,mergeHeight:i-r}}(i,n,t);r("colspan",l,i,o),r("rowspan",s,i,o);for(const e of n)le(e,i,o);$(i.findAncestor("table"),t),o.setSelection(i,"in")})}}function le(e,t,o){se(e)||(se(t)&&o.remove(o.createRangeIn(t)),o.move(o.createRangeIn(e),o.createPositionAt(t,"end"))),o.remove(e)}function se(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}function ae(e,t,o,n){const i=parseInt(e.getAttribute(n)||1);return Math.max(o,t+i)}class ce extends n.Command{refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=V(e.document.selection),o=S(t),n=t[0].findAncestor("table"),i=[];for(let t=o.first;t<=o.last;t++)for(const o of n.getChild(t).getChildren())i.push(e.createRangeOn(o));e.change(e=>{e.setSelection(i)})}}class de extends n.Command{refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=V(e.document.selection),o=t[0],n=t.pop(),i=o.findAncestor("table"),r=this.editor.plugins.get("TableUtils"),l=r.getCellLocation(o),s=r.getCellLocation(n),a=Math.min(l.column,s.column),c=Math.max(l.column,s.column),d=[];for(const t of new h(i,{startColumn:a,endColumn:c}))d.push(e.createRangeOn(t.cell));e.change(e=>{e.setSelection(d)})}}function ue(e){e.document.registerPostFixer(t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;const i=new Set;for(const t of o){let o;"table"==t.name&&"insert"==t.type&&(o=t.position.nodeAfter),"tableRow"!=t.name&&"tableCell"!=t.name||(o=t.position.findAncestor("table")),me(t)&&(o=t.range.start.findAncestor("table")),o&&!i.has(o)&&(n=he(o,e)||n,n=be(o,e)||n,i.add(o))}return n}(t,e))}function he(e,t){let o=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||0),o=Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0),n=[];for(const{row:i,cell:r,cellHeight:l}of new h(e)){if(l<2)continue;const e=i<t?t:o;if(i+l>e){const t=e-i;n.push({cell:r,rowspan:t})}}return n}(e);if(n.length){o=!0;for(const e of n)r("rowspan",e.rowspan,e.cell,t,1)}return o}function be(e,t){let o=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:o}of new h(e,{includeAllSlots:!0}))t[o]++;return t}(e),i=[];for(const[t,o]of n.entries())!o&&e.getChild(t).is("element","tableRow")&&i.push(t);if(i.length){o=!0;for(const o of i.reverse())t.remove(e.getChild(o)),n.splice(o,1)}const r=n.filter((t,o)=>e.getChild(o).is("element","tableRow")),s=r[0];if(!r.every(e=>e===s)){const n=r.reduce((e,t)=>t>e?t:e,0);for(const[i,s]of r.entries()){const r=n-s;if(r){for(let o=0;o<r;o++)l(t,t.createPositionAt(e.getChild(i),"end"));o=!0}}}return o}function me(e){const t="attribute"===e.type,o=e.attributeKey;return t&&("headingRows"===o||"colspan"===o||"rowspan"===o)}function ge(e){e.document.registerPostFixer(t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o)"insert"==t.type&&"table"==t.name&&(n=pe(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=fe(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=we(t.position.nodeAfter,e)||n),_e(t)&&(n=we(t.position.parent,e)||n);return n}(t,e))}function pe(e,t){let o=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(o=fe(n,t)||o);return o}function fe(e,t){let o=!1;for(const n of e.getChildren())o=we(n,t)||o;return o}function we(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const o=Array.from(e.getChildren()).filter(e=>e.is("$text"));for(const e of o)t.wrap(t.createRangeOn(e),"paragraph");return!!o.length}function _e(e){return!(!e.position||!e.position.parent.is("element","tableCell"))&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function ke(e,t){e.document.registerPostFixer(()=>function(e,t){const o=new Set;for(const t of e.getChanges()){const e="attribute"==t.type?t.range.start.parent:t.position.parent;e.is("element","tableCell")&&o.add(e)}for(const n of o.values())for(const o of[...n.getChildren()].filter(e=>ve(e,t)))e.refreshItem(o);return!1}(e.document.differ,t))}function ve(e,t){if(!e.is("element","paragraph"))return!1;const o=t.toViewElement(e);return!!o&&p(e)!==o.is("element","span")}function Ce(e){e.document.registerPostFixer(()=>function(e){const t=e.document.differ,o=new Set;for(const e of t.getChanges()){if("attribute"!=e.type)continue;const t=e.range.start.nodeAfter;t&&t.is("element","table")&&"headingRows"==e.attributeKey&&o.add(t)}if(o.size){for(const e of o.values())t.refreshItem(e);return!0}return!1}(e))}o(11);class ye extends n.Plugin{static get pluginName(){return"TableEditing"}init(){const e=this.editor,t=e.model,o=t.schema,n=e.conversion;o.register("table",{allowWhere:"$block",allowAttributes:["headingRows","headingColumns"],isObject:!0,isBlock:!0}),o.register("tableRow",{allowIn:"table",isLimit:!0}),o.register("tableCell",{allowIn:"tableRow",allowChildren:"$block",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add(e=>{e.on("element:figure",(e,t,o)=>{if(!o.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!n||!o.consumable.test(n,{name:!0}))return;const i=o.convertItem(n,t.modelCursor),r=Object(a.first)(i.modelRange.getItems());r&&(o.convertChildren(t.viewItem,o.writer.createPositionAt(r,"end")),o.updateConversionResult(r,t))})}),n.for("upcast").add(c()),n.for("editingDowncast").add(m({asWidget:!0})),n.for("dataDowncast").add(m()),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add(e=>{e.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()},{priority:"high"})}),n.for("editingDowncast").add(e=>e.on("insert:tableRow",(e,t,o)=>{const n=t.item;if(!o.consumable.consume(n,"insert"))return;const i=n.parent,r=function(e){for(const t of e.getChildren())if("table"===t.name)return t}(o.mapper.toViewElement(i)),l=i.getChildIndex(n),s=new h(i,{row:l}),a={headingRows:i.getAttribute("headingRows")||0,headingColumns:i.getAttribute("headingColumns")||0},c=new Map;for(const e of s){const t=c.get(l)||_(r,n,l,a,o);c.set(l,t),o.consumable.consume(e.cell,"insert"),w(e,a,o.writer.createPositionAt(t,"end"),o,{asWidget:!0})}})),n.for("editingDowncast").add(e=>e.on("remove:tableRow",(e,t,o)=>{e.stop();const n=o.writer,i=o.mapper,r=i.toViewPosition(t.position).getLastMatchingPosition(e=>!e.item.is("element","tr")).nodeAfter,l=r.parent.parent,s=n.createRangeOn(r),a=n.remove(s);for(const e of n.createRangeIn(a).getItems())i.unbindViewElement(e);C("thead",l,o),C("tbody",l,o)},{priority:"higher"})),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(d("td")),n.for("upcast").add(d("th")),n.for("editingDowncast").add(e=>e.on("insert:tableCell",(e,t,o)=>{const n=t.item;if(!o.consumable.consume(n,"insert"))return;const i=n.parent,r=i.parent,l=r.getChildIndex(i),s=new h(r,{row:l}),a={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0};for(const e of s)if(e.cell===n){const t=o.mapper.toViewElement(i);return void w(e,a,o.writer.createPositionAt(t,i.getChildIndex(n)),o,{asWidget:!0})}})),n.for("editingDowncast").elementToElement({model:"paragraph",view:g,converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:Te("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Te("rowspan")},view:"rowspan"}),n.for("editingDowncast").add(e=>e.on("attribute:headingColumns:table",(e,t,o)=>{const n=t.item;if(!o.consumable.consume(t.item,e.name))return;const i={headingRows:n.getAttribute("headingRows")||0,headingColumns:n.getAttribute("headingColumns")||0},r=t.attributeOldValue,l=t.attributeNewValue,s=(r>l?r:l)-1;for(const e of new h(n,{endColumn:s}))f(e,i,o)})),e.data.mapper.on("modelToViewPosition",(e,t)=>{const o=t.modelPosition.parent,n=t.modelPosition.nodeBefore;if(!o.is("element","tableCell"))return;if(!n||!n.is("element","paragraph"))return;const i=t.mapper.toViewElement(n),r=t.mapper.toViewElement(o);i===r&&(t.viewPosition=t.mapper.findPositionIn(r,n.maxOffset))}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new T(e)),e.commands.add("insertTableRowAbove",new L(e,{order:"above"})),e.commands.add("insertTableRowBelow",new L(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new N(e,{order:"left"})),e.commands.add("insertTableColumnRight",new N(e,{order:"right"})),e.commands.add("removeTableRow",new Y(e)),e.commands.add("removeTableColumn",new Q(e)),e.commands.add("splitTableCellVertically",new z(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new z(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new re(e)),e.commands.add("mergeTableCellRight",new J(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new J(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new J(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new J(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new ee(e)),e.commands.add("setTableRowHeader",new Z(e)),e.commands.add("selectTableRow",new ce(e)),e.commands.add("selectTableColumn",new de(e)),Ce(t),ue(t),ke(t,e.editing.mapper),ge(t)}static get requires(){return[te]}}function Te(e){return t=>{const o=parseInt(t.getAttribute(e));return Number.isNaN(o)||o<=0?null:o}}var xe=o(0);o(13);class Ae extends xe.View{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(e,t)=>`${t} × ${e}`),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-insert-table-dropdown__label"]},children:[{text:t.to("label")}]}],on:{mousedown:t.to(e=>{e.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(e,t)=>{const{row:o,column:n}=t.target.dataset;this.set({rows:parseInt(o),columns:parseInt(n)})}),this.on("change:columns",()=>{this._highlightGridBoxes()}),this.on("change:rows",()=>{this._highlightGridBoxes()})}focus(){}focusLast(){}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((o,n)=>{const i=Math.floor(n/10)<e&&n%10<t;o.set("isOn",i)})}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const o=Math.floor(t/10),n=t%10;e.push(new Ve(this.locale,o+1,n+1))}return this.createCollection(e)}}class Ve extends xe.View{constructor(e,t,o){super(e);const n=this.bindTemplate;this.set("isOn",!1),this.setTemplate({tag:"div",attributes:{class:["ck-insert-table-dropdown-grid-box",n.if("isOn","ck-on")],"data-row":t,"data-column":o}})}}class Se extends n.Plugin{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,o="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",o=>{const n=e.commands.get("insertTable"),i=Object(xe.createDropdown)(o);let r;return i.bind("isEnabled").to(n),i.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',label:t("Insert table"),tooltip:!0}),i.on("change:isOpen",()=>{r||(r=new Ae(o),i.panelView.children.add(r),r.delegate("execute").to(i),i.buttonView.on("open",()=>{r.rows=0,r.columns=0}),i.on("execute",()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()}))}),i}),e.ui.componentFactory.add("tableColumn",e=>{const n=[{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"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',n,e)}),e.ui.componentFactory.add("tableRow",e=>{const o=[{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"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',o,e)}),e.ui.componentFactory.add("mergeTableCells",e=>{const n=[{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"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',n,e)})}_prepareDropdown(e,t,o,n){const i=this.editor,r=Object(xe.createDropdown)(n),l=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(l,"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(r,"execute",e=>{i.execute(e.source.commandName),i.editing.view.focus()}),r}_prepareMergeSplitButtonDropdown(e,t,o,n){const i=this.editor,r=Object(xe.createDropdown)(n,xe.SplitButtonView),l=i.commands.get("mergeTableCells"),s=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([l,...s],"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(r.buttonView,"execute",()=>{i.execute("mergeTableCells"),i.editing.view.focus()}),this.listenTo(r,"execute",e=>{i.execute(e.source.commandName),i.editing.view.focus()}),r}_fillDropdownWithListOptions(e,t){const o=this.editor,n=[],i=new a.Collection;for(const e of t)Re(e,o,n,i);return Object(xe.addListToDropdown)(e,i,o.ui.componentFactory),n}}function Re(e,t,o,n){const i=e.model=new xe.Model(e.model),{commandName:r,bindIsOn:l}=e.model;if("button"===e.type||"switchbutton"===e.type){const e=t.commands.get(r);o.push(e),i.set({commandName:r}),i.bind("isEnabled").to(e),l&&i.bind("isOn").to(e,"value")}i.set({withText:!0}),n.add(e)}o(15);class Ie extends n.Plugin{static get pluginName(){return"TableSelection"}static get requires(){return[te]}init(){const e=this.editor.model;this.listenTo(e,"deleteContent",(e,t)=>this._handleDeleteContent(e,t),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=x(this.editor.model.document.selection);return 0==e.length?null:e}getSelectionAsFragment(){const e=this.getSelectedTableCells();return e?this.editor.model.change(t=>{const o=t.createDocumentFragment(),n=this.editor.plugins.get("TableUtils"),{first:i,last:r}=R(e),{first:l,last:s}=S(e),a=e[0].findAncestor("table");let c=s,d=r;if(I(e,n)){const e={firstColumn:i,lastColumn:r,firstRow:l,lastRow:s};c=q(a,e),d=G(a,e)}const u=M(a,{startRow:l,startColumn:i,endRow:c,endColumn:d},t);return t.insert(u,o,0),o}):null}setCellSelection(e,t){const o=this._getCellsToSelect(e,t);this.editor.model.change(e=>{e.setSelection(o.cells.map(t=>e.createRangeOn(t)),{backward:o.backward})})}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=this.editor.model.document.selection,t=Object(a.first)(e.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(e=>e.on("selection",(e,o,n)=>{const i=n.writer;!function(e){for(const o of t)e.removeClass("ck-editor__editable_selected",o);t.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const o=n.mapper.toViewElement(e);i.addClass("ck-editor__editable_selected",o),t.add(o)}const l=n.mapper.toViewElement(r[r.length-1]);i.setSelection(l,0)},{priority:"lowest"}))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(o=>{const n=o.createPositionAt(t[0],0),i=e.model.schema.getNearestSelectionRange(n);o.setSelection(i)})}})}_handleDeleteContent(e,t){const[o,n]=t,i=this.editor.model,r=!n||"backward"==n.direction,l=x(o);l.length&&(e.stop(),i.change(e=>{const t=l[r?l.length-1:0];i.change(e=>{for(const t of l)i.deleteContent(e.createSelection(t,"in"))});const n=i.schema.getNearestSelectionRange(e.createPositionAt(t,0));o.is("documentSelection")?e.setSelection(n):o.setTo(n)}))}_getCellsToSelect(e,t){const o=this.editor.plugins.get("TableUtils"),n=o.getCellLocation(e),i=o.getCellLocation(t),r=Math.min(n.row,i.row),l=Math.max(n.row,i.row),s=Math.min(n.column,i.column),a=Math.max(n.column,i.column),c=new Array(l-r+1).fill(null).map(()=>[]),d={startRow:r,endRow:l,startColumn:s,endColumn:a};for(const{row:t,cell:o}of new h(e.findAncestor("table"),d))c[t-r].push(o);const u=i.row<n.row,b=i.column<n.column;return u&&c.reverse(),b&&c.forEach(e=>e.reverse()),{cells:c.flat(),backward:u||b}}}class Pe extends n.Plugin{static get pluginName(){return"TableClipboard"}static get requires(){return[Ie,te]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",(e,t)=>this._onCopyCut(e,t)),this.listenTo(t,"cut",(e,t)=>this._onCopyCut(e,t)),this.listenTo(e.model,"insertContent",(e,t)=>this._onInsertContent(e,...t),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const o=this.editor.plugins.get(Ie);if(!o.getSelectedTableCells())return;if("cut"==e.name&&this.editor.isReadOnly)return;t.preventDefault(),e.stop();const n=this.editor.data,i=this.editor.editing.view.document,r=n.toView(o.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,o){if(o&&!o.is("documentSelection"))return;const n=this.editor.model,i=this.editor.plugins.get(te);let r=function(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const o=t.createRangeIn(e);for(const e of o.getItems())if(e.is("element","table")){const n=t.createRange(o.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const i=t.createRange(t.createPositionAfter(e),o.end);return t.hasContent(i,{ignoreWhitespaces:!0})?null:e}return null}(t,n);if(!r)return;const l=V(n.document.selection);l.length?(e.stop(),n.change(e=>{const t={width:i.getColumns(r),height:i.getRows(r)},o=function(e,t,o,n){const i=e[0].findAncestor("table"),r=R(e),l=S(e),s={firstColumn:r.first,lastColumn:r.last,firstRow:l.first,lastRow:l.last},a=1===e.length;a&&(s.lastRow+=t.height-1,s.lastColumn+=t.width-1,function(e,t,o,n){const i=n.getColumns(e),r=n.getRows(e);o>i&&n.insertColumns(e,{at:i,columns:o-i});t>r&&n.insertRows(e,{at:r,rows:t-r})}(i,s.lastRow+1,s.lastColumn+1,n));a||!I(e,n)?function(e,t,o){const{firstRow:n,lastRow:i,firstColumn:r,lastColumn:l}=t,s={first:n,last:i},a={first:r,last:l};Be(e,r,s,o),Be(e,l+1,s,o),Ee(e,n,a,o),Ee(e,i+1,a,o,n)}(i,s,o):(s.lastRow=q(i,s),s.lastColumn=G(i,s));return s}(l,t,e,i),n=o.lastRow-o.firstRow+1,s=o.lastColumn-o.firstColumn+1,a={startRow:0,startColumn:0,endRow:Math.min(n,t.height)-1,endColumn:Math.min(s,t.width)-1};r=M(r,a,e);const c=l[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,c,o,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=P(d.map(t=>e.createRangeOn(t)));e.setSelection(t)}else e.setSelection(d[0],0)})):$(r,i)}_replaceSelectedCellsWithPasted(e,t,o,n,i){const{width:r,height:l}=t,s=function(e,t,o){const n=new Array(o).fill(null).map(()=>new Array(t).fill(null));for(const{column:t,row:o,cell:i}of new h(e))n[o][t]=i;return n}(e,r,l),a=[...new h(o,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let d;for(const e of a){const{row:t,column:o}=e;o===n.firstColumn&&(d=e.getPositionBefore());const a=t-n.firstRow,u=o-n.firstColumn,h=s[a%l][u%r],b=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(e,b,d,i);m&&(j(m,t,o,n.lastRow,n.lastColumn,i),c.push(m),d=i.createPositionAfter(m))}const u=parseInt(o.getAttribute("headingRows")||0),b=parseInt(o.getAttribute("headingColumns")||0),m=n.firstRow<u&&u<=n.lastRow,g=n.firstColumn<b&&b<=n.lastColumn;if(m){const e=Ee(o,u,{first:n.firstColumn,last:n.lastColumn},i,n.firstRow);c.push(...e)}if(g){const e=Be(o,b,{first:n.firstRow,last:n.lastRow},i);c.push(...e)}return c}_replaceTableSlotCell(e,t,o,n){const{cell:i,isAnchor:r}=e;return r&&n.remove(i),t?(n.insert(t,o),t):null}}function Ee(e,t,o,n,i=0){if(t<1)return;return H(e,t,i).filter(({column:e,cellWidth:t})=>Oe(e,t,o)).map(({cell:e})=>F(e,t,n))}function Be(e,t,o,n){if(t<1)return;return D(e,t).filter(({row:e,cellHeight:t})=>Oe(e,t,o)).map(({cell:e,column:o})=>W(e,o,t,n))}function Oe(e,t,o){const n=e+t-1,{first:i,last:r}=o;return e>=i&&e<=r||e<i&&n>=i}class Le extends n.Plugin{static get pluginName(){return"TableKeyboard"}static get requires(){return[Ie]}init(){const e=this.editor.editing.view.document;this.editor.keystrokes.set("Tab",(...e)=>this._handleTabOnSelectedTable(...e),{priority:"low"}),this.editor.keystrokes.set("Tab",this._getTabHandler(!0),{priority:"low"}),this.editor.keystrokes.set("Shift+Tab",this._getTabHandler(!1),{priority:"low"}),this.listenTo(e,"arrowKey",(...e)=>this._onArrowKey(...e),{context:"table"})}_handleTabOnSelectedTable(e,t){const o=this.editor,n=o.model.document.selection.getSelectedElement();n&&n.is("element","table")&&(t(),o.model.change(e=>{e.setSelection(e.createRangeIn(n.getChild(0).getChild(0)))}))}_getTabHandler(e){const t=this.editor;return(o,n)=>{let i=A(t.model.document.selection)[0];if(i||(i=this.editor.plugins.get("TableSelection").getFocusCell()),!i)return;n();const r=i.parent,l=r.parent,s=l.getChildIndex(r),a=r.getChildIndex(i),c=0===a;if(!e&&c&&0===s)return void t.model.change(e=>{e.setSelection(e.createRangeOn(l))});const d=this.editor.plugins.get("TableUtils"),u=a===r.childCount-1,h=s===d.getRows(l)-1;if(e&&h&&u&&(t.execute("insertTableRowBelow"),s===d.getRows(l)-1))return void t.model.change(e=>{e.setSelection(e.createRangeOn(l))});let b;if(e&&u){const e=l.getChild(s+1);b=e.getChild(0)}else if(!e&&c){const e=l.getChild(s-1);b=e.getChild(e.childCount-1)}else b=r.getChild(a+(e?1:-1));t.model.change(e=>{e.setSelection(e.createRangeIn(b))})}}_onArrowKey(e,t){const o=this.editor,n=t.keyCode,i=Object(a.getLocalizedArrowKeyCodeDirection)(n,o.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const o=this.editor.model.document.selection,n=["right","down"].includes(e),i=x(o);if(i.length){let o;return o=t?this.editor.plugins.get("TableSelection").getFocusCell():n?i[i.length-1]:i[0],this._navigateFromCellInDirection(o,e,t),!0}const r=o.focus.findAncestor("tableCell");return!!r&&(!(t&&!o.isCollapsed&&o.isBackward==n)&&(!!this._isSelectionAtCellEdge(o,r,n)&&(this._navigateFromCellInDirection(r,e,t),!0)))}_isSelectionAtCellEdge(e,t,o){const n=this.editor.model,i=this.editor.model.schema,r=o?e.getLastPosition():e.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell")){return n.createPositionAt(t,o?"end":0).isTouching(r)}const l=n.createSelection(r);return n.modifySelection(l,{direction:o?"forward":"backward"}),r.isEqual(l.focus)}_navigateFromCellInDirection(e,t,o=!1){const n=this.editor.model,i=e.findAncestor("table"),r=[...new h(i,{includeAllSlots:!0})],{row:l,column:s}=r[r.length-1],a=r.find(({cell:t})=>t==e);let{row:c,column:d}=a;switch(t){case"left":d--;break;case"up":c--;break;case"right":d+=a.cellWidth;break;case"down":c+=a.cellHeight}if(c<0||c>l||d<0&&c<=0||d>s&&c>=l)return void n.change(e=>{e.setSelection(e.createRangeOn(i))});d<0?(d=o?0:s,c--):d>s&&(d=o?s:0,c++);const u=r.find(e=>e.row==c&&e.column==d).cell,b=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(o&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=n.createPositionAt(u,b?0:"end");n.change(t=>{t.setSelection(e)})}}}var Ne=o(4);class ze extends Ne.DomEventObserver{constructor(e){super(e),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class Me extends n.Plugin{static get pluginName(){return"TableMouse"}static get requires(){return[Ie]}init(){this.editor.editing.view.addObserver(ze),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor;let t=!1;const o=e.plugins.get(Ie);this.listenTo(e.editing.view.document,"mousedown",(n,i)=>{if(!this.isEnabled||!o.isEnabled)return;if(!i.domEvent.shiftKey)return;const r=o.getAnchorCell()||A(e.model.document.selection)[0];if(!r)return;const l=this._getModelTableCellFromDomEvent(i);l&&He(r,l)&&(t=!0,o.setCellSelection(r,l),i.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{t=!1}),this.listenTo(e.editing.view.document,"selectionChange",e=>{t&&e.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,o,n=!1,i=!1;const r=e.plugins.get(Ie);this.listenTo(e.editing.view.document,"mousedown",(e,o)=>{this.isEnabled&&r.isEnabled&&(o.domEvent.shiftKey||o.domEvent.ctrlKey||o.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(o)))}),this.listenTo(e.editing.view.document,"mousemove",(e,l)=>{if(!l.domEvent.buttons)return;if(!t)return;const s=this._getModelTableCellFromDomEvent(l);s&&He(t,s)&&(o=s,n||o==t||(n=!0)),n&&(i=!0,r.setCellSelection(t,o),l.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1,i=!1,t=null,o=null}),this.listenTo(e.editing.view.document,"selectionChange",e=>{i&&e.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,o=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(o).parent.findAncestor("tableCell",{includeSelf:!0})}}function He(e,t){return e.parent.parent==t.parent.parent}o(17);class Fe extends n.Plugin{static get requires(){return[ye,Se,Ie,Me,Le,Pe,i.Widget]}static get pluginName(){return"Table"}}function De(e){const t=e.getSelectedElement();return t&&je(t)?t:null}function We(e){let t=e.getFirstPosition().parent;for(;t;){if(t.is("element")&&je(t))return t;t=t.parent}return null}function je(e){return!!e.getCustomProperty("table")&&Object(i.isWidget)(e)}class Ue extends n.Plugin{static get requires(){return[i.WidgetToolbarRepository]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,o=e.plugins.get(i.WidgetToolbarRepository),n=e.config.get("table.contentToolbar"),r=e.config.get("table.tableToolbar");n&&o.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:We}),r&&o.register("table",{ariaLabel:t("Table toolbar"),items:r,getRelatedElement:De})}}o(19);class Ke extends xe.View{constructor(e,t){super(e);const o=this.bindTemplate;this.set("value",""),this.set("id"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.set("ariaDescribedById"),this.options=t,this._dropdownView=this._createDropdownView(),this._inputView=this._createInputTextView(),this._stillTyping=!1,this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color",o.if("hasError","ck-error")],id:o.to("id"),"aria-invalid":o.if("hasError",!0),"aria-describedby":o.to("ariaDescribedById")},children:[this._dropdownView,this._inputView]}),this.on("change:value",(e,t,o)=>this._setInputValue(o))}focus(){this._inputView.focus()}_createDropdownView(){const e=this.locale,t=e.t,o=this.bindTemplate,n=this._createColorGrid(e),i=Object(xe.createDropdown)(e),r=new xe.View,l=this._createRemoveColorButton();return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:o.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",o.if("value","ck-hidden",e=>""!=e)]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.tooltip=t("Color picker"),i.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",i.panelView.children.add(l),i.panelView.children.add(n),i.bind("isEnabled").to(this,"isReadOnly",e=>!e),i}_createInputTextView(){const e=this.locale,t=new xe.InputTextView(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 e=t.element.value,o=this.options.colorDefinitions.find(t=>e===t.label);this._stillTyping=!0,this.value=o&&o.color||e}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createRemoveColorButton(){const e=this.locale,t=e.t,o=new xe.ButtonView(e),i=this.options.defaultColorValue||"",r=t(i?"Restore default":"Remove color");return o.class="ck-input-color__remove-color",o.withText=!0,o.icon=n.icons.eraser,o.label=r,o.on("execute",()=>{this.value=i,this._dropdownView.isOpen=!1,this.fire("input")}),o}_createColorGrid(e){const t=new xe.ColorGridView(e,{colorDefinitions:this.options.colorDefinitions,columns:this.options.columns});return t.on("execute",(e,t)=>{this.value=t.value,this._dropdownView.isOpen=!1,this.fire("input")}),t.bind("selectedColor").to(this,"value"),t}_setInputValue(e){if(!this._stillTyping){const t=$e(e),o=this.options.colorDefinitions.find(e=>t===$e(e.color));this._inputView.value=o?o.label:e||""}}}function $e(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const qe=e=>""===e;function Ge(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function Je(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function Xe(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function Ye(e){return e=e.trim(),qe(e)||Object(Ne.isColor)(e)}function Qe(e){return e=e.trim(),qe(e)||it(e)||Object(Ne.isLength)(e)||Object(Ne.isPercentage)(e)}function Ze(e){return e=e.trim(),qe(e)||it(e)||Object(Ne.isLength)(e)}function et(e,t){const o=new a.Collection,n=Ge(e.t);for(const i in n){const r={type:"button",model:new xe.Model({_borderStyleValue:i,label:n[i],withText:!0})};"none"===i?r.model.bind("isOn").to(e,"borderStyle",e=>"none"===t?!e:e===i):r.model.bind("isOn").to(e,"borderStyle",e=>e===i),o.add(r)}return o}function tt(e){const{view:t,icons:o,toolbar:n,labels:i,propertyName:r,nameToValue:l,defaultValue:s}=e;for(const e in i){const a=new xe.ButtonView(t.locale);a.set({label:i[e],icon:o[e],tooltip:i[e]});const c=l?l(e):e;a.bind("isOn").to(t,r,e=>{let t=e;return""===e&&s&&(t=s),c===t}),a.on("execute",()=>{t[r]=c}),n.items.add(a)}}const ot=[{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 nt(e){return(t,o,n)=>{const i=new Ke(t.locale,{colorDefinitions:(r=e.colorConfig,r.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))),columns:e.columns,defaultColorValue:e.defaultColorValue});var r;return i.set({id:o,ariaDescribedById:n}),i.bind("isReadOnly").to(t,"isEnabled",e=>!e),i.bind("hasError").to(t,"errorText",e=>!!e),i.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(i),i}}function it(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}o(21);class rt extends xe.View{constructor(e,t={}){super(e);const o=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach(e=>this.children.add(e)),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",o.to("class")],role:o.to("_role"),"aria-labelledby":o.to("_ariaLabelledBy")},children:this.children})}}o(8),o(9),o(25);const lt={left:n.icons.alignLeft,center:n.icons.alignCenter,right:n.icons.alignRight,justify:n.icons.alignJustify,top:n.icons.alignTop,middle:n.icons.alignMiddle,bottom:n.icons.alignBottom};class st extends xe.View{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:c,operatorLabel:d,heightInput:u,dimensionsLabel:h}=this._createDimensionFields(),{horizontalAlignmentToolbar:b,verticalAlignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new a.FocusTracker,this.keystrokes=new a.KeystrokeHandler,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=u,this.horizontalAlignmentToolbar=b,this.verticalAlignmentToolbar=m;const{saveButtonView:p,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=p,this.cancelButtonView=f,this._focusables=new xe.ViewCollection,this._focusCycler=new xe.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new xe.FormHeaderView(e,{label:this.t("Cell properties")})),this.children.add(new rt(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new rt(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new rt(e,{children:[new rt(e,{labelView:h,children:[h,c,d,u],class:"ck-table-form__dimensions-row"}),new rt(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new rt(e,{labelView:g,children:[g,b,m],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new rt(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(),Object(xe.submitHandler)({view:this}),[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)}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=nt({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color}),n=this.locale,i=this.t,r=new xe.LabelView(n);r.text=i("Border");const l=Ge(i),s=new xe.LabeledFieldView(n,xe.createLabeledDropdown);s.set({label:i("Style"),class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>l[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),Object(xe.addListToDropdown)(s.fieldView,et(this,t.style));const a=new xe.LabeledFieldView(n,xe.createLabeledInputText);a.set({label:i("Width"),class:"ck-table-form__border-width"}),a.fieldView.bind("value").to(this,"borderWidth"),a.bind("isEnabled").to(this,"borderStyle",at),a.fieldView.on("input",()=>{this.borderWidth=a.fieldView.element.value});const c=new xe.LabeledFieldView(n,o);return c.set({label:i("Color"),class:"ck-table-form__border-color"}),c.fieldView.bind("value").to(this,"borderColor"),c.bind("isEnabled").to(this,"borderStyle",at),c.fieldView.on("input",()=>{this.borderColor=c.fieldView.value}),this.on("change:borderStyle",(e,o,n,i)=>{at(n)||(this.borderColor="",this.borderWidth=""),at(i)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:c,borderWidthInput:a}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Background");const n=nt({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor}),i=new xe.LabeledFieldView(e,n);return i.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",()=>{this.backgroundColor=i.fieldView.value}),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Dimensions");const n=new xe.LabeledFieldView(e,xe.createLabeledInputText);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const i=new xe.View(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new xe.LabeledFieldView(e,xe.createLabeledInputText);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createPaddingField(){const e=this.locale,t=this.t,o=new xe.LabeledFieldView(e,xe.createLabeledInputText);return o.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),o.fieldView.bind("value").to(this,"padding"),o.fieldView.on("input",()=>{this.padding=o.fieldView.element.value}),o}_createAlignmentFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Table cell text alignment");const n=new xe.ToolbarView(e),i="rtl"===this.locale.contentLanguageDirection;n.set({isCompact:!0,ariaLabel:t("Horizontal text alignment toolbar")}),tt({view:this,icons:lt,toolbar:n,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(i){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new xe.ToolbarView(e);return r.set({isCompact:!0,ariaLabel:t("Vertical text alignment toolbar")}),tt({view:this,icons:lt,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:n,verticalAlignmentToolbar:r,alignmentLabel:o}}_createActionButtons(){const e=this.locale,t=this.t,o=new xe.ButtonView(e),i=new xe.ButtonView(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return o.set({label:t("Save"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0}),o.bind("isEnabled").toMany(r,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",type:"cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:o,cancelButtonView:i}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,o=t("Align cell text to the left"),n=t("Align cell text to the center"),i=t("Align cell text to the right"),r=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o,justify:r}:{left:o,center:n,right:i,justify:r}}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 at(e){return"none"!==e}var ct=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},dt=o(10),ut="object"==typeof self&&self&&self.Object===Object&&self,ht=dt.a||ut||Function("return this")(),bt=function(){return ht.Date.now()},mt=/\s/;var gt=function(e){for(var t=e.length;t--&&mt.test(e.charAt(t)););return t},pt=/^\s+/;var ft=function(e){return e?e.slice(0,gt(e)+1).replace(pt,""):e},wt=ht.Symbol,_t=Object.prototype,kt=_t.hasOwnProperty,vt=_t.toString,Ct=wt?wt.toStringTag:void 0;var yt=function(e){var t=kt.call(e,Ct),o=e[Ct];try{e[Ct]=void 0;var n=!0}catch(e){}var i=vt.call(e);return n&&(t?e[Ct]=o:delete e[Ct]),i},Tt=Object.prototype.toString;var xt=function(e){return Tt.call(e)},At=wt?wt.toStringTag:void 0;var Vt=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":At&&At in Object(e)?yt(e):xt(e)};var St=function(e){return null!=e&&"object"==typeof e};var Rt=function(e){return"symbol"==typeof e||St(e)&&"[object Symbol]"==Vt(e)},It=/^[-+]0x[0-9a-f]+$/i,Pt=/^0b[01]+$/i,Et=/^0o[0-7]+$/i,Bt=parseInt;var Ot=function(e){if("number"==typeof e)return e;if(Rt(e))return NaN;if(ct(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ct(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=ft(e);var o=Pt.test(e);return o||Et.test(e)?Bt(e.slice(2),o?2:8):It.test(e)?NaN:+e},Lt=Math.max,Nt=Math.min;var zt=function(e,t,o){var n,i,r,l,s,a,c=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var o=n,r=i;return n=i=void 0,c=t,l=e.apply(r,o)}function m(e){return c=e,s=setTimeout(p,t),d?b(e):l}function g(e){var o=e-a;return void 0===a||o>=t||o<0||u&&e-c>=r}function p(){var e=bt();if(g(e))return f(e);s=setTimeout(p,function(e){var o=t-(e-a);return u?Nt(o,r-(e-c)):o}(e))}function f(e){return s=void 0,h&&n?b(e):(n=i=void 0,l)}function w(){var e=bt(),o=g(e);if(n=arguments,i=this,a=e,o){if(void 0===s)return m(a);if(u)return clearTimeout(s),s=setTimeout(p,t),b(a)}return void 0===s&&(s=setTimeout(p,t)),l}return t=Ot(t)||0,ct(o)&&(d=!!o.leading,r=(u="maxWait"in o)?Lt(Ot(o.maxWait)||0,t):r,h="trailing"in o?!!o.trailing:h),w.cancel=function(){void 0!==s&&clearTimeout(s),c=0,n=a=i=s=void 0},w.flush=function(){return void 0===s?l:f(bt())},w};const Mt=xe.BalloonPanelView.defaultPositions,Ht=[Mt.northArrowSouth,Mt.northArrowSouthWest,Mt.northArrowSouthEast,Mt.southArrowNorth,Mt.southArrowNorthWest,Mt.southArrowNorthEast],Ft=[...Ht,i.centeredBalloonPositionForLongWidgets];function Dt(e,t){const o=e.plugins.get("ContextualBalloon");if(We(e.editing.view.document.selection)){let n;n="cell"===t?jt(e):Wt(e),o.updatePosition(n)}}function Wt(e){const t=e.model.document.selection.getFirstPosition().findAncestor("table"),o=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.viewToDom(o),positions:Ft}}function jt(e){const t=e.editing.mapper,o=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const o=t.editing.mapper,n=t.editing.view.domConverter,i=Array.from(e).map(e=>{const t=Ut(e.start),i=o.toViewElement(t);return new a.Rect(n.viewToDom(i))});return a.Rect.getBoundingRect(i)}(n.getRanges(),e),positions:Ht};const i=Ut(n.getFirstPosition()),r=t.toViewElement(i);return{target:o.viewToDom(r),positions:Ht}}function Ut(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}function Kt(e){if(!e||!ct(e))return e;const{top:t,right:o,bottom:n,left:i}=e;return t==o&&o==n&&n==i?t:void 0}function $t(e,t){const o=parseFloat(e);return Number.isNaN(o)||String(o)!==String(e)?e:`${o}${t}`}function qt(e,t={}){const o=Object.assign({borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:""},e);return t.includeAlignmentProperty&&!o.alignment&&(o.alignment="center"),t.includePaddingProperty&&!o.padding&&(o.padding=""),t.includeVerticalAlignmentProperty&&!o.verticalAlignment&&(o.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!o.horizontalAlignment&&(o.horizontalAlignment=t.isRightToLeftContent?"right":"left"),o}const Gt={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",width:"tableCellWidth",height:"tableCellHeight",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class Jt extends n.Plugin{static get requires(){return[xe.ContextualBalloon]}static get pluginName(){return"TableCellPropertiesUI"}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:ot,backgroundColors:ot})}init(){const e=this.editor,t=e.t;this._defaultTableCellProperties=qt(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(xe.ContextualBalloon),this.view=this._createPropertiesView(),this._undoStepBatch=null,e.ui.componentFactory.add("tableCellProperties",o=>{const n=new xe.ButtonView(o);n.set({label:t("Cell properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const i=Object.values(Gt).map(t=>e.commands.get(t));return n.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.editing.view.document,o=e.config.get("table.tableCellProperties"),n=Object(xe.normalizeColorOptions)(o.borderColors),i=Object(xe.getLocalizedColorOptions)(e.locale,n),r=Object(xe.normalizeColorOptions)(o.backgroundColors),l=Object(xe.getLocalizedColorOptions)(e.locale,r),s=new st(e.locale,{borderColors:i,backgroundColors:l,defaultTableCellProperties:this._defaultTableCellProperties}),a=e.t;s.render(),this.listenTo(s,"submit",()=>{this._hideView()}),this.listenTo(s,"cancel",()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()}),s.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),this.listenTo(e.ui,"update",()=>{We(t.selection)?this._isViewVisible&&Dt(e,"cell"):this._hideView()}),Object(xe.clickOutsideHandler)({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=Je(a),d=Xe(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle",this._defaultTableCellProperties.borderStyle)),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableCellBorderColor",errorText:c,validator:Ye,defaultValue:this._defaultTableCellProperties.borderColor})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:Ze,defaultValue:this._defaultTableCellProperties.borderWidth})),s.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:s.paddingInput,commandName:"tableCellPadding",errorText:d,validator:Qe,defaultValue:this._defaultTableCellProperties.padding})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableCellWidth",errorText:d,validator:Qe,defaultValue:this._defaultTableCellProperties.width})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableCellHeight",errorText:d,validator:Qe,defaultValue:this._defaultTableCellProperties.height})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableCellBackgroundColor",errorText:c,validator:Ye,defaultValue:this._defaultTableCellProperties.backgroundColor})),s.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment",this._defaultTableCellProperties.horizontalAlignment)),s.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment",this._defaultTableCellProperties.verticalAlignment)),s}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(Gt).map(([t,o])=>{const n=this._defaultTableCellProperties[t]||"";return[t,e.get(o).value||n]}).forEach(([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})}_showView(){const e=this.editor;this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:jt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){if(!this._isViewInBalloon)return;const e=this.editor;this.stopListening(e.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(e,t){return(o,n,i,r)=>{(r||t!==i)&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i,defaultValue:r}=e,l=zt(()=>{o.errorText=i},500);return(e,i,s,a)=>{l.cancel(),(a||r!==s)&&(n(s)?(this.editor.execute(t,{value:s,batch:this._undoStepBatch}),o.errorText=null):l())}}}function Xt(e,t){const{viewElement:o,defaultValue:n,modelAttribute:i,styleName:r,reduceBoxSides:l=!1}=t;e.for("upcast").attributeToAttribute({view:{name:o,styles:{[r]:/[\s\S]+/}},model:{key:i,value:e=>{const t=e.getNormalizedStyle(r),o=l?eo(t):t;if(n!==o)return o}}})}function Yt(e,t,o){e.for("upcast").add(e=>e.on("element:"+t,(e,t,n)=>{if(!t.modelRange)return;const i=["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(e=>t.viewItem.hasStyle(e));if(!i.length)return;const r={styles:i};if(!n.consumable.test(t.viewItem,r))return;const l=[...t.modelRange.getItems({shallow:!0})].pop();n.consumable.consume(t.viewItem,r);const s={style:t.viewItem.getNormalizedStyle("border-style"),color:t.viewItem.getNormalizedStyle("border-color"),width:t.viewItem.getNormalizedStyle("border-width")},a={style:eo(s.style),color:eo(s.color),width:eo(s.width)};a.style!==o.style&&n.writer.setAttribute("borderStyle",a.style,l),a.color!==o.color&&n.writer.setAttribute("borderColor",a.color,l),a.width!==o.width&&n.writer.setAttribute("borderWidth",a.width,l)}))}function Qt(e,{modelElement:t,modelAttribute:o,styleName:n}){e.for("downcast").attributeToAttribute({model:{name:t,key:o},view:e=>({key:"style",value:{[n]:e}})})}function Zt(e,{modelAttribute:t,styleName:o}){e.for("downcast").add(e=>e.on(`attribute:${t}:table`,(e,t,n)=>{const{item:i,attributeNewValue:r}=t,{mapper:l,writer:s}=n;if(!n.consumable.consume(t.item,e.name))return;const a=[...l.toViewElement(i).getChildren()].find(e=>e.is("element","table"));r?s.setStyle(o,r,a):s.removeStyle(o,a)}))}function eo(e){if(!e)return;return["top","right","bottom","left"].map(t=>e[t]).reduce((e,t)=>e==t?e:null)||e}class to extends n.Command{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=!!e.length,this.value=this._getSingleValue(e)}execute(e={}){const{value:t,batch:o}=e,n=this.editor.model,i=V(n.document.selection),r=this._getValueToSet(t);n.enqueueChange(o||"default",e=>{r?i.forEach(t=>e.setAttribute(this.attributeName,r,t)):i.forEach(t=>e.removeAttribute(this.attributeName,t))})}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(e=>this._getAttribute(e)===t)?t:void 0}}class oo extends to{constructor(e,t){super(e,"padding",t)}_getAttribute(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){if((e=$t(e,"px"))!==this._defaultValue)return e}}class no extends to{constructor(e,t){super(e,"width",t)}_getValueToSet(e){if((e=$t(e,"px"))!==this._defaultValue)return e}}class io extends to{constructor(e,t){super(e,"height",t)}_getValueToSet(e){return(e=$t(e,"px"))===this._defaultValue?null:e}}class ro extends to{constructor(e,t){super(e,"backgroundColor",t)}}class lo extends to{constructor(e,t){super(e,"verticalAlignment",t)}}class so extends to{constructor(e,t){super(e,"horizontalAlignment",t)}}class ao extends to{constructor(e,t){super(e,"borderStyle",t)}_getAttribute(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class co extends to{constructor(e,t){super(e,"borderColor",t)}_getAttribute(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class uo extends to{constructor(e,t){super(e,"borderWidth",t)}_getAttribute(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){if((e=$t(e,"px"))!==this._defaultValue)return e}}const ho=/^(top|middle|bottom)$/,bo=/^(left|center|right|justify)$/;class mo extends n.Plugin{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[ye]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=qt(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(Ne.addBorderRules),function(e,t,o){e.extend("tableCell",{allowAttributes:["borderWidth","borderColor","borderStyle"]}),Yt(t,"td",o),Yt(t,"th",o),Qt(t,{modelElement:"tableCell",modelAttribute:"borderStyle",styleName:"border-style"}),Qt(t,{modelElement:"tableCell",modelAttribute:"borderColor",styleName:"border-color"}),Qt(t,{modelElement:"tableCell",modelAttribute:"borderWidth",styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new ao(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new co(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new uo(e,n.borderWidth)),function(e,t,o){e.extend("tableCell",{allowAttributes:["horizontalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"horizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":bo}},model:{key:"horizontalAlignment",value:e=>{const t=e.getStyle("text-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:bo}},model:{key:"horizontalAlignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new so(e,n.horizontalAlignment)),go(t,o,{modelAttribute:"width",styleName:"width",defaultValue:n.width}),e.commands.add("tableCellWidth",new no(e,n.width)),go(t,o,{modelAttribute:"height",styleName:"height",defaultValue:n.height}),e.commands.add("tableCellHeight",new io(e,n.height)),e.data.addStyleProcessorRules(Ne.addPaddingRules),go(t,o,{modelAttribute:"padding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new oo(e,n.padding)),e.data.addStyleProcessorRules(Ne.addBackgroundRules),go(t,o,{modelAttribute:"backgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new ro(e,n.backgroundColor)),function(e,t,o){e.extend("tableCell",{allowAttributes:["verticalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"verticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":ho}},model:{key:"verticalAlignment",value:e=>{const t=e.getStyle("vertical-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:ho}},model:{key:"verticalAlignment",value:e=>{const t=e.getAttribute("valign");return t===o?null:t}}})}(t,o,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new lo(e,n.verticalAlignment))}}function go(e,t,o){const{modelAttribute:n}=o;e.extend("tableCell",{allowAttributes:[n]}),Xt(t,{viewElement:/^(td|th)$/,...o}),Qt(t,{modelElement:"tableCell",...o})}class po extends n.Plugin{static get pluginName(){return"TableCellProperties"}static get requires(){return[mo,Jt]}}class fo extends n.Command{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,o=t.document.selection,{value:n,batch:i}=e,r=o.getFirstPosition().findAncestor("table"),l=this._getValueToSet(n);t.enqueueChange(i||"default",e=>{l?e.setAttribute(this.attributeName,l,r):e.removeAttribute(this.attributeName,r)})}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}}class wo extends fo{constructor(e,t){super(e,"backgroundColor",t)}}class _o extends fo{constructor(e,t){super(e,"borderColor",t)}_getValue(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class ko extends fo{constructor(e,t){super(e,"borderStyle",t)}_getValue(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class vo extends fo{constructor(e,t){super(e,"borderWidth",t)}_getValue(e){if(!e)return;const t=Kt(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){if((e=$t(e,"px"))!==this._defaultValue)return e}}class Co extends fo{constructor(e,t){super(e,"width",t)}_getValueToSet(e){if((e=$t(e,"px"))!==this._defaultValue)return e}}class yo extends fo{constructor(e,t){super(e,"height",t)}_getValueToSet(e){return(e=$t(e,"px"))===this._defaultValue?null:e}}class To extends fo{constructor(e,t){super(e,"alignment",t)}}const xo=/^(left|center|right)$/,Ao=/^(left|none|right)$/;class Vo extends n.Plugin{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[ye]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=qt(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(Ne.addBorderRules),function(e,t,o){e.extend("table",{allowAttributes:["borderWidth","borderColor","borderStyle"]}),Yt(t,"table",o),Zt(t,{modelAttribute:"borderColor",styleName:"border-color"}),Zt(t,{modelAttribute:"borderStyle",styleName:"border-style"}),Zt(t,{modelAttribute:"borderWidth",styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new _o(e,n.borderColor)),e.commands.add("tableBorderStyle",new ko(e,n.borderStyle)),e.commands.add("tableBorderWidth",new vo(e,n.borderWidth)),function(e,t,o){e.extend("table",{allowAttributes:["alignment"]}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"alignment"},view:e=>({key:"style",value:{float:"center"===e?"none":e}}),converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:Ao}},model:{key:"alignment",value:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t===o?null:t}}}).attributeToAttribute({view:{attributes:{align:xo}},model:{name:"table",key:"alignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.alignment),e.commands.add("tableAlignment",new To(e,n.alignment)),So(t,o,{modelAttribute:"width",styleName:"width",defaultValue:n.width}),e.commands.add("tableWidth",new Co(e,n.width)),So(t,o,{modelAttribute:"height",styleName:"height",defaultValue:n.height}),e.commands.add("tableHeight",new yo(e,n.height)),e.data.addStyleProcessorRules(Ne.addBackgroundRules),function(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),Xt(t,{viewElement:"table",...o}),Zt(t,o)}(t,o,{modelAttribute:"backgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new wo(e,n.backgroundColor))}}function So(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),Xt(t,{viewElement:/^(table|figure)$/,...o}),Qt(t,{modelElement:"table",...o})}o(28);const Ro={left:n.icons.objectLeft,center:n.icons.objectCenter,right:n.icons.objectRight};class Io extends xe.View{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:c,operatorLabel:d,heightInput:u,dimensionsLabel:h}=this._createDimensionFields(),{alignmentToolbar:b,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new a.FocusTracker,this.keystrokes=new a.KeystrokeHandler,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.widthInput=c,this.heightInput=u,this.alignmentToolbar=b;const{saveButtonView:g,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=p,this._focusables=new xe.ViewCollection,this._focusCycler=new xe.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new xe.FormHeaderView(e,{label:this.t("Table properties")})),this.children.add(new rt(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new rt(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new rt(e,{children:[new rt(e,{labelView:h,children:[h,c,d,u],class:"ck-table-form__dimensions-row"}),new rt(e,{labelView:m,children:[m,b],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new rt(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(),Object(xe.submitHandler)({view:this}),[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)}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=nt({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color}),n=this.locale,i=this.t,r=new xe.LabelView(n);r.text=i("Border");const l=Ge(this.t),s=new xe.LabeledFieldView(n,xe.createLabeledDropdown);s.set({label:i("Style"),class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>l[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),Object(xe.addListToDropdown)(s.fieldView,et(this,t.style));const a=new xe.LabeledFieldView(n,xe.createLabeledInputText);a.set({label:i("Width"),class:"ck-table-form__border-width"}),a.fieldView.bind("value").to(this,"borderWidth"),a.bind("isEnabled").to(this,"borderStyle",Po),a.fieldView.on("input",()=>{this.borderWidth=a.fieldView.element.value});const c=new xe.LabeledFieldView(n,o);return c.set({label:i("Color"),class:"ck-table-form__border-color"}),c.fieldView.bind("value").to(this,"borderColor"),c.bind("isEnabled").to(this,"borderStyle",Po),c.fieldView.on("input",()=>{this.borderColor=c.fieldView.value}),this.on("change:borderStyle",(e,o,n,i)=>{Po(n)||(this.borderColor="",this.borderWidth=""),Po(i)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:c,borderWidthInput:a}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Background");const n=nt({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor}),i=new xe.LabeledFieldView(e,n);return i.set({label:t("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",()=>{this.backgroundColor=i.fieldView.value}),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Dimensions");const n=new xe.LabeledFieldView(e,xe.createLabeledInputText);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const i=new xe.View(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new xe.LabeledFieldView(e,xe.createLabeledInputText);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Alignment");const n=new xe.ToolbarView(e);return n.set({isCompact:!0,ariaLabel:t("Table alignment toolbar")}),tt({view:this,icons:Ro,toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:o,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,o=new xe.ButtonView(e),i=new xe.ButtonView(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return o.set({label:t("Save"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0}),o.bind("isEnabled").toMany(r,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",type:"cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:o,cancelButtonView:i}}get _alignmentLabels(){const e=this.locale,t=this.t,o=t("Align table to the left"),n=t("Center table"),i=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o}:{left:o,center:n,right:i}}}function Po(e){return"none"!==e}const Eo={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class Bo extends n.Plugin{static get requires(){return[xe.ContextualBalloon]}static get pluginName(){return"TablePropertiesUI"}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:ot,backgroundColors:ot})}init(){const e=this.editor,t=e.t;this._defaultTableProperties=qt(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=e.plugins.get(xe.ContextualBalloon),this.view=this._createPropertiesView(),this._undoStepBatch=null,e.ui.componentFactory.add("tableProperties",o=>{const n=new xe.ButtonView(o);n.set({label:t("Table properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const i=Object.values(Eo).map(t=>e.commands.get(t));return n.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableProperties"),o=Object(xe.normalizeColorOptions)(t.borderColors),n=Object(xe.getLocalizedColorOptions)(e.locale,o),i=Object(xe.normalizeColorOptions)(t.backgroundColors),r=Object(xe.getLocalizedColorOptions)(e.locale,i),l=new Io(e.locale,{borderColors:n,backgroundColors:r,defaultTableProperties:this._defaultTableProperties}),s=e.t;l.render(),this.listenTo(l,"submit",()=>{this._hideView()}),this.listenTo(l,"cancel",()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()}),l.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),Object(xe.clickOutsideHandler)({emitter:l,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const a=Je(s),c=Xe(s);return l.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle",this._defaultTableProperties.borderStyle)),l.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:l.borderColorInput,commandName:"tableBorderColor",errorText:a,validator:Ye,defaultValue:this._defaultTableProperties.borderColor})),l.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:l.borderWidthInput,commandName:"tableBorderWidth",errorText:c,validator:Ze,defaultValue:this._defaultTableProperties.borderWidth})),l.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:l.backgroundInput,commandName:"tableBackgroundColor",errorText:a,validator:Ye,defaultValue:this._defaultTableProperties.backgroundColor})),l.on("change:width",this._getValidatedPropertyChangeCallback({viewField:l.widthInput,commandName:"tableWidth",errorText:c,validator:Qe,defaultValue:this._defaultTableProperties.width})),l.on("change:height",this._getValidatedPropertyChangeCallback({viewField:l.heightInput,commandName:"tableHeight",errorText:c,validator:Qe,defaultValue:this._defaultTableProperties.height})),l.on("change:alignment",this._getPropertyChangeCallback("tableAlignment",this._defaultTableProperties.alignment)),l}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(Eo).map(([t,o])=>{const n=this._defaultTableProperties[t]||"";return[t,e.get(o).value||n]}).forEach(([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})}_showView(){const e=this.editor;this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Wt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;We(e.editing.view.document.selection)?this._isViewVisible&&Dt(e,"table"):this._hideView()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(e,t){return(o,n,i,r)=>{(r||t!==i)&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i,defaultValue:r}=e,l=zt(()=>{o.errorText=i},500);return(e,i,s,a)=>{l.cancel(),(a||r!==s)&&(n(s)?(this.editor.execute(t,{value:s,batch:this._undoStepBatch}),o.errorText=null):l())}}}class Oo extends n.Plugin{static get pluginName(){return"TableProperties"}static get requires(){return[Vo,Bo]}}function Lo(e){e.document.registerPostFixer(t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o){if("insert"!=t.type)continue;if(t.position.parent.is("element","table")||"table"==t.name){const o="table"==t.name?t.position.nodeAfter:t.position.parent,i=Array.from(o.getChildren()).filter(e=>e.is("element","caption")),r=i.shift();if(!r)continue;for(const t of i)e.move(e.createRangeIn(t),r,"end"),e.remove(t);r.nextSibling&&(e.move(e.createRangeOn(r),o,"end"),n=!0),n=!!i.length||n}}return n}(t,e))}function No(e){return!!e&&e.is("element","table")}function zo(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function Mo(e){const t=e.parent;return"figcaption"==e.name&&t&&"figure"==t.name&&t.hasClass("table")||"caption"==e.name&&t&&"table"==t.name?{name:!0}:null}function Ho(e){const t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")}class Fo extends n.Command{refresh(){const e=Ho(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?this.value=!!zo(e):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(e=>{this.value?this._hideTableCaption(e):this._showTableCaption(e,t)})}_showTableCaption(e,t){const o=Ho(this.editor.model.document.selection),n=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(o)||e.createElement("caption");e.append(n,o),t&&e.setSelection(n,"in")}_hideTableCaption(e){const t=Ho(this.editor.model.document.selection),o=this.editor.plugins.get("TableCaptionEditing"),n=zo(t);o._saveCaption(t,n),e.setSelection(e.createRangeIn(t.getChild(0).getChild(0))),e.remove(n)}}class Do extends n.Plugin{static get pluginName(){return"TableCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema,o=e.editing.view,n=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new Fo(this.editor)),e.conversion.for("upcast").elementToElement({view:Mo,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>No(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!No(e.parent))return null;const r=t.createEditableElement("figcaption");return t.setCustomProperty("tableCaption",!0,r),Object(Ne.enablePlaceholder)({view:o,element:r,text:n("Enter table caption"),keepOnFocus:!0}),Object(i.toWidgetEditable)(r,t)}}),Lo(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Ne.Element.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class Wo extends n.Plugin{static get pluginName(){return"TableCaptionUI"}init(){const e=this.editor,t=e.editing.view,o=e.t;e.ui.componentFactory.add("toggleTableCaption",i=>{const r=e.commands.get("toggleTableCaption"),l=new xe.ButtonView(i);return l.set({icon:n.icons.caption,tooltip:!0,isToggleable:!0}),l.bind("isOn","isEnabled").to(r,"value","isEnabled"),l.bind("label").to(r,"value",e=>o(e?"Toggle caption off":"Toggle caption on")),this.listenTo(l,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),r.value){const o=function(e){const t=Ho(e);return t?zo(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(o);if(!n)return;t.scrollToTheSelection(),t.change(e=>{e.addClass("table__caption_highlighted",n)})}}),l})}}o(30);class jo extends n.Plugin{static get pluginName(){return"TableCaption"}static get requires(){return[Do,Wo]}}}]);
5
+ !function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"Align cell text to the bottom":"Align cell text to the bottom","Align cell text to the center":"Align cell text to the center","Align cell text to the left":"Align cell text to the left","Align cell text to the middle":"Align cell text to the middle","Align cell text to the right":"Align cell text to the right","Align cell text to the top":"Align cell text to the top","Align table to the left":"Align table to the left","Align table to the right":"Align table to the right",Alignment:"Alignment",Background:"Background",Border:"Border","Cell properties":"Cell properties","Center table":"Center table",Color:"Color","Color picker":"Color picker",Column:"Column",Dashed:"Dashed","Delete column":"Delete column","Delete row":"Delete row",Dimensions:"Dimensions",Dotted:"Dotted",Double:"Double","Enter table caption":"Enter table caption",Groove:"Groove","Header column":"Header column","Header row":"Header row",Height:"Height","Horizontal text alignment toolbar":"Horizontal text alignment toolbar","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert row above":"Insert row above","Insert row below":"Insert row below","Insert table":"Insert table",Inset:"Inset","Justify cell text":"Justify cell text","Merge cell down":"Merge cell down","Merge cell left":"Merge cell left","Merge cell right":"Merge cell right","Merge cell up":"Merge cell up","Merge cells":"Merge cells",None:"None",Outset:"Outset",Padding:"Padding",Ridge:"Ridge",Row:"Row","Select column":"Select column","Select row":"Select row",Solid:"Solid","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Style:"Style","Table alignment toolbar":"Table alignment toolbar","Table cell text alignment":"Table cell text alignment","Table properties":"Table properties","Table toolbar":"Table toolbar",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".','The value is invalid. Try "10px" or "2em" or simply "2".':'The value is invalid. Try "10px" or "2em" or simply "2".',"Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on","Vertical text alignment toolbar":"Vertical text alignment toolbar",Width:"Width"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),window.CKEditor5=window.CKEditor5||{},window.CKEditor5.table=function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=32)}([function(e,t,o){e.exports=o(6)("./src/ui.js")},function(e,t,o){e.exports=o(6)("./src/core.js")},function(e,t,o){e.exports=o(6)("./src/utils.js")},function(e,t,o){e.exports=o(6)("./src/engine.js")},function(e,t,o){e.exports=o(6)("./src/widget.js")},function(e,t,o){"use strict";var n,i=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var e={};return function(t){if(void 0===e[t]){var o=document.querySelector(t);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}e[t]=o}return e[t]}}(),l=[];function s(e){for(var t=-1,o=0;o<l.length;o++)if(l[o].identifier===e){t=o;break}return t}function a(e,t){for(var o={},n=[],i=0;i<e.length;i++){var r=e[i],a=t.base?r[0]+t.base:r[0],c=o[a]||0,d="".concat(a," ").concat(c);o[a]=c+1;var u=s(d),h={css:r[1],media:r[2],sourceMap:r[3]};-1!==u?(l[u].references++,l[u].updater(h)):l.push({identifier:d,updater:p(h,t),references:1}),n.push(d)}return n}function c(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var i=o.nc;i&&(n.nonce=i)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var l=r(e.insert||"head");if(!l)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");l.appendChild(t)}return t}var d,u=(d=[],function(e,t){return d[e]=t,d.filter(Boolean).join("\n")});function h(e,t,o,n){var i=o?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=u(t,i);else{var r=document.createTextNode(i),l=e.childNodes;l[t]&&e.removeChild(l[t]),l.length?e.insertBefore(r,l[t]):e.appendChild(r)}}function b(e,t,o){var n=o.css,i=o.media,r=o.sourceMap;if(i?e.setAttribute("media",i):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var m=null,g=0;function p(e,t){var o,n,i;if(t.singleton){var r=g++;o=m||(m=c(t)),n=h.bind(null,o,r,!1),i=h.bind(null,o,r,!0)}else o=c(t),n=b.bind(null,o,t),i=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(o)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else i()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=i());var o=a(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<o.length;n++){var i=s(o[n]);l[i].references--}for(var r=a(e,t),c=0;c<o.length;c++){var d=s(o[c]);0===l[d].references&&(l[d].updater(),l.splice(d,1))}o=r}}}},function(e,t){e.exports=CKEditor5.dll},,function(e,t,o){var n=o(5),i=o(23);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t,o){var n=o(5),i=o(24);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t,o){"use strict";(function(e){var o="object"==typeof e&&e&&e.Object===Object&&e;t.a=o}).call(this,o(27))},function(e,t,o){var n=o(5),i=o(12);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=":root{--ck-color-table-focused-cell-background:rgba(158,207,250,0.3)}.ck-widget.table td.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table td.ck-editor__nested-editable:focus,.ck-widget.table th.ck-editor__nested-editable.ck-editor__nested-editable_focused,.ck-widget.table th.ck-editor__nested-editable:focus{background:var(--ck-color-table-focused-cell-background);border-style:none;outline:1px solid var(--ck-color-focus-border);outline-offset:-1px}"},function(e,t,o){var n=o(5),i=o(14);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck .ck-insert-table-dropdown__grid{display:flex;flex-direction:row;flex-wrap:wrap}:root{--ck-insert-table-dropdown-padding:10px;--ck-insert-table-dropdown-box-height:11px;--ck-insert-table-dropdown-box-width:12px;--ck-insert-table-dropdown-box-margin:1px}.ck .ck-insert-table-dropdown__grid{width:calc(var(--ck-insert-table-dropdown-box-width)*10 + var(--ck-insert-table-dropdown-box-margin)*20 + var(--ck-insert-table-dropdown-padding)*2);padding:var(--ck-insert-table-dropdown-padding) var(--ck-insert-table-dropdown-padding) 0}.ck .ck-insert-table-dropdown__label{text-align:center}.ck .ck-insert-table-dropdown-grid-box{width:var(--ck-insert-table-dropdown-box-width);height:var(--ck-insert-table-dropdown-box-height);margin:var(--ck-insert-table-dropdown-box-margin);border:1px solid var(--ck-color-base-border);border-radius:1px}.ck .ck-insert-table-dropdown-grid-box.ck-on{border-color:var(--ck-color-focus-border);background:var(--ck-color-focus-outer-shadow)}"},function(e,t,o){var n=o(5),i=o(16);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=':root{--ck-table-selected-cell-background:rgba(158,207,250,0.3)}.ck.ck-editor__editable .table table td.ck-editor__editable_selected,.ck.ck-editor__editable .table table th.ck-editor__editable_selected{position:relative;caret-color:transparent;outline:unset;box-shadow:unset}.ck.ck-editor__editable .table table td.ck-editor__editable_selected:after,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:after{content:"";pointer-events:none;background-color:var(--ck-table-selected-cell-background);position:absolute;top:0;left:0;right:0;bottom:0}.ck.ck-editor__editable .table table td.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table td.ck-editor__editable_selected:focus,.ck.ck-editor__editable .table table th.ck-editor__editable_selected ::selection,.ck.ck-editor__editable .table table th.ck-editor__editable_selected:focus{background-color:transparent}.ck.ck-editor__editable .table table td.ck-editor__editable_selected .ck-widget_selected,.ck.ck-editor__editable .table table th.ck-editor__editable_selected .ck-widget_selected{outline:unset}'},function(e,t,o){var n=o(5),i=o(18);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck-content .table{margin:.9em auto;display:table}.ck-content .table table{border-collapse:collapse;border-spacing:0;width:100%;height:100%;border:1px double #b3b3b3}.ck-content .table table td,.ck-content .table table th{min-width:2em;padding:.4em;border:1px solid #bfbfbf}.ck-content .table table th{font-weight:700;background:hsla(0,0%,0%,5%)}.ck-content[dir=rtl] .table th{text-align:right}.ck-content[dir=ltr] .table th{text-align:left}.ck-editor__editable .ck-table-bogus-paragraph{display:inline-block;width:100%}"},function(e,t,o){var n=o(5),i=o(20);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-input-color{width:100%;display:flex;flex-direction:row-reverse}.ck.ck-input-color>input.ck.ck-input-text{min-width:auto;flex-grow:1}.ck.ck-input-color>div.ck.ck-dropdown{min-width:auto}.ck.ck-input-color>div.ck.ck-dropdown>.ck-input-color__button .ck-dropdown__arrow{display:none}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview{position:relative;overflow:hidden}.ck.ck-input-color .ck.ck-input-color__button .ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{position:absolute;display:block}[dir=ltr] .ck.ck-input-color>.ck.ck-input-text{border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-input-text{border-top-left-radius:0;border-bottom-left-radius:0}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{padding:0}[dir=ltr] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-left-width:0;border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button{border-right-width:0;border-top-right-radius:0;border-bottom-right-radius:0}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button.ck-disabled{background:var(--ck-color-input-disabled-background)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{border-radius:0}.ck-rounded-corners .ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview,.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview{width:20px;height:20px;border:1px solid var(--ck-color-input-border)}.ck.ck-input-color>.ck.ck-dropdown>.ck.ck-button.ck-input-color__button>.ck.ck-input-color__button__preview>.ck.ck-input-color__button__preview__no-color-indicator{top:-30%;left:50%;height:150%;width:8%;background:red;border-radius:2px;transform:rotate(45deg);transform-origin:50%}.ck.ck-input-color .ck.ck-input-color__remove-color{width:100%;border-bottom:1px solid var(--ck-color-input-border);padding:calc(var(--ck-spacing-standard)/2) var(--ck-spacing-standard);border-bottom-left-radius:0;border-bottom-right-radius:0}[dir=ltr] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-right-radius:0}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color{border-top-left-radius:0}.ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-right:var(--ck-spacing-standard)}[dir=rtl] .ck.ck-input-color .ck.ck-input-color__remove-color .ck.ck-icon{margin-right:0;margin-left:var(--ck-spacing-standard)}"},function(e,t,o){var n=o(5),i=o(22);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-form__row{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between}.ck.ck-form__row>:not(.ck-label){flex-grow:1}.ck.ck-form__row.ck-table-form__action-row .ck-button-cancel,.ck.ck-form__row.ck-table-form__action-row .ck-button-save{justify-content:center}.ck.ck-form__row{padding:var(--ck-spacing-standard) var(--ck-spacing-large) 0}[dir=ltr] .ck.ck-form__row>:not(.ck-label)+*{margin-left:var(--ck-spacing-large)}[dir=rtl] .ck.ck-form__row>:not(.ck-label)+*{margin-right:var(--ck-spacing-large)}.ck.ck-form__row>.ck-label{width:100%;min-width:100%}.ck.ck-form__row.ck-table-form__action-row{margin-top:var(--ck-spacing-large)}.ck.ck-form__row.ck-table-form__action-row .ck-button .ck-button__label{color:var(--ck-color-text)}"},function(e,t){e.exports=".ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}"},function(e,t){e.exports='.ck.ck-table-form .ck-form__row.ck-table-form__background-row,.ck.ck-table-form .ck-form__row.ck-table-form__border-row{flex-wrap:wrap}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{flex-wrap:wrap;align-items:center}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view{display:flex;flex-direction:column-reverse;align-items:center}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-labeled-field-view .ck.ck-dropdown,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{flex-grow:0}.ck.ck-table-form .ck.ck-labeled-field-view{position:relative}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{position:absolute;left:50%;bottom:calc(var(--ck-table-properties-error-arrow-size)*-1);transform:translate(-50%,100%);z-index:1}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{content:"";position:absolute;top:calc(var(--ck-table-properties-error-arrow-size)*-1);left:50%;transform:translateX(-50%)}:root{--ck-table-properties-error-arrow-size:6px;--ck-table-properties-min-error-width:150px}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-labeled-field-view>.ck-label{font-size:var(--ck-font-size-tiny);text-align:center}.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-style,.ck.ck-table-form .ck-form__row.ck-table-form__border-row .ck-table-form__border-width{width:80px;min-width:80px;max-width:80px}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row{padding:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__height,.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimensions-row__width{margin:0}.ck.ck-table-form .ck-form__row.ck-table-form__dimensions-row .ck-table-form__dimension-operator{align-self:flex-end;display:inline-block;height:var(--ck-ui-component-min-height);line-height:var(--ck-ui-component-min-height);margin:0 var(--ck-spacing-small)}.ck.ck-table-form .ck.ck-labeled-field-view{padding-top:var(--ck-spacing-standard)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{border-radius:0}.ck-rounded-corners .ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status,.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status.ck-rounded-corners{border-radius:var(--ck-border-radius)}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{background:var(--ck-color-base-error);color:var(--ck-color-base-background);padding:var(--ck-spacing-small) var(--ck-spacing-medium);min-width:var(--ck-table-properties-min-error-width);text-align:center}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status:after{border-left:var(--ck-table-properties-error-arrow-size) solid transparent;border-bottom:var(--ck-table-properties-error-arrow-size) solid var(--ck-color-base-error);border-right:var(--ck-table-properties-error-arrow-size) solid transparent;border-top:0 solid transparent}.ck.ck-table-form .ck.ck-labeled-field-view .ck.ck-labeled-field-view__status{animation:ck-table-form-labeled-view-status-appear .15s ease both}.ck.ck-table-form .ck.ck-labeled-field-view .ck-input.ck-error:not(:focus)+.ck.ck-labeled-field-view__status{display:none}@keyframes ck-table-form-labeled-view-status-appear{0%{opacity:0}to{opacity:1}}'},function(e,t,o){var n=o(5),i=o(26);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row{flex-wrap:wrap}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:first-of-type{flex-grow:0.57}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar:last-of-type{flex-grow:0.43}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar .ck-button{flex-grow:1}.ck.ck-table-cell-properties-form{width:320px}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__padding-row{align-self:flex-end;padding:0;width:25%}.ck.ck-table-cell-properties-form .ck-form__row.ck-table-cell-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}"},function(e,t){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch(e){"object"==typeof window&&(o=window)}e.exports=o},function(e,t,o){var n=o(5),i=o(29);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=".ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{flex-wrap:wrap;flex-basis:0;align-content:baseline}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items{flex-wrap:nowrap}.ck.ck-table-properties-form{width:320px}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row{align-self:flex-end;padding:0}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar{background:none;margin-top:var(--ck-spacing-standard)}.ck.ck-table-properties-form .ck-form__row.ck-table-properties-form__alignment-row .ck.ck-toolbar .ck-toolbar__items>*{width:40px}"},function(e,t,o){var n=o(5),i=o(31);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);var r={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};n(i,r);e.exports=i.locals||{}},function(e,t){e.exports=":root{--ck-color-table-caption-background:#f7f7f7;--ck-color-table-caption-text:#333;--ck-color-table-caption-highlighted-background:#fd0}.ck-content .table>figcaption{display:table-caption;caption-side:top;word-break:break-word;text-align:center;color:var(--ck-color-table-caption-text);background-color:var(--ck-color-table-caption-background);padding:.6em;font-size:.75em;outline-offset:-1px}.ck.ck-editor__editable .table>figcaption.table__caption_highlighted{animation:ck-table-caption-highlight .6s ease-out}.ck.ck-editor__editable .table>figcaption.ck-placeholder:before{padding-left:inherit;padding-right:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes ck-table-caption-highlight{0%{background-color:var(--ck-color-table-caption-highlighted-background)}to{background-color:var(--ck-color-table-caption-background)}}"},function(e,t,o){"use strict";o.r(t),o.d(t,"Table",(function(){return He})),o.d(t,"TableEditing",(function(){return ye})),o.d(t,"TableUI",(function(){return Se})),o.d(t,"TableToolbar",(function(){return Ue})),o.d(t,"TableCellProperties",(function(){return go})),o.d(t,"TableCellPropertiesEditing",(function(){return bo})),o.d(t,"TableCellPropertiesUI",(function(){return Gt})),o.d(t,"TableProperties",(function(){return Bo})),o.d(t,"TablePropertiesEditing",(function(){return Ao})),o.d(t,"TablePropertiesUI",(function(){return Eo})),o.d(t,"TableCaption",(function(){return Wo})),o.d(t,"TableCaptionEditing",(function(){return Ho})),o.d(t,"TableCaptionUI",(function(){return Do})),o.d(t,"TableClipboard",(function(){return Pe})),o.d(t,"TableMouse",(function(){return Me})),o.d(t,"TableKeyboard",(function(){return Le})),o.d(t,"TableSelection",(function(){return Ie})),o.d(t,"TableUtils",(function(){return te}));var n=o(1),i=o(4);function r(e,t,o,n,i=1){t>i?n.setAttribute(e,t,o):n.removeAttribute(e,o)}function l(e,t,o={}){const n=e.createElement("tableCell",o);return e.insertElement("paragraph",n),e.insert(n,t),n}function s(e,t){const o=t.parent.parent,n=parseInt(o.getAttribute("headingColumns")||0),{column:i}=e.getCellLocation(t);return!!n&&i<n}var a=o(2);function c(){return e=>{e.on("element:table",(e,t,o)=>{const n=t.viewItem;if(!o.consumable.test(n,{name:!0}))return;const{rows:i,headingRows:r,headingColumns:s}=function(e){const t={headingRows:0,headingColumns:0},o=[],n=[];let i;for(const r of Array.from(e.getChildren()))if("tbody"===r.name||"thead"===r.name||"tfoot"===r.name){"thead"!==r.name||i||(i=r);const e=Array.from(r.getChildren()).filter(e=>e.is("element","tr"));for(const r of e)if("thead"===r.parent.name&&r.parent===i)t.headingRows++,o.push(r);else{n.push(r);const e=u(r);e>t.headingColumns&&(t.headingColumns=e)}}return t.rows=[...o,...n],t}(n),a={};s&&(a.headingColumns=s),r&&(a.headingRows=r);const c=o.writer.createElement("table",a);if(o.safeInsert(c,t.modelCursor)){if(o.consumable.consume(n,{name:!0}),i.forEach(e=>o.convertItem(e,o.writer.createPositionAt(c,"end"))),o.convertChildren(n,o.writer.createPositionAt(c,"end")),c.isEmpty){const e=o.writer.createElement("tableRow");o.writer.insert(e,o.writer.createPositionAt(c,"end")),l(o.writer,o.writer.createPositionAt(e,"end"))}o.updateConversionResult(c,t)}})}}function d(e){return t=>{t.on("element:"+e,(e,t,o)=>{if(t.modelRange&&t.viewItem.isEmpty){const e=t.modelRange.start.nodeAfter,n=o.writer.createPositionAt(e,0);o.writer.insertElement("paragraph",n)}},{priority:"low"})}}function u(e){let t=0,o=0;const n=Array.from(e.getChildren()).filter(e=>"th"===e.name||"td"===e.name);for(;o<n.length&&"th"===n[o].name;){const e=n[o];t+=parseInt(e.getAttribute("colspan")||1),o++}return t}class h{constructor(e,t={}){this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?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(){const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const o=this._getSpanned();if(o)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(o.cell,o.row,o.column));else{const o=e.getChild(this._cellIndex);if(!o)return this._advanceToNextRow();const n=parseInt(o.getAttribute("colspan")||1),i=parseInt(o.getAttribute("rowspan")||1);(n>1||i>1)&&this._recordSpans(o,i,n),this._shouldSkipSlot()||(t=this._formatOutValue(o)),this._nextCellAtColumn=this._column+n}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 void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,o=this._column){return{done:!1,value:new b(this,e,t,o)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,o=this._column<this._startColumn,n=void 0!==this._endColumn&&this._column>this._endColumn;return e||t||o||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,o){const n={cell:e,row:this._row,column:this._column};for(let e=this._row;e<this._row+t;e++)for(let t=this._column;t<this._column+o;t++)e==this._row&&t==this._column||this._markSpannedCell(e,t,n)}_markSpannedCell(e,t,o){this._spannedCells.has(e)||this._spannedCells.set(e,new Map);this._spannedCells.get(e).set(t,o)}}class b{constructor(e,t,o,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=o,this.cellAnchorColumn=n,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 m(e={}){return t=>t.on("insert:table",(t,o,n)=>{const r=o.item;if(!n.consumable.consume(r,"insert"))return;n.consumable.consume(r,"attribute:headingRows:table"),n.consumable.consume(r,"attribute:headingColumns:table");const l=e&&e.asWidget,s=n.writer.createContainerElement("figure",{class:"table"}),a=n.writer.createContainerElement("table");let c;var d,u;n.writer.insert(n.writer.createPositionAt(s,0),a),l&&(d=s,(u=n.writer).setCustomProperty("table",!0,d),c=Object(i.toWidget)(d,u,{hasSelectionHandle:!0}));const b=new h(r),m={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0},g=new Map;for(const t of b){const{row:o,cell:i}=t,l=r.getChild(o),s=g.get(o)||_(a,l,o,m,n);g.set(o,s),n.consumable.consume(i,"insert");w(t,m,n.writer.createPositionAt(s,"end"),n,e)}for(const e of r.getChildren()){const t=e.index;e.is("element","tableRow")&&!g.has(t)&&g.set(t,_(a,e,t,m,n))}const p=n.mapper.toViewPosition(o.range.start);n.mapper.bindElements(r,l?c:s),n.writer.insert(p,l?c:s)})}function g(e,t){const{writer:o}=t;if(e.parent.is("element","tableCell"))return p(e)?o.createContainerElement("span",{class:"ck-table-bogus-paragraph"}):o.createContainerElement("p")}function p(e){return 1===e.parent.childCount&&!y(e)}function f(e,t,o){const{cell:n}=e,r=k(e,t),l=o.mapper.toViewElement(n);l&&l.name!==r&&function(e,t,o){const n=o.writer,r=o.mapper.toViewElement(e),l=n.createEditableElement(t,r.getAttributes()),s=Object(i.toWidgetEditable)(l,n);n.insert(n.createPositionAfter(r),s),n.move(n.createRangeIn(r),n.createPositionAt(s,0)),n.remove(n.createRangeOn(r)),o.mapper.unbindViewElement(r),o.mapper.bindElements(e,s)}(n,r,o)}function w(e,t,o,n,r){const l=r&&r.asWidget,s=k(e,t),a=l?Object(i.toWidgetEditable)(n.writer.createEditableElement(s),n.writer):n.writer.createContainerElement(s),c=e.cell,d=c.getChild(0),u=1===c.childCount&&"paragraph"===d.name;if(n.writer.insert(o,a),n.mapper.bindElements(c,a),!l&&u&&!y(d)){const e=c.getChild(0);n.consumable.consume(e,"insert"),n.mapper.bindElements(e,a)}}function _(e,t,o,n,i){i.consumable.consume(t,"insert");const r=t.isEmpty?i.writer.createEmptyElement("tr"):i.writer.createContainerElement("tr");i.mapper.bindElements(t,r);const l=n.headingRows,s=function(e,t,o){const n=v(e,t);return n||function(e,t,o){const n=o.writer.createContainerElement(e),i=o.writer.createPositionAt(t,"tbody"==e?"end":0);return o.writer.insert(i,n),n}(e,t,o)}(function(e,t){return e<t.headingRows?"thead":"tbody"}(o,n),e,i),a=l>0&&o>=l?o-l:o,c=i.writer.createPositionAt(s,a);return i.writer.insert(c,r),r}function k(e,t){const{row:o,column:n}=e,{headingColumns:i,headingRows:r}=t;if(r&&r>o)return"th";return i&&i>n?"th":"td"}function v(e,t){for(const o of t.getChildren())if(o.name==e)return o}function C(e,t,o){const n=v(e,t);n&&0===n.childCount&&o.writer.remove(o.writer.createRangeOn(n))}function y(e){return!![...e.getAttributeKeys()].length}class T extends n.Command{refresh(){const e=this.editor.model,t=e.document.selection,o=e.schema;this.isEnabled=function(e,t){const o=e.getFirstPosition().parent,n=o===o.root?o:o.parent;return t.checkChild(n,"table")}(t,o)}execute(e={}){const t=this.editor.model,o=t.document.selection,n=this.editor.plugins.get("TableUtils"),r=this.editor.config.get("table"),l=Object(i.findOptimalInsertionRange)(o,t),s=r.defaultHeadings.rows,a=r.defaultHeadings.columns;void 0===e.headingRows&&s&&(e.headingRows=s),void 0===e.headingColumns&&a&&(e.headingColumns=a),t.change(o=>{const i=n.createTable(o,e);t.insertContent(i,l),o.setSelection(o.createPositionAt(i.getNodeByPath([0,0,0]),0))})}}function x(e){const t=[];for(const o of P(e.getRanges())){const e=o.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}function A(e){const t=[];for(const o of e.getRanges()){const e=o.start.findAncestor("tableCell");e&&t.push(e)}return t}function V(e){const t=x(e);return t.length?t:A(e)}function S(e){return E(e.map(e=>e.parent.index))}function R(e){const t=e[0].findAncestor("table");return E([...new h(t)].filter(t=>e.includes(t.cell)).map(e=>e.column))}function I(e,t){if(e.length<2||!function(e){const t=e[0].findAncestor("table"),o=S(e),n=parseInt(t.getAttribute("headingRows")||0);if(!O(o,n))return!1;const i=parseInt(t.getAttribute("headingColumns")||0);return O(R(e),i)}(e))return!1;const o=new Set,n=new Set;let i=0;for(const r of e){const{row:e,column:l}=t.getCellLocation(r),s=parseInt(r.getAttribute("rowspan")||1),a=parseInt(r.getAttribute("colspan")||1);o.add(e),n.add(l),s>1&&o.add(e+s-1),a>1&&n.add(l+a-1),i+=s*a}return function(e,t){const o=Array.from(e.values()),n=Array.from(t.values()),i=Math.max(...o),r=Math.min(...o),l=Math.max(...n),s=Math.min(...n);return(i-r+1)*(l-s+1)}(o,n)==i}function P(e){return Array.from(e).sort(B)}function E(e){const t=e.sort((e,t)=>e-t);return{first:t[0],last:t[t.length-1]}}function B(e,t){const o=e.start,n=t.start;return o.isBefore(n)?-1:1}function O({first:e,last:t},o){return e<o===t<o}class L extends n.Command{constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=!!V(this.editor.model.document.selection).length;this.isEnabled=e}execute(){const e=this.editor,t=e.model.document.selection,o=e.plugins.get("TableUtils"),n="above"===this.order,i=V(t),r=S(i),l=n?r.first:r.last,s=i[0].findAncestor("table");o.insertRows(s,{at:n?l:l+1,copyStructureFromAbove:!n})}}class N extends n.Command{constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=!!V(this.editor.model.document.selection).length;this.isEnabled=e}execute(){const e=this.editor,t=e.model.document.selection,o=e.plugins.get("TableUtils"),n="left"===this.order,i=V(t),r=R(i),l=n?r.first:r.last,s=i[0].findAncestor("table");o.insertColumns(s,{columns:1,at:n?l:l+1})}}class z extends n.Command{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=V(this.editor.model.document.selection)[0],t="horizontally"===this.direction,o=this.editor.plugins.get("TableUtils");t?o.splitCellHorizontally(e,2):o.splitCellVertically(e,2)}}function M(e,t,o){const{startRow:n,startColumn:i,endRow:s,endColumn:a}=t,c=o.createElement("table"),d=s-n+1;for(let e=0;e<d;e++)o.insertElement("tableRow",c,"end");const u=[...new h(e,{startRow:n,endRow:s,startColumn:i,endColumn:a,includeAllSlots:!0})];for(const{row:e,column:t,cell:r,isAnchor:d,cellAnchorRow:h,cellAnchorColumn:b}of u){const u=e-n,m=c.getChild(u);if(d){const n=o.cloneElement(r);o.append(n,m),j(n,e,t,s,a,o)}else(h<n||b<i)&&l(o,o.createPositionAt(m,"end"))}return function(e,t,o,n,i){const l=parseInt(t.getAttribute("headingRows")||0);if(l>0){r("headingRows",l-o,e,i,0)}const s=parseInt(t.getAttribute("headingColumns")||0);if(s>0){r("headingColumns",s-n,e,i,0)}}(c,e,n,i,o),c}function F(e,t,o=0){const n=[],i=new h(e,{startRow:o,endRow:t-1});for(const e of i){const{row:o,cellHeight:i}=e,r=o+i-1;o<t&&t<=r&&n.push(e)}return n}function H(e,t,o){const n=e.parent,i=n.parent,s=n.index,a=t-s,c={},d=parseInt(e.getAttribute("rowspan"))-a;d>1&&(c.rowspan=d);const u=parseInt(e.getAttribute("colspan")||1);u>1&&(c.colspan=u);const b=s+a,m=[...new h(i,{startRow:s,endRow:b,includeAllSlots:!0})];let g,p=null;for(const t of m){const{row:n,column:i,cell:r}=t;r===e&&void 0===g&&(g=i),void 0!==g&&g===i&&n===b&&(p=l(o,t.getPositionBefore(),c))}return r("rowspan",a,e,o),p}function D(e,t){const o=[],n=new h(e);for(const e of n){const{column:n,cellWidth:i}=e,r=n+i-1;n<t&&t<=r&&o.push(e)}return o}function W(e,t,o,n){const i=o-t,s={},a=parseInt(e.getAttribute("colspan"))-i;a>1&&(s.colspan=a);const c=parseInt(e.getAttribute("rowspan")||1);c>1&&(s.rowspan=c);const d=l(n,n.createPositionAfter(e),s);return r("colspan",i,e,n),d}function j(e,t,o,n,i,l){const s=parseInt(e.getAttribute("colspan")||1),a=parseInt(e.getAttribute("rowspan")||1);if(o+s-1>i){r("colspan",i-o+1,e,l,1)}if(t+a-1>n){r("rowspan",n-t+1,e,l,1)}}function U(e,t){const o=t.getColumns(e),n=new Array(o).fill(0);for(const{column:t}of new h(e))n[t]++;const i=n.reduce((e,t,o)=>t?e:[...e,o],[]);if(i.length>0){const o=i[i.length-1];return t.removeColumns(e,{at:o}),!0}return!1}function K(e,t){const o=[],n=t.getRows(e);for(let t=0;t<n;t++){e.getChild(t).isEmpty&&o.push(t)}if(o.length>0){const n=o[o.length-1];return t.removeRows(e,{at:n}),!0}return!1}function $(e,t){U(e,t)||K(e,t)}function q(e,t){const o=Array.from(new h(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(o.every(({cellHeight:e})=>1===e))return t.lastRow;const n=o[0].cellHeight-1;return t.lastRow+n}function G(e,t){const o=Array.from(new h(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(o.every(({cellWidth:e})=>1===e))return t.lastColumn;const n=o[0].cellWidth-1;return t.lastColumn+n}class J extends n.Command{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=A(e.document.selection)[0],o=this.value,n=this.direction;e.change(e=>{const i="right"==n||"down"==n,r=i?t:o,l=i?o:t,s=l.parent;!function(e,t,o){X(e)||(X(t)&&o.remove(o.createRangeIn(t)),o.move(o.createRangeIn(e),o.createPositionAt(t,"end")));o.remove(e)}(l,r,e);const a=this.isHorizontal?"colspan":"rowspan",c=parseInt(t.getAttribute(a)||1),d=parseInt(o.getAttribute(a)||1);e.setAttribute(a,c+d,r),e.setSelection(e.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");$(s.findAncestor("table"),u)})}_getMergeableCell(){const e=A(this.editor.model.document.selection)[0];if(!e)return;const t=this.editor.plugins.get("TableUtils"),o=this.isHorizontal?function(e,t,o){const n=e.parent.parent,i="right"==t?e.nextSibling:e.previousSibling,r=(n.getAttribute("headingColumns")||0)>0;if(!i)return;const l="right"==t?e:i,a="right"==t?i:e,{column:c}=o.getCellLocation(l),{column:d}=o.getCellLocation(a),u=parseInt(l.getAttribute("colspan")||1),h=s(o,l),b=s(o,a);if(r&&h!=b)return;return c+u===d?i:void 0}(e,this.direction,t):function(e,t,o){const n=e.parent,i=n.parent,r=i.getChildIndex(n);if("down"==t&&r===o.getRows(i)-1||"up"==t&&0===r)return;const l=parseInt(e.getAttribute("rowspan")||1),s=i.getAttribute("headingRows")||0,a="down"==t&&r+l===s,c="up"==t&&r===s;if(s&&(a||c))return;const d=parseInt(e.getAttribute("rowspan")||1),u="down"==t?r+d:r,b=[...new h(i,{endRow:u})],m=b.find(t=>t.cell===e).column,g=b.find(({row:e,cellHeight:o,column:n})=>n===m&&("down"==t?e===u:u===e+o));return g&&g.cell}(e,this.direction,t);if(!o)return;const n=this.isHorizontal?"rowspan":"colspan",i=parseInt(e.getAttribute(n)||1);return parseInt(o.getAttribute(n)||1)===i?o:void 0}}function X(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}class Y extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=e[0];if(t){const o=t.findAncestor("table"),n=this.editor.plugins.get("TableUtils").getRows(o)-1,i=S(e),r=0===i.first&&i.last===n;this.isEnabled=!r}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),o=V(e.document.selection),n=S(o),i=o[0],r=i.findAncestor("table"),l=t.getCellLocation(i).column;e.change(e=>{const o=n.last-n.first+1;t.removeRows(r,{at:n.first,rows:o});const i=function(e,t,o,n){const i=e.getChild(Math.min(t,n-1));let r=i.getChild(0),l=0;for(const e of i.getChildren()){if(l>o)return r;r=e,l+=parseInt(e.getAttribute("colspan")||1)}return r}(r,n.first,l,t.getRows(r));e.setSelection(e.createPositionAt(i,0))})}}class Q extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=e[0];if(t){const o=t.findAncestor("table"),n=this.editor.plugins.get("TableUtils").getColumns(o),{first:i,last:r}=R(e);this.isEnabled=r-i<n-1}else this.isEnabled=!1}execute(){const[e,t]=function(e){const t=V(e),o=t[0],n=t.pop(),i=[o,n];return o.isBefore(n)?i:i.reverse()}(this.editor.model.document.selection),o=e.parent.parent,n=[...new h(o)],i={first:n.find(t=>t.cell===e).column,last:n.find(e=>e.cell===t).column},r=function(e,t,o,n){return parseInt(o.getAttribute("colspan")||1)>1?o:t.previousSibling||o.nextSibling?o.nextSibling||t.previousSibling:n.first?e.reverse().find(({column:e})=>e<n.first).cell:e.reverse().find(({column:e})=>e>n.last).cell}(n,e,t,i);this.editor.model.change(e=>{const t=i.last-i.first+1;this.editor.plugins.get("TableUtils").removeColumns(o,{at:i.first,columns:t}),e.setSelection(e.createPositionAt(r,0))})}}class Z extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=e.length>0;this.isEnabled=t,this.value=t&&e.every(e=>this._isInHeading(e,e.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.model,o=V(t.document.selection),n=o[0].findAncestor("table"),{first:i,last:l}=S(o),s=this.value?i:l+1,a=n.getAttribute("headingRows")||0;t.change(e=>{if(s){const t=F(n,s,s>a?a:0);for(const{cell:o}of t)H(o,s,e)}r("headingRows",s,n,e,0)})}_isInHeading(e,t){const o=parseInt(t.getAttribute("headingRows")||0);return!!o&&e.parent.index<o}}class ee extends n.Command{refresh(){const e=V(this.editor.model.document.selection),t=this.editor.plugins.get("TableUtils"),o=e.length>0;this.isEnabled=o,this.value=o&&e.every(e=>s(t,e))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.model,o=V(t.document.selection),n=o[0].findAncestor("table"),{first:i,last:l}=R(o),s=this.value?i:l+1;t.change(e=>{if(s){const t=D(n,s);for(const{cell:o,column:n}of t)W(o,n,s,e)}r("headingColumns",s,n,e,0)})}}class te extends n.Plugin{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,o=t.parent,n=o.getChildIndex(t),i=new h(o,{row:n});for(const{cell:t,row:o,column:n}of i)if(t===e)return{row:o,column:n}}createTable(e,t){const o=e.createElement("table"),n=parseInt(t.rows)||2,i=parseInt(t.columns)||2;return oe(e,o,0,n,i),t.headingRows&&r("headingRows",Math.min(t.headingRows,n),o,e,0),t.headingColumns&&r("headingColumns",Math.min(t.headingColumns,i),o,e,0),o}insertRows(e,t={}){const o=this.editor.model,n=t.at||0,i=t.rows||1,s=void 0!==t.copyStructureFromAbove,c=t.copyStructureFromAbove?n-1:n,d=this.getRows(e),u=this.getColumns(e);if(n>d)throw new a.CKEditorError("tableutils-insertrows-insert-out-of-range",this,{options:t});o.change(t=>{const o=e.getAttribute("headingRows")||0;if(o>n&&r("headingRows",o+i,e,t,0),!s&&(0===n||n===d))return void oe(t,e,n,i,u);const a=s?Math.max(n,c):n,b=new h(e,{endRow:a}),m=new Array(u).fill(1);for(const{row:e,column:o,cellHeight:r,cellWidth:l,cell:a}of b){const d=e+r-1,u=e<=c&&c<=d;e<n&&n<=d?(t.setAttribute("rowspan",r+i,a),m[o]=-l):s&&u&&(m[o]=l)}for(let o=0;o<i;o++){const o=t.createElement("tableRow");t.insert(o,e,n);for(let e=0;e<m.length;e++){const n=m[e],i=t.createPositionAt(o,"end");n>0&&l(t,i,n>1?{colspan:n}:null),e+=Math.abs(n)-1}}})}insertColumns(e,t={}){const o=this.editor.model,n=t.at||0,i=t.columns||1;o.change(t=>{const o=e.getAttribute("headingColumns");n<o&&t.setAttribute("headingColumns",o+i,e);const r=this.getColumns(e);if(0===n||r===n){for(const o of e.getChildren())o.is("element","tableRow")&&ne(i,t,t.createPositionAt(o,n?"end":0));return}const l=new h(e,{column:n,includeAllSlots:!0});for(const e of l){const{row:o,cell:r,cellAnchorColumn:s,cellAnchorRow:a,cellWidth:c,cellHeight:d}=e;if(s<n){t.setAttribute("colspan",c+i,r);const e=a+d-1;for(let t=o;t<=e;t++)l.skipRow(t)}else ne(i,t,e.getPositionBefore())}})}removeRows(e,t){const o=this.editor.model,n=t.rows||1,i=this.getRows(e),l=t.at,s=l+n-1;if(s>i-1)throw new a.CKEditorError("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});o.change(t=>{const{cellsToMove:o,cellsToTrim:n}=function(e,t,o){const n=new Map,i=[];for(const{row:r,column:l,cellHeight:s,cell:a}of new h(e,{endRow:o})){const e=r+s-1;if(r>=t&&r<=o&&e>o){const e=s-(o-r+1);n.set(l,{cell:a,rowspan:e})}if(r<t&&e>=t){let n;n=e>=o?o-t+1:e-t+1,i.push({cell:a,rowspan:s-n})}}return{cellsToMove:n,cellsToTrim:i}}(e,l,s);if(o.size){!function(e,t,o,n){const i=[...new h(e,{includeAllSlots:!0,row:t})],l=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:a}of i)if(o.has(e)){const{cell:t,rowspan:i}=o.get(e),a=s?n.createPositionAfter(s):n.createPositionAt(l,0);n.move(n.createRangeOn(t),a),r("rowspan",i,t,n),s=t}else a&&(s=t)}(e,s+1,o,t)}for(let o=s;o>=l;o--)t.remove(e.getChild(o));for(const{rowspan:e,cell:o}of n)r("rowspan",e,o,t);!function(e,t,o,n){const i=e.getAttribute("headingRows")||0;if(t<i){r("headingRows",o<i?i-(o-t+1):t,e,n,0)}}(e,l,s,t),U(e,this)||K(e,this)})}removeColumns(e,t){const o=this.editor.model,n=t.at,i=t.columns||1,l=t.at+i-1;o.change(t=>{!function(e,t,o){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const i=Math.min(n-1,t.last)-t.first+1;o.setAttribute("headingColumns",n-i,e)}}(e,{first:n,last:l},t);for(let o=l;o>=n;o--)for(const{cell:n,column:i,cellWidth:l}of[...new h(e)])i<=o&&l>1&&i+l>o?r("colspan",l-1,n,t):i===o&&t.remove(n);K(e,this)||U(e,this)})}splitCellVertically(e,t=2){const o=this.editor.model,n=e.parent.parent,i=parseInt(e.getAttribute("rowspan")||1),l=parseInt(e.getAttribute("colspan")||1);o.change(o=>{if(l>1){const{newCellsSpan:n,updatedSpan:s}=ie(l,t);r("colspan",s,e,o);const a={};n>1&&(a.colspan=n),i>1&&(a.rowspan=i);ne(l>t?t-1:l-1,o,o.createPositionAfter(e),a)}if(l<t){const s=t-l,a=[...new h(n)],{column:c}=a.find(({cell:t})=>t===e),d=a.filter(({cell:t,cellWidth:o,column:n})=>t!==e&&n===c||n<c&&n+o>c);for(const{cell:e,cellWidth:t}of d)o.setAttribute("colspan",t+s,e);const u={};i>1&&(u.rowspan=i),ne(s,o,o.createPositionAfter(e),u);const b=n.getAttribute("headingColumns")||0;b>c&&r("headingColumns",b+s,n,o)}})}splitCellHorizontally(e,t=2){const o=this.editor.model,n=e.parent,i=n.parent,l=i.getChildIndex(n),s=parseInt(e.getAttribute("rowspan")||1),a=parseInt(e.getAttribute("colspan")||1);o.change(o=>{if(s>1){const n=[...new h(i,{startRow:l,endRow:l+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:d}=ie(s,t);r("rowspan",d,e,o);const{column:u}=n.find(({cell:t})=>t===e),b={};c>1&&(b.rowspan=c),a>1&&(b.colspan=a);for(const e of n){const{column:t,row:n}=e,i=t===u,r=(n+l+d)%c==0;n>=l+d&&i&&r&&ne(1,o,e.getPositionBefore(),b)}}if(s<t){const n=t-s,c=[...new h(i,{startRow:0,endRow:l})];for(const{cell:t,cellHeight:i,row:r}of c)if(t!==e&&r+i>l){const e=i+n;o.setAttribute("rowspan",e,t)}const d={};a>1&&(d.colspan=a),oe(o,i,l+1,n,1,d);const u=i.getAttribute("headingRows")||0;u>l&&r("headingRows",u+n,i,o)}})}getColumns(e){return[...e.getChild(0).getChildren()].reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||1),0)}getRows(e){return Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0)}}function oe(e,t,o,n,i,r={}){for(let l=0;l<n;l++){const n=e.createElement("tableRow");e.insert(n,t,o),ne(i,e,e.createPositionAt(n,"end"),r)}}function ne(e,t,o,n={}){for(let i=0;i<e;i++)l(t,o,n)}function ie(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const o=Math.floor(e/t);return{newCellsSpan:o,updatedSpan:e-o*t+o}}class re extends n.Command{refresh(){const e=x(this.editor.model.document.selection);this.isEnabled=I(e,this.editor.plugins.get(te))}execute(){const e=this.editor.model,t=this.editor.plugins.get(te);e.change(o=>{const n=x(e.document.selection),i=n.shift(),{mergeWidth:l,mergeHeight:s}=function(e,t,o){let n=0,i=0;for(const e of t){const{row:t,column:r}=o.getCellLocation(e);n=ae(e,r,n,"colspan"),i=ae(e,t,i,"rowspan")}const{row:r,column:l}=o.getCellLocation(e);return{mergeWidth:n-l,mergeHeight:i-r}}(i,n,t);r("colspan",l,i,o),r("rowspan",s,i,o);for(const e of n)le(e,i,o);$(i.findAncestor("table"),t),o.setSelection(i,"in")})}}function le(e,t,o){se(e)||(se(t)&&o.remove(o.createRangeIn(t)),o.move(o.createRangeIn(e),o.createPositionAt(t,"end"))),o.remove(e)}function se(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}function ae(e,t,o,n){const i=parseInt(e.getAttribute(n)||1);return Math.max(o,t+i)}class ce extends n.Command{refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=V(e.document.selection),o=S(t),n=t[0].findAncestor("table"),i=[];for(let t=o.first;t<=o.last;t++)for(const o of n.getChild(t).getChildren())i.push(e.createRangeOn(o));e.change(e=>{e.setSelection(i)})}}class de extends n.Command{refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=V(e.document.selection),o=t[0],n=t.pop(),i=o.findAncestor("table"),r=this.editor.plugins.get("TableUtils"),l=r.getCellLocation(o),s=r.getCellLocation(n),a=Math.min(l.column,s.column),c=Math.max(l.column,s.column),d=[];for(const t of new h(i,{startColumn:a,endColumn:c}))d.push(e.createRangeOn(t.cell));e.change(e=>{e.setSelection(d)})}}function ue(e){e.document.registerPostFixer(t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;const i=new Set;for(const t of o){let o;"table"==t.name&&"insert"==t.type&&(o=t.position.nodeAfter),"tableRow"!=t.name&&"tableCell"!=t.name||(o=t.position.findAncestor("table")),me(t)&&(o=t.range.start.findAncestor("table")),o&&!i.has(o)&&(n=he(o,e)||n,n=be(o,e)||n,i.add(o))}return n}(t,e))}function he(e,t){let o=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||0),o=Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0),n=[];for(const{row:i,cell:r,cellHeight:l}of new h(e)){if(l<2)continue;const e=i<t?t:o;if(i+l>e){const t=e-i;n.push({cell:r,rowspan:t})}}return n}(e);if(n.length){o=!0;for(const e of n)r("rowspan",e.rowspan,e.cell,t,1)}return o}function be(e,t){let o=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:o}of new h(e,{includeAllSlots:!0}))t[o]++;return t}(e),i=[];for(const[t,o]of n.entries())!o&&e.getChild(t).is("element","tableRow")&&i.push(t);if(i.length){o=!0;for(const o of i.reverse())t.remove(e.getChild(o)),n.splice(o,1)}const r=n.filter((t,o)=>e.getChild(o).is("element","tableRow")),s=r[0];if(!r.every(e=>e===s)){const n=r.reduce((e,t)=>t>e?t:e,0);for(const[i,s]of r.entries()){const r=n-s;if(r){for(let o=0;o<r;o++)l(t,t.createPositionAt(e.getChild(i),"end"));o=!0}}}return o}function me(e){const t="attribute"===e.type,o=e.attributeKey;return t&&("headingRows"===o||"colspan"===o||"rowspan"===o)}function ge(e){e.document.registerPostFixer(t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o)"insert"==t.type&&"table"==t.name&&(n=pe(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=fe(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=we(t.position.nodeAfter,e)||n),_e(t)&&(n=we(t.position.parent,e)||n);return n}(t,e))}function pe(e,t){let o=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(o=fe(n,t)||o);return o}function fe(e,t){let o=!1;for(const n of e.getChildren())o=we(n,t)||o;return o}function we(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const o=Array.from(e.getChildren()).filter(e=>e.is("$text"));for(const e of o)t.wrap(t.createRangeOn(e),"paragraph");return!!o.length}function _e(e){return!(!e.position||!e.position.parent.is("element","tableCell"))&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function ke(e,t){e.document.registerPostFixer(()=>function(e,t){const o=new Set;for(const t of e.getChanges()){const e="attribute"==t.type?t.range.start.parent:t.position.parent;e.is("element","tableCell")&&o.add(e)}for(const n of o.values())for(const o of[...n.getChildren()].filter(e=>ve(e,t)))e.refreshItem(o);return!1}(e.document.differ,t))}function ve(e,t){if(!e.is("element","paragraph"))return!1;const o=t.toViewElement(e);return!!o&&p(e)!==o.is("element","span")}function Ce(e){e.document.registerPostFixer(()=>function(e){const t=e.document.differ,o=new Set;for(const e of t.getChanges())if("attribute"===e.type){const t=e.range.start.nodeAfter;t&&t.is("element","table")&&"headingRows"===e.attributeKey&&o.add(t)}else if("insert"===e.type||"remove"===e.type)if("tableRow"===e.name){const t=e.position.findAncestor("table"),n=t.getAttribute("headingRows")||0;e.position.offset<n&&o.add(t)}else if("tableCell"===e.name){const t=e.position.findAncestor("table"),n=t.getAttribute("headingColumns")||0;e.position.offset<n&&o.add(t)}if(o.size){for(const e of o.values())t.refreshItem(e);return!0}return!1}(e))}o(11);class ye extends n.Plugin{static get pluginName(){return"TableEditing"}init(){const e=this.editor,t=e.model,o=t.schema,n=e.conversion;o.register("table",{allowWhere:"$block",allowAttributes:["headingRows","headingColumns"],isObject:!0,isBlock:!0}),o.register("tableRow",{allowIn:"table",isLimit:!0}),o.register("tableCell",{allowIn:"tableRow",allowChildren:"$block",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add(e=>{e.on("element:figure",(e,t,o)=>{if(!o.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!n||!o.consumable.test(n,{name:!0}))return;const i=o.convertItem(n,t.modelCursor),r=Object(a.first)(i.modelRange.getItems());r&&(o.consumable.consume(t.viewItem,{name:!0,classes:"table"}),o.convertChildren(t.viewItem,o.writer.createPositionAt(r,"end")),o.updateConversionResult(r,t))})}),n.for("upcast").add(c()),n.for("editingDowncast").add(m({asWidget:!0})),n.for("dataDowncast").add(m()),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add(e=>{e.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()},{priority:"high"})}),n.for("editingDowncast").add(e=>e.on("insert:tableRow",(e,t,o)=>{const n=t.item;if(!o.consumable.consume(n,"insert"))return;const i=n.parent,r=function(e){for(const t of e.getChildren())if("table"===t.name)return t}(o.mapper.toViewElement(i)),l=i.getChildIndex(n),s=new h(i,{row:l}),a={headingRows:i.getAttribute("headingRows")||0,headingColumns:i.getAttribute("headingColumns")||0},c=new Map;for(const e of s){const t=c.get(l)||_(r,n,l,a,o);c.set(l,t),o.consumable.consume(e.cell,"insert"),w(e,a,o.writer.createPositionAt(t,"end"),o,{asWidget:!0})}})),n.for("editingDowncast").add(e=>e.on("remove:tableRow",(e,t,o)=>{e.stop();const n=o.writer,i=o.mapper,r=i.toViewPosition(t.position).getLastMatchingPosition(e=>!e.item.is("element","tr")).nodeAfter,l=r.parent.parent,s=n.createRangeOn(r),a=n.remove(s);for(const e of n.createRangeIn(a).getItems())i.unbindViewElement(e);C("thead",l,o),C("tbody",l,o)},{priority:"higher"})),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(d("td")),n.for("upcast").add(d("th")),n.for("editingDowncast").add(e=>e.on("insert:tableCell",(e,t,o)=>{const n=t.item;if(!o.consumable.consume(n,"insert"))return;const i=n.parent,r=i.parent,l=r.getChildIndex(i),s=new h(r,{row:l}),a={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0};for(const e of s)if(e.cell===n){const t=o.mapper.toViewElement(i);return void w(e,a,o.writer.createPositionAt(t,i.getChildIndex(n)),o,{asWidget:!0})}})),n.for("editingDowncast").elementToElement({model:"paragraph",view:g,converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:Te("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Te("rowspan")},view:"rowspan"}),n.for("editingDowncast").add(e=>e.on("attribute:headingColumns:table",(e,t,o)=>{const n=t.item;if(!o.consumable.consume(t.item,e.name))return;const i={headingRows:n.getAttribute("headingRows")||0,headingColumns:n.getAttribute("headingColumns")||0},r=t.attributeOldValue,l=t.attributeNewValue,s=(r>l?r:l)-1;for(const e of new h(n,{endColumn:s}))f(e,i,o)})),e.data.mapper.on("modelToViewPosition",(e,t)=>{const o=t.modelPosition.parent,n=t.modelPosition.nodeBefore;if(!o.is("element","tableCell"))return;if(!n||!n.is("element","paragraph"))return;const i=t.mapper.toViewElement(n),r=t.mapper.toViewElement(o);i===r&&(t.viewPosition=t.mapper.findPositionIn(r,n.maxOffset))}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new T(e)),e.commands.add("insertTableRowAbove",new L(e,{order:"above"})),e.commands.add("insertTableRowBelow",new L(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new N(e,{order:"left"})),e.commands.add("insertTableColumnRight",new N(e,{order:"right"})),e.commands.add("removeTableRow",new Y(e)),e.commands.add("removeTableColumn",new Q(e)),e.commands.add("splitTableCellVertically",new z(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new z(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new re(e)),e.commands.add("mergeTableCellRight",new J(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new J(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new J(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new J(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new ee(e)),e.commands.add("setTableRowHeader",new Z(e)),e.commands.add("selectTableRow",new ce(e)),e.commands.add("selectTableColumn",new de(e)),Ce(t),ue(t),ke(t,e.editing.mapper),ge(t)}static get requires(){return[te]}}function Te(e){return t=>{const o=parseInt(t.getAttribute(e));return Number.isNaN(o)||o<=0?null:o}}var xe=o(0);o(13);class Ae extends xe.View{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(e,t)=>`${t} × ${e}`),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-insert-table-dropdown__label"]},children:[{text:t.to("label")}]}],on:{mousedown:t.to(e=>{e.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(e,t)=>{const{row:o,column:n}=t.target.dataset;this.set({rows:parseInt(o),columns:parseInt(n)})}),this.on("change:columns",()=>{this._highlightGridBoxes()}),this.on("change:rows",()=>{this._highlightGridBoxes()})}focus(){}focusLast(){}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((o,n)=>{const i=Math.floor(n/10)<e&&n%10<t;o.set("isOn",i)})}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const o=Math.floor(t/10),n=t%10;e.push(new Ve(this.locale,o+1,n+1))}return this.createCollection(e)}}class Ve extends xe.View{constructor(e,t,o){super(e);const n=this.bindTemplate;this.set("isOn",!1),this.setTemplate({tag:"div",attributes:{class:["ck-insert-table-dropdown-grid-box",n.if("isOn","ck-on")],"data-row":t,"data-column":o}})}}class Se extends n.Plugin{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,o="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",o=>{const n=e.commands.get("insertTable"),i=Object(xe.createDropdown)(o);let r;return i.bind("isEnabled").to(n),i.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',label:t("Insert table"),tooltip:!0}),i.on("change:isOpen",()=>{r||(r=new Ae(o),i.panelView.children.add(r),r.delegate("execute").to(i),i.buttonView.on("open",()=>{r.rows=0,r.columns=0}),i.on("execute",()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()}))}),i}),e.ui.componentFactory.add("tableColumn",e=>{const n=[{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"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',n,e)}),e.ui.componentFactory.add("tableRow",e=>{const o=[{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"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',o,e)}),e.ui.componentFactory.add("mergeTableCells",e=>{const n=[{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"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',n,e)})}_prepareDropdown(e,t,o,n){const i=this.editor,r=Object(xe.createDropdown)(n),l=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(l,"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(r,"execute",e=>{i.execute(e.source.commandName),i.editing.view.focus()}),r}_prepareMergeSplitButtonDropdown(e,t,o,n){const i=this.editor,r=Object(xe.createDropdown)(n,xe.SplitButtonView),l=i.commands.get("mergeTableCells"),s=this._fillDropdownWithListOptions(r,o);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([l,...s],"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(r.buttonView,"execute",()=>{i.execute("mergeTableCells"),i.editing.view.focus()}),this.listenTo(r,"execute",e=>{i.execute(e.source.commandName),i.editing.view.focus()}),r}_fillDropdownWithListOptions(e,t){const o=this.editor,n=[],i=new a.Collection;for(const e of t)Re(e,o,n,i);return Object(xe.addListToDropdown)(e,i,o.ui.componentFactory),n}}function Re(e,t,o,n){const i=e.model=new xe.Model(e.model),{commandName:r,bindIsOn:l}=e.model;if("button"===e.type||"switchbutton"===e.type){const e=t.commands.get(r);o.push(e),i.set({commandName:r}),i.bind("isEnabled").to(e),l&&i.bind("isOn").to(e,"value")}i.set({withText:!0}),n.add(e)}o(15);class Ie extends n.Plugin{static get pluginName(){return"TableSelection"}static get requires(){return[te]}init(){const e=this.editor.model;this.listenTo(e,"deleteContent",(e,t)=>this._handleDeleteContent(e,t),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=x(this.editor.model.document.selection);return 0==e.length?null:e}getSelectionAsFragment(){const e=this.getSelectedTableCells();return e?this.editor.model.change(t=>{const o=t.createDocumentFragment(),n=this.editor.plugins.get("TableUtils"),{first:i,last:r}=R(e),{first:l,last:s}=S(e),a=e[0].findAncestor("table");let c=s,d=r;if(I(e,n)){const e={firstColumn:i,lastColumn:r,firstRow:l,lastRow:s};c=q(a,e),d=G(a,e)}const u=M(a,{startRow:l,startColumn:i,endRow:c,endColumn:d},t);return t.insert(u,o,0),o}):null}setCellSelection(e,t){const o=this._getCellsToSelect(e,t);this.editor.model.change(e=>{e.setSelection(o.cells.map(t=>e.createRangeOn(t)),{backward:o.backward})})}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=this.editor.model.document.selection,t=Object(a.first)(e.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(e=>e.on("selection",(e,o,n)=>{const i=n.writer;!function(e){for(const o of t)e.removeClass("ck-editor__editable_selected",o);t.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const o=n.mapper.toViewElement(e);i.addClass("ck-editor__editable_selected",o),t.add(o)}const l=n.mapper.toViewElement(r[r.length-1]);i.setSelection(l,0)},{priority:"lowest"}))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(o=>{const n=o.createPositionAt(t[0],0),i=e.model.schema.getNearestSelectionRange(n);o.setSelection(i)})}})}_handleDeleteContent(e,t){const[o,n]=t,i=this.editor.model,r=!n||"backward"==n.direction,l=x(o);l.length&&(e.stop(),i.change(e=>{const t=l[r?l.length-1:0];i.change(e=>{for(const t of l)i.deleteContent(e.createSelection(t,"in"))});const n=i.schema.getNearestSelectionRange(e.createPositionAt(t,0));o.is("documentSelection")?e.setSelection(n):o.setTo(n)}))}_getCellsToSelect(e,t){const o=this.editor.plugins.get("TableUtils"),n=o.getCellLocation(e),i=o.getCellLocation(t),r=Math.min(n.row,i.row),l=Math.max(n.row,i.row),s=Math.min(n.column,i.column),a=Math.max(n.column,i.column),c=new Array(l-r+1).fill(null).map(()=>[]),d={startRow:r,endRow:l,startColumn:s,endColumn:a};for(const{row:t,cell:o}of new h(e.findAncestor("table"),d))c[t-r].push(o);const u=i.row<n.row,b=i.column<n.column;return u&&c.reverse(),b&&c.forEach(e=>e.reverse()),{cells:c.flat(),backward:u||b}}}class Pe extends n.Plugin{static get pluginName(){return"TableClipboard"}static get requires(){return[Ie,te]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",(e,t)=>this._onCopyCut(e,t)),this.listenTo(t,"cut",(e,t)=>this._onCopyCut(e,t)),this.listenTo(e.model,"insertContent",(e,t)=>this._onInsertContent(e,...t),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const o=this.editor.plugins.get(Ie);if(!o.getSelectedTableCells())return;if("cut"==e.name&&this.editor.isReadOnly)return;t.preventDefault(),e.stop();const n=this.editor.data,i=this.editor.editing.view.document,r=n.toView(o.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,o){if(o&&!o.is("documentSelection"))return;const n=this.editor.model,i=this.editor.plugins.get(te);let r=function(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const o=t.createRangeIn(e);for(const e of o.getItems())if(e.is("element","table")){const n=t.createRange(o.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const i=t.createRange(t.createPositionAfter(e),o.end);return t.hasContent(i,{ignoreWhitespaces:!0})?null:e}return null}(t,n);if(!r)return;const l=V(n.document.selection);l.length?(e.stop(),n.change(e=>{const t={width:i.getColumns(r),height:i.getRows(r)},o=function(e,t,o,n){const i=e[0].findAncestor("table"),r=R(e),l=S(e),s={firstColumn:r.first,lastColumn:r.last,firstRow:l.first,lastRow:l.last},a=1===e.length;a&&(s.lastRow+=t.height-1,s.lastColumn+=t.width-1,function(e,t,o,n){const i=n.getColumns(e),r=n.getRows(e);o>i&&n.insertColumns(e,{at:i,columns:o-i});t>r&&n.insertRows(e,{at:r,rows:t-r})}(i,s.lastRow+1,s.lastColumn+1,n));a||!I(e,n)?function(e,t,o){const{firstRow:n,lastRow:i,firstColumn:r,lastColumn:l}=t,s={first:n,last:i},a={first:r,last:l};Be(e,r,s,o),Be(e,l+1,s,o),Ee(e,n,a,o),Ee(e,i+1,a,o,n)}(i,s,o):(s.lastRow=q(i,s),s.lastColumn=G(i,s));return s}(l,t,e,i),n=o.lastRow-o.firstRow+1,s=o.lastColumn-o.firstColumn+1,a={startRow:0,startColumn:0,endRow:Math.min(n,t.height)-1,endColumn:Math.min(s,t.width)-1};r=M(r,a,e);const c=l[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,c,o,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=P(d.map(t=>e.createRangeOn(t)));e.setSelection(t)}else e.setSelection(d[0],0)})):$(r,i)}_replaceSelectedCellsWithPasted(e,t,o,n,i){const{width:r,height:l}=t,s=function(e,t,o){const n=new Array(o).fill(null).map(()=>new Array(t).fill(null));for(const{column:t,row:o,cell:i}of new h(e))n[o][t]=i;return n}(e,r,l),a=[...new h(o,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let d;for(const e of a){const{row:t,column:o}=e;o===n.firstColumn&&(d=e.getPositionBefore());const a=t-n.firstRow,u=o-n.firstColumn,h=s[a%l][u%r],b=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(e,b,d,i);m&&(j(m,t,o,n.lastRow,n.lastColumn,i),c.push(m),d=i.createPositionAfter(m))}const u=parseInt(o.getAttribute("headingRows")||0),b=parseInt(o.getAttribute("headingColumns")||0),m=n.firstRow<u&&u<=n.lastRow,g=n.firstColumn<b&&b<=n.lastColumn;if(m){const e=Ee(o,u,{first:n.firstColumn,last:n.lastColumn},i,n.firstRow);c.push(...e)}if(g){const e=Be(o,b,{first:n.firstRow,last:n.lastRow},i);c.push(...e)}return c}_replaceTableSlotCell(e,t,o,n){const{cell:i,isAnchor:r}=e;return r&&n.remove(i),t?(n.insert(t,o),t):null}}function Ee(e,t,o,n,i=0){if(t<1)return;return F(e,t,i).filter(({column:e,cellWidth:t})=>Oe(e,t,o)).map(({cell:e})=>H(e,t,n))}function Be(e,t,o,n){if(t<1)return;return D(e,t).filter(({row:e,cellHeight:t})=>Oe(e,t,o)).map(({cell:e,column:o})=>W(e,o,t,n))}function Oe(e,t,o){const n=e+t-1,{first:i,last:r}=o;return e>=i&&e<=r||e<i&&n>=i}class Le extends n.Plugin{static get pluginName(){return"TableKeyboard"}static get requires(){return[Ie]}init(){const e=this.editor.editing.view.document;this.editor.keystrokes.set("Tab",(...e)=>this._handleTabOnSelectedTable(...e),{priority:"low"}),this.editor.keystrokes.set("Tab",this._getTabHandler(!0),{priority:"low"}),this.editor.keystrokes.set("Shift+Tab",this._getTabHandler(!1),{priority:"low"}),this.listenTo(e,"arrowKey",(...e)=>this._onArrowKey(...e),{context:"table"})}_handleTabOnSelectedTable(e,t){const o=this.editor,n=o.model.document.selection.getSelectedElement();n&&n.is("element","table")&&(t(),o.model.change(e=>{e.setSelection(e.createRangeIn(n.getChild(0).getChild(0)))}))}_getTabHandler(e){const t=this.editor;return(o,n)=>{let i=A(t.model.document.selection)[0];if(i||(i=this.editor.plugins.get("TableSelection").getFocusCell()),!i)return;n();const r=i.parent,l=r.parent,s=l.getChildIndex(r),a=r.getChildIndex(i),c=0===a;if(!e&&c&&0===s)return void t.model.change(e=>{e.setSelection(e.createRangeOn(l))});const d=this.editor.plugins.get("TableUtils"),u=a===r.childCount-1,h=s===d.getRows(l)-1;if(e&&h&&u&&(t.execute("insertTableRowBelow"),s===d.getRows(l)-1))return void t.model.change(e=>{e.setSelection(e.createRangeOn(l))});let b;if(e&&u){const e=l.getChild(s+1);b=e.getChild(0)}else if(!e&&c){const e=l.getChild(s-1);b=e.getChild(e.childCount-1)}else b=r.getChild(a+(e?1:-1));t.model.change(e=>{e.setSelection(e.createRangeIn(b))})}}_onArrowKey(e,t){const o=this.editor,n=t.keyCode,i=Object(a.getLocalizedArrowKeyCodeDirection)(n,o.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const o=this.editor.model,n=o.document.selection,i=["right","down"].includes(e),r=x(n);if(r.length){let o;return o=t?this.editor.plugins.get("TableSelection").getFocusCell():i?r[r.length-1]:r[0],this._navigateFromCellInDirection(o,e,t),!0}const l=n.focus.findAncestor("tableCell");if(!l)return!1;if(!n.isCollapsed)if(t){if(n.isBackward==i&&!n.containsEntireContent(l))return!1}else{const e=n.getSelectedElement();if(!e||!o.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(n,l,i)&&(this._navigateFromCellInDirection(l,e,t),!0)}_isSelectionAtCellEdge(e,t,o){const n=this.editor.model,i=this.editor.model.schema,r=o?e.getLastPosition():e.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell")){return n.createPositionAt(t,o?"end":0).isTouching(r)}const l=n.createSelection(r);return n.modifySelection(l,{direction:o?"forward":"backward"}),r.isEqual(l.focus)}_navigateFromCellInDirection(e,t,o=!1){const n=this.editor.model,i=e.findAncestor("table"),r=[...new h(i,{includeAllSlots:!0})],{row:l,column:s}=r[r.length-1],a=r.find(({cell:t})=>t==e);let{row:c,column:d}=a;switch(t){case"left":d--;break;case"up":c--;break;case"right":d+=a.cellWidth;break;case"down":c+=a.cellHeight}if(c<0||c>l||d<0&&c<=0||d>s&&c>=l)return void n.change(e=>{e.setSelection(e.createRangeOn(i))});d<0?(d=o?0:s,c--):d>s&&(d=o?s:0,c++);const u=r.find(e=>e.row==c&&e.column==d).cell,b=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(o&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=n.createPositionAt(u,b?0:"end");n.change(t=>{t.setSelection(e)})}}}var Ne=o(3);class ze extends Ne.DomEventObserver{constructor(e){super(e),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class Me extends n.Plugin{static get pluginName(){return"TableMouse"}static get requires(){return[Ie]}init(){this.editor.editing.view.addObserver(ze),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor;let t=!1;const o=e.plugins.get(Ie);this.listenTo(e.editing.view.document,"mousedown",(n,i)=>{if(!this.isEnabled||!o.isEnabled)return;if(!i.domEvent.shiftKey)return;const r=o.getAnchorCell()||A(e.model.document.selection)[0];if(!r)return;const l=this._getModelTableCellFromDomEvent(i);l&&Fe(r,l)&&(t=!0,o.setCellSelection(r,l),i.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{t=!1}),this.listenTo(e.editing.view.document,"selectionChange",e=>{t&&e.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,o,n=!1,i=!1;const r=e.plugins.get(Ie);this.listenTo(e.editing.view.document,"mousedown",(e,o)=>{this.isEnabled&&r.isEnabled&&(o.domEvent.shiftKey||o.domEvent.ctrlKey||o.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(o)))}),this.listenTo(e.editing.view.document,"mousemove",(e,l)=>{if(!l.domEvent.buttons)return;if(!t)return;const s=this._getModelTableCellFromDomEvent(l);s&&Fe(t,s)&&(o=s,n||o==t||(n=!0)),n&&(i=!0,r.setCellSelection(t,o),l.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1,i=!1,t=null,o=null}),this.listenTo(e.editing.view.document,"selectionChange",e=>{i&&e.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,o=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(o).parent.findAncestor("tableCell",{includeSelf:!0})}}function Fe(e,t){return e.parent.parent==t.parent.parent}o(17);class He extends n.Plugin{static get requires(){return[ye,Se,Ie,Me,Le,Pe,i.Widget]}static get pluginName(){return"Table"}}function De(e){const t=e.getSelectedElement();return t&&je(t)?t:null}function We(e){let t=e.getFirstPosition().parent;for(;t;){if(t.is("element")&&je(t))return t;t=t.parent}return null}function je(e){return!!e.getCustomProperty("table")&&Object(i.isWidget)(e)}class Ue extends n.Plugin{static get requires(){return[i.WidgetToolbarRepository]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,o=e.plugins.get(i.WidgetToolbarRepository),n=e.config.get("table.contentToolbar"),r=e.config.get("table.tableToolbar");n&&o.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:We}),r&&o.register("table",{ariaLabel:t("Table toolbar"),items:r,getRelatedElement:De})}}o(19);class Ke extends xe.View{constructor(e,t){super(e);const o=this.bindTemplate;this.set("value",""),this.set("id"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.set("ariaDescribedById"),this.options=t,this._dropdownView=this._createDropdownView(),this._inputView=this._createInputTextView(),this._stillTyping=!1,this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color",o.if("hasError","ck-error")],id:o.to("id"),"aria-invalid":o.if("hasError",!0),"aria-describedby":o.to("ariaDescribedById")},children:[this._dropdownView,this._inputView]}),this.on("change:value",(e,t,o)=>this._setInputValue(o))}focus(){this._inputView.focus()}_createDropdownView(){const e=this.locale,t=e.t,o=this.bindTemplate,n=this._createColorGrid(e),i=Object(xe.createDropdown)(e),r=new xe.View,l=this._createRemoveColorButton();return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:o.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",o.if("value","ck-hidden",e=>""!=e)]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.tooltip=t("Color picker"),i.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",i.panelView.children.add(l),i.panelView.children.add(n),i.bind("isEnabled").to(this,"isReadOnly",e=>!e),i}_createInputTextView(){const e=this.locale,t=new xe.InputTextView(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 e=t.element.value,o=this.options.colorDefinitions.find(t=>e===t.label);this._stillTyping=!0,this.value=o&&o.color||e}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createRemoveColorButton(){const e=this.locale,t=e.t,o=new xe.ButtonView(e),i=this.options.defaultColorValue||"",r=t(i?"Restore default":"Remove color");return o.class="ck-input-color__remove-color",o.withText=!0,o.icon=n.icons.eraser,o.label=r,o.on("execute",()=>{this.value=i,this._dropdownView.isOpen=!1,this.fire("input")}),o}_createColorGrid(e){const t=new xe.ColorGridView(e,{colorDefinitions:this.options.colorDefinitions,columns:this.options.columns});return t.on("execute",(e,t)=>{this.value=t.value,this._dropdownView.isOpen=!1,this.fire("input")}),t.bind("selectedColor").to(this,"value"),t}_setInputValue(e){if(!this._stillTyping){const t=$e(e),o=this.options.colorDefinitions.find(e=>t===$e(e.color));this._inputView.value=o?o.label:e||""}}}function $e(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const qe=e=>""===e;function Ge(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function Je(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function Xe(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function Ye(e){return e=e.trim(),qe(e)||Object(Ne.isColor)(e)}function Qe(e){return e=e.trim(),qe(e)||it(e)||Object(Ne.isLength)(e)||Object(Ne.isPercentage)(e)}function Ze(e){return e=e.trim(),qe(e)||it(e)||Object(Ne.isLength)(e)}function et(e,t){const o=new a.Collection,n=Ge(e.t);for(const i in n){const r={type:"button",model:new xe.Model({_borderStyleValue:i,label:n[i],withText:!0})};"none"===i?r.model.bind("isOn").to(e,"borderStyle",e=>"none"===t?!e:e===i):r.model.bind("isOn").to(e,"borderStyle",e=>e===i),o.add(r)}return o}function tt(e){const{view:t,icons:o,toolbar:n,labels:i,propertyName:r,nameToValue:l,defaultValue:s}=e;for(const e in i){const a=new xe.ButtonView(t.locale);a.set({label:i[e],icon:o[e],tooltip:i[e]});const c=l?l(e):e;a.bind("isOn").to(t,r,e=>{let t=e;return""===e&&s&&(t=s),c===t}),a.on("execute",()=>{t[r]=c}),n.items.add(a)}}const ot=[{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 nt(e){return(t,o,n)=>{const i=new Ke(t.locale,{colorDefinitions:(r=e.colorConfig,r.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))),columns:e.columns,defaultColorValue:e.defaultColorValue});var r;return i.set({id:o,ariaDescribedById:n}),i.bind("isReadOnly").to(t,"isEnabled",e=>!e),i.bind("hasError").to(t,"errorText",e=>!!e),i.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(i),i}}function it(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}o(21);class rt extends xe.View{constructor(e,t={}){super(e);const o=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach(e=>this.children.add(e)),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",o.to("class")],role:o.to("_role"),"aria-labelledby":o.to("_ariaLabelledBy")},children:this.children})}}o(8),o(9),o(25);const lt={left:n.icons.alignLeft,center:n.icons.alignCenter,right:n.icons.alignRight,justify:n.icons.alignJustify,top:n.icons.alignTop,middle:n.icons.alignMiddle,bottom:n.icons.alignBottom};class st extends xe.View{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:c,operatorLabel:d,heightInput:u,dimensionsLabel:h}=this._createDimensionFields(),{horizontalAlignmentToolbar:b,verticalAlignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new a.FocusTracker,this.keystrokes=new a.KeystrokeHandler,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=u,this.horizontalAlignmentToolbar=b,this.verticalAlignmentToolbar=m;const{saveButtonView:p,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=p,this.cancelButtonView=f,this._focusables=new xe.ViewCollection,this._focusCycler=new xe.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new xe.FormHeaderView(e,{label:this.t("Cell properties")})),this.children.add(new rt(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new rt(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new rt(e,{children:[new rt(e,{labelView:h,children:[h,c,d,u],class:"ck-table-form__dimensions-row"}),new rt(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new rt(e,{labelView:g,children:[g,b,m],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new rt(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(),Object(xe.submitHandler)({view:this}),[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)}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=nt({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color}),n=this.locale,i=this.t,r=new xe.LabelView(n);r.text=i("Border");const l=Ge(i),s=new xe.LabeledFieldView(n,xe.createLabeledDropdown);s.set({label:i("Style"),class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>l[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),Object(xe.addListToDropdown)(s.fieldView,et(this,t.style));const a=new xe.LabeledFieldView(n,xe.createLabeledInputText);a.set({label:i("Width"),class:"ck-table-form__border-width"}),a.fieldView.bind("value").to(this,"borderWidth"),a.bind("isEnabled").to(this,"borderStyle",at),a.fieldView.on("input",()=>{this.borderWidth=a.fieldView.element.value});const c=new xe.LabeledFieldView(n,o);return c.set({label:i("Color"),class:"ck-table-form__border-color"}),c.fieldView.bind("value").to(this,"borderColor"),c.bind("isEnabled").to(this,"borderStyle",at),c.fieldView.on("input",()=>{this.borderColor=c.fieldView.value}),this.on("change:borderStyle",(e,o,n,i)=>{at(n)||(this.borderColor="",this.borderWidth=""),at(i)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:c,borderWidthInput:a}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Background");const n=nt({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor}),i=new xe.LabeledFieldView(e,n);return i.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",()=>{this.backgroundColor=i.fieldView.value}),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Dimensions");const n=new xe.LabeledFieldView(e,xe.createLabeledInputText);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const i=new xe.View(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new xe.LabeledFieldView(e,xe.createLabeledInputText);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createPaddingField(){const e=this.locale,t=this.t,o=new xe.LabeledFieldView(e,xe.createLabeledInputText);return o.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),o.fieldView.bind("value").to(this,"padding"),o.fieldView.on("input",()=>{this.padding=o.fieldView.element.value}),o}_createAlignmentFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Table cell text alignment");const n=new xe.ToolbarView(e),i="rtl"===this.locale.contentLanguageDirection;n.set({isCompact:!0,ariaLabel:t("Horizontal text alignment toolbar")}),tt({view:this,icons:lt,toolbar:n,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(i){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new xe.ToolbarView(e);return r.set({isCompact:!0,ariaLabel:t("Vertical text alignment toolbar")}),tt({view:this,icons:lt,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:n,verticalAlignmentToolbar:r,alignmentLabel:o}}_createActionButtons(){const e=this.locale,t=this.t,o=new xe.ButtonView(e),i=new xe.ButtonView(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return o.set({label:t("Save"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0}),o.bind("isEnabled").toMany(r,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:o,cancelButtonView:i}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,o=t("Align cell text to the left"),n=t("Align cell text to the center"),i=t("Align cell text to the right"),r=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o,justify:r}:{left:o,center:n,right:i,justify:r}}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 at(e){return"none"!==e}var ct=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},dt=o(10),ut="object"==typeof self&&self&&self.Object===Object&&self,ht=dt.a||ut||Function("return this")(),bt=function(){return ht.Date.now()},mt=/\s/;var gt=function(e){for(var t=e.length;t--&&mt.test(e.charAt(t)););return t},pt=/^\s+/;var ft=function(e){return e?e.slice(0,gt(e)+1).replace(pt,""):e},wt=ht.Symbol,_t=Object.prototype,kt=_t.hasOwnProperty,vt=_t.toString,Ct=wt?wt.toStringTag:void 0;var yt=function(e){var t=kt.call(e,Ct),o=e[Ct];try{e[Ct]=void 0;var n=!0}catch(e){}var i=vt.call(e);return n&&(t?e[Ct]=o:delete e[Ct]),i},Tt=Object.prototype.toString;var xt=function(e){return Tt.call(e)},At=wt?wt.toStringTag:void 0;var Vt=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":At&&At in Object(e)?yt(e):xt(e)};var St=function(e){return null!=e&&"object"==typeof e};var Rt=function(e){return"symbol"==typeof e||St(e)&&"[object Symbol]"==Vt(e)},It=/^[-+]0x[0-9a-f]+$/i,Pt=/^0b[01]+$/i,Et=/^0o[0-7]+$/i,Bt=parseInt;var Ot=function(e){if("number"==typeof e)return e;if(Rt(e))return NaN;if(ct(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ct(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=ft(e);var o=Pt.test(e);return o||Et.test(e)?Bt(e.slice(2),o?2:8):It.test(e)?NaN:+e},Lt=Math.max,Nt=Math.min;var zt=function(e,t,o){var n,i,r,l,s,a,c=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var o=n,r=i;return n=i=void 0,c=t,l=e.apply(r,o)}function m(e){return c=e,s=setTimeout(p,t),d?b(e):l}function g(e){var o=e-a;return void 0===a||o>=t||o<0||u&&e-c>=r}function p(){var e=bt();if(g(e))return f(e);s=setTimeout(p,function(e){var o=t-(e-a);return u?Nt(o,r-(e-c)):o}(e))}function f(e){return s=void 0,h&&n?b(e):(n=i=void 0,l)}function w(){var e=bt(),o=g(e);if(n=arguments,i=this,a=e,o){if(void 0===s)return m(a);if(u)return clearTimeout(s),s=setTimeout(p,t),b(a)}return void 0===s&&(s=setTimeout(p,t)),l}return t=Ot(t)||0,ct(o)&&(d=!!o.leading,r=(u="maxWait"in o)?Lt(Ot(o.maxWait)||0,t):r,h="trailing"in o?!!o.trailing:h),w.cancel=function(){void 0!==s&&clearTimeout(s),c=0,n=a=i=s=void 0},w.flush=function(){return void 0===s?l:f(bt())},w};const Mt=xe.BalloonPanelView.defaultPositions,Ft=[Mt.northArrowSouth,Mt.northArrowSouthWest,Mt.northArrowSouthEast,Mt.southArrowNorth,Mt.southArrowNorthWest,Mt.southArrowNorthEast,Mt.viewportStickyNorth];function Ht(e,t){const o=e.plugins.get("ContextualBalloon");if(We(e.editing.view.document.selection)){let n;n="cell"===t?Wt(e):Dt(e),o.updatePosition(n)}}function Dt(e){const t=e.model.document.selection.getFirstPosition().findAncestor("table"),o=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.viewToDom(o),positions:Ft}}function Wt(e){const t=e.editing.mapper,o=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const o=t.editing.mapper,n=t.editing.view.domConverter,i=Array.from(e).map(e=>{const t=jt(e.start),i=o.toViewElement(t);return new a.Rect(n.viewToDom(i))});return a.Rect.getBoundingRect(i)}(n.getRanges(),e),positions:Ft};const i=jt(n.getFirstPosition()),r=t.toViewElement(i);return{target:o.viewToDom(r),positions:Ft}}function jt(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}function Ut(e){if(!e||!ct(e))return e;const{top:t,right:o,bottom:n,left:i}=e;return t==o&&o==n&&n==i?t:void 0}function Kt(e,t){const o=parseFloat(e);return Number.isNaN(o)||String(o)!==String(e)?e:`${o}${t}`}function $t(e,t={}){const o=Object.assign({borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:""},e);return t.includeAlignmentProperty&&!o.alignment&&(o.alignment="center"),t.includePaddingProperty&&!o.padding&&(o.padding=""),t.includeVerticalAlignmentProperty&&!o.verticalAlignment&&(o.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!o.horizontalAlignment&&(o.horizontalAlignment=t.isRightToLeftContent?"right":"left"),o}const qt={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",width:"tableCellWidth",height:"tableCellHeight",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class Gt extends n.Plugin{static get requires(){return[xe.ContextualBalloon]}static get pluginName(){return"TableCellPropertiesUI"}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:ot,backgroundColors:ot})}init(){const e=this.editor,t=e.t;this._defaultTableCellProperties=$t(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(xe.ContextualBalloon),this.view=this._createPropertiesView(),this._undoStepBatch=null,e.ui.componentFactory.add("tableCellProperties",o=>{const n=new xe.ButtonView(o);n.set({label:t("Cell properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const i=Object.values(qt).map(t=>e.commands.get(t));return n.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.editing.view.document,o=e.config.get("table.tableCellProperties"),n=Object(xe.normalizeColorOptions)(o.borderColors),i=Object(xe.getLocalizedColorOptions)(e.locale,n),r=Object(xe.normalizeColorOptions)(o.backgroundColors),l=Object(xe.getLocalizedColorOptions)(e.locale,r),s=new st(e.locale,{borderColors:i,backgroundColors:l,defaultTableCellProperties:this._defaultTableCellProperties}),a=e.t;s.render(),this.listenTo(s,"submit",()=>{this._hideView()}),this.listenTo(s,"cancel",()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()}),s.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),this.listenTo(e.ui,"update",()=>{We(t.selection)?this._isViewVisible&&Ht(e,"cell"):this._hideView()}),Object(xe.clickOutsideHandler)({emitter:s,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=Je(a),d=Xe(a);return s.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle",this._defaultTableCellProperties.borderStyle)),s.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:s.borderColorInput,commandName:"tableCellBorderColor",errorText:c,validator:Ye,defaultValue:this._defaultTableCellProperties.borderColor})),s.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:s.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:Ze,defaultValue:this._defaultTableCellProperties.borderWidth})),s.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:s.paddingInput,commandName:"tableCellPadding",errorText:d,validator:Qe,defaultValue:this._defaultTableCellProperties.padding})),s.on("change:width",this._getValidatedPropertyChangeCallback({viewField:s.widthInput,commandName:"tableCellWidth",errorText:d,validator:Qe,defaultValue:this._defaultTableCellProperties.width})),s.on("change:height",this._getValidatedPropertyChangeCallback({viewField:s.heightInput,commandName:"tableCellHeight",errorText:d,validator:Qe,defaultValue:this._defaultTableCellProperties.height})),s.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:s.backgroundInput,commandName:"tableCellBackgroundColor",errorText:c,validator:Ye,defaultValue:this._defaultTableCellProperties.backgroundColor})),s.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment",this._defaultTableCellProperties.horizontalAlignment)),s.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment",this._defaultTableCellProperties.verticalAlignment)),s}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(qt).map(([t,o])=>{const n=this._defaultTableCellProperties[t]||"";return[t,e.get(o).value||n]}).forEach(([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})}_showView(){const e=this.editor;this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Wt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){if(!this._isViewInBalloon)return;const e=this.editor;this.stopListening(e.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(e,t){return(o,n,i,r)=>{(r||t!==i)&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i,defaultValue:r}=e,l=zt(()=>{o.errorText=i},500);return(e,i,s,a)=>{l.cancel(),(a||r!==s)&&(n(s)?(this.editor.execute(t,{value:s,batch:this._undoStepBatch}),o.errorText=null):l())}}}function Jt(e,t){const{viewElement:o,defaultValue:n,modelAttribute:i,styleName:r,reduceBoxSides:l=!1}=t;e.for("upcast").attributeToAttribute({view:{name:o,styles:{[r]:/[\s\S]+/}},model:{key:i,value:e=>{const t=e.getNormalizedStyle(r),o=l?Zt(t):t;if(n!==o)return o}}})}function Xt(e,t,o){e.for("upcast").add(e=>e.on("element:"+t,(e,t,n)=>{if(!t.modelRange)return;const i=["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(e=>t.viewItem.hasStyle(e));if(!i.length)return;const r={styles:i};if(!n.consumable.test(t.viewItem,r))return;const l=[...t.modelRange.getItems({shallow:!0})].pop();n.consumable.consume(t.viewItem,r);const s={style:t.viewItem.getNormalizedStyle("border-style"),color:t.viewItem.getNormalizedStyle("border-color"),width:t.viewItem.getNormalizedStyle("border-width")},a={style:Zt(s.style),color:Zt(s.color),width:Zt(s.width)};a.style!==o.style&&n.writer.setAttribute("borderStyle",a.style,l),a.color!==o.color&&n.writer.setAttribute("borderColor",a.color,l),a.width!==o.width&&n.writer.setAttribute("borderWidth",a.width,l)}))}function Yt(e,{modelElement:t,modelAttribute:o,styleName:n}){e.for("downcast").attributeToAttribute({model:{name:t,key:o},view:e=>({key:"style",value:{[n]:e}})})}function Qt(e,{modelAttribute:t,styleName:o}){e.for("downcast").add(e=>e.on(`attribute:${t}:table`,(e,t,n)=>{const{item:i,attributeNewValue:r}=t,{mapper:l,writer:s}=n;if(!n.consumable.consume(t.item,e.name))return;const a=[...l.toViewElement(i).getChildren()].find(e=>e.is("element","table"));r?s.setStyle(o,r,a):s.removeStyle(o,a)}))}function Zt(e){if(!e)return;return["top","right","bottom","left"].map(t=>e[t]).reduce((e,t)=>e==t?e:null)||e}class eo extends n.Command{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=V(this.editor.model.document.selection);this.isEnabled=!!e.length,this.value=this._getSingleValue(e)}execute(e={}){const{value:t,batch:o}=e,n=this.editor.model,i=V(n.document.selection),r=this._getValueToSet(t);n.enqueueChange(o||"default",e=>{r?i.forEach(t=>e.setAttribute(this.attributeName,r,t)):i.forEach(t=>e.removeAttribute(this.attributeName,t))})}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(e=>this._getAttribute(e)===t)?t:void 0}}class to extends eo{constructor(e,t){super(e,"padding",t)}_getAttribute(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){if((e=Kt(e,"px"))!==this._defaultValue)return e}}class oo extends eo{constructor(e,t){super(e,"width",t)}_getValueToSet(e){if((e=Kt(e,"px"))!==this._defaultValue)return e}}class no extends eo{constructor(e,t){super(e,"height",t)}_getValueToSet(e){return(e=Kt(e,"px"))===this._defaultValue?null:e}}class io extends eo{constructor(e,t){super(e,"backgroundColor",t)}}class ro extends eo{constructor(e,t){super(e,"verticalAlignment",t)}}class lo extends eo{constructor(e,t){super(e,"horizontalAlignment",t)}}class so extends eo{constructor(e,t){super(e,"borderStyle",t)}_getAttribute(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class ao extends eo{constructor(e,t){super(e,"borderColor",t)}_getAttribute(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class co extends eo{constructor(e,t){super(e,"borderWidth",t)}_getAttribute(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){if((e=Kt(e,"px"))!==this._defaultValue)return e}}const uo=/^(top|middle|bottom)$/,ho=/^(left|center|right|justify)$/;class bo extends n.Plugin{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[ye]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=$t(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(Ne.addBorderRules),function(e,t,o){e.extend("tableCell",{allowAttributes:["borderWidth","borderColor","borderStyle"]}),Xt(t,"td",o),Xt(t,"th",o),Yt(t,{modelElement:"tableCell",modelAttribute:"borderStyle",styleName:"border-style"}),Yt(t,{modelElement:"tableCell",modelAttribute:"borderColor",styleName:"border-color"}),Yt(t,{modelElement:"tableCell",modelAttribute:"borderWidth",styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new so(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new ao(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new co(e,n.borderWidth)),function(e,t,o){e.extend("tableCell",{allowAttributes:["horizontalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"horizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":ho}},model:{key:"horizontalAlignment",value:e=>{const t=e.getStyle("text-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:ho}},model:{key:"horizontalAlignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new lo(e,n.horizontalAlignment)),mo(t,o,{modelAttribute:"width",styleName:"width",defaultValue:n.width}),e.commands.add("tableCellWidth",new oo(e,n.width)),mo(t,o,{modelAttribute:"height",styleName:"height",defaultValue:n.height}),e.commands.add("tableCellHeight",new no(e,n.height)),e.data.addStyleProcessorRules(Ne.addPaddingRules),mo(t,o,{modelAttribute:"padding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new to(e,n.padding)),e.data.addStyleProcessorRules(Ne.addBackgroundRules),mo(t,o,{modelAttribute:"backgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new io(e,n.backgroundColor)),function(e,t,o){e.extend("tableCell",{allowAttributes:["verticalAlignment"]}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"verticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":uo}},model:{key:"verticalAlignment",value:e=>{const t=e.getStyle("vertical-align");return t===o?null:t}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:uo}},model:{key:"verticalAlignment",value:e=>{const t=e.getAttribute("valign");return t===o?null:t}}})}(t,o,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new ro(e,n.verticalAlignment))}}function mo(e,t,o){const{modelAttribute:n}=o;e.extend("tableCell",{allowAttributes:[n]}),Jt(t,{viewElement:/^(td|th)$/,...o}),Yt(t,{modelElement:"tableCell",...o})}class go extends n.Plugin{static get pluginName(){return"TableCellProperties"}static get requires(){return[bo,Gt]}}class po extends n.Command{constructor(e,t,o){super(e),this.attributeName=t,this._defaultValue=o}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,o=t.document.selection,{value:n,batch:i}=e,r=o.getFirstPosition().findAncestor("table"),l=this._getValueToSet(n);t.enqueueChange(i||"default",e=>{l?e.setAttribute(this.attributeName,l,r):e.removeAttribute(this.attributeName,r)})}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}}class fo extends po{constructor(e,t){super(e,"backgroundColor",t)}}class wo extends po{constructor(e,t){super(e,"borderColor",t)}_getValue(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class _o extends po{constructor(e,t){super(e,"borderStyle",t)}_getValue(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class ko extends po{constructor(e,t){super(e,"borderWidth",t)}_getValue(e){if(!e)return;const t=Ut(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){if((e=Kt(e,"px"))!==this._defaultValue)return e}}class vo extends po{constructor(e,t){super(e,"width",t)}_getValueToSet(e){if((e=Kt(e,"px"))!==this._defaultValue)return e}}class Co extends po{constructor(e,t){super(e,"height",t)}_getValueToSet(e){return(e=Kt(e,"px"))===this._defaultValue?null:e}}class yo extends po{constructor(e,t){super(e,"alignment",t)}}const To=/^(left|center|right)$/,xo=/^(left|none|right)$/;class Ao extends n.Plugin{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[ye]}init(){const e=this.editor,t=e.model.schema,o=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=$t(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(Ne.addBorderRules),function(e,t,o){e.extend("table",{allowAttributes:["borderWidth","borderColor","borderStyle"]}),Xt(t,"table",o),Qt(t,{modelAttribute:"borderColor",styleName:"border-color"}),Qt(t,{modelAttribute:"borderStyle",styleName:"border-style"}),Qt(t,{modelAttribute:"borderWidth",styleName:"border-width"})}(t,o,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new wo(e,n.borderColor)),e.commands.add("tableBorderStyle",new _o(e,n.borderStyle)),e.commands.add("tableBorderWidth",new ko(e,n.borderWidth)),function(e,t,o){e.extend("table",{allowAttributes:["alignment"]}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"alignment"},view:e=>({key:"style",value:{float:"center"===e?"none":e}}),converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:xo}},model:{key:"alignment",value:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t===o?null:t}}}).attributeToAttribute({view:{attributes:{align:To}},model:{name:"table",key:"alignment",value:e=>{const t=e.getAttribute("align");return t===o?null:t}}})}(t,o,n.alignment),e.commands.add("tableAlignment",new yo(e,n.alignment)),Vo(t,o,{modelAttribute:"width",styleName:"width",defaultValue:n.width}),e.commands.add("tableWidth",new vo(e,n.width)),Vo(t,o,{modelAttribute:"height",styleName:"height",defaultValue:n.height}),e.commands.add("tableHeight",new Co(e,n.height)),e.data.addStyleProcessorRules(Ne.addBackgroundRules),function(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),Jt(t,{viewElement:"table",...o}),Qt(t,o)}(t,o,{modelAttribute:"backgroundColor",styleName:"background-color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new fo(e,n.backgroundColor))}}function Vo(e,t,o){const{modelAttribute:n}=o;e.extend("table",{allowAttributes:[n]}),Jt(t,{viewElement:/^(table|figure)$/,...o}),Yt(t,{modelElement:"table",...o})}o(28);const So={left:n.icons.objectLeft,center:n.icons.objectCenter,right:n.icons.objectRight};class Ro extends xe.View{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:o,borderWidthInput:n,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:l,backgroundInput:s}=this._createBackgroundFields(),{widthInput:c,operatorLabel:d,heightInput:u,dimensionsLabel:h}=this._createDimensionFields(),{alignmentToolbar:b,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new a.FocusTracker,this.keystrokes=new a.KeystrokeHandler,this.children=this.createCollection(),this.borderStyleDropdown=o,this.borderWidthInput=n,this.borderColorInput=i,this.backgroundInput=s,this.widthInput=c,this.heightInput=u,this.alignmentToolbar=b;const{saveButtonView:g,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=p,this._focusables=new xe.ViewCollection,this._focusCycler=new xe.FocusCycler({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new xe.FormHeaderView(e,{label:this.t("Table properties")})),this.children.add(new rt(e,{labelView:r,children:[r,o,i,n],class:"ck-table-form__border-row"})),this.children.add(new rt(e,{labelView:l,children:[l,s],class:"ck-table-form__background-row"})),this.children.add(new rt(e,{children:[new rt(e,{labelView:h,children:[h,c,d,u],class:"ck-table-form__dimensions-row"}),new rt(e,{labelView:m,children:[m,b],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new rt(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(),Object(xe.submitHandler)({view:this}),[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)}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},o=nt({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color}),n=this.locale,i=this.t,r=new xe.LabelView(n);r.text=i("Border");const l=Ge(this.t),s=new xe.LabeledFieldView(n,xe.createLabeledDropdown);s.set({label:i("Style"),class:"ck-table-form__border-style"}),s.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),s.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>l[e||"none"]),s.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),s.bind("isEmpty").to(this,"borderStyle",e=>!e),Object(xe.addListToDropdown)(s.fieldView,et(this,t.style));const a=new xe.LabeledFieldView(n,xe.createLabeledInputText);a.set({label:i("Width"),class:"ck-table-form__border-width"}),a.fieldView.bind("value").to(this,"borderWidth"),a.bind("isEnabled").to(this,"borderStyle",Io),a.fieldView.on("input",()=>{this.borderWidth=a.fieldView.element.value});const c=new xe.LabeledFieldView(n,o);return c.set({label:i("Color"),class:"ck-table-form__border-color"}),c.fieldView.bind("value").to(this,"borderColor"),c.bind("isEnabled").to(this,"borderStyle",Io),c.fieldView.on("input",()=>{this.borderColor=c.fieldView.value}),this.on("change:borderStyle",(e,o,n,i)=>{Io(n)||(this.borderColor="",this.borderWidth=""),Io(i)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:s,borderColorInput:c,borderWidthInput:a}}_createBackgroundFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Background");const n=nt({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor}),i=new xe.LabeledFieldView(e,n);return i.set({label:t("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",()=>{this.backgroundColor=i.fieldView.value}),{backgroundRowLabel:o,backgroundInput:i}}_createDimensionFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Dimensions");const n=new xe.LabeledFieldView(e,xe.createLabeledInputText);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const i=new xe.View(e);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new xe.LabeledFieldView(e,xe.createLabeledInputText);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:o,widthInput:n,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const e=this.locale,t=this.t,o=new xe.LabelView(e);o.text=t("Alignment");const n=new xe.ToolbarView(e);return n.set({isCompact:!0,ariaLabel:t("Table alignment toolbar")}),tt({view:this,icons:So,toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:o,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,o=new xe.ButtonView(e),i=new xe.ButtonView(e),r=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return o.set({label:t("Save"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0}),o.bind("isEnabled").toMany(r,"errorText",(...e)=>e.every(e=>!e)),i.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),{saveButtonView:o,cancelButtonView:i}}get _alignmentLabels(){const e=this.locale,t=this.t,o=t("Align table to the left"),n=t("Center table"),i=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:i,center:n,left:o}:{left:o,center:n,right:i}}}function Io(e){return"none"!==e}const Po={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class Eo extends n.Plugin{static get requires(){return[xe.ContextualBalloon]}static get pluginName(){return"TablePropertiesUI"}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:ot,backgroundColors:ot})}init(){const e=this.editor,t=e.t;this._defaultTableProperties=$t(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=e.plugins.get(xe.ContextualBalloon),this.view=this._createPropertiesView(),this._undoStepBatch=null,e.ui.componentFactory.add("tableProperties",o=>{const n=new xe.ButtonView(o);n.set({label:t("Table properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const i=Object.values(Po).map(t=>e.commands.get(t));return n.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableProperties"),o=Object(xe.normalizeColorOptions)(t.borderColors),n=Object(xe.getLocalizedColorOptions)(e.locale,o),i=Object(xe.normalizeColorOptions)(t.backgroundColors),r=Object(xe.getLocalizedColorOptions)(e.locale,i),l=new Ro(e.locale,{borderColors:n,backgroundColors:r,defaultTableProperties:this._defaultTableProperties}),s=e.t;l.render(),this.listenTo(l,"submit",()=>{this._hideView()}),this.listenTo(l,"cancel",()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()}),l.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),Object(xe.clickOutsideHandler)({emitter:l,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const a=Je(s),c=Xe(s);return l.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle",this._defaultTableProperties.borderStyle)),l.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:l.borderColorInput,commandName:"tableBorderColor",errorText:a,validator:Ye,defaultValue:this._defaultTableProperties.borderColor})),l.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:l.borderWidthInput,commandName:"tableBorderWidth",errorText:c,validator:Ze,defaultValue:this._defaultTableProperties.borderWidth})),l.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:l.backgroundInput,commandName:"tableBackgroundColor",errorText:a,validator:Ye,defaultValue:this._defaultTableProperties.backgroundColor})),l.on("change:width",this._getValidatedPropertyChangeCallback({viewField:l.widthInput,commandName:"tableWidth",errorText:c,validator:Qe,defaultValue:this._defaultTableProperties.width})),l.on("change:height",this._getValidatedPropertyChangeCallback({viewField:l.heightInput,commandName:"tableHeight",errorText:c,validator:Qe,defaultValue:this._defaultTableProperties.height})),l.on("change:alignment",this._getPropertyChangeCallback("tableAlignment",this._defaultTableProperties.alignment)),l}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(Po).map(([t,o])=>{const n=this._defaultTableProperties[t]||"";return[t,e.get(o).value||n]}).forEach(([e,o])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,o)})}_showView(){const e=this.editor;this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Dt(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;We(e.editing.view.document.selection)?this._isViewVisible&&Ht(e,"table"):this._hideView()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(e,t){return(o,n,i,r)=>{(r||t!==i)&&this.editor.execute(e,{value:i,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:o,validator:n,errorText:i,defaultValue:r}=e,l=zt(()=>{o.errorText=i},500);return(e,i,s,a)=>{l.cancel(),(a||r!==s)&&(n(s)?(this.editor.execute(t,{value:s,batch:this._undoStepBatch}),o.errorText=null):l())}}}class Bo extends n.Plugin{static get pluginName(){return"TableProperties"}static get requires(){return[Ao,Eo]}}function Oo(e){e.document.registerPostFixer(t=>function(e,t){const o=t.document.differ.getChanges();let n=!1;for(const t of o){if("insert"!=t.type)continue;if(t.position.parent.is("element","table")||"table"==t.name){const o="table"==t.name?t.position.nodeAfter:t.position.parent,i=Array.from(o.getChildren()).filter(e=>e.is("element","caption")),r=i.shift();if(!r)continue;for(const t of i)e.move(e.createRangeIn(t),r,"end"),e.remove(t);r.nextSibling&&(e.move(e.createRangeOn(r),o,"end"),n=!0),n=!!i.length||n}}return n}(t,e))}function Lo(e){return!!e&&e.is("element","table")}function No(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function zo(e){const t=e.parent;return"figcaption"==e.name&&t&&"figure"==t.name&&t.hasClass("table")||"caption"==e.name&&t&&"table"==t.name?{name:!0}:null}function Mo(e){const t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")}class Fo extends n.Command{refresh(){const e=Mo(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?this.value=!!No(e):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(e=>{this.value?this._hideTableCaption(e):this._showTableCaption(e,t)})}_showTableCaption(e,t){const o=Mo(this.editor.model.document.selection),n=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(o)||e.createElement("caption");e.append(n,o),t&&e.setSelection(n,"in")}_hideTableCaption(e){const t=Mo(this.editor.model.document.selection),o=this.editor.plugins.get("TableCaptionEditing"),n=No(t);o._saveCaption(t,n),e.setSelection(e.createRangeIn(t.getChild(0).getChild(0))),e.remove(n)}}class Ho extends n.Plugin{static get pluginName(){return"TableCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema,o=e.editing.view,n=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new Fo(this.editor)),e.conversion.for("upcast").elementToElement({view:zo,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>Lo(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!Lo(e.parent))return null;const r=t.createEditableElement("figcaption");return t.setCustomProperty("tableCaption",!0,r),Object(Ne.enablePlaceholder)({view:o,element:r,text:n("Enter table caption"),keepOnFocus:!0}),Object(i.toWidgetEditable)(r,t)}}),Oo(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?Ne.Element.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class Do extends n.Plugin{static get pluginName(){return"TableCaptionUI"}init(){const e=this.editor,t=e.editing.view,o=e.t;e.ui.componentFactory.add("toggleTableCaption",i=>{const r=e.commands.get("toggleTableCaption"),l=new xe.ButtonView(i);return l.set({icon:n.icons.caption,tooltip:!0,isToggleable:!0}),l.bind("isOn","isEnabled").to(r,"value","isEnabled"),l.bind("label").to(r,"value",e=>o(e?"Toggle caption off":"Toggle caption on")),this.listenTo(l,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),r.value){const o=function(e){const t=Mo(e);return t?No(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(o);if(!n)return;t.scrollToTheSelection(),t.change(e=>{e.addClass("table__caption_highlighted",n)})}}),l})}}o(30);class Wo extends n.Plugin{static get pluginName(){return"TableCaption"}static get requires(){return[Ho,Do]}}}]);