diff --git a/src/web/assets/ckeconfig/dist/ckeconfig.js b/src/web/assets/ckeconfig/dist/ckeconfig.js
index 31df0367..8a531acf 100644
--- a/src/web/assets/ckeconfig/dist/ckeconfig.js
+++ b/src/web/assets/ckeconfig/dist/ckeconfig.js
@@ -1,3 +1,3 @@
/*! For license information please see ckeconfig.js.LICENSE.txt */
-(function(){var __webpack_modules__={150:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){"use strict";var _ckeconfig_css__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(778),_ckeconfig_css__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_ckeconfig_css__WEBPACK_IMPORTED_MODULE_0__),jquery__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(311),jquery__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_1__);function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],u=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _createForOfIteratorHelper(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nn.parts.length&&(r.parts.length=n.parts.length)}else{var a=[];for(o=0;o=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function i(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1){var n=u.value.findIndex((function(e){return t.some((function(t){return t.button===e}))}));if(-1!==n)for(var o=0;o '),r=t()('
').appendTo(n);return e.appendTo(r),n},moveHelperToCursor:!0,onDragStart:function(){Garnish.$bod.addClass("dragging");var e=u.drag.$draggee;if(u.draggingSourceItem=t().contains(u.$sourceContainer[0],e[0]),u.draggingSeparator=e.hasClass("ckeditor-tb--separator"),u.$insertion=t()('
').css({width:e.outerWidth()}),u.draggingSourceItem)if(u.draggingSeparator)e.css("visibility","");else{var n="ltr"===Craft.orientation?"margin-right":"margin-left",r=-1*e.outerWidth();e.stop().velocity(s({},n,r),200,(function(){e.addClass("hidden")}))}else e.addClass("hidden"),u.$insertion.insertBefore(e),u.showingInsertion=!0;u.setMidpoints()},onDrag:function(){u.checkForNewClosestItem()},onDragStop:function(){Garnish.$bod.removeClass("dragging");var e=u.drag.$draggee;if(u.checkForNewClosestItem(),u.showingInsertion)if(u.draggingSourceItem){var n;if(u.draggingSeparator)n=u.renderSeparator();else{var a=e.data("componentNames");n=u.renderComponentGroup(a);var c,l=o(a);try{var d=function(){var e=c.value,t=f.flat().find((function(t){return t.button===e}));t&&t.configOption&&i.addSetting(t.configOption)};for(l.s();!(c=l.n()).done;)d()}catch(e){l.e(e)}finally{l.f()}}n.data("sourceItem",e[0]),n.css("visibility","hidden"),u.$insertion.replaceWith(n),u.drag.$draggee=n}else u.$insertion.replaceWith(e),e.removeClass("hidden");else{if(!u.draggingSourceItem){var _=t()(e.data("sourceItem"));if(e.remove(),u.drag.$draggee=e=_,!u.draggingSeparator){var p,h=o(_.data("componentNames"));try{var g=function(){var e=p.value,t=f.flat().find((function(t){return t.button===e}));t&&t.configOption&&i.removeSetting(t.configOption)};for(h.s();!(p=h.n()).done;)g()}catch(e){h.e(e)}finally{h.f()}}}if(!u.draggingSeparator){e.removeClass("hidden");var m="ltr"===Craft.orientation?"margin-right":"margin-left",v=e.css(m);e.css(m,"");var y=e.css(m);e.css(m,v),e.stop().velocity(s({},m,y),200,(function(){e.css(m,"")}))}}u.drag.returnHelpersToDraggees(),u.$items=u.$targetContainer.children(),u.value=[];var b,C=o(u.$items.toArray());try{for(C.s();!(b=C.n()).done;){var j,w=b.value,E=t()(w);E.hasClass("ckeditor-tb--separator")?u.value.push("|"):(j=u.value).push.apply(j,r(E.data("componentNames")))}}catch(e){C.e(e)}finally{C.f()}u.$input.val(JSON.stringify(u.value))}});var h,g={},m=o(f);try{for(m.s();!(h=m.n()).done;){var v=h.value,y=u.renderComponentGroup(v);y&&(y.appendTo(u.$sourceContainer),g[v.map((function(e){return e.button})).join(",")]=y[0],u.value.includes(v[0].button)&&y.addClass("hidden"))}}catch(e){m.e(e)}finally{m.f()}g["|"]=u.renderSeparator().appendTo(u.$sourceContainer)[0],u.$items=t()();for(var b=function(e){var t,n,r=u.value[e];if("|"===r)t=u.renderSeparator().appendTo(u.$targetContainer),n="|";else{var o=f.find((function(e){return e.some((function(e){return e.button===r}))}));if(!o)return C=e,0;if(!(t=u.renderComponentGroup(o)))return C=e,0;t.appendTo(u.$targetContainer),n=o.map((function(e){return e.button})).join(","),e+=o.length-1}t.data("sourceItem",g[n]),u.$items=u.$items.add(t),C=e},C=0;C ');return this.drag.addItems(e),e},renderComponentGroup:function(e){var n,r=[],i=[],a=o(e=e.map((function(e){return"string"==typeof e?e:e.button})));try{for(a.s();!(n=a.n()).done;){var s=n.value,u=void 0;try{u=this.renderComponent(s)}catch(e){console.warn(e);continue}r.push(u);var c=(u.is("[data-cke-tooltip-text]")?u:u.find("[data-cke-tooltip-text]")).attr("data-cke-tooltip-text");i.push(c?c.replace(/ \(.*\)$/,""):"".concat(s[0].toUpperCase()).concat(s.slice(1)))}}catch(e){a.e(e)}finally{a.f()}if(!r.length)return!1;var l=t()('
').append(r);return l.attr("data-cke-tooltip-text",i.join(", ")),l.data("componentNames",e),this.drag.addItems(l),l},renderComponent:function(e){var n=this.components[e];if(!n)throw"Missing component: ".concat(e);n.isRendered||n.render();var r=t()(n.element.outerHTML);return r.data("componentName",e),r},getClosestItem:function(){var e=this;if(!Garnish.hitTest(this.drag.mouseX,this.drag.mouseY,this.$targetContainer))return!1;if(!this.$items.length)return null;var n=this.$items.toArray();this.showingInsertion&&n.push(this.$insertion[0]);var o=n.map((function(n){var r=t().data(n,"midpoint");return Garnish.getDist(r.left,r.top,e.drag.mouseX,e.drag.mouseY)})),i=Math.min.apply(Math,r(o));return n[o.indexOf(i)]},checkForNewClosestItem:function(){var e=this.getClosestItem();!1!==e?e!==this.$insertion[0]&&(e?this.drag.mouseX=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nn.parts.length&&(r.parts.length=n.parts.length)}else{var a=[];for(o=0;o=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function i(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1){var n=u.value.findIndex((function(e){return t.some((function(t){return t.button===e}))}));if(-1!==n)for(var o=0;o '),r=t()('
').appendTo(n);return e.appendTo(r),n},moveHelperToCursor:!0,onDragStart:function(){Garnish.$bod.addClass("dragging");var e=u.drag.$draggee;if(u.draggingSourceItem=t().contains(u.$sourceContainer[0],e[0]),u.draggingSeparator=e.hasClass("ckeditor-tb--separator"),u.$insertion=t()('
').css({width:e.outerWidth()}),u.draggingSourceItem)if(u.draggingSeparator)e.css("visibility","");else{var n="ltr"===Craft.orientation?"margin-right":"margin-left",r=-1*e.outerWidth();e.stop().velocity(s({},n,r),200,(function(){e.addClass("hidden")}))}else e.addClass("hidden"),u.$insertion.insertBefore(e),u.showingInsertion=!0;u.setMidpoints()},onDrag:function(){u.checkForNewClosestItem()},onDragStop:function(){Garnish.$bod.removeClass("dragging");var e=u.drag.$draggee;if(u.checkForNewClosestItem(),u.showingInsertion)if(u.draggingSourceItem){var n;if(u.draggingSeparator)n=u.renderSeparator();else{var a=e.data("componentNames");n=u.renderComponentGroup(a);var c,l=o(a);try{var d=function(){var e=c.value,t=f.flat().find((function(t){return t.button===e}));t&&t.configOption&&i.addSetting(t.configOption)};for(l.s();!(c=l.n()).done;)d()}catch(e){l.e(e)}finally{l.f()}}n.data("sourceItem",e[0]),n.css("visibility","hidden"),u.$insertion.replaceWith(n),u.drag.$draggee=n}else u.$insertion.replaceWith(e),e.removeClass("hidden");else{if(!u.draggingSourceItem){var _=t()(e.data("sourceItem"));if(e.remove(),u.drag.$draggee=e=_,!u.draggingSeparator){var p,h=o(_.data("componentNames"));try{var g=function(){var e=p.value,t=f.flat().find((function(t){return t.button===e}));t&&t.configOption&&i.removeSetting(t.configOption)};for(h.s();!(p=h.n()).done;)g()}catch(e){h.e(e)}finally{h.f()}}}if(!u.draggingSeparator){e.removeClass("hidden");var m="ltr"===Craft.orientation?"margin-right":"margin-left",v=e.css(m);e.css(m,"");var y=e.css(m);e.css(m,v),e.stop().velocity(s({},m,y),200,(function(){e.css(m,"")}))}}u.drag.returnHelpersToDraggees(),u.$items=u.$targetContainer.children(),u.value=[];var b,C=o(u.$items.toArray());try{for(C.s();!(b=C.n()).done;){var j,w=b.value,E=t()(w);E.hasClass("ckeditor-tb--separator")?u.value.push("|"):(j=u.value).push.apply(j,r(E.data("componentNames")))}}catch(e){C.e(e)}finally{C.f()}u.$input.val(JSON.stringify(u.value))}});var h,g={},m=o(f);try{for(m.s();!(h=m.n()).done;){var v=h.value,y=u.renderComponentGroup(v);y&&(y.appendTo(u.$sourceContainer),g[v.map((function(e){return e.button})).join(",")]=y[0],u.value.includes(v[0].button)&&y.addClass("hidden"))}}catch(e){m.e(e)}finally{m.f()}g["|"]=u.renderSeparator().appendTo(u.$sourceContainer)[0],u.$items=t()();for(var b=function(e){var t,n,r=u.value[e];if("|"===r)t=u.renderSeparator().appendTo(u.$targetContainer),n="|";else{var o=f.find((function(e){return e.some((function(e){return e.button===r}))}));if(!o)return C=e,0;if(!(t=u.renderComponentGroup(o)))return C=e,0;t.appendTo(u.$targetContainer),n=o.map((function(e){return e.button})).join(","),e+=o.length-1}t.data("sourceItem",g[n]),u.$items=u.$items.add(t),C=e},C=0;C ');return this.drag.addItems(e),e},renderComponentGroup:function(e){var n,r=[],i=[],a=o(e=e.map((function(e){return"string"==typeof e?e:e.button})));try{for(a.s();!(n=a.n()).done;){var s=n.value,u=void 0;try{u=this.renderComponent(s)}catch(e){console.warn(e);continue}r.push(u);var c=(u.is("[data-cke-tooltip-text]")?u:u.find("[data-cke-tooltip-text]")).attr("data-cke-tooltip-text");i.push(c?c.replace(/ \(.*\)$/,""):"".concat(s[0].toUpperCase()).concat(s.slice(1)))}}catch(e){a.e(e)}finally{a.f()}if(!r.length)return!1;var l=t()('
').append(r);return l.attr("data-cke-tooltip-text",i.join(", ")),l.data("componentNames",e),this.drag.addItems(l),l},renderComponent:function(e){var n=this.components[e];if(!n)throw"Missing component: ".concat(e);n.isRendered||n.render();var r=t()(n.element.outerHTML);return r.data("componentName",e),r},getClosestItem:function(){var e=this;if(!Garnish.hitTest(this.drag.mouseX,this.drag.mouseY,this.$targetContainer))return!1;if(!this.$items.length)return null;var n=this.$items.toArray();this.showingInsertion&&n.push(this.$insertion[0]);var o=n.map((function(n){var r=t().data(n,"midpoint");return Garnish.getDist(r.left,r.top,e.drag.mouseX,e.drag.mouseY)})),i=Math.min.apply(Math,r(o));return n[o.indexOf(i)]},checkForNewClosestItem:function(){var e=this.getClosestItem();!1!==e?e!==this.$insertion[0]&&(e?this.drag.mouseX {\n this.language = $selectedOption.data('language');\n switch (this.language) {\n case 'json':\n // get the js value\n lastJsValue = this.jsEditor.getModel().getValue();\n // check if the js value has any functions in it\n if (this.jsContainsFunctions(lastJsValue)) {\n // if it does - show the confirmation dialogue\n if (\n !confirm(\n Craft.t(\n 'ckeditor',\n 'Your JavaScript config contains functions. If you switch to JSON, they will be lost. Would you like to continue?',\n ),\n )\n ) {\n // if user cancels - go back to the previous option (js)\n let listbox = $languagePicker.data('listbox');\n listbox.$options.not('[data-language=\"json\"]').trigger('click');\n break;\n }\n }\n // if user confirms that they want to proceed, or we don't have functions in the js value,\n // go ahead and switch\n this.$jsonContainer.removeClass('hidden');\n this.$jsContainer.addClass('hidden');\n const json = this.js2json(lastJsValue);\n lastJsValue = null;\n this.jsonEditor.getModel().setValue(json || '{\\n \\n}');\n this.jsEditor.getModel().setValue('');\n break;\n case 'js':\n this.$jsonContainer.addClass('hidden');\n this.$jsContainer.removeClass('hidden');\n let js;\n // if we have the last remembered js value, it means we're switching back after cancelled confirmation,\n // so let's use it\n if (lastJsValue !== null) {\n js = lastJsValue;\n lastJsValue = null;\n } else {\n js = this.json2js(this.jsonEditor.getModel().getValue());\n }\n this.jsEditor.getModel().setValue(js || 'return {\\n \\n}');\n this.jsonEditor.getModel().setValue('');\n break;\n }\n },\n });\n\n // Handle Paste\n this.jsonEditor.onDidPaste((ev) => {\n const pastedContent = this.jsonEditor\n .getModel()\n .getValueInRange(ev.range);\n let config;\n try {\n eval(`config = {${pastedContent}}`);\n } catch (e) {\n // oh well\n return;\n }\n const json = JSON.stringify(config, null, 2);\n const trimmed = Craft.trim(json.substring(1, json.length - 1));\n if (!trimmed) {\n return;\n }\n this.jsonEditor.executeEdits('', [\n {\n range: ev.range,\n text: trimmed,\n },\n ]);\n });\n },\n\n getConfig: function () {\n let json;\n if (this.language === 'json') {\n json = Craft.trim(this.jsonEditor.getModel().getValue()) || '{}';\n } else {\n const value = Craft.trim(this.jsEditor.getModel().getValue());\n json = value ? this.js2json(value) : '{}';\n if (json === false) {\n return false;\n }\n }\n\n try {\n const config = JSON.parse(json);\n return $.isPlainObject(config) ? config : false;\n } catch (e) {\n return false;\n }\n },\n\n setConfig: function (config) {\n const json = this.config2json(config);\n\n if (this.language === 'json') {\n this.jsonEditor.getModel().setValue(json);\n } else {\n const js = this.json2js(json);\n this.jsEditor.getModel().setValue(js || 'return {\\n \\n}');\n }\n },\n\n addSetting: function (setting) {\n const config = this.getConfig();\n if (!config) {\n return;\n }\n\n // already present?\n if (typeof config[setting] !== 'undefined') {\n return;\n }\n\n if (typeof this.defaults[setting] === 'undefined') {\n this.populateDefault(setting);\n if (typeof this.defaults[setting] === 'undefined') {\n return;\n }\n }\n\n config[setting] = this.defaults[setting];\n this.setConfig(config);\n },\n\n removeSetting: function (setting) {\n const config = this.getConfig();\n if (!config) {\n return;\n }\n\n // not present?\n if (typeof config[setting] === 'undefined') {\n return;\n }\n\n // keep track of the value in case the setting needs to be added back later\n this.defaults[setting] = config[setting];\n\n delete config[setting];\n this.setConfig(config);\n },\n\n populateDefault: function (setting) {\n let schema;\n try {\n schema =\n window.monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas.find(\n (s) => s.uri === this.jsonSchemaUri,\n ).schema;\n } catch (e) {\n console.warn('Couldn’t get config options JSON schema.', e);\n return;\n }\n\n if (\n !schema.$defs ||\n !schema.$defs.EditorConfig ||\n !schema.$defs.EditorConfig.properties\n ) {\n console.warn(\n 'Config options JSON schema is missing $defs.EditorConfig.properties',\n );\n return;\n }\n\n if (!schema.$defs.EditorConfig.properties[setting]) {\n return;\n }\n\n const property = schema.$defs.EditorConfig.properties[setting];\n if (property.default) {\n this.defaults[setting] = property.default;\n return;\n }\n\n if (!property.$ref) {\n return;\n }\n\n const m = property.$ref.match(/^#\\/\\$defs\\/(\\w+)/);\n if (!m) {\n return;\n }\n\n const defName = m[1];\n if (!schema.$defs[defName] || !schema.$defs[defName].default) {\n return;\n }\n\n this.defaults[setting] = schema.$defs[defName].default;\n },\n\n replacer: function (key, value) {\n if (typeof value === 'function') {\n return '__HAS__FUNCTION__';\n }\n return value;\n },\n\n jsContainsFunctions: function (js) {\n let config = this.getValidJsonConfig(js);\n if (config === false) {\n return true;\n }\n\n let json = JSON.stringify(config, this.replacer, 2);\n if (json.match(/__HAS__FUNCTION__/)) {\n return true;\n }\n\n return false;\n },\n\n config2json: function (config) {\n let json = JSON.stringify(config, null, 2);\n if (json === '{}') {\n json = '{\\n \\n}';\n }\n return json;\n },\n\n getValidJsonConfig: function (js) {\n const m = (js || '').match(/return\\s*(\\{[\\w\\W]*})/);\n if (!m) {\n return false;\n }\n let config;\n // See if it's valid JSON\n try {\n eval(`config = ${m[1]};`);\n } catch (e) {\n // oh well\n return false;\n }\n\n return config;\n },\n\n js2json: function (js) {\n let config = this.getValidJsonConfig(js);\n\n if (config === false) {\n return false;\n }\n\n return this.config2json(config);\n },\n\n json2js: function (json) {\n let config;\n try {\n config = JSON.parse(json);\n } catch (e) {\n return false;\n }\n if (!$.isPlainObject(config)) {\n return false;\n }\n let js = this.jsify(config, '');\n if (js === '{\\n}') {\n js = '{\\n \\n}';\n }\n return `return ${js}`;\n },\n\n jsify: function (value, indent) {\n let js;\n if ($.isArray(value)) {\n js = '[\\n';\n for (const v of value) {\n js += `${indent} ${this.jsify(v, indent + ' ')},\\n`;\n }\n js += `${indent}]`;\n } else if ($.isPlainObject(value)) {\n js = '{\\n';\n for (const [k, v] of Object.entries(value)) {\n js += `${indent} ${k}: ${this.jsify(v, indent + ' ')},\\n`;\n }\n js += `${indent}}`;\n } else if (typeof value === 'string' && !value.match(/[\\r\\n']/)) {\n js = `'${value}'`;\n } else {\n js = JSON.stringify(value);\n }\n return js;\n },\n});\n","// style-loader: Adds some css to the DOM by adding a `),e=this.attachShadow({mode:"open"});e.appendChild(t.content.cloneNode(!0)),e.addEventListener("move",this),this[Zu]=this[Xu].map((t=>new t(e)))}connectedCallback(){if(this.hasOwnProperty("color")){const t=this.color;delete this.color,this.color=t}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(t,e,n){const o=this.colorModel.fromAttr(n);this[$u](o)||(this.color=o)}handleEvent(t){const e=this[Yu],n={...e,...t.detail};let o;this[Qu](n),Lu(n,e)||this[$u](o=this.colorModel.fromHsva(n))||(this[Ku]=o,ju(this,"color-changed",{value:o}))}[$u](t){return this.color&&this.colorModel.equal(t,this.color)}[Qu](t){this[Yu]=t,this[Zu].forEach((e=>e.update(t)))}}const eh={defaultColor:"#000",toHsva:t=>(({r:t,g:e,b:n,a:o})=>{const i=Math.max(t,e,n),r=i-Math.min(t,e,n),s=r?i===t?(e-n)/r:i===e?2+(n-t)/r:4+(t-e)/r:0;return{h:Pu(60*(s<0?s+6:s)),s:Pu(i?r/i*100:0),v:Pu(i/255*100),a:o}})(Ou(t)),fromHsva:({h:t,s:e,v:n})=>(({r:t,g:e,b:n,a:o})=>{const i=o<1?zu(Pu(255*o)):"";return"#"+zu(t)+zu(e)+zu(n)+i})((({h:t,s:e,v:n,a:o})=>{t=t/360*6,e/=100,n/=100;const i=Math.floor(t),r=n*(1-e),s=n*(1-(t-i)*e),a=n*(1-(1-t+i)*e),c=i%6;return{r:Pu(255*[n,s,r,r,a,n][c]),g:Pu(255*[a,n,n,s,r,r][c]),b:Pu(255*[r,r,a,n,n,s][c]),a:Pu(o,2)}})({h:t,s:e,v:n,a:1})),equal:(t,e)=>t.toLowerCase()===e.toLowerCase()||Lu(Ou(t),Ou(e)),fromAttr:t=>t};class nh extends th{get colorModel(){return eh}}class oh extends si{_parentElement;constructor(t=[]){super(t,{idProperty:"viewUid"}),this.on("add",((t,e,n)=>{this._renderViewIntoCollectionParent(e,n)})),this.on("remove",((t,e)=>{e.element&&this._parentElement&&e.element.remove()})),this._parentElement=null}destroy(){this.map((t=>t.destroy()))}setParent(t){this._parentElement=t;for(const t of this)this._renderViewIntoCollectionParent(t)}delegate(...t){if(!t.length||!t.every((t=>"string"==typeof t)))throw new An("ui-viewcollection-delegate-wrong-events",this);return{to:e=>{for(const n of this)for(const o of t)n.delegate(o).to(e);this.on("add",((n,o)=>{for(const n of t)o.delegate(n).to(e)})),this.on("remove",((n,o)=>{for(const n of t)o.stopDelegating(n,e)}))}}}_renderViewIntoCollectionParent(t,e){t.isRendered||t.render(),t.element&&this._parentElement&&this._parentElement.insertBefore(t.element,this._parentElement.children[e])}remove(t){return super.remove(t)}}class ih extends(Mn()){ns;tag;text;attributes;children;eventListeners;_isRendered;_revertData;constructor(t){super(),Object.assign(this,mh(ph(t))),this._isRendered=!1,this._revertData=null}render(){const t=this._renderNode({intoFragment:!0});return this._isRendered=!0,t}apply(t){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:t,intoFragment:!1,isApplying:!0,revertData:this._revertData}),t}revert(t){if(!this._revertData)throw new An("ui-template-revert-not-applied",[this,t]);this._revertTemplateFromNode(t,this._revertData)}*getViews(){yield*function*t(e){if(e.children)for(const n of e.children)_h(n)?yield n:Ch(n)&&(yield*t(n))}(this)}static bind(t,e){return{to(n,o){return new sh({eventNameOrFunction:n,attribute:n,observable:t,emitter:e,callback:o})},if(n,o,i){return new ah({observable:t,emitter:e,attribute:n,valueIfTrue:o,callback:i})}}}static extend(t,e){if(t._isRendered)throw new An("template-extend-render",[this,t]);bh(t,mh(ph(e)))}_renderNode(t){let e;if(e=t.node?this.tag&&this.text:this.tag?this.text:!this.text,e)throw new An("ui-template-wrong-syntax",this);return this.text?this._renderText(t):this._renderElement(t)}_renderElement(t){let e=t.node;return e||(e=t.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(t),this._renderElementChildren(t),this._setUpListeners(t),e}_renderText(t){let e=t.node;return e?t.revertData.text=e.textContent:e=t.node=document.createTextNode(""),ch(this.text)?this._bindToObservable({schema:this.text,updater:dh(e),data:t}):e.textContent=this.text.join(""),e}_renderAttributes(t){if(!this.attributes)return;const e=t.node,n=t.revertData;for(const o in this.attributes){const i=e.getAttribute(o),r=this.attributes[o];n&&(n.attributes[o]=i);const s=Ah(r)?r[0].ns:null;if(ch(r)){const a=Ah(r)?r[0].value:r;n&&yh(o)&&a.unshift(i),this._bindToObservable({schema:a,updater:uh(e,o,s),data:t})}else if("style"==o&&"string"!=typeof r[0])this._renderStyleAttribute(r[0],t);else{n&&i&&yh(o)&&r.unshift(i);const t=r.map((t=>t&&t.value||t)).reduce(((t,e)=>t.concat(e)),[]).reduce(fh,"");wh(t)||e.setAttributeNS(s,o,t)}}}_renderStyleAttribute(t,e){const n=e.node;for(const o in t){const i=t[o];ch(i)?this._bindToObservable({schema:[i],updater:hh(n,o),data:e}):n.style[o]=i}}_renderElementChildren(t){const e=t.node,n=t.intoFragment?document.createDocumentFragment():e,o=t.isApplying;let i=0;for(const r of this.children)if(vh(r)){if(!o){r.setParent(e);for(const t of r)n.appendChild(t.element)}}else if(_h(r))o||(r.isRendered||r.render(),n.appendChild(r.element));else if(so(r))n.appendChild(r);else if(o){const e={children:[],bindings:[],attributes:{}};t.revertData.children.push(e),r._renderNode({intoFragment:!1,node:n.childNodes[i++],isApplying:!0,revertData:e})}else n.appendChild(r.render());t.intoFragment&&e.appendChild(n)}_setUpListeners(t){if(this.eventListeners)for(const e in this.eventListeners){const n=this.eventListeners[e].map((n=>{const[o,i]=e.split("@");return n.activateDomEventListener(o,i,t)}));t.revertData&&t.revertData.bindings.push(n)}}_bindToObservable({schema:t,updater:e,data:n}){const o=n.revertData;lh(t,e,n);const i=t.filter((t=>!wh(t))).filter((t=>t.observable)).map((o=>o.activateAttributeListener(t,e,n)));o&&o.bindings.push(i)}_revertTemplateFromNode(t,e){for(const t of e.bindings)for(const e of t)e();if(e.text)return void(t.textContent=e.text);const n=t;for(const t in e.attributes){const o=e.attributes[t];null===o?n.removeAttribute(t):n.setAttribute(t,o)}for(let t=0;tlh(t,e,n);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,o),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,o)}}}class sh extends rh{eventNameOrFunction;constructor(t){super(t),this.eventNameOrFunction=t.eventNameOrFunction}activateDomEventListener(t,e,n){const o=(t,n)=>{e&&!n.target.matches(e)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,t,o),()=>{this.emitter.stopListening(n.node,t,o)}}}class ah extends rh{valueIfTrue;constructor(t){super(t),this.valueIfTrue=t.valueIfTrue}getValue(t){return!wh(super.getValue(t))&&(this.valueIfTrue||!0)}}function ch(t){return!!t&&(t.value&&(t=t.value),Array.isArray(t)?t.some(ch):t instanceof rh)}function lh(t,e,{node:n}){const o=function(t,e){return t.map((t=>t instanceof rh?t.getValue(e):t))}(t,n);let i;i=1==t.length&&t[0]instanceof ah?o[0]:o.reduce(fh,""),wh(i)?e.remove():e.set(i)}function dh(t){return{set(e){t.textContent=e},remove(){t.textContent=""}}}function uh(t,e,n){return{set(o){t.setAttributeNS(n,e,o)},remove(){t.removeAttributeNS(n,e)}}}function hh(t,e){return{set(n){t.style[e]=n},remove(){t.style[e]=null}}}function ph(t){return Fe(t,(t=>{if(t&&(t instanceof rh||Ch(t)||_h(t)||vh(t)))return t}))}function mh(t){if("string"==typeof t?t=function(t){return{text:[t]}}(t):t.text&&function(t){t.text=ii(t.text)}(t),t.on&&(t.eventListeners=function(t){for(const e in t)gh(t,e);return t}(t.on),delete t.on),!t.text){t.attributes&&function(t){for(const e in t)t[e].value&&(t[e].value=ii(t[e].value)),gh(t,e)}(t.attributes);const e=[];if(t.children)if(vh(t.children))e.push(t.children);else for(const n of t.children)Ch(n)||_h(n)||so(n)?e.push(n):e.push(new ih(n));t.children=e}return t}function gh(t,e){t[e]=ii(t[e])}function fh(t,e){return wh(e)?t:wh(t)?e:`${t} ${e}`}function kh(t,e){for(const n in e)t[n]?t[n].push(...e[n]):t[n]=e[n]}function bh(t,e){if(e.attributes&&(t.attributes||(t.attributes={}),kh(t.attributes,e.attributes)),e.eventListeners&&(t.eventListeners||(t.eventListeners={}),kh(t.eventListeners,e.eventListeners)),e.text&&t.text.push(...e.text),e.children&&e.children.length){if(t.children.length!=e.children.length)throw new An("ui-template-extend-children-mismatch",t);let n=0;for(const o of e.children)bh(t.children[n++],o)}}function wh(t){return!t&&0!==t}function _h(t){return t instanceof xh}function Ch(t){return t instanceof ih}function vh(t){return t instanceof oh}function Ah(t){return o(t[0])&&t[0].ns}function yh(t){return"class"==t||"style"==t}class xh extends(lo(qn())){element;isRendered;locale;t;template;_viewCollections;_unboundChildren;_bindTemplate;constructor(t){super(),this.element=null,this.isRendered=!1,this.locale=t,this.t=t&&t.t,this._viewCollections=new si,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((e,n)=>{n.locale=t,n.t=t&&t.t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=ih.bind(this,this)}createCollection(t){const e=new oh(t);return this._viewCollections.add(e),e}registerChild(t){eo(t)||(t=[t]);for(const e of t)this._unboundChildren.add(e)}deregisterChild(t){eo(t)||(t=[t]);for(const e of t)this._unboundChildren.remove(e)}setTemplate(t){this.template=new ih(t)}extendTemplate(t){ih.extend(this.template,t)}render(){if(this.isRendered)throw new An("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map((t=>t.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}}function Eh({emitter:t,activator:e,callback:n,contextElements:o,listenerOptions:i}){t.listenTo(document,"mousedown",((t,i)=>{if(!e())return;const r="function"==typeof i.composedPath?i.composedPath():[],s="function"==typeof o?o():o;for(const t of s)if(t.contains(i.target)||r.includes(t))return;n()}),i)}function Dh(t){return class extends t{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...t){super(...t),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}function Sh({view:t}){t.listenTo(t.element,"submit",((e,n)=>{n.preventDefault(),t.fire("submit")}),{useCapture:!0})}function Th({keystrokeHandler:t,focusTracker:e,gridItems:n,numberOfColumns:o,uiLanguageDirection:i}){const r="number"==typeof o?()=>o:o;function s(t){return o=>{const i=n.find((t=>t.element===e.focusedElement)),r=n.getIndex(i),s=t(r,n);n.get(s).focus(),o.stopPropagation(),o.preventDefault()}}function a(t,e){return t===e-1?0:t+1}function c(t,e){return 0===t?e-1:t-1}t.set("arrowright",s(((t,e)=>"rtl"===i?c(t,e.length):a(t,e.length)))),t.set("arrowleft",s(((t,e)=>"rtl"===i?a(t,e.length):c(t,e.length)))),t.set("arrowup",s(((t,e)=>{let n=t-r();return n<0&&(n=t+r()*Math.floor(e.length/r()),n>e.length-1&&(n-=r())),n}))),t.set("arrowdown",s(((t,e)=>{let n=t+r();return n>e.length-1&&(n=t%r()),n})))}class Bh extends xh{static presentationalAttributeNames=["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"];constructor(){super();const t=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",t.if("isVisible","ck-hidden",(t=>!t)),"ck-reset_all-excluded",t.if("isColorInherited","ck-icon_inherit-color")],viewBox:t.to("viewBox")}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",(()=>{this._updateXMLContent(),this._colorFillPaths()})),this.on("change:fillColor",(()=>{this._colorFillPaths()}))}_updateXMLContent(){if(this.content){const t=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),e=t.getAttribute("viewBox");e&&(this.viewBox=e);for(const{name:e,value:n}of Array.from(t.attributes))Bh.presentationalAttributeNames.includes(e)&&this.element.setAttribute(e,n);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;t.childNodes.length>0;)this.element.appendChild(t.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((t=>{t.style.fill=this.fillColor}))}}class Ih extends xh{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const t=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:t.to("style"),id:t.to("id")},children:[{text:t.to("text")}]})}}class Mh extends xh{children;labelView;iconView;keystrokeView;_focusDelayed=null;constructor(t,e=new Ih){super(t);const n=this.bindTemplate,o=_n();this.set("_ariaPressed",!1),this.set("_ariaChecked",!1),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${o}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(e),this.iconView=new Bh,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const i={tag:"button",attributes:{class:["ck","ck-button",n.to("class"),n.if("isEnabled","ck-disabled",(t=>!t)),n.if("isVisible","ck-hidden",(t=>!t)),n.to("isOn",(t=>t?"ck-on":"ck-off")),n.if("withText","ck-button_with-text"),n.if("withKeystroke","ck-button_with-keystroke")],role:n.to("role"),type:n.to("type",(t=>t||"button")),tabindex:n.to("tabindex"),"aria-checked":n.to("_ariaChecked"),"aria-pressed":n.to("_ariaPressed"),"aria-label":n.to("ariaLabel"),"aria-labelledby":n.to("ariaLabelledBy"),"aria-disabled":n.if("isEnabled",!0,(t=>!t)),"data-cke-tooltip-text":n.to("_tooltipString"),"data-cke-tooltip-position":n.to("tooltipPosition")},children:this.children,on:{click:n.to((t=>{this.isEnabled?this.fire("execute"):t.preventDefault()}))}};this.bind("_ariaPressed").to(this,"isOn",this,"isToggleable",this,"role",((t,e,n)=>!(!e||Ph(n))&&String(!!t))),this.bind("_ariaChecked").to(this,"isOn",this,"isToggleable",this,"role",((t,e,n)=>!(!e||!Ph(n))&&String(!!t))),rn.isSafari&&(this._focusDelayed||(this._focusDelayed=gi((()=>this.focus()),0)),i.on.mousedown=n.to((()=>{this._focusDelayed()})),i.on.mouseup=n.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(i)}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_setupLabelView(t){return t.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),t}_createKeystrokeView(){const t=new xh;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(t=>Xo(t)))}]}),t}_getTooltipString(t,e,n){return t?"string"==typeof t?t:(n&&(n=Xo(n)),t instanceof Function?t(e,n):`${e}${n?` (${n})`:""}`):""}}function Ph(t){switch(t){case"radio":case"checkbox":case"option":case"switch":case"menuitemcheckbox":case"menuitemradio":return!0;default:return!1}}class Oh extends xh{children;iconView;constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("label",e.label||""),this.set("class",e.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",n.to("class")]},children:this.children}),e.icon&&(this.iconView=new Bh,this.iconView.content=e.icon,this.children.add(this.iconView));const o=new xh(t);o.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:n.to("label")}]}),this.children.add(o)}}class Nh extends(Mn()){focusables;focusTracker;keystrokeHandler;actions;constructor(t){if(super(),this.focusables=t.focusables,this.focusTracker=t.focusTracker,this.keystrokeHandler=t.keystrokeHandler,this.actions=t.actions,t.actions&&t.keystrokeHandler)for(const e in t.actions){let n=t.actions[e];"string"==typeof n&&(n=[n]);for(const o of n)t.keystrokeHandler.set(o,((t,n)=>{this[e](),n()}),t.keystrokeHandlerOptions)}this.on("forwardCycle",(()=>this.focusFirst()),{priority:"low"}),this.on("backwardCycle",(()=>this.focusLast()),{priority:"low"})}get first(){return this.focusables.find(zh)||null}get last(){return this.focusables.filter(zh).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let t=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((e,n)=>{const o=e.element===this.focusTracker.focusedElement;return o&&(t=n),o})),t)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const t=this.next;t&&this.focusables.getIndex(t)===this.current||t===this.first?this.fire("forwardCycle"):this._focus(t,1)}focusPrevious(){const t=this.previous;t&&this.focusables.getIndex(t)===this.current||t===this.last?this.fire("backwardCycle"):this._focus(t,-1)}chain(t){const e=()=>null===this.current?null:this.focusables.get(this.current);this.listenTo(t,"forwardCycle",(t=>{const n=e();this.focusNext(),n!==e()&&t.stop()}),{priority:"low"}),this.listenTo(t,"backwardCycle",(t=>{const n=e();this.focusPrevious(),n!==e()&&t.stop()}),{priority:"low"})}unchain(t){this.stopListening(t)}_focus(t,e){t&&this.focusTracker.focusedElement!==t.element&&t.focus(e)}_getDomFocusableItem(t){const e=this.focusables.length;if(!e)return null;const n=this.current;if(null===n)return this[1===t?"first":"last"];let o=this.focusables.get(n),i=(n+e+t)%e;do{const n=this.focusables.get(i);if(zh(n)){o=n;break}i=(i+e+t)%e}while(i!==n);return o}}function zh(t){return Lh(t)&&Io(t.element)}function Lh(t){return!(!("focus"in t)||"function"!=typeof t.focus)}function Rh(t){return class extends t{_onDragBound=this._onDrag.bind(this);_onDragEndBound=this._onDragEnd.bind(this);_lastDraggingCoordinates={x:0,y:0};constructor(...t){super(...t),this.on("render",(()=>{this._attachListeners()})),this.set("isDragging",!1)}_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(en.document,"mouseup",this._onDragEndBound),this.listenTo(en.document,"touchend",this._onDragEndBound),this.listenTo(en.document,"mousemove",this._onDragBound),this.listenTo(en.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(en.document,"mouseup",this._onDragEndBound),this.stopListening(en.document,"touchend",this._onDragEndBound),this.stopListening(en.document,"mousemove",this._onDragBound),this.stopListening(en.document,"touchmove",this._onDragBound)}_onDragStart(t,e){if(!this._isHandleElementPressed(e))return;this._attachDragListeners();let n=0,o=0;e instanceof MouseEvent?(n=e.clientX,o=e.clientY):(n=e.touches[0].clientX,o=e.touches[0].clientY),this._lastDraggingCoordinates={x:n,y:o},this.isDragging=!0}_onDrag(t,e){if(!this.isDragging)return void this._detachDragListeners();let n=0,o=0;e instanceof MouseEvent?(n=e.clientX,o=e.clientY):(n=e.touches[0].clientX,o=e.touches[0].clientY),e.preventDefault(),this.fire("drag",{deltaX:Math.round(n-this._lastDraggingCoordinates.x),deltaY:Math.round(o-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:n,y:o}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(t){return!!this.dragHandleElement&&(this.dragHandleElement===t.target||t.target instanceof HTMLElement&&this.dragHandleElement.contains(t.target))}}}class Fh extends xh{children;keystrokes;focusCycler;_focusTracker;_focusables;constructor(t){super(t),this.children=this.createCollection(),this.keystrokes=new hi,this._focusTracker=new ci,this._focusables=new oh,this.focusCycler=new Nh({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(t){for(const e of t){const t=new Mh(this.locale);let n;for(n in t.on("execute",(()=>e.onExecute())),e.onCreate&&e.onCreate(t),e)"onExecute"!=n&&"onCreate"!=n&&t.set(n,e[n]);this.children.add(t)}this._updateFocusCyclableItems()}focus(t){-1===t?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach((t=>{this._focusables.add(t),this._focusTracker.add(t.element)}))}}class jh extends xh{children;constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}reset(){for(;this.children.length;)this.children.remove(0)}}const Vh="screen-center",Hh="editor-center",Uh="editor-top-side",Wh=Eo("px");class Gh extends(Rh(xh)){parts;headerView;closeButtonView;actionsView;static defaultOffset=15;contentView;keystrokes;focusTracker;wasMoved=!1;_getCurrentDomRoot;_getViewportOffset;_focusables;_focusCycler;constructor(t,{getCurrentDomRoot:e,getViewportOffset:n}){super(t);const o=this.bindTemplate,i=t.t;this.set("className",""),this.set("ariaLabel",i("Editor dialog")),this.set("isModal",!1),this.set("position",Vh),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=e,this._getViewportOffset=n,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new hi,this.focusTracker=new ci,this._focusables=new oh,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",o.if("isModal","ck-dialog-overlay__transparent",(t=>!t)),o.if("_isVisible","ck-hidden",(t=>!t))],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",o.if("isModal","ck-dialog_modal"),o.to("className")],role:"dialog","aria-label":o.to("ariaLabel"),style:{top:o.to("_top",(t=>Wh(t))),left:o.to("_left",(t=>Wh(t))),visibility:o.if("_isTransparent","hidden")}},children:this.parts}]})}render(){super.render(),this.keystrokes.set("Esc",((t,e)=>{t.defaultPrevented||(this.fire("close",{source:"escKeyPress"}),e())})),this.on("drag",((t,{deltaX:e,deltaY:n})=>{this.wasMoved=!0,this.moveBy(e,n)})),this.listenTo(en.window,"resize",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.listenTo(en.document,"scroll",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.on("change:_isVisible",((t,e,n)=>{n&&(this._isTransparent=!0,setTimeout((()=>{this.updatePosition(),this._isTransparent=!1,this.focus()}),10))})),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView&&!this.isModal?this.headerView.element:null}setupParts({icon:t,title:e,hasCloseButton:n=!0,content:o,actionButtons:i}){e&&(this.headerView=new Oh(this.locale,{icon:t}),n&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=e,this.ariaLabel=e,this.parts.add(this.headerView,0)),o&&(o instanceof xh&&(o=[o]),this.contentView=new jh(this.locale),this.contentView.children.addMany(o),this.parts.add(this.contentView)),i&&(this.actionsView=new Fh(this.locale),this.actionsView.setButtons(i),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(t,e){const n=this._getViewportRect(),o=this._getDialogRect();t+o.width>n.right&&(t=n.right-o.width),t{var e;this._focusables.add(t),this.focusTracker.add(t.element),Lh(e=t)&&"focusCycler"in e&&e.focusCycler instanceof Nh&&this._focusCycler.chain(t.focusCycler)}))}_createCloseButton(){const t=new Mh(this.locale),e=this.locale.t;return t.set({label:e("Close"),tooltip:!0,icon:yu.cancel}),t.on("execute",(()=>this.fire("close",{source:"closeButton"}))),t}}class qh extends iu{view;static _visibleDialogPlugin;_onHide;static get pluginName(){return"Dialog"}static get isOfficialPlugin(){return!0}constructor(t){super(t);const e=t.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set({id:null,isOpen:!1}),t.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:e("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}destroy(){super.destroy(),this._unlockBodyScroll()}_initShowHideListeners(){this.on("show",((t,e)=>{this._show(e)})),this.on("show",((t,e)=>{e.onShow&&e.onShow(this)}),{priority:"low"}),this.on("hide",(()=>{qh._visibleDialogPlugin&&qh._visibleDialogPlugin._hide()})),this.on("hide",(()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)}),{priority:"low"})}_initFocusToggler(){const t=this.editor;t.keystrokes.set("Ctrl+F6",((e,n)=>{this.isOpen&&!this.view.isModal&&(this.view.focusTracker.isFocused?t.editing.view.focus():this.view.focus(),n())}))}_initMultiRootIntegration(){const t=this.editor.model;t.document.on("change:data",(()=>{if(!this.view)return;const e=t.document.differ.getChangedRoots();for(const t of e)t.state&&this.view.updatePosition()}))}show(t){this.hide(),this.fire(`show:${t.id}`,t)}_show({id:t,icon:e,title:n,hasCloseButton:o=!0,content:i,actionButtons:r,className:s,isModal:a,position:c,onHide:l}){const d=this.editor;this.view=new Gh(d.locale,{getCurrentDomRoot:()=>d.editing.view.getDomRoot(d.model.document.selection.anchor.root.rootName),getViewportOffset:()=>d.ui.viewportOffset});const u=this.view;u.on("close",(()=>{this.hide()})),d.ui.view.body.add(u),d.keystrokes.listenTo(u.element),c||(c=a?Vh:Hh),a&&this._lockBodyScroll(),u.set({position:c,_isVisible:!0,className:s,isModal:a}),u.setupParts({icon:e,title:n,hasCloseButton:o,content:i,actionButtons:r}),this.id=t,l&&(this._onHide=l),this.isOpen=!0,qh._visibleDialogPlugin=this}hide(){qh._visibleDialogPlugin&&qh._visibleDialogPlugin.fire(`hide:${qh._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;const t=this.editor,e=this.view;e.isModal&&this._unlockBodyScroll(),e.contentView&&e.contentView.reset(),t.ui.view.body.remove(e),t.ui.focusTracker.remove(e.element),t.keystrokes.stopListening(e.element),e.destroy(),t.editing.view.focus(),this.id=null,this.isOpen=!1,qh._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add("ck-dialog-scroll-locked")}_unlockBodyScroll(){document.documentElement.classList.remove("ck-dialog-scroll-locked")}}class $h extends Mh{_checkIconHolderView=new Kh;constructor(t,e=new Ih){super(t,e),this.set({hasCheckSpace:!1,_hasCheck:this.isToggleable});const n=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-list-item-button",n.if("isToggleable","ck-list-item-button_toggleable")]}}),this.bind("_hasCheck").to(this,"hasCheckSpace",this,"isToggleable",((t,e)=>t||e))}render(){super.render(),this._hasCheck&&this.children.add(this._checkIconHolderView,0),this._watchCheckIconHolderMount()}_watchCheckIconHolderMount(){this._checkIconHolderView.bind("isOn").to(this,"isOn",(t=>this.isToggleable&&t)),this.on("change:_hasCheck",((t,e,n)=>{const{children:o,_checkIconHolderView:i}=this;n?o.add(i,0):o.remove(i)}))}}class Kh extends xh{children;_checkIconView=this._createCheckIconView();constructor(){super();const t=this.bindTemplate;this.children=this.createCollection(),this.set("isOn",!1),this.setTemplate({tag:"span",children:this.children,attributes:{class:["ck","ck-list-item-button__check-holder",t.to("isOn",(t=>t?"ck-on":"ck-off"))]}})}render(){super.render(),this.isOn&&this.children.add(this._checkIconView,0),this._watchCheckIconMount()}_watchCheckIconMount(){this.on("change:isOn",((t,e,n)=>{const{children:o,_checkIconView:i}=this;n&&!o.has(i)?o.add(i):!n&&o.has(i)&&o.remove(i)}))}_createCheckIconView(){const t=new Bh;return t.content=yu.check,t.extendTemplate({attributes:{class:"ck-list-item-button__check-icon"}}),t}}class Yh extends $h{constructor(t){super(t),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class Qh extends xh{id;constructor(t){super(t),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${_n()}`;const e=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:e.to("for")},children:[{text:e.to("text")}]})}}class Zh extends xh{constructor(t,e){super(t);const n=t.t,o=new Qh;o.text=n("Help Contents. To close this dialog press ESC."),this.setTemplate({tag:"div",attributes:{class:["ck","ck-accessibility-help-dialog__content"],"aria-labelledby":o.id,role:"document",tabindex:-1},children:[no(document,"p",{},n("Below, you can find a list of keyboard shortcuts that can be used in the editor.")),...this._createCategories(Array.from(e.values())),o]})}focus(){this.element.focus()}_createCategories(t){return t.map((t=>{const e=[no(document,"h3",{},t.label),...Array.from(t.groups.values()).map((t=>this._createGroup(t))).flat()];return t.description&&e.splice(1,0,no(document,"p",{},t.description)),no(document,"section",{},e)}))}_createGroup(t){const e=t.keystrokes.sort(((t,e)=>t.label.localeCompare(e.label))).map((t=>this._createGroupRow(t))).flat(),n=[no(document,"dl",{},e)];return t.label&&n.unshift(no(document,"h4",{},t.label)),n}_createGroupRow(t){const e=this.locale.t,n=no(document,"dt"),o=no(document,"dd"),i="string"==typeof(s=t.keystroke)?[[s]]:"string"==typeof s[0]?[s]:s,r=[];var s;for(const t of i)r.push(t.map(Jh).join(""));return n.innerHTML=t.label,o.innerHTML=r.join(", ")+(t.mayRequireFn&&rn.isMac?` ${e("(may require Fn )")}`:""),[n,o]}}function Jh(t){return Xo(t).split("+").map((t=>`${t} `)).join("+")}var Xh=' ';class tp extends iu{contentView=null;static get requires(){return[qh]}static get pluginName(){return"AccessibilityHelp"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t;t.ui.componentFactory.add("accessibilityHelp",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0,withText:!1,label:e("Accessibility help")}),t})),t.ui.componentFactory.add("menuBar:accessibilityHelp",(()=>{const t=this._createButton(Yh);return t.label=e("Accessibility"),t})),t.keystrokes.set("Alt+0",((t,e)=>{this._toggleDialog(),e()})),this._setupRootLabels()}_createButton(t){const e=this.editor,n=e.plugins.get("Dialog"),o=new t(e.locale);return o.set({keystroke:"Alt+0",icon:Xh,isToggleable:!0}),o.on("execute",(()=>this._toggleDialog())),o.bind("isOn").to(n,"id",(t=>"accessibilityHelp"===t)),o}_setupRootLabels(){const t=this.editor,e=t.editing.view,n=t.t;function o(t,e){const o=[e.getAttribute("aria-label"),n("Press %0 for help.",[Xo("Alt+0")])].filter((t=>t)).join(". ");t.setAttribute("aria-label",o,e)}t.ui.on("ready",(()=>{e.change((t=>{for(const n of e.document.roots)o(t,n)})),t.on("addRoot",((n,i)=>{const r=t.editing.view.document.getRoot(i.rootName);e.change((t=>o(t,r)))}),{priority:"low"})}))}_toggleDialog(){const t=this.editor,e=t.plugins.get("Dialog"),n=t.locale.t;this.contentView||(this.contentView=new Zh(t.locale,t.accessibility.keystrokeInfos)),"accessibilityHelp"===e.id?e.hide():e.show({id:"accessibilityHelp",className:"ck-accessibility-help-dialog",title:n("Accessibility help"),icon:Xh,hasCloseButton:!0,content:this.contentView})}}class ep extends oh{locale;_bodyCollectionContainer;static _bodyWrapper;constructor(t,e=[]){super(e),this.locale=t}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new ih({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection,role:"application"},children:this}).render(),ep._bodyWrapper&&ep._bodyWrapper.isConnected||(ep._bodyWrapper=no(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(ep._bodyWrapper)),ep._bodyWrapper.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove(),ep._bodyWrapper&&!ep._bodyWrapper.childElementCount&&(ep._bodyWrapper.remove(),delete ep._bodyWrapper)}}class np extends Mh{toggleSwitchView;constructor(t){super(t),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const t=new xh;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),t}}class op extends(ip($h)){}function ip(t){return class extends t{buttonView;_fileInputView;constructor(...t){super(...t),this.buttonView=this,this._fileInputView=new rp(this.locale),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",(()=>{this._fileInputView.open()})),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}render(){super.render(),this.children.add(this._fileInputView)}}}class rp extends xh{constructor(t){super(t),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:e.to("acceptedType"),multiple:e.to("allowMultipleFiles")},on:{change:e.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}var sp=' ';class ap extends xh{buttonView;children;constructor(t,e){super(t);const n=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),e&&this.children.addMany(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",n.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:n.if("isCollapsed","hidden"),"aria-labelledby":n.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){const t=new Mh(this.locale),e=t.bindTemplate;return t.set({withText:!0,icon:sp}),t.extendTemplate({attributes:{"aria-expanded":e.to("isOn",(t=>String(t)))}}),t.bind("label").to(this),t.bind("isOn").to(this,"isCollapsed",(t=>!t)),t.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),t}}function cp(t,e){const n=t.t,o={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return e.map((t=>{const e=o[t.label];return e&&e!=t.label&&(t.label=e),t}))}function lp(t){return t.map(dp).filter((t=>!!t))}function dp(t){return"string"==typeof t?{model:t,label:t,hasBorder:!1,view:{name:"span",styles:{color:t}}}:{model:t.color,label:t.label||t.color,hasBorder:void 0!==t.hasBorder&&t.hasBorder,view:{name:"span",styles:{color:`${t.color}`}}}}class up extends Mh{constructor(t){super(t);const e=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon=' ',this.extendTemplate({attributes:{style:{backgroundColor:e.to("color",(t=>rn.isMediaForcedColors?null:t))},class:["ck","ck-color-grid__tile",e.if("hasBorder","ck-color-selector__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}class hp extends xh{columns;items;focusTracker;keystrokes;constructor(t,e){super(t);const n=e&&e.colorDefinitions?e.colorDefinitions:[];this.columns=e&&e.columns?e.columns:5;const o={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new ci,this.keystrokes=new hi,this.items.on("add",((t,e)=>{e.isOn=e.color===this.selectedColor})),n.forEach((t=>{const e=new up;e.set({color:t.color,label:t.label,tooltip:!0,hasBorder:t.options.hasBorder}),e.on("execute",(()=>{this.fire("execute",{value:t.color,hasBorder:t.options.hasBorder,label:t.label})})),this.items.add(e)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:o}}),this.on("change:selectedColor",((t,e,n)=>{for(const t of this.items)t.isOn=t.color===n}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",((t,e)=>{this.focusTracker.add(e.element)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element),Th({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}function pp(t,e){if(!t)return"";const n=mp(t);if(!n)return"";if(n.space===e)return t;if(o=n,!Object.keys(Iu).includes(o.space))return"";var o;const i=Iu[n.space][e];return i?function(t,e){switch(e){case"hex":return`#${t}`;case"rgb":return`rgb( ${t[0]}, ${t[1]}, ${t[2]} )`;case"hsl":return`hsl( ${t[0]}, ${t[1]}%, ${t[2]}% )`;case"hwb":return`hwb( ${t[0]}, ${t[1]}, ${t[2]} )`;case"lab":return`lab( ${t[0]}% ${t[1]} ${t[2]} )`;case"lch":return`lch( ${t[0]}% ${t[1]} ${t[2]} )`;default:return""}}(i("hex"===n.space?n.hexValue:n.values),e):""}function mp(t){if(t.startsWith("#")){const e=Su(t);return{space:"hex",values:e.values,hexValue:t,alpha:e.alpha}}const e=Su(t);return e.space?e:null}class gp extends xh{fieldView;labelView;statusView;fieldWrapperChildren;constructor(t,e){super(t);const n=`ck-labeled-field-view-${_n()}`,o=`ck-labeled-field-view-status-${_n()}`;this.fieldView=e(this,n,o),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(n),this.statusView=this._createStatusView(o),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",((t,e)=>t||e));const i=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",i.to("class"),i.if("isEnabled","ck-disabled",(t=>!t)),i.if("isEmpty","ck-labeled-field-view_empty"),i.if("isFocused","ck-labeled-field-view_focused"),i.if("placeholder","ck-labeled-field-view_placeholder"),i.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(t){const e=new Qh(this.locale);return e.for=t,e.bind("text").to(this,"label"),e}_createStatusView(t){const e=new xh(this.locale),n=this.bindTemplate;return e.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(t=>!t))],id:t,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),e}focus(t){this.fieldView.focus(t)}}class fp extends xh{focusTracker;constructor(t){super(t),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new ci,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",e.if("isFocused","ck-input_focused"),e.if("isEmpty","ck-input-text_empty"),e.if("hasError","ck-error")],id:e.to("id"),placeholder:e.to("placeholder"),tabindex:e.to("tabIndex"),readonly:e.to("isReadOnly"),"aria-invalid":e.if("hasError",!0),"aria-describedby":e.to("ariaDescribedById"),"aria-label":e.to("ariaLabel")},on:{input:e.to(((...t)=>{this.fire("input",...t),this._updateIsEmpty()})),change:e.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((t,e,n)=>{this._setDomElementValue(n),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(t){this.element.value=t||0===t?t:""}}class kp extends fp{constructor(t){super(t),this.set("inputMode","text");const e=this.bindTemplate;this.extendTemplate({attributes:{inputmode:e.to("inputMode")}})}}class bp extends kp{constructor(t){super(t),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class wp extends kp{constructor(t,{min:e,max:n,step:o}={}){super(t);const i=this.bindTemplate;this.set("min",e),this.set("max",n),this.set("step",o),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:i.to("min"),max:i.to("max"),step:i.to("step")}})}}class _p extends xh{children;constructor(t){super(t);const e=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",e.to("position",(t=>`ck-dropdown__panel_${t}`)),e.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:e.to((t=>{"input"!==t.target.tagName.toLocaleLowerCase()&&t.preventDefault()}))}})}focus(){if(this.children.length){const t=this.children.first;"function"==typeof t.focus?t.focus():yn("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const t=this.children.last;"function"==typeof t.focusLast?t.focusLast():t.focus()}}}class Cp extends xh{buttonView;panelView;focusTracker;keystrokes;listView;toolbarView;menuView;constructor(t,e,n){super(t);const o=this.bindTemplate;this.buttonView=e,this.panelView=n,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new hi,this.focusTracker=new ci,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",o.to("class"),o.if("isEnabled","ck-disabled",(t=>!t))],id:o.to("id"),"aria-describedby":o.to("ariaDescribedById")},children:[e,n]}),e.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":o.to("isOpen")}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",(()=>{this.isOpen=!this.isOpen})),this.on("change:isOpen",((t,e,n)=>{if(n)if("auto"===this.panelPosition){const t=Cp._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=t?t.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition})),this.keystrokes.listenTo(this.element);const t=(t,e)=>{this.isOpen&&(this.isOpen=!1,e())};this.keystrokes.set("arrowdown",((t,e)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,e())})),this.keystrokes.set("arrowright",((t,e)=>{this.isOpen&&e()})),this.keystrokes.set("arrowleft",t),this.keystrokes.set("esc",t)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:t,north:e,southEast:n,southWest:o,northEast:i,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:c,northMiddleWest:l}=Cp.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[n,o,s,a,t,i,r,c,l,e]:[o,n,a,s,t,r,i,l,c,e]}get _defaultPanelPositionName(){return"rtl"===this.locale.uiLanguageDirection?"sw":"se"}static defaultPanelPositions={south:(t,e)=>({top:t.bottom,left:t.left-(e.width-t.width)/2,name:"s"}),southEast:t=>({top:t.bottom,left:t.left,name:"se"}),southWest:(t,e)=>({top:t.bottom,left:t.left-e.width+t.width,name:"sw"}),southMiddleEast:(t,e)=>({top:t.bottom,left:t.left-(e.width-t.width)/4,name:"sme"}),southMiddleWest:(t,e)=>({top:t.bottom,left:t.left-3*(e.width-t.width)/4,name:"smw"}),north:(t,e)=>({top:t.top-e.height,left:t.left-(e.width-t.width)/2,name:"n"}),northEast:(t,e)=>({top:t.top-e.height,left:t.left,name:"ne"}),northWest:(t,e)=>({top:t.top-e.height,left:t.left-e.width+t.width,name:"nw"}),northMiddleEast:(t,e)=>({top:t.top-e.height,left:t.left-(e.width-t.width)/4,name:"nme"}),northMiddleWest:(t,e)=>({top:t.top-e.height,left:t.left-3*(e.width-t.width)/4,name:"nmw"})};static _getOptimalPosition=Mo}class vp extends Mh{arrowView;constructor(t){super(t),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(t=>String(t)))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const t=new Bh;return t.content=sp,t.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),t}}class Ap extends xh{children;constructor(t){super(t);const e=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",e.if("isVisible","ck-hidden",(t=>!t))],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class yp extends xh{constructor(t){super(t),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class xp extends xh{labelView;items;children;constructor(t,e=new Qh){super(t);const n=this.bindTemplate,o=new Ep(t);this.set({label:"",isVisible:!0}),this.labelView=e,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,o]),o.set({role:"group",ariaLabelledBy:e.id}),o.focusTracker.destroy(),o.keystrokes.destroy(),this.items=o.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",n.if("isVisible","ck-hidden",(t=>!t))]},children:this.children})}focus(){if(this.items){const t=this.items.find((t=>!(t instanceof yp)));t&&t.focus()}}}class Ep extends xh{focusables;items;focusTracker;keystrokes;_focusCycler;_listItemGroupToChangeListeners=new WeakMap;constructor(t){super(t);const e=this.bindTemplate;this.focusables=new oh,this.items=this.createCollection(),this.focusTracker=new ci,this.keystrokes=new hi,this._focusCycler=new Nh({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:e.to("role"),"aria-label":e.to("ariaLabel"),"aria-labelledby":e.to("ariaLabelledBy")},children:this.items})}render(){super.render();for(const t of this.items)t instanceof xp?this._registerFocusableItemsGroup(t):t instanceof Ap&&this._registerFocusableListItem(t);this.items.on("change",((t,e)=>{for(const t of e.removed)t instanceof xp?this._deregisterFocusableItemsGroup(t):t instanceof Ap&&this._deregisterFocusableListItem(t);for(const t of Array.from(e.added).reverse())t instanceof xp?this._registerFocusableItemsGroup(t,e.index):this._registerFocusableListItem(t,e.index)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(t,e){this.focusTracker.add(t.element),this.focusables.add(t,e)}_deregisterFocusableListItem(t){this.focusTracker.remove(t.element),this.focusables.remove(t)}_getOnGroupItemsChangeCallback(t){return(e,n)=>{for(const t of n.removed)this._deregisterFocusableListItem(t);for(const e of Array.from(n.added).reverse())this._registerFocusableListItem(e,this.items.getIndex(t)+n.index)}}_registerFocusableItemsGroup(t,e){Array.from(t.items).forEach(((t,n)=>{const o=void 0!==e?e+n:void 0;this._registerFocusableListItem(t,o)}));const n=this._getOnGroupItemsChangeCallback(t);this._listItemGroupToChangeListeners.set(t,n),t.items.on("change",n)}_deregisterFocusableItemsGroup(t){for(const e of t.items)this._deregisterFocusableListItem(e);t.items.off("change",this._listItemGroupToChangeListeners.get(t)),this._listItemGroupToChangeListeners.delete(t)}}const Dp=Eo("px"),Sp={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class Tp extends xh{content;_pinWhenIsVisibleCallback;_resizeObserver;constructor(t){super(t);const e=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this._resizeObserver=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",e.to("position",(t=>`ck-balloon-panel_${t}`)),e.if("isVisible","ck-balloon-panel_visible"),e.if("withArrow","ck-balloon-panel_with-arrow"),e.to("class")],style:{top:e.to("top",Dp),left:e.to("left",Dp)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(t){const e=Bp(t.target);if(e&&!Io(e))return!1;this.show();const n=Tp.defaultPositions,o=Object.assign({},{element:this.element,positions:[n.southArrowNorth,n.southArrowNorthMiddleWest,n.southArrowNorthMiddleEast,n.southArrowNorthWest,n.southArrowNorthEast,n.northArrowSouth,n.northArrowSouthMiddleWest,n.northArrowSouthMiddleEast,n.northArrowSouthWest,n.northArrowSouthEast,n.viewportStickyNorth],limiter:en.document.body,fitInViewport:!0},t),i=Tp._getOptimalPosition(o)||Sp,r=parseInt(i.left),s=parseInt(i.top),a=i.name,c=i.config||{},{withArrow:l=!0}=c;return this.top=s,this.left=r,this.position=a,this.withArrow=l,!0}pin(t){this.unpin(),this._startPinning(t)&&(this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(t):this._stopPinning()},this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback))}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(t){if(!this.attachTo(t))return!1;let e=Bp(t.target);const n=t.limiter?Bp(t.limiter):en.document.body;if(this.listenTo(en.document,"scroll",((o,i)=>{const r=i.target,s=e&&r.contains(e),a=n&&r.contains(n);!s&&!a&&e&&n||this.attachTo(t)}),{useCapture:!0}),this.listenTo(en.window,"resize",(()=>{this.attachTo(t)})),!this._resizeObserver&&(e&&go(e)&&(e=e.parentElement),e)){const t=()=>{Io(e)||this.unpin()};this._resizeObserver=new yo(e,t)}return!0}_stopPinning(){this.stopListening(en.document,"scroll"),this.stopListening(en.window,"resize"),this._resizeObserver&&(this._resizeObserver.destroy(),this._resizeObserver=null)}static generatePositions(t={}){const{sideOffset:e=Tp.arrowSideOffset,heightOffset:n=Tp.arrowHeightOffset,stickyVerticalOffset:o=Tp.stickyVerticalOffset,config:i}=t;return{northWestArrowSouthWest:(t,n)=>({top:r(t,n),left:t.left-e,name:"arrow_sw",...i&&{config:i}}),northWestArrowSouthMiddleWest:(t,n)=>({top:r(t,n),left:t.left-.25*n.width-e,name:"arrow_smw",...i&&{config:i}}),northWestArrowSouth:(t,e)=>({top:r(t,e),left:t.left-e.width/2,name:"arrow_s",...i&&{config:i}}),northWestArrowSouthMiddleEast:(t,n)=>({top:r(t,n),left:t.left-.75*n.width+e,name:"arrow_sme",...i&&{config:i}}),northWestArrowSouthEast:(t,n)=>({top:r(t,n),left:t.left-n.width+e,name:"arrow_se",...i&&{config:i}}),northArrowSouthWest:(t,n)=>({top:r(t,n),left:t.left+t.width/2-e,name:"arrow_sw",...i&&{config:i}}),northArrowSouthMiddleWest:(t,n)=>({top:r(t,n),left:t.left+t.width/2-.25*n.width-e,name:"arrow_smw",...i&&{config:i}}),northArrowSouth:(t,e)=>({top:r(t,e),left:t.left+t.width/2-e.width/2,name:"arrow_s",...i&&{config:i}}),northArrowSouthMiddleEast:(t,n)=>({top:r(t,n),left:t.left+t.width/2-.75*n.width+e,name:"arrow_sme",...i&&{config:i}}),northArrowSouthEast:(t,n)=>({top:r(t,n),left:t.left+t.width/2-n.width+e,name:"arrow_se",...i&&{config:i}}),northEastArrowSouthWest:(t,n)=>({top:r(t,n),left:t.right-e,name:"arrow_sw",...i&&{config:i}}),northEastArrowSouthMiddleWest:(t,n)=>({top:r(t,n),left:t.right-.25*n.width-e,name:"arrow_smw",...i&&{config:i}}),northEastArrowSouth:(t,e)=>({top:r(t,e),left:t.right-e.width/2,name:"arrow_s",...i&&{config:i}}),northEastArrowSouthMiddleEast:(t,n)=>({top:r(t,n),left:t.right-.75*n.width+e,name:"arrow_sme",...i&&{config:i}}),northEastArrowSouthEast:(t,n)=>({top:r(t,n),left:t.right-n.width+e,name:"arrow_se",...i&&{config:i}}),southWestArrowNorthWest:t=>({top:s(t),left:t.left-e,name:"arrow_nw",...i&&{config:i}}),southWestArrowNorthMiddleWest:(t,n)=>({top:s(t),left:t.left-.25*n.width-e,name:"arrow_nmw",...i&&{config:i}}),southWestArrowNorth:(t,e)=>({top:s(t),left:t.left-e.width/2,name:"arrow_n",...i&&{config:i}}),southWestArrowNorthMiddleEast:(t,n)=>({top:s(t),left:t.left-.75*n.width+e,name:"arrow_nme",...i&&{config:i}}),southWestArrowNorthEast:(t,n)=>({top:s(t),left:t.left-n.width+e,name:"arrow_ne",...i&&{config:i}}),southArrowNorthWest:t=>({top:s(t),left:t.left+t.width/2-e,name:"arrow_nw",...i&&{config:i}}),southArrowNorthMiddleWest:(t,n)=>({top:s(t),left:t.left+t.width/2-.25*n.width-e,name:"arrow_nmw",...i&&{config:i}}),southArrowNorth:(t,e)=>({top:s(t),left:t.left+t.width/2-e.width/2,name:"arrow_n",...i&&{config:i}}),southArrowNorthMiddleEast:(t,n)=>({top:s(t),left:t.left+t.width/2-.75*n.width+e,name:"arrow_nme",...i&&{config:i}}),southArrowNorthEast:(t,n)=>({top:s(t),left:t.left+t.width/2-n.width+e,name:"arrow_ne",...i&&{config:i}}),southEastArrowNorthWest:t=>({top:s(t),left:t.right-e,name:"arrow_nw",...i&&{config:i}}),southEastArrowNorthMiddleWest:(t,n)=>({top:s(t),left:t.right-.25*n.width-e,name:"arrow_nmw",...i&&{config:i}}),southEastArrowNorth:(t,e)=>({top:s(t),left:t.right-e.width/2,name:"arrow_n",...i&&{config:i}}),southEastArrowNorthMiddleEast:(t,n)=>({top:s(t),left:t.right-.75*n.width+e,name:"arrow_nme",...i&&{config:i}}),southEastArrowNorthEast:(t,n)=>({top:s(t),left:t.right-n.width+e,name:"arrow_ne",...i&&{config:i}}),westArrowEast:(t,e)=>({top:t.top+t.height/2-e.height/2,left:t.left-e.width-n,name:"arrow_e",...i&&{config:i}}),eastArrowWest:(t,e)=>({top:t.top+t.height/2-e.height/2,left:t.right+n,name:"arrow_w",...i&&{config:i}}),viewportStickyNorth:(t,e,n,r)=>{const s=r||n;return t.getIntersection(s)?s.height-t.height>o?null:{top:s.top+o,left:t.left+t.width/2-e.width/2,name:"arrowless",config:{withArrow:!1,...i}}:null}};function r(t,e){return t.top-e.height-n}function s(t){return t.bottom+n}}static arrowSideOffset=25;static arrowHeightOffset=10;static stickyVerticalOffset=20;static _getOptimalPosition=Mo;static defaultPositions=Tp.generatePositions()}function Bp(t){return je(t)?t:fo(t)?t.commonAncestorContainer:"function"==typeof t?Bp(t()):null}class Ip extends xh{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class Mp extends xh{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function Pp(t){if(Array.isArray(t))return{items:t,removeItems:[]};const e={items:[],removeItems:[]};return t?{...e,...t}:e}const Op=(()=>({alignLeft:yu.alignLeft,bold:yu.bold,importExport:yu.importExport,paragraph:yu.paragraph,plus:yu.plus,text:yu.text,threeVerticalDots:yu.threeVerticalDots,pilcrow:yu.pilcrow,dragIndicator:yu.dragIndicator}))();class Np extends xh{options;items;focusTracker;keystrokes;itemsView;children;focusables;_focusCycler;_behavior;constructor(t,e){super(t);const n=this.bindTemplate,o=this.t;this.options=e||{},this.set("ariaLabel",o("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new ci,this.keystrokes=new hi,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new zp(t),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const i="rtl"===t.uiLanguageDirection;this._focusCycler=new Nh({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[i?"arrowright":"arrowleft","arrowup"],focusNext:[i?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",n.to("class"),n.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":n.to("ariaLabel"),style:{maxWidth:n.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((t=>{t.target===s.element&&t.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new Rp(this):new Lp(this)}render(){super.render(),this.focusTracker.add(this.element);for(const t of this.items)this.focusTracker.add(t);this.items.on("add",((t,e)=>{this.focusTracker.add(e)})),this.items.on("remove",((t,e)=>{this.focusTracker.remove(e)})),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(t,e,n){this.items.addMany(this._buildItemsFromConfig(t,e,n))}_buildItemsFromConfig(t,e,n){const i=Pp(t),r=n||i.removeItems;return this._cleanItemsConfiguration(i.items,e,r).map((t=>o(t)?this._createNestedToolbarDropdown(t,e,r):"|"===t?new Ip:"-"===t?new Mp:e.create(t))).filter((t=>!!t))}_cleanItemsConfiguration(t,e,n){const i=t.filter(((t,i,r)=>"|"===t||-1===n.indexOf(t)&&("-"===t?!this.options.shouldGroupWhenFull||(yn("toolbarview-line-break-ignored-when-grouping-items",r),!1):!(!o(t)&&!e.has(t)&&(yn("toolbarview-item-unavailable",{item:t}),1)))));return this._cleanSeparatorsAndLineBreaks(i)}_cleanSeparatorsAndLineBreaks(t){const e=t=>"-"!==t&&"|"!==t,n=t.length,o=t.findIndex(e);if(-1===o)return[];const i=n-t.slice().reverse().findIndex(e);return t.slice(o,i).filter(((t,n,o)=>!!e(t)||!(n>0&&o[n-1]===t)))}_createNestedToolbarDropdown(t,e,n){let{label:o,icon:i,items:r,tooltip:s=!0,withText:a=!1}=t;if(r=this._cleanItemsConfiguration(r,e,n),!r.length)return null;const c=jp(this.locale);return o||yn("toolbarview-nested-toolbar-dropdown-missing-label",t),c.class="ck-toolbar__nested-toolbar-dropdown",c.buttonView.set({label:o,tooltip:s,withText:!!a}),!1!==i?c.buttonView.icon=Op[i]||i||yu.threeVerticalDots:c.buttonView.withText=!0,Vp(c,(()=>c.toolbarView._buildItemsFromConfig(r,e,n))),c}}class zp extends xh{children;constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Lp{constructor(t){const e=t.bindTemplate;t.set("isVertical",!1),t.itemsView.children.bindTo(t.items).using((t=>t)),t.focusables.bindTo(t.items).using((t=>Lh(t)?t:null)),t.extendTemplate({attributes:{class:[e.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class Rp{view;viewChildren;viewFocusables;viewItemsView;viewFocusTracker;viewLocale;ungroupedItems;groupedItems;groupedItemsDropdown;resizeObserver=null;cachedPadding=null;shouldUpdateGroupingOnNextResize=!1;viewElement;constructor(t){this.view=t,this.viewChildren=t.children,this.viewFocusables=t.focusables,this.viewItemsView=t.itemsView,this.viewFocusTracker=t.focusTracker,this.viewLocale=t.locale,this.ungroupedItems=t.createCollection(),this.groupedItems=t.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),t.itemsView.children.bindTo(this.ungroupedItems).using((t=>t)),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),t.children.on("change",this._updateFocusCyclableItems.bind(this)),t.items.on("change",((t,e)=>{const n=e.index,o=Array.from(e.added);for(const t of e.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(t):this.ungroupedItems.remove(t);for(let t=n;tthis.ungroupedItems.length?this.groupedItems.add(e,t-this.ungroupedItems.length):this.ungroupedItems.add(e,t)}this._updateGrouping()})),t.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(t){this.viewElement=t.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(t)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Io(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const t=this.groupedItems.length;let e;for(;this._areItemsOverflowing;)this._groupLastItem(),e=!0;if(!e&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==t&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const t=this.viewElement,e=this.viewLocale.uiLanguageDirection,n=new wo(t.lastChild),o=new wo(t);if(!this.cachedPadding){const n=en.window.getComputedStyle(t),o="ltr"===e?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[o])}return"ltr"===e?n.right>o.right-this.cachedPadding:n.left{t&&t===e.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),t=e.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(t){t.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Ip),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const t=this.viewLocale,e=t.t,n=jp(t);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition="ltr"===t.uiLanguageDirection?"sw":"se",Vp(n,this.groupedItems),n.buttonView.set({label:e("Show more items"),tooltip:!0,tooltipPosition:"rtl"===t.uiLanguageDirection?"se":"sw",icon:yu.threeVerticalDots}),n}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((t=>{Lh(t)&&this.viewFocusables.add(t)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class Fp extends xh{children;actionView;arrowView;keystrokes;focusTracker;constructor(t,e){super(t);const n=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(e),this.arrowView=this._createArrowView(),this.keystrokes=new hi,this.focusTracker=new ci,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",n.to("class"),n.if("isVisible","ck-hidden",(t=>!t)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",((t,e)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),e())})),this.keystrokes.set("arrowleft",((t,e)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),e())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(t){const e=t||new Mh;return t||e.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),e.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),e.delegate("execute").to(this),e}_createArrowView(){const t=new Mh,e=t.bindTemplate;return t.icon=sp,t.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":e.to("isOn"),"aria-haspopup":!0,"aria-expanded":e.to("isOn",(t=>String(t)))}}),t.bind("isEnabled").to(this),t.bind("label").to(this),t.bind("tooltip").to(this),t.delegate("execute").to(this,"open"),t}}function jp(t,e=vp){const n="function"==typeof e?new e(t):e,o=new _p(t),i=new Cp(t,n,o);return n.bind("isEnabled").to(i),n instanceof Fp?n.arrowView.bind("isOn").to(i,"isOpen"):n.bind("isOn").to(i,"isOpen"),function(t){(function(t){Eh({emitter:t,activator:()=>t.isRendered&&t.isOpen,callback:()=>{t.isOpen=!1},contextElements:()=>[t.element,...qp(t.focusTracker).filter((e=>!t.element.contains(e)))]})})(t),function(t){t.on("execute",(e=>{e.source instanceof np||(t.isOpen=!1)}))}(t),function(t){t.focusTracker.on("change:isFocused",((e,n,o)=>{!o&&t.isOpen&&(t.isOpen=!1)}))}(t),function(t){t.keystrokes.set("arrowdown",((e,n)=>{t.isOpen&&(t.panelView.focus(),n())})),t.keystrokes.set("arrowup",((e,n)=>{t.isOpen&&(t.panelView.focusLast(),n())}))}(t),function(t){t.on("change:isOpen",((e,n,o)=>{o||t.focusTracker.elements.some((t=>t.contains(en.document.activeElement)))&&t.buttonView.focus()}))}(t),function(t){t.on("change:isOpen",((e,n,o)=>{o&&t.panelView.focus()}),{priority:"low"})}(t)}(i),i}function Vp(t,e,n={}){t.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),t.isOpen?Hp(t,e,n):t.once("change:isOpen",(()=>Hp(t,e,n)),{priority:"highest"}),n.enableActiveItemFocusOnDropdownOpen&&Gp(t,(()=>t.toolbarView.items.find((t=>t.isOn))))}function Hp(t,e,n){const o=t.locale,i=o.t,r=t.toolbarView=new Np(o),s="function"==typeof e?e():e;r.ariaLabel=n.ariaLabel||i("Dropdown toolbar"),n.maxWidth&&(r.maxWidth=n.maxWidth),n.class&&(r.class=n.class),n.isCompact&&(r.isCompact=n.isCompact),n.isVertical&&(r.isVertical=!0),s instanceof oh?r.items.bindTo(s).using((t=>t)):r.items.addMany(s),t.panelView.children.add(r),t.focusTracker.add(r),r.items.delegate("execute").to(t)}function Up(t,e,n={}){t.isOpen?Wp(t,e,n):t.once("change:isOpen",(()=>Wp(t,e,n)),{priority:"highest"}),Gp(t,(()=>t.listView.items.find((t=>t instanceof Ap&&t.children.first.isOn))))}function Wp(t,e,n){const o=t.locale,i=t.listView=new Ep(o),r="function"==typeof e?e():e;i.ariaLabel=n.ariaLabel,i.role=n.role,$p(t,i.items,r,o),t.panelView.children.add(i),i.items.delegate("execute").to(t)}function Gp(t,e){t.on("change:isOpen",(()=>{if(!t.isOpen)return;const n=e();n&&("function"==typeof n.focus?n.focus():yn("ui-dropdown-focus-child-on-open-child-missing-focus",{view:n}))}),{priority:Cn.low-10})}function qp(t){return[...t.elements,...t.externalViews.flatMap((t=>qp(t.focusTracker)))]}function $p(t,e,n,o){e.on("change",(()=>{const t=[...e].reduce(((t,e)=>(e instanceof Ap&&e.children.first instanceof $h&&t.push(e.children.first),t)),[]),n=t.some((t=>t.isToggleable));t.forEach((t=>{t.hasCheckSpace=n}))})),e.bindTo(n).using((e=>{if("separator"===e.type)return new yp(o);if("group"===e.type){const n=new xp(o);return n.set({label:e.label}),$p(t,n.items,e.items,o),n.items.delegate("execute").to(t),n}if("button"===e.type||"switchbutton"===e.type){const t="menuitemcheckbox"===e.model.role||"menuitemradio"===e.model.role,n=new Ap(o);let i;return"button"===e.type?(i=new $h(o),i.set({isToggleable:t})):i=new np(o),i.bind(...Object.keys(e.model)).to(e.model),i.delegate("execute").to(n),n.children.add(i),n}return null}))}const Kp=(t,e,n)=>{const o=new bp(t.locale);return o.set({id:e,ariaDescribedById:n}),o.bind("isReadOnly").to(t,"isEnabled",(t=>!t)),o.bind("hasError").to(t,"errorText",(t=>!!t)),o.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused","placeholder").to(o),o},Yp=(t,e,n)=>{const o=new wp(t.locale);return o.set({id:e,ariaDescribedById:n,inputMode:"numeric"}),o.bind("isReadOnly").to(t,"isEnabled",(t=>!t)),o.bind("hasError").to(t,"errorText",(t=>!!t)),o.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused","placeholder").to(o),o},Qp=(t,e,n)=>{const o=jp(t.locale);return o.set({id:e,ariaDescribedById:n}),o.bind("isEnabled").to(t),o};class Zp extends xh{hexInputRow;_debounceColorPickerEvent;_config;constructor(t,e={}){super(t),this.set({color:"",_hexColor:""}),this.hexInputRow=this._createInputRow();const n=this.createCollection();e.hideInput||n.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:n}),this._config=e,this._debounceColorPickerEvent=nr((t=>{this.set("color",t),this.fire("colorSelected",{color:this.color})}),150,{leading:!0}),this.on("set:color",((t,e,n)=>{t.return=pp(n,this._config.format||"hsl")})),this.on("change:color",(()=>{this._hexColor=Jp(this.color)})),this.on("change:_hexColor",(()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Jp(this.color)!=Jp(this._hexColor)&&(this.color=this._hexColor)}))}render(){var t,e;if(super.render(),t="hex-color-picker",e=nh,void 0===customElements.get(t)&&customElements.define(t,e),this.picker=en.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);const t=document.createElement("style");t.textContent='[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}',this.picker.shadowRoot.appendChild(t)}this.picker.addEventListener("color-changed",(t=>{const e=t.detail.value;this._debounceColorPickerEvent(e)}))}focus(){!this._config.hideInput&&(rn.isGecko||rn.isiOS||rn.isSafari)&&this.hexInputRow.children.get(1).focus(),this.slidersView.first.focus()}_createSlidersView(){const t=[...this.picker.shadowRoot.children].filter((t=>"slider"===t.getAttribute("role"))).map((t=>new Xp(t)));this.slidersView=this.createCollection(),t.forEach((t=>{this.slidersView.add(t)}))}_createInputRow(){const t=this._createColorInput();return new em(this.locale,t)}_createColorInput(){const t=new gp(this.locale,Kp),{t:e}=this.locale;return t.set({label:e("HEX"),class:"color-picker-hex-input"}),t.fieldView.bind("value").to(this,"_hexColor",(e=>t.isFocused?t.fieldView.value:e.startsWith("#")?e.substring(1):e)),t.fieldView.on("input",(()=>{const e=t.fieldView.element.value;if(e){const t=nm(e);t&&this._debounceColorPickerEvent(t)}})),t}isValid(){const{t:t}=this.locale;return!!this._config.hideInput||(this.resetValidationStatus(),!!this.hexInputRow.getParsedColor()||(this.hexInputRow.inputView.errorText=t('Please enter a valid color (e.g. "ff0000").'),!1))}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}}function Jp(t){let e=function(t){if(!t)return"";const e=mp(t);return e?"hex"===e.space?e.hexValue:pp(t,"hex"):"#000"}(t);return e||(e="#000"),4===e.length&&(e="#"+[e[1],e[1],e[2],e[2],e[3],e[3]].join("")),e.toLowerCase()}class Xp extends xh{constructor(t){super(),this.element=t}focus(){this.element.focus()}}class tm extends xh{constructor(t){super(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class em extends xh{children;inputView;constructor(t,e){super(t),this.inputView=e,this.children=this.createCollection([new tm,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}getParsedColor(){return nm(this.inputView.fieldView.element.value)}}function nm(t){if(!t)return null;const e=t.trim().replace(/^#/,"");return[3,4,6,8].includes(e.length)&&/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(e)?`#${e}`:null}class om extends(qn(si)){constructor(t){super(t),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(t,e){return this.find((e=>e.color===t.color))?this:super.add(t,e)}hasColor(t){return!!this.find((e=>e.color===t))}}class im extends xh{items;colorDefinitions;focusTracker;columns;documentColors;documentColorsCount;staticColorsGrid;documentColorsGrid;colorPickerButtonView;removeColorButtonView;_focusables;_documentColorsLabel;_removeButtonLabel;_colorPickerLabel;constructor(t,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r,colorPickerLabel:s,focusTracker:a,focusables:c}){super(t);const l=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=a,this.items=this.createCollection(),this.colorDefinitions=e,this.columns=n,this.documentColors=new om,this.documentColorsCount=r,this._focusables=c,this._removeButtonLabel=o,this._colorPickerLabel=s,this._documentColorsLabel=i,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",l.if("isVisible","ck-hidden",(t=>!t))]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(t,e){const n=t.document,o=this.documentColorsCount;this.documentColors.clear();for(const i of n.getRoots()){const n=t.createRangeIn(i);for(const t of n.getItems())if(t.is("$textProxy")&&t.hasAttribute(e)&&(this._addColorToDocumentColors(t.getAttribute(e)),this.documentColors.length>=o))return}}updateSelectedColors(){const t=this.documentColorsGrid,e=this.staticColorsGrid,n=this.selectedColor;e.selectedColor=n,t&&(t.selectedColor=n)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){const t=ih.bind(this.documentColors,this.documentColors),e=new xh(this.locale);e.setTemplate({tag:"span",attributes:{class:["ck","ck-color-grid__label",t.if("isEmpty","ck-hidden")]},children:[{text:this._documentColorsLabel}]}),this.items.add(e),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new Mh,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:yu.colorPalette,class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",(()=>{this.fire("colorPicker:show")}))}_createRemoveColorButton(){const t=new Mh;return t.set({withText:!0,icon:yu.eraser,label:this._removeButtonLabel}),t.class="ck-color-selector__remove-color",t.on("execute",(()=>{this.fire("execute",{value:null,source:"removeColorButton"})})),t.render(),t}_createStaticColorsGrid(){const t=new hp(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return t.on("execute",((t,e)=>{this.fire("execute",{value:e.value,source:"staticColorsGrid"})})),t}_createDocumentColorsGrid(){const t=ih.bind(this.documentColors,this.documentColors),e=new hp(this.locale,{columns:this.columns});return e.extendTemplate({attributes:{class:t.if("isEmpty","ck-hidden")}}),e.items.bindTo(this.documentColors).using((t=>{const e=new up;return e.set({color:t.color,hasBorder:t.options&&t.options.hasBorder}),t.label&&e.set({label:t.label,tooltip:!0}),e.on("execute",(()=>{this.fire("execute",{value:t.color,source:"documentColorsGrid"})})),e})),this.documentColors.on("change:isEmpty",((t,n,o)=>{o&&(e.selectedColor=null)})),e}_addColorToDocumentColors(t){const e=this.colorDefinitions.find((e=>e.color===t));e?this.documentColors.add(Object.assign({},e)):this.documentColors.add({color:t,label:t,options:{hasBorder:!1}})}}class rm extends xh{items;colorPickerView;saveButtonView;cancelButtonView;actionBarView;focusTracker;keystrokes;_focusables;_colorPickerViewConfig;constructor(t,{focusTracker:e,focusables:n,keystrokes:o,colorPickerViewConfig:i}){super(t),this.items=this.createCollection(),this.focusTracker=e,this.keystrokes=o,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=n,this._colorPickerViewConfig=i;const r=this.bindTemplate,{saveButtonView:s,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=s,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:s,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",r.if("isVisible","ck-hidden",(t=>!t))]},children:this.items})}render(){super.render();const t=new Zp(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=t,this.colorPickerView.render(),this.selectedColor&&(t.color=this.selectedColor),this.listenTo(this,"change:selectedColor",((e,n,o)=>{t.color=o})),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set("enter",(t=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire("execute",{value:this.selectedColor}),t.stopPropagation(),t.preventDefault())}))}_stopPropagationOnArrowsKeys(){const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t)}_addColorPickersElementsToFocusTracker(){for(const t of this.colorPickerView.slidersView)this.focusTracker.add(t.element),this._focusables.add(t);const t=this.colorPickerView.hexInputRow.children.get(1);t.element&&(this.focusTracker.add(t.element),this._focusables.add(t)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:t,cancelButtonView:e}){const n=new xh,o=this.createCollection();return o.add(t),o.add(e),n.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:o}),n}_createActionButtons(){const t=this.locale,e=t.t,n=new Mh(t),o=new Mh(t);return n.set({icon:yu.check,class:"ck-button-save",type:"button",withText:!1,label:e("Accept")}),o.set({icon:yu.cancel,class:"ck-button-cancel",type:"button",withText:!1,label:e("Cancel")}),n.on("execute",(()=>{this.colorPickerView.isValid()&&this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})})),o.on("execute",(()=>{this.fire("colorPicker:cancel")})),{saveButtonView:n,cancelButtonView:o}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",((t,e)=>{this.fire("execute",{value:e.color,source:"colorPicker"}),this.set("selectedColor",e.color)}))}}class sm extends xh{focusTracker;keystrokes;items;colorGridsFragmentView;colorPickerFragmentView;_focusCycler;_focusables;_colorPickerViewConfig;constructor(t,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r,colorPickerLabel:s,colorPickerViewConfig:a}){super(t),this.items=this.createCollection(),this.focusTracker=new ci,this.keystrokes=new hi,this._focusables=new oh,this._colorPickerViewConfig=a,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new im(t,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r,colorPickerLabel:s,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new rm(t,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:a}),this.set("_isColorGridsFragmentVisible",!0),this.set("_isColorPickerFragmentVisible",!1),this.set("selectedColor",void 0),this.colorGridsFragmentView.bind("isVisible").to(this,"_isColorGridsFragmentVisible"),this.colorPickerFragmentView.bind("isVisible").to(this,"_isColorPickerFragmentVisible"),this.on("change:selectedColor",((t,e,n)=>{this.colorGridsFragmentView.set("selectedColor",n),this.colorPickerFragmentView.set("selectedColor",n)})),this.colorGridsFragmentView.on("change:selectedColor",((t,e,n)=>{this.set("selectedColor",n)})),this.colorPickerFragmentView.on("change:selectedColor",((t,e,n)=>{this.set("selectedColor",n)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector"]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){this.colorPickerFragmentView.colorPickerView&&!this._isColorPickerFragmentVisible&&(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(t,e){this.colorGridsFragmentView.updateDocumentColors(t,e)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate("execute").to(this),this.colorGridsFragmentView.delegate("colorPicker:show").to(this))}_appendColorPickerFragment(){2!==this.items.length&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{this.showColorPickerFragment()})),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate("execute").to(this),this.colorPickerFragmentView.delegate("colorPicker:cancel").to(this))}}class am{editor;_components=new Map;constructor(t){this.editor=t}*names(){for(const t of this._components.values())yield t.originalName}add(t,e){this._components.set(cm(t),{callback:e,originalName:t})}create(t){if(!this.has(t))throw new An("componentfactory-item-missing",this,{name:t});return this._components.get(cm(t)).callback(this.editor.locale)}has(t){return this._components.has(cm(t))}}function cm(t){return String(t).toLowerCase()}const lm="ck-tooltip";class dm extends(lo()){tooltipTextView;balloonPanelView;static defaultBalloonPositions=Tp.generatePositions({heightOffset:5,sideOffset:13});_currentElementWithTooltip=null;_currentTooltipPosition=null;_mutationObserver=null;_pinTooltipDebounced;_unpinTooltipDebounced;_watchdogExcluded;static _editors=new Set;static _instance=null;constructor(t){if(super(),dm._editors.add(t),dm._instance)return dm._instance;dm._instance=this,this.tooltipTextView=new xh(t.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new Tp(t.locale),this.balloonPanelView.class=lm,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=function(t){const e=new MutationObserver((()=>{t()}));return{attach(t){e.observe(t,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){e.disconnect()}}}((()=>{this._updateTooltipPosition()})),this._pinTooltipDebounced=nr(this._pinTooltip,600),this._unpinTooltipDebounced=nr(this._unpinTooltip,400),this.listenTo(en.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(en.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(en.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(en.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(en.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(en.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(t){const e=t.ui.view&&t.ui.view.body;dm._editors.delete(t),this.stopListening(t.ui),e&&e.has(this.balloonPanelView)&&e.remove(this.balloonPanelView),dm._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),dm._instance=null)}static getPositioningFunctions(t){const e=dm.defaultBalloonPositions;return{s:[e.southArrowNorth,e.southArrowNorthEast,e.southArrowNorthWest],n:[e.northArrowSouth],e:[e.eastArrowWest],w:[e.westArrowEast],sw:[e.southArrowNorthEast],se:[e.southArrowNorthWest]}[t]}_onKeyDown(t,e){"Escape"===e.key&&this._currentElementWithTooltip&&(this._unpinTooltip(),e.stopPropagation())}_onEnterOrFocus(t,{target:e}){const n=um(e);n?n!==this._currentElementWithTooltip&&(this._unpinTooltip(),"focus"!==t.name||n.matches(":hover")?this._pinTooltipDebounced(n,hm(n)):this._pinTooltip(n,hm(n))):"focus"===t.name&&this._unpinTooltip()}_onLeaveOrBlur(t,{target:e,relatedTarget:n}){if("mouseleave"===t.name){if(!je(e))return;const t=this.balloonPanelView.element,o=t&&(t===n||t.contains(n)),i=!o&&e===t;if(o)return void this._unpinTooltipDebounced.cancel();if(!i&&this._currentElementWithTooltip&&e!==this._currentElementWithTooltip)return;const r=um(e),s=um(n);(i||r&&r!==s)&&this._unpinTooltipDebounced()}else{if(this._currentElementWithTooltip&&e!==this._currentElementWithTooltip)return;this._unpinTooltipDebounced()}}_onScroll(t,{target:e}){this._currentElementWithTooltip&&(e.contains(this.balloonPanelView.element)&&e.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(t,{text:e,position:n,cssClass:o}){this._unpinTooltip();const i=ai(dm._editors.values()).ui.view.body;i.has(this.balloonPanelView)||i.add(this.balloonPanelView),this.tooltipTextView.text=e,this.balloonPanelView.class=[lm,o].filter((t=>t)).join(" "),this.balloonPanelView.pin({target:t,positions:dm.getPositioningFunctions(n)}),this._mutationObserver.attach(t);for(const t of dm._editors)this.listenTo(t.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=t,this._currentTooltipPosition=n}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const t of dm._editors)this.stopListening(t.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;const t=hm(this._currentElementWithTooltip);Io(this._currentElementWithTooltip)&&t.text?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:dm.getPositioningFunctions(t.position)}):this._unpinTooltip()}}function um(t){return je(t)?t.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function hm(t){return{text:t.dataset.ckeTooltipText,position:t.dataset.ckeTooltipPosition||"s",cssClass:t.dataset.ckeTooltipClass||""}}class pm extends(lo()){editor;_balloonView=null;_showBalloonThrottled=$d((()=>this._showBalloon()),50,{leading:!0});_lastFocusedEditableElement=null;_balloonClass;constructor(t,e={}){super(),this.editor=t,this._balloonClass=e.balloonClass,t.on("ready",(()=>this._handleEditorReady()))}destroy(){const t=this._balloonView;t&&(t.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const t=this.editor;this._isEnabled()&&t.ui.view&&(t.ui.focusTracker.on("change:isFocused",((t,e,n)=>{this._updateLastFocusedEditableElement(),n?this._showBalloon():this._hideBalloon()})),t.ui.focusTracker.on("change:focusedElement",((t,e,n)=>{this._updateLastFocusedEditableElement(),n&&this._showBalloon()})),t.ui.on("update",(()=>{this._showBalloonThrottled()})))}_getNormalizedConfig(){return{side:"ltr"===this.editor.locale.contentLanguageDirection?"right":"left",position:"border",verticalOffset:0,horizontalOffset:5}}_showBalloon(){const t=this._getBalloonAttachOptions();t&&(this._balloonView||(this._balloonView=this._createBalloonView()),this._balloonView.pin(t))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_createBalloonView(){const t=this.editor,e=new Tp,n=this._createBadgeContent();return e.content.add(n),this._balloonClass&&(e.class=this._balloonClass),t.ui.view.body.add(e),e}_getBalloonAttachOptions(){if(!this._lastFocusedEditableElement)return null;const t=this._getNormalizedConfig(),e="right"===t.side?mm(this._lastFocusedEditableElement,n=t,((t,e)=>t.left+t.width-e.width-n.horizontalOffset)):function(t,e){return mm(t,e,(t=>t.left+e.horizontalOffset))}(this._lastFocusedEditableElement,t);var n;return{target:this._lastFocusedEditableElement,positions:[e]}}_updateLastFocusedEditableElement(){const t=this.editor,e=t.ui.focusTracker.isFocused,n=t.ui.focusTracker.focusedElement;if(!e||!n)return void(this._lastFocusedEditableElement=null);const o=Array.from(t.ui.getEditableElementsNames()).map((e=>t.ui.getEditableElement(e)));o.includes(n)?this._lastFocusedEditableElement=n:this._lastFocusedEditableElement=o[0]}}function mm(t,e,n){return(o,i)=>{const r=new wo(t);if(r.width<350||r.height<50)return null;let s;s="inside"===e.position?r.bottom-i.height:r.bottom-i.height/2,s-=e.verticalOffset;const a=n(r,i),c=o.clone().moveTo(a,s).getIntersection(i.clone().moveTo(a,s)).getVisible();return!c||c.getArea() \n',isColorInherited:!1}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/powered-by-ckeditor/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...e?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[e]}]:[],n],on:{dragstart:o.to((t=>t.preventDefault()))}}]})}}class km extends pm{licenseTypeMessage={evaluation:"For evaluation purposes only",trial:"For evaluation purposes only",development:"For development purposes only"};constructor(t){super(t,{balloonClass:"ck-evaluation-badge-balloon"})}_isEnabled(){const t=wm(this.editor.config.get("licenseKey"));return Boolean(t&&this.licenseTypeMessage[t])}_createBadgeContent(){const t=wm(this.editor.config.get("licenseKey"));return new bm(this.editor.locale,this.licenseTypeMessage[t])}_getNormalizedConfig(){const t=super._getNormalizedConfig(),e=this.editor.config.get("ui.poweredBy")||{};return{position:e.position||t.position,side:"left"===(e.side||t.side)?"right":"left",verticalOffset:t.verticalOffset,horizontalOffset:t.horizontalOffset}}}class bm extends xh{constructor(t,e){super(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-evaluation-badge"],"aria-hidden":!0},children:[{tag:"span",attributes:{class:["ck","ck-evaluation-badge__label"]},children:[e]}]})}}function wm(t){if("GPL"==t)return"GPL";const e=fi(t.split(".")[1]);return e?e.licenseType||"production":null}const _m={POLITE:"polite",ASSERTIVE:"assertive"};class Cm{editor;view;constructor(t){this.editor=t,t.once("ready",(()=>{for(const t of Object.values(_m))this.announce("",t)}))}announce(t,e=_m.POLITE){const n=this.editor;if(!n.ui.view)return;this.view||(this.view=new vm(n.locale),n.ui.view.body.add(this.view));const{politeness:o,isUnsafeHTML:i}="string"==typeof e?{politeness:e}:e;let r=this.view.regionViews.find((t=>t.politeness===o));r||(r=new Am(n,o),this.view.regionViews.add(r)),r.announce({announcement:t,isUnsafeHTML:i})}}class vm extends xh{regionViews;constructor(t){super(t),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class Am extends xh{politeness;_domConverter;_pruneAnnouncementsInterval;constructor(t,e){super(t.locale),this.setTemplate({tag:"div",attributes:{"aria-live":e,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),t.on("destroy",(()=>{null!==this._pruneAnnouncementsInterval&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)})),this.politeness=e,this._domConverter=t.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval((()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()}),5e3)}announce({announcement:t,isUnsafeHTML:e}){if(!t.trim().length)return;const n=document.createElement("li");e?this._domConverter.setContentOf(n,t):n.innerText=t,this._listElement.appendChild(n)}get _listElement(){return this.element.querySelector("ul")}}class ym extends Ap{constructor(t,e){super(t);const n=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:n.to("mouseenter")}}),this.delegate("mouseenter").to(e)}}const xm={toggleMenusAndFocusItemsOnHover(t){t.on("menu:mouseenter",(e=>{if(t.isFocusBorderEnabled||t.isOpen){if(t.isOpen)for(const n of t.menus){const t=e.path[0],o=t instanceof ym&&t.children.first===n;n.isOpen=(e.path.includes(n)||o)&&n.isEnabled}e.source.focus()}}))},focusCycleMenusOnArrows(t){const e="rtl"===t.locale.uiLanguageDirection;function n(e,n){const o=t.children.getIndex(e),i=e.isOpen,r=t.children.length,s=t.children.get((o+r+n)%r);e.isOpen=!1,i&&(s.isOpen=!0),s.buttonView.focus()}t.on("menu:arrowright",(t=>{n(t.source,e?-1:1)})),t.on("menu:arrowleft",(t=>{n(t.source,e?1:-1)}))},closeMenusWhenTheBarCloses(t){t.on("change:isOpen",(()=>{t.isOpen||t.menus.forEach((t=>{t.isOpen=!1}))}))},closeMenuWhenAnotherOnTheSameLevelOpens(t){t.on("menu:change:isOpen",((e,n,o)=>{o&&t.menus.filter((t=>e.source.parentMenuView===t.parentMenuView&&e.source!==t&&t.isOpen)).forEach((t=>{t.isOpen=!1}))}))},closeOnClickOutside(t){Eh({emitter:t,activator:()=>t.isOpen,callback:()=>t.close(),contextElements:()=>t.children.map((t=>t.element))})},enableFocusHighlightOnInteraction(t){let e=!1;t.on("change:isOpen",((n,o,i)=>{i||(e||(t.isFocusBorderEnabled=!1),e=!1)})),t.listenTo(t.element,"keydown",(()=>{e=!0}),{useCapture:!0}),t.listenTo(t.element,"keyup",(()=>{e=!1}),{useCapture:!0}),t.listenTo(t.element,"focus",(()=>{e&&(t.isFocusBorderEnabled=!0)}),{useCapture:!0})}},Em={openAndFocusPanelOnArrowDownKey(t){t.keystrokes.set("arrowdown",((e,n)=>{t.focusTracker.focusedElement===t.buttonView.element&&(t.isOpen||(t.isOpen=!0),t.panelView.focus(),n())}))},openOnArrowRightKey(t){const e="rtl"===t.locale.uiLanguageDirection?"arrowleft":"arrowright";t.keystrokes.set(e,((e,n)=>{t.focusTracker.focusedElement===t.buttonView.element&&t.isEnabled&&(t.isOpen||(t.isOpen=!0),t.panelView.focus(),n())}))},openOnButtonClick(t){t.buttonView.on("execute",(()=>{t.isOpen=!0}))},toggleOnButtonClick(t){t.buttonView.on("execute",(()=>{t.isOpen=!t.isOpen}))},openAndFocusOnEnterKeyPress(t){t.keystrokes.set("enter",((e,n)=>{t.focusTracker.focusedElement===t.buttonView.element&&(t.isOpen=!0,t.panelView.focus(),n())}))},closeOnArrowLeftKey(t){const e="rtl"===t.locale.uiLanguageDirection?"arrowright":"arrowleft";t.keystrokes.set(e,((e,n)=>{t.isOpen&&(t.isOpen=!1,t.focus(),n())}))},closeOnEscKey(t){t.keystrokes.set("esc",((e,n)=>{t.isOpen&&(t.isOpen=!1,t.focus(),n())}))},closeOnParentClose(t){t.parentMenuView.on("change:isOpen",((e,n,o)=>{o||e.source!==t.parentMenuView||(t.isOpen=!1)}))}},Dm={southEast:t=>({top:t.bottom,left:t.left,name:"se"}),southWest:(t,e)=>({top:t.bottom,left:t.left-e.width+t.width,name:"sw"}),northEast:(t,e)=>({top:t.top-e.height,left:t.left,name:"ne"}),northWest:(t,e)=>({top:t.top-e.height,left:t.left-e.width+t.width,name:"nw"}),eastSouth:t=>({top:t.top,left:t.right-5,name:"es"}),eastNorth:(t,e)=>({top:t.top-e.height,left:t.right-5,name:"en"}),westSouth:(t,e)=>({top:t.top,left:t.left-e.width+5,name:"ws"}),westNorth:(t,e)=>({top:t.top-e.height,left:t.left-e.width+5,name:"wn"})},Sm=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"previewMergeFields",items:["menuBar:previewMergeFields"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:insertImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable"]},{groupId:"insertInline",items:["menuBar:link","menuBar:bookmark","menuBar:comment","menuBar:insertMergeField"]},{groupId:"insertMinorWidgets",items:["menuBar:mediaEmbed","menuBar:insertTemplate","menuBar:specialCharacters","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]},{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:multiLevelList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function Tm({normalizedConfig:t,locale:e,componentFactory:n,extraItems:o}){const i=wr(t);return Bm(t,i,o),function(t,e){const n=e.removeItems,o=[];e.items=e.items.filter((({menuId:t})=>!n.includes(t)||(o.push(t),!1))),Om(e.items,(t=>{t.groups=t.groups.filter((({groupId:t})=>!n.includes(t)||(o.push(t),!1)));for(const e of t.groups)e.items=e.items.filter((t=>{const e=Lm(t);return!n.includes(e)||(o.push(e),!1)}))}));for(const e of n)o.includes(e)||yn("menu-bar-item-could-not-be-removed",{menuBarConfig:t,itemName:e})}(t,i),Bm(t,i,i.addItems),function(t,e,n){Om(e.items,(o=>{for(const i of o.groups)i.items=i.items.filter((i=>{const r="string"==typeof i&&!n.has(i);return r&&!e.isUsingDefaultConfig&&yn("menu-bar-item-unavailable",{menuBarConfig:t,parentMenuConfig:wr(o),componentName:i}),!r}))}))}(t,i,n),Mm(t,i),function(t,e){const n=e.t,o={File:n({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:n({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:n({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:n({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:n({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:n({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:n({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:n({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:n({string:"Font",id:"MENU_BAR_MENU_FONT"})};Om(t.items,(t=>{t.label in o&&(t.label=o[t.label])}))}(i,e),i}function Bm(t,e,n){const o=[];if(0!=n.length){for(const t of n){const n=(r=t.position).startsWith("start")?"start":r.startsWith("end")?"end":r.startsWith("after")?"after":"before",s=zm(t.position);if("object"==typeof(i=t)&&"menu"in i)if(s){const i=e.items.findIndex((t=>t.menuId===s));-1!=i?"before"===n?(e.items.splice(i,0,t.menu),o.push(t)):"after"===n&&(e.items.splice(i+1,0,t.menu),o.push(t)):Im(e,t.menu,s,n)&&o.push(t)}else"start"===n?(e.items.unshift(t.menu),o.push(t)):"end"===n&&(e.items.push(t.menu),o.push(t));else Nm(t)?Om(e.items,(e=>{if(e.menuId===s)"start"===n?(e.groups.unshift(t.group),o.push(t)):"end"===n&&(e.groups.push(t.group),o.push(t));else{const i=e.groups.findIndex((t=>t.groupId===s));-1!==i&&("before"===n?(e.groups.splice(i,0,t.group),o.push(t)):"after"===n&&(e.groups.splice(i+1,0,t.group),o.push(t)))}})):Im(e,t.item,s,n)&&o.push(t)}var i;for(const e of n)o.includes(e)||yn("menu-bar-item-could-not-be-added",{menuBarConfig:t,addedItemConfig:e})}var r}function Im(t,e,n,o){let i=!1;return Om(t.items,(t=>{for(const{groupId:r,items:s}of t.groups){if(i)return;if(r===n)"start"===o?(s.unshift(e),i=!0):"end"===o&&(s.push(e),i=!0);else{const t=s.findIndex((t=>Lm(t)===n));-1!==t&&("before"===o?(s.splice(t,0,e),i=!0):"after"===o&&(s.splice(t+1,0,e),i=!0))}}})),i}function Mm(t,e){const n=e.isUsingDefaultConfig;let o=!1;e.items=e.items.filter((e=>!!e.groups.length||(Pm(t,e,n),!1))),e.items.length?(Om(e.items,(e=>{e.groups=e.groups.filter((t=>!!t.items.length||(o=!0,!1)));for(const i of e.groups)i.items=i.items.filter((e=>!(Rm(e)&&!e.groups.length&&(Pm(t,e,n),o=!0,1))))})),o&&Mm(t,e)):Pm(t,t,n)}function Pm(t,e,n){n||yn("menu-bar-menu-empty",{menuBarConfig:t,emptyMenuConfig:e})}function Om(t,e){if(Array.isArray(t))for(const e of t)n(e);function n(t){e(t);for(const e of t.groups)for(const t of e.items)Rm(t)&&n(t)}}function Nm(t){return"object"==typeof t&&"group"in t}function zm(t){const e=t.match(/^[^:]+:(.+)/);return e?e[1]:null}function Lm(t){return"string"==typeof t?t:t.menuId}function Rm(t){return"object"==typeof t&&"menuId"in t}class Fm extends(qn()){editor;componentFactory;focusTracker;tooltipManager;poweredBy;evaluationBadge;ariaLiveAnnouncer;isReady=!1;_editableElementsMap=new Map;_focusableToolbarDefinitions=[];_extraMenuBarElements=[];_lastFocusedForeignElement=null;constructor(t){super();const e=t.editing.view;this.editor=t,this.componentFactory=new am(t),this.focusTracker=new ci,this.tooltipManager=new dm(t),this.poweredBy=new gm(t),this.evaluationBadge=new km(t),this.ariaLiveAnnouncer=new Cm(t),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.once("ready",(()=>{this._bindBodyCollectionWithFocusTracker(),this.isReady=!0})),this.listenTo(e.document,"layoutChanged",this.update.bind(this)),this.listenTo(e,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy(),this.evaluationBadge.destroy();for(const t of this._editableElementsMap.values())t.ckeditorInstance=null,this.editor.keystrokes.stopListening(t);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[]}setEditableElement(t,e){this._editableElementsMap.set(t,e),e.ckeditorInstance||(e.ckeditorInstance=this.editor),this.focusTracker.add(e);const n=()=>{this.editor.editing.view.getDomRoot(t)||this.editor.keystrokes.listenTo(e)};this.isReady?n():this.once("ready",n)}removeEditableElement(t){const e=this._editableElementsMap.get(t);e&&(this._editableElementsMap.delete(t),this.editor.keystrokes.stopListening(e),this.focusTracker.remove(e),e.ckeditorInstance=null)}getEditableElement(t="main"){return this._editableElementsMap.get(t)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(t,e={}){t.isRendered?(this.focusTracker.add(t),this.editor.keystrokes.listenTo(t.element)):t.once("render",(()=>{this.focusTracker.add(t),this.editor.keystrokes.listenTo(t.element)})),this._focusableToolbarDefinitions.push({toolbarView:t,options:e})}extendMenuBar(t){this._extraMenuBarElements.push(t)}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_initMenuBar(t){const e=t.element;this.focusTracker.add(e),this.editor.keystrokes.listenTo(e);const n=function(t){let e;return e="items"in t&&t.items?{items:t.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...t}:{items:wr(Sm),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...t},e}(this.editor.config.get("menuBar")||{});t.fillFromConfig(n,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set("Esc",((t,n)=>{e.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),n())})),this.editor.keystrokes.set("Alt+F9",((n,o)=>{e.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),t.isFocusBorderEnabled=!0,t.focus(),o())}))}_readViewportOffsetFromConfig(){const t=this.editor,e=t.config.get("ui.viewportOffset");if(e)return e;const n=t.config.get("toolbar.viewportTopOffset");return n?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:n}):{top:0}}_initFocusTracking(){const t=this.editor;let e;t.keystrokes.set("Alt+F10",((t,n)=>{this._saveLastFocusedForeignElement();const o=this._getCurrentFocusedToolbarDefinition();o&&e||(e=this._getFocusableCandidateToolbarDefinitions());for(let t=0;t{const o=this._getCurrentFocusedToolbarDefinition();o&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):t.editing.view.focus(),o.options.afterBlur&&o.options.afterBlur(),n())}))}_saveLastFocusedForeignElement(){const t=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(t)&&!Array.from(this.editor.editing.view.domRoots.values()).includes(t)&&(this._lastFocusedForeignElement=t)}_getFocusableCandidateToolbarDefinitions(){const t=[];for(const e of this._focusableToolbarDefinitions){const{toolbarView:n,options:o}=e;(Io(n.element)||o.beforeFocus)&&t.push(e)}return t.sort(((t,e)=>jm(t)-jm(e))),t}_getCurrentFocusedToolbarDefinition(){for(const t of this._focusableToolbarDefinitions)if(t.toolbarView.element&&t.toolbarView.element.contains(this.focusTracker.focusedElement))return t;return null}_focusFocusableCandidateToolbar(t){const{toolbarView:e,options:{beforeFocus:n}}=t;return n&&n(),!!Io(e.element)&&(e.focus(),!0)}_handleScrollToTheSelection(t,e){const n={top:0,bottom:0,left:0,right:0,...this.viewportOffset};e.viewportOffset.top+=n.top,e.viewportOffset.bottom+=n.bottom,e.viewportOffset.left+=n.left,e.viewportOffset.right+=n.right}_bindBodyCollectionWithFocusTracker(){const t=this.view.body;for(const e of t)this.focusTracker.add(e.element);t.on("add",((t,e)=>{this.focusTracker.add(e.element)})),t.on("remove",((t,e)=>{this.focusTracker.remove(e.element)}))}}function jm(t){const{toolbarView:e,options:n}=t;let o=10;return Io(e.element)&&o--,n.isContextual&&o--,o}class Vm extends xh{body;menuBarView;constructor(t){super(t),this.body=new ep(t)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class Hm extends Vm{top;main;_voiceLabelView;constructor(t){super(t),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:t.uiLanguageDirection,lang:t.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}_createVoiceLabel(){const t=this.t,e=new Qh;return e.text=t("Rich Text Editor"),e.extendTemplate({attributes:{class:"ck-voice-label"}}),e}}class Um extends xh{name=null;_editingView;_editableElement;_hasExternalElement;constructor(t,e,n){super(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:t.contentLanguage,dir:t.contentLanguageDirection}}),this.set("isFocused",!1),this._editableElement=n,this._hasExternalElement=!!this._editableElement,this._editingView=e}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",(()=>this._updateIsFocusedClasses())),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}get hasExternalElement(){return this._hasExternalElement}_updateIsFocusedClasses(){const t=this._editingView;function e(e){t.change((n=>{const o=t.document.getRoot(e.name);n.addClass(e.isFocused?"ck-focused":"ck-blurred",o),n.removeClass(e.isFocused?"ck-blurred":"ck-focused",o)}))}t.isRenderingInProgress?function n(o){t.once("change:isRenderingInProgress",((t,i,r)=>{r?n(o):e(o)}))}(this):e(this)}}class Wm extends Um{_options;constructor(t,e,n,o={}){super(t,e,n),this._options=o,this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const t=this._editingView;t.change((e=>{const n=t.document.getRoot(this.name);e.setAttribute("aria-label",this.getEditableAriaLabel(),n)}))}getEditableAriaLabel(){const t=this.locale.t,e=this._options.label,n=this._editableElement,o=this.name;if("string"==typeof e)return e;if("object"==typeof e)return e[o];if("function"==typeof e)return e(this);if(n){const t=n.getAttribute("aria-label");if(t)return t}return t("Rich Text Editor. Editing area: %0",o)}}class Gm extends(qn()){constructor(t,e){super(),e&&Wi(this,e),t&&this.set(t)}}const qm=Eo("px");class $m extends iu{positionLimiter;visibleStack;_viewToStack=new Map;_idToStack=new Map;_view=null;_rotatorView=null;_fakePanelsView=null;static get pluginName(){return"ContextualBalloon"}static get isOfficialPlugin(){return!0}constructor(t){super(t),this.positionLimiter=()=>{const t=this.editor.editing.view,e=t.document.selection.editableElement;return e?t.domConverter.mapViewToDom(e.root):null},this.decorate("getPositionOptions"),this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(t){return Array.from(this._viewToStack.keys()).includes(t)}add(t){if(this._view||this._createPanelView(),this.hasView(t.view))throw new An("contextualballoon-add-view-exist",[this,t]);const e=t.stackId||"main";if(!this._idToStack.has(e))return this._idToStack.set(e,new Map([[t.view,t]])),this._viewToStack.set(t.view,this._idToStack.get(e)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!t.singleViewMode||this.showStack(e));const n=this._idToStack.get(e);t.singleViewMode&&this.showStack(e),n.set(t.view,t),this._viewToStack.set(t.view,n),n===this._visibleStack&&this._showView(t)}remove(t){if(!this.hasView(t))throw new An("contextualballoon-remove-view-not-exist",[this,t]);const e=this._viewToStack.get(t);this._singleViewMode&&this.visibleView===t&&(this._singleViewMode=!1),this.visibleView===t&&(1===e.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(e.values())[e.size-2])),1===e.size?(this._idToStack.delete(this._getStackId(e)),this._numberOfStacks=this._idToStack.size):e.delete(t),this._viewToStack.delete(t)}updatePosition(t){t&&(this._visibleStack.get(this.visibleView).position=t),this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition()}getPositionOptions(){let t=Array.from(this._visibleStack.values()).pop().position;return t&&(t.limiter||(t=Object.assign({},t,{limiter:this.positionLimiter})),t=Object.assign({},t,{viewportOffsetConfig:this.editor.ui.viewportOffset})),t}showStack(t){this.visibleStack=t;const e=this._idToStack.get(t);if(!e)throw new An("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==e&&this._showView(Array.from(e.values()).pop())}_createPanelView(){this._view=new Tp(this.editor.locale),this.editor.ui.view.body.add(this._view),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(t){return Array.from(this._idToStack.entries()).find((e=>e[1]===t))[0]}_showNextStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)+1;t[e]||(e=0),this.showStack(this._getStackId(t[e]))}_showPrevStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)-1;t[e]||(e=t.length-1),this.showStack(this._getStackId(t[e]))}_createRotatorView(){const t=new Km(this.editor.locale),e=this.editor.locale.t;return this.view.content.add(t),t.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((t,e)=>!e&&t>1)),t.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),t.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((t,n)=>{if(n<2)return"";const o=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return e("%0 of %1",[o,n])})),t.buttonNextView.on("execute",(()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),t.buttonPrevView.on("execute",(()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),t}_createFakePanelsView(){const t=new Ym(this.editor.locale,this.view);return t.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((t,e)=>!e&&t>=2?Math.min(t-1,2):0)),t.listenTo(this.view,"change:top",(()=>t.updatePosition())),t.listenTo(this.view,"change:left",(()=>t.updatePosition())),this.editor.ui.view.body.add(t),t}_showView({view:t,balloonClassName:e="",withArrow:n=!0,singleViewMode:o=!1}){this.view.class=e,this.view.withArrow=n,this._rotatorView.showView(t),this.visibleView=t,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),o&&(this._singleViewMode=!0)}}class Km extends xh{focusTracker;buttonPrevView;buttonNextView;content;constructor(t){super(t);const e=t.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new ci,this.buttonPrevView=this._createButtonView(e("Previous"),yu.previousArrow),this.buttonNextView=this._createButtonView(e("Next"),yu.nextArrow),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",n.to("isNavigationVisible",(t=>t?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(t){this.hideView(),this.content.add(t)}hideView(){this.content.clear()}_createButtonView(t,e){const n=new Mh(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n}}class Ym extends xh{content;_balloonPanelView;constructor(t,e){super(t);const n=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=e,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",n.to("numberOfPanels",(t=>t?"":"ck-hidden"))],style:{top:n.to("top",qm),left:n.to("left",qm),width:n.to("width",qm),height:n.to("height",qm)}},children:this.content}),this.on("change:numberOfPanels",((t,e,n,o)=>{n>o?this._addPanels(n-o):this._removePanels(o-n),this.updatePosition()}))}_addPanels(t){for(;t--;){const t=new xh;t.setTemplate({tag:"div"}),this.content.add(t),this.registerChild(t)}}_removePanels(t){for(;t--;){const t=this.content.last;this.content.remove(t),this.deregisterChild(t),t.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:t,left:e}=this._balloonPanelView,{width:n,height:o}=new wo(this._balloonPanelView.element);Object.assign(this,{top:t,left:e,width:n,height:o})}}}const Qm=Eo("px");class Zm extends xh{content;contentPanelElement;_contentPanelPlaceholder;constructor(t){super(t);const e=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheBottomOfLimiter",!1),this.set("_stickyTopOffset",null),this.set("_stickyBottomOffset",null),this.content=this.createCollection(),this._contentPanelPlaceholder=new ih({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:e.to("isSticky",(t=>t?"block":"none")),height:e.to("isSticky",(t=>t?Qm(this._contentPanelRect.height):null))}}}).render(),this.contentPanelElement=new ih({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",e.if("isSticky","ck-sticky-panel__content_sticky"),e.if("_isStickyToTheBottomOfLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:e.to("isSticky",(t=>t?Qm(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:e.to("_stickyTopOffset",(t=>t?Qm(t):t)),bottom:e.to("_stickyBottomOffset",(t=>t?Qm(t):t)),marginLeft:e.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this.contentPanelElement]})}render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(en.document,"scroll",(()=>{this.checkIfShouldBeSticky()}),{useCapture:!0}),this.listenTo(this,"change:isActive",(()=>{this.checkIfShouldBeSticky()}))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const t=new wo(this.limiterElement);let e=t.getVisible();if(e){const t=new wo(en.window);t.top+=this.viewportTopOffset,t.height-=this.viewportTopOffset,e=e.getIntersection(t)}if(e&&t.tope.bottom){const n=Math.max(t.bottom-e.bottom,0)+this.limiterBottomOffset;t.bottom-n>t.top+this._contentPanelRect.height?this._stickToBottomOfLimiter(n):this._unstick()}else this._contentPanelRect.height+this.limiterBottomOffsetString(t))),"data-cke-tooltip-disabled":e.to("isOn")},on:{mouseenter:e.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const t=new Bh;return t.content=sp,t.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),t}}class Xm extends xh{children;constructor(t){super(t);const e=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-menu-bar__menu__panel",e.to("position",(t=>`ck-menu-bar__menu__panel_position_${t}`)),e.if("isVisible","ck-hidden",(t=>!t))],tabindex:"-1"},children:this.children,on:{selectstart:e.to((t=>{"input"!==t.target.tagName.toLocaleLowerCase()&&t.preventDefault()}))}})}focus(t=1){this.children.length&&(1===t?this.children.first.focus():this.children.last.focus())}}class tg extends xh{buttonView;panelView;focusTracker;keystrokes;constructor(t){super(t);const e=this.bindTemplate;this.buttonView=new Jm(t),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new Xm(t),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new hi,this.focusTracker=new ci,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",e.to("class"),e.if("isEnabled","ck-disabled",(t=>!t)),e.if("parentMenuView","ck-menu-bar__menu_top-level",(t=>!t))]},children:[this.buttonView,this.panelView]})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),Em.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Em.openOnButtonClick(this),Em.openOnArrowRightKey(this),Em.closeOnArrowLeftKey(this),Em.openAndFocusOnEnterKeyPress(this),Em.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Em.openAndFocusPanelOnArrowDownKey(this),Em.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",((t,e)=>{this.fire("arrowright"),e()})),this.keystrokes.set("arrowleft",((t,e)=>{this.fire("arrowleft"),e()}))}_repositionPanelOnOpen(){this.on("change:isOpen",((t,e,n)=>{if(!n)return;const o=tg._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=o?o.name:this._defaultMenuPositionName}))}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:t,southWest:e,northEast:n,northWest:o,westSouth:i,eastSouth:r,westNorth:s,eastNorth:a}=Dm;return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?[r,a,i,s]:[t,e,n,o]:this.parentMenuView?[i,s,r,a]:[e,t,o,n]}get _defaultMenuPositionName(){return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?"es":"se":this.parentMenuView?"ws":"sw"}static _getOptimalPosition=Mo}class eg extends Ep{constructor(t){super(t),this.role="menu",this.items.on("change",this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){const t=Array.from(this.items).some((t=>{const e=ng(t);return e&&e.isToggleable}));this.items.forEach((e=>{const n=ng(e);n&&(n.hasCheckSpace=t)}))}}function ng(t){return t instanceof Ap?t.children.map((t=>function(t){return"object"==typeof t&&"buttonView"in t&&t.buttonView instanceof Mh}(t)?t.buttonView:t)).find((t=>t instanceof $h)):null}class og extends op{constructor(t){super(t),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const ig=["mouseenter","arrowleft","arrowright","change:isOpen"];class rg extends xh{children;menus=[];constructor(t){super(t);const e=t.t,n=this.bindTemplate;this.set({isOpen:!1,isFocusBorderEnabled:!1}),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar",n.if("isFocusBorderEnabled","ck-menu-bar_focus-border-enabled")],"aria-label":e("Editor menu bar"),role:"menubar"},children:this.children})}fillFromConfig(t,e,n=[]){const o=Tm({normalizedConfig:t,locale:this.locale,componentFactory:e,extraItems:n}).items.map((t=>this._createMenu({componentFactory:e,menuDefinition:t})));this.children.addMany(o)}render(){super.render(),xm.toggleMenusAndFocusItemsOnHover(this),xm.closeMenusWhenTheBarCloses(this),xm.closeMenuWhenAnotherOnTheSameLevelOpens(this),xm.focusCycleMenusOnArrows(this),xm.closeOnClickOutside(this),xm.enableFocusHighlightOnInteraction(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const t of this.children)t.isOpen=!1}registerMenu(t,e=null){e?(t.delegate(...ig).to(e),t.parentMenuView=e):t.delegate(...ig).to(this,(t=>"menu:"+t)),t._attachBehaviors(),this.menus.push(t)}_createMenu({componentFactory:t,menuDefinition:e,parentMenuView:n}){const o=this.locale,i=new tg(o);return this.registerMenu(i,n),i.buttonView.set({label:e.label}),i.once("change:isOpen",(()=>{const n=new eg(o);n.ariaLabel=e.label,i.panelView.children.add(n),n.items.addMany(this._createMenuItems({menuDefinition:e,parentMenuView:i,componentFactory:t}))})),i}_createMenuItems({menuDefinition:t,parentMenuView:e,componentFactory:n}){const i=this.locale,r=[];for(const s of t.groups){for(const t of s.items){const s=new ym(i,e);if(o(t))s.children.add(this._createMenu({componentFactory:n,menuDefinition:t,parentMenuView:e}));else{const o=this._createMenuItemContentFromFactory({componentName:t,componentFactory:n,parentMenuView:e});if(!o)continue;s.children.add(o)}r.push(s)}s!==t.groups[t.groups.length-1]&&r.push(new yp(i))}return r}_createMenuItemContentFromFactory({componentName:t,parentMenuView:e,componentFactory:n}){const o=n.create(t);return o instanceof tg||o instanceof Yh||o instanceof og?(this._registerMenuTree(o,e),o.on("execute",(()=>{this.close()})),o):(yn("menu-bar-component-unsupported",{componentName:t,componentView:o}),null)}_registerMenuTree(t,e){if(!(t instanceof tg))return void t.delegate("mouseenter").to(e);this.registerMenu(t,e);const n=t.panelView.children.filter((t=>t instanceof eg))[0];if(!n)return void t.delegate("mouseenter").to(e);const o=n.items.filter((t=>t instanceof Ap));for(const e of o)this._registerMenuTree(e.children.get(0),t)}_setupIsOpenUpdater(){let t;this.on("menu:change:isOpen",((e,n,o)=>{clearTimeout(t),o?this.isOpen=!0:t=setTimeout((()=>{this.isOpen=Array.from(this.children).some((t=>t.isOpen))}),0)}))}}const sg=["left","right","center","justify"];function ag(t){return sg.includes(t)}function cg(t,e){return"rtl"==e.contentLanguageDirection?"right"===t:"left"===t}function lg(t){const e=t.map((t=>{let e;return e="string"==typeof t?{name:t}:t,e})).filter((t=>{const e=sg.includes(t.name);return e||yn("alignment-config-name-not-recognized",{option:t}),e})),n=e.filter((t=>Boolean(t.className))).length;if(n&&n{const i=o.slice(n+1);if(i.some((t=>t.name==e.name)))throw new An("alignment-config-name-already-defined",{option:e,configuredOptions:t});if(e.className&&i.some((t=>t.className==e.className)))throw new An("alignment-config-classname-already-defined",{option:e,configuredOptions:t})})),e}const dg="alignment";class ug extends su{refresh(){const t=this.editor.locale,e=ai(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(e)&&this._canBeAligned(e),this.isEnabled&&e.hasAttribute("alignment")?this.value=e.getAttribute("alignment"):this.value="rtl"===t.contentLanguageDirection?"right":"left"}execute(t={}){const e=this.editor,n=e.locale,o=e.model,i=o.document,r=t.value;o.change((t=>{const e=Array.from(i.selection.getSelectedBlocks()).filter((t=>this._canBeAligned(t))),o=e[0].getAttribute("alignment");cg(r,n)||o===r||!r?function(t,e){for(const n of t)e.removeAttribute(dg,n)}(e,t):function(t,e,n){for(const o of t)e.setAttribute(dg,n,o)}(e,t,r)}))}_canBeAligned(t){return this.editor.model.schema.checkAttribute(t,dg)}}class hg extends iu{static get pluginName(){return"AlignmentEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("alignment",{options:sg.map((t=>({name:t})))})}init(){const t=this.editor,e=t.locale,n=t.model.schema,o=lg(t.config.get("alignment.options")).filter((t=>ag(t.name)&&!cg(t.name,e))),i=o.some((t=>!!t.className));n.extend("$block",{allowAttributes:"alignment"}),t.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),i?t.conversion.attributeToAttribute(function(t){const e={};for(const n of t)e[n.name]={key:"class",value:n.className};return{model:{key:"alignment",values:t.map((t=>t.name))},view:e}}(o)):t.conversion.for("downcast").attributeToAttribute(function(t){const e={};for(const{name:n}of t)e[n]={key:"style",value:{"text-align":n}};return{model:{key:"alignment",values:t.map((t=>t.name))},view:e}}(o));const r=function(t){const e=[];for(const{name:n}of t)e.push({view:{key:"style",value:{"text-align":n}},model:{key:"alignment",value:n}});return e}(o);for(const e of r)t.conversion.for("upcast").attributeToAttribute(e);const s=function(t){const e=[];for(const{name:n}of t)e.push({view:{key:"align",value:n},model:{key:"alignment",value:n}});return e}(o);for(const e of s)t.conversion.for("upcast").attributeToAttribute(e);t.commands.add("alignment",new ug(t))}}const pg=(()=>new Map([["left",yu.alignLeft],["right",yu.alignRight],["center",yu.alignCenter],["justify",yu.alignJustify]]))();class mg extends iu{get localizedOptionTitles(){const t=this.editor.t;return{left:t("Align left"),right:t("Align right"),center:t("Align center"),justify:t("Justify")}}static get pluginName(){return"AlignmentUI"}static get isOfficialPlugin(){return!0}init(){const t=lg(this.editor.config.get("alignment.options"));t.map((t=>t.name)).filter(ag).forEach((t=>this._addButton(t))),this._addToolbarDropdown(t),this._addMenuBarMenu(t)}_addButton(t){this.editor.ui.componentFactory.add(`alignment:${t}`,(e=>this._createButton(e,t)))}_createButton(t,e,n={}){const o=this.editor,i=o.commands.get("alignment"),r=new Mh(t);return r.set({label:this.localizedOptionTitles[e],icon:pg.get(e),tooltip:!0,isToggleable:!0,...n}),r.bind("isEnabled").to(i),r.bind("isOn").to(i,"value",(t=>t===e)),this.listenTo(r,"execute",(()=>{o.execute("alignment",{value:e}),o.editing.view.focus()})),r}_addToolbarDropdown(t){const e=this.editor;e.ui.componentFactory.add("alignment",(n=>{const o=jp(n),i="rtl"===n.uiLanguageDirection?"w":"e",r=n.t;Vp(o,(()=>t.map((t=>this._createButton(n,t.name,{tooltipPosition:i})))),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:r("Text alignment toolbar")}),o.buttonView.set({label:r("Text alignment"),tooltip:!0}),o.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const s="rtl"===n.contentLanguageDirection?pg.get("right"):pg.get("left"),a=e.commands.get("alignment");return o.buttonView.bind("icon").to(a,"value",(t=>pg.get(t)||s)),o.bind("isEnabled").to(a,"isEnabled"),this.listenTo(o,"execute",(()=>{e.editing.view.focus()})),o}))}_addMenuBarMenu(t){const e=this.editor;e.ui.componentFactory.add("menuBar:alignment",(n=>{const o=e.commands.get("alignment"),i=n.t,r=new tg(n),s=new eg(n);r.bind("isEnabled").to(o),s.set({ariaLabel:i("Text alignment"),role:"menu"}),r.buttonView.set({label:i("Text alignment")});for(const i of t){const t=new ym(n,r),a=new Yh(n);a.delegate("execute").to(r),a.set({label:this.localizedOptionTitles[i.name],icon:pg.get(i.name),role:"menuitemcheckbox",isToggleable:!0}),a.on("execute",(()=>{e.execute("alignment",{value:i.name}),e.editing.view.focus()})),a.bind("isOn").to(o,"value",(t=>t===i.name)),a.bind("isEnabled").to(o,"isEnabled"),t.children.add(a),s.items.add(t)}return r.panelView.children.add(s),r}))}}class gg{model;limit;_isLocked;_size;_batch=null;_changeCallback;_selectionChangeCallback;constructor(t,e=20){this.model=t,this._size=0,this.limit=e,this._isLocked=!1,this._changeCallback=(t,e)=>{e.isLocal&&e.isUndoable&&e!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(t){this._size+=t,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(t=!1){this.isLocked&&!t||(this._batch=null,this._size=0)}}class fg extends su{_buffer;constructor(t,e){super(t),this._buffer=new gg(t.model,e),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(t={}){const e=this.editor.model,n=e.document,o=t.text||"",i=o.length;let r=n.selection;if(t.selection?r=t.selection:t.range&&(r=e.createSelection(t.range)),!e.canEditAt(r))return;const s=t.resultRange;e.enqueueChange(this._buffer.batch,(t=>{this._buffer.lock();const a=Array.from(n.selection.getAttributes());e.deleteContent(r),o&&e.insertContent(t.createText(o,a),r),s?t.setSelection(s):r.is("documentSelection")||t.setSelection(r),this._buffer.unlock(),this._buffer.input(i)}))}}const kg=["insertText","insertReplacementText"],bg=[...kg,"insertCompositionText"];class wg extends $s{focusObserver;constructor(t){super(t),this.focusObserver=t.getObserver(ta);const e=rn.isAndroid?bg:kg,n=t.document;n.on("beforeinput",((o,i)=>{if(!this.isEnabled)return;const{data:r,targetRanges:s,inputType:a,domEvent:c}=i;if(!e.includes(a))return;this.focusObserver.flush();const l=new bn(n,"insertText");n.fire(l,new Ks(t,c,{text:r,selection:t.createSelection(s)})),l.stop.called&&o.stop()})),rn.isAndroid||n.on("compositionend",((e,{data:o,domEvent:i})=>{this.isEnabled&&o&&n.fire("insertText",new Ks(t,i,{text:o}))}),{priority:"lowest"})}observe(){}stopObserving(){}}class _g extends iu{_compositionQueue;static get pluginName(){return"Input"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.model,n=t.editing.view,o=t.editing.mapper,i=e.document.selection;this._compositionQueue=new Cg(t),n.addObserver(wg);const r=new fg(t,t.config.get("typing.undoStep")||20);t.commands.add("insertText",r),t.commands.add("input",r),this.listenTo(n.document,"insertText",((r,s)=>{n.document.isComposing||s.preventDefault(),rn.isAndroid&&n.document.isComposing&&this._compositionQueue.flush("next beforeinput");const{text:a,selection:c}=s;let l;l=c?Array.from(c.getRanges()).map((t=>o.toModelRange(t))):Array.from(i.getRanges());let d=a;if(rn.isAndroid){const t=Array.from(l[0].getItems()).reduce(((t,e)=>t+(e.is("$textProxy")?e.data:"")),"");if(t&&(t.length<=d.length?d.startsWith(t)&&(d=d.substring(t.length),l[0].start=l[0].start.getShiftedBy(t.length)):t.startsWith(d)&&(l[0].start=l[0].start.getShiftedBy(d.length),d="")),0==d.length&&l[0].isCollapsed)return}const u={text:d,selection:e.createSelection(l)};rn.isAndroid&&n.document.isComposing?this._compositionQueue.push(u):(t.execute("insertText",u),n.scrollToTheSelection())})),rn.isAndroid?this.listenTo(n.document,"keydown",((t,o)=>{!i.isCollapsed&&229==o.keyCode&&n.document.isComposing&&vg(e,r)})):this.listenTo(n.document,"compositionstart",(()=>{i.isCollapsed||vg(e,r)})),rn.isAndroid?(this.listenTo(n.document,"mutations",((t,{mutations:e})=>{if(n.document.isComposing)for(const{node:t}of e){const e=Ag(t,o),n=o.toModelElement(e);if(this._compositionQueue.isComposedElement(n))return void this._compositionQueue.flush("mutations")}})),this.listenTo(n.document,"compositionend",(()=>{this._compositionQueue.flush("composition end")})),this.listenTo(n.document,"compositionend",(()=>{const t=[];for(const e of this._compositionQueue.flushComposedElements()){const n=o.toViewElement(e);n&&t.push({type:"children",node:n})}t.length&&n.document.fire("mutations",{mutations:t})}),{priority:"lowest"})):this.listenTo(n.document,"compositionend",(()=>{n.document.fire("mutations",{mutations:[]})}),{priority:"lowest"})}destroy(){super.destroy(),this._compositionQueue.destroy()}}class Cg{editor;flushDebounced=nr((()=>this.flush("timeout")),50);_queue=[];_compositionElements=new Set;constructor(t){this.editor=t}destroy(){for(this.flushDebounced.cancel(),this._compositionElements.clear();this._queue.length;)this.shift()}get length(){return this._queue.length}push(t){const e={text:t.text};if(t.selection){e.selectionRanges=[];for(const n of t.selection.getRanges())e.selectionRanges.push(La.fromRange(n)),this._compositionElements.add(n.start.parent)}this._queue.push(e),this.flushDebounced()}shift(){const t=this._queue.shift(),e={text:t.text};if(t.selectionRanges){const n=t.selectionRanges.map((t=>function(t){const e=t.toRange();return t.detach(),"$graveyard"==e.root.rootName?null:e}(t))).filter((t=>!!t));n.length&&(e.selection=this.editor.model.createSelection(n))}return e}flush(t){const e=this.editor,n=e.model,o=e.editing.view;if(this.flushDebounced.cancel(),!this._queue.length)return;const i=e.commands.get("insertText").buffer;n.enqueueChange(i.batch,(()=>{for(i.lock();this._queue.length;){const t=this.shift();e.execute("insertText",t)}i.unlock()})),o.scrollToTheSelection()}isComposedElement(t){return this._compositionElements.has(t)}flushComposedElements(){const t=Array.from(this._compositionElements);return this._compositionElements.clear(),t}}function vg(t,e){if(!e.isEnabled)return;const n=e.buffer;n.lock(),t.enqueueChange(n.batch,(()=>{t.deleteContent(t.document.selection)})),n.unlock()}function Ag(t,e){let n=t.is("$text")?t.parent:t;for(;!e.toModelElement(n);)n=n.parent;return n}class yg extends su{direction;_buffer;constructor(t,e){super(t),this.direction=e,this._buffer=new gg(t.model,t.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(t={}){const e=this.editor.model,n=e.document;e.enqueueChange(this._buffer.batch,(o=>{this._buffer.lock();const i=o.createSelection(t.selection||n.selection);if(!e.canEditAt(i))return;const r=t.sequence||1,s=i.isCollapsed;if(i.isCollapsed&&e.modifySelection(i,{direction:this.direction,unit:t.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(o);if(this._shouldReplaceFirstBlockWithParagraph(i,r))return void this.editor.execute("paragraph",{selection:i});if(i.isCollapsed)return;let a=0;i.getFirstRange().getMinimalFlatRanges().forEach((t=>{a+=Xn(t.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),e.deleteContent(i,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),o.setSelection(i),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(t){if(t>1)return!1;const e=this.editor.model,n=e.document.selection,o=e.schema.getLimitElement(n);if(!n.isCollapsed||!n.containsEntireContent(o))return!1;if(!e.schema.checkChild(o,"paragraph"))return!1;const i=o.getChild(0);return!i||!i.is("element","paragraph")}_replaceEntireContentWithParagraph(t){const e=this.editor.model,n=e.document.selection,o=e.schema.getLimitElement(n),i=t.createElement("paragraph");t.remove(t.createRangeIn(o)),t.insert(i,o),t.setSelection(i,0)}_shouldReplaceFirstBlockWithParagraph(t,e){const n=this.editor.model;if(e>1||"backward"!=this.direction)return!1;if(!t.isCollapsed)return!1;const o=t.getFirstPosition(),i=n.schema.getLimitElement(o),r=i.getChild(0);return o.parent==r&&!!t.containsEntireContent(r)&&!!n.schema.checkChild(i,"paragraph")&&"paragraph"!=r.name}}const xg="word",Eg="selection",Dg="backward",Sg="forward",Tg={deleteContent:{unit:Eg,direction:Dg},deleteContentBackward:{unit:"codePoint",direction:Dg},deleteWordBackward:{unit:xg,direction:Dg},deleteHardLineBackward:{unit:Eg,direction:Dg},deleteSoftLineBackward:{unit:Eg,direction:Dg},deleteContentForward:{unit:"character",direction:Sg},deleteWordForward:{unit:xg,direction:Sg},deleteHardLineForward:{unit:Eg,direction:Sg},deleteSoftLineForward:{unit:Eg,direction:Sg}};class Bg extends $s{constructor(t){super(t);const e=t.document;let n=0;e.on("keydown",(()=>{n++})),e.on("keyup",(()=>{n=0})),e.on("beforeinput",((o,i)=>{if(!this.isEnabled)return;const{targetRanges:r,domEvent:s,inputType:a}=i,c=Tg[a];if(!c)return;const l={direction:c.direction,unit:c.unit,sequence:n};l.unit==Eg&&(l.selectionToRemove=t.createSelection(r[0])),"deleteContentBackward"===a&&(rn.isAndroid&&(l.sequence=1),function(t){if(1!=t.length||t[0].isCollapsed)return!1;const e=t[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let n=0;for(const{nextPosition:t,item:o}of e){if(t.parent.is("$text")){const e=t.parent.data,o=t.offset;if(ki(e,o)||bi(e,o)||_i(e,o))continue;n++}else(o.is("containerElement")||o.is("emptyElement"))&&n++;if(n>1)return!0}return!1}(r)&&(l.unit=Eg,l.selectionToRemove=t.createSelection(r)));const d=new Zr(e,"delete",r[0]);e.fire(d,new Ks(t,s,l)),d.stop.called&&o.stop()})),rn.isBlink&&function(t){const e=t.view,n=e.document;let o=null,i=!1;function r(t){return t==Yo.backspace||t==Yo.delete}function s(t){return t==Yo.backspace?Dg:Sg}n.on("keydown",((t,{keyCode:e})=>{o=e,i=!1})),n.on("keyup",((a,{keyCode:c,domEvent:l})=>{const d=n.selection,u=t.isEnabled&&c==o&&r(c)&&!d.isCollapsed&&!i;if(o=null,u){const t=d.getFirstRange(),o=new Zr(n,"delete",t),i={unit:Eg,direction:s(c),selectionToRemove:d};n.fire(o,new Ks(e,l,i))}})),n.on("beforeinput",((t,{inputType:e})=>{const n=Tg[e];r(o)&&n&&n.direction==s(o)&&(i=!0)}),{priority:"high"}),n.on("beforeinput",((t,{inputType:e,data:n})=>{o==Yo.delete&&"insertText"==e&&""==n&&t.stop()}),{priority:"high"})}(this)}observe(){}stopObserving(){}}class Ig extends iu{_undoOnBackspace;static get pluginName(){return"Delete"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.editing.view,n=e.document,o=t.model.document;e.addObserver(Bg),this._undoOnBackspace=!1;const i=new yg(t,"forward");t.commands.add("deleteForward",i),t.commands.add("forwardDelete",i),t.commands.add("delete",new yg(t,"backward")),this.listenTo(n,"delete",((o,i)=>{n.isComposing||i.preventDefault();const{direction:r,sequence:s,selectionToRemove:a,unit:c}=i,l="forward"===r?"deleteForward":"delete",d={sequence:s};if("selection"==c){const e=Array.from(a.getRanges()).map((e=>t.editing.mapper.toModelRange(e)));d.selection=t.model.createSelection(e)}else d.unit=c;t.execute(l,d),e.scrollToTheSelection()}),{priority:"low"}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(n,"delete",((e,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,t.execute("undo"),n.preventDefault(),e.stop())}),{context:"$capture"}),this.listenTo(o,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Mg extends iu{static get requires(){return[_g,Ig]}static get pluginName(){return"Typing"}static get isOfficialPlugin(){return!0}}function Pg(t,e){let n=t.start;return{text:Array.from(t.getWalker({ignoreElementEnd:!1})).reduce(((t,{item:o})=>o.is("$text")||o.is("$textProxy")?t+o.data:(n=e.createPositionAfter(o),"")),""),range:e.createRange(n,t.end)}}class Og extends(qn()){model;testCallback;_hasMatch;constructor(t,e){super(),this.model=t,this.testCallback=e,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(t.document.selection),this.stopListening(t.document))})),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const t=this.model.document;this.listenTo(t.selection,"change:range",((e,{directChange:n})=>{n&&(t.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))})),this.listenTo(t,"change:data",((t,e)=>{!e.isUndo&&e.isLocal&&this._evaluateTextBeforeSelection("data",{batch:e})}))}_evaluateTextBeforeSelection(t,e={}){const n=this.model,o=n.document.selection,i=n.createRange(n.createPositionAt(o.focus.parent,0),o.focus),{text:r,range:s}=Pg(i,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const n=Object.assign(e,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${t}`,n)}}}class Ng extends iu{attributes;_overrideUid;_isNextGravityRestorationSkipped=!1;static get pluginName(){return"TwoStepCaretMovement"}static get isOfficialPlugin(){return!0}constructor(t){super(t),this.attributes=new Set,this._overrideUid=null}init(){const t=this.editor,e=t.model,n=t.editing.view,o=t.locale,i=e.document.selection;this.listenTo(n.document,"arrowKey",((t,e)=>{if(!i.isCollapsed)return;if(e.shiftKey||e.altKey||e.ctrlKey)return;const n=e.keyCode==Yo.arrowright,r=e.keyCode==Yo.arrowleft;if(!n&&!r)return;const s=o.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(e):this._handleBackwardMovement(e),!0===a&&t.stop()}),{context:"$text",priority:"highest"}),this.listenTo(i,"change:range",((t,e)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!e.directChange&&Vg(i.getFirstPosition(),this.attributes)||this._restoreGravity())})),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(t){this.attributes.add(t)}_handleForwardMovement(t){const e=this.attributes,n=this.editor.model,o=n.document.selection,i=o.getFirstPosition();return!(this._isGravityOverridden||i.isAtStart&&zg(o,e)||!Vg(i,e)||(Fg(t),zg(o,e)&&Vg(i,e,!0)?Rg(n,e):this._overrideGravity(),0))}_handleBackwardMovement(t){const e=this.attributes,n=this.editor.model,o=n.document.selection,i=o.getFirstPosition();return this._isGravityOverridden?(Fg(t),this._restoreGravity(),Vg(i,e,!0)?Rg(n,e):Lg(n,e,i),!0):i.isAtStart?!!zg(o,e)&&(Fg(t),Lg(n,e,i),!0):!zg(o,e)&&Vg(i,e,!0)?(Fg(t),Lg(n,e,i),!0):!!jg(i,e)&&(i.isAtEnd&&!zg(o,e)&&Vg(i,e)?(Fg(t),Lg(n,e,i),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const t=this.editor,e=t.model,n=e.document.selection,o=t.editing.view.document;t.editing.view.addObserver(sd);let i=!1;this.listenTo(o,"mousedown",(()=>{i=!0})),this.listenTo(o,"selectionChange",(()=>{const t=this.attributes;if(!i)return;if(i=!1,!n.isCollapsed)return;if(!zg(n,t))return;const o=n.getFirstPosition();Vg(o,t)&&(o.isAtStart||Vg(o,t,!0)?Rg(e,t):this._isGravityOverridden||this._overrideGravity())}))}_enableInsertContentSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection,n=this.attributes;this.listenTo(t,"insertContent",(()=>{const o=e.getFirstPosition();zg(e,n)&&Vg(o,n)&&Rg(t,n)}),{priority:"low"})}_handleDeleteContentAfterNode(){const t=this.editor,e=t.model,n=e.document.selection,o=t.editing.view;let i=!1,r=!1;this.listenTo(o.document,"delete",((t,e)=>{i="backward"===e.direction}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{if(!i)return;const t=n.getFirstPosition();r=zg(n,this.attributes)&&!jg(t,this.attributes)}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{i&&(i=!1,r||t.model.enqueueChange((()=>{const t=n.getFirstPosition();zg(n,this.attributes)&&Vg(t,this.attributes)&&(t.isAtStart||Vg(t,this.attributes,!0)?Rg(e,this.attributes):this._isGravityOverridden||this._overrideGravity())})))}),{priority:"low"})}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((t=>t.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((t=>{t.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function zg(t,e){for(const n of e)if(t.hasAttribute(n))return!0;return!1}function Lg(t,e,n){const o=n.nodeBefore;t.change((n=>{if(o){const e=[],i=t.schema.isObject(o)&&t.schema.isInline(o);for(const[n,r]of o.getAttributes())!t.schema.checkAttribute("$text",n)||i&&!1===t.schema.getAttributeProperties(n).copyFromObject||e.push([n,r]);n.setSelectionAttribute(e)}else n.removeSelectionAttribute(e)}))}function Rg(t,e){t.change((t=>{t.removeSelectionAttribute(e)}))}function Fg(t){t.preventDefault()}function jg(t,e){return Vg(t.getShiftedBy(-1),e)}function Vg(t,e,n=!1){const{nodeBefore:o,nodeAfter:i}=t;for(const t of e){const e=o?o.getAttribute(t):void 0,r=i?i.getAttribute(t):void 0;if((!n||void 0!==e&&void 0!==r)&&r!==e)return!0}return!1}function Hg(t){return new RegExp(`(^|\\s)(${t})([^${t}]*)(${t})$`)}function Ug(t,e,n,o){return o.createRange(Wg(t,e,n,!0,o),Wg(t,e,n,!1,o))}function Wg(t,e,n,o,i){let r=t.textNode||(o?t.nodeBefore:t.nodeAfter),s=null;for(;r&&r.getAttribute(e)==n;)s=r,r=o?r.previousSibling:r.nextSibling;return s?i.createPositionAt(s,o?"before":"after"):t}function Gg(t,e,n,o){const i=t.editing.view,r=new Set;i.document.registerPostFixer((i=>{const s=t.model.document.selection;let a=!1;if(s.hasAttribute(e)){const c=Ug(s.getFirstPosition(),e,s.getAttribute(e),t.model),l=t.editing.mapper.toViewRange(c);for(const t of l.getItems())t.is("element",n)&&!t.hasClass(o)&&(i.addClass(o,t),r.add(t),a=!0)}return a})),t.conversion.for("editingDowncast").add((t=>{function e(){i.change((t=>{for(const e of r.values())t.removeClass(o,e),r.delete(e)}))}t.on("insert",e,{priority:"highest"}),t.on("remove",e,{priority:"highest"}),t.on("attribute",e,{priority:"highest"}),t.on("selection",e,{priority:"highest"})}))}function qg(t,e,n,o){let i,r=null;"function"==typeof o?i=o:(r=t.commands.get(o),i=()=>{t.execute(o)}),t.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!e.isEnabled)return;const c=ai(t.model.document.selection.getRanges());if(!c.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const l=Array.from(t.model.document.differ.getChanges()),d=l[0];if(1!=l.length||"insert"!==d.type||"$text"!=d.name||1!=d.length)return;const u=d.position.parent;if(u.is("element","codeBlock"))return;if(u.is("element","listItem")&&"function"!=typeof o&&!["numberedList","bulletedList","todoList"].includes(o))return;if(r&&!0===r.value)return;const h=u.getChild(0),p=t.model.createRangeOn(h);if(!p.containsRange(c)&&!c.end.isEqual(p.end))return;const m=n.exec(h.data.substr(0,c.end.offset));m&&t.model.enqueueChange((e=>{const n=e.createPositionAt(u,0),o=e.createPositionAt(u,m[0].length),r=new La(n,o);if(!1!==i({match:m})){e.remove(r);const n=t.model.document.selection.getFirstRange(),o=e.createRangeIn(u);!u.isEmpty||o.isEqual(n)||o.containsRange(n,!0)||e.remove(u)}r.detach(),t.model.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function $g(t,e,n,o){let i,r;n instanceof RegExp?i=n:r=n,r=r||(t=>{let e;const n=[],o=[];for(;null!==(e=i.exec(t))&&!(e&&e.length<4);){let{index:t,1:i,2:r,3:s}=e;const a=i+r+s;t+=e[0].length-a.length;const c=[t,t+i.length],l=[t+i.length+r.length,t+i.length+r.length+s.length];n.push(c),n.push(l),o.push([t+i.length,t+i.length+r.length])}return{remove:n,format:o}}),t.model.document.on("change:data",((n,i)=>{if(i.isUndo||!i.isLocal||!e.isEnabled)return;const s=t.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const d=a.focus,u=d.parent,{text:h,range:p}=function(t,e){let n=t.start;return{text:Array.from(t.getItems()).reduce(((t,o)=>!o.is("$text")&&!o.is("$textProxy")||o.getAttribute("code")?(n=e.createPositionAfter(o),""):t+o.data),""),range:e.createRange(n,t.end)}}(s.createRange(s.createPositionAt(u,0),d),s),m=r(h),g=Kg(p.start,m.format,s),f=Kg(p.start,m.remove,s);g.length&&f.length&&s.enqueueChange((e=>{if(!1!==o(e,g)){for(const t of f.reverse())e.remove(t);s.enqueueChange((()=>{t.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function Kg(t,e,n){return e.filter((t=>void 0!==t[0]&&void 0!==t[1])).map((e=>n.createRange(t.getShiftedBy(e[0]),t.getShiftedBy(e[1]))))}function Yg(t,e){return(n,o)=>{if(!t.commands.get(e).isEnabled)return!1;const i=t.model.schema.getValidRanges(o,e);for(const t of i)n.setAttribute(e,!0,t);n.removeSelectionAttribute(e)}}Hg('"'),Hg("'"),Hg("'"),Hg('"'),Hg('"'),Hg("'");class Qg extends su{attributeKey;constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=void 0===t.forceValue?!this.value:t.forceValue;e.change((t=>{if(n.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,!0):t.removeSelectionAttribute(this.attributeKey);else{const i=e.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const e of i)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}}))}_getValueFromFirstAllowedNode(){const t=this.editor.model,e=t.schema,n=t.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const t of n.getRanges())for(const n of t.getItems())if(e.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}}const Zg="bold";class Jg extends iu{static get pluginName(){return"BoldEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:Zg}),t.model.schema.setAttributeProperties(Zg,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Zg,view:"strong",upcastAlso:["b",t=>{const e=t.getStyle("font-weight");return e&&("bold"==e||Number(e)>=600)?{name:!0,styles:["font-weight"]}:null}]}),t.commands.add(Zg,new Qg(t,Zg)),t.keystrokes.set("CTRL+B",Zg),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Bold text"),keystroke:"CTRL+B"}]})}}function Xg({editor:t,commandName:e,plugin:n,icon:o,label:i,keystroke:r}){return s=>{const a=t.commands.get(e),c=new s(t.locale);return c.set({label:i,icon:o,keystroke:r,isToggleable:!0}),c.bind("isEnabled").to(a,"isEnabled"),c.bind("isOn").to(a,"value"),c instanceof Yh?c.set({role:"menuitemcheckbox"}):c.set({tooltip:!0}),n.listenTo(c,"execute",(()=>{t.execute(e),t.editing.view.focus()})),c}}const tf="bold";class ef extends iu{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:tf,plugin:this,icon:yu.bold,label:e("Bold"),keystroke:"CTRL+B"});t.ui.componentFactory.add(tf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+tf,(()=>n(Yh)))}}const nf="code";class of extends iu{static get pluginName(){return"CodeEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ng]}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:nf}),t.model.schema.setAttributeProperties(nf,{isFormatting:!0,copyOnEnter:!1}),t.conversion.attributeToElement({model:nf,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),t.commands.add(nf,new Qg(t,nf)),t.plugins.get(Ng).registerAttribute(nf),Gg(t,nf,"code","ck-code_selected"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}const rf="code";class sf extends iu{static get pluginName(){return"CodeUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:rf,plugin:this,icon:' ',label:e("Code")});t.ui.componentFactory.add(rf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+rf,(()=>n(Yh)))}}const af="italic";class cf extends iu{static get pluginName(){return"ItalicEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:af}),t.model.schema.setAttributeProperties(af,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:af,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(af,new Qg(t,af)),t.keystrokes.set("CTRL+I",af),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Italic text"),keystroke:"CTRL+I"}]})}}const lf="italic";class df extends iu{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:lf,plugin:this,icon:' ',keystroke:"CTRL+I",label:e("Italic")});t.ui.componentFactory.add(lf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+lf,(()=>n(Yh)))}}const uf="strikethrough";class hf extends iu{static get pluginName(){return"StrikethroughEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:uf}),t.model.schema.setAttributeProperties(uf,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:uf,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),t.commands.add(uf,new Qg(t,uf)),t.keystrokes.set("CTRL+SHIFT+X","strikethrough"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const pf="strikethrough";class mf extends iu{static get pluginName(){return"StrikethroughUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:pf,plugin:this,icon:' ',keystroke:"CTRL+SHIFT+X",label:e("Strikethrough")});t.ui.componentFactory.add(pf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+pf,(()=>n(Yh)))}}const gf="subscript";class ff extends iu{static get pluginName(){return"SubscriptEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:gf}),t.model.schema.setAttributeProperties(gf,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:gf,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),t.commands.add(gf,new Qg(t,gf))}}const kf="subscript";class bf extends iu{static get pluginName(){return"SubscriptUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:kf,plugin:this,icon:' ',label:e("Subscript")});t.ui.componentFactory.add(kf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+kf,(()=>n(Yh)))}}const wf="superscript";class _f extends iu{static get pluginName(){return"SuperscriptEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:wf}),t.model.schema.setAttributeProperties(wf,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:wf,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),t.commands.add(wf,new Qg(t,wf))}}const Cf="superscript";class vf extends iu{static get pluginName(){return"SuperscriptUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:Cf,plugin:this,icon:' ',label:e("Superscript")});t.ui.componentFactory.add(Cf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+Cf,(()=>n(Yh)))}}const Af="underline";class yf extends iu{static get pluginName(){return"UnderlineEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:Af}),t.model.schema.setAttributeProperties(Af,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Af,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),t.commands.add(Af,new Qg(t,Af)),t.keystrokes.set("CTRL+U","underline"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Underline text"),keystroke:"CTRL+U"}]})}}const xf="underline";class Ef extends iu{static get pluginName(){return"UnderlineUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=Xg({editor:t,commandName:xf,plugin:this,icon:' ',label:e("Underline"),keystroke:"CTRL+U"});t.ui.componentFactory.add(xf,(()=>n(Mh))),t.ui.componentFactory.add("menuBar:"+xf,(()=>n(Yh)))}}function*Df(t,e){for(const n of e)n&&t.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}class Sf extends su{execute(){this.editor.model.change((t=>{this.enterBlock(t),this.fire("afterExecute",{writer:t})}))}enterBlock(t){const e=this.editor.model,n=e.document.selection,o=e.schema,i=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(o.isLimit(s)||o.isLimit(a))return i||s!=a||e.deleteContent(n),!1;if(i){const e=Df(t.model.schema,n.getAttributes());return Tf(t,r.start),t.setSelectionAttribute(e),!0}{const o=!(r.start.isAtStart&&r.end.isAtEnd),i=s==a;if(e.deleteContent(n,{leaveUnmerged:o}),o){if(i)return Tf(t,n.focus),!0;t.setSelection(a,0)}}return!1}}function Tf(t,e){t.split(e),t.setSelection(e.parent.nextSibling,0)}const Bf={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class If extends $s{constructor(t){super(t);const e=this.document;let n=!1;e.on("keydown",((t,e)=>{n=e.shiftKey})),e.on("beforeinput",((o,i)=>{if(!this.isEnabled)return;let r=i.inputType;rn.isSafari&&n&&"insertParagraph"==r&&(r="insertLineBreak");const s=i.domEvent,a=Bf[r];if(!a)return;const c=new Zr(e,"enter",i.targetRanges[0]);e.fire(c,new Ks(t,s,{isSoft:a.isSoft})),c.stop.called&&o.stop()}))}observe(){}stopObserving(){}}class Mf extends iu{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.editing.view,n=e.document,o=this.editor.t;e.addObserver(If),t.commands.add("enter",new Sf(t)),this.listenTo(n,"enter",((o,i)=>{n.isComposing||i.preventDefault(),i.isSoft||(t.execute("enter"),e.scrollToTheSelection())}),{priority:"low"}),t.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class Pf extends su{execute(){const t=this.editor.model,e=t.document;t.change((n=>{!function(t,e,n){const o=n.isCollapsed,i=n.getFirstRange(),r=i.start.parent,s=i.end.parent,a=r==s;if(o){const o=Df(t.schema,n.getAttributes());Of(t,e,i.end),e.removeSelectionAttribute(n.getAttributeKeys()),e.setSelectionAttribute(o)}else{const o=!(i.start.isAtStart&&i.end.isAtEnd);t.deleteContent(n,{leaveUnmerged:o}),a?Of(t,e,n.focus):o&&e.setSelection(s,0)}}(t,n,e.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const t=this.editor.model,e=t.document;this.isEnabled=function(t,e){if(e.rangeCount>1)return!1;const n=e.anchor;if(!n||!t.checkChild(n,"softBreak"))return!1;const o=e.getFirstRange(),i=o.start.parent,r=o.end.parent;return!Nf(i,t)&&!Nf(r,t)||i===r}(t.schema,e.selection)}}function Of(t,e,n){const o=e.createElement("softBreak");t.insertContent(o,n),e.setSelection(o,"after")}function Nf(t,e){return!t.is("rootElement")&&(e.isLimit(t)||Nf(t.parent,e))}class zf extends iu{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.model.schema,n=t.conversion,o=t.editing.view,i=o.document,r=this.editor.t;e.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(t,{writer:e})=>e.createEmptyElement("br")}),o.addObserver(If),t.commands.add("shiftEnter",new Pf(t)),this.listenTo(i,"enter",((e,n)=>{i.isComposing||n.preventDefault(),n.isSoft&&(t.execute("shiftEnter"),o.scrollToTheSelection())}),{priority:"low"}),t.accessibility.addKeystrokeInfos({keystrokes:[{label:r("Insert a soft break (a <br>
element)"),keystroke:"Shift+Enter"}]})}}class Lf extends su{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.schema,o=e.document.selection,i=Array.from(o.getSelectedBlocks()),r=void 0===t.forceValue?!this.value:t.forceValue;e.change((t=>{if(r){const e=i.filter((t=>Rf(t)||jf(n,t)));this._applyQuote(t,e)}else this._removeQuote(t,i.filter(Rf))}))}_getValue(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());return!(!t||!Rf(t))}_checkEnabled(){if(this.value)return!0;const t=this.editor.model.document.selection,e=this.editor.model.schema,n=ai(t.getSelectedBlocks());return!!n&&jf(e,n)}_removeQuote(t,e){Ff(t,e).reverse().forEach((e=>{if(e.start.isAtStart&&e.end.isAtEnd)return void t.unwrap(e.start.parent);if(e.start.isAtStart){const n=t.createPositionBefore(e.start.parent);return void t.move(e,n)}e.end.isAtEnd||t.split(e.end);const n=t.createPositionAfter(e.end.parent);t.move(e,n)}))}_applyQuote(t,e){const n=[];Ff(t,e).reverse().forEach((e=>{let o=Rf(e.start);o||(o=t.createElement("blockQuote"),t.wrap(e,o)),n.push(o)})),n.reverse().reduce(((e,n)=>e.nextSibling==n?(t.merge(t.createPositionAfter(e)),e):n))}}function Rf(t){return"blockQuote"==t.parent.name?t.parent:null}function Ff(t,e){let n,o=0;const i=[];for(;o{const o=t.model.document.differ.getChanges();for(const t of o)if("insert"==t.type){const o=t.position.nodeAfter;if(!o)continue;if(o.is("element","blockQuote")&&o.isEmpty)return n.remove(o),!0;if(o.is("element","blockQuote")&&!e.checkChild(t.position,o))return n.unwrap(o),!0;if(o.is("element")){const t=n.createRangeIn(o);for(const o of t.getItems())if(o.is("element","blockQuote")&&!e.checkChild(n.createPositionBefore(o),o))return n.unwrap(o),!0}}else if("remove"==t.type){const e=t.position.parent;if(e.is("element","blockQuote")&&e.isEmpty)return n.remove(e),!0}return!1}));const n=this.editor.editing.view.document,o=t.model.document.selection,i=t.commands.get("blockQuote");this.listenTo(n,"enter",((e,n)=>{o.isCollapsed&&i.value&&o.getLastPosition().parent.isEmpty&&(t.execute("blockQuote"),t.editing.view.scrollToTheSelection(),n.preventDefault(),e.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((e,n)=>{if("backward"!=n.direction||!o.isCollapsed||!i.value)return;const r=o.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(t.execute("blockQuote"),t.editing.view.scrollToTheSelection(),n.preventDefault(),e.stop())}),{context:"blockquote"})}}class Hf extends iu{static get pluginName(){return"BlockQuoteUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add("blockQuote",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add("menuBar:blockQuote",(()=>{const t=this._createButton(Yh);return t.set({role:"menuitemcheckbox"}),t}))}_createButton(t){const e=this.editor,n=e.locale,o=e.commands.get("blockQuote"),i=new t(e.locale),r=n.t;return i.set({label:r("Block quote"),icon:yu.quote,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value"),this.listenTo(i,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),i}}class Uf extends(Mn()){_stack=[];add(t,e){const n=this._stack,o=n[0];this._insertDescriptor(t);const i=n[0];o===i||Wf(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}remove(t,e){const n=this._stack,o=n[0];this._removeDescriptor(t);const i=n[0];o===i||Wf(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}_insertDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t.id));if(Wf(t,e[n]))return;n>-1&&e.splice(n,1);let o=0;for(;e[o]&&(i=e[o],r=t,i.priority>r.priority||!(i.priorityGf(r.classes));)o++;var i,r;e.splice(o,0,t)}_removeDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t));n>-1&&e.splice(n,1)}}function Wf(t,e){return t&&e&&t.priority==e.priority&&Gf(t.classes)==Gf(e.classes)}function Gf(t){return Array.isArray(t)?t.sort().join(","):t}const qf="ck-widget_selected";function $f(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function Kf(t,e,n={}){if(!t.is("containerElement"))throw new An("widget-to-widget-wrong-element-type",null,{element:t});return e.setAttribute("contenteditable","false",t),e.addClass("ck-widget",t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=tk,e.setCustomProperty("widgetLabel",[],t),n.label&&function(t,e){t.getCustomProperty("widgetLabel").push(e)}(t,n.label),n.hasSelectionHandle&&function(t,e){const n=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(t){const e=this.toDomElement(t),n=new Bh;return n.set("content",' '),n.render(),e.appendChild(n.element),e}));e.insert(e.createPositionAt(t,0),n),e.addClass(["ck-widget_with-selection-handle"],t)}(t,e),Zf(t,e),t}function Yf(t,e,n){if(e.classes&&n.addClass(ii(e.classes),t),e.attributes)for(const o in e.attributes)n.setAttribute(o,e.attributes[o],t)}function Qf(t,e,n){if(e.classes&&n.removeClass(ii(e.classes),t),e.attributes)for(const o in e.attributes)n.removeAttribute(o,t)}function Zf(t,e,n=Yf,o=Qf){const i=new Uf;i.on("change:top",((e,i)=>{i.oldDescriptor&&o(t,i.oldDescriptor,i.writer),i.newDescriptor&&n(t,i.newDescriptor,i.writer)})),e.setCustomProperty("addHighlight",((t,e,n)=>i.add(e,n)),t),e.setCustomProperty("removeHighlight",((t,e,n)=>i.remove(e,n)),t)}function Jf(t,e,n={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),e.setAttribute("role","textbox",t),e.setAttribute("tabindex","-1",t),n.label&&e.setAttribute("aria-label",n.label,t),e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",((n,o,i)=>{e.setAttribute("contenteditable",i?"false":"true",t)})),t.on("change:isFocused",((n,o,i)=>{i?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)})),Zf(t,e),t}function Xf(t,e){const n=t.getSelectedElement();if(n){const o=ok(t);if(o)return e.createRange(e.createPositionAt(n,o))}return e.schema.findOptimalInsertionRange(t)}function tk(){return null}const ek="widget-type-around";function nk(t,e,n){return!!t&&$f(t)&&!n.isInline(e)}function ok(t){return t.getAttribute(ek)}const ik=["before","after"],rk=(new DOMParser).parseFromString(' ',"image/svg+xml").firstChild,sk="ck-widget__type-around_disabled";class ak extends iu{_currentFakeCaretModelElement=null;static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[Mf,Ig]}init(){const t=this.editor,e=t.editing.view;this.on("change:isEnabled",((n,o,i)=>{e.change((t=>{for(const n of e.document.roots)i?t.removeClass(sk,n):t.addClass(sk,n)})),i||t.model.change((t=>{t.removeSelectionAttribute(ek)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(t,e){const n=this.editor,o=n.editing.view,i=n.model.schema.getAttributesWithProperty(t,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(t,e),attributes:i}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(t,e,n,o){this.listenTo(t,e,((...t)=>{this.isEnabled&&n(...t)}),o)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor.model.document.selection,e=ok(t);if(!e)return!1;const n=t.getSelectedElement();return this._insertParagraph(n,e),!0}_enableTypeAroundUIInjection(){const t=this.editor,e=t.model.schema,n=t.locale.t,o={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",((t,i,r)=>{const s=r.mapper.toViewElement(i.item);s&&nk(s,i.item,e)&&(!function(t,e,n){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const n=this.toDomElement(t);return function(t,e){for(const n of ik){const o=new ih({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:e[n],"aria-hidden":"true"},children:[t.ownerDocument.importNode(rk,!0)]});t.appendChild(o.render())}}(n,e),function(t){const e=new ih({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}(n),n}));t.insert(t.createPositionAt(n,"end"),o)}(r.writer,o,s),s.getCustomProperty("widgetLabel").push((()=>this.isEnabled?n("Press Enter to type after or press Shift + Enter to type before the widget"):"")))}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const t=this.editor,e=t.model,n=e.document.selection,o=e.schema,i=t.editing.view;function r(t){return`ck-widget_type-around_show-fake-caret_${t}`}this._listenToIfEnabled(i.document,"arrowKey",((t,e)=>{this._handleArrowKeyPress(t,e)}),{context:[$f,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((e,n)=>{n.directChange&&t.model.change((t=>{t.removeSelectionAttribute(ek)}))})),this._listenToIfEnabled(e.document,"change:data",(()=>{const e=n.getSelectedElement();e&&nk(t.editing.mapper.toViewElement(e),e,o)||t.model.change((t=>{t.removeSelectionAttribute(ek)}))})),this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",((t,e,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);t&&(i.removeClass(ik.map(r),t),this._currentFakeCaretModelElement=null)}const s=e.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!nk(a,s,o))return;const c=ok(e.selection);c&&(i.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",((e,n,o)=>{o||t.model.change((t=>{t.removeSelectionAttribute(ek)}))}))}_handleArrowKeyPress(t,e){const n=this.editor,o=n.model,i=o.document.selection,r=o.schema,s=n.editing.view,a=function(t,e){const n=ti(t,e);return"down"===n||"right"===n}(e.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;nk(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):i.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):e.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(e.preventDefault(),t.stop())}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor.model,n=ok(e.document.selection);return e.change((e=>n?n!==(t?"after":"before")&&(e.removeSelectionAttribute(ek),!0):(e.setSelectionAttribute(ek,t?"after":"before"),!0)))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor,n=e.model,o=n.schema,i=e.plugins.get("Widget"),r=i._getObjectElementNextToSelection(t);return!!nk(e.editing.mapper.toViewElement(r),r,o)&&(n.change((e=>{i._setSelectionOverElement(r),e.setSelectionAttribute(ek,t?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor,n=e.model,o=n.schema,i=e.editing.mapper,r=n.document.selection,s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!nk(i.toViewElement(s),s,o)&&(n.change((e=>{e.setSelection(s,"on"),e.setSelectionAttribute(ek,t?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const t=this.editor,e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",((n,o)=>{const i=o.domTarget.closest(".ck-widget__type-around__button");if(!i)return;const r=i.classList.contains("ck-widget__type-around__button_before")?"before":"after",s=function(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}(i,e.domConverter),a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r),o.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor,e=t.model.document.selection,n=t.editing.view;this._listenToIfEnabled(n.document,"enter",((n,o)=>{if("atTarget"!=n.eventPhase)return;const i=e.getSelectedElement(),r=t.editing.mapper.toViewElement(i),s=t.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:nk(r,i,s)&&(this._insertParagraph(i,o.isSoft?"before":"after"),a=!0),a&&(o.preventDefault(),n.stop())}),{context:$f})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view.document;this._listenToIfEnabled(t,"insertText",((e,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.selection=t.selection)}),{priority:"high"}),rn.isAndroid?this._listenToIfEnabled(t,"keydown",((t,e)=>{229==e.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(t,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const t=this.editor,e=t.editing.view,n=t.model,o=n.schema;this._listenToIfEnabled(e.document,"delete",((e,i)=>{if("atTarget"!=e.eventPhase)return;const r=ok(n.document.selection);if(!r)return;const s=i.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)t.execute("delete",{selection:n.createSelection(a,"on")});else{const e=o.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e)if(e.isCollapsed){const i=n.createSelection(e.start);if(n.modifySelection(i,{direction:s}),i.focus.isEqual(e.start)){const t=function(t,e){let n=e;for(const o of e.getAncestors({parentFirst:!0})){if(o.childCount>1||t.isLimit(o))break;n=o}return n}(o,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")}))}i.preventDefault(),e.stop()}),{context:$f})}_enableInsertContentIntegration(){const t=this.editor,e=this.editor.model,n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",((t,[o,i])=>{if(i&&!i.is("documentSelection"))return;const r=ok(n);return r?(t.stop(),e.change((t=>{const i=n.getSelectedElement(),s=e.createPositionAt(i,r),a=t.createSelection(s),c=e.insertContent(o,a);return t.setSelection(a),c}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"insertObject",((t,n)=>{const[,o,i={}]=n;if(o&&!o.is("documentSelection"))return;const r=ok(e);r&&(i.findOptimalPosition=r,n[3]=i)}),{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"deleteContent",((t,[n])=>{n&&!n.is("documentSelection")||ok(e)&&t.stop()}),{priority:"high"})}}function ck(t,e,n){const o=t.schema,i=t.createRangeIn(e.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:t,item:s,type:a}of i.getWalker({startPosition:e,direction:n})){if(o.isLimit(s)&&!o.isInline(s))return t;if(a==r&&o.isBlock(s))return null}return null}function lk(t,e,n){const o="backward"==n?e.end:e.start;if(t.checkChild(o,"$text"))return o;for(const{nextPosition:o}of e.getWalker({direction:n}))if(t.checkChild(o,"$text"))return o;return null}class dk extends iu{_previouslySelected=new Set;static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[ak,Ig]}init(){const t=this.editor,e=t.editing.view,n=e.document,o=t.t;this.editor.editing.downcastDispatcher.on("selection",((e,n,o)=>{const i=o.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=t.editing.mapper.toViewElement(s);var c;$f(a)&&o.consumable.consume(r,"selection")&&i.setSelection(i.createRangeOn(a),{fake:!0,label:(c=a,c.getCustomProperty("widgetLabel").reduce(((t,e)=>"function"==typeof e?t?t+". "+e():e():t?t+". "+e:e),""))})})),this.editor.editing.downcastDispatcher.on("selection",((t,e,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const o=n.writer,i=o.document.selection;let r=null;for(const t of i.getRanges())for(const e of t){const t=e.item;$f(t)&&(s=t,!(a=r)||!Array.from(s.getAncestors()).includes(a))&&(o.addClass(qf,t),this._previouslySelected.add(t),r=t)}var s,a}),{priority:"low"}),e.addObserver(sd),this.listenTo(n,"mousedown",((...t)=>this._onMousedown(...t))),this.listenTo(n,"arrowKey",((...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)}),{context:[$f,"$text"]}),this.listenTo(n,"arrowKey",((...t)=>{this._preventDefaultOnArrowKeyPress(...t)}),{context:"$root"}),this.listenTo(n,"arrowKey",function(t){const e=t.model;return(n,o)=>{const i=o.keyCode==Yo.arrowup,r=o.keyCode==Yo.arrowdown,s=o.shiftKey,a=e.document.selection;if(!i&&!r)return;const c=r;if(s&&function(t,e){return!t.isCollapsed&&t.isBackward==e}(a,c))return;const l=function(t,e,n){const o=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition(),n=ck(o,t,"forward");if(!n)return null;const i=o.createRange(t,n),r=lk(o.schema,i,"backward");return r?o.createRange(t,r):null}{const t=e.isCollapsed?e.focus:e.getFirstPosition(),n=ck(o,t,"backward");if(!n)return null;const i=o.createRange(n,t),r=lk(o.schema,i,"forward");return r?o.createRange(r,t):null}}(t,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(t,e,n){const o=t.model,i=t.view.domConverter;if(n){const t=o.createSelection(e.start);o.modifySelection(t),t.focus.isAtEnd||e.start.isEqual(t.focus)||(e=o.createRange(t.focus,e.end))}const r=t.mapper.toViewRange(e),s=i.viewRangeToDom(r),a=wo.getDomRangeRects(s);let c;for(const t of a)if(void 0!==c){if(Math.round(t.top)>=c)return!1;c=Math.max(c,Math.round(t.bottom))}else c=Math.round(t.bottom);return!0}(t,l,c))&&(e.change((t=>{const n=c?l.end:l.start;if(s){const o=e.createSelection(a.anchor);o.setFocus(n),t.setSelection(o)}else t.setSelection(n)})),n.stop(),o.preventDefault(),o.stopPropagation())}}}(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())}),{context:"$root"}),this.listenTo(n,"tab",((t,e)=>{"atTarget"==t.eventPhase&&(e.shiftKey||this._selectFirstNestedEditable()&&(e.preventDefault(),t.stop()))}),{context:$f,priority:"low"}),this.listenTo(n,"tab",((t,e)=>{e.shiftKey&&this._selectAncestorWidget()&&(e.preventDefault(),t.stop())}),{priority:"low"}),this.listenTo(n,"keydown",((t,e)=>{e.keystroke==Yo.esc&&this._selectAncestorWidget()&&(e.preventDefault(),t.stop())}),{priority:"low"}),t.accessibility.addKeystrokeInfoGroup({id:"widget",label:o("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:o("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:o("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:o("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:o("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:o("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(t,e){const n=this.editor,o=n.editing.view,i=o.document;let r=e.target;if(!r)return;if(e.domEvent.detail>=3)return void(this._selectBlockContent(r)&&e.preventDefault());if(!$f(r)){const t=function(t){let e=t;for(;e;){if(e.is("editableElement")||$f(e))return e;e=e.parent}return null}(r);if(!t)return;if($f(t))r=t;else{const t=function(t,e){const n=mo(e.domEvent);let o=null;if(o=n?t.domConverter.domRangeToView(n):t.createRange(t.createPositionAt(e.target,0)),!o)return null;const i=o.start;if(!i.parent)return null;let r=i.parent;return i.parent.is("editableElement")&&(i.isAtEnd&&i.nodeBefore?r=i.nodeBefore:i.isAtStart&&i.nodeAfter&&(r=i.nodeAfter)),r.is("$text")?r.parent:r}(o,e);if(!t||!$f(t))return;r=t}}rn.isAndroid&&e.preventDefault(),i.isFocused||o.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_selectBlockContent(t){const e=this.editor,n=e.model,o=e.editing.mapper,i=n.schema,r=o.findMappedViewAncestor(this.editor.editing.view.createPositionAt(t,0)),s=function(t,e){for(const n of t.getAncestors({includeSelf:!0,parentFirst:!0})){if(e.checkChild(n,"$text"))return n;if(e.isLimit(n)&&!e.isObject(n))break}return null}(o.toModelElement(r),n.schema);return!!s&&(n.change((t=>{const e=i.isLimit(s)?null:function(t,e){const n=new ga({startPosition:t});for(const{item:t}of n){if(e.isLimit(t)||!t.is("element"))return null;if(e.checkChild(t,"$text"))return t}return null}(t.createPositionAfter(s),i),n=t.createPositionAt(s,0),o=e?t.createPositionAt(e,0):t.createPositionAt(s,"end");t.setSelection(t.createRange(n,o))})),!0)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode,o=this.editor.model,i=o.schema,r=o.document.selection,s=r.getSelectedElement(),a=ti(n,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&i.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition(),s=i.getNearestSelectionRange(n,c?"forward":"backward");return void(s&&(o.change((t=>{t.setSelection(s)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,l=s.nodeBefore;return void((a&&i.isObject(a)||l&&i.isObject(l))&&(o.change((t=>{t.setSelection(c?s:n)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&i.isObject(d)){if(i.isInline(d)&&l)return;this._setSelectionOverElement(d),e.preventDefault(),t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model,o=n.schema,i=n.document.selection.getSelectedElement();i&&o.isObject(i)&&(e.preventDefault(),t.stop())}_handleDelete(t){const e=this.editor.model.document.selection;if(!this.editor.model.canEditAt(e))return;if(!e.isCollapsed)return;const n=this._getObjectElementNextToSelection(t);return n?(this.editor.model.change((t=>{let o=e.anchor.parent;for(;o.isEmpty;){const e=o;o=e.parent,t.remove(e)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(t){this.editor.model.change((e=>{e.setSelection(e.createRangeOn(t))}))}_getObjectElementNextToSelection(t){const e=this.editor.model,n=e.schema,o=e.document.selection,i=e.createSelection(o);if(e.modifySelection(i,{direction:t?"forward":"backward"}),i.isEqual(o))return null;const r=t?i.focus.nodeBefore:i.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(qf,e);this._previouslySelected.clear()}_selectFirstNestedEditable(){const t=this.editor,e=this.editor.editing.view.document;for(const n of e.selection.getFirstRange().getItems())if(n.is("editableElement")){const e=t.editing.mapper.toModelElement(n);if(!e)continue;const o=t.model.createPositionAt(e,0),i=t.model.schema.getNearestSelectionRange(o,"forward");return t.model.change((t=>{t.setSelection(i)})),!0}return!1}_selectAncestorWidget(){const t=this.editor,e=t.editing.mapper,n=t.editing.view.document.selection.getFirstPosition().parent,o=(n.is("$text")?n.parent:n).findAncestor($f);if(!o)return!1;const i=e.toModelElement(o);return!!i&&(t.model.change((t=>{t.setSelection(i,"on")})),!0)}}class uk extends iu{_toolbarDefinitions=new Map;_balloon;static get requires(){return[$m]}static get pluginName(){return"WidgetToolbarRepository"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",(e=>{(function(t){const e=t.getSelectedElement();return!(!e||!$f(e))})(t.editing.view.document.selection)&&e.stop()}),{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values())t.view.destroy()}register(t,{ariaLabel:e,items:n,getRelatedElement:o,balloonClassName:i="ck-toolbar-container"}){if(!n.length)return void yn("widget-toolbar-no-items",{toolbarId:t});const r=this.editor,s=r.t,a=new Np(r.locale);if(a.ariaLabel=e||s("Widget toolbar"),this._toolbarDefinitions.has(t))throw new An("widget-toolbar-duplicated",this,{toolbarId:t});const c={view:a,getRelatedElement:o,balloonClassName:i,itemsConfig:n,initialized:!1};r.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const t=o(r.editing.view.document.selection);t&&this._showToolbar(c,t)},afterBlur:()=>{this._hideToolbar(c)}}),this._toolbarDefinitions.set(t,c)}_updateToolbarsVisibility(){let t=0,e=null,n=null;for(const o of this._toolbarDefinitions.values()){const i=o.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&i)if(this.editor.ui.focusTracker.isFocused){const r=i.getAncestors().length;r>t&&(t=r,e=i,n=o)}else this._isToolbarVisible(o)&&this._hideToolbar(o);else this._isToolbarInBalloon(o)&&this._hideToolbar(o)}n&&this._showToolbar(n,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?hk(this.editor,e):this._isToolbarInBalloon(t)||(t.initialized||(t.initialized=!0,t.view.fillFromConfig(t.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:t.view,position:pk(this.editor,e),balloonClassName:t.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);hk(this.editor,e)}})))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function hk(t,e){const n=t.plugins.get("ContextualBalloon"),o=pk(t,e);n.updatePosition(o)}function pk(t,e){const n=t.editing.view,o=Tp.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}var mk=function(t){return t==t&&!o(t)},gk=function(t,e){return function(n){return null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}},fk=function(t){var e=function(t){for(var e=Rt(t),n=e.length;n--;){var o=e[n],i=t[o];e[n]=[o,i,mk(i)]}return e}(t);return 1==e.length&&e[0][2]?gk(e[0][0],e[0][1]):function(n){return n===t||function(t,e,n,o){var i=n.length,r=i,s=!o;if(null==t)return!r;for(t=Object(t);i--;){var a=n[i];if(s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++i{o.preventDefault();const i=o.dropRange?[o.dropRange]:null,r=new bn(e,t);e.fire(r,{dataTransfer:o.dataTransfer,method:n.name,targetRanges:i,target:o.target,domEvent:o.domEvent}),r.stop.called&&o.stopPropagation()}}this.listenTo(e,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(e,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(e,"dragover",n("dragging"),{priority:"low"})}onDomEvent(t){const e="clipboardData"in t?t.clipboardData:t.dataTransfer,n="drop"==t.type||"paste"==t.type,o={dataTransfer:new oa(e,{cacheFiles:n})};if("drop"==t.type||"dragover"==t.type){const e=mo(t);o.dropRange=e&&this.view.domConverter.domRangeToView(e)}this.fire(t.type,t,o)}}const Ak=["figcaption","li"],yk=["ol","ul"];function xk(t){if(t.is("$text")||t.is("$textProxy"))return t.data;if(t.is("element","img")&&t.hasAttribute("alt"))return t.getAttribute("alt");if(t.is("element","br"))return"\n";let e="",n=null;for(const r of t.getChildren())e+=(o=r,((i=n)?o.is("element","li")&&!o.isEmpty&&o.getChild(0).is("containerElement")||yk.includes(o.name)&&yk.includes(i.name)?"\n\n":o.is("containerElement")||i.is("containerElement")?Ak.includes(o.name)||Ak.includes(i.name)?"\n":o.is("element")&&o.getCustomProperty("dataPipeline:transparentRendering")||i.is("element")&&i.getCustomProperty("dataPipeline:transparentRendering")?"":"\n\n":"":"")+xk(r)),n=r;var o,i;return e}class Ek extends iu{_markersToCopy=new Map;static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(t,e){this._markersToCopy.set(t,e)}_copySelectedFragmentWithMarkers(t,e,n=t=>t.model.getSelectedContent(t.model.document.selection)){return this.editor.model.change((o=>{const i=o.model.document.selection;o.setSelection(e);const r=this._insertFakeMarkersIntoSelection(o,o.model.document.selection,t),s=n(o),a=this._removeFakeMarkersInsideElement(o,s);for(const[t,e]of Object.entries(r)){a[t]||=o.createRangeIn(s);for(const t of e)o.remove(t)}s.markers.clear();for(const[t,e]of Object.entries(a))s.markers.set(t,e);return o.setSelection(i),s}))}_pasteMarkersIntoTransformedElement(t,e){const n=this._getPasteMarkersFromRangeMap(t);return this.editor.model.change((t=>{const o=this._insertFakeMarkersElements(t,n),i=e(t),r=this._removeFakeMarkersInsideElement(t,i);for(const e of Object.values(o).flat())t.remove(e);for(const[e,n]of Object.entries(r))t.model.markers.has(e)||t.addMarker(e,{usingOperation:!0,affectsData:!0,range:n});return i}))}_pasteFragmentWithMarkers(t){const e=this._getPasteMarkersFromRangeMap(t.markers);t.markers.clear();for(const n of e)t.markers.set(n.name,n.range);return this.editor.model.insertContent(t)}_forceMarkersCopy(t,e,n={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const o=this._markersToCopy.get(t);this._markersToCopy.set(t,n),e(),o?this._markersToCopy.set(t,o):this._markersToCopy.delete(t)}_isMarkerCopyable(t,e){const n=this._getMarkerClipboardConfig(t);if(!n)return!1;if(!e)return!0;const{allowedActions:o}=n;return"all"===o||o.includes(e)}_hasMarkerConfiguration(t){return!!this._getMarkerClipboardConfig(t)}_getMarkerClipboardConfig(t){const[e]=t.split(":");return this._markersToCopy.get(e)||null}_insertFakeMarkersIntoSelection(t,e,n){const o=this._getCopyableMarkersFromSelection(t,e,n);return this._insertFakeMarkersElements(t,o)}_getCopyableMarkersFromSelection(t,e,n){const o=Array.from(e.getRanges()),i=new Set(o.flatMap((e=>Array.from(t.model.markers.getMarkersIntersectingRange(e)))));return Array.from(i).filter((t=>{if(!this._isMarkerCopyable(t.name,n))return!1;const{copyPartiallySelected:e}=this._getMarkerClipboardConfig(t.name);if(!e){const e=t.getRange();return o.some((t=>t.containsRange(e,!0)))}return!0})).map((t=>({name:"dragstart"===n?this._getUniqueMarkerName(t.name):t.name,range:t.getRange()})))}_getPasteMarkersFromRangeMap(t,e=null){const{model:n}=this.editor;return(t instanceof Map?Array.from(t.entries()):Object.entries(t)).flatMap((([t,o])=>{if(!this._hasMarkerConfiguration(t))return[{name:t,range:o}];if(this._isMarkerCopyable(t,e)){const e=this._getMarkerClipboardConfig(t),i=n.markers.has(t)&&"$graveyard"===n.markers.get(t).getRange().root.rootName;return(e.duplicateOnPaste||i)&&(t=this._getUniqueMarkerName(t)),[{name:t,range:o}]}return[]}))}_insertFakeMarkersElements(t,e){const n={},o=e.flatMap((t=>{const{start:e,end:n}=t.range;return[{position:e,marker:t,type:"start"},{position:n,marker:t,type:"end"}]})).sort((({position:t},{position:e})=>t.isBefore(e)?1:-1));for(const{position:e,marker:i,type:r}of o){const o=t.createElement("$marker",{"data-name":i.name,"data-type":r});n[i.name]||(n[i.name]=[]),n[i.name].push(o),t.insert(o,e)}return n}_removeFakeMarkersInsideElement(t,e){const n=this._getAllFakeMarkersFromElement(t,e).reduce(((e,n)=>{const o=n.markerElement&&t.createPositionBefore(n.markerElement);let i=e[n.name],r=!1;return i&&i.start&&i.end&&(this._getMarkerClipboardConfig(n.name).duplicateOnPaste?e[this._getUniqueMarkerName(n.name)]=e[n.name]:r=!0,i=null),r||(e[n.name]={...i,[n.type]:o}),n.markerElement&&t.remove(n.markerElement),e}),{});return Ck(n,(n=>new Aa(n.start||t.createPositionFromPath(e,[0]),n.end||t.createPositionAt(e,"end"))))}_getAllFakeMarkersFromElement(t,e){const n=Array.from(t.createRangeIn(e)).flatMap((({item:t})=>{if(!t.is("element","$marker"))return[];const e=t.getAttribute("data-name"),n=t.getAttribute("data-type");return[{markerElement:t,name:e,type:n}]})),o=[],i=[];for(const t of n)"end"===t.type&&(n.some((e=>e.name===t.name&&"start"===e.type))||o.push({markerElement:null,name:t.name,type:"start"})),"start"===t.type&&(n.some((e=>e.name===t.name&&"end"===e.type))||i.unshift({markerElement:null,name:t.name,type:"end"}));return[...o,...n,...i]}_getUniqueMarkerName(t){const e=t.split(":"),n=_n().substring(1,6);return 3===e.length?`${e.slice(0,2).join(":")}:${n}`:`${e.join(":")}:${n}`}}class Dk extends iu{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[Ek]}init(){this.editor.editing.view.addObserver(vk),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(t,e,n){const o=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===n},(()=>{const i=o._copySelectedFragmentWithMarkers(n,e);this.fire("outputTransformation",{dataTransfer:t,content:i,method:n})}))}_setupPasteDrop(){const t=this.editor,e=t.model,n=t.editing.view,o=n.document,i=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(o,"clipboardInput",((e,n)=>{"paste"!=n.method||t.model.canEditAt(t.model.document.selection)||e.stop()}),{priority:"highest"}),this.listenTo(o,"clipboardInput",((t,e)=>{const o=e.dataTransfer;let i;if(e.content)i=e.content;else{let t="";o.getData("text/html")?t=function(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>1==e.length?" ":e)).replace(//g,"")}(o.getData("text/html")):o.getData("text/plain")&&(((r=(r=o.getData("text/plain")).replace(/&/g,"&").replace(//g,">").replace(/\r?\n\r?\n/g,"
").replace(/\r?\n/g," ").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||r.includes(" "))&&(r=`
${r}
`),t=r),i=this.editor.data.htmlProcessor.toView(t)}var r;const s=new bn(this,"inputTransformation");this.fire(s,{content:i,dataTransfer:o,targetRanges:e.targetRanges,method:e.method}),s.stop.called&&t.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((t,n)=>{if(n.content.isEmpty)return;const o=this.editor.data.toModel(n.content,"$clipboardHolder");0!=o.childCount&&(t.stop(),e.change((()=>{this.fire("contentInsertion",{content:o,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((t,e)=>{e.resultRange=i._pasteFragmentWithMarkers(e.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,n=t.editing.view.document,o=(t,n)=>{const o=n.dataTransfer;n.preventDefault(),this._fireOutputTransformationEvent(o,e.selection,t.name)};this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",((e,n)=>{t.model.canEditAt(t.model.document.selection)?o(e,n):n.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((e,o)=>{const i=t.data.toView(o.content);n.fire("clipboardOutput",{dataTransfer:o.dataTransfer,content:i,method:o.method})}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,o)=>{o.content.isEmpty||(o.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(o.content)),o.dataTransfer.setData("text/plain",xk(o.content))),"cut"==o.method&&t.model.deleteContent(e.selection)}),{priority:"low"})}}const Sk=Eo("px");class Tk extends xh{constructor(){super();const t=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",t.if("isVisible","ck-hidden",(t=>!t))],style:{left:t.to("left",(t=>Sk(t))),top:t.to("top",(t=>Sk(t))),width:t.to("width",(t=>Sk(t)))}}})}}class Bk extends iu{removeDropMarkerDelayed=gi((()=>this.removeDropMarker()),40);_updateDropMarkerThrottled=$d((t=>this._updateDropMarker(t)),40);_reconvertMarkerThrottled=$d((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0);_dropTargetLineView=new Tk;_domEmitter=new(lo());_scrollables=new Map;static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:t}of this._scrollables.values())t.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(t,e,n,o,i,r){this.removeDropMarkerDelayed.cancel();const s=Ik(this.editor,t,e,n,o,i,r);if(s)return r&&r.containsRange(s)?this.removeDropMarker():void this._updateDropMarkerThrottled(s)}getFinalDropRange(t,e,n,o,i,r){const s=Ik(this.editor,t,e,n,o,i,r);return this.removeDropMarker(),s}removeDropMarker(){const t=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,t.markers.has("drop-target")&&t.change((t=>{t.removeMarker("drop-target")}))}_setupDropMarker(){const t=this.editor;t.ui.view.body.add(this._dropTargetLineView),t.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),t.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(e,{writer:n})=>{if(t.model.schema.checkChild(e.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(n);e.markerRange.isCollapsed?this._updateDropTargetLine(e.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(t){const e=this.editor,n=e.model.markers;e.model.change((e=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(t)||e.updateMarker("drop-target",{range:t}):e.addMarker("drop-target",{range:t,usingOperation:!1,affectsData:!1})}))}_createDropTargetPosition(t){return t.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);return e.append("",t.createElement("span"),""),e}))}_updateDropTargetLine(t){const e=this.editor.editing,n=t.start.nodeBefore,o=t.start.nodeAfter,i=t.start.parent,r=n?e.mapper.toViewElement(n):null,s=r?e.view.domConverter.mapViewToDom(r):null,a=o?e.mapper.toViewElement(o):null,c=a?e.view.domConverter.mapViewToDom(a):null,l=e.mapper.toViewElement(i);if(!l)return;const d=e.view.domConverter.mapViewToDom(l),u=this._getScrollableRect(l),{scrollX:h,scrollY:p}=en.window,m=s?new wo(s):null,g=c?new wo(c):null,f=new wo(d).excludeScrollbarsAndBorders(),k=m?m.bottom:f.top,b=g?g.top:f.bottom,w=en.window.getComputedStyle(d),_=k<=b?(k+b)/2:b;if(u.top<_&&_a.schema.checkChild(r,t)))){if(a.schema.checkChild(r,"$text"))return a.createRange(r);if(e)return Pk(t,Nk(t,e.parent),o,i)}}}else if(a.schema.isInline(l))return Pk(t,l,o,i);if(a.schema.isBlock(l))return Pk(t,l,o,i);if(a.schema.checkChild(l,"$block")){const e=Array.from(l.getChildren()).filter((e=>e.is("element")&&!Mk(t,e)));let n=0,r=e.length;if(0==r)return a.createRange(a.createPositionAt(l,"end"));for(;n{n?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),rn.isAndroid&&this.forceDisabled("noAndroidSupport"),t.plugins.has("BlockToolbar")){const e=t.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(e,"dragstart",((t,e)=>this._handleBlockDragStart(e))),this._domEmitter.listenTo(en.document,"dragover",((t,e)=>this._handleBlockDragging(e))),this._domEmitter.listenTo(en.document,"drop",((t,e)=>this._handleBlockDragging(e))),this._domEmitter.listenTo(en.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&e.setAttribute("draggable","true"),this.on("change:isEnabled",((t,n,o)=>{e.setAttribute("draggable",o?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(t){if(!this.isEnabled)return;const e=this.editor.model,n=e.document.selection,o=this.editor.editing.view,i=Array.from(n.getSelectedBlocks()),r=e.createRange(e.createPositionBefore(i[0]),e.createPositionAfter(i[i.length-1]));e.change((t=>t.setSelection(r))),this._isBlockDragging=!0,o.focus(),o.getObserver(vk).onDomEvent(t)}_handleBlockDragging(t){if(!this.isEnabled||!this._isBlockDragging)return;const e=t.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),n=t.clientY,o=document.elementFromPoint(e,n),i=this.editor.editing.view;o&&o.closest(".ck-editor__editable")&&i.getObserver(vk).onDomEvent({...t,type:t.type,dataTransfer:t.dataTransfer,target:o,clientX:e,clientY:n,preventDefault:()=>t.preventDefault(),stopPropagation:()=>t.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class Lk extends iu{_draggedRange;_draggingUid;_draggableElement;_clearDraggableAttributesDelayed=gi((()=>this._clearDraggableAttributes()),40);_blockMode=!1;_domEmitter=new(lo());_previewContainer;static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[Dk,dk,Bk,zk]}init(){const t=this.editor,e=t.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,e.addObserver(vk),e.addObserver(sd),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(t,"change:isReadOnly",((t,e,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((t,e,n)=>{n||this._finalizeDragging(!1)})),rn.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const t=this.editor,e=t.model,n=t.editing.view,o=n.document,i=t.plugins.get(Bk);this.listenTo(o,"dragstart",((t,n)=>{if(n.target&&n.target.is("editableElement"))return void n.preventDefault();if(this._prepareDraggedRange(n.target),!this._draggedRange)return void n.preventDefault();this._draggingUid=_n(),n.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",n.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const o=e.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(n.dataTransfer,o,"dragstart");const{dataTransfer:i,domTarget:r,domEvent:s}=n,{clientX:a}=s;this._updatePreview({dataTransfer:i,domTarget:r,clientX:a}),n.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((t,e)=>{this._finalizeDragging(!e.dataTransfer.isCanceled&&"move"==e.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(en.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(o,"dragleave",(()=>{i.removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,e)=>{if(!this.isEnabled)return void(e.dataTransfer.dropEffect="none");const{clientX:n,clientY:o}=e.domEvent;i.updateDropMarker(e.target,e.targetRanges,n,o,this._blockMode,this._draggedRange),this._draggedRange||(e.dataTransfer.dropEffect="copy"),rn.isGecko||("copy"==e.dataTransfer.effectAllowed?e.dataTransfer.dropEffect="copy":["all","copyMove"].includes(e.dataTransfer.effectAllowed)&&(e.dataTransfer.dropEffect="move")),t.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor,e=t.editing.view.document,n=t.plugins.get(Bk);this.listenTo(e,"clipboardInput",((e,o)=>{if("drop"!=o.method)return;const{clientX:i,clientY:r}=o.domEvent,s=n.getFinalDropRange(o.target,o.targetRanges,i,r,this._blockMode,this._draggedRange);return s?(this._draggedRange&&this._draggingUid!=o.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),"move"==Rk(o.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(s,!0)?(this._finalizeDragging(!1),void e.stop()):void(o.targetRanges=[t.editing.mapper.toViewRange(s)])):(this._finalizeDragging(!1),void e.stop())}),{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(Dk);t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n=e.targetRanges.map((t=>this.editor.editing.mapper.toModelRange(t)));this.editor.model.change((t=>t.setSelection(n)))}),{priority:"high"}),t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n="move"==Rk(e.dataTransfer),o=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(o&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor,e=t.editing.view,n=e.document;this.listenTo(n,"mousedown",((o,i)=>{if(rn.isAndroid||!i)return;this._clearDraggableAttributesDelayed.cancel();let r=Fk(i.target);if(rn.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();t&&$f(t)||(r=n.selection.editableElement)}r&&(e.change((t=>{t.setAttribute("draggable","true",r)})),this._draggableElement=t.editing.mapper.toModelElement(r))})),this.listenTo(n,"mouseup",(()=>{rn.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const t=this.editor.editing;t.view.change((e=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&e.removeAttribute("draggable",t.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_finalizeDragging(t){const e=this.editor,n=e.model;e.plugins.get(Bk).removeDropMarker(),this._clearDraggableAttributes(),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(t&&this.isEnabled&&n.change((t=>{const e=n.createSelection(this._draggedRange);n.deleteContent(e,{doNotAutoparagraph:!0});const o=e.getFirstPosition().parent;o.isEmpty&&!n.schema.checkChild(o,"$text")&&n.schema.checkChild(o,"paragraph")&&t.insertElement("paragraph",o,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(t){const e=this.editor,n=e.model,o=n.document.selection,i=t?Fk(t):null;if(i){const t=e.editing.mapper.toModelElement(i);return this._draggedRange=La.fromRange(n.createRangeOn(t)),this._blockMode=n.schema.isBlock(t),void(e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop"))}if(o.isCollapsed&&!o.getFirstPosition().parent.isEmpty)return;const r=Array.from(o.getSelectedBlocks()),s=o.getFirstRange();if(0==r.length)return void(this._draggedRange=La.fromRange(s));const a=jk(n,r);if(r.length>1)this._draggedRange=La.fromRange(a),this._blockMode=!0;else if(1==r.length){const t=s.start.isTouching(a.start)&&s.end.isTouching(a.end);this._draggedRange=La.fromRange(t?a:s),this._blockMode=t}n.change((t=>t.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:t,domTarget:e,clientX:n}){const o=this.editor.editing.view,i=o.document.selection.editableElement,r=o.domConverter.mapViewToDom(i),s=en.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=no(en.document,"div",{style:"position: fixed; left: -999999px;"}),en.document.body.appendChild(this._previewContainer));const a=new wo(r);if(r.contains(e))return;const c=parseFloat(s.paddingLeft),l=no(en.document,"div");l.className="ck ck-content",l.style.width=s.width,l.style.paddingLeft=`${a.left-n+c}px`,rn.isiOS&&(l.style.backgroundColor="white"),o.domConverter.setContentOf(l,t.getData("text/html")),t.setDragImage(l,0,0),this._previewContainer.appendChild(l)}}function Rk(t){return rn.isGecko?t.dropEffect:["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function Fk(t){if(t.is("editableElement"))return null;if(t.hasClass("ck-widget__selection-handle"))return t.findAncestor($f);if($f(t))return t;const e=t.findAncestor((t=>$f(t)||t.is("editableElement")));return $f(e)?e:null}function jk(t,e){const n=e[0],o=e[e.length-1],i=n.getCommonAncestor(o),r=t.createPositionBefore(n),s=t.createPositionAfter(o);if(i&&i.is("element")&&!t.schema.isLimit(i)){const e=t.createRangeOn(i),n=r.isTouching(e.start),o=s.isTouching(e.end);if(n&&o)return jk(t,[i])}return t.createRange(r,s)}class Vk extends iu{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[Dk]}init(){const t=this.editor,e=t.model,n=t.editing.view,o=e.document.selection;n.addObserver(vk),t.plugins.get(Dk).on("contentInsertion",((t,n)=>{(function(t,e){let n=e.createRangeIn(t);if(1==t.childCount){const o=t.getChild(0);o.is("element")&&e.schema.isBlock(o)&&!e.schema.isObject(o)&&!e.schema.isLimit(o)&&(n=e.createRangeIn(o))}for(const t of n.getItems()){if(!e.schema.isInline(t))return!1;if(Array.from(t.getAttributeKeys()).find((t=>e.schema.getAttributeProperties(t).isFormatting)))return!1}return!0})(n.content,e)&&e.change((t=>{const i=Array.from(o.getAttributes()).filter((([t])=>e.schema.getAttributeProperties(t).isFormatting));o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0}),i.push(...o.getAttributes());const r=t.createRangeIn(n.content);for(const n of r.getItems())for(const o of i)e.schema.checkAttribute(n,o[0])&&t.setAttribute(o[0],o[1],n)}))}))}}class Hk extends iu{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Ek,Dk,Lk,Vk]}init(){const t=this.editor,e=this.editor.t;t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Copy selected content"),keystroke:"CTRL+C"},{label:e("Paste content"),keystroke:"CTRL+V"},{label:e("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}function Uk(t){const e=t.t,n=t.config.get("codeBlock.languages");for(const t of n)"Plain text"===t.label&&(t.label=e("Plain text")),void 0===t.class&&(t.class=`language-${t.language}`);return n}function Wk(t,e,n){const o={};for(const i of t)"class"===e?o[i[e].split(" ").shift()]=i[n]:o[i[e]]=i[n];return o}function Gk(t){return t.data.match(/^(\s*)/)[0]}function qk(t){const e=t.document.selection,n=[];if(e.isCollapsed)return[e.anchor];const o=e.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:e}of o){let o=e.is("$textProxy")?e.textNode:e;const i=o.parent;if(!i.is("element","codeBlock")||o.is("element","softBreak"))continue;for(;o.previousSibling&&!o.previousSibling.is("element","softBreak");)o=o.previousSibling;const r=o.is("$text")?o.startOffset+Gk(o).length:o.startOffset,s=t.createPositionAt(i,r);n.every((t=>!t.isEqual(s)))&&n.push(s)}return n}function $k(t){const e=ai(t.getSelectedBlocks());return!!e&&e.is("element","codeBlock")}function Kk(t,e){return!e.is("rootElement")&&!t.isLimit(e)&&t.checkChild(e.parent,"codeBlock")}function Yk(t,e,n,o){const i=Wk(e,"language","label"),r=n.getAttribute("language");if(r in i){return t("enter"===o?"Entering %0 code snippet":"Leaving %0 code snippet",i[r])}return t("enter"===o?"Entering code snippet":"Leaving code snippet")}function Qk(t,e){for(t.textNode&&(t=e.createPositionBefore(t.textNode));t.nodeBefore&&!t.nodeBefore.is("element","softBreak");)t=e.createPositionBefore(t.nodeBefore);const n=t.nodeAfter;return n&&n.is("$text")?n:null}class Zk extends su{_lastLanguage;constructor(t){super(t),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor,n=e.model,o=n.document.selection,i=Uk(e)[0],r=Array.from(o.getSelectedBlocks()),s=null==t.forceValue?!this.value:t.forceValue,a=function(t,e,n){return t.language?t.language:t.usePreviousLanguageChoice&&e?e:n}(t,this._lastLanguage,i.language);n.change((t=>{s?this._applyCodeBlock(t,r,a):this._removeCodeBlock(t,r)}))}_getValue(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());return!(!t||!t.is("element","codeBlock"))&&t.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const t=this.editor.model.document.selection,e=this.editor.model.schema,n=ai(t.getSelectedBlocks());return!!n&&Kk(e,n)}_applyCodeBlock(t,e,n){this._lastLanguage=n;const o=this.editor.model.schema,i=e.filter((t=>Kk(o,t)));for(const e of i)t.rename(e,"codeBlock"),t.setAttribute("language",n,e),o.removeDisallowedAttributes([e],t),Array.from(e.getChildren()).filter((t=>!o.checkChild(e,t))).forEach((e=>t.remove(e)));i.reverse().forEach(((e,n)=>{const o=i[n+1];e.previousSibling===o&&(t.appendElement("softBreak",o),t.merge(t.createPositionBefore(e)))}))}_removeCodeBlock(t,e){const n=e.filter((t=>t.is("element","codeBlock")));for(const e of n){const n=t.createRangeOn(e);for(const e of Array.from(n.getItems()).reverse())if(e.is("element","softBreak")&&e.parent.is("element","codeBlock")){const{position:n}=t.split(t.createPositionBefore(e)),o=n.nodeAfter;t.rename(o,"paragraph"),t.removeAttribute("language",o),t.remove(e)}t.rename(e,"paragraph"),t.removeAttribute("language",e)}}}class Jk extends su{_indentSequence;constructor(t){super(t),this._indentSequence=t.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model;t.change((e=>{const n=qk(t);for(const o of n){const n=e.createText(this._indentSequence);t.insertContent(n,o)}}))}_checkEnabled(){return!!this._indentSequence&&$k(this.editor.model.document.selection)}}class Xk extends su{_indentSequence;constructor(t){super(t),this._indentSequence=t.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model;t.change((()=>{const e=qk(t);for(const n of e){const e=tb(t,n,this._indentSequence);e&&t.deleteContent(t.createSelection(e))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const t=this.editor.model;return!!$k(t.document.selection)&&qk(t).some((e=>tb(t,e,this._indentSequence)))}}function tb(t,e,n){const o=Qk(e,t);if(!o)return null;const i=Gk(o),r=i.lastIndexOf(n);if(r+n.length!==i.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=o;return t.createRange(t.createPositionAt(s,a+r),t.createPositionAt(s,a+r+n.length))}function eb(t,e,n=!1){const o=Wk(e,"language","class"),i=Wk(e,"language","label");return(e,r,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=c.toViewPosition(t.createPositionBefore(r.item)),h={};n&&(h["data-language"]=i[d],h.spellcheck="false");const p=o[d]?{class:o[d]}:void 0,m=a.createContainerElement("code",p),g=a.createContainerElement("pre",h,m);a.insert(u,g),c.bindElements(r.item,m)}}const nb="paragraph";class ob extends iu{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[zf]}constructor(t){super(t),t.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const t=this.editor,e=t.model.schema,n=t.model,o=t.editing.view,i=Uk(t);t.commands.add("codeBlock",new Zk(t)),t.commands.add("indentCodeBlock",new Jk(t)),t.commands.add("outdentCodeBlock",new Xk(t)),this.listenTo(o.document,"tab",((e,n)=>{const o=n.shiftKey?"outdentCodeBlock":"indentCodeBlock";t.commands.get(o).isEnabled&&(t.execute(o),n.stopPropagation(),n.preventDefault(),e.stop())}),{context:"pre"}),e.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),e.addAttributeCheck(((t,n)=>{const o=t.getItem(t.length-2);if(e.getAttributeProperties(n).isFormatting&&o&&"codeBlock"==o.name)return!1})),t.editing.downcastDispatcher.on("insert:codeBlock",eb(n,i,!0)),t.data.downcastDispatcher.on("insert:codeBlock",eb(n,i)),t.data.downcastDispatcher.on("insert:softBreak",function(t){return(e,n,o)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:i,mapper:r,consumable:s}=o;if(!s.consume(n.item,"insert"))return;const a=r.toViewPosition(t.createPositionBefore(n.item));i.insert(a,i.createText("\n"))}}(n),{priority:"high"}),t.data.upcastDispatcher.on("element:code",function(t,e){const n=Wk(e,"class","language"),o=e[0].language;return(t,e,i)=>{const r=e.viewItem,s=r.parent;if(!s||!s.is("element","pre"))return;if(e.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:c}=i;if(!a.test(r,{name:!0}))return;const l=c.createElement("codeBlock"),d=[...r.getClassNames()];d.length||d.push("");for(const t of d){const e=n[t];if(e){c.setAttribute("language",e,l);break}}l.hasAttribute("language")||c.setAttribute("language",o,l),i.convertChildren(r,l),i.safeInsert(l,e.modelCursor)&&(a.consume(r,{name:!0}),i.updateConversionResult(l,e))}}(0,i)),t.data.upcastDispatcher.on("text",((t,e,{consumable:n,writer:o})=>{let i=e.modelCursor;if(!n.test(e.viewItem))return;if(!i.findAncestor("codeBlock"))return;n.consume(e.viewItem);const r=e.viewItem.data.split("\n").map((t=>o.createText(t))),s=r[r.length-1];for(const t of r)if(o.insert(t,i),i=i.getShiftedBy(t.offsetSize),t!==s){const t=o.createElement("softBreak");o.insert(t,i),i=o.createPositionAfter(t)}e.modelRange=o.createRange(e.modelCursor,i),e.modelCursor=i})),t.data.upcastDispatcher.on("element:pre",((t,e,{consumable:n})=>{const o=e.viewItem;if(o.findAncestor("pre"))return;const i=Array.from(o.getChildren()),r=i.find((t=>t.is("element","code")));if(r)for(const t of i)t!==r&&t.is("$text")&&n.consume(t,{name:!0})}),{priority:"high"}),this.listenTo(t.editing.view.document,"clipboardInput",((e,o)=>{let i=n.createRange(n.document.selection.anchor);if(o.targetRanges&&(i=t.editing.mapper.toModelRange(o.targetRanges[0])),!i.start.parent.is("element","codeBlock"))return;const r=o.dataTransfer.getData("text/plain"),s=new ad(t.editing.view.document);o.content=function(t,e){const n=t.createDocumentFragment(),o=e.split("\n"),i=o.reduce(((e,n,i)=>(e.push(n),i{const i=t.model,r=i.document.selection;r.anchor.parent.is("element","codeBlock")&&i.change((t=>{const n=t.createRangeIn(o.content);for(const o of[...n.getItems()])o.is("node")&&!e.checkChild(r.anchor,o)&&t.remove(o)}))})),this.listenTo(n,"getSelectedContent",((t,[o])=>{const i=o.anchor;!o.isCollapsed&&i.parent.is("element","codeBlock")&&i.hasSameParentAs(o.focus)&&n.change((n=>{const r=t.return;if(i.parent.is("element")&&(r.childCount>1||o.containsEntireContent(i.parent))){const e=n.createElement("codeBlock",i.parent.getAttributes());n.append(r,e);const o=n.createDocumentFragment();return n.append(e,o),void(t.return=o)}const s=r.getChild(0);e.checkAttribute(s,"code")&&n.setAttribute("code",!0,s)}))}))}afterInit(){const t=this.editor,e=t.commands,n=e.get("indent"),o=e.get("outdent");n&&n.registerChildCommand(e.get("indentCodeBlock"),{priority:"highest"}),o&&o.registerChildCommand(e.get("outdentCodeBlock")),this.listenTo(t.editing.view.document,"enter",((e,n)=>{t.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(t,e){const n=t.model.document,o=t.editing.view,i=n.selection.getLastPosition(),r=i.nodeAfter;return!(e||!n.selection.isCollapsed||!i.isAtStart)&&(!!rb(r)&&(t.model.change((e=>{t.execute("enter");const o=n.selection.anchor.parent.previousSibling;e.rename(o,nb),e.setSelection(o,"in"),t.model.schema.removeDisallowedAttributes([o],e),e.remove(r)})),o.scrollToTheSelection(),!0))}(t,n.isSoft)||function(t,e){const n=t.model,o=n.document,i=t.editing.view,r=o.selection.getLastPosition(),s=r.nodeBefore;let a;if(e||!o.selection.isCollapsed||!r.isAtEnd||!s||!s.previousSibling)return!1;if(rb(s)&&rb(s.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling),n.createPositionAfter(s));else if(ib(s)&&rb(s.previousSibling)&&rb(s.previousSibling.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling),n.createPositionAfter(s));else{if(!(ib(s)&&rb(s.previousSibling)&&ib(s.previousSibling.previousSibling)&&s.previousSibling.previousSibling&&rb(s.previousSibling.previousSibling.previousSibling)))return!1;a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling.previousSibling),n.createPositionAfter(s))}return t.model.change((e=>{e.remove(a),t.execute("enter");const n=o.selection.anchor.parent;e.rename(n,nb),t.model.schema.removeDisallowedAttributes([n],e)})),i.scrollToTheSelection(),!0}(t,n.isSoft)||function(t){const e=t.model,n=e.document;let o;const i=Qk(n.selection.getLastPosition(),e);i&&i.is("$text")&&(o=Gk(i)),t.model.change((e=>{t.execute("shiftEnter"),o&&e.insertText(o,n.selection.anchor)}))}(t),n.preventDefault(),e.stop())}),{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:t,ui:e,t:n}=this.editor,o=Uk(this.editor);let i=null;t.document.selection.on("change:range",(()=>{const r=t.document.selection.focus.parent;e&&i!==r&&r.is("element")&&(i&&i.is("element","codeBlock")&&e.ariaLiveAnnouncer.announce(Yk(n,o,i,"leave")),r.is("element","codeBlock")&&e.ariaLiveAnnouncer.announce(Yk(n,o,r,"enter")),i=r)}))}}function ib(t){return t&&t.is("$text")&&!t.data.match(/\S/)}function rb(t){return t&&t.is("element","softBreak")}class sb extends iu{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t,n=t.ui.componentFactory,o=Uk(t),i=this._getLanguageListItemDefinitions(o),r=t.commands.get("codeBlock");n.add("codeBlock",(n=>{const o=jp(n,Fp),s=o.buttonView,a=e("Insert code block");return s.set({label:a,tooltip:!0,icon:yu.codeBlock,isToggleable:!0}),s.bind("isOn").to(r,"value",(t=>!!t)),s.on("execute",(()=>{t.execute("codeBlock",{usePreviousLanguageChoice:!0}),t.editing.view.focus()})),o.on("execute",(e=>{t.execute("codeBlock",{language:e.source._codeBlockLanguage,forceValue:!0}),t.editing.view.focus()})),o.class="ck-code-block-dropdown",o.bind("isEnabled").to(r),Up(o,i,{role:"menu",ariaLabel:a}),o})),n.add("menuBar:codeBlock",(n=>{const o=new tg(n);o.buttonView.set({role:"menuitem",label:e("Code block"),icon:yu.codeBlock}),o.bind("isEnabled").to(r);const s=new eg(n);s.set({ariaLabel:e("Insert code block")});for(const e of i){const i=new ym(n,o),a=new Yh(n);a.bind(...Object.keys(e.model)).to(e.model),a.set({isToggleable:!0,role:"menuitemcheckbox"}),a.delegate("execute").to(o),a.on("execute",(()=>{t.execute("codeBlock",{language:e.model._codeBlockLanguage,forceValue:r.value!=e.model._codeBlockLanguage}),t.editing.view.focus()})),i.children.add(a),s.items.add(i)}return o.panelView.children.add(s),o}))}_getLanguageListItemDefinitions(t){const e=this.editor.commands.get("codeBlock"),n=new si;for(const o of t){const t={type:"button",model:new Gm({_codeBlockLanguage:o.language,label:o.label,role:"menuitemradio",withText:!0})};t.model.bind("isOn").to(e,"value",(e=>e===t.model._codeBlockLanguage)),n.add(t)}return n}}class ab extends Fm{view;_toolbarConfig;_elementReplacer;constructor(t,e){super(t),this.view=e,this._toolbarConfig=Pp(t.config.get("toolbar")),this._elementReplacer=new Jn,this.listenTo(t.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(t){const e=this.editor,n=this.view,o=e.editing.view,i=n.editable,r=o.document.getRoot();i.name=r.rootName,n.render();const s=i.element;this.setEditableElement(i.name,s),n.editable.bind("isFocused").to(this.focusTracker),o.attachDomRoot(s),t&&this._elementReplacer.replace(t,this.element),this._initPlaceholder(),this._initToolbar(),n.menuBarView&&this._initMenuBar(n.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const t=this.view,e=this.editor.editing.view;this._elementReplacer.restore(),e.getDomRoot(t.editable.name)&&e.detachDomRoot(t.editable.name),t.destroy()}_initToolbar(){const t=this.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),t.stickyPanel.limiterElement=t.element,t.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:t})=>t||0)),t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(){const t=this.editor,e=t.editing.view,n=e.document.getRoot(),o=t.sourceElement;let i;const r=t.config.get("placeholder");r&&(i="string"==typeof r?r:r[this.view.editable.name]),!i&&o&&"textarea"===o.tagName.toLowerCase()&&(i=o.getAttribute("placeholder")),i&&(n.placeholder=i),Ar({view:e,element:n,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:t}=this.view,e=this.editor.plugins.get("ContextualBalloon");e.on("getPositionOptions",(e=>{const n=e.return;if(!n||!t.isSticky||!t.element)return;const o=new wo(t.element).height,i="function"==typeof n.target?n.target():n.target,r="function"==typeof n.limiter?n.limiter():n.limiter;if(i&&r&&new wo(i).height>=new wo(r).height-o)return;const s={...n.viewportOffsetConfig},a=(s.top||0)+o;e.return={...n,viewportOffsetConfig:{...s,top:a}}}),{priority:"low"});const n=()=>{e.visibleView&&e.updatePosition()};this.listenTo(t,"change:isSticky",n),this.listenTo(this.editor.ui,"change:viewportOffset",n)}_handleScrollToTheSelectionWithStickyPanel(t,e,n){const o=this.view.stickyPanel;if(o.isSticky){const t=new wo(o.element).height;e.viewportOffset.top+=t}else{const t=()=>{this.editor.editing.view.scrollToTheSelection(n)};this.listenTo(o,"change:isSticky",t),setTimeout((()=>{this.stopListening(o,"change:isSticky",t)}),20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const t=this.view.stickyPanel,e=this.editor.plugins.get("Dialog");e.on("show",(()=>{const n=e.view;n.on("moveTo",((e,o)=>{if(!t.isSticky||n.wasMoved||n.isModal)return;const i=new wo(t.contentPanelElement);o[1]t.updateSourceElement();O(o.submit)&&(n=o.submit,o.submit=()=>{i(),n.apply(o)}),o.addEventListener("submit",i),t.on("destroy",(()=>{o.removeEventListener("submit",i),n&&(o.submit=n)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(t,e={}){return new Promise((n=>{const o=new this(t,e);n(o.initPlugins().then((()=>o.ui.init(db(t)?t:null))).then((()=>o.data.init(o.config.get("initialData")))).then((()=>o.fire("ready"))).then((()=>o)))}))}}function db(t){return je(t)}class ub extends su{constructor(t){super(t),this.affectsData=!1}execute(){const t=this.editor.model,e=t.document.selection;let n=t.schema.getLimitElement(e);if(e.containsEntireContent(n)||!hb(t.schema,n))do{if(n=n.parent,!n)return}while(!hb(t.schema,n));t.change((t=>{t.setSelection(n,"in")}))}}function hb(t,e){return t.isLimit(e)&&(t.checkChild(e,"$text")||t.checkChild(e,"paragraph"))}const pb=Jo("Ctrl+A");class mb extends iu{static get pluginName(){return"SelectAllEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t,n=t.editing.view.document;t.commands.add("selectAll",new ub(t)),this.listenTo(n,"keydown",((e,n)=>{Zo(n)===pb&&(t.execute("selectAll"),n.preventDefault())})),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Select all"),keystroke:"CTRL+A"}]})}}class gb extends iu{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add("menuBar:selectAll",(()=>this._createButton(Yh)))}_createButton(t){const e=this.editor,n=e.locale,o=e.commands.get("selectAll"),i=new t(e.locale),r=n.t;return i.set({label:r("Select all"),icon:' ',keystroke:"Ctrl+A"}),i.bind("isEnabled").to(o,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),i}}class fb extends iu{static get requires(){return[mb,gb]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}class kb extends su{_stack=[];_createdBatches=new WeakSet;constructor(t){super(t),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(t.data,"set",((t,e)=>{e[1]={...e[1]};const n=e[1];n.batchType||(n.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(t.data,"set",((t,e)=>{e[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(t){const e=this.editor.model.document.selection,n={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(t,e,n){const o=this.editor.model,i=o.document,r=[],s=t.map((t=>t.getTransformedByOperations(n))),a=s.flat();for(const t of s){const e=t.filter((t=>t.root!=i.graveyard)).filter((t=>!wb(t,a)));e.length&&(bb(e),r.push(e[0]))}r.length&&o.change((t=>{t.setSelection(r,{backward:e})}))}_undo(t,e){const n=this.editor.model,o=n.document;this._createdBatches.add(e);const i=t.operations.slice().filter((t=>t.isDocumentOperation));i.reverse();for(const t of i){const i=t.baseVersion+1,r=Array.from(o.history.getOperations(i)),s=pl([t.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let i of s){const r=i.affectedSelectable;r&&!n.canEditAt(r)&&(i=new ol(i.baseVersion)),e.addOperation(i),n.applyOperation(i),o.history.setOperationAsUndone(t,i)}}}}function bb(t){t.sort(((t,e)=>t.start.isBefore(e.start)?-1:1));for(let e=1;ee!==t&&e.containsRange(t,!0)))}class _b extends kb{execute(t=null){const e=t?this._stack.findIndex((e=>e.batch==t)):this._stack.length-1,n=this._stack.splice(e,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,(()=>{this._undo(n.batch,o);const t=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,t)})),this.fire("revert",n.batch,o),this.refresh()}}class Cb extends kb{execute(){const t=this._stack.pop(),e=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(e,(()=>{const n=t.batch.operations[t.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(n);this._restoreSelection(t.selection.ranges,t.selection.isBackward,o),this._undo(t.batch,e)})),this.refresh()}}class vb extends iu{_undoCommand;_redoCommand;_batchRegistry=new WeakSet;static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t;this._undoCommand=new _b(t),this._redoCommand=new Cb(t),t.commands.add("undo",this._undoCommand),t.commands.add("redo",this._redoCommand),this.listenTo(t.model,"applyOperation",((t,e)=>{const n=e[0];if(!n.isDocumentOperation)return;const o=n.batch,i=this._redoCommand.createdBatches.has(o),r=this._undoCommand.createdBatches.has(o);this._batchRegistry.has(o)||(this._batchRegistry.add(o),o.isUndoable&&(i?this._undoCommand.addBatch(o):r||(this._undoCommand.addBatch(o),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((t,e,n)=>{this._redoCommand.addBatch(n)})),t.keystrokes.set("CTRL+Z","undo"),t.keystrokes.set("CTRL+Y","redo"),t.keystrokes.set("CTRL+SHIFT+Z","redo"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Undo"),keystroke:"CTRL+Z"},{label:e("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class Ab extends iu{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?yu.undo:yu.redo,i="ltr"==e.uiLanguageDirection?yu.redo:yu.undo;this._addButtonsToFactory("undo",n("Undo"),"CTRL+Z",o),this._addButtonsToFactory("redo",n("Redo"),"CTRL+Y",i)}_addButtonsToFactory(t,e,n,o){const i=this.editor;i.ui.componentFactory.add(t,(()=>{const i=this._createButton(Mh,t,e,n,o);return i.set({tooltip:!0}),i})),i.ui.componentFactory.add("menuBar:"+t,(()=>this._createButton(Yh,t,e,n,o)))}_createButton(t,e,n,o,i){const r=this.editor,s=r.locale,a=r.commands.get(e),c=new t(s);return c.set({label:n,icon:i,keystroke:o}),c.bind("isEnabled").to(a,"isEnabled"),this.listenTo(c,"execute",(()=>{r.execute(e),r.editing.view.focus()})),c}}class yb extends iu{static get requires(){return[vb,Ab]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}class xb extends xh{children;_findInputView;_replaceInputView;_findButtonView;_findPrevButtonView;_findNextButtonView;_advancedOptionsCollapsibleView;_matchCaseSwitchView;_wholeWordsOnlySwitchView;_replaceButtonView;_replaceAllButtonView;_inputsDivView;_actionButtonsDivView;_focusTracker;_keystrokes;_focusables;focusCycler;constructor(t){super(t);const e=t.t;this.children=this.createCollection(),this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",((t,e)=>t>0&&!e)),this._findInputView=this._createInputField(e("Find in text…")),this._findPrevButtonView=this._createButton({label:e("Previous result"),class:"ck-button-prev",icon:yu.previousArrow,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:e("Next result"),class:"ck-button-next",icon:yu.previousArrow,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(e("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:e("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:e("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:e("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new ci,this._keystrokes=new hi,this._focusables=new oh,this.focusCycler=new Nh({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Sh({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(t){-1===t?this.focusCycler.focusLast():this.focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createInputsDiv(){const t=this.locale,e=t.t,n=new xh(t);return this._findInputView.fieldView.on("input",(()=>{this.isDirty=!0})),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findPrevious:t})=>t)),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findNext:t})=>t)),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:t},e)=>t&&e)),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",((t,n)=>t||!n?"":e("Tip: Find some text first in order to replace it."))),n.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),n}_onFindButtonExecute(){if(this._textToFind)this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly});else{const t=this.t;this._findInputView.errorText=t("Text to find must not be empty.")}}_injectFindResultsCounter(){const t=this.locale,e=t.t,n=this.bindTemplate,o=new xh(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",((t,n)=>e("%0 of %1",[t,n]))),o.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",n.if("isDirty","ck-hidden")]},children:[{text:n.to("_resultsCounterText")}]});const i=()=>{const e=this._findInputView.fieldView.element;if(!e||!Io(e))return;const n=new wo(o.element).width,i="ltr"===t.uiLanguageDirection?"paddingRight":"paddingLeft";e.style[i]=n?`calc( 2 * var(--ck-spacing-standard) + ${n}px )`:""};this.on("change:_resultsCounterText",i,{priority:"low"}),this.on("change:isDirty",i,{priority:"low"}),this._findInputView.template.children[0].children.push(o)}_createAdvancedOptionsCollapsible(){const t=this.locale.t,e=new ap(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return e.set({label:t("Advanced options"),isCollapsed:!0}),e}_createActionButtonsDiv(){const t=new xh(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:t},e)=>t&&e)),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replaceAll:t},e)=>t&&e)),this._replaceButtonView.on("execute",(()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})})),this._replaceAllButtonView.on("execute",(()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()})),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),t.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),t}_createMatchCaseSwitch(){const t=this.locale.t,e=new np(this.locale);return e.set({label:t("Match case"),withText:!0}),e.bind("isOn").to(this,"_matchCase"),e.on("execute",(()=>{this._matchCase=!this._matchCase,this.isDirty=!0})),e}_createWholeWordsOnlySwitch(){const t=this.locale.t,e=new np(this.locale);return e.set({label:t("Whole words only"),withText:!0}),e.bind("isOn").to(this,"_wholeWordsOnly"),e.on("execute",(()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0})),e}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach((t=>{this._focusables.add(t),this._focusTracker.add(t.element)}))}_initKeystrokeHandling(){const t=t=>t.stopPropagation(),e=t=>{t.stopPropagation(),t.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",(t=>{e(t),this._findNextButtonView.fire("execute")})),this._keystrokes.set("shift+f3",(t=>{e(t),this._findPrevButtonView.fire("execute")})),this._keystrokes.set("enter",(t=>{const n=t.target;n===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),e(t)):n!==this._replaceInputView.fieldView.element||this.isDirty||(this._replaceButtonView.fire("execute"),e(t))})),this._keystrokes.set("shift+enter",(t=>{t.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),e(t))})),this._keystrokes.set("arrowright",t),this._keystrokes.set("arrowleft",t),this._keystrokes.set("arrowup",t),this._keystrokes.set("arrowdown",t)}_createButton(t){const e=new Mh(this.locale);return e.set(t),e}_createInputField(t,e){const n=new gp(this.locale,Kp);return n.label=t,n.class=e,n}}var Eb=' ';class Db extends iu{static get requires(){return[qh]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}formView;constructor(t){super(t),t.config.define("findAndReplace.uiType","dialog"),this.formView=null}init(){const t=this.editor,e="dropdown"===t.config.get("findAndReplace.uiType"),n=t.commands.get("find"),o=this.editor.t;t.ui.componentFactory.add("findAndReplace",(()=>{let o;return e?(o=this._createDropdown(),o.bind("isEnabled").to(n)):o=this._createDialogButtonForToolbar(),t.keystrokes.set("Ctrl+F",((e,i)=>{if(n.isEnabled){if(o instanceof Cp){const t=o.buttonView;t.isOn||t.fire("execute")}else o.isOn?t.plugins.get("Dialog").view.focus():o.fire("execute");i()}})),o})),e||t.ui.componentFactory.add("menuBar:findAndReplace",(()=>this._createDialogButtonForMenuBar())),t.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const t=this.editor,e=t.locale.t,n=jp(t.locale);return n.once("change:isOpen",(()=>{this.formView=this._createFormView(),this.formView.children.add(new Oh(t.locale,{label:e("Find and replace")}),0),n.panelView.children.add(this.formView)})),n.on("change:isOpen",((t,e,n)=>{n?this._setupFormView():this.fire("searchReseted")}),{priority:"low"}),n.buttonView.set({icon:Eb,label:e("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),n}_createDialogButtonForToolbar(){const t=this.editor,e=this._createButton(Mh),n=t.plugins.get("Dialog");return e.set({tooltip:!0}),e.bind("isOn").to(n,"id",(t=>"findAndReplace"===t)),e.on("execute",(()=>{e.isOn?n.hide():this._showDialog()})),e}_createDialogButtonForMenuBar(){const t=this._createButton(Yh),e=this.editor.plugins.get("Dialog"),n=this.editor.plugins.get("Dialog");return t.set({role:"menuitemcheckbox",isToggleable:!0}),t.bind("isOn").to(n,"id",(t=>"findAndReplace"===t)),t.on("execute",(()=>{"findAndReplace"!==e.id?this._showDialog():e.hide()})),t}_createButton(t){const e=this.editor,n=e.commands.get("find"),o=new t(e.locale),i=e.locale.t;return o.bind("isEnabled").to(n),o.set({icon:Eb,label:i("Find and replace"),keystroke:"CTRL+F"}),o}_showDialog(){const t=this.editor,e=t.plugins.get("Dialog"),n=t.locale.t;this.formView||(this.formView=this._createFormView()),e.show({id:"findAndReplace",title:n("Find and replace"),content:this.formView,position:Uh,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const t=this.editor,e=new(Dh(xb))(t.locale),n=t.commands,o=this.editor.plugins.get("FindAndReplaceEditing").state;e.bind("highlightOffset").to(o,"highlightedOffset"),e.listenTo(o.results,"change",(()=>{e.matchCount=o.results.length}));const i=n.get("findNext"),r=n.get("findPrevious"),s=n.get("replace"),a=n.get("replaceAll");return e.bind("_areCommandsEnabled").to(i,"isEnabled",r,"isEnabled",s,"isEnabled",a,"isEnabled",((t,e,n,o)=>({findNext:t,findPrevious:e,replace:n,replaceAll:o}))),e.delegate("findNext","findPrevious","replace","replaceAll").to(this),e.on("change:isDirty",((t,e,n)=>{n&&this.fire("searchReseted")})),e}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class Sb extends su{_state;constructor(t,e){super(t),this.isEnabled=!0,this.affectsData=!1,this._state=e}execute(t,{matchCase:e,wholeWords:n}={}){const{editor:o}=this,{model:i}=o,r=o.plugins.get("FindAndReplaceUtils");let s,a="";s="string"==typeof t?(...o)=>({results:r.findByTextCallback(t,{matchCase:e,wholeWords:n})(...o),searchText:t}):t;const c=s;s=(...t)=>{const e=c(...t);return e&&"searchText"in e&&(a=e.searchText),e};const l=i.document.getRootNames().reduce(((t,e)=>r.updateFindResultFromRange(i.createRangeIn(i.document.getRoot(e)),i,s,t)),null);return this._state.clear(i),this._state.results.addMany(l),this._state.highlightedResult=l.get(0),this._state.searchText=a,s&&(this._state.lastSearchCallback=s),this._state.matchCase=!!e,this._state.matchWholeWords=!!n,{results:l,findCallback:s}}}class Tb extends(qn()){constructor(t){super(),this.set("results",new si),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",((e,{removed:n,index:o})=>{if(Array.from(n).length){let e=!1;if(t.change((o=>{for(const i of n)this.highlightedResult===i&&(e=!0),t.markers.has(i.marker.name)&&o.removeMarker(i.marker)})),e){const t=o>=this.results.length?0:o;this.highlightedResult=this.results.get(t)}}})),this.on("change:highlightedResult",(()=>{this.refreshHighlightOffset(t)}))}clear(t){this.searchText="",t.change((e=>{if(this.highlightedResult){const n=this.highlightedResult.marker.name.split(":")[1],o=t.markers.get(`findResultHighlighted:${n}`);o&&e.removeMarker(o)}[...this.results].forEach((({marker:t})=>{e.removeMarker(t)}))})),this.results.clear()}refreshHighlightOffset(t){const{highlightedResult:e,results:n}=this;this.highlightedOffset=e?Bb(t,[...n]).indexOf(e)+1:0}}function Bb(t,e){const n={before:-1,same:0,after:1,different:1};return t.document.getRootNames().flatMap((t=>e.filter((e=>e.marker.getStart().root.rootName===t)).sort(((t,e)=>n[t.marker.getStart().compareWith(e.marker.getStart())]))))}class Ib extends su{_state;constructor(t,e){super(t),this.isEnabled=!0,this._state=e,this._isEnabledBasedOnSelection=!1}_replace(t,e){const{model:n}=this.editor,o=e.marker.getRange();n.canEditAt(o)&&n.change((i=>{if("$graveyard"===o.root.rootName)return void this._state.results.remove(e);let r={};for(const t of o.getItems())if(t.is("$text")||t.is("$textProxy")){r=t.getAttributes();break}n.insertContent(i.createText(t,r),o),this._state.results.has(e)&&this._state.results.remove(e)}))}}class Mb extends Ib{execute(t,e){const n=Math.max(this._state.highlightedOffset-1,0);if(this._replace(t,e),this._state.results.length){const t=Bb(this.editor.model,[...this._state.results]);this._state.highlightedResult=t[n%t.length]}}}class Pb extends Ib{execute(t,e){const{editor:n}=this,{model:o}=n,i=n.plugins.get("FindAndReplaceUtils"),r=e instanceof si?e:o.document.getRootNames().reduce(((t,n)=>i.updateFindResultFromRange(o.createRangeIn(o.document.getRoot(n)),o,i.findByTextCallback(e,this._state),t)),null);r.length&&o.change((()=>{[...r].forEach((e=>{this._replace(t,e)}))}))}}class Ob extends su{_state;constructor(t,e){super(t),this.affectsData=!1,this._state=e,this.isEnabled=!1,this.listenTo(this._state.results,"change",(()=>{this.isEnabled=this._state.results.length>1}))}refresh(){this.isEnabled=this._state.results.length>1}execute(){const t=this._state.results,e=t.getIndex(this._state.highlightedResult),n=e+1>=t.length?0:e+1;this._state.highlightedResult=this._state.results.get(n)}}class Nb extends Ob{execute(){const t=this._state.results.getIndex(this._state.highlightedResult),e=t-1<0?this._state.results.length-1:t-1;this._state.highlightedResult=this._state.results.get(e)}}class zb extends iu{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(t,e,n,o){const i=o||new si;return e.change((o=>{[...t].forEach((({type:t,item:r})=>{if("elementStart"===t&&e.schema.checkChild(r,"$text")){let t=n({item:r,text:this.rangeToText(e.createRangeIn(r))});if(!t)return;"results"in t&&(t=t.results),t.forEach((t=>{const e=`findResult:${_n()}`,n=o.addMarker(e,{usingOperation:!1,affectsData:!1,range:o.createRange(o.createPositionAt(r,t.start),o.createPositionAt(r,t.end))}),s=function(t,e){const n=t.find((({marker:t})=>e.getStart().isBefore(t.getStart())));return n?t.getIndex(n):t.length}(i,n);(t=>i.find((e=>{const{marker:n}=e,o=n.getRange(),i=t.getRange();return o.isEqual(i)})))(n)||i.add({id:e,label:t.label,marker:n},s)}))}}))})),i}rangeToText(t){return Array.from(t.getItems()).reduce(((t,e)=>e.is("$text")||e.is("$textProxy")?t+e.data:`${t}\n`),"")}findByTextCallback(t,e){let n="gu";e.matchCase||(n+="i");let o=`(${i=t,(i=Ni(i))&&Eu.test(i)?i.replace(xu,"\\$&"):i})`;var i;if(e.wholeWords){const e="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+e).test(t)||(o=`(^|${e}|_)${o}`),new RegExp(e+"$").test(t)||(o=`${o}(?=_|${e}|$)`)}const r=new RegExp(o,n);return function({text:t}){return[...t.matchAll(r)].map(Lb)}}}function Lb(t){const e=t.length-1;let n=t.index;return 3===t.length&&(n+=t[1].length),{label:t[e],start:n,end:n+t[e].length}}class Rb extends iu{static get requires(){return[zb]}static get pluginName(){return"FindAndReplaceEditing"}static get isOfficialPlugin(){return!0}state;init(){this.state=new Tb(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",((t,e,n,o)=>{const{model:i}=this.editor;i.change((t=>{if(o){const e=o.marker.name.split(":")[1],n=i.markers.get(`findResultHighlighted:${e}`);n&&t.removeMarker(n)}if(n){const e=n.marker.name.split(":")[1];t.addMarker(`findResultHighlighted:${e}`,{usingOperation:!1,affectsData:!1,range:n.marker.getRange()})}}))}));const t=nr(((t,e,n)=>{if(n){const t=this.editor.editing.view.domConverter,e=this.editor.editing.mapper.toViewRange(n.marker.getRange());zo({target:t.viewRangeToDom(e),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",t,{priority:"low"}),this.listenTo(this.editor,"destroy",t.cancel),this.on("change:_isSearchActive",((t,e,n)=>{n?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)}))}find(t,e){return this._isSearchActive=!0,this.editor.execute("find",t,e),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new Sb(this.editor,this.state)),this.editor.commands.add("findNext",new Ob(this.editor,this.state)),this.editor.commands.add("findPrevious",new Nb(this.editor,this.state)),this.editor.commands.add("replace",new Mb(this.editor,this.state)),this.editor.commands.add("replaceAll",new Pb(this.editor,this.state))}_defineConverters(){const{editor:t}=this;t.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:t})=>{const[,e]=t.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":e}}}}),t.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:t})=>{const[,e]=t.split(":");return{name:"span",classes:["ck-find-result_selected"],attributes:{"data-find-result":e}}}})}_onDocumentChange=()=>{const t=new Set,e=new Set,n=this.editor.model,{results:o}=this.state,i=n.document.differ.getChanges(),r=n.document.differ.getChangedMarkers();i.forEach((o=>{o.position&&("$text"===o.name||o.position.nodeAfter&&n.schema.isInline(o.position.nodeAfter)?(t.add(o.position.parent),[...n.markers.getMarkersAtPosition(o.position)].forEach((t=>{e.add(t.name)}))):"insert"===o.type&&o.position.nodeAfter&&t.add(o.position.nodeAfter))})),r.forEach((({name:t,data:{newRange:n}})=>{n&&"$graveyard"===n.start.root.rootName&&e.add(t)})),t.forEach((t=>{[...n.markers.getMarkersIntersectingRange(n.createRangeIn(t))].forEach((t=>e.add(t.name)))})),e.forEach((t=>{o.has(t)&&(o.get(t)===this.state.highlightedResult&&(this.state.highlightedResult=null),o.remove(t))}));const s=[],a=this.editor.plugins.get("FindAndReplaceUtils");t.forEach((t=>{const e=a.updateFindResultFromRange(n.createRangeOn(t),n,this.state.lastSearchCallback,o);s.push(...e)})),r.forEach((t=>{if(t.data.newRange){const e=a.updateFindResultFromRange(t.data.newRange,n,this.state.lastSearchCallback,o);s.push(...e)}})),!this.state.highlightedResult&&s.length?this.state.highlightedResult=s[0]:this.state.refreshHighlightOffset(n)}}class Fb extends su{attributeKey;constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute(this.attributeKey),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=t.value,i=t.batch,r=t=>{if(n.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,o):t.removeSelectionAttribute(this.attributeKey);else{const i=e.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const e of i)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}};i?e.enqueueChange(i,(t=>{r(t)})):e.change((t=>{r(t)}))}}const jb="fontSize",Vb="fontFamily",Hb="fontColor",Ub="fontBackgroundColor";function Wb(t,e){const n={model:{key:t,values:[]},view:{},upcastAlso:{}};for(const t of e)n.model.values.push(t.model),n.view[t.model]=t.view,t.upcastAlso&&(n.upcastAlso[t.model]=t.upcastAlso);return n}function Gb(t){return e=>e.getStyle(t).replace(/\s/g,"")}function qb(t){return(e,{writer:n})=>n.createAttributeElement("span",{style:`${t}:${e}`},{priority:7})}class $b extends Fb{constructor(t){super(t,Vb)}}function Kb(t){return t.map(Yb).filter((t=>void 0!==t))}function Yb(t){return"object"==typeof t?t:"default"===t?{title:"Default",model:void 0}:"string"==typeof t?function(t){const e=t.replace(/"|'/g,"").split(","),n=e[0],o=e.map(Qb).join(", ");return{title:n,model:o,view:{name:"span",styles:{"font-family":o},priority:7}}}(t):void 0}function Qb(t){return(t=t.trim()).indexOf(" ")>0&&(t=`'${t}'`),t}class Zb extends iu{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define(Vb,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Vb}),t.model.schema.setAttributeProperties(Vb,{isFormatting:!0,copyOnEnter:!0});const e=Kb(t.config.get("fontFamily.options")).filter((t=>t.model)),n=Wb(Vb,e);t.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):t.conversion.attributeToElement(n),t.commands.add(Vb,new $b(t))}_prepareAnyValueConverters(){const t=this.editor;t.conversion.for("downcast").attributeToElement({model:Vb,view:(t,{writer:e})=>e.createAttributeElement("span",{style:"font-family:"+t},{priority:7})}),t.conversion.for("upcast").elementToAttribute({model:{key:Vb,value:t=>t.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:Vb,value:t=>t.getAttribute("face")}})}}var Jb=' ';class Xb extends iu{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t,n=this._getLocalizedOptions(),o=t.commands.get(Vb),i=e("Font Family"),r=function(t,e){const n=new si;for(const o of t){const t={type:"button",model:new Gm({commandName:Vb,commandParam:o.model,label:o.title,role:"menuitemradio",withText:!0})};t.model.bind("isOn").to(e,"value",(t=>t===o.model||!(!t||!o.model)&&t.split(",")[0].replace(/'/g,"").toLowerCase()===o.model.toLowerCase())),o.view&&"string"!=typeof o.view&&o.view.styles&&t.model.set("labelStyle",`font-family: ${o.view.styles["font-family"]}`),n.add(t)}return n}(n,o);t.ui.componentFactory.add(Vb,(e=>{const n=jp(e);return Up(n,r,{role:"menu",ariaLabel:i}),n.buttonView.set({label:i,icon:Jb,tooltip:!0}),n.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()})),n})),t.ui.componentFactory.add(`menuBar:${Vb}`,(e=>{const n=new tg(e);n.buttonView.set({label:i,icon:Jb}),n.bind("isEnabled").to(o);const s=new eg(e);for(const o of r){const i=new ym(e,n),r=new Yh(e);r.set({role:"menuitemradio",isToggleable:!0}),r.bind(...Object.keys(o.model)).to(o.model),r.delegate("execute").to(n),r.on("execute",(()=>{t.execute(o.model.commandName,{value:o.model.commandParam}),t.editing.view.focus()})),i.children.add(r),s.items.add(i)}return n.panelView.children.add(s),n}))}_getLocalizedOptions(){const t=this.editor,e=t.t;return Kb(t.config.get(Vb).options).map((t=>("Default"===t.title&&(t.title=e("Default")),t)))}}class tw extends iu{static get requires(){return[Zb,Xb]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class ew extends Fb{constructor(t){super(t,jb)}}function nw(t){return t.map((t=>function(t){if("number"==typeof t&&(t=String(t)),"object"==typeof t&&((e=t).title&&e.model&&e.view))return iw(t);var e;const n=function(t){return"string"==typeof t?ow[t]:ow[t.model]}(t);return n?iw(n):"default"===t?{model:void 0,title:"Default"}:function(t){let e;if("object"==typeof t){if(!t.model)throw new An("font-size-invalid-definition",null,t);e=parseFloat(t.model)}else e=parseFloat(t);return isNaN(e)}(t)?void 0:function(t){return"string"==typeof t&&(t={title:t,model:`${parseFloat(t)}px`}),t.view={name:"span",styles:{"font-size":t.model}},iw(t)}(t)}(t))).filter((t=>void 0!==t))}const ow={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function iw(t){return t.view&&"string"!=typeof t.view&&!t.view.priority&&(t.view.priority=7),t}const rw=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class sw extends iu{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define(jb,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:jb}),t.model.schema.setAttributeProperties(jb,{isFormatting:!0,copyOnEnter:!0});const e=t.config.get("fontSize.supportAllValues"),n=nw(this.editor.config.get("fontSize.options")).filter((t=>t.model)),o=Wb(jb,n);e?(this._prepareAnyValueConverters(o),this._prepareCompatibilityConverter()):t.conversion.attributeToElement(o),t.commands.add(jb,new ew(t))}_prepareAnyValueConverters(t){const e=this.editor,n=t.model.values.filter((t=>!wd(String(t))&&!Cd(String(t))));if(n.length)throw new An("font-size-invalid-use-of-named-presets",null,{presets:n});e.conversion.for("downcast").attributeToElement({model:jb,view:(t,{writer:e})=>{if(t)return e.createAttributeElement("span",{style:"font-size:"+t},{priority:7})}}),e.conversion.for("upcast").elementToAttribute({model:{key:jb,value:t=>t.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:jb,value:t=>{const e=t.getAttribute("size"),n="-"===e[0]||"+"===e[0];let o=parseInt(e,10);n&&(o=3+o);const i=rw.length-1,r=Math.min(Math.max(o,0),i);return rw[r]}}})}}var aw=' ';class cw extends iu{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t,n=this._getLocalizedOptions(),o=t.commands.get(jb),i=e("Font Size"),r=function(t,e){const n=new si;for(const o of t){const t={type:"button",model:new Gm({commandName:jb,commandParam:o.model,label:o.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};o.view&&"string"!=typeof o.view&&(o.view.styles&&t.model.set("labelStyle",`font-size:${o.view.styles["font-size"]}`),o.view.classes&&t.model.set("class",`${t.model.class} ${o.view.classes}`)),t.model.bind("isOn").to(e,"value",(t=>t===o.model)),n.add(t)}return n}(n,o);t.ui.componentFactory.add(jb,(e=>{const n=jp(e);return Up(n,r,{role:"menu",ariaLabel:i}),n.buttonView.set({label:i,icon:aw,tooltip:!0}),n.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),n.bind("isEnabled").to(o),this.listenTo(n,"execute",(e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()})),n})),t.ui.componentFactory.add(`menuBar:${jb}`,(e=>{const n=new tg(e);n.buttonView.set({label:i,icon:aw}),n.bind("isEnabled").to(o);const s=new eg(e);for(const o of r){const i=new ym(e,n),r=new Yh(e);r.set({role:"menuitemradio",isToggleable:!0}),r.bind(...Object.keys(o.model)).to(o.model),r.delegate("execute").to(n),r.on("execute",(()=>{t.execute(o.model.commandName,{value:o.model.commandParam}),t.editing.view.focus()})),i.children.add(r),s.items.add(i)}return n.panelView.children.add(s),n}))}_getLocalizedOptions(){const t=this.editor,e=t.t,n={Default:e("Default"),Tiny:e("Tiny"),Small:e("Small"),Big:e("Big"),Huge:e("Huge")};return nw(t.config.get(jb).options).map((t=>{const e=n[t.title];return e&&e!=t.title&&(t=Object.assign({},t,{title:e})),t}))}}class lw extends iu{static get requires(){return[sw,cw]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(t){return nw(t)}}class dw extends Fb{constructor(t){super(t,Hb)}}class uw extends iu{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define(Hb,{colors:[{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"}],columns:5}),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:Hb,value:Gb("color")}}),t.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Hb,value:t=>t.getAttribute("color")}}),t.conversion.for("downcast").attributeToElement({model:Hb,view:qb("color")}),t.commands.add(Hb,new dw(t)),t.model.schema.extend("$text",{allowAttributes:Hb}),t.model.schema.setAttributeProperties(Hb,{isFormatting:!0,copyOnEnter:!0})}}class hw extends iu{commandName;componentName;icon;dropdownLabel;columns;constructor(t,{commandName:e,componentName:n,icon:o,dropdownLabel:i}){super(t),this.commandName=e,this.componentName=n,this.icon=o,this.dropdownLabel=i,this.columns=t.config.get(`${this.componentName}.columns`)}init(){const t=this.editor,e=t.locale,n=e.t,o=t.commands.get(this.commandName),i=t.config.get(this.componentName),r=cp(e,lp(i.colors)),s=i.documentColors,a=!1!==i.colorPicker;t.ui.componentFactory.add(this.componentName,(e=>{const c=jp(e);let l=!1;const d=function({dropdownView:t,colors:e,columns:n,removeButtonLabel:o,colorPickerLabel:i,documentColorsLabel:r,documentColorsCount:s,colorPickerViewConfig:a}){const c=t.locale,l=new sm(c,{colors:e,columns:n,removeButtonLabel:o,colorPickerLabel:i,documentColorsLabel:r,documentColorsCount:s,colorPickerViewConfig:a});return t.colorSelectorView=l,t.panelView.children.add(l),l}({dropdownView:c,colors:r.map((t=>({label:t.label,color:t.model,options:{hasBorder:t.hasBorder}}))),columns:this.columns,removeButtonLabel:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:0!==s?n("Document colors"):"",documentColorsCount:void 0===s?this.columns:s,colorPickerViewConfig:!!a&&(i.colorPicker||{})});return d.bind("selectedColor").to(o,"value"),c.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),c.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),c.bind("isEnabled").to(o),d.on("execute",((e,n)=>{c.isOpen&&t.execute(this.commandName,{value:n.value,batch:this._undoStepBatch}),"colorPicker"!==n.source&&t.editing.view.focus(),"colorPickerSaveButton"===n.source&&(c.isOpen=!1)})),d.on("colorPicker:show",(()=>{this._undoStepBatch=t.model.createBatch()})),d.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(c.isOpen=!1,t.execute("undo",this._undoStepBatch)),t.editing.view.focus()})),c.on("change:isOpen",((e,n,o)=>{l||(l=!0,c.colorSelectorView.appendUI()),o&&(0!==s&&d.updateDocumentColors(t.model,this.componentName),d.updateSelectedColors(),d.showColorGridsFragment())})),Gp(c,(()=>c.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((t=>t.isOn)))),c})),t.ui.componentFactory.add(`menuBar:${this.componentName}`,(e=>{const i=new tg(e);i.buttonView.set({label:this.dropdownLabel,icon:this.icon}),i.bind("isEnabled").to(o);let a=!1;const c=new sm(e,{colors:r.map((t=>({label:t.label,color:t.model,options:{hasBorder:t.hasBorder}}))),columns:this.columns,removeButtonLabel:n("Remove color"),colorPickerLabel:n("Color picker"),documentColorsLabel:0!==s?n("Document colors"):"",documentColorsCount:void 0===s?this.columns:s,colorPickerViewConfig:!1});return c.bind("selectedColor").to(o,"value"),c.delegate("execute").to(i),c.on("execute",((e,n)=>{t.execute(this.commandName,{value:n.value,batch:this._undoStepBatch}),t.editing.view.focus()})),i.on("change:isOpen",((e,n,o)=>{a||(a=!0,c.appendUI()),o&&(0!==s&&c.updateDocumentColors(t.model,this.componentName),c.updateSelectedColors(),c.showColorGridsFragment())})),i.panelView.children.add(c),i}))}}class pw extends hw{constructor(t){const e=t.locale.t;super(t,{commandName:Hb,componentName:Hb,icon:' ',dropdownLabel:e("Font Color")})}static get pluginName(){return"FontColorUI"}}class mw extends iu{static get requires(){return[uw,pw]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class gw extends Fb{constructor(t){super(t,Ub)}}class fw extends iu{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define(Ub,{colors:[{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"}],columns:5}),t.data.addStyleProcessorRules(Od),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:Ub,value:Gb("background-color")}}),t.conversion.for("downcast").attributeToElement({model:Ub,view:qb("background-color")}),t.commands.add(Ub,new gw(t)),t.model.schema.extend("$text",{allowAttributes:Ub}),t.model.schema.setAttributeProperties(Ub,{isFormatting:!0,copyOnEnter:!0})}}class kw extends hw{constructor(t){const e=t.locale.t;super(t,{commandName:Ub,componentName:Ub,icon:' ',dropdownLabel:e("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class bw extends iu{static get requires(){return[fw,kw]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}class ww extends su{constructor(t){super(t),this._isEnabledBasedOnSelection=!1}refresh(){const t=this.editor.model,e=ai(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("element","paragraph"),this.isEnabled=!!e&&_w(e,t.schema)}execute(t={}){const e=this.editor.model,n=e.document,o=t.selection||n.selection;e.canEditAt(o)&&e.change((t=>{const n=o.getSelectedBlocks();for(const o of n)!o.is("element","paragraph")&&_w(o,e.schema)&&t.rename(o,"paragraph")}))}}function _w(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class Cw extends su{constructor(t){super(t),this._isEnabledBasedOnSelection=!1}execute(t){const e=this.editor.model,n=t.attributes;let o=t.position;return e.canEditAt(o)?e.change((t=>{if(o=this._findPositionToInsertParagraph(o,t),!o)return null;const i=t.createElement("paragraph");return n&&e.schema.setAllowedAttributes(i,n,t),e.insertContent(i,o),t.setSelection(i,"in"),t.createPositionAt(i,0)})):null}_findPositionToInsertParagraph(t,e){const n=this.editor.model;if(n.schema.checkChild(t,"paragraph"))return t;const o=n.schema.findAllowedParent(t,"paragraph");if(!o)return null;const i=t.parent,r=n.schema.checkChild(i,"$text");return i.isEmpty||r&&t.isAtEnd?n.createPositionAfter(i):!i.isEmpty&&r&&t.isAtStart?n.createPositionBefore(i):e.split(t,o).position}}class vw extends iu{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.model;t.commands.add("paragraph",new ww(t)),t.commands.add("insertParagraph",new Cw(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,{writer:e})=>vw.paragraphLikeElements.has(t.name)?t.isEmpty?null:e.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}static paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"])}class Aw extends su{modelElements;constructor(t,e){super(t),this.modelElements=e}refresh(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some((e=>yw(t,e,this.editor.model.schema)))}execute(t){const e=this.editor.model,n=e.document,o=t.value;e.change((t=>{const i=Array.from(n.selection.getSelectedBlocks()).filter((t=>yw(t,o,e.schema)));for(const e of i)e.is("element",o)||t.rename(e,o)}))}}function yw(t,e,n){return n.checkChild(t.parent,e)&&!n.isObject(t)}const xw="paragraph";class Ew extends iu{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[vw]}init(){const t=this.editor,e=t.config.get("heading.options"),n=[];for(const o of e)"paragraph"!==o.model&&(t.model.schema.register(o.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new Aw(t,n))}afterInit(){const t=this.editor,e=t.commands.get("enter"),n=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",((e,o)=>{const i=t.model.document.selection.getFirstPosition().parent;n.some((t=>i.is("element",t.model)))&&!i.is("element",xw)&&0===i.childCount&&o.writer.rename(i,xw)}))}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:Cn.low+1})}}class Dw extends iu{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t,n=function(t){const e=t.t,n={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return t.config.get("heading.options").map((t=>{const e=n[t.title];return e&&e!=t.title&&(t.title=e),t}))}(t),o=e("Choose heading"),i=e("Heading");t.ui.componentFactory.add("heading",(e=>{const r={},s=new si,a=t.commands.get("heading"),c=t.commands.get("paragraph"),l=[a];for(const t of n){const e={type:"button",model:new Gm({label:t.title,class:t.class,role:"menuitemradio",withText:!0})};"paragraph"===t.model?(e.model.bind("isOn").to(c,"value"),e.model.set("commandName","paragraph"),l.push(c)):(e.model.bind("isOn").to(a,"value",(e=>e===t.model)),e.model.set({commandName:"heading",commandValue:t.model})),s.add(e),r[t.model]=t.title}const d=jp(e);return Up(d,s,{ariaLabel:i,role:"menu"}),d.buttonView.set({ariaLabel:i,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:i}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...t)=>t.some((t=>t)))),d.buttonView.bind("label").to(a,"value",c,"value",((t,e)=>{const n=e?"paragraph":t;return"boolean"==typeof n?o:r[n]?r[n]:o})),d.buttonView.bind("ariaLabel").to(a,"value",c,"value",((t,e)=>{const n=e?"paragraph":t;return"boolean"==typeof n?i:r[n]?`${r[n]}, ${i}`:i})),this.listenTo(d,"execute",(e=>{const{commandName:n,commandValue:o}=e.source;t.execute(n,o?{value:o}:void 0),t.editing.view.focus()})),d})),t.ui.componentFactory.add("menuBar:heading",(o=>{const i=new tg(o),r=t.commands.get("heading"),s=t.commands.get("paragraph"),a=[r],c=new eg(o);i.set({class:"ck-heading-dropdown"}),c.set({ariaLabel:e("Heading"),role:"menu"}),i.buttonView.set({label:e("Heading")}),i.panelView.children.add(c);for(const e of n){const n=new ym(o,i),l=new Yh(o);n.children.add(l),c.items.add(n),l.set({isToggleable:!0,label:e.title,role:"menuitemradio",class:e.class}),l.delegate("execute").to(i),l.on("execute",(()=>{const n="paragraph"===e.model?"paragraph":"heading";t.execute(n,{value:e.model}),t.editing.view.focus()})),"paragraph"===e.model?(l.bind("isOn").to(s,"value"),a.push(s)):l.bind("isOn").to(r,"value",(t=>t===e.model))}return i.bind("isEnabled").toMany(a,"isEnabled",((...t)=>t.some((t=>t)))),i}))}}class Sw extends iu{static get requires(){return[Ew,Dw]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class Tw extends su{refresh(){const t=this.editor.model,e=t.schema,n=t.document.selection;this.isEnabled=function(t,e,n){const o=function(t,e){const n=Xf(t,e).start.parent;return n.isEmpty&&!n.is("element","$root")?n.parent:n}(t,n);return e.checkChild(o,"horizontalLine")}(n,e,t)}execute(){const t=this.editor.model;t.change((e=>{const n=e.createElement("horizontalLine");t.insertObject(n,null,null,{setSelection:"after"})}))}}class Bw extends iu{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.model.schema,n=t.t,o=t.conversion;e.register("horizontalLine",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToElement({model:"horizontalLine",view:(t,{writer:e})=>e.createEmptyElement("hr")}),o.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(t,{writer:e})=>{const o=n("Horizontal line"),i=e.createContainerElement("div",null,e.createEmptyElement("hr"));return e.addClass("ck-horizontal-line",i),e.setCustomProperty("hr",!0,i),function(t,e,n){return e.setCustomProperty("horizontalLine",!0,t),Kf(t,e,{label:n})}(i,e,o)}}),o.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),t.commands.add("horizontalLine",new Tw(t))}}class Iw extends iu{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add("horizontalLine",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add("menuBar:horizontalLine",(()=>this._createButton(Yh)))}_createButton(t){const e=this.editor,n=e.locale,o=e.commands.get("horizontalLine"),i=new t(e.locale),r=n.t;return i.set({label:r("Horizontal line"),icon:yu.horizontalLine}),i.bind("isEnabled").to(o,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),i}}class Mw extends su{refresh(){const t=this.editor.model,e=t.schema,n=t.document.selection,o=Pw(n);this.isEnabled=function(t,e,n){const o=function(t,e){const n=Xf(t,e).start.parent;return n.isEmpty&&!n.is("rootElement")?n.parent:n}(t,n);return e.checkChild(o,"rawHtml")}(n,e,t),this.value=o?o.getAttribute("value")||"":null}execute(t){const e=this.editor.model,n=e.document.selection;e.change((o=>{let i;null!==this.value?i=Pw(n):(i=o.createElement("rawHtml"),e.insertObject(i,null,null,{setSelection:"on"})),o.setAttribute("value",t,i)}))}}function Pw(t){const e=t.getSelectedElement();return e&&e.is("element","rawHtml")?e:null}class Ow extends iu{_widgetButtonViewReferences=new Set;static get pluginName(){return"HtmlEmbedEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:t=>(yn("html-embed-provide-sanitize-function"),{html:t,hasChanged:!1})})}init(){const t=this.editor;t.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),t.commands.add("htmlEmbed",new Mw(t)),this._setupConversion()}_setupConversion(){const t=this.editor,e=t.t,n=t.editing.view,o=this._widgetButtonViewReferences,i=t.config.get("htmlEmbed");function r({editor:t,domElement:n,state:i,props:r}){n.textContent="";const a=n.ownerDocument;let c;if(i.isEditable){const t={isDisabled:!1,placeholder:r.textareaPlaceholder};c=s({domDocument:a,state:i,props:t}),n.append(c)}else if(i.showPreviews){const o={sanitizeHtml:r.sanitizeHtml};n.append(function({editor:t,domDocument:n,state:o,props:i}){const r=i.sanitizeHtml(o.getRawHtmlValue()),s=no(n,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},o.getRawHtmlValue().length>0?e("No preview available"):e("Empty snippet content")),a=no(n,"div",{class:"raw-html-embed__preview-content",dir:t.locale.contentLanguageDirection}),c=n.createRange().createContextualFragment(r.html);a.appendChild(c);return no(n,"div",{class:"raw-html-embed__preview"},[s,a])}({domDocument:a,state:i,props:o,editor:t}))}else{const t={isDisabled:!0,placeholder:r.textareaPlaceholder};n.append(s({domDocument:a,state:i,props:t}))}const l={onEditClick:r.onEditClick,onSaveClick:()=>{r.onSaveClick(c.value)},onCancelClick:r.onCancelClick};n.prepend(function({editor:t,domDocument:e,state:n,props:i}){const r=no(e,"div",{class:"raw-html-embed__buttons-wrapper"});if(n.isEditable){const e=Nw(t,"save",i.onSaveClick),n=Nw(t,"cancel",i.onCancelClick);r.append(e.element,n.element),o.add(e).add(n)}else{const e=Nw(t,"edit",i.onEditClick);r.append(e.element),o.add(e)}return r}({editor:t,domDocument:a,state:i,props:l}))}function s({domDocument:t,state:e,props:n}){const o=no(t,"textarea",{placeholder:n.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return o.disabled=n.isDisabled,o.value=e.getRawHtmlValue(),o}this.editor.editing.view.on("render",(()=>{for(const t of o){if(t.element&&t.element.isConnected)return;t.destroy(),o.delete(t)}}),{priority:"lowest"}),t.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),t.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(t,{writer:e})=>e.createElement("rawHtml",{value:t.getCustomProperty("$rawContent")})}),t.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(t,{writer:e})=>e.createRawElement("div",{class:"raw-html-embed"},(function(e){e.innerHTML=t.getAttribute("value")||""}))}),t.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(o,{writer:s})=>{let a,c,l;const d=s.createRawElement("div",{class:"raw-html-embed__content-wrapper"},(function(e){a=e,r({editor:t,domElement:e,state:c,props:l}),a.addEventListener("mousedown",(()=>{if(c.isEditable){const e=t.model;e.document.selection.getSelectedElement()!==o&&e.change((t=>t.setSelection(o,"on")))}}),!0)})),u={makeEditable(){c=Object.assign({},c,{isEditable:!0}),r({domElement:a,editor:t,state:c,props:l}),n.change((t=>{t.setAttribute("data-cke-ignore-events","true",d)})),a.querySelector("textarea").focus()},save(e){e!==c.getRawHtmlValue()?(t.execute("htmlEmbed",e),t.editing.view.focus()):this.cancel()},cancel(){c=Object.assign({},c,{isEditable:!1}),r({domElement:a,editor:t,state:c,props:l}),t.editing.view.focus(),n.change((t=>{t.removeAttribute("data-cke-ignore-events",d)}))}};c={showPreviews:i.showPreviews,isEditable:!1,getRawHtmlValue:()=>o.getAttribute("value")||""},l={sanitizeHtml:i.sanitizeHtml,textareaPlaceholder:e("Paste raw HTML here..."),onEditClick(){u.makeEditable()},onSaveClick(t){u.save(t)},onCancelClick(){u.cancel()}};const h=s.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":e("HTML snippet"),dir:t.locale.uiLanguageDirection},d);return s.setCustomProperty("rawHtmlApi",u,h),s.setCustomProperty("rawHtml",!0,h),Kf(h,s,{label:e("HTML snippet"),hasSelectionHandle:!0})}})}}function Nw(t,e,n){const{t:o}=t.locale,i=new Mh(t.locale),r=t.commands.get("htmlEmbed");return i.set({class:`raw-html-embed__${e}-button`,icon:yu.pencil,tooltip:!0,tooltipPosition:"rtl"===t.locale.uiLanguageDirection?"e":"w"}),i.render(),"edit"===e?(i.set({icon:yu.pencil,label:o("Edit source")}),i.bind("isEnabled").to(r)):"save"===e?(i.set({icon:yu.check,label:o("Save changes")}),i.bind("isEnabled").to(r)):i.set({icon:yu.cancel,label:o("Cancel")}),i.on("execute",n),i}class zw extends iu{static get pluginName(){return"HtmlEmbedUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t;t.ui.componentFactory.add("htmlEmbed",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0,label:e("Insert HTML")}),t})),t.ui.componentFactory.add("menuBar:htmlEmbed",(()=>{const t=this._createButton(Yh);return t.set({label:e("HTML snippet")}),t}))}_createButton(t){const e=this.editor,n=e.commands.get("htmlEmbed"),o=new t(e.locale);return o.set({icon:yu.html}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("htmlEmbed"),e.editing.view.focus(),e.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()})),o}}var Lw,Rw,Fw=(Lw={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},function(t){return null==Lw?void 0:Lw[t]}),jw=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Vw=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g"),Hw=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Uw=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ww="\\ud800-\\udfff",Gw="\\u2700-\\u27bf",qw="a-z\\xdf-\\xf6\\xf8-\\xff",$w="A-Z\\xc0-\\xd6\\xd8-\\xde",Kw="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Yw="["+Kw+"]",Qw="\\d+",Zw="["+Gw+"]",Jw="["+qw+"]",Xw="[^"+Ww+Kw+Qw+Gw+qw+$w+"]",t_="(?:\\ud83c[\\udde6-\\uddff]){2}",e_="[\\ud800-\\udbff][\\udc00-\\udfff]",n_="["+$w+"]",o_="(?:"+Jw+"|"+Xw+")",i_="(?:"+n_+"|"+Xw+")",r_="(?:['’](?:d|ll|m|re|s|t|ve))?",s_="(?:['’](?:D|LL|M|RE|S|T|VE))?",a_="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",c_="[\\ufe0e\\ufe0f]?",l_=c_+a_+"(?:\\u200d(?:"+["[^"+Ww+"]",t_,e_].join("|")+")"+c_+a_+")*",d_="(?:"+[Zw,t_,e_].join("|")+")"+l_,u_=RegExp([n_+"?"+Jw+"+"+r_+"(?="+[Yw,n_,"$"].join("|")+")",i_+"+"+s_+"(?="+[Yw,n_+o_,"$"].join("|")+")",n_+"?"+o_+"+"+r_,n_+"+"+s_,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Qw,d_].join("|"),"g"),h_=function(t,e,n){return t=Ni(t),void 0===(e=n?void 0:e)?function(t){return Uw.test(t)}(t)?function(t){return t.match(u_)||[]}(t):function(t){return t.match(Hw)||[]}(t):t.match(e)||[]},p_=RegExp("['’]","g"),m_=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),g_=function(t){return m_.test(t)},f_="\\ud800-\\udfff",k_="["+f_+"]",b_="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",w_="\\ud83c[\\udffb-\\udfff]",__="[^"+f_+"]",C_="(?:\\ud83c[\\udde6-\\uddff]){2}",v_="[\\ud800-\\udbff][\\udc00-\\udfff]",A_="(?:"+b_+"|"+w_+")?",y_="[\\ufe0e\\ufe0f]?",x_=y_+A_+"(?:\\u200d(?:"+[__,C_,v_].join("|")+")"+y_+A_+")*",E_="(?:"+[__+b_+"?",b_,C_,v_,k_].join("|")+")",D_=RegExp(w_+"(?="+w_+")|"+E_+x_,"g"),S_=function(t){return g_(t)?function(t){return t.match(D_)||[]}(t):function(t){return t.split("")}(t)},T_=function(t){t=Ni(t);var e,n,o,i,r=g_(t)?S_(t):void 0,s=r?r[0]:t.charAt(0),a=r?(e=r,n=1,i=e.length,o=void 0===o?i:o,!n&&o>=i?e:Hi(e,n,o)).join(""):t.slice(1);return s.toUpperCase()+a},B_=(Rw=function(t,e,n){return t+(n?" ":"")+T_(e)},function(t){return function(t,e,n,o){var i=-1,r=null==t?0:t.length;for(o&&r&&(n=t[++i]);++in.writer.createElement(t,{htmlContent:e.getCustomProperty("$rawContent")})}function L_(t,{view:e,isInline:n}){const o=t.t;return(t,{writer:i})=>{const r=o("HTML object"),s=R_(e,t,i),a=t.getAttribute(N_(e));return i.addClass("html-object-embed__content",s),a&&P_(i,a,s),Kf(i.createContainerElement(n?"span":"div",{class:"html-object-embed","data-html-object-embed-label":r},s),i,{label:r})}}function R_(t,e,n){return n.createRawElement(t,null,((t,n)=>{n.setContentOf(t,e.getAttribute("htmlContent"))}))}function F_({model:t,view:e},n){return(o,{writer:i,consumable:r})=>{if(!o.hasAttribute(t))return null;const s=i.createContainerElement(e),a=o.getAttribute(t);return r.consume(o,`attribute:${t}`),P_(i,a,s),s.getFillerOffset=()=>null,n?Kf(s,i):s}}function j_({priority:t,view:e}){return(n,o)=>{if(!n)return;const{writer:i}=o,r=i.createAttributeElement(e,null,{priority:t});return P_(i,n,r),r}}function V_({view:t},e){return n=>{n.on(`element:${t}`,((t,n,o)=>{if(!n.modelRange||n.modelRange.isCollapsed)return;const i=e.processViewAttributes(n.viewItem,o);i&&o.writer.setAttribute(N_(n.viewItem.name),i,n.modelRange)}),{priority:"low"})}}function H_({view:t,model:e}){return n=>{n.on(`attribute:${N_(t)}:${e}`,((t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const{attributeOldValue:o,attributeNewValue:i}=e;M_(n.writer,o,i,n.mapper.toViewElement(e.item))}))}}var U_=[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6","$text"],allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowIn:["$root","$container"],allowChildren:["paragraph","htmlP","htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}}],W_=[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref"},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}];class G_ extends iu{_definitions=[];static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const t of U_)this.registerBlockElement(t);for(const t of W_)this.registerInlineElement(t)}registerBlockElement(t){this._definitions.push({...t,isBlock:!0})}registerInlineElement(t){this._definitions.push({...t,isInline:!0})}extendBlockElement(t){this._extendDefinition({...t,isBlock:!0})}extendInlineElement(t){this._extendDefinition({...t,isInline:!0})}getDefinitionsForView(t,e=!1){const n=new Set;for(const o of this._getMatchingViewDefinitions(t)){if(e)for(const t of this._getReferences(o.model))n.add(t);n.add(o)}return n}getDefinitionsForModel(t){return this._definitions.filter((e=>e.model==t))}_getMatchingViewDefinitions(t){return this._definitions.filter((e=>e.view&&function(t,e){return"string"==typeof t?t===e:t instanceof RegExp&&t.test(e)}(t,e.view)))}*_getReferences(t){const e=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],n=this._definitions.filter((e=>e.model==t));for(const{modelSchema:o}of n)if(o)for(const n of e)for(const e of ii(o[n]||[])){const n=this._definitions.filter((t=>t.model==e));for(const o of n)e!==t&&(yield*this._getReferences(o.model),yield o)}}_extendDefinition(t){const e=Array.from(this._definitions.entries()).filter((([,e])=>e.model==t.model));if(0!=e.length)for(const[n,o]of e)this._definitions[n]=I_({},o,t,((t,e)=>Array.isArray(t)?t.concat(e):void 0));else this._definitions.push(t)}}class q_ extends iu{_dataSchema;_allowedAttributes;_disallowedAttributes;_allowedElements;_disallowedElements;_dataInitialized;_coupledAttributes;constructor(t){super(t),this._dataSchema=t.plugins.get("DataSchema"),this._allowedAttributes=new Ir,this._disallowedAttributes=new Ir,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get isOfficialPlugin(){return!0}static get requires(){return[G_,dk]}loadAllowedConfig(t){for(const e of t){const t=e.name||/[\s\S]+/,n=Z_(e);this.allowElement(t),n.forEach((t=>this.allowAttributes(t)))}}loadDisallowedConfig(t){for(const e of t){const t=e.name||/[\s\S]+/,n=Z_(e);0==n.length?this.disallowElement(t):n.forEach((t=>this.disallowAttributes(t)))}}loadAllowedEmptyElementsConfig(t){for(const e of t)this.allowEmptyElement(e)}allowElement(t){for(const e of this._dataSchema.getDefinitionsForView(t,!0))this._addAllowedElement(e),this._coupledAttributes=null}disallowElement(t){for(const e of this._dataSchema.getDefinitionsForView(t,!1))this._disallowedElements.add(e.view)}allowEmptyElement(t){for(const e of this._dataSchema.getDefinitionsForView(t,!0))e.isInline&&this._dataSchema.extendInlineElement({...e,allowEmpty:!0})}allowAttributes(t){this._allowedAttributes.add(t)}disallowAttributes(t){this._disallowedAttributes.add(t)}processViewAttributes(t,e){const{consumable:n}=e;return $_(t,this._disallowedAttributes,n),function(t,{attributes:e,classes:n,styles:o}){return e.length||n.length||o.length?{...e.length&&{attributes:K_(t,e)},...o.length&&{styles:Y_(t,o)},...n.length&&{classes:n}}:null}(t,$_(t,this._allowedAttributes,n))}_addAllowedElement(t){if(!this._allowedElements.has(t)){if(this._allowedElements.add(t),"appliesToBlock"in t&&"string"==typeof t.appliesToBlock)for(const e of this._dataSchema.getDefinitionsForModel(t.appliesToBlock))e.isBlock&&this._addAllowedElement(e);this._dataInitialized&&this.editor.data.once("set",(()=>{this._fireRegisterEvent(t)}),{priority:Cn.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",(()=>{this._dataInitialized=!0;for(const t of this._allowedElements)this._fireRegisterEvent(t)}),{priority:Cn.highest+1})}_registerElementHandlers(){this.on("register",((t,e)=>{const n=this.editor.model.schema;if(e.isObject&&!n.isRegistered(e.model))this._registerObjectElement(e);else if(e.isBlock)this._registerBlockElement(e);else{if(!e.isInline)throw new An("data-filter-invalid-definition",null,e);this._registerInlineElement(e)}t.stop()}),{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const t=this.editor.model,e=t.document.selection;t.document.registerPostFixer((e=>{const n=t.document.differ.getChanges();let o=!1;const i=this._getCoupledAttributesMap();for(const t of n){if("attribute"!=t.type||null!==t.attributeNewValue)continue;const n=i.get(t.attributeKey);if(n)for(const{item:i}of t.range.getWalker())for(const t of n)i.hasAttribute(t)&&(e.removeAttribute(t,i),o=!0)}return o})),this.listenTo(e,"change:attribute",((n,{attributeKeys:o})=>{const i=new Set,r=this._getCoupledAttributesMap();for(const t of o){if(e.hasAttribute(t))continue;const n=r.get(t);if(n)for(const t of n)e.hasAttribute(t)&&i.add(t)}0!=i.size&&t.change((t=>{for(const e of i)t.removeSelectionAttribute(e)}))}))}_registerAssociatedHtmlAttributesPostFixer(){const t=this.editor.model;t.document.registerPostFixer((e=>{const n=t.document.differ.getChanges();let o=!1;for(const i of n)if("insert"===i.type&&"$text"!==i.name)for(const n of i.attributes.keys())n.startsWith("html")&&n.endsWith("Attributes")&&(t.schema.checkAttribute(i.name,n)||(e.removeAttribute(n,i.position.nodeAfter),o=!0));return o}))}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const t of this._allowedElements)if(t.coupledAttribute&&t.model){const e=this._coupledAttributes.get(t.coupledAttribute);e?e.push(t.model):this._coupledAttributes.set(t.coupledAttribute,[t.model])}return this._coupledAttributes}_fireRegisterEvent(t){t.view&&this._disallowedElements.has(t.view)||this.fire(t.view?`register:${t.view}`:"register",t)}_registerObjectElement(t){const e=this.editor,n=e.model.schema,o=e.conversion,{view:i,model:r}=t;n.register(r,t.modelSchema),i&&(n.extend(t.model,{allowAttributes:[N_(i),"htmlContent"]}),e.data.registerRawContentMatcher({name:i}),o.for("upcast").elementToElement({view:i,model:z_(t),converterPriority:Cn.low+2}),o.for("upcast").add(V_(t,this)),o.for("editingDowncast").elementToStructure({model:{name:r,attributes:[N_(i)]},view:L_(e,t)}),o.for("dataDowncast").elementToElement({model:r,view:(t,{writer:e})=>R_(i,t,e)}),o.for("dataDowncast").add(H_(t)))}_registerBlockElement(t){const e=this.editor,n=e.model.schema,o=e.conversion,{view:i,model:r}=t;if(!n.isRegistered(t.model)){if(n.register(t.model,t.modelSchema),!i)return;o.for("upcast").elementToElement({model:r,view:i,converterPriority:Cn.low+2}),o.for("downcast").elementToElement({model:r,view:i})}i&&(n.extend(t.model,{allowAttributes:N_(i)}),o.for("upcast").add(V_(t,this)),o.for("downcast").add(H_(t)))}_registerInlineElement(t){const e=this.editor,n=e.model.schema,o=e.conversion,i=t.model;t.appliesToBlock||(n.extend("$text",{allowAttributes:i}),t.attributeProperties&&n.setAttributeProperties(i,t.attributeProperties),o.for("upcast").add(function({view:t,model:e,allowEmpty:n},o){return e=>{e.on(`element:${t}`,((t,e,r)=>{let s=o.processViewAttributes(e.viewItem,r);if(s||r.consumable.test(e.viewItem,{name:!0})){if(s=s||{},r.consumable.consume(e.viewItem,{name:!0}),e.modelRange||(e=Object.assign(e,r.convertChildren(e.viewItem,e.modelCursor))),n&&e.modelRange.isCollapsed&&Object.keys(s).length){const t=r.writer.createElement("htmlEmptyElement");if(!r.safeInsert(t,e.modelCursor))return;const n=r.getSplitParts(t);return e.modelRange=r.writer.createRange(e.modelRange.start,r.writer.createPositionAfter(n[n.length-1])),r.updateConversionResult(t,e),void i(t,s,r)}for(const t of e.modelRange.getItems())i(t,s,r)}}),{priority:"low"})};function i(t,n,o){if(o.schema.checkAttribute(t,e)){const i=function(t,e){const n=wr(t);let o="attributes";for(o in e)n[o]="classes"==o?Array.from(new Set([...t[o]||[],...e[o]])):{...t[o],...e[o]};return n}(n,t.getAttribute(e)||{});o.writer.setAttribute(e,i,t)}}}(t,this)),o.for("downcast").attributeToElement({model:i,view:j_(t)}),t.allowEmpty&&(n.setAttributeProperties(i,{copyFromObject:!1}),n.isRegistered("htmlEmptyElement")||n.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"}),e.data.htmlProcessor.domConverter.registerInlineObjectMatcher((e=>e.name==t.view&&e.isEmpty&&Array.from(e.getAttributeKeys()).length?{name:!0}:null)),o.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:F_(t,!0)}),o.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:F_(t)})))}}function $_(t,e,n){const o=e.matchAll(t)||[],i=t.document.stylesProcessor;return o.reduce(((e,{match:o})=>{for(const r of o.styles||[]){const o=i.getRelatedStyles(r).filter((t=>t.split("-").length>r.split("-").length)).sort(((t,e)=>e.split("-").length-t.split("-").length));for(const i of o)n.consume(t,{styles:[i]})&&e.styles.push(i);n.consume(t,{styles:[r]})&&e.styles.push(r)}for(const i of o.classes||[])n.consume(t,{classes:[i]})&&e.classes.push(i);for(const i of o.attributes||[])n.consume(t,{attributes:[i]})&&e.attributes.push(i);return e}),{attributes:[],classes:[],styles:[]})}function K_(t,e){const n={};for(const o of e){const e=t.getAttribute(o);void 0!==e&&Bo(o)&&(n[o]=e)}return n}function Y_(t,e){const n=new Or(t.document.stylesProcessor);for(const o of e){const e=t.getStyle(o);void 0!==e&&n.set(o,e)}return Object.fromEntries(n.getStylesEntries())}function Q_(t,e){const{name:n}=t,o=t[e];return D(o)?Object.entries(o).map((([t,o])=>({name:n,[e]:{[t]:o}}))):Array.isArray(o)?o.map((t=>({name:n,[e]:[t]}))):[t]}function Z_(t){const{name:e,attributes:n,classes:o,styles:i}=t,r=[];return n&&r.push(...Q_({name:e,attributes:n},"attributes")),o&&r.push(...Q_({name:e,classes:o},"classes")),i&&r.push(...Q_({name:e,styles:i},"styles")),r}class J_ extends iu{static get requires(){return[q_]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const t=this.editor.plugins.get(q_);t.on("register:pre",((e,n)=>{if("codeBlock"!==n.model)return;const o=this.editor,i=o.model.schema,r=o.conversion;i.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),r.for("upcast").add(function(t){return e=>{e.on("element:code",((e,n,o)=>{const i=n.viewItem,r=i.parent;function s(e,i){const r=t.processViewAttributes(e,o);r&&o.writer.setAttribute(i,r,n.modelRange)}r&&r.is("element","pre")&&(s(r,"htmlPreAttributes"),s(i,"htmlContentAttributes"))}),{priority:"low"})}}(t)),r.for("downcast").add((t=>{t.on("attribute:htmlPreAttributes:codeBlock",((t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const{attributeOldValue:o,attributeNewValue:i}=e,r=n.mapper.toViewElement(e.item).parent;M_(n.writer,o,i,r)})),t.on("attribute:htmlContentAttributes:codeBlock",((t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const{attributeOldValue:o,attributeNewValue:i}=e,r=n.mapper.toViewElement(e.item);M_(n.writer,o,i,r)}))})),e.stop()}))}}class X_ extends iu{static get requires(){return[q_]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(q_).on("register",((t,e)=>{const n=e,o=this.editor,i=o.model.schema,r=o.conversion;if(!n.paragraphLikeModel)return;if(i.isRegistered(n.model)||i.isRegistered(n.paragraphLikeModel))return;const s={model:n.paragraphLikeModel,view:n.view};i.register(n.model,n.modelSchema),i.register(s.model,{inheritAllFrom:"$block"}),r.for("upcast").elementToElement({view:n.view,model:(t,{writer:e})=>this._hasBlockContent(t)?e.createElement(n.model):e.createElement(s.model),converterPriority:Cn.low+.5}),r.for("downcast").elementToElement({view:n.view,model:n.model}),this._addAttributeConversion(n),r.for("downcast").elementToElement({view:s.view,model:s.model}),this._addAttributeConversion(s),t.stop()}))}_hasBlockContent(t){const e=this.editor.editing.view,n=e.domConverter.blockElements;for(const o of e.createRangeIn(t).getItems())if(o.is("element")&&n.includes(o.name))return!0;return!1}_addAttributeConversion(t){const e=this.editor,n=e.conversion,o=e.plugins.get(q_);e.model.schema.extend(t.model,{allowAttributes:N_(t.view)}),n.for("upcast").add(V_(t,o)),n.for("downcast").add(H_(t))}}class tC extends iu{static get requires(){return[G_,Mf]}static get pluginName(){return"HeadingElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("HeadingEditing"))return;const e=t.config.get("heading.options");this.registerHeadingElements(t,e)}registerHeadingElements(t,e){const n=t.plugins.get(G_),o=[];for(const t of e)"model"in t&&"view"in t&&(n.registerBlockElement({view:t.view,model:t.model}),o.push(t.model));n.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:o}}),n.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:o}})}}function eC(t,e,n){const o=t.createRangeOn(e);for(const{item:t}of o.getWalker())if(t.is("element",n))return t}class nC extends iu{static get requires(){return[q_]}static get pluginName(){return"ImageElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("ImageInlineEditing")&&!t.plugins.has("ImageBlockEditing"))return;const e=t.model.schema,n=t.conversion,o=t.plugins.get(q_);o.on("register:figure",(()=>{n.for("upcast").add(function(t){return e=>{e.on("element:figure",((e,n,o)=>{const i=n.viewItem;if(!n.modelRange||!i.hasClass("image"))return;const r=t.processViewAttributes(i,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,n.modelRange)}),{priority:"low"})}}(o))})),o.on("register:img",((i,r)=>{"imageBlock"!==r.model&&"imageInline"!==r.model||(e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),n.for("upcast").add(function(t){return e=>{e.on("element:img",((e,n,o)=>{if(!n.modelRange)return;const i=n.viewItem,r=t.processViewAttributes(i,o);r&&o.writer.setAttribute("htmlImgAttributes",r,n.modelRange)}),{priority:"low"})}}(o)),n.for("downcast").add((t=>{function e(e,n){t.on(`attribute:${n}:imageBlock`,((t,n,o)=>{if(!o.consumable.test(n.item,t.name))return;const{attributeOldValue:i,attributeNewValue:r}=n,s=o.mapper.toViewElement(n.item),a=eC(o.writer,s,e);a&&(M_(o.writer,i,r,a),o.consumable.consume(n.item,t.name))}),{priority:"low"}),"a"===e&&t.on("attribute:linkHref:imageBlock",((t,e,n)=>{if(!n.consumable.consume(e.item,"attribute:htmlLinkAttributes:imageBlock"))return;const o=n.mapper.toViewElement(e.item),i=eC(n.writer,o,"a");P_(n.writer,e.item.getAttribute("htmlLinkAttributes"),i)}),{priority:"low"})}var n;n="htmlImgAttributes",t.on(`attribute:${n}:imageInline`,((t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const{attributeOldValue:o,attributeNewValue:i}=e,r=n.mapper.toViewElement(e.item);M_(n.writer,o,i,r)}),{priority:"low"}),e("img","htmlImgAttributes"),e("figure","htmlFigureAttributes"),e("a","htmlLinkAttributes")})),t.plugins.has("LinkImage")&&n.for("upcast").add(function(t,e){const n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,o,i)=>{const r=o.viewItem;if(!n.findViewImgElement(r))return;const s=o.modelCursor.parent;if(!s.is("element","imageBlock"))return;const a=t.processViewAttributes(r,i);a&&i.writer.setAttribute("htmlLinkAttributes",a,s)}),{priority:"low"})}}(o,t)),i.stop())}))}}class oC extends iu{static get requires(){return[q_]}static get pluginName(){return"MediaEmbedElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("MediaEmbed")||t.config.get("mediaEmbed.previewsInData"))return;const e=t.model.schema,n=t.conversion,o=this.editor.plugins.get(q_),i=this.editor.plugins.get(G_),r=t.config.get("mediaEmbed.elementName");i.registerBlockElement({model:"media",view:r}),o.on("register:figure",(()=>{n.for("upcast").add(function(t){return e=>{e.on("element:figure",((e,n,o)=>{const i=n.viewItem;if(!n.modelRange||!i.hasClass("media"))return;const r=t.processViewAttributes(i,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,n.modelRange)}),{priority:"low"})}}(o))})),o.on(`register:${r}`,((t,i)=>{"media"===i.model&&(e.extend("media",{allowAttributes:[N_(r),"htmlFigureAttributes"]}),n.for("upcast").add(function(t,e){const n=(n,o,i)=>{!function(e,n){const r=t.processViewAttributes(e,i);r&&i.writer.setAttribute(n,r,o.modelRange)}(o.viewItem,N_(e))};return t=>{t.on(`element:${e}`,n,{priority:"low"})}}(o,r)),n.for("dataDowncast").add(function(t){return e=>{function n(t,n){e.on(`attribute:${n}:media`,((e,n,o)=>{if(!o.consumable.consume(n.item,e.name))return;const{attributeOldValue:i,attributeNewValue:r}=n,s=o.mapper.toViewElement(n.item),a=eC(o.writer,s,t);M_(o.writer,i,r,a)}))}n(t,N_(t)),n("figure","htmlFigureAttributes")}}(r)),t.stop())}))}}class iC extends iu{static get requires(){return[q_]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get(q_);t.on("register:script",((e,n)=>{const o=this.editor,i=o.model.schema,r=o.conversion;i.register("htmlScript",n.modelSchema),i.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),o.data.registerRawContentMatcher({name:"script"}),r.for("upcast").elementToElement({view:"script",model:z_(n)}),r.for("upcast").add(V_(n,t)),r.for("downcast").elementToElement({model:"htmlScript",view:(t,{writer:e})=>R_("script",t,e)}),r.for("downcast").add(H_(n)),e.stop()}))}}class rC extends iu{static get requires(){return[q_]}static get pluginName(){return"TableElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("TableEditing"))return;const e=t.model.schema,n=t.conversion,o=t.plugins.get(q_),i=t.plugins.get("TableUtils");o.on("register:figure",(()=>{n.for("upcast").add(function(t){return e=>{e.on("element:figure",((e,n,o)=>{const i=n.viewItem;if(!n.modelRange||!i.hasClass("table"))return;const r=t.processViewAttributes(i,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,n.modelRange)}),{priority:"low"})}}(o))})),o.on("register:table",((r,s)=>{"table"===s.model&&(e.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),n.for("upcast").add(function(t){return e=>{e.on("element:table",((e,n,o)=>{if(!n.modelRange)return;const i=n.viewItem;r(i,"htmlTableAttributes");for(const t of i.getChildren())t.is("element","thead")&&r(t,"htmlTheadAttributes"),t.is("element","tbody")&&r(t,"htmlTbodyAttributes");function r(e,i){const r=t.processViewAttributes(e,o);r&&o.writer.setAttribute(i,r,n.modelRange)}}),{priority:"low"})}}(o)),n.for("downcast").add((t=>{function e(e,n){t.on(`attribute:${n}:table`,((t,n,o)=>{if(!o.consumable.test(n.item,t.name))return;const i=o.mapper.toViewElement(n.item),r=eC(o.writer,i,e);r&&(o.consumable.consume(n.item,t.name),M_(o.writer,n.attributeOldValue,n.attributeNewValue,r))}))}e("table","htmlTableAttributes"),e("figure","htmlFigureAttributes"),e("thead","htmlTheadAttributes"),e("tbody","htmlTbodyAttributes")})),t.model.document.registerPostFixer(function(t,e){return n=>{const o=t.document.differ.getChanges();let i=!1;for(const t of o){if("attribute"!=t.type||"headingRows"!=t.attributeKey)continue;const o=t.range.start.nodeAfter,r=o.getAttribute("htmlTheadAttributes"),s=o.getAttribute("htmlTbodyAttributes");r&&!t.attributeNewValue?(n.removeAttribute("htmlTheadAttributes",o),i=!0):s&&t.attributeNewValue==e.getRows(o)&&(n.removeAttribute("htmlTbodyAttributes",o),i=!0)}return i}}(t.model,i)),r.stop())}))}}class sC extends iu{static get requires(){return[q_]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get(q_);t.on("register:style",((e,n)=>{const o=this.editor,i=o.model.schema,r=o.conversion;i.register("htmlStyle",n.modelSchema),i.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),o.data.registerRawContentMatcher({name:"style"}),r.for("upcast").elementToElement({view:"style",model:z_(n)}),r.for("upcast").add(V_(n,t)),r.for("downcast").elementToElement({model:"htmlStyle",view:(t,{writer:e})=>R_("style",t,e)}),r.for("downcast").add(H_(n)),e.stop()}))}}class aC extends iu{static get requires(){return[q_]}static get pluginName(){return"ListElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;if(!t.plugins.has("ListEditing"))return;const e=t.model.schema,n=t.conversion,o=t.plugins.get(q_),i=t.plugins.get("ListEditing"),r=t.plugins.get("ListUtils"),s=["ul","ol","li"];i.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:P_}),i.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:P_}),i.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:P_}),o.on("register",((t,i)=>{if(!s.includes(i.view))return;if(t.stop(),e.checkAttribute("$block","htmlLiAttributes"))return;const r=s.map((t=>N_(t)));e.extend("$listItem",{allowAttributes:r}),n.for("upcast").add((t=>{t.on("element:ul",cC("htmlUlAttributes",o),{priority:"low"}),t.on("element:ol",cC("htmlOlAttributes",o),{priority:"low"}),t.on("element:li",cC("htmlLiAttributes",o),{priority:"low"})}))})),i.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:o,previousNodeInList:i}of e)if(i){if(i.getAttribute("listType")==o.getAttribute("listType")){const e=lC(i.getAttribute("listType")),r=i.getAttribute(e);!_r(o.getAttribute(e),r)&&n.model.schema.checkAttribute(o,e)&&(n.setAttribute(e,r,o),t.return=!0)}if(i.getAttribute("listItemId")==o.getAttribute("listItemId")){const e=i.getAttribute("htmlLiAttributes");!_r(o.getAttribute("htmlLiAttributes"),e)&&n.model.schema.checkAttribute(o,"htmlLiAttributes")&&(n.setAttribute("htmlLiAttributes",e,o),t.return=!0)}}})),i.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:o}of e){const e=o.getAttribute("listType");!r.isNumberedListType(e)&&o.getAttribute("htmlOlAttributes")&&(n.removeAttribute("htmlOlAttributes",o),t.return=!0),r.isNumberedListType(e)&&o.getAttribute("htmlUlAttributes")&&(n.removeAttribute("htmlUlAttributes",o),t.return=!0)}}))}afterInit(){const t=this.editor;if(!t.commands.get("indentList"))return;const e=t.commands.get("indentList");this.listenTo(e,"afterExecute",((e,n)=>{t.model.change((e=>{for(const o of n){const n=lC(o.getAttribute("listType"));t.model.schema.checkAttribute(o,n)&&e.setAttribute(n,{},o)}}))}))}}function cC(t,e){return(n,o,i)=>{const r=o.viewItem;o.modelRange||Object.assign(o,i.convertChildren(o.viewItem,o.modelCursor));const s=e.processViewAttributes(r,i);for(const e of o.modelRange.getItems({shallow:!0}))e.hasAttribute("listItemId")&&(e.hasAttribute("htmlUlAttributes")||e.hasAttribute("htmlOlAttributes")||i.writer.model.schema.checkAttribute(e,t)&&i.writer.setAttribute(t,s||{},e))}}function lC(t){return"numbered"===t||"customNumbered"==t?"htmlOlAttributes":"htmlUlAttributes"}class dC extends iu{static get requires(){return[q_,G_]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get(q_),e=this.editor.plugins.get(G_);t.on("register:$customElement",((n,o)=>{n.stop();const i=this.editor,r=i.model.schema,s=i.conversion,a=i.editing.view.domConverter.unsafeElements,c=i.data.htmlProcessor.domConverter.preElements;r.register(o.model,o.modelSchema),r.extend(o.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),i.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),s.for("upcast").elementToElement({view:/.*/,model:(n,r)=>{if("$comment"==n.name)return null;if(!function(t){try{document.createElement(t)}catch(t){return!1}return!0}(n.name))return null;if(e.getDefinitionsForView(n.name).size)return null;a.includes(n.name)||a.push(n.name),c.includes(n.name)||c.push(n.name);const s=r.writer.createElement(o.model,{htmlElementName:n.name}),l=t.processViewAttributes(n,r);let d;if(l&&r.writer.setAttribute("htmlCustomElementAttributes",l,s),n.is("element","template")&&n.getCustomProperty("$rawContent"))d=n.getCustomProperty("$rawContent");else{const t=new ad(n.document).createDocumentFragment(n),e=i.data.htmlProcessor.domConverter.viewToDom(t),o=e.firstChild;for(;o.firstChild;)e.appendChild(o.firstChild);o.remove(),d=i.data.htmlProcessor.htmlWriter.getHtml(e)}r.writer.setAttribute("htmlContent",d,s);for(const{item:t}of i.editing.view.createRangeIn(n))r.consumable.consume(t,{name:!0});return s},converterPriority:"low"}),s.for("editingDowncast").elementToElement({model:{name:o.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(t,{writer:e})=>{const n=t.getAttribute("htmlElementName"),o=e.createRawElement(n);return t.hasAttribute("htmlCustomElementAttributes")&&P_(e,t.getAttribute("htmlCustomElementAttributes"),o),o}}),s.for("dataDowncast").elementToElement({model:{name:o.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(t,{writer:e})=>{const n=t.getAttribute("htmlElementName"),o=t.getAttribute("htmlContent"),i=e.createRawElement(n,null,((t,e)=>{e.setContentOf(t,o)}));return t.hasAttribute("htmlCustomElementAttributes")&&P_(e,t.getAttribute("htmlCustomElementAttributes"),i),i}})}))}}function*uC(t,e,n){if(e)if(!(Symbol.iterator in e)&&e.is("documentSelection")&&e.isCollapsed)t.schema.checkAttributeInSelection(e,n)&&(yield e);else for(const o of function(t,e,n){return!(Symbol.iterator in e)&&(e.is("node")||e.is("$text")||e.is("$textProxy"))?t.schema.checkAttribute(e,n)?[t.createRangeOn(e)]:[]:t.schema.getValidRanges(t.createSelection(e).getRanges(),n)}(t,e,n))yield*o.getItems({shallow:!0})}function hC(t){return t.createContainerElement("figure",{class:"image"},[t.createEmptyElement("img"),t.createSlot("children")])}function pC(t,e){const n=t.plugins.get("ImageUtils"),o=t.plugins.has("ImageInlineEditing")&&t.plugins.has("ImageBlockEditing");return t=>n.isInlineImageView(t)?o&&("block"==t.getStyle("display")||t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==e?null:i(t):null;function i(t){const e={name:!0};return t.hasAttribute("src")&&(e.attributes=["src"]),e}}function mC(t,e){const n=ai(e.getSelectedBlocks());return!n||t.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}function gC(t){return t&&t.endsWith("px")?parseInt(t):null}function fC(t){const e=gC(t.getStyle("width")),n=gC(t.getStyle("height"));return!(!e||!n)}const kC=/^(image|image-inline)$/;class bC extends iu{_domEmitter=new(lo());static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(t){return this.isInlineImage(t)||this.isBlockImage(t)}isInlineImageView(t){return!!t&&t.is("element","img")}isBlockImageView(t){return!!t&&t.is("element","figure")&&t.hasClass("image")}insertImage(t={},e=null,n=null,o={}){const i=this.editor,r=i.model,s=r.document.selection,a=wC(i,e||s,n);t={...Object.fromEntries(s.getAttributes()),...t};for(const e in t)r.schema.checkAttribute(a,e)||delete t[e];return r.change((n=>{const{setImageSizes:i=!0}=o,s=n.createElement(a,t);return r.insertObject(s,e,null,{setSelection:"on",findOptimalPosition:e||"imageInline"==a?void 0:"auto"}),s.parent?(i&&this.setImageNaturalSizeAttributes(s),s):null}))}setImageNaturalSizeAttributes(t){const e=t.getAttribute("src");e&&(t.getAttribute("width")||t.getAttribute("height")||this.editor.model.change((n=>{const o=new en.window.Image;this._domEmitter.listenTo(o,"load",(()=>{t.getAttribute("width")||t.getAttribute("height")||this.editor.model.enqueueChange(n.batch,(e=>{e.setAttribute("width",o.naturalWidth,t),e.setAttribute("height",o.naturalHeight,t)})),this._domEmitter.stopListening(o,"load")})),o.src=e})))}getClosestSelectedImageWidget(t){const e=t.getFirstPosition();if(!e)return null;const n=t.getSelectedElement();if(n&&this.isImageWidget(n))return n;let o=e.parent;for(;o;){if(o.is("element")&&this.isImageWidget(o))return o;o=o.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(t){return t.findAncestor({classes:kC})}isImageAllowed(){const t=this.editor.model.document.selection;return function(t,e){if("imageBlock"==wC(t,e,null)){const n=function(t,e){const n=Xf(t,e).start.parent;return n.isEmpty&&!n.is("element","$root")?n.parent:n}(e,t.model);if(t.model.schema.checkChild(n,"imageBlock"))return!0}else if(t.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}(this.editor,t)&&function(t){return[...t.focus.getAncestors()].every((t=>!t.is("element","imageBlock")))}(t)}toImageWidget(t,e,n){return e.setCustomProperty("image",!0,t),Kf(t,e,{label:()=>{const e=this.findViewImgElement(t).getAttribute("alt");return e?`${e} ${n}`:n}})}isImageWidget(t){return!!t.getCustomProperty("image")&&$f(t)}isBlockImage(t){return!!t&&t.is("element","imageBlock")}isInlineImage(t){return!!t&&t.is("element","imageInline")}findViewImgElement(t){if(this.isInlineImageView(t))return t;const e=this.editor.editing.view;for(const{item:n}of e.createRangeIn(t))if(this.isInlineImageView(n))return n}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function wC(t,e,n){const o=t.model.schema,i=t.config.get("image.insert.type");return t.plugins.has("ImageBlockEditing")?t.plugins.has("ImageInlineEditing")?n||("inline"===i?"imageInline":"auto"!==i?"imageBlock":e.is("selection")?mC(o,e):o.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}const _C=new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class CC extends su{refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled&&t.hasAttribute("alt")?this.value=t.getAttribute("alt"):this.value=!1}execute(t){const e=this.editor,n=e.plugins.get("ImageUtils"),o=e.model,i=n.getClosestSelectedImageElement(o.document.selection);o.change((e=>{e.setAttribute("alt",t.newValue,i)}))}}class vC extends iu{static get requires(){return[bC]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new CC(this.editor))}}class AC extends xh{focusTracker;keystrokes;labeledInput;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(t){super(t);const e=this.locale.t;this.focusTracker=new ci,this.keystrokes=new hi,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(e("Save"),yu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(e("Cancel"),yu.cancel,"ck-button-cancel","cancel"),this._focusables=new oh,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Sh({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(t,e,n,o){const i=new Mh(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createLabeledInputView(){const t=this.locale.t,e=new gp(this.locale,Kp);return e.label=t("Text alternative"),e}}function yC(t){const e=t.editing.view,n=Tp.defaultPositions,o=t.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(o.getClosestSelectedImageWidget(e.document.selection)),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class xC extends iu{_balloon;_form;static get requires(){return[$m]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const t=this.editor,e=t.t;t.ui.componentFactory.add("imageTextAlternative",(n=>{const o=t.commands.get("imageTextAlternative"),i=new Mh(n);return i.set({label:e("Change image text alternative"),icon:yu.textAlternative,tooltip:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",(t=>!!t)),this.listenTo(i,"execute",(()=>{this._showForm()})),i}))}_createForm(){const t=this.editor,e=t.editing.view.document,n=t.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Dh(AC))(t.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{t.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((t,e)=>{this._hideForm(!0),e()})),this.listenTo(t.ui,"update",(()=>{n.getClosestSelectedImageWidget(e.selection)?this._isVisible&&function(t){const e=t.plugins.get("ContextualBalloon");if(t.plugins.get("ImageUtils").getClosestSelectedImageWidget(t.editing.view.document.selection)){const n=yC(t);e.updatePosition(n)}}(t):this._hideForm(!0)})),Eh({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const t=this.editor,e=t.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:yC(t)}),n.fieldView.value=n.fieldView.element.value=e.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(t=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),t&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class EC extends iu{static get requires(){return[vC,xC]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function DC(t,e){const n=(e,n,o)=>{if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);null===n.attributeNewValue?(i.removeAttribute("srcset",s),i.removeAttribute("sizes",s)):n.attributeNewValue&&(i.setAttribute("srcset",n.attributeNewValue,s),i.setAttribute("sizes","100vw",s))};return t=>{t.on(`attribute:srcset:${e}`,n)}}function SC(t,e,n){const o=(e,n,o)=>{if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)};return t=>{t.on(`attribute:${n}:${e}`,o)}}class TC extends $s{observe(t){this.listenTo(t,"load",((t,e)=>{const n=e.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(e)}),{useCapture:!0})}stopObserving(t){this.stopListening(t)}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}}class BC extends su{constructor(t){super(t);const e=t.config.get("image.insert.type");t.plugins.has("ImageBlockEditing")||"block"===e&&yn("image-block-plugin-required"),t.plugins.has("ImageInlineEditing")||"inline"===e&&yn("image-inline-plugin-required")}refresh(){const t=this.editor.plugins.get("ImageUtils");this.isEnabled=t.isImageAllowed()}execute(t){const e=ii(t.source),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((e,r)=>{const s=n.getSelectedElement();if("string"==typeof e&&(e={src:e}),r&&s&&o.isImage(s)){const n=this.editor.model.createPositionAfter(s);o.insertImage({...e,...i},n,t.imageType)}else o.insertImage({...e,...i},null,t.imageType)}))}}class IC extends su{constructor(t){super(t),this.decorate("cleanupImage")}refresh(){const t=this.editor.plugins.get("ImageUtils"),e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=t.isImage(e),this.value=this.isEnabled?e.getAttribute("src"):null}execute(t){const e=this.editor.model.document.selection.getSelectedElement(),n=this.editor.plugins.get("ImageUtils");this.editor.model.change((o=>{o.setAttribute("src",t.source,e),this.cleanupImage(o,e),n.setImageNaturalSizeAttributes(e)}))}cleanupImage(t,e){t.removeAttribute("srcset",e),t.removeAttribute("sizes",e),t.removeAttribute("sources",e),t.removeAttribute("width",e),t.removeAttribute("height",e),t.removeAttribute("alt",e)}}class MC extends iu{static get requires(){return[bC]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.conversion;t.editing.view.addObserver(TC),e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const n=new BC(t),o=new IC(t);t.commands.add("insertImage",n),t.commands.add("replaceImageSource",o),t.commands.add("imageInsert",n)}}class PC extends iu{static get requires(){return[bC]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(t){const e=this.editor,n=e.plugins.get("ImageUtils"),o="imageBlock"===t?"figure":"img";function i(e,o,i,r){e.on(`attribute:${o}:${t}`,((e,o,s)=>{if(!s.consumable.consume(o.item,e.name))return;const a=s.writer,c=s.mapper.toViewElement(o.item),l=n.findViewImgElement(c);if(null!==o.attributeNewValue?a.setAttribute(i,o.attributeNewValue,l):a.removeAttribute(i,l),o.item.hasAttribute("sources"))return;const d=o.item.hasAttribute("resizedWidth");if("imageInline"===t&&!d&&!r)return;const u=o.item.getAttribute("width"),h=o.item.getAttribute("height");u&&h&&a.setStyle("aspect-ratio",`${u}/${h}`,l)}))}e.conversion.for("upcast").attributeToAttribute({view:{name:o,styles:{width:/.+/}},model:{key:"width",value:t=>fC(t)?gC(t.getStyle("width")):null}}).attributeToAttribute({view:{name:o,key:"width"},model:"width"}).attributeToAttribute({view:{name:o,styles:{height:/.+/}},model:{key:"height",value:t=>fC(t)?gC(t.getStyle("height")):null}}).attributeToAttribute({view:{name:o,key:"height"},model:"height"}),e.conversion.for("editingDowncast").add((t=>{i(t,"width","width",!0),i(t,"height","height",!0)})),e.conversion.for("dataDowncast").add((t=>{i(t,"width","width",!1),i(t,"height","height",!1)}))}}class OC extends su{_modelElementName;constructor(t,e){super(t),this._modelElementName=e}refresh(){const t=this.editor.plugins.get("ImageUtils"),e=t.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=t.isInlineImage(e):this.isEnabled=t.isBlockImage(e)}execute(t={}){const e=this.editor,n=this.editor.model,o=e.plugins.get("ImageUtils"),i=o.getClosestSelectedImageElement(n.document.selection),r=Object.fromEntries(i.getAttributes());return r.src||r.uploadId?n.change((e=>{const{setImageSizes:s=!0}=t,a=Array.from(n.markers).filter((t=>t.getRange().containsItem(i))),c=o.insertImage(r,n.createSelection(i,"on"),this._modelElementName,{setImageSizes:s});if(!c)return null;const l=e.createRangeOn(c);for(const t of a){const n=t.getRange(),o="$graveyard"!=n.root.rootName?n.getJoined(l,!0):l;e.updateMarker(t,{range:o})}return{oldElement:i,newElement:c}})):null}}class NC extends iu{static get requires(){return[bC]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const t=this.editor.model.schema;t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["placeholder"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const t=this.editor,e=t.conversion,n=t.plugins.get("ImageUtils");e.for("editingDowncast").add((t=>{t.on("attribute:placeholder",((t,e,o)=>{if(!o.consumable.test(e.item,t.name))return;if(!e.item.is("element","imageBlock")&&!e.item.is("element","imageInline"))return;o.consumable.consume(e.item,t.name);const i=o.writer,r=o.mapper.toViewElement(e.item),s=n.findViewImgElement(r);e.attributeNewValue?(i.addClass("image_placeholder",s),i.setStyle("background-image",`url(${e.attributeNewValue})`,s),i.setCustomProperty("editingPipeline:doNotReuseOnce",!0,s)):(i.removeClass("image_placeholder",s),i.removeStyle("background-image",s))}))}))}_setupLoadListener(){const t=this.editor,e=t.model,n=t.editing,o=n.view,i=t.plugins.get("ImageUtils");o.addObserver(TC),this.listenTo(o.document,"imageLoaded",((t,r)=>{const s=o.domConverter.mapDomToView(r.target);if(!s)return;const a=i.getImageWidgetFromImageView(s);if(!a)return;const c=n.mapper.toModelElement(a);c&&c.hasAttribute("placeholder")&&e.enqueueChange({isUndoable:!1},(t=>{t.removeAttribute("placeholder",c)}))}))}}class zC extends iu{static get requires(){return[MC,PC,bC,NC,Dk]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),t.plugins.has("ImageInlineEditing")&&(t.commands.add("imageTypeBlock",new OC(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:e})=>hC(e)}),n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:n})=>o.toImageWidget(hC(n),n,e("image widget"))}),n.for("downcast").add(SC(o,"imageBlock","src")).add(SC(o,"imageBlock","alt")).add(DC(o,"imageBlock")),n.for("upcast").elementToElement({view:pC(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:void 0)}).add(function(t){const e=(e,n,o)=>{if(!o.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const i=t.findViewImgElement(n.viewItem);if(!i||!o.consumable.test(i,{name:!0}))return;o.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=ai(o.convertItem(i,n.modelCursor).modelRange.getItems());r?(o.convertChildren(n.viewItem,r),o.updateConversionResult(r,n)):o.consumable.revert(n.viewItem,{name:!0,classes:"image"})};return t=>{t.on("element:figure",e)}}(o))}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils"),i=t.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isInlineImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const c=e.createSelection(a);if("imageBlock"===mC(e.schema,c)){const t=new ad(n.document),e=s.map((e=>t.createElement("figure",{class:"image"},e)));r.content=t.createDocumentFragment(e)}})),this.listenTo(i,"contentInsertion",((t,n)=>{"paste"===n.method&&e.change((t=>{const e=t.createRangeIn(n.content);for(const t of e.getItems())t.is("element","imageBlock")&&o.setImageNaturalSizeAttributes(t)}))}))}}class LC extends xh{focusTracker;keystrokes;_focusables;_focusCycler;children;constructor(t,e=[]){super(t),this.focusTracker=new ci,this.keystrokes=new hi,this._focusables=new oh,this.children=this.createCollection(),this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const t of e)this.children.add(t),this._focusables.add(t),t instanceof ap&&this._focusables.addMany(t.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),Sh({view:this});for(const t of this._focusables)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element);const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class RC extends iu{static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[bC]}dropdownView;_integrations=new Map;constructor(t){super(t),t.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const t=this.editor,e=t.model.document.selection,n=t.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(t.model.document,"change",(()=>{this.isImageSelected=n.isImage(e.getSelectedElement())}));const o=t=>this._createToolbarComponent(t);t.ui.componentFactory.add("insertImage",o),t.ui.componentFactory.add("imageInsert",o),t.ui.componentFactory.add("menuBar:insertImage",(t=>this._createMenuBarComponent(t)))}registerIntegration({name:t,observable:e,buttonViewCreator:n,formViewCreator:o,menuBarButtonViewCreator:i,requiresForm:r=!1}){this._integrations.has(t)&&yn("image-insert-integration-exists",{name:t}),this._integrations.set(t,{observable:e,buttonViewCreator:n,menuBarButtonViewCreator:i,formViewCreator:o,requiresForm:r})}_createToolbarComponent(t){const e=this.editor,n=t.t,o=this._prepareIntegrations();if(!o.length)return null;let i;const r=o[0];if(1==o.length){if(!r.requiresForm)return r.buttonViewCreator(!0);i=r.buttonViewCreator(!0)}else{const e=r.buttonViewCreator(!1);i=new Fp(t,e),i.tooltip=!0,i.bind("label").to(this,"isImageSelected",(t=>n(t?"Replace image":"Insert image")))}const s=this.dropdownView=jp(t,i),a=o.map((({observable:t})=>"function"==typeof t?t():t));return s.bind("isEnabled").toMany(a,"isEnabled",((...t)=>t.some((t=>t)))),s.once("change:isOpen",(()=>{const t=o.map((({formViewCreator:t})=>t(1==o.length))),n=new LC(e.locale,t);s.panelView.children.add(n)})),s}_createMenuBarComponent(t){const e=t.t,n=this._prepareIntegrations();if(!n.length)return null;let o;const i=n[0];if(1==n.length)o=i.menuBarButtonViewCreator(!0);else{o=new tg(t);const i=new eg(t);o.panelView.children.add(i),o.buttonView.set({icon:yu.image,label:e("Image")});for(const e of n){const n=new ym(t,o),r=e.menuBarButtonViewCreator(!1);n.children.add(r),i.items.add(n)}}return o}_prepareIntegrations(){const t=this.editor.config.get("image.insert.integrations"),e=[];if(!t.length)return yn("image-insert-integrations-not-specified"),e;for(const n of t)this._integrations.has(n)?e.push(this._integrations.get(n)):["upload","assetManager","url"].includes(n)||yn("image-insert-unknown-integration",{item:n});return e.length||yn("image-insert-integrations-not-registered"),e}}class FC extends iu{static get requires(){return[zC,dk,EC,RC]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class jC extends iu{static get requires(){return[MC,PC,bC,NC,Dk]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),t.plugins.has("ImageBlockEditing")&&(t.commands.add("imageTypeInline",new OC(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageInline",view:(t,{writer:e})=>e.createEmptyElement("img")}),n.for("editingDowncast").elementToStructure({model:"imageInline",view:(t,{writer:n})=>o.toImageWidget(function(t){return t.createContainerElement("span",{class:"image-inline"},t.createEmptyElement("img"))}(n),n,e("image widget"))}),n.for("downcast").add(SC(o,"imageInline","src")).add(SC(o,"imageInline","alt")).add(DC(o,"imageInline")),n.for("upcast").elementToElement({view:pC(t,"imageInline"),model:(t,{writer:e})=>e.createElement("imageInline",t.hasAttribute("src")?{src:t.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils"),i=t.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isBlockImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const c=e.createSelection(a);if("imageInline"===mC(e.schema,c)){const t=new ad(n.document),e=s.map((e=>1===e.childCount?(Array.from(e.getAttributes()).forEach((n=>t.setAttribute(...n,o.findViewImgElement(e)))),e.getChild(0)):e));r.content=t.createDocumentFragment(e)}})),this.listenTo(i,"contentInsertion",((t,n)=>{"paste"===n.method&&e.change((t=>{const e=t.createRangeIn(n.content);for(const t of e.getItems())t.is("element","imageInline")&&o.setImageNaturalSizeAttributes(t)}))}))}}class VC extends iu{static get requires(){return[jC,dk,EC,RC]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}class HC extends iu{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[bC]}getCaptionFromImageModelElement(t){for(const e of t.getChildren())if(e&&e.is("element","caption"))return e;return null}getCaptionFromModelSelection(t){const e=this.editor.plugins.get("ImageUtils"),n=t.getFirstPosition().findAncestor("caption");return n&&e.isBlockImage(n.parent)?n:null}matchImageCaptionViewElement(t){const e=this.editor.plugins.get("ImageUtils");return"figcaption"==t.name&&e.isBlockImageView(t.parent)?{name:!0}:null}}class UC extends su{refresh(){const t=this.editor,e=t.plugins.get("ImageCaptionUtils"),n=t.plugins.get("ImageUtils");if(!t.plugins.has(zC))return this.isEnabled=!1,void(this.value=!1);const o=t.model.document.selection,i=o.getSelectedElement();if(!i){const t=e.getCaptionFromModelSelection(o);return this.isEnabled=!!t,void(this.value=!!t)}this.isEnabled=n.isImage(i),this.isEnabled?this.value=!!e.getCaptionFromImageModelElement(i):this.value=!1}execute(t={}){const{focusCaptionOnShow:e}=t;this.editor.model.change((t=>{this.value?this._hideImageCaption(t):this._showImageCaption(t,e)}))}_showImageCaption(t,e){const n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing"),i=this.editor.plugins.get("ImageUtils");let r=n.getSelectedElement();const s=o._getSavedCaption(r);i.isInlineImage(r)&&(this.editor.execute("imageTypeBlock"),r=n.getSelectedElement());const a=s||t.createElement("caption");t.append(a,r),e&&t.setSelection(a,"in")}_hideImageCaption(t){const e=this.editor,n=e.model.document.selection,o=e.plugins.get("ImageCaptionEditing"),i=e.plugins.get("ImageCaptionUtils");let r,s=n.getSelectedElement();s?r=i.getCaptionFromImageModelElement(s):(r=i.getCaptionFromModelSelection(n),s=r.parent),o._saveCaption(s,r),t.setSelection(s,"on"),t.remove(r)}}class WC extends iu{static get requires(){return[bC,HC]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}_savedCaptionsMap;constructor(t){super(t),this._savedCaptionsMap=new WeakMap}init(){const t=this.editor,e=t.model.schema;e.isRegistered("caption")?e.extend("caption",{allowIn:"imageBlock"}):e.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),t.commands.add("toggleImageCaption",new UC(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),o=t.plugins.get("ImageCaptionUtils"),i=t.t;t.conversion.for("upcast").elementToElement({view:t=>o.matchImageCaptionViewElement(t),model:"caption"}),t.conversion.for("dataDowncast").elementToElement({model:"caption",view:(t,{writer:e})=>n.isBlockImage(t.parent)?e.createContainerElement("figcaption"):null}),t.conversion.for("editingDowncast").elementToElement({model:"caption",view:(t,{writer:o})=>{if(!n.isBlockImage(t.parent))return null;const r=o.createEditableElement("figcaption");o.setCustomProperty("imageCaption",!0,r),r.placeholder=i("Enter image caption"),Ar({view:e,element:r,keepOnFocus:!0});const s=t.parent.getAttribute("alt");return Jf(r,o,{label:s?i("Caption for image: %0",[s]):i("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.plugins.get("ImageCaptionUtils"),o=t.commands.get("imageTypeInline"),i=t.commands.get("imageTypeBlock"),r=t=>{if(!t.return)return;const{oldElement:o,newElement:i}=t.return;if(!o)return;if(e.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(t)return void this._saveCaption(i,t)}const r=this._getSavedCaption(o);r&&this._saveCaption(i,r)};o&&this.listenTo(o,"execute",r,{priority:"low"}),i&&this.listenTo(i,"execute",r,{priority:"low"})}_getSavedCaption(t){const e=this._savedCaptionsMap.get(t);return e?ma.fromJSON(e):null}_saveCaption(t,e){this._savedCaptionsMap.set(t,e.toJSON())}_registerCaptionReconversion(){const t=this.editor,e=t.model,n=t.plugins.get("ImageUtils"),o=t.plugins.get("ImageCaptionUtils");e.document.on("change:data",(()=>{const i=e.document.differ.getChanges();for(const e of i){if("alt"!==e.attributeKey)continue;const i=e.range.start.nodeAfter;if(n.isBlockImage(i)){const e=o.getCaptionFromImageModelElement(i);if(!e)return;t.editing.reconvertItem(e)}}}))}}class GC extends iu{static get requires(){return[HC]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageCaptionUtils"),o=t.t;t.ui.componentFactory.add("toggleImageCaption",(i=>{const r=t.commands.get("toggleImageCaption"),s=new Mh(i);return s.set({icon:yu.caption,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.bind("label").to(r,"value",(t=>o(t?"Toggle caption off":"Toggle caption on"))),this.listenTo(s,"execute",(()=>{t.execute("toggleImageCaption",{focusCaptionOnShow:!0});const o=n.getCaptionFromModelSelection(t.model.document.selection);if(o){const n=t.editing.mapper.toViewElement(o);e.scrollToTheSelection(),e.change((t=>{t.addClass("image__caption_highlighted",n)}))}t.editing.view.focus()})),s}))}}class qC extends su{_defaultStyles;_styles;constructor(t,e){super(t),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(e.map((t=>{if(t.isDefault)for(const e of t.modelElements)this._defaultStyles[e]=t.name;return[t.name,t]})))}refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled?t.hasAttribute("imageStyle")?this.value=t.getAttribute("imageStyle"):this.value=this._defaultStyles[t.name]:this.value=!1}execute(t={}){const e=this.editor,n=e.model,o=e.plugins.get("ImageUtils");n.change((e=>{const i=t.value,{setImageSizes:r=!0}=t;let s=o.getClosestSelectedImageElement(n.document.selection);i&&this.shouldConvertImageType(i,s)&&(this.editor.execute(o.isBlockImage(s)?"imageTypeInline":"imageTypeBlock",{setImageSizes:r}),s=o.getClosestSelectedImageElement(n.document.selection)),!i||this._styles.get(i).isDefault?e.removeAttribute("imageStyle",s):e.setAttribute("imageStyle",i,s),r&&o.setImageNaturalSizeAttributes(s)}))}shouldConvertImageType(t,e){return!this._styles.get(t).modelElements.includes(e.name)}}const $C={get inline(){return{name:"inline",title:"In line",icon:yu.objectInline,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:yu.objectLeft,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:yu.objectBlockLeft,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:yu.objectCenter,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:yu.objectRight,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:yu.objectBlockRight,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:yu.objectCenter,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:yu.objectRight,modelElements:["imageBlock"],className:"image-style-side"}}},KC=(()=>({full:yu.objectFullWidth,left:yu.objectBlockLeft,right:yu.objectBlockRight,center:yu.objectCenter,inlineLeft:yu.objectLeft,inlineRight:yu.objectRight,inline:yu.objectInline}))(),YC=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function QC(t){yn("image-style-configuration-definition-invalid",t)}var ZC={normalizeStyles:function(t){return(t.configuredStyles.options||[]).map((t=>{return"string"==typeof(e="string"==typeof(e=t)?$C[e]?{...$C[e]}:{name:e}:function(t,e){const n={...e};for(const o in t)Object.prototype.hasOwnProperty.call(e,o)||(n[o]=t[o]);return n}($C[e.name],e)).icon&&(e.icon=KC[e.icon]||e.icon),e;var e})).filter((e=>function(t,{isBlockPluginLoaded:e,isInlinePluginLoaded:n}){const{modelElements:o,name:i}=t;if(!(o&&o.length&&i))return QC({style:t}),!1;{const i=[e?"imageBlock":null,n?"imageInline":null];if(!o.some((t=>i.includes(t))))return yn("image-style-missing-dependency",{style:t,missingPlugins:o.map((t=>"imageBlock"===t?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(e,t)))},getDefaultStylesConfiguration:function(t,e){return t&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:t?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(t){return t.has("ImageBlockEditing")&&t.has("ImageInlineEditing")?[...YC]:[]},warnInvalidStyle:QC,DEFAULT_OPTIONS:$C,DEFAULT_ICONS:KC,DEFAULT_DROPDOWN_DEFINITIONS:YC};function JC(t,e){for(const n of e)if(n.name===t)return n}class XC extends iu{static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[bC]}normalizedStyles;init(){const{normalizeStyles:t,getDefaultStylesConfiguration:e}=ZC,n=this.editor,o=n.plugins.has("ImageBlockEditing"),i=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",e(o,i)),this.normalizedStyles=t({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:i}),this._setupConversion(o,i),this._setupPostFixer(),n.commands.add("imageStyle",new qC(n,this.normalizedStyles))}_setupConversion(t,e){const n=this.editor,o=n.model.schema,i=(r=this.normalizedStyles,(t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const o=JC(e.attributeNewValue,r),i=JC(e.attributeOldValue,r),s=n.mapper.toViewElement(e.item),a=n.writer;i&&a.removeClass(i.className,s),o&&a.addClass(o.className,s)});var r;const s=function(t){const e={imageInline:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageInline"))),imageBlock:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageBlock")))};return(t,n,o)=>{if(!n.modelRange)return;const i=n.viewItem,r=ai(n.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const t of e[r.name])o.consumable.consume(i,{classes:t.className})&&o.writer.setAttribute("imageStyle",t.name,r)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",i),n.data.downcastDispatcher.on("attribute:imageStyle",i),t&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),e&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",s,{priority:"low"}))}_setupPostFixer(){const t=this.editor,e=t.model.document,n=t.plugins.get(bC),o=new Map(this.normalizedStyles.map((t=>[t.name,t])));e.registerPostFixer((t=>{let i=!1;for(const r of e.differ.getChanges())if("insert"==r.type||"attribute"==r.type&&"imageStyle"==r.attributeKey){let e="insert"==r.type?r.position.nodeAfter:r.range.start.nodeAfter;if(e&&e.is("element","paragraph")&&e.childCount>0&&(e=e.getChild(0)),!n.isImage(e))continue;const s=e.getAttribute("imageStyle");if(!s)continue;const a=o.get(s);a&&a.modelElements.includes(e.name)||(t.removeAttribute("imageStyle",e),i=!0)}return i}))}}class tv extends iu{static get requires(){return[XC]}static get pluginName(){return"ImageStyleUI"}static get isOfficialPlugin(){return!0}get localizedDefaultStylesTitles(){const t=this.editor.t;return{"Wrap text":t("Wrap text"),"Break text":t("Break text"),"In line":t("In line"),"Full size image":t("Full size image"),"Side image":t("Side image"),"Left aligned image":t("Left aligned image"),"Centered image":t("Centered image"),"Right aligned image":t("Right aligned image")}}init(){const t=this.editor.plugins,e=this.editor.config.get("image.toolbar")||[],n=ev(t.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const t of n)this._createButton(t);const i=ev([...e.filter(o),...ZC.getDefaultDropdownDefinitions(t)],this.localizedDefaultStylesTitles);for(const t of i)this._createDropdown(t,n)}_createDropdown(t,e){const n=this.editor.ui.componentFactory;n.add(t.name,(o=>{let i;const{defaultItem:r,items:s,title:a}=t,c=s.filter((t=>e.find((({name:e})=>nv(e)===t)))).map((t=>{const e=n.create(t);return t===r&&(i=e),e}));s.length!==c.length&&ZC.warnInvalidStyle({dropdown:t});const l=jp(o,Fp),d=l.buttonView,u=d.arrowView;return Vp(l,c,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:ov(a,i.label),class:null,tooltip:!0}),u.unbind("label"),u.set({label:a}),d.bind("icon").toMany(c,"isOn",((...t)=>{const e=t.findIndex(qe);return e<0?i.icon:c[e].icon})),d.bind("label").toMany(c,"isOn",((...t)=>{const e=t.findIndex(qe);return ov(a,e<0?i.label:c[e].label)})),d.bind("isOn").toMany(c,"isOn",((...t)=>t.some(qe))),d.bind("class").toMany(c,"isOn",((...t)=>t.some(qe)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{c.some((({isOn:t})=>t))?l.isOpen=!l.isOpen:i.fire("execute")})),l.bind("isEnabled").toMany(c,"isEnabled",((...t)=>t.some(qe))),this.listenTo(l,"execute",(()=>{this.editor.editing.view.focus()})),l}))}_createButton(t){const e=t.name;this.editor.ui.componentFactory.add(nv(e),(n=>{const o=this.editor.commands.get("imageStyle"),i=new Mh(n);return i.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",(t=>t===e)),i.on("execute",this._executeCommand.bind(this,e)),i}))}_executeCommand(t){this.editor.execute("imageStyle",{value:t}),this.editor.editing.view.focus()}}function ev(t,e){for(const n of t)e[n.title]&&(n.title=e[n.title]);return t}function nv(t){return`imageStyle:${t}`}function ov(t,e){return(t?t+": ":"")+e}class iv extends iu{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.commands.add("indent",new cu(t)),t.commands.add("outdent",new cu(t))}}class rv extends iu{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?yu.indent:yu.outdent,i="ltr"==e.uiLanguageDirection?yu.outdent:yu.indent;this._defineButton("indent",n("Increase indent"),o),this._defineButton("outdent",n("Decrease indent"),i)}_defineButton(t,e,n){const o=this.editor;o.ui.componentFactory.add(t,(()=>{const o=this._createButton(Mh,t,e,n);return o.set({tooltip:!0}),o})),o.ui.componentFactory.add("menuBar:"+t,(()=>this._createButton(Yh,t,e,n)))}_createButton(t,e,n,o){const i=this.editor,r=i.commands.get(e),s=new t(i.locale);return s.set({label:n,icon:o}),s.bind("isEnabled").to(r,"isEnabled"),this.listenTo(s,"execute",(()=>{i.execute(e),i.editing.view.focus()})),s}}class sv extends su{_indentBehavior;constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());t&&this._isIndentationChangeAllowed(t)?this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const t=this.editor.model,e=this._getBlocksToChange();t.change((t=>{for(const n of e){const e=n.getAttribute("blockIndent"),o=this._indentBehavior.getNextIndent(e);o?t.setAttribute("blockIndent",o,n):t.removeAttribute("blockIndent",n)}}))}_getBlocksToChange(){const t=this.editor.model.document.selection;return Array.from(t.getSelectedBlocks()).filter((t=>this._isIndentationChangeAllowed(t)))}_isIndentationChangeAllowed(t){const e=this.editor;return!!e.model.schema.checkAttribute(t,"blockIndent")&&(!e.plugins.has("ListUtils")||(!this._indentBehavior.isForward||!e.plugins.get("ListUtils").isListItemBlock(t)))}}class av{isForward;offset;unit;constructor(t){this.isForward="forward"===t.direction,this.offset=t.offset,this.unit=t.unit}checkEnabled(t){const e=parseFloat(t||"0");return this.isForward||e>0}getNextIndent(t){const e=parseFloat(t||"0");if(t&&!t.endsWith(this.unit))return this.isForward?this.offset+this.unit:void 0;const n=e+(this.isForward?this.offset:-this.offset);return n>0?n+this.unit:void 0}}class cv{isForward;classes;constructor(t){this.isForward="forward"===t.direction,this.classes=t.classes}checkEnabled(t){const e=this.classes.indexOf(t);return this.isForward?e=0}getNextIndent(t){const e=this.classes.indexOf(t),n=this.isForward?1:-1;return this.classes[e+n]}}const lv=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];function dv(t,e){return`${t}:${e=e||oi(t)}`}class uv extends su{refresh(){const t=this.editor.model,e=t.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,"language")}execute({languageCode:t,textDirection:e}={}){const n=this.editor.model,o=n.document.selection,i=!!t&&dv(t,e);n.change((t=>{if(o.isCollapsed)i?t.setSelectionAttribute("language",i):t.removeSelectionAttribute("language");else{const e=n.schema.getValidRanges(o.getRanges(),"language");for(const n of e)i?t.setAttribute("language",i,n):t.removeAttribute("language",n)}}))}_getValueFromFirstAllowedNode(){const t=this.editor.model,e=t.schema,n=t.document.selection;if(n.isCollapsed)return n.getAttribute("language")||!1;for(const t of n.getRanges())for(const n of t.getItems())if(e.checkAttribute(n,"language"))return n.getAttribute("language")||!1;return!1}}class hv extends iu{static get pluginName(){return"TextPartLanguageEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"language"}),t.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),t.commands.add("textPartLanguage",new uv(t))}_defineConverters(){const t=this.editor.conversion;t.for("upcast").elementToAttribute({model:{key:"language",value:t=>dv(t.getAttribute("lang"),t.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),t.for("downcast").attributeToElement({model:"language",view:(t,{writer:e},n)=>{if(!t)return;if(!n.item.is("$textProxy")&&!n.item.is("documentSelection"))return;const{languageCode:o,textDirection:i}=function(t){const[e,n]=t.split(":");return{languageCode:e,textDirection:n}}(t);return e.createAttributeElement("span",{lang:o,dir:i})}})}}class pv extends iu{static get pluginName(){return"TextPartLanguageUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.t,n=e("Choose language"),o=e("Language");t.ui.componentFactory.add("textPartLanguage",(e=>{const{definitions:i,titles:r}=this._getItemMetadata(),s=t.commands.get("textPartLanguage"),a=jp(e);return Up(a,i,{ariaLabel:o,role:"menu"}),a.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),a.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),a.bind("isEnabled").to(s,"isEnabled"),a.buttonView.bind("label").to(s,"value",(t=>t&&r[t]||n)),a.buttonView.bind("ariaLabel").to(s,"value",(t=>{const e=t&&r[t];return e?`${e}, ${o}`:o})),this.listenTo(a,"execute",(e=>{s.execute({languageCode:e.source.languageCode,textDirection:e.source.textDirection}),t.editing.view.focus()})),a})),t.ui.componentFactory.add("menuBar:textPartLanguage",(n=>{const{definitions:i}=this._getItemMetadata(),r=t.commands.get("textPartLanguage"),s=new tg(n);s.buttonView.set({label:o});const a=new eg(n);a.set({ariaLabel:e("Language"),role:"menu"});for(const t of i){if("button"!=t.type){a.items.add(new yp(n));continue}const e=new ym(n,s),o=new Yh(n);o.set({role:"menuitemradio",isToggleable:!0}),o.bind(...Object.keys(t.model)).to(t.model),o.delegate("execute").to(s),e.children.add(o),a.items.add(e)}return s.bind("isEnabled").to(r,"isEnabled"),s.panelView.children.add(a),s.on("execute",(e=>{r.execute({languageCode:e.source.languageCode,textDirection:e.source.textDirection}),t.editing.view.focus()})),s}))}_getItemMetadata(){const t=this.editor,e=new si,n={},o=t.commands.get("textPartLanguage"),i=t.config.get("language.textPartLanguage"),r=(0,t.locale.t)("Remove language");e.add({type:"button",model:new Gm({label:r,languageCode:!1,withText:!0})}),e.add({type:"separator"});for(const t of i){const i={type:"button",model:new Gm({label:t.title,languageCode:t.languageCode,role:"menuitemradio",textDirection:t.textDirection,withText:!0})},r=dv(t.languageCode,t.textDirection);i.model.bind("isOn").to(o,"value",(t=>t===r)),e.add(i),n[r]=t.title}return{definitions:e,titles:n}}}class mv{_definitions=new Set;get length(){return this._definitions.size}add(t){Array.isArray(t)?t.forEach((t=>this._definitions.add(t))):this._definitions.add(t)}getDispatcher(){return t=>{t.on("attribute:linkHref",((t,e,n)=>{if(!n.consumable.test(e.item,"attribute:linkHref"))return;if(!e.item.is("selection")&&!n.schema.isInline(e.item))return;const o=n.writer,i=o.document.selection;for(const t of this._definitions){const r=o.createAttributeElement("a",t.attributes,{priority:5});t.classes&&o.addClass(t.classes,r);for(const e in t.styles)o.setStyle(e,t.styles[e],r);o.setCustomProperty("link",!0,r),t.callback(e.attributeNewValue)?e.item.is("selection")?o.wrap(i.getFirstRange(),r):o.wrap(n.mapper.toViewRange(e.range),r):o.unwrap(n.mapper.toViewRange(e.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",((t,e,{writer:n,mapper:o})=>{const i=o.toViewElement(e.item),r=Array.from(i.getChildren()).find((t=>t.is("element","a")));if(r)for(const t of this._definitions){const o=pi(t.attributes);if(t.callback(e.attributeNewValue)){for(const[t,e]of o)"class"===t?n.addClass(e,r):n.setAttribute(t,e,r);t.classes&&n.addClass(t.classes,r);for(const e in t.styles)n.setStyle(e,t.styles[e],r)}else{for(const[t,e]of o)"class"===t?n.removeClass(e,r):n.removeAttribute(t,r);t.classes&&n.removeClass(t.classes,r);for(const e in t.styles)n.removeStyle(e,r)}}}))}}}const gv=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,fv=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,kv=/^((\w+:(\/{2,})?)|(\W))/i,bv=["https?","ftps?","mailto"],wv="Ctrl+K";function _v(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,n),n}function Cv(t,e=bv){const n=String(t),o=e.join("|");return function(t,e){return!!t.replace(gv,"").match(e)}(n,new RegExp(`${"^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("",o)}`,"i"))?n:"#"}function vv(t,e){return!!t&&e.checkAttribute(t.name,"linkHref")}function Av(t,e){const n=(o=t,fv.test(o)?"mailto:":e);var o;const i=!!n&&!yv(t);return t&&i?n+t:t}function yv(t){return kv.test(t)}function xv(t){window.open(t,"_blank","noopener")}function Ev(t){const e=t.plugins.has("BookmarkEditing")?t.plugins.get("BookmarkEditing"):null;return{isScrollableToTarget:function(t){return!!t&&t.startsWith("#")&&!!e&&!!e.getElementForBookmarkId(t.slice(1))},scrollToTarget:function(n){const o=n.slice(1),i=e.getElementForBookmarkId(o);t.model.change((t=>{t.setSelection(i,"on")})),t.editing.view.scrollToTheSelection({alignToTop:!0,forceScroll:!0})}}}class Dv extends su{manualDecorators=new si;automaticDecorators=new mv;restoreManualDecoratorStates(){for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement()||ai(e.getSelectedBlocks());vv(n,t.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttribute(n,"linkHref")):(this.value=e.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref"));for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}execute(t,e={}){const n=this.editor.model,o=n.document.selection,i=[],r=[];for(const t in e)e[t]?i.push(t):r.push(t);n.change((e=>{if(o.isCollapsed){const s=o.getFirstPosition();if(o.hasAttribute("linkHref")){const a=Sv(o);let c=Ug(s,"linkHref",o.getAttribute("linkHref"),n);o.getAttribute("linkHref")===a&&(c=this._updateLinkContent(n,e,c,t)),e.setAttribute("linkHref",t,c),i.forEach((t=>{e.setAttribute(t,!0,c)})),r.forEach((t=>{e.removeAttribute(t,c)})),e.setSelection(e.createPositionAfter(c.end.nodeBefore))}else if(""!==t){const r=pi(o.getAttributes());r.set("linkHref",t),i.forEach((t=>{r.set(t,!0)}));const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...i,...r].forEach((t=>{e.removeSelectionAttribute(t)}))}else{const s=n.schema.getValidRanges(o.getRanges(),"linkHref"),a=[];for(const t of o.getSelectedBlocks())n.schema.checkAttribute(t,"linkHref")&&a.push(e.createRangeOn(t));const c=a.slice();for(const t of s)this._isRangeToUpdate(t,a)&&c.push(t);for(const s of c){let a=s;if(1===c.length){const i=Sv(o);o.getAttribute("linkHref")===i&&(a=this._updateLinkContent(n,e,s,t),e.setSelection(e.createSelection(a)))}e.setAttribute("linkHref",t,a),i.forEach((t=>{e.setAttribute(t,!0,a)})),r.forEach((t=>{e.removeAttribute(t,a)}))}}}))}_getDecoratorStateFromModel(t){const e=this.editor.model,n=e.document.selection,o=n.getSelectedElement();return vv(o,e.schema)?o.getAttribute(t):n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e)if(n.containsRange(t))return!1;return!0}_updateLinkContent(t,e,n,o){const i=e.createText(o,{linkHref:o});return t.insertContent(i,n)}}function Sv(t){if(t.isCollapsed){const e=t.getFirstPosition();return e.textNode&&e.textNode.data}{const e=Array.from(t.getFirstRange().getItems());if(e.length>1)return null;const n=e[0];return n.is("$text")||n.is("$textProxy")?n.data:null}}class Tv extends su{refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement();vv(n,t.schema)?this.isEnabled=t.schema.checkAttribute(n,"linkHref"):this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}execute(){const t=this.editor,e=this.editor.model,n=e.document.selection,o=t.commands.get("link");e.change((t=>{const i=n.isCollapsed?[Ug(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of i)if(t.removeAttribute("linkHref",e),o)for(const n of o.manualDecorators)t.removeAttribute(n.id,e)}))}}class Bv extends(qn()){id;defaultValue;label;attributes;classes;styles;constructor({id:t,label:e,attributes:n,classes:o,styles:i,defaultValue:r}){super(),this.id=t,this.set("value",void 0),this.defaultValue=r,this.label=e,this.attributes=n,this.classes=o,this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const Iv="automatic",Mv=/^(https?:)?\/\//;class Pv extends iu{static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ng,_g,Dk]}constructor(t){super(t),t.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1})}init(){const t=this.editor,e=this.editor.config.get("link.allowedProtocols");t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:_v}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,n)=>_v(Cv(t,e),n)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new Dv(t)),t.commands.add("unlink",new Tv(t));const n=function(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach((t=>("label"in t&&n[t.label]&&(t.label=n[t.label]),t))),e}(t.t,function(t){const e=[];if(t)for(const[n,o]of Object.entries(t)){const t=Object.assign({},o,{id:`link${T_(n)}`});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(n.filter((t=>t.mode===Iv))),this._enableManualDecorators(n.filter((t=>"manual"===t.mode))),t.plugins.get(Ng).registerAttribute("linkHref"),Gg(t,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_enableAutomaticDecorators(t){const e=this.editor,n=e.commands.get("link").automaticDecorators;e.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:Iv,callback:t=>!!t&&Mv.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(t),n.length&&e.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(t){if(!t.length)return;const e=this.editor,n=e.commands.get("link").manualDecorators;t.forEach((t=>{e.model.schema.extend("$text",{allowAttributes:t.id});const o=new Bv(t);n.add(o),e.conversion.for("downcast").attributeToElement({model:o.id,view:(t,{writer:e,schema:n},{item:i})=>{if((i.is("selection")||n.isInline(i))&&t){const t=e.createAttributeElement("a",o.attributes,{priority:5});o.classes&&e.addClass(o.classes,t);for(const n in o.styles)e.setStyle(n,o.styles[n],t);return e.setCustomProperty("link",!0,t),t}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",...o._createPattern()},model:{key:o.id}})}))}_enableLinkOpen(){const t=this.editor,e=t.editing.view.document,n=Ev(t);function o(t){n.isScrollableToTarget(t)?n.scrollToTarget(t):xv(t)}this.listenTo(e,"click",((t,e)=>{if(!(rn.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey))return;let n=e.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const i=n.getAttribute("href");i&&(t.stop(),e.preventDefault(),o(i))}),{context:"$capture"}),this.listenTo(e,"keydown",((e,n)=>{const i=t.commands.get("link").value;i&&n.keyCode===Yo.enter&&n.altKey&&(e.stop(),o(i))}))}_enableSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection;this.listenTo(e,"change:attribute",((n,{attributeKeys:o})=>{o.includes("linkHref")&&!e.hasAttribute("linkHref")&&t.change((e=>{var n;!function(t,e){t.removeSelectionAttribute("linkHref");for(const n of e)t.removeSelectionAttribute(n)}(e,(n=t.schema,n.getDefinition("$text").allowAttributes.filter((t=>t.startsWith("link")))))}))}))}_enableClipboardIntegration(){const t=this.editor,e=t.model,n=this.editor.config.get("link.defaultProtocol");n&&this.listenTo(t.plugins.get("ClipboardPipeline"),"contentInsertion",((t,o)=>{e.change((t=>{const e=t.createRangeIn(o.content);for(const o of e.getItems())if(o.hasAttribute("linkHref")){const e=Av(o.getAttribute("linkHref"),n);t.setAttribute("linkHref",e,o)}}))}))}}class Ov extends xh{focusTracker=new ci;keystrokes=new hi;urlInputView;saveButtonView;cancelButtonView;_manualDecoratorSwitches;children;_validators;_focusables=new oh;_focusCycler;constructor(t,e,n){super(t);const o=t.t;this._validators=n,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(o("Save"),yu.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(o("Cancel"),yu.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const i=["ck","ck-link-form","ck-responsive-form"];e.manualDecorators.length&&i.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:i,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((t,e)=>(t[e.name]=e.isOn,t)),{})}render(){super.render(),Sh({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const t of this._validators){const e=t(this);if(e)return this.urlInputView.errorText=e,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createUrlInput(){const t=this.locale.t,e=new gp(this.locale,Kp);return e.fieldView.inputMode="url",e.label=t("Link URL"),e}_createButton(t,e,n,o){const i=new Mh(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const o=new np(this.locale);o.set({name:n.id,label:n.label,withText:!0}),o.bind("isOn").toMany([n,t],"value",((t,e)=>void 0===e&&void 0===t?!!n.defaultValue:!!t)),o.on("execute",(()=>{n.set("value",!o.isOn)})),e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new xh;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),e.add(t)}return e.add(this.saveButtonView),e.add(this.cancelButtonView),e}get url(){const{element:t}=this.urlInputView.fieldView;return t?t.value.trim():null}}class Nv extends xh{focusTracker=new ci;keystrokes=new hi;previewButtonView;unlinkButtonView;editButtonView;_focusables=new oh;_focusCycler;_linkConfig;_options;constructor(t,e={},n){super(t);const o=t.t;this._options=n,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(o("Unlink"),' ',"unlink"),this.editButtonView=this._createButton(o("Edit link"),yu.pencil,"edit"),this.set("href",void 0),this._linkConfig=e,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(t,e,n){const o=new Mh(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.delegate("execute").to(this,n),o}_createPreviewButton(){const t=new Mh(this.locale),e=this.bindTemplate,n=this.t;return t.set({withText:!0}),t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",(t=>t&&Cv(t,this._linkConfig.allowedProtocols))),target:"_blank",rel:"noopener noreferrer"},on:{click:e.to((t=>{this._options&&this._options.isScrollableToTarget(this.href)?(t.preventDefault(),this._options.scrollToTarget(this.href)):xv(this.href)}))}}),t.bind("tooltip").to(this,"href",(t=>this._options&&this._options.isScrollableToTarget(t)?n("Scroll to target"):n("Open link in new tab"))),t.bind("label").to(this,"href",(t=>t||n("This link has no URL"))),t.bind("isEnabled").to(this,"href",(t=>!!t)),t.template.tag="a",t}}var zv=' ';const Lv="link-ui";class Rv extends iu{actionsView=null;formView=null;_balloon;static get requires(){return[$m]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.editing.view.addObserver(rd),this._balloon=t.plugins.get($m),this._createToolbarLinkButton(),this._enableBalloonActivators(),t.conversion.for("editingDowncast").markerToHighlight({model:Lv,view:{classes:["ck-fake-link-selection"]}}),t.conversion.for("editingDowncast").markerToElement({model:Lv,view:(t,{writer:e})=>{if(!t.markerRange.isCollapsed)return null;const n=e.createUIElement("span");return e.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],n),n}}),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Create link"),keystroke:wv},{label:e("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const t=this.editor,e=new Nv(t.locale,t.config.get("link"),Ev(t)),n=t.commands.get("link"),o=t.commands.get("unlink");return e.bind("href").to(n,"value"),e.editButtonView.bind("isEnabled").to(n),e.unlinkButtonView.bind("isEnabled").to(o),this.listenTo(e,"edit",(()=>{this._addFormView()})),this.listenTo(e,"unlink",(()=>{t.execute("unlink"),this._hideUI()})),e.keystrokes.set("Esc",((t,e)=>{this._hideUI(),e()})),e.keystrokes.set(wv,((t,e)=>{this._addFormView(),e()})),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),n=t.config.get("link.defaultProtocol"),o=new(Dh(Ov))(t.locale,e,function(t){const e=t.t,n=t.config.get("link.allowCreatingEmptyLinks");return[t=>{if(!n&&!t.url.length)return e("Link URL must not be empty.")}]}(t));return o.urlInputView.fieldView.bind("value").to(e,"value"),o.urlInputView.bind("isEnabled").to(e,"isEnabled"),o.saveButtonView.bind("isEnabled").to(e,"isEnabled"),this.listenTo(o,"submit",(()=>{if(o.isValid()){const{value:e}=o.urlInputView.fieldView.element,i=Av(e,n);t.execute("link",i,o.getDecoratorSwitchesState()),this._closeFormView()}})),this.listenTo(o.urlInputView,"change:errorText",(()=>{t.ui.update()})),this.listenTo(o,"cancel",(()=>{this._closeFormView()})),o.keystrokes.set("Esc",((t,e)=>{this._closeFormView(),e()})),o}_createToolbarLinkButton(){const t=this.editor;t.ui.componentFactory.add("link",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add("menuBar:link",(()=>{const t=this._createButton(Yh);return t.set({role:"menuitemcheckbox"}),t}))}_createButton(t){const e=this.editor,n=e.locale,o=e.commands.get("link"),i=new t(e.locale),r=n.t;return i.set({label:r("Link"),icon:zv,keystroke:wv,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",(t=>!!t)),this.listenTo(i,"execute",(()=>this._showUI(!0))),i}_enableBalloonActivators(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),t.keystrokes.set(wv,((e,n)=>{n(),t.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((t,e)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),e())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((t,e)=>{this._isUIVisible&&(this._hideUI(),e())})),Eh({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const t=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.urlInputView.fieldView.value=t.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates(),void 0!==t.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(t=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),t&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),t&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),t.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const t=this.editor,e=t.editing.view.document;let n=this._getSelectedLinkElement(),o=r();const i=()=>{const t=this._getSelectedLinkElement(),e=r();n&&!t||!n&&e!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=t,o=e};function r(){return e.selection.focus.getAncestors().reverse().find((t=>t.is("element")))}this.listenTo(t.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const t=this._balloon.visibleView;return!!this.formView&&t==this.formView||this._areActionsVisible}_getBalloonPositionData(){const t=this.editor.editing.view,e=this.editor.model,n=t.document;let o;if(e.markers.has(Lv)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(Lv)),n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));o=t.domConverter.viewRangeToDom(n)}else o=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:o}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection,n=e.getSelectedElement();if(e.isCollapsed||n&&$f(n))return Fv(e.getFirstPosition());{const n=e.getFirstRange().getTrimmed(),o=Fv(n.start),i=Fv(n.end);return o&&o==i&&t.createRangeIn(o).getTrimmed().isEqual(n)?o:null}}_showFakeVisualSelection(){const t=this.editor.model;t.change((e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(Lv))e.updateMarker(Lv,{range:n});else if(n.start.isAtEnd){const o=n.start.getLastMatchingPosition((({item:e})=>!t.schema.isContent(e)),{boundaries:n});e.addMarker(Lv,{usingOperation:!1,affectsData:!1,range:e.createRange(o,n.end)})}else e.addMarker(Lv,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const t=this.editor.model;t.markers.has(Lv)&&t.change((t=>{t.removeMarker(Lv)}))}}function Fv(t){return t.getAncestors().find((t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e}))||null}const jv=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");function Vv(t){const e=jv.exec(t);return e?e[2]:null}class Hv extends iu{static get requires(){return["ImageEditing","ImageUtils",Pv]}static get pluginName(){return"LinkImageEditing"}static get isOfficialPlugin(){return!0}afterInit(){const t=this.editor,e=t.model.schema;t.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["linkHref"]}),t.conversion.for("upcast").add(function(t){const e=t.plugins.has("ImageInlineEditing"),n=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,o,i)=>{const r=o.viewItem,s=n.findViewImgElement(r);if(!s)return;const a=s.findAncestor((t=>n.isBlockImageView(t)));if(e&&!a)return;if(!i.consumable.consume(r,{attributes:["href"]}))return;const c=r.getAttribute("href");if(!c)return;let l=o.modelCursor.parent;if(!l.is("element","imageBlock")){const t=i.convertItem(s,o.modelCursor);o.modelRange=t.modelRange,o.modelCursor=t.modelCursor,l=o.modelCursor.nodeBefore}l&&l.is("element","imageBlock")&&i.writer.setAttribute("linkHref",c,l)}),{priority:"high"})}}(t)),t.conversion.for("downcast").add(function(t){const e=t.plugins.get("ImageUtils");return t=>{t.on("attribute:linkHref:imageBlock",((t,n,o)=>{if(!o.consumable.consume(n.item,t.name))return;const i=o.mapper.toViewElement(n.item),r=o.writer,s=Array.from(i.getChildren()).find((t=>t.is("element","a"))),a=e.findViewImgElement(i),c=a.parent.is("element","picture")?a.parent:a;if(s)n.attributeNewValue?r.setAttribute("href",n.attributeNewValue,s):(r.move(r.createRangeOn(c),r.createPositionAt(i,0)),r.remove(s));else{const t=r.createContainerElement("a",{href:n.attributeNewValue});r.insert(r.createPositionAt(i,0),t),r.move(r.createRangeOn(c),r.createPositionAt(t,0))}}),{priority:"high"})}}(t)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const t=this.editor,e=t.commands.get("link").automaticDecorators;e.length&&t.conversion.for("downcast").add(e.getDispatcherForLinkedImage())}_enableManualDecorators(){const t=this.editor,e=t.commands.get("link");for(const n of e.manualDecorators)t.plugins.has("ImageBlockEditing")&&t.model.schema.extend("imageBlock",{allowAttributes:n.id}),t.plugins.has("ImageInlineEditing")&&t.model.schema.extend("imageInline",{allowAttributes:n.id}),t.conversion.for("downcast").add(Uv(n)),t.conversion.for("upcast").add(Wv(t,n))}}function Uv(t){return e=>{e.on(`attribute:${t.id}:imageBlock`,((e,n,o)=>{const i=o.mapper.toViewElement(n.item),r=Array.from(i.getChildren()).find((t=>t.is("element","a")));if(r){for(const[e,n]of pi(t.attributes))o.writer.setAttribute(e,n,r);t.classes&&o.writer.addClass(t.classes,r);for(const e in t.styles)o.writer.setStyle(e,t.styles[e],r)}}))}}function Wv(t,e){const n=t.plugins.has("ImageInlineEditing"),o=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,i,r)=>{const s=i.viewItem,a=o.findViewImgElement(s);if(!a)return;const c=a.findAncestor((t=>o.isBlockImageView(t)));if(n&&!c)return;const l=new Ir(e._createPattern()).match(s);if(!l)return;if(!r.consumable.consume(s,l.match))return;const d=i.modelCursor.nodeBefore||i.modelCursor.parent;r.writer.setAttribute(e.id,!0,d)}),{priority:"high"})}}class Gv extends iu{static get requires(){return[Pv,Rv,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"click",((e,n)=>{this._isSelectedLinkedImage(t.model.document.selection)&&(n.preventDefault(),e.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const t=this.editor,e=t.t;t.ui.componentFactory.add("linkImage",(n=>{const o=new Mh(n),i=t.plugins.get("LinkUI"),r=t.commands.get("link");return o.set({isEnabled:!0,label:e("Link image"),icon:zv,keystroke:wv,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(r,"isEnabled"),o.bind("isOn").to(r,"value",(t=>!!t)),this.listenTo(o,"execute",(()=>{this._isSelectedLinkedImage(t.model.document.selection)?i._addActionsView():i._showUI(!0)})),o}))}_isSelectedLinkedImage(t){const e=t.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(e)&&e.hasAttribute("linkHref")}}class qv{_startElement;_referenceIndent;_isForward;_includeSelf;_sameAttributes;_sameIndent;_lowerIndent;_higherIndent;constructor(t,e){this._startElement=t,this._referenceIndent=t.getAttribute("listIndent"),this._isForward="forward"==e.direction,this._includeSelf=!!e.includeSelf,this._sameAttributes=ii(e.sameAttributes||[]),this._sameIndent=!!e.sameIndent,this._lowerIndent=!!e.lowerIndent,this._higherIndent=!!e.higherIndent}static first(t,e){return ai(new this(t,e)[Symbol.iterator]())}*[Symbol.iterator](){const t=[];for(const{node:e}of $v(this._getStartNode(),this._isForward?"forward":"backward")){const n=e.getAttribute("listIndent");if(nthis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){t.push(e);continue}}else{if(!this._sameIndent){if(this._higherIndent){t.length&&(yield*t,t.length=0);break}continue}if(this._sameAttributes.some((t=>e.getAttribute(t)!==this._startElement.getAttribute(t))))break}t.length&&(yield*t,t.length=0),yield e}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}function*$v(t,e="forward"){const n="forward"==e,o=[];let i=null;for(;Qv(t);){let e=null;if(i){const n=t.getAttribute("listIndent"),r=i.getAttribute("listIndent");n>r?o[r]=i:nt.getAttribute("listItemId")!=e))}function lA(t){return Array.from(t).filter((t=>"$graveyard"!==t.root.rootName)).sort(((t,e)=>t.index-e.index))}function dA(t){const e=t.document.selection.getSelectedElement();return e&&t.schema.isObject(e)&&t.schema.isBlock(e)?e:null}function uA(t,e){return e.checkChild(t.parent,"listItem")&&e.checkChild(t,"$text")&&!e.isObject(t)}function hA(t){return"numbered"==t||"customNumbered"==t}function pA(t,e,n){return Jv(e,{direction:"forward"}).pop().index>t.index?rA(t,e,n):[]}class mA extends su{_direction;constructor(t,e){super(t),this._direction=e}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=gA(t.document.selection);t.change((t=>{const n=[];cA(e)&&!tA(e[0])?("forward"==this._direction&&n.push(...sA(e,t)),n.push(...iA(e[0],t))):"forward"==this._direction?n.push(...sA(e,t,{expand:!0})):n.push(...function(t,e){const n=nA(t=ii(t)),o=new Set,i=Math.min(...n.map((t=>t.getAttribute("listIndent")))),r=new Map;for(const t of n)r.set(t,qv.first(t,{lowerIndent:!0}));for(const t of n){if(o.has(t))continue;o.add(t);const n=t.getAttribute("listIndent")-1;if(n<0)aA(t,e);else{if(t.getAttribute("listIndent")==i){const n=pA(t,r.get(t),e);for(const t of n)o.add(t);if(n.length)continue}e.setAttribute("listIndent",n,t)}}return lA(o)}(e,t));for(const e of n){if(!e.hasAttribute("listType"))continue;const n=qv.first(e,{sameIndent:!0});n&&t.setAttribute("listType",n.getAttribute("listType"),e)}this._fireAfterExecute(n)}))}_fireAfterExecute(t){this.fire("afterExecute",lA(new Set(t)))}_checkEnabled(){let t=gA(this.editor.model.document.selection),e=t[0];if(!e)return!1;if("backward"==this._direction)return!0;if(cA(t)&&!tA(t[0]))return!0;t=nA(t),e=t[0];const n=qv.first(e,{sameIndent:!0});return!!n&&n.getAttribute("listType")==e.getAttribute("listType")}}function gA(t){const e=Array.from(t.getSelectedBlocks()),n=e.findIndex((t=>!Qv(t)));return-1!=n&&(e.length=n),e}class fA extends su{type;_listWalkerOptions;constructor(t,e,n={}){super(t),this.type=e,this._listWalkerOptions=n.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document,o=dA(e),i=Array.from(n.selection.getSelectedBlocks()).filter((t=>e.schema.checkAttribute(t,"listType")||uA(t,e.schema))),r=void 0!==t.forceValue?!t.forceValue:this.value;e.change((s=>{if(r){const t=i[i.length-1],e=Jv(t,{direction:"forward"}),n=[];e.length>1&&n.push(...iA(e[1],s)),n.push(...aA(i,s)),n.push(...function(t,e){const n=[];let o=Number.POSITIVE_INFINITY;for(const{node:i}of $v(t.nextSibling,"forward")){const t=i.getAttribute("listIndent");if(0==t)break;t{const{firstElement:r,lastElement:s}=this._getMergeSubjectElements(n,t),a=r.getAttribute("listIndent")||0,c=s.getAttribute("listIndent"),l=s.getAttribute("listItemId");if(a!=c){const t=(d=s,Array.from(new qv(d,{direction:"forward",higherIndent:!0})));o.push(...sA([s,...t],i,{indentBy:a-c,expand:a{const e=iA(this._getStartBlock(),t);this._fireAfterExecute(e)}))}_fireAfterExecute(t){this.fire("afterExecute",lA(new Set(t)))}_checkEnabled(){const t=this.editor.model.document.selection,e=this._getStartBlock();return t.isCollapsed&&Qv(e)&&!tA(e)}_getStartBlock(){const t=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?t:t.nextSibling}}class wA extends iu{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(t){return oA(t)}isFirstBlockOfListItem(t){return tA(t)}isListItemBlock(t){return Qv(t)}expandListBlocksToCompleteItems(t,e={}){return nA(t,e)}isNumberedListType(t){return hA(t)}}function _A(t){return t.is("element","ol")||t.is("element","ul")}function CA(t){return t.is("element","li")}function vA(t,e,n,o=xA(n,e)){return t.createAttributeElement(yA(n),null,{priority:2*e/100-100,id:o})}function AA(t,e,n){return t.createAttributeElement("li",null,{priority:(2*e+1)/100-100,id:n})}function yA(t){return"numbered"==t||"customNumbered"==t?"ol":"ul"}function xA(t,e){return`list-${t}-${e}`}function EA(t,e){const n=t.nodeBefore;if(Qv(n)){let t=n;for(const{node:n}of $v(t,"backward"))if(t=n,e.has(t))return;e.set(n,t)}else{const n=t.nodeAfter;Qv(n)&&e.set(n,n)}}function DA(t,e,n,{dataPipeline:o}={}){const i=function(t){return(e,n)=>{const o=[];for(const n of t)e.hasAttribute(n)&&o.push(`attribute:${n}`);return!!o.every((t=>!1!==n.test(e,t)))&&(o.forEach((t=>n.consume(e,t))),!0)}}(t);return(r,s,a)=>{const{writer:c,mapper:l,consumable:d}=a,u=s.item;if(!t.includes(s.attributeKey))return;if(!i(u,d))return;const h=function(t,e,n){const o=n.createRangeOn(t);return e.toViewRange(o).getTrimmed().end.nodeBefore}(u,l,n);TA(h,c,l),function(t,e){let n=t.parent;for(;n.is("attributeElement")&&["ul","ol","li"].includes(n.name);){const o=n.parent;e.unwrap(e.createRangeOn(t),n),n=o}}(h,c);const p=function(t,e,n,o,{dataPipeline:i}){let r=o.createRangeOn(e);if(!tA(t))return r;for(const s of n){if("itemMarker"!=s.scope)continue;const n=s.createElement(o,t,{dataPipeline:i});if(!n)continue;if(o.setCustomProperty("listItemMarker",!0,n),s.canInjectMarkerIntoElement&&s.canInjectMarkerIntoElement(t)?o.insert(o.createPositionAt(e,0),n):(o.insert(r.start,n),r=o.createRange(o.createPositionBefore(n),o.createPositionAfter(e))),!s.createWrapperElement||!s.canWrapElement)continue;const a=s.createWrapperElement(o,t,{dataPipeline:i});o.setCustomProperty("listItemWrapper",!0,a),s.canWrapElement(t)?r=o.wrap(r,a):(r=o.wrap(o.createRangeOn(n),a),r=o.createRange(r.start,o.createPositionAfter(e)))}return r}(u,h,e,c,{dataPipeline:o});!function(t,e,n,o){if(!t.hasAttribute("listIndent"))return;const i=t.getAttribute("listIndent");let r=t;for(let t=i;t>=0;t--){const i=AA(o,t,r.getAttribute("listItemId")),s=vA(o,t,r.getAttribute("listType"));for(const t of n)"list"!=t.scope&&"item"!=t.scope||!r.hasAttribute(t.attributeName)||t.setAttributeOnDowncast(o,r.getAttribute(t.attributeName),"list"==t.scope?s:i);if(e=o.wrap(e,i),e=o.wrap(e,s),0==t)break;if(r=qv.first(r,{lowerIndent:!0}),!r)break}}(u,p,e,c)}}function SA(t,{dataPipeline:e}={}){return(n,{writer:o})=>{if(!BA(n,t))return null;if(!e)return o.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const i=o.createContainerElement("p");return o.setCustomProperty("dataPipeline:transparentRendering",!0,i),i}}function TA(t,e,n){for(;t.parent.is("attributeElement")&&t.parent.getCustomProperty("listItemWrapper");)e.unwrap(e.createRangeOn(t),t.parent);const o=[];i(e.createPositionBefore(t).getWalker({direction:"backward"})),i(e.createRangeIn(t).getWalker());for(const t of o)e.remove(t);function i(t){for(const{item:e}of t){if(e.is("element")&&n.toModelElement(e))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&o.push(e)}}}function BA(t,e,n=Zv(t)){if(!Qv(t))return!1;for(const n of t.getAttributeKeys())if(!n.startsWith("selection:")&&!e.includes(n))return!1;return n.length<2}const IA=["listType","listIndent","listItemId"];class MA extends iu{_downcastStrategies=[];static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Mf,Ig,wA,Dk]}constructor(t){super(t),t.config.define("list.multiBlock",!0)}init(){const t=this.editor,e=t.model,n=t.config.get("list.multiBlock");if(t.plugins.has("LegacyListEditing"))throw new An("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});e.schema.register("$listItem",{allowAttributes:IA}),n?(e.schema.extend("$container",{allowAttributesOf:"$listItem"}),e.schema.extend("$block",{allowAttributesOf:"$listItem"}),e.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):e.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const t of IA)e.schema.setAttributeProperties(t,{copyOnReplace:!0});t.commands.add("numberedList",new fA(t,"numbered")),t.commands.add("bulletedList",new fA(t,"bulleted")),t.commands.add("customNumberedList",new fA(t,"customNumbered",{multiLevel:!0})),t.commands.add("customBulletedList",new fA(t,"customBulleted",{multiLevel:!0})),t.commands.add("indentList",new mA(t,"forward")),t.commands.add("outdentList",new mA(t,"backward")),t.commands.add("splitListItemBefore",new bA(t,"before")),t.commands.add("splitListItemAfter",new bA(t,"after")),n&&(t.commands.add("mergeListItemBackward",new kA(t,"backward")),t.commands.add("mergeListItemForward",new kA(t,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const t=this.editor.commands,e=t.get("indent"),n=t.get("outdent");e&&e.registerChildCommand(t.get("indentList"),{priority:"high"}),n&&n.registerChildCommand(t.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(t){this._downcastStrategies.push(t)}getListAttributeNames(){return[...IA,...this._downcastStrategies.map((t=>t.attributeName))]}_setupDeleteIntegration(){const t=this.editor,e=t.commands.get("mergeListItemBackward"),n=t.commands.get("mergeListItemForward");this.listenTo(t.editing.view.document,"delete",((o,i)=>{const r=t.model.document.selection;dA(t.model)||t.model.change((()=>{const s=r.getFirstPosition();if(r.isCollapsed&&"backward"==i.direction){if(!s.isAtStart)return;const n=s.parent;if(!Qv(n))return;if(qv.first(n,{sameAttributes:"listType",sameIndent:!0})||0!==n.getAttribute("listIndent")){if(!e||!e.isEnabled)return;e.execute({shouldMergeOnBlocksContentLevel:PA(t.model,"backward")})}else eA(n)||t.execute("splitListItemAfter"),t.execute("outdentList");i.preventDefault(),o.stop()}else{if(r.isCollapsed&&!r.getLastPosition().isAtEnd)return;if(!n||!n.isEnabled)return;n.execute({shouldMergeOnBlocksContentLevel:PA(t.model,"forward")}),i.preventDefault(),o.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const t=this.editor,e=t.model,n=t.commands,o=n.get("enter");this.listenTo(t.editing.view.document,"enter",((n,o)=>{const i=e.document,r=i.selection.getFirstPosition().parent;if(i.selection.isCollapsed&&Qv(r)&&r.isEmpty&&!o.isSoft){const e=tA(r),i=eA(r);e&&i?(t.execute("outdentList"),o.preventDefault(),n.stop()):e&&!i?(t.execute("splitListItemAfter"),o.preventDefault(),n.stop()):i&&(t.execute("splitListItemBefore"),o.preventDefault(),n.stop())}}),{context:"li"}),this.listenTo(o,"afterExecute",(()=>{const e=n.get("splitListItemBefore");e.refresh(),e.isEnabled&&2===Zv(t.model.document.selection.getLastPosition().parent).length&&e.execute()}))}_setupTabIntegration(){const t=this.editor;this.listenTo(t.editing.view.document,"tab",((e,n)=>{const o=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(o).isEnabled&&(t.execute(o),n.stopPropagation(),n.preventDefault(),e.stop())}),{context:"li"})}_setupConversion(){const t=this.editor,e=t.model,n=this.getListAttributeNames(),o=t.config.get("list.multiBlock"),i=o?"paragraph":"listItem";t.conversion.for("upcast").elementToElement({view:"li",model:(t,{writer:e})=>e.createElement(i,{listType:""})}).elementToElement({view:"p",model:(t,{writer:e})=>t.parent&&t.parent.is("element","li")?e.createElement(i,{listType:""}):null,converterPriority:"high"}).add((t=>{t.on("element:li",((t,e,n)=>{const{writer:o,schema:i}=n;if(!e.modelRange)return;const r=Array.from(e.modelRange.getItems({shallow:!0})).filter((t=>i.checkAttribute(t,"listItemId")));if(!r.length)return;const s=Yv.next(),a=function(t){let e=0,n=t.parent;for(;n;){if(CA(n))e++;else{const t=n.previousSibling;t&&CA(t)&&e++}n=n.parent}return e}(e.viewItem);let c=e.viewItem.parent&&e.viewItem.parent.is("element","ol")?"numbered":"bulleted";const l=r[0].getAttribute("listType");l&&(c=l);const d={listItemId:s,listIndent:a,listType:c};for(const t of r)t.hasAttribute("listItemId")||o.setAttributes(d,t);r.length>1&&r[1].getAttribute("listItemId")!=d.listItemId&&n.keepEmptyElement(r[0])}))})),o||t.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),t.conversion.for("editingDowncast").elementToElement({model:i,view:SA(n),converterPriority:"high"}).add((t=>{var o;t.on("attribute",DA(n,this._downcastStrategies,e)),t.on("remove",(o=e.schema,(t,e,n)=>{const{writer:i,mapper:r}=n,s=t.name.split(":")[1];if(!o.checkAttribute(s,"listItemId"))return;const a=r.toViewPosition(e.position),c=e.position.getShiftedBy(e.length),l=r.toViewPosition(c,{isPhantom:!0}),d=i.createRange(a,l).getTrimmed().end.nodeBefore;d&&TA(d,i,r)}))})),t.conversion.for("dataDowncast").elementToElement({model:i,view:SA(n,{dataPipeline:!0}),converterPriority:"high"}).add((t=>{t.on("attribute",DA(n,this._downcastStrategies,e,{dataPipeline:!0}))}));const r=(s=this._downcastStrategies,a=t.editing.view,(t,e)=>{if(e.modelPosition.offset>0)return;const n=e.modelPosition.parent;if(!Qv(n))return;if(!s.some((t=>"itemMarker"==t.scope&&t.canInjectMarkerIntoElement&&t.canInjectMarkerIntoElement(n))))return;const o=e.mapper.toViewElement(n),i=a.createRangeIn(o),r=i.getWalker();let c=i.start;for(const{item:t}of r){if(t.is("element")&&e.mapper.toModelElement(t)||t.is("$textProxy"))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&(c=a.createPositionAfter(t),r.skip((({previousPosition:t})=>!t.isEqual(c))))}e.viewPosition=c});var s,a;t.editing.mapper.on("modelToViewPosition",r),t.data.mapper.on("modelToViewPosition",r),this.listenTo(e.document,"change:data",function(t,e,n,o){return()=>{const o=t.document.differ.getChanges(),s=[],a=new Map,c=new Set;for(const t of o)if("insert"==t.type&&"$text"!=t.name)EA(t.position,a),t.attributes.has("listItemId")?c.add(t.position.nodeAfter):EA(t.position.getShiftedBy(t.length),a);else if("remove"==t.type&&t.attributes.has("listItemId"))EA(t.position,a);else if("attribute"==t.type){const e=t.range.start.nodeAfter;n.includes(t.attributeKey)?(EA(t.range.start,a),null===t.attributeNewValue?(EA(t.range.start.getShiftedBy(1),a),r(e)&&s.push(e)):c.add(e)):Qv(e)&&r(e)&&s.push(e)}for(const t of a.values())s.push(...i(t,c));for(const t of new Set(s))e.reconvertItem(t)};function i(t,e){const o=[],i=new Set,a=[];for(const{node:c,previous:l}of $v(t,"forward")){if(i.has(c))continue;const t=c.getAttribute("listIndent");l&&tn.includes(t))));const d=Jv(c,{direction:"forward"});for(const t of d)i.add(t),(r(t,d)||s(t,a,e))&&o.push(t)}return o}function r(t,i){const r=e.mapper.toViewElement(t);if(!r)return!1;if(o.fire("checkElement",{modelElement:t,viewElement:r}))return!0;if(!t.is("element","paragraph")&&!t.is("element","listItem"))return!1;const s=BA(t,n,i);return!(!s||!r.is("element","p"))||!(s||!r.is("element","span"))}function s(t,n,i){if(i.has(t))return!1;const r=e.mapper.toViewElement(t);let s=n.length-1;for(let t=r.parent;!t.is("editableElement");t=t.parent){const e=CA(t),i=_A(t);if(!i&&!e)continue;const r="checkAttributes:"+(e?"item":"list");if(o.fire(r,{viewElement:t,modelAttributes:n[s]}))break;if(i&&(s--,s<0))return!1}return!0}}(e,t.editing,n,this),{priority:"high"}),this.on("checkAttributes:item",((t,{viewElement:e,modelAttributes:n})=>{e.id!=n.listItemId&&(t.return=!0,t.stop())})),this.on("checkAttributes:list",((t,{viewElement:e,modelAttributes:n})=>{e.name==yA(n.listType)&&e.id==xA(n.listType,n.listIndent)||(t.return=!0,t.stop())}))}_setupModelPostFixing(){const t=this.editor.model,e=this.getListAttributeNames();t.document.registerPostFixer((n=>function(t,e,n,o){const i=t.document.differ.getChanges(),r=new Map,s=o.editor.config.get("list.multiBlock");let a=!1;for(const o of i){if("insert"==o.type&&"$text"!=o.name){const i=o.position.nodeAfter;if(!t.schema.checkAttribute(i,"listItemId"))for(const t of Array.from(i.getAttributeKeys()))n.includes(t)&&(e.removeAttribute(t,i),a=!0);EA(o.position,r),o.attributes.has("listItemId")||EA(o.position.getShiftedBy(o.length),r);for(const{item:e,previousPosition:n}of t.createRangeIn(i))Qv(e)&&EA(n,r)}else"remove"==o.type?EA(o.position,r):"attribute"==o.type&&n.includes(o.attributeKey)&&(EA(o.range.start,r),null===o.attributeNewValue&&EA(o.range.start.getShiftedBy(1),r));if(!s&&"attribute"==o.type&&IA.includes(o.attributeKey)){const t=o.range.start.nodeAfter;null===o.attributeNewValue&&t&&t.is("element","listItem")?(e.rename(t,"paragraph"),a=!0):null===o.attributeOldValue&&t&&t.is("element")&&"listItem"!=t.name&&(e.rename(t,"listItem"),a=!0)}}const c=new Set;for(const t of r.values())a=o.fire("postFixer",{listNodes:new Kv(t),listHead:t,writer:e,seenIds:c})||a;return a}(t,n,e,this))),this.on("postFixer",((t,{listNodes:e,writer:n})=>{t.return=function(t,e){let n=0,o=-1,i=null,r=!1;for(const{node:s}of t){const t=s.getAttribute("listIndent");if(t>n){let a;null===i?(i=t-n,a=n):(i>t&&(i=t),a=t-i),a>o+1&&(a=o+1),e.setAttribute("listIndent",a,s),r=!0,o=a}else i=null,n=t+1,o=t}return r}(e,n)||t.return}),{priority:"high"}),this.on("postFixer",((t,{listNodes:e,writer:n,seenIds:o})=>{t.return=function(t,e,n){const o=new Set;let i=!1;for(const{node:r}of t){if(o.has(r))continue;let t=r.getAttribute("listType"),s=r.getAttribute("listItemId");if(e.has(s)&&(s=Yv.next()),e.add(s),r.is("element","listItem"))r.getAttribute("listItemId")!=s&&(n.setAttribute("listItemId",s,r),i=!0);else for(const e of Jv(r,{direction:"forward"}))o.add(e),e.getAttribute("listType")!=t&&(s=Yv.next(),t=e.getAttribute("listType")),e.getAttribute("listItemId")!=s&&(n.setAttribute("listItemId",s,e),i=!0)}return i}(e,o,n)||t.return}),{priority:"high"})}_setupClipboardIntegration(){const t=this.editor.model,e=this.editor.plugins.get("ClipboardPipeline");this.listenTo(t,"insertContent",function(t){return(e,[n,o])=>{const i=n.is("documentFragment")?Array.from(n.getChildren()):[n];if(!i.length)return;const r=(o?t.createSelection(o):t.document.selection).getFirstPosition();let s;if(Qv(r.parent))s=r.parent;else{if(!Qv(r.nodeBefore)||!Qv(r.nodeAfter))return;s=r.nodeBefore}t.change((t=>{const e=s.getAttribute("listType"),n=s.getAttribute("listIndent"),o=i[0].getAttribute("listIndent")||0,r=Math.max(n-o,0);for(const n of i){const o=Qv(n);s.is("element","listItem")&&n.is("element","paragraph")&&t.rename(n,"listItem"),t.setAttributes({listIndent:(o?n.getAttribute("listIndent"):0)+r,listItemId:o?n.getAttribute("listItemId"):Yv.next(),listType:e},n)}}))}}(t),{priority:"high"}),this.listenTo(e,"outputTransformation",((e,n)=>{t.change((t=>{const e=Array.from(n.content.getChildren()),o=e[e.length-1];if(e.length>1&&o.is("element")&&o.isEmpty&&e.slice(0,-1).every(Qv)&&t.remove(o),"copy"==n.method||"cut"==n.method){const e=Array.from(n.content.getChildren());cA(e)&&aA(e,t)}}))}))}_setupAccessibilityIntegration(){const t=this.editor,e=t.t;t.accessibility.addKeystrokeInfoGroup({id:"list",label:e("Keystrokes that can be used in a list"),keystrokes:[{label:e("Increase list item indent"),keystroke:"Tab"},{label:e("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function PA(t,e){const n=t.document.selection;if(!n.isCollapsed)return!dA(t);if("forward"===e)return!0;const o=n.getFirstPosition().parent,i=o.previousSibling;return!t.schema.isObject(i)&&(!!i.isEmpty||cA([o,i]))}function OA(t,e,n,o){t.ui.componentFactory.add(e,(()=>{const i=NA(Mh,t,e,n,o);return i.set({tooltip:!0,isToggleable:!0}),i})),t.ui.componentFactory.add(`menuBar:${e}`,(()=>{const i=NA(Yh,t,e,n,o);return i.set({role:"menuitemcheckbox",isToggleable:!0}),i}))}function NA(t,e,n,o,i){const r=e.commands.get(n),s=new t(e.locale);return s.set({label:o,icon:i}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(n),e.editing.view.focus()})),s}class zA extends iu{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||OA(this.editor,"numberedList",t("Numbered List"),yu.numberedList),this.editor.ui.componentFactory.has("bulletedList")||OA(this.editor,"bulletedList",t("Bulleted List"),yu.bulletedList)}}class LA extends su{refresh(){const t=this._getValue();this.value=t,this.isEnabled=null!=t}execute({startIndex:t=1}={}){const e=this.editor.model,n=e.document;let o=Array.from(n.selection.getSelectedBlocks()).filter((t=>Qv(t)&&hA(t.getAttribute("listType"))));o=oA(o),e.change((e=>{for(const n of o)e.setAttribute("listStart",t>=0?t:1,n)}))}_getValue(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());return t&&Qv(t)&&hA(t.getAttribute("listType"))?t.getAttribute("listStart"):null}}const RA={},FA={},jA={},VA=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:t,typeAttribute:e,listType:n}of VA)RA[t]=n,FA[t]=e,e&&(jA[e]=t);function HA(){return VA.map((t=>t.listStyle))}function UA(t){return RA[t]||null}function WA(t){return jA[t]||null}function GA(t){return FA[t]||null}class qA extends su{defaultType;_supportedTypes;constructor(t,e,n){super(t),this.defaultType=e,this._supportedTypes=n}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document;e.change((e=>{this._tryToConvertItemsToList(t);let o=Array.from(n.selection.getSelectedBlocks()).filter((t=>t.hasAttribute("listType")));if(o.length){o=oA(o);for(const n of o)e.setAttribute("listStyle",t.type||this.defaultType,n)}}))}isStyleTypeSupported(t){return!this._supportedTypes||this._supportedTypes.includes(t)}_getValue(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());return Qv(t)?t.getAttribute("listStyle"):null}_checkEnabled(){const t=this.editor,e=t.commands.get("numberedList"),n=t.commands.get("bulletedList");return e.isEnabled||n.isEnabled}_tryToConvertItemsToList(t){if(!t.type)return;const e=UA(t.type);if(!e)return;const n=this.editor,o=`${e}List`;n.commands.get(o).value||n.execute(o)}}class $A extends su{refresh(){const t=this._getValue();this.value=t,this.isEnabled=null!=t}execute(t={}){const e=this.editor.model,n=e.document;let o=Array.from(n.selection.getSelectedBlocks()).filter((t=>Qv(t)&&"numbered"==t.getAttribute("listType")));o=oA(o),e.change((e=>{for(const n of o)e.setAttribute("listReversed",!!t.reversed,n)}))}_getValue(){const t=ai(this.editor.model.document.selection.getSelectedBlocks());return Qv(t)&&"numbered"==t.getAttribute("listType")?t.getAttribute("listReversed"):null}}function KA(t){return(e,n,o)=>{const{writer:i,schema:r,consumable:s}=o;if(!1===s.test(n.viewItem,t.viewConsumables))return;n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor));let a=!1;for(const e of n.modelRange.getItems({shallow:!0}))r.checkAttribute(e,t.attributeName)&&t.appliesToListItem(e)&&(e.hasAttribute(t.attributeName)||(i.setAttribute(t.attributeName,t.getAttributeOnUpcast(n.viewItem),e),a=!0));a&&s.consume(n.viewItem,t.viewConsumables)}}class YA extends iu{static get pluginName(){return"ListPropertiesUtils"}static get isOfficialPlugin(){return!0}getAllSupportedStyleTypes(){return HA()}getListTypeFromListStyleType(t){return UA(t)}getListStyleTypeFromTypeAttribute(t){return WA(t)}getTypeAttributeFromListStyleType(t){return GA(t)}}function QA(t){const{startIndex:e,reversed:n,styles:o}=t;return{styles:ZA(o),startIndex:e||!1,reversed:n||!1}}function ZA(t){const e={listTypes:["bulleted","numbered"],useAttribute:!1};return!0===t||(t?Array.isArray(t)||"string"==typeof t?e.listTypes=ii(t):(e.listTypes=t.listTypes?ii(t.listTypes):e.listTypes,e.useAttribute=!!t.useAttribute):e.listTypes=[]),e}const JA="default";class XA extends iu{static get requires(){return[MA,YA]}static get pluginName(){return"ListPropertiesEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}init(){const t=this.editor,e=t.model,n=t.plugins.get(MA),o=function(t){const e=[],n=QA(t);if(t.styles){const t=n.styles.useAttribute;e.push({attributeName:"listStyle",defaultValue:JA,viewConsumables:{styles:"list-style-type"},addCommand(e){let n=HA();t&&(n=n.filter((t=>!!GA(t)))),e.commands.add("listStyle",new qA(e,JA,n))},appliesToListItem(t){return"numbered"==t.getAttribute("listType")||"bulleted"==t.getAttribute("listType")},hasValidAttribute(t){if(!this.appliesToListItem(t))return!t.hasAttribute("listStyle");if(!t.hasAttribute("listStyle"))return!1;const e=t.getAttribute("listStyle");return e==JA||UA(e)==t.getAttribute("listType")},setAttributeOnDowncast(e,n,o){if(n&&n!==JA){if(!t)return void e.setStyle("list-style-type",n,o);{const t=GA(n);if(t)return void e.setAttribute("type",t,o)}}e.removeStyle("list-style-type",o),e.removeAttribute("type",o)},getAttributeOnUpcast(t){const e=t.getStyle("list-style-type");if(e)return e;const n=t.getAttribute("type");return n?WA(n):JA}})}return t.reversed&&e.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(t){t.commands.add("listReversed",new $A(t))},appliesToListItem(t){return"numbered"==t.getAttribute("listType")},hasValidAttribute(t){return this.appliesToListItem(t)==t.hasAttribute("listReversed")},setAttributeOnDowncast(t,e,n){e?t.setAttribute("reversed","reversed",n):t.removeAttribute("reversed",n)},getAttributeOnUpcast(t){return t.hasAttribute("reversed")}}),t.startIndex&&e.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(t){t.commands.add("listStart",new LA(t))},appliesToListItem(t){return hA(t.getAttribute("listType"))},hasValidAttribute(t){return this.appliesToListItem(t)==t.hasAttribute("listStart")},setAttributeOnDowncast(t,e,n){0==e||e>1?t.setAttribute("start",e,n):t.removeAttribute("start",n)},getAttributeOnUpcast(t){const e=t.getAttribute("start");return e>=0?e:1}}),e}(t.config.get("list.properties"));for(const i of o)i.addCommand(t),e.schema.extend("$listItem",{allowAttributes:i.attributeName}),n.registerDowncastStrategy({scope:"list",attributeName:i.attributeName,setAttributeOnDowncast(t,e,n){i.setAttributeOnDowncast(t,e,n)}});t.conversion.for("upcast").add((t=>{for(const e of o)t.on("element:ol",KA(e)),t.on("element:ul",KA(e))})),n.on("checkAttributes:list",((t,{viewElement:e,modelAttributes:n})=>{for(const i of o)i.getAttributeOnUpcast(e)!=n[i.attributeName]&&(t.return=!0,t.stop())})),this.listenTo(t.commands.get("indentList"),"afterExecute",((t,n)=>{e.change((t=>{for(const e of n)for(const n of o)n.appliesToListItem(e)&&t.setAttribute(n.attributeName,n.defaultValue,e)}))})),n.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:i}of e)for(const e of o)e.hasValidAttribute(i)||(e.appliesToListItem(i)?n.setAttribute(e.attributeName,e.defaultValue,i):n.removeAttribute(e.attributeName,i),t.return=!0)})),n.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:i,previousNodeInList:r}of e)if(r&&r.getAttribute("listType")==i.getAttribute("listType"))for(const e of o){const{attributeName:o}=e;if(!e.appliesToListItem(i))continue;const s=r.getAttribute(o);i.getAttribute(o)!=s&&(n.setAttribute(o,s,i),t.return=!0)}}))}}class ty extends xh{children;stylesView=null;additionalPropertiesCollapsibleView=null;startIndexFieldView=null;reversedSwitchButtonView=null;focusTracker=new ci;keystrokes=new hi;focusables=new oh;focusCycler;constructor(t,{enabledProperties:e,styleButtonViews:n,styleGridAriaLabel:o}){super(t);const i=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Nh({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),n&&n.length?(this.stylesView=this._createStylesView(n,o),this.children.add(this.stylesView)):i.push("ck-list-properties_without-styles"),(e.startIndex||e.reversed)&&(this._addNumberedListPropertyViews(e),i.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:i},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const t of this.stylesView.children)this.stylesView.focusTracker.add(t.element);Th({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>en.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(t,e){const n=new xh(this.locale);return n.children=n.createCollection(),n.children.addMany(t),n.setTemplate({tag:"div",attributes:{"aria-label":e,class:["ck","ck-list-styles-list"]},children:n.children}),n.children.delegate("execute").to(this),n.focus=function(){this.children.first.focus()},n.focusTracker=new ci,n.keystrokes=new hi,n.render(),n.keystrokes.listenTo(n.element),n}_addNumberedListPropertyViews(t){const e=this.locale.t,n=[];t.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),n.push(this.startIndexFieldView)),t.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),n.push(this.reversedSwitchButtonView)),this.stylesView?(this.additionalPropertiesCollapsibleView=new ap(this.locale,n),this.additionalPropertiesCollapsibleView.set({label:e("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(n,"isEnabled",((...t)=>t.some((t=>t)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((t,e,n)=>{n||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(n)}_createStartIndexField(){const t=this.locale.t,e=new gp(this.locale,Yp);return e.set({label:t("Start at"),class:"ck-numbered-list-properties__start-index"}),e.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),e.fieldView.on("input",(()=>{const n=e.fieldView.element,o=n.valueAsNumber;Number.isNaN(o)?e.errorText=t("Invalid start index value."):n.checkValidity()?this.fire("listStart",{startIndex:o}):e.errorText=t("Start index must be greater than 0.")})),e}_createReversedSwitchButton(){const t=this.locale.t,e=new np(this.locale);return e.set({withText:!0,label:t("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),e.delegate("execute").to(this,"listReversed"),e}}class ey extends iu{static get pluginName(){return"ListPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,n=t.config.get("list.properties"),o=QA(n),i=o.styles.listTypes;if(i.includes("bulleted")){const n=[{label:e("Toggle the disc list style"),tooltip:e("Disc"),type:"disc",icon:' '},{label:e("Toggle the circle list style"),tooltip:e("Circle"),type:"circle",icon:' '},{label:e("Toggle the square list style"),tooltip:e("Square"),type:"square",icon:' '}],i=e("Bulleted List"),r=e("Bulleted list styles toolbar"),s="bulletedList";t.ui.componentFactory.add(s,ny({editor:t,normalizedConfig:o,parentCommandName:s,buttonLabel:i,buttonIcon:yu.bulletedList,styleGridAriaLabel:r,styleDefinitions:n})),t.ui.componentFactory.add(`menuBar:${s}`,iy({editor:t,normalizedConfig:o,parentCommandName:s,buttonLabel:i,styleGridAriaLabel:r,styleDefinitions:n}))}if(i.includes("numbered")||n.startIndex||n.reversed){const n=[{label:e("Toggle the decimal list style"),tooltip:e("Decimal"),type:"decimal",icon:' '},{label:e("Toggle the decimal with leading zero list style"),tooltip:e("Decimal with leading zero"),type:"decimal-leading-zero",icon:' '},{label:e("Toggle the lower–roman list style"),tooltip:e("Lower–roman"),type:"lower-roman",icon:' '},{label:e("Toggle the upper–roman list style"),tooltip:e("Upper-roman"),type:"upper-roman",icon:' '},{label:e("Toggle the lower–latin list style"),tooltip:e("Lower-latin"),type:"lower-latin",icon:' '},{label:e("Toggle the upper–latin list style"),tooltip:e("Upper-latin"),type:"upper-latin",icon:' '}],r=e("Numbered List"),s=e("Numbered list styles toolbar"),a="numberedList";t.ui.componentFactory.add(a,ny({editor:t,normalizedConfig:o,parentCommandName:a,buttonLabel:r,buttonIcon:yu.numberedList,styleGridAriaLabel:s,styleDefinitions:n})),i.includes("numbered")&&t.ui.componentFactory.add(`menuBar:${a}`,iy({editor:t,normalizedConfig:o,parentCommandName:a,buttonLabel:r,styleGridAriaLabel:s,styleDefinitions:n}))}}}function ny({editor:t,normalizedConfig:e,parentCommandName:n,buttonLabel:o,buttonIcon:i,styleGridAriaLabel:r,styleDefinitions:s}){const a=t.commands.get(n);return c=>{const l=jp(c,Fp),d=l.buttonView;return l.bind("isEnabled").to(a),l.class="ck-list-styles-dropdown",d.on("execute",(()=>{t.execute(n),t.editing.view.focus()})),d.set({label:o,icon:i,tooltip:!0,isToggleable:!0}),d.bind("isOn").to(a,"value",(t=>!!t)),l.once("change:isOpen",(()=>{const o=function({editor:t,normalizedConfig:e,dropdownView:n,parentCommandName:o,styleDefinitions:i,styleGridAriaLabel:r}){const s=t.locale,a={...e,..."numberedList"!=o?{startIndex:!1,reversed:!1}:null},c=o.replace("List","");let l=null;if(e.styles.listTypes.includes(c)){const e=t.commands.get("listStyle"),n=oy({editor:t,parentCommandName:o,listStyleCommand:e}),r=ry(e);l=i.filter(r).map(n)}const d=new ty(s,{styleGridAriaLabel:r,enabledProperties:a,styleButtonViews:l});if(e.styles.listTypes.includes(c)&&Gp(n,(()=>d.stylesView.children.find((t=>t.isOn)))),a.startIndex){const e=t.commands.get("listStart");d.startIndexFieldView.bind("isEnabled").to(e),d.startIndexFieldView.fieldView.bind("value").to(e),d.on("listStart",((e,n)=>t.execute("listStart",n)))}if(a.reversed){const e=t.commands.get("listReversed");d.reversedSwitchButtonView.bind("isEnabled").to(e),d.reversedSwitchButtonView.bind("isOn").to(e,"value",(t=>!!t)),d.on("listReversed",(()=>{const n=e.value;t.execute("listReversed",{reversed:!n})}))}return d.delegate("execute").to(n),d}({editor:t,normalizedConfig:e,dropdownView:l,parentCommandName:n,styleGridAriaLabel:r,styleDefinitions:s});l.panelView.children.add(o)})),l.on("execute",(()=>{t.editing.view.focus()})),l}}function oy({editor:t,listStyleCommand:e,parentCommandName:n}){const o=t.locale,i=t.commands.get(n);return({label:r,type:s,icon:a,tooltip:c})=>{const l=new Mh(o);return l.set({label:r,icon:a,tooltip:c}),e.on("change:value",(()=>{l.isOn=e.value===s})),l.on("execute",(()=>{i.value?e.value===s?t.execute(n):e.value!==s&&t.execute("listStyle",{type:s}):t.model.change((()=>{t.execute("listStyle",{type:s})}))})),l}}function iy({editor:t,normalizedConfig:e,parentCommandName:n,buttonLabel:o,styleGridAriaLabel:i,styleDefinitions:r}){return s=>{const a=new tg(s),c=t.commands.get(n),l=t.commands.get("listStyle"),d=ry(l),u=oy({editor:t,parentCommandName:n,listStyleCommand:l}),h=r.filter(d).map(u),p=new ty(s,{styleGridAriaLabel:i,enabledProperties:{...e,startIndex:!1,reversed:!1},styleButtonViews:h});return p.delegate("execute").to(a),a.buttonView.set({label:o,icon:yu[n]}),a.panelView.children.add(p),a.bind("isEnabled").to(c,"isEnabled"),a.on("execute",(()=>{t.editing.view.focus()})),a}}function ry(t){return"function"==typeof t.isStyleTypeSupported?e=>t.isStyleTypeSupported(e.type):()=>!0}class sy extends su{constructor(t){super(t),this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}refresh(){const t=this._getSelectedItems();this.value=this._getValue(t),this.isEnabled=!!t.length}execute(t={}){this.editor.model.change((e=>{const n=this._getSelectedItems(),o=void 0===t.forceValue?!this._getValue(n):t.forceValue;for(const t of n)o?e.setAttribute("todoListChecked",!0,t):e.removeAttribute("todoListChecked",t)}))}_getValue(t){return t.every((t=>t.getAttribute("todoListChecked")))}_getSelectedItems(){const t=this.editor.model,e=t.schema,n=t.document.selection.getFirstRange(),o=n.start.parent,i=[];e.checkAttribute(o,"todoListChecked")&&i.push(...Zv(o));for(const t of n.getItems({shallow:!0}))e.checkAttribute(t,"todoListChecked")&&!i.includes(t)&&i.push(...Zv(t));return i}}class ay extends Ys{domEventType=["change"];onDomEvent(t){if(t.target){const e=this.view.domConverter.mapDomToView(t.target);e&&e.is("element","input")&&"checkbox"==e.getAttribute("type")&&e.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",t)}}}const cy=Jo("Ctrl+Enter");class ly extends iu{static get pluginName(){return"TodoListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[MA]}init(){const t=this.editor,e=t.model,n=t.editing,o=t.plugins.get(MA),i=t.config.get("list.multiBlock")?"paragraph":"listItem";t.commands.add("todoList",new fA(t,"todo")),t.commands.add("checkTodoList",new sy(t)),n.view.addObserver(ay),e.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),e.schema.addAttributeCheck((t=>{const e=t.last;if(!e.getAttribute("listItemId")||"todo"!=e.getAttribute("listType"))return!1}),"todoListChecked"),t.conversion.for("upcast").add((t=>{t.on("element:input",((t,e,n)=>{const o=e.modelCursor,i=o.parent,r=e.viewItem;if(!n.consumable.test(r,{name:!0}))return;if("checkbox"!=r.getAttribute("type")||!o.isAtStart||!i.hasAttribute("listType"))return;n.consumable.consume(r,{name:!0});const s=n.writer;s.setAttribute("listType","todo",i),e.viewItem.hasAttribute("checked")&&s.setAttribute("todoListChecked",!0,i),e.modelRange=s.createRange(o)})),t.on("element:li",((t,e,n)=>{const{writer:o,schema:i}=n;if(!e.modelRange)return;const r=Array.from(e.modelRange.getItems({shallow:!0})).filter((t=>"todo"===t.getAttribute("listType")&&i.checkAttribute(t,"listItemId"))).reduce(((t,e)=>{const n=e.getAttribute("listItemId");return t.has(n)||t.set(n,Zv(e)),t}),new Map);for(const[,t]of r.entries())if(t.some((t=>t.getAttribute("todoListChecked"))))for(const e of t)o.setAttribute("todoListChecked",!0,e)}),{priority:"low"}),t.on("element:label",dy({name:"label",classes:"todo-list__label"})),t.on("element:label",dy({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),t.on("element:span",dy({name:"span",classes:"todo-list__label__description"})),t.on("element:ul",function(){const t=new Ir({name:"ul",classes:"todo-list"});return(e,n,o)=>{const i=t.match(n.viewItem);if(!i)return;const r=i.match;r.name=!1,o.consumable.consume(n.viewItem,r)}}())})),t.conversion.for("downcast").elementToElement({model:i,view:(t,{writer:e})=>{if(uy(t,o.getListAttributeNames()))return e.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),o.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(t,e,n){"todo"==e?t.addClass("todo-list",n):t.removeClass("todo-list",n)}}),o.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(t,e,{dataPipeline:n}){if("todo"!=e.getAttribute("listType"))return null;const o=t.createUIElement("input",{type:"checkbox",...e.getAttribute("todoListChecked")?{checked:"checked"}:null,...n?{disabled:"disabled"}:{tabindex:"-1"}});if(n)return o;const i=t.createContainerElement("span",{contenteditable:"false"},o);return i.getFillerOffset=()=>null,i},canWrapElement(t){return uy(t,o.getListAttributeNames())},createWrapperElement(t,e,{dataPipeline:n}){const i=["todo-list__label"];return uy(e,o.getListAttributeNames())||i.push("todo-list__label_without-description"),t.createAttributeElement(n?"label":"span",{class:i.join(" ")})}}),o.on("checkElement",((t,{modelElement:e,viewElement:n})=>{const i=uy(e,o.getListAttributeNames());n.hasClass("todo-list__label__description")!=i&&(t.return=!0,t.stop())})),o.on("checkElement",((e,{modelElement:n,viewElement:o})=>{const i="todo"==n.getAttribute("listType")&&tA(n);let r=!1;const s=t.editing.view.createPositionBefore(o).getWalker({direction:"backward"});for(const{item:e}of s){if(e.is("element")&&t.editing.mapper.toModelElement(e))break;e.is("element","input")&&"checkbox"==e.getAttribute("type")&&(r=!0)}r!=i&&(e.return=!0,e.stop())})),o.on("postFixer",((t,{listNodes:e,writer:n})=>{for(const{node:o,previousNodeInList:i}of e){if(!i)continue;if(i.getAttribute("listItemId")!=o.getAttribute("listItemId"))continue;const e=i.hasAttribute("todoListChecked"),r=o.hasAttribute("todoListChecked");r&&!e?(n.removeAttribute("todoListChecked",o),t.return=!0):!r&&e&&(n.setAttribute("todoListChecked",!0,o),t.return=!0)}})),e.document.registerPostFixer((t=>{const n=e.document.differ.getChanges();let o=!1;for(const e of n)if("attribute"==e.type&&"listType"==e.attributeKey){const n=e.range.start.nodeAfter;"todo"==e.attributeOldValue&&n.hasAttribute("todoListChecked")&&(t.removeAttribute("todoListChecked",n),o=!0)}else if("insert"==e.type&&"$text"!=e.name)for(const{item:n}of t.createRangeOn(e.position.nodeAfter))n.is("element")&&"todo"!=n.getAttribute("listType")&&n.hasAttribute("todoListChecked")&&(t.removeAttribute("todoListChecked",n),o=!0);return o})),this.listenTo(n.view.document,"keydown",((e,n)=>{Zo(n)===cy&&(t.execute("checkTodoList"),e.stop())}),{priority:"high"}),this.listenTo(n.view.document,"todoCheckboxChange",((t,e)=>{const o=e.target;if(!o||!o.is("element","input"))return;const i=n.view.createPositionAfter(o),r=n.mapper.toModelPosition(i).parent;r&&Qv(r)&&"todo"==r.getAttribute("listType")&&this._handleCheckmarkChange(r)})),this.listenTo(n.view.document,"arrowKey",function(t,e){return(n,o)=>{const i=ti(o.keyCode,e.contentLanguageDirection),r=t.schema,s=t.document.selection;if(!s.isCollapsed)return;const a=s.getFirstPosition(),c=a.parent;if("right"==i&&a.isAtEnd){const e=r.getNearestSelectionRange(t.createPositionAfter(c),"forward");if(!e)return;const i=e.start.parent;i&&Qv(i)&&"todo"==i.getAttribute("listType")&&(t.change((t=>t.setSelection(e))),o.preventDefault(),o.stopPropagation(),n.stop())}else if("left"==i&&a.isAtStart&&Qv(c)&&"todo"==c.getAttribute("listType")){const e=r.getNearestSelectionRange(t.createPositionBefore(c),"backward");if(!e)return;t.change((t=>t.setSelection(e))),o.preventDefault(),o.stopPropagation(),n.stop()}}}(e,t.locale),{context:"$text"}),this.listenTo(n.mapper,"viewToModelPosition",((t,n)=>{const o=n.viewPosition.parent,i=o.is("attributeElement","li")&&0==n.viewPosition.offset,r=hy(o)&&n.viewPosition.offset<=1,s=o.is("element","span")&&"false"==o.getAttribute("contenteditable")&&hy(o.parent);if(!i&&!r&&!s)return;const a=n.modelPosition.nodeAfter;a&&"todo"==a.getAttribute("listType")&&(n.modelPosition=e.createPositionAt(a,0))}),{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(t){const e=this.editor,n=e.model,o=Array.from(n.document.selection.getRanges());n.change((n=>{n.setSelection(t,"end"),e.execute("checkTodoList"),n.setSelection(o)}))}_initAriaAnnouncements(){const{model:t,ui:e,t:n}=this.editor;let o=null;e&&t.document.selection.on("change:range",(()=>{const i=t.document.selection.focus.parent,r=py(o),s=py(i);r&&!s?e.ariaLiveAnnouncer.announce(n("Leaving a to-do list")):!r&&s&&e.ariaLiveAnnouncer.announce(n("Entering a to-do list")),o=i}))}}function dy(t){const e=new Ir(t);return(t,n,o)=>{const i=e.match(n.viewItem);i&&o.consumable.consume(n.viewItem,i.match)&&Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor))}}function uy(t,e){return(t.is("element","paragraph")||t.is("element","listItem"))&&"todo"==t.getAttribute("listType")&&tA(t)&&function(t,e){for(const n of t.getAttributeKeys())if(!n.startsWith("selection:")&&!e.includes(n))return!1;return!0}(t,e)}function hy(t){return!!t&&t.is("attributeElement")&&t.hasClass("todo-list__label")}function py(t){return!(!t||!t.is("element","paragraph")&&!t.is("element","listItem")||"todo"!=t.getAttribute("listType"))}class my extends iu{static get pluginName(){return"TodoListUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.t;OA(this.editor,"todoList",t("To-do List"),yu.todoList)}}let gy={baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const fy=/[&<>"']/,ky=/[&<>"']/g,by=/[<>"']|&(?!#?\w+;)/,wy=/[<>"']|&(?!#?\w+;)/g,_y={"&":"&","<":"<",">":">",'"':""","'":"'"},Cy=t=>_y[t];function vy(t,e){if(e){if(fy.test(t))return t.replace(ky,Cy)}else if(by.test(t))return t.replace(wy,Cy);return t}const Ay=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function yy(t){return t.replace(Ay,((t,e)=>"colon"===(e=e.toLowerCase())?":":"#"===e.charAt(0)?"x"===e.charAt(1)?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""))}const xy=/(^|[^\[])\^/g;function Ey(t,e){t=t.source||t,e=e||"";const n={replace:(e,o)=>(o=(o=o.source||o).replace(xy,"$1"),t=t.replace(e,o),n),getRegex:()=>new RegExp(t,e)};return n}const Dy=/[^\w:]/g,Sy=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ty(t,e,n){if(t){let t;try{t=decodeURIComponent(yy(n)).replace(Dy,"").toLowerCase()}catch(t){return null}if(0===t.indexOf("javascript:")||0===t.indexOf("vbscript:")||0===t.indexOf("data:"))return null}e&&!Sy.test(n)&&(n=function(t,e){By[" "+t]||(Iy.test(t)?By[" "+t]=t+"/":By[" "+t]=Ly(t,"/",!0));const n=-1===(t=By[" "+t]).indexOf(":");return"//"===e.substring(0,2)?n?e:t.replace(My,"$1")+e:"/"===e.charAt(0)?n?e:t.replace(Py,"$1")+e:t+e}(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(t){return null}return n}const By={},Iy=/^[^:]+:\/*[^/]*$/,My=/^([^:]+:)[\s\S]*$/,Py=/^([^:]+:\/*[^/]*)[\s\S]*$/,Oy={exec:function(){}};function Ny(t){let e,n,o=1;for(;o{let o=!1,i=e;for(;--i>=0&&"\\"===n[i];)o=!o;return o?"|":" |"})).split(/ \|/);let o=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>e)n.splice(e);else for(;n.length1;)1&e&&(n+=t),e>>=1,t+=t;return n+t}function jy(t,e,n,o){const i=e.href,r=e.title?vy(e.title):null,s=t[1].replace(/\\([\[\]])/g,"$1");if("!"!==t[0].charAt(0)){o.state.inLink=!0;const t={type:"link",raw:n,href:i,title:r,text:s,tokens:o.inlineTokens(s,[])};return o.state.inLink=!1,t}return{type:"image",raw:n,href:i,title:r,text:vy(s)}}class Vy{constructor(t){this.options=t||gy}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const t=e[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Ly(t,"\n")}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const t=e[0],n=function(t,e){const n=t.match(/^(\s+)(?:```)/);if(null===n)return e;const o=n[1];return e.split("\n").map((t=>{const e=t.match(/^\s+/);if(null===e)return t;const[n]=e;return n.length>=o.length?t.slice(o.length):t})).join("\n")}(t,e[3]||"");return{type:"code",raw:t,lang:e[2]?e[2].trim():e[2],text:n}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let t=e[2].trim();if(/#$/.test(t)){const e=Ly(t,"#");this.options.pedantic?t=e.trim():e&&!/ $/.test(e)||(t=e.trim())}const n={type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:[]};return this.lexer.inline(n.text,n.tokens),n}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:e[0]}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){const t=e[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:e[0],tokens:this.lexer.blockTokens(t,[]),text:t}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n,o,i,r,s,a,c,l,d,u,h,p,m=e[1].trim();const g=m.length>1,f={type:"list",raw:"",ordered:g,start:g?+m.slice(0,-1):"",loose:!1,items:[]};m=g?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=g?m:"[*+-]");const k=new RegExp(`^( {0,3}${m})((?: [^\\n]*)?(?:\\n|$))`);for(;t&&(p=!1,e=k.exec(t))&&!this.rules.block.hr.test(t);){if(n=e[0],t=t.substring(n.length),l=e[2].split("\n",1)[0],d=t.split("\n",1)[0],this.options.pedantic?(r=2,h=l.trimLeft()):(r=e[2].search(/[^ ]/),r=r>4?1:r,h=l.slice(r),r+=e[1].length),a=!1,!l&&/^ *$/.test(d)&&(n+=d+"\n",t=t.substring(d.length+1),p=!0),!p){const e=new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])`);for(;t&&(u=t.split("\n",1)[0],l=u,this.options.pedantic&&(l=l.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!e.test(l));){if(l.search(/[^ ]/)>=r||!l.trim())h+="\n"+l.slice(r);else{if(a)break;h+="\n"+l}a||l.trim()||(a=!0),n+=u+"\n",t=t.substring(u.length+1)}}f.loose||(c?f.loose=!0:/\n *\n *$/.test(n)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(h),o&&(i="[ ] "!==o[0],h=h.replace(/^\[[ xX]\] +/,""))),f.items.push({type:"list_item",raw:n,task:!!o,checked:i,loose:!1,text:h}),f.raw+=n}f.items[f.items.length-1].raw=n.trimRight(),f.items[f.items.length-1].text=h.trimRight(),f.raw=f.raw.trimRight();const b=f.items.length;for(s=0;s"space"===t.type)),e=t.every((t=>{const e=t.raw.split("");let n=0;for(const t of e)if("\n"===t&&(n+=1),n>1)return!0;return!1}));!f.loose&&t.length&&e&&(f.loose=!0,f.items[s].loose=!0)}return f}}html(t){const e=this.rules.block.html.exec(t);if(e){const t={type:"html",raw:e[0],pre:!this.options.sanitizer&&("pre"===e[1]||"script"===e[1]||"style"===e[1]),text:e[0]};return this.options.sanitize&&(t.type="paragraph",t.text=this.options.sanitizer?this.options.sanitizer(e[0]):vy(e[0]),t.tokens=[],this.lexer.inline(t.text,t.tokens)),t}}def(t){const e=this.rules.block.def.exec(t);if(e)return e[3]&&(e[3]=e[3].substring(1,e[3].length-1)),{type:"def",tag:e[1].toLowerCase().replace(/\s+/g," "),raw:e[0],href:e[2],title:e[3]}}table(t){const e=this.rules.block.table.exec(t);if(e){const t={type:"table",header:zy(e[1]).map((t=>({text:t}))),align:e[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:e[3]&&e[3].trim()?e[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(t.header.length===t.align.length){t.raw=e[0];let n,o,i,r,s=t.align.length;for(n=0;n({text:t})));for(s=t.header.length,o=0;o/i.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(e[0]):vy(e[0]):e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const t=e[2].trim();if(!this.options.pedantic&&/^$/.test(t))return;const e=Ly(t.slice(0,-1),"\\");if((t.length-e.length)%2==0)return}else{const t=function(t,e){if(-1===t.indexOf(e[1]))return-1;const n=t.length;let o=0,i=0;for(;i-1){const n=(0===e[0].indexOf("!")?5:4)+e[1].length+t;e[2]=e[2].substring(0,t),e[0]=e[0].substring(0,n).trim(),e[3]=""}}let n=e[2],o="";if(this.options.pedantic){const t=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);t&&(n=t[1],o=t[3])}else o=e[3]?e[3].slice(1,-1):"";return n=n.trim(),/^$/.test(t)?n.slice(1):n.slice(1,-1)),jy(e,{href:n?n.replace(this.rules.inline._escapes,"$1"):n,title:o?o.replace(this.rules.inline._escapes,"$1"):o},e[0],this.lexer)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let t=(n[2]||n[1]).replace(/\s+/g," ");if(t=e[t.toLowerCase()],!t||!t.href){const t=n[0].charAt(0);return{type:"text",raw:t,text:t}}return jy(n,t,n[0],this.lexer)}}emStrong(t,e,n=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o)return;if(o[3]&&n.match(/[\p{L}\p{N}]/u))return;const i=o[1]||o[2]||"";if(!i||i&&(""===n||this.rules.inline.punctuation.exec(n))){const n=o[0].length-1;let i,r,s=n,a=0;const c="*"===o[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+n);null!=(o=c.exec(e));){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(r=i.length,o[3]||o[4]){s+=r;continue}if((o[5]||o[6])&&n%3&&!((n+r)%3)){a+=r;continue}if(s-=r,s>0)continue;if(r=Math.min(r,r+s+a),Math.min(n,r)%2){const e=t.slice(1,n+o.index+r);return{type:"em",raw:t.slice(0,n+o.index+r+1),text:e,tokens:this.lexer.inlineTokens(e,[])}}const e=t.slice(2,n+o.index+r-1);return{type:"strong",raw:t.slice(0,n+o.index+r+1),text:e,tokens:this.lexer.inlineTokens(e,[])}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let t=e[2].replace(/\n/g," ");const n=/[^ ]/.test(t),o=/^ /.test(t)&&/ $/.test(t);return n&&o&&(t=t.substring(1,t.length-1)),t=vy(t,!0),{type:"codespan",raw:e[0],text:t}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2],[])}}autolink(t,e){const n=this.rules.inline.autolink.exec(t);if(n){let t,o;return"@"===n[2]?(t=vy(this.options.mangle?e(n[1]):n[1]),o="mailto:"+t):(t=vy(n[1]),o=t),{type:"link",raw:n[0],text:t,href:o,tokens:[{type:"text",raw:t,text:t}]}}}url(t,e){let n;if(n=this.rules.inline.url.exec(t)){let t,o;if("@"===n[2])t=vy(this.options.mangle?e(n[0]):n[0]),o="mailto:"+t;else{let e;do{e=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0]}while(e!==n[0]);t=vy(n[0]),o="www."===n[1]?"http://"+t:t}return{type:"link",raw:n[0],text:t,href:o,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(t,e){const n=this.rules.inline.text.exec(t);if(n){let t;return t=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):vy(n[0]):n[0]:vy(this.options.smartypants?e(n[0]):n[0]),{type:"text",raw:n[0],text:t}}}}const Hy={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Oy,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};Hy.def=Ey(Hy.def).replace("label",Hy._label).replace("title",Hy._title).getRegex(),Hy.bullet=/(?:[*+-]|\d{1,9}[.)])/,Hy.listItemStart=Ey(/^( *)(bull) */).replace("bull",Hy.bullet).getRegex(),Hy.list=Ey(Hy.list).replace(/bull/g,Hy.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Hy.def.source+")").getRegex(),Hy._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Hy._comment=/|$)/,Hy.html=Ey(Hy.html,"i").replace("comment",Hy._comment).replace("tag",Hy._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hy.paragraph=Ey(Hy._paragraph).replace("hr",Hy.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Hy._tag).getRegex(),Hy.blockquote=Ey(Hy.blockquote).replace("paragraph",Hy.paragraph).getRegex(),Hy.normal=Ny({},Hy),Hy.gfm=Ny({},Hy.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),Hy.gfm.table=Ey(Hy.gfm.table).replace("hr",Hy.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Hy._tag).getRegex(),Hy.gfm.paragraph=Ey(Hy._paragraph).replace("hr",Hy.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Hy.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Hy._tag).getRegex(),Hy.pedantic=Ny({},Hy.normal,{html:Ey("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)| \\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Hy._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Oy,paragraph:Ey(Hy.normal._paragraph).replace("hr",Hy.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Hy.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const Uy={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Oy,tag:"^comment|^[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Oy,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\.5&&(n="x"+n.toString(16)),o+=""+n+";";return o}Uy._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",Uy.punctuation=Ey(Uy.punctuation).replace(/punctuation/g,Uy._punctuation).getRegex(),Uy.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,Uy.escapedEmSt=/\\\*|\\_/g,Uy._comment=Ey(Hy._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),Uy.emStrong.lDelim=Ey(Uy.emStrong.lDelim).replace(/punct/g,Uy._punctuation).getRegex(),Uy.emStrong.rDelimAst=Ey(Uy.emStrong.rDelimAst,"g").replace(/punct/g,Uy._punctuation).getRegex(),Uy.emStrong.rDelimUnd=Ey(Uy.emStrong.rDelimUnd,"g").replace(/punct/g,Uy._punctuation).getRegex(),Uy._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,Uy._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,Uy._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,Uy.autolink=Ey(Uy.autolink).replace("scheme",Uy._scheme).replace("email",Uy._email).getRegex(),Uy._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,Uy.tag=Ey(Uy.tag).replace("comment",Uy._comment).replace("attribute",Uy._attribute).getRegex(),Uy._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Uy._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,Uy._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,Uy.link=Ey(Uy.link).replace("label",Uy._label).replace("href",Uy._href).replace("title",Uy._title).getRegex(),Uy.reflink=Ey(Uy.reflink).replace("label",Uy._label).replace("ref",Hy._label).getRegex(),Uy.nolink=Ey(Uy.nolink).replace("ref",Hy._label).getRegex(),Uy.reflinkSearch=Ey(Uy.reflinkSearch,"g").replace("reflink",Uy.reflink).replace("nolink",Uy.nolink).getRegex(),Uy.normal=Ny({},Uy),Uy.pedantic=Ny({},Uy.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ey(/^!?\[(label)\]\((.*?)\)/).replace("label",Uy._label).getRegex(),reflink:Ey(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Uy._label).getRegex()}),Uy.gfm=Ny({},Uy.normal,{escape:Ey(Uy.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\!!(n=o.call({lexer:this},t,e))&&(t=t.substring(n.raw.length),e.push(n),!0)))))if(n=this.tokenizer.space(t))t=t.substring(n.raw.length),1===n.raw.length&&e.length>0?e[e.length-1].raw+="\n":e.push(n);else if(n=this.tokenizer.code(t))t=t.substring(n.raw.length),o=e[e.length-1],!o||"paragraph"!==o.type&&"text"!==o.type?e.push(n):(o.raw+="\n"+n.raw,o.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text);else if(n=this.tokenizer.fences(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.heading(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.hr(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.blockquote(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.list(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.html(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.def(t))t=t.substring(n.raw.length),o=e[e.length-1],!o||"paragraph"!==o.type&&"text"!==o.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(o.raw+="\n"+n.raw,o.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text);else if(n=this.tokenizer.table(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.lheading(t))t=t.substring(n.raw.length),e.push(n);else{if(i=t,this.options.extensions&&this.options.extensions.startBlock){let e=1/0;const n=t.slice(1);let o;this.options.extensions.startBlock.forEach((function(t){o=t.call({lexer:this},n),"number"==typeof o&&o>=0&&(e=Math.min(e,o))})),e<1/0&&e>=0&&(i=t.substring(0,e+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))o=e[e.length-1],r&&"paragraph"===o.type?(o.raw+="\n"+n.raw,o.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):e.push(n),r=i.length!==t.length,t=t.substring(n.raw.length);else if(n=this.tokenizer.text(t))t=t.substring(n.raw.length),o=e[e.length-1],o&&"text"===o.type?(o.raw+="\n"+n.raw,o.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):e.push(n);else if(t){const e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}throw new Error(e)}}return this.state.top=!0,e}inline(t,e){this.inlineQueue.push({src:t,tokens:e})}inlineTokens(t,e=[]){let n,o,i,r,s,a,c=t;if(this.tokens.links){const t=Object.keys(this.tokens.links);if(t.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(c));)t.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(c=c.slice(0,r.index)+"["+Fy("a",r[0].length-2)+"]"+c.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(c));)c=c.slice(0,r.index)+"["+Fy("a",r[0].length-2)+"]"+c.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.escapedEmSt.exec(c));)c=c.slice(0,r.index)+"++"+c.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;t;)if(s||(a=""),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((o=>!!(n=o.call({lexer:this},t,e))&&(t=t.substring(n.raw.length),e.push(n),!0)))))if(n=this.tokenizer.escape(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.tag(t))t=t.substring(n.raw.length),o=e[e.length-1],o&&"text"===n.type&&"text"===o.type?(o.raw+=n.raw,o.text+=n.text):e.push(n);else if(n=this.tokenizer.link(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.reflink(t,this.tokens.links))t=t.substring(n.raw.length),o=e[e.length-1],o&&"text"===n.type&&"text"===o.type?(o.raw+=n.raw,o.text+=n.text):e.push(n);else if(n=this.tokenizer.emStrong(t,c,a))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.codespan(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.br(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.del(t))t=t.substring(n.raw.length),e.push(n);else if(n=this.tokenizer.autolink(t,Gy))t=t.substring(n.raw.length),e.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(t,Gy))){if(i=t,this.options.extensions&&this.options.extensions.startInline){let e=1/0;const n=t.slice(1);let o;this.options.extensions.startInline.forEach((function(t){o=t.call({lexer:this},n),"number"==typeof o&&o>=0&&(e=Math.min(e,o))})),e<1/0&&e>=0&&(i=t.substring(0,e+1))}if(n=this.tokenizer.inlineText(i,Wy))t=t.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(a=n.raw.slice(-1)),s=!0,o=e[e.length-1],o&&"text"===o.type?(o.raw+=n.raw,o.text+=n.text):e.push(n);else if(t){const e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}throw new Error(e)}}else t=t.substring(n.raw.length),e.push(n);return e}}class $y{constructor(t){this.options=t||gy}code(t,e,n){const o=(e||"").match(/\S*/)[0];if(this.options.highlight){const e=this.options.highlight(t,o);null!=e&&e!==t&&(n=!0,t=e)}return t=t.replace(/\n$/,"")+"\n",o?''+(n?t:vy(t,!0))+"
\n":""+(n?t:vy(t,!0))+"
\n"}blockquote(t){return"\n"+t+" \n"}html(t){return t}heading(t,e,n,o){return this.options.headerIds?"\n":""+t+" \n"}hr(){return this.options.xhtml?" \n":" \n"}list(t,e,n){const o=e?"ol":"ul";return"<"+o+(e&&1!==n?' start="'+n+'"':"")+">\n"+t+""+o+">\n"}listitem(t){return""+t+" \n"}checkbox(t){return" "}paragraph(t){return""+t+"
\n"}table(t,e){return e&&(e=""+e+" "),"\n"}tablerow(t){return"\n"+t+" \n"}tablecell(t,e){const n=e.header?"th":"td";return(e.align?"<"+n+' align="'+e.align+'">':"<"+n+">")+t+""+n+">\n"}strong(t){return""+t+" "}em(t){return""+t+" "}codespan(t){return""+t+"
"}br(){return this.options.xhtml?" ":" "}del(t){return""+t+""}link(t,e,n){if(null===(t=Ty(this.options.sanitize,this.options.baseUrl,t)))return n;let o='"+n+" ",o}image(t,e,n){if(null===(t=Ty(this.options.sanitize,this.options.baseUrl,t)))return n;let o=' ":">",o}text(t){return t}}class Ky{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,e,n){return""+n}image(t,e,n){return""+n}br(){return""}}class Yy{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,e){let n=t,o=0;if(this.seen.hasOwnProperty(n)){o=this.seen[t];do{o++,n=t+"-"+o}while(this.seen.hasOwnProperty(n))}return e||(this.seen[t]=o,this.seen[n]=0),n}slug(t,e={}){const n=this.serialize(t);return this.getNextSafeSlug(n,e.dryrun)}}class Qy{constructor(t){this.options=t||gy,this.options.renderer=this.options.renderer||new $y,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ky,this.slugger=new Yy}static parse(t,e){return new Qy(e).parse(t)}static parseInline(t,e){return new Qy(e).parseInline(t)}parse(t,e=!0){let n,o,i,r,s,a,c,l,d,u,h,p,m,g,f,k,b,w,_,C="";const v=t.length;for(n=0;n0&&"paragraph"===f.tokens[0].type?(f.tokens[0].text=w+" "+f.tokens[0].text,f.tokens[0].tokens&&f.tokens[0].tokens.length>0&&"text"===f.tokens[0].tokens[0].type&&(f.tokens[0].tokens[0].text=w+" "+f.tokens[0].tokens[0].text)):f.tokens.unshift({type:"text",text:w}):g+=w),g+=this.parse(f.tokens,m),d+=this.renderer.listitem(g,b,k);C+=this.renderer.list(d,h,p);continue;case"html":C+=this.renderer.html(u.text);continue;case"paragraph":C+=this.renderer.paragraph(this.parseInline(u.tokens));continue;case"text":for(d=u.tokens?this.parseInline(u.tokens):u.text;n+1{o(t.text,t.lang,(function(e,n){if(e)return r(e);null!=n&&n!==t.text&&(t.text=n,t.escaped=!0),s--,0===s&&r()}))}),0))})),void(0===s&&r())}try{const n=qy.lex(t,e);return e.walkTokens&&Zy.walkTokens(n,e.walkTokens),Qy.parse(n,e)}catch(t){if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"An error occurred:
"+vy(t.message+"",!0)+" ";throw t}}function Jy(t,e){return Array(e+1).join(t)}Zy.options=Zy.setOptions=function(t){var e;return Ny(Zy.defaults,t),e=Zy.defaults,gy=e,Zy},Zy.getDefaults=function(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}},Zy.defaults=gy,Zy.use=function(...t){const e=Ny({},...t),n=Zy.defaults.extensions||{renderers:{},childTokens:{}};let o;t.forEach((t=>{if(t.extensions&&(o=!0,t.extensions.forEach((t=>{if(!t.name)throw new Error("extension name required");if(t.renderer){const e=n.renderers?n.renderers[t.name]:null;n.renderers[t.name]=e?function(...n){let o=t.renderer.apply(this,n);return!1===o&&(o=e.apply(this,n)),o}:t.renderer}if(t.tokenizer){if(!t.level||"block"!==t.level&&"inline"!==t.level)throw new Error("extension level must be 'block' or 'inline'");n[t.level]?n[t.level].unshift(t.tokenizer):n[t.level]=[t.tokenizer],t.start&&("block"===t.level?n.startBlock?n.startBlock.push(t.start):n.startBlock=[t.start]:"inline"===t.level&&(n.startInline?n.startInline.push(t.start):n.startInline=[t.start]))}t.childTokens&&(n.childTokens[t.name]=t.childTokens)}))),t.renderer){const n=Zy.defaults.renderer||new $y;for(const e in t.renderer){const o=n[e];n[e]=(...i)=>{let r=t.renderer[e].apply(n,i);return!1===r&&(r=o.apply(n,i)),r}}e.renderer=n}if(t.tokenizer){const n=Zy.defaults.tokenizer||new Vy;for(const e in t.tokenizer){const o=n[e];n[e]=(...i)=>{let r=t.tokenizer[e].apply(n,i);return!1===r&&(r=o.apply(n,i)),r}}e.tokenizer=n}if(t.walkTokens){const n=Zy.defaults.walkTokens;e.walkTokens=function(e){t.walkTokens.call(this,e),n&&n.call(this,e)}}o&&(e.extensions=n),Zy.setOptions(e)}))},Zy.walkTokens=function(t,e){for(const n of t)switch(e.call(Zy,n),n.type){case"table":for(const t of n.header)Zy.walkTokens(t.tokens,e);for(const t of n.rows)for(const n of t)Zy.walkTokens(n.tokens,e);break;case"list":Zy.walkTokens(n.items,e);break;default:Zy.defaults.extensions&&Zy.defaults.extensions.childTokens&&Zy.defaults.extensions.childTokens[n.type]?Zy.defaults.extensions.childTokens[n.type].forEach((function(t){Zy.walkTokens(n[t],e)})):n.tokens&&Zy.walkTokens(n.tokens,e)}},Zy.parseInline=function(t,e){if(null==t)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof t)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected");Ry(e=Ny({},Zy.defaults,e||{}));try{const n=qy.lexInline(t,e);return e.walkTokens&&Zy.walkTokens(n,e.walkTokens),Qy.parseInline(n,e)}catch(t){if(t.message+="\nPlease report this to https://github.com/markedjs/marked.",e.silent)return"An error occurred:
"+vy(t.message+"",!0)+" ";throw t}},Zy.Parser=Qy,Zy.parser=Qy.parse,Zy.Renderer=$y,Zy.TextRenderer=Ky,Zy.Lexer=qy,Zy.lexer=qy.lex,Zy.Tokenizer=Vy,Zy.Slugger=Yy,Zy.parse=Zy,Zy.options,Zy.setOptions,Zy.use,Zy.walkTokens,Zy.parseInline,Qy.parse,qy.lex;var Xy={};function tx(t){return t?t.replace(/(\n+\s*)+/g,"\n"):""}function ex(t){for(var e in this.options=t,this._keep=[],this._remove=[],this.blankRule={replacement:t.blankReplacement},this.keepReplacement=t.keepReplacement,this.defaultRule={replacement:t.defaultReplacement},this.array=[],t.rules)this.array.push(t.rules[e])}function nx(t,e,n){for(var o=0;o-1)return!0}else{if("function"!=typeof o)throw new TypeError("`filter` needs to be a string, array, or function");if(o.call(t,e,n))return!0}}Xy.paragraph={filter:"p",replacement:function(t){return"\n\n"+t+"\n\n"}},Xy.lineBreak={filter:"br",replacement:function(t,e,n){return n.br+"\n"}},Xy.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(t,e,n){var o=Number(e.nodeName.charAt(1));return"setext"===n.headingStyle&&o<3?"\n\n"+t+"\n"+Jy(1===o?"=":"-",t.length)+"\n\n":"\n\n"+Jy("#",o)+" "+t+"\n\n"}},Xy.blockquote={filter:"blockquote",replacement:function(t){return"\n\n"+(t=(t=t.replace(/^\n+|\n+$/g,"")).replace(/^/gm,"> "))+"\n\n"}},Xy.list={filter:["ul","ol"],replacement:function(t,e){var n=e.parentNode;return"LI"===n.nodeName&&n.lastElementChild===e?"\n"+t:"\n\n"+t+"\n\n"}},Xy.listItem={filter:"li",replacement:function(t,e,n){t=t.replace(/^\n+/,"").replace(/\n+$/,"\n").replace(/\n/gm,"\n ");var o=n.bulletListMarker+" ",i=e.parentNode;if("OL"===i.nodeName){var r=i.getAttribute("start"),s=Array.prototype.indexOf.call(i.children,e);o=(r?Number(r)+s:s+1)+". "}return o+t+(e.nextSibling&&!/\n$/.test(t)?"\n":"")}},Xy.indentedCodeBlock={filter:function(t,e){return"indented"===e.codeBlockStyle&&"PRE"===t.nodeName&&t.firstChild&&"CODE"===t.firstChild.nodeName},replacement:function(t,e,n){return"\n\n "+e.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},Xy.fencedCodeBlock={filter:function(t,e){return"fenced"===e.codeBlockStyle&&"PRE"===t.nodeName&&t.firstChild&&"CODE"===t.firstChild.nodeName},replacement:function(t,e,n){for(var o,i=((e.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],r=e.firstChild.textContent,s=n.fence.charAt(0),a=3,c=new RegExp("^"+s+"{3,}","gm");o=c.exec(r);)o[0].length>=a&&(a=o[0].length+1);var l=Jy(s,a);return"\n\n"+l+i+"\n"+r.replace(/\n$/,"")+"\n"+l+"\n\n"}},Xy.horizontalRule={filter:"hr",replacement:function(t,e,n){return"\n\n"+n.hr+"\n\n"}},Xy.inlineLink={filter:function(t,e){return"inlined"===e.linkStyle&&"A"===t.nodeName&&t.getAttribute("href")},replacement:function(t,e){var n=e.getAttribute("href");n&&(n=n.replace(/([()])/g,"\\$1"));var o=tx(e.getAttribute("title"));return o&&(o=' "'+o.replace(/"/g,'\\"')+'"'),"["+t+"]("+n+o+")"}},Xy.referenceLink={filter:function(t,e){return"referenced"===e.linkStyle&&"A"===t.nodeName&&t.getAttribute("href")},replacement:function(t,e,n){var o,i,r=e.getAttribute("href"),s=tx(e.getAttribute("title"));switch(s&&(s=' "'+s+'"'),n.linkReferenceStyle){case"collapsed":o="["+t+"][]",i="["+t+"]: "+r+s;break;case"shortcut":o="["+t+"]",i="["+t+"]: "+r+s;break;default:var a=this.references.length+1;o="["+t+"]["+a+"]",i="["+a+"]: "+r+s}return this.references.push(i),o},references:[],append:function(t){var e="";return this.references.length&&(e="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),e}},Xy.emphasis={filter:["em","i"],replacement:function(t,e,n){return t.trim()?n.emDelimiter+t+n.emDelimiter:""}},Xy.strong={filter:["strong","b"],replacement:function(t,e,n){return t.trim()?n.strongDelimiter+t+n.strongDelimiter:""}},Xy.code={filter:function(t){var e=t.previousSibling||t.nextSibling,n="PRE"===t.parentNode.nodeName&&!e;return"CODE"===t.nodeName&&!n},replacement:function(t){if(!t)return"";t=t.replace(/\r?\n|\r/g," ");for(var e=/^`|^ .*?[^ ].* $|`$/.test(t)?" ":"",n="`",o=t.match(/`+/gm)||[];-1!==o.indexOf(n);)n+="`";return n+e+t+e+n}},Xy.image={filter:"img",replacement:function(t,e){var n=tx(e.getAttribute("alt")),o=e.getAttribute("src")||"",i=tx(e.getAttribute("title"));return o?"!["+n+"]("+o+(i?' "'+i+'"':"")+")":""}},ex.prototype={add:function(t,e){this.array.unshift(e)},keep:function(t){this._keep.unshift({filter:t,replacement:this.keepReplacement})},remove:function(t){this._remove.unshift({filter:t,replacement:function(){return""}})},forNode:function(t){return t.isBlank?this.blankRule:(e=nx(this.array,t,this.options))||(e=nx(this._keep,t,this.options))||(e=nx(this._remove,t,this.options))?e:this.defaultRule;var e},forEach:function(t){for(var e=0;e{if(!i.consumable.consume(o.item,n.name))return;const r=o.attributeNewValue,s=i.writer,a=i.mapper.toViewElement(o.item),c=[...a.getChildren()].find((t=>t.getCustomProperty("media-content")));s.remove(c);const l=t.getMediaViewElement(s,r,e);s.insert(s.createPositionAt(a,0),l)};return t=>{t.on("attribute:url:media",n)}}function ux(t){const e=t.getSelectedElement();return e&&function(t){return!!t.getCustomProperty("media")&&$f(t)}(e)?e:null}function hx(t,e,n,o){return t.createContainerElement("figure",{class:"media"},[e.getMediaViewElement(t,n,o),t.createSlot()])}function px(t){const e=t.getSelectedElement();return e&&e.is("element","media")?e:null}function mx(t,e,n,o){t.change((i=>{const r=i.createElement("media",{url:e});t.insertObject(r,n,null,{setSelection:"on",findOptimalPosition:o?"auto":void 0})}))}ax.tableCell={filter:["th","td"],replacement:function(t,e){return lx(t,e)}},ax.tableRow={filter:"tr",replacement:function(t,e){var n="",o={left:":--",right:"--:",center:":-:"};if(cx(e))for(var i=0;i{e.setAttribute("url",t,o)})):mx(e,t,n,!0)}}class fx{locale;providerDefinitions;constructor(t,e){const n=e.providers,o=e.extraProviders||[],i=new Set(e.removeProviders),r=n.concat(o).filter((t=>{const e=t.name;return e?!i.has(e):(yn("media-embed-no-provider-name",{provider:t}),!1)}));this.locale=t,this.providerDefinitions=r}hasMedia(t){return!!this._getMedia(t)}getMediaViewElement(t,e,n){return this._getMedia(e).getViewElement(t,n)}_getMedia(t){if(!t)return new kx(this.locale);t=t.trim();for(const e of this.providerDefinitions){const n=e.html,o=ii(e.url);for(const e of o){const o=this._getUrlMatches(t,e);if(o)return new kx(this.locale,t,o,n)}}return null}_getUrlMatches(t,e){let n=t.match(e);if(n)return n;let o=t.replace(/^https?:\/\//,"");return n=o.match(e),n||(o=o.replace(/^www\./,""),n=o.match(e),n||null)}}class kx{url;_locale;_match;_previewRenderer;constructor(t,e,n,o){this.url=this._getValidUrl(e),this._locale=t,this._match=n,this._previewRenderer=o}getViewElement(t,e){const n={};let o;if(e.renderForEditingView||e.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(n["data-oembed-url"]=this.url),e.renderForEditingView&&(n.class="ck-media__wrapper");const i=this._getPreviewHtml(e);o=t.createRawElement("div",n,((t,e)=>{e.setContentOf(t,i)}))}else this.url&&(n.url=this.url),o=t.createEmptyElement(e.elementName,n);return t.setCustomProperty("media-content",!0,o),o}_getPreviewHtml(t){return this._previewRenderer?this._previewRenderer(this._match):this.url&&t.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const t=new Bh,e=this._locale.t;return t.content=' ',t.viewBox="0 0 64 42",new ih({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[t]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":e("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(t){return t?t.match(/^https?/)?t:"https://"+t:null}}class bx extends iu{static get pluginName(){return"MediaEmbedEditing"}static get isOfficialPlugin(){return!0}registry;constructor(t){super(t),t.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:[/^dailymotion\.com\/video\/(\w+)/,/^dai.ly\/(\w+)/],html:t=>`
`},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:t=>`
`},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/shorts\/([\w-]+)(?:\?t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:t=>{const e=t[1],n=t[2];return`VIDEO
`}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:t=>`
`},{name:"instagram",url:[/^instagram\.com\/p\/(\w+)/,/^instagram\.com\/reel\/(\w+)/]},{name:"twitter",url:[/^twitter\.com/,/^x\.com/]},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new fx(t.locale,t.config.get("mediaEmbed"))}init(){const t=this.editor,e=t.model.schema,n=t.t,o=t.conversion,i=t.config.get("mediaEmbed.previewsInData"),r=t.config.get("mediaEmbed.elementName"),s=this.registry;t.commands.add("mediaEmbed",new gx(t)),e.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),o.for("dataDowncast").elementToStructure({model:"media",view:(t,{writer:e})=>{const n=t.getAttribute("url");return hx(e,s,n,{elementName:r,renderMediaPreview:!!n&&i})}}),o.for("dataDowncast").add(dx(s,{elementName:r,renderMediaPreview:i})),o.for("editingDowncast").elementToStructure({model:"media",view:(t,{writer:e})=>{const o=t.getAttribute("url");return function(t,e,n){return e.setCustomProperty("media",!0,t),Kf(t,e,{label:n})}(hx(e,s,o,{elementName:r,renderForEditingView:!0}),e,n("media widget"))}}),o.for("editingDowncast").add(dx(s,{elementName:r,renderForEditingView:!0})),o.for("upcast").elementToElement({view:t=>["oembed",r].includes(t.name)&&t.getAttribute("url")?{name:!0}:null,model:(t,{writer:e})=>{const n=t.getAttribute("url");return s.hasMedia(n)?e.createElement("media",{url:n}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(t,{writer:e})=>{const n=t.getAttribute("data-oembed-url");return s.hasMedia(n)?e.createElement("media",{url:n}):null}}).add((t=>{t.on("element:figure",((t,e,n)=>{if(!n.consumable.consume(e.viewItem,{name:!0,classes:"media"}))return;const{modelRange:o,modelCursor:i}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=o,e.modelCursor=i,ai(o.getItems())||n.consumable.revert(e.viewItem,{name:!0,classes:"media"})}))}))}}const wx=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class _x extends iu{static get requires(){return[Hk,Ig,yb]}static get pluginName(){return"AutoMediaEmbed"}static get isOfficialPlugin(){return!0}_timeoutId;_positionToInsert;constructor(t){super(t),this._timeoutId=null,this._positionToInsert=null}init(){const t=this.editor,e=t.model.document,n=t.plugins.get("ClipboardPipeline");this.listenTo(n,"inputTransformation",(()=>{const t=e.selection.getFirstRange(),n=Cl.fromPosition(t.start);n.stickiness="toPrevious";const o=Cl.fromPosition(t.end);o.stickiness="toNext",e.once("change:data",(()=>{this._embedMediaBetweenPositions(n,o),n.detach(),o.detach()}),{priority:"high"})})),t.commands.get("undo").on("execute",(()=>{this._timeoutId&&(en.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedMediaBetweenPositions(t,e){const n=this.editor,o=n.plugins.get(bx).registry,i=new La(t,e),r=i.getWalker({ignoreElementEnd:!0});let s="";for(const t of r)t.item.is("$textProxy")&&(s+=t.item.data);s=s.trim(),s.match(wx)&&o.hasMedia(s)&&n.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=Cl.fromPosition(t),this._timeoutId=en.window.setTimeout((()=>{n.model.change((t=>{this._timeoutId=null,t.remove(i),i.detach();let e=null;"$graveyard"!==this._positionToInsert.root.rootName&&(e=this._positionToInsert),mx(n.model,s,e,!1),this._positionToInsert.detach(),this._positionToInsert=null})),n.plugins.get(Ig).requestUndoOnBackspace()}),100)):i.detach()}}class Cx extends xh{focusTracker;keystrokes;urlInputView;_validators;_urlInputViewInfoDefault;_urlInputViewInfoTip;constructor(t,e){super(e),this.focusTracker=new ci,this.keystrokes=new hi,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this._validators=t,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView]})}render(){super.render(),Sh({view:this}),this.focusTracker.add(this.urlInputView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.urlInputView.focus()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(t){this.urlInputView.fieldView.value=t.trim()}isValid(){this.resetFormStatus();for(const t of this._validators){const e=t(this);if(e)return this.urlInputView.errorText=e,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const t=this.locale.t,e=new gp(this.locale,Kp),n=e.fieldView;return this._urlInputViewInfoDefault=t("Paste the media URL in the input."),this._urlInputViewInfoTip=t("Tip: Paste the URL into the content to embed faster."),e.label=t("Media URL"),e.infoText=this._urlInputViewInfoDefault,n.inputMode="url",n.on("input",(()=>{e.infoText=n.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=n.element.value.trim()})),e}}class vx extends iu{static get requires(){return[bx,qh]}static get pluginName(){return"MediaEmbedUI"}static get isOfficialPlugin(){return!0}_formView;init(){const t=this.editor;t.ui.componentFactory.add("mediaEmbed",(()=>{const t=this.editor.locale.t,e=this._createDialogButton(Mh);return e.tooltip=!0,e.label=t("Insert media"),e})),t.ui.componentFactory.add("menuBar:mediaEmbed",(()=>{const t=this.editor.locale.t,e=this._createDialogButton(Yh);return e.label=t("Media"),e}))}_createDialogButton(t){const e=this.editor,n=new t(e.locale),o=e.commands.get("mediaEmbed"),i=this.editor.plugins.get("Dialog");return n.icon=' ',n.bind("isEnabled").to(o,"isEnabled"),n.on("execute",(()=>{"mediaEmbed"===i.id?i.hide():this._showDialog()})),n}_showDialog(){const t=this.editor,e=t.plugins.get("Dialog"),n=t.commands.get("mediaEmbed"),o=t.locale.t;if(!this._formView){const e=t.plugins.get(bx).registry;this._formView=new(Dh(Cx))(function(t,e){return[e=>{if(!e.url.length)return t("The URL must not be empty.")},n=>{if(!e.hasMedia(n.url))return t("This media URL is not supported.")}]}(t.t,e),t.locale),this._formView.on("submit",(()=>this._handleSubmitForm()))}e.show({id:"mediaEmbed",title:o("Insert media"),content:this._formView,isModal:!0,onShow:()=>{this._formView.url=n.value||"",this._formView.resetFormStatus(),this._formView.urlInputView.fieldView.select()},actionButtons:[{label:o("Cancel"),withText:!0,onExecute:()=>e.hide()},{label:o("Accept"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSubmitForm()}]})}_handleSubmitForm(){const t=this.editor,e=t.plugins.get("Dialog");this._formView.isValid()&&(t.execute("mediaEmbed",this._formView.url),e.hide(),t.editing.view.focus())}}Yo.arrowup,Yo.arrowdown,Yo.esc,Yo.enter,Yo.tab;class Ax extends su{refresh(){const t=this.editor.model,e=t.schema,n=t.document.selection;this.isEnabled=function(t,e,n){const o=function(t,e){const n=Xf(t,e).start.parent;return n.isEmpty&&!n.is("element","$root")?n.parent:n}(t,n);return e.checkChild(o,"pageBreak")}(n,e,t)}execute(){const t=this.editor.model;t.change((e=>{const n=e.createElement("pageBreak");t.insertObject(n,null,null,{setSelection:"after"})}))}}class yx extends iu{static get pluginName(){return"PageBreakEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.model.schema,n=t.t,o=t.conversion;e.register("pageBreak",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToStructure({model:"pageBreak",view:(t,{writer:e})=>e.createContainerElement("div",{class:"page-break",style:"page-break-after: always"},e.createContainerElement("span",{style:"display: none"}))}),o.for("editingDowncast").elementToStructure({model:"pageBreak",view:(t,{writer:e})=>{const o=n("Page break"),i=e.createContainerElement("div"),r=e.createRawElement("span",{class:"page-break__label"},(function(t){t.innerText=n("Page break")}));return e.addClass("page-break",i),e.insert(e.createPositionAt(i,0),r),function(t,e,n){return e.setCustomProperty("pageBreak",!0,t),Kf(t,e,{label:n})}(i,e,o)}}),o.for("upcast").elementToElement({view:t=>{const e="always"==t.getStyle("page-break-before"),n="always"==t.getStyle("page-break-after");if(!e&&!n)return null;if(1==t.childCount){const e=t.getChild(0);if(!e.is("element","span")||"none"!=e.getStyle("display"))return null}else if(t.childCount>1)return null;return{name:!0}},model:"pageBreak",converterPriority:"high"}),t.commands.add("pageBreak",new Ax(t))}}class xx extends iu{static get pluginName(){return"PageBreakUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add("pageBreak",(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add("menuBar:pageBreak",(()=>this._createButton(Yh)))}_createButton(t){const e=this.editor,n=e.locale,o=e.commands.get("pageBreak"),i=new t(e.locale),r=n.t;return i.set({label:r("Page break"),icon:' '}),i.bind("isEnabled").to(o,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("pageBreak"),e.editing.view.focus()})),i}}function Ex(t){return void 0!==t&&t.endsWith("px")}function Dx(t){return t.toFixed(2).replace(/\.?0+$/,"")+"px"}function Sx(t){const e=t.element.previousSibling;return(n=e||t.element.parent).is("element","ol")||n.is("element","ul");var n}function Tx(t,e){const n=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),o=/mso-level-number-format:([^;]{0,100});/gi,i=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=new RegExp(`@list\\s+l${t.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),s=new RegExp(`@list l${t.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=r.exec(e),c=s.exec(e),l=a&&!c,d=n.exec(e);let u="decimal",h="ol",p=null;if(d&&d[1]){const e=o.exec(d[1]);if(e&&e[1]&&(u=e[1].trim(),h="bullet"!==u&&"image"!==u?"ol":"ul"),"bullet"===u){const e=function(t){if("li"==t.name&&"ul"==t.parent.name&&t.parent.hasAttribute("type"))return t.parent.getAttribute("type");const e=function(t){if(t.getChild(0).is("$text"))return null;for(const e of t.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);if(t)return t.is("$text")?t:t.getChild(0)}return null}(t);if(!e)return null;const n=e._data;return"o"===n?"circle":"·"===n?"disc":"§"===n?"square":null}(t.element);e&&(u=e)}else{const t=i.exec(d[1]);t&&t[1]&&(p=parseInt(t[1]))}l&&(h="ol")}return{type:h,startIndex:p,style:Bx(u),isLegalStyleList:l}}function Bx(t){if(t.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(t){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return t;default:return null}}function Ix(t,e,n){const o=e.createElement(t.type);return t.style&&e.setStyle("list-style-type",t.style,o),t.startIndex&&t.startIndex>1&&e.setAttribute("start",t.startIndex,o),t.isLegalStyleList&&n&&e.addClass("legal-list",o),o}function Mx(t){const e=t.getStyle("mso-list");if(void 0===e)return{};const n=e.match(/(^|\s{1,100})l(\d+)/i),o=e.match(/\s{0,100}lfo(\d+)/i),i=e.match(/\s{0,100}level(\d+)/i);return n&&o&&i?{id:n[2],order:o[1],indent:parseInt(i[1])}:{indent:1}}function Px(t,e){const n=new Ir({name:"span",styles:{"mso-list":"Ignore"}}),o=e.createRangeIn(t);for(const t of o)"elementStart"===t.type&&n.match(t.item)&&e.remove(t.item)}function Ox(t){const e=t.getStyle("margin-left");return void 0===e||e.endsWith("px")?e:function(t){const e=parseFloat(t);return t.endsWith("pt")?Dx(96*e/72):t.endsWith("pc")?Dx(12*e*96/72):t.endsWith("in")?Dx(96*e):t.endsWith("cm")?Dx(96*e/2.54):t.endsWith("mm")?Dx(e/10*96/2.54):t}(e)}const Nx=/ /i,zx=/xmlns:o="urn:schemas-microsoft-com/i;class Lx{document;hasMultiLevelListPlugin;constructor(t,e=!1){this.document=t,this.hasMultiLevelListPlugin=e}isActive(t){return Nx.test(t)||zx.test(t)}execute(t){const e=new ad(this.document),{body:n,stylesString:o}=t._parsedData;!function(t,e){const n=[];for(const o of e.createRangeIn(t)){const t=o.item;t.is("element","a")&&!t.hasAttribute("href")&&(t.hasAttribute("id")||t.hasAttribute("name"))&&n.push(t)}for(const t of n){const n=t.parent.getChildIndex(t)+1,o=t.getChildren();e.insertChild(n,o,t.parent)}}(n,e),function(t,e,n){if(!t.childCount)return;const o=new ad(t.document),i=function(t,e){const n=e.createRangeIn(t),o=[],i=new Set;for(const t of n.getItems()){if(!t.is("element")||!t.name.match(/^(p|h\d+|li|div)$/))continue;let e=Ox(t);if(void 0===e||0!=parseFloat(e)||Array.from(t.getClassNames()).find((t=>t.startsWith("MsoList")))||(e=void 0),t.hasStyle("mso-list")||void 0!==e&&i.has(e)){const n=Mx(t);o.push({element:t,id:n.id,order:n.order,indent:n.indent,marginLeft:e}),void 0!==e&&i.add(e)}else i.clear()}return o}(t,o);if(!i.length)return;const r={},s=[];for(const t of i)if(void 0!==t.indent){Sx(t)||(s.length=0);const i=`${t.id}:${t.indent}`,a=Math.min(t.indent-1,s.length);if(as.length-1||s[a].listElement.name!=c.type){0==a&&"ol"==c.type&&void 0!==t.id&&r[i]&&(c.startIndex=r[i]);const e=Ix(c,o,n);if(Ex(t.marginLeft)&&(0==a||Ex(s[a-1].marginLeft))){let n=t.marginLeft;a>0&&(n=Dx(parseFloat(n)-parseFloat(s[a-1].marginLeft))),o.setStyle("padding-left",n,e)}if(0==s.length){const n=t.element.parent,i=n.getChildIndex(t.element)+1;o.insertChild(i,e,n)}else{const t=s[a-1].listItemElements;o.appendChild(e,t[t.length-1])}s[a]={...t,listElement:e,listItemElements:[]},0==a&&void 0!==t.id&&(r[i]=c.startIndex||1)}}const c="li"==t.element.name?t.element:o.createElement("li");o.appendChild(c,s[a].listElement),s[a].listItemElements.push(c),0==a&&void 0!==t.id&&r[i]++,t.element!=c&&o.appendChild(t.element,c),Px(t.element,o),o.removeStyle("text-indent",t.element),o.removeStyle("margin-left",t.element)}else{const e=s.find((e=>e.marginLeft==t.marginLeft));if(e){const n=e.listItemElements;o.appendChild(t.element,n[n.length-1]),o.removeStyle("margin-left",t.element)}else s.length=0}}(n,o,this.hasMultiLevelListPlugin),function(t,e){if(!t.childCount)return;const n=new ad(t.document),o=function(t,e){const n=e.createRangeIn(t),o=new Ir({name:/v:(.+)/}),i=[];for(const t of n){if("elementStart"!=t.type)continue;const e=t.item,n=e.previousSibling,r=n&&n.is("element")?n.name:null,s=["Chart"],a=o.match(e),c=e.getAttribute("o:gfxdata"),l="v:shapetype"===r,d=c&&s.some((t=>e.getAttribute("id").includes(t)));a&&c&&!l&&!d&&i.push(t.item.getAttribute("id"))}return i}(t,n);!function(t,e,n){const o=n.createRangeIn(e),i=new Ir({name:"img"}),r=[];for(const e of o)if(e.item.is("element")&&i.match(e.item)){const n=e.item,o=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];o.length&&o.every((e=>t.indexOf(e)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const t of r)n.remove(t)}(o,t,n),function(t,e,n){const o=n.createRangeIn(e),i=[];for(const e of o)if("elementStart"==e.type&&e.item.is("element","v:shape")){const n=e.item.getAttribute("id");if(t.includes(n))continue;r(e.item.parent.getChildren(),n)||i.push(e.item)}for(const t of i){const e={src:s(t)};t.hasAttribute("alt")&&(e.alt=t.getAttribute("alt"));const o=n.createElement("img",e);n.insertChild(t.index+1,o,t.parent)}function r(t,e){for(const n of t)if(n.is("element")){if("img"==n.name&&n.getAttribute("v:shapes")==e)return!0;if(r(n.getChildren(),e))return!0}return!1}function s(t){for(const e of t.getChildren())if(e.is("element")&&e.getAttribute("src"))return e.getAttribute("src")}}(o,t,n),function(t,e){const n=e.createRangeIn(t),o=new Ir({name:/v:(.+)/}),i=[];for(const t of n)"elementStart"==t.type&&o.match(t.item)&&i.push(t.item);for(const t of i)e.remove(t)}(t,n);const i=function(t,e){const n=e.createRangeIn(t),o=new Ir({name:"img"}),i=[];for(const t of n)t.item.is("element")&&o.match(t.item)&&t.item.getAttribute("src").startsWith("file://")&&i.push(t.item);return i}(t,n);i.length&&function(t,e,n){if(t.length===e.length)for(let i=0;iString.fromCharCode(parseInt(t,16)))).join(""))}`;n.setAttribute("src",r,t[i])}var o}(i,function(t){if(!t)return[];const e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,n=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),o=t.match(n),i=[];if(o)for(const t of o){let n=!1;t.includes("\\pngblip")?n="image/png":t.includes("\\jpegblip")&&(n="image/jpeg"),n&&i.push({hex:t.replace(e,"").replace(/[^\da-fA-F]/g,""),type:n})}return i}(e),n)}(n,t.dataTransfer.getData("text/rtf")),function(t){const e=[],n=new ad(t.document);for(const{item:o}of n.createRangeIn(t))if(o.is("element")){for(const t of o.getClassNames())/\bmso/gi.exec(t)&&n.removeClass(t,o);for(const t of o.getStyleNames())/\bmso/gi.exec(t)&&n.removeStyle(t,o);(o.is("element","w:sdt")||o.is("element","w:sdtpr")&&o.isEmpty||o.is("element","o:p")&&o.isEmpty)&&e.push(o)}for(const t of e){const e=t.parent,o=e.getChildIndex(t);n.insertChild(o,t.getChildren(),e),n.remove(t)}}(n),t.content=n}}function Rx(t,e,n,{blockElements:o,inlineObjectElements:i}){let r=n.createPositionAt(t,"forward"==e?"after":"before");return r=r.getLastMatchingPosition((({item:t})=>t.is("element")&&!o.includes(t.name)&&!i.includes(t.name)),{direction:e}),"forward"==e?r.nodeAfter:r.nodeBefore}function Fx(t,e){return!!t&&t.is("element")&&e.includes(t.name)}const jx=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Vx{document;constructor(t){this.document=t}isActive(t){return jx.test(t)}execute(t){const e=new ad(this.document),{body:n}=t._parsedData;!function(t,e){for(const n of t.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const o=t.getChildIndex(n);e.remove(n),e.insertChild(o,n.getChildren(),t)}}(n,e),function(t,e){for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","li")){const n=t.getChild(0);n&&n.is("element","p")&&e.unwrapElement(n)}}}(n,e),function(t,e){const n=new is(e.document.stylesProcessor),o=new Us(n,{renderingMode:"data"}),i=o.blockElements,r=o.inlineObjectElements,s=[];for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","br")){const n=Rx(t,"forward",e,{blockElements:i,inlineObjectElements:r}),o=Rx(t,"backward",e,{blockElements:i,inlineObjectElements:r}),a=Fx(n,i);(Fx(o,i)||a)&&s.push(t)}}for(const t of s)t.hasClass("Apple-interchange-newline")?e.remove(t):e.replace(t,e.createElement("p"))}(n,e),t.content=n}}const Hx=/(\s+)<\/span>/g,((t,e)=>1===e.length?" ":Array(e.length+1).join(" ").substr(0,e.length)))}const Gx="removeFormat";class qx extends iu{static get pluginName(){return"RemoveFormatUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add(Gx,(()=>{const t=this._createButton(Mh);return t.set({tooltip:!0}),t})),t.ui.componentFactory.add(`menuBar:${Gx}`,(()=>this._createButton(Yh)))}_createButton(t){const e=this.editor,n=e.locale,o=e.commands.get(Gx),i=new t(e.locale),r=n.t;return i.set({label:r("Remove Format"),icon:' '}),i.bind("isEnabled").to(o,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute(Gx),e.editing.view.focus()})),i}}class $x extends su{refresh(){const t=this.editor.model;this.isEnabled=!!ai(this._getFormattingItems(t.document.selection,t.schema))}execute(){const t=this.editor.model,e=t.schema;t.change((n=>{for(const o of this._getFormattingItems(t.document.selection,e))if(o.is("selection"))for(const t of this._getFormattingAttributes(o,e))n.removeSelectionAttribute(t);else{const t=n.createRangeOn(o);for(const i of this._getFormattingAttributes(o,e))n.removeAttribute(i,t)}}))}*_getFormattingItems(t,e){const n=t=>!!ai(this._getFormattingAttributes(t,e));for(const o of t.getRanges())for(const t of o.getItems())!e.isBlock(t)&&n(t)&&(yield t);for(const e of t.getSelectedBlocks())n(e)&&(yield e);n(t)&&(yield t)}*_getFormattingAttributes(t,e){for(const[n]of t.getAttributes()){const t=e.getAttributeProperties(n);t&&t.isFormatting&&(yield n)}}}class Kx extends iu{static get pluginName(){return"RemoveFormatEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.commands.add("removeFormat",new $x(t))}}function Yx(t,e,n=" "){return`${n.repeat(Math.max(0,e))}${t}`}const Qx="SourceEditingMode";class Zx extends iu{static get pluginName(){return"SourceEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Au]}_elementReplacer;_replacedRoots;_dataFromRoots;constructor(t){super(t),this.set("isSourceEditingMode",!1),this._elementReplacer=new Jn,this._replacedRoots=new Map,this._dataFromRoots=new Map,t.config.define("sourceEditing.allowCollaborationFeatures",!1)}init(){this._checkCompatibility();const t=this.editor,e=t.locale.t;t.ui.componentFactory.add("sourceEditing",(()=>{const t=this._createButton(Mh);return t.set({label:e("Source"),icon:' ',tooltip:!0,class:"ck-source-editing-button"}),t})),t.ui.componentFactory.add("menuBar:sourceEditing",(()=>{const t=this._createButton(Yh);return t.set({label:e("Show source"),role:"menuitemcheckbox"}),t})),this._isAllowedToHandleSourceEditingMode()&&(this.on("change:isSourceEditingMode",((t,e,n)=>{n?(this._hideVisibleDialog(),this._showSourceEditing(),this._disableCommands()):(this._hideSourceEditing(),this._enableCommands())})),this.on("change:isEnabled",((t,e,n)=>this._handleReadOnlyMode(!n))),this.listenTo(t,"change:isReadOnly",((t,e,n)=>this._handleReadOnlyMode(n)))),t.data.on("get",(()=>{this.isSourceEditingMode&&this.updateEditorData()}),{priority:"high"})}updateEditorData(){const t=this.editor,e={};for(const[t,n]of this._replacedRoots){const o=this._dataFromRoots.get(t),i=n.dataset.value;o!==i&&(e[t]=i,this._dataFromRoots.set(t,i))}Object.keys(e).length&&t.data.set(e,{batchType:{isUndoable:!0},suppressErrorInCollaboration:!0})}_checkCompatibility(){const t=this.editor,e=t.config.get("sourceEditing.allowCollaborationFeatures");if(!e&&t.plugins.has("RealTimeCollaborativeEditing"))throw new An("source-editing-incompatible-with-real-time-collaboration",null);!e&&["CommentsEditing","TrackChangesEditing","RevisionHistory"].some((e=>t.plugins.has(e)))&&console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the collaboration features."),t.plugins.has("RestrictedEditingModeEditing")&&console.warn("You initialized the editor with the source editing feature and restricted editing feature. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the restricted editing feature.")}_showSourceEditing(){const t=this.editor,e=t.editing.view,n=t.model;n.change((t=>{t.setSelection(null),t.removeSelectionAttribute(n.document.selection.getAttributeKeys())}));for(const[n,i]of e.domRoots){const r=function(t){return t.startsWith("<")}(o=t.data.get({rootName:n}))?function(t){const e=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],n=e.map((t=>t.name)).join("|"),o=t.replace(new RegExp(`?(${n})( .*?)?>`,"g"),"\n$&\n").replace(/ ]*>/g,"$&\n").split("\n");let i=0,r=!1;return o.filter((t=>t.length)).map((t=>(r=function(t,e){return new RegExp("").test(t)?"first":new RegExp(" ").test(t)?"last":("first"===e||"middle"===e)&&"middle"}(t,r),function(t,e){return e.some((e=>!e.isVoid&&!!new RegExp(`<${e.name}( .*?)?>`).test(t)))}(t,e)?Yx(t,i++):function(t,e){return e.some((e=>new RegExp(`${e.name}>`).test(t)))}(t,e)?Yx(t,--i):"middle"===r||"last"===r?t:Yx(t,i)))).join("\n")}(o):o,s=no(i.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"}),a=no(i.ownerDocument,"div",{class:"ck-source-editing-area","data-value":r},[s]);s.value=r,s.setSelectionRange(0,0),s.addEventListener("input",(()=>{a.dataset.value=s.value,t.ui.update()})),e.change((t=>{const o=e.document.getRoot(n);t.addClass("ck-hidden",o)})),t.ui.setEditableElement("sourceEditing:"+n,s),this._replacedRoots.set(n,a),this._elementReplacer.replace(i,a),this._dataFromRoots.set(n,r)}var o;this._focusSourceEditing()}_hideSourceEditing(){const t=this.editor.editing.view;this.updateEditorData(),t.change((e=>{for(const[n]of this._replacedRoots)e.removeClass("ck-hidden",t.document.getRoot(n))})),this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),t.focus()}_focusSourceEditing(){const t=this.editor,[e]=this._replacedRoots.values(),n=e.querySelector("textarea");t.editing.view.document.isFocused=!1,n.focus()}_disableCommands(){const t=this.editor;for(const e of t.commands.commands())e.forceDisabled(Qx);t.plugins.has("CommentsArchiveUI")&&t.plugins.get("CommentsArchiveUI").forceDisabled(Qx)}_enableCommands(){const t=this.editor;for(const e of t.commands.commands())e.clearForceDisabled(Qx);t.plugins.has("CommentsArchiveUI")&&t.plugins.get("CommentsArchiveUI").clearForceDisabled(Qx)}_handleReadOnlyMode(t){if(this.isSourceEditingMode)for(const[,e]of this._replacedRoots)e.querySelector("textarea").readOnly=t}_isAllowedToHandleSourceEditingMode(){const t=this.editor.ui.view.editable;return t&&!t.hasExternalElement}_hideVisibleDialog(){if(this.editor.plugins.has("Dialog")){const t=this.editor.plugins.get("Dialog");t.isOpen&&t.hide()}}_createButton(t){const e=this.editor,n=new t(e.locale);return n.set({withText:!0,isToggleable:!0}),n.bind("isOn").to(this,"isSourceEditingMode"),n.bind("isEnabled").to(this,"isEnabled",e,"isReadOnly",e.plugins.get(Au),"hasAny",((t,e,n)=>!!t&&!e&&!n)),this.listenTo(n,"execute",(()=>{this.isSourceEditingMode=!this.isSourceEditingMode})),n}}class Jx extends Mh{styleDefinition;previewView;constructor(t,e){super(t),this.styleDefinition=e,this.previewView=this._createPreview(),this.set({label:e.name,class:"ck-style-grid__button",withText:!0}),this.extendTemplate({attributes:{role:"option"}}),this.children.add(this.previewView,0)}_createPreview(){const t=new xh(this.locale);return t.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[this.styleDefinition.previewTemplate]}),t}}class Xx extends xh{focusTracker;keystrokes;children;constructor(t,e){super(t),this.focusTracker=new ci,this.keystrokes=new hi,this.set("activeStyles",[]),this.set("enabledStyles",[]),this.children=this.createCollection(),this.children.delegate("execute").to(this);for(const n of e){const e=new Jx(t,n);this.children.add(e)}this.on("change:activeStyles",(()=>{for(const t of this.children)t.isOn=this.activeStyles.includes(t.styleDefinition.name)})),this.on("change:enabledStyles",(()=>{for(const t of this.children)t.isEnabled=this.enabledStyles.includes(t.styleDefinition.name)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-grid"],role:"listbox"},children:this.children})}render(){super.render();for(const t of this.children)this.focusTracker.add(t.element);Th({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.children,numberOfColumns:3,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.keystrokes.listenTo(this.element)}focus(){this.children.first.focus()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}class tE extends xh{gridView;labelView;constructor(t,e,n){super(t),this.labelView=new Qh(t),this.labelView.text=e,this.gridView=new Xx(t,n),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel__style-group"],role:"group","aria-labelledby":this.labelView.id},children:[this.labelView,this.gridView]})}}class eE extends xh{focusTracker;keystrokes;children;blockStylesGroupView;inlineStylesGroupView;_focusables;_focusCycler;constructor(t,e){super(t);const n=t.t;this.focusTracker=new ci,this.keystrokes=new hi,this.children=this.createCollection(),this.blockStylesGroupView=new tE(t,n("Block styles"),e.block),this.inlineStylesGroupView=new tE(t,n("Text styles"),e.inline),this.set("activeStyles",[]),this.set("enabledStyles",[]),this._focusables=new oh,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["shift + tab"],focusNext:["tab"]}}),e.block.length&&this.children.add(this.blockStylesGroupView),e.inline.length&&this.children.add(this.inlineStylesGroupView),this.blockStylesGroupView.gridView.delegate("execute").to(this),this.inlineStylesGroupView.gridView.delegate("execute").to(this),this.blockStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel"]},children:this.children})}render(){super.render(),this._focusables.add(this.blockStylesGroupView.gridView),this._focusables.add(this.inlineStylesGroupView.gridView),this.focusTracker.add(this.blockStylesGroupView.gridView.element),this.focusTracker.add(this.inlineStylesGroupView.gridView.element),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}const nE=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class oE extends iu{_htmlSupport;static get pluginName(){return"StyleUtils"}static get isOfficialPlugin(){return!0}constructor(t){super(t),this.decorate("isStyleEnabledForBlock"),this.decorate("isStyleActiveForBlock"),this.decorate("getAffectedBlocks"),this.decorate("isStyleEnabledForInlineSelection"),this.decorate("isStyleActiveForInlineSelection"),this.decorate("getAffectedInlineSelectable"),this.decorate("getStylePreview"),this.decorate("configureGHSDataFilter")}init(){this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport")}normalizeConfig(t,e=[]){const n={block:[],inline:[]};for(const o of e){const e=[],i=[];for(const n of t.getDefinitionsForView(o.element)){const t="appliesToBlock"in n&&n.appliesToBlock;if(n.isBlock||t){if("string"==typeof t)e.push(t);else if(n.isBlock){const t=n;e.push(n.model),t.paragraphLikeModel&&e.push(t.paragraphLikeModel)}}else i.push(n.model)}const r=this.getStylePreview(o,[{text:"AaBbCcDdEeFfGgHhIiJj"}]);e.length?n.block.push({...o,previewTemplate:r,modelElements:e,isBlock:!0}):n.inline.push({...o,previewTemplate:r,ghsAttributes:i})}return n}isStyleEnabledForBlock(t,e){const n=this.editor.model,o=this._htmlSupport.getGhsAttributeNameForElement(t.element);return!!n.schema.checkAttribute(e,o)&&t.modelElements.includes(e.name)}isStyleActiveForBlock(t,e){const n=this._htmlSupport.getGhsAttributeNameForElement(t.element),o=e.getAttribute(n);return this.hasAllClasses(o,t.classes)}getAffectedBlocks(t,e){return t.modelElements.includes(e.name)?[e]:null}isStyleEnabledForInlineSelection(t,e){const n=this.editor.model;for(const o of t.ghsAttributes)if(n.schema.checkAttributeInSelection(e,o))return!0;return!1}isStyleActiveForInlineSelection(t,e){for(const n of t.ghsAttributes){const o=this._getValueFromFirstAllowedNode(e,n);if(this.hasAllClasses(o,t.classes))return!0}return!1}getAffectedInlineSelectable(t,e){return e}getStylePreview(t,e){const{element:n,classes:o}=t;return{tag:(i=n,nE.includes(i)?"div":n),attributes:{class:o},children:e};var i}hasAllClasses(t,e){return o(t)&&(n=t,Boolean(n.classes)&&Array.isArray(n.classes))&&e.every((e=>t.classes.includes(e)));var n}configureGHSDataFilter({block:t,inline:e}){const n=this.editor.plugins.get("DataFilter");n.loadAllowedConfig(t.map(iE)),n.loadAllowedConfig(e.map(iE))}_getValueFromFirstAllowedNode(t,e){const n=this.editor.model.schema;if(t.isCollapsed)return t.getAttribute(e);for(const o of t.getRanges())for(const t of o.getItems())if(n.checkAttribute(t,e))return t.getAttribute(e);return null}}function iE({element:t,classes:e}){return{name:t,classes:e}}class rE extends iu{static get pluginName(){return"StyleUI"}static get isOfficialPlugin(){return!0}static get requires(){return[oE]}init(){const t=this.editor,e=t.plugins.get("DataSchema"),n=t.plugins.get("StyleUtils"),o=t.config.get("style.definitions"),i=n.normalizeConfig(e,o);t.ui.componentFactory.add("style",(e=>{const n=e.t,o=jp(e),r=t.commands.get("style");return o.once("change:isOpen",(()=>{const t=new eE(e,i);o.panelView.children.add(t),t.delegate("execute").to(o),t.bind("activeStyles").to(r,"value"),t.bind("enabledStyles").to(r,"enabledStyles")})),o.bind("isEnabled").to(r),o.buttonView.withText=!0,o.buttonView.bind("label").to(r,"value",(t=>t.length>1?n("Multiple styles"):1===t.length?t[0]:n("Styles"))),o.bind("class").to(r,"value",(t=>{const e=["ck-style-dropdown"];return t.length>1&&e.push("ck-style-dropdown_multiple-active"),e.join(" ")})),o.on("execute",(e=>{t.execute("style",{styleName:e.source.styleDefinition.name}),t.editing.view.focus()})),o}))}}class sE extends su{_styleDefinitions;_styleUtils;constructor(t,e){super(t),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=e,this._styleUtils=this.editor.plugins.get(oE)}refresh(){const t=this.editor.model,e=t.document.selection,n=new Set,o=new Set;for(const t of this._styleDefinitions.inline)this._styleUtils.isStyleEnabledForInlineSelection(t,e)&&o.add(t.name),this._styleUtils.isStyleActiveForInlineSelection(t,e)&&n.add(t.name);const i=ai(e.getSelectedBlocks())||e.getFirstPosition().parent;if(i){const e=i.getAncestors({includeSelf:!0,parentFirst:!0});for(const i of e){if(i.is("rootElement"))break;for(const t of this._styleDefinitions.block)this._styleUtils.isStyleEnabledForBlock(t,i)&&(o.add(t.name),this._styleUtils.isStyleActiveForBlock(t,i)&&n.add(t.name));if(t.schema.isObject(i))break}}this.enabledStyles=Array.from(o).sort(),this.isEnabled=this.enabledStyles.length>0,this.value=this.isEnabled?Array.from(n).sort():[]}execute({styleName:t,forceValue:e}){if(!this.enabledStyles.includes(t))return void yn("style-command-executed-with-incorrect-style-name");const n=this.editor.model,o=n.document.selection,i=this.editor.plugins.get("GeneralHtmlSupport"),r=[...this._styleDefinitions.inline,...this._styleDefinitions.block],s=r.filter((({name:t})=>this.value.includes(t))),a=r.find((({name:e})=>e==t)),c=void 0===e?!this.value.includes(a.name):e;n.change((()=>{let t;t=function(t){return"isBlock"in t}(a)?this._findAffectedBlocks(function(t){const e=Array.from(t.getSelectedBlocks());return e.length?e:[t.getFirstPosition().parent]}(o),a):[this._styleUtils.getAffectedInlineSelectable(a,o)];for(const e of t)c?i.addModelHtmlClass(a.element,a.classes,e):i.removeModelHtmlClass(a.element,aE(s,a),e)}))}_findAffectedBlocks(t,e){const n=new Set;for(const o of t){const t=o.getAncestors({includeSelf:!0,parentFirst:!0});for(const o of t){if(o.is("rootElement"))break;const t=this._styleUtils.getAffectedBlocks(e,o);if(t){for(const e of t)n.add(e);break}}}return n}}function aE(t,e){return t.reduce(((t,n)=>n.name===e.name?t:t.filter((t=>!n.classes.includes(t)))),e.classes)}class cE extends iu{_listUtils;_styleUtils;_htmlSupport;static get pluginName(){return"ListStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[oE,"GeneralHtmlSupport"]}init(){const t=this.editor;t.plugins.has("ListEditing")&&(this._styleUtils=t.plugins.get(oE),this._listUtils=this.editor.plugins.get("ListUtils"),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",((t,[e,n])=>{this._isStyleEnabledForBlock(e,n)&&(t.return=!0,t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForBlock",((t,[e,n])=>{this._isStyleActiveForBlock(e,n)&&(t.return=!0,t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",((t,[e,n])=>{const o=this._getAffectedBlocks(e,n);o&&(t.return=o,t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getStylePreview",((t,[e,n])=>{const o=this._getStylePreview(e,n);o&&(t.return=o,t.stop())}),{priority:"high"}))}_isStyleEnabledForBlock(t,e){const n=this.editor.model;if(!["ol","ul","li"].includes(t.element))return!1;if(!this._listUtils.isListItemBlock(e))return!1;const o=this._htmlSupport.getGhsAttributeNameForElement(t.element);if("ol"==t.element||"ul"==t.element){if(!n.schema.checkAttribute(e,o))return!1;const i=this._listUtils.isNumberedListType(e.getAttribute("listType"))?"ol":"ul";return t.element==i}return n.schema.checkAttribute(e,o)}_isStyleActiveForBlock(t,e){const n=this._htmlSupport.getGhsAttributeNameForElement(t.element),o=e.getAttribute(n);return this._styleUtils.hasAllClasses(o,t.classes)}_getAffectedBlocks(t,e){return this._isStyleEnabledForBlock(t,e)?"li"==t.element?this._listUtils.expandListBlocksToCompleteItems(e,{withNested:!1}):this._listUtils.expandListBlocksToCompleteList(e):null}_getStylePreview(t,e){const{element:n,classes:o}=t;return"ol"==n||"ul"==n?{tag:n,attributes:{class:o},children:[{tag:"li",children:e}]}:"li"==n?{tag:"ol",children:[{tag:n,attributes:{class:o},children:e}]}:null}}class lE extends iu{_tableUtils;_styleUtils;static get pluginName(){return"TableStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[oE]}init(){const t=this.editor;t.plugins.has("TableEditing")&&(this._styleUtils=t.plugins.get(oE),this._tableUtils=this.editor.plugins.get("TableUtils"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",((t,[e,n])=>{this._isApplicable(e,n)&&(t.return=this._isStyleEnabledForBlock(e,n),t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",((t,[e,n])=>{this._isApplicable(e,n)&&(t.return=this._getAffectedBlocks(e,n),t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"configureGHSDataFilter",((t,[{block:e}])=>{this.editor.plugins.get("DataFilter").loadAllowedConfig(e.filter((t=>"figcaption"==t.element)).map((t=>({name:"caption",classes:t.classes}))))})))}_isApplicable(t,e){return["td","th"].includes(t.element)?"tableCell"==e.name:!!["thead","tbody"].includes(t.element)&&"table"==e.name}_isStyleEnabledForBlock(t,e){if(["td","th"].includes(t.element)){const n=this._tableUtils.getCellLocation(e),o=e.parent.parent,i=o.getAttribute("headingRows")||0,r=o.getAttribute("headingColumns")||0,s=n.row0:n{"a"==e.element&&(t.return=this._isStyleEnabled(e,n),t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForInlineSelection",((t,[e,n])=>{"a"==e.element&&(t.return=this._isStyleActive(e,n),t.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedInlineSelectable",((t,[e,n])=>{if("a"!=e.element)return;const o=this._getAffectedSelectable(e,n);o&&(t.return=o,t.stop())}),{priority:"high"}))}_isStyleEnabled(t,e){const n=this.editor.model;if(e.isCollapsed)return e.hasAttribute("linkHref");for(const t of e.getRanges())for(const e of t.getItems())if((e.is("$textProxy")||n.schema.isInline(e))&&e.hasAttribute("linkHref"))return!0;return!1}_isStyleActive(t,e){const n=this.editor.model,o=this._htmlSupport.getGhsAttributeNameForElement(t.element);if(e.isCollapsed){if(e.hasAttribute("linkHref")){const n=e.getAttribute(o);if(this._styleUtils.hasAllClasses(n,t.classes))return!0}return!1}for(const i of e.getRanges())for(const e of i.getItems())if((e.is("$textProxy")||n.schema.isInline(e))&&e.hasAttribute("linkHref")){const n=e.getAttribute(o);return this._styleUtils.hasAllClasses(n,t.classes)}return!1}_getAffectedSelectable(t,e){const n=this.editor.model;if(e.isCollapsed){const t=e.getAttribute("linkHref");return Ug(e.getFirstPosition(),"linkHref",t,n)}const o=[];for(const t of e.getRanges()){const e=n.createRange(uE(t.start,"linkHref",!0,n),uE(t.end,"linkHref",!1,n));for(const t of e.getItems())(t.is("$textProxy")||n.schema.isInline(t))&&t.hasAttribute("linkHref")&&o.push(this.editor.model.createRangeOn(t))}return function(t){for(let e=1;e!0}=e;t.for("upcast").attributeToAttribute({view:{name:i,styles:{[o]:/[\s\S]+/}},model:{key:n,value:t=>{if(!a(t))return;const e=t.getNormalizedStyle(o),n=s?kE(e):e;return r!==n?n:void 0}}})}function mE(t,e,n,o){t.for("upcast").add((t=>t.on("element:"+e,((t,e,i)=>{if(!e.modelRange)return;const r=["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((t=>e.viewItem.hasStyle(t)));if(!r.length)return;const s={styles:r};if(!i.consumable.test(e.viewItem,s))return;const a=[...e.modelRange.getItems({shallow:!0})].pop();i.consumable.consume(e.viewItem,s);const c={style:e.viewItem.getNormalizedStyle("border-style"),color:e.viewItem.getNormalizedStyle("border-color"),width:e.viewItem.getNormalizedStyle("border-width")},l={style:kE(c.style),color:kE(c.color),width:kE(c.width)};l.style!==o.style&&i.writer.setAttribute(n.style,l.style,a),l.color!==o.color&&i.writer.setAttribute(n.color,l.color,a),l.width!==o.width&&i.writer.setAttribute(n.width,l.width,a)}))))}function gE(t,e){const{modelElement:n,modelAttribute:o,styleName:i}=e;t.for("downcast").attributeToAttribute({model:{name:n,key:o},view:t=>({key:"style",value:{[i]:t}})})}function fE(t,e){const{modelAttribute:n,styleName:o}=e;t.for("downcast").add((t=>t.on(`attribute:${n}:table`,((t,e,n)=>{const{item:i,attributeNewValue:r}=e,{mapper:s,writer:a}=n;if(!n.consumable.consume(e.item,t.name))return;const c=[...s.toViewElement(i).getChildren()].find((t=>t.is("element","table")));r?a.setStyle(o,r,c):a.removeStyle(o,c)}))))}function kE(t){if(!t)return;const e=["top","right","bottom","left"];if(!e.every((e=>t[e])))return t;const n=t.top;return e.every((e=>t[e]===n))?n:t}function bE(t,e,n,o,i=1){null!=e&&null!=i&&e>i?o.setAttribute(t,e,n):o.removeAttribute(t,n)}function wE(t,e,n={}){const o=t.createElement("tableCell",n);return t.insertElement("paragraph",o),t.insert(o,e),o}function _E(t,e){const n=e.parent.parent,o=parseInt(n.getAttribute("headingColumns")||"0"),{column:i}=t.getCellLocation(e);return!!o&&i{e.on(`element:${t}`,((t,e,{writer:n})=>{if(!e.modelRange)return;const o=e.modelRange.start.nodeAfter,i=n.createPositionAt(o,0);if(e.viewItem.isEmpty)return void n.insertElement("paragraph",i);const r=Array.from(o.getChildren());if(r.every((t=>t.is("element","$marker")))){const t=n.createElement("paragraph");n.insert(t,n.createPositionAt(o,0));for(const e of r)n.move(n.createRangeOn(e),n.createPositionAt(t,"end"))}}),{priority:"low"})}}function yE(t){let e=0,n=0;const o=Array.from(t.getChildren()).filter((t=>"th"===t.name||"td"===t.name));for(;n1||i>1)&&this._recordSpans(n,i,o),this._shouldSkipSlot()||(e=this._formatOutValue(n)),this._nextCellAtColumn=this._column+o}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,e||this.next()}skipRow(t){this._skipRows.add(t)}_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(t,e=this._row,n=this._column){return{done:!1,value:new EE(this,t,e,n)}}_shouldSkipSlot(){const t=this._skipRows.has(this._row),e=this._rowthis._endColumn;return t||e||n||o}_getSpanned(){const t=this._spannedCells.get(this._row);return t&&t.get(this._column)||null}_recordSpans(t,e,n){const o={cell:t,row:this._row,column:this._column};for(let t=this._row;t0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const t=this._getRowLength(0);for(let e=this._startRow;!this._jumpedToStartRow;e--)t===this._getRowLength(e)&&(this._row=e,this._rowIndex=e,this._jumpedToStartRow=!0)}_getRowLength(t){return[...this._table.getChild(t).getChildren()].reduce(((t,e)=>t+parseInt(e.getAttribute("colspan")||"1")),0)}}class EE{cell;row;column;cellAnchorRow;cellAnchorColumn;_cellIndex;_rowIndex;_table;constructor(t,e,n,o){this.cell=e,this.row=t._row,this.column=t._column,this.cellAnchorRow=n,this.cellAnchorColumn=o,this._cellIndex=t._cellIndex,this._rowIndex=t._rowIndex,this._table=t._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 DE(t,e){return(n,{writer:o})=>{const i=n.getAttribute("headingRows")||0,r=o.createContainerElement("table",null,[]),s=o.createContainerElement("figure",{class:"table"},r);i>0&&o.insert(o.createPositionAt(r,"end"),o.createContainerElement("thead",null,o.createSlot((t=>t.is("element","tableRow")&&t.indext.is("element","tableRow")&&t.index>=i))));for(const{positionOffset:t,filter:n}of e.additionalSlots)o.insert(o.createPositionAt(r,t),o.createSlot(n));return o.insert(o.createPositionAt(r,"after"),o.createSlot((t=>!t.is("element","tableRow")&&!e.additionalSlots.some((({filter:e})=>e(t)))))),e.asWidget?function(t,e){return e.setCustomProperty("table",!0,t),Kf(t,e,{hasSelectionHandle:!0})}(s,o):s}}function SE(t={}){return(e,{writer:n})=>{const o=e.parent,i=o.parent,r=i.getChildIndex(o),s=new xE(i,{row:r}),a=i.getAttribute("headingRows")||0,c=i.getAttribute("headingColumns")||0;let l=null;for(const o of s)if(o.cell==e){const e=o.row{if(!e.parent.is("element","tableCell"))return null;if(!BE(e))return null;if(t.asWidget)return n.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const t=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,t),t}}}function BE(t){return 1==t.parent.childCount&&!!t.getAttributeKeys().next().done}class IE extends su{refresh(){const t=this.editor.model,e=t.document.selection,n=t.schema;this.isEnabled=function(t,e){const n=t.getFirstPosition().parent,o=n===n.root?n:n.parent;return e.checkChild(o,"table")}(e,n)}execute(t={}){const e=this.editor,n=e.model,o=e.plugins.get("TableUtils"),i=e.config.get("table.defaultHeadings.rows"),r=e.config.get("table.defaultHeadings.columns");void 0===t.headingRows&&i&&(t.headingRows=i),void 0===t.headingColumns&&r&&(t.headingColumns=r),n.change((e=>{const i=o.createTable(e,t);n.insertObject(i,null,null,{findOptimalPosition:"auto"}),e.setSelection(e.createPositionAt(i.getNodeByPath([0,0,0]),0))}))}}class ME extends su{order;constructor(t,e={}){super(t),this.order=e.order||"below"}refresh(){const t=this.editor.model.document.selection,e=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(t).length;this.isEnabled=e}execute(){const t=this.editor,e=t.model.document.selection,n=t.plugins.get("TableUtils"),o="above"===this.order,i=n.getSelectionAffectedTableCells(e),r=n.getRowIndexes(i),s=o?r.first:r.last,a=i[0].findAncestor("table");n.insertRows(a,{at:o?s:s+1,copyStructureFromAbove:!o})}}class PE extends su{order;constructor(t,e={}){super(t),this.order=e.order||"right"}refresh(){const t=this.editor.model.document.selection,e=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(t).length;this.isEnabled=e}execute(){const t=this.editor,e=t.model.document.selection,n=t.plugins.get("TableUtils"),o="left"===this.order,i=n.getSelectionAffectedTableCells(e),r=n.getColumnIndexes(i),s=o?r.first:r.last,a=i[0].findAncestor("table");n.insertColumns(a,{columns:1,at:o?s:s+1})}}class OE extends su{direction;constructor(t,e={}){super(t),this.direction=e.direction||"horizontally"}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===t.length}execute(){const t=this.editor.plugins.get("TableUtils"),e=t.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?t.splitCellHorizontally(e,2):t.splitCellVertically(e,2)}}function NE(t,e,n){const{startRow:o,startColumn:i,endRow:r,endColumn:s}=e,a=n.createElement("table"),c=r-o+1;for(let t=0;t0&&bE("headingRows",r-n,t,i,0);const s=parseInt(e.getAttribute("headingColumns")||"0");s>0&&bE("headingColumns",s-o,t,i,0)}(a,t,o,i,n),a}function zE(t,e,n=0){const o=[],i=new xE(t,{startRow:n,endRow:e-1});for(const t of i){const{row:n,cellHeight:i}=t;n1&&(a.rowspan=c);const l=parseInt(t.getAttribute("colspan")||"1");l>1&&(a.colspan=l);const d=r+s,u=[...new xE(i,{startRow:r,endRow:d,includeAllSlots:!0})];let h,p=null;for(const e of u){const{row:o,column:i,cell:r}=e;r===t&&void 0===h&&(h=i),void 0!==h&&h===i&&o===d&&(p=wE(n,e.getPositionBefore(),a))}return bE("rowspan",s,t,n),p}function RE(t,e){const n=[],o=new xE(t);for(const t of o){const{column:o,cellWidth:i}=t;o1&&(r.colspan=s);const a=parseInt(t.getAttribute("rowspan")||"1");a>1&&(r.rowspan=a);const c=wE(o,o.createPositionAfter(t),r);return bE("colspan",i,t,o),c}function jE(t,e,n,o,i,r){const s=parseInt(t.getAttribute("colspan")||"1"),a=parseInt(t.getAttribute("rowspan")||"1");n+s-1>i&&bE("colspan",i-n+1,t,r,1),e+a-1>o&&bE("rowspan",o-e+1,t,r,1)}function VE(t,e){const n=e.getColumns(t),o=new Array(n).fill(0);for(const{column:e}of new xE(t))o[e]++;const i=o.reduce(((t,e,n)=>e?t:[...t,n]),[]);if(i.length>0){const n=i[i.length-1];return e.removeColumns(t,{at:n}),!0}return!1}function HE(t,e){const n=[],o=e.getRows(t);for(let e=0;e0){const o=n[n.length-1];return e.removeRows(t,{at:o}),!0}return!1}function UE(t,e){VE(t,e)||HE(t,e)}function WE(t,e){const n=Array.from(new xE(t,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(n.every((({cellHeight:t})=>1===t)))return e.lastRow;const o=n[0].cellHeight-1;return e.lastRow+o}function GE(t,e){const n=Array.from(new xE(t,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(n.every((({cellWidth:t})=>1===t)))return e.lastColumn;const o=n[0].cellWidth-1;return e.lastColumn+o}class qE extends su{direction;isHorizontal;constructor(t,e){super(t),this.direction=e.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const t=this._getMergeableCell();this.value=t,this.isEnabled=!!t}execute(){const t=this.editor.model,e=t.document,n=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(e.selection)[0],o=this.value,i=this.direction;t.change((t=>{const e="right"==i||"down"==i,r=e?n:o,s=e?o:n,a=s.parent;!function(t,e,n){$E(t)||($E(e)&&n.remove(n.createRangeIn(e)),n.move(n.createRangeIn(t),n.createPositionAt(e,"end"))),n.remove(t)}(s,r,t);const c=this.isHorizontal?"colspan":"rowspan",l=parseInt(n.getAttribute(c)||"1"),d=parseInt(o.getAttribute(c)||"1");t.setAttribute(c,l+d,r),t.setSelection(t.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");UE(a.findAncestor("table"),u)}))}_getMergeableCell(){const t=this.editor.model.document,e=this.editor.plugins.get("TableUtils"),n=e.getTableCellsContainingSelection(t.selection)[0];if(!n)return;const o=this.isHorizontal?function(t,e,n){const o=t.parent.parent,i="right"==e?t.nextSibling:t.previousSibling,r=(o.getAttribute("headingColumns")||0)>0;if(!i)return;const s="right"==e?t:i,a="right"==e?i:t,{column:c}=n.getCellLocation(s),{column:l}=n.getCellLocation(a),d=parseInt(s.getAttribute("colspan")||"1"),u=_E(n,s),h=_E(n,a);return r&&u!=h?void 0:c+d===l?i:void 0}(n,this.direction,e):function(t,e,n){const o=t.parent,i=o.parent,r=i.getChildIndex(o);if("down"==e&&r===n.getRows(i)-1||"up"==e&&0===r)return null;const s=parseInt(t.getAttribute("rowspan")||"1"),a=i.getAttribute("headingRows")||0;if(a&&("down"==e&&r+s===a||"up"==e&&r===a))return null;const c=parseInt(t.getAttribute("rowspan")||"1"),l="down"==e?r+c:r,d=[...new xE(i,{endRow:l})],u=d.find((e=>e.cell===t)).column,h=d.find((({row:t,cellHeight:n,column:o})=>o===u&&("down"==e?t===l:l===t+n)));return h&&h.cell?h.cell:null}(n,this.direction,e);if(!o)return;const i=this.isHorizontal?"rowspan":"colspan",r=parseInt(n.getAttribute(i)||"1");return parseInt(o.getAttribute(i)||"1")===r?o:void 0}}function $E(t){const e=t.getChild(0);return 1==t.childCount&&e.is("element","paragraph")&&e.isEmpty}class KE extends su{refresh(){const t=this.editor.plugins.get("TableUtils"),e=t.getSelectionAffectedTableCells(this.editor.model.document.selection),n=e[0];if(n){const o=n.findAncestor("table"),i=t.getRows(o)-1,r=t.getRowIndexes(e),s=0===r.first&&r.last===i;this.isEnabled=!s}else this.isEnabled=!1}execute(){const t=this.editor.model,e=this.editor.plugins.get("TableUtils"),n=e.getSelectionAffectedTableCells(t.document.selection),o=e.getRowIndexes(n),i=n[0],r=i.findAncestor("table"),s=e.getCellLocation(i).column;t.change((t=>{const n=o.last-o.first+1;e.removeRows(r,{at:o.first,rows:n});const i=function(t,e,n,o){const i=t.getChild(Math.min(e,o-1));let r=i.getChild(0),s=0;for(const t of i.getChildren()){if(s>n)return r;r=t,s+=parseInt(t.getAttribute("colspan")||"1")}return r}(r,o.first,s,e.getRows(r));t.setSelection(t.createPositionAt(i,0))}))}}class YE extends su{refresh(){const t=this.editor.plugins.get("TableUtils"),e=t.getSelectionAffectedTableCells(this.editor.model.document.selection),n=e[0];if(n){const o=n.findAncestor("table"),i=t.getColumns(o),{first:r,last:s}=t.getColumnIndexes(e);this.isEnabled=s-rt.cell===e)).column,last:i.find((t=>t.cell===n)).column},s=function(t,e,n,o){return parseInt(n.getAttribute("colspan")||"1")>1?n:e.previousSibling||n.nextSibling?n.nextSibling||e.previousSibling:o.first?t.reverse().find((({column:t})=>tt>o.last)).cell}(i,e,n,r);this.editor.model.change((e=>{const n=r.last-r.first+1;t.removeColumns(o,{at:r.first,columns:n}),e.setSelection(e.createPositionAt(s,0))}))}}class QE extends su{refresh(){const t=this.editor.plugins.get("TableUtils"),e=this.editor.model,n=t.getSelectionAffectedTableCells(e.document.selection),o=n.length>0;this.isEnabled=o,this.value=o&&n.every((t=>this._isInHeading(t,t.parent.parent)))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.plugins.get("TableUtils"),n=this.editor.model,o=e.getSelectionAffectedTableCells(n.document.selection),i=o[0].findAncestor("table"),{first:r,last:s}=e.getRowIndexes(o),a=this.value?r:s+1,c=i.getAttribute("headingRows")||0;n.change((t=>{if(a){const e=zE(i,a,a>c?c:0);for(const{cell:n}of e)LE(n,a,t)}bE("headingRows",a,i,t,0)}))}_isInHeading(t,e){const n=parseInt(e.getAttribute("headingRows")||"0");return!!n&&t.parent.index0;this.isEnabled=o,this.value=o&&n.every((t=>_E(e,t)))}execute(t={}){if(t.forceValue===this.value)return;const e=this.editor.plugins.get("TableUtils"),n=this.editor.model,o=e.getSelectionAffectedTableCells(n.document.selection),i=o[0].findAncestor("table"),{first:r,last:s}=e.getColumnIndexes(o),a=this.value?r:s+1;n.change((t=>{if(a){const e=RE(i,a);for(const{cell:n,column:o}of e)FE(n,o,a,t)}bE("headingColumns",a,i,t,0)}))}}function JE(t){const e=function(t){if(t.is("element","tableColumnGroup"))return t;const e=t.getChildren();return Array.from(e).find((t=>t.is("element","tableColumnGroup")))}(t);return e?Array.from(e.getChildren()):[]}class XE extends iu{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(t){const e=t.parent,n=e.parent,o=n.getChildIndex(e),i=new xE(n,{row:o});for(const{cell:e,row:n,column:o}of i)if(e===t)return{row:n,column:o}}createTable(t,e){const n=t.createElement("table"),o=e.rows||2,i=e.columns||2;return tD(t,n,0,o,i),e.headingRows&&bE("headingRows",Math.min(e.headingRows,o),n,t,0),e.headingColumns&&bE("headingColumns",Math.min(e.headingColumns,i),n,t,0),n}insertRows(t,e={}){const n=this.editor.model,o=e.at||0,i=e.rows||1,r=void 0!==e.copyStructureFromAbove,s=e.copyStructureFromAbove?o-1:o,a=this.getRows(t),c=this.getColumns(t);if(o>a)throw new An("tableutils-insertrows-insert-out-of-range",this,{options:e});n.change((e=>{const n=t.getAttribute("headingRows")||0;if(n>o&&bE("headingRows",n+i,t,e,0),!r&&(0===o||o===a))return void tD(e,t,o,i,c);const l=r?Math.max(o,s):o,d=new xE(t,{endRow:l}),u=new Array(c).fill(1);for(const{row:t,column:n,cellHeight:a,cellWidth:c,cell:l}of d){const d=t+a-1,h=t<=s&&s<=d;t0&&wE(e,i,o>1?{colspan:o}:void 0),t+=Math.abs(o)-1}}}))}insertColumns(t,e={}){const n=this.editor.model,o=e.at||0,i=e.columns||1;n.change((e=>{const n=t.getAttribute("headingColumns");oi-1)throw new An("tableutils-removerows-row-index-out-of-range",this,{table:t,options:e});n.change((e=>{const n={first:r,last:s},{cellsToMove:o,cellsToTrim:i}=function(t,{first:e,last:n}){const o=new Map,i=[];for(const{row:r,column:s,cellHeight:a,cell:c}of new xE(t,{endRow:n})){const t=r+a-1;if(r>=e&&r<=n&&t>n){const t=a-(n-r+1);o.set(s,{cell:c,rowspan:t})}if(r=e){let o;o=t>=n?n-e+1:t-e+1,i.push({cell:c,rowspan:a-o})}}return{cellsToMove:o,cellsToTrim:i}}(t,n);o.size&&function(t,e,n,o){const i=[...new xE(t,{includeAllSlots:!0,row:e})],r=t.getChild(e);let s;for(const{column:t,cell:e,isAnchor:a}of i)if(n.has(t)){const{cell:e,rowspan:i}=n.get(t),a=s?o.createPositionAfter(s):o.createPositionAt(r,0);o.move(o.createRangeOn(e),a),bE("rowspan",i,e,o),s=e}else a&&(s=e)}(t,s+1,o,e);for(let n=s;n>=r;n--)e.remove(t.getChild(n));for(const{rowspan:t,cell:n}of i)bE("rowspan",t,n,e);!function(t,{first:e,last:n},o){const i=t.getAttribute("headingRows")||0;e{!function(t,e,n){const o=t.getAttribute("headingColumns")||0;if(o&&e.first=o;i--){for(const{cell:n,column:o,cellWidth:r}of[...new xE(t)])o<=i&&r>1&&o+r>i?bE("colspan",r-1,n,e):o===i&&e.remove(n);if(n[i]){const t=0===i?n[1]:n[i-1],o=parseFloat(n[i].getAttribute("columnWidth")),r=parseFloat(t.getAttribute("columnWidth"));e.remove(n[i]),e.setAttribute("columnWidth",o+r+"%",t)}}HE(t,this)||VE(t,this)}))}splitCellVertically(t,e=2){const n=this.editor.model,o=t.parent.parent,i=parseInt(t.getAttribute("rowspan")||"1"),r=parseInt(t.getAttribute("colspan")||"1");n.change((n=>{if(r>1){const{newCellsSpan:o,updatedSpan:s}=nD(r,e);bE("colspan",s,t,n);const a={};o>1&&(a.colspan=o),i>1&&(a.rowspan=i),eD(r>e?e-1:r-1,n,n.createPositionAfter(t),a)}if(re===t)),l=a.filter((({cell:e,cellWidth:n,column:o})=>e!==t&&o===c||oc));for(const{cell:t,cellWidth:e}of l)n.setAttribute("colspan",e+s,t);const d={};i>1&&(d.rowspan=i),eD(s,n,n.createPositionAfter(t),d);const u=o.getAttribute("headingColumns")||0;u>c&&bE("headingColumns",u+s,o,n)}}))}splitCellHorizontally(t,e=2){const n=this.editor.model,o=t.parent,i=o.parent,r=i.getChildIndex(o),s=parseInt(t.getAttribute("rowspan")||"1"),a=parseInt(t.getAttribute("colspan")||"1");n.change((n=>{if(s>1){const o=[...new xE(i,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:l}=nD(s,e);bE("rowspan",l,t,n);const{column:d}=o.find((({cell:e})=>e===t)),u={};c>1&&(u.rowspan=c),a>1&&(u.colspan=a);let h=0;for(const t of o){const{column:e,row:o}=t,i=e===d;h>=c&&i&&(h=0),o>=r+l&&i&&(h||eD(1,n,t.getPositionBefore(),u),h++)}}if(sr){const t=i+o;n.setAttribute("rowspan",t,e)}const l={};a>1&&(l.colspan=a),tD(n,i,r+1,o,1,l);const d=i.getAttribute("headingRows")||0;d>r&&bE("headingRows",d+o,i,n)}}))}getColumns(t){return[...t.getChild(0).getChildren()].filter((t=>t.is("element","tableCell"))).reduce(((t,e)=>t+parseInt(e.getAttribute("colspan")||"1")),0)}getRows(t){return Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0)}createTableWalker(t,e={}){return new xE(t,e)}getSelectedTableCells(t){const e=[];for(const n of this.sortRanges(t.getRanges())){const t=n.getContainedElement();t&&t.is("element","tableCell")&&e.push(t)}return e}getTableCellsContainingSelection(t){const e=[];for(const n of t.getRanges()){const t=n.start.findAncestor("tableCell");t&&e.push(t)}return e}getSelectionAffectedTableCells(t){const e=this.getSelectedTableCells(t);return e.length?e:this.getTableCellsContainingSelection(t)}getRowIndexes(t){const e=t.map((t=>t.parent.index));return this._getFirstLastIndexesObject(e)}getColumnIndexes(t){const e=t[0].findAncestor("table"),n=[...new xE(e)].filter((e=>t.includes(e.cell))).map((t=>t.column));return this._getFirstLastIndexesObject(n)}isSelectionRectangular(t){if(t.length<2||!this._areCellInTheSameTableSection(t))return!1;const e=new Set,n=new Set;let o=0;for(const i of t){const{row:t,column:r}=this.getCellLocation(i),s=parseInt(i.getAttribute("rowspan"))||1,a=parseInt(i.getAttribute("colspan"))||1;e.add(t),n.add(r),s>1&&e.add(t+s-1),a>1&&n.add(r+a-1),o+=s*a}const i=function(t,e){const n=Array.from(t.values()),o=Array.from(e.values());return(Math.max(...n)-Math.min(...n)+1)*(Math.max(...o)-Math.min(...o)+1)}(e,n);return i==o}sortRanges(t){return Array.from(t).sort(oD)}_getFirstLastIndexesObject(t){const e=t.sort(((t,e)=>t-e));return{first:e[0],last:e[e.length-1]}}_areCellInTheSameTableSection(t){const e=t[0].findAncestor("table"),n=this.getRowIndexes(t),o=parseInt(e.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(n,o))return!1;const i=this.getColumnIndexes(t),r=parseInt(e.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(i,r)}_areIndexesInSameSection({first:t,last:e},n){return t{const o=e.getSelectedTableCells(t.document.selection),i=o.shift(),{mergeWidth:r,mergeHeight:s}=function(t,e,n){let o=0,i=0;for(const t of e){const{row:e,column:r}=n.getCellLocation(t);o=aD(t,r,o,"colspan"),i=aD(t,e,i,"rowspan")}const{row:r,column:s}=n.getCellLocation(t);return{mergeWidth:o-s,mergeHeight:i-r}}(i,o,e);bE("colspan",r,i,n),bE("rowspan",s,i,n);for(const t of o)rD(t,i,n);UE(i.findAncestor("table"),e),n.setSelection(i,"in")}))}}function rD(t,e,n){sD(t)||(sD(e)&&n.remove(n.createRangeIn(e)),n.move(n.createRangeIn(t),n.createPositionAt(e,"end"))),n.remove(t)}function sD(t){const e=t.getChild(0);return 1==t.childCount&&e.is("element","paragraph")&&e.isEmpty}function aD(t,e,n,o){const i=parseInt(t.getAttribute(o)||"1");return Math.max(n,e+i)}class cD extends su{constructor(t){super(t),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const t=this.editor.model,e=this.editor.plugins.get("TableUtils"),n=e.getSelectionAffectedTableCells(t.document.selection),o=e.getRowIndexes(n),i=n[0].findAncestor("table"),r=[];for(let e=o.first;e<=o.last;e++)for(const n of i.getChild(e).getChildren())r.push(t.createRangeOn(n));t.change((t=>{t.setSelection(r)}))}}class lD extends su{constructor(t){super(t),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const t=this.editor.plugins.get("TableUtils"),e=this.editor.model,n=t.getSelectionAffectedTableCells(e.document.selection),o=n[0],i=n.pop(),r=o.findAncestor("table"),s=t.getCellLocation(o),a=t.getCellLocation(i),c=Math.min(s.column,a.column),l=Math.max(s.column,a.column),d=[];for(const t of new xE(r,{startColumn:c,endColumn:l}))d.push(e.createRangeOn(t.cell));e.change((t=>{t.setSelection(d)}))}}function dD(t,e){let n=!1;const o=function(t){const e=parseInt(t.getAttribute("headingRows")||"0"),n=Array.from(t.getChildren()).reduce(((t,e)=>e.is("element","tableRow")?t+1:t),0),o=[];for(const{row:i,cell:r,cellHeight:s}of new xE(t)){if(s<2)continue;const t=it){const e=t-i;o.push({cell:r,rowspan:e})}}return o}(t);if(o.length){n=!0;for(const t of o)bE("rowspan",t.rowspan,t.cell,e,1)}return n}function uD(t,e){let n=!1;const o=function(t){const e=new Array(t.childCount).fill(0);for(const{rowIndex:n}of new xE(t,{includeAllSlots:!0}))e[n]++;return e}(t),i=[];for(const[e,n]of o.entries())!n&&t.getChild(e).is("element","tableRow")&&i.push(e);if(i.length){n=!0;for(const n of i.reverse())e.remove(t.getChild(n)),o.splice(n,1)}const r=o.filter(((e,n)=>t.getChild(n).is("element","tableRow"))),s=r[0];if(!r.every((t=>t===s))){const o=r.reduce(((t,e)=>e>t?e:t),0);for(const[i,s]of r.entries()){const r=o-s;if(r){for(let n=0;nt.is("$text")));for(const t of n)e.wrap(e.createRangeOn(t),"paragraph");return!!n.length}function fD(t){return!!t.position.parent.is("element","tableCell")&&("insert"==t.type&&"$text"==t.name||"remove"==t.type)}function kD(t,e){if(!t.is("element","paragraph"))return!1;const n=e.toViewElement(t);return!!n&&BE(t)!==n.is("element","span")}class bD extends iu{_additionalSlots;static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[XE]}constructor(t){super(t),this._additionalSlots=[]}init(){const t=this.editor,e=t.model,n=e.schema,o=t.conversion,i=t.plugins.get(XE);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),o.for("upcast").add((t=>{t.on("element:figure",((t,e,n)=>{if(!n.consumable.test(e.viewItem,{name:!0,classes:"table"}))return;const o=function(t){for(const e of t.getChildren())if(e.is("element","table"))return e}(e.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(e.viewItem,{name:!0,classes:"table"});const i=ai(n.convertItem(o,e.modelCursor).modelRange.getItems());i?(n.convertChildren(e.viewItem,n.writer.createPositionAt(i,"end")),n.updateConversionResult(i,e)):n.consumable.revert(e.viewItem,{name:!0,classes:"table"})}))})),o.for("upcast").add((t=>{t.on("element:table",((t,e,n)=>{const o=e.viewItem;if(!n.consumable.test(o,{name:!0}))return;const{rows:i,headingRows:r,headingColumns:s}=function(t){let e,n=0;const o=[],i=[];let r;for(const s of Array.from(t.getChildren())){if("tbody"!==s.name&&"thead"!==s.name&&"tfoot"!==s.name)continue;"thead"!==s.name||r||(r=s);const t=Array.from(s.getChildren()).filter((t=>t.is("element","tr")));for(const a of t)if(r&&s===r||"tbody"===s.name&&Array.from(a.getChildren()).length&&Array.from(a.getChildren()).every((t=>t.is("element","th"))))n++,o.push(a);else{i.push(a);const t=yE(a);(!e||tn.convertItem(t,n.writer.createPositionAt(c,"end")))),n.convertChildren(o,n.writer.createPositionAt(c,"end")),c.isEmpty){const t=n.writer.createElement("tableRow");n.writer.insert(t,n.writer.createPositionAt(c,"end")),wE(n.writer,n.writer.createPositionAt(t,"end"))}n.updateConversionResult(c,e)}}))})),o.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:DE(i,{asWidget:!0,additionalSlots:this._additionalSlots})}),o.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:DE(i,{additionalSlots:this._additionalSlots})}),o.for("upcast").elementToElement({model:"tableRow",view:"tr"}),o.for("upcast").add((t=>{t.on("element:tr",((t,e)=>{e.viewItem.isEmpty&&0==e.modelCursor.index&&t.stop()}),{priority:"high"})})),o.for("downcast").elementToElement({model:"tableRow",view:(t,{writer:e})=>t.isEmpty?e.createEmptyElement("tr"):e.createContainerElement("tr")}),o.for("upcast").elementToElement({model:"tableCell",view:"td"}),o.for("upcast").elementToElement({model:"tableCell",view:"th"}),o.for("upcast").add(AE("td")),o.for("upcast").add(AE("th")),o.for("editingDowncast").elementToElement({model:"tableCell",view:SE({asWidget:!0})}),o.for("dataDowncast").elementToElement({model:"tableCell",view:SE()}),o.for("editingDowncast").elementToElement({model:"paragraph",view:TE({asWidget:!0}),converterPriority:"high"}),o.for("dataDowncast").elementToElement({model:"paragraph",view:TE(),converterPriority:"high"}),o.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),o.for("upcast").attributeToAttribute({model:{key:"colspan",value:wD("colspan")},view:"colspan"}),o.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),o.for("upcast").attributeToAttribute({model:{key:"rowspan",value:wD("rowspan")},view:"rowspan"}),t.config.define("table.defaultHeadings.rows",0),t.config.define("table.defaultHeadings.columns",0),t.commands.add("insertTable",new IE(t)),t.commands.add("insertTableRowAbove",new ME(t,{order:"above"})),t.commands.add("insertTableRowBelow",new ME(t,{order:"below"})),t.commands.add("insertTableColumnLeft",new PE(t,{order:"left"})),t.commands.add("insertTableColumnRight",new PE(t,{order:"right"})),t.commands.add("removeTableRow",new KE(t)),t.commands.add("removeTableColumn",new YE(t)),t.commands.add("splitTableCellVertically",new OE(t,{direction:"vertically"})),t.commands.add("splitTableCellHorizontally",new OE(t,{direction:"horizontally"})),t.commands.add("mergeTableCells",new iD(t)),t.commands.add("mergeTableCellRight",new qE(t,{direction:"right"})),t.commands.add("mergeTableCellLeft",new qE(t,{direction:"left"})),t.commands.add("mergeTableCellDown",new qE(t,{direction:"down"})),t.commands.add("mergeTableCellUp",new qE(t,{direction:"up"})),t.commands.add("setTableColumnHeader",new ZE(t)),t.commands.add("setTableRowHeader",new QE(t)),t.commands.add("selectTableRow",new cD(t)),t.commands.add("selectTableColumn",new lD(t)),function(t){t.document.registerPostFixer((e=>function(t,e){const n=e.document.differ.getChanges();let o=!1;const i=new Set;for(const e of n){let n=null;"insert"==e.type&&"table"==e.name&&(n=e.position.nodeAfter),"insert"!=e.type&&"remove"!=e.type||"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table")),hD(e)&&(n=e.range.start.findAncestor("table")),n&&!i.has(n)&&(o=dD(n,t)||o,o=uD(n,t)||o,i.add(n))}return o}(e,t)))}(e),function(t){t.document.registerPostFixer((e=>function(t,e){const n=e.document.differ.getChanges();let o=!1;for(const e of n)"insert"==e.type&&"table"==e.name&&(o=pD(e.position.nodeAfter,t)||o),"insert"==e.type&&"tableRow"==e.name&&(o=mD(e.position.nodeAfter,t)||o),"insert"==e.type&&"tableCell"==e.name&&(o=gD(e.position.nodeAfter,t)||o),"remove"!=e.type&&"insert"!=e.type||!fD(e)||(o=gD(e.position.parent,t)||o);return o}(e,t)))}(e),this.listenTo(e.document,"change:data",(()=>{!function(t,e){const n=t.document.differ;for(const t of n.getChanges()){let n,o=!1;if("attribute"==t.type){const e=t.range.start.nodeAfter;if(!e||!e.is("element","table"))continue;if("headingRows"!=t.attributeKey&&"headingColumns"!=t.attributeKey)continue;n=e,o="headingRows"==t.attributeKey}else"tableRow"!=t.name&&"tableCell"!=t.name||(n=t.position.findAncestor("table"),o="tableRow"==t.name);if(!n)continue;const i=n.getAttribute("headingRows")||0,r=n.getAttribute("headingColumns")||0,s=new xE(n);for(const t of s){const n=t.rowkD(t,e.mapper)));for(const t of n)e.reconvertItem(t)}}(e,t.editing)}))}registerAdditionalSlot(t){this._additionalSlots.push(t)}}function wD(t){return e=>{const n=parseInt(e.getAttribute(t));return Number.isNaN(n)||n<=0?null:n}}class _D extends xh{items;keystrokes;focusTracker;constructor(t){super(t);const e=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new hi,this.focusTracker=new ci,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((t,e)=>`${e} × ${t}`)),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":e.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:e.to("label")}]}],on:{mousedown:e.to((t=>{t.preventDefault()})),click:e.to((()=>{this.fire("execute")}))}}),this.on("boxover",((t,e)=>{const{row:n,column:o}=e.target.dataset;this.items.get(10*(parseInt(n,10)-1)+(parseInt(o,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((t,e,n)=>{if(!n)return;const{row:o,column:i}=n.dataset;this.set({rows:parseInt(o),columns:parseInt(i)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),Th({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const t of this.items)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const t=this.rows,e=this.columns;this.items.map(((n,o)=>{const i=Math.floor(o/10){const o=t.commands.get("insertTable"),i=jp(n);let r;return i.bind("isEnabled").to(o),i.buttonView.set({icon:yu.table,label:e("Insert table"),tooltip:!0}),i.on("change:isOpen",(()=>{r||(r=new _D(n),i.panelView.children.add(r),r.delegate("execute").to(i),i.on("execute",(()=>{t.execute("insertTable",{rows:r.rows,columns:r.columns}),t.editing.view.focus()})))})),i})),t.ui.componentFactory.add("menuBar:insertTable",(n=>{const o=t.commands.get("insertTable"),i=new tg(n),r=new _D(n);return r.delegate("execute").to(i),i.on("change:isOpen",((t,e,n)=>{n||r.reset()})),r.on("execute",(()=>{t.execute("insertTable",{rows:r.rows,columns:r.columns}),t.editing.view.focus()})),i.buttonView.set({label:e("Table"),icon:yu.table}),i.panelView.children.add(r),i.bind("isEnabled").to(o),i})),t.ui.componentFactory.add("tableColumn",(t=>{const o=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:e("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:e("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:e("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:e("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:e("Select column")}}];return this._prepareDropdown(e("Column"),' ',o,t)})),t.ui.componentFactory.add("tableRow",(t=>{const n=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:e("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:e("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:e("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:e("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:e("Select row")}}];return this._prepareDropdown(e("Row"),' ',n,t)})),t.ui.componentFactory.add("mergeTableCells",(t=>{const o=[{type:"button",model:{commandName:"mergeTableCellUp",label:e("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:e("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:e("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:e("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:e("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:e("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(e("Merge cells"),' ',o,t)}))}_prepareDropdown(t,e,n,o){const i=this.editor,r=jp(o),s=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:t,icon:e,tooltip:!0}),r.bind("isEnabled").toMany(s,"isEnabled",((...t)=>t.some((t=>t)))),this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName),t.source instanceof np||i.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(t,e,n,o){const i=this.editor,r=jp(o,Fp),s="mergeTableCells",a=i.commands.get(s),c=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:t,icon:e,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([a,...c],"isEnabled",((...t)=>t.some((t=>t)))),this.listenTo(r.buttonView,"execute",(()=>{i.execute(s),i.editing.view.focus()})),this.listenTo(r,"execute",(t=>{i.execute(t.source.commandName),i.editing.view.focus()})),r}_fillDropdownWithListOptions(t,e){const n=this.editor,o=[],i=new si;for(const t of e)vD(t,n,o,i);return Up(t,i),o}}function vD(t,e,n,o){if("button"===t.type||"switchbutton"===t.type){const o=t.model=new Gm(t.model),{commandName:i,bindIsOn:r}=t.model,s=e.commands.get(i);n.push(s),o.set({commandName:i}),o.bind("isEnabled").to(s),r&&o.bind("isOn").to(s,"value"),o.set({withText:!0})}o.add(t)}class AD extends iu{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[XE,XE]}init(){const t=this.editor,e=t.model,n=t.editing.view;this.listenTo(e,"deleteContent",((t,e)=>this._handleDeleteContent(t,e)),{priority:"high"}),this.listenTo(n.document,"insertText",((t,e)=>this._handleInsertTextEvent(t,e)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const t=this.editor.plugins.get(XE),e=this.editor.model.document.selection,n=t.getSelectedTableCells(e);return 0==n.length?null:n}getSelectionAsFragment(){const t=this.editor.plugins.get(XE),e=this.getSelectedTableCells();return e?this.editor.model.change((n=>{const o=n.createDocumentFragment(),{first:i,last:r}=t.getColumnIndexes(e),{first:s,last:a}=t.getRowIndexes(e),c=e[0].findAncestor("table");let l=a,d=r;if(t.isSelectionRectangular(e)){const t={firstColumn:i,lastColumn:r,firstRow:s,lastRow:a};l=WE(c,t),d=GE(c,t)}const u=NE(c,{startRow:s,startColumn:i,endRow:l,endColumn:d},n);return n.insert(u,o,0),o})):null}setCellSelection(t,e){const n=this._getCellsToSelect(t,e);this.editor.model.change((t=>{t.setSelection(n.cells.map((e=>t.createRangeOn(e))),{backward:n.backward})}))}getFocusCell(){const t=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return t&&t.is("element","tableCell")?t:null}getAnchorCell(){const t=ai(this.editor.model.document.selection.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const t=this.editor,e=new Set;t.conversion.for("editingDowncast").add((t=>t.on("selection",((t,n,o)=>{const i=o.writer;!function(t){for(const n of e)t.removeClass("ck-editor__editable_selected",n);e.clear()}(i);const r=this.getSelectedTableCells();if(!r)return;for(const t of r){const n=o.mapper.toViewElement(t);i.addClass("ck-editor__editable_selected",n),e.add(n)}const s=o.mapper.toViewElement(r[r.length-1]);i.setSelection(s,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const t=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const e=this.getSelectedTableCells();if(!e)return;t.model.change((n=>{const o=n.createPositionAt(e[0],0),i=t.model.schema.getNearestSelectionRange(o);n.setSelection(i)}))}}))}_handleDeleteContent(t,e){const n=this.editor.plugins.get(XE),o=e[0],i=e[1],r=this.editor.model,s=!i||"backward"==i.direction,a=n.getSelectedTableCells(o);a.length&&(t.stop(),r.change((t=>{const e=a[s?a.length-1:0];r.change((t=>{for(const e of a)r.deleteContent(t.createSelection(e,"in"))}));const n=r.schema.getNearestSelectionRange(t.createPositionAt(e,0));o.is("documentSelection")?t.setSelection(n):o.setTo(n)})))}_handleInsertTextEvent(t,e){const n=this.editor,o=this.getSelectedTableCells();if(!o)return;const i=n.editing.view,r=n.editing.mapper,s=o.map((t=>i.createRangeOn(r.toViewElement(t))));e.selection=i.createSelection(s)}_getCellsToSelect(t,e){const n=this.editor.plugins.get("TableUtils"),o=n.getCellLocation(t),i=n.getCellLocation(e),r=Math.min(o.row,i.row),s=Math.max(o.row,i.row),a=Math.min(o.column,i.column),c=Math.max(o.column,i.column),l=new Array(s-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:s,startColumn:a,endColumn:c};for(const{row:e,cell:n}of new xE(t.findAncestor("table"),d))l[e-r].push(n);const u=i.rowt.reverse())),{cells:l.flat(),backward:u||h}}}class yD extends iu{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Ek,Dk,AD,XE]}init(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"copy",((t,e)=>this._onCopyCut(t,e))),this.listenTo(e,"cut",((t,e)=>this._onCopyCut(t,e))),this.listenTo(t.model,"insertContent",((t,[e,n])=>this._onInsertContent(t,e,n)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(t,e){const n=this.editor.editing.view,o=this.editor.plugins.get(AD),i=this.editor.plugins.get(Ek);o.getSelectedTableCells()&&("cut"!=t.name||this.editor.model.canEditAt(this.editor.model.document.selection))&&(e.preventDefault(),t.stop(),this.editor.model.enqueueChange({isUndoable:"cut"===t.name},(()=>{const r=i._copySelectedFragmentWithMarkers(t.name,this.editor.model.document.selection,(()=>o.getSelectionAsFragment()));n.document.fire("clipboardOutput",{dataTransfer:e.dataTransfer,content:this.editor.data.toView(r),method:t.name})})))}_onInsertContent(t,e,n){if(n&&!n.is("documentSelection"))return;const o=this.editor.model,i=this.editor.plugins.get(XE),r=this.editor.plugins.get(Ek),s=this.getTableIfOnlyTableInContent(e,o);if(!s)return;const a=i.getSelectionAffectedTableCells(o.document.selection);a.length?(t.stop(),e.is("documentFragment")?r._pasteMarkersIntoTransformedElement(e.markers,(t=>this._replaceSelectedCells(s,a,t))):this.editor.model.change((t=>{this._replaceSelectedCells(s,a,t)}))):UE(s,i)}_replaceSelectedCells(t,e,n){const o=this.editor.plugins.get(XE),i={width:o.getColumns(t),height:o.getRows(t)},r=function(t,e,n,o){const i=t[0].findAncestor("table"),r=o.getColumnIndexes(t),s=o.getRowIndexes(t),a={firstColumn:r.first,lastColumn:r.last,firstRow:s.first,lastRow:s.last},c=1===t.length;return c&&(a.lastRow+=e.height-1,a.lastColumn+=e.width-1,function(t,e,n,o){const i=o.getColumns(t),r=o.getRows(t);n>i&&o.insertColumns(t,{at:i,columns:n-i}),e>r&&o.insertRows(t,{at:r,rows:e-r})}(i,a.lastRow+1,a.lastColumn+1,o)),c||!o.isSelectionRectangular(t)?function(t,e,n){const{firstRow:o,lastRow:i,firstColumn:r,lastColumn:s}=e,a={first:o,last:i},c={first:r,last:s};ED(t,r,a,n),ED(t,s+1,a,n),xD(t,o,c,n),xD(t,i+1,c,n,o)}(i,a,n):(a.lastRow=WE(i,a),a.lastColumn=GE(i,a)),a}(e,i,n,o),s=r.lastRow-r.firstRow+1,a=r.lastColumn-r.firstColumn+1;t=NE(t,{startRow:0,startColumn:0,endRow:Math.min(s,i.height)-1,endColumn:Math.min(a,i.width)-1},n);const c=e[0].findAncestor("table"),l=this._replaceSelectedCellsWithPasted(t,i,c,r,n);if(this.editor.plugins.get("TableSelection").isEnabled){const t=o.sortRanges(l.map((t=>n.createRangeOn(t))));n.setSelection(t)}else n.setSelection(l[0],0);return c}_replaceSelectedCellsWithPasted(t,e,n,o,i){const{width:r,height:s}=e,a=function(t,e,n){const o=new Array(n).fill(null).map((()=>new Array(e).fill(null)));for(const{column:e,row:n,cell:i}of new xE(t))o[n][e]=i;return o}(t,r,s),c=[...new xE(n,{startRow:o.firstRow,endRow:o.lastRow,startColumn:o.firstColumn,endColumn:o.lastColumn,includeAllSlots:!0})],l=[];let d;for(const t of c){const{row:e,column:n}=t;n===o.firstColumn&&(d=t.getPositionBefore());const c=e-o.firstRow,u=n-o.firstColumn,h=a[c%s][u%r],p=h?i.cloneElement(h):null,m=this._replaceTableSlotCell(t,p,d,i);m&&(jE(m,e,n,o.lastRow,o.lastColumn,i),l.push(m),d=i.createPositionAfter(m))}const u=parseInt(n.getAttribute("headingRows")||"0"),h=parseInt(n.getAttribute("headingColumns")||"0"),p=o.firstRowDD(t,e,n))).map((({cell:t})=>LE(t,e,o)))}function ED(t,e,n,o){if(!(e<1))return RE(t,e).filter((({row:t,cellHeight:e})=>DD(t,e,n))).map((({cell:t,column:n})=>FE(t,n,e,o)))}function DD(t,e,n){const o=t+e-1,{first:i,last:r}=n;return t>=i&&t<=r||t=i}class SD extends iu{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[AD,XE]}init(){const t=this.editor,e=t.editing.view.document,n=t.t;this.listenTo(e,"arrowKey",((...t)=>this._onArrowKey(...t)),{context:"table"}),this.listenTo(e,"tab",((...t)=>this._handleTabOnSelectedTable(...t)),{context:"figure"}),this.listenTo(e,"tab",((...t)=>this._handleTab(...t)),{context:["th","td"]}),t.accessibility.addKeystrokeInfoGroup({id:"table",label:n("Keystrokes that can be used in a table cell"),keystrokes:[{label:n("Move the selection to the next cell"),keystroke:"Tab"},{label:n("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:n("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:n("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(t,e){const n=this.editor,o=n.model.document.selection.getSelectedElement();o&&o.is("element","table")&&(e.preventDefault(),e.stopPropagation(),t.stop(),n.model.change((t=>{t.setSelection(t.createRangeIn(o.getChild(0).getChild(0)))})))}_handleTab(t,e){const n=this.editor,o=this.editor.plugins.get(XE),i=this.editor.plugins.get("TableSelection"),r=n.model.document.selection,s=!e.shiftKey;let a=o.getTableCellsContainingSelection(r)[0];if(a||(a=i.getFocusCell()),!a)return;e.preventDefault(),e.stopPropagation(),t.stop();const c=a.parent,l=c.parent,d=l.getChildIndex(c),u=c.getChildIndex(a),h=0===u;if(!s&&h&&0===d)return void n.model.change((t=>{t.setSelection(t.createRangeOn(l))}));const p=u===c.childCount-1,m=d===o.getRows(l)-1;if(s&&m&&p&&(n.execute("insertTableRowBelow"),d===o.getRows(l)-1))return void n.model.change((t=>{t.setSelection(t.createRangeOn(l))}));let g;if(s&&p){const t=l.getChild(d+1);g=t.getChild(0)}else if(!s&&h){const t=l.getChild(d-1);g=t.getChild(t.childCount-1)}else g=c.getChild(u+(s?1:-1));n.model.change((t=>{t.setSelection(t.createRangeIn(g))}))}_onArrowKey(t,e){const n=this.editor,o=ti(e.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(o,e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),t.stop())}_handleArrowKeys(t,e){const n=this.editor.plugins.get(XE),o=this.editor.plugins.get("TableSelection"),i=this.editor.model,r=i.document.selection,s=["right","down"].includes(t),a=n.getSelectedTableCells(r);if(a.length){let n;return n=e?o.getFocusCell():s?a[a.length-1]:a[0],this._navigateFromCellInDirection(n,t,e),!0}const c=r.focus.findAncestor("tableCell");if(!c)return!1;if(!r.isCollapsed)if(e){if(r.isBackward==s&&!r.containsEntireContent(c))return!1}else{const t=r.getSelectedElement();if(!t||!i.schema.isObject(t))return!1}return!!this._isSelectionAtCellEdge(r,c,s)&&(this._navigateFromCellInDirection(c,t,e),!0)}_isSelectionAtCellEdge(t,e,n){const o=this.editor.model,i=this.editor.model.schema,r=n?t.getLastPosition():t.getFirstPosition();if(!i.getLimitElement(r).is("element","tableCell"))return o.createPositionAt(e,n?"end":0).isTouching(r);const s=o.createSelection(r);return o.modifySelection(s,{direction:n?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(t,e,n=!1){const o=this.editor.model,i=t.findAncestor("table"),r=[...new xE(i,{includeAllSlots:!0})],{row:s,column:a}=r[r.length-1],c=r.find((({cell:e})=>e==t));let{row:l,column:d}=c;switch(e){case"left":d--;break;case"up":l--;break;case"right":d+=c.cellWidth;break;case"down":l+=c.cellHeight}if(l<0||l>s||d<0&&l<=0||d>a&&l>=s)return void o.change((t=>{t.setSelection(t.createRangeOn(i))}));d<0?(d=n?0:a,l--):d>a&&(d=n?a:0,l++);const u=r.find((t=>t.row==l&&t.column==d)).cell,h=["right","down"].includes(e),p=this.editor.plugins.get("TableSelection");if(n&&p.isEnabled){const e=p.getAnchorCell()||t;p.setCellSelection(e,u)}else{const t=o.createPositionAt(u,h?0:"end");o.change((e=>{e.setSelection(t)}))}}}class TD extends Ys{domEventType=["mousemove","mouseleave"];onDomEvent(t){this.fire(t.type,t)}}class BD extends iu{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[AD,XE]}init(){this.editor.editing.view.addObserver(TD),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const t=this.editor,e=t.plugins.get(XE);let n=!1;const o=t.plugins.get(AD);this.listenTo(t.editing.view.document,"mousedown",((i,r)=>{const s=t.model.document.selection;if(!this.isEnabled||!o.isEnabled)return;if(!r.domEvent.shiftKey)return;const a=o.getAnchorCell()||e.getTableCellsContainingSelection(s)[0];if(!a)return;const c=this._getModelTableCellFromDomEvent(r);c&&ID(a,c)&&(n=!0,o.setCellSelection(a,c),r.preventDefault())})),this.listenTo(t.editing.view.document,"mouseup",(()=>{n=!1})),this.listenTo(t.editing.view.document,"selectionChange",(t=>{n&&t.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const t=this.editor;let e,n,o=!1,i=!1;const r=t.plugins.get(AD);this.listenTo(t.editing.view.document,"mousedown",((t,n)=>{this.isEnabled&&r.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(e=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(t.editing.view.document,"mousemove",((t,s)=>{if(!s.domEvent.buttons)return;if(!e)return;const a=this._getModelTableCellFromDomEvent(s);a&&ID(e,a)&&(n=a,o||n==e||(o=!0)),o&&(i=!0,r.setCellSelection(e,n),s.preventDefault())})),this.listenTo(t.editing.view.document,"mouseup",(()=>{o=!1,i=!1,e=null,n=null})),this.listenTo(t.editing.view.document,"selectionChange",(t=>{i&&t.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(t){const e=t.target,n=this.editor.editing.view.createPositionAt(e,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function ID(t,e){return t.parent.parent==e.parent.parent}function MD(t){return PD(t)||OD(t)}function PD(t){const e=t.getSelectedElement();return e&&ND(e)?e:null}function OD(t){const e=t.getFirstPosition();if(!e)return null;let n=e.parent;for(;n;){if(n.is("element")&&ND(n))return n;n=n.parent}return null}function ND(t){return!!t.getCustomProperty("table")&&$f(t)}class zD extends xh{options;focusTracker;focusCycler;_focusables;dropdownView;inputView;keystrokes;_stillTyping;constructor(t,e){super(t),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=e,this.focusTracker=new ci,this._focusables=new oh,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new hi,this._stillTyping=!1,this.focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",((t,e,n)=>this._setInputValue(n)))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach((t=>{this.focusTracker.add(t.element),this._focusables.add(t)})),this.keystrokes.listenTo(this.element)}focus(t){-1===t?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const t=this.locale,e=t.t,n=this.bindTemplate,o=this._createColorSelector(t),i=jp(t),r=new xh;return r.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:n.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",n.if("value","ck-hidden",(t=>""!=t))]}}]}),i.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),i.buttonView.children.add(r),i.buttonView.label=e("Color picker"),i.buttonView.tooltip=!0,i.panelPosition="rtl"===t.uiLanguageDirection?"se":"sw",i.panelView.children.add(o),i.bind("isEnabled").to(this,"isReadOnly",(t=>!t)),i.on("change:isOpen",((t,e,n)=>{n&&(o.updateSelectedColors(),o.showColorGridsFragment())})),i}_createInputTextView(){const t=this.locale,e=new bp(t);return e.extendTemplate({on:{blur:e.bindTemplate.to("blur")}}),e.value=this.value,e.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(e),e.on("input",(()=>{const t=e.element.value,n=this.options.colorDefinitions.find((e=>t===e.label));this._stillTyping=!0,this.value=n&&n.color||t})),e.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(e.element.value)})),e.delegate("input").to(this),e}_createColorSelector(t){const e=t.t,n=this.options.defaultColorValue||"",o=e(n?"Restore default":"Remove color"),i=new sm(t,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:o,colorPickerLabel:e("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});i.appendUI(),i.on("execute",((t,e)=>{"colorPickerSaveButton"!==e.source?(this.value=e.value||n,this.fire("input"),"colorPicker"!==e.source&&(this.dropdownView.isOpen=!1)):this.dropdownView.isOpen=!1}));let r=this.value;return i.on("colorPicker:cancel",(()=>{this.value=r,this.fire("input"),this.dropdownView.isOpen=!1})),i.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{r=this.value})),i.bind("selectedColor").to(this,"value"),i}_setInputValue(t){if(!this._stillTyping){const e=LD(t),n=this.options.colorDefinitions.find((t=>e===LD(t.color)));this.inputView.value=n?n.label:t||""}}}function LD(t){return t.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const RD=t=>""===t;function FD(t){return{none:t("None"),solid:t("Solid"),dotted:t("Dotted"),dashed:t("Dashed"),double:t("Double"),groove:t("Groove"),ridge:t("Ridge"),inset:t("Inset"),outset:t("Outset")}}function jD(t){return t('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function VD(t){return t('The value is invalid. Try "10px" or "2em" or simply "2".')}function HD(t){return t=t.trim().toLowerCase(),RD(t)||gd(t)}function UD(t){return t=t.trim(),RD(t)||YD(t)||wd(t)||Cd(t)}function WD(t){return t=t.trim(),RD(t)||YD(t)||wd(t)}function GD(t,e){const n=new si,o=FD(t.t);for(const i in o){const r={type:"button",model:new Gm({_borderStyleValue:i,label:o[i],role:"menuitemradio",withText:!0})};"none"===i?r.model.bind("isOn").to(t,"borderStyle",(t=>"none"===e?!t:t===i)):r.model.bind("isOn").to(t,"borderStyle",(t=>t===i)),n.add(r)}return n}function qD(t){const{view:e,icons:n,toolbar:o,labels:i,propertyName:r,nameToValue:s,defaultValue:a}=t;for(const t in i){const c=new Mh(e.locale);c.set({label:i[t],icon:n[t],tooltip:i[t]});const l=s?s(t):t;c.bind("isOn").to(e,r,(t=>{let e=t;return""===t&&a&&(e=a),l===e})),c.on("execute",(()=>{e[r]=l})),o.items.add(c)}}const $D=[{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 KD(t){return(e,n,o)=>{const i=new zD(e.locale,{colorDefinitions:(r=t.colorConfig,r.map((t=>({color:t.model,label:t.label,options:{hasBorder:t.hasBorder}})))),columns:t.columns,defaultColorValue:t.defaultColorValue,colorPickerConfig:t.colorPickerConfig});var r;return i.inputView.set({id:n,ariaDescribedById:o}),i.bind("isReadOnly").to(e,"isEnabled",(t=>!t)),i.bind("hasError").to(e,"errorText",(t=>!!t)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused").to(i),i}}function YD(t){const e=parseFloat(t);return!Number.isNaN(e)&&t===String(e)}class QD extends xh{children;constructor(t,e={}){super(t);const n=this.bindTemplate;this.set("class",e.class||null),this.children=this.createCollection(),e.children&&e.children.forEach((t=>this.children.add(t))),this.set("_role",null),this.set("_ariaLabelledBy",null),e.labelView&&this.set({_role:"group",_ariaLabelledBy:e.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",n.to("class")],role:n.to("_role"),"aria-labelledby":n.to("_ariaLabelledBy")},children:this.children})}}class ZD extends xh{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(t,e){super(t),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=e;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:s,backgroundInput:a}=this._createBackgroundFields(),{widthInput:c,operatorLabel:l,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{horizontalAlignmentToolbar:h,verticalAlignmentToolbar:p,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new ci,this.keystrokes=new hi,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=i,this.backgroundInput=a,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=d,this.horizontalAlignmentToolbar=h,this.verticalAlignmentToolbar=p;const{saveButtonView:g,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=f,this._focusables=new oh,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Oh(t,{label:this.t("Cell properties")})),this.children.add(new QD(t,{labelView:r,children:[r,n,i,o],class:"ck-table-form__border-row"})),this.children.add(new QD(t,{labelView:s,children:[s,a],class:"ck-table-form__background-row"})),this.children.add(new QD(t,{children:[new QD(t,{labelView:u,children:[u,c,l,d],class:"ck-table-form__dimensions-row"}),new QD(t,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new QD(t,{labelView:m,children:[m,h,p],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new QD(t,{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(),Sh({view:this}),[this.borderColorInput,this.backgroundInput].forEach((t=>{this._focusCycler.chain(t.fieldView.focusCycler)})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const t=this.options.defaultTableCellProperties,e={style:t.borderStyle,width:t.borderWidth,color:t.borderColor},n=KD({colorConfig:this.options.borderColors,columns:5,defaultColorValue:e.color,colorPickerConfig:this.options.colorPickerConfig}),o=this.locale,i=this.t,r=i("Style"),s=new Qh(o);s.text=i("Border");const a=FD(i),c=new gp(o,Qp);c.set({label:r,class:"ck-table-form__border-style"}),c.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.fieldView.buttonView.bind("label").to(this,"borderStyle",(t=>a[t||"none"])),c.fieldView.on("execute",(t=>{this.borderStyle=t.source._borderStyleValue})),c.bind("isEmpty").to(this,"borderStyle",(t=>!t)),Up(c.fieldView,GD(this,e.style),{role:"menu",ariaLabel:r});const l=new gp(o,Kp);l.set({label:i("Width"),class:"ck-table-form__border-width"}),l.fieldView.bind("value").to(this,"borderWidth"),l.bind("isEnabled").to(this,"borderStyle",JD),l.fieldView.on("input",(()=>{this.borderWidth=l.fieldView.element.value}));const d=new gp(o,n);return d.set({label:i("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",JD),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((t,n,o,i)=>{JD(o)||(this.borderColor="",this.borderWidth=""),JD(i)||(this.borderColor=e.color,this.borderWidth=e.width)})),{borderRowLabel:s,borderStyleDropdown:c,borderColorInput:d,borderWidthInput:l}}_createBackgroundFields(){const t=this.locale,e=this.t,n=new Qh(t);n.text=e("Background");const o=KD({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),i=new gp(t,o);return i.set({label:e("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:n,backgroundInput:i}}_createDimensionFields(){const t=this.locale,e=this.t,n=new Qh(t);n.text=e("Dimensions");const o=new gp(t,Kp);o.set({label:e("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",(()=>{this.width=o.fieldView.element.value}));const i=new xh(t);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new gp(t,Kp);return r.set({label:e("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:n,widthInput:o,operatorLabel:i,heightInput:r}}_createPaddingField(){const t=this.locale,e=this.t,n=new gp(t,Kp);return n.set({label:e("Padding"),class:"ck-table-cell-properties-form__padding"}),n.fieldView.bind("value").to(this,"padding"),n.fieldView.on("input",(()=>{this.padding=n.fieldView.element.value})),n}_createAlignmentFields(){const t=this.locale,e=this.t,n=new Qh(t),o={left:yu.alignLeft,center:yu.alignCenter,right:yu.alignRight,justify:yu.alignJustify,top:yu.alignTop,middle:yu.alignMiddle,bottom:yu.alignBottom};n.text=e("Table cell text alignment");const i=new Np(t),r="rtl"===t.contentLanguageDirection;i.set({isCompact:!0,ariaLabel:e("Horizontal text alignment toolbar")}),qD({view:this,icons:o,toolbar:i,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:t=>{if(r){if("left"===t)return"right";if("right"===t)return"left"}return t},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const s=new Np(t);return s.set({isCompact:!0,ariaLabel:e("Vertical text alignment toolbar")}),qD({view:this,icons:o,toolbar:s,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:i,verticalAlignmentToolbar:s,alignmentLabel:n}}_createActionButtons(){const t=this.locale,e=this.t,n=new Mh(t),o=new Mh(t),i=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return n.set({label:e("Save"),icon:yu.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(i,"errorText",((...t)=>t.every((t=>!t)))),o.set({label:e("Cancel"),icon:yu.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _horizontalAlignmentLabels(){const t=this.locale,e=this.t,n=e("Align cell text to the left"),o=e("Align cell text to the center"),i=e("Align cell text to the right"),r=e("Justify cell text");return"rtl"===t.uiLanguageDirection?{right:i,center:o,left:n,justify:r}:{left:n,center:o,right:i,justify:r}}get _verticalAlignmentLabels(){const t=this.t;return{top:t("Align cell text to the top"),middle:t("Align cell text to the middle"),bottom:t("Align cell text to the bottom")}}}function JD(t){return"none"!==t}const XD=(()=>[Tp.defaultPositions.northArrowSouth,Tp.defaultPositions.northArrowSouthWest,Tp.defaultPositions.northArrowSouthEast,Tp.defaultPositions.southArrowNorth,Tp.defaultPositions.southArrowNorthWest,Tp.defaultPositions.southArrowNorthEast,Tp.defaultPositions.viewportStickyNorth])();function tS(t,e){const n=t.plugins.get("ContextualBalloon"),o=t.editing.view.document.selection;let i;"cell"===e?OD(o)&&(i=nS(t)):MD(o)&&(i=eS(t)),i&&n.updatePosition(i)}function eS(t){const e=vE(t.model.document.selection),n=t.editing.mapper.toViewElement(e);return{target:t.editing.view.domConverter.mapViewToDom(n),positions:XD}}function nS(t){const e=t.editing.mapper,n=t.editing.view.domConverter,o=t.model.document.selection;if(o.rangeCount>1)return{target:()=>function(t,e){const n=e.editing.mapper,o=e.editing.view.domConverter,i=Array.from(t).map((t=>{const e=oS(t.start),i=n.toViewElement(e);return new wo(o.mapViewToDom(i))}));return wo.getBoundingRect(i)}(o.getRanges(),t),positions:XD};const i=oS(o.getFirstPosition()),r=e.toViewElement(i);return{target:n.mapViewToDom(r),positions:XD}}function oS(t){return t.nodeAfter&&t.nodeAfter.is("element","tableCell")?t.nodeAfter:t.findAncestor("tableCell")}function iS(t){if(!t||!o(t))return t;const{top:e,right:n,bottom:i,left:r}=t;return e==n&&n==i&&i==r?e:void 0}function rS(t,e){const n=parseFloat(t);return Number.isNaN(n)||String(n)!==String(t)?t:`${n}${e}`}function sS(t,e={}){const n={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...t};return e.includeAlignmentProperty&&!n.alignment&&(n.alignment="center"),e.includePaddingProperty&&!n.padding&&(n.padding=""),e.includeVerticalAlignmentProperty&&!n.verticalAlignment&&(n.verticalAlignment="middle"),e.includeHorizontalAlignmentProperty&&!n.horizontalAlignment&&(n.horizontalAlignment=e.isRightToLeftContent?"right":"left"),n}function aS(t,e){return sS({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...t},e)}function cS(t,e){return sS({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...t},e)}const lS={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class dS extends iu{_defaultTableCellProperties;_balloon;view;_undoStepBatch;_isReady;static get requires(){return[$m]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("table.tableCellProperties",{borderColors:$D,backgroundColors:$D})}init(){const t=this.editor,e=t.t;this._defaultTableCellProperties=cS(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===t.locale.contentLanguageDirection}),this._balloon=t.plugins.get($m),this.view=null,this._isReady=!1,t.ui.componentFactory.add("tableCellProperties",(n=>{const o=new Mh(n);o.set({label:e("Cell properties"),icon:' ',tooltip:!0}),this.listenTo(o,"execute",(()=>this._showView()));const i=Object.values(lS).map((e=>t.commands.get(e)));return o.bind("isEnabled").toMany(i,"isEnabled",((...t)=>t.some((t=>t)))),o}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const t=this.editor,e=t.config.get("table.tableCellProperties"),n=lp(e.borderColors),o=cp(t.locale,n),i=lp(e.backgroundColors),r=cp(t.locale,i),s=!1!==e.colorPicker,a=new ZD(t.locale,{borderColors:o,backgroundColors:r,defaultTableCellProperties:this._defaultTableCellProperties,colorPickerConfig:!!s&&(e.colorPicker||{})}),c=t.t;a.render(),this.listenTo(a,"submit",(()=>{this._hideView()})),this.listenTo(a,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),a.keystrokes.set("Esc",((t,e)=>{this._hideView(),e()})),Eh({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const l=jD(c),d=VD(c);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:l,validator:HD})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:WD})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:d,validator:UD})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:d,validator:UD})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:d,validator:UD})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:l,validator:HD})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),a}_fillViewFormFromCommandValues(){const t=this.editor.commands,e=t.get("tableCellBorderStyle");Object.entries(lS).map((([e,n])=>{const o=this._defaultTableCellProperties[e]||"";return[e,t.get(n).value||o]})).forEach((([t,n])=>{("borderColor"!==t&&"borderWidth"!==t||"none"!==e.value)&&this.view.set(t,n)})),this._isReady=!0}_showView(){const t=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(t.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:nS(t)}),this._undoStepBatch=t.model.createBatch(),this.view.focus()}_hideView(){const t=this.editor;this.stopListening(t.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const t=this.editor;OD(t.editing.view.document.selection)?this._isViewVisible&&tS(t,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(t){return(e,n,o)=>{this._isReady&&this.editor.execute(t,{value:o,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(t){const{commandName:e,viewField:n,validator:o,errorText:i}=t,r=nr((()=>{n.errorText=i}),500);return(t,i,s)=>{r.cancel(),this._isReady&&(o(s)?(this.editor.execute(e,{value:s,batch:this._undoStepBatch}),n.errorText=null):r())}}}class uS extends su{attributeName;_defaultValue;constructor(t,e,n){super(t),this.attributeName=e,this._defaultValue=n}refresh(){const t=this.editor,e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(t.model.document.selection);this.isEnabled=!!e.length,this.value=this._getSingleValue(e)}execute(t={}){const{value:e,batch:n}=t,o=this.editor.model,i=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(o.document.selection),r=this._getValueToSet(e);o.enqueueChange(n,(t=>{r?i.forEach((e=>t.setAttribute(this.attributeName,r,e))):i.forEach((e=>t.removeAttribute(this.attributeName,e)))}))}_getAttribute(t){if(!t)return;const e=t.getAttribute(this.attributeName);return e!==this._defaultValue?e:void 0}_getValueToSet(t){if(t!==this._defaultValue)return t}_getSingleValue(t){const e=this._getAttribute(t[0]);return t.every((t=>this._getAttribute(t)===e))?e:void 0}}class hS extends uS{constructor(t,e){super(t,"tableCellWidth",e)}_getValueToSet(t){if((t=rS(t,"px"))!==this._defaultValue)return t}}class pS extends iu{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[bD]}init(){const t=this.editor,e=cS(t.config.get("table.tableCellProperties.defaultProperties"));CE(t.model.schema,t.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:e.width}),t.commands.add("tableCellWidth",new hS(t,e.width))}}class mS extends uS{constructor(t,e){super(t,"tableCellPadding",e)}_getAttribute(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){const e=rS(t,"px");if(e!==this._defaultValue)return e}}class gS extends uS{constructor(t,e){super(t,"tableCellHeight",e)}_getValueToSet(t){const e=rS(t,"px");if(e!==this._defaultValue)return e}}class fS extends uS{constructor(t,e){super(t,"tableCellBackgroundColor",e)}}class kS extends uS{constructor(t,e){super(t,"tableCellVerticalAlignment",e)}}class bS extends uS{constructor(t,e){super(t,"tableCellHorizontalAlignment",e)}}class wS extends uS{constructor(t,e){super(t,"tableCellBorderStyle",e)}_getAttribute(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class _S extends uS{constructor(t,e){super(t,"tableCellBorderColor",e)}_getAttribute(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class CS extends uS{constructor(t,e){super(t,"tableCellBorderWidth",e)}_getAttribute(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){const e=rS(t,"px");if(e!==this._defaultValue)return e}}const vS=/^(top|middle|bottom)$/,AS=/^(left|center|right|justify)$/;class yS extends iu{static get pluginName(){return"TableCellPropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[bD,pS]}init(){const t=this.editor,e=t.model.schema,n=t.conversion;t.config.define("table.tableCellProperties.defaultProperties",{});const o=cS(t.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===t.locale.contentLanguageDirection});t.data.addStyleProcessorRules(Nd),function(t,e,n){const o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};t.extend("tableCell",{allowAttributes:Object.values(o)}),mE(e,"td",o,n),mE(e,"th",o,n),gE(e,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),gE(e,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),gE(e,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}(e,n,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),t.commands.add("tableCellBorderStyle",new wS(t,o.borderStyle)),t.commands.add("tableCellBorderColor",new _S(t,o.borderColor)),t.commands.add("tableCellBorderWidth",new CS(t,o.borderWidth)),CE(e,n,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:o.height}),t.commands.add("tableCellHeight",new gS(t,o.height)),t.data.addStyleProcessorRules(qd),CE(e,n,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:o.padding}),t.commands.add("tableCellPadding",new mS(t,o.padding)),t.data.addStyleProcessorRules(Od),CE(e,n,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),t.commands.add("tableCellBackgroundColor",new fS(t,o.backgroundColor)),function(t,e,n){t.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:t=>({key:"style",value:{"text-align":t}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":AS}},model:{key:"tableCellHorizontalAlignment",value:t=>{const e=t.getStyle("text-align");return e===n?null:e}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:AS}},model:{key:"tableCellHorizontalAlignment",value:t=>{const e=t.getAttribute("align");return e===n?null:e}}})}(e,n,o.horizontalAlignment),t.commands.add("tableCellHorizontalAlignment",new bS(t,o.horizontalAlignment)),function(t,e,n){t.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:t=>({key:"style",value:{"vertical-align":t}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":vS}},model:{key:"tableCellVerticalAlignment",value:t=>{const e=t.getStyle("vertical-align");return e===n?null:e}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:vS}},model:{key:"tableCellVerticalAlignment",value:t=>{const e=t.getAttribute("valign");return e===n?null:e}}})}(e,n,o.verticalAlignment),t.commands.add("tableCellVerticalAlignment",new kS(t,o.verticalAlignment))}}class xS extends su{attributeName;_defaultValue;constructor(t,e,n){super(t),this.attributeName=e,this._defaultValue=n}refresh(){const t=vE(this.editor.model.document.selection);this.isEnabled=!!t,this.value=this._getValue(t)}execute(t={}){const e=this.editor.model,n=e.document.selection,{value:o,batch:i}=t,r=vE(n),s=this._getValueToSet(o);e.enqueueChange(i,(t=>{s?t.setAttribute(this.attributeName,s,r):t.removeAttribute(this.attributeName,r)}))}_getValue(t){if(!t)return;const e=t.getAttribute(this.attributeName);return e!==this._defaultValue?e:void 0}_getValueToSet(t){if(t!==this._defaultValue)return t}}class ES extends xS{constructor(t,e){super(t,"tableBackgroundColor",e)}}class DS extends xS{constructor(t,e){super(t,"tableBorderColor",e)}_getValue(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class SS extends xS{constructor(t,e){super(t,"tableBorderStyle",e)}_getValue(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}}class TS extends xS{constructor(t,e){super(t,"tableBorderWidth",e)}_getValue(t){if(!t)return;const e=iS(t.getAttribute(this.attributeName));return e!==this._defaultValue?e:void 0}_getValueToSet(t){const e=rS(t,"px");if(e!==this._defaultValue)return e}}class BS extends xS{constructor(t,e){super(t,"tableWidth",e)}_getValueToSet(t){if((t=rS(t,"px"))!==this._defaultValue)return t}}class IS extends xS{constructor(t,e){super(t,"tableHeight",e)}_getValueToSet(t){if((t=rS(t,"px"))!==this._defaultValue)return t}}class MS extends xS{constructor(t,e){super(t,"tableAlignment",e)}}const PS=/^(left|center|right)$/,OS=/^(left|none|right)$/;class NS extends iu{static get pluginName(){return"TablePropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[bD]}init(){const t=this.editor,e=t.model.schema,n=t.conversion;t.config.define("table.tableProperties.defaultProperties",{});const o=aS(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});t.data.addStyleProcessorRules(Nd),function(t,e,n){const o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};t.extend("table",{allowAttributes:Object.values(o)}),mE(e,"table",o,n),fE(e,{modelAttribute:o.color,styleName:"border-color"}),fE(e,{modelAttribute:o.style,styleName:"border-style"}),fE(e,{modelAttribute:o.width,styleName:"border-width"})}(e,n,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),t.commands.add("tableBorderColor",new DS(t,o.borderColor)),t.commands.add("tableBorderStyle",new SS(t,o.borderStyle)),t.commands.add("tableBorderWidth",new TS(t,o.borderWidth)),function(t,e,n){t.extend("table",{allowAttributes:["tableAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment"},view:t=>({key:"style",value:{float:"center"===t?"none":t}}),converterPriority:"high"}),e.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:OS}},model:{key:"tableAlignment",value:t=>{let e=t.getStyle("float");return"none"===e&&(e="center"),e===n?null:e}}}).attributeToAttribute({view:{attributes:{align:PS}},model:{name:"table",key:"tableAlignment",value:t=>{const e=t.getAttribute("align");return e===n?null:e}}})}(e,n,o.alignment),t.commands.add("tableAlignment",new MS(t,o.alignment)),zS(e,n,{modelAttribute:"tableWidth",styleName:"width",defaultValue:o.width}),t.commands.add("tableWidth",new BS(t,o.width)),zS(e,n,{modelAttribute:"tableHeight",styleName:"height",defaultValue:o.height}),t.commands.add("tableHeight",new IS(t,o.height)),t.data.addStyleProcessorRules(Od),function(t,e,n){const{modelAttribute:o}=n;t.extend("table",{allowAttributes:[o]}),pE(e,{viewElement:"table",...n}),fE(e,n)}(e,n,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),t.commands.add("tableBackgroundColor",new ES(t,o.backgroundColor))}}function zS(t,e,n){const{modelAttribute:o}=n;t.extend("table",{allowAttributes:[o]}),pE(e,{viewElement:/^(table|figure)$/,shouldUpcast:t=>!("table"==t.name&&"figure"==t.parent.name),...n}),gE(e,{modelElement:"table",...n})}class LS extends xh{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(t,e){super(t),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=e;const{borderStyleDropdown:n,borderWidthInput:o,borderColorInput:i,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:s,backgroundInput:a}=this._createBackgroundFields(),{widthInput:c,operatorLabel:l,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{alignmentToolbar:h,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new ci,this.keystrokes=new hi,this.children=this.createCollection(),this.borderStyleDropdown=n,this.borderWidthInput=o,this.borderColorInput=i,this.backgroundInput=a,this.widthInput=c,this.heightInput=d,this.alignmentToolbar=h;const{saveButtonView:m,cancelButtonView:g}=this._createActionButtons();this.saveButtonView=m,this.cancelButtonView=g,this._focusables=new oh,this._focusCycler=new Nh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Oh(t,{label:this.t("Table properties")})),this.children.add(new QD(t,{labelView:r,children:[r,n,i,o],class:"ck-table-form__border-row"})),this.children.add(new QD(t,{labelView:s,children:[s,a],class:"ck-table-form__background-row"})),this.children.add(new QD(t,{children:[new QD(t,{labelView:u,children:[u,c,l,d],class:"ck-table-form__dimensions-row"}),new QD(t,{labelView:p,children:[p,h],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new QD(t,{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(),Sh({view:this}),[this.borderColorInput,this.backgroundInput].forEach((t=>{this._focusCycler.chain(t.fieldView.focusCycler)})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const t=this.options.defaultTableProperties,e={style:t.borderStyle,width:t.borderWidth,color:t.borderColor},n=KD({colorConfig:this.options.borderColors,columns:5,defaultColorValue:e.color,colorPickerConfig:this.options.colorPickerConfig}),o=this.locale,i=this.t,r=i("Style"),s=new Qh(o);s.text=i("Border");const a=FD(i),c=new gp(o,Qp);c.set({label:r,class:"ck-table-form__border-style"}),c.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.fieldView.buttonView.bind("label").to(this,"borderStyle",(t=>a[t||"none"])),c.fieldView.on("execute",(t=>{this.borderStyle=t.source._borderStyleValue})),c.bind("isEmpty").to(this,"borderStyle",(t=>!t)),Up(c.fieldView,GD(this,e.style),{role:"menu",ariaLabel:r});const l=new gp(o,Kp);l.set({label:i("Width"),class:"ck-table-form__border-width"}),l.fieldView.bind("value").to(this,"borderWidth"),l.bind("isEnabled").to(this,"borderStyle",RS),l.fieldView.on("input",(()=>{this.borderWidth=l.fieldView.element.value}));const d=new gp(o,n);return d.set({label:i("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",RS),d.fieldView.on("input",(()=>{this.borderColor=d.fieldView.value})),this.on("change:borderStyle",((t,n,o,i)=>{RS(o)||(this.borderColor="",this.borderWidth=""),RS(i)||(this.borderColor=e.color,this.borderWidth=e.width)})),{borderRowLabel:s,borderStyleDropdown:c,borderColorInput:d,borderWidthInput:l}}_createBackgroundFields(){const t=this.locale,e=this.t,n=new Qh(t);n.text=e("Background");const o=KD({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),i=new gp(t,o);return i.set({label:e("Color"),class:"ck-table-properties-form__background"}),i.fieldView.bind("value").to(this,"backgroundColor"),i.fieldView.on("input",(()=>{this.backgroundColor=i.fieldView.value})),{backgroundRowLabel:n,backgroundInput:i}}_createDimensionFields(){const t=this.locale,e=this.t,n=new Qh(t);n.text=e("Dimensions");const o=new gp(t,Kp);o.set({label:e("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",(()=>{this.width=o.fieldView.element.value}));const i=new xh(t);i.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new gp(t,Kp);return r.set({label:e("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:n,widthInput:o,operatorLabel:i,heightInput:r}}_createAlignmentFields(){const t=this.locale,e=this.t,n=new Qh(t);n.text=e("Alignment");const o=new Np(t);return o.set({isCompact:!0,ariaLabel:e("Table alignment toolbar")}),qD({view:this,icons:{left:yu.objectLeft,center:yu.objectCenter,right:yu.objectRight},toolbar:o,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:n,alignmentToolbar:o}}_createActionButtons(){const t=this.locale,e=this.t,n=new Mh(t),o=new Mh(t),i=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return n.set({label:e("Save"),icon:yu.check,class:"ck-button-save",type:"submit",withText:!0}),n.bind("isEnabled").toMany(i,"errorText",((...t)=>t.every((t=>!t)))),o.set({label:e("Cancel"),icon:yu.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:n,cancelButtonView:o}}get _alignmentLabels(){const t=this.locale,e=this.t,n=e("Align table to the left"),o=e("Center table"),i=e("Align table to the right");return"rtl"===t.uiLanguageDirection?{right:i,center:o,left:n}:{left:n,center:o,right:i}}}function RS(t){return"none"!==t}const FS={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class jS extends iu{_defaultTableProperties;_balloon;view=null;_undoStepBatch;_isReady;static get requires(){return[$m]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}constructor(t){super(t),t.config.define("table.tableProperties",{borderColors:$D,backgroundColors:$D})}init(){const t=this.editor,e=t.t;this._defaultTableProperties=aS(t.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._balloon=t.plugins.get($m),t.ui.componentFactory.add("tableProperties",(n=>{const o=new Mh(n);o.set({label:e("Table properties"),icon:' ',tooltip:!0}),this.listenTo(o,"execute",(()=>this._showView()));const i=Object.values(FS).map((e=>t.commands.get(e)));return o.bind("isEnabled").toMany(i,"isEnabled",((...t)=>t.some((t=>t)))),o}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(){const t=this.editor,e=t.config.get("table.tableProperties"),n=lp(e.borderColors),o=cp(t.locale,n),i=lp(e.backgroundColors),r=cp(t.locale,i),s=!1!==e.colorPicker,a=new LS(t.locale,{borderColors:o,backgroundColors:r,defaultTableProperties:this._defaultTableProperties,colorPickerConfig:!!s&&(e.colorPicker||{})}),c=t.t;a.render(),this.listenTo(a,"submit",(()=>{this._hideView()})),this.listenTo(a,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),a.keystrokes.set("Esc",((t,e)=>{this._hideView(),e()})),Eh({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const l=jD(c),d=VD(c);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableBorderColor",errorText:l,validator:HD})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableBorderWidth",errorText:d,validator:WD})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableBackgroundColor",errorText:l,validator:HD})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableWidth",errorText:d,validator:UD})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableHeight",errorText:d,validator:UD})),a.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),a}_fillViewFormFromCommandValues(){const t=this.editor.commands,e=t.get("tableBorderStyle");Object.entries(FS).map((([e,n])=>{const o=e,i=this._defaultTableProperties[o]||"";return[o,t.get(n).value||i]})).forEach((([t,n])=>{("borderColor"!==t&&"borderWidth"!==t||"none"!==e.value)&&this.view.set(t,n)})),this._isReady=!0}_showView(){const t=this.editor;this.view||(this.view=this._createPropertiesView()),this.listenTo(t.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:eS(t)}),this._undoStepBatch=t.model.createBatch(),this.view.focus()}_hideView(){const t=this.editor;this.stopListening(t.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const t=this.editor;MD(t.editing.view.document.selection)?this._isViewVisible&&tS(t,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(t){return(e,n,o)=>{this._isReady&&this.editor.execute(t,{value:o,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(t){const{commandName:e,viewField:n,validator:o,errorText:i}=t,r=nr((()=>{n.errorText=i}),500);return(t,i,s)=>{r.cancel(),this._isReady&&(o(s)?(this.editor.execute(e,{value:s,batch:this._undoStepBatch}),n.errorText=null):r())}}}function VS(t){return!!t&&t.is("element","table")}function HS(t){for(const e of t.getChildren())if(e.is("element","caption"))return e;return null}function US(t){const e=t.parent;return"figcaption"==t.name&&e&&e.is("element","figure")&&e.hasClass("table")||"caption"==t.name&&e&&e.is("element","table")?{name:!0}:null}class WS extends su{refresh(){const t=vE(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled?this.value=!!HS(t):this.value=!1}execute({focusCaptionOnShow:t=!1}={}){this.editor.model.change((e=>{this.value?this._hideTableCaption(e):this._showTableCaption(e,t)}))}_showTableCaption(t,e){const n=this.editor.model,o=vE(n.document.selection),i=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(o)||t.createElement("caption");n.insertContent(i,o,"end"),e&&t.setSelection(i,"in")}_hideTableCaption(t){const e=this.editor.model,n=vE(e.document.selection),o=this.editor.plugins.get("TableCaptionEditing"),i=HS(n);o._saveCaption(n,i),e.deleteContent(t.createSelection(i,"on"))}}class GS extends iu{_savedCaptionsMap;static get pluginName(){return"TableCaptionEditing"}static get isOfficialPlugin(){return!0}constructor(t){super(t),this._savedCaptionsMap=new WeakMap}init(){const t=this.editor,e=t.model.schema,n=t.editing.view,o=t.t;var i;e.isRegistered("caption")?e.extend("caption",{allowIn:"table"}):e.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),t.commands.add("toggleTableCaption",new WS(this.editor)),t.conversion.for("upcast").elementToElement({view:US,model:"caption"}),t.conversion.for("dataDowncast").elementToElement({model:"caption",view:(t,{writer:e})=>VS(t.parent)?e.createContainerElement("figcaption"):null}),t.conversion.for("editingDowncast").elementToElement({model:"caption",view:(t,{writer:e})=>{if(!VS(t.parent))return null;const i=e.createEditableElement("figcaption");return e.setCustomProperty("tableCaption",!0,i),i.placeholder=o("Enter table caption"),Ar({view:n,element:i,keepOnFocus:!0}),Jf(i,e)}}),(i=t.model).document.registerPostFixer((t=>function(t,e){const n=e.document.differ.getChanges();let o=!1;for(const e of n){if("insert"!=e.type)continue;const n=e.position.parent;if(n.is("element","table")||"table"==e.name){const i="table"==e.name?e.position.nodeAfter:n,r=Array.from(i.getChildren()).filter((t=>t.is("element","caption"))),s=r.shift();if(!s)continue;for(const e of r)t.move(t.createRangeIn(e),s,"end"),t.remove(e);s.nextSibling&&(t.move(t.createRangeOn(s),i,"end"),o=!0),o=!!r.length||o}}return o}(t,i)))}_getSavedCaption(t){const e=this._savedCaptionsMap.get(t);return e?ma.fromJSON(e):null}_saveCaption(t,e){this._savedCaptionsMap.set(t,e.toJSON())}}class qS extends iu{static get pluginName(){return"TableCaptionUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.editing.view,n=t.t;t.ui.componentFactory.add("toggleTableCaption",(o=>{const i=t.commands.get("toggleTableCaption"),r=new Mh(o);return r.set({icon:yu.caption,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(i,"value","isEnabled"),r.bind("label").to(i,"value",(t=>n(t?"Toggle caption off":"Toggle caption on"))),this.listenTo(r,"execute",(()=>{if(t.execute("toggleTableCaption",{focusCaptionOnShow:!0}),i.value){const n=function(t){const e=vE(t);return e?HS(e):null}(t.model.document.selection),o=t.editing.mapper.toViewElement(n);if(!o)return;e.scrollToTheSelection(),e.change((t=>{t.addClass("table__caption_highlighted",o)}))}t.editing.view.focus()})),r}))}}function $S(t){if(t.is("$text")||t.is("$textProxy"))return t.data;const e=t;let n="",o=null;for(const t of e.getChildren()){const e=$S(t);o&&o.is("element")&&(n+="\n"),n+=e,o=t}return n}function KS(t){return KS="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},KS(t)}function YS(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,r=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw r}}}}(t);try{var d=function(){var t=c.value;s.push((function(){return new Promise((function(o){var i=n._isTransformUrl(t.url);if(!i&&r)n._getTransformUrl(t.id,r,(function(t){a.push(t),o()}));else{var s=n._buildAssetUrl(t.id,t.url,i?e:r);a.push(s),o()}}))}))};for(l.s();!(c=l.n()).done;)d()}catch(t){l.e(t)}finally{l.f()}}else o()}))}},{key:"_buildAssetUrl",value:function(t,e,n){return"".concat(e,"#asset:").concat(t,":").concat(n?"transform:"+n:"url")}},{key:"_removeTransformFromUrl",value:function(t){return t.replace(/(^|\/)(_[^\/]+\/)([^\/]+)$/,"$1$3")}},{key:"_isTransformUrl",value:function(t){return/(^|\/)_[^\/]+\/[^\/]+$/.test(t)}},{key:"_getTransformUrl",value:function(t,e,n){var o=this;Craft.sendActionRequest("POST","ckeditor/ckeditor/image-url",{data:{assetId:t,transform:e}}).then((function(i){var r=i.data;n(o._buildAssetUrl(t,r.url,e))})).catch((function(){alert("There was an error generating the transform URL.")}))}},{key:"_getAssetUrlComponents",value:function(t){var e=t.match(/(.*)#asset:(\d+):(url|transform):?([a-zA-Z][a-zA-Z0-9_]*)?/);return e?{url:e[1],assetId:e[2],transform:"url"!==e[3]?e[4]:null}:null}}],o=[{key:"pluginName",get:function(){return"CraftImageInsertUI"}}],n&&QS(e.prototype,n),o&&QS(e,o),Object.defineProperty(e,"prototype",{writable:!1}),a}(RC);function tT(t){return tT="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tT(t)}function eT(t,e){if(t){if("string"==typeof t)return nT(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nT(t,e):void 0}}function nT(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n ',s.keystroke="Ctrl+K",s.tooltip=!0,s.isToggleable=!0,t.listenTo(s,"execute",(function(){return t._linkUI._showUI(!0)})),r.on("execute",(function(e){if(e.source.linkOption){var n=e.source.linkOption;t._showElementSelectorModal(n)}else t._linkUI._showUI(!0)})),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",(function(t){return!!t})),Up(r,(function(){return t._getLinkListItemDefinitions(n)})),r}))}else this._linkUI._createToolbarLinkButton()}},{key:"_getLinkListItemDefinitions",value:function(t){var e,n=new si,o=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=eT(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,r=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return r=t.done,t},e:function(t){s=!0,i=t},f:function(){try{r||null==e.return||e.return()}finally{if(s)throw i}}}}(t);try{for(o.s();!(e=o.n()).done;){var i=e.value;n.add({type:"button",model:new Gm({label:i.label,linkOption:i,withText:!0})})}}catch(t){o.e(t)}finally{o.f()}return n.add({type:"button",model:new Gm({label:Craft.t("ckeditor","Insert link"),withText:!0})}),n}},{key:"_showElementSelectorModal",value:function(t){var e=this,n=this.editor,o=n.model,i=o.document.selection,r=i.isCollapsed,s=i.getFirstRange(),a=function(){n.editing.view.focus(),!r&&s&&o.change((function(t){t.setSelection(s)})),e._linkUI._hideFakeVisualSelection()};this._linkUI._getSelectedLinkElement()||this._linkUI._showFakeVisualSelection(),Craft.createElementSelectorModal(t.elementType,{storageKey:"ckeditor:".concat(this.pluginName,":").concat(t.elementType),sources:t.sources,criteria:t.criteria,defaultSiteId:n.config.get("elementSiteId"),autoFocusSearchBox:!1,onSelect:function(c){if(c.length){var l=c[0],d="".concat(l.url,"#").concat(t.refHandle,":").concat(l.id,"@").concat(l.siteId);n.editing.view.focus(),!r&&s?(o.change((function(t){t.setSelection(s)})),n.commands.get("link").execute(d)):o.change((function(t){if(t.insertText(l.label,{linkHref:d},i.getFirstPosition()),s instanceof Aa)try{var e=s.clone();e.end.path[1]+=l.label.length,t.setSelection(e)}catch(t){}})),e._linkUI._hideFakeVisualSelection(),setTimeout((function(){n.editing.view.focus(),e._linkUI._showUI(!0)}),100)}else a()},onCancel:function(){a()},closeOtherModals:!1})}},{key:"_modifyFormViewTemplate",value:function(){var t=this;this._linkUI.formView||this._linkUI._createViews();var e,n=this._linkUI.formView,o=n.urlInputView,i=o.fieldView;n.template.attributes.class.push("ck-link-form_layout-vertical","ck-vertical-form"),this.siteDropdownView=jp(n.locale),this.siteDropdownView.buttonView.set({label:"",withText:!0,isVisible:!1}),this.siteDropdownItemModels=Object.fromEntries(Craft.sites.map((function(t){return[t.id,new Gm({label:t.name,siteId:t.id,withText:!0})]}))),this.siteDropdownItemModels.current=new Gm({label:Craft.t("ckeditor","Link to the current site"),siteId:null,withText:!0}),Up(this.siteDropdownView,new si([].concat(function(t){if(Array.isArray(t))return nT(t)}(e=Craft.sites.map((function(e){return{type:"button",model:t.siteDropdownItemModels[e.id]}})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||eT(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[{type:"button",model:this.siteDropdownItemModels.current}]))),this.siteDropdownView.on("execute",(function(e){var n=t._urlInputRefMatch();if(n){var o=e.source.siteId,r=n[1];o&&(r+="@".concat(o));var s=t._urlInputValue().replace(n[0],r);i.set("value",s)}else console.warn("No reference tag hash present in URL: ".concat(t._urlInputValue()))}));var r=n.children,s=r.getIndex(o);r.add(this.siteDropdownView,s+1),n._focusables.add(this.siteDropdownView),n.focusTracker.add(this.siteDropdownView.element),this.listenTo(i,"change:value",(function(){t._toggleSiteDropdownView()})),this.listenTo(i,"input",(function(){t._toggleSiteDropdownView()}))}},{key:"_urlInputValue",value:function(){return this._linkUI.formView.urlInputView.fieldView.element.value}},{key:"_urlInputRefMatch",value:function(){return this._urlInputValue().match(this.localizedRefHandleRE)}},{key:"_toggleSiteDropdownView",value:function(){var t=this._urlInputRefMatch();if(t){this.siteDropdownView.buttonView.set("isVisible",!0);var e=t[2]?parseInt(t[2],10):null;e&&void 0===this.siteDropdownItemModels[e]&&(e=null),this._selectSiteDropdownItem(e)}else this.siteDropdownView.buttonView.set("isVisible",!1)}},{key:"_selectSiteDropdownItem",value:function(t){var e=this.siteDropdownItemModels[null!=t?t:"current"],n=t?Craft.t("ckeditor","Site: {name}",{name:e.label}):e.label;this.siteDropdownView.buttonView.set("label",n),Object.values(this.siteDropdownItemModels).forEach((function(t){t.set("isOn",t===e)}))}}])&&oT(e.prototype,n),o&&oT(e,o),Object.defineProperty(e,"prototype",{writable:!1}),a}(iu);function aT(t){return aT="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},aT(t)}function cT(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,o=new Array(e);nt.length)&&(e=t.length);for(var n=0,o=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,r=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw r}}}}(e.createRangeIn(e.document.getRoot()).getWalker({ignoreElementEnd:!0}));try{for(o.s();!(t=o.n()).done;){var i=t.value;if(i.item.is("element")&&"imageBlock"===i.item.name){var r=this._srcInfo(i.item);r&&n.push({element:i.item,srcInfo:r})}}}catch(t){o.e(t)}finally{o.f()}return n}}])&&IT(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(su);function NT(t){return NT="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},NT(t)}function zT(t,e){for(var n=0;n=0;--r){var s=this.tryEntries[r],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),l=o.call(s,"finallyLoc");if(c&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&o.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var o=n.completion;if("throw"===o.type){var i=o.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,o){return this.delegate={iterator:I(e),resultName:n,nextLoc:o},"next"===this.method&&(this.arg=t),f}},e}function sB(t,e,n,o,i,r,s){try{var a=t[r](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(o,i)}function aB(t,e){for(var n=0;n{const{mapper:i,viewPosition:r}=o,s=i.findMappedViewAncestor(r);if(!e(s))return;const a=i.toModelElement(s);o.modelPosition=t.createPositionAt(a,r.isAtStart?"before":"after")}))}},{key:"_defineSchema",value:function(){this.editor.model.schema.register("craftEntryModel",{inheritAllFrom:"$blockObject",allowAttributes:["cardHtml","entryId","siteId"],allowChildren:!1})}},{key:"_defineConverters",value:function(){var t=this,e=this.editor.conversion;e.for("upcast").elementToElement({view:{name:"craft-entry"},model:function(t,e){var n,o=e.writer,i=t.getAttribute("data-card-html"),r=t.getAttribute("data-entry-id"),s=null!==(n=t.getAttribute("data-site-id"))&&void 0!==n?n:null;return o.createElement("craftEntryModel",{cardHtml:i,entryId:r,siteId:s})}}),e.for("editingDowncast").elementToElement({model:"craftEntryModel",view:function(t,e){var o,i,r=e.writer,s=null!==(o=t.getAttribute("entryId"))&&void 0!==o?o:null,a=null!==(i=t.getAttribute("siteId"))&&void 0!==i?i:null,c=r.createContainerElement("div",{class:"cke-entry-card","data-entry-id":s,"data-site-id":a});return n(t,r,c),Kf(c,r)}}),e.for("dataDowncast").elementToElement({model:"craftEntryModel",view:function(t,e){var n,o,i=e.writer,r=null!==(n=t.getAttribute("entryId"))&&void 0!==n?n:null,s=null!==(o=t.getAttribute("siteId"))&&void 0!==o?o:null;return i.createContainerElement("craft-entry",{"data-entry-id":r,"data-site-id":s})}});var n=function(e,n,o){t._getCardHtml(e).then((function(e){var i=n.createRawElement("div",null,(function(t){t.innerHTML=e.cardHtml,Craft.appendHeadHtml(e.headHtml),Craft.appendBodyHtml(e.bodyHtml)}));n.insert(n.createPositionAt(o,0),i);var r=t.editor;r.editing.view.focus(),setTimeout((function(){Craft.cp.elementThumbLoader.load($(r.ui.element))}),100),r.model.change((function(t){r.ui.update(),$(r.sourceElement).trigger("keyup")}))}))}}},{key:"_getCardHtml",value:(i=rB().mark((function t(e){var n,o,i,r,s,a,c,l,d,u,h,p,m,g,f,k;return rB().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=null!==(n=e.getAttribute("cardHtml"))&&void 0!==n?n:null,s=$(this.editor.sourceElement).parents(".field"),a=$(s[0]).data("layout-element"),!r){t.next=5;break}return t.abrupt("return",{cardHtml:r});case 5:if(c=null!==(o=e.getAttribute("entryId"))&&void 0!==o?o:null,l=null!==(i=e.getAttribute("siteId"))&&void 0!==i?i:null,t.prev=7,d=this.editor,u=$(d.ui.view.element).closest("form,.lp-editor-container"),!(h=u.data("elementEditor"))){t.next=14;break}return t.next=14,h.checkForm();case 14:return t.next=16,Craft.sendActionRequest("POST","ckeditor/ckeditor/entry-card-html",{data:{entryId:c,siteId:l,layoutElementUid:a}});case 16:return p=t.sent,m=p.data,t.abrupt("return",m);case 21:return t.prev=21,t.t0=t.catch(7),console.error(null===t.t0||void 0===t.t0||null===(g=t.t0.response)||void 0===g?void 0:g.data),k=''+((null===t.t0||void 0===t.t0||null===(f=t.t0.response)||void 0===f||null===(f=f.data)||void 0===f?void 0:f.message)||"An unknown error occurred.")+"
",t.abrupt("return",{cardHtml:k});case 26:case"end":return t.stop()}}),t,this,[[7,21]])})),r=function(){var t=this,e=arguments;return new Promise((function(n,o){var r=i.apply(t,e);function s(t){sB(r,n,o,s,a,"next",t)}function a(t){sB(r,n,o,s,a,"throw",t)}s(void 0)}))},function(t){return r.apply(this,arguments)})}],o=[{key:"requires",get:function(){return[dk]}},{key:"pluginName",get:function(){return"CraftEntriesEditing"}}],n&&aB(e.prototype,n),o&&aB(e,o),Object.defineProperty(e,"prototype",{writable:!1}),l}(iu);function uB(t){return uB="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},uB(t)}function hB(t,e){for(var n=0;n=0;--r){var s=this.tryEntries[r],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),l=o.call(s,"finallyLoc");if(c&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&o.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var o=n.completion;if("throw"===o.type){var i=o.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,o){return this.delegate={iterator:I(e),resultName:n,nextLoc:o},"next"===this.method&&(this.arg=t),f}},e}function bB(t,e,n,o,i,r,s){try{var a=t[r](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(o,i)}function wB(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var r=t.apply(e,n);function s(t){bB(r,o,i,s,a,"next",t)}function a(t){bB(r,o,i,s,a,"throw",t)}s(void 0)}))}}function _B(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:null;null===e&&(e=this.editor.model.document.selection.getSelectedElement());var n=e.getAttribute("entryId"),o=null!==(t=e.getAttribute("siteId"))&&void 0!==t?t:null;this._showEditEntrySlideout(n,o,e)}},{key:"_createToolbarEntriesButton",value:function(t){var e=this,n=this.editor,o=n.config.get("entryTypeOptions"),i=n.commands.get("insertEntry");if(o&&o.length){var r=jp(t);return r.buttonView.set({label:n.config.get("createButtonLabel")||Craft.t("app","New {type}",{type:Craft.t("app","entry")}),tooltip:!0,withText:!0}),r.bind("isEnabled").to(i),Up(r,(function(){return e._getDropdownItemsDefinitions(o,i)}),{ariaLabel:Craft.t("ckeditor","Entry types list")}),this.listenTo(r,"execute",(function(t){e._showCreateEntrySlideout(t.source.commandValue)})),r}}},{key:"_getDropdownItemsDefinitions",value:function(t,e){var n=new si;return t.map((function(t){var e={type:"button",model:new Gm({commandValue:t.value,label:t.label||t.value,icon:t.icon,withText:!0})};n.add(e)})),n}},{key:"_createEditEntryBtn",value:function(t){var e=this,n=new Mh(t);return n.set({isEnabled:!0,label:Craft.t("app","Edit {type}",{type:Craft.t("app","entry")}),tooltip:!0,withText:!0}),this.listenTo(n,"execute",(function(t){e._initEditEntrySlideout()})),n}},{key:"getElementEditor",value:function(){return $(this.editor.ui.view.element).closest("form,.lp-editor-container").data("elementEditor")}},{key:"_getCardElement",value:function(t){return $(this.editor.ui.element).find('.element.card[data-id="'+t+'"]')}},{key:"_showEditEntrySlideout",value:function(t,e,n){var o,i=this,r=this.editor,s=this.getElementEditor(),a=Craft.createElementEditor(this.elementType,null,{elementId:t,params:{siteId:e},onBeforeSubmit:(o=wB(kB().mark((function e(){var n,o;return kB().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(n=i._getCardElement(t))||!Garnish.hasAttr(n,"data-owner-is-canonical")||s.settings.isUnpublishedDraft){e.next=9;break}return e.next=4,a.elementEditor.checkForm(!0,!0);case 4:if(o=$(r.sourceElement).attr("name"),!s||!o){e.next=8;break}return e.next=8,s.setFormValue(o,"*");case 8:s.settings.draftId&&a.elementEditor.settings.draftId&&(a.elementEditor.settings.saveParams||(a.elementEditor.settings.saveParams={}),a.elementEditor.settings.saveParams.action="elements/save-nested-element-for-derivative",a.elementEditor.settings.saveParams.newOwnerId=s.getDraftElementId(n.data("owner-id")));case 9:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)}),onSubmit:function(e){var o=i._getCardElement(t);null!==o&&e.data.id!=o.data("id")&&(o.attr("data-id",e.data.id).data("id",e.data.id).data("owner-id",e.data.ownerId),r.editing.model.change((function(t){t.setAttribute("entryId",e.data.id,n),r.ui.update()})),Craft.refreshElementInstances(e.data.id))}})}},{key:"_showCreateEntrySlideout",value:(i=wB(kB().mark((function t(e){var n,o,i,r,s,a,c;return kB().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.editor,o=n.config.get("nestedElementAttributes"),i=Object.assign({},o,{typeId:e}),!(r=this.getElementEditor())){t.next=8;break}return t.next=7,r.markDeltaNameAsModified(n.sourceElement.name);case 7:i.ownerId=r.getDraftElementId(o.ownerId);case 8:return t.prev=8,t.next=11,Craft.sendActionRequest("POST","elements/create",{data:i});case 11:a=t.sent,s=a.data,t.next=19;break;case 15:throw t.prev=15,t.t0=t.catch(8),Craft.cp.displayError(null===t.t0||void 0===t.t0||null===(c=t.t0.response)||void 0===c||null===(c=c.data)||void 0===c?void 0:c.error),t.t0;case 19:Craft.createElementEditor(this.elementType,{elementId:s.element.id,draftId:s.element.draftId,params:{fresh:1,siteId:s.element.siteId}}).on("submit",(function(t){n.commands.execute("insertEntry",{entryId:t.data.id,siteId:t.data.siteId})}));case 21:case"end":return t.stop()}}),t,this,[[8,15]])}))),function(t){return i.apply(this,arguments)})}],o=[{key:"requires",get:function(){return[uk]}},{key:"pluginName",get:function(){return"CraftEntriesUI"}}],n&&_B(e.prototype,n),o&&_B(e,o),Object.defineProperty(e,"prototype",{writable:!1}),c}(iu);function yB(t){return yB="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yB(t)}function xB(t,e){for(var n=0;n=0;--r){var s=this.tryEntries[r],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),l=o.call(s,"finallyLoc");if(c&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&o.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var o=n.completion;if("throw"===o.type){var i=o.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,o){return this.delegate={iterator:I(e),resultName:n,nextLoc:o},"next"===this.method&&(this.arg=t),f}},e}function MB(t,e,n,o,i,r,s){try{var a=t[r](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(o,i)}function PB(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var r=t.apply(e,n);function s(t){MB(r,o,i,s,a,"next",t)}function a(t){MB(r,o,i,s,a,"throw",t)}s(void 0)}))}}function OB(t){return function(t){if(Array.isArray(t))return RB(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||LB(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function NB(t){return NB="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},NB(t)}function zB(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,i,r,s,a=[],c=!0,l=!1;try{if(r=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(o=r.call(n)).done)&&(a.push(o.value),a.length!==e);c=!0);}catch(t){l=!0,i=t}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}(t,e)||LB(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function LB(t,e){if(t){if("string"==typeof t)return RB(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?RB(t,e):void 0}}function RB(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n{const t=e.selection.getFirstRange(),n=Cl.fromPosition(t.start);n.stickiness="toPrevious";const o=Cl.fromPosition(t.end);o.stickiness="toNext",e.once("change:data",(()=>{this._embedImageBetweenPositions(n,o),n.detach(),o.detach()}),{priority:"high"})})),t.commands.get("undo").on("execute",(()=>{this._timeoutId&&(en.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedImageBetweenPositions(t,e){const n=this.editor,o=new La(t,e),i=o.getWalker({ignoreElementEnd:!0}),r=Object.fromEntries(n.model.document.selection.getAttributes()),s=this.editor.plugins.get("ImageUtils");let a="";for(const t of i)t.item.is("$textProxy")&&(a+=t.item.data);a=a.trim(),a.match(_C)?(this._positionToInsert=Cl.fromPosition(t),this._timeoutId=setTimeout((()=>{n.commands.get("insertImage").isEnabled?(n.model.change((t=>{let e;this._timeoutId=null,t.remove(o),o.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(e=this._positionToInsert.toPosition()),s.insertImage({...r,src:a},e),this._positionToInsert.detach(),this._positionToInsert=null})),n.plugins.get("Delete").requestUndoOnBackspace()):o.detach()}),100)):o.detach()}},class extends iu{static get requires(){return[Ig,Pv]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.model.document.selection;t.on("change:range",(()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(t,e){return e.textNode&&e.textNode.hasAttribute("linkHref")?Ug(e,"linkHref",e.textNode.getAttribute("linkHref"),t):null}_selectEntireLinks(t,e){const n=this.editor.model,o=n.document.selection,i=o.getFirstPosition(),r=o.getLastPosition();let s=e.getJoined(this._expandLinkRange(n,i)||e);s&&(s=s.getJoined(this._expandLinkRange(n,r)||e)),s&&(s.start.isBefore(i)||s.end.isAfter(r))&&t.setSelection(s)}_enablePasteLinking(){const t=this.editor,e=t.model,n=e.document.selection,o=t.plugins.get("ClipboardPipeline"),i=t.commands.get("link");o.on("inputTransformation",((t,o)=>{if(!this.isEnabled||!i.isEnabled||n.isCollapsed||"paste"!==o.method)return;if(n.rangeCount>1)return;const r=n.getFirstRange(),s=o.dataTransfer.getData("text/plain");if(!s)return;const a=s.match(jv);a&&a[2]===s&&(e.change((t=>{this._selectEntireLinks(t,r),i.execute(s)})),t.stop())}),{priority:"high"})}_enableTypingHandling(){const t=this.editor,e=new Og(t.model,(t=>{if(!function(t){return t.length>4&&" "===t[t.length-1]&&" "!==t[t.length-2]}(t))return;const e=Vv(t.substr(0,t.length-1));return e?{url:e}:void 0}));e.on("matched:data",((e,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),c=t.model.createRange(a,s);this._applyAutoLink(r,c)})),e.bind("isEnabled").to(this)}_enableEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("enter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition();if(!t.parent.previousSibling)return;const n=e.createRangeIn(t.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("shiftEnter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition(),n=e.createRange(e.createPositionAt(t.parent,0),t.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(t){const e=this.editor.model,{text:n,range:o}=Pg(t,e),i=Vv(n);if(i){const t=e.createRange(o.end.getShiftedBy(-i.length),o.end);this._applyAutoLink(i,t)}}_applyAutoLink(t,e){const n=this.editor.model,o=Av(t,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}(e,n)&&yv(o)&&!function(t){const e=t.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}(e)&&this._persistAutoLink(o,e)}_persistAutoLink(t,e){const n=this.editor.model,o=this.editor.plugins.get("Delete");n.enqueueChange((i=>{i.setAttribute("linkHref",t,e),n.enqueueChange((()=>{o.requestUndoOnBackspace()}))}))}},class extends iu{static get requires(){return[Ig]}static get pluginName(){return"Autoformat"}static get isOfficialPlugin(){return!0}afterInit(){const t=this.editor,e=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const t=this.editor.commands;t.get("bulletedList")&&qg(this.editor,this,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&qg(this.editor,this,/^1[.|)]\s$/,"numberedList"),t.get("todoList")&&qg(this.editor,this,/^\[\s?\]\s$/,"todoList"),t.get("checkTodoList")&&qg(this.editor,this,/^\[\s?x\s?\]\s$/,(()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")}))}_addBasicStylesAutoformats(){const t=this.editor.commands;if(t.get("bold")){const t=Yg(this.editor,"bold");$g(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),$g(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=Yg(this.editor,"italic");$g(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),$g(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=Yg(this.editor,"code");$g(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(t.get("strikethrough")){const t=Yg(this.editor,"strikethrough");$g(this.editor,this,/(~~)([^~]+)(~~)$/g,t)}}_addHeadingAutoformats(){const t=this.editor.commands.get("heading");t&&t.modelElements.filter((t=>t.match(/^heading[1-6]$/))).forEach((e=>{const n=e[7],o=new RegExp(`^(#{${n}})\\s$`);qg(this.editor,this,o,(()=>{if(!t.isEnabled||t.value===e)return!1;this.editor.execute("heading",{value:e})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&qg(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const t=this.editor,e=t.model.document.selection;t.commands.get("codeBlock")&&qg(t,this,/^```$/,(()=>{if(e.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&qg(this.editor,this,/^---$/,"horizontalLine")}},class extends iu{static get requires(){return[Vf,Hf]}static get pluginName(){return"BlockQuote"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[Jg,ef]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[of,sf]}static get pluginName(){return"Code"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[ob,sb]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[MA,zA]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[XA,ey]}static get pluginName(){return"ListProperties"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[tp,Hk,Mf,fb,zf,Mg,yb]}static get pluginName(){return"Essentials"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[Rb,Db]}static get pluginName(){return"FindAndReplace"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.plugins.get("FindAndReplaceUI"),e=this.editor.plugins.get("FindAndReplaceEditing"),n=e.state;t.on("findNext",((t,o)=>{o?(n.searchText=o.searchText,e.find(o.searchText,o)):this.editor.execute("findNext")})),t.on("findPrevious",((t,o)=>{o&&n.searchText!==o.searchText?e.find(o.searchText):this.editor.execute("findPrevious")})),t.on("replace",((t,o)=>{n.searchText!==o.searchText&&e.find(o.searchText);const i=n.highlightedResult;i&&this.editor.execute("replace",o.replaceText,i)})),t.on("replaceAll",((t,o)=>{n.searchText!==o.searchText&&e.find(o.searchText),this.editor.execute("replaceAll",o.replaceText,n.results)})),t.on("searchReseted",(()=>{n.clear(this.editor.model),e.stop()}))}},class extends iu{static get requires(){return[tw,lw,mw,bw]}static get pluginName(){return"Font"}static get isOfficialPlugin(){return!0}},class extends iu{static get pluginName(){return"GeneralHtmlSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[q_,J_,X_,tC,nC,oC,iC,rC,sC,aC,dC]}init(){const t=this.editor,e=t.plugins.get(q_);e.loadAllowedEmptyElementsConfig(t.config.get("htmlSupport.allowEmpty")||[]),e.loadAllowedConfig(t.config.get("htmlSupport.allow")||[]),e.loadDisallowedConfig(t.config.get("htmlSupport.disallow")||[])}getGhsAttributeNameForElement(t){const e=this.editor.plugins.get("DataSchema"),n=Array.from(e.getDefinitionsForView(t,!1)),o=n.find((t=>t.isInline&&!n[0].isObject));return o?o.model:N_(t)}addModelHtmlClass(t,e,n){const o=this.editor.model,i=this.getGhsAttributeNameForElement(t);o.change((t=>{for(const r of uC(o,n,i))O_(t,r,i,"classes",(t=>{for(const n of ii(e))t.add(n)}))}))}removeModelHtmlClass(t,e,n){const o=this.editor.model,i=this.getGhsAttributeNameForElement(t);o.change((t=>{for(const r of uC(o,n,i))O_(t,r,i,"classes",(t=>{for(const n of ii(e))t.delete(n)}))}))}setModelHtmlAttributes(t,e,n){const o=this.editor.model,i=this.getGhsAttributeNameForElement(t);o.change((t=>{for(const r of uC(o,n,i))O_(t,r,i,"attributes",(t=>{for(const[n,o]of Object.entries(e))t.set(n,o)}))}))}removeModelHtmlAttributes(t,e,n){const o=this.editor.model,i=this.getGhsAttributeNameForElement(t);o.change((t=>{for(const r of uC(o,n,i))O_(t,r,i,"attributes",(t=>{for(const n of ii(e))t.delete(n)}))}))}setModelHtmlStyles(t,e,n){const o=this.editor.model,i=this.getGhsAttributeNameForElement(t);o.change((t=>{for(const r of uC(o,n,i))O_(t,r,i,"styles",(t=>{for(const[n,o]of Object.entries(e))t.set(n,o)}))}))}removeModelHtmlStyles(t,e,n){const o=this.editor.model,i=this.getGhsAttributeNameForElement(t);o.change((t=>{for(const r of uC(o,n,i))O_(t,r,i,"styles",(t=>{for(const n of ii(e))t.delete(n)}))}))}},Sw,class extends iu{static get requires(){return[Bw,Iw,dk]}static get pluginName(){return"HorizontalLine"}static get isOfficialPlugin(){return!0}},class extends iu{static get pluginName(){return"HtmlComment"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=new Map;t.data.processor.skipComments=!1,t.model.schema.addAttributeCheck(((t,e)=>{if(t.endsWith("$root")&&e.startsWith("$comment"))return!0})),t.conversion.for("upcast").elementToMarker({view:"$comment",model:t=>{const n=`$comment:${_n()}`,o=t.getCustomProperty("$rawContent");return e.set(n,o),n}}),t.conversion.for("dataDowncast").markerToElement({model:"$comment",view:(t,{writer:e})=>{let n;for(const e of this.editor.model.document.getRootNames())if(n=this.editor.model.document.getRoot(e),n.hasAttribute(t.markerName))break;const o=t.markerName,i=n.getAttribute(o),r=e.createUIElement("$comment");return e.setCustomProperty("$rawContent",i,r),r}}),t.model.document.registerPostFixer((n=>{let o=!1;const i=t.model.document.differ.getChangedMarkers().filter((t=>t.name.startsWith("$comment:")));for(const t of i){const{oldRange:i,newRange:r}=t.data;if(!i||!r||i.root!=r.root){if(i){const e=i.root;e.hasAttribute(t.name)&&(n.removeAttribute(t.name,e),o=!0)}if(r){const i=r.root;"$graveyard"==i.rootName?(n.removeMarker(t.name),o=!0):i.hasAttribute(t.name)||(n.setAttribute(t.name,e.get(t.name)||"",i),o=!0)}}}return o})),t.data.on("set",(()=>{for(const e of t.model.markers.getMarkersGroup("$comment"))this.removeHtmlComment(e.name)}),{priority:"high"}),t.model.on("deleteContent",((e,[n])=>{for(const e of n.getRanges()){const n=t.model.schema.getLimitElement(e),o=t.model.createPositionAt(n,0),i=t.model.createPositionAt(n,"end");let r;r=o.isTouching(e.start)&&i.isTouching(e.end)?this.getHtmlCommentsInRange(t.model.createRange(o,i)):this.getHtmlCommentsInRange(e,{skipBoundaries:!0});for(const t of r)this.removeHtmlComment(t)}}),{priority:"high"})}createHtmlComment(t,e){const n=_n(),o=this.editor.model,i=o.document.getRoot(t.root.rootName),r=`$comment:${n}`;return o.change((n=>{const o=n.createRange(t);return n.addMarker(r,{usingOperation:!0,affectsData:!0,range:o}),n.setAttribute(r,e,i),r}))}removeHtmlComment(t){const e=this.editor,n=e.model.markers.get(t);return!!n&&(e.model.change((t=>{t.removeMarker(n)})),!0)}getHtmlCommentData(t){const e=this.editor.model.markers.get(t);if(!e)return null;let n="";for(const e of this.editor.model.document.getRoots())if(e.hasAttribute(t)){n=e.getAttribute(t);break}return{content:n,position:e.getStart()}}getHtmlCommentsInRange(t,{skipBoundaries:e=!1}={}){const n=!e;return Array.from(this.editor.model.markers.getMarkersGroup("$comment")).filter((e=>function(t,e){const o=t.getRange().start;return(o.isAfter(e.start)||n&&o.isEqual(e.start))&&(o.isBefore(e.end)||n&&o.isEqual(e.end))}(e,t))).map((t=>t.name))}},class extends iu{static get requires(){return[Ow,zw,dk]}static get pluginName(){return"HtmlEmbed"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[FC,VC]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[WC,GC]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[XC,tv]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[uk,bC]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const t=this.editor,e=t.t,n=t.plugins.get(uk),i=t.plugins.get("ImageUtils");var r;n.register("image",{ariaLabel:e("Image toolbar"),items:(r=t.config.get("image.toolbar")||[],r.map((t=>o(t)?t.name:t))),getRelatedElement:t=>i.getClosestSelectedImageWidget(t)})}},class extends iu{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[iv,rv]}},class extends iu{constructor(t){super(t),t.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.config.get("indentBlock");e.classes&&e.classes.length?(this._setupConversionUsingClasses(e.classes),t.commands.add("indentBlock",new sv(t,new cv({direction:"forward",classes:e.classes}))),t.commands.add("outdentBlock",new sv(t,new cv({direction:"backward",classes:e.classes})))):(t.data.addStyleProcessorRules(Gd),this._setupConversionUsingOffset(),t.commands.add("indentBlock",new sv(t,new av({direction:"forward",offset:e.offset,unit:e.unit}))),t.commands.add("outdentBlock",new sv(t,new av({direction:"backward",offset:e.offset,unit:e.unit}))))}afterInit(){const t=this.editor,e=t.model.schema,n=t.commands.get("indent"),o=t.commands.get("outdent"),i=t.config.get("heading.options");(i&&i.map((t=>t.model))||lv).forEach((t=>{e.isRegistered(t)&&e.extend(t,{allowAttributes:"blockIndent"})})),e.setAttributeProperties("blockIndent",{isFormatting:!0}),n.registerChildCommand(t.commands.get("indentBlock")),o.registerChildCommand(t.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const t=this.editor.conversion,e="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";t.for("upcast").attributeToAttribute({view:{styles:{[e]:/[\s\S]+/}},model:{key:"blockIndent",value:t=>{if(!t.is("element","li"))return t.getStyle(e)}}}),t.for("downcast").attributeToAttribute({model:"blockIndent",view:t=>({key:"style",value:{[e]:t}})})}_setupConversionUsingClasses(t){const e={model:{key:"blockIndent",values:[]},view:{}};for(const n of t)e.model.values.push(n),e.view[n]={key:"class",value:[n]};this.editor.conversion.attributeToAttribute(e)}},class extends iu{static get requires(){return[cf,df]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}},Pv,class extends iu{static get requires(){return[Hv,Gv]}static get pluginName(){return"LinkImage"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[bx,vx,_x,dk]}static get pluginName(){return"MediaEmbed"}static get isOfficialPlugin(){return!0}},class extends iu{static get requires(){return[uk]}static get pluginName(){return"MediaEmbedToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const t=this.editor,e=t.t;t.plugins.get(uk).register("mediaEmbed",{ariaLabel:e("Media toolbar"),items:t.config.get("mediaEmbed.toolbar")||[],getRelatedElement:ux})}},class extends iu{static get requires(){return[yx,xx,dk]}static get pluginName(){return"PageBreak"}static get isOfficialPlugin(){return!0}},class extends iu{static get pluginName(){return"PasteFromOffice"}static get isOfficialPlugin(){return!0}static get requires(){return[Dk]}init(){const t=this.editor,e=t.plugins.get("ClipboardPipeline"),n=t.editing.view.document,o=[],i=this.editor.plugins.has("MultiLevelList");o.push(new Lx(n,i)),o.push(new Vx(n)),o.push(new Ux(n)),e.on("inputTransformation",((e,i)=>{if(i._isTransformedWithPasteFromOffice)return;if(t.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const r=i.dataTransfer.getData("text/html"),s=o.find((t=>t.isActive(r)));s&&(i._parsedData||(i._parsedData=function(t,e){const n=new DOMParser,o=function(t){return Wx(Wx(t)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(t){const e="