!function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=11)}([function(e,t,i){"use strict";i.d(t,"a",(function(){return n})),i.d(t,"b",(function(){return s}));class n extends Error{constructor(e,t,i){super(`${e}${i?" "+JSON.stringify(i):""}${o(e)}`),this.name="CKEditorError",this.context=t,this.data=i}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new n(e.message,t);throw i.stack=e.stack,i}}function s(e,t){console.warn(...r(e,t))}function o(e){return"\nRead more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-"+e}function r(e,t){const i=o(e);return t?[e,t,i]:[e,i]}},,function(e,t,i){"use strict";var n=i(6),s="object"==typeof self&&self&&self.Object===Object&&self,o=n.a||s||Function("return this")();t.a=o},function(e,t,i){"use strict";(function(e){var n=i(2),s=i(10),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,r=o&&"object"==typeof e&&e&&!e.nodeType&&e,a=r&&r.exports===o?n.a.Buffer:void 0,l=(a?a.isBuffer:void 0)||s.a;t.a=l}).call(this,i(8)(e))},function(e,t,i){"use strict";(function(e){var n=i(6),s="object"==typeof exports&&exports&&!exports.nodeType&&exports,o=s&&"object"==typeof e&&e&&!e.nodeType&&e,r=o&&o.exports===s&&n.a.process,a=function(){try{var e=o&&o.require&&o.require("util").types;return e||r&&r.binding&&r.binding("util")}catch(e){}}();t.a=a}).call(this,i(8)(e))},function(e,t,i){"use strict";(function(e){var t=i(0);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const n="object"==typeof window?window:e;if(n.CKEDITOR_VERSION)throw new t.a("ckeditor-duplicated-modules",null);n.CKEDITOR_VERSION="27.1.0"}).call(this,i(9))},function(e,t,i){"use strict";(function(e){var i="object"==typeof e&&e&&e.Object===Object&&e;t.a=i}).call(this,i(9))},function(e,t,i){"use strict";(function(e){var n=i(2),s="object"==typeof exports&&exports&&!exports.nodeType&&exports,o=s&&"object"==typeof e&&e&&!e.nodeType&&e,r=o&&o.exports===s?n.a.Buffer:void 0,a=r?r.allocUnsafe:void 0;t.a=function(e,t){if(t)return e.slice();var i=e.length,n=a?a(i):new e.constructor(i);return e.copy(n),n}}).call(this,i(8)(e))},function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){"use strict";t.a=function(){return!1}},function(e,t,i){"use strict";i.r(t);var n=
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(){return function e(){e.called=!0}};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class s{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=n(),this.off=n()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const o=new Array(256).fill().map((e,t)=>("0"+t.toString(16)).slice(-2));function r(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0;return"e"+o[e>>0&255]+o[e>>8&255]+o[e>>16&255]+o[e>>24&255]+o[t>>0&255]+o[t>>8&255]+o[t>>16&255]+o[t>>24&255]+o[i>>0&255]+o[i>>8&255]+o[i>>16&255]+o[i>>24&255]+o[n>>0&255]+o[n>>8&255]+o[n>>16&255]+o[n>>24&255]}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var a={get(e){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5},l=(i(5),i(0));
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const c=Symbol("listeningTo"),h=Symbol("emitterId");var d={on(e,t,i={}){this.listenTo(this,e,t,i)},once(e,t,i){let n=!1;this.listenTo(this,e,(function(e,...i){n||(n=!0,e.off(),t.call(this,e,...i))}),i)},off(e,t){this.stopListening(this,e,t)},listenTo(e,t,i,n={}){let s,o;this[c]||(this[c]={});const r=this[c];m(e)||u(e);const a=m(e);(s=r[a])||(s=r[a]={emitter:e,callbacks:{}}),(o=s.callbacks[t])||(o=s.callbacks[t]=[]),o.push(i),function(e,t,i,n,s){t._addEventListener?t._addEventListener(i,n,s):e._addEventListener.call(t,i,n,s)}(this,e,t,i,n)},stopListening(e,t,i){const n=this[c];let s=e&&m(e);const o=n&&s&&n[s],r=o&&t&&o.callbacks[t];if(!(!n||e&&!o||t&&!r))if(i){w(this,e,t,i);-1!==r.indexOf(i)&&(1===r.length?delete o.callbacks[t]:w(this,e,t,i))}else if(r){for(;i=r.pop();)w(this,e,t,i);delete o.callbacks[t]}else if(o){for(t in o.callbacks)this.stopListening(e,t);delete n[s]}else{for(s in n)this.stopListening(n[s].emitter);delete this[c]}},fire(e,...t){try{const i=e instanceof s?e:new s(this,e),n=i.name;let o=function e(t,i){let n;if(!t._events||!(n=t._events[i])||!n.callbacks.length)return i.indexOf(":")>-1?e(t,i.substr(0,i.lastIndexOf(":"))):null;return n.callbacks}(this,n);if(i.path.push(this),o){const e=[i,...t];o=Array.from(o);for(let t=0;t<o.length&&(o[t].callback.apply(this,e),i.off.called&&(delete i.off.called,this._removeEventListener(n,o[t].callback)),!i.stop.called);t++);}if(this._delegations){const e=this._delegations.get(n),s=this._delegations.get("*");e&&p(e,i,t),s&&p(s,i,t)}return i.return}catch(e){l.a.rethrowUnexpectedError(e,this)}},delegate(...e){return{to:(t,i)=>{this._delegations||(this._delegations=new Map),e.forEach(e=>{const n=this._delegations.get(e);n?n.set(t,i):this._delegations.set(e,new Map([[t,i]]))})}}},stopDelegating(e,t){if(this._delegations)if(e)if(t){const i=this._delegations.get(e);i&&i.delete(t)}else this._delegations.delete(e);else this._delegations.clear()},_addEventListener(e,t,i){!function(e,t){const i=f(e);if(i[t])return;let n=t,s=null;const o=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},o.push(i[n]),s&&i[n].childEvents.push(s),s=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of o)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(s)}}(this,e);const n=g(this,e),s=a.get(i.priority),o={callback:t,priority:s};for(const e of n){let t=!1;for(let i=0;i<e.length;i++)if(e[i].priority<s){e.splice(i,0,o),t=!0;break}t||e.push(o)}},_removeEventListener(e,t){const i=g(this,e);for(const e of i)for(let i=0;i<e.length;i++)e[i].callback==t&&(e.splice(i,1),i--)}};function u(e,t){e[h]||(e[h]=t||r())}function m(e){return e[h]}function f(e){return e._events||Object.defineProperty(e,"_events",{value:{}}),e._events}function g(e,t){const i=f(e)[t];if(!i)return[];let n=[i.callbacks];for(let t=0;t<i.childEvents.length;t++){const s=g(e,i.childEvents[t]);n=n.concat(s)}return n}function p(e,t,i){for(let[n,o]of e){o?"function"==typeof o&&(o=o(t.name)):o=t.name;const e=new s(t.source,o);e.path=[...t.path],n.fire(e,...i)}}function w(e,t,i,n){t._removeEventListener?t._removeEventListener(i,n):e._removeEventListener.call(t,i,n)}var b=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},_=i(2),v=_.a.Symbol,y=Object.prototype,k=y.hasOwnProperty,C=y.toString,A=v?v.toStringTag:void 0;var x=function(e){var t=k.call(e,A),i=e[A];try{e[A]=void 0;var n=!0}catch(e){}var s=C.call(e);return n&&(t?e[A]=i:delete e[A]),s},T=Object.prototype.toString;var P=function(e){return T.call(e)},E=v?v.toStringTag:void 0;var S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":E&&E in Object(e)?x(e):P(e)};var R,I=function(e){if(!b(e))return!1;var t=S(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},V=_.a["__core-js_shared__"],O=(R=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var N=function(e){return!!O&&O in e},M=Function.prototype.toString;var B=function(e){if(null!=e){try{return M.call(e)}catch(e){}try{return e+""}catch(e){}}return""},F=/^\[object .+?Constructor\]$/,D=Function.prototype,z=Object.prototype,L=D.toString,H=z.hasOwnProperty,j=RegExp("^"+L.call(H).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var W=function(e){return!(!b(e)||N(e))&&(I(e)?j:F).test(B(e))};var q=function(e,t){return null==e?void 0:e[t]};var $=function(e,t){var i=q(e,t);return W(i)?i:void 0},U=function(){try{var e=$(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var K=function(e,t,i){"__proto__"==t&&U?U(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i};var G=function(e,t){return e===t||e!=e&&t!=t},J=Object.prototype.hasOwnProperty;var Y=function(e,t,i){var n=e[t];J.call(e,t)&&G(n,i)&&(void 0!==i||t in e)||K(e,t,i)};var Q=function(e,t,i,n){var s=!i;i||(i={});for(var o=-1,r=t.length;++o<r;){var a=t[o],l=n?n(i[a],e[a],a,i,e):void 0;void 0===l&&(l=e[a]),s?K(i,a,l):Y(i,a,l)}return i};var X=function(e){return e};var Z=function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)},ee=Math.max;var te=function(e,t,i){return t=ee(void 0===t?e.length-1:t,0),function(){for(var n=arguments,s=-1,o=ee(n.length-t,0),r=Array(o);++s<o;)r[s]=n[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=n[s];return a[t]=i(r),Z(e,this,a)}};var ie=function(e){return function(){return e}},ne=U?function(e,t){return U(e,"toString",{configurable:!0,enumerable:!1,value:ie(t),writable:!0})}:X,se=Date.now;var oe=function(e){var t=0,i=0;return function(){var n=se(),s=16-(n-i);if(i=n,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ne);var re=function(e,t){return oe(te(e,t,X),e+"")};var ae=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var le=function(e){return null!=e&&ae(e.length)&&!I(e)},ce=/^(?:0|[1-9]\d*)$/;var he=function(e,t){var i=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==i||"symbol"!=i&&ce.test(e))&&e>-1&&e%1==0&&e<t};var de=function(e,t,i){if(!b(i))return!1;var n=typeof t;return!!("number"==n?le(i)&&he(t,i.length):"string"==n&&t in i)&&G(i[t],e)};var ue=function(e){return re((function(t,i){var n=-1,s=i.length,o=s>1?i[s-1]:void 0,r=s>2?i[2]:void 0;for(o=e.length>3&&"function"==typeof o?(s--,o):void 0,r&&de(i[0],i[1],r)&&(o=s<3?void 0:o,s=1),t=Object(t);++n<s;){var a=i[n];a&&e(t,a,n,o)}return t}))};var me=function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n};var fe=function(e){return null!=e&&"object"==typeof e};var ge=function(e){return fe(e)&&"[object Arguments]"==S(e)},pe=Object.prototype,we=pe.hasOwnProperty,be=pe.propertyIsEnumerable,_e=ge(function(){return arguments}())?ge:function(e){return fe(e)&&we.call(e,"callee")&&!be.call(e,"callee")},ve=Array.isArray,ye=i(3),ke={};ke["[object Float32Array]"]=ke["[object Float64Array]"]=ke["[object Int8Array]"]=ke["[object Int16Array]"]=ke["[object Int32Array]"]=ke["[object Uint8Array]"]=ke["[object Uint8ClampedArray]"]=ke["[object Uint16Array]"]=ke["[object Uint32Array]"]=!0,ke["[object Arguments]"]=ke["[object Array]"]=ke["[object ArrayBuffer]"]=ke["[object Boolean]"]=ke["[object DataView]"]=ke["[object Date]"]=ke["[object Error]"]=ke["[object Function]"]=ke["[object Map]"]=ke["[object Number]"]=ke["[object Object]"]=ke["[object RegExp]"]=ke["[object Set]"]=ke["[object String]"]=ke["[object WeakMap]"]=!1;var Ce=function(e){return fe(e)&&ae(e.length)&&!!ke[S(e)]};var Ae=function(e){return function(t){return e(t)}},xe=i(4),Te=xe.a&&xe.a.isTypedArray,Pe=Te?Ae(Te):Ce,Ee=Object.prototype.hasOwnProperty;var Se=function(e,t){var i=ve(e),n=!i&&_e(e),s=!i&&!n&&Object(ye.a)(e),o=!i&&!n&&!s&&Pe(e),r=i||n||s||o,a=r?me(e.length,String):[],l=a.length;for(var c in e)!t&&!Ee.call(e,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||he(c,l))||a.push(c);return a},Re=Object.prototype;var Ie=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Re)};var Ve=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t},Oe=Object.prototype.hasOwnProperty;var Ne=function(e){if(!b(e))return Ve(e);var t=Ie(e),i=[];for(var n in e)("constructor"!=n||!t&&Oe.call(e,n))&&i.push(n);return i};var Me=function(e){return le(e)?Se(e,!0):Ne(e)},Be=ue((function(e,t){Q(t,Me(t),e)}));
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Fe=Symbol("observableProperties"),De=Symbol("boundObservables"),ze=Symbol("boundProperties"),Le=Symbol("decoratedMethods"),He=Symbol("decoratedOriginal"),je={set(e,t){if(b(e))return void Object.keys(e).forEach(t=>{this.set(t,e[t])},this);qe(this);const i=this[Fe];if(e in this&&!i.has(e))throw new l.a("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i.get(e),set(t){const n=i.get(e);let s=this.fire("set:"+e,e,t,n);void 0===s&&(s=t),n===s&&i.has(e)||(i.set(e,s),this.fire("change:"+e,e,s,n))}}),this[e]=t},bind(...e){if(!e.length||!Ke(e))throw new l.a("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new l.a("observable-bind-duplicate-properties",this);qe(this);const t=this[ze];e.forEach(e=>{if(t.has(e))throw new l.a("observable-bind-rebind",this)});const i=new Map;return e.forEach(e=>{const n={property:e,to:[]};t.set(e,n),i.set(e,n)}),{to:$e,toMany:Ue,_observable:this,_bindProperties:e,_to:[],_bindings:i}},unbind(...e){if(!this[Fe])return;const t=this[ze],i=this[De];if(e.length){if(!Ke(e))throw new l.a("observable-unbind-wrong-properties",this);e.forEach(e=>{const n=t.get(e);if(!n)return;let s,o,r,a;n.to.forEach(e=>{s=e[0],o=e[1],r=i.get(s),a=r[o],a.delete(n),a.size||delete r[o],Object.keys(r).length||(i.delete(s),this.stopListening(s,"change"))}),t.delete(e)})}else i.forEach((e,t)=>{this.stopListening(t,"change")}),i.clear(),t.clear()},decorate(e){const t=this[e];if(!t)throw new l.a("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,(e,i)=>{e.return=t.apply(this,i)}),this[e]=function(...t){return this.fire(e,t)},this[e][He]=t,this[Le]||(this[Le]=[]),this[Le].push(e)}};Be(je,d),je.stopListening=function(e,t,i){if(!e&&this[Le]){for(const e of this[Le])this[e]=this[e][He];delete this[Le]}d.stopListening.call(this,e,t,i)};var We=je;function qe(e){e[Fe]||(Object.defineProperty(e,Fe,{value:new Map}),Object.defineProperty(e,De,{value:new Map}),Object.defineProperty(e,ze,{value:new Map}))}function $e(...e){const t=function(...e){if(!e.length)throw new l.a("observable-bind-to-parse-error",null);const t={to:[]};let i;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach(e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new l.a("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}}),t}(...e),i=Array.from(this._bindings.keys()),n=i.length;if(!t.callback&&t.to.length>1)throw new l.a("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new l.a("observable-bind-to-extra-callback",this);var s;
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */t.to.forEach(e=>{if(e.properties.length&&e.properties.length!==n)throw new l.a("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)}),this._to=t.to,t.callback&&(this._bindings.get(i[0]).callback=t.callback),s=this._observable,this._to.forEach(e=>{const t=s[De];let i;t.get(e.observable)||s.listenTo(e.observable,"change",(n,o)=>{i=t.get(e.observable)[o],i&&i.forEach(e=>{Ge(s,e.property)})})}),function(e){let t;e._bindings.forEach((i,n)=>{e._to.forEach(s=>{t=s.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([s.observable,t]),function(e,t,i,n){const s=e[De],o=s.get(i),r=o||{};r[n]||(r[n]=new Set);r[n].add(t),o||s.set(i,r)}(e._observable,i,s.observable,t)})})}(this),this._bindProperties.forEach(e=>{Ge(this._observable,e)})}function Ue(e,t,i){if(this._bindings.size>1)throw new l.a("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const i=e.map(e=>[e,t]);return Array.prototype.concat.apply([],i)}(e,t),i)}function Ke(e){return e.every(e=>"string"==typeof e)}function Ge(e,t){const i=e[ze].get(t);let n;i.callback?n=i.callback.apply(e,i.to.map(e=>e[0][e[1]])):(n=i.to[0],n=n[0][n[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=n:e.set(t,n)}function Je(e,...t){t.forEach(t=>{Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)).forEach(i=>{if(i in e.prototype)return;const n=Object.getOwnPropertyDescriptor(t,i);n.enumerable=!1,Object.defineProperty(e.prototype,i,n)})})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ye{constructor(e){this.editor=e,this.set("isEnabled",!0),this._disableStack=new Set}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Qe,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Qe),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function Qe(e){e.return=!1,e.stop()}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Je(Ye,We);class Xe{constructor(e){this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.on("execute",e=>{this.isEnabled||e.stop()},{priority:"high"}),this.listenTo(e,"change:isReadOnly",(e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Ze,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Ze),this.refresh())}execute(){}destroy(){this.stopListening()}}function Ze(e){e.return=!1,e.stop()}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Je(Xe,We);class et extends Xe{constructor(e){super(e),this._childCommands=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return null!=t&&t.execute(e)}registerChildCommand(e){this._childCommands.push(e),e.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){return this._childCommands.find(e=>e.isEnabled)}}var tt=function(e,t){return function(i){return e(t(i))}},it=tt(Object.getPrototypeOf,Object),nt=Function.prototype,st=Object.prototype,ot=nt.toString,rt=st.hasOwnProperty,at=ot.call(Object);var lt=function(e){if(!fe(e)||"[object Object]"!=S(e))return!1;var t=it(e);if(null===t)return!0;var i=rt.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&ot.call(i)==at};var ct=function(){this.__data__=[],this.size=0};var ht=function(e,t){for(var i=e.length;i--;)if(G(e[i][0],t))return i;return-1},dt=Array.prototype.splice;var ut=function(e){var t=this.__data__,i=ht(t,e);return!(i<0)&&(i==t.length-1?t.pop():dt.call(t,i,1),--this.size,!0)};var mt=function(e){var t=this.__data__,i=ht(t,e);return i<0?void 0:t[i][1]};var ft=function(e){return ht(this.__data__,e)>-1};var gt=function(e,t){var i=this.__data__,n=ht(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function pt(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}pt.prototype.clear=ct,pt.prototype.delete=ut,pt.prototype.get=mt,pt.prototype.has=ft,pt.prototype.set=gt;var wt=pt;var bt=function(){this.__data__=new wt,this.size=0};var _t=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i};var vt=function(e){return this.__data__.get(e)};var yt=function(e){return this.__data__.has(e)},kt=$(_.a,"Map"),Ct=$(Object,"create");var At=function(){this.__data__=Ct?Ct(null):{},this.size=0};var xt=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Tt=Object.prototype.hasOwnProperty;var Pt=function(e){var t=this.__data__;if(Ct){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return Tt.call(t,e)?t[e]:void 0},Et=Object.prototype.hasOwnProperty;var St=function(e){var t=this.__data__;return Ct?void 0!==t[e]:Et.call(t,e)};var Rt=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ct&&void 0===t?"__lodash_hash_undefined__":t,this};function It(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}It.prototype.clear=At,It.prototype.delete=xt,It.prototype.get=Pt,It.prototype.has=St,It.prototype.set=Rt;var Vt=It;var Ot=function(){this.size=0,this.__data__={hash:new Vt,map:new(kt||wt),string:new Vt}};var Nt=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Mt=function(e,t){var i=e.__data__;return Nt(t)?i["string"==typeof t?"string":"hash"]:i.map};var Bt=function(e){var t=Mt(this,e).delete(e);return this.size-=t?1:0,t};var Ft=function(e){return Mt(this,e).get(e)};var Dt=function(e){return Mt(this,e).has(e)};var zt=function(e,t){var i=Mt(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function Lt(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}Lt.prototype.clear=Ot,Lt.prototype.delete=Bt,Lt.prototype.get=Ft,Lt.prototype.has=Dt,Lt.prototype.set=zt;var Ht=Lt;var jt=function(e,t){var i=this.__data__;if(i instanceof wt){var n=i.__data__;if(!kt||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new Ht(n)}return i.set(e,t),this.size=i.size,this};function Wt(e){var t=this.__data__=new wt(e);this.size=t.size}Wt.prototype.clear=bt,Wt.prototype.delete=_t,Wt.prototype.get=vt,Wt.prototype.has=yt,Wt.prototype.set=jt;var qt=Wt;var $t=function(e,t){for(var i=-1,n=null==e?0:e.length;++i<n&&!1!==t(e[i],i,e););return e},Ut=tt(Object.keys,Object),Kt=Object.prototype.hasOwnProperty;var Gt=function(e){if(!Ie(e))return Ut(e);var t=[];for(var i in Object(e))Kt.call(e,i)&&"constructor"!=i&&t.push(i);return t};var Jt=function(e){return le(e)?Se(e):Gt(e)};var Yt=function(e,t){return e&&Q(t,Jt(t),e)};var Qt=function(e,t){return e&&Q(t,Me(t),e)},Xt=i(7);var Zt=function(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i<n;)t[i]=e[i];return t};var ei=function(e,t){for(var i=-1,n=null==e?0:e.length,s=0,o=[];++i<n;){var r=e[i];t(r,i,e)&&(o[s++]=r)}return o};var ti=function(){return[]},ii=Object.prototype.propertyIsEnumerable,ni=Object.getOwnPropertySymbols,si=ni?function(e){return null==e?[]:(e=Object(e),ei(ni(e),(function(t){return ii.call(e,t)})))}:ti;var oi=function(e,t){return Q(e,si(e),t)};var ri=function(e,t){for(var i=-1,n=t.length,s=e.length;++i<n;)e[s+i]=t[i];return e},ai=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)ri(t,si(e)),e=it(e);return t}:ti;var li=function(e,t){return Q(e,ai(e),t)};var ci=function(e,t,i){var n=t(e);return ve(e)?n:ri(n,i(e))};var hi=function(e){return ci(e,Jt,si)};var di=function(e){return ci(e,Me,ai)},ui=$(_.a,"DataView"),mi=$(_.a,"Promise"),fi=$(_.a,"Set"),gi=$(_.a,"WeakMap"),pi=B(ui),wi=B(kt),bi=B(mi),_i=B(fi),vi=B(gi),yi=S;(ui&&"[object DataView]"!=yi(new ui(new ArrayBuffer(1)))||kt&&"[object Map]"!=yi(new kt)||mi&&"[object Promise]"!=yi(mi.resolve())||fi&&"[object Set]"!=yi(new fi)||gi&&"[object WeakMap]"!=yi(new gi))&&(yi=function(e){var t=S(e),i="[object Object]"==t?e.constructor:void 0,n=i?B(i):"";if(n)switch(n){case pi:return"[object DataView]";case wi:return"[object Map]";case bi:return"[object Promise]";case _i:return"[object Set]";case vi:return"[object WeakMap]"}return t});var ki=yi,Ci=Object.prototype.hasOwnProperty;var Ai=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&Ci.call(e,"index")&&(i.index=e.index,i.input=e.input),i},xi=_.a.Uint8Array;var Ti=function(e){var t=new e.constructor(e.byteLength);return new xi(t).set(new xi(e)),t};var Pi=function(e,t){var i=t?Ti(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)},Ei=/\w*$/;var Si=function(e){var t=new e.constructor(e.source,Ei.exec(e));return t.lastIndex=e.lastIndex,t},Ri=v?v.prototype:void 0,Ii=Ri?Ri.valueOf:void 0;var Vi=function(e){return Ii?Object(Ii.call(e)):{}};var Oi=function(e,t){var i=t?Ti(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)};var Ni=function(e,t,i){var n=e.constructor;switch(t){case"[object ArrayBuffer]":return Ti(e);case"[object Boolean]":case"[object Date]":return new n(+e);case"[object DataView]":return Pi(e,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Oi(e,i);case"[object Map]":return new n;case"[object Number]":case"[object String]":return new n(e);case"[object RegExp]":return Si(e);case"[object Set]":return new n;case"[object Symbol]":return Vi(e)}},Mi=Object.create,Bi=function(){function e(){}return function(t){if(!b(t))return{};if(Mi)return Mi(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}();var Fi=function(e){return"function"!=typeof e.constructor||Ie(e)?{}:Bi(it(e))};var Di=function(e){return fe(e)&&"[object Map]"==ki(e)},zi=xe.a&&xe.a.isMap,Li=zi?Ae(zi):Di;var Hi=function(e){return fe(e)&&"[object Set]"==ki(e)},ji=xe.a&&xe.a.isSet,Wi=ji?Ae(ji):Hi,qi={};qi["[object Arguments]"]=qi["[object Array]"]=qi["[object ArrayBuffer]"]=qi["[object DataView]"]=qi["[object Boolean]"]=qi["[object Date]"]=qi["[object Float32Array]"]=qi["[object Float64Array]"]=qi["[object Int8Array]"]=qi["[object Int16Array]"]=qi["[object Int32Array]"]=qi["[object Map]"]=qi["[object Number]"]=qi["[object Object]"]=qi["[object RegExp]"]=qi["[object Set]"]=qi["[object String]"]=qi["[object Symbol]"]=qi["[object Uint8Array]"]=qi["[object Uint8ClampedArray]"]=qi["[object Uint16Array]"]=qi["[object Uint32Array]"]=!0,qi["[object Error]"]=qi["[object Function]"]=qi["[object WeakMap]"]=!1;var $i=function e(t,i,n,s,o,r){var a,l=1&i,c=2&i,h=4&i;if(n&&(a=o?n(t,s,o,r):n(t)),void 0!==a)return a;if(!b(t))return t;var d=ve(t);if(d){if(a=Ai(t),!l)return Zt(t,a)}else{var u=ki(t),m="[object Function]"==u||"[object GeneratorFunction]"==u;if(Object(ye.a)(t))return Object(Xt.a)(t,l);if("[object Object]"==u||"[object Arguments]"==u||m&&!o){if(a=c||m?{}:Fi(t),!l)return c?li(t,Qt(a,t)):oi(t,Yt(a,t))}else{if(!qi[u])return o?t:{};a=Ni(t,u,l)}}r||(r=new qt);var f=r.get(t);if(f)return f;r.set(t,a),Wi(t)?t.forEach((function(s){a.add(e(s,i,n,s,t,r))})):Li(t)&&t.forEach((function(s,o){a.set(o,e(s,i,n,o,t,r))}));var g=d?void 0:(h?c?di:hi:c?Me:Jt)(t);return $t(g||t,(function(s,o){g&&(s=t[o=s]),Y(a,o,e(s,i,n,o,t,r))})),a};var Ui=function(e,t){return $i(e,5,t="function"==typeof t?t:void 0)};var Ki=function(e){return fe(e)&&1===e.nodeType&&!lt(e)};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gi{constructor(e,t){this._config={},t&&this.define(Ji(t)),e&&this._setObjectToTarget(this._config,e)}set(e,t){this._setToTarget(this._config,e,t)}define(e,t){this._setToTarget(this._config,e,t,!0)}get(e){return this._getFromSource(this._config,e)}*names(){for(const e of Object.keys(this._config))yield e}_setToTarget(e,t,i,n=!1){if(lt(t))return void this._setObjectToTarget(e,t,n);const s=t.split(".");t=s.pop();for(const t of s)lt(e[t])||(e[t]={}),e=e[t];if(lt(i))return lt(e[t])||(e[t]={}),e=e[t],void this._setObjectToTarget(e,i,n);n&&void 0!==e[t]||(e[t]=i)}_getFromSource(e,t){const i=t.split(".");t=i.pop();for(const t of i){if(!lt(e[t])){e=null;break}e=e[t]}return e?Ji(e[t]):void 0}_setObjectToTarget(e,t,i){Object.keys(t).forEach(n=>{this._setToTarget(e,n,t[n],i)})}}function Ji(e){return Ui(e,Yi)}function Yi(e){return Ki(e)?e:void 0}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Qi(e){return!(!e||!e[Symbol.iterator])}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xi{constructor(e={},t={}){const i=Qi(e);if(i||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],i)for(const t of e)this._items.push(t),this._itemMap.set(this._getItemIdBeforeAdding(t),t)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(void 0===t)t=this._items.length;else if(t>this._items.length||t<0)throw new l.a("collection-add-item-invalid-index",this);for(let i=0;i<e.length;i++){const n=e[i],s=this._getItemIdBeforeAdding(n),o=t+i;this._items.splice(o,0,n),this._itemMap.set(s,n),this.fire("add",n,o)}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if("string"==typeof e)t=this._itemMap.get(e);else{if("number"!=typeof e)throw new l.a("collection-get-invalid-arg",this);t=this._items[e]}return t||null}has(e){if("string"==typeof e)return this._itemMap.has(e);{const t=e[this._idProperty];return this._itemMap.has(t)}}getIndex(e){let t;return t="string"==typeof e?this._itemMap.get(e):e,this._items.indexOf(t)}remove(e){const[t,i]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:i}),t}map(e,t){return this._items.map(e,t)}find(e,t){return this._items.find(e,t)}filter(e,t){return this._items.filter(e,t)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const e=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:e,index:0})}bindTo(e){if(this._bindToCollection)throw new l.a("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:e=>{this._setUpBindToBinding(t=>new e(t))},using:e=>{"function"==typeof e?this._setUpBindToBinding(t=>e(t)):this._setUpBindToBinding(t=>t[e])}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(i,n,s)=>{const o=t._bindToCollection==this,r=t._bindToInternalToExternalMap.get(n);if(o&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(s);let o=s;for(const e of this._skippedIndexesFromExternal)s>e&&o--;for(const e of t._skippedIndexesFromExternal)o>=e&&o++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,o);for(let e=0;e<t._skippedIndexesFromExternal.length;e++)o<=t._skippedIndexesFromExternal[e]&&t._skippedIndexesFromExternal[e]++}};for(const e of t)i(0,e,t.getIndex(e));this.listenTo(t,"add",i),this.listenTo(t,"remove",(e,t,i)=>{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((e,t)=>(i<t&&e.push(t-1),i>t&&e.push(t),e),[])})}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],"string"!=typeof i)throw new l.a("collection-add-invalid-id",this);if(this.get(i))throw new l.a("collection-add-item-already-exists",this)}else e[t]=i=r();return i}_remove(e){let t,i,n,s=!1;const o=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),s=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],s=!n,n&&(i=n[o])):(n=e,i=n[o],t=this._items.indexOf(n),s=-1==t||!this._itemMap.get(i)),s)throw new l.a("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}Je(Xi,d);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Zi{constructor(e,t=[],i=[]){this._context=e,this._plugins=new Map,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new l.a("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const n=this,s=this._context;!function e(t,i=new Set){t.forEach(t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!n._availablePlugins.has(t.pluginName)&&n._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))})}(e),u(e);const o=[...function e(t,i=new Set){return t.map(e=>a(e)?e:n._availablePlugins.get(e)).reduce((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(u(n.requires,n),e(n.requires,i).forEach(e=>t.add(e))),t.add(n)),new Set)}(e.filter(e=>!h(e,t)))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new l.a("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new l.a("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new l.a("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=n._availablePlugins.get(t);if(!s)throw new l.a("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const o=e.indexOf(s);if(-1===o){if(n._contextPlugins.has(s))return;throw new l.a("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new l.a("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(o,1,i),n._availablePlugins.set(t,i)}}(o,i);const r=function(e){return e.map(e=>{const t=n._contextPlugins.get(e)||new e(s);return n._add(e,t),t})}(o);return m(r,"init").then(()=>m(r,"afterInit")).then(()=>r);function a(e){return"function"==typeof e}function c(e){return a(e)&&e.isContextPlugin}function h(e,t){return t.some(t=>t===e||(d(e)===t||d(t)===e))}function d(e){return a(e)?e.pluginName||e.name:e}function u(e,i=null){e.map(e=>a(e)?e:n._availablePlugins.get(e)||e).forEach(e=>{!function(e,t){if(a(e))return;if(t)throw new l.a("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:d(t)});throw new l.a("plugincollection-plugin-not-found",s,{plugin:e})}(e,i),function(e,t){if(!c(t))return;if(c(e))return;throw new l.a("plugincollection-context-required",s,{plugin:d(e),requiredBy:d(t)})}(e,i),function(e,i){if(!i)return;if(!h(e,t))return;throw new l.a("plugincollection-required",s,{plugin:d(e),requiredBy:d(i)})}(e,i)})}function m(e,t){return e.reduce((e,i)=>i[t]?n._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e,Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new l.a("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function en(e){return Array.isArray(e)?e:[e]}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function tn(e,t,i=1){if("number"!=typeof i)throw new l.a("translation-service-quantity-not-a-number",null,{quantity:i});const n=Object.keys(window.CKEDITOR_TRANSLATIONS).length;1===n&&(e=Object.keys(window.CKEDITOR_TRANSLATIONS)[0]);const s=t.id||t.string;if(0===n||!function(e,t){return!!window.CKEDITOR_TRANSLATIONS[e]&&!!window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,s))return 1!==i?t.plural:t.string;const o=window.CKEDITOR_TRANSLATIONS[e].dictionary,r=window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1);if("string"==typeof o[s])return o[s];const a=Number(r(i));return o[s][a]}Je(Zi,d),window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={});
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const nn=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function sn(e){return nn.includes(e)?"rtl":"ltr"}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class on{constructor(e={}){this.uiLanguage=e.uiLanguage||"en",this.contentLanguage=e.contentLanguage||this.uiLanguage,this.uiLanguageDirection=sn(this.uiLanguage),this.contentLanguageDirection=sn(this.contentLanguage),this.t=(e,t)=>this._t(e,t)}get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=en(t),"string"==typeof e&&(e={string:e});const i=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,(e,i)=>i<t.length?t[i]:e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(tn(this.uiLanguage,e,i),t)}}class rn{constructor(e){this.config=new Gi(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new Zi(this,t);const i=this.config.get("language")||{};this.locale=new on({uiLanguage:"string"==typeof i?i:i.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new Xi,this._contextOwner=null}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new l.a("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new l.a("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,e=>e.destroy())).then(()=>this.plugins.destroy())}_addEditor(e,t){if(this._contextOwner)throw new l.a("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise(t=>{const i=new this(e);t(i.initPlugins().then(()=>i))})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class an{constructor(e){this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function ln(e,t){const i=Math.min(e.length,t.length);for(let n=0;n<i;n++)if(e[n]!=t[n])return n;return e.length==t.length?"same":e.length<t.length?"prefix":"extension"}Je(an,We);var cn=function(e){return $i(e,4)};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hn{constructor(e){this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new l.a("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=ln(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&(this.root===e.root&&!this.isBefore(e))}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t){this.fire("change:"+e,t),this.parent&&this.parent._fireChange(e,t)}toJSON(){const e=cn(this);return delete e.parent,e}is(e){return"node"===e||"view:node"===e}}Je(hn,d);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class dn extends hn{constructor(e,t){super(e),this._textData=t}is(e){return"$text"===e||"view:$text"===e||"text"===e||"view:text"===e||"node"===e||"view:node"===e}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(e){return e instanceof dn&&(this===e||this.data===e.data)}_clone(){return new dn(this.document,this.data)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class un{constructor(e,t,i){if(this.textNode=e,t<0||t>e.data.length)throw new l.a("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new l.a("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}is(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function mn(e){return Qi(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fn{constructor(...e){this._patterns=[],this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),t.classes&&("string"==typeof t.classes||t.classes instanceof RegExp)&&(t.classes=[t.classes]),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=gn(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=gn(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}}function gn(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){if(e instanceof RegExp)return e.test(t);return e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=[];for(const n in e){const s=e[n];if(!t.hasAttribute(n))return null;{const e=t.getAttribute(n);if(!0===s)i.push(n);else if(s instanceof RegExp){if(!s.test(e))return null;i.push(n)}else{if(e!==s)return null;i.push(n)}}}return i}(t.attributes,e),!i.attributes)?null:!(t.classes&&(i.classes=function(e,t){const i=[];for(const n of e)if(n instanceof RegExp){const e=t.getClassNames();for(const t of e)n.test(t)&&i.push(t);if(0===i.length)return null}else{if(!t.hasClass(n))return null;i.push(n)}return i}(t.classes,e),!i.classes))&&(!(t.styles&&(i.styles=function(e,t){const i=[];for(const n in e){const s=e[n];if(!t.hasStyle(n))return null;{const e=t.getStyle(n);if(s instanceof RegExp){if(!s.test(e))return null;i.push(n)}else{if(e!==s)return null;i.push(n)}}}return i}(t.styles,e),!i.styles))&&i)}var pn=function(e){return"symbol"==typeof e||fe(e)&&"[object Symbol]"==S(e)},wn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bn=/^\w*$/;var _n=function(e,t){if(ve(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!pn(e))||(bn.test(e)||!wn.test(e)||null!=t&&e in Object(t))};function vn(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var i=function(){var n=arguments,s=t?t.apply(this,n):n[0],o=i.cache;if(o.has(s))return o.get(s);var r=e.apply(this,n);return i.cache=o.set(s,r)||o,r};return i.cache=new(vn.Cache||Ht),i}vn.Cache=Ht;var yn=vn;var kn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Cn=/\\(\\)?/g,An=function(e){var t=yn(e,(function(e){return 500===i.size&&i.clear(),e})),i=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(kn,(function(e,i,n,s){t.push(n?s.replace(Cn,"$1"):i||e)})),t}));var xn=function(e,t){for(var i=-1,n=null==e?0:e.length,s=Array(n);++i<n;)s[i]=t(e[i],i,e);return s},Tn=v?v.prototype:void 0,Pn=Tn?Tn.toString:void 0;var En=function e(t){if("string"==typeof t)return t;if(ve(t))return xn(t,e)+"";if(pn(t))return Pn?Pn.call(t):"";var i=t+"";return"0"==i&&1/t==-1/0?"-0":i};var Sn=function(e){return null==e?"":En(e)};var Rn=function(e,t){return ve(e)?e:_n(e,t)?[e]:An(Sn(e))};var In=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var Vn=function(e){if("string"==typeof e||pn(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var On=function(e,t){for(var i=0,n=(t=Rn(t,e)).length;null!=e&&i<n;)e=e[Vn(t[i++])];return i&&i==n?e:void 0};var Nn=function(e,t,i){var n=-1,s=e.length;t<0&&(t=-t>s?0:s+t),(i=i>s?s:i)<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var o=Array(s);++n<s;)o[n]=e[n+t];return o};var Mn=function(e,t){return t.length<2?e:On(e,Nn(t,0,-1))};var Bn=function(e,t){return t=Rn(t,e),null==(e=Mn(e,t))||delete e[Vn(In(t))]};var Fn=function(e,t){return null==e||Bn(e,t)};var Dn=function(e,t,i){var n=null==e?void 0:On(e,t);return void 0===n?i:n};var zn=function(e,t,i){(void 0!==i&&!G(e[t],i)||void 0===i&&!(t in e))&&K(e,t,i)};var Ln=function(e){return function(t,i,n){for(var s=-1,o=Object(t),r=n(t),a=r.length;a--;){var l=r[e?a:++s];if(!1===i(o[l],l,o))break}return t}}();var Hn=function(e){return fe(e)&&le(e)};var jn=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var Wn=function(e){return Q(e,Me(e))};var qn=function(e,t,i,n,s,o,r){var a=jn(e,i),l=jn(t,i),c=r.get(l);if(c)zn(e,i,c);else{var h=o?o(a,l,i+"",e,t,r):void 0,d=void 0===h;if(d){var u=ve(l),m=!u&&Object(ye.a)(l),f=!u&&!m&&Pe(l);h=l,u||m||f?ve(a)?h=a:Hn(a)?h=Zt(a):m?(d=!1,h=Object(Xt.a)(l,!0)):f?(d=!1,h=Oi(l,!0)):h=[]:lt(l)||_e(l)?(h=a,_e(a)?h=Wn(a):b(a)&&!I(a)||(h=Fi(l))):d=!1}d&&(r.set(l,h),s(h,l,n,o,r),r.delete(l)),zn(e,i,h)}};var $n=function e(t,i,n,s,o){t!==i&&Ln(i,(function(r,a){if(o||(o=new qt),b(r))qn(t,i,a,n,e,s,o);else{var l=s?s(jn(t,a),r,a+"",t,i,o):void 0;void 0===l&&(l=r),zn(t,a,l)}}),Me)},Un=ue((function(e,t,i){$n(e,t,i)}));var Kn=function(e,t,i,n){if(!b(e))return e;for(var s=-1,o=(t=Rn(t,e)).length,r=o-1,a=e;null!=a&&++s<o;){var l=Vn(t[s]),c=i;if("__proto__"===l||"constructor"===l||"prototype"===l)return e;if(s!=r){var h=a[l];void 0===(c=n?n(h,l,a):void 0)&&(c=b(h)?h:he(t[s+1])?[]:{})}Y(a,l,c),a=a[l]}return e};var Gn=function(e,t,i){return null==e?e:Kn(e,t,i)};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jn{constructor(e){this._styles={},this._styleProcessor=e}get isEmpty(){const e=Object.entries(this._styles);return!Array.from(e).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=Array.from(function(e){let t=null,i=0,n=0,s=null;const o=new Map;if(""===e)return o;";"!=e.charAt(e.length-1)&&(e+=";");for(let r=0;r<e.length;r++){const a=e.charAt(r);if(null===t)switch(a){case":":s||(s=e.substr(i,r-i),n=r+1);break;case'"':case"'":t=a;break;case";":{const t=e.substr(n,r-n);s&&o.set(s.trim(),t.trim()),s=null,i=r+1;break}}else a===t&&(t=null)}return o}(e).entries());for(const[e,i]of t)this._styleProcessor.toNormalizedForm(e,i,this._styles)}has(e){if(this.isEmpty)return!1;const t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);return Array.isArray(t)}set(e,t){if(b(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=Qn(e);Fn(this._styles,t),delete this._styles[e],this._cleanEmptyObjectsOnPath(t)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this._getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!b(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);return Array.isArray(t)?t[1]:void 0}getStyleNames(){if(this.isEmpty)return[];return this._getStylesEntries().map(([e])=>e)}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=Dn(this._styles,i);if(!n)return;!Array.from(Object.keys(n)).length&&this.remove(i)}}class Yn{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(b(t))Xn(i,Qn(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:s,value:o}=n(t);Xn(i,s,o)}else Xn(i,e,t)}getNormalized(e,t){if(!e)return Un({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return Dn(t,i);const n=i(e,t);if(n)return n}return Dn(t,Qn(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);if(void 0===i)return[];if(this._reducers.has(e)){return this._reducers.get(e)(i)}return[[e,i]]}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function Qn(e){return e.replace("-",".")}function Xn(e,t,i){let n=i;b(i)&&(n=Un({},Dn(e,t),i)),Gn(e,t,n)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zn extends hn{constructor(e,t,i,n){if(super(e),this.name=t,this._attrs=function(e){e=mn(e);for(const[t,i]of e)null===i?e.delete(t):"string"!=typeof i&&e.set(t,String(i));return e}(i),this._children=[],n&&this._insertChild(0,n),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");es(this._classes,e),this._attrs.delete("class")}this._styles=new Jn(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._isAllowedInsideAttributeElement=!1}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}get isAllowedInsideAttributeElement(){return this._isAllowedInsideAttributeElement}is(e,t=null){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if("class"==e)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==e){const e=this._styles.toString();return""==e?void 0:e}return this._attrs.get(e)}hasAttribute(e){return"class"==e?this._classes.size>0:"style"==e?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(e){if(!(e instanceof Zn))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this.isAllowedInsideAttributeElement!=e.isAllowedInsideAttributeElement)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(){return this._styles.getStyleNames()}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new fn(...e);let i=this.parent;for(;i;){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).map(e=>`${e[0]}="${e[1]}"`).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":" "+i)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._isAllowedInsideAttributeElement=this.isAllowedInsideAttributeElement,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new dn(e,t)];Qi(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new dn(e,t):t instanceof un?new dn(e,t.data):t)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_setAttribute(e,t){t=String(t),this._fireChange("attributes",this),"class"==e?es(this._classes,t):"style"==e?this._styles.setTo(t):this._attrs.set(e,t)}_removeAttribute(e){return this._fireChange("attributes",this),"class"==e?this._classes.size>0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of en(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of en(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of en(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function es(e,t){const i=t.split(/\s+/);e.clear(),i.forEach(t=>e.add(t))}class ts extends Zn{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=is}is(e,t=null){return t?t===this.name&&("containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e}}function is(){const e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const t of e)if(!t.is("uiElement"))return null;return this.childCount}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ns extends ts{constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",t=>t&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}is(e,t=null){return t?t===this.name&&("editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e}destroy(){this.stopListening()}}Je(ns,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const ss=Symbol("rootName");class os extends ns{constructor(e,t){super(e,t),this.rootName="main"}is(e,t=null){return t?t===this.name&&("rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e}get rootName(){return this.getCustomProperty(ss)}set rootName(e){this._setCustomProperty(ss,e)}set _name(e){this.name=e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rs{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new l.a("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new l.a("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this.position=as._createAt(e.startPosition):this.position=as._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}skip(e){let t,i,n;do{n=this.position,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this.position=n)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0};let n;if(i instanceof dn){if(e.isAtEnd)return this.position=as._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof Zn)return this.shallow?e.offset++:e=new as(n,0),this.position=e,this._formatReturnValue("elementStart",n,t,e,1);if(n instanceof dn){if(this.singleCharacters)return e=new as(n,0),this.position=e,this._next();{let i,s=n.data.length;return n==this._boundaryEndParent?(s=this.boundaries.end.offset,i=new un(n,0,s),e=as._createAfter(i)):(i=new un(n,0,n.data.length),e.offset++),this.position=e,this._formatReturnValue("text",i,t,e,s)}}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{n=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset}const s=new un(i,e.offset,n);return e.offset+=n,this.position=e,this._formatReturnValue("text",s,t,e,n)}return e=as._createAfter(i),this.position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0};let n;if(i instanceof dn){if(e.isAtStart)return this.position=as._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof Zn)return this.shallow?(e.offset--,this.position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new as(n,n.childCount),this.position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof dn){if(this.singleCharacters)return e=new as(n,n.data.length),this.position=e,this._previous();{let i,s=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new un(n,t,n.data.length-t),s=i.data.length,e=as._createBefore(i)}else i=new un(n,0,n.data.length),e.offset--;return this.position=e,this._formatReturnValue("text",i,t,e,s)}}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const s=new un(i,e.offset,n);return this.position=e,this._formatReturnValue("text",s,t,e,n)}return e=as._createBefore(i),this.position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,s){return t instanceof un&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=as._createAfter(t.textNode):(n=as._createAfter(t.textNode),this.position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=as._createBefore(t.textNode):(n=as._createBefore(t.textNode),this.position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class as{constructor(e,t){this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return 0===this.offset}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof ns);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=as._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new rs(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}is(e){return"position"===e||"view:position"===e}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const n=ln(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]<i[n]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new rs(e)}clone(){return new as(this.parent,this.offset)}static _createAt(e,t){if(e instanceof as)return new this(e.parent,e.offset);{const i=e;if("end"==t)t=i.is("$text")?i.data.length:i.childCount;else{if("before"==t)return this._createBefore(i);if("after"==t)return this._createAfter(i);if(0!==t&&!t)throw new l.a("view-createpositionat-offset-required",i)}return new as(i,t)}}static _createAfter(e){if(e.is("$textProxy"))return new as(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new l.a("view-position-after-root",e,{root:e});return new as(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new as(e.textNode,e.offsetInText);if(!e.parent)throw new l.a("view-position-before-root",e,{root:e});return new as(e.parent,e.index)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ls{constructor(e,t=null){this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new rs({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let e=this.start.getLastMatchingPosition(cs,{direction:"backward"}),t=this.end.getLastMatchingPosition(cs);return e.parent.is("$text")&&e.isAtStart&&(e=as._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=as._createAfter(t.parent)),new ls(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(cs);if(e.isAfter(this.end)||e.isEqual(this.end))return new ls(e,e);let t=this.end.getLastMatchingPosition(cs,{direction:"backward"});const i=e.nodeAfter,n=t.nodeBefore;return i&&i.is("$text")&&(e=new as(i,0)),n&&n.is("$text")&&(t=new as(n,n.data.length)),new ls(e,t)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),n=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&n}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new ls(this.start,e.start)),this.containsPosition(e.end)&&t.push(new ls(e.end,this.end))):t.push(this.clone()),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new ls(t,i)}return null}getWalker(e={}){return e.boundaries=this,new rs(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(t=this.end.parent.previousSibling),e&&e.is("element")&&e===t?e:null}clone(){return new ls(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new rs(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new rs(e);yield t.position;for(const e of t)yield e.nextPosition}is(e){return"range"===e||"view:range"===e}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}static _createFromParentsAndOffsets(e,t,i,n){return new this(new as(e,t),new as(i,n))}static _createFromPositionAndShift(e,t){const i=e,n=e.getShiftedBy(t);return t>0?new this(i,n):new this(n,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(as._createBefore(e),t)}}function cs(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function hs(e){let t=0;for(const i of e)t++;return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ds{constructor(e=null,t,i){this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",this.setTo(e,t,i)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=hs(this.getRanges());if(t!=hs(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(e,t,i){if(null===e)this._setRanges([]),this._setFakeOptions(t);else if(e instanceof ds||e instanceof us)this._setRanges(e.getRanges(),e.isBackward),this._setFakeOptions({fake:e.isFake,label:e.fakeSelectionLabel});else if(e instanceof ls)this._setRanges([e],t&&t.backward),this._setFakeOptions(t);else if(e instanceof as)this._setRanges([new ls(e)]),this._setFakeOptions(t);else if(e instanceof hn){const n=!!i&&!!i.backward;let s;if(void 0===t)throw new l.a("view-selection-setto-required-second-parameter",this);s="in"==t?ls._createIn(e):"on"==t?ls._createOn(e):new ls(as._createAt(e,t)),this._setRanges([s],n),this._setFakeOptions(i)}else{if(!Qi(e))throw new l.a("view-selection-setto-not-selectable",this);this._setRanges(e,t&&t.backward),this._setFakeOptions(t)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new l.a("view-selection-setfocus-no-ranges",this);const i=as._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new ls(i,n),!0):this._addRange(new ls(n,i)),this.fire("change")}is(e){return"selection"===e||"view:selection"===e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof ls))throw new l.a("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new l.a("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new ls(e.start,e.end))}}Je(ds,d);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class us{constructor(e=null,t,i){this._selection=new ds,this._selection.delegate("change").to(this),this._selection.setTo(e,t,i)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}is(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e}_setTo(e,t,i){this._selection.setTo(e,t,i)}_setFocus(e,t){this._selection.setFocus(e,t)}}Je(us,d);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ms extends s{constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const fs=Symbol("bubbling contexts");var gs={fire(e,...t){try{const i=e instanceof s?e:new s(this,e),n=_s(this);if(!n.size)return;if(ps(i,"capturing",this),ws(n,"$capture",i,...t))return i.return;const o=i.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,a=!!r&&Boolean(bs(n,r));let l=r||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),s=i.getPath();return n.length>s.length?t:i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(o);if(ps(i,"atTarget",l),!a){if(ws(n,"$text",i,...t))return i.return;ps(i,"bubbling",l)}for(;l;){if(l.is("rootElement")){if(ws(n,"$root",i,...t))return i.return}else if(l.is("element")&&ws(n,l.name,i,...t))return i.return;if(ws(n,l,i,...t))return i.return;l=l.parent,ps(i,"bubbling",l)}return ps(i,"bubbling",this),ws(n,"$document",i,...t),i.return}catch(e){l.a.rethrowUnexpectedError(e,this)}},_addEventListener(e,t,i){const n=en(i.context||"$document"),s=_s(this);for(const o of n){let n=s.get(o);n||(n=Object.create(d),s.set(o,n)),this.listenTo(n,e,t,i)}},_removeEventListener(e,t){const i=_s(this);for(const n of i.values())this.stopListening(n,e,t)}};function ps(e,t,i){e instanceof ms&&(e._eventPhase=t,e._currentTarget=i)}function ws(e,t,i,...n){const s="string"==typeof t?e.get(t):bs(e,t);return!!s&&(s.fire(i,...n),i.stop.called)}function bs(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function _s(e){return e[fs]||(e[fs]=new Map),e[fs]}class vs{constructor(e){this.selection=new us,this.roots=new Xi({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}}Je(vs,gs),Je(vs,We);class ys extends Zn{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ks,this._priority=10,this._id=null,this._clonesGroup=null}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new l.a("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}is(e,t=null){return t?t===this.name&&("attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e):"attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}}function ks(){if(Cs(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(Cs(e)>1)return null;e=e.parent}return!e||Cs(e)>1?null:this.childCount}function Cs(e){return Array.from(e.getChildren()).filter(e=>!e.is("uiElement")).length}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */ys.DEFAULT_PRIORITY=10;class As extends Zn{constructor(e,t,i,n){super(e,t,i,n),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=xs}is(e,t=null){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e}_insertChild(e,t){if(t&&(t instanceof hn||Array.from(t).length>0))throw new l.a("view-emptyelement-cannot-add",[this,t])}}function xs(){return null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ts=navigator.userAgent.toLowerCase();var Ps={isMac:function(e){return e.indexOf("macintosh")>-1}(Ts),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(Ts),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(Ts),isAndroid:function(e){return e.indexOf("android")>-1}(Ts),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(Ts),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */()}};const Es={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},Ss={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},Rs=function(){const e={arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){const i=String.fromCharCode(t);e[i.toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return e}(),Is=Object.fromEntries(Object.entries(Rs).map(([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)]));function Vs(e){let t;if("string"==typeof e){if(t=Rs[e.toLowerCase()],!t)throw new l.a("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?Rs.alt:0)+(e.ctrlKey?Rs.ctrl:0)+(e.shiftKey?Rs.shift:0)+(e.metaKey?Rs.cmd:0);return t}function Os(e){return"string"==typeof e&&(e=function(e){return e.split("+").map(e=>e.trim())}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e)),e.map(e=>"string"==typeof e?function(e){if(e.endsWith("!"))return Vs(e.slice(0,-1));const t=Vs(e);return Ps.isMac&&t==Rs.ctrl?Rs.cmd:t}(e):e).reduce((e,t)=>t+e,0)}function Ns(e){let t=Os(e);return Object.entries(Ps.isMac?Es:Ss).reduce((e,[i,n])=>(0!=(t&Rs[i])&&(t&=~Rs[i],e+=n),e),"")+(t?Is[t]:"")}function Ms(e,t){const i="ltr"===t;switch(e){case Rs.arrowleft:return i?"left":"right";case Rs.arrowright:return i?"right":"left";case Rs.arrowup:return"up";case Rs.arrowdown:return"down"}}function Bs(e,t){const i=Ms(e,t);return"down"===i||"right"===i}class Fs extends Zn{constructor(e,t,i,n){super(e,t,i,n),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=zs}is(e,t=null){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e}_insertChild(e,t){if(t&&(t instanceof hn||Array.from(t).length>0))throw new l.a("view-uielement-cannot-add",this)}render(e){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}}function Ds(e){e.document.on("arrowKey",(t,i)=>function(e,t,i){if(t.keyCode==Rs.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,s=e.focusOffset,o=i.domPositionToView(t,s);if(null===o)return;let r=!1;const a=o.getLastMatchingPosition(e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement"))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(0,i,e.domConverter),{priority:"low"})}function zs(){return null}class Ls extends Zn{constructor(e,t,i,n){super(e,t,i,n),this._isAllowedInsideAttributeElement=!0,this.getFillerOffset=Hs}is(e,t=null){return t?t===this.name&&("rawElement"===e||"view:rawElement"===e||"element"===e||"view:element"===e):"rawElement"===e||"view:rawElement"===e||e===this.name||e==="view:"+this.name||"element"===e||"view:element"===e||"node"===e||"view:node"===e}_insertChild(e,t){if(t&&(t instanceof hn||Array.from(t).length>0))throw new l.a("view-rawelement-cannot-add",[this,t])}}function Hs(){return null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class js{constructor(e,t){this.document=e,this._children=[],t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}is(e){return"documentFragment"===e||"view:documentFragment"===e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){if("string"==typeof t)return[new dn(e,t)];Qi(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new dn(e,t):t instanceof un?new dn(e,t.data):t)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_fireChange(e,t){this.fire("change:"+e,t)}}Je(js,d);class Ws{constructor(e){this.document=e,this._cloneGroups=new Map}setSelection(e,t,i){this.document.selection._setTo(e,t,i)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new js(this.document,e)}createText(e){return new dn(this.document,e)}createAttributeElement(e,t,i={}){const n=new ys(this.document,e,t);return i.priority&&(n._priority=i.priority),i.id&&(n._id=i.id),n}createContainerElement(e,t,i={}){const n=new ts(this.document,e,t);return void 0!==i.isAllowedInsideAttributeElement&&(n._isAllowedInsideAttributeElement=i.isAllowedInsideAttributeElement),n}createEditableElement(e,t){const i=new ns(this.document,e,t);return i._document=this.document,i}createEmptyElement(e,t,i={}){const n=new As(this.document,e,t);return void 0!==i.isAllowedInsideAttributeElement&&(n._isAllowedInsideAttributeElement=i.isAllowedInsideAttributeElement),n}createUIElement(e,t,i,n={}){const s=new Fs(this.document,e,t);return i&&(s.render=i),void 0!==n.isAllowedInsideAttributeElement&&(s._isAllowedInsideAttributeElement=n.isAllowedInsideAttributeElement),s}createRawElement(e,t,i,n={}){const s=new Ls(this.document,e,t);return s.render=i||(()=>{}),void 0!==n.isAllowedInsideAttributeElement&&(s._isAllowedInsideAttributeElement=n.isAllowedInsideAttributeElement),s}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){lt(e)&&void 0===i&&(i=t),i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof as?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new l.a("view-writer-break-non-container-element",this.document);if(!t.parent)throw new l.a("view-writer-break-root",this.document);if(e.isAtStart)return as._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(as._createAfter(t),i);const n=new ls(e,as._createAt(t,"end")),s=new as(i,0);this.move(n,s)}return as._createAfter(t)}mergeAttributes(e){const t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&0===i.childCount){const e=i.parent,t=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new as(e,t))}const n=i.getChild(t-1),s=i.getChild(t);if(!n||!s)return e;if(n.is("$text")&&s.is("$text"))return Gs(n,s);if(n.is("attributeElement")&&s.is("attributeElement")&&n.isSimilar(s)){const e=n.childCount;return n._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new as(n,e))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!(t&&i&&t.is("containerElement")&&i.is("containerElement")))throw new l.a("view-writer-merge-containers-invalid-position",this.document);const n=t.getChild(t.childCount-1),s=n instanceof dn?as._createAt(n,"end"):as._createAt(t,"end");return this.move(ls._createIn(i),as._createAt(t,"end")),this.remove(ls._createOn(i)),s}insert(e,t){(function e(t,i){for(const n of t){if(!Js.some(e=>n instanceof e))throw new l.a("view-writer-insert-invalid-node-type",i);n.is("$text")||e(n.getChildren(),i)}})(t=Qi(t)?[...t]:[t],this.document);const i=t.reduce((e,t)=>{const i=e[e.length-1],n=!(t.is("uiElement")&&t.isAllowedInsideAttributeElement);return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e},[]);let n=null,s=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(s,e,t);n||(n=i.start),s=i.end}return n?new ls(n,s):new ls(e)}remove(e){const t=e instanceof ls?e:ls._createOn(e);if(Qs(t,this.document),t.isCollapsed)return new js(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),s=i.parent,o=n.offset-i.offset,r=s._removeChildren(i.offset,o);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new js(this.document,r)}clear(e,t){Qs(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let s;if(i.is("element")&&t.isSimilar(i))s=ls._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find(e=>e.is("element")&&t.isSimilar(e));e&&(s=ls._createIn(e))}s&&(s.end.isAfter(e.end)&&(s.end=e.end),s.start.isBefore(e.start)&&(s.start=e.start),this.remove(s))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,s=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-s}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof ys))throw new l.a("view-writer-wrap-invalid-attribute",this.document);if(Qs(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some(e=>!e.is("uiElement")))&&(n=n.getLastMatchingPosition(e=>e.item.is("uiElement"))),n=this._wrapPosition(n,t);const s=this.document.selection;return s.isCollapsed&&s.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new ls(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof ys))throw new l.a("view-writer-unwrap-invalid-attribute",this.document);if(Qs(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._unwrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new ls(r,a)}rename(e,t){const i=new ts(this.document,e,t.getAttributes());return this.insert(as._createAfter(t),i),this.move(ls._createIn(t),as._createAt(i,0)),this.remove(ls._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return as._createAt(e,t)}createPositionAfter(e){return as._createAfter(e)}createPositionBefore(e){return as._createBefore(e)}createRange(e,t){return new ls(e,t)}createRangeOn(e){return ls._createOn(e)}createRangeIn(e){return ls._createIn(e)}createSelection(e,t,i){return new ds(e,t,i)}_insertNodes(e,t,i){let n,s;if(n=i?qs(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new l.a("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?Ks(e):e;const o=n._insertChild(s.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=s.getShiftedBy(o),a=this.mergeAttributes(s);a.isEqual(s)||r.offset--;const c=this.mergeAttributes(r);return new ls(a,c)}_wrapChildren(e,t,i,n){let s=t;const o=[];for(;s<i;){const t=e.getChild(s),i=t.is("$text"),r=t.is("attributeElement"),a=t.isAllowedInsideAttributeElement;if(r&&this._wrapAttributeElement(n,t))o.push(new as(e,s));else if(i||a||r&&$s(n,t)){const i=n._clone();t._remove(),i._appendChild(t),e._insertChild(s,i),this._addToClonedElementsGroup(i),o.push(new as(e,s))}else r&&this._wrapChildren(t,0,t.childCount,n);s++}let r=0;for(const e of o){if(e.offset-=r,e.offset==t)continue;this.mergeAttributes(e).isEqual(e)||(r++,i--)}return ls._createFromParentsAndOffsets(e,t,e,i)}_unwrapChildren(e,t,i,n){let s=t;const o=[];for(;s<i;){const t=e.getChild(s);if(t.is("attributeElement"))if(t.isSimilar(n)){const n=t.getChildren(),r=t.childCount;t._remove(),e._insertChild(s,n),this._removeFromClonedElementsGroup(t),o.push(new as(e,s),new as(e,s+r)),s+=r,i+=r-1}else this._unwrapAttributeElement(n,t)?(o.push(new as(e,s),new as(e,s+1)),s++):(this._unwrapChildren(t,0,t.childCount,n),s++);else s++}let r=0;for(const e of o){if(e.offset-=r,e.offset==t||e.offset==i)continue;this.mergeAttributes(e).isEqual(e)||(r++,i--)}return ls._createFromParentsAndOffsets(e,t,e,i)}_wrapRange(e,t){const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._wrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new ls(r,a)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return Us(e.clone());e.parent.is("$text")&&(e=Ks(e));const i=this.createAttributeElement();i._priority=Number.POSITIVE_INFINITY,i.isSimilar=()=>!1,e.parent._insertChild(e.offset,i);const n=new ls(e,e.getShiftedBy(1));this.wrap(n,t);const s=new as(i.parent,i.index);i._remove();const o=s.nodeBefore,r=s.nodeAfter;return o instanceof dn&&r instanceof dn?Gs(o,r):Us(s)}_wrapAttributeElement(e,t){if(!Xs(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!Xs(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(Qs(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new ls(i,i)}const s=this._breakAttributes(n,t),o=s.parent.childCount,r=this._breakAttributes(i,t);return s.offset+=s.parent.childCount-o,new ls(r,s)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new l.a("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new l.a("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new l.a("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&Ys(n.parent))return e.clone();if(Ys(n))return e.clone();if(n.is("$text"))return this._breakAttributes(Ks(e),t);if(i==n.childCount){const e=new as(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new as(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,s=n._clone();n.parent._insertChild(e,s),this._addToClonedElementsGroup(s);const o=n.childCount-i,r=n._removeChildren(i,o);s._appendChild(r);const a=new as(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function qs(e){let t=e.parent;for(;!Ys(t);){if(!t)return;t=t.parent}return t}function $s(e,t){return e.priority<t.priority||!(e.priority>t.priority)&&e.getIdentity()<t.getIdentity()}function Us(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new as(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new as(i,0):e}function Ks(e){if(e.offset==e.parent.data.length)return new as(e.parent.parent,e.parent.index+1);if(0===e.offset)return new as(e.parent.parent,e.parent.index);const t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new dn(e.root.document,t)),new as(e.parent.parent,e.parent.index+1)}function Gs(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new as(e,i)}const Js=[dn,ys,ts,As,Ls,Fs];function Ys(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function Qs(e,t){const i=qs(e.start),n=qs(e.end);if(!i||!n||i!==n)throw new l.a("view-writer-invalid-range-container",t)}function Xs(e,t){return null===e.id&&null===t.id}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Zs(e){return"[object Text]"==Object.prototype.toString.call(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const eo=e=>e.createTextNode(" "),to=e=>{const t=e.createElement("span");return t.dataset.ckeFiller=!0,t.innerHTML=" ",t},io=e=>{const t=e.createElement("br");return t.dataset.ckeFiller=!0,t},no="⁠".repeat(7);function so(e){return Zs(e)&&e.data.substr(0,7)===no}function oo(e){return 7==e.data.length&&so(e)}function ro(e){return so(e)?e.data.slice(7):e.data}function ao(e,t){if(t.keyCode==Rs.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;so(t)&&i<=7&&e.collapse(t,0)}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function lo(e,t,i,n=!1){i=i||function(e,t){return e===t},Array.isArray(e)||(e=Array.prototype.slice.call(e)),Array.isArray(t)||(t=Array.prototype.slice.call(t));const s=function(e,t,i){const n=co(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=ho(e,n),o=ho(t,n),r=co(s,o,i),a=e.length-r,l=t.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(e,t,i);return n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:s}=e;if(-1===i)return Array(t).fill("equal");let o=[];i>0&&(o=o.concat(Array(i).fill("equal")));s-i>0&&(o=o.concat(Array(s-i).fill("insert")));n-i>0&&(o=o.concat(Array(n-i).fill("delete")));s<t&&(o=o.concat(Array(t-s).fill("equal")));return o}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(s,t.length):function(e,t){const i=[],{firstIndex:n,lastIndexOld:s,lastIndexNew:o}=t;o-n>0&&i.push({index:n,type:"insert",values:e.slice(n,o)});s-n>0&&i.push({index:n+(o-n),type:"delete",howMany:s-n});return i}(t,s)}function co(e,t,i){for(let n=0;n<Math.max(e.length,t.length);n++)if(void 0===e[n]||void 0===t[n]||!i(e[n],t[n]))return n;return-1}function ho(e,t){return e.slice(t).reverse()}function uo(e,t,i){i=i||function(e,t){return e===t};const n=e.length,s=t.length;if(n>200||s>200||n+s>300)return uo.fastDiff(e,t,i,!0);let o,r;if(s<n){const i=e;e=t,t=i,o="delete",r="insert"}else o="insert",r="delete";const a=e.length,l=t.length,c=l-a,h={},d={};function u(n){const s=(void 0!==d[n-1]?d[n-1]:-1)+1,c=void 0!==d[n+1]?d[n+1]:-1,u=s>c?-1:1;h[n+u]&&(h[n]=h[n+u].slice(0)),h[n]||(h[n]=[]),h[n].push(s>c?o:r);let m=Math.max(s,c),f=m-n;for(;f<a&&m<l&&i(e[f],t[m]);)f++,m++,h[n].push("equal");return m}let m,f=0;do{for(m=-f;m<c;m++)d[m]=u(m);for(m=c+f;m>c;m--)d[m]=u(m);d[c]=u(c),f++}while(d[c]!==l);return h[c].slice(1)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function mo(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function fo(e){const t=e.parentNode;t&&t.removeChild(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function go(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */uo.fastDiff=lo;class po{constructor(e,t){this.domDocuments=new Set,this.domConverter=e,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=t,this.isFocused=!1,this._inlineFiller=null,this._fakeSelectionContainer=null}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new l.a("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){let e;for(const e of this.markedChildren)this._updateChildrenMappings(e);this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;so(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=wo(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=this.domConverter.mapViewToDom(e).childNodes,n=Array.from(this.domConverter.viewChildrenToDom(e,t.ownerDocument,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findReplaceActions(s,i,n);if(-1!==o.indexOf("replace")){const t={equal:0,insert:0,delete:0};for(const s of o)if("replace"===s){const s=t.equal+t.insert,o=t.equal+t.delete,r=e.getChild(s);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,i[o]),fo(n[s]),t.equal++}else t[s]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?as._createBefore(this.selection.getFirstPosition().parent):e}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&Zs(t.parent)&&so(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!so(e))throw new l.a("view-renderer-filler-was-lost",this);oo(e)?e.parentNode.removeChild(e):e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor(e=>e.hasAttribute("contenteditable"));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;if(i===t.getFillerOffset())return!1;const n=e.nodeBefore,s=e.nodeAfter;return!(n instanceof dn||s instanceof dn)}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e),n=this.domConverter.viewToDom(e,i.ownerDocument),s=i.data;let o=n.data;const r=t.inlineFillerPosition;if(r&&r.parent==e.parent&&r.offset==e.index&&(o=no+o),s!=o){const e=lo(s,o);for(const t of e)"insert"===t.type?i.insertData(t.index,t.values.join("")):i.deleteData(t.index,t.howMany)}}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map(e=>e.name),n=e.getAttributeKeys();for(const i of n)t.setAttribute(i,e.getAttribute(i));for(const n of i)e.hasAttribute(n)||t.removeAttribute(n)}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;const n=t.inlineFillerPosition,s=this.domConverter.mapViewToDom(e).childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,i.ownerDocument,{bind:!0,inlineFillerPosition:n}));n&&n.parent===e&&wo(i.ownerDocument,o,n.offset);const r=this._diffNodeLists(s,o);let a=0;const l=new Set;for(const e of r)"delete"===e?(l.add(s[a]),fo(s[a])):"equal"===e&&a++;a=0;for(const e of r)"insert"===e?(mo(i,a,o[a]),a++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(o[a])),a++);for(const e of l)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return uo(e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;i[i.length-1]==t&&i.pop();return i}(e,this._fakeSelectionContainer),t,_o.bind(null,this.domConverter))}_findReplaceActions(e,t,i){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let n=[],s=[],o=[];const r={equal:0,insert:0,delete:0};for(const a of e)"insert"===a?o.push(i[r.equal+r.insert]):"delete"===a?s.push(t[r.equal+r.delete]):(n=n.concat(uo(s,o,bo).map(e=>"equal"===e?"replace":e)),n.push("equal"),s=[],o=[]),r[a]++;return n.concat(uo(s,o,bo).map(e=>"equal"===e?"replace":e))}_markDescendantTextToSync(e){if(e)if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}_updateSelection(){if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e&&(this.selection.isFake?this._updateFakeSelection(e):(this._removeFakeSelection(),this._updateDomSelection(e)))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),s=t.createRange();n.removeAllRanges(),s.selectNodeContents(i),n.addRange(s)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(i.parent,i.offset),t.extend(n.parent,n.offset),Ps.isGecko&&function(e,t){const i=e.parent;if(i.nodeType!=Node.ELEMENT_NODE||e.offset!=i.childNodes.length-1)return;const n=i.childNodes[e.offset];n&&"BR"==n.tagName&&t.addRange(t.getRangeAt(0))}(n,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){if(e.getSelection().rangeCount){const t=e.activeElement,i=this.domConverter.mapDomToView(t);t&&i&&e.getSelection().removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function wo(e,t,i){const n=t instanceof Array?t:t.childNodes,s=n[i];if(Zs(s))return s.data=no+s.data,s;{const s=e.createTextNode(no);return Array.isArray(t)?n.splice(i,0,s):mo(t,i,s),s}}function bo(e,t){return go(e)&&go(t)&&!Zs(e)&&!Zs(t)&&e.nodeType!==Node.COMMENT_NODE&&t.nodeType!==Node.COMMENT_NODE&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function _o(e,t,i){return t===i||(Zs(t)&&Zs(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}Je(po,We);var vo={window:window,document:document};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function yo(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ko(e){const t=[];for(;e&&e.nodeType!=Node.DOCUMENT_NODE;)t.unshift(e),e=e.parentNode;return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Co=io(document),Ao=eo(document),xo=to(document);class To{constructor(e,t={}){this.document=e,this.blockFillerMode=t.blockFillerMode||"br",this.preElements=["pre"],this.blockElements=["p","div","h1","h2","h3","h4","h5","h6","li","dd","dt","figcaption","td","th"],this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new fn,this._encounteredRawContentDomNodes=new WeakSet}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new ds(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of e.childNodes)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}viewToDom(e,t,i={}){if(e.is("$text")){const i=this._processDataFromViewText(e);return t.createTextNode(i)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let n;if(e.is("documentFragment"))n=t.createDocumentFragment(),i.bind&&this.bindDocumentFragments(n,e);else{if(e.is("uiElement"))return n=e.render(t),i.bind&&this.bindElements(n,e),n;n=e.hasAttribute("xmlns")?t.createElementNS(e.getAttribute("xmlns"),e.name):t.createElement(e.name),e.is("rawElement")&&e.render(n),i.bind&&this.bindElements(n,e);for(const t of e.getAttributeKeys())n.setAttribute(t,e.getAttribute(t))}if(!1!==i.withChildren)for(const s of this.viewChildrenToDom(e,t,i))n.appendChild(s);return n}}*viewChildrenToDom(e,t,i={}){const n=e.getFillerOffset&&e.getFillerOffset();let s=0;for(const o of e.getChildren())n===s&&(yield this._getBlockFiller(t)),yield this.viewToDom(o,t,i),s++;n===s&&(yield this._getBlockFiller(t))}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=document.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return so(i)&&(n+=7),{parent:i,offset:n}}{let i,n,s;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(e.nodeBefore),!n)return null;i=n.parentNode,s=n.nextSibling}if(Zs(s)&&so(s))return{parent:s,offset:7};return{parent:i,offset:n?yo(n)+1:0}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const i=this.getHostViewElement(e);if(i)return i;if(Zs(e)){if(oo(e))return null;{const t=this._processDataFromDomText(e);return""===t?null:new dn(this.document,t)}}if(this.isComment(e))return null;{if(this.mapDomToView(e))return this.mapDomToView(e);let i;if(this.isDocumentFragment(e))i=new js(this.document),t.bind&&this.bindDocumentFragments(e,i);else{const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();i=new Zn(this.document,n),t.bind&&this.bindElements(e,i);const s=e.attributes;for(let e=s.length-1;e>=0;e--)i._setAttribute(s[e].name,s[e].value);if(!1!==t.withChildren&&this._rawContentElementMatcher.match(i))return i._setCustomProperty("$rawContent",e.innerHTML),this._encounteredRawContentDomNodes.add(e),i}if(!1!==t.withChildren)for(const n of this.domChildrenToView(e,t))i._appendChild(n);return i}}*domChildrenToView(e,t={}){for(let i=0;i<e.childNodes.length;i++){const n=e.childNodes[i],s=this.domToView(n,t);null!==s&&(yield s)}}domSelectionToView(e){if(1===e.rangeCount){let t=e.getRangeAt(0).startContainer;Zs(t)&&(t=t.parentNode);const i=this.fakeSelectionToView(t);if(i)return i}const t=this.isDomSelectionBackward(e),i=[];for(let t=0;t<e.rangeCount;t++){const n=e.getRangeAt(t),s=this.domRangeToView(n);s&&i.push(s)}return new ds(i,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),i=this.domPositionToView(e.endContainer,e.endOffset);return t&&i?new ls(t,i):null}domPositionToView(e,t){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,yo(e));const i=this.mapDomToView(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return as._createBefore(i);if(Zs(e)){if(oo(e))return this.domPositionToView(e.parentNode,yo(e));const i=this.findCorrespondingViewText(e);let n=t;return i?(so(e)&&(n-=7,n=n<0?0:n),new as(i,n)):null}if(0===t){const t=this.mapDomToView(e);if(t)return new as(t,0)}else{const i=e.childNodes[t-1],n=Zs(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(n&&n.parent)return new as(n.parent,n.index+1)}return null}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(oo(e))return null;const t=this.getHostViewElement(e);if(t)return t;const i=e.previousSibling;if(i){if(!this.isElement(i))return null;const e=this.mapDomToView(i);if(e){return e.nextSibling instanceof dn?e.nextSibling:null}}else{const t=this.mapDomToView(e.parentNode);if(t){const e=t.getChild(0);return e instanceof dn?e:null}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){const t=e.previousSibling;return t&&this.mapViewToDom(t)?this.mapViewToDom(t).nextSibling:!t&&e.parent&&this.mapViewToDom(e.parent)?this.mapViewToDom(e.parent).childNodes[0]:null}focus(e){const t=this.mapViewToDom(e);if(t&&t.ownerDocument.activeElement!==t){const{scrollX:e,scrollY:i}=vo.window,n=[];Eo(t,e=>{const{scrollLeft:t,scrollTop:i}=e;n.push([t,i])}),t.focus(),Eo(t,e=>{const[t,i]=n.shift();e.scrollLeft=t,e.scrollTop=i}),vo.window.scrollTo(e,i)}}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isComment(e){return e&&e.nodeType==Node.COMMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(Co):!("BR"!==e.tagName||!So(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(xo)||function(e,t){return e.isEqualNode(Ao)&&So(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements))}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=document.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset);const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=ko(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}_getBlockFiller(e){switch(this.blockFillerMode){case"nbsp":return eo(e);case"markedNbsp":return to(e);case"br":return io(e)}}_isDomSelectionPositionCorrect(e,t){if(Zs(e)&&so(e)&&t<7)return!1;if(this.isElement(e)&&so(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}_processDataFromViewText(e){let t=e.data;if(e.getAncestors().some(e=>this.preElements.includes(e.name)))return t;if(" "==t.charAt(0)){const i=this._getTouchingViewTextNode(e,!1);!(i&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingViewTextNode(e,!0);" "!=t.charAt(t.length-2)&&i&&" "!=i.data.charAt(0)||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some(e=>this.preElements.includes(e.name)))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_processDataFromDomText(e){let t=e.data;if(Po(e,this.preElements))return ro(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const i=this._getTouchingInlineDomNode(e,!1),n=this._getTouchingInlineDomNode(e,!0),s=this._checkShouldLeftTrimDomText(e,i),o=this._checkShouldRightTrimDomText(e,n);return s&&(t=t.replace(/^ /,"")),o&&(t=t.replace(/ $/,"")),t=ro(new Text(t)),t=t.replace(/ \u00A0/g,"  "),(/( |\u00A0)\u00A0$/.test(t)||!n||n.data&&" "==n.data.charAt(0))&&(t=t.replace(/\u00A0$/," ")),s&&(t=t.replace(/^\u00A0/," ")),t}_checkShouldLeftTrimDomText(e,t){return!t||(!!Ki(t)||!this._encounteredRawContentDomNodes.has(e.previousSibling)&&/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)))}_checkShouldRightTrimDomText(e,t){return!t&&!so(e)}_getTouchingViewTextNode(e,t){const i=new rs({startPosition:t?as._createAfter(e):as._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("containerElement"))return null;if(e.item.is("element","br"))return null;if(e.item.is("$textProxy"))return e.item}return null}_getTouchingInlineDomNode(e,t){if(!e.parentNode)return null;const i=t?"nextNode":"previousNode",n=e.ownerDocument,s=ko(e)[0],o=n.createTreeWalker(s,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:e=>Zs(e)||"BR"==e.tagName?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});o.currentNode=e;const r=o[i]();if(null!==r){const t=function(e,t){const i=ko(e),n=ko(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}(e,r);if(t&&!Po(e,this.blockElements,t)&&!Po(r,this.blockElements,t))return r}return null}}function Po(e,t,i){let n=ko(e);return i&&(n=n.slice(n.indexOf(i)+1)),n.some(e=>e.tagName&&t.includes(e.tagName.toLowerCase()))}function Eo(e,t){for(;e&&e!=vo.document;)t(e),e=e.parentNode}function So(e,t){const i=e.parentNode;return i&&i.tagName&&t.includes(i.tagName.toLowerCase())}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ro(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var Io=Be({},d,{listenTo(e,...t){if(go(e)||Ro(e)){const i=this._getProxyEmitter(e)||new Vo(e);i.attach(...t),e=i}d.listenTo.call(this,e,...t)},stopListening(e,t,i){if(go(e)||Ro(e)){const t=this._getProxyEmitter(e);if(!t)return;e=t}d.stopListening.call(this,e,t,i),e instanceof Vo&&e.detach(t)},_getProxyEmitter(e){return t=this,i=Oo(e),t[c]&&t[c][i]?t[c][i].emitter:null;var t,i}});class Vo{constructor(e){u(this,Oo(e)),this._domNode=e}}function Oo(e){return e["data-ck-expando"]||(e["data-ck-expando"]=r())}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Be(Vo.prototype,d,{attach(e,t,i={}){if(this._domListeners&&this._domListeners[e])return;const n={capture:!!i.useCapture,passive:!!i.usePassive},s=this._createDomListener(e,n);this._domNode.addEventListener(e,s,n),this._domListeners||(this._domListeners={}),this._domListeners[e]=s},detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()},_createDomListener(e,t){const i=t=>{this.fire(e,t)};return i.removeListener=()=>{this._domNode.removeEventListener(e,i,t),delete this._domListeners[e]},i}});class No{constructor(e){this.view=e,this.document=e.document,this.isEnabled=!1}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}Je(No,Io);var Mo=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};var Bo=function(e){return this.__data__.has(e)};function Fo(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new Ht;++t<i;)this.add(e[t])}Fo.prototype.add=Fo.prototype.push=Mo,Fo.prototype.has=Bo;var Do=Fo;var zo=function(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1};var Lo=function(e,t){return e.has(t)};var Ho=function(e,t,i,n,s,o){var r=1&i,a=e.length,l=t.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(e),h=o.get(t);if(c&&h)return c==t&&h==e;var d=-1,u=!0,m=2&i?new Do:void 0;for(o.set(e,t),o.set(t,e);++d<a;){var f=e[d],g=t[d];if(n)var p=r?n(g,f,d,t,e,o):n(f,g,d,e,t,o);if(void 0!==p){if(p)continue;u=!1;break}if(m){if(!zo(t,(function(e,t){if(!Lo(m,t)&&(f===e||s(f,e,i,n,o)))return m.push(t)}))){u=!1;break}}else if(f!==g&&!s(f,g,i,n,o)){u=!1;break}}return o.delete(e),o.delete(t),u};var jo=function(e){var t=-1,i=Array(e.size);return e.forEach((function(e,n){i[++t]=[n,e]})),i};var Wo=function(e){var t=-1,i=Array(e.size);return e.forEach((function(e){i[++t]=e})),i},qo=v?v.prototype:void 0,$o=qo?qo.valueOf:void 0;var Uo=function(e,t,i,n,s,o,r){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new xi(e),new xi(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return G(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=jo;case"[object Set]":var l=1&n;if(a||(a=Wo),e.size!=t.size&&!l)return!1;var c=r.get(e);if(c)return c==t;n|=2,r.set(e,t);var h=Ho(a(e),a(t),n,s,o,r);return r.delete(e),h;case"[object Symbol]":if($o)return $o.call(e)==$o.call(t)}return!1},Ko=Object.prototype.hasOwnProperty;var Go=function(e,t,i,n,s,o){var r=1&i,a=hi(e),l=a.length;if(l!=hi(t).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in t:Ko.call(t,h)))return!1}var d=o.get(e),u=o.get(t);if(d&&u)return d==t&&u==e;var m=!0;o.set(e,t),o.set(t,e);for(var f=r;++c<l;){var g=e[h=a[c]],p=t[h];if(n)var w=r?n(p,g,h,t,e,o):n(g,p,h,e,t,o);if(!(void 0===w?g===p||s(g,p,i,n,o):w)){m=!1;break}f||(f="constructor"==h)}if(m&&!f){var b=e.constructor,_=t.constructor;b==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof _&&_ instanceof _||(m=!1)}return o.delete(e),o.delete(t),m},Jo=Object.prototype.hasOwnProperty;var Yo=function(e,t,i,n,s,o){var r=ve(e),a=ve(t),l=r?"[object Array]":ki(e),c=a?"[object Array]":ki(t),h="[object Object]"==(l="[object Arguments]"==l?"[object Object]":l),d="[object Object]"==(c="[object Arguments]"==c?"[object Object]":c),u=l==c;if(u&&Object(ye.a)(e)){if(!Object(ye.a)(t))return!1;r=!0,h=!1}if(u&&!h)return o||(o=new qt),r||Pe(e)?Ho(e,t,i,n,s,o):Uo(e,t,l,i,n,s,o);if(!(1&i)){var m=h&&Jo.call(e,"__wrapped__"),f=d&&Jo.call(t,"__wrapped__");if(m||f){var g=m?e.value():e,p=f?t.value():t;return o||(o=new qt),s(g,p,i,n,o)}}return!!u&&(o||(o=new qt),Go(e,t,i,n,s,o))};var Qo=function e(t,i,n,s,o){return t===i||(null==t||null==i||!fe(t)&&!fe(i)?t!=t&&i!=i:Yo(t,i,n,s,e,o))};var Xo=function(e,t,i){var n=(i="function"==typeof i?i:void 0)?i(e,t):void 0;return void 0===n?Qo(e,t,void 0,i):!!n};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zo extends No{constructor(e){super(e),this._config={childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},this.domConverter=e.domConverter,this.renderer=e._renderer,this._domElements=[],this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.push(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(0===e.length)return;const t=this.domConverter,i=new Map,n=new Set;for(const i of e)if("childList"===i.type){const e=t.mapDomToView(i.target);if(e&&(e.is("uiElement")||e.is("rawElement")))continue;e&&!this._isBogusBrMutation(i)&&n.add(e)}for(const s of e){const e=t.mapDomToView(s.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===s.type){const e=t.findCorrespondingViewText(s.target);e&&!n.has(e.parent)?i.set(e,{type:"text",oldText:e.data,newText:ro(s.target),node:e}):!e&&so(s.target)&&n.add(t.mapDomToView(s.target.parentNode))}}const s=[];for(const e of i.values())this.renderer.markToSync("text",e.node),s.push(e);for(const e of n){const i=t.mapViewToDom(e),n=Array.from(e.getChildren()),o=Array.from(t.domChildrenToView(i,{withChildren:!1}));Xo(n,o,a)||(this.renderer.markToSync("children",e),s.push({type:"children",oldChildren:n,newChildren:o,node:e}))}const o=e[0].target.ownerDocument.getSelection();let r=null;if(o&&o.anchorNode){const e=t.domPositionToView(o.anchorNode,o.anchorOffset),i=t.domPositionToView(o.focusNode,o.focusOffset);e&&i&&(r=new ds(e),r.setFocus(i))}function a(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}s.length&&(this.document.fire("mutations",s,r),this.view.forceRender())}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class er{constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Be(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tr extends No{constructor(e){super(e),this.useCapture=!1}observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach(t=>{this.listenTo(e,t,(e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)},{useCapture:this.useCapture})})}fire(e,t,i){this.isEnabled&&this.document.fire(e,new er(this.view,t,i))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ir extends tr{constructor(e){super(e),this.domEventType=["keydown","keyup"]}onDomEvent(e){this.fire(e.type,e,{keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return Vs(this)}})}}var nr=function(){return _.a.Date.now()},sr=/\s/;var or=function(e){for(var t=e.length;t--&&sr.test(e.charAt(t)););return t},rr=/^\s+/;var ar=function(e){return e?e.slice(0,or(e)+1).replace(rr,""):e},lr=/^[-+]0x[0-9a-f]+$/i,cr=/^0b[01]+$/i,hr=/^0o[0-7]+$/i,dr=parseInt;var ur=function(e){if("number"==typeof e)return e;if(pn(e))return NaN;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=ar(e);var i=cr.test(e);return i||hr.test(e)?dr(e.slice(2),i?2:8):lr.test(e)?NaN:+e},mr=Math.max,fr=Math.min;var gr=function(e,t,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,u=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var i=n,o=s;return n=s=void 0,c=t,r=e.apply(o,i)}function f(e){return c=e,a=setTimeout(p,t),h?m(e):r}function g(e){var i=e-l;return void 0===l||i>=t||i<0||d&&e-c>=o}function p(){var e=nr();if(g(e))return w(e);a=setTimeout(p,function(e){var i=t-(e-l);return d?fr(i,o-(e-c)):i}(e))}function w(e){return a=void 0,u&&n?m(e):(n=s=void 0,r)}function _(){var e=nr(),i=g(e);if(n=arguments,s=this,l=e,i){if(void 0===a)return f(l);if(d)return clearTimeout(a),a=setTimeout(p,t),m(l)}return void 0===a&&(a=setTimeout(p,t)),r}return t=ur(t)||0,b(i)&&(h=!!i.leading,o=(d="maxWait"in i)?mr(ur(i.maxWait)||0,t):o,u="trailing"in i?!!i.trailing:u),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},_.flush=function(){return void 0===a?r:w(nr())},_};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class pr extends No{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=gr(e=>this.document.fire("selectionChangeDone",e),200)}observe(){const e=this.document;e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)},{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new ds(t.getRanges(),{backward:t.isBackward,fake:!1});e!=Rs.arrowleft&&e!=Rs.arrowup||i.setTo(i.getFirstPosition()),e!=Rs.arrowright&&e!=Rs.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class wr extends No{constructor(e){super(e),this.mutationObserver=e.getObserver(Zo),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=gr(e=>this.document.fire("selectionChangeDone",e),200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument;this._documents.has(t)||(this.listenTo(t,"selectionchange",(e,i)=>{this._handleSelectionChange(i,t)}),this._documents.add(t))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(i);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(i)||++this._loopbackCounter>60))if(this.selection.isSimilar(n))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:n,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class br extends tr{constructor(e){super(e),this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",()=>{t.isFocused=!0,this._renderTimeoutId=setTimeout(()=>e.forceRender(),50)}),t.on("blur",(i,n)=>{const s=t.selection.editableElement;null!==s&&s!==n.target||(t.isFocused=!1,e.forceRender())})}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _r extends tr{constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */class vr extends tr{constructor(e){super(e),this.domEventType=["beforeinput"]}onDomEvent(e){this.fire(e.type,e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yr{constructor(){this._replacedElements=[]}replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach(({element:e,newElement:t})=>{e.style.display="",t&&t.remove()}),this._replacedElements=[]}}var kr=function(e){return"string"==typeof e||!ve(e)&&fe(e)&&"[object String]"==S(e)};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Cr(e,t,i={},n=[]){const s=i&&i.xmlns,o=s?e.createElementNS(s,t):e.createElement(t);for(const e in i)o.setAttribute(e,i[e]);!kr(n)&&Qi(n)||(n=[n]);for(let t of n)kr(t)&&(t=e.createTextNode(t)),o.appendChild(t);return o}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Ar(e){return"[object Range]"==Object.prototype.toString.apply(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function xr(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Tr=["top","right","bottom","left","width","height"];class Pr{constructor(e){const t=Ar(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Ki(e)||t)if(t){const t=Pr.getDomRangeRects(e);Er(this,Pr.getBoundingRect(t))}else Er(this,e.getBoundingClientRect());else if(Ro(e)){const{innerWidth:t,innerHeight:i}=e;Er(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else Er(this,e)}clone(){return new Pr(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left)};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new Pr(t)}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(!Sr(e)){let i=e.parentNode||e.commonAncestorContainer;for(;i&&!Sr(i);){const e=new Pr(i),n=t.getIntersection(e);if(!n)return null;n.getArea()<t.getArea()&&(t=n),i=i.parentNode}}return t}isEqual(e){for(const t of Tr)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!(!t||!t.isEqual(e))}excludeScrollbarsAndBorders(){const e=this._source;let t,i,n;if(Ro(e))t=e.innerWidth-e.document.documentElement.clientWidth,i=e.innerHeight-e.document.documentElement.clientHeight,n=e.getComputedStyle(e.document.documentElement).direction;else{const s=xr(this._source);t=e.offsetWidth-e.clientWidth-s.left-s.right,i=e.offsetHeight-e.clientHeight-s.top-s.bottom,n=e.ownerDocument.defaultView.getComputedStyle(e).direction,this.left+=s.left,this.top+=s.top,this.right-=s.right,this.bottom-=s.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=t,"ltr"===n?this.right-=t:this.left+=t,this.height-=i,this.bottom-=i,this}static getDomRangeRects(e){const t=[],i=Array.from(e.getClientRects());if(i.length)for(const e of i)t.push(new Pr(e));else{let i=e.startContainer;Zs(i)&&(i=i.parentNode);const n=new Pr(i.getBoundingClientRect());n.right=n.left,n.width=0,t.push(n)}return t}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY};let i=0;for(const n of e)i++,t.left=Math.min(t.left,n.left),t.top=Math.min(t.top,n.top),t.right=Math.max(t.right,n.right),t.bottom=Math.max(t.bottom,n.bottom);return 0==i?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new Pr(t))}}function Er(e,t){for(const i of Tr)e[i]=t[i]}function Sr(e){return!!Ki(e)&&e===e.ownerDocument.body}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rr{constructor(e,t){Rr._observerInstance||Rr._createObserver(),this._element=e,this._callback=t,Rr._addElementCallback(e,t),Rr._observerInstance.observe(e)}destroy(){Rr._deleteElementCallback(this._element,this._callback)}static _addElementCallback(e,t){Rr._elementCallbacks||(Rr._elementCallbacks=new Map);let i=Rr._elementCallbacks.get(e);i||(i=new Set,Rr._elementCallbacks.set(e,i)),i.add(t)}static _deleteElementCallback(e,t){const i=Rr._getElementCallbacks(e);i&&(i.delete(t),i.size||(Rr._elementCallbacks.delete(e),Rr._observerInstance.unobserve(e))),Rr._elementCallbacks&&!Rr._elementCallbacks.size&&(Rr._observerInstance=null,Rr._elementCallbacks=null)}static _getElementCallbacks(e){return Rr._elementCallbacks?Rr._elementCallbacks.get(e):null}static _createObserver(){let e;e="function"==typeof vo.window.ResizeObserver?vo.window.ResizeObserver:Ir,Rr._observerInstance=new e(e=>{for(const t of e){const e=Rr._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}})}}Rr._observerInstance=null,Rr._elementCallbacks=null;class Ir{constructor(e){this._callback=e,this._elements=new Set,this._previousRects=new Map,this._periodicCheckTimeout=null}observe(e){this._elements.add(e),this._checkElementRectsAndExecuteCallback(),1===this._elements.size&&this._startPeriodicCheck()}unobserve(e){this._elements.delete(e),this._previousRects.delete(e),this._elements.size||this._stopPeriodicCheck()}_startPeriodicCheck(){const e=()=>{this._checkElementRectsAndExecuteCallback(),this._periodicCheckTimeout=setTimeout(e,100)};this.listenTo(vo.window,"resize",()=>{this._checkElementRectsAndExecuteCallback()}),this._periodicCheckTimeout=setTimeout(e,100)}_stopPeriodicCheck(){clearTimeout(this._periodicCheckTimeout),this.stopListening(),this._previousRects.clear()}_checkElementRectsAndExecuteCallback(){const e=[];for(const t of this._elements)this._hasRectChanged(t)&&e.push({target:t,contentRect:this._previousRects.get(t)});e.length&&this._callback(e)}_hasRectChanged(e){if(!e.ownerDocument.body.contains(e))return!1;const t=new Pr(e),i=this._previousRects.get(e),n=!i||!i.isEqual(t);return this._previousRects.set(e,t),n}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Vr(e){return t=>t+e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Or(e){const t=e.next();return t.done?null:t.value}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Je(Ir,Io);class Nr{constructor(){this.set("isFocused",!1),this.set("focusedElement",null),this._elements=new Set,this._nextEventLoopTimeout=null}add(e){if(this._elements.has(e))throw new l.a("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",()=>this._focus(e),{useCapture:!0}),this.listenTo(e,"blur",()=>this._blur(),{useCapture:!0}),this._elements.add(e)}remove(e){e===this.focusedElement&&this._blur(e),this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e))}destroy(){this.stopListening()}_focus(e){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=e,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0)}}Je(Nr,Io),Je(Nr,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Mr{constructor(){this._listener=Object.create(Io)}listenTo(e){this._listener.listenTo(e,"keydown",(e,t)=>{this._listener.fire("_keydown:"+Vs(t),t)})}set(e,t,i={}){const n=Os(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,(e,i)=>{t(i,()=>{i.preventDefault(),i.stopPropagation(),e.stop()}),e.return=!0},{priority:s})}press(e){return!!this._listener.fire("_keydown:"+Vs(e),e)}destroy(){this._listener.stopListening()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Br extends No{constructor(e){super(e),this.document.on("keydown",(e,t)=>{if(this.isEnabled&&((i=t.keyCode)==Rs.arrowright||i==Rs.arrowleft||i==Rs.arrowup||i==Rs.arrowdown)){const i=new ms(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i})}observe(){}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Fr({target:e,viewportOffset:t=0}){const i=qr(e);let n=i,s=null;for(;n;){let o;o=$r(n==i?e:s),zr(o,()=>Ur(e,n));const r=Ur(e,n);if(Dr(n,r,t),n.parent!=n){if(s=n.frameElement,n=n.parent,!s)return}else n=null}}function Dr(e,t,i){const n=t.clone().moveBy(0,i),s=t.clone().moveBy(0,-i),o=new Pr(e).excludeScrollbarsAndBorders();if(![s,n].every(e=>o.contains(e))){let{scrollX:r,scrollY:a}=e;Hr(s,o)?a-=o.top-t.top+i:Lr(n,o)&&(a+=t.bottom-o.bottom+i),jr(t,o)?r-=o.left-t.left+i:Wr(t,o)&&(r+=t.right-o.right+i),e.scrollTo(r,a)}}function zr(e,t){const i=qr(e);let n,s;for(;e!=i.document.body;)s=t(),n=new Pr(e).excludeScrollbarsAndBorders(),n.contains(s)||(Hr(s,n)?e.scrollTop-=n.top-s.top:Lr(s,n)&&(e.scrollTop+=s.bottom-n.bottom),jr(s,n)?e.scrollLeft-=n.left-s.left:Wr(s,n)&&(e.scrollLeft+=s.right-n.right)),e=e.parentNode}function Lr(e,t){return e.bottom>t.bottom}function Hr(e,t){return e.top<t.top}function jr(e,t){return e.left<t.left}function Wr(e,t){return e.right>t.right}function qr(e){return Ar(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function $r(e){if(Ar(e)){let t=e.commonAncestorContainer;return Zs(t)&&(t=t.parentNode),t}return e.parentNode}function Ur(e,t){const i=qr(e),n=new Pr(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new Pr(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Object.assign({},{scrollViewportToShowTarget:Fr,scrollAncestorsToShowTarget:function(e){zr($r(e),()=>new Pr(e))}});class Kr{constructor(e){this.document=new vs(e),this.domConverter=new To(this.document),this.domRoots=new Map,this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new po(this.domConverter,this.document.selection),this._renderer.bind("isFocused").to(this.document),this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this._writer=new Ws(this.document),this.addObserver(Zo),this.addObserver(wr),this.addObserver(br),this.addObserver(ir),this.addObserver(pr),this.addObserver(_r),this.addObserver(Br),Ps.isAndroid&&this.addObserver(vr),this.document.on("arrowKey",ao,{priority:"low"}),Ds(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0})}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:s}of Array.from(e.attributes))n[t]=s,"class"===t?this._writer.addClass(s.split(" "),i):this._writer.setAttribute(t,s,i);this._initialDomRootAttributes.set(e,n);const s=()=>{this._writer.setAttribute("contenteditable",!i.isReadOnly,i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};s(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",(e,t)=>this._renderer.markToSync("children",t)),i.on("change:attributes",(e,t)=>this._renderer.markToSync("attributes",t)),i.on("change:text",(e,t)=>this._renderer.markToSync("text",t)),i.on("change:isReadOnly",()=>this.change(s)),i.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:e})=>t.removeAttribute(e));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection(){const e=this.document.selection.getFirstRange();e&&Fr({target:this.domConverter.viewRangeToDom(e),viewportOffset:20})}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new l.a("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(e){l.a.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return as._createAt(e,t)}createPositionAfter(e){return as._createAfter(e)}createPositionBefore(e){return as._createBefore(e)}createRange(e,t){return new ls(e,t)}createRangeOn(e){return ls._createOn(e)}createRangeIn(e){return ls._createIn(e)}createSelection(e,t,i){return new ds(e,t,i)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}Je(Kr,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Gr{constructor(e){this.parent=null,this._attrs=mn(e)}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new l.a("model-node-not-found-in-parent",this);return e}get startOffset(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildStartOffset(this)))throw new l.a("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=ln(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&(this.root===e.root&&!this.isBefore(e))}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((e,t)=>(e[t[0]]=t[1],e),{})),e}is(e){return"node"===e||"model:node"===e}_clone(){return new Gr(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=mn(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jr extends Gr{constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}is(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new Jr(this.data,this.getAttributes())}static fromJSON(e){return new Jr(e.data,e.attributes)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yr{constructor(e,t,i){if(this.textNode=e,t<0||t>e.offsetSize)throw new l.a("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new l.a("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}is(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qr{constructor(e){this._nodes=[],e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce((e,t)=>e+t.offsetSize,0)}getNode(e){return this._nodes[e]||null}getNodeIndex(e){const t=this._nodes.indexOf(e);return-1==t?null:t}getNodeStartOffset(e){const t=this.getNodeIndex(e);return null===t?null:this._nodes.slice(0,t).reduce((e,t)=>e+t.offsetSize,0)}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new l.a("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&e<t+i.offsetSize)return this.getNodeIndex(i);t+=i.offsetSize}if(t!=e)throw new l.a("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.length}_insertNodes(e,t){for(const e of t)if(!(e instanceof Gr))throw new l.a("model-nodelist-insertnodes-not-node",this);this._nodes.splice(e,0,...t)}_removeNodes(e,t=1){return this._nodes.splice(e,t)}toJSON(){return this._nodes.map(e=>e.toJSON())}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xr extends Gr{constructor(e,t,i){super(t),this.name=e,this._children=new Qr,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}is(e,t=null){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}findAncestor(e,t={includeSelf:!1}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map(e=>e._clone(!0)):null;return new Xr(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Jr(e)];Qi(e)||(e=[e]);return Array.from(e).map(e=>"string"==typeof e?new Jr(e):e instanceof Yr?new Jr(e.data,e.getAttributes()):e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}static fromJSON(e){let t=null;if(e.children){t=[];for(const i of e.children)i.name?t.push(Xr.fromJSON(i)):t.push(Jr.fromJSON(i))}return new Xr(e.name,e.attributes,t)}}class Zr{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new l.a("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new l.a("model-tree-walker-unknown-direction",e,{direction:t});this.direction=t,this.boundaries=e.boundaries||null,e.startPosition?this.position=e.startPosition.clone():this.position=ta._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}skip(e){let t,i,n,s;do{n=this.position,s=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this.position=n,this._visitedParent=s)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0};const n=t.parent,s=ia(t,n),o=s||na(t,n,s);if(o instanceof Xr)return this.shallow?t.offset++:(t.path.push(0),this._visitedParent=o),this.position=t,ea("elementStart",o,e,t,1);if(o instanceof Jr){let n;if(this.singleCharacters)n=1;else{let e=o.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<e&&(e=this.boundaries.end.offset),n=e-t.offset}const s=t.offset-o.startOffset,r=new Yr(o,s,n);return t.offset+=n,this.position=t,ea("text",r,e,t,n)}return t.path.pop(),t.offset++,this.position=t,this._visitedParent=i.parent,this.ignoreElementEnd?this._next():ea("elementEnd",i,e,t)}_previous(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&0===t.offset)return{done:!0};if(i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0};const n=t.parent,s=ia(t,n),o=s||sa(t,n,s);if(o instanceof Xr)return t.offset--,this.shallow?(this.position=t,ea("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this.position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():ea("elementEnd",o,e,t));if(o instanceof Jr){let n;if(this.singleCharacters)n=1;else{let e=o.startOffset;this._boundaryStartParent==i&&this.boundaries.start.offset>e&&(e=this.boundaries.start.offset),n=t.offset-e}const s=t.offset-o.startOffset,r=new Yr(o,s-n,n);return t.offset-=n,this.position=t,ea("text",r,e,t,n)}return t.path.pop(),this.position=t,this._visitedParent=i.parent,ea("elementStart",i,e,t,1)}}function ea(e,t,i,n,s){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ta{constructor(e,t,i="toNone"){if(!e.is("element")&&!e.is("documentFragment"))throw new l.a("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new l.a("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChild(e.offsetToIndex(this.path[t])),!e)throw new l.a("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new l.a("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return ia(this,this.parent)}get nodeAfter(){const e=this.parent;return na(this,e,ia(this,e))}get nodeBefore(){const e=this.parent;return sa(this,e,ia(this,e))}get isAtStart(){return 0===this.offset}get isAtEnd(){return this.offset==this.parent.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=ln(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]<e.path[t]?"before":"after"}}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Zr(t);return i.skip(e),i.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const t=ln(this.path,e.path),i="string"==typeof t?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,i)}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}getShiftedBy(e){const t=this.clone(),i=t.offset+e;return t.offset=i<0?0:i,t}isAfter(e){return"after"==this.compareWith(e)}isBefore(e){return"before"==this.compareWith(e)}isEqual(e){return"same"==this.compareWith(e)}isTouching(e){let t=null,i=null;switch(this.compareWith(e)){case"same":return!0;case"before":t=ta._createAt(this),i=ta._createAt(e);break;case"after":t=ta._createAt(e),i=ta._createAt(this);break;default:return!1}let n=t.parent;for(;t.path.length+i.path.length;){if(t.isEqual(i))return!0;if(t.path.length>i.path.length){if(t.offset!==n.maxOffset)return!1;t.path=t.path.slice(0,-1),n=n.parent,t.offset++}else{if(0!==i.offset)return!1;i.path=i.path.slice(0,-1)}}}is(e){return"position"===e||"model:position"===e}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==ln(this.getParentPath(),e.getParentPath())}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=ta._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?ta._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=ta._createAt(this);if(this.root!=e.root)return i;if("same"==ln(e.getParentPath(),this.getParentPath())){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;i.offset-=t}}else if("prefix"==ln(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=ta._createAt(this);if(this.root!=e.root)return i;if("same"==ln(e.getParentPath(),this.getParentPath()))(e.offset<this.offset||e.offset==this.offset&&"toPrevious"!=this.stickiness)&&(i.offset+=t);else if("prefix"==ln(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;e.offset<=this.path[n]&&(i.path[n]+=t)}return i}_getTransformedByMove(e,t,i){if(t=t._getTransformedByDeletion(e,i),e.isEqual(t))return ta._createAt(this);const n=this._getTransformedByDeletion(e,i);return null===n||e.isEqual(this)&&"toNext"==this.stickiness||e.getShiftedBy(i).isEqual(this)&&"toPrevious"==this.stickiness?this._getCombined(e,t):n._getTransformedByInsertion(t,i)}_getCombined(e,t){const i=e.path.length-1,n=ta._createAt(t);return n.stickiness=this.stickiness,n.offset=n.offset+this.path[i]-e.offset,n.path=[...n.path,...this.path.slice(i+1)],n}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,t,i="toNone"){if(e instanceof ta)return new ta(e.root,e.path,e.stickiness);{const n=e;if("end"==t)t=n.maxOffset;else{if("before"==t)return this._createBefore(n,i);if("after"==t)return this._createAfter(n,i);if(0!==t&&!t)throw new l.a("model-createpositionat-offset-required",[this,e])}if(!n.is("element")&&!n.is("documentFragment"))throw new l.a("model-position-parent-incorrect",[this,e]);const s=n.getPath();return s.push(t),new this(n.root,s,i)}}static _createAfter(e,t){if(!e.parent)throw new l.a("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,t)}static _createBefore(e,t){if(!e.parent)throw new l.a("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if("$graveyard"===e.root){const i=new ta(t.graveyard,e.path);return i.stickiness=e.stickiness,i}if(!t.getRoot(e.root))throw new l.a("model-position-fromjson-no-root",t,{rootName:e.root});return new ta(t.getRoot(e.root),e.path,e.stickiness)}}function ia(e,t){const i=t.getChild(t.offsetToIndex(e.offset));return i&&i.is("$text")&&i.startOffset<e.offset?i:null}function na(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset))}function sa(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset)-1)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class oa{constructor(e,t=null){this.start=ta._createAt(e),this.end=t?ta._createAt(t):ta._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new Zr({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return"same"==ln(this.start.getParentPath(),this.end.getParentPath())}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),n=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&n}containsItem(e){const t=ta._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}is(e){return"range"===e||"model:range"===e}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new oa(this.start,e.start)),this.containsPosition(e.end)&&t.push(new oa(e.end,this.end))):t.push(new oa(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new oa(t,i)}return null}getJoined(e,t=!1){let i=this.isIntersecting(e);if(i||(i=this.start.isBefore(e.start)?t?this.end.isTouching(e.start):this.end.isEqual(e.start):t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!i)return null;let n=this.start,s=this.end;return e.start.isBefore(n)&&(n=e.start),e.end.isAfter(s)&&(s=e.end),new oa(n,s)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,i=ta._createAt(this.start);let n=i.parent;for(;i.path.length>t+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new oa(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new oa(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new Zr(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Zr(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new Zr(e);yield t.position;for(const e of t)yield e.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new oa(this.start,this.end)]}getTransformedByOperations(e){const t=[new oa(this.start,this.end)];for(const i of e)for(let e=0;e<t.length;e++){const n=t[e].getTransformedByOperation(i);t.splice(e,1,...n),e+=n.length-1}for(let e=0;e<t.length;e++){const i=t[e];for(let n=e+1;n<t.length;n++){const e=t[n];(i.containsRange(e)||e.containsRange(i)||i.isEqual(e))&&t.splice(n,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const e=this.start.nodeAfter,t=this.end.nodeBefore;return e&&e.is("element")&&e===t?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,t=!1){return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e,t=!1){const i=e.sourcePosition,n=e.howMany,s=e.targetPosition;return this._getTransformedByMove(i,s,n,t)}_getTransformedBySplitOperation(e){const t=this.start._getTransformedBySplitOperation(e);let i=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(i=this.end.getShiftedBy(1)),t.root!=i.root&&(i=this.end.getShiftedBy(-1)),new oa(t,i)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new oa(this.start);let t=this.start._getTransformedByMergeOperation(e),i=this.end._getTransformedByMergeOperation(e);return t.root!=i.root&&(i=this.end.getShiftedBy(-1)),t.isAfter(i)?(e.sourcePosition.isBefore(e.targetPosition)?(t=ta._createAt(i),t.offset=0):(e.deletionPosition.isEqual(t)||(i=e.deletionPosition),t=e.targetPosition),new oa(t,i)):new oa(t,i)}_getTransformedByInsertion(e,t,i=!1){if(i&&this.containsPosition(e))return[new oa(this.start,e),new oa(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const i=new oa(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,t),i.end=i.end._getTransformedByInsertion(e,t),[i]}}_getTransformedByMove(e,t,i,n=!1){if(this.isCollapsed){const n=this.start._getTransformedByMove(e,t,i);return[new oa(n)]}const s=oa._createFromPositionAndShift(e,i),o=t._getTransformedByDeletion(e,i);if(this.containsPosition(t)&&!n&&(s.containsPosition(this.start)||s.containsPosition(this.end))){const n=this.start._getTransformedByMove(e,t,i),s=this.end._getTransformedByMove(e,t,i);return[new oa(n,s)]}let r;const a=this.getDifference(s);let l=null;const c=this.getIntersection(s);if(1==a.length?l=new oa(a[0].start._getTransformedByDeletion(e,i),a[0].end._getTransformedByDeletion(e,i)):2==a.length&&(l=new oa(this.start,this.end._getTransformedByDeletion(e,i))),r=l?l._getTransformedByInsertion(o,i,null!==c||n):[],c){const e=new oa(c.start._getCombined(s.start,o),c.end._getCombined(s.start,o));2==r.length?r.splice(1,0,e):r.push(e)}return r}_getTransformedByDeletion(e,t){let i=this.start._getTransformedByDeletion(e,t),n=this.end._getTransformedByDeletion(e,t);return null==i&&null==n?null:(null==i&&(i=e),null==n&&(n=e),new oa(i,n))}static _createFromPositionAndShift(e,t){const i=e,n=e.getShiftedBy(t);return t>0?new this(i,n):new this(n,i)}static _createIn(e){return new this(ta._createAt(e,0),ta._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(ta._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new l.a("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort((e,t)=>e.start.isAfter(t.start)?1:-1);const i=e.indexOf(t),n=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(n.start);t++)n.start=ta._createAt(e[t].start);for(let t=i+1;t<e.length&&e[t].start.isEqual(n.end);t++)n.end=ta._createAt(e[t].end);return n}static fromJSON(e,t){return new this(ta.fromJSON(e.start,t),ta.fromJSON(e.end,t))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ra{constructor(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._viewToModelLengthCallbacks=new Map,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),s=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=ta._createAt(n,s)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e){const t=this.toModelElement(e);if(this._viewToModelMapping.delete(e),this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);this._modelToViewMapping.get(t)==e&&this._modelToViewMapping.delete(t)}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new oa(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new ls(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={isPhantom:!1}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let n=0;for(let i=0;i<t;i++)n+=this.getModelLength(e.getChild(i));return n}getModelLength(e){if(this._viewToModelLengthCallbacks.get(e.name)){return this._viewToModelLengthCallbacks.get(e.name)(e)}if(this._viewToModelMapping.has(e))return 1;if(e.is("$text"))return e.data.length;if(e.is("uiElement"))return 0;{let t=0;for(const i of e.getChildren())t+=this.getModelLength(i);return t}}findPositionIn(e,t){let i,n=0,s=0,o=0;if(e.is("$text"))return new as(e,t);for(;s<t;)i=e.getChild(o),n=this.getModelLength(i),s+=n,o++;return s==t?this._moveViewPositionToTextNode(new as(e,o)):this.findPositionIn(i,t-(s-n))}_moveViewPositionToTextNode(e){const t=e.nodeBefore,i=e.nodeAfter;return t instanceof dn?new as(t,t.data.length):i instanceof dn?new as(i,0):e}}Je(ra,d);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class aa{constructor(){this._consumable=new Map,this._textProxyRegistry=new Map}add(e,t){t=la(t),e instanceof Yr&&(e=this._getSymbolForTextProxy(e)),this._consumable.has(e)||this._consumable.set(e,new Map),this._consumable.get(e).set(t,!0)}consume(e,t){return t=la(t),e instanceof Yr&&(e=this._getSymbolForTextProxy(e)),!!this.test(e,t)&&(this._consumable.get(e).set(t,!1),!0)}test(e,t){t=la(t),e instanceof Yr&&(e=this._getSymbolForTextProxy(e));const i=this._consumable.get(e);if(void 0===i)return null;const n=i.get(t);return void 0===n?null:n}revert(e,t){t=la(t),e instanceof Yr&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return!1===i?(this._consumable.get(e).set(t,!0),!0):!0!==i&&null}_getSymbolForTextProxy(e){let t=null;const i=this._textProxyRegistry.get(e.startOffset);if(i){const n=i.get(e.endOffset);n&&(t=n.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e.startOffset,e.endOffset,e.parent)),t}_addSymbolForTextProxy(e,t,i){const n=Symbol("textProxySymbol");let s,o;return s=this._textProxyRegistry.get(e),s||(s=new Map,this._textProxyRegistry.set(e,s)),o=s.get(t),o||(o=new Map,s.set(t,o)),o.set(i,n),n}}function la(e){const t=e.split(":");return t.length>1?t[0]+":"+t[1]:t[0]}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ca{constructor(e){this.conversionApi=Object.assign({dispatcher:this},e),this._reconversionEventsMapping=new Map}convertChanges(e,t,i){for(const t of e.getMarkersToRemove())this.convertMarkerRemove(t.name,t.range,i);const n=this._mapChangesWithAutomaticReconversion(e);for(const e of n)"insert"===e.type?this.convertInsert(oa._createFromPositionAndShift(e.position,e.length),i):"remove"===e.type?this.convertRemove(e.position,e.length,e.name,i):"reconvert"===e.type?this.reconvertElement(e.element,i):this.convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,i);for(const e of this.conversionApi.mapper.flushUnboundMarkerNames()){const n=t.get(e).getRange();this.convertMarkerRemove(e,n,i),this.convertMarkerAdd(e,n,i)}for(const t of e.getMarkersToAdd())this.convertMarkerAdd(t.name,t.range,i)}convertInsert(e,t){this.conversionApi.writer=t,this.conversionApi.consumable=this._createInsertConsumable(e);for(const t of Array.from(e).map(da))this._convertInsertWithAttributes(t);this._clearConversionApi()}convertRemove(e,t,i,n){this.conversionApi.writer=n,this.fire("remove:"+i,{position:e,length:t},this.conversionApi),this._clearConversionApi()}convertAttribute(e,t,i,n,s){this.conversionApi.writer=s,this.conversionApi.consumable=this._createConsumableForRange(e,"attribute:"+t);for(const s of e){const e={item:s.item,range:oa._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire("attribute:"+t,e)}this._clearConversionApi()}reconvertElement(e,t){const i=oa._createOn(e);this.conversionApi.writer=t,this.conversionApi.consumable=this._createInsertConsumable(i);const n=this.conversionApi.mapper,s=n.toViewElement(e);t.remove(s),this._convertInsertWithAttributes({item:e,range:i});const o=n.toViewElement(e);for(const i of oa._createIn(e)){const{item:e}=i,s=ua(e,n);s?s.root!==o.root&&t.move(t.createRangeOn(s),n.toViewPosition(ta._createBefore(e))):this._convertInsertWithAttributes(da(i))}n.unbindViewElement(s),this._clearConversionApi()}convertSelection(e,t,i){const n=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this.conversionApi.writer=i,this.conversionApi.consumable=this._createSelectionConsumable(e,n),this.fire("selection",{selection:e},this.conversionApi),e.isCollapsed){for(const t of n){const i=t.getRange();if(!ha(e.getFirstPosition(),t,this.conversionApi.mapper))continue;const n={item:e,markerName:t.name,markerRange:i};this.conversionApi.consumable.test(e,"addMarker:"+t.name)&&this.fire("addMarker:"+t.name,n,this.conversionApi)}for(const t of e.getAttributeKeys()){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.conversionApi.consumable.test(e,"attribute:"+i.attributeKey)&&this.fire("attribute:"+i.attributeKey+":$text",i,this.conversionApi)}this._clearConversionApi()}}convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;this.conversionApi.writer=i;const n="addMarker:"+e,s=new aa;if(s.add(t,n),this.conversionApi.consumable=s,this.fire(n,{markerName:e,markerRange:t},this.conversionApi),s.test(t,n)){this.conversionApi.consumable=this._createConsumableForRange(t,n);for(const i of t.getItems()){if(!this.conversionApi.consumable.test(i,n))continue;const s={item:i,range:oa._createOn(i),markerName:e,markerRange:t};this.fire(n,s,this.conversionApi)}this._clearConversionApi()}}convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&(this.conversionApi.writer=i,this.fire("removeMarker:"+e,{markerName:e,markerRange:t},this.conversionApi),this._clearConversionApi())}_mapReconversionTriggerEvent(e,t){this._reconversionEventsMapping.set(t,e)}_createInsertConsumable(e){const t=new aa;for(const i of e){const e=i.item;t.add(e,"insert");for(const i of e.getAttributeKeys())t.add(e,"attribute:"+i)}return t}_createConsumableForRange(e,t){const i=new aa;for(const n of e.getItems())i.add(n,t);return i}_createSelectionConsumable(e,t){const i=new aa;i.add(e,"selection");for(const n of t)i.add(e,"addMarker:"+n.name);for(const t of e.getAttributeKeys())i.add(e,"attribute:"+t);return i}_testAndFire(e,t){this.conversionApi.consumable.test(t.item,e)&&this.fire(function(e,t){const i=t.item.name||"$text";return`${e}:${i}`}(e,t),t,this.conversionApi)}_clearConversionApi(){delete this.conversionApi.writer,delete this.conversionApi.consumable}_convertInsertWithAttributes(e){this._testAndFire("insert",e);for(const t of e.item.getAttributeKeys())e.attributeKey=t,e.attributeOldValue=null,e.attributeNewValue=e.item.getAttribute(t),this._testAndFire("attribute:"+t,e)}_mapChangesWithAutomaticReconversion(e){const t=new Set,i=[];for(const n of e.getChanges()){const e=n.position||n.range.start,s=e.parent;if(ia(e,s)){i.push(n);continue}const o="attribute"===n.type?na(e,s,null):s;if(o.is("$text")){i.push(n);continue}let r;if(r="attribute"===n.type?`attribute:${n.attributeKey}:${o.name}`:`${n.type}:${n.name}`,this._isReconvertTriggerEvent(r,o.name)){if(t.has(o))continue;t.add(o),i.push({type:"reconvert",element:o})}else i.push(n)}return i}_isReconvertTriggerEvent(e,t){return this._reconversionEventsMapping.get(e)===t}}function ha(e,t,i){const n=t.getRange(),s=Array.from(e.getAncestors());s.shift(),s.reverse();return!s.some(e=>{if(n.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}})}function da(e){return{item:e.item,range:oa._createFromPositionAndShift(e.previousPosition,e.length)}}function ua(e,t){if(e.is("textProxy")){const i=t.toViewPosition(ta._createBefore(e)).parent;return i.is("$text")?i:null}return t.toViewElement(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Je(ca,d);class ma{constructor(e,t,i){this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,e&&this.setTo(e,t,i)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new oa(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?new oa(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?new oa(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(e,t,i){if(null===e)this._setRanges([]);else if(e instanceof ma)this._setRanges(e.getRanges(),e.isBackward);else if(e&&"function"==typeof e.getRanges)this._setRanges(e.getRanges(),e.isBackward);else if(e instanceof oa)this._setRanges([e],!!t&&!!t.backward);else if(e instanceof ta)this._setRanges([new oa(e)]);else if(e instanceof Gr){const n=!!i&&!!i.backward;let s;if("in"==t)s=oa._createIn(e);else if("on"==t)s=oa._createOn(e);else{if(void 0===t)throw new l.a("model-selection-setto-required-second-parameter",[this,e]);s=new oa(ta._createAt(e,t))}this._setRanges([s],n)}else{if(!Qi(e))throw new l.a("model-selection-setto-not-selectable",[this,e]);this._setRanges(e,t&&!!t.backward)}}_setRanges(e,t=!1){const i=(e=Array.from(e)).some(t=>{if(!(t instanceof oa))throw new l.a("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(e=>!e.isEqual(t))});if(e.length!==this._ranges.length||i){this._removeAllRanges();for(const t of e)this._pushRange(t);this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0})}}setFocus(e,t){if(null===this.anchor)throw new l.a("model-selection-setfocus-no-ranges",[this,e]);const i=ta._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new oa(i,n)),this._lastRangeBackward=!0):(this._pushRange(new oa(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}is(e){return"selection"===e||"model:selection"===e}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=pa(t.start,e);i&&wa(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&ga(n,e,t)&&(yield n)}const n=pa(t.end,e);n&&!t.end.isTouching(ta._createAt(n,0))&&wa(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=ta._createAt(e,0),i=ta._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new oa(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new l.a("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}function fa(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&e.parent)}function ga(e,t,i){return fa(e,t)&&wa(e,i)}function pa(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let s=!1;const o=n.find(e=>!s&&(s=i.isLimit(e),!s&&fa(e,t)));return n.forEach(e=>t.add(e)),o}function wa(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);if(!i)return!0;return!t.containsRange(oa._createOn(i),!0)}Je(ma,d);class ba extends oa{constructor(e,t){super(e,t),_a.call(this)}detach(){this.stopListening()}is(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e}toRange(){return new oa(this.start,this.end)}static fromRange(e){return new ba(e.start,e.end)}}function _a(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&va.call(this,i)},{priority:"low"})}function va(e){const t=this.getTransformedByOperation(e),i=oa._createFromRanges(t),n=!i.isEqual(this),s=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let o=null;if(n){"$graveyard"==i.root.rootName&&(o="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:o})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:o})}Je(ba,d);class ya{constructor(e){this._selection=new ka(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection._updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}is(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(e,t,i){this._selection.setTo(e,t,i)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection._getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return"selection:"+e}static _isStoreAttributeKey(e){return e.startsWith("selection:")}}Je(ya,d);class ka extends ma{constructor(e){super(),this.markers=new Xi({idProperty:"name"}),this._model=e.model,this._document=e,this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this.listenTo(this._model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{for(const e of this.getRanges())if(!this._document._validateSelectionRange(e))throw new l.a("document-selection-wrong-position",this,{range:e})}),this.listenTo(this._model.markers,"update",(e,t,i,n)=>{this._updateMarker(t,n)}),this.listenTo(this._document,"change",(e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,e=>{const t=Array.from(i.getAttributeKeys()).filter(e=>e.startsWith("selection:"));for(const n of t)e.removeAttribute(n,i)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this._model,t)})}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(e,t,i){super.setTo(e,t,i),this._updateAttributes(!0),this._updateMarkers()}setFocus(e,t){super.setFocus(e,t),this._updateAttributes(!0),this._updateMarkers()}setAttribute(e,t){if(this._setAttribute(e,t)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=r();return this._overriddenGravityRegister.add(e),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new l.a("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this._updateMarkers()}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=ba.fromRange(e);return t.on("change:range",(e,i,n)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}}),t}_updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const s=Array.from(this.markers),o=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!o?(this.markers.add(e),n=!0):!i&&o&&(this.markers.remove(e),n=!0)}else o&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateAttributes(e){const t=mn(this._getSurroundingAttributes()),i=mn(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";if("low"==n&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,i),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e){this._setAttribute(i,n,!1)&&t.add(i)}return t}*_getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith("selection:")){const i=t.substr("selection:".length);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,s=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Ca(n)),i||(i=Ca(s)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!t.isInline(e)&&!i;)e=e.previousSibling,i=Ca(e)}if(!i){let e=s;for(;e&&!t.isInline(e)&&!i;)e=e.nextSibling,i=Ca(e)}i||(i=this._getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item))break;if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Ca(e){return e instanceof Yr||e instanceof Jr?e.getAttributes():null}class Aa{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}var xa=function(e){return $i(e,5)};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ta extends Aa{elementToElement(e){return this.add(function(e){return(e=xa(e)).view=Sa(e.view,"container"),t=>{var i;if(t.on("insert:"+e.model,(i=e.view,(e,t,n)=>{const s=i(t.item,n);if(!s)return;if(!n.consumable.consume(t.item,"insert"))return;const o=n.mapper.toViewPosition(t.range.start);n.mapper.bindElements(t.item,s),n.writer.insert(o,s)}),{priority:e.converterPriority||"normal"}),e.triggerBy){if(e.triggerBy.attributes)for(const i of e.triggerBy.attributes)t._mapReconversionTriggerEvent(e.model,`attribute:${i}:${e.model}`);if(e.triggerBy.children)for(const i of e.triggerBy.children)t._mapReconversionTriggerEvent(e.model,"insert:"+i),t._mapReconversionTriggerEvent(e.model,"remove:"+i)}}}(e))}attributeToElement(e){return this.add(function(e){e=xa(e);let t="attribute:"+(e.model.key?e.model.key:e.model);e.model.name&&(t+=":"+e.model.name);if(e.model.values)for(const t of e.model.values)e.view[t]=Sa(e.view[t],"attribute");else e.view=Sa(e.view,"attribute");const i=Ra(e);return n=>{n.on(t,function(e){return(t,i,n)=>{const s=e(i.attributeOldValue,n),o=e(i.attributeNewValue,n);if(!s&&!o)return;if(!n.consumable.consume(i.item,t.name))return;const r=n.writer,a=r.document.selection;if(i.item instanceof ma||i.item instanceof ya)r.wrap(a.getFirstRange(),o);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&s&&(e=r.unwrap(e,s)),null!==i.attributeNewValue&&o&&r.wrap(e,o)}}}(i),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=xa(e);let t="attribute:"+(e.model.key?e.model.key:e.model);e.model.name&&(t+=":"+e.model.name);if(e.model.values)for(const t of e.model.values)e.view[t]=Ia(e.view[t]);else e.view=Ia(e.view);const i=Ra(e);return n=>{var s;n.on(t,(s=i,(e,t,i)=>{const n=s(t.attributeOldValue,i),o=s(t.attributeNewValue,i);if(!n&&!o)return;if(!i.consumable.consume(t.item,e.name))return;const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new l.a("conversion-attribute-to-attribute-on-text",[t,i]);if(null!==t.attributeOldValue&&n)if("class"==n.key){const e=en(n.value);for(const t of e)a.removeClass(t,r)}else if("style"==n.key){const e=Object.keys(n.value);for(const t of e)a.removeStyle(t,r)}else a.removeAttribute(n.key,r);if(null!==t.attributeNewValue&&o)if("class"==o.key){const e=en(o.value);for(const t of e)a.addClass(t,r)}else if("style"==o.key){const e=Object.keys(o.value);for(const t of e)a.setStyle(t,o.value[t],r)}else a.setAttribute(o.key,o.value,r)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){return(e=xa(e)).view=Sa(e.view,"ui"),t=>{var i;t.on("addMarker:"+e.model,(i=e.view,(e,t,n)=>{t.isOpening=!0;const s=i(t,n);t.isOpening=!1;const o=i(t,n);if(!s||!o)return;const r=t.markerRange;if(r.isCollapsed&&!n.consumable.consume(r,e.name))return;for(const t of r)if(!n.consumable.consume(t.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(r.start),s),n.mapper.bindElementToMarker(s,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),n.mapper.bindElementToMarker(o,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),t.on("removeMarker:"+e.model,(e.view,(e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on("addMarker:"+e.model,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof ma||t.item instanceof ya||t.item.is("$textProxy")))return;const s=Va(i,t,n);if(!s)return;if(!n.consumable.consume(t.item,e.name))return;const o=n.writer,r=Pa(o,s),a=o.document.selection;if(t.item instanceof ma||t.item instanceof ya)o.wrap(a.getFirstRange(),r,a);else{const e=n.mapper.toViewRange(t.range),i=o.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on("addMarker:"+e.model,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof Xr))return;const s=Va(e,i,n);if(!s)return;if(!n.consumable.test(i.item,t.name))return;const o=n.mapper.toViewElement(i.item);if(o&&o.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of oa._createIn(i.item))n.consumable.consume(e.item,t.name);o.getCustomProperty("addHighlight")(o,s,n.writer),n.mapper.bindElementToMarker(o,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on("removeMarker:"+e.model,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const s=Va(e,i,n);if(!s)return;const o=Pa(n.writer,s),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(e),o):e.getCustomProperty("removeHighlight")(e,s.id,n.writer);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=xa(e)).model;e.view||(e.view=i=>({group:t,name:i.substr(e.model.length+1)}));return i=>{var n;i.on("addMarker:"+t,(n=e.view,(e,t,i)=>{const s=n(t.markerName,i);if(!s)return;const o=t.markerRange;i.consumable.consume(o,e.name)&&(Ea(o,!1,i,t,s),Ea(o,!0,i,t,s),e.stop())}),{priority:e.converterPriority||"normal"}),i.on("removeMarker:"+t,function(e){return(t,i,n)=>{const s=e(i.markerName,n);if(!s)return;const o=n.mapper.markerNameToElements(i.markerName);if(o){for(const e of o)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${s.group}-start-before`,e),r(`data-${s.group}-start-after`,e),r(`data-${s.group}-end-before`,e),r(`data-${s.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(s.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}}function Pa(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),t.priority&&(i._priority=t.priority),i._id=t.id,i}function Ea(e,t,i,n,s){const o=t?e.start:e.end;if(i.schema.checkChild(o,"$text")){!function(e,t,i,n,s){const o=`${s.group}-${t?"start":"end"}`,r=s.name?{name:s.name}:null,a=i.writer.createUIElement(o,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(o),t,i,n,s)}else{let e,r;t&&o.nodeAfter||!t&&!o.nodeBefore?(e=o.nodeAfter,r=!0):(e=o.nodeBefore,r=!1);!function(e,t,i,n,s,o){const r=`data-${o.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(o.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,s.markerName)}(i.mapper.toViewElement(e),t,r,i,n,s)}}function Sa(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){"string"==typeof e&&(e={name:e});let n;const s=t.writer,o=Object.assign({},e.attributes);if("container"==i)n=s.createContainerElement(e.name,o);else if("attribute"==i){const t={priority:e.priority||ys.DEFAULT_PRIORITY};n=s.createAttributeElement(e.name,o,t)}else n=s.createUIElement(e.name,o);if(e.styles){const t=Object.keys(e.styles);for(const i of t)s.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)s.addClass(t,n);else for(const e of t)s.addClass(e,n)}return n}(e,n,t)}function Ra(e){return e.model.values?(t,i)=>{const n=e.view[t];return n?n(t,i):null}:e.view}function Ia(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Va(e,t,i){const n="function"==typeof e?e(t,i):e;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Oa(e){const{schema:t,document:i}=e.model;for(const n of i.getRootNames()){const s=i.getRoot(n);if(s.isEmpty&&!t.checkChild(s,"$text")&&t.checkChild(s,"paragraph"))return e.insertElement("paragraph",s),!0}return!1}function Na(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function Ma(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ba extends Aa{elementToElement(e){return this.add(Fa(e))}elementToAttribute(e){return this.add(function(e){La(e=xa(e));const t=Ha(e,!1),i=Da(e.view),n=i?"element:"+i:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=xa(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key;let i;if("class"==t||"style"==t){i={["class"==t?"classes":"styles"]:e.view.value}}else{const n=void 0===e.view.value?/[\s\S]*/:e.view.value;i={attributes:{[t]:n}}}e.view.name&&(i.name=e.view.name);return e.view=i,t}(e));La(e,t);const i=Ha(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return Object(l.b)("upcast-helpers-element-to-marker-deprecated"),this.add(function(e){return function(e){const t=e.model;e.model=(e,i)=>{const n="string"==typeof t?t:t(e,i);return i.writer.createElement("$marker",{"data-name":n})}}(e=xa(e)),Fa(e)}(e))}dataToMarker(e){return this.add(function(e){(e=xa(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t=za(ja(e,"start")),i=za(ja(e,"end"));return n=>{n.on("element:"+e.view+"-start",t,{priority:e.converterPriority||"normal"}),n.on("element:"+e.view+"-end",i,{priority:e.converterPriority||"normal"});const s=a.get("low"),o=a.get("highest"),r=a.get(e.converterPriority)/o;n.on("element",function(e){return(t,i,n)=>{const s="data-"+e.view;function o(t,s){for(const o of s){const s=e.model(o,n),r=n.writer.createElement("$marker",{"data-name":s});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}i.modelRange||(i=Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor))),n.consumable.consume(i.viewItem,{attributes:s+"-end-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-end-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-start-before").split(","))}}(e),{priority:s+r})}}(e))}}function Fa(e){const t=za(e=xa(e)),i=Da(e.view),n=i?"element:"+i:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function Da(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function za(e){const t=new fn(e.view);return(i,n,s)=>{const o=t.match(n.viewItem);if(!o)return;const r=o.match;if(r.name=!0,!s.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,s);a&&s.safeInsert(a,n.modelCursor)&&(s.consumable.consume(n.viewItem,r),s.convertChildren(n.viewItem,a),s.updateConversionResult(a,n))}}function La(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,s="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:s}}function Ha(e,t){const i=new fn(e.view);return(n,s,o)=>{const r=i.match(s.viewItem);if(!r)return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(s.viewItem,o):e.model.value;if(null===l)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!Da(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,s.viewItem)?delete r.match.name:r.match.name=!0,!o.consumable.test(s.viewItem,r.match))return;s.modelRange||(s=Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor)));(function(e,t,i,n){let s=!1;for(const o of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(o,t.key)&&(s=!0,o.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,o));return s})(s.modelRange,{key:a,value:l},t,o)&&o.consumable.consume(s.viewItem,r.match)}}function ja(e,t){const i={};return i.view=e.view+"-"+t,i.model=(t,i)=>{const n=t.getAttribute("name"),s=e.model(n,i);return i.writer.createElement("$marker",{"data-name":s})},i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wa{constructor(e,t){this.model=e,this.view=new Kr(t),this.mapper=new ra,this.downcastDispatcher=new ca({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.selection,s=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(i,"change",()=>{this.view.change(e=>{this.downcastDispatcher.convertChanges(i.differ,s,e),this.downcastDispatcher.convertSelection(n,s,e)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const s=n.newSelection,o=[];for(const e of s.getRanges())o.push(t.toModelRange(e));const r=e.createSelection(o,{backward:s.isBackward});r.isEqual(e.document.selection)||e.change(e=>{e.setSelection(r)})}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",(e,t,i)=>{if(!i.consumable.consume(t.item,"insert"))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)},{priority:"lowest"}),this.downcastDispatcher.on("remove",(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),s=t.position.getShiftedBy(t.length),o=i.mapper.toViewPosition(s,{isPhantom:!0}),r=i.writer.createRange(n,o),a=i.writer.remove(r.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e)},{priority:"low"}),this.downcastDispatcher.on("selection",(e,t,i)=>{const n=i.writer,s=n.document.selection;for(const e of s.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)},{priority:"low"}),this.downcastDispatcher.on("selection",(e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=[];for(const e of n.getRanges()){const t=i.mapper.toViewRange(e);s.push(t)}i.writer.setSelection(s,{backward:n.isBackward})},{priority:"low"}),this.downcastDispatcher.on("selection",(e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=i.writer,o=n.getFirstPosition(),r=i.mapper.toViewPosition(o),a=s.breakAttributes(r);s.setSelection(a)},{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(e=>{if("$graveyard"==e.rootName)return null;const t=new os(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t})}destroy(){this.view.destroy(),this.stopListening()}}Je(Wa,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class qa{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new l.a("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $a{constructor(){this._consumables=new Map}add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new Ua(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const n=e.getClassNames();for(const e of n)t.classes.push(e);const s=e.getStyleNames();for(const e of s)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new $a(e)),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,$a.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=$a.createFrom(i,t);return t}}class Ua{constructor(e){this.element=e,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(e){e.name&&(this._canConsumeName=!0);for(const t in this._consumables)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t in this._consumables)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t in this._consumables)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t in this._consumables)t in e&&this._revert(t,e[t])}_add(e,t){const i=ve(t)?t:[t],n=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new l.a("viewconsumable-invalid-attribute",this);if(n.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!0)}}_test(e,t){const i=ve(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=n.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=ve(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(n.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=ve(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){!1===n.get(t)&&n.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ka{constructor(){this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new Ga(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new Ga(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new l.a("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},t)],this._clearCache()}extend(e,t){if(!this._sourceDefinitions[e])throw new l.a("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:e.is&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!!t&&!(!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!!t&&!(!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!!t&&!(!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t=null){if(e instanceof ta){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof Xr))throw new l.a("schema-check-merge-no-element-before",this);if(!(i instanceof Xr))throw new l.a("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",(t,[i,n])=>{if(!n)return;const s=e(i,n);"boolean"==typeof s&&(t.stop(),t.return=s)},{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",(t,[i,n])=>{const s=e(i,n);"boolean"==typeof s&&(t.stop(),t.return=s)},{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;if(e instanceof ta)t=e.parent;else{t=(e instanceof oa?[e]:Array.from(e.getRanges())).reduce((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i},null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Jr("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if(this.checkChild(e,"$text"))return new oa(e);let i,n;const s=e.getAncestors().reverse().find(e=>this.isLimit(e))||e.root;"both"!=t&&"backward"!=t||(i=new Zr({boundaries:oa._createIn(s),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new Zr({boundaries:oa._createIn(s),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return oa._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new oa(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))ol(this,i,t);else{const e=oa._createIn(i).getPositions();for(const i of e){ol(this,i.nodeBefore||i.parent,t)}}}createContext(e){return new Ga(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=Ja(t[n],n);for(const t of i)Ya(e,t);for(const t of i)Qa(e,t);for(const t of i)Xa(e,t),Za(e,t);for(const t of i)el(e,t),tl(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const n=t.getItem(i);if(e.allowIn.includes(n.name)){if(0==i)return!0;{const e=this.getDefinition(n);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const s of e.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(oa._createIn(s),t)),this.checkAttribute(s,t)||(i.isEqual(n)||(yield new oa(i,n)),i=ta._createAfter(s)),n=ta._createAfter(s);i.isEqual(n)||(yield new oa(i,n))}}Je(Ka,We);class Ga{constructor(e){if(e instanceof Ga)return e;"string"==typeof e?e=[e]:Array.isArray(e)||(e=e.getAncestors({includeSelf:!0})),this._items=e.map(sl)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new Ga([e]);return t._items=[...this._items,...t._items],t}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function Ja(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter(e=>e.startsWith("is"));for(const n of e)t[n]=i[n]}}(e,i),il(e,i,"allowIn"),il(e,i,"allowContentOf"),il(e,i,"allowWhere"),il(e,i,"allowAttributes"),il(e,i,"allowAttributesOf"),il(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function Ya(e,t){for(const i of e[t].allowContentOf)if(e[i]){nl(e,i).forEach(e=>{e.allowIn.push(t)})}delete e[t].allowContentOf}function Qa(e,t){for(const i of e[t].allowWhere){const n=e[i];if(n){const i=n.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function Xa(e,t){for(const i of e[t].allowAttributesOf){const n=e[i];if(n){const i=n.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function Za(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const n=e[t];if(n){const e=Object.keys(n).filter(e=>e.startsWith("is"));for(const t of e)t in i||(i[t]=n[t])}}delete i.inheritTypesFrom}function el(e,t){const i=e[t],n=i.allowIn.filter(t=>e[t]);i.allowIn=Array.from(new Set(n))}function tl(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function il(e,t,i){for(const n of e)"string"==typeof n[i]?t[i].push(n[i]):Array.isArray(n[i])&&t[i].push(...n[i])}function nl(e,t){const i=e[t];return(n=e,Object.keys(n).map(e=>n[e])).filter(e=>e.allowIn.includes(i.name));var n}function sl(e){return"string"==typeof e||e.is("documentFragment")?{name:"string"==typeof e?e:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:e.is("element")?e.name:"$text",*getAttributeKeys(){yield*e.getAttributeKeys()},getAttribute:t=>e.getAttribute(t)}}function ol(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rl{constructor(e={}){this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this.conversionApi=Object.assign({},e),this.conversionApi.convertItem=this._convertItem.bind(this),this.conversionApi.convertChildren=this._convertChildren.bind(this),this.conversionApi.safeInsert=this._safeInsert.bind(this),this.conversionApi.updateConversionResult=this._updateConversionResult.bind(this),this.conversionApi.splitToAllowedParent=this._splitToAllowedParent.bind(this),this.conversionApi.getSplitParts=this._getSplitParts.bind(this)}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new Ga(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const s=t.createElement(n.name,e);i&&t.append(s,i),i=ta._createAt(s,0)}return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=$a.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,s);s.markers=function(e,t){const i=new Set,n=new Map,s=oa._createIn(e).getItems();for(const e of s)"$marker"==e.name&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),s=t.createPositionBefore(e);n.has(i)?n.get(i).end=s.clone():n.set(i,new oa(s.clone())),t.remove(e)}return n}(s,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(e,t){const i=Object.assign({viewItem:e,modelCursor:t,modelRange:null});if(e.is("element")?this.fire("element:"+e.name,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof oa))throw new l.a("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:ta._createAt(t,0);const n=new oa(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof oa&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const s=this._cursorParents.get(e);t.modelCursor=s?n.createPositionAt(s,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let s=i.findAllowedParent(t,e);if(s){if(s===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(s)&&(s=null)}if(!s)return Na(t,e,i)?{position:Ma(t,n)}:null;const o=this.conversionApi.writer.split(t,s),r=[];for(const e of o.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=o.range.end.parent;return this._cursorParents.set(e,a),{position:o.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_removeEmptyElements(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}}Je(rl,d);class al{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ll{constructor(e){this._domParser=new DOMParser,this._domConverter=new To(e,{blockFillerMode:"nbsp"}),this._htmlWriter=new al}toData(e){const t=this._domConverter.viewToDom(e,document);return this._htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this._domConverter.domToView(t)}registerRawContentMatcher(e){this._domConverter.registerRawContentMatcher(e)}useFillerType(e){this._domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){const t=this._domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cl{constructor(e,t){this.model=e,this.mapper=new ra,this.downcastDispatcher=new ca({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",(e,t,i)=>{if(!i.consumable.consume(t.item,"insert"))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)},{priority:"lowest"}),this.upcastDispatcher=new rl({schema:e.schema}),this.viewDocument=new vs(t),this.stylesProcessor=t,this.htmlProcessor=new ll(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Ws(this.viewDocument),this.upcastDispatcher.on("text",(e,t,{schema:i,consumable:n,writer:s})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(o,"$text")){if(!Na(o,"$text",i))return;o=Ma(o,s)}n.consume(t.viewItem);const r=s.createText(t.viewItem.data);s.insert(r,o),t.modelRange=s.createRange(o,o.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end},{priority:"lowest"}),this.upcastDispatcher.on("element",(e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}},{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",(e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}},{priority:"lowest"}),this.decorate("init"),this.decorate("set"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange("transparent",Oa)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new l.a("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const s=oa._createIn(e),o=new js(i);this.mapper.bindElements(e,o),this.downcastDispatcher.conversionApi.options=t,this.downcastDispatcher.convertInsert(s,n);const r=e.is("documentFragment")?Array.from(e.markers):function(e){const t=[],i=e.root.document;if(!i)return[];const n=oa._createIn(e);for(const e of i.model.markers){const i=n.getIntersection(e.getRange());i&&t.push([e.name,i])}return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);for(const[e,t]of r)this.downcastDispatcher.convertMarkerAdd(e,t,n);return delete this.downcastDispatcher.conversionApi.options,o}init(e){if(this.model.document.version)throw new l.a("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new l.a("datacontroller-init-non-existent-root",this);return this.model.enqueueChange("transparent",e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}}),Promise.resolve()}set(e){let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new l.a("datacontroller-set-non-existent-root",this);this.model.enqueueChange("transparent",e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.remove(e.createRangeIn(n)),e.insert(this.parse(t[i],n),n,0)}})}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change(i=>this.upcastDispatcher.convert(e,i,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRootNames().includes(t))return!1;return!0}}Je(cl,We);class hl{constructor(e,t){this._helpers=new Map,this._downcast=en(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=en(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new l.a("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new l.a("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of dl(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of dl(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of dl(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new l.a("conversion-group-exists",this);const n=i?new Ta(t):new Ba(t);this._helpers.set(e,n)}}function*dl(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],s=e.upcastAlso?e.upcastAlso[t]:void 0;yield*ul(i,n,s)}else yield*ul(e.model,e.view,e.upcastAlso)}function*ul(e,t,i){if(yield{model:e,view:t},i)for(const t of en(i))yield{model:e,view:t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ml{constructor(e="default"){this.operations=[],this.type=e}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.batch=this,this.operations.push(e),e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fl{constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e){return new this(e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gl{constructor(e){this.markers=new Map,this._children=new Qr,e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}is(e){return"documentFragment"===e||"model:documentFragment"===e}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(Xr.fromJSON(i)):t.push(Jr.fromJSON(i));return new gl(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Jr(e)];Qi(e)||(e=[e]);return Array.from(e).map(e=>"string"==typeof e?new Jr(e):e instanceof Yr?new Jr(e.data,e.getAttributes()):e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}}function pl(e,t){const i=(t=_l(t)).reduce((e,t)=>e+t.offsetSize,0),n=e.parent;yl(e);const s=e.index;return n._insertChild(s,t),vl(n,s+t.length),vl(n,s),new oa(e,e.getShiftedBy(i))}function wl(e){if(!e.isFlat)throw new l.a("operation-utils-remove-range-not-flat",this);const t=e.start.parent;yl(e.start),yl(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return vl(t,e.start.index),i}function bl(e,t){if(!e.isFlat)throw new l.a("operation-utils-move-range-not-flat",this);const i=wl(e);return pl(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function _l(e){const t=[];e instanceof Array||(e=[e]);for(let i=0;i<e.length;i++)if("string"==typeof e[i])t.push(new Jr(e[i]));else if(e[i]instanceof Yr)t.push(new Jr(e[i].data,e[i].getAttributes()));else if(e[i]instanceof gl||e[i]instanceof Qr)for(const n of e[i])t.push(n);else e[i]instanceof Gr&&t.push(e[i]);for(let e=1;e<t.length;e++){const i=t[e],n=t[e-1];i instanceof Jr&&n instanceof Jr&&kl(i,n)&&(t.splice(e-1,2,new Jr(n.data+i.data,n.getAttributes())),e--)}return t}function vl(e,t){const i=e.getChild(t-1),n=e.getChild(t);if(i&&n&&i.is("$text")&&n.is("$text")&&kl(i,n)){const s=new Jr(i.data+n.data,i.getAttributes());e._removeChildren(t-1,2),e._insertChild(t-1,s)}}function yl(e){const t=e.textNode,i=e.parent;if(t){const n=e.offset-t.startOffset,s=t.index;i._removeChildren(s,1);const o=new Jr(t.data.substr(0,n),t.getAttributes()),r=new Jr(t.data.substr(n),t.getAttributes());i._insertChild(s,[o,r])}}function kl(e,t){const i=e.getAttributes(),n=t.getAttributes();for(const e of i){if(e[1]!==t.getAttribute(e[0]))return!1;n.next()}return n.next().done}var Cl=function(e,t){return Qo(e,t)};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Al extends fl{constructor(e,t,i,n,s){super(s),this.range=e.clone(),this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}get type(){return null===this.oldValue?"addAttribute":null===this.newValue?"removeAttribute":"changeAttribute"}clone(){return new Al(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Al(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new l.a("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!Cl(e.getAttribute(this.key),this.oldValue))throw new l.a("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(null===this.oldValue&&null!==this.newValue&&e.hasAttribute(this.key))throw new l.a("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){Cl(this.oldValue,this.newValue)||function(e,t,i){yl(e.start),yl(e.end);for(const n of e.getItems({shallow:!0})){const e=n.is("$textProxy")?n.textNode:n;null!==i?e._setAttribute(t,i):e._removeAttribute(t),vl(e.parent,e.index)}vl(e.end.parent,e.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new Al(oa.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xl extends fl{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new l.a("detach-operation-on-document-node",this)}_execute(){wl(oa._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tl extends fl{constructor(e,t,i,n){super(n),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNone"}get type(){return"$graveyard"==this.targetPosition.root.rootName?"remove":"$graveyard"==this.sourcePosition.root.rootName?"reinsert":"move"}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new this.constructor(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,i=this.sourcePosition.offset,n=this.targetPosition.offset;if(i+this.howMany>e.maxOffset)throw new l.a("move-operation-nodes-do-not-exist",this);if(e===t&&i<n&&n<i+this.howMany)throw new l.a("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&"prefix"==ln(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())){const e=this.sourcePosition.path.length-1;if(this.targetPosition.path[e]>=i&&this.targetPosition.path[e]<i+this.howMany)throw new l.a("move-operation-node-into-itself",this)}}_execute(){bl(oa._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){const i=ta.fromJSON(e.sourcePosition,t),n=ta.fromJSON(e.targetPosition,t);return new this(i,e.howMany,n,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pl extends fl{constructor(e,t,i){super(i),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new Qr(_l(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}clone(){const e=new Qr([...this.nodes].map(e=>e._clone(!0))),t=new Pl(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new ta(e,[0]);return new Tl(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new l.a("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new Qr([...e].map(e=>e._clone(!0))),pl(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const t of e.nodes)t.name?i.push(Xr.fromJSON(t)):i.push(Jr.fromJSON(t));const n=new Pl(ta.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class El extends fl{constructor(e,t,i,n,s,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=i?i.clone():null,this.affectsData=s,this._markers=n}get type(){return"marker"}clone(){return new El(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new El(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){const e=this.newRange?"_set":"_remove";this._markers[e](this.name,this.newRange,!0,this.affectsData)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new El(e.name,e.oldRange?oa.fromJSON(e.oldRange,t):null,e.newRange?oa.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sl extends fl{constructor(e,t,i,n){super(n),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=i}get type(){return"rename"}clone(){return new Sl(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new Sl(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof Xr))throw new l.a("rename-operation-wrong-position",this);if(e.name!==this.oldName)throw new l.a("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new Sl(ta.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rl extends fl{constructor(e,t,i,n,s){super(s),this.root=e,this.key=t,this.oldValue=i,this.newValue=n}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new Rl(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Rl(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new l.a("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(null!==this.oldValue&&this.root.getAttribute(this.key)!==this.oldValue)throw new l.a("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new l.a("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new l.a("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new Rl(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Il extends fl{constructor(e,t,i,n,s){super(s),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=n.clone()}get type(){return"merge"}get deletionPosition(){return new ta(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new oa(this.sourcePosition,e)}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),i=new ta(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new Vl(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new l.a("merge-operation-source-position-invalid",this);if(!t.parent)throw new l.a("merge-operation-target-position-invalid",this);if(this.howMany!=e.maxOffset)throw new l.a("merge-operation-how-many-invalid",this)}_execute(){const e=this.sourcePosition.parent;bl(oa._createIn(e),this.targetPosition),bl(oa._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const i=ta.fromJSON(e.sourcePosition,t),n=ta.fromJSON(e.targetPosition,t),s=ta.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,n,s,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vl extends fl{constructor(e,t,i,n,s){super(s),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new ta(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new oa(this.splitPosition,e)}clone(){return new this.constructor(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new ta(e,[0]);return new Il(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new l.a("split-operation-position-invalid",this);if(!e.parent)throw new l.a("split-operation-split-in-root",this);if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new l.a("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new l.a("split-operation-graveyard-position-invalid",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)bl(oa._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const t=e._clone();pl(this.insertionPosition,t)}bl(new oa(ta._createAt(e,this.splitPosition.offset),ta._createAt(e,e.maxOffset)),this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const t=e.path.slice(0,-1);return t[t.length-1]++,new ta(e.root,t,"toPrevious")}static fromJSON(e,t){const i=ta.fromJSON(e.splitPosition,t),n=ta.fromJSON(e.insertionPosition,t),s=e.graveyardPosition?ta.fromJSON(e.graveyardPosition,t):null;return new this(i,e.howMany,n,s,e.baseVersion)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ol extends Xr{constructor(e,t,i="main"){super(t),this._document=e,this.rootName=i}get document(){return this._document}is(e,t){return t?t===this.name&&("rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e):"rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e||"node"===e||"model:node"===e}toJSON(){return this.rootName}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Nl{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Jr(e,t)}createElement(e,t){return new Xr(e,t)}createDocumentFragment(){return new gl}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Jr&&""==e.data)return;const n=ta._createAt(t,i);if(e.parent){if(zl(e.root,n.root))return void this.move(oa._createOn(e),n);if(e.root.document)throw new l.a("model-writer-insert-forbidden-move",this);this.remove(e)}const s=n.root.document?n.root.document.version:null,o=new Pl(n,e,s);if(e instanceof Jr&&(o.shouldReceiveAttributes=!0),this.batch.addOperation(o),this.model.applyOperation(o),e instanceof gl)for(const[t,i]of e.markers){const e=ta._createAt(i.root,0),s={range:new oa(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,s):this.addMarker(t,s)}}insertText(e,t,i,n){t instanceof gl||t instanceof Xr||t instanceof ta?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof gl||t instanceof Xr||t instanceof ta?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof gl||t instanceof Xr?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof gl||t instanceof Xr?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof oa){const n=i.getMinimalFlatRanges();for(const i of n)Ml(this,e,t,i)}else Bl(this,e,t,i)}setAttributes(e,t){for(const[i,n]of mn(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof oa){const i=t.getMinimalFlatRanges();for(const t of i)Ml(this,e,null,t)}else Bl(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof oa)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof oa))throw new l.a("writer-move-invalid-range",this);if(!e.isFlat)throw new l.a("writer-move-range-not-flat",this);const n=ta._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!zl(e.root,n.root))throw new l.a("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,o=new Tl(e.start,e.end.offset-e.start.offset,n,s);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof oa?e:oa._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Dl(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof Xr))throw new l.a("writer-merge-no-element-before",this);if(!(i instanceof Xr))throw new l.a("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(e,t,i){return this.model.createSelection(e,t,i)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(oa._createIn(i),ta._createAt(t,"end")),this.remove(i)}_merge(e){const t=ta._createAt(e.nodeBefore,"end"),i=ta._createAt(e.nodeAfter,0),n=e.root.document.graveyard,s=new ta(n,[0]),o=e.root.document.version,r=new Il(i,e.nodeAfter.maxOffset,t,s,o);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Xr))throw new l.a("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new Sl(ta._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,s=e.parent;if(!s.parent)throw new l.a("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new l.a("writer-split-invalid-limit-element",this);do{const t=s.root.document?s.root.document.version:null,o=s.maxOffset-e.offset,r=Vl.getInsertionPosition(e),a=new Vl(e,o,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=s,n=e.parent.nextSibling),s=(e=this.createPositionAfter(e.parent)).parent}while(s!==t);return{position:e,range:new oa(ta._createAt(i,"end"),ta._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new l.a("writer-wrap-range-not-flat",this);const i=t instanceof Xr?t:new Xr(t);if(i.childCount>0)throw new l.a("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new l.a("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new oa(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,ta._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new l.a("writer-unwrap-element-no-parent",this);this.move(oa._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new l.a("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,s=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new l.a("writer-addmarker-marker-exists",this);if(!n)throw new l.a("writer-addmarker-no-range",this);return i?(Fl(this,e,null,n,s),this.model.markers.get(e)):this.model.markers._set(e,n,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new l.a("writer-updatemarker-marker-not-exists",this);if(!t)return void this.model.markers._refresh(n);const s="boolean"==typeof t.usingOperation,o="boolean"==typeof t.affectsData,r=o?t.affectsData:n.affectsData;if(!s&&!t.range&&!o)throw new l.a("writer-updatemarker-wrong-options",this);const a=n.getRange(),c=t.range?t.range:a;s&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?Fl(this,i,null,c,r):(Fl(this,i,a,null,r),this.model.markers._set(i,c,void 0,r)):n.managedUsingOperations?Fl(this,i,a,c,r):this.model.markers._set(i,c,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new l.a("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);Fl(this,t,i.getRange(),null,i.affectsData)}setSelection(e,t,i){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(e,t,i)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of mn(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=ya._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=ya._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new l.a("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let s=!1;if("move"===e)s=t.containsPosition(n.start)||t.start.isEqual(n.start)||t.containsPosition(n.end)||t.end.isEqual(n.end);else{const e=t.nodeBefore,i=t.nodeAfter,o=n.start.parent==e&&n.start.isAtEnd,r=n.end.parent==i&&0==n.end.offset,a=n.end.nodeAfter==i,l=n.start.nodeAfter==i;s=o||r||a||l}s&&this.updateMarker(i.name,{range:n})}}}function Ml(e,t,i,n){const s=e.model,o=s.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&h(),c=r),r=e.nextPosition,a=l;function h(){const n=new oa(c,r),l=n.root.document?o.version:null,h=new Al(n,t,a,i,l);e.batch.addOperation(h),s.applyOperation(h)}r instanceof ta&&r!=c&&a!=i&&h()}function Bl(e,t,i,n){const s=e.model,o=s.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?o.version:null;l=new Rl(n,t,r,i,e)}else{a=new oa(ta._createBefore(n),e.createPositionAfter(n));const s=a.root.document?o.version:null;l=new Al(a,t,r,i,s)}e.batch.addOperation(l),s.applyOperation(l)}}function Fl(e,t,i,n,s){const o=e.model,r=o.document,a=new El(t,i,n,o.markers,s,r.version);e.batch.addOperation(a),o.applyOperation(a)}function Dl(e,t,i,n){let s;if(e.root.document){const i=n.document,o=new ta(i.graveyard,[0]);s=new Tl(e,t,o,i.version)}else s=new xl(e,t);i.addOperation(s),n.applyOperation(s)}function zl(e,t){return e===t||e instanceof Ol&&t instanceof Ol}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ll{constructor(e){this._markerCollection=e,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size}refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize);const t=oa._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getRange();this.bufferMarkerChange(e.name,t,t,e.affectsData)}this._cachedChanges=null}bufferOperation(e){switch(e.type){case"insert":if(this._isInInsertedElement(e.position.parent))return;this._markInsert(e.position.parent,e.position.offset,e.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const t of e.range.getItems({shallow:!0}))this._isInInsertedElement(t.parent)||this._markAttribute(t);break;case"remove":case"move":case"reinsert":{if(e.sourcePosition.isEqual(e.targetPosition)||e.sourcePosition.getShiftedBy(e.howMany).isEqual(e.targetPosition))return;const t=this._isInInsertedElement(e.sourcePosition.parent),i=this._isInInsertedElement(e.targetPosition.parent);t||this._markRemove(e.sourcePosition.parent,e.sourcePosition.offset,e.howMany),i||this._markInsert(e.targetPosition.parent,e.getMovedRangeStart().offset,e.howMany);break}case"rename":{if(this._isInInsertedElement(e.position.parent))return;this._markRemove(e.position.parent,e.position.offset,1),this._markInsert(e.position.parent,e.position.offset,1);const t=oa._createFromPositionAndShift(e.position,1);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getRange();this.bufferMarkerChange(e.name,t,t,e.affectsData)}break}case"split":{const t=e.splitPosition.parent;this._isInInsertedElement(t)||this._markRemove(t,e.splitPosition.offset,e.howMany),this._isInInsertedElement(e.insertionPosition.parent)||this._markInsert(e.insertionPosition.parent,e.insertionPosition.offset,1),e.graveyardPosition&&this._markRemove(e.graveyardPosition.parent,e.graveyardPosition.offset,1);break}case"merge":{const t=e.sourcePosition.parent;this._isInInsertedElement(t.parent)||this._markRemove(t.parent,t.startOffset,1);const i=e.graveyardPosition.parent;this._markInsert(i,e.graveyardPosition.offset,1);const n=e.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,e.targetPosition.offset,t.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i,n){const s=this._changedMarkers.get(e);s?(s.newRange=i,s.affectsData=n,null==s.oldRange&&null==s.newRange&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{oldRange:t,newRange:i,affectsData:n})}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldRange&&e.push({name:t,range:i.oldRange});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newRange&&e.push({name:t,range:i.newRange});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(e=>({name:e[0],data:{oldRange:e[1].oldRange,newRange:e[1].newRange}}))}hasDataChanges(){for(const[,e]of this._changedMarkers)if(e.affectsData)return!0;return this._changesInElement.size>0}getChanges(e={includeChangesInGraveyard:!1}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offset<t.offset?-1:1),n=this._elementSnapshots.get(e),s=Hl(e.getChildren()),o=jl(n.length,i);let r=0,a=0;for(const i of o)if("i"===i)t.push(this._getInsertDiff(e,r,s[r].name)),r++;else if("r"===i)t.push(this._getRemoveDiff(e,r,n[a].name)),a++;else if("a"===i){const i=s[r].attributes,o=n[a].attributes;let l;if("$text"==s[r].name)l=new oa(ta._createAt(e,r),ta._createAt(e,r+1));else{const t=e.offsetToIndex(r);l=new oa(ta._createAt(e,r),ta._createAt(e.getChild(t),0))}t.push(...this._getAttributesDiff(l,o,i)),r++,a++}else r++,a++}t.sort((e,t)=>e.position.root!=t.position.root?e.position.root.rootName<t.position.root.rootName?-1:1:e.position.isEqual(t.position)?e.changeCount-t.changeCount:e.position.isBefore(t.position)?-1:1);for(let e=1,i=0;e<t.length;e++){const n=t[i],s=t[e],o="remove"==n.type&&"remove"==s.type&&"$text"==n.name&&"$text"==s.name&&n.position.isEqual(s.position),r="insert"==n.type&&"insert"==s.type&&"$text"==n.name&&"$text"==s.name&&n.position.parent==s.position.parent&&n.position.offset+n.length==s.position.offset,a="attribute"==n.type&&"attribute"==s.type&&n.position.parent==s.position.parent&&n.range.isFlat&&s.range.isFlat&&n.position.offset+n.length==s.position.offset&&n.attributeKey==s.attributeKey&&n.attributeOldValue==s.attributeOldValue&&n.attributeNewValue==s.attributeNewValue;o||r||a?(n.length++,a&&(n.range.end=n.range.end.getShiftedBy(1)),t[e]=null):i=e}t=t.filter(e=>e);for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t.slice(),this._cachedChanges=t.filter(Wl),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard:this._cachedChanges}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._cachedChanges=null}_markInsert(e,t,i){const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;e<i.length;e++)i[e].howMany<1&&(i.splice(e,1),e--)}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshot(e){this._elementSnapshots.has(e)||this._elementSnapshots.set(e,Hl(e.getChildren()))}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const i of t){const n=e.offset+e.howMany,s=i.offset+i.howMany;if("insert"==e.type&&("insert"==i.type&&(e.offset<=i.offset?i.offset+=e.howMany:e.offset<s&&(i.howMany+=e.nodesToHandle,e.nodesToHandle=0)),"remove"==i.type&&e.offset<i.offset&&(i.offset+=e.howMany),"attribute"==i.type))if(e.offset<=i.offset)i.offset+=e.howMany;else if(e.offset<s){const s=i.howMany;i.howMany=e.offset-i.offset,t.unshift({type:"attribute",offset:n,howMany:s-i.howMany,count:this._changeCount++})}if("remove"==e.type){if("insert"==i.type)if(n<=i.offset)i.offset-=e.howMany;else if(n<=s)if(e.offset<i.offset){const t=n-i.offset;i.offset=e.offset,i.howMany-=t,e.nodesToHandle-=t}else i.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=i.offset)e.nodesToHandle-=i.howMany,i.howMany=0;else if(e.offset<s){const t=s-e.offset;i.howMany-=t,e.nodesToHandle-=t}if("remove"==i.type&&(n<=i.offset?i.offset-=e.howMany:e.offset<i.offset&&(e.nodesToHandle+=i.howMany,i.howMany=0)),"attribute"==i.type)if(n<=i.offset)i.offset-=e.howMany;else if(e.offset<i.offset){const t=n-i.offset;i.offset=e.offset,i.howMany-=t}else if(e.offset<s)if(n<=s){const n=i.howMany;i.howMany=e.offset-i.offset;const s=n-i.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:s,count:this._changeCount++})}else i.howMany-=s-e.offset}if("attribute"==e.type){if("insert"==i.type)if(e.offset<i.offset&&n>i.offset){if(n>s){const e={type:"attribute",offset:s,howMany:n-s,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offset<s&&(n>s?(e.nodesToHandle=n-s,e.offset=s):e.nodesToHandle=0);if("remove"==i.type&&e.offset<i.offset&&n>i.offset){const s={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(s,t),t.push(s),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=s?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=s&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:ta._createAt(e,t),name:i,length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,i){return{type:"remove",position:ta._createAt(e,t),name:i,length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[s,o]of t){const t=i.has(s)?i.get(s):null;t!==o&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:o,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(s)}for(const[t,s]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:s,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&n<e.offset+e.howMany)return!0;return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,i){const n=new oa(ta._createAt(e,t),ta._createAt(e,t+i));for(const e of n.getItems({shallow:!0}))e.is("element")&&(this._elementSnapshots.delete(e),this._changesInElement.delete(e),this._removeAllNestedChanges(e,0,e.maxOffset))}}function Hl(e){const t=[];for(const i of e)if(i.is("$text"))for(let e=0;e<i.data.length;e++)t.push({name:"$text",attributes:new Map(i.getAttributes())});else t.push({name:i.name,attributes:new Map(i.getAttributes())});return t}function jl(e,t){const i=[];let n=0,s=0;for(const e of t){if(e.offset>n){for(let t=0;t<e.offset-n;t++)i.push("e");s+=e.offset-n}if("insert"==e.type){for(let t=0;t<e.howMany;t++)i.push("i");n=e.offset+e.howMany}else if("remove"==e.type){for(let t=0;t<e.howMany;t++)i.push("r");n=e.offset,s+=e.howMany}else i.push(..."a".repeat(e.howMany).split("")),n=e.offset+e.howMany,s+=e.howMany}if(s<e)for(let t=0;t<e-s-n;t++)i.push("e");return i}function Wl(e){const t=e.position&&"$graveyard"==e.position.root.rootName,i=e.range&&"$graveyard"==e.range.root.rootName;return!t&&!i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ql{constructor(){this._operations=[],this._undoPairs=new Map,this._undoneOperations=new Set}addOperation(e){this._operations.includes(e)||this._operations.push(e)}getOperations(e=Number.NEGATIVE_INFINITY,t=Number.POSITIVE_INFINITY){const i=[];for(const n of this._operations)n.baseVersion>=e&&n.baseVersion<t&&i.push(n);return i}getOperation(e){for(const t of this._operations)if(t.baseVersion==e)return t}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function $l(e,t){return!!(i=e.charAt(t-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var i}function Ul(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Kl{constructor(e){this.model=e,this.version=0,this.history=new ql(this),this.selection=new ya(this),this.roots=new Xi({idProperty:"rootName"}),this.differ=new Ll(e.markers),this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root","$graveyard"),this.listenTo(e,"applyOperation",(e,t)=>{const i=t[0];if(i.isDocumentOperation&&i.baseVersion!==this.version)throw new l.a("model-document-applyoperation-wrong-version",this,{operation:i})},{priority:"highest"}),this.listenTo(e,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)},{priority:"high"}),this.listenTo(e,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&(this.version++,this.history.addOperation(i))},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(e,t,i,n)=>{this.differ.bufferMarkerChange(t.name,i,n,t.affectsData),null===i&&t.on("change",(e,i)=>{this.differ.bufferMarkerChange(t.name,i,t.getRange(),t.affectsData)})})}get graveyard(){return this.getRoot("$graveyard")}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new l.a("model-document-createroot-name-exists",this,{name:t});const i=new Ol(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(){return Array.from(this.roots,e=>e.rootName).filter(e=>"$graveyard"!=e)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=cn(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const e of this.roots)if(e!==this.graveyard)return e;return this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return Gl(e.start)&&Gl(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}}function Gl(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!$l(i,n)&&!Ul(i,n)}return!0}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Je(Kl,d);class Jl{constructor(){this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){return this._markers.has(e)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const s=e instanceof Yl?e.name:e;if(s.includes(","))throw new l.a("markercollection-incorrect-marker-name",this);const o=this._markers.get(s);if(o){const e=o.getRange();let r=!1;return e.isEqual(t)||(o._attachLiveRange(ba.fromRange(t)),r=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,r=!0),"boolean"==typeof n&&n!=o.affectsData&&(o._affectsData=n,r=!0),r&&this.fire("update:"+s,o,e,t),o}const r=ba.fromRange(t),a=new Yl(s,r,i,n);return this._markers.set(s,a),this.fire("update:"+s,a,null,t),a}_remove(e){const t=e instanceof Yl?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire("update:"+t,i,i.getRange(),null),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof Yl?e.name:e,i=this._markers.get(t);if(!i)throw new l.a("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire("update:"+t,i,n,n,i.managedUsingOperations,i.affectsData)}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}Je(Jl,d);class Yl{constructor(e,t,i,n){this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new l.a("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new l.a("marker-destroyed",this);return this._affectsData}getStart(){if(!this._liveRange)throw new l.a("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new l.a("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new l.a("marker-destroyed",this);return this._liveRange.toRange()}is(e){return"marker"===e||"model:marker"===e}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Je(Yl,d);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ql extends fl{get type(){return"noop"}clone(){return new Ql(this.baseVersion)}getReversed(){return new Ql(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Xl={};Xl[Al.className]=Al,Xl[Pl.className]=Pl,Xl[El.className]=El,Xl[Tl.className]=Tl,Xl[Ql.className]=Ql,Xl[fl.className]=fl,Xl[Sl.className]=Sl,Xl[Rl.className]=Rl,Xl[Vl.className]=Vl,Xl[Il.className]=Il;
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Zl extends ta{constructor(e,t,i="toNone"){if(super(e,t,i),!this.root.is("rootElement"))throw new l.a("model-liveposition-root-not-rootelement",e);ec.call(this)}detach(){this.stopListening()}is(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e}toPosition(){return new ta(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}function ec(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&tc.call(this,i)},{priority:"low"})}function tc(e){const t=this.getTransformedByOperation(e);if(!this.isEqual(t)){const e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}Je(Zl,d);class ic{constructor(e,t,i){this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0),this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new l.a("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this.nodeToSelect?oa._createOn(this.nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new oa(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(this.schema.isObject(e))return void this._handleObject(e);let t=this._checkAndAutoParagraphToAllowedPosition(e);t||(t=this._checkAndSplitToAllowedPosition(e),t)?(this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=Zl.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleObject(e){this._checkAndSplitToAllowedPosition(e)?this._appendToFragment(e):this._tryAutoparagraphing(e)}_handleDisallowedNode(e){e.is("element")?this.handleNodes(e.getChildren()):this._tryAutoparagraphing(e)}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new l.a("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this.nodeToSelect=e:this.nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=Zl.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=Zl.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof Xr))return;if(!this._canMergeLeft(e))return;const t=Zl._createBefore(e);t.stickiness="toNext";const i=Zl.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=Zl._createAt(t.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=Zl._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof Xr))return;if(!this._canMergeRight(e))return;const t=Zl._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new l.a("insertcontent-invalid-insertion-position",this);this.position=ta._createAt(t.nodeBefore,"end");const i=Zl.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=Zl._createAt(t.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=Zl._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof Xr&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof Xr&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_tryAutoparagraphing(e){const t=this.writer.createElement("paragraph");this._getAllowedIn(t,this.position.parent)&&this.schema.checkChild(t,e)&&(t._appendChild(e),this._handleNode(t))}_checkAndAutoParagraphToAllowedPosition(e){if(this.schema.checkChild(this.position.parent,e))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",e))return!1;this._insertPartialFragment();const t=this.writer.createElement("paragraph");return this.writer.insert(t,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=t,this.position=this.writer.createPositionAt(t,0),!0}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(e,this.position.parent);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;){if(this.schema.isLimit(this.position.parent))return!1;if(this.position.isAtStart){const e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const e=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=e,this.canMergeWith.add(this.position.nodeAfter)}}return!0}_getAllowedIn(e,t){return this.schema.checkChild(t,e)?t:t.parent?this._getAllowedIn(e,t.parent):null}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function nc(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const s=e.schema;e.change(e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();if(n.start.parent==n.end.parent)return!1;return e.checkChild(i,"paragraph")}(s,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),oc(e,e.createPositionAt(i,0),t)}(e,t);const[o,r]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"}),n=i.getLastPosition()}}return[Zl.fromPosition(i,"toPrevious"),Zl.fromPosition(n,"toNext")]}(n);o.isTouching(r)||e.remove(e.createRange(o,r)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!sc(e.model.schema,t,i))return;const[s,o]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let s=0;for(;i[s]&&i[s]==n[s];)s++;return[i[s],n[s]]}(t,i);if(!s||!o)return;!n.hasContent(s,{ignoreMarkers:!0})&&n.hasContent(o,{ignoreMarkers:!0})?function e(t,i,n,s){const o=i.parent,r=n.parent;if(o==s||r==s)return;i=t.createPositionAfter(o),(n=t.createPositionBefore(r)).isEqual(i)||t.insert(o,n);for(;i.parent.isEmpty;){const e=i.parent;i=t.createPositionBefore(e),t.remove(e)}if(n=t.createPositionBefore(r),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name);e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(t,n),!sc(t.model.schema,i,n))return;e(t,i,n,s)}(e,t,i,s.parent):function e(t,i,n,s){const o=i.parent,r=n.parent;if(o==s||r==s)return;i=t.createPositionAfter(o),(n=t.createPositionBefore(r)).isEqual(i)||t.insert(r,i);t.merge(i);for(;n.parent.isEmpty;){const e=n.parent;n=t.createPositionBefore(e),t.remove(e)}if(!sc(t.model.schema,i,n))return;e(t,i,n,s)}(e,t,i,s.parent)}(e,o,r),s.removeDisallowedAttributes(o.parent.getChildren(),e)),rc(e,t,o),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(s,o)&&oc(e,o,t),o.detach(),r.detach()})}function sc(e,t,i){const n=t.parent,s=i.parent;return n!=s&&(!e.isLimit(n)&&!e.isLimit(s)&&function(e,t,i){const n=new oa(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function oc(e,t,i){const n=e.createElement("paragraph");e.insert(n,t),rc(e,i,e.createPositionAt(n,0))}function rc(e,t,i){t instanceof ya?e.setSelection(i):t.setTo(i)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ac(e,t){const{isForward:i,walker:n,unit:s,schema:o}=e,{type:r,item:a,nextPosition:l}=t;if("text"==r)return"word"===e.unit?function(e,t){let i=e.position.textNode;if(i){let n=e.position.offset-i.startOffset;for(;!cc(i.data,n,t)&&!hc(i,n,t);){e.next();const s=t?e.position.nodeAfter:e.position.nodeBefore;if(s&&s.is("$text")){const n=s.data.charAt(t?0:s.data.length-1);' ,.?!:;"-()'.includes(n)||(e.next(),i=e.position.textNode)}n=e.position.offset-i.startOffset}}return e.position}(n,i):function(e,t){const i=e.position.textNode;if(i){const n=i.data;let s=e.position.offset-i.startOffset;for(;$l(n,s)||"character"==t&&Ul(n,s);)e.next(),s=e.position.offset-i.startOffset}return e.position}(n,s);if(r==(i?"elementStart":"elementEnd")){if(o.isSelectable(a))return ta._createAt(a,i?"after":"before");if(o.checkChild(l,"$text"))return l}else{if(o.isLimit(a))return void n.skip(()=>!0);if(o.checkChild(l,"$text"))return l}}function lc(e,t){const i=e.root,n=ta._createAt(i,t?"end":0);return t?new oa(e,n):new oa(n,e)}function cc(e,t,i){const n=t+(i?0:-1);return' ,.?!:;"-()'.includes(e.charAt(n))}function hc(e,t,i){return t===(i?e.endOffset:0)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function dc(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map(e=>t.createRangeOn(e)).filter(t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end))).forEach(e=>{i.push(e.start.parent),t.remove(e)}),i.forEach(e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function uc(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.selection,n=t.schema,s=[];let o=!1;for(const e of i.getRanges()){const t=mc(e,n);t&&!t.isEqual(e)?(s.push(t),o=!0):s.push(e)}o&&e.setSelection(function(e){const t=[];t.push(e.shift());for(const i of e){const e=t.pop();if(i.isEqual(e))t.push(e);else if(i.isIntersecting(e)){const n=e.start.isAfter(i.start)?i.start:e.start,s=e.end.isAfter(i.end)?e.end:i.end,o=new oa(n,s);t.push(o)}else t.push(e),t.push(i)}return t}(s),{backward:i.isBackward})}(t,e))}function mc(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n)return null;if(!n.isCollapsed)return n;const s=n.start;if(i.isEqual(s))return null;return new oa(s)}(e,t):function(e,t){const{start:i,end:n}=e,s=t.checkChild(i,"$text"),o=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(s&&o)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),s=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||s}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),s=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),o=e?e.start:i,r=s?s.end:n;return new oa(o,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,s=l&&(!e||!gc(i.nodeAfter,t)),o=c&&(!e||!gc(n.nodeBefore,t));let h=i,d=n;return s&&(h=ta._createBefore(fc(r,t))),o&&(d=ta._createAfter(fc(a,t))),new oa(h,d)}return null}(e,t)}function fc(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function gc(e,t){return e&&t.isSelectable(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class pc{constructor(){this.markers=new Jl,this.document=new Kl(this),this.schema=new Ka,this._pendingChanges=[],this._currentWriter=null,["insertContent","deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(e=>this.decorate(e)),this.on("applyOperation",(e,t)=>{t[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$block",{allowIn:"$root",isBlock:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",isLimit:!0}),this.schema.extend("$text",{allowIn:"$clipboardHolder"}),this.schema.register("$documentFragment",{allowContentOf:"$root",isLimit:!0}),this.schema.extend("$text",{allowIn:"$documentFragment"}),this.schema.register("$marker"),this.schema.addChildCheck((e,t)=>{if("$marker"===t.name)return!0}),uc(this),this.document.registerPostFixer(Oa)}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new ml,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){l.a.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{"string"==typeof e?e=new ml(e):"function"==typeof e&&(t=e,e=new ml),this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){l.a.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i){
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
return function(e,t,i,n){return e.change(s=>{let o;o=i?i instanceof ma||i instanceof ya?i:s.createSelection(i,n):e.document.selection,o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const r=new ic(e,s,o.anchor);let a;a=t.is("documentFragment")?t.getChildren():[t],r.handleNodes(a);const l=r.getSelectionRange();l&&(o instanceof ya?s.setSelection(l):o.setTo(l));const c=r.getAffectedRange()||e.createRange(o.anchor);return r.destroy(),c})}(this,e,t,i)}deleteContent(e,t){nc(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,s="backward"!=i.direction,o=i.unit?i.unit:"character",r=t.focus,a=new Zr({boundaries:lc(r,s),singleCharacters:!0,direction:s?"forward":"backward"}),l={walker:a,schema:n,isForward:s,unit:o};let c;for(;c=a.next();){if(c.done)return;const i=ac(l,c.value);if(i)return void(t instanceof ya?e.change(e=>{e.setSelectionFocus(i)}):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change(e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const s=n.start.root,o=n.start.getCommonPath(n.end),r=s.getNodeByPath(o);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[o.length]),e.createPositionAt(r,n.end.path[o.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],s=e.createRange(e.createPositionAt(i,0),t.start);dc(e.createRange(t.end,e.createPositionAt(i,"end")),e),dc(s,e)}return i})}(this,e)}hasContent(e,t={}){const i=e instanceof Xr?oa._createIn(e):e;if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:s=!1}=t;if(!s)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}createPositionFromPath(e,t,i){return new ta(e,t,i)}createPositionAt(e,t){return ta._createAt(e,t)}createPositionAfter(e){return ta._createAfter(e)}createPositionBefore(e){return ta._createBefore(e)}createRange(e,t){return new oa(e,t)}createRangeIn(e){return oa._createIn(e)}createRangeOn(e){return oa._createOn(e)}createSelection(e,t,i){return new ma(e,t,i)}createBatch(e){return new ml(e)}createOperationFromJSON(e){return class{static fromJSON(e,t){return Xl[e.__className].fromJSON(e,t)}}.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];for(this.fire("_beforeChanges");this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new Nl(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}return this.fire("_afterChanges"),e}}Je(pc,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class wc extends Mr{constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bc{constructor(e={}){this._context=e.context||new rn({language:e.language}),this._context._addEditor(this,!e.context);const t=Array.from(this.constructor.builtinPlugins||[]);this.config=new Gi(e,this.constructor.defaultConfig),this.config.define("plugins",t),this.config.define(this._context._getEditorConfig()),this.plugins=new Zi(this,t,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this.commands=new qa,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.set("isReadOnly",!1),this.model=new pc;const i=new Yn;this.data=new cl(this.model,i),this.editing=new Wa(this.model,i),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new hl([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new wc(this),this.keystrokes.listenTo(this.editing.view.document)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],s=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,s)}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise(e=>this.once("ready",e))),e.then(()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()}).then(()=>this.plugins.destroy()).then(()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()}).then(()=>this._context._removeEditor(this))}execute(...e){try{return this.commands.execute(...e)}catch(e){l.a.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}}Je(bc,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class _c{constructor(e){this.editor=e,this._components=new Map}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(vc(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new l.a("componentfactory-item-missing",this,{name:e});return this._components.get(vc(e)).callback(this.editor.locale)}has(e){return this._components.has(vc(e))}}function vc(e){return String(e).toLowerCase()}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yc{constructor(e){this.editor=e,this.componentFactory=new _c(e),this.focusTracker=new Nr,this._editableElementsMap=new Map,this.listenTo(e.editing.view.document,"layoutChanged",()=>this.update())}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null;this._editableElementsMap=new Map}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}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}}Je(yc,d);var kc={setData(e){this.data.set(e)},getData(e){return this.data.get(e)}};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var Cc={updateSourceElement(){if(!this.sourceElement)throw new l.a("editor-missing-sourceelement",this);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
var e,t;e=this.sourceElement,t=this.data.get(),e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ac extends an{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Xi({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new l.a("pendingactions-add-invalid-message",this);const t=Object.create(We);return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}var xc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.591 10.177 4.243 4.242a1 1 0 0 1-1.415 1.415l-4.242-4.243-4.243 4.243a1 1 0 0 1-1.414-1.415l4.243-4.242L4.52 5.934A1 1 0 0 1 5.934 4.52l4.243 4.243 4.242-4.243a1 1 0 1 1 1.415 1.414l-4.243 4.243z"/></svg>',Tc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.972 16.615a.997.997 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a.997.997 0 0 1-.745.292z"/></svg>';
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Pc=xc,Ec=Tc,Sc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m8.636 9.531-2.758 3.94a.5.5 0 0 0 .122.696l3.224 2.284h1.314l2.636-3.736L8.636 9.53zm.288 8.451L5.14 15.396a2 2 0 0 1-.491-2.786l6.673-9.53a2 2 0 0 1 2.785-.49l3.742 2.62a2 2 0 0 1 .491 2.785l-7.269 10.053-2.147-.066z"/><path d="M4 18h5.523v-1H4zm-2 0h1v-1H2z"/></svg>',Rc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5.085 6.22 2.943 4.078a.75.75 0 1 1 1.06-1.06l2.592 2.59A11.094 11.094 0 0 1 10 5.068c4.738 0 8.578 3.101 8.578 5.083 0 1.197-1.401 2.803-3.555 3.887l1.714 1.713a.75.75 0 0 1-.09 1.138.488.488 0 0 1-.15.084.75.75 0 0 1-.821-.16L6.17 7.304c-.258.11-.51.233-.757.365l6.239 6.24-.006.005.78.78c-.388.094-.78.166-1.174.215l-1.11-1.11h.011L4.55 8.197a7.2 7.2 0 0 0-.665.514l-.112.098 4.897 4.897-.005.006 1.276 1.276a10.164 10.164 0 0 1-1.477-.117l-.479-.479-.009.009-4.863-4.863-.022.031a2.563 2.563 0 0 0-.124.2c-.043.077-.08.158-.108.241a.534.534 0 0 0-.028.133.29.29 0 0 0 .008.072.927.927 0 0 0 .082.226c.067.133.145.26.234.379l3.242 3.365.025.01.59.623c-3.265-.918-5.59-3.155-5.59-4.668 0-1.194 1.448-2.838 3.663-3.93zm7.07.531a4.632 4.632 0 0 1 1.108 5.992l.345.344.046-.018a9.313 9.313 0 0 0 2-1.112c.256-.187.5-.392.727-.613.137-.134.27-.277.392-.431.072-.091.141-.185.203-.286.057-.093.107-.19.148-.292a.72.72 0 0 0 .036-.12.29.29 0 0 0 .008-.072.492.492 0 0 0-.028-.133.999.999 0 0 0-.036-.096 2.165 2.165 0 0 0-.071-.145 2.917 2.917 0 0 0-.125-.2 3.592 3.592 0 0 0-.263-.335 5.444 5.444 0 0 0-.53-.523 7.955 7.955 0 0 0-1.054-.768 9.766 9.766 0 0 0-1.879-.891c-.337-.118-.68-.219-1.027-.301zm-2.85.21-.069.002a.508.508 0 0 0-.254.097.496.496 0 0 0-.104.679.498.498 0 0 0 .326.199l.045.005c.091.003.181.003.272.012a2.45 2.45 0 0 1 2.017 1.513c.024.061.043.125.069.185a.494.494 0 0 0 .45.287h.008a.496.496 0 0 0 .35-.158.482.482 0 0 0 .13-.335.638.638 0 0 0-.048-.219 3.379 3.379 0 0 0-.36-.723 3.438 3.438 0 0 0-2.791-1.543l-.028-.001h-.013z"/></svg>',Ic='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.91 10.54c.26-.23.64-.21.88.03l3.36 3.14 2.23-2.06a.64.64 0 0 1 .87 0l2.52 2.97V4.5H3.2v10.12l3.71-4.08zm10.27-7.51c.6 0 1.09.47 1.09 1.05v11.84c0 .59-.49 1.06-1.09 1.06H2.79c-.6 0-1.09-.47-1.09-1.06V4.08c0-.58.49-1.05 1.1-1.05h14.38zm-5.22 5.56a1.96 1.96 0 1 1 3.4-1.96 1.96 1.96 0 0 1-3.4 1.96z"/></svg>',Vc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.239 13.938-2.88-1.663a.75.75 0 0 1 .75-1.3L9 12.067V4.75a.75.75 0 1 1 1.5 0v7.318l1.89-1.093a.75.75 0 0 1 .75 1.3l-2.879 1.663a.752.752 0 0 1-.511.187.752.752 0 0 1-.511-.187zM4.25 17a.75.75 0 1 1 0-1.5h10.5a.75.75 0 0 1 0 1.5H4.25z"/></svg>',Oc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.75 11.875a.752.752 0 0 1 .508.184l2.883 1.666a.75.75 0 0 1-.659 1.344l-.091-.044-1.892-1.093.001 4.318a.75.75 0 1 1-1.5 0v-4.317l-1.89 1.092a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .51-.187zM15.25 9a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM9.75.375a.75.75 0 0 1 .75.75v4.318l1.89-1.093.092-.045a.75.75 0 0 1 .659 1.344l-2.883 1.667a.752.752 0 0 1-.508.184.752.752 0 0 1-.511-.187L6.359 5.65a.75.75 0 0 1 .75-1.299L9 5.442V1.125a.75.75 0 0 1 .75-.75z"/></svg>',Nc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10.261 7.062 2.88 1.663a.75.75 0 0 1-.75 1.3L10.5 8.933v7.317a.75.75 0 1 1-1.5 0V8.932l-1.89 1.093a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .511-.187.752.752 0 0 1 .511.187zM15.25 4a.75.75 0 1 1 0 1.5H4.75a.75.75 0 0 1 0-1.5h10.5z"/></svg>',Mc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',Bc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm2.286 4c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75z"/></svg>',Fc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M18 3.75a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 8a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 4a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75zm0-8a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75z"/></svg>',Dc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',zc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M18 4.5V3H2v1.5h16zm0 3V6h-5.674v1.5H18zm0 3V9h-5.674v1.5H18zm0 3V12h-5.674v1.5H18zm-8.5-6V12h-6V7.5h6zm.818-1.5H2.682C2.305 6 2 6.407 2 6.91v5.68c0 .503.305.91.682.91h7.636c.377 0 .682-.407.682-.91V6.91c0-.503-.305-.91-.682-.91zM18 16.5V15H2v1.5h16z"/></svg>',Lc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 4.5V3h16v1.5zm4.5 3V12h7V7.5h-7zM5.758 6h8.484c.419 0 .758.407.758.91v5.681c0 .502-.34.909-.758.909H5.758c-.419 0-.758-.407-.758-.91V6.91c0-.503.34-.91.758-.91zM2 16.5V15h16v1.5z"/></svg>',Hc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 4.5V3h16v1.5zm0 3V6h5.674v1.5zm0 3V9h5.674v1.5zm0 3V12h5.674v1.5zm8.5-6V12h6V7.5h-6zM9.682 6h7.636c.377 0 .682.407.682.91v5.68c0 .503-.305.91-.682.91H9.682c-.377 0-.682-.407-.682-.91V6.91c0-.503.305-.91.682-.91zM2 16.5V15h16v1.5z"/></svg>',jc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 4.5V3h16v1.5zm2.5 3V12h11V7.5h-11zM4.061 6H15.94c.586 0 1.061.407 1.061.91v5.68c0 .503-.475.91-1.061.91H4.06c-.585 0-1.06-.407-1.06-.91V6.91C3 6.406 3.475 6 4.061 6zM2 16.5V15h16v1.5z"/></svg>',Wc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M18.095 2H1.905C.853 2 0 2.895 0 4v12c0 1.105.853 2 1.905 2h16.19C19.147 18 20 17.105 20 16V4c0-1.105-.853-2-1.905-2zm0 1.5c.263 0 .476.224.476.5v12c0 .276-.213.5-.476.5H1.905a.489.489 0 0 1-.476-.5V4c0-.276.213-.5.476-.5h16.19z"/></svg>',qc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M13 6H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2zm0 1.5a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5V8a.5.5 0 0 1 .5-.5h11z"/></svg>',$c='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M7 10H2a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h5a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2zm0 1.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5h5z"/></svg>',Uc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M10 8H2a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2zm0 1.5a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-6a.5.5 0 0 1 .5-.5h8z"/></svg>',Kc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.3 17.37-.061.088a1.518 1.518 0 0 1-.934.535l-4.178.663-.806-4.153a1.495 1.495 0 0 1 .187-1.058l.056-.086L8.77 2.639c.958-1.351 2.803-1.076 4.296-.03 1.497 1.047 2.387 2.693 1.433 4.055L7.3 17.37zM9.14 4.728l-5.545 8.346 3.277 2.294 5.544-8.346L9.14 4.728zM6.07 16.512l-3.276-2.295.53 2.73 2.746-.435zM9.994 3.506 13.271 5.8c.316-.452-.16-1.333-1.065-1.966-.905-.634-1.895-.78-2.212-.328zM8 18.5 9.375 17H19v1.5H8z"/></svg>',Gc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 10.423a6.5 6.5 0 0 1 6.056-6.408l.038.67C6.448 5.423 5.354 7.663 5.22 10H9c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574zm8 0a6.5 6.5 0 0 1 6.056-6.408l.038.67c-2.646.739-3.74 2.979-3.873 5.315H17c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574z"/></svg>',Jc='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="9.5" cy="4.5" r="1.5"/><circle cx="9.5" cy="10.5" r="1.5"/><circle cx="9.5" cy="16.5" r="1.5"/></svg>';
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Yc({emitter:e,activator:t,callback:i,contextElements:n}){e.listenTo(document,"mousedown",(e,s)=>{if(!t())return;const o="function"==typeof s.composedPath?s.composedPath():[];for(const e of n)if(e.contains(s.target)||o.includes(e))return;i()})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Qc(e){e.set("_isCssTransitionsDisabled",!1),e.disableCssTransitions=()=>{e._isCssTransitionsDisabled=!0},e.enableCssTransitions=()=>{e._isCssTransitionsDisabled=!1},e.extendTemplate({attributes:{class:[e.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Xc({view:e}){e.listenTo(e.element,"submit",(t,i)=>{i.preventDefault(),e.fire("submit")},{useCapture:!0})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zc extends Xi{constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",(e,t,i)=>{this._renderViewIntoCollectionParent(t,i)}),this.on("remove",(e,t)=>{t.element&&this._parentElement&&t.element.remove()}),this._parentElement=null}destroy(){this.map(e=>e.destroy())}setParent(e){this._parentElement=e;for(const e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!e.every(e=>"string"==typeof e))throw new l.a("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const n of e)i.delegate(n).to(t);this.on("add",(i,n)=>{for(const i of e)n.delegate(i).to(t)}),this.on("remove",(i,n)=>{for(const i of e)n.stopDelegating(i,t)})}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class eh{constructor(e){this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Xi,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",(t,i)=>{i.locale=e}),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=th.bind(this,this)}createCollection(e){const t=new Zc(e);return this._viewCollections.add(t),t}registerChild(e){Qi(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){Qi(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new th(e)}extendTemplate(e){th.extend(this.template,e)}render(){if(this.isRendered)throw new l.a("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(e=>e.destroy()),this.template&&this.template._revertData&&this.template.revert(this.element)}}Je(eh,Io),Je(eh,We);class th{constructor(e){Object.assign(this,dh(hh(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:e,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new l.a("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const i of t.children)ph(i)?yield i:wh(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new nh({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,s)=>new sh({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:s})}}static extend(e,t){if(e._isRendered)throw new l.a("template-extend-render",[this,e]);!function e(t,i){i.attributes&&(t.attributes||(t.attributes={}),fh(t.attributes,i.attributes));i.eventListeners&&(t.eventListeners||(t.eventListeners={}),fh(t.eventListeners,i.eventListeners));i.text&&t.text.push(...i.text);if(i.children&&i.children.length){if(t.children.length!=i.children.length)throw new l.a("ui-template-extend-children-mismatch",t);let n=0;for(const s of i.children)e(t.children[n++],s)}}(e,dh(hh(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new l.a("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),oh(this.text)?this._bindToObservable({schema:this.text,updater:ah(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){let t,i,n,s;if(!this.attributes)return;const o=e.node,r=e.revertData;for(t in this.attributes)if(n=o.getAttribute(t),i=this.attributes[t],r&&(r.attributes[t]=n),s=b(i[0])&&i[0].ns?i[0].ns:null,oh(i)){const a=s?i[0].value:i;r&&_h(t)&&a.unshift(n),this._bindToObservable({schema:a,updater:lh(o,t,s),data:e})}else"style"==t&&"string"!=typeof i[0]?this._renderStyleAttribute(i[0],e):(r&&n&&_h(t)&&i.unshift(n),i=i.map(e=>e&&e.value||e).reduce((e,t)=>e.concat(t),[]).reduce(mh,""),gh(i)||o.setAttributeNS(s,t,i))}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const s=e[n];oh(s)?this._bindToObservable({schema:[s],updater:ch(i,n),data:t}):i.style[n]=s}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let s=0;for(const o of this.children)if(bh(o)){if(!n){o.setParent(t);for(const e of o)i.appendChild(e.element)}}else if(ph(o))n||(o.isRendered||o.render(),i.appendChild(o.element));else if(go(o))i.appendChild(o);else if(n){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),o._renderNode({node:i.childNodes[s++],isApplying:!0,revertData:t})}else i.appendChild(o.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map(i=>{const[n,s]=t.split("@");return i.activateDomEventListener(n,s,e)});e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;rh(e,t,i);const s=e.filter(e=>!gh(e)).filter(e=>e.observable).map(n=>n.activateAttributeListener(e,t,i));n&&n.bindings.push(s)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)e.textContent=t.text;else{for(const i in t.attributes){const n=t.attributes[i];null===n?e.removeAttribute(i):e.setAttribute(i,n)}for(let i=0;i<t.children.length;++i)this._revertTemplateFromNode(e.childNodes[i],t.children[i])}}}Je(th,d);class ih{constructor(e){Object.assign(this,e)}getValue(e){const t=this.observable[this.attribute];return this.callback?this.callback(t,e):t}activateAttributeListener(e,t,i){const n=()=>rh(e,t,i);return this.emitter.listenTo(this.observable,"change:"+this.attribute,n),()=>{this.emitter.stopListening(this.observable,"change:"+this.attribute,n)}}}class nh extends ih{activateDomEventListener(e,t,i){const n=(e,i)=>{t&&!i.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,e,n),()=>{this.emitter.stopListening(i.node,e,n)}}}class sh extends ih{getValue(e){return!gh(super.getValue(e))&&(this.valueIfTrue||!0)}}function oh(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(oh):e instanceof ih)}function rh(e,t,{node:i}){let n=function(e,t){return e.map(e=>e instanceof ih?e.getValue(t):e)}(e,i);n=1==e.length&&e[0]instanceof sh?n[0]:n.reduce(mh,""),gh(n)?t.remove():t.set(n)}function ah(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function lh(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function ch(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function hh(e){return Ui(e,e=>{if(e&&(e instanceof ih||wh(e)||ph(e)||bh(e)))return e})}function dh(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=en(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)uh(e,t);return e}(e.on),delete e.on),!e.text){e.attributes&&function(e){for(const t in e)e[t].value&&(e[t].value=en(e[t].value)),uh(e,t)}(e.attributes);const t=[];if(e.children)if(bh(e.children))t.push(e.children);else for(const i of e.children)wh(i)||ph(i)||go(i)?t.push(i):t.push(new th(i));e.children=t}return e}function uh(e,t){e[t]=en(e[t])}function mh(e,t){return gh(t)?e:gh(e)?t:`${e} ${t}`}function fh(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function gh(e){return!e&&0!==e}function ph(e){return e instanceof eh}function wh(e){return e instanceof th}function bh(e){return e instanceof Zc}function _h(e){return"class"==e||"style"==e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vh extends Zc{constructor(e,t=[]){super(t),this.locale=e}attachToDom(){this._bodyCollectionContainer=new th({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let e=document.querySelector(".ck-body-wrapper");e||(e=Cr(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(e)),e.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const e=document.querySelector(".ck-body-wrapper");e&&0==e.childElementCount&&e.remove()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yh extends eh{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon"],viewBox:e.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 e=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),t=e.getAttribute("viewBox");for(t&&(this.viewBox=t),this.element.innerHTML="";e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach(e=>{e.style.fill=this.fillColor})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kh extends eh{constructor(e){super(e),this.set("text",""),this.set("position","s");const t=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip",t.to("position",e=>"ck-tooltip_"+e),t.if("text","ck-hidden",e=>!e.trim())]},children:[{tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:t.to("text")}]}]})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ch extends eh{constructor(e){super(e);const t=this.bindTemplate,i=r();this.set("class"),this.set("labelStyle"),this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.tooltipView=this._createTooltipView(),this.labelView=this._createLabelView(i),this.iconView=new yh,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)),this.setTemplate({tag:"button",attributes:{class:["ck","ck-button",t.to("class"),t.if("isEnabled","ck-disabled",e=>!e),t.if("isVisible","ck-hidden",e=>!e),t.to("isOn",e=>e?"ck-on":"ck-off"),t.if("withText","ck-button_with-text"),t.if("withKeystroke","ck-button_with-keystroke")],type:t.to("type",e=>e||"button"),tabindex:t.to("tabindex"),"aria-labelledby":"ck-editor__aria-label_"+i,"aria-disabled":t.if("isEnabled",!0,e=>!e),"aria-pressed":t.to("isOn",e=>!!this.isToggleable&&String(e))},children:this.children,on:{mousedown:t.to(e=>{e.preventDefault()}),click:t.to(e=>{this.isEnabled?this.fire("execute"):e.preventDefault()})}})}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.tooltipView),this.children.add(this.labelView),this.withKeystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}_createTooltipView(){const e=new kh;return e.bind("text").to(this,"_tooltipString"),e.bind("position").to(this,"tooltipPosition"),e}_createLabelView(e){const t=new eh,i=this.bindTemplate;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:i.to("labelStyle"),id:"ck-editor__aria-label_"+e},children:[{text:this.bindTemplate.to("label")}]}),t}_createKeystrokeView(){const e=new eh;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",e=>Ns(e))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=Ns(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ah extends Ch{constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new eh;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function xh(e,t){const i=e.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return t.map(e=>{const t=n[e.label];return t&&t!=e.label&&(e.label=t),e})}function Th(e){return e.map(Ph).filter(e=>!!e)}function Ph(e){return"string"==typeof e?{model:e,label:e,hasBorder:!1,view:{name:"span",styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:void 0!==e.hasBorder&&e.hasBorder,view:{name:"span",styles:{color:""+e.color}}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Eh extends Ch{constructor(e){super(e);const t=this.bindTemplate;this.set("color"),this.set("hasBorder"),this.icon='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M16.935 5.328a2 2 0 0 1 0 2.829l-7.778 7.778a2 2 0 0 1-2.829 0L3.5 13.107a1.999 1.999 0 1 1 2.828-2.829l.707.707a1 1 0 0 0 1.414 0l5.658-5.657a2 2 0 0 1 2.828 0z"/><path d="M14.814 6.035 8.448 12.4a1 1 0 0 1-1.414 0l-1.413-1.415A1 1 0 1 0 4.207 12.4l2.829 2.829a1 1 0 0 0 1.414 0l7.778-7.778a1 1 0 1 0-1.414-1.415z"/></svg>',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color")},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sh{constructor(e){if(Object.assign(this,e),e.actions&&e.keystrokeHandler)for(const t in e.actions){let i=e.actions[t];"string"==typeof i&&(i=[i]);for(const n of i)e.keystrokeHandler.set(n,(e,i)=>{this[t](),i()})}}get first(){return this.focusables.find(Rh)||null}get last(){return this.focusables.filter(Rh).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find((t,i)=>{const n=t.element===this.focusTracker.focusedElement;return n&&(e=i),n}),e)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(e){e&&e.focus()}_getFocusableItem(e){const t=this.current,i=this.focusables.length;if(!i)return null;if(null===t)return this[1===e?"first":"last"];let n=(t+i+e)%i;do{const t=this.focusables.get(n);if(Rh(t))return t;n=(n+i+e)%i}while(n!==t);return null}}function Rh(e){return!(!e.focus||"none"==vo.window.getComputedStyle(e.element).display)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ih extends eh{constructor(e,t){super(e);const i=t&&t.colorDefinitions||[],n={};t&&t.columns&&(n.gridTemplateColumns=`repeat( ${t.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new Nr,this.keystrokes=new Mr,this._focusCycler=new Sh({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.items.on("add",(e,t)=>{t.isOn=t.color===this.selectedColor}),i.forEach(e=>{const t=new Eh;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})}),this.items.add(t)}),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",(e,t,i)=>{for(const e of this.items)e.isOn=e.color===i})}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",(e,t)=>{this.focusTracker.add(t.element)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element)}}var Vh='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136L.941 4.523z"/></svg>';
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Oh extends Ch{constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new yh;return e.content=Vh,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Nh extends eh{constructor(e){super(e);const t=this.bindTemplate;this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(),this.arrowView=this._createArrowView(),this.keystrokes=new Mr,this.focusTracker=new Nr,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",t.if("isVisible","ck-hidden",e=>!e),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",(e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())}),this.keystrokes.set("arrowleft",(e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())})}focus(){this.actionView.focus()}_createActionView(){const e=new Ch;return 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 e=new Ch,t=e.bindTemplate;return e.icon=Vh,e.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":t.to("isOn",e=>String(e))}}),e.bind("isEnabled").to(this),e.delegate("execute").to(this,"open"),e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Mh extends eh{constructor(e){super(e);const t=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",t.to("position",e=>"ck-dropdown__panel_"+e),t.if("isVisible","ck-dropdown__panel-visible")]},children:this.children,on:{selectstart:t.to(e=>e.preventDefault())}})}focus(){this.children.length&&this.children.first.focus()}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Bh({element:e,target:t,positions:i,limiter:n,fitInViewport:s}){I(t)&&(t=t()),I(n)&&(n=n());const o=function(e){return e&&e.parentNode?e.offsetParent===vo.document.body?null:e.offsetParent:null}(e),r=new Pr(e),a=new Pr(t);let l,c;if(n||s){const e=function(e,t){const{elementRect:i,viewportRect:n}=t,s=i.getArea(),o=function(e,{targetRect:t,elementRect:i,limiterRect:n,viewportRect:s}){const o=[],r=i.getArea();for(const a of e){const e=Fh(a,t,i);if(!e)continue;const[l,c]=e;let h=0,d=0;if(n)if(s){const e=n.getIntersection(s);e&&(h=e.getIntersectionArea(c))}else h=n.getIntersectionArea(c);s&&(d=s.getIntersectionArea(c));const u={positionName:l,positionRect:c,limiterIntersectArea:h,viewportIntersectArea:d};if(h===r)return[u];o.push(u)}return o}(e,t);if(n){const e=Dh(o.filter(({viewportIntersectArea:e})=>e===s),s);if(e)return e}return Dh(o,s)}(i,{targetRect:a,elementRect:r,limiterRect:n&&new Pr(n).getVisible(),viewportRect:s&&new Pr(vo.window)});[c,l]=e||Fh(i[0],a,r)}else[c,l]=Fh(i[0],a,r);let h=zh(l);return o&&(h=function({left:e,top:t},i){const n=zh(new Pr(i)),s=xr(i);return e-=n.left,t-=n.top,e+=i.scrollLeft,t+=i.scrollTop,e-=s.left,t-=s.top,{left:e,top:t}}(h,o)),{left:h.left,top:h.top,name:c}}function Fh(e,t,i){const n=e(t,i);if(!n)return null;const{left:s,top:o,name:r}=n;return[r,i.clone().moveTo(s,o)]}function Dh(e,t){let i,n,s=0;for(const{positionName:o,positionRect:r,limiterIntersectArea:a,viewportIntersectArea:l}of e){if(a===t)return[o,r];const e=l**2+a**2;e>s&&(s=e,i=r,n=o)}return i?[n,i]:null}function zh({left:e,top:t}){const{scrollX:i,scrollY:n}=vo.window;return{left:e+i,top:t+n}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Lh extends eh{constructor(e,t,i){super(e);const n=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class"),this.set("id"),this.set("panelPosition","auto"),this.keystrokes=new Mr,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",e=>!e)],id:n.to("id"),"aria-describedby":n.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"]}})}render(){super.render(),this.listenTo(this.buttonView,"open",()=>{this.isOpen=!this.isOpen}),this.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",()=>{this.isOpen&&("auto"===this.panelPosition?this.panelView.position=Lh._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions}).name:this.panelView.position=this.panelPosition)}),this.keystrokes.listenTo(this.element);const e=(e,t)=>{this.isOpen&&(this.buttonView.focus(),this.isOpen=!1,t())};this.keystrokes.set("arrowdown",(e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())}),this.keystrokes.set("arrowright",(e,t)=>{this.isOpen&&t()}),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:n,northEast:s,northWest:o,southMiddleEast:r,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=Lh.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,r,a,e,s,o,l,c,t]:[n,i,a,r,e,o,s,c,l,t]}}Lh.defaultPanelPositions={south:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/2,name:"s"}),southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),southMiddleEast:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/4,name:"sme"}),southMiddleWest:(e,t)=>({top:e.bottom,left:e.left-3*(t.width-e.width)/4,name:"smw"}),north:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/2,name:"n"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),northMiddleEast:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/4,name:"nme"}),northMiddleWest:(e,t)=>({top:e.top-t.height,left:e.left-3*(t.width-e.width)/4,name:"nmw"})},Lh._getOptimalPosition=Bh;
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Hh extends eh{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jh extends eh{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Wh(e){return Array.isArray(e)?{items:e,removeItems:[]}:e?Object.assign({items:[],removeItems:[]},e):{items:[],removeItems:[]}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qh extends eh{constructor(e,t){super(e);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Nr,this.keystrokes=new Mr,this.set("class"),this.set("isCompact",!1),this.itemsView=new $h(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection(),this._focusCycler=new Sh({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["arrowleft","arrowup"],focusNext:["arrowright","arrowdown"]}});const s=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var o;this.options.shouldGroupWhenFull&&this.options.isFloating&&s.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:s,role:"toolbar","aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")}},children:this.children,on:{mousedown:(o=this,o.bindTemplate.to(e=>{e.target===o.element&&e.preventDefault()}))}}),this._behavior=this.options.shouldGroupWhenFull?new Kh(this):new Uh(this)}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",(e,t)=>{this.focusTracker.add(t.element)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t){const i=Wh(e),n=i.items.filter((e,n,s)=>"|"===e||-1===i.removeItems.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(Object(l.b)("toolbarview-line-break-ignored-when-grouping-items",s),!1):!!t.has(e)||(Object(l.b)("toolbarview-item-unavailable",{name:e}),!1))),s=this._cleanSeparators(n).map(e=>"|"===e?new Hh:"-"===e?new jh:t.create(e));this.items.addMany(s)}_cleanSeparators(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t),s=i-e.slice().reverse().findIndex(t);return e.slice(n,s).filter((e,i,n)=>{if(t(e))return!0;return!(i>0&&n[i-1]===e)})}}class $h extends eh{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Uh{constructor(e){const t=e.bindTemplate;e.set("isVertical",!1),e.itemsView.children.bindTo(e.items).using(e=>e),e.focusables.bindTo(e.items).using(e=>e),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class Kh{constructor(e){this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,e.itemsView.children.bindTo(this.ungroupedItems).using(e=>e),this.ungroupedItems.on("add",this._updateFocusCycleableItems.bind(this)),this.ungroupedItems.on("remove",this._updateFocusCycleableItems.bind(this)),e.children.on("add",this._updateFocusCycleableItems.bind(this)),e.children.on("remove",this._updateFocusCycleableItems.bind(this)),e.items.on("change",(e,t)=>{const i=t.index;for(const e of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=i;e<i+t.added.length;e++){const n=t.added[e-i];e>this.ungroupedItems.length?this.groupedItems.add(n,e-this.ungroupedItems.length):this.ungroupedItems.add(n,e)}this._updateGrouping()}),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!this.viewElement.offsetParent)return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,i=new Pr(e.lastChild),n=new Pr(e);if(!this.cachedPadding){const i=vo.window.getComputedStyle(e),n="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(i[n])}return"ltr"===t?i.right>n.right-this.cachedPadding:i.left<n.left+this.cachedPadding}_enableGroupingOnResize(){let e;this.resizeObserver=new Rr(this.viewElement,t=>{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)}),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",()=>{this._updateGrouping()})}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Hh),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 e=this.viewLocale,t=e.t,i=Qh(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",Xh(i,[]),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Jc}),i.toolbarView.items.bindTo(this.groupedItems).using(e=>e),i}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gh extends eh{constructor(){super(),this.items=this.createCollection(),this.focusTracker=new Nr,this.keystrokes=new Mr,this._focusCycler=new Sh({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"]},children:this.items})}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",(e,t)=>{this.focusTracker.add(t.element)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jh extends eh{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item"]},children:this.children})}focus(){this.children.first.focus()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yh extends eh{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Qh(e,t=Oh){const i=new t(e),n=new Mh(e),s=new Lh(e,i,n);return i.bind("isEnabled").to(s),i instanceof Oh?i.bind("isOn").to(s,"isOpen"):i.arrowView.bind("isOn").to(s,"isOpen"),function(e){(function(e){e.on("render",()=>{Yc({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:[e.element]})})})(e),function(e){e.on("execute",t=>{t.source instanceof Ah||(e.isOpen=!1)})}(e),function(e){e.keystrokes.set("arrowdown",(t,i)=>{e.isOpen&&(e.panelView.focus(),i())}),e.keystrokes.set("arrowup",(t,i)=>{e.isOpen&&(e.panelView.focusLast(),i())})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e)}(s),s}function Xh(e,t){const i=e.locale,n=i.t,s=e.toolbarView=new qh(i);s.set("ariaLabel",n("Dropdown toolbar")),e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),t.map(e=>s.items.add(e)),e.panelView.children.add(s),s.items.delegate("execute").to(e)}function Zh(e,t){const i=e.locale,n=e.listView=new Gh(i);n.items.bindTo(t).using(({type:e,model:t})=>{if("separator"===e)return new Yh(i);if("button"===e||"switchbutton"===e){const n=new Jh(i);let s;return s="button"===e?new Ch(i):new Ah(i),s.bind(...Object.keys(t)).to(t),s.delegate("execute").to(n),n.children.add(s),n}}),e.panelView.children.add(n),n.items.delegate("execute").to(e)}class ed extends eh{constructor(e){super(e),this.body=new vh(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class td extends eh{constructor(e){super(e),this.set("text"),this.set("for"),this.id="ck-editor__label_"+r();const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class id extends ed{constructor(e){super(e),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:e.uiLanguageDirection,lang:e.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 e=this.t,t=new td;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class nd extends eh{constructor(e,t,i){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=t}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()}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change(i=>{const n=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",n)})}e.isRenderingInProgress?function i(n){e.once("change:isRenderingInProgress",(e,s,o)=>{o?i(n):t(n)})}(this):t(this)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class sd extends nd{constructor(e,t,i){super(e,t,i),this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView,t=this.t;e.change(i=>{const n=e.document.getRoot(this.name);i.setAttribute("aria-label",t("Rich Text Editor, %0",this.name),n)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class od extends eh{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children});const n=new eh(e);n.setTemplate({tag:"span",attributes:{class:["ck","ck-form__header__label"]},children:[{text:i.to("label")}]}),this.children.add(n)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rd extends eh{constructor(e){super(e),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById"),this.focusTracker=new Nr,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{type:"text",class:["ck","ck-input","ck-input-text",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},on:{input:t.to("input"),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",(e,t,i)=>{this._setDomElementValue(i),this._updateIsEmpty()})}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ad extends eh{constructor(e,t){super(e);const i="ck-labeled-field-view-"+r(),n="ck-labeled-field-view-status-"+r();this.fieldView=t(this,i,n),this.set("label"),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class"),this.set("placeholder"),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(n),this.bind("_statusText").to(this,"errorText",this,"infoText",(e,t)=>e||t);const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",s.to("class"),s.if("isEnabled","ck-disabled",e=>!e),s.if("isEmpty","ck-labeled-field-view_empty"),s.if("isFocused","ck-labeled-field-view_focused"),s.if("placeholder","ck-labeled-field-view_placeholder"),s.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:[this.fieldView,this.labelView]},this.statusView]})}_createLabelView(e){const t=new td(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new eh(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",e=>!e)],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ld(e,t,i){const n=new rd(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",e=>!e),n.bind("hasError").to(e,"errorText",e=>!!e),n.on("input",()=>{e.errorText=null}),e.bind("isEmpty","isFocused","placeholder").to(n),n}function cd(e,t,i){const n=Qh(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isEnabled").to(e),n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hd extends an{static get pluginName(){return"Notification"}init(){this.on("show:warning",(e,t)=>{window.alert(t.message)},{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t="show:"+e.type+(e.namespace?":"+e.namespace:"");this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class dd{constructor(e,t){t&&Be(this,t),e&&this.set(e)}}Je(dd,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */
const ud=Vr("px"),md=vo.document.body;class fd extends eh{constructor(e){super(e);const t=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"),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",e=>"ck-balloon-panel_"+e),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",ud),left:t.to("left",ud)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=fd.defaultPositions,i=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast],limiter:md,fitInViewport:!0},e),n=fd._getOptimalPosition(i),s=parseInt(n.left),o=parseInt(n.top),r=n.name;Object.assign(this,{top:o,left:s,position:r})}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),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(e){this.attachTo(e);const t=gd(e.target),i=e.limiter?gd(e.limiter):md;this.listenTo(vo.document,"scroll",(n,s)=>{const o=s.target,r=t&&o.contains(t),a=i&&o.contains(i);!r&&!a&&t&&i||this.attachTo(e)},{useCapture:!0}),this.listenTo(vo.window,"resize",()=>{this.attachTo(e)})}_stopPinning(){this.stopListening(vo.document,"scroll"),this.stopListening(vo.window,"resize")}}function gd(e){return Ki(e)?e:Ar(e)?e.commonAncestorContainer:"function"==typeof e?gd(e()):null}function pd(e,t){return e.top-t.height-fd.arrowVerticalOffset}function wd(e){return e.bottom+fd.arrowVerticalOffset}fd.arrowHorizontalOffset=25,fd.arrowVerticalOffset=10,fd._getOptimalPosition=Bh,fd.defaultPositions={northWestArrowSouthWest:(e,t)=>({top:pd(e,t),left:e.left-fd.arrowHorizontalOffset,name:"arrow_sw"}),northWestArrowSouthMiddleWest:(e,t)=>({top:pd(e,t),left:e.left-.25*t.width-fd.arrowHorizontalOffset,name:"arrow_smw"}),northWestArrowSouth:(e,t)=>({top:pd(e,t),left:e.left-t.width/2,name:"arrow_s"}),northWestArrowSouthMiddleEast:(e,t)=>({top:pd(e,t),left:e.left-.75*t.width+fd.arrowHorizontalOffset,name:"arrow_sme"}),northWestArrowSouthEast:(e,t)=>({top:pd(e,t),left:e.left-t.width+fd.arrowHorizontalOffset,name:"arrow_se"}),northArrowSouthWest:(e,t)=>({top:pd(e,t),left:e.left+e.width/2-fd.arrowHorizontalOffset,name:"arrow_sw"}),northArrowSouthMiddleWest:(e,t)=>({top:pd(e,t),left:e.left+e.width/2-.25*t.width-fd.arrowHorizontalOffset,name:"arrow_smw"}),northArrowSouth:(e,t)=>({top:pd(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s"}),northArrowSouthMiddleEast:(e,t)=>({top:pd(e,t),left:e.left+e.width/2-.75*t.width+fd.arrowHorizontalOffset,name:"arrow_sme"}),northArrowSouthEast:(e,t)=>({top:pd(e,t),left:e.left+e.width/2-t.width+fd.arrowHorizontalOffset,name:"arrow_se"}),northEastArrowSouthWest:(e,t)=>({top:pd(e,t),left:e.right-fd.arrowHorizontalOffset,name:"arrow_sw"}),northEastArrowSouthMiddleWest:(e,t)=>({top:pd(e,t),left:e.right-.25*t.width-fd.arrowHorizontalOffset,name:"arrow_smw"}),northEastArrowSouth:(e,t)=>({top:pd(e,t),left:e.right-t.width/2,name:"arrow_s"}),northEastArrowSouthMiddleEast:(e,t)=>({top:pd(e,t),left:e.right-.75*t.width+fd.arrowHorizontalOffset,name:"arrow_sme"}),northEastArrowSouthEast:(e,t)=>({top:pd(e,t),left:e.right-t.width+fd.arrowHorizontalOffset,name:"arrow_se"}),southWestArrowNorthWest:(e,t)=>({top:wd(e),left:e.left-fd.arrowHorizontalOffset,name:"arrow_nw"}),southWestArrowNorthMiddleWest:(e,t)=>({top:wd(e),left:e.left-.25*t.width-fd.arrowHorizontalOffset,name:"arrow_nmw"}),southWestArrowNorth:(e,t)=>({top:wd(e),left:e.left-t.width/2,name:"arrow_n"}),southWestArrowNorthMiddleEast:(e,t)=>({top:wd(e),left:e.left-.75*t.width+fd.arrowHorizontalOffset,name:"arrow_nme"}),southWestArrowNorthEast:(e,t)=>({top:wd(e),left:e.left-t.width+fd.arrowHorizontalOffset,name:"arrow_ne"}),southArrowNorthWest:(e,t)=>({top:wd(e),left:e.left+e.width/2-fd.arrowHorizontalOffset,name:"arrow_nw"}),southArrowNorthMiddleWest:(e,t)=>({top:wd(e),left:e.left+e.width/2-.25*t.width-fd.arrowHorizontalOffset,name:"arrow_nmw"}),southArrowNorth:(e,t)=>({top:wd(e),left:e.left+e.width/2-t.width/2,name:"arrow_n"}),southArrowNorthMiddleEast:(e,t)=>({top:wd(e),left:e.left+e.width/2-.75*t.width+fd.arrowHorizontalOffset,name:"arrow_nme"}),southArrowNorthEast:(e,t)=>({top:wd(e),left:e.left+e.width/2-t.width+fd.arrowHorizontalOffset,name:"arrow_ne"}),southEastArrowNorthWest:(e,t)=>({top:wd(e),left:e.right-fd.arrowHorizontalOffset,name:"arrow_nw"}),southEastArrowNorthMiddleWest:(e,t)=>({top:wd(e),left:e.right-.25*t.width-fd.arrowHorizontalOffset,name:"arrow_nmw"}),southEastArrowNorth:(e,t)=>({top:wd(e),left:e.right-t.width/2,name:"arrow_n"}),southEastArrowNorthMiddleEast:(e,t)=>({top:wd(e),left:e.right-.75*t.width+fd.arrowHorizontalOffset,name:"arrow_nme"}),southEastArrowNorthEast:(e,t)=>({top:wd(e),left:e.right-t.width+fd.arrowHorizontalOffset,name:"arrow_ne"})};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const bd=Vr("px");class _d extends Ye{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.set("visibleView",null),this.view=new fd(e.locale),e.ui.view.body.add(this.view),e.ui.focusTracker.add(this.view.element),this._viewToStack=new Map,this._idToStack=new Map,this.set("_numberOfStacks",0),this.set("_singleViewMode",!1),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this.hasView(e.view))throw new l.a("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new l.a("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new l.a("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find(t=>t[1]===e)[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new vd(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",(e,t)=>!t&&e>1),e.on("change:isNavigationVisible",()=>this.updatePosition(),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",(e,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[n,i])}),e.buttonNextView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()}),e.buttonPrevView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()}),e}_createFakePanelsView(){const e=new yd(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(e,t)=>!t&&e>=2?Math.min(e-1,2):0),e.listenTo(this.view,"change:top",()=>e.updatePosition()),e.listenTo(this.view,"change:left",()=>e.updatePosition()),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&!e.limiter&&(e=Object.assign({},e,{limiter:this.positionLimiter})),e}}class vd extends eh{constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Nr,this.buttonPrevView=this._createButtonView(t("Previous"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>'),this.buttonNextView=this._createButtonView(t("Next"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.537 14.813a.888.888 0 1 1-1.254-1.255L10.84 10 7.283 6.442a.888.888 0 1 1 1.254-1.255L12.74 9.39a.888.888 0 0 1-.16 1.382l-4.043 4.042z"/></svg>'),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",i.to("isNavigationVisible",e=>e?"":"ck-hidden")]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new Ch(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class yd extends eh{constructor(e,t){super(e);const i=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=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",e=>e?"":"ck-hidden")],style:{top:i.to("top",bd),left:i.to("left",bd),width:i.to("width",bd),height:i.to("height",bd)}},children:this.content}),this.on("change:numberOfPanels",(e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()})}_addPanels(e){for(;e--;){const e=new eh;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:n}=new Pr(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const kd=Vr("px");class Cd extends eh{constructor(e){super(e);const t=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("_isStickyToTheLimiter",!1),this.set("_hasViewportTopOffset",!1),this.content=this.createCollection(),this._contentPanelPlaceholder=new th({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",e=>e?"block":"none"),height:t.to("isSticky",e=>e?kd(this._panelRect.height):null)}}}).render(),this._contentPanel=new th({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",e=>e?kd(this._contentPanelPlaceholder.getBoundingClientRect().width):null),top:t.to("_hasViewportTopOffset",e=>e?kd(this.viewportTopOffset):null),bottom:t.to("_isStickyToTheLimiter",e=>e?kd(this.limiterBottomOffset):null),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this._contentPanel]})}render(){super.render(),this._checkIfShouldBeSticky(),this.listenTo(vo.window,"scroll",()=>{this._checkIfShouldBeSticky()}),this.listenTo(this,"change:isActive",()=>{this._checkIfShouldBeSticky()})}_checkIfShouldBeSticky(){const e=this._panelRect=this._contentPanel.getBoundingClientRect();let t;this.limiterElement?(t=this._limiterRect=this.limiterElement.getBoundingClientRect(),this.isSticky=this.isActive&&t.top<this.viewportTopOffset&&this._panelRect.height+this.limiterBottomOffset<t.height):this.isSticky=!1,this.isSticky?(this._isStickyToTheLimiter=t.bottom<e.height+this.limiterBottomOffset+this.viewportTopOffset,this._hasViewportTopOffset=!this._isStickyToTheLimiter&&!!this.viewportTopOffset,this._marginLeft=this._isStickyToTheLimiter?null:kd(-vo.window.scrollX)):(this._isStickyToTheLimiter=!1,this._hasViewportTopOffset=!1,this._marginLeft=null)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
Vr("px");
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
Vr("px");
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
Vr("px");
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Ad=new WeakMap;function xd(e){const{view:t,element:i,text:n,isDirectHost:s=!0,keepOnFocus:o=!1}=e,r=t.document;Ad.has(r)||(Ad.set(r,new Map),r.registerPostFixer(e=>Pd(r,e))),Ad.get(r).set(i,{text:n,isDirectHost:s,keepOnFocus:o,hostElement:s?i:null}),t.change(e=>Pd(r,e))}function Td(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function Pd(e,t){const i=Ad.get(e),n=[];let s=!1;for(const[e,o]of i)o.isDirectHost&&(n.push(e),Ed(t,e,o)&&(s=!0));for(const[e,o]of i){if(o.isDirectHost)continue;const i=Sd(e);i&&(n.includes(i)||(o.hostElement=i,Ed(t,e,o)&&(s=!0)))}return s}function Ed(e,t,i){const{text:n,isDirectHost:s,hostElement:o}=i;let r=!1;o.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,o),r=!0);return(s||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;if(Array.from(e.getChildren()).some(e=>!e.is("uiElement")))return!1;if(t)return!0;const i=e.document;if(!i.isFocused)return!0;const n=i.selection.anchor;return n&&n.parent!==e}(o,i.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,o)&&(r=!0):Td(e,o)&&(r=!0),r}function Sd(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement"))return t}return null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Rd=new Map;function Id(e,t,i){let n=Rd.get(e);n||(n=new Map,Rd.set(e,n)),n.set(t,i)}function Vd(e){return[e]}function Od(e,t,i={}){const n=function(e,t){const i=Rd.get(e);return i&&i.has(t)?i.get(t):Vd}(e.constructor,t.constructor);try{return n(e=e.clone(),t,i)}catch(e){throw e}}function Nd(e,t,i){e=e.slice(),t=t.slice();const n=new Md(i.document,i.useRelations,i.forceWeakRemove);n.setOriginalOperations(e),n.setOriginalOperations(t);const s=n.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:s};const o=new WeakMap;for(const t of e)o.set(t,0);const r={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a<e.length;){const i=e[a],s=o.get(i);if(s==t.length){a++;continue}const r=t[s],l=Od(i,r,n.getContext(i,r,!0)),c=Od(r,i,n.getContext(r,i,!1));n.updateRelation(i,r),n.setOriginalOperations(l,i),n.setOriginalOperations(c,r);for(const e of l)o.set(e,s+c.length);e.splice(a,1,...l),t.splice(s,1,...c)}if(i.padWithNoOps){const i=e.length-r.originalOperationsACount,n=t.length-r.originalOperationsBCount;Fd(e,n-i),Fd(t,i-n)}return Bd(e,r.nextBaseVersionB),Bd(t,r.nextBaseVersionA),{operationsA:e,operationsB:t,originalOperations:s}}class Md{constructor(e,t,i=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!i,this._relations=new Map}setOriginalOperations(e,t=null){const i=t?this.originalOperations.get(t):null;for(const t of e)this.originalOperations.set(t,i||t)}updateRelation(e,t){switch(e.constructor){case Tl:switch(t.constructor){case Il:e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)&&this._setRelation(e,t,"moveTargetAfter");break;case Tl:e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter")}break;case Vl:switch(t.constructor){case Il:e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");break;case Tl:if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const i=oa._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=i.end.offset-e.splitPosition.offset,s=e.splitPosition.offset-i.start.offset;this._setRelation(e,t,{howMany:n,offset:s})}}}break;case Il:switch(t.constructor){case Il:e.targetPosition.isEqual(t.sourcePosition)||this._setRelation(e,t,"mergeTargetNotMoved"),e.sourcePosition.isEqual(t.targetPosition)&&this._setRelation(e,t,"mergeSourceNotMoved"),e.sourcePosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeSameElement");break;case Vl:e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource")}break;case El:{const i=e.newRange;if(!i)return;switch(t.constructor){case Tl:{const n=oa._createFromPositionAndShift(t.sourcePosition,t.howMany),s=n.containsPosition(i.start)||n.start.isEqual(i.start),o=n.containsPosition(i.end)||n.end.isEqual(i.end);!s&&!o||n.containsRange(i)||this._setRelation(e,t,{side:s?"left":"right",path:s?i.start.path.slice():i.end.path.slice()});break}case Il:{const n=i.start.isEqual(t.targetPosition),s=i.start.isEqual(t.deletionPosition),o=i.end.isEqual(t.deletionPosition),r=i.end.isEqual(t.sourcePosition);(n||s||o||r)&&this._setRelation(e,t,{wasInLeftElement:n,wasStartBeforeMergedElement:s,wasEndBeforeMergedElement:o,wasInRightElement:r});break}}break}}}getContext(e,t,i){return{aIsStrong:i,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const i=this.originalOperations.get(t),n=this._history.getUndoneOperation(i);if(!n)return null;const s=this.originalOperations.get(e),o=this._relations.get(s);return o&&o.get(n)||null}_setRelation(e,t,i){const n=this.originalOperations.get(e),s=this.originalOperations.get(t);let o=this._relations.get(n);o||(o=new Map,this._relations.set(n,o)),o.set(s,i)}}function Bd(e,t){for(const i of e)i.baseVersion=t++}function Fd(e,t){for(let i=0;i<t;i++)e.push(new Ql(0))}function Dd(e,t,i){const n=e.nodes.getNode(0).getAttribute(t);if(n==i)return null;const s=new oa(e.position,e.position.getShiftedBy(e.howMany));return new Al(s,t,n,i,0)}function zd(e,t){return null===e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany)}function Ld(e,t){const i=[];for(let n=0;n<e.length;n++){const s=e[n],o=new Tl(s.start,s.end.offset-s.start.offset,t,0);i.push(o);for(let t=n+1;t<e.length;t++)e[t]=e[t]._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)[0];t=t._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)}return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Id(Al,Al,(e,t,i)=>{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map(t=>new Al(t,e.key,e.oldValue,e.newValue,0)),s=e.range.getIntersection(t.range);return s&&i.aIsStrong&&n.push(new Al(s,t.key,t.newValue,e.newValue,0)),0==n.length?[new Ql(0)]:n}return[e]}),Id(Al,Pl,(e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map(t=>new Al(t,e.key,e.oldValue,e.newValue,e.baseVersion));if(t.shouldReceiveAttributes){const n=Dd(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]}),Id(Al,Il,(e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(oa._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map(t=>new Al(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),Id(Al,Tl,(e,t)=>function(e,t){const i=oa._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,s=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(s=e.getDifference(i),n=e.getIntersection(i)):s=[e];const o=[];for(let e of s){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i);e=e._getTransformedByInsertion(i,t.howMany,n),o.push(...e)}n&&o.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return o}(e.range,t).map(t=>new Al(t,e.key,e.oldValue,e.newValue,e.baseVersion))),Id(Al,Vl,(e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new oa(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]}),Id(Pl,Al,(e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=Dd(e,t.key,t.newValue);n&&i.push(n)}return i}),Id(Pl,Pl,(e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e])),Id(Pl,Tl,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),Id(Pl,Vl,(e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e])),Id(Pl,Il,(e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e])),Id(El,Pl,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e])),Id(El,El,(e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new Ql(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]}),Id(El,Il,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e])),Id(El,Tl,(e,t,i)=>{if(e.oldRange&&(e.oldRange=oa._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=oa._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.start.path=i.abRelation.path,e.newRange.end=n.end,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=n.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=oa._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]}),Id(El,Vl,(e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=ta._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=ta._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=ta._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=ta._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]}),Id(Il,Pl,(e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e])),Id(Il,Il,(e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new ta(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new Ql(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,s="$graveyard"==t.targetPosition.root.rootName,o=n&&!s;if(s&&!n||!o&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Tl(i,e.howMany,n,0)]}return[new Ql(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),Id(Il,Tl,(e,t,i)=>{const n=oa._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new Ql(0)]:(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])}),Id(Il,Vl,(e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const n=0!=t.howMany,s=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||s||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}),Id(Tl,Pl,(e,t)=>{const i=oa._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]}),Id(Tl,Tl,(e,t,i)=>{const n=oa._createFromPositionAndShift(e.sourcePosition,e.howMany),s=oa._createFromPositionAndShift(t.sourcePosition,t.howMany);let o,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),o=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),zd(e,t)&&zd(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Ld([n],o);if(s.containsPosition(e.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Ld([n],o);const l=ln(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Ld([n],o);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],h=n.getDifference(s);for(const e of h){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==ln(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const d=n.getIntersection(s);return null!==d&&r&&(d.start=d.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),d.end=d.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(d):1==c.length?s.start.isBefore(n.start)||s.start.isEqual(n.start)?c.unshift(d):c.push(d):c.splice(1,0,d)),0===c.length?[new Ql(e.baseVersion)]:Ld(c,o)}),Id(Tl,Vl,(e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const s=oa._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(s.start.hasSameParentAs(t.splitPosition)&&s.containsPosition(t.splitPosition)){let e=new oa(t.splitPosition,s.end);e=e._getTransformedBySplitOperation(t);return Ld([new oa(s.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const o=[s._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=s.start.isEqual(t.graveyardPosition)||s.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&o.push(oa._createFromPositionAndShift(t.insertionPosition,1))}return Ld(o,n)}),Id(Tl,Il,(e,t,i)=>{const n=oa._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new Ql(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),s=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Tl(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),s=s._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const o=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),r=new Tl(n,1,o,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new ta(r.targetPosition.root,a);s=s._getTransformedByMove(n,o,1);const c=new Tl(s,t.howMany,l,0);return i.push(r),i.push(c),i}const s=oa._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=s.start,e.howMany=s.end.offset-s.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]}),Id(Sl,Pl,(e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e])),Id(Sl,Il,(e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e])),Id(Sl,Tl,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),Id(Sl,Sl,(e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new Ql(0)];e.oldName=t.newName}return[e]}),Id(Sl,Vl,(e,t)=>{if("same"==ln(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new Sl(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]}),Id(Rl,Rl,(e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new Ql(0)];e.oldValue=t.newValue}return[e]}),Id(Vl,Pl,(e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset<t.position.offset&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByInsertOperation(t),e.insertionPosition=e.insertionPosition._getTransformedByInsertOperation(t),[e])),Id(Vl,Il,(e,t,i)=>{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new ta(t.graveyardPosition.root,i),s=Vl.getInsertionPosition(new ta(t.graveyardPosition.root,i)),o=new Vl(n,0,s,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Vl.getInsertionPosition(e.splitPosition),e.graveyardPosition=o.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[o,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Vl.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),Id(Vl,Tl,(e,t,i)=>{const n=oa._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const s=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&s){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),s=n.path.slice();s.push(0);const o=new ta(n.root,s);return[new Tl(i,e.howMany,o,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const s=e.splitPosition.isEqual(t.targetPosition);if(s&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Vl.getInsertionPosition(e.splitPosition),[e];if(s&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany),e.splitPosition=t.sourcePosition.clone(),e.insertionPosition=Vl.getInsertionPosition(e.splitPosition),[e]}return t.sourcePosition.isEqual(t.targetPosition)||(e.splitPosition.hasSameParentAs(t.sourcePosition)&&e.splitPosition.offset<=t.sourcePosition.offset&&(e.howMany-=t.howMany),e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany)),e.splitPosition.stickiness="toNone",e.splitPosition=e.splitPosition._getTransformedByMoveOperation(t),e.splitPosition.stickiness="toNext",e.graveyardPosition?e.insertionPosition=e.insertionPosition._getTransformedByMoveOperation(t):e.insertionPosition=Vl.getInsertionPosition(e.splitPosition),[e]}),Id(Vl,Vl,(e,t,i)=>{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new Ql(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new Ql(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,s="$graveyard"==t.splitPosition.root.rootName,o=n&&!s;if(s&&!n||!o&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Tl(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Tl(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new Ql(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new ta(t.insertionPosition.root,i);return[e,new Tl(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset<t.splitPosition.offset&&(e.howMany-=t.howMany),e.splitPosition=e.splitPosition._getTransformedBySplitOperation(t),e.insertionPosition=Vl.getInsertionPosition(e.splitPosition),[e]});class Hd extends tr{constructor(e){super(e),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jd extends tr{constructor(e){super(e),this.domEventType=["mousedown","mouseup"]}onDomEvent(e){this.fire(e.type,e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wd{constructor(e){this.document=e}createDocumentFragment(e){return new js(this.document,e)}createElement(e,t,i){return new Zn(this.document,e,t,i)}createText(e){return new dn(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new Zn(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){lt(e)&&void 0===i&&(i=t),i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return as._createAt(e,t)}createPositionAfter(e){return as._createAfter(e)}createPositionBefore(e){return as._createBefore(e)}createRange(e,t){return new ls(e,t)}createRangeOn(e){return ls._createOn(e)}createRangeIn(e){return ls._createIn(e)}createSelection(e,t,i){return new ds(e,t,i)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const qd=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,$d=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Ud=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Kd=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Gd=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Jd=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple","currentcolor","transparent"]);function Yd(e){return e.startsWith("#")?qd.test(e):e.startsWith("rgb")?$d.test(e)||Ud.test(e):e.startsWith("hsl")?Kd.test(e)||Gd.test(e):Jd.has(e.toLowerCase())}const Qd=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Xd(e){return Qd.includes(e)}const Zd=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function eu(e){return Zd.test(e)}const tu=/^[+-]?[0-9]*([.][0-9]+)?%$/;function iu(e){return tu.test(e)}const nu=["repeat-x","repeat-y","repeat","space","round","no-repeat"];const su=["center","top","bottom","left","right"];function ou(e){return su.includes(e)}const ru=["fixed","scroll","local"];function au(e){return ru.includes(e)}const lu=/^url\(/;function cu(e){return lu.test(e)}function hu(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=fu(e),i=t[0],n=t[2]||i,s=t[1]||i;return{top:i,bottom:n,right:s,left:t[3]||s}}function du(e){return t=>{const{top:i,right:n,bottom:s,left:o}=t,r=[];return[i,n,o,s].every(e=>!!e)?r.push([e,uu(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),s&&r.push([e+"-bottom",s]),o&&r.push([e+"-left",o])),r}}function uu({top:e,right:t,bottom:i,left:n}){const s=[];return n!==t?s.push(e,t,i,n):i!==e?s.push(e,t,i):t!==e?s.push(e,t):s.push(e),s.join(" ")}function mu(e){return t=>({path:e,value:hu(t)})}function fu(e){return e.replace(/, /g,",").split(" ").map(e=>e.replace(/,/g,", "))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function gu(e){e.setNormalizer("background",pu),e.setNormalizer("background-color",e=>({path:"background.color",value:e})),e.setReducer("background",e=>{const t=[];return t.push(["background-color",e.color]),t})}function pu(e){const t={},i=fu(e);for(const e of i)n=e,nu.includes(n)?(t.repeat=t.repeat||[],t.repeat.push(e)):ou(e)?(t.position=t.position||[],t.position.push(e)):au(e)?t.attachment=e:Yd(e)?t.color=e:cu(e)&&(t.image=e);var n;return{path:"background",value:t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function wu(e){e.setNormalizer("border",bu),e.setNormalizer("border-top",_u("top")),e.setNormalizer("border-right",_u("right")),e.setNormalizer("border-bottom",_u("bottom")),e.setNormalizer("border-left",_u("left")),e.setNormalizer("border-color",vu("color")),e.setNormalizer("border-width",vu("width")),e.setNormalizer("border-style",vu("style")),e.setNormalizer("border-top-color",ku("color","top")),e.setNormalizer("border-top-style",ku("style","top")),e.setNormalizer("border-top-width",ku("width","top")),e.setNormalizer("border-right-color",ku("color","right")),e.setNormalizer("border-right-style",ku("style","right")),e.setNormalizer("border-right-width",ku("width","right")),e.setNormalizer("border-bottom-color",ku("color","bottom")),e.setNormalizer("border-bottom-style",ku("style","bottom")),e.setNormalizer("border-bottom-width",ku("width","bottom")),e.setNormalizer("border-left-color",ku("color","left")),e.setNormalizer("border-left-style",ku("style","left")),e.setNormalizer("border-left-width",ku("width","left")),e.setExtractor("border-top",Cu("top")),e.setExtractor("border-right",Cu("right")),e.setExtractor("border-bottom",Cu("bottom")),e.setExtractor("border-left",Cu("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",du("border-color")),e.setReducer("border-style",du("border-style")),e.setReducer("border-width",du("border-width")),e.setReducer("border-top",Pu("top")),e.setReducer("border-right",Pu("right")),e.setReducer("border-bottom",Pu("bottom")),e.setReducer("border-left",Pu("left")),e.setReducer("border",Tu),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function bu(e){const{color:t,style:i,width:n}=xu(e);return{path:"border",value:{color:hu(t),style:hu(i),width:hu(n)}}}function _u(e){return t=>{const{color:i,style:n,width:s}=xu(t),o={};return void 0!==i&&(o.color={[e]:i}),void 0!==n&&(o.style={[e]:n}),void 0!==s&&(o.width={[e]:s}),{path:"border",value:o}}}function vu(e){return t=>({path:"border",value:yu(t,e)})}function yu(e,t){return{[t]:hu(e)}}function ku(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function Cu(e){return(t,i)=>{if(i.border)return Au(i.border,e)}}function Au(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function xu(e){const t={},i=fu(e);for(const e of i)eu(e)||/thin|medium|thick/.test(e)?t.width=e:Xd(e)?t.style=e:t.color=e;return t}function Tu(e){const t=[];return t.push(...Eu(Au(e,"top"),"top")),t.push(...Eu(Au(e,"right"),"right")),t.push(...Eu(Au(e,"bottom"),"bottom")),t.push(...Eu(Au(e,"left"),"left")),t}function Pu(e){return t=>Eu(t,e)}function Eu(e,t){const i=[];return e&&void 0!==e.width&&i.push(e.width),e&&void 0!==e.style&&i.push(e.style),e&&void 0!==e.color&&i.push(e.color),i.length?[["border-"+t,i.join(" ")]]:[]}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Su(e){e.setNormalizer("margin",mu("margin")),e.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),e.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),e.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),e.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),e.setReducer("margin",du("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ru(e){e.setNormalizer("padding",mu("padding")),e.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),e.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),e.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),e.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),e.setReducer("padding",du("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Iu extends yc{constructor(e,t){super(e),this.view=t,this._toolbarConfig=Wh(e.config.get("toolbar")),this._elementReplacer=new yr}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,s=i.editable,o=n.document.getRoot();s.name=o.rootName,i.render();const r=s.element;this.setEditableElement(s.name,r),this.focusTracker.add(r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy(),super.destroy()}_initToolbar(){const e=this.editor,t=this.view,i=e.editing.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),t.stickyPanel.limiterElement=t.element,this._toolbarConfig.viewportTopOffset&&(t.stickyPanel.viewportTopOffset=this._toolbarConfig.viewportTopOffset),t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),function({origin:e,originKeystrokeHandler:t,originFocusTracker:i,toolbar:n,beforeFocus:s,afterBlur:o}){i.add(n.element),t.set("Alt+F10",(e,t)=>{i.isFocused&&!n.focusTracker.isFocused&&(s&&s(),n.focus(),t())}),n.keystrokes.set("Esc",(t,i)=>{n.focusTracker.isFocused&&(e.focus(),o&&o(),i())})}({origin:i,originFocusTracker:this.focusTracker,originKeystrokeHandler:e.keystrokes,toolbar:t.toolbar})}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement,s=e.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder");s&&xd({view:t,element:i,text:s,isDirectHost:!1,keepOnFocus:!0})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vu extends id{constructor(e,t,i={}){super(e),this.stickyPanel=new Cd(e),this.toolbar=new qh(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editable=new sd(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ou extends bc{constructor(e,t){super(t),Ki(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new Vu(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i});this.ui=new Iu(this,n),
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(e){if(!I(e.updateSourceElement))throw new l.a("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(t&&"textarea"===t.tagName.toLowerCase()&&t.form){let i;const n=t.form,s=()=>e.updateSourceElement();I(n.submit)&&(i=n.submit,n.submit=()=>{s(),i.apply(n)}),n.addEventListener("submit",s),e.on("destroy",()=>{n.removeEventListener("submit",s),i&&(n.submit=i)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise(i=>{const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init(Ki(e)?e:null)).then(()=>{if(!Ki(e)&&t.initialData)throw new l.a("editor-create-initial-data",null);const i=void 0!==t.initialData?t.initialData:function(e){return Ki(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);return n.data.init(i)}).then(()=>n.fire("ready")).then(()=>n))})}}Je(Ou,kc),Je(Ou,Cc);class Nu{constructor(e){this.files=function(e){const t=e.files?Array.from(e.files):[],i=e.items?Array.from(e.items):[];if(t.length)return t;return i.filter(e=>"file"===e.kind).map(e=>e.getAsFile())}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e),this._native=e}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class Mu extends tr{constructor(e){super(e);const t=this.document;function i(e){return(i,n)=>{n.preventDefault();const o=n.dropRange?[n.dropRange]:null,r=new s(t,e);t.fire(r,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:o,target:n.target}),r.stop.called&&n.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"})}onDomEvent(e){const t={dataTransfer:new Nu(e.clipboardData?e.clipboardData:e.dataTransfer)};"drop"!=e.type&&"dragover"!=e.type||(t.dropRange=function(e,t){const i=t.target.ownerDocument,n=t.clientX,s=t.clientY;let o;i.caretRangeFromPoint&&i.caretRangeFromPoint(n,s)?o=i.caretRangeFromPoint(n,s):t.rangeParent&&(o=i.createRange(),o.setStart(t.rangeParent,t.rangeOffset),o.collapse(!0));if(o)return e.domConverter.domRangeToView(o);return null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.view,e)),this.fire(e.type,e,t)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Bu=["figcaption","li"];
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Fu extends Ye{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(Mu),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document;this.listenTo(n,"clipboardInput",t=>{e.isReadOnly&&t.stop()},{priority:"highest"}),this.listenTo(n,"clipboardInput",(e,t)=>{const n=t.dataTransfer;let o=t.content||"";var r;
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */o||(n.getData("text/html")?o=function(e){return e.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>1==t.length?" ":t)}(n.getData("text/html")):n.getData("text/plain")&&(((r=(r=n.getData("text/plain")).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/^\s/,"&nbsp;").replace(/\s$/,"&nbsp;").replace(/\s\s/g," &nbsp;")).includes("</p><p>")||r.includes("<br>"))&&(r=`<p>${r}</p>`),o=r),o=this.editor.data.htmlProcessor.toView(o));const a=new s(this,"inputTransformation");this.fire(a,{content:o,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),a.stop.called&&e.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change(()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(e,i)=>{i.resultRange=t.insertContent(i.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document;function n(n,s){const o=s.dataTransfer;s.preventDefault();const r=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:o,content:r,method:n.name})}this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",(t,i)=>{e.isReadOnly?i.preventDefault():n(t,i)},{priority:"low"}),this.listenTo(i,"clipboardOutput",(i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",function e(t){let i="";if(t.is("$text")||t.is("$textProxy"))i=t.data;else if(t.is("element","img")&&t.hasAttribute("alt"))i=t.getAttribute("alt");else if(t.is("element","br"))i="\n";else{let n=null;for(const s of t.getChildren()){const t=e(s);n&&(n.is("containerElement")||s.is("containerElement"))&&(Bu.includes(n.name)||Bu.includes(s.name)?i+="\n":i+="\n\n"),i+=t,n=s}}return i}(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function*Du(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zu extends Xe{execute(){const e=this.editor.model,t=e.document;e.change(i=>{!function(e,t,i,n){const s=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,a=o.end.parent;if(n.isLimit(r)||n.isLimit(a))return void(s||r!=a||e.deleteContent(i));if(s){const e=Du(t.model.schema,i.getAttributes());Lu(t,o.start),t.setSelectionAttribute(e)}else{const n=!(o.start.isAtStart&&o.end.isAtEnd),s=r==a;e.deleteContent(i,{leaveUnmerged:n}),n&&(s?Lu(t,i.focus):t.setSelection(a,0))}}(this.editor.model,i,t.selection,e.schema),this.fire("afterExecute",{writer:i})})}}function Lu(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hu extends No{constructor(e){super(e);const t=this.document;t.on("keydown",(e,i)=>{if(this.isEnabled&&i.keyCode==Rs.enter){const n=new ms(t,"enter",t.selection.getFirstRange());t.fire(n,new er(t,i.domEvent,{isSoft:i.shiftKey})),n.stop.called&&e.stop()}})}observe(){}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ju extends Ye{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver(Hu),e.commands.add("enter",new zu(e)),this.listenTo(i,"enter",(i,n)=>{n.preventDefault(),n.isSoft||(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wu{constructor(e,t=20){this.model=e,this.size=0,this.limit=t,this.isLocked=!1,this._changeCallback=(e,t)=>{"transparent"!=t.type&&t!==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()),this._batch}input(e){this.size+=e,this.size>=this.limit&&this._reset(!0)}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(e){this.isLocked&&!e||(this._batch=null,this.size=0)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qu extends Xe{constructor(e,t){super(e),this.direction=t,this._buffer=new Wu(e.model,e.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,n=>{this._buffer.lock();const s=n.createSelection(e.selection||i.selection),o=e.sequence||1,r=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit}),this._shouldEntireContentBeReplacedWithParagraph(o))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(s,o))return void this.editor.execute("paragraph",{selection:s});if(s.isCollapsed)return;let a=0;s.getFirstRange().getMinimalFlatRanges().forEach(e=>{a+=hs(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),t.deleteContent(s,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(a),n.setSelection(s),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(n)))return!1;if(!t.schema.checkChild(n,"paragraph"))return!1;const s=n.getChild(0);return!s||"paragraph"!==s.name}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),s=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(s,n),e.setSelection(s,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const n=e.getFirstPosition(),s=i.schema.getLimitElement(n),o=s.getChild(0);return n.parent==o&&(!!e.containsEntireContent(o)&&(!!i.schema.checkChild(s,"paragraph")&&"paragraph"!=o.name))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $u extends No{constructor(e){super(e);const t=e.document;let i=0;function n(e,i,n){const s=new ms(t,"delete",t.selection.getFirstRange());t.fire(s,new er(t,i,n)),s.stop.called&&e.stop()}t.on("keyup",(e,t)=>{t.keyCode!=Rs.delete&&t.keyCode!=Rs.backspace||(i=0)}),t.on("keydown",(e,t)=>{const s={};if(t.keyCode==Rs.delete)s.direction="forward",s.unit="character";else{if(t.keyCode!=Rs.backspace)return;s.direction="backward",s.unit="codePoint"}const o=Ps.isMac?t.altKey:t.ctrlKey;s.unit=o?"word":s.unit,s.sequence=++i,n(e,t.domEvent,s)}),Ps.isAndroid&&t.on("beforeinput",(t,i)=>{if("deleteContentBackward"!=i.domEvent.inputType)return;const s={unit:"codepoint",direction:"backward",sequence:1},o=i.domTarget.ownerDocument.defaultView.getSelection();o.anchorNode==o.focusNode&&o.anchorOffset+1!=o.focusOffset&&(s.selectionToRemove=e.domConverter.domSelectionToView(o)),n(t,i.domEvent,s)})}observe(){}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Uu extends Ye{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver($u);const n=new qu(e,"forward");if(e.commands.add("deleteForward",n),e.commands.add("forwardDelete",n),e.commands.add("delete",new qu(e,"backward")),this.listenTo(i,"delete",(i,n)=>{const s={unit:n.unit,sequence:n.sequence};if(n.selectionToRemove){const t=e.model.createSelection(),i=[];for(const t of n.selectionToRemove.getRanges())i.push(e.editing.mapper.toModelRange(t));t.setTo(i),s.selection=t}e.execute("forward"==n.direction?"deleteForward":"delete",s),n.preventDefault(),t.scrollToTheSelection()},{priority:"low"}),Ps.isAndroid){let e=null;this.listenTo(i,"delete",(t,i)=>{const n=i.domTarget.ownerDocument.defaultView.getSelection();e={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}},{priority:"lowest"}),this.listenTo(i,"keyup",(t,i)=>{if(e){const t=i.domTarget.ownerDocument.defaultView.getSelection();t.collapse(e.anchorNode,e.anchorOffset),t.extend(e.focusNode,e.focusOffset),e=null}})}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ku{constructor(){this._stack=[]}add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const s=i[0];n===s||Gu(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const s=i[0];n===s||Gu(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex(t=>t.id===e.id);if(Gu(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Ju(t[n],e);)n++;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex(t=>t.id===e);i>-1&&t.splice(i,1)}}function Gu(e,t){return e&&t&&e.priority==t.priority&&Yu(e.classes)==Yu(t.classes)}function Ju(e,t){return e.priority>t.priority||!(e.priority<t.priority)&&Yu(e.classes)>Yu(t.classes)}function Yu(e){return Array.isArray(e)?e.sort().join(","):e}Je(Ku,d);function Qu(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function Xu(e,t,i={}){if(!e.is("containerElement"))throw new l.a("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=am,i.label&&function(e,t,i){i.setCustomProperty("widgetLabel",t,e)}(e,i.label,t),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),i=new yh;return i.set("content",'<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>'),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e,t),tm(e,t,Zu,em),e}function Zu(e,t,i){if(t.classes&&i.addClass(en(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function em(e,t,i){if(t.classes&&i.removeClass(en(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function tm(e,t,i,n){const s=new Ku;s.on("change:top",(t,s)=>{s.oldDescriptor&&n(e,s.oldDescriptor,s.writer),s.newDescriptor&&i(e,s.newDescriptor,s.writer)}),t.setCustomProperty("addHighlight",(e,t,i)=>s.add(t,i),e),t.setCustomProperty("removeHighlight",(e,t,i)=>s.remove(t,i),e)}function im(e){const t=e.getCustomProperty("widgetLabel");return t?"function"==typeof t?t():t:""}function nm(e,t){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",(i,n,s)=>{t.setAttribute("contenteditable",s?"false":"true",e)}),e.on("change:isFocused",(i,n,s)=>{s?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)}),e}function sm(e,t){const i=e.getSelectedElement();if(i){const n=cm(e);if(n)return t.createPositionAt(i,n);if(t.schema.isBlock(i))return t.createPositionAfter(i)}const n=e.getSelectedBlocks().next().value;if(n){if(n.isEmpty)return t.createPositionAt(n,0);const i=t.createPositionAfter(n);return e.focus.isTouching(i)?i:t.createPositionBefore(n)}return e.focus}function om(e,t){const i=e.getSelectedElement();return!!i&&t.isObject(i)}function rm(e,t){const i=new Pr(vo.window),n=i.getIntersection(e),s=t.height+fd.arrowVerticalOffset;if(e.top-s>i.top||e.bottom+s<i.bottom)return null;const o=n||e,r=o.left+o.width/2-t.width/2;return{top:Math.max(e.top,0)+fd.arrowVerticalOffset,left:r,name:"arrow_n"}}function am(){return null}function lm(e,t,i){return e&&Qu(e)&&!i.isInline(t)}function cm(e){return e.getAttribute("widget-type-around")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const hm=[Vs("arrowUp"),Vs("arrowRight"),Vs("arrowDown"),Vs("arrowLeft"),9,16,17,18,19,20,27,33,34,35,36,45,91,93,144,145,173,174,175,176,177,178,179,255];for(let e=112;e<=135;e++)hm.push(e);function dm(e){return!(!e.ctrlKey&&!e.metaKey)||hm.includes(e.keyCode)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const um=["before","after"],mm=(new DOMParser).parseFromString('<svg viewBox="0 0 10 8" xmlns="http://www.w3.org/2000/svg"><path d="M9.055.263v3.972h-6.77M1 4.216l2-2.038m-2 2 2 2.038"/></svg>',"image/svg+xml").firstChild;class fm extends Ye{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[ju,Uu]}constructor(e){super(e),this._currentFakeCaretModelElement=null}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(i,n,s)=>{t.change(e=>{for(const i of t.document.roots)s?e.removeClass("ck-widget__type-around_disabled",i):e.addClass("ck-widget__type-around_disabled",i)}),s||e.model.change(e=>{e.removeSelectionAttribute("widget-type-around")})}),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view;i.execute("insertParagraph",{position:i.model.createPositionAt(e,t)}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,(...e)=>{this.isEnabled&&i(...e)},n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=cm(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(e,i,s)=>{const o=s.mapper.toViewElement(i.item);lm(o,i.item,t)&&function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const i=this.toDomElement(e);return function(e,t){for(const i of um){const n=new th({tag:"div",attributes:{class:["ck","ck-widget__type-around__button","ck-widget__type-around__button_"+i],title:t[i]},children:[e.ownerDocument.importNode(mm,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new th({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(s.writer,n,o)},{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,n=t.schema,s=e.editing.view;function o(e){return"ck-widget_type-around_show-fake-caret_"+e}this._listenToIfEnabled(s.document,"arrowKey",(e,t)=>{this._handleArrowKeyPress(e,t)},{context:[Qu,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(t,i)=>{i.directChange&&e.model.change(e=>{e.removeSelectionAttribute("widget-type-around")})}),this._listenToIfEnabled(t.document,"change:data",()=>{const t=i.getSelectedElement();if(t){if(lm(e.editing.mapper.toViewElement(t),t,n))return}e.model.change(e=>{e.removeSelectionAttribute("widget-type-around")})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(e,t,i)=>{const s=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(s.removeClass(um.map(o),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!lm(a,r,n))return;const l=cm(t.selection);l&&(s.addClass(o(l),a),this._currentFakeCaretModelElement=r)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(t,i,n)=>{n||e.model.change(e=>{e.removeSelectionAttribute("widget-type-around")})})}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,s=n.document.selection,o=n.schema,r=i.editing.view,a=Bs(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;lm(l,i.editing.mapper.toModelElement(l),o)?c=this._handleArrowKeyPressOnSelectedWidget(a):s.isCollapsed&&(c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=cm(t.document.selection);return t.change(t=>{if(!i)return t.setSelectionAttribute("widget-type-around",e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute("widget-type-around"),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,s=t.plugins.get("Widget"),o=s._getObjectElementNextToSelection(e);return!!lm(t.editing.mapper.toViewElement(o),o,n)&&(i.change(t=>{s._setSelectionOverElement(o),t.setSelectionAttribute("widget-type-around",e?"before":"after")}),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(i,n)=>{const s=n.domTarget.closest(".ck-widget__type-around__button");if(!s)return;const o=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(s),r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(s,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,o),n.preventDefault(),i.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",(i,n)=>{if("atTarget"!=i.eventPhase)return;const s=t.getSelectedElement(),o=e.editing.mapper.toViewElement(s),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:lm(o,s,r)&&(this._insertParagraph(s,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())},{context:Qu})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view,t=[Rs.enter,Rs.delete,Rs.backspace];this._listenToIfEnabled(e.document,"keydown",(e,i)=>{t.includes(i.keyCode)||dm(i)||this._insertParagraphAccordingToFakeCaretPosition()},{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",(t,s)=>{if("atTarget"!=t.eventPhase)return;const o=cm(i.document.selection);if(!o)return;const r=s.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===o===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,o),r);if(t)if(t.isCollapsed){const s=i.createSelection(t.start);if(i.modifySelection(s,{direction:r}),s.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change(i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")})}else i.change(i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")})}s.preventDefault(),t.stop()},{context:Qu})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(e,[n,s])=>{if(s&&!s.is("documentSelection"))return;const o=cm(i);return o?(e.stop(),t.change(e=>{const s=i.getSelectedElement(),r=t.createPositionAt(s,o),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l})):void 0},{priority:"high"})}}function gm(e){const t=e.model;return(i,n)=>{const s=n.keyCode==Rs.arrowup,o=n.keyCode==Rs.arrowdown,r=n.shiftKey,a=t.document.selection;if(!s&&!o)return;const l=o;if(r&&function(e,t){return!e.isCollapsed&&e.isBackward==t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(a,l))return;const c=function(e,t,i){const n=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=pm(n,e,"forward");if(!i)return null;const s=n.createRange(e,i),o=wm(n.schema,s,"backward");return o&&e.isBefore(o)?n.createRange(e,o):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=pm(n,e,"backward");if(!i)return null;const s=n.createRange(i,e),o=wm(n.schema,s,"forward");return o&&e.isAfter(o)?n.createRange(o,e):null}}(e,a,l);c&&!c.isCollapsed&&function(e,t,i){const n=e.model,s=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const o=e.mapper.toViewRange(t),r=s.viewRangeToDom(o),a=Pr.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l)&&(t.change(e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)}),i.stop(),n.preventDefault(),n.stopPropagation())}}function pm(e,t,i){const n=e.schema,s=e.createRangeIn(t.root),o="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of s.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==o&&n.isBlock(r))return null}return null}function wm(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n}class bm extends Ye{static get pluginName(){return"Widget"}static get requires(){return[fm,Uu]}init(){const e=this.editor.editing.view,t=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",(e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,s=n.document.selection,o=s.getSelectedElement();let r=null;for(const e of s.getRanges())for(const t of e){const e=t.item;Qu(e)&&!_m(e,r)&&(n.addClass("ck-widget_selected",e),this._previouslySelected.add(e),r=e,e==o&&n.setSelection(s.getRanges(),{fake:!0,label:im(o)}))}},{priority:"low"}),e.addObserver(jd),this.listenTo(t,"mousedown",(...e)=>this._onMousedown(...e)),this.listenTo(t,"arrowKey",(...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)},{context:[Qu,"$text"]}),this.listenTo(t,"arrowKey",(...e)=>{this._preventDefaultOnArrowKeyPress(...e)},{context:"$root"}),this.listenTo(t,"arrowKey",gm(this.editor.editing),{context:"$text"}),this.listenTo(t,"delete",(e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())},{context:"$root"})}_onMousedown(e,t){const i=this.editor,n=i.editing.view,s=n.document;let o=t.target;if(function(e){for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(Qu(e))return!1;e=e.parent}return!1}(o)){if((Ps.isSafari||Ps.isGecko)&&t.domEvent.detail>=3){const e=i.editing.mapper,n=o.is("attributeElement")?o.findAncestor(e=>!e.is("attributeElement")):o,s=e.toModelElement(n);t.preventDefault(),this.editor.model.change(e=>{e.setSelection(s,"in")})}return}if(!Qu(o)&&(o=o.findAncestor(Qu),!o))return;Ps.isAndroid&&t.preventDefault(),s.isFocused||n.focus();const r=i.editing.mapper.toModelElement(o);this._setSelectionOverElement(r)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,s=n.schema,o=n.document.selection,r=o.getSelectedElement(),a=Bs(i,this.editor.locale.contentLanguageDirection);if(r&&s.isObject(r)){const i=a?o.getLastPosition():o.getFirstPosition(),r=s.getNearestSelectionRange(i,a?"forward":"backward");return void(r&&(n.change(e=>{e.setSelection(r)}),t.preventDefault(),e.stop()))}if(!o.isCollapsed)return;const l=this._getObjectElementNextToSelection(a);l&&s.isObject(l)&&(this._setSelectionOverElement(l),t.preventDefault(),e.stop())}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,s=i.document.selection.getSelectedElement();s&&n.isObject(s)&&(t.preventDefault(),e.stop())}_handleDelete(e){if(this.editor.isReadOnly)return;const t=this.editor.model.document.selection;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change(e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)}),!0):void 0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,s=t.createSelection(n);t.modifySelection(s,{direction:e?"forward":"backward"});const o=e?s.focus.nodeBefore:s.focus.nodeAfter;return o&&i.isObject(o)?o:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass("ck-widget_selected",t);this._previouslySelected.clear()}}function _m(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}var vm=function(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return b(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),gr(e,t,{leading:n,maxWait:t,trailing:s})};
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ym extends Ye{static get pluginName(){return"DragDrop"}static get requires(){return[Fu,bm]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=vm(e=>this._updateDropMarker(e),40),this._removeDropMarkerDelayed=Am(()=>this._removeDropMarker(),40),this._clearDraggableAttributesDelayed=Am(()=>this._clearDraggableAttributes(),40),t.addObserver(Mu),t.addObserver(jd),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(e,t,i)=>{i||this._finalizeDragging(!1)}),Ps.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=t.document,n=e.editing.view,s=n.document;this.listenTo(s,"dragstart",(n,o)=>{const a=i.selection;if(o.target&&o.target.is("editableElement"))return void o.preventDefault();const l=o.target?xm(o.target):null;if(l){const i=e.editing.mapper.toModelElement(l);this._draggedRange=ba.fromRange(t.createRangeOn(i))}else if(!s.selection.isCollapsed){const e=s.selection.getSelectedElement();e&&Qu(e)||(this._draggedRange=ba.fromRange(a.getFirstRange()))}if(!this._draggedRange)return void o.preventDefault();this._draggingUid=r(),o.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",o.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange()),h=e.data.toView(t.getSelectedContent(c));s.fire("clipboardOutput",{dataTransfer:o.dataTransfer,content:h,method:n.name}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(s,"dragend",(e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)},{priority:"low"}),this.listenTo(s,"dragenter",()=>{this.isEnabled&&n.focus()}),this.listenTo(s,"dragleave",()=>{this._removeDropMarkerDelayed()}),this.listenTo(s,"dragging",(t,i)=>{if(!this.isEnabled)return void(i.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const n=km(e,i.targetRanges,i.target);this._draggedRange||(i.dataTransfer.dropEffect="copy"),Ps.isGecko||("copy"==i.dataTransfer.effectAllowed?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),n&&this._updateDropMarkerThrottled(n)},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",(t,i)=>{if("drop"!=i.method)return;const n=km(e,i.targetRanges,i.target);if(this._removeDropMarker(),!n)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=i.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Cm(i.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(n,!0))return this._finalizeDragging(!1),void t.stop();i.targetRanges=[e.editing.mapper.toViewRange(n)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Fu);e.on("contentInsertion",(e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map(e=>this.editor.editing.mapper.toModelRange(e));this.editor.model.change(e=>e.setSelection(i))},{priority:"high"}),e.on("contentInsertion",(e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==Cm(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",(n,s)=>{if(Ps.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let o=xm(s.target);if(Ps.isBlink&&!e.isReadOnly&&!o&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&Qu(e)||(o=i.selection.editableElement)}o&&(t.change(e=>{e.setAttribute("draggable","true",o)}),this._draggableElement=e.editing.mapper.toModelElement(o))}),this.listenTo(i,"mouseup",()=>{Ps.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_setupDropMarker(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return i.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.innerHTML="&NoBreak;<span></span>&NoBreak;",t}))}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change(t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change(e=>{e.removeMarker("drop-target")})}_finalizeDragging(e){const t=this.editor.model;this._removeDropMarker(),this._clearDraggableAttributes(),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&t.deleteContent(t.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function km(e,t,i){const n=e.model,s=e.editing.mapper;let o=null;const r=t?t[0].start:null;if(i.is("uiElement")&&(i=i.parent),o=function(e,t){const i=e.model,n=e.editing.mapper;if(Qu(t))return i.createRangeOn(n.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor(e=>Qu(e)||e.is("editableElement"));if(Qu(e))return i.createRangeOn(n.toModelElement(e))}return null}(e,i),o)return o;const a=function(e,t){const i=e.editing.mapper,n=e.editing.view,s=i.toModelElement(t);if(s)return s;const o=n.createPositionBefore(t),r=i.findMappedViewAncestor(o);return i.toModelElement(r)}(e,i),l=r?s.toModelPosition(r):null;return l?(o=function(e,t,i){const n=e.model;if(!n.schema.checkChild(i,"$block"))return null;const s=n.createPositionAt(i,0),o=t.path.slice(0,s.path.length),r=n.createPositionFromPath(t.root,o).nodeAfter;if(r&&n.schema.isObject(r))return n.createRangeOn(r);return null}(e,l,a),o||(o=n.schema.getNearestSelectionRange(l,Ps.isGecko?"forward":"backward"),o||function(e,t){const i=e.model;for(;t;){if(i.schema.isObject(t))return i.createRangeOn(t);t=t.parent}}(e,l.parent))):function(e,t){const i=e.model,n=i.schema,s=i.createPositionAt(t,0);return n.getNearestSelectionRange(s,"forward")}(e,a)}function Cm(e){return Ps.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Am(e,t){let i;function n(...s){n.cancel(),i=setTimeout(()=>e(...s),t)}return n.cancel=()=>{clearTimeout(i)},n}function xm(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(Qu);if(Qu(e))return e;const t=e.findAncestor(e=>Qu(e)||e.is("editableElement"));return Qu(t)?t:null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tm extends Ye{static get pluginName(){return"PastePlainText"}static get requires(){return[Fu]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=t.document.selection;let o=!1;i.addObserver(Mu),this.listenTo(n,"keydown",(e,t)=>{o=t.shiftKey}),e.plugins.get(Fu).on("contentInsertion",(e,i)=>{(o||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==[...i.getAttributeKeys()].length}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i.content,t.schema))&&t.change(e=>{const n=Array.from(s.getAttributes()).filter(([e])=>t.schema.getAttributeProperties(e).isFormatting);s.isCollapsed||t.deleteContent(s,{doNotAutoparagraph:!0}),n.push(...s.getAttributes());const o=e.createRangeIn(i.content);for(const t of o.getItems())t.is("$textProxy")&&e.setAttributes(n,t)})})}}class Pm extends Ye{static get pluginName(){return"Clipboard"}static get requires(){return[Fu,ym,Tm]}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Em extends Xe{execute(){const e=this.editor.model,t=e.document;e.change(i=>{!function(e,t,i){const n=i.isCollapsed,s=i.getFirstRange(),o=s.start.parent,r=s.end.parent,a=o==r;if(n){const n=Du(e.schema,i.getAttributes());Sm(e,t,s.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?Sm(e,t,i.focus):n&&t.setSelection(r,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})})}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),s=n.start.parent,o=n.end.parent;if((Rm(s,e)||Rm(o,e))&&s!==o)return!1;return!0}(e.schema,t.selection)}}function Sm(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function Rm(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Rm(e.parent,t))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Im extends Ye{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,s=n.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(Hu),e.commands.add("shiftEnter",new Em(e)),this.listenTo(s,"enter",(t,i)=>{i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())},{priority:"low"})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vm extends Xe{execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!Om(e.schema,i))do{if(i=i.parent,!i)return}while(!Om(e.schema,i));e.change(e=>{e.setSelection(i,"in")})}}function Om(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Nm=Os("Ctrl+A");class Mm extends Ye{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new Vm(e)),this.listenTo(t,"keydown",(t,i)=>{Vs(i)===Nm&&(e.execute("selectAll"),i.preventDefault())})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Bm extends Ye{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",t=>{const i=e.commands.get("selectAll"),n=new Ch(t),s=t.t;return n.set({label:s("Select all"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M.75 15.5a.75.75 0 0 1 .75.75V18l.008.09A.5.5 0 0 0 2 18.5h1.75a.75.75 0 1 1 0 1.5H1.5l-.144-.007a1.5 1.5 0 0 1-1.35-1.349L0 18.5v-2.25a.75.75 0 0 1 .75-.75zm18.5 0a.75.75 0 0 1 .75.75v2.25l-.007.144a1.5 1.5 0 0 1-1.349 1.35L18.5 20h-2.25a.75.75 0 1 1 0-1.5H18a.5.5 0 0 0 .492-.41L18.5 18v-1.75a.75.75 0 0 1 .75-.75zm-10.45 3c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm.45-5.5a.75.75 0 1 1 0 1.5h-8.5a.75.75 0 1 1 0-1.5h8.5zM1.3 11c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM1.3 7c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5h-2.5a.75.75 0 1 1 0-1.5h2.5zm-5 0a.75.75 0 1 1 0 1.5h-5.5a.75.75 0 0 1 0-1.5h5.5zm-6.5-5a.75.75 0 0 1 0 1.5H2a.5.5 0 0 0-.492.41L1.5 2v1.75a.75.75 0 0 1-1.5 0V1.5l.007-.144A1.5 1.5 0 0 1 1.356.006L1.5 0h2.25zM18.5 0l.144.007a1.5 1.5 0 0 1 1.35 1.349L20 1.5v2.25a.75.75 0 1 1-1.5 0V2l-.008-.09A.5.5 0 0 0 18 1.5h-1.75a.75.75 0 1 1 0-1.5h2.25zM8.8 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6z"/></svg>',keystroke:"Ctrl+A",tooltip:!0}),n.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(n,"execute",()=>{e.execute("selectAll"),e.editing.view.focus()}),n})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Fm extends Ye{static get requires(){return[Mm,Bm]}static get pluginName(){return"SelectAll"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Dm extends Xe{constructor(e,t){super(e),this._buffer=new Wu(e.model,t),this._batches=new WeakSet}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,n=e.text||"",s=n.length,o=e.range?t.createSelection(e.range):i.selection,r=e.resultRange;t.enqueueChange(this._buffer.batch,e=>{this._buffer.lock(),this._batches.add(this._buffer.batch),t.deleteContent(o),n&&t.insertContent(e.createText(n,i.selection.getAttributes()),o),r?e.setSelection(r):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(s)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function zm(e){if(e.newChildren.length-e.oldChildren.length!=1)return;const t=function(e,t){const i=[];let n,s=0;return e.forEach(e=>{"equal"==e?(o(),s++):"insert"==e?(r("insert")?n.values.push(t[s]):(o(),n={type:"insert",index:s,values:[t[s]]}),s++):r("delete")?n.howMany++:(o(),n={type:"delete",index:s,howMany:1})}),o(),i;function o(){n&&(i.push(n),n=null)}function r(e){return n&&n.type==e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(uo(e.oldChildren,e.newChildren,Lm),e.newChildren);if(t.length>1)return;const i=t[0];return i.values[0]&&i.values[0].is("$text")?i:void 0}function Lm(e,t){return e&&e.is("$text")&&t&&t.is("$text")?e.data===t.data:e===t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hm{constructor(e){this.editor=e,this.editing=this.editor.editing}handle(e,t){if(function(e){if(0==e.length)return!1;for(const t of e)if("children"===t.type&&!zm(t))return!0;return!1}(e))this._handleContainerChildrenMutations(e,t);else for(const i of e)this._handleTextMutation(i,t),this._handleTextNodeInsertion(i)}_handleContainerChildrenMutations(e,t){const i=function(e){const t=e.map(e=>e.node).reduce((e,t)=>e.getCommonAncestor(t,{includeSelf:!0}));if(!t)return;return t.getAncestors({includeSelf:!0,parentFirst:!0}).find(e=>e.is("containerElement")||e.is("rootElement"))}(e);if(!i)return;const n=this.editor.editing.view.domConverter.mapViewToDom(i),s=new To(this.editor.editing.view.document),o=this.editor.data.toModel(s.domToView(n)).getChild(0),r=this.editor.editing.mapper.toModelElement(i);if(!r)return;const a=Array.from(o.getChildren()),l=Array.from(r.getChildren()),c=a[a.length-1],h=l[l.length-1],d=c&&c.is("element","softBreak"),u=h&&!h.is("element","softBreak");d&&u&&a.pop();const m=this.editor.model.schema;if(!jm(a,m)||!jm(l,m))return;const f=a.map(e=>e.is("$text")?e.data:"@").join("").replace(/\u00A0/g," "),g=l.map(e=>e.is("$text")?e.data:"@").join("").replace(/\u00A0/g," ");if(g===f)return;const p=uo(g,f),{firstChangeAt:w,insertions:b,deletions:_}=Wm(p);let v=null;t&&(v=this.editing.mapper.toModelRange(t.getFirstRange()));const y=f.substr(w,b),k=this.editor.model.createRange(this.editor.model.createPositionAt(r,w),this.editor.model.createPositionAt(r,w+_));this.editor.execute("input",{text:y,range:k,resultRange:v})}_handleTextMutation(e,t){if("text"!=e.type)return;const i=e.newText.replace(/\u00A0/g," "),n=e.oldText.replace(/\u00A0/g," ");if(n===i)return;const s=uo(n,i),{firstChangeAt:o,insertions:r,deletions:a}=Wm(s);let l=null;t&&(l=this.editing.mapper.toModelRange(t.getFirstRange()));const c=this.editing.view.createPositionAt(e.node,o),h=this.editing.mapper.toModelPosition(c),d=this.editor.model.createRange(h,h.getShiftedBy(a)),u=i.substr(o,r);this.editor.execute("input",{text:u,range:d,resultRange:l})}_handleTextNodeInsertion(e){if("children"!=e.type)return;const t=zm(e),i=this.editing.view.createPositionAt(e.node,t.index),n=this.editing.mapper.toModelPosition(i),s=t.values[0].data;this.editor.execute("input",{text:s.replace(/\u00A0/g," "),range:this.editor.model.createRange(n)})}}function jm(e,t){return e.every(e=>t.isInline(e))}function Wm(e){let t=null,i=null;for(let n=0;n<e.length;n++){"equal"!=e[n]&&(t=null===t?n:t,i=n)}let n=0,s=0;for(let o=t;o<=i;o++)"insert"!=e[o]&&n++,"delete"!=e[o]&&s++;return{insertions:s,deletions:n,firstChangeAt:t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qm extends Ye{static get pluginName(){return"Input"}init(){const e=this.editor,t=new Dm(e,e.config.get("typing.undoStep")||20);e.commands.add("input",t),function(e){let t=null;const i=e.model,n=e.editing.view,s=e.commands.get("input");function o(e){const o=i.document,a=n.document.isComposing,l=t&&t.isEqual(o.selection);t=null,s.isEnabled&&(dm(e)||o.selection.isCollapsed||a&&229===e.keyCode||!a&&229===e.keyCode&&l||r())}function r(){const e=s.buffer;e.lock();const t=e.batch;s._batches.add(t),i.enqueueChange(t,()=>{i.deleteContent(i.document.selection)}),e.unlock()}Ps.isAndroid?n.document.on("beforeinput",(e,t)=>o(t),{priority:"lowest"}):n.document.on("keydown",(e,t)=>o(t),{priority:"lowest"}),n.document.on("compositionstart",(function(){const e=i.document,t=1!==e.selection.rangeCount||e.selection.getFirstRange().isFlat;if(e.selection.isCollapsed||t)return;r()}),{priority:"lowest"}),n.document.on("compositionend",()=>{t=i.createSelection(i.document.selection)},{priority:"lowest"})}(e),function(e){e.editing.view.document.on("mutations",(t,i,n)=>{new Hm(e).handle(i,n)})}(e)}isInput(e){return this.editor.commands.get("input")._batches.has(e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $m extends Ye{static get requires(){return[qm,Uu]}static get pluginName(){return"Typing"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Um(e,t){let i=e.start;return{text:Array.from(e.getItems()).reduce((e,n)=>n.is("$text")||n.is("$textProxy")?e+n.data:(i=t.createPositionAfter(n),""),""),range:t.createRange(i,e.end)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Km{constructor(e,t){this.model=e,this.testCallback=t,this.hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))}),this._startListening()}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",(t,{directChange:i})=>{i&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))}),this.listenTo(e,"change:data",(e,t)=>{"transparent"!=t.type&&this._evaluateTextBeforeSelection("data",{batch:t})})}_evaluateTextBeforeSelection(e,t={}){const i=this.model,n=i.document.selection,s=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:o,range:r}=Um(s,i),a=this.testCallback(o);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const i=Object.assign(t,{text:o,range:r});"object"==typeof a&&Object.assign(i,a),this.fire("matched:"+e,i)}}}Je(Km,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Gm extends Ye{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,s=t.document.selection;this.listenTo(i.document,"arrowKey",(e,t)=>{if(!s.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==Rs.arrowright,o=t.keyCode==Rs.arrowleft;if(!i&&!o)return;const r=n.contentLanguageDirection;let a=!1;a="ltr"===r&&i||"rtl"===r&&o?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()},{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(s,"change:range",(e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&Xm(s.getFirstPosition(),this.attributes)||this._restoreGravity())})}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model.document.selection,n=i.getFirstPosition();return!this._isGravityOverridden&&((!n.isAtStart||!Jm(i,t))&&(Xm(n,t)?(Qm(e),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return this._isGravityOverridden?(Qm(e),this._restoreGravity(),Ym(i,t,s),!0):s.isAtStart?!!Jm(n,t)&&(Qm(e),Ym(i,t,s),!0):function(e,t){return Xm(e.getShiftedBy(-1),t)}(s,t)?s.isAtEnd&&!Jm(n,t)&&Xm(s,t)?(Qm(e),Ym(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change(e=>e.overrideSelectionGravity())}_restoreGravity(){this.editor.model.change(e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null})}}function Jm(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function Ym(e,t,i){const n=i.nodeBefore;e.change(e=>{n?e.setSelectionAttribute(n.getAttributes()):e.removeSelectionAttribute(t)})}function Qm(e){e.preventDefault()}function Xm(e,t){const{nodeBefore:i,nodeAfter:n}=e;for(const e of t){const t=i?i.getAttribute(e):void 0;if((n?n.getAttribute(e):void 0)!==t)return!0}return!1}var Zm=/[\\^$.*+?()[\]{}|]/g;RegExp(Zm.source);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
ef('"'),ef("'"),ef("'"),ef('"'),ef('"'),ef("'");function ef(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function tf(e,t,i,n){return n.createRange(nf(e,t,i,!0,n),nf(e,t,i,!1,n))}function nf(e,t,i,n,s){let o=e.textNode||(n?e.nodeBefore:e.nodeAfter),r=null;for(;o&&o.getAttribute(t)==i;)r=o,o=n?o.previousSibling:o.nextSibling;return r?s.createPositionAt(r,n?"before":"after"):e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function sf(e,t,i,n){const s=e.editing.view,o=new Set;s.document.registerPostFixer(s=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=tf(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(s.addClass(n,e),o.add(e),a=!0)}return a}),e.conversion.for("editingDowncast").add(e=>{function t(){s.change(e=>{for(const t of o.values())e.removeClass(n,t),o.delete(t)})}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class of extends Xe{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(e.data,"set",()=>this.clearStack())}refresh(){this.isEnabled=this._stack.length>0}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,s=n.document,o=[],r=e.map(e=>e.getTransformedByOperations(i)),a=r.flat();for(const e of r){const t=e.filter(e=>e.root!=s.graveyard).filter(e=>!af(e,a));t.length&&(rf(t),o.push(t[0]))}o.length&&n.change(e=>{e.setSelection(o,{backward:t})})}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter(e=>e.isDocumentOperation);s.reverse();for(const e of s){const s=e.baseVersion+1,o=Array.from(n.history.getOperations(s)),r=Nd([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const s of r)t.addOperation(s),i.applyOperation(s),n.history.setOperationAsUndone(e,s)}}}function rf(e){e.sort((e,t)=>e.start.isBefore(t.start)?-1:1);for(let t=1;t<e.length;t++){const i=e[t-1].getJoined(e[t],!0);i&&(t--,e.splice(t,2,i))}}function af(e,t){return t.some(t=>t!==e&&t.containsRange(e,!0))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lf extends of{execute(e=null){const t=e?this._stack.findIndex(t=>t.batch==e):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(n,()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e),this.fire("revert",i.batch,n)}),this.refresh()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cf extends of{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(t,()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)}),this.refresh()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hf extends Ye{static get pluginName(){return"UndoEditing"}constructor(e){super(e),this._batchRegistry=new WeakSet}init(){const e=this.editor;this._undoCommand=new lf(e),this._redoCommand=new cf(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",(e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,s=this._redoCommand._createdBatches.has(n),o=this._undoCommand._createdBatches.has(n);this._batchRegistry.has(n)||"transparent"==n.type&&!s&&!o||(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack()),this._batchRegistry.add(n))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(e,t,i)=>{this._redoCommand.addBatch(i)}),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}var df='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m5.042 9.367 2.189 1.837a.75.75 0 0 1-.965 1.149l-3.788-3.18a.747.747 0 0 1-.21-.284.75.75 0 0 1 .17-.945L6.23 4.762a.75.75 0 1 1 .964 1.15L4.863 7.866h8.917A.75.75 0 0 1 14 7.9a4 4 0 1 1-1.477 7.718l.344-1.489a2.5 2.5 0 1 0 1.094-4.73l.008-.032H5.042z"/></svg>',uf='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m14.958 9.367-2.189 1.837a.75.75 0 0 0 .965 1.149l3.788-3.18a.747.747 0 0 0 .21-.284.75.75 0 0 0-.17-.945L13.77 4.762a.75.75 0 1 0-.964 1.15l2.331 1.955H6.22A.75.75 0 0 0 6 7.9a4 4 0 1 0 1.477 7.718l-.344-1.489A2.5 2.5 0 1 1 6.039 9.4l-.008-.032h8.927z"/></svg>';
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class mf extends Ye{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?df:uf,s="ltr"==t.uiLanguageDirection?uf:df;this._addButton("undo",i("Undo"),"CTRL+Z",n),this._addButton("redo",i("Redo"),"CTRL+Y",s)}_addButton(e,t,i,n){const s=this.editor;s.ui.componentFactory.add(e,o=>{const r=s.commands.get(e),a=new Ch(o);return a.set({label:t,icon:n,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",()=>{s.execute(e),s.editing.view.focus()}),a})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ff extends Ye{static get requires(){return[hf,mf]}static get pluginName(){return"Undo"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class gf{constructor(){const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}Je(gf,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class pf extends Ye{static get pluginName(){return"FileRepository"}static get requires(){return[Ac]}init(){this.loaders=new Xi,this.loaders.on("add",()=>this._updatePendingAction()),this.loaders.on("remove",()=>this._updatePendingAction()),this._loadersMap=new Map,this._pendingAction=null,this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(e,t)=>t?e/t*100:0)}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return Object(l.b)("filerepository-no-upload-adapter"),null;const t=new wf(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then(e=>{this._loadersMap.set(e,t)}).catch(()=>{}),t.on("change:uploaded",()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e}),t.on("change:uploadTotal",()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e}),t}destroyLoader(e){const t=e instanceof wf?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((e,i)=>{e===t&&this._loadersMap.delete(i)})}_updatePendingAction(){const e=this.editor.plugins.get(Ac);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}Je(pf,We);class wf{constructor(e,t){this.id=r(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new gf,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(e,t)=>t?e/t*100:0),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then(e=>this._filePromiseWrapper?e:null):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new l.a("filerepository-read-wrong-status",this);return this.status="reading",this.file.then(e=>this._reader.read(e)).then(e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e}).catch(e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e})}upload(){if("idle"!=this.status)throw new l.a("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then(()=>this._adapter.upload()).then(e=>(this.uploadResponse=e,this.status="idle",e)).catch(e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e})}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch(()=>{}),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then(e=>{t.isFulfilled=!0,i(e)}).catch(e=>{t.isFulfilled=!0,n(e)})}),t}}Je(wf,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class bf extends eh{constructor(e){super(e),this.buttonView=new Ch(e),this._fileInputView=new _f(e),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.setTemplate({tag:"span",attributes:{class:"ck-file-dialog-button"},children:[this.buttonView,this._fileInputView]}),this.buttonView.on("execute",()=>{this._fileInputView.open()})}focus(){this.buttonView.focus()}}class _f extends eh{constructor(e){super(e),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to(()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""})}})}open(){this.element.click()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vf{constructor(e,t){this.loader=e,this.options=t}upload(){return this.loader.file.then(e=>new Promise((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.options.uploadUrl,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,s=this.loader,o=`Couldn't upload file: ${i.name}.`;n.addEventListener("error",()=>t(o)),n.addEventListener("abort",()=>t()),n.addEventListener("load",()=>{const i=n.response;if(!i||i.error)return t(i&&i.error&&i.error.message?i.error.message:o);const s=i.url?{default:i.url}:i.urls;e({...i,urls:s})}),n.upload&&n.upload.addEventListener("progress",e=>{e.lengthComputable&&(s.uploadTotal=e.total,s.uploaded=e.loaded)})}_sendRequest(e){const t=this.options.headers||{},i=this.options.withCredentials||!1;for(const e of Object.keys(t))this.xhr.setRequestHeader(e,t[e]);this.xhr.withCredentials=i;const n=new FormData;n.append("upload",e),this.xhr.send(n)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function yf(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const i of t){const t=i.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}("ckCsrfToken");var t,i;return e&&40==e.length||(e=function(e){let t="";const i=new Uint8Array(e);window.crypto.getRandomValues(i);for(let e=0;e<i.length;e++){const n="abcdefghijklmnopqrstuvwxyz0123456789".charAt(i[e]%"abcdefghijklmnopqrstuvwxyz0123456789".length);t+=Math.random()>.5?n.toUpperCase():n}return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(40),t="ckCsrfToken",i=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(i)+";path=/"),e}class kf{constructor(e,t,i){this.loader=e,this.url=t,this.t=i}upload(){return this.loader.file.then(e=>new Promise((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,s=this.loader,o=(0,this.t)("Cannot upload file:")+` ${i.name}.`;n.addEventListener("error",()=>t(o)),n.addEventListener("abort",()=>t()),n.addEventListener("load",()=>{const i=n.response;if(!i||!i.uploaded)return t(i&&i.error&&i.error.message?i.error.message:o);e({default:i.url})}),n.upload&&n.upload.addEventListener("progress",e=>{e.lengthComputable&&(s.uploadTotal=e.total,s.uploaded=e.loaded)})}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",yf()),this.xhr.send(t)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Cf(e,t,i,n){let s,o=null;"function"==typeof n?s=n:(o=e.commands.get(n),s=()=>{e.execute(n)}),e.model.document.on("change:data",(r,a)=>{if(o&&!o.isEnabled||!t.isEnabled)return;const l=Or(e.model.document.selection.getRanges());if(!l.isCollapsed)return;if("transparent"==a.type)return;const c=Array.from(e.model.document.differ.getChanges()),h=c[0];if(1!=c.length||"insert"!==h.type||"$text"!=h.name||1!=h.length)return;const d=h.position.parent;if(d.is("element","codeBlock"))return;if(d.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(o&&!0===o.value)return;const u=d.getChild(0),m=e.model.createRangeOn(u);if(!m.containsRange(l)&&!l.end.isEqual(m.end))return;const f=i.exec(u.data.substr(0,l.end.offset));f&&e.model.enqueueChange(t=>{const i=t.createPositionAt(d,0),n=t.createPositionAt(d,f[0].length),o=new ba(i,n);if(!1!==s({match:f})){t.remove(o);const i=e.model.document.selection.getFirstRange(),n=t.createRangeIn(d);!d.isEmpty||n.isEqual(i)||n.containsRange(i,!0)||t.remove(d)}o.detach()})})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Af(e,t,i,n){let s,o;i instanceof RegExp?s=i:o=i,o=o||(e=>{let t;const i=[],n=[];for(;null!==(t=s.exec(e))&&!(t&&t.length<4);){let{index:e,1:s,2:o,3:r}=t;const a=s+o+r;e+=t[0].length-a.length;const l=[e,e+s.length],c=[e+s.length+o.length,e+s.length+o.length+r.length];i.push(l),i.push(c),n.push([e+s.length,e+s.length+o.length])}return{remove:i,format:n}}),e.model.document.on("change:data",(i,s)=>{if("transparent"==s.type||!t.isEnabled)return;const r=e.model,a=r.document.selection;if(!a.isCollapsed)return;const l=Array.from(r.document.differ.getChanges()),c=l[0];if(1!=l.length||"insert"!==c.type||"$text"!=c.name||1!=c.length)return;const h=a.focus,d=h.parent,{text:u,range:m}=function(e,t){let i=e.start;return{text:Array.from(e.getItems()).reduce((e,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(i=t.createPositionAfter(n),""):e+n.data,""),range:t.createRange(i,e.end)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(r.createRange(r.createPositionAt(d,0),h),r),f=o(u),g=xf(m.start,f.format,r),p=xf(m.start,f.remove,r);g.length&&p.length&&r.enqueueChange(e=>{if(!1!==n(e,g))for(const t of p.reverse())e.remove(t)})})}function xf(e,t,i){return t.filter(e=>void 0!==e[0]&&void 0!==e[1]).map(t=>i.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1])))}function Tf(e,t){return(i,n)=>{if(!e.commands.get(t).isEnabled)return!1;const s=e.model.schema.getValidRanges(n,t);for(const e of s)i.setAttribute(t,!0,e);i.removeSelectionAttribute(t)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pf extends Xe{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change(e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ef extends Ye{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"bold"}),e.model.schema.setAttributeProperties("bold",{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:"bold",view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t?"bold"==t||Number(t)>=600?{name:!0,styles:["font-weight"]}:void 0:null}]}),e.commands.add("bold",new Pf(e,"bold")),e.keystrokes.set("CTRL+B","bold")}}class Sf extends Ye{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("bold",i=>{const n=e.commands.get("bold"),s=new Ch(i);return s.set({label:t("Bold"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.187 17H5.773c-.637 0-1.092-.138-1.364-.415-.273-.277-.409-.718-.409-1.323V4.738c0-.617.14-1.062.419-1.332.279-.27.73-.406 1.354-.406h4.68c.69 0 1.288.041 1.793.124.506.083.96.242 1.36.478.341.197.644.447.906.75a3.262 3.262 0 0 1 .808 2.162c0 1.401-.722 2.426-2.167 3.075C15.05 10.175 16 11.315 16 13.01a3.756 3.756 0 0 1-2.296 3.504 6.1 6.1 0 0 1-1.517.377c-.571.073-1.238.11-2 .11zm-.217-6.217H7v4.087h3.069c1.977 0 2.965-.69 2.965-2.072 0-.707-.256-1.22-.768-1.537-.512-.319-1.277-.478-2.296-.478zM7 5.13v3.619h2.606c.729 0 1.292-.067 1.69-.2a1.6 1.6 0 0 0 .91-.765c.165-.267.247-.566.247-.897 0-.707-.26-1.176-.778-1.409-.519-.232-1.31-.348-2.375-.348H7z"/></svg>',keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("bold"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rf extends Ye{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"italic"}),e.model.schema.setAttributeProperties("italic",{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:"italic",view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add("italic",new Pf(e,"italic")),e.keystrokes.set("CTRL+I","italic")}}class If extends Ye{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("italic",i=>{const n=e.commands.get("italic"),s=new Ch(i);return s.set({label:t("Italic"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.586 14.633.021.004c-.036.335.095.655.393.962.082.083.173.15.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15c.474-.07.809-.182 1.005-.334.157-.122.291-.32.404-.597l2.416-9.55a1.053 1.053 0 0 0-.281-.823 1.12 1.12 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195c-.376.056-.65.155-.823.296-.215.175-.423.439-.623.79l-2.366 9.347z"/></svg>',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("italic"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vf extends Ye{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"underline"}),e.model.schema.setAttributeProperties("underline",{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:"underline",view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add("underline",new Pf(e,"underline")),e.keystrokes.set("CTRL+U","underline")}}class Of extends Ye{static get pluginName(){return"UnderlineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("underline",i=>{const n=e.commands.get("underline"),s=new Ch(i);return s.set({label:t("Underline"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 18v-1.5h14V18zm2.2-8V3.6c0-.4.4-.6.8-.6.3 0 .7.2.7.6v6.2c0 2 1.3 2.8 3.2 2.8 1.9 0 3.4-.9 3.4-2.9V3.6c0-.3.4-.5.8-.5.3 0 .7.2.7.5V10c0 2.7-2.2 4-4.9 4-2.6 0-4.7-1.2-4.7-4z"/></svg>',keystroke:"CTRL+U",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("underline"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Nf extends Ye{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"strikethrough"}),e.model.schema.setAttributeProperties("strikethrough",{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:"strikethrough",view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add("strikethrough",new Pf(e,"strikethrough")),e.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}class Mf extends Ye{static get pluginName(){return"StrikethroughUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("strikethrough",i=>{const n=e.commands.get("strikethrough"),s=new Ch(i);return s.set({label:t("Strikethrough"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 16.4c-.8-.4-1.5-.9-2.2-1.5a.6.6 0 0 1-.2-.5l.3-.6h1c1 1.2 2.1 1.7 3.7 1.7 1 0 1.8-.3 2.3-.6.6-.4.6-1.2.6-1.3.2-1.2-.9-2.1-.9-2.1h2.1c.3.7.4 1.2.4 1.7v.8l-.6 1.2c-.6.8-1.1 1-1.6 1.2a6 6 0 0 1-2.4.6c-1 0-1.8-.3-2.5-.6zM6.8 9 6 8.3c-.4-.5-.5-.8-.5-1.6 0-.7.1-1.3.5-1.8.4-.6 1-1 1.6-1.3a6.3 6.3 0 0 1 4.7 0 4 4 0 0 1 1.7 1l.3.7c0 .1.2.4-.2.7-.4.2-.9.1-1 0a3 3 0 0 0-1.2-1c-.4-.2-1-.3-2-.4-.7 0-1.4.2-2 .6-.8.6-1 .8-1 1.5 0 .8.5 1 1.2 1.5.6.4 1.1.7 1.9 1H6.8z"/><path d="M3 10.5V9h14v1.5z"/></svg>',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("strikethrough"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Bf="code";class Ff extends Ye{static get pluginName(){return"CodeEditing"}static get requires(){return[Gm]}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Bf}),e.model.schema.setAttributeProperties(Bf,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:Bf,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),e.commands.add(Bf,new Pf(e,Bf)),e.plugins.get(Gm).registerAttribute(Bf),sf(e,Bf,"code","ck-code_selected")}}class Df extends Ye{static get pluginName(){return"CodeUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("code",i=>{const n=e.commands.get("code"),s=new Ch(i);return s.set({label:t("Code"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 5.7 5.2 3.9v1.3l-5.6 4c-.1.2-.3.2-.5.2-.3-.1-.6-.7-.6-1l.3-.4 4.7-3.5L11.5 7l-.2-.2c-.1-.3-.1-.6 0-.8.2-.2.5-.4.8-.4a.8.8 0 0 1 .4.1zm-5.2 0L2 9.6v1.3l5.6 4c.1.2.3.2.5.2.3-.1.7-.7.6-1 0-.1 0-.3-.2-.4l-5-3.5L8.2 7l.2-.2c.1-.3.1-.6 0-.8-.2-.2-.5-.4-.8-.4a.8.8 0 0 0-.3.1z"/></svg>',tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("code"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zf extends Ye{static get pluginName(){return"SubscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"subscript"}),e.model.schema.setAttributeProperties("subscript",{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:"subscript",view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add("subscript",new Pf(e,"subscript"))}}class Lf extends Ye{static get pluginName(){return"SubscriptUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("subscript",i=>{const n=e.commands.get("subscript"),s=new Ch(i);return s.set({label:t("Subscript"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.03 10.349 3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82zm8.147 7.829h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309z"/></svg>',tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("subscript"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hf extends Ye{static get pluginName(){return"SuperscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"superscript"}),e.model.schema.setAttributeProperties("superscript",{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:"superscript",view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add("superscript",new Pf(e,"superscript"))}}class jf extends Ye{static get pluginName(){return"SuperscriptUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("superscript",i=>{const n=e.commands.get("superscript"),s=new Ch(i);return s.set({label:t("Superscript"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M15.677 8.678h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309zM7.03 10.349l3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82z"/></svg>',tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("superscript"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Wf extends Xe{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,s=Array.from(n.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change(e=>{if(o){const t=s.filter(e=>qf(e)||Uf(i,e));this._applyQuote(e,t)}else this._removeQuote(e,s.filter(qf))})}_getValue(){const e=Or(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!qf(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Or(e.getSelectedBlocks());return!!i&&Uf(t,i)}_removeQuote(e,t){$f(e,t).reverse().forEach(t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)})}_applyQuote(e,t){const i=[];$f(e,t).reverse().forEach(t=>{let n=qf(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)}),i.reverse().reduce((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i)}}function qf(e){return"blockQuote"==e.parent.name?e.parent:null}function $f(e,t){let i,n=0;const s=[];for(;n<t.length;){const o=t[n],r=t[n+1];i||(i=e.createPositionBefore(o)),r&&o.nextSibling==r||(s.push(e.createRange(i,e.createPositionAfter(o))),i=null),n++}return s}function Uf(e,t){const i=e.checkChild(t.parent,"blockQuote"),n=e.checkChild(["$root","blockQuote"],t);return i&&n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Kf extends Ye{static get pluginName(){return"BlockQuoteEditing"}static get requires(){return[ju,Uu]}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new Wf(e)),t.register("blockQuote",{allowWhere:"$block",allowContentOf:"$root"}),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer(i=>{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1});const i=this.editor.editing.view.document,n=e.model.document.selection,s=e.commands.get("blockQuote");this.listenTo(i,"enter",(t,i)=>{if(!n.isCollapsed||!s.value)return;n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())},{context:"blockquote"}),this.listenTo(i,"delete",(t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!s.value)return;const o=n.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())},{context:"blockquote"})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gf extends Ye{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",i=>{const n=e.commands.get("blockQuote"),s=new Ch(i);return s.set({label:t("Block quote"),icon:Gc,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("blockQuote"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Jf extends Xe{refresh(){const e=this.editor.model,t=Or(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Yf(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document;t.change(n=>{const s=(e.selection||i.selection).getSelectedBlocks();for(const e of s)!e.is("element","paragraph")&&Yf(e,t.schema)&&n.rename(e,"paragraph")})}}function Yf(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qf extends Xe{execute(e){const t=this.editor.model;let i=e.position;t.change(e=>{const n=e.createElement("paragraph");if(!t.schema.checkChild(i.parent,n)){const s=t.schema.findAllowedParent(i,n);if(!s)return;i=e.split(i,s).position}t.insertContent(n,i),e.setSelection(n,"in")})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xf extends Ye{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Jf(e)),e.commands.add("insertParagraph",new Qf(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Xf.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Xf.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Zf extends Xe{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Or(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>eg(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change(e=>{const s=Array.from(i.selection.getSelectedBlocks()).filter(e=>eg(e,n,t.schema));for(const t of s)t.is("element",n)||e.rename(t,n)})}}function eg(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tg extends Ye{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.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[Xf]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Zf(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(t,n)=>{const s=e.model.document.selection.getFirstPosition().parent;i.some(e=>s.is("element",e.model))&&!s.is("element","paragraph")&&0===s.childCount&&n.writer.rename(s,"paragraph")})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:a.get("low")+1})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ig extends Ye{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=function(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map(e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e})}(e),n=t("Choose heading"),s=t("Heading");e.ui.componentFactory.add("heading",t=>{const o={},r=new Xi,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new dd({label:e.title,class:e.class,withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",t=>t===e.model),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),o[e.model]=e.title}const h=Qh(t);return Zh(h,r),h.buttonView.set({isOn:!1,withText:!0,tooltip:s}),h.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),h.bind("isEnabled").toMany(c,"isEnabled",(...e)=>e.some(e=>e)),h.buttonView.bind("label").to(a,"value",l,"value",(e,t)=>{const i=e||t&&"paragraph";return o[i]?o[i]:n}),this.listenTo(h,"execute",t=>{e.execute(t.source.commandName,t.source.commandValue?{value:t.source.commandValue}:void 0),e.editing.view.focus()}),h})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ng extends Ye{static get requires(){return[_d]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",t=>{(function(e){const t=e.getSelectedElement();return!(!t||!Qu(t))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */)(e.editing.view.document.selection)&&t.stop()},{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui,"update",()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui.focusTracker,"change:isFocused",()=>{this._updateToolbarsVisibility()},{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:n,balloonClassName:s="ck-toolbar-container"}){if(!i.length)return void Object(l.b)("widget-toolbar-no-items",{toolbarId:e});const o=this.editor,r=o.t,a=new qh(o.locale);if(a.ariaLabel=t||r("Widget toolbar"),this._toolbarDefinitions.has(e))throw new l.a("widget-toolbar-duplicated",this,{toolbarId:e});a.fillFromConfig(i,o.ui.componentFactory),this._toolbarDefinitions.set(e,{view:a,getRelatedElement:n,balloonClassName:s})}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const s=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&s)if(this.editor.ui.focusTracker.isFocused){const o=s.getAncestors().length;o>e&&(e=o,t=s,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?sg(this.editor,t):this._isToolbarInBalloon(e)||(this._balloon.add({view:e.view,position:og(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);sg(this.editor,t)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function sg(e,t){const i=e.plugins.get("ContextualBalloon"),n=og(e,t);i.updatePosition(n)}function og(e,t){const i=e.editing.view,n=fd.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,rm]}}class rg{constructor(e){this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}begin(e,t,i){const n=new Pr(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains("ck-widget__resizer__handle-"+i))return i}(e),this._referenceCoordinates=function(e,t){const i=new Pr(e),n=t.split("-"),s={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return s.x+=e.ownerDocument.defaultView.scrollX,s.y+=e.ownerDocument.defaultView.scrollY,s}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.activeHandlePosition)),this.originalWidth=n.width,this.originalHeight=n.height,this.aspectRatio=n.width/n.height;const s=i.style.width;s&&s.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(s):this.originalWidthPercents=function(e,t){const i=e.parentElement,n=parseFloat(i.ownerDocument.defaultView.getComputedStyle(i).width);return t.width/n*100}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}Je(rg,We);class ag{constructor(e){this._options=e,this._domResizerWrapper=null,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())},{priority:"high"}),this.on("change:isEnabled",()=>{this.isEnabled&&this.redraw()})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(i=>{const n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),e._domResizerWrapper=i,e.on("change:isEnabled",(e,t,n)=>{i.style.display=n?"":"none"}),i.style.display=e.isEnabled?"":"none",i}));i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n})}begin(e){this.state=new rg(this._options),this._sizeUI.bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change(e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)});const i=this._getHandleHost(),n=new Pr(i);t.handleHostWidth=Math.round(n.width),t.handleHostHeight=Math.round(n.height);const s=new Pr(i);t.width=Math.round(s.width),t.height=Math.round(s.height),this.redraw(n),this.state.update(t)}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change(()=>{this._cleanup(),this._options.onCommit(t)})}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const n=t.parentElement,s=this._getHandleHost(),o=this._viewResizerWrapper,r=[o.getStyle("width"),o.getStyle("height"),o.getStyle("left"),o.getStyle("top")];let a;if(n.isSameNode(s)){const t=e||new Pr(s);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[s.offsetWidth+"px",s.offsetHeight+"px",s.offsetLeft+"px",s.offsetTop+"px"];"same"!==ln(r,a)&&this._options.editor.editing.view.change(e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},o)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeUI.dismiss(),this._sizeUI.isVisible=!1;this._options.editor.editing.view.change(e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,i={x:(n=e).pageX,y:n.pageY};var n;const s=!this._options.isCentered||this._options.isCentered(this),o={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};s&&t.activeHandlePosition.endsWith("-right")&&(o.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),s&&(o.x*=2);const r={width:Math.abs(t.originalWidth+o.x),height:Math.abs(t.originalHeight+o.y)};r.dominant=r.width/t.aspectRatio>r.height?"width":"height",r.max=r[r.dominant];const a={width:r.width,height:r.height};return"width"==r.dominant?a.height=a.width/t.aspectRatio:a.width=a.height*t.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new th({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,"ck-widget__resizer__handle-"+i)}}).render());var i}_appendSizeUI(e){const t=new lg;t.render(),this._sizeUI=t,e.appendChild(t.element)}}Je(ag,We);class lg extends eh{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("activeHandlePosition",e=>e?"ck-orientation-"+e:"")],style:{display:e.if("isVisible","none",e=>!e)}},children:[{text:e.to("label")}]})}bindToState(e,t){this.bind("isVisible").to(t,"proposedWidth",t,"proposedHeight",(e,t)=>null!==e&&null!==t),this.bind("label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(t,i,n)=>"px"===e.unit?`${t}×${i}`:n+"%"),this.bind("activeHandlePosition").to(t)}dismiss(){this.unbind(),this.isVisible=!1}}class cg extends Ye{static get pluginName(){return"WidgetResize"}init(){this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map;const e=vo.window.document;this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0}),this.editor.editing.view.addObserver(jd),this._observer=Object.create(Io),this.listenTo(this.editor.editing.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));const t=()=>{this.visibleResizer&&this.visibleResizer.redraw()},i=vm(t,200);this.on("change:visibleResizer",t),this.editor.ui.on("update",i),this._observer.listenTo(vo.window,"resize",i);const n=this.editor.editing.view.document.selection;n.on("change",()=>{const e=n.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(e)||null})}destroy(){this._observer.stopListening();for(const e of this._resizers.values())e.destroy()}attachTo(e){const t=new ag(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",()=>{e.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{e.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{e.clearForceDisabled("resize")},{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==t&&(this.visibleResizer=t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;ag.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i),this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}Je(cg,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class hg extends No{observe(e){this.listenTo(e,"load",(e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)},{useCapture:!0})}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function dg(e){return!!e.getCustomProperty("image")&&Qu(e)}function ug(e){const t=e.getSelectedElement();return t&&dg(t)?t:null}function mg(e){return!!e&&e.is("element","image")}function fg(e,t={},i=null){e.change(n=>{const s=n.createElement("image",t),o=i||sm(e.document.selection,e);e.insertContent(s,o),s.parent&&n.setSelection(s,"on")})}function gg(e){const t=e.schema,i=e.document.selection;return function(e,t,i){const n=function(e,t){const i=sm(e,t).parent;if(i.isEmpty&&!i.is("element","$root"))return i.parent;return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e,i);return t.checkChild(n,"image")}(i,t,e)&&!om(i,t)&&function(e){return[...e.focus.getAncestors()].every(e=>!e.is("element","image"))}(i)}function pg(e){const t=[];for(const i of e.getChildren())t.push(i),i.is("element")&&t.push(...i.getChildren());return t.find(e=>e.is("element","img"))}function wg(e){return i=>{i.on(`attribute:${e}:image`,t)};function t(e,t,i){if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=pg(i.mapper.toViewElement(t.item));n.setAttribute(t.attributeKey,t.attributeNewValue||"",s)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bg extends Xe{refresh(){this.isEnabled=gg(this.editor.model)}execute(e){const t=this.editor.model;for(const i of en(e.source))fg(t,{src:i})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _g extends Ye{static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;e.editing.view.addObserver(hg),t.register("image",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),n.for("dataDowncast").elementToElement({model:"image",view:(e,{writer:t})=>vg(t)}),n.for("editingDowncast").elementToElement({model:"image",view:(e,{writer:t})=>function(e,t,i){return t.setCustomProperty("image",!0,e),Xu(e,t,{label:function(){const t=pg(e).getAttribute("alt");return t?`${t} ${i}`:i}})}(vg(t),t,i("image widget"))}),n.for("downcast").add(wg("src")).add(wg("alt")).add(function(){return t=>{t.on("attribute:srcset:image",e)};function e(e,t,i){if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=pg(i.mapper.toViewElement(t.item));if(null===t.attributeNewValue){const e=t.attributeOldValue;e.data&&(n.removeAttribute("srcset",s),n.removeAttribute("sizes",s),e.width&&n.removeAttribute("width",s))}else{const e=t.attributeNewValue;e.data&&(n.setAttribute("srcset",e.data,s),n.setAttribute("sizes","100vw",s),e.width&&n.setAttribute("width",e.width,s))}}}()),n.for("upcast").elementToElement({view:{name:"img",attributes:{src:!0}},model:(e,{writer:t})=>t.createElement("image",{src:e.getAttribute("src")})}).attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}}).add(function(){return t=>{t.on("element:figure",e)};function e(e,t,i){if(!i.consumable.test(t.viewItem,{name:!0,classes:"image"}))return;const n=pg(t.viewItem);if(!n||!n.hasAttribute("src")||!i.consumable.test(n,{name:!0}))return;const s=Or(i.convertItem(n,t.modelCursor).modelRange.getItems());s&&(i.convertChildren(t.viewItem,s),i.updateConversionResult(s,t))}}());const s=new bg(e);e.commands.add("insertImage",s),e.commands.add("imageInsert",s)}}function vg(e){const t=e.createEmptyElement("img"),i=e.createContainerElement("figure",{class:"image"});return e.insert(e.createPositionAt(i,0),t),i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yg extends Xe{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=mg(e),mg(e)&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor.model,i=t.document.selection.getSelectedElement();t.change(t=>{t.setAttribute("alt",e.newValue,i)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kg extends Ye{static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new yg(this.editor))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cg extends eh{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new Nr,this.keystrokes=new Mr,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Ec,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),Pc,"ck-button-cancel","cancel"),this._focusables=new Zc,this._focusCycler=new Sh({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]}),Qc(this)}render(){super.render(),this.keystrokes.listenTo(this.element),Xc({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)})}_createButton(e,t,i,n){const s=new Ch(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createLabeledInputView(){const e=this.locale.t,t=new ad(this.locale,ld);return t.label=e("Text alternative"),t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ag(e){const t=e.plugins.get("ContextualBalloon");if(ug(e.editing.view.document.selection)){const i=xg(e);t.updatePosition(i)}}function xg(e){const t=e.editing.view,i=fd.defaultPositions;return{target:t.domConverter.viewToDom(t.document.selection.getSelectedElement()),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast]}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tg extends Ye{static get requires(){return[_d]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",i=>{const n=e.commands.get("imageTextAlternative"),s=new Ch(i);return s.set({label:t("Change image text alternative"),icon:Rc,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{this._showForm()}),s})}_createForm(){const e=this.editor,t=e.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new Cg(e.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{e.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",(e,t)=>{this._hideForm(!0),t()}),this.listenTo(e.ui,"update",()=>{ug(t.selection)?this._isVisible&&Ag(e):this._hideForm(!0)}),Yc({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:xg(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pg extends Ye{static get requires(){return[kg,Tg]}static get pluginName(){return"ImageTextAlternative"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Eg(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}function Sg(e){const t=e.parent;return"figcaption"==e.name&&t&&"figure"==t.name&&t.hasClass("image")?{name:!0}:null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rg extends Ye{static get pluginName(){return"ImageCaptionEditing"}init(){const e=this.editor,t=e.editing.view,i=e.model.schema,n=e.data,s=e.editing,o=e.t;i.register("caption",{allowIn:"image",allowContentOf:"$block",isLimit:!0}),e.model.document.registerPostFixer(e=>this._insertMissingModelCaptionElement(e)),e.conversion.for("upcast").elementToElement({view:Sg,model:"caption"});n.downcastDispatcher.on("insert:caption",Ig(e=>e.createContainerElement("figcaption"),!1));const r=
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(e,t){return i=>{const n=i.createEditableElement("figcaption");return i.setCustomProperty("imageCaption",!0,n),xd({view:e,element:n,text:t}),nm(n,i)}}(t,o("Enter image caption"));s.downcastDispatcher.on("insert:caption",Ig(r)),s.downcastDispatcher.on("insert",this._fixCaptionVisibility(e=>e.item),{priority:"high"}),s.downcastDispatcher.on("remove",this._fixCaptionVisibility(e=>e.position.parent),{priority:"high"}),t.document.registerPostFixer(e=>this._updateCaptionVisibility(e))}_updateCaptionVisibility(e){const t=this.editor.editing.mapper,i=this._lastSelectedCaption;let n;const s=this.editor.model.document.selection,o=s.getSelectedElement();if(o&&o.is("element","image")){const e=Eg(o);n=t.toViewElement(e)}const r=Vg(s.getFirstPosition().parent);if(r&&(n=t.toViewElement(r)),n&&!this.editor.isReadOnly)return i?(i===n||(Og(i,e),this._lastSelectedCaption=n),Ng(n,e)):(this._lastSelectedCaption=n,Ng(n,e));if(i){const t=Og(i,e);return this._lastSelectedCaption=null,t}return!1}_fixCaptionVisibility(e){return(t,i,n)=>{const s=Vg(e(i)),o=this.editor.editing.mapper,r=n.writer;if(s){const e=o.toViewElement(s);e&&(s.childCount?r.removeClass("ck-hidden",e):r.addClass("ck-hidden",e))}}}_insertMissingModelCaptionElement(e){const t=this.editor.model,i=t.document.differ.getChanges(),n=[];for(const e of i)if("insert"==e.type&&"$text"!=e.name){const i=e.position.nodeAfter;if(i.is("element","image")&&!Eg(i)&&n.push(i),!i.is("element","image")&&i.childCount)for(const e of t.createRangeIn(i).getItems())e.is("element","image")&&!Eg(e)&&n.push(e)}for(const t of n)e.appendElement("caption",t);return!!n.length}}function Ig(e,t=!0){return(i,n,s)=>{const o=n.item;if((o.childCount||t)&&mg(o.parent)){if(!s.consumable.consume(n.item,"insert"))return;const t=s.mapper.toViewElement(n.range.start.parent),i=e(s.writer),r=s.writer;o.childCount||r.addClass("ck-hidden",i),function(e,t,i,n){const s=n.writer.createPositionAt(i,"end");n.writer.insert(s,e),n.mapper.bindElements(t,e)}(i,n.item,t,s)}}}function Vg(e){const t=e.getAncestors({includeSelf:!0}).find(e=>"caption"==e.name);return t&&t.parent&&"image"==t.parent.name?t:null}function Og(e,t){return!e.childCount&&!e.hasClass("ck-hidden")&&(t.addClass("ck-hidden",e),!0)}function Ng(e,t){return!!e.hasClass("ck-hidden")&&(t.removeClass("ck-hidden",e),!0)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Mg extends Xe{constructor(e,t){super(e),this.defaultStyle=!1,this.styles=t.reduce((e,t)=>(e[t.name]=t,t.isDefault&&(this.defaultStyle=t.name),e),{})}refresh(){const e=this.editor.model.document.selection.getSelectedElement();if(this.isEnabled=mg(e),e)if(e.hasAttribute("imageStyle")){const t=e.getAttribute("imageStyle");this.value=!!this.styles[t]&&t}else this.value=this.defaultStyle;else this.value=!1}execute(e){const t=e.value,i=this.editor.model,n=i.document.selection.getSelectedElement();i.change(e=>{this.styles[t].isDefault?e.removeAttribute("imageStyle",n):e.setAttribute("imageStyle",t,n)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Bg(e,t){for(const i of t)if(i.name===e)return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Fg={full:{name:"full",title:"Full size image",icon:jc,isDefault:!0},side:{name:"side",title:"Side image",icon:Hc,className:"image-style-side"},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:zc,className:"image-style-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:Lc,className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:Hc,className:"image-style-align-right"}},Dg={full:jc,left:zc,right:Hc,center:Lc};function zg(e=[]){return e.map(Lg)}function Lg(e){if("string"==typeof e){const t=e;Fg[t]?e=Object.assign({},Fg[t]):(Object(l.b)("image-style-not-found",{name:t}),e={name:t})}else if(Fg[e.name]){const t=Fg[e.name],i=Object.assign({},e);for(const n in t)Object.prototype.hasOwnProperty.call(e,n)||(i[n]=t[n]);e=i}return"string"==typeof e.icon&&Dg[e.icon]&&(e.icon=Dg[e.icon]),e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hg extends Ye{static get pluginName(){return"ImageStyleEditing"}init(){const e=this.editor,t=e.model.schema,i=e.data,n=e.editing;e.config.define("image.styles",["full","side"]);const s=zg(e.config.get("image.styles"));t.extend("image",{allowAttributes:"imageStyle"});const o=function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=Bg(i.attributeNewValue,e),o=Bg(i.attributeOldValue,e),r=n.mapper.toViewElement(i.item),a=n.writer;o&&a.removeClass(o.className,r),s&&a.addClass(s.className,r)}}(s);n.downcastDispatcher.on("attribute:imageStyle:image",o),i.downcastDispatcher.on("attribute:imageStyle:image",o),i.upcastDispatcher.on("element:figure",function(e){const t=e.filter(e=>!e.isDefault);return(e,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=Or(i.modelRange.getItems());if(!o||n.schema.checkAttribute(o,"imageStyle"))for(const e of t)n.consumable.consume(s,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,o)}}(s),{priority:"low"}),e.commands.add("imageStyle",new Mg(e,s))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jg extends Ye{static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=function(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(zg(this.editor.config.get("image.styles")),this.localizedDefaultStylesTitles);for(const t of e)this._createButton(t)}_createButton(e){const t=this.editor,i="imageStyle:"+e.name;t.ui.componentFactory.add(i,i=>{const n=t.commands.get("imageStyle"),s=new Ch(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",t=>t===e.name),this.listenTo(s,"execute",()=>{t.execute("imageStyle",{value:e.name}),t.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Wg(e){const t=e.map(e=>e.replace("+","\\+"));return new RegExp(`^image\\/(${t.join("|")})$`)}function qg(e){return new Promise((t,i)=>{const n=e.getAttribute("src");fetch(n).then(e=>e.blob()).then(e=>{const i=$g(e,n),s=i.replace("image/",""),o=new File([e],"image."+s,{type:i});t(o)}).catch(e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise((t,i)=>{const n=vo.document.createElement("img");n.addEventListener("load",()=>{const e=vo.document.createElement("canvas");e.width=n.width,e.height=n.height;e.getContext("2d").drawImage(n,0,0),e.toBlob(e=>e?t(e):i())}),n.addEventListener("error",()=>i()),n.src=e})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e).then(t=>{const i=$g(t,e),n=i.replace("image/","");return new File([t],"image."+n,{type:i})})}(n).then(t).catch(i):i(e))})}function $g(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class Ug extends Ye{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=i=>{const n=new bf(i),s=e.commands.get("uploadImage"),o=e.config.get("image.upload.types"),r=Wg(o);return n.set({acceptedType:o.map(e=>"image/"+e).join(","),allowMultipleFiles:!0}),n.buttonView.set({label:t("Insert image"),icon:Ic,tooltip:!0}),n.buttonView.bind("isEnabled").to(s),n.on("done",(t,i)=>{const n=Array.from(i).filter(e=>r.test(e.type));n.length&&e.execute("uploadImage",{file:n})}),n};e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Kg extends Ye{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.placeholder="data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 700 250"><rect rx="4"/></svg>')}init(){this.editor.editing.downcastDispatcher.on("attribute:uploadStatus:image",(...e)=>this.uploadStatusChange(...e))}uploadStatusChange(e,t,i){const n=this.editor,s=t.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get(pf),a=o?t.attributeNewValue:null,l=this.placeholder,c=n.editing.mapper.toViewElement(s),h=i.writer;if("reading"==a)return Gg(c,h),void Jg(l,c,h);if("uploading"==a){const e=r.loaders.get(o);return Gg(c,h),void(e?(Yg(c,h),function(e,t,i,n){const s=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),s),i.on("change:uploadedPercent",(e,t,i)=>{n.change(e=>{e.setStyle("width",i+"%",s)})})}(c,h,e,n.editing.view),function(e,t,i){if(i.data){const n=pg(e);t.setAttribute("src",i.data,n)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(c,h,e)):Jg(l,c,h))}"complete"==a&&r.loaders.get(o)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout(()=>{i.change(e=>e.remove(e.createRangeOn(n)))},3e3)}(c,h,n.editing.view),function(e,t){Xg(e,t,"progressBar")}(c,h),Yg(c,h),function(e,t){t.removeClass("ck-appear",e)}(c,h)}}function Gg(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function Jg(e,t,i){t.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",t);const n=pg(t);n.getAttribute("src")!==e&&i.setAttribute("src",e,n),Qg(t,"placeholder")||i.insert(i.createPositionAfter(n),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(i))}function Yg(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),Xg(e,t,"placeholder")}function Qg(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function Xg(e,t,i){const n=Qg(e,i);n&&t.remove(t.createRangeOn(n))}class Zg extends Xe{refresh(){const e=this.editor.model.document.selection.getSelectedElement(),t=e&&"image"===e.name||!1;this.isEnabled=gg(this.editor.model)||t}execute(e){const t=this.editor,i=t.model,n=t.plugins.get(pf);for(const t of en(e.file))ep(i,n,t)}}function ep(e,t,i){const n=t.createLoader(i);n&&fg(e,{uploadId:n.id})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tp extends Ye{static get requires(){return[pf,hd,Fu]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}})}init(){const e=this.editor,t=e.model.document,i=e.model.schema,n=e.conversion,s=e.plugins.get(pf),o=Wg(e.config.get("image.upload.types"));i.extend("image",{allowAttributes:["uploadId","uploadStatus"]});const r=new Zg(e);e.commands.add("uploadImage",r),e.commands.add("imageUpload",r),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const s=Array.from(i.dataTransfer.files).filter(e=>!!e&&o.test(e.type));s.length&&(t.stop(),e.model.change(t=>{i.targetRanges&&t.setSelection(i.targetRanges.map(t=>e.editing.mapper.toModelRange(t))),e.model.enqueueChange("default",()=>{e.execute("uploadImage",{file:s})})}))}),this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",(t,i)=>{const n=Array.from(e.editing.view.createRangeIn(i.content)).filter(e=>{return!(!(t=e.item).is("element","img")||!t.getAttribute("src"))&&(t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||t.getAttribute("src").match(/^blob:/g))&&!e.item.getAttribute("uploadProcessed");var t}).map(e=>({promise:qg(e.item),imageElement:e.item}));if(!n.length)return;const o=new Wd(e.editing.view.document);for(const e of n){o.setAttribute("uploadProcessed",!0,e.imageElement);const t=s.createLoader(e.promise);t&&(o.setAttribute("src","",e.imageElement),o.setAttribute("uploadId",t.id,e.imageElement))}}),e.editing.view.document.on("dragover",(e,t)=>{t.preventDefault()}),t.on("change",()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0});for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,n="$graveyard"==t.position.root.rootName;for(const t of ip(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=s.loaders.get(e);i&&(n?i.abort():"idle"==i.status&&this._readAndUpload(i,t))}}}),this.on("uploadComplete",(e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change(e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e)})},{priority:"low"})}_readAndUpload(e,t){const i=this.editor,n=i.model,s=i.locale.t,o=i.plugins.get(pf),r=i.plugins.get(hd);return n.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","reading",t)}),e.read().then(()=>{const s=e.upload();if(Ps.isSafari){const e=pg(i.editing.mapper.toViewElement(t));i.editing.view.once("render",()=>{if(!e.parent)return;const t=i.editing.view.domConverter.mapViewToDom(e.parent);if(!t)return;const n=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=n})}return n.enqueueChange("transparent",e=>{e.setAttribute("uploadStatus","uploading",t)}),s}).then(e=>{n.enqueueChange("transparent",i=>{i.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:e,imageElement:t})}),a()}).catch(i=>{if("error"!==e.status&&"aborted"!==e.status)throw i;"error"==e.status&&i&&r.showWarning(i,{title:s("Upload failed"),namespace:"upload"}),a(),n.enqueueChange("transparent",e=>{e.remove(t)})});function a(){n.enqueueChange("transparent",e=>{e.removeAttribute("uploadId",t),e.removeAttribute("uploadStatus",t)}),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const s=Object.keys(e).filter(e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0}).map(t=>`${e[t]} ${t}w`).join(", ");""!=s&&i.setAttribute("srcset",{data:s,width:n},t)}}function ip(e,t){return Array.from(e.model.createRangeOn(t)).filter(e=>e.item.is("element","image")).map(e=>e.item)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */
class np{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach(e=>this._definitions.add(e)):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",(e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;const n=i.writer,s=n.document.selection;for(const e of this._definitions){const o=n.createAttributeElement("a",e.attributes,{priority:5});n.setCustomProperty("link",!0,o),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(s.getFirstRange(),o):n.wrap(i.mapper.toViewRange(t.range),o):n.unwrap(i.mapper.toViewRange(t.range),o)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:image",(e,t,i)=>{const n=i.mapper.toViewElement(t.item),s=Array.from(n.getChildren()).find(e=>"a"===e.name);for(const e of this._definitions){const n=mn(e.attributes);if(e.callback(t.attributeNewValue))for(const[e,t]of n)"class"===e?i.writer.addClass(t,s):i.writer.setAttribute(e,t,s);else for(const[e,t]of n)"class"===e?i.writer.removeClass(t,s):i.writer.removeAttribute(e,s)}})}}}var sp=function(e,t,i){var n=e.length;return i=void 0===i?n:i,!t&&i>=n?e:Nn(e,t,i)},op=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var rp=function(e){return op.test(e)};var ap=function(e){return e.split("")},lp="[\\ud800-\\udfff]",cp="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",hp="\\ud83c[\\udffb-\\udfff]",dp="[^\\ud800-\\udfff]",up="(?:\\ud83c[\\udde6-\\uddff]){2}",mp="[\\ud800-\\udbff][\\udc00-\\udfff]",fp="(?:"+cp+"|"+hp+")"+"?",gp="[\\ufe0e\\ufe0f]?"+fp+("(?:\\u200d(?:"+[dp,up,mp].join("|")+")[\\ufe0e\\ufe0f]?"+fp+")*"),pp="(?:"+[dp+cp+"?",cp,up,mp,lp].join("|")+")",wp=RegExp(hp+"(?="+hp+")|"+pp+gp,"g");var bp=function(e){return e.match(wp)||[]};var _p=function(e){return rp(e)?bp(e):ap(e)};var vp=function(e){return function(t){t=Sn(t);var i=rp(t)?_p(t):void 0,n=i?i[0]:t.charAt(0),s=i?sp(i,1).join(""):t.slice(1);return n[e]()+s}}("toUpperCase");
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const yp=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,kp=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,Cp=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Ap=/^((\w+:(\/{2,})?)|(\W))/i;function xp(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function Tp(e){return function(e){return e.replace(yp,"").match(kp)}(e=String(e))?e:"#"}function Pp(e,t){return!!e&&(e.is("element","image")&&t.checkAttribute("image","linkHref"))}function Ep(e,t){const i=(n=e,Cp.test(n)?"mailto:":t);var n;const s=!!i&&!Ap.test(e);return e&&s?i+e:e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sp extends Xe{constructor(e){super(e),this.manualDecorators=new Xi,this.automaticDecorators=new np}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document,i=Or(t.selection.getSelectedBlocks());Pp(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.selection.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,s=[],o=[];for(const e in t)t[e]?s.push(e):o.push(e);i.change(t=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=tf(r,"linkHref",n.getAttribute("linkHref"),i);t.setAttribute("linkHref",e,a),s.forEach(e=>{t.setAttribute(e,!0,a)}),o.forEach(e=>{t.removeAttribute(e,a)}),t.setSelection(t.createPositionAfter(a.end.nodeBefore))}else if(""!==e){const o=mn(n.getAttributes());o.set("linkHref",e),s.forEach(e=>{o.set(e,!0)});const{end:a}=i.insertContent(t.createText(e,o),r);t.setSelection(a)}["linkHref",...s,...o].forEach(e=>{t.removeSelectionAttribute(e)})}else{const r=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of r)this._isRangeToUpdate(e,a)&&l.push(e);for(const i of l)t.setAttribute("linkHref",e,i),s.forEach(e=>{t.setAttribute(e,!0,i)}),o.forEach(e=>{t.removeAttribute(e,i)})}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document,n=Or(i.selection.getSelectedBlocks());return Pp(n,t.schema)?n.getAttribute(e):i.selection.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rp extends Xe{refresh(){const e=this.editor.model,t=e.document,i=Or(t.selection.getSelectedBlocks());Pp(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change(e=>{const s=i.isCollapsed?[tf(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of s)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ip{constructor({id:e,label:t,attributes:i,defaultValue:n}){this.id=e,this.set("value"),this.defaultValue=n,this.label=t,this.attributes=i}}Je(Ip,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Vp=/^(https?:)?\/\//;class Op extends Ye{static get pluginName(){return"LinkEditing"}static get requires(){return[Gm,qm,Fu]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:xp}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>xp(Tp(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new Sp(e)),e.commands.add("unlink",new Rp(e));const t=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach(e=>(e.label&&i[e.label]&&(e.label=i[e.label]),e)),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:"link"+vp(i)});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter(e=>"automatic"===e.mode)),this._enableManualDecorators(t.filter(e=>"manual"===e.mode));e.plugins.get(Gm).registerAttribute("linkHref"),sf(e,"linkHref","a","ck-link_selected"),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:"automatic",callback:e=>Vp.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(e=>{t.model.schema.extend("$text",{allowAttributes:e.id}),i.add(new Ip(e)),t.conversion.for("downcast").attributeToElement({model:e.id,view:(t,{writer:n})=>{if(t){const t=i.get(e.id).attributes,s=n.createAttributeElement("a",t,{priority:5});return n.setCustomProperty("link",!0,s),s}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:i.get(e.id).attributes},model:{key:e.id}})})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor,t=e.model,i=t.document.selection,n=e.commands.get("link");this.listenTo(t,"insertContent",()=>{const e=i.anchor.nodeBefore,s=i.anchor.nodeAfter;i.hasAttribute("linkHref")&&e&&e.hasAttribute("linkHref")&&(s&&s.hasAttribute("linkHref")||t.change(e=>{Np(e,n.manualDecorators)}))},{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.commands.get("link");e.editing.view.addObserver(jd);let i=!1;this.listenTo(e.editing.view.document,"mousedown",()=>{i=!0}),this.listenTo(e.editing.view.document,"selectionChange",()=>{if(!i)return;i=!1;const n=e.model.document.selection;if(!n.isCollapsed)return;if(!n.hasAttribute("linkHref"))return;const s=n.getFirstPosition(),o=tf(s,"linkHref",n.getAttribute("linkHref"),e.model);(s.isTouching(o.start)||s.isTouching(o.end))&&e.model.change(e=>{Np(e,t.manualDecorators)})})}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let i,n;this.listenTo(t.document,"delete",()=>{n=!0},{priority:"high"}),this.listenTo(e.model,"deleteContent",()=>{const t=e.model.document.selection;t.isCollapsed||(n?n=!1:Mp(e)&&function(e){const t=e.document.selection,i=t.getFirstPosition(),n=t.getLastPosition(),s=i.nodeAfter;if(!s)return!1;if(!s.is("$text"))return!1;if(!s.hasAttribute("linkHref"))return!1;const o=n.textNode||n.nodeBefore;if(s===o)return!0;return tf(i,"linkHref",s.getAttribute("linkHref"),e).containsRange(e.createRange(i,n),!0)}(e.model)&&(i=t.getAttributes()))},{priority:"high"}),this.listenTo(e.model,"insertContent",(t,[s])=>{n=!1,Mp(e)&&i&&(e.model.change(e=>{for(const[t,n]of i)e.setAttribute(t,n,s)}),i=null)},{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view,s=e.commands.get("link");let o=!1,r=!1;this.listenTo(n.document,"delete",(e,t)=>{r=t.domEvent.keyCode===Rs.backspace},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{o=!1;const e=i.getFirstPosition(),n=i.getAttribute("linkHref");if(!n)return;const s=tf(e,"linkHref",n,t);o=s.containsPosition(e)||s.end.isEqual(e)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{r&&(r=!1,o||e.model.enqueueChange(e=>{Np(e,s.manualDecorators)}))},{priority:"low"})}}function Np(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i.id)}function Mp(e){return e.plugins.get("Input").isInput(e.model.change(e=>e.batch))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Bp extends eh{constructor(e,t){super(e);const i=e.t;this.focusTracker=new Nr,this.keystrokes=new Mr,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Ec,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),Pc,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusables=new Zc,this._focusCycler=new Sh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const n=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&n.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:n,tabindex:"-1"},children:this.children}),Qc(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((e,t)=>(e[t.name]=t.isOn,e),{})}render(){super.render(),Xc({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new ad(this.locale,ld);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const s=new Ch(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new Ah(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",(e,t)=>void 0===t&&void 0===e?i.defaultValue:e),n.on("execute",()=>{i.set("value",!n.isOn)}),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new eh;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map(e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}})),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Fp extends eh{constructor(e){super(e);const t=e.t;this.focusTracker=new Nr,this.keystrokes=new Mr,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184zm4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>',"unlink"),this.editButtonView=this._createButton(t("Edit link"),Kc,"edit"),this.set("href"),this._focusables=new Zc,this._focusCycler=new Sh({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(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new Ch(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new Ch(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",e=>e&&Tp(e)),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",e=>e||i("This link has no URL")),e.bind("isEnabled").to(this,"href",e=>!!e),e.template.tag="a",e.template.eventListeners={},e}}class Dp extends Ye{static get requires(){return[_d]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(Hd),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=e.plugins.get(_d),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),e.conversion.for("editingDowncast").markerToHighlight({model:"link-ui",view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:"link-ui",view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const e=this.editor,t=new Fp(e.locale),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",()=>{this._addFormView()}),this.listenTo(t,"unlink",()=>{e.execute("unlink"),this._hideUI()}),t.keystrokes.set("Esc",(e,t)=>{this._hideUI(),t()}),t.keystrokes.set("Ctrl+K",(e,t)=>{this._addFormView(),t()}),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new Bp(e.locale,t);return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isReadOnly").to(t,"isEnabled",e=>!e),n.saveButtonView.bind("isEnabled").to(t),this.listenTo(n,"submit",()=>{const{value:t}=n.urlInputView.fieldView.element,s=Ep(t,i);e.execute("link",s,n.getDecoratorSwitchesState()),this._closeFormView()}),this.listenTo(n,"cancel",()=>{this._closeFormView()}),n.keystrokes.set("Esc",(e,t)=>{this._closeFormView(),t()}),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),i=e.t;e.keystrokes.set("Ctrl+K",(e,i)=>{i(),t.isEnabled&&this._showUI(!0)}),e.ui.componentFactory.add("link",e=>{const n=new Ch(e);return n.isEnabled=!0,n.label=i("Link"),n.icon='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>',n.keystroke="Ctrl+K",n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(t,"isEnabled"),n.bind("isOn").to(t,"value",e=>!!e),this.listenTo(n,"execute",()=>this._showUI(!0)),n})}_enableUserBalloonInteractions(){const e=this.editor.editing.view.document;this.listenTo(e,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),this.editor.keystrokes.set("Tab",(e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),Yc({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=o();const s=()=>{const e=this._getSelectedLinkElement(),t=o();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function o(){return t.selection.focus.getAncestors().reverse().find(e=>e.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n=null;if(t.markers.has("link-ui")){const t=Array.from(this.editor.editing.mapper.markerNameToElements("link-ui")),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else{const t=this._getSelectedLinkElement(),s=i.selection.getFirstRange();n=t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(s)}return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection;if(t.isCollapsed)return zp(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=zp(i.start),s=zp(i.end);return n&&n==s&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has("link-ui"))t.updateMarker("link-ui",{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(({item:t})=>!e.schema.isContent(t),{boundaries:i});t.addMarker("link-ui",{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker("link-ui",{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has("link-ui")&&e.change(e=>{e.removeMarker("link-ui")})}}function zp(e){return e.getAncestors().find(e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Lp=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");class Hp extends Ye{static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new Km(e.model,e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=jp(e.substr(0,e.length-1));return t?{url:t}:void 0}),i=e.plugins.get("Input");t.on("matched:data",(t,n)=>{const{batch:s,range:o,url:r}=n;if(!i.isInput(s))return;const a=o.end.getShiftedBy(-1),l=a.getShiftedBy(-r.length),c=e.model.createRange(l,a);this._applyAutoLink(r,c)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=Um(e,t),s=jp(i);if(s){const e=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,e)}}_applyAutoLink(e,t){const i=this.editor.model;this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,i)&&i.enqueueChange(i=>{const n=this.editor.config.get("link.defaultProtocol"),s=Ep(e,n);i.setAttribute("linkHref",s,t)})}}function jp(e){const t=Lp.exec(e);return t?t[2]:null}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Wp extends Xe{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=Array.from(i.selection.getSelectedBlocks()).filter(e=>$p(e,t.schema)),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change(e=>{if(s){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,s=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e<i&&(i=e);const n=e-i;s.push({element:t,listIndent:n}),t=t.nextSibling}s=s.reverse();for(const t of s)e.setAttribute("listIndent",t.listIndent,t.element)}if(!s){let e=Number.POSITIVE_INFINITY;for(const t of n)t.is("element","listItem")&&t.getAttribute("listIndent")<e&&(e=t.getAttribute("listIndent"));e=0===e?1:e,qp(n,!0,e),qp(n,!1,e)}for(const t of n.reverse())s&&"listItem"==t.name?e.rename(t,"paragraph"):s||"listItem"==t.name?s||"listItem"!=t.name||t.getAttribute("listType")==this.type||e.setAttribute("listType",this.type,t):(e.setAttributes({listType:this.type,listIndent:0},t),e.rename(t,"listItem"));this.fire("_executeCleanup",n)})}_getValue(){const e=Or(this.editor.model.document.selection.getSelectedBlocks());return!!e&&e.is("element","listItem")&&e.getAttribute("listType")==this.type}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Or(e.getSelectedBlocks());return!!i&&$p(i,t)}}function qp(e,t,i){const n=t?e[0]:e[e.length-1];if(n.is("element","listItem")){let s=n[t?"previousSibling":"nextSibling"],o=n.getAttribute("listIndent");for(;s&&s.is("element","listItem")&&s.getAttribute("listIndent")>=i;)o>s.getAttribute("listIndent")&&(o=s.getAttribute("listIndent")),s.getAttribute("listIndent")==o&&e[t?"unshift":"push"](s),s=s[t?"previousSibling":"nextSibling"]}}function $p(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Up extends Xe{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change(e=>{const t=i[i.length-1];let n=t.nextSibling;for(;n&&"listItem"==n.name&&n.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(n),n=n.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)})}_checkEnabled(){const e=Or(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let n=e.previousSibling;for(;n&&n.is("element","listItem")&&n.getAttribute("listIndent")>=t;){if(n.getAttribute("listIndent")==t)return n.getAttribute("listType")==i;n=n.previousSibling}return!1}return!0}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Kp(e,t){const i=t.mapper,n=t.writer,s="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=ew,t}(n),r=n.createContainerElement(s,null);return n.insert(n.createPositionAt(r,0),o),i.bindElements(e,o),o}function Gp(e,t,i,n){const s=t.parent,o=i.mapper,r=i.writer;let a=o.toViewPosition(n.createPositionBefore(e));const l=Qp(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(l);a=r.breakContainer(r.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=o.toViewPosition(n.createPositionAt(c,"end"));const e=o.findMappedViewAncestor(a),t=Zp(e);a=t?r.createPositionBefore(t):r.createPositionAt(e,"end")}else a=o.toViewPosition(n.createPositionBefore(e));if(a=Yp(a),r.insert(a,s),c&&"listItem"==c.name){const e=o.toViewElement(c),i=r.createRange(r.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=r.breakContainer(r.createPositionBefore(e.item)),s=e.item.parent,o=r.createPositionAt(t,"end");Jp(r,o.nodeBefore,o.nodeAfter),r.move(r.createRangeOn(s),o),i.position=n}}else{const i=s.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=o.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(t,"end")))}}Jp(r,s,s.nextSibling),Jp(r,s.previousSibling,s)}function Jp(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function Yp(e){return e.getLastMatchingPosition(e=>e.item.is("uiElement"))}function Qp(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,s=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(i&&s==e||n&&s>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function Xp(e,t,i,n){e.ui.componentFactory.add(t,s=>{const o=e.commands.get(t),r=new Ch(s);return r.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",()=>{e.execute(t),e.editing.view.focus()}),r})}function Zp(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}function ew(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:is.call(this)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function tw(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;s.consume(i.item,"insert"),s.consume(i.item,"attribute:listType"),s.consume(i.item,"attribute:listIndent");const o=i.item;Gp(o,Kp(o,n),n,e)}}function iw(e,t,i){if(!i.consumable.consume(t.item,"attribute:listType"))return;const n=i.mapper.toViewElement(t.item),s=i.writer;s.breakContainer(s.createPositionBefore(n)),s.breakContainer(s.createPositionAfter(n));const o=n.parent,r="numbered"==t.attributeNewValue?"ol":"ul";s.rename(r,o)}function nw(e,t,i){const n=i.mapper.toViewElement(t.item).parent,s=i.writer;Jp(s,n,n.nextSibling),Jp(s,n.previousSibling,n);for(const e of t.item.getChildren())i.consumable.consume(e,"insert")}function sw(e,t,i){if("listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const n=i.writer,s=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=n.breakContainer(e),"li"==e.parent.name);){const t=e,i=n.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=n.remove(n.createRange(t,i));s.push(e)}e=n.createPositionAfter(e.parent)}if(s.length>0){for(let t=0;t<s.length;t++){const i=e.nodeBefore;if(e=n.insert(e,s[t]).end,t>0){const t=Jp(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}Jp(n,e.nodeBefore,e.nodeAfter)}}}function ow(e,t,i){const n=i.mapper.toViewPosition(t.position),s=n.nodeBefore,o=n.nodeAfter;Jp(i.writer,s,o)}function rw(e,t,i){if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),s=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t.viewItem);e.setAttribute("listIndent",s,n);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,n),!i.safeInsert(n,t.modelCursor))return;const r=function(e,t,i){const{writer:n,schema:s}=i;let o=n.createPositionAfter(e);for(const r of t)if("ul"==r.name||"ol"==r.name)o=i.convertItem(r,o).modelCursor;else{const t=i.convertItem(r,n.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!s.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:dw(t.modelCursor),o=n.createPositionAfter(e))}return o}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,r),i.updateConversionResult(n,t)}}function aw(e,t,i){if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||mw(t))&&t._remove()}}}function lw(e,t,i){if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1,n=!0;for(const t of e)i&&!mw(t)&&t._remove(),t.is("$text")?(n&&(t._data=t.data.trimStart()),t.nextSibling&&!mw(t.nextSibling)||(t._data=t.data.trimEnd())):mw(t)&&(i=!0),n=!1}}function cw(e){return(t,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const t=i.mapper.toViewElement(n),s=t.getAncestors().find(mw),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==s){i.viewPosition=e.nextPosition;break}}}}}function hw(e,[t,i]){let n,s=t.is("documentFragment")?t.getChild(0):t;if(n=i?this.createSelection(i):this.document.selection,s&&s.is("element","listItem")){const e=n.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;s&&s.is("element","listItem");)s._setAttribute("listIndent",s.getAttribute("listIndent")+e),s=s.nextSibling}}}function dw(e){const t=new Zr({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function uw(e,t,i,n,s,o){const r=Qp(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e,foo:"b"}),a=s.mapper,l=s.writer,c=r?r.getAttribute("listIndent"):null;let h;if(r)if(c==e){const e=a.toViewElement(r).parent;h=l.createPositionAfter(e)}else{const e=o.createPositionAt(r,"end");h=a.toViewPosition(e)}else h=i;h=Yp(h);for(const e of[...n.getChildren()])mw(e)&&(h=l.move(l.createRangeOn(e),h).end,Jp(l,e,e.nextSibling),Jp(l,e.previousSibling,e))}function mw(e){return e.is("element","ol")||e.is("element","ul")}class fw extends Ye{static get pluginName(){return"ListEditing"}static get requires(){return[ju,Uu]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var n;e.model.document.registerPostFixer(t=>function(e,t){const i=e.document.differ.getChanges(),n=new Map;let s=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)o(n.position);else if("insert"==n.type&&"listItem"!=n.name){if("$text"!=n.name){const i=n.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),s=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),s=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),s=!0);for(const t of Array.from(e.createRangeIn(i)).filter(e=>e.item.is("element","listItem")))o(t.previousPosition)}o(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?o(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&o(n.range.start);for(const e of n.values())r(e),a(e);return s;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(n.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,n.has(e))return;n.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&n.set(t,t)}}function r(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>i){let r;null===n?(n=o-i,r=i):(n>o&&(n=o),r=o-n),t.setAttribute("listIndent",r,e),s=!0}else n=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const n=i[o];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),s=!0)}else i[o]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t)),i.mapper.registerViewToModelLength("li",gw),t.mapper.registerViewToModelLength("li",gw),i.mapper.on("modelToViewPosition",cw(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,s=i.parent,o=t.mapper;if("ul"==s.name||"ol"==s.name){if(i.isAtEnd){const e=o.toModelElement(i.nodeBefore),s=o.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(s)}else{const e=o.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==s.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=o.toModelElement(s);let a=1,l=i.nodeBefore;for(;l&&mw(l);)a+=o.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(r).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",cw(i.view)),e.conversion.for("editingDowncast").add(t=>{t.on("insert",sw,{priority:"high"}),t.on("insert:listItem",tw(e.model)),t.on("attribute:listType:listItem",iw,{priority:"high"}),t.on("attribute:listType:listItem",nw,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const s=n.mapper.toViewElement(i.item),o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r);o.remove(l),a&&a.nextSibling&&Jp(o,a,a.nextSibling),uw(i.attributeOldValue+1,i.range.start,l.start,s,n,e),Gp(i.item,s,n,e);for(const e of i.item.getChildren())n.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,n)=>{const s=n.mapper.toViewPosition(i.position).getLastMatchingPosition(e=>!e.item.is("element","li")).nodeAfter,o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r),c=o.remove(l);a&&a.nextSibling&&Jp(o,a,a.nextSibling);uw(n.mapper.toModelElement(s).getAttribute("listIndent")+1,i.position,l.start,s,n,e);for(const e of o.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",ow,{priority:"low"})}),e.conversion.for("dataDowncast").add(t=>{t.on("insert",sw,{priority:"high"}),t.on("insert:listItem",tw(e.model))}),e.conversion.for("upcast").add(e=>{e.on("element:ul",aw,{priority:"high"}),e.on("element:ol",aw,{priority:"high"}),e.on("element:li",lw,{priority:"high"}),e.on("element:li",rw)}),e.model.on("insertContent",hw,{priority:"high"}),e.commands.add("numberedList",new Wp(e,"numbered")),e.commands.add("bulletedList",new Wp(e,"bulleted")),e.commands.add("indentList",new Up(e,"forward")),e.commands.add("outdentList",new Up(e,"backward"));const s=i.view.document;this.listenTo(s,"enter",(e,t)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())},{context:"li"}),this.listenTo(s,"delete",(e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const s=n.parent;if("listItem"!==s.name)return;s.previousSibling&&"listItem"===s.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())},{context:"li"});const o=e=>(t,i)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),i())};e.keystrokes.set("Tab",o("indentList")),e.keystrokes.set("Shift+Tab",o("outdentList"))}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function gw(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=gw(e);return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class pw extends Ye{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;Xp(this.editor,"numberedList",e("Numbered List"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM3.5 3v5H2V3.7H1v-1h2.5V3zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001c-.048.405-.16.734-.333.988-.175.254-.59.692-1.244 1.312H4.3v1h-4l.043-.043zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>'),Xp(this.editor,"bulletedList",e("Bulleted List"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z"/></svg>')}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ww extends Xe{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=mg(e),e&&e.hasAttribute("width")?this.value={width:e.getAttribute("width"),height:null}:this.value=null}execute(e){const t=this.editor.model,i=t.document.selection.getSelectedElement();this.value={width:e.width,height:null},i&&t.change(t=>{t.setAttribute("width",e.width,i)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bw extends Ye{static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new ww(e);this._registerSchema(),this._registerConverters(),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}_registerSchema(){this.editor.model.schema.extend("image",{allowAttributes:"width"}),this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0})}_registerConverters(){const e=this.editor;e.conversion.for("downcast").add(e=>e.on("attribute:width:image",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,s),n.addClass("image_resized",s)):(n.removeStyle("width",s),n.removeClass("image_resized",s))})),e.conversion.for("upcast").attributeToAttribute({view:{name:"figure",styles:{width:/.+/}},model:{key:"width",value:e=>e.getStyle("width")}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const _w={small:$c,medium:Uc,large:qc,original:Wc};class vw extends Ye{static get requires(){return[bw]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:s}=e,o=n?n+this._resizeUnit:null;t.ui.componentFactory.add(i,i=>{const n=new Ch(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!_w[s])throw new l.a("imageresizebuttons-missing-icon",t,e);return n.set({label:a,icon:_w[s],tooltip:a,isToggleable:!0}),n.bind("isEnabled").to(this),n.bind("isOn").to(r,"value",yw(o)),this.listenTo(n,"execute",()=>{t.execute("resizeImage",{width:o})}),n})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find(e=>!e.value),s=s=>{const o=t.commands.get("resizeImage"),r=Qh(s,Oh),a=r.buttonView;return a.set({tooltip:i("Resize image"),commandValue:n.value,icon:_w.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button"}),a.bind("label").to(o,"value",e=>e&&e.width?e.width:this._getOptionLabelValue(n)),r.bind("isOn").to(o),r.bind("isEnabled").to(this),Zh(r,this._getResizeDropdownListItemDefinitions(e,o)),r.listView.ariaLabel=i("Image resize list"),this.listenTo(r,"execute",e=>{t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus()}),r};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t){const i=this.editor.t;return e.label?e.label:t?e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const i=new Xi;return e.map(e=>{const n=e.value?e.value+this._resizeUnit:null,s={type:"button",model:new dd({commandName:"resizeImage",commandValue:n,label:this._getOptionLabelValue(e),withText:!0,icon:null})};s.model.bind("isOn").to(t,"value",yw(n)),i.add(s)}),i}}function yw(e){return t=>null===e&&t===e||t&&t.width===e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kw extends Ye{static get requires(){return[cg]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view;t.addObserver(hg),this.listenTo(t.document,"imageLoaded",(i,n)=>{if(!n.target.matches("figure.image.ck-widget > img, figure.image.ck-widget > a > img"))return;const s=e.editing.view.domConverter.domToView(n.target).findAncestor("figure");let o=this.editor.plugins.get(cg).getResizerByViewElement(s);if(o)return void o.redraw();const r=e.editing.mapper.toModelElement(s);o=e.plugins.get(cg).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:r,viewElement:s,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:e=>e,isCentered(){const e=r.getAttribute("imageStyle");return!e||"full"==e||"alignCenter"==e},onCommit(t){e.execute("resizeImage",{width:t})}}),o.on("updateSize",()=>{s.hasClass("image_resized")||t.change(e=>{e.addClass("image_resized",s)})}),o.bind("isEnabled").to(this)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Cw=["left","right","center","justify"];function Aw(e){return Cw.includes(e)}function xw(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function Tw(e){const t=e.map(e=>{let t;return t="string"==typeof e?{name:e}:e,t}).filter(e=>{const t=!!Cw.includes(e.name);return t||Object(l.b)("alignment-config-name-not-recognized",{option:e}),t}),i=t.filter(e=>!!e.className).length;if(i&&i<t.length)throw new l.a("alignment-config-classnames-are-missing",{configuredOptions:e});return t.forEach((t,i,n)=>{const s=n.slice(i+1);if(s.some(e=>e.name==t.name))throw new l.a("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className){if(s.some(e=>e.className==t.className))throw new l.a("alignment-config-classname-already-defined",{option:t,configuredOptions:e})}}),t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pw extends Xe{refresh(){const e=this.editor.locale,t=Or(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!t&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,s=n.document,o=e.value;n.change(e=>{const t=Array.from(s.selection.getSelectedBlocks()).filter(e=>this._canBeAligned(e)),n=t[0].getAttribute("alignment");xw(o,i)||n===o||!o?function(e,t){for(const i of e)t.removeAttribute("alignment",i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute("alignment",i,n)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,e,o)})}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,"alignment")}}class Ew extends Ye{static get pluginName(){return"AlignmentEditing"}constructor(e){super(e),e.config.define("alignment",{options:[...Cw.map(e=>({name:e}))]})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=Tw(e.config.get("alignment.options")).filter(e=>Aw(e.name)&&!xw(e.name,t)),s=n.some(e=>!!e.className);i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),s?e.conversion.attributeToAttribute(function(e){const t={model:{key:"alignment",values:e.map(e=>e.name)},view:{}};for(const i of e)t.view[i.name]={key:"class",value:i.className};return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={model:{key:"alignment",values:e.map(e=>e.name)},view:{}};for(const{name:i}of e)t.view[i]={key:"style",value:{"text-align":i}};return t}(n));const o=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of o)e.conversion.for("upcast").attributeToAttribute(t);const r=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of r)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new Pw(e))}}const Sw=new Map([["left",Mc],["right",Fc],["center",Bc],["justify",Dc]]);class Rw extends Ye{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const e=this.editor,t=e.ui.componentFactory,i=e.t,n=Tw(e.config.get("alignment.options"));n.map(e=>e.name).filter(Aw).forEach(e=>this._addButton(e)),t.add("alignment",e=>{const s=Qh(e),o=n.map(e=>t.create("alignment:"+e.name));Xh(s,o),s.buttonView.set({label:i("Text alignment"),tooltip:!0}),s.toolbarView.isVertical=!0,s.toolbarView.ariaLabel=i("Text alignment toolbar"),s.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===e.contentLanguageDirection?Sw.get("right"):Sw.get("left");return s.buttonView.bind("icon").toMany(o,"isOn",(...e)=>{const t=e.findIndex(e=>e);return t<0?r:o[t].icon}),s.bind("isEnabled").toMany(o,"isEnabled",(...e)=>e.some(e=>e)),s})}_addButton(e){const t=this.editor;t.ui.componentFactory.add("alignment:"+e,i=>{const n=t.commands.get("alignment"),s=new Ch(i);return s.set({label:this.localizedOptionTitles[e],icon:Sw.get(e),tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n),s.bind("isOn").to(n,"value",t=>t===e),this.listenTo(s,"execute",()=>{t.execute("alignment",{value:e}),t.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Iw(e,t){if(!e.childCount)return;const i=new Wd(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new fn({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),s=[];for(const e of i)if("elementStart"===e.type&&n.match(e.item)){const t=Nw(e.item);s.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return s}(e,i);if(!n.length)return;let s=null,o=1;n.forEach((e,r)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;if(!i)return!0;return n=i,!(n.is("element","ol")||n.is("element","ul"));var n}(n[r-1],e),l=a?null:n[r-1],c=(d=e,(h=l)?d.indent-h.indent:d.indent-1);var h,d;if(a&&(s=null,o=1),!s||0!==c){const n=function(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,s=i.exec(t);let o="decimal",r="ol";if(s&&s[1]){const t=n.exec(s[1]);if(t&&t[1]&&(o=t[1].trim(),r="bullet"!==o&&"image"!==o?"ol":"ul"),"bullet"===o){const t=function(e){const t=function(e){if(e.getChild(0).is("$text"))return null;const t=e.getChild(0).getChild(0);if(t.is("$text"))return t;return t.getChild(0)}(e);if(!t)return null;const i=t._data;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(o=t)}}return{type:r,style:Vw(o)}}(e,t);if(s){if(e.indent>o){const e=s.getChild(s.childCount-1),t=e.getChild(e.childCount-1);s=Ow(n,t,i),o+=1}else if(e.indent<o){const t=o-e.indent;s=function(e,t){const i=e.getAncestors({parentFirst:!0});let n=null,s=0;for(const e of i)if("ul"!==e.name&&"ol"!==e.name||s++,s===t){n=e;break}return n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(s,t),o=parseInt(e.indent)}}else s=Ow(n,e.element,i);e.indent<=o&&(s.is("element",n.type)||(s=i.rename(n.type,s)))}const u=function(e,t){return function(e,t){const i=new fn({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}(e,t),t.rename("li",e)}(e.element,i);i.appendChild(u,s)})}function Vw(e){switch(e){case"arabic-leading-zero":return"decimal-leading-zero";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 e;default:return null}}function Ow(e,t,i){const n=t.parent,s=i.createElement(e.type),o=n.getChildIndex(t)+1;return i.insertChild(o,s,n),e.style&&i.setStyle("list-style-type",e.style,s),s}function Nw(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),n=i.match(/\s{0,100}lfo(\d+)/i),s=i.match(/\s{0,100}level(\d+)/i);e&&n&&s&&(t.id=e[2],t.order=n[1],t.indent=s[1])}return t}const Mw=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Bw{constructor(e){this.document=e}isActive(e){return Mw.test(e)}execute(e){const t=new Wd(this.document);!
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(e.content,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(e.content,t)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Fw(e){return e.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Dw(e,t){const i=new DOMParser,n=function(e){return Fw(Fw(e)).replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g,"").replace(/ <\//g," </").replace(/ <o:p><\/o:p>/g," <o:p></o:p>").replace(/<o:p>(&nbsp;|\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)</g,"><")}(function(e){const t=e.indexOf("</body>");if(t<0)return e;const i=e.indexOf("</html>",t+"</body>".length);return e.substring(0,t+"</body>".length)+(i>=0?e.substring(i):"")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e=e.replace(/<!--\[if gte vml 1]>/g,""))),s=i.parseFromString(n,"text/html");!function(e){e.querySelectorAll("span[style*=spacerun]").forEach(e=>{const t=e.innerText.length||0;e.innerHTML=Array(t+1).join("  ").substr(0,t)})}(s);const o=s.body.innerHTML,r=function(e,t){const i=new vs(t),n=new To(i,{blockFillerMode:"nbsp"}),s=e.createDocumentFragment(),o=e.body.childNodes;for(;o.length>0;)s.appendChild(o[0]);return n.domToView(s)}(s,t),a=function(e){const t=[],i=[],n=Array.from(e.getElementsByTagName("style"));for(const e of n)e.sheet&&e.sheet.cssRules&&e.sheet.cssRules.length&&(t.push(e.sheet),i.push(e.innerHTML));return{styles:t,stylesString:i.join(" ")}}(s);return{body:r,bodyString:o,styles:a.styles,stylesString:a.stylesString}}function zw(e,t){if(!e.childCount)return;const i=new Wd;!function(e,t,i){const n=i.createRangeIn(t),s=new fn({name:"img"}),o=[];for(const t of n)if(s.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every(t=>e.indexOf(t)>-1)?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(function(e,t){const i=t.createRangeIn(e),n=new fn({name:/v:(.+)/}),s=[];for(const e of i){const t=e.item,i=t.previousSibling&&t.previousSibling.name||null;n.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==i&&s.push(e.item.getAttribute("id"))}return s}(e,i),e,i),function(e,t){const i=t.createRangeIn(e),n=new fn({name:/v:(.+)/}),s=[];for(const e of i)n.match(e.item)&&s.push(e.item);for(const e of s)t.remove(e)}(e,i);const n=function(e,t){const i=t.createRangeIn(e),n=new fn({name:"img"}),s=[];for(const e of i)n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&s.push(e.item);return s}(e,i);n.length&&function(e,t,i){if(e.length===t.length)for(let s=0;s<e.length;s++){const o=`data:${t[s].type};base64,${n=t[s].hex,btoa(n.match(/\w{2}/g).map(e=>String.fromCharCode(parseInt(e,16))).join(""))}`;i.setAttribute("src",o,e[s])}var n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(n,function(e){if(!e)return[];const t=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+t.source+"))([\\da-fA-F\\s]+)\\}","g"),n=e.match(i),s=[];if(n)for(const e of n){let i=!1;e.includes("\\pngblip")?i="image/png":e.includes("\\jpegblip")&&(i="image/jpeg"),i&&s.push({hex:e.replace(t,"").replace(/[^\da-fA-F]/g,""),type:i})}return s}(t),i)}const Lw=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,Hw=/xmlns:o="urn:schemas-microsoft-com/i;class jw{constructor(e){this.document=e}isActive(e){return Lw.test(e)||Hw.test(e)}execute(e){const{body:t,stylesString:i}=Dw(e.dataTransfer.getData("text/html"),this.document.stylesProcessor);Iw(t,i),zw(t,e.dataTransfer.getData("text/rtf")),e.content=t}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ww extends Xe{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change(e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qw extends Xi{constructor(e){super(e),this.set("isEmpty",!0),this.on("change",()=>{this.set("isEmpty",0===this.length)})}add(e,t){this.find(t=>t.color===e.color)||super.add(e,t)}hasColor(e){return!!this.find(t=>t.color===e)}}Je(qw,We);
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class $w extends eh{constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o}){super(e),this.items=this.createCollection(),this.colorDefinitions=t,this.focusTracker=new Nr,this.keystrokes=new Mr,this.set("selectedColor"),this.removeButtonLabel=n,this.columns=i,this.documentColors=new qw,this.documentColorsCount=o,this._focusCycler=new Sh({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this._documentColorsLabel=s,this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._removeColorButton())}updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRootNames()){const o=i.getRoot(s),r=e.createRangeIn(o);for(const e of r.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=n))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,i=this.selectedColor;t.selectedColor=i,e&&(e.selectedColor=i)}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}appendGrids(){if(!this.staticColorsGrid&&(this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount)){const e=th.bind(this.documentColors,this.documentColors),t=new td(this.locale);t.text=this._documentColorsLabel,t.extendTemplate({attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]}}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_removeColorButton(){const e=new Ch;return e.set({withText:!0,icon:Sc,tooltip:!0,label:this.removeButtonLabel}),e.class="ck-color-table__remove-color",e.on("execute",()=>{this.fire("execute",{value:null})}),e}_createStaticColorsGrid(){const e=new Ih(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.delegate("execute").to(this),e}_createDocumentColorsGrid(){const e=th.bind(this.documentColors,this.documentColors),t=new Ih(this.locale,{columns:this.columns});return t.delegate("execute").to(this),t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using(e=>{const t=new Eh;return t.set({color:e.color,hasBorder:e.options&&e.options.hasBorder}),e.label&&t.set({label:e.label,tooltip:!0}),t.on("execute",()=>{this.fire("execute",{value:e.color})}),t}),this.documentColors.on("change:isEmpty",(e,i,n)=>{n&&(t.selectedColor=null)}),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find(t=>t.color===e);t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Uw(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function Kw(e){return t=>t.getStyle(e).replace(/\s/g,"")}function Gw(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Jw extends Ww{constructor(e){super(e,"fontFamily")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Yw(e){return e.map(Qw).filter(e=>!!e)}function Qw(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],n=t.map(Xw).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function Xw(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zw extends Ye{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define("fontFamily",{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 e=this.editor;e.model.schema.extend("$text",{allowAttributes:"fontFamily"}),e.model.schema.setAttributeProperties("fontFamily",{isFormatting:!0,copyOnEnter:!0});const t=Uw("fontFamily",Yw(e.config.get("fontFamily.options")).filter(e=>e.model));e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(t),e.commands.add("fontFamily",new Jw(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:"fontFamily",view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:"fontFamily",value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:"fontFamily",value:e=>e.getAttribute("face")}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class eb extends Ye{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get("fontFamily");e.ui.componentFactory.add("fontFamily",s=>{const o=Qh(s);return Zh(o,function(e,t){const i=new Xi;for(const n of e){const e={type:"button",model:new dd({commandName:"fontFamily",commandParam:n.model,label:n.title,withText:!0})};e.model.bind("isOn").to(t,"value",e=>e===n.model||!(!e||!n.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===n.model.toLowerCase()),n.view&&n.view.styles&&e.model.set("labelStyle","font-family: "+n.view.styles["font-family"]),i.add(e)}return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i,n)),o.buttonView.set({label:t("Font Family"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.03 3h6.149a.75.75 0 1 1 0 1.5h-5.514L11.03 3zm1.27 3h4.879a.75.75 0 1 1 0 1.5h-4.244L12.3 6zm1.27 3h3.609a.75.75 0 1 1 0 1.5h-2.973L13.57 9zm-2.754 2.5L8.038 4.785 5.261 11.5h5.555zm.62 1.5H4.641l-1.666 4.028H1.312l5.789-14h1.875l5.789 14h-1.663L11.436 13z"/></svg>',tooltip:!0}),o.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),o.bind("isEnabled").to(n),this.listenTo(o,"execute",t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()}),o})}_getLocalizedOptions(){const e=this.editor,t=e.t;return Yw(e.config.get("fontFamily").options).map(e=>("Default"===e.title&&(e.title=t("Default")),e))}}class tb extends Ye{static get requires(){return[Zw,eb]}static get pluginName(){return"FontFamily"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ib extends Ww{constructor(e){super(e,"fontSize")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function nb(e){return e.map(e=>function(e){if(t=e,"object"==typeof t&&t.title&&t.model&&t.view)return ob(e);var t;const i=function(e){return sb[e]||sb[e.model]}(e);if(i)return ob(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new l.a("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e))return;return function(e){"number"!=typeof e&&"string"!=typeof e||(e={title:String(e),model:parseFloat(e)+"px"});return e.view={name:"span",styles:{"font-size":e.model}},ob(e)}(e)}(e)).filter(e=>!!e)}const sb={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 ob(e){return e.view.priority||(e.view.priority=7),e}const rb=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class ab extends Ye{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define("fontSize",{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"fontSize"}),e.model.schema.setAttributeProperties("fontSize",{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=Uw("fontSize",nb(this.editor.config.get("fontSize.options")).filter(e=>e.model));t?(this._prepareAnyValueConverters(i),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add("fontSize",new ib(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter(e=>!eu(String(e))&&!iu(String(e)));if(i.length)throw new l.a("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:"fontSize",view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:"fontSize",value:e=>e.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:"fontSize",value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const s=rb.length-1,o=Math.min(Math.max(n,0),s);return rb[o]}}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class lb extends Ye{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get("fontSize");e.ui.componentFactory.add("fontSize",s=>{const o=Qh(s);return Zh(o,function(e,t){const i=new Xi;for(const n of e){const e={type:"button",model:new dd({commandName:"fontSize",commandParam:n.model,label:n.title,class:"ck-fontsize-option",withText:!0})};n.view&&n.view.styles&&e.model.set("labelStyle","font-size:"+n.view.styles["font-size"]),n.view&&n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`),e.model.bind("isOn").to(t,"value",e=>e===n.model),i.add(e)}return i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i,n)),o.buttonView.set({label:t("Font Size"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.816 11.5 7.038 4.785 4.261 11.5h5.555zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13zm7.55 2.279.779-.779.707.707-2.265 2.265-2.193-2.265.707-.707.765.765V4.825c0-.042 0-.083.002-.123l-.77.77-.707-.707L17.207 2.5l2.265 2.265-.707.707-.782-.782c.002.043.003.089.003.135v10.454z"/></svg>',tooltip:!0}),o.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),o.bind("isEnabled").to(n),this.listenTo(o,"execute",t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()}),o})}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return nb(e.config.get("fontSize").options).map(e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e})}}class cb extends Ye{static get requires(){return[ab,lb]}static get pluginName(){return"FontSize"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hb extends Ww{constructor(e){super(e,"fontColor")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class db extends Ye{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define("fontColor",{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}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:"fontColor",value:Kw("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:"fontColor",value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:"fontColor",view:Gw("color")}),e.commands.add("fontColor",new hb(e)),e.model.schema.extend("$text",{allowAttributes:"fontColor"}),e.model.schema.setAttributeProperties("fontColor",{isFormatting:!0,copyOnEnter:!0})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ub extends Ye{constructor(e,{commandName:t,icon:i,componentName:n,dropdownLabel:s}){super(e),this.commandName=t,this.componentName=n,this.icon=i,this.dropdownLabel=s,this.columns=e.config.get(this.componentName+".columns"),this.colorTableView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),s=xh(t,Th(e.config.get(this.componentName).colors)),o=e.config.get(this.componentName+".documentColors");e.ui.componentFactory.add(this.componentName,t=>{const r=Qh(t);return this.colorTableView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o}){const r=e.locale,a=new $w(r,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o});return e.colorTableView=a,e.panelView.children.add(a),a.delegate("execute").to(e,"execute"),a}({dropdownView:r,colors:s.map(e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),documentColorsLabel:0!==o?i("Document colors"):void 0,documentColorsCount:void 0===o?this.columns:o}),this.colorTableView.bind("selectedColor").to(n,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(n),r.on("execute",(t,i)=>{e.execute(this.commandName,i),e.editing.view.focus()}),r.on("change:isOpen",(t,i,n)=>{r.colorTableView.appendGrids(),n&&(0!==o&&this.colorTableView.updateDocumentColors(e.model,this.componentName),this.colorTableView.updateSelectedColors())}),r})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class mb extends ub{constructor(e){super(e,{commandName:"fontColor",componentName:"fontColor",icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.4 10.3 10 4.5l-2.4 5.8h4.8zm.5 1.2H7.1L5.7 15H4.2l5-12h1.6l5 12h-1.5L13 11.5zm3.1 7H4a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2z"/></svg>',dropdownLabel:(0,e.locale.t)("Font Color")})}static get pluginName(){return"FontColorUI"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fb extends Ye{static get requires(){return[db,mb]}static get pluginName(){return"FontColor"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gb extends Ww{constructor(e){super(e,"fontBackgroundColor")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class pb extends Ye{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define("fontBackgroundColor",{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}),e.data.addStyleProcessorRules(gu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:"fontBackgroundColor",value:Kw("background-color")}}),e.conversion.for("downcast").attributeToElement({model:"fontBackgroundColor",view:Gw("background-color")}),e.commands.add("fontBackgroundColor",new gb(e)),e.model.schema.extend("$text",{allowAttributes:"fontBackgroundColor"}),e.model.schema.setAttributeProperties("fontBackgroundColor",{isFormatting:!0,copyOnEnter:!0})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class wb extends ub{constructor(e){super(e,{commandName:"fontBackgroundColor",componentName:"fontBackgroundColor",icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M4 2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm8.38 9.262H7.62L10 5.506l2.38 5.756zm.532 1.285L14.34 16h1.426L10.804 4H9.196L4.234 16H5.66l1.428-3.453h5.824z"/></svg>',dropdownLabel:(0,e.locale.t)("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bb extends Ye{static get requires(){return[pb,wb]}static get pluginName(){return"FontBackgroundColor"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function _b(e,t){return e=>{e.on("attribute:url:media",i)};function i(i,n,s){if(!s.consumable.consume(n.item,i.name))return;const o=n.attributeNewValue,r=s.writer,a=s.mapper.toViewElement(n.item),l=[...a.getChildren()].find(e=>e.getCustomProperty("media-content"));r.remove(l);const c=e.getMediaViewElement(r,o,t);r.insert(r.createPositionAt(a,0),c)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function vb(e,t,i,n){const s=e.createContainerElement("figure",{class:"media"});return e.insert(e.createPositionAt(s,0),t.getMediaViewElement(e,i,n)),s}function yb(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function kb(e,t,i){e.change(n=>{const s=n.createElement("media",{url:t});e.insertContent(s,i),n.setSelection(s,"on")})}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cb extends Xe{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema,n=yb(t);this.value=n?n.getAttribute("url"):null,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){let i=sm(e,t).parent;i.isEmpty&&!t.schema.isLimit(i)&&(i=i.parent);return t.schema.checkChild(i,"media")}(t,e)&&!om(t,i)}execute(e){const t=this.editor.model,i=t.document.selection,n=yb(i);if(n)t.change(t=>{t.setAttribute("url",e,n)});else{const n=sm(i,t);kb(t,e,n)}}}class Ab{constructor(e,t){const i=t.providers,n=t.extraProviders||[],s=new Set(t.removeProviders),o=i.concat(n).filter(e=>{const t=e.name;return t?!s.has(t):(Object(l.b)("media-embed-no-provider-name",{provider:e}),!1)});this.locale=e,this.providerDefinitions=o}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,i){return this._getMedia(t).getViewElement(e,i)}_getMedia(e){if(!e)return new xb(this.locale);e=e.trim();for(const t of this.providerDefinitions){const i=t.html,n=en(t.url);for(const t of n){const n=this._getUrlMatches(e,t);if(n)return new xb(this.locale,e,n,i)}}return null}_getUrlMatches(e,t){let i=e.match(t);if(i)return i;let n=e.replace(/^https?:\/\//,"");return i=n.match(t),i||(n=n.replace(/^www\./,""),i=n.match(t),i||null)}}class xb{constructor(e,t,i,n){this.url=this._getValidUrl(t),this._t=e.t,this._match=i,this._previewRenderer=n}getViewElement(e,t){const i={};let n;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(i["data-oembed-url"]=this.url),t.renderForEditingView&&(i.class="ck-media__wrapper");const s=this._getPreviewHtml(t);n=e.createRawElement("div",i,(function(e){e.innerHTML=s}))}else this.url&&(i.url=this.url),n=e.createEmptyElement(t.elementName,i);return e.setCustomProperty("media-content",!0,n),n}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new kh,t=new yh;e.text=this._t("Open media in new tab"),t.content='<svg viewBox="0 0 64 42" xmlns="http://www.w3.org/2000/svg"><path d="M47.426 17V3.713L63.102 0v19.389h-.001l.001.272c0 1.595-2.032 3.43-4.538 4.098-2.506.668-4.538-.083-4.538-1.678 0-1.594 2.032-3.43 4.538-4.098.914-.244 2.032-.565 2.888-.603V4.516L49.076 7.447v9.556A1.014 1.014 0 0 0 49 17h-1.574zM29.5 17h-8.343a7.073 7.073 0 1 0-4.657 4.06v3.781H3.3a2.803 2.803 0 0 1-2.8-2.804V8.63a2.803 2.803 0 0 1 2.8-2.805h4.082L8.58 2.768A1.994 1.994 0 0 1 10.435 1.5h8.985c.773 0 1.477.448 1.805 1.149l1.488 3.177H26.7c1.546 0 2.8 1.256 2.8 2.805V17zm-11.637 0H17.5a1 1 0 0 0-1 1v.05A4.244 4.244 0 1 1 17.863 17zm29.684 2c.97 0 .953-.048.953.889v20.743c0 .953.016.905-.953.905H19.453c-.97 0-.953.048-.953-.905V19.89c0-.937-.016-.889.97-.889h28.077zm-4.701 19.338V22.183H24.154v16.155h18.692zM20.6 21.375v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616V37.53H20.6zm24.233-16.155v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615V37.53h-1.615zM29.485 25.283a.4.4 0 0 1 .593-.35l9.05 4.977a.4.4 0 0 1 0 .701l-9.05 4.978a.4.4 0 0 1-.593-.35v-9.956z"/></svg>',t.viewBox="0 0 64 42";return new th({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},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]},e]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tb extends Ye{static get pluginName(){return"MediaEmbedEditing"}constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; "><iframe src="https://www.dailymotion.com/embed/video/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" width="480" height="270" allowfullscreen allow="autoplay"></iframe></div>`},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;"><iframe src="https://open.spotify.com/embed/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe></div>`},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)/,/^youtube\.com\/embed\/([\w-]+)/,/^youtu\.be\/([\w-]+)/],html:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;"><iframe src="https://www.youtube.com/embed/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>`},{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:e=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;"><iframe src="https://player.vimeo.com/video/${e[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>`},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:/^google\.com\/maps/},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new Ab(e.locale,e.config.get("mediaEmbed"))}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion,s=e.config.get("mediaEmbed.previewsInData"),o=e.config.get("mediaEmbed.elementName"),r=this.registry;e.commands.add("mediaEmbed",new Cb(e)),t.register("media",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["url"]}),n.for("dataDowncast").elementToElement({model:"media",view:(e,{writer:t})=>{const i=e.getAttribute("url");return vb(t,r,i,{elementName:o,renderMediaPreview:i&&s})}}),n.for("dataDowncast").add(_b(r,{elementName:o,renderMediaPreview:s})),n.for("editingDowncast").elementToElement({model:"media",view:(e,{writer:t})=>{const n=e.getAttribute("url");return function(e,t,i){return t.setCustomProperty("media",!0,e),Xu(e,t,{label:i})}(vb(t,r,n,{elementName:o,renderForEditingView:!0}),t,i("media widget"))}}),n.for("editingDowncast").add(_b(r,{elementName:o,renderForEditingView:!0})),n.for("upcast").elementToElement({view:e=>["oembed",o].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,{writer:t})=>{const i=e.getAttribute("url");if(r.hasMedia(i))return t.createElement("media",{url:i})}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,{writer:t})=>{const i=e.getAttribute("data-oembed-url");if(r.hasMedia(i))return t.createElement("media",{url:i})}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Pb=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class Eb extends Ye{static get requires(){return[Pm,ff]}static get pluginName(){return"AutoMediaEmbed"}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document;this.listenTo(e.plugins.get("ClipboardPipeline"),"inputTransformation",()=>{const e=t.selection.getFirstRange(),i=Zl.fromPosition(e.start);i.stickiness="toPrevious";const n=Zl.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",()=>{this._embedMediaBetweenPositions(i,n),i.detach(),n.detach()},{priority:"high"})}),e.commands.get("undo").on("execute",()=>{this._timeoutId&&(vo.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedMediaBetweenPositions(e,t){const i=this.editor,n=i.plugins.get(Tb).registry,s=new ba(e,t),o=s.getWalker({ignoreElementEnd:!0});let r="";for(const e of o)e.item.is("$textProxy")&&(r+=e.item.data);if(r=r.trim(),!r.match(Pb))return void s.detach();if(!n.hasMedia(r))return void s.detach();i.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=Zl.fromPosition(e),this._timeoutId=vo.window.setTimeout(()=>{i.model.change(e=>{let t;this._timeoutId=null,e.remove(s),s.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),kb(i.model,r,t),this._positionToInsert.detach(),this._positionToInsert=null})},100)):s.detach()}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sb extends eh{constructor(e,t){super(t);const i=t.t;this.focusTracker=new Nr,this.keystrokes=new Mr,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Ec,"ck-button-save"),this.saveButtonView.type="submit",this.saveButtonView.bind("isEnabled").to(this,"mediaURLInputValue",e=>!!e),this.cancelButtonView=this._createButton(i("Cancel"),Pc,"ck-button-cancel","cancel"),this._focusables=new Zc,this._focusCycler=new Sh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]}),Qc(this)}render(){super.render(),Xc({view:this});[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e),this.listenTo(this.urlInputView.element,"selectstart",(e,t)=>{t.stopPropagation()},{priority:"high"})}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.element.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new ad(this.locale,ld),i=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,i.on("input",()=>{t.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=i.element.value.trim()}),t}_createButton(e,t,i,n){const s=new Ch(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Rb extends Ye{static get requires(){return[Tb]}static get pluginName(){return"MediaEmbedUI"}init(){const e=this.editor,t=e.commands.get("mediaEmbed"),i=e.plugins.get(Tb).registry;e.ui.componentFactory.add("mediaEmbed",n=>{const s=Qh(n),o=new Sb(function(e,t){return[t=>{if(!t.url.length)return e("The URL must not be empty.")},i=>{if(!t.hasMedia(i.url))return e("This media URL is not supported.")}]}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e.t,i),e.locale);return this._setUpDropdown(s,o,t,e),this._setUpForm(s,o,t),s})}_setUpDropdown(e,t,i){const n=this.editor,s=n.t,o=e.buttonView;function r(){n.editing.view.focus(),e.isOpen=!1}e.bind("isEnabled").to(i),e.panelView.children.add(t),o.set({label:s("Insert media"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M18.68 3.03c.6 0 .59-.03.59.55v12.84c0 .59.01.56-.59.56H1.29c-.6 0-.59.03-.59-.56V3.58c0-.58-.01-.55.6-.55h17.38zM15.77 15V5H4.2v10h11.57zM2 4v1h1V4H2zm0 2v1h1V6H2zm0 2v1h1V8H2zm0 2v1h1v-1H2zm0 2v1h1v-1H2zm0 2v1h1v-1H2zM17 4v1h1V4h-1zm0 2v1h1V6h-1zm0 2v1h1V8h-1zm0 2v1h1v-1h-1zm0 2v1h1v-1h-1zm0 2v1h1v-1h-1zM7.5 7.177a.4.4 0 0 1 .593-.351l5.133 2.824a.4.4 0 0 1 0 .7l-5.133 2.824a.4.4 0 0 1-.593-.35V7.176v.001z"/></svg>',tooltip:!0}),o.on("open",()=>{t.disableCssTransitions(),t.url=i.value||"",t.urlInputView.fieldView.select(),t.focus(),t.enableCssTransitions()},{priority:"low"}),e.on("submit",()=>{t.isValid()&&(n.execute("mediaEmbed",t.url),r())}),e.on("change:isOpen",()=>t.resetFormStatus()),e.on("cancel",()=>r())}_setUpForm(e,t,i){t.delegate("submit","cancel").to(e),t.urlInputView.bind("value").to(i,"value"),t.urlInputView.bind("isReadOnly").to(i,"isEnabled",e=>!e)}}class Ib extends Ye{static get pluginName(){return"RemoveFormatUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("removeFormat",i=>{const n=e.commands.get("removeFormat"),s=new Ch(i);return s.set({label:t("Remove Format"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.69 14.915c.053.052.173.083.36.093a.366.366 0 0 1 .345.485l-.003.01a.738.738 0 0 1-.697.497h-2.67a.374.374 0 0 1-.353-.496l.013-.038a.681.681 0 0 1 .644-.458c.197-.012.325-.043.386-.093a.28.28 0 0 0 .072-.11L9.592 4.5H6.269c-.359-.017-.609.013-.75.09-.142.078-.289.265-.442.563-.192.29-.516.464-.864.464H4.17a.43.43 0 0 1-.407-.569L4.46 3h13.08l-.62 2.043a.81.81 0 0 1-.775.574h-.114a.486.486 0 0 1-.486-.486c.001-.284-.054-.464-.167-.54-.112-.076-.367-.106-.766-.091h-3.28l-2.68 10.257c-.006.074.007.127.038.158zM3 17h8a.5.5 0 1 1 0 1H3a.5.5 0 1 1 0-1zm11.299 1.17a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.06-1.06l1.415 1.414 1.414-1.415a.75.75 0 1 1 1.06 1.06l-1.413 1.415 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414-1.414 1.414z"/></svg>',tooltip:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute("removeFormat"),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vb extends Xe{refresh(){const e=this.editor.model;this.isEnabled=!!Or(this._getFormattingItems(e.document.selection,e.schema))}execute(){const e=this.editor.model,t=e.schema;e.change(i=>{for(const n of this._getFormattingItems(e.document.selection,t))if(n.is("selection"))for(const e of this._getFormattingAttributes(n,t))i.removeSelectionAttribute(e);else{const e=i.createRangeOn(n);for(const s of this._getFormattingAttributes(n,t))i.removeAttribute(s,e)}})}*_getFormattingItems(e,t){const i=e=>!!Or(this._getFormattingAttributes(e,t));for(const n of e.getRanges())for(const e of n.getItems())!t.isBlock(e)&&i(e)&&(yield e);for(const t of e.getSelectedBlocks())i(t)&&(yield t);i(e)&&(yield e)}*_getFormattingAttributes(e,t){for(const[i]of e.getAttributes()){const e=t.getAttributeProperties(i);e&&e.isFormatting&&(yield i)}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ob extends Ye{static get pluginName(){return"RemoveFormatEditing"}init(){const e=this.editor;e.commands.add("removeFormat",new Vb(e))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Nb(e,t,i,n,s=1){t>s?n.setAttribute(e,t,i):n.removeAttribute(e,i)}function Mb(e,t,i={}){const n=e.createElement("tableCell",i);return e.insertElement("paragraph",n),e.insert(n,t),n}function Bb(e,t){const i=t.parent.parent,n=parseInt(i.getAttribute("headingColumns")||0),{column:s}=e.getCellLocation(t);return!!n&&s<n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Fb(){return e=>{e.on("element:table",(e,t,i)=>{const n=t.viewItem;if(!i.consumable.test(n,{name:!0}))return;const{rows:s,headingRows:o,headingColumns:r}=function(e){const t={headingRows:0,headingColumns:0},i=[],n=[];let s;for(const o of Array.from(e.getChildren()))if("tbody"===o.name||"thead"===o.name||"tfoot"===o.name){"thead"!==o.name||s||(s=o);const e=Array.from(o.getChildren()).filter(e=>e.is("element","tr"));for(const o of e)if("thead"===o.parent.name&&o.parent===s)t.headingRows++,i.push(o);else{n.push(o);const e=zb(o);e>t.headingColumns&&(t.headingColumns=e)}}return t.rows=[...i,...n],t}(n),a={};r&&(a.headingColumns=r),o&&(a.headingRows=o);const l=i.writer.createElement("table",a);if(i.safeInsert(l,t.modelCursor)){if(i.consumable.consume(n,{name:!0}),s.forEach(e=>i.convertItem(e,i.writer.createPositionAt(l,"end"))),l.isEmpty){const e=i.writer.createElement("tableRow");i.writer.insert(e,i.writer.createPositionAt(l,"end")),Mb(i.writer,i.writer.createPositionAt(e,"end"))}i.updateConversionResult(l,t)}})}}function Db(e){return t=>{t.on("element:"+e,(e,t,i)=>{if(t.modelRange&&t.viewItem.isEmpty){const e=t.modelRange.start.nodeAfter,n=i.writer.createPositionAt(e,0);i.writer.insertElement("paragraph",n)}},{priority:"low"})}}function zb(e){let t=0,i=0;const n=Array.from(e.getChildren()).filter(e=>"th"===e.name||"td"===e.name);for(;i<n.length&&"th"===n[i].name;){const e=n[i];t+=parseInt(e.getAttribute("colspan")||1),i++}return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Lb{constructor(e,t={}){this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){const e=this._table.getChild(this._row);if(!e||this._isOverEndRow())return{done:!0};if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const i=this._getSpanned();if(i)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(i.cell,i.row,i.column));else{const i=e.getChild(this._cellIndex);if(!i)return this._advanceToNextRow();const n=parseInt(i.getAttribute("colspan")||1),s=parseInt(i.getAttribute("rowspan")||1);(n>1||s>1)&&this._recordSpans(i,s,n),this._shouldSkipSlot()||(t=this._formatOutValue(i)),this._nextCellAtColumn=this._column+n}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,i=this._column){return{done:!1,value:new Hb(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,i=this._column<this._startColumn,n=void 0!==this._endColumn&&this._column>this._endColumn;return e||t||i||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,i){const n={cell:e,row:this._row,column:this._column};for(let e=this._row;e<this._row+t;e++)for(let t=this._column;t<this._column+i;t++)e==this._row&&t==this._column||this._markSpannedCell(e,t,n)}_markSpannedCell(e,t,i){this._spannedCells.has(e)||this._spannedCells.set(e,new Map);this._spannedCells.get(e).set(t,i)}}class Hb{constructor(e,t,i,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=i,this.cellAnchorColumn=n,this._cellIndex=e._cellIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||1)}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||1)}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function jb(e={}){return t=>t.on("insert:table",(t,i,n)=>{const s=i.item;if(!n.consumable.consume(s,"insert"))return;n.consumable.consume(s,"attribute:headingRows:table"),n.consumable.consume(s,"attribute:headingColumns:table");const o=e&&e.asWidget,r=n.writer.createContainerElement("figure",{class:"table"}),a=n.writer.createContainerElement("table");let l;var c,h;n.writer.insert(n.writer.createPositionAt(r,0),a),o&&(c=r,(h=n.writer).setCustomProperty("table",!0,c),l=Xu(c,h,{hasSelectionHandle:!0}));const d=new Lb(s),u={headingRows:s.getAttribute("headingRows")||0,headingColumns:s.getAttribute("headingColumns")||0},m=new Map;for(const t of d){const{row:i,cell:o}=t,r=s.getChild(i),l=m.get(i)||Kb(a,r,i,u,n);m.set(i,l),n.consumable.consume(o,"insert");Ub(t,u,n.writer.createPositionAt(l,"end"),n,e)}for(const e of s.getChildren()){const t=e.index;m.has(t)||m.set(t,Kb(a,e,t,u,n))}const f=n.mapper.toViewPosition(i.range.start);n.mapper.bindElements(s,o?l:r),n.writer.insert(f,o?l:r)})}function Wb(e,t){const{writer:i}=t;if(e.parent.is("element","tableCell"))return qb(e)?i.createContainerElement("span",{style:"display:inline-block"}):i.createContainerElement("p")}function qb(e){return 1===e.parent.childCount&&!Qb(e)}function $b(e,t,i){const{cell:n}=e,s=Gb(e,t),o=i.mapper.toViewElement(n);o&&o.name!==s&&function(e,t,i){const n=i.writer,s=i.mapper.toViewElement(e),o=nm(n.createEditableElement(t,s.getAttributes()),n);tm(o,n,(e,t,i)=>i.addClass(en(t.classes),e),(e,t,i)=>i.removeClass(en(t.classes),e)),n.insert(n.createPositionAfter(s),o),n.move(n.createRangeIn(s),n.createPositionAt(o,0)),n.remove(n.createRangeOn(s)),i.mapper.unbindViewElement(s),i.mapper.bindElements(e,o)}(n,s,i)}function Ub(e,t,i,n,s){const o=s&&s.asWidget,r=Gb(e,t),a=o?nm(n.writer.createEditableElement(r),n.writer):n.writer.createContainerElement(r);o&&tm(a,n.writer,(e,t,i)=>i.addClass(en(t.classes),e),(e,t,i)=>i.removeClass(en(t.classes),e));const l=e.cell,c=l.getChild(0),h=1===l.childCount&&"paragraph"===c.name;if(n.writer.insert(i,a),n.mapper.bindElements(l,a),!o&&h&&!Qb(c)){const e=l.getChild(0);n.consumable.consume(e,"insert"),n.mapper.bindElements(e,a)}}function Kb(e,t,i,n,s){s.consumable.consume(t,"insert");const o=t.isEmpty?s.writer.createEmptyElement("tr"):s.writer.createContainerElement("tr");s.mapper.bindElements(t,o);const r=n.headingRows,a=function(e,t,i){const n=Jb(e,t);return n||function(e,t,i){const n=i.writer.createContainerElement(e),s=i.writer.createPositionAt(t,"tbody"==e?"end":0);return i.writer.insert(s,n),n}(e,t,i)}(function(e,t){return e<t.headingRows?"thead":"tbody"}(i,n),e,s),l=r>0&&i>=r?i-r:i,c=s.writer.createPositionAt(a,l);return s.writer.insert(c,o),o}function Gb(e,t){const{row:i,column:n}=e,{headingColumns:s,headingRows:o}=t;if(o&&o>i)return"th";return s&&s>n?"th":"td"}function Jb(e,t){for(const i of t.getChildren())if(i.name==e)return i}function Yb(e,t,i){const n=Jb(e,t);n&&0===n.childCount&&i.writer.remove(i.writer.createRangeOn(n))}function Qb(e){return!![...e.getAttributeKeys()].length}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xb extends Xe{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema;this.isEnabled=function(e,t){const i=e.getFirstPosition().parent,n=i===i.root?i:i.parent;return t.checkChild(n,"table")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,i)&&!om(t,i)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=this.editor.plugins.get("TableUtils"),s=sm(i,t);t.change(i=>{const o=n.createTable(i,e);t.insertContent(o,s),i.setSelection(i.createPositionAt(o.getNodeByPath([0,0,0]),0))})}}function Zb(e){const t=[];for(const i of o_(e.getRanges())){const e=i.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}function e_(e){const t=[];for(const i of e.getRanges()){const e=i.start.findAncestor("tableCell");e&&t.push(e)}return t}function t_(e){const t=Zb(e);return t.length?t:e_(e)}function i_(e){return r_(e.map(e=>e.parent.index))}function n_(e){const t=e[0].findAncestor("table");return r_([...new Lb(t)].filter(t=>e.includes(t.cell)).map(e=>e.column))}function s_(e,t){if(e.length<2||!function(e){const t=e[0].findAncestor("table"),i=i_(e),n=parseInt(t.getAttribute("headingRows")||0);if(!l_(i,n))return!1;const s=parseInt(t.getAttribute("headingColumns")||0);return l_(n_(e),s)}(e))return!1;const i=new Set,n=new Set;let s=0;for(const o of e){const{row:e,column:r}=t.getCellLocation(o),a=parseInt(o.getAttribute("rowspan")||1),l=parseInt(o.getAttribute("colspan")||1);i.add(e),n.add(r),a>1&&i.add(e+a-1),l>1&&n.add(r+l-1),s+=a*l}return function(e,t){const i=Array.from(e.values()),n=Array.from(t.values()),s=Math.max(...i),o=Math.min(...i),r=Math.max(...n),a=Math.min(...n);return(s-o+1)*(r-a+1)}(i,n)==s}function o_(e){return Array.from(e).sort(a_)}function r_(e){const t=e.sort((e,t)=>e-t);return{first:t[0],last:t[t.length-1]}}function a_(e,t){const i=e.start,n=t.start;return i.isBefore(n)?-1:1}function l_({first:e,last:t},i){return e<i===t<i}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class c_ extends Xe{constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="above"===this.order,s=t_(t),o=i_(s),r=n?o.first:o.last,a=s[0].findAncestor("table");i.insertRows(a,{at:n?r:r+1,copyStructureFromAbove:!n})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class h_ extends Xe{constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="left"===this.order,s=t_(t),o=n_(s),r=n?o.first:o.last,a=s[0].findAncestor("table");i.insertColumns(a,{columns:1,at:n?r:r+1})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class d_ extends Xe{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=t_(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=t_(this.editor.model.document.selection)[0],t="horizontally"===this.direction,i=this.editor.plugins.get("TableUtils");t?i.splitCellHorizontally(e,2):i.splitCellVertically(e,2)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function u_(e,t,i){const{startRow:n,startColumn:s,endRow:o,endColumn:r}=t,a=i.createElement("table"),l=o-n+1;for(let e=0;e<l;e++)i.insertElement("tableRow",a,"end");const c=[...new Lb(e,{startRow:n,endRow:o,startColumn:s,endColumn:r,includeAllSlots:!0})];for(const{row:e,column:t,cell:l,isAnchor:h,cellAnchorRow:d,cellAnchorColumn:u}of c){const c=e-n,m=a.getChild(c);if(h){const n=i.cloneElement(l);i.append(n,m),w_(n,e,t,o,r,i)}else(d<n||u<s)&&Mb(i,i.createPositionAt(m,"end"))}return function(e,t,i,n,s){const o=parseInt(t.getAttribute("headingRows")||0);if(o>0){Nb("headingRows",o-i,e,s,0)}const r=parseInt(t.getAttribute("headingColumns")||0);if(r>0){Nb("headingColumns",r-n,e,s,0)}}(a,e,n,s,i),a}function m_(e,t,i=0){const n=[],s=new Lb(e,{startRow:i,endRow:t-1});for(const e of s){const{row:i,cellHeight:s}=e,o=i+s-1;i<t&&t<=o&&n.push(e)}return n}function f_(e,t,i){const n=e.parent,s=n.parent,o=n.index,r=t-o,a={},l=parseInt(e.getAttribute("rowspan"))-r;l>1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||1);c>1&&(a.colspan=c);const h=o+r,d=[...new Lb(s,{startRow:o,endRow:h,includeAllSlots:!0})];let u,m=null;for(const t of d){const{row:n,column:s,cell:o}=t;o===e&&void 0===u&&(u=s),void 0!==u&&u===s&&n===h&&(m=Mb(i,t.getPositionBefore(),a))}return Nb("rowspan",r,e,i),m}function g_(e,t){const i=[],n=new Lb(e);for(const e of n){const{column:n,cellWidth:s}=e,o=n+s-1;n<t&&t<=o&&i.push(e)}return i}function p_(e,t,i,n){const s=i-t,o={},r=parseInt(e.getAttribute("colspan"))-s;r>1&&(o.colspan=r);const a=parseInt(e.getAttribute("rowspan")||1);a>1&&(o.rowspan=a);const l=Mb(n,n.createPositionAfter(e),o);return Nb("colspan",s,e,n),l}function w_(e,t,i,n,s,o){const r=parseInt(e.getAttribute("colspan")||1),a=parseInt(e.getAttribute("rowspan")||1);if(i+r-1>s){Nb("colspan",s-i+1,e,o,1)}if(t+a-1>n){Nb("rowspan",n-t+1,e,o,1)}}function b_(e,t){const i=t.getColumns(e),n=new Array(i).fill(0);for(const{column:t}of new Lb(e))n[t]++;const s=n.reduce((e,t,i)=>t?e:[...e,i],[]);if(s.length>0){const i=s[s.length-1];return t.removeColumns(e,{at:i}),!0}return!1}function __(e,t){const i=[];for(let t=0;t<e.childCount;t++){e.getChild(t).isEmpty&&i.push(t)}if(i.length>0){const n=i[i.length-1];return t.removeRows(e,{at:n}),!0}return!1}function v_(e,t){b_(e,t)||__(e,t)}function y_(e,t){const i=Array.from(new Lb(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(i.every(({cellHeight:e})=>1===e))return t.lastRow;const n=i[0].cellHeight-1;return t.lastRow+n}function k_(e,t){const i=Array.from(new Lb(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(i.every(({cellWidth:e})=>1===e))return t.lastColumn;const n=i[0].cellWidth-1;return t.lastColumn+n}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class C_ extends Xe{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e_(e.document.selection)[0],i=this.value,n=this.direction;e.change(e=>{const s="right"==n||"down"==n,o=s?t:i,r=s?i:t,a=r.parent;!function(e,t,i){A_(e)||(A_(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end")));i.remove(e)}(r,o,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(t.getAttribute(l)||1),h=parseInt(i.getAttribute(l)||1);e.setAttribute(l,c+h,o),e.setSelection(e.createRangeIn(o));const d=this.editor.plugins.get("TableUtils");v_(a.findAncestor("table"),d)})}_getMergeableCell(){const e=e_(this.editor.model.document.selection)[0];if(!e)return;const t=this.editor.plugins.get("TableUtils"),i=this.isHorizontal?function(e,t,i){const n=e.parent.parent,s="right"==t?e.nextSibling:e.previousSibling,o=(n.getAttribute("headingColumns")||0)>0;if(!s)return;const r="right"==t?e:s,a="right"==t?s:e,{column:l}=i.getCellLocation(r),{column:c}=i.getCellLocation(a),h=parseInt(r.getAttribute("colspan")||1),d=Bb(i,r),u=Bb(i,a);if(o&&d!=u)return;return l+h===c?s:void 0}(e,this.direction,t):function(e,t){const i=e.parent,n=i.parent,s=n.getChildIndex(i);if("down"==t&&s===n.childCount-1||"up"==t&&0===s)return;const o=parseInt(e.getAttribute("rowspan")||1),r=n.getAttribute("headingRows")||0,a="down"==t&&s+o===r,l="up"==t&&s===r;if(r&&(a||l))return;const c=parseInt(e.getAttribute("rowspan")||1),h="down"==t?s+c:s,d=[...new Lb(n,{endRow:h})],u=d.find(t=>t.cell===e).column,m=d.find(({row:e,cellHeight:i,column:n})=>n===u&&("down"==t?e===h:h===e+i));return m&&m.cell}(e,this.direction);if(!i)return;const n=this.isHorizontal?"rowspan":"colspan",s=parseInt(e.getAttribute(n)||1);return parseInt(i.getAttribute(n)||1)===s?i:void 0}}function A_(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class x_ extends Xe{refresh(){const e=t_(this.editor.model.document.selection),t=e[0];if(t){const i=t.findAncestor("table"),n=this.editor.plugins.get("TableUtils").getRows(i)-1,s=i_(e),o=0===s.first&&s.last===n;this.isEnabled=!o}else this.isEnabled=!1}execute(){const e=this.editor.model,t=t_(e.document.selection),i=i_(t),n=t[0],s=n.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getCellLocation(n).column;e.change(e=>{const t=i.last-i.first+1;this.editor.plugins.get("TableUtils").removeRows(s,{at:i.first,rows:t});const n=function(e,t,i){const n=e.getChild(t)||e.getChild(e.childCount-1);let s=n.getChild(0),o=0;for(const e of n.getChildren()){if(o>i)return s;s=e,o+=parseInt(e.getAttribute("colspan")||1)}return s}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(s,i.first,o);e.setSelection(e.createPositionAt(n,0))})}}class T_ extends Xe{refresh(){const e=t_(this.editor.model.document.selection),t=e[0];if(t){const i=t.findAncestor("table"),n=this.editor.plugins.get("TableUtils").getColumns(i),{first:s,last:o}=n_(e);this.isEnabled=o-s<n-1}else this.isEnabled=!1}execute(){const[e,t]=function(e){const t=t_(e),i=t[0],n=t.pop(),s=[i,n];return i.isBefore(n)?s:s.reverse()}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.editor.model.document.selection),i=e.parent.parent,n=[...new Lb(i)],s={first:n.find(t=>t.cell===e).column,last:n.find(e=>e.cell===t).column},o=function(e,t,i,n){return parseInt(i.getAttribute("colspan")||1)>1?i:t.previousSibling||i.nextSibling?i.nextSibling||t.previousSibling:n.first?e.reverse().find(({column:e})=>e<n.first).cell:e.reverse().find(({column:e})=>e>n.last).cell}(n,e,t,s);this.editor.model.change(e=>{const t=s.last-s.first+1;this.editor.plugins.get("TableUtils").removeColumns(i,{at:s.first,columns:t}),e.setSelection(e.createPositionAt(o,0))})}}class P_ extends Xe{refresh(){const e=t_(this.editor.model.document.selection),t=e.length>0;this.isEnabled=t,this.value=t&&e.every(e=>this._isInHeading(e,e.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.model,i=t_(t.document.selection),n=i[0].findAncestor("table"),{first:s,last:o}=i_(i),r=this.value?s:o+1,a=n.getAttribute("headingRows")||0;t.change(e=>{if(r){const t=m_(n,r,r>a?a:0);for(const{cell:i}of t)f_(i,r,e)}Nb("headingRows",r,n,e,0)})}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||0);return!!i&&e.parent.index<i}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class E_ extends Xe{refresh(){const e=t_(this.editor.model.document.selection),t=this.editor.plugins.get("TableUtils"),i=e.length>0;this.isEnabled=i,this.value=i&&e.every(e=>Bb(t,e))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.model,i=t_(t.document.selection),n=i[0].findAncestor("table"),{first:s,last:o}=n_(i),r=this.value?s:o+1;t.change(e=>{if(r){const t=g_(n,r);for(const{cell:i,column:n}of t)p_(i,n,r,e)}Nb("headingColumns",r,n,e,0)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class S_ extends Ye{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,i=t.parent,n=i.getChildIndex(t),s=new Lb(i,{row:n});for(const{cell:t,row:i,column:n}of s)if(t===e)return{row:i,column:n}}createTable(e,t){const i=e.createElement("table");return R_(e,i,0,parseInt(t.rows)||2,parseInt(t.columns)||2),t.headingRows&&Nb("headingRows",t.headingRows,i,e,0),t.headingColumns&&Nb("headingColumns",t.headingColumns,i,e,0),i}insertRows(e,t={}){const i=this.editor.model,n=t.at||0,s=t.rows||1,o=void 0!==t.copyStructureFromAbove,r=t.copyStructureFromAbove?n-1:n,a=this.getRows(e),l=this.getColumns(e);i.change(t=>{const i=e.getAttribute("headingRows")||0;if(i>n&&Nb("headingRows",i+s,e,t,0),!o&&(0===n||n===a))return void R_(t,e,n,s,l);const c=o?Math.max(n,r):n,h=new Lb(e,{endRow:c}),d=new Array(l).fill(1);for(const{row:e,column:i,cellHeight:a,cellWidth:l,cell:c}of h){const h=e+a-1,u=e<=r&&r<=h;e<n&&n<=h?(t.setAttribute("rowspan",a+s,c),d[i]=-l):o&&u&&(d[i]=l)}for(let i=0;i<s;i++){const i=t.createElement("tableRow");t.insert(i,e,n);for(let e=0;e<d.length;e++){const n=d[e],s=t.createPositionAt(i,"end");n>0&&Mb(t,s,n>1?{colspan:n}:null),e+=Math.abs(n)-1}}})}insertColumns(e,t={}){const i=this.editor.model,n=t.at||0,s=t.columns||1;i.change(t=>{const i=e.getAttribute("headingColumns");n<i&&t.setAttribute("headingColumns",i+s,e);const o=this.getColumns(e);if(0===n||o===n){for(const i of e.getChildren())I_(s,t,t.createPositionAt(i,n?"end":0));return}const r=new Lb(e,{column:n,includeAllSlots:!0});for(const e of r){const{row:i,cell:o,cellAnchorColumn:a,cellAnchorRow:l,cellWidth:c,cellHeight:h}=e;if(a<n){t.setAttribute("colspan",c+s,o);const e=l+h-1;for(let t=i;t<=e;t++)r.skipRow(t)}else I_(s,t,e.getPositionBefore())}})}removeRows(e,t){const i=this.editor.model,n=t.rows||1,s=t.at,o=s+n-1;i.change(t=>{const{cellsToMove:i,cellsToTrim:n}=function(e,t,i){const n=new Map,s=[];for(const{row:o,column:r,cellHeight:a,cell:l}of new Lb(e,{endRow:i})){const e=o+a-1;if(o>=t&&o<=i&&e>i){const e=a-(i-o+1);n.set(r,{cell:l,rowspan:e})}if(o<t&&e>=t){let n;n=e>=i?i-t+1:e-t+1,s.push({cell:l,rowspan:a-n})}}return{cellsToMove:n,cellsToTrim:s}}(e,s,o);if(i.size){!function(e,t,i,n){const s=[...new Lb(e,{includeAllSlots:!0,row:t})],o=e.getChild(t);let r;for(const{column:e,cell:t,isAnchor:a}of s)if(i.has(e)){const{cell:t,rowspan:s}=i.get(e),a=r?n.createPositionAfter(r):n.createPositionAt(o,0);n.move(n.createRangeOn(t),a),Nb("rowspan",s,t,n),r=t}else a&&(r=t)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e,o+1,i,t)}for(let i=o;i>=s;i--)t.remove(e.getChild(i));for(const{rowspan:e,cell:i}of n)Nb("rowspan",e,i,t);!function(e,t,i,n){const s=e.getAttribute("headingRows")||0;if(t<s){Nb("headingRows",i<s?s-(i-t+1):t,e,n,0)}}(e,s,o,t),b_(e,this)||__(e,this)})}removeColumns(e,t){const i=this.editor.model,n=t.at,s=t.columns||1,o=t.at+s-1;i.change(t=>{!function(e,t,i){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const s=Math.min(n-1,t.last)-t.first+1;i.setAttribute("headingColumns",n-s,e)}}(e,{first:n,last:o},t);for(let i=o;i>=n;i--)for(const{cell:n,column:s,cellWidth:o}of[...new Lb(e)])s<=i&&o>1&&s+o>i?Nb("colspan",o-1,n,t):s===i&&t.remove(n);__(e,this)||b_(e,this)})}splitCellVertically(e,t=2){const i=this.editor.model,n=e.parent.parent,s=parseInt(e.getAttribute("rowspan")||1),o=parseInt(e.getAttribute("colspan")||1);i.change(i=>{if(o>1){const{newCellsSpan:n,updatedSpan:r}=V_(o,t);Nb("colspan",r,e,i);const a={};n>1&&(a.colspan=n),s>1&&(a.rowspan=s);I_(o>t?t-1:o-1,i,i.createPositionAfter(e),a)}if(o<t){const r=t-o,a=[...new Lb(n)],{column:l}=a.find(({cell:t})=>t===e),c=a.filter(({cell:t,cellWidth:i,column:n})=>t!==e&&n===l||n<l&&n+i>l);for(const{cell:e,cellWidth:t}of c)i.setAttribute("colspan",t+r,e);const h={};s>1&&(h.rowspan=s),I_(r,i,i.createPositionAfter(e),h);const d=n.getAttribute("headingColumns")||0;d>l&&Nb("headingColumns",d+r,n,i)}})}splitCellHorizontally(e,t=2){const i=this.editor.model,n=e.parent,s=n.parent,o=s.getChildIndex(n),r=parseInt(e.getAttribute("rowspan")||1),a=parseInt(e.getAttribute("colspan")||1);i.change(i=>{if(r>1){const n=[...new Lb(s,{startRow:o,endRow:o+r-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=V_(r,t);Nb("rowspan",c,e,i);const{column:h}=n.find(({cell:t})=>t===e),d={};l>1&&(d.rowspan=l),a>1&&(d.colspan=a);for(const e of n){const{column:t,row:n}=e,s=t===h,r=(n+o+c)%l==0;n>=o+c&&s&&r&&I_(1,i,e.getPositionBefore(),d)}}if(r<t){const n=t-r,l=[...new Lb(s,{startRow:0,endRow:o})];for(const{cell:t,cellHeight:s,row:r}of l)if(t!==e&&r+s>o){const e=s+n;i.setAttribute("rowspan",e,t)}const c={};a>1&&(c.colspan=a),R_(i,s,o+1,n,1,c);const h=s.getAttribute("headingRows")||0;h>o&&Nb("headingRows",h+n,s,i)}})}getColumns(e){return[...e.getChild(0).getChildren()].reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||1),0)}getRows(e){return e.childCount}}function R_(e,t,i,n,s,o={}){for(let r=0;r<n;r++){const n=e.createElement("tableRow");e.insert(n,t,i),I_(s,e,e.createPositionAt(n,"end"),o)}}function I_(e,t,i,n={}){for(let s=0;s<e;s++)Mb(t,i,n)}function V_(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const i=Math.floor(e/t);return{newCellsSpan:i,updatedSpan:e-i*t+i}}class O_ extends Xe{refresh(){const e=Zb(this.editor.model.document.selection);this.isEnabled=s_(e,this.editor.plugins.get(S_))}execute(){const e=this.editor.model,t=this.editor.plugins.get(S_);e.change(i=>{const n=Zb(e.document.selection),s=n.shift(),{mergeWidth:o,mergeHeight:r}=function(e,t,i){let n=0,s=0;for(const e of t){const{row:t,column:o}=i.getCellLocation(e);n=B_(e,o,n,"colspan"),s=B_(e,t,s,"rowspan")}const{row:o,column:r}=i.getCellLocation(e);return{mergeWidth:n-r,mergeHeight:s-o}}(s,n,t);Nb("colspan",o,s,i),Nb("rowspan",r,s,i);for(const e of n)N_(e,s,i);v_(s.findAncestor("table"),t),i.setSelection(s,"in")})}}function N_(e,t,i){M_(e)||(M_(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}function M_(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}function B_(e,t,i,n){const s=parseInt(e.getAttribute(n)||1);return Math.max(i,t+s)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class F_ extends Xe{refresh(){const e=t_(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=t_(e.document.selection),i=i_(t),n=t[0].findAncestor("table"),s=[];for(let t=i.first;t<=i.last;t++)for(const i of n.getChild(t).getChildren())s.push(e.createRangeOn(i));e.change(e=>{e.setSelection(s)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class D_ extends Xe{refresh(){const e=t_(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=t_(e.document.selection),i=t[0],n=t.pop(),s=i.findAncestor("table"),o=this.editor.plugins.get("TableUtils"),r=o.getCellLocation(i),a=o.getCellLocation(n),l=Math.min(r.column,a.column),c=Math.max(r.column,a.column),h=[];for(const t of new Lb(s,{startColumn:l,endColumn:c}))h.push(e.createRangeOn(t.cell));e.change(e=>{e.setSelection(h)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function z_(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;const s=new Set;for(const t of i){let i;"table"==t.name&&"insert"==t.type&&(i=t.position.nodeAfter),"tableRow"!=t.name&&"tableCell"!=t.name||(i=t.position.findAncestor("table")),j_(t)&&(i=t.range.start.findAncestor("table")),i&&!s.has(i)&&(n=L_(i,e)||n,n=H_(i,e)||n,s.add(i))}return n}(t,e))}function L_(e,t){let i=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||0),i=e.childCount,n=[];for(const{row:s,cell:o,cellHeight:r}of new Lb(e)){if(r<2)continue;const e=s<t?t:i;if(s+r>e){const t=e-s;n.push({cell:o,rowspan:t})}}return n}(e);if(n.length){i=!0;for(const e of n)Nb("rowspan",e.rowspan,e.cell,t,1)}return i}function H_(e,t){let i=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{row:i}of new Lb(e,{includeAllSlots:!0}))t[i]++;return t}(e),s=[];for(const[e,t]of n.entries())t||s.push(e);if(s.length){i=!0;for(const i of s.reverse())t.remove(e.getChild(i)),n.splice(i,1)}const o=n[0];if(!n.every(e=>e===o)){const s=n.reduce((e,t)=>t>e?t:e,0);for(const[o,r]of n.entries()){const n=s-r;if(n){for(let i=0;i<n;i++)Mb(t,t.createPositionAt(e.getChild(o),"end"));i=!0}}}return i}function j_(e){const t="attribute"===e.type,i=e.attributeKey;return t&&("headingRows"===i||"colspan"===i||"rowspan"===i)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function W_(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i)"insert"==t.type&&"table"==t.name&&(n=q_(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=$_(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=U_(t.position.nodeAfter,e)||n),K_(t)&&(n=U_(t.position.parent,e)||n);return n}(t,e))}function q_(e,t){let i=!1;for(const n of e.getChildren())i=$_(n,t)||i;return i}function $_(e,t){let i=!1;for(const n of e.getChildren())i=U_(n,t)||i;return i}function U_(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const i=Array.from(e.getChildren()).filter(e=>e.is("$text"));for(const e of i)t.wrap(t.createRangeOn(e),"paragraph");return!!i.length}function K_(e){return!(!e.position||!e.position.parent.is("element","tableCell"))&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function G_(e,t){e.document.registerPostFixer(()=>function(e,t){const i=new Set;for(const t of e.getChanges()){const e="attribute"==t.type?t.range.start.parent:t.position.parent;e.is("element","tableCell")&&i.add(e)}for(const n of i.values())for(const i of[...n.getChildren()].filter(e=>J_(e,t)))e.refreshItem(i);return!1}(e.document.differ,t))}function J_(e,t){if(!e.is("element","paragraph"))return!1;const i=t.toViewElement(e);return!!i&&qb(e)!==i.is("element","span")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Y_(e){e.document.registerPostFixer(()=>function(e){const t=e.document.differ,i=new Set;for(const e of t.getChanges()){if("attribute"!=e.type)continue;const t=e.range.start.nodeAfter;t&&t.is("element","table")&&"headingRows"==e.attributeKey&&i.add(t)}if(i.size){for(const e of i.values())t.refreshItem(e);return!0}return!1}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e))}class Q_ extends Ye{static get pluginName(){return"TableEditing"}init(){const e=this.editor,t=e.model,i=t.schema,n=e.conversion;i.register("table",{allowWhere:"$block",allowAttributes:["headingRows","headingColumns"],isObject:!0,isBlock:!0}),i.register("tableRow",{allowIn:"table",isLimit:!0}),i.register("tableCell",{allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),i.extend("$block",{allowIn:"tableCell"}),n.for("upcast").add(Fb()),n.for("editingDowncast").add(jb({asWidget:!0})),n.for("dataDowncast").add(jb()),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add(e=>{e.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()},{priority:"high"})}),n.for("editingDowncast").add(e=>e.on("insert:tableRow",(e,t,i)=>{const n=t.item;if(!i.consumable.consume(n,"insert"))return;const s=n.parent,o=function(e){for(const t of e.getChildren())if("table"===t.name)return t}(i.mapper.toViewElement(s)),r=s.getChildIndex(n),a=new Lb(s,{row:r}),l={headingRows:s.getAttribute("headingRows")||0,headingColumns:s.getAttribute("headingColumns")||0},c=new Map;for(const e of a){const t=c.get(r)||Kb(o,n,r,l,i);c.set(r,t),i.consumable.consume(e.cell,"insert"),Ub(e,l,i.writer.createPositionAt(t,"end"),i,{asWidget:!0})}})),n.for("editingDowncast").add(e=>e.on("remove:tableRow",(e,t,i)=>{e.stop();const n=i.writer,s=i.mapper,o=s.toViewPosition(t.position).getLastMatchingPosition(e=>!e.item.is("element","tr")).nodeAfter,r=o.parent.parent,a=n.createRangeOn(o),l=n.remove(a);for(const e of n.createRangeIn(l).getItems())s.unbindViewElement(e);Yb("thead",r,i),Yb("tbody",r,i)},{priority:"higher"})),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(Db("td")),n.for("upcast").add(Db("th")),n.for("editingDowncast").add(e=>e.on("insert:tableCell",(e,t,i)=>{const n=t.item;if(!i.consumable.consume(n,"insert"))return;const s=n.parent,o=s.parent,r=o.getChildIndex(s),a=new Lb(o,{row:r}),l={headingRows:o.getAttribute("headingRows")||0,headingColumns:o.getAttribute("headingColumns")||0};for(const e of a)if(e.cell===n){const t=i.mapper.toViewElement(s);return void Ub(e,l,i.writer.createPositionAt(t,s.getChildIndex(n)),i,{asWidget:!0})}})),e.conversion.for("editingDowncast").elementToElement({model:"paragraph",view:Wb,converterPriority:"high"}),n.attributeToAttribute({model:"colspan",view:"colspan"}),n.attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("editingDowncast").add(e=>e.on("attribute:headingColumns:table",(e,t,i)=>{const n=t.item;if(!i.consumable.consume(t.item,e.name))return;const s={headingRows:n.getAttribute("headingRows")||0,headingColumns:n.getAttribute("headingColumns")||0},o=t.attributeOldValue,r=t.attributeNewValue,a=(o>r?o:r)-1;for(const e of new Lb(n,{endColumn:a}))$b(e,s,i)})),e.commands.add("insertTable",new Xb(e)),e.commands.add("insertTableRowAbove",new c_(e,{order:"above"})),e.commands.add("insertTableRowBelow",new c_(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new h_(e,{order:"left"})),e.commands.add("insertTableColumnRight",new h_(e,{order:"right"})),e.commands.add("removeTableRow",new x_(e)),e.commands.add("removeTableColumn",new T_(e)),e.commands.add("splitTableCellVertically",new d_(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new d_(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new O_(e)),e.commands.add("mergeTableCellRight",new C_(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new C_(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new C_(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new C_(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new E_(e)),e.commands.add("setTableRowHeader",new P_(e)),e.commands.add("selectTableRow",new F_(e)),e.commands.add("selectTableColumn",new D_(e)),Y_(t),z_(t),G_(t,e.editing.mapper),W_(t)}static get requires(){return[S_]}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class X_ extends eh{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(e,t)=>`${t} × ${e}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck-insert-table-dropdown__label"]},children:[{text:t.to("label")}]}],on:{mousedown:t.to(e=>{e.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(e,t)=>{const{row:i,column:n}=t.target.dataset;this.set({rows:parseInt(i),columns:parseInt(n)})}),this.on("change:columns",()=>{this._highlightGridBoxes()}),this.on("change:rows",()=>{this._highlightGridBoxes()})}focus(){}focusLast(){}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((i,n)=>{const s=Math.floor(n/10)<e&&n%10<t;i.set("isOn",s)})}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const i=Math.floor(t/10),n=t%10;e.push(new Z_(this.locale,i+1,n+1))}return this.createCollection(e)}}class Z_ extends eh{constructor(e,t,i){super(e);const n=this.bindTemplate;this.set("isOn",!1),this.setTemplate({tag:"div",attributes:{class:["ck-insert-table-dropdown-grid-box",n.if("isOn","ck-on")],"data-row":t,"data-column":i}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ev extends Ye{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,i="ltr"===e.locale.contentLanguageDirection;e.ui.componentFactory.add("insertTable",i=>{const n=e.commands.get("insertTable"),s=Qh(i);let o;return s.bind("isEnabled").to(n),s.buttonView.set({icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',label:t("Insert table"),tooltip:!0}),s.on("change:isOpen",()=>{o||(o=new X_(i),s.panelView.children.add(o),o.delegate("execute").to(s),s.buttonView.on("open",()=>{o.rows=0,o.columns=0}),s.on("execute",()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()}))}),s}),e.ui.componentFactory.add("tableColumn",e=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:i?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:i?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',n,e)}),e.ui.componentFactory.add("tableRow",e=>{const i=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',i,e)}),e.ui.componentFactory.add("mergeTableCells",e=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:i?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:i?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',n,e)})}_prepareDropdown(e,t,i,n){const s=this.editor,o=Qh(n),r=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0}),o.bind("isEnabled").toMany(r,"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(o,"execute",e=>{s.execute(e.source.commandName),s.editing.view.focus()}),o}_prepareMergeSplitButtonDropdown(e,t,i,n){const s=this.editor,o=Qh(n,Nh);return this._fillDropdownWithListOptions(o,i),o.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),this.listenTo(o.buttonView,"execute",()=>{s.execute("mergeTableCells"),s.editing.view.focus()}),this.listenTo(o,"execute",e=>{s.execute(e.source.commandName),s.editing.view.focus()}),o}_fillDropdownWithListOptions(e,t){const i=this.editor,n=[],s=new Xi;for(const e of t)tv(e,i,n,s);return Zh(e,s,i.ui.componentFactory),n}}function tv(e,t,i,n){const s=e.model=new dd(e.model),{commandName:o,bindIsOn:r}=e.model;if("button"===e.type||"switchbutton"===e.type){const e=t.commands.get(o);i.push(e),s.set({commandName:o}),s.bind("isEnabled").to(e),r&&s.bind("isOn").to(e,"value")}s.set({withText:!0}),n.add(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class iv extends Ye{static get pluginName(){return"TableSelection"}static get requires(){return[S_]}init(){const e=this.editor.model;this.listenTo(e,"deleteContent",(e,t)=>this._handleDeleteContent(e,t),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=Zb(this.editor.model.document.selection);return 0==e.length?null:e}getSelectionAsFragment(){const e=this.getSelectedTableCells();return e?this.editor.model.change(t=>{const i=t.createDocumentFragment(),n=this.editor.plugins.get("TableUtils"),{first:s,last:o}=n_(e),{first:r,last:a}=i_(e),l=e[0].findAncestor("table");let c=a,h=o;if(s_(e,n)){const e={firstColumn:s,lastColumn:o,firstRow:r,lastRow:a};c=y_(l,e),h=k_(l,e)}const d=u_(l,{startRow:r,startColumn:s,endRow:c,endColumn:h},t);return t.insert(d,i,0),i}):null}setCellSelection(e,t){const i=this._getCellsToSelect(e,t);this.editor.model.change(e=>{e.setSelection(i.cells.map(t=>e.createRangeOn(t)),{backward:i.backward})})}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=Or(this.editor.model.document.selection.getRanges()).getContainedElement();return e&&e.is("element","tableCell")?e:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(e=>e.on("selection",(e,i,n)=>{const s=n.writer;!function(e){for(const i of t)e.removeClass("ck-editor__editable_selected",i);t.clear()}(s);const o=this.getSelectedTableCells();if(!o)return;for(const e of o){const i=n.mapper.toViewElement(e);s.addClass("ck-editor__editable_selected",i),t.add(i)}const r=n.mapper.toViewElement(o[o.length-1]);s.setSelection(r,0)},{priority:"lowest"}))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(i=>{const n=i.createPositionAt(t[0],0),s=e.model.schema.getNearestSelectionRange(n);i.setSelection(s)})}})}_handleDeleteContent(e,t){const[i,n]=t,s=this.editor.model,o=!n||"backward"==n.direction,r=Zb(i);r.length&&(e.stop(),s.change(e=>{const t=r[o?r.length-1:0];s.change(e=>{for(const t of r)s.deleteContent(e.createSelection(t,"in"))});const n=s.schema.getNearestSelectionRange(e.createPositionAt(t,0));i.is("documentSelection")?e.setSelection(n):i.setTo(n)}))}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),n=i.getCellLocation(e),s=i.getCellLocation(t),o=Math.min(n.row,s.row),r=Math.max(n.row,s.row),a=Math.min(n.column,s.column),l=Math.max(n.column,s.column),c=new Array(r-o+1).fill(null).map(()=>[]),h={startRow:o,endRow:r,startColumn:a,endColumn:l};for(const{row:t,cell:i}of new Lb(e.findAncestor("table"),h))c[t-o].push(i);const d=s.row<n.row,u=s.column<n.column;return d&&c.reverse(),u&&c.forEach(e=>e.reverse()),{cells:c.flat(),backward:d||u}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class nv extends Ye{static get pluginName(){return"TableClipboard"}static get requires(){return[iv,S_]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",(e,t)=>this._onCopyCut(e,t)),this.listenTo(t,"cut",(e,t)=>this._onCopyCut(e,t)),this.listenTo(e.model,"insertContent",(e,t)=>this._onInsertContent(e,...t),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const i=this.editor.plugins.get(iv);if(!i.getSelectedTableCells())return;if("cut"==e.name&&this.editor.isReadOnly)return;t.preventDefault(),e.stop();const n=this.editor.data,s=this.editor.editing.view.document,o=n.toView(i.getSelectionAsFragment());s.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:o,method:e.name})}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const n=this.editor.model,s=this.editor.plugins.get(S_);let o=function(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const i=t.createRangeIn(e);for(const e of i.getItems())if(e.is("element","table")){const n=t.createRange(i.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const s=t.createRange(t.createPositionAfter(e),i.end);return t.hasContent(s,{ignoreWhitespaces:!0})?null:e}return null}(t,n);if(!o)return;const r=t_(n.document.selection);r.length?(e.stop(),n.change(e=>{const t={width:s.getColumns(o),height:s.getRows(o)},i=function(e,t,i,n){const s=e[0].findAncestor("table"),o=n_(e),r=i_(e),a={firstColumn:o.first,lastColumn:o.last,firstRow:r.first,lastRow:r.last},l=1===e.length;l&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,i,n){const s=n.getColumns(e),o=n.getRows(e);i>s&&n.insertColumns(e,{at:s,columns:i-s});t>o&&n.insertRows(e,{at:o,rows:t-o})}(s,a.lastRow+1,a.lastColumn+1,n));l||!s_(e,n)?function(e,t,i){const{firstRow:n,lastRow:s,firstColumn:o,lastColumn:r}=t,a={first:n,last:s},l={first:o,last:r};ov(e,o,a,i),ov(e,r+1,a,i),sv(e,n,l,i),sv(e,s+1,l,i,n)}(s,a,i):(a.lastRow=y_(s,a),a.lastColumn=k_(s,a));return a}(r,t,e,s),n=i.lastRow-i.firstRow+1,a=i.lastColumn-i.firstColumn+1,l={startRow:0,startColumn:0,endRow:Math.min(n,t.height)-1,endColumn:Math.min(a,t.width)-1};o=u_(o,l,e);const c=r[0].findAncestor("table"),h=this._replaceSelectedCellsWithPasted(o,t,c,i,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=o_(h.map(t=>e.createRangeOn(t)));e.setSelection(t)}else e.setSelection(h[0],0)})):v_(o,s)}_replaceSelectedCellsWithPasted(e,t,i,n,s){const{width:o,height:r}=t,a=function(e,t,i){const n=new Array(i).fill(null).map(()=>new Array(t).fill(null));for(const{column:t,row:i,cell:s}of new Lb(e))n[i][t]=s;return n}(e,o,r),l=[...new Lb(i,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let h;for(const e of l){const{row:t,column:i}=e;i===n.firstColumn&&(h=e.getPositionBefore());const l=t-n.firstRow,d=i-n.firstColumn,u=a[l%r][d%o],m=u?s.cloneElement(u):null,f=this._replaceTableSlotCell(e,m,h,s);f&&(w_(f,t,i,n.lastRow,n.lastColumn,s),c.push(f),h=s.createPositionAfter(f))}const d=parseInt(i.getAttribute("headingRows")||0),u=parseInt(i.getAttribute("headingColumns")||0),m=n.firstRow<d&&d<=n.lastRow,f=n.firstColumn<u&&u<=n.lastColumn;if(m){const e=sv(i,d,{first:n.firstColumn,last:n.lastColumn},s,n.firstRow);c.push(...e)}if(f){const e=ov(i,u,{first:n.firstRow,last:n.lastRow},s);c.push(...e)}return c}_replaceTableSlotCell(e,t,i,n){const{cell:s,isAnchor:o}=e;return o&&n.remove(s),t?(n.insert(t,i),t):null}}function sv(e,t,i,n,s=0){if(t<1)return;return m_(e,t,s).filter(({column:e,cellWidth:t})=>rv(e,t,i)).map(({cell:e})=>f_(e,t,n))}function ov(e,t,i,n){if(t<1)return;return g_(e,t).filter(({row:e,cellHeight:t})=>rv(e,t,i)).map(({cell:e,column:i})=>p_(e,i,t,n))}function rv(e,t,i){const n=e+t-1,{first:s,last:o}=i;return e>=s&&e<=o||e<s&&n>=s}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class av extends Ye{static get pluginName(){return"TableKeyboard"}static get requires(){return[iv]}init(){const e=this.editor.editing.view.document;this.editor.keystrokes.set("Tab",(...e)=>this._handleTabOnSelectedTable(...e),{priority:"low"}),this.editor.keystrokes.set("Tab",this._getTabHandler(!0),{priority:"low"}),this.editor.keystrokes.set("Shift+Tab",this._getTabHandler(!1),{priority:"low"}),this.listenTo(e,"arrowKey",(...e)=>this._onArrowKey(...e),{context:"table"})}_handleTabOnSelectedTable(e,t){const i=this.editor,n=i.model.document.selection.getSelectedElement();n&&n.is("element","table")&&(t(),i.model.change(e=>{e.setSelection(e.createRangeIn(n.getChild(0).getChild(0)))}))}_getTabHandler(e){const t=this.editor;return(i,n)=>{let s=e_(t.model.document.selection)[0];if(s||(s=this.editor.plugins.get("TableSelection").getFocusCell()),!s)return;n();const o=s.parent,r=o.parent,a=r.getChildIndex(o),l=o.getChildIndex(s),c=0===l;if(!e&&c&&0===a)return void t.model.change(e=>{e.setSelection(e.createRangeOn(r))});const h=l===o.childCount-1,d=a===r.childCount-1;if(e&&d&&h&&(t.execute("insertTableRowBelow"),a===r.childCount-1))return void t.model.change(e=>{e.setSelection(e.createRangeOn(r))});let u;if(e&&h){const e=r.getChild(a+1);u=e.getChild(0)}else if(!e&&c){const e=r.getChild(a-1);u=e.getChild(e.childCount-1)}else u=o.getChild(l+(e?1:-1));t.model.change(e=>{e.setSelection(e.createRangeIn(u))})}}_onArrowKey(e,t){const i=this.editor,n=Ms(t.keyCode,i.locale.contentLanguageDirection);this._handleArrowKeys(n,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const i=this.editor.model.document.selection,n=["right","down"].includes(e),s=Zb(i);if(s.length){let i;return i=t?this.editor.plugins.get("TableSelection").getFocusCell():n?s[s.length-1]:s[0],this._navigateFromCellInDirection(i,e,t),!0}const o=i.focus.findAncestor("tableCell");return!!o&&(!(t&&!i.isCollapsed&&i.isBackward==n)&&(!!this._isSelectionAtCellEdge(i,o,n)&&(this._navigateFromCellInDirection(o,e,t),!0)))}_isSelectionAtCellEdge(e,t,i){const n=this.editor.model,s=this.editor.model.schema,o=i?e.getLastPosition():e.getFirstPosition();if(!s.getLimitElement(o).is("element","tableCell")){return n.createPositionAt(t,i?"end":0).isTouching(o)}const r=n.createSelection(o);return n.modifySelection(r,{direction:i?"forward":"backward"}),o.isEqual(r.focus)}_navigateFromCellInDirection(e,t,i=!1){const n=this.editor.model,s=e.findAncestor("table"),o=[...new Lb(s,{includeAllSlots:!0})],{row:r,column:a}=o[o.length-1],l=o.find(({cell:t})=>t==e);let{row:c,column:h}=l;switch(t){case"left":h--;break;case"up":c--;break;case"right":h+=l.cellWidth;break;case"down":c+=l.cellHeight}if(c<0||c>r||h<0&&c<=0||h>a&&c>=r)return void n.change(e=>{e.setSelection(e.createRangeOn(s))});h<0?(h=i?0:a,c--):h>a&&(h=i?a:0,c++);const d=o.find(e=>e.row==c&&e.column==h).cell,u=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(i&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,d)}else{const e=n.createPositionAt(d,u?0:"end");n.change(t=>{t.setSelection(e)})}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lv extends tr{constructor(e){super(e),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cv extends Ye{static get pluginName(){return"TableMouse"}static get requires(){return[iv]}init(){this.editor.editing.view.addObserver(lv),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor;let t=!1;const i=e.plugins.get(iv);this.listenTo(e.editing.view.document,"mousedown",(n,s)=>{if(!this.isEnabled||!i.isEnabled)return;if(!s.domEvent.shiftKey)return;const o=i.getAnchorCell()||e_(e.model.document.selection)[0];if(!o)return;const r=this._getModelTableCellFromDomEvent(s);r&&hv(o,r)&&(t=!0,i.setCellSelection(o,r),s.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{t=!1}),this.listenTo(e.editing.view.document,"selectionChange",e=>{t&&e.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,i,n=!1,s=!1;const o=e.plugins.get(iv);this.listenTo(e.editing.view.document,"mousedown",(e,i)=>{this.isEnabled&&o.isEnabled&&(i.domEvent.shiftKey||i.domEvent.ctrlKey||i.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(i)))}),this.listenTo(e.editing.view.document,"mousemove",(e,r)=>{if(!r.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(r);a&&hv(t,a)&&(i=a,n||i==t||(n=!0)),n&&(s=!0,o.setCellSelection(t,i),r.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1,s=!1,t=null,i=null}),this.listenTo(e.editing.view.document,"selectionChange",e=>{s&&e.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,i=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(i).parent.findAncestor("tableCell",{includeSelf:!0})}}function hv(e,t){return e.parent.parent==t.parent.parent}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function dv(e){const t=e.getSelectedElement();return t&&mv(t)?t:null}function uv(e){const t=function(e,t){let i=t.parent;for(;i;){if(i.name===e)return i;i=i.parent}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */("table",e.getFirstPosition());return t&&mv(t.parent)?t.parent:null}function mv(e){return!!e.getCustomProperty("table")&&Qu(e)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function fv(e,t,i,n){e.for("upcast").attributeToAttribute({view:{styles:{[n]:/[\s\S]+/}},model:{name:t,key:i,value:e=>e.getNormalizedStyle(n)}})}function gv(e,t){e.for("upcast").add(e=>e.on("element:"+t,(e,t,i)=>{if(!t.modelRange)return;const n=["border-top","border-right","border-bottom","border-left"].filter(e=>t.viewItem.hasStyle(e));if(!n.length)return;const s={styles:n};if(!i.consumable.test(t.viewItem,s))return;const o=[...t.modelRange.getItems({shallow:!0})].pop();i.consumable.consume(t.viewItem,s),i.writer.setAttribute("borderStyle",t.viewItem.getNormalizedStyle("border-style"),o),i.writer.setAttribute("borderColor",t.viewItem.getNormalizedStyle("border-color"),o),i.writer.setAttribute("borderWidth",t.viewItem.getNormalizedStyle("border-width"),o)}))}function pv(e,t,i,n){e.for("downcast").attributeToAttribute({model:{name:t,key:i},view:e=>({key:"style",value:{[n]:e}})})}function wv(e,t,i){e.for("downcast").add(e=>e.on(`attribute:${t}:table`,(e,t,n)=>{const{item:s,attributeNewValue:o}=t,{mapper:r,writer:a}=n;if(!n.consumable.consume(t.item,e.name))return;const l=[...r.toViewElement(s).getChildren()].find(e=>e.is("element","table"));o?a.setStyle(i,o,l):a.removeStyle(i,l)}))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bv extends Xe{constructor(e,t){super(e),this.attributeName=t}refresh(){const e=this.editor.model.document.selection.getFirstPosition().findAncestor("table");this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,i=t.document.selection,{value:n,batch:s}=e,o=i.getFirstPosition().findAncestor("table"),r=this._getValueToSet(n);t.enqueueChange(s||"default",e=>{r?e.setAttribute(this.attributeName,r,o):e.removeAttribute(this.attributeName,o)})}_getValue(e){if(e)return e.getAttribute(this.attributeName)}_getValueToSet(e){return e}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _v extends bv{constructor(e){super(e,"backgroundColor")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function vv(e){if(!e||!b(e))return e;const{top:t,right:i,bottom:n,left:s}=e;return t==i&&i==n&&n==s?t:void 0}function yv(e,t){const i=parseFloat(e);return Number.isNaN(i)||String(i)!==String(e)?e:`${i}${t}`}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kv extends bv{constructor(e){super(e,"borderColor")}_getValue(e){if(e)return vv(e.getAttribute(this.attributeName))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cv extends bv{constructor(e){super(e,"borderStyle")}_getValue(e){if(e)return vv(e.getAttribute(this.attributeName))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Av extends bv{constructor(e){super(e,"borderWidth")}_getValue(e){if(e)return vv(e.getAttribute(this.attributeName))}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xv extends bv{constructor(e){super(e,"width")}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tv extends bv{constructor(e){super(e,"height")}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pv extends bv{constructor(e){super(e,"alignment")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ev=/^(left|right)$/;class Sv extends Ye{static get pluginName(){return"TablePropertiesEditing"}static get requires(){return[Q_]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.data.addStyleProcessorRules(wu),function(e,t){e.extend("table",{allowAttributes:["borderWidth","borderColor","borderStyle"]}),gv(t,"table"),wv(t,"borderColor","border-color"),wv(t,"borderStyle","border-style"),wv(t,"borderWidth","border-width")}(t,i),e.commands.add("tableBorderColor",new kv(e)),e.commands.add("tableBorderStyle",new Cv(e)),e.commands.add("tableBorderWidth",new Av(e)),function(e,t){e.extend("table",{allowAttributes:["alignment"]}),t.attributeToAttribute({model:{name:"table",key:"alignment",values:["left","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}}},converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{attributes:{align:Ev}},model:{name:"table",key:"alignment",value:e=>e.getAttribute("align")}})}(t,i),e.commands.add("tableAlignment",new Pv(e)),Rv(t,i,"width","width"),e.commands.add("tableWidth",new xv(e)),Rv(t,i,"height","height"),e.commands.add("tableHeight",new Tv(e)),e.data.addStyleProcessorRules(gu),function(e,t,i,n){e.extend("table",{allowAttributes:[i]}),fv(t,"table",i,n),wv(t,i,n)}(t,i,"backgroundColor","background-color"),e.commands.add("tableBackgroundColor",new _v(e))}}function Rv(e,t,i,n){e.extend("table",{allowAttributes:[i]}),fv(t,"table",i,n),pv(t,"table",i,n)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Iv extends eh{constructor(e,t){super(e);const i=this.bindTemplate;this.set("value",""),this.set("id"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.set("ariaDescribedById"),this.options=t,this._dropdownView=this._createDropdownView(e),this._inputView=this._createInputTextView(e),this._stillTyping=!1,this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color",i.if("hasError","ck-error")],id:i.to("id"),"aria-invalid":i.if("hasError",!0),"aria-describedby":i.to("ariaDescribedById")},children:[this._dropdownView,this._inputView]}),this.on("change:value",(e,t,i)=>this._setInputValue(i))}focus(){this._inputView.focus()}_createDropdownView(){const e=this.locale,t=e.t,i=this.bindTemplate,n=this._createColorGrid(e),s=Qh(e),o=new eh,r=this._createRemoveColorButton(e);return o.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:i.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",i.if("value","ck-hidden",e=>""!=e)]}}]}),s.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),s.buttonView.children.add(o),s.buttonView.tooltip=t("Color picker"),s.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",s.panelView.children.add(r),s.panelView.children.add(n),s.bind("isEnabled").to(this,"isReadOnly",e=>!e),s}_createInputTextView(){const e=this.locale,t=new rd(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",()=>{const e=t.element.value,i=this.options.colorDefinitions.find(t=>e===t.label);this._stillTyping=!0,this.value=i&&i.color||e}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createRemoveColorButton(){const e=this.locale,t=e.t,i=new Ch(e);return i.class="ck-input-color__remove-color",i.withText=!0,i.icon=Sc,i.label=t("Remove color"),i.on("execute",()=>{this.value="",this._dropdownView.isOpen=!1,this.fire("input")}),i}_createColorGrid(e){const t=new Ih(e,{colorDefinitions:this.options.colorDefinitions,columns:this.options.columns});return t.on("execute",(e,t)=>{this.value=t.value,this._dropdownView.isOpen=!1,this.fire("input")}),t.bind("selectedColor").to(this,"value"),t}_setInputValue(e){if(!this._stillTyping){const t=Vv(e),i=this.options.colorDefinitions.find(e=>t===Vv(e.color));this._inputView.value=i?i.label:e||""}}}function Vv(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ov=e=>""===e;function Nv(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function Mv(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function Bv(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function Fv(e){return e=e.trim(),Ov(e)||Yd(e)}function Dv(e){return e=e.trim(),Ov(e)||qv(e)||eu(e)||iu(e)}function zv(e){return e=e.trim(),Ov(e)||qv(e)||eu(e)}function Lv(e){const t=new Xi,i=Nv(e.t);for(const n in i){const s={type:"button",model:new dd({_borderStyleValue:"none"===n?"":n,label:i[n],withText:!0})};"none"===n?s.model.bind("isOn").to(e,"borderStyle",e=>!e):s.model.bind("isOn").to(e,"borderStyle",e=>e===n),t.add(s)}return t}function Hv({view:e,icons:t,toolbar:i,labels:n,propertyName:s,nameToValue:o}){for(const r in n){const a=new Ch(e.locale);a.set({label:n[r],icon:t[r],tooltip:n[r]}),a.bind("isOn").to(e,s,e=>e===o(r)),a.on("execute",()=>{e[s]=o(r)}),i.items.add(a)}}const jv=[{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 Wv(e){return(t,i,n)=>{const s=new Iv(t.locale,{colorDefinitions:(o=e.colorConfig,o.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))),columns:e.columns});var o;
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */return s.set({id:i,ariaDescribedById:n}),s.bind("isReadOnly").to(t,"isEnabled",e=>!e),s.bind("hasError").to(t,"errorText",e=>!!e),s.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(s),s}}function qv(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}class $v extends eh{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach(e=>this.children.add(e)),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")],role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Uv={left:zc,center:Lc,right:Hc};class Kv extends eh{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:s,borderRowLabel:o}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:h,dimensionsLabel:d}=this._createDimensionFields(),{alignmentToolbar:u,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new Nr,this.keystrokes=new Mr,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=s,this.backgroundInput=a,this.widthInput=l,this.heightInput=h,this.alignmentToolbar=u;const{saveButtonView:f,cancelButtonView:g}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=g,this._focusables=new Zc,this._focusCycler=new Sh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new od(e,{label:this.t("Table properties")})),this.children.add(new $v(e,{labelView:o,children:[o,i,s,n],class:"ck-table-form__border-row"})),this.children.add(new $v(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})),this.children.add(new $v(e,{children:[new $v(e,{labelView:d,children:[d,l,c,h],class:"ck-table-form__dimensions-row"}),new $v(e,{labelView:m,children:[m,u],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new $v(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Xc({view:this}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=Wv({colorConfig:this.options.borderColors,columns:5}),t=this.locale,i=this.t,n=new td(t);n.text=i("Border");const s=Nv(this.t),o=new ad(t,cd);o.set({label:i("Style"),class:"ck-table-form__border-style"}),o.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),o.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>s[e||"none"]),o.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),o.bind("isEmpty").to(this,"borderStyle",e=>!e),Zh(o.fieldView,Lv(this));const r=new ad(t,ld);r.set({label:i("Width"),class:"ck-table-form__border-width"}),r.fieldView.bind("value").to(this,"borderWidth"),r.bind("isEnabled").to(this,"borderStyle",Gv),r.fieldView.on("input",()=>{this.borderWidth=r.fieldView.element.value});const a=new ad(t,e);return a.set({label:i("Color"),class:"ck-table-form__border-color"}),a.fieldView.bind("value").to(this,"borderColor"),a.bind("isEnabled").to(this,"borderStyle",Gv),a.fieldView.on("input",()=>{this.borderColor=a.fieldView.value}),this.on("change:borderStyle",(e,t,i)=>{Gv(i)||(this.borderColor="",this.borderWidth="")}),{borderRowLabel:n,borderStyleDropdown:o,borderColorInput:a,borderWidthInput:r}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new td(e);i.text=t("Background");const n=Wv({colorConfig:this.options.backgroundColors,columns:5}),s=new ad(e,n);return s.set({label:t("Color"),class:"ck-table-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",()=>{this.backgroundColor=s.fieldView.value}),{backgroundRowLabel:i,backgroundInput:s}}_createDimensionFields(){const e=this.locale,t=this.t,i=new td(e);i.text=t("Dimensions");const n=new ad(e,ld);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const s=new eh(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const o=new ad(e,ld);return o.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),o.fieldView.bind("value").to(this,"height"),o.fieldView.on("input",()=>{this.height=o.fieldView.element.value}),{dimensionsLabel:i,widthInput:n,operatorLabel:s,heightInput:o}}_createAlignmentFields(){const e=this.locale,t=this.t,i=new td(e);i.text=t("Alignment");const n=new qh(e);return n.set({isCompact:!0,ariaLabel:t("Table alignment toolbar")}),Hv({view:this,icons:Uv,toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",nameToValue:e=>"center"===e?"":e}),{alignmentLabel:i,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,i=new Ch(e),n=new Ch(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return i.set({label:t("Save"),icon:Ec,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",(...e)=>e.every(e=>!e)),n.set({label:t("Cancel"),icon:Pc,class:"ck-button-cancel",type:"cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}get _alignmentLabels(){const e=this.locale,t=this.t,i=t("Align table to the left"),n=t("Center table"),s=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:s,center:n,left:i}:{left:i,center:n,right:s}}}function Gv(e){return!!e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Jv=fd.defaultPositions,Yv=[Jv.northArrowSouth,Jv.northArrowSouthWest,Jv.northArrowSouthEast,Jv.southArrowNorth,Jv.southArrowNorthWest,Jv.southArrowNorthEast],Qv=[...Yv,rm];function Xv(e,t){const i=e.plugins.get("ContextualBalloon");if(uv(e.editing.view.document.selection)){let n;n="cell"===t?ey(e):Zv(e),i.updatePosition(n)}}function Zv(e){const t=e.model.document.selection.getFirstPosition().findAncestor("table"),i=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.viewToDom(i),positions:Qv}}function ey(e){const t=e.editing.mapper,i=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const i=t.editing.mapper,n=t.editing.view.domConverter,s=Array.from(e).map(e=>{const t=ty(e.start),s=i.toViewElement(t);return new Pr(n.viewToDom(s))});return Pr.getBoundingRect(s)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(n.getRanges(),e),positions:Yv};const s=ty(n.getFirstPosition()),o=t.toViewElement(s);return{target:i.viewToDom(o),positions:Yv}}function ty(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}const iy={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class ny extends Ye{static get requires(){return[_d]}static get pluginName(){return"TablePropertiesUI"}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:jv,backgroundColors:jv})}init(){const e=this.editor,t=e.t;this._balloon=e.plugins.get(_d),this.view=this._createPropertiesView(),this._undoStepBatch=null,e.ui.componentFactory.add("tableProperties",i=>{const n=new Ch(i);n.set({label:t("Table properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const s=Object.values(iy).map(t=>e.commands.get(t));return n.bind("isEnabled").toMany(s,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.config.get("table.tableProperties"),i=Th(t.borderColors),n=xh(e.locale,i),s=Th(t.backgroundColors),o=xh(e.locale,s),r=new Kv(e.locale,{borderColors:n,backgroundColors:o}),a=e.t;r.render(),this.listenTo(r,"submit",()=>{this._hideView()}),this.listenTo(r,"cancel",()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()}),r.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),Yc({emitter:r,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const l=Mv(a),c=Bv(a);return r.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),r.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:r.borderColorInput,commandName:"tableBorderColor",errorText:l,validator:Fv})),r.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:r.borderWidthInput,commandName:"tableBorderWidth",errorText:c,validator:zv})),r.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:r.backgroundInput,commandName:"tableBackgroundColor",errorText:l,validator:Fv})),r.on("change:width",this._getValidatedPropertyChangeCallback({viewField:r.widthInput,commandName:"tableWidth",errorText:c,validator:Dv})),r.on("change:height",this._getValidatedPropertyChangeCallback({viewField:r.heightInput,commandName:"tableHeight",errorText:c,validator:Dv})),r.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),r}_fillViewFormFromCommandValues(){const e=this.editor.commands;Object.entries(iy).map(([t,i])=>[t,e.get(i).value||""]).forEach(([e,t])=>this.view.set(e,t))}_showView(){const e=this.editor;this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:Zv(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;uv(e.editing.view.document.selection)?this._isViewVisible&&Xv(e,"table"):this._hideView()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback({commandName:e,viewField:t,validator:i,errorText:n}){const s=gr(()=>{t.errorText=n},500);return(n,o,r)=>{s.cancel(),i(r)?(this.editor.execute(e,{value:r,batch:this._undoStepBatch}),t.errorText=null):s()}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const sy={left:Mc,center:Bc,right:Fc,justify:Dc,top:Nc,middle:Oc,bottom:Vc};class oy extends eh{constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:s,borderRowLabel:o}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:h,dimensionsLabel:d}=this._createDimensionFields(),{horizontalAlignmentToolbar:u,verticalAlignmentToolbar:m,alignmentLabel:f}=this._createAlignmentFields();this.focusTracker=new Nr,this.keystrokes=new Mr,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=s,this.backgroundInput=a,this.paddingInput=this._createPaddingField(),this.widthInput=l,this.heightInput=h,this.horizontalAlignmentToolbar=u,this.verticalAlignmentToolbar=m;const{saveButtonView:g,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=p,this._focusables=new Zc,this._focusCycler=new Sh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new od(e,{label:this.t("Cell properties")})),this.children.add(new $v(e,{labelView:o,children:[o,i,s,n],class:"ck-table-form__border-row"})),this.children.add(new $v(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})),this.children.add(new $v(e,{children:[new $v(e,{labelView:d,children:[d,l,c,h],class:"ck-table-form__dimensions-row"}),new $v(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new $v(e,{labelView:f,children:[f,u,m],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new $v(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Xc({view:this}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=Wv({colorConfig:this.options.borderColors,columns:5}),t=this.locale,i=this.t,n=new td(t);n.text=i("Border");const s=Nv(i),o=new ad(t,cd);o.set({label:i("Style"),class:"ck-table-form__border-style"}),o.fieldView.buttonView.set({isOn:!1,withText:!0,tooltip:i("Style")}),o.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>s[e||"none"]),o.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),o.bind("isEmpty").to(this,"borderStyle",e=>!e),Zh(o.fieldView,Lv(this));const r=new ad(t,ld);r.set({label:i("Width"),class:"ck-table-form__border-width"}),r.fieldView.bind("value").to(this,"borderWidth"),r.bind("isEnabled").to(this,"borderStyle",ry),r.fieldView.on("input",()=>{this.borderWidth=r.fieldView.element.value});const a=new ad(t,e);return a.set({label:i("Color"),class:"ck-table-form__border-color"}),a.fieldView.bind("value").to(this,"borderColor"),a.bind("isEnabled").to(this,"borderStyle",ry),a.fieldView.on("input",()=>{this.borderColor=a.fieldView.value}),this.on("change:borderStyle",(e,t,i)=>{ry(i)||(this.borderColor="",this.borderWidth="")}),{borderRowLabel:n,borderStyleDropdown:o,borderColorInput:a,borderWidthInput:r}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new td(e);i.text=t("Background");const n=Wv({colorConfig:this.options.backgroundColors,columns:5}),s=new ad(e,n);return s.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",()=>{this.backgroundColor=s.fieldView.value}),{backgroundRowLabel:i,backgroundInput:s}}_createDimensionFields(){const e=this.locale,t=this.t,i=new td(e);i.text=t("Dimensions");const n=new ad(e,ld);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const s=new eh(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const o=new ad(e,ld);return o.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),o.fieldView.bind("value").to(this,"height"),o.fieldView.on("input",()=>{this.height=o.fieldView.element.value}),{dimensionsLabel:i,widthInput:n,operatorLabel:s,heightInput:o}}_createPaddingField(){const e=this.locale,t=this.t,i=new ad(e,ld);return i.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),i.fieldView.bind("value").to(this,"padding"),i.fieldView.on("input",()=>{this.padding=i.fieldView.element.value}),i}_createAlignmentFields(){const e=this.locale,t=this.t,i=new td(e);i.text=t("Table cell text alignment");const n=new qh(e),s="rtl"===this.locale.contentLanguageDirection;n.set({isCompact:!0,ariaLabel:t("Horizontal text alignment toolbar")}),Hv({view:this,icons:sy,toolbar:n,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>e===(s?"right":"left")?"":e});const o=new qh(e);return o.set({isCompact:!0,ariaLabel:t("Vertical text alignment toolbar")}),Hv({view:this,icons:sy,toolbar:o,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",nameToValue:e=>"middle"===e?"":e}),{horizontalAlignmentToolbar:n,verticalAlignmentToolbar:o,alignmentLabel:i}}_createActionButtons(){const e=this.locale,t=this.t,i=new Ch(e),n=new Ch(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return i.set({label:t("Save"),icon:Ec,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",(...e)=>e.every(e=>!e)),n.set({label:t("Cancel"),icon:Pc,class:"ck-button-cancel",type:"cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,i=t("Align cell text to the left"),n=t("Align cell text to the center"),s=t("Align cell text to the right"),o=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:s,center:n,left:i,justify:o}:{left:i,center:n,right:s,justify:o}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function ry(e){return!!e}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const ay={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",width:"tableCellWidth",height:"tableCellHeight",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class ly extends Ye{static get requires(){return[_d]}static get pluginName(){return"TableCellPropertiesUI"}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:jv,backgroundColors:jv})}init(){const e=this.editor,t=e.t;this._balloon=e.plugins.get(_d),this.view=this._createPropertiesView(),this._undoStepBatch=null,e.ui.componentFactory.add("tableCellProperties",i=>{const n=new Ch(i);n.set({label:t("Cell properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const s=Object.values(ay).map(t=>e.commands.get(t));return n.bind("isEnabled").toMany(s,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view.destroy()}_createPropertiesView(){const e=this.editor,t=e.editing.view.document,i=e.config.get("table.tableCellProperties"),n=Th(i.borderColors),s=xh(e.locale,n),o=Th(i.backgroundColors),r=xh(e.locale,o),a=new oy(e.locale,{borderColors:s,backgroundColors:r}),l=e.t;a.render(),this.listenTo(a,"submit",()=>{this._hideView()}),this.listenTo(a,"cancel",()=>{this._undoStepBatch.operations.length&&e.execute("undo",this._undoStepBatch),this._hideView()}),a.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),this.listenTo(e.ui,"update",()=>{uv(t.selection)?this._isViewVisible&&Xv(e,"cell"):this._hideView()}),Yc({emitter:a,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const c=Mv(l),h=Bv(l);return a.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),a.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:a.borderColorInput,commandName:"tableCellBorderColor",errorText:c,validator:Fv})),a.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:a.borderWidthInput,commandName:"tableCellBorderWidth",errorText:h,validator:zv})),a.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:a.paddingInput,commandName:"tableCellPadding",errorText:h,validator:Dv})),a.on("change:width",this._getValidatedPropertyChangeCallback({viewField:a.widthInput,commandName:"tableCellWidth",errorText:h,validator:Dv})),a.on("change:height",this._getValidatedPropertyChangeCallback({viewField:a.heightInput,commandName:"tableCellHeight",errorText:h,validator:Dv})),a.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:a.backgroundInput,commandName:"tableCellBackgroundColor",errorText:c,validator:Fv})),a.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),a.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),a}_fillViewFormFromCommandValues(){const e=this.editor.commands;Object.entries(ay).map(([t,i])=>[t,e.get(i).value||""]).forEach(([e,t])=>this.view.set(e,t))}_showView(){const e=this.editor;this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:ey(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){if(!this._isViewInBalloon)return;const e=this.editor;this.stopListening(e.ui,"update"),this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}get _isViewVisible(){return this._balloon.visibleView===this.view}get _isViewInBalloon(){return this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback({commandName:e,viewField:t,validator:i,errorText:n}){const s=gr(()=>{t.errorText=n},500);return(n,o,r)=>{s.cancel(),i(r)?(this.editor.execute(e,{value:r,batch:this._undoStepBatch}),t.errorText=null):s()}}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cy extends Xe{constructor(e,t){super(e),this.attributeName=t}refresh(){const e=t_(this.editor.model.document.selection);this.isEnabled=!!e.length,this.value=this._getSingleValue(e)}execute(e={}){const{value:t,batch:i}=e,n=this.editor.model,s=t_(n.document.selection),o=this._getValueToSet(t);n.enqueueChange(i||"default",e=>{o?s.forEach(t=>e.setAttribute(this.attributeName,o,t)):s.forEach(t=>e.removeAttribute(this.attributeName,t))})}_getAttribute(e){if(e)return e.getAttribute(this.attributeName)}_getValueToSet(e){return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(e=>this._getAttribute(e)===t)?t:void 0}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hy extends cy{constructor(e){super(e,"padding")}_getAttribute(e){if(e)return vv(e.getAttribute(this.attributeName))}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class dy extends cy{constructor(e){super(e,"width")}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class uy extends cy{constructor(e){super(e,"height")}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class my extends cy{constructor(e){super(e,"backgroundColor")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fy extends cy{constructor(e){super(e,"verticalAlignment")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gy extends cy{constructor(e){super(e,"horizontalAlignment")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class py extends cy{constructor(e){super(e,"borderStyle")}_getAttribute(e){if(e)return vv(e.getAttribute(this.attributeName))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class wy extends cy{constructor(e){super(e,"borderColor")}_getAttribute(e){if(e)return vv(e.getAttribute(this.attributeName))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class by extends cy{constructor(e){super(e,"borderWidth")}_getAttribute(e){if(e)return vv(e.getAttribute(this.attributeName))}_getValueToSet(e){return yv(e,"px")}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const _y=/^(top|bottom)$/;class vy extends Ye{static get pluginName(){return"TableCellPropertiesEditing"}static get requires(){return[Q_]}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.locale;e.data.addStyleProcessorRules(wu),function(e,t){e.extend("tableCell",{allowAttributes:["borderWidth","borderColor","borderStyle"]}),gv(t,"td"),gv(t,"th"),pv(t,"tableCell","borderStyle","border-style"),pv(t,"tableCell","borderColor","border-color"),pv(t,"tableCell","borderWidth","border-width")}(t,i),e.commands.add("tableCellBorderStyle",new py(e)),e.commands.add("tableCellBorderColor",new wy(e)),e.commands.add("tableCellBorderWidth",new by(e)),function(e,t,i){e.extend("tableCell",{allowAttributes:["horizontalAlignment"]});const n=["rtl"==i.contentLanguageDirection?"left":"right","center","justify"];t.attributeToAttribute({model:{name:"tableCell",key:"horizontalAlignment",values:n},view:n.reduce((e,t)=>({...e,[t]:{key:"style",value:{"text-align":t}}}),{})})}(t,i,n),e.commands.add("tableCellHorizontalAlignment",new gy(e)),yy(t,i,"width","width"),e.commands.add("tableCellWidth",new dy(e)),yy(t,i,"height","height"),e.commands.add("tableCellHeight",new uy(e)),e.data.addStyleProcessorRules(Ru),yy(t,i,"padding","padding"),e.commands.add("tableCellPadding",new hy(e)),e.data.addStyleProcessorRules(gu),yy(t,i,"backgroundColor","background-color"),e.commands.add("tableCellBackgroundColor",new my(e)),function(e,t){e.extend("tableCell",{allowAttributes:["verticalAlignment"]}),t.attributeToAttribute({model:{name:"tableCell",key:"verticalAlignment",values:["top","bottom"]},view:{top:{key:"style",value:{"vertical-align":"top"}},bottom:{key:"style",value:{"vertical-align":"bottom"}}}}),t.for("upcast").attributeToAttribute({view:{attributes:{valign:_y}},model:{name:"tableCell",key:"verticalAlignment",value:e=>e.getAttribute("valign")}})}(t,i),e.commands.add("tableCellVerticalAlignment",new fy(e))}}function yy(e,t,i,n){e.extend("tableCell",{allowAttributes:[i]}),fv(t,"tableCell",i,n),pv(t,"tableCell",i,n)}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ky extends Ye{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new et(e)),e.commands.add("outdent",new et(e))}}var Cy='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zM1.632 6.95 5.02 9.358a.4.4 0 0 1-.013.661l-3.39 2.207A.4.4 0 0 1 1 11.892V7.275a.4.4 0 0 1 .632-.326z"/></svg>',Ay='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zm1.618-9.55L.98 9.358a.4.4 0 0 0 .013.661l3.39 2.207A.4.4 0 0 0 5 11.892V7.275a.4.4 0 0 0-.632-.326z"/></svg>';
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class xy extends Ye{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Cy:Ay,s="ltr"==t.uiLanguageDirection?Ay:Cy;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,s=>{const o=n.commands.get(e),r=new Ch(s);return r.set({label:t,icon:i,tooltip:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(r,"execute",()=>{n.execute(e),n.editing.view.focus()}),r})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ty extends Xe{constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=this.editor.model,t=Or(e.document.selection.getSelectedBlocks());t&&e.schema.checkAttribute(t,"blockIndent")?this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=function(e){const t=e.document.selection,i=e.schema;return Array.from(t.getSelectedBlocks()).filter(e=>i.checkAttribute(e,"blockIndent"))}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);e.change(e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}})}}class Py{constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||0);return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||0);if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ey{constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t<this.classes.length-1:t>=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Sy=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ry extends Xe{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change(e=>{const s=t.schema.getValidRanges(i.getRanges(),"highlight");if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,s=t.getLastMatchingPosition(i,{direction:"backward"}),o=t.getLastMatchingPosition(i),r=e.createRange(s,o);n&&this.value!==n?(e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else for(const t of s)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Iy extends Ye{static get pluginName(){return"HighlightEditing"}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new Ry(e))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Vy extends Ye{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),Sc,null,e=>{e.bind("isEnabled").to(t,"isEnabled")})}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,Oy(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",t=>t===e.model),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,s){const o=this.editor;o.ui.componentFactory.add(e,e=>{const r=new Ch(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",()=>{o.execute("highlight",{value:n}),o.editing.view.focus()}),s(r),r})}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,s=e[0],o=e.reduce((e,t)=>(e[t.model]=t,e),{});n.add("highlight",r=>{const a=t.commands.get("highlight"),l=Qh(r,Nh),c=l.buttonView;c.set({tooltip:i("Highlight"),lastExecuted:s.model,commandValue:s.model,isToggleable:!0}),c.bind("icon").to(a,"value",e=>Oy(d(e,"type"))),c.bind("color").to(a,"value",e=>d(e,"color")),c.bind("commandValue").to(a,"value",e=>d(e,"model")),c.bind("isOn").to(a,"value",e=>!!e),c.delegate("execute").to(l);const h=e.map(e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",()=>l.buttonView.set({lastExecuted:e.model})),t});function d(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return o[i][t]}return l.bind("isEnabled").toMany(h,"isEnabled",(...e)=>e.some(e=>e)),h.push(new Hh),h.push(n.create("removeHighlight")),Xh(l,h),function(e){e.buttonView.actionView.iconView.bind("fillColor").to(e.buttonView,"color")}(l),l.toolbarView.ariaLabel=i("Text highlight toolbar"),c.on("execute",()=>{t.execute("highlight",{value:c.commandValue}),t.editing.view.focus()}),l})}}function Oy(e){return"marker"===e?'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M10.798 1.59 3.002 12.875l1.895 1.852 2.521 1.402 6.997-12.194z"/><path d="m2.556 16.727.234-.348c-.297-.151-.462-.293-.498-.426-.036-.137.002-.416.115-.837.094-.25.15-.449.169-.595a4.495 4.495 0 0 0 0-.725c-.209-.621-.303-1.041-.284-1.26.02-.218.178-.506.475-.862l6.77-9.414c.539-.91 1.605-.85 3.199.18 1.594 1.032 2.188 1.928 1.784 2.686l-5.877 10.36c-.158.412-.333.673-.526.782-.193.108-.604.179-1.232.21-.362.131-.608.237-.738.318-.13.081-.305.238-.526.47-.293.265-.504.397-.632.397-.096 0-.27-.075-.524-.226l-.31.41-1.6-1.12zm-.279.415 1.575 1.103-.392.515H1.19l1.087-1.618zm8.1-13.656-4.953 6.9L8.75 12.57l4.247-7.574c.175-.25-.188-.647-1.092-1.192-.903-.546-1.412-.652-1.528-.32zM8.244 18.5 9.59 17h9.406v1.5H8.245z"/></svg>':'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M10.126 2.268 2.002 13.874l1.895 1.852 2.521 1.402L14.47 5.481l-1.543-2.568-2.801-.645z"/><path d="m4.5 18.088-2.645-1.852-.04-2.95-.006-.005.006-.008v-.025l.011.008L8.73 2.97c.165-.233.356-.417.567-.557l-1.212.308L4.604 7.9l-.83-.558 3.694-5.495 2.708-.69 1.65 1.145.046.018.85-1.216 2.16 1.512-.856 1.222c.828.967 1.144 2.141.432 3.158L7.55 17.286l.006.005-3.055.797H4.5zm-.634.166-1.976.516-.026-1.918 2.002 1.402zM9.968 3.817l-.006-.004-6.123 9.184 3.277 2.294 6.108-9.162.005.003c.317-.452-.16-1.332-1.064-1.966-.891-.624-1.865-.776-2.197-.349zM8.245 18.5 9.59 17h9.406v1.5H8.245z"/></svg>'}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ny extends Xe{constructor(e){super(e),this._selectedElements=[],this.on("execute",()=>{this.refresh()},{priority:"highest"})}refresh(){this._selectedElements=this._getSelectedItems(),this.value=this._selectedElements.every(e=>!!e.getAttribute("todoListChecked")),this.isEnabled=!!this._selectedElements.length}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,s=[];t.checkAttribute(n,"todoListChecked")&&s.push(n);for(const e of i.getItems())t.checkAttribute(e,"todoListChecked")&&!s.includes(e)&&s.push(e);return s}execute(e={}){this.editor.model.change(t=>{for(const i of this._selectedElements){(void 0===e.forceValue?!this.value:e.forceValue)?t.setAttribute("todoListChecked",!0,i):t.removeAttribute("todoListChecked",i)}})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function My(e,t,i){const n=t.modelCursor,s=n.parent,o=t.viewItem;if("checkbox"!=o.getAttribute("type")||"listItem"!=s.name||!n.isAtStart)return;if(!i.consumable.consume(o,{name:!0}))return;const r=i.writer;r.setAttribute("listType","todo",s),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,s),t.modelRange=r.createRange(n)}function By(e){return(t,i)=>{const n=i.modelPosition,s=n.parent;if(!s.is("element","listItem")||"todo"!=s.getAttribute("listType"))return;const o=Dy(i.mapper.toViewElement(s),e);o&&(i.viewPosition=i.mapper.findPositionIn(o,n.offset))}}function Fy(e,t,i,n){return t.createUIElement("label",{class:"todo-list__label",contenteditable:!1},(function(t){const s=Cr(document,"input",{type:"checkbox"});i&&s.setAttribute("checked","checked"),s.addEventListener("change",()=>n(e));const o=this.toDomElement(t);return o.appendChild(s),o}))}function Dy(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("containerElement","span")&&e.item.hasClass("todo-list__label__description"))return e.item}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const zy=Os("Ctrl+Enter");class Ly extends Ye{static get pluginName(){return"TodoListEditing"}static get requires(){return[fw]}init(){const e=this.editor,{editing:t,data:i,model:n}=e;n.schema.extend("listItem",{allowAttributes:["todoListChecked"]}),n.schema.addAttributeCheck((e,t)=>{const i=e.last;if("todoListChecked"==t&&"listItem"==i.name&&"todo"!=i.getAttribute("listType"))return!1}),e.commands.add("todoList",new Wp(e,"todo"));const s=new Ny(e);var o,r;e.commands.add("checkTodoList",s),e.commands.add("todoListCheck",s),i.downcastDispatcher.on("insert:listItem",function(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;if("todo"!=i.item.getAttribute("listType"))return;const o=i.item;s.consume(o,"insert"),s.consume(o,"attribute:listType"),s.consume(o,"attribute:listIndent"),s.consume(o,"attribute:todoListChecked");const r=n.writer,a=Kp(o,n);r.addClass("todo-list",a.parent);const l=r.createContainerElement("label",{class:"todo-list__label"}),c=r.createEmptyElement("input",{type:"checkbox",disabled:"disabled"}),h=r.createContainerElement("span",{class:"todo-list__label__description"});o.getAttribute("todoListChecked")&&r.setAttribute("checked","checked",c),r.insert(r.createPositionAt(a,0),l),r.insert(r.createPositionAt(l,0),c),r.insert(r.createPositionAfter(c),h),Gp(o,a,n,e)}}(n),{priority:"high"}),i.upcastDispatcher.on("element:input",My,{priority:"high"}),t.downcastDispatcher.on("insert:listItem",function(e,t){return(i,n,s)=>{const o=s.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;if("todo"!=n.item.getAttribute("listType"))return;const r=n.item;o.consume(r,"insert"),o.consume(r,"attribute:listType"),o.consume(r,"attribute:listIndent"),o.consume(r,"attribute:todoListChecked");const a=s.writer,l=Kp(r,s),c=!!r.getAttribute("todoListChecked"),h=Fy(r,a,c,t),d=a.createContainerElement("span",{class:"todo-list__label__description"});a.addClass("todo-list",l.parent),a.insert(a.createPositionAt(l,0),h),a.insert(a.createPositionAfter(h),d),Gp(r,l,s,e)}}(n,e=>this._handleCheckmarkChange(e)),{priority:"high"}),t.downcastDispatcher.on("attribute:listType:listItem",(o=e=>this._handleCheckmarkChange(e),r=t.view,(e,t,i)=>{const n=i.mapper.toViewElement(t.item),s=i.writer,a=function(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("uiElement","label"))return e.item}(n,r);if("todo"==t.attributeNewValue){const e=!!t.item.getAttribute("todoListChecked"),i=Fy(t.item,s,e,o),r=s.createContainerElement("span",{class:"todo-list__label__description"}),a=s.createRangeIn(n),l=Zp(n),c=Yp(a.start),h=l?s.createPositionBefore(l):a.end,d=s.createRange(c,h);s.addClass("todo-list",n.parent),s.move(d,s.createPositionAt(r,0)),s.insert(s.createPositionAt(n,0),i),s.insert(s.createPositionAfter(i),r)}else if("todo"==t.attributeOldValue){const e=Dy(n,r);s.removeClass("todo-list",n.parent),s.remove(a),s.move(s.createRangeIn(e),s.createPositionBefore(e)),s.remove(e)}})),t.downcastDispatcher.on("attribute:todoListChecked:listItem",function(e){return(t,i,n)=>{if("todo"!=i.item.getAttribute("listType"))return;if(!n.consumable.consume(i.item,"attribute:todoListChecked"))return;const{mapper:s,writer:o}=n,r=!!i.item.getAttribute("todoListChecked"),a=s.toViewElement(i.item).getChild(0),l=Fy(i.item,o,r,e);o.insert(o.createPositionAfter(a),l),o.remove(a)}}(e=>this._handleCheckmarkChange(e))),t.mapper.on("modelToViewPosition",By(t.view)),i.mapper.on("modelToViewPosition",By(t.view)),this.listenTo(t.view.document,"arrowKey",function(e,t){return(i,n)=>{if("left"!=Ms(n.keyCode,t.contentLanguageDirection))return;const s=e.schema,o=e.document.selection;if(!o.isCollapsed)return;const r=o.getFirstPosition(),a=r.parent;if("listItem"===a.name&&"todo"==a.getAttribute("listType")&&r.isAtStart){const t=s.getNearestSelectionRange(e.createPositionBefore(a),"backward");t&&e.change(e=>e.setSelection(t)),n.preventDefault(),n.stopPropagation(),i.stop()}}}(n,e.locale),{context:"li"}),this.listenTo(t.view.document,"keydown",(t,i)=>{Vs(i)===zy&&(e.execute("checkTodoList"),t.stop())},{priority:"high"});const a=new Set;this.listenTo(n,"applyOperation",(e,t)=>{const i=t[0];if("rename"==i.type&&"listItem"==i.oldName){const e=i.position.nodeAfter;e.hasAttribute("todoListChecked")&&a.add(e)}else if("changeAttribute"==i.type&&"listType"==i.key&&"todo"===i.oldValue)for(const e of i.range.getItems())e.hasAttribute("todoListChecked")&&"todo"!==e.getAttribute("listType")&&a.add(e)}),n.document.registerPostFixer(e=>{let t=!1;for(const i of a)e.removeAttribute("todoListChecked",i),t=!0;return a.clear(),t})}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change(i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Hy extends Ye{static get pluginName(){return"TodoListUI"}init(){const e=this.editor.t;Xp(this.editor,"todoList",e("To-do List"),'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m2.315 14.705 2.224-2.24a.689.689 0 0 1 .963 0 .664.664 0 0 1 0 .949L2.865 16.07a.682.682 0 0 1-.112.089.647.647 0 0 1-.852-.051L.688 14.886a.635.635 0 0 1 0-.903.647.647 0 0 1 .91 0l.717.722zm5.185.045a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75zM2.329 5.745l2.21-2.226a.689.689 0 0 1 .963 0 .664.664 0 0 1 0 .95L2.865 7.125a.685.685 0 0 1-.496.196.644.644 0 0 1-.468-.187L.688 5.912a.635.635 0 0 1 0-.903.647.647 0 0 1 .91 0l.73.736zM7.5 5.75A.75.75 0 0 1 8.25 5h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>')}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function jy(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class="language-"+e.language);return i}function Wy(e,t,i){const n={};for(const s of e)"class"===t?n[s[t].split(" ").shift()]=s[i]:n[s[t]]=s[i];return n}function qy(e){return e.data.match(/^(\s*)/)[0]}function $y(e){const t=e.document.selection,i=[];if(t.isCollapsed)i.push(t.anchor);else{const n=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of n)if(t.is("$textProxy")&&t.parent.is("element","codeBlock")){const n=qy(t.textNode),{parent:s,startOffset:o}=t.textNode,r=e.createPositionAt(s,o+n.length);i.push(r)}}return i}function Uy(e){const t=Or(e.getSelectedBlocks());return t&&t.is("element","codeBlock")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ky extends Xe{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,s=jy(t)[0],o=Array.from(n.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue,a=e.language||s.language;i.change(e=>{r?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)})}_getValue(){const e=Or(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!e.is("element","codeBlock"))&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Or(e.getSelectedBlocks());return!!i&&Gy(t,i)}_applyCodeBlock(e,t,i){const n=this.editor.model.schema,s=t.filter(e=>Gy(n,e));for(const t of s)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e);s.reverse().forEach((t,i)=>{const n=s[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))})}_removeCodeBlock(e,t){const i=t.filter(e=>e.is("element","codeBlock"));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t));e.rename(i.nodeAfter,"paragraph"),e.removeAttribute("language",i.nodeAfter),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}function Gy(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jy extends Xe{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=$y(e);for(const e of i)t.insertText(this._indentSequence,e)})}_checkEnabled(){return!!this._indentSequence&&Uy(this.editor.model.document.selection)}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yy extends Xe{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=$y(e);for(const e of i){const i=Qy(this.editor.model,e,this._indentSequence);i&&t.remove(i)}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!Uy(e.document.selection)&&$y(e).some(t=>Qy(e,t,this._indentSequence))}}function Qy(e,t,i){const n=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);if(!n)return null;const s=qy(n),o=s.lastIndexOf(i);if(o+i.length!==s.length)return null;if(-1===o)return null;const{parent:r,startOffset:a}=n;return e.createRange(e.createPositionAt(r,a+o),e.createPositionAt(r,a+o+i.length))}function Xy(e,t,i=!1){const n=Wy(t,"language","class"),s=Wy(t,"language","label");return(t,o,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(o.item,"insert"))return;const h=o.item.getAttribute("language"),d=l.toViewPosition(e.createPositionBefore(o.item)),u={};i&&(u["data-language"]=s[h],u.spellcheck="false");const m=a.createContainerElement("pre",u),f=a.createContainerElement("code",{class:n[h]||null});a.insert(a.createPositionAt(m,0),f),a.insert(d,m),l.bindElements(o.item,f)}}class Zy extends Ye{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Im]}constructor(e){super(e),e.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 e=this.editor,t=e.model.schema,i=e.model,n=(e.editing.view,jy(e));e.commands.add("codeBlock",new Ky(e)),e.commands.add("indentCodeBlock",new Jy(e)),e.commands.add("outdentCodeBlock",new Yy(e));const s=e=>(t,i)=>{this.editor.commands.get(e).isEnabled&&(this.editor.execute(e),i())};e.keystrokes.set("Tab",s("indentCodeBlock")),e.keystrokes.set("Shift+Tab",s("outdentCodeBlock")),t.register("codeBlock",{allowWhere:"$block",isBlock:!0,allowAttributes:["language"]}),t.extend("$text",{allowIn:"codeBlock"}),t.addAttributeCheck(e=>{if(e.endsWith("codeBlock $text"))return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",Xy(i,n,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Xy(i,n)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:s,mapper:o,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=o.toViewPosition(e.createPositionBefore(i.item));s.insert(a,s.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=Wy(t,"class","language"),n=t[0].language;return(e,t,s)=>{const o=t.viewItem,r=o.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=s;if(!a.test(o,{name:!0}))return;const c=l.createElement("codeBlock"),h=[...o.getClassNames()];h.length||h.push("");for(const e of h){const t=i[e];if(t){l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),s.convertChildren(o,c),s.safeInsert(c,t.modelCursor)&&(a.consume(o,{name:!0}),s.updateConversionResult(c,t))}}(0,n)),e.data.upcastDispatcher.on("text",(e,t,{consumable:i,writer:n})=>{let s=t.modelCursor;if(!i.test(t.viewItem))return;if(!s.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map(e=>n.createText(e)),r=o[o.length-1];for(const e of o)if(n.insert(e,s),s=s.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,s),s=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,s),t.modelCursor=s}),this.listenTo(e.editing.view.document,"clipboardInput",(t,n)=>{let s=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(s=e.editing.mapper.toModelRange(n.targetRanges[0])),!s.start.parent.is("element","codeBlock"))return;const o=n.dataTransfer.getData("text/plain"),r=new Wd(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),s=n.reduce((t,i,s)=>(t.push(i),s<n.length-1&&t.push(e.createElement("br")),t),[]);return e.appendChild(s,i),i}(r,o)}),this.listenTo(i,"getSelectedContent",(e,[n])=>{const s=n.anchor;!n.isCollapsed&&s.parent.is("element","codeBlock")&&s.hasSameParentAs(n.focus)&&i.change(i=>{const o=e.return;if(o.childCount>1||n.containsEntireContent(s.parent)){const t=i.createElement("codeBlock",s.parent.getAttributes());i.append(o,t);const n=i.createDocumentFragment();i.append(t,n),e.return=n}else{const e=o.getChild(0);t.checkAttribute(e,"code")&&i.setAttribute("code",!0,e)}})})}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock")),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",(t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model.document,n=e.editing.view,s=i.selection.getLastPosition(),o=s.nodeAfter;if(t||!i.selection.isCollapsed||!s.isAtStart)return!1;if(!o||!o.is("element","softBreak"))return!1;return e.model.change(t=>{e.execute("enter");const n=i.selection.anchor.parent.previousSibling;t.rename(n,"paragraph"),t.setSelection(n,"in"),e.model.schema.removeDisallowedAttributes([n],t),t.remove(o)}),n.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeBefore;let a;if(t||!n.selection.isCollapsed||!o.isAtEnd||!r)return!1;if(r.is("element","softBreak"))a=i.createRangeOn(r);else{if(!r.is("$text")||r.data.match(/\S/)||!r.previousSibling||!r.previousSibling.is("element","softBreak"))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r))}return e.model.change(t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,"paragraph"),e.model.schema.removeDisallowedAttributes([i],t)}),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model.document,i=t.selection.getLastPosition(),n=i.nodeBefore||i.textNode;let s;n&&n.is("$text")&&(s=qy(n));e.model.change(i=>{e.execute("shiftEnter"),s&&i.insertText(s,t.selection.anchor)})}(e),i.preventDefault(),t.stop())},{context:"pre"})}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ek extends Ye{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=jy(e),s=n[0];i.add("codeBlock",i=>{const o=e.commands.get("codeBlock"),r=Qh(i,Nh),a=r.buttonView;return a.set({label:t("Insert code block"),tooltip:!0,icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.87 12.61a.75.75 0 0 1-.089.976l-.085.07-3.154 2.254 3.412 2.414a.75.75 0 0 1 .237.95l-.057.095a.75.75 0 0 1-.95.237l-.096-.058-4.272-3.022-.003-1.223 4.01-2.867a.75.75 0 0 1 1.047.174zm2.795-.231.095.057 4.011 2.867-.003 1.223-4.272 3.022-.095.058a.75.75 0 0 1-.88-.151l-.07-.086-.058-.095a.75.75 0 0 1 .15-.88l.087-.07 3.412-2.414-3.154-2.253-.085-.071a.75.75 0 0 1 .862-1.207zM16 0a2 2 0 0 1 2 2v9.354l-.663-.492-.837-.001V2a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3.118L7.156 19H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h14zM5.009 15l.003 1H3v-1h2.009zm2.188-2-1.471 1H5v-1h2.197zM10 11v.095L8.668 12H7v-1h3zm4-2v1H7V9h7zm0-2v1H7V7h7zm-4-2v1H5V5h5zM6 3v1H3V3h3z"/></svg>',isToggleable:!0}),a.bind("isOn").to(o,"value",e=>!!e),a.on("execute",()=>{e.execute("codeBlock",{language:s.language}),e.editing.view.focus()}),r.on("execute",t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(o),Zh(r,this._getLanguageListItemDefinitions(n)),r})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new Xi;for(const n of e){const e={type:"button",model:new dd({_codeBlockLanguage:n.language,label:n.label,withText:!0})};e.model.bind("isOn").to(t,"value",t=>t===e.model._codeBlockLanguage),i.add(e)}return i}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tk extends Xe{refresh(){const e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=mg(e),mg(e)&&e.hasAttribute("title")?this.value=e.getAttribute("title"):this.value=!1}execute(e){const t=this.editor.model,i=t.document.selection.getSelectedElement();t.change(t=>{t.setAttribute("title",e.newValue,i)})}}class ik extends Ye{init(){this.editor.commands.add("imageTitle",new tk(this.editor))}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class nk extends eh{constructor(e,t){super(e);const i="ck-input-"+r(),n="ck-status-"+r();this.set("label"),this.set("value"),this.set("isReadOnly",!1),this.set("errorText",null),this.set("infoText",null),this.labelView=this._createLabelView(i),this.inputView=this._createInputView(t,i,n),this.statusView=this._createStatusView(n),this.bind("_statusText").to(this,"errorText",this,"infoText",(e,t)=>e||t);const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-input",s.if("isReadOnly","ck-disabled")]},children:[this.labelView,this.inputView,this.statusView]})}_createLabelView(e){const t=new td(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createInputView(e,t,i){const n=new e(this.locale,i);return n.id=t,n.ariaDescribedById=i,n.bind("value").to(this),n.bind("isReadOnly").to(this),n.bind("hasError").to(this,"errorText",e=>!!e),n.on("input",()=>{this.errorText=null}),n}_createStatusView(e){const t=new eh(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-input__status",i.if("errorText","ck-labeled-input__status_error"),i.if("_statusText","ck-hidden",e=>!e)],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}select(){this.inputView.select()}focus(){this.inputView.focus()}}class sk extends eh{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new Nr,this.keystrokes=new Mr,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Tc,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),xc,"ck-button-cancel","cancel"),this._focusables=new Zc,this._focusCycler=new Sh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-title-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Xc({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)})}_createButton(e,t,i,n){const s=new Ch(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createLabeledInputView(){const e=this.locale.t,t=new nk(this.locale,rd);return t.label=e("Image title"),t.inputView.placeholder=e("Image title"),t}}class ok extends Ye{static get requires(){return[_d]}static get pluginName(){return"ImageTitleUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTitle",i=>{const n=e.commands.get("imageTitle"),s=new Ch(i);return s.set({label:t("Change image title"),icon:'<?xml version="1.0" encoding="iso-8859-1"?>\r\n\x3c!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  --\x3e\r\n<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r\n\t viewBox="0 0 25.531 25.531" style="enable-background:new 0 0 25.531 25.531;" xml:space="preserve">\r\n<g>\r\n\t<g id="c179_text">\r\n\t\t<path d="M25.198,6.273c-0.014,0.23-0.045,0.389-0.087,0.467c-0.045,0.084-0.176,0.145-0.392,0.183\r\n\t\t\tc-0.469,0.104-0.781-0.074-0.935-0.533C23.239,4.7,22.59,3.578,21.84,3.016c-1.041-0.773-2.862-1.161-5.469-1.161\r\n\t\t\tc-1.054,0-1.633,0.115-1.734,0.343c-0.036,0.075-0.057,0.184-0.057,0.324v18.999c0,0.812,0.188,1.383,0.571,1.709\r\n\t\t\tc0.382,0.32,1.069,0.731,2.201,0.999c0.483,0.103,0.97,0.2,1.034,0.239c0.46,0,0.504,1.057-0.376,1.057\r\n\t\t\tc-0.025,0.016-10.375-0.008-10.375-0.008s-0.723-0.439-0.074-1.023c0.271-0.121,0.767-0.343,0.767-0.343s1.83-0.614,2.211-1.009\r\n\t\t\tc0.434-0.445,0.648-1.164,0.648-2.154V2.521c0-0.369-0.229-0.585-0.687-0.647c-0.049-0.015-0.425-0.02-1.122-0.02\r\n\t\t\tc-2.415,0-4.191,0.418-5.338,1.259C3.176,3.735,2.411,4.877,1.737,6.545C1.52,7.065,1.22,7.234,0.84,7.058\r\n\t\t\tC0.408,6.957,0.251,6.719,0.363,6.353c0.445-1.374,0.668-3.31,0.668-5.814c0-0.292,0.387-0.586,1.163-0.533L23.56,0.064\r\n\t\t\tc0.709-0.104,1.096,0.012,1.16,0.343C25.076,2.096,25.234,4.052,25.198,6.273z"/>\r\n\t</g>\r\n\t<g id="Capa_1_282_">\r\n\t</g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n<g>\r\n</g>\r\n</svg>\r\n',tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>this._showForm()),s})}_createForm(){const e=this.editor,t=e.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new sk(e.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{e.execute("imageTitle",{newValue:this._form.labeledInput.inputView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this._form.keystrokes.set("Esc",(e,t)=>{this._hideForm(!0),t()}),this.listenTo(e.ui,"update",()=>{ug(t.selection)?this._isVisible&&Ag(e):this._hideForm(!0)}),Yc({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const e=this.editor,t=e.commands.get("imageTitle"),i=this._form.labeledInput;this._isInBalloon||this._balloon.add({view:this._form,position:xg(e)}),i.value=i.inputView.element.value=t.value||"",this._form.labeledInput.select()}_hideForm(e){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}class rk extends Xe{execute(){this.editor.model.change(e=>{this.editor.model.insertContent(function(e){const t=prompt("Image URL");if(!t)return;const i=e.createElement("signBox"),n=e.createElement("authorImage"),s=e.createElement("signDescription"),o=e.createElement("signBoldDescription");return e.setAttribute("src",t,n),e.insertText("Christophe Baudia,",o),e.insertText("CEO at GeoMoby ",s),e.append(n,i),e.append(o,i),e.append(s,i),i}(e))})}refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema.findAllowedParent(t.getFirstPosition(),"signBox");this.isEnabled=null!==i}}class ak extends Ye{static get requires(){return[bm]}init(){console.log("SimpleBoxUI#init() got called"),this._defineSchema(),this._defineConverters(),this.editor.commands.add("addSign",new rk(this.editor))}_defineSchema(){const e=this.editor.model.schema;e.register("signBox",{isObject:!0,allowWhere:"$block"}),e.register("authorImage",{isLimit:!0,allowIn:"signBox",allowAttributes:["src"],allowContentOf:"$block"}),e.register("signDescription",{isLimit:!0,allowIn:"signBox",allowContentOf:"$block"}),e.register("signBoldDescription",{isLimit:!0,allowIn:"signBox",allowContentOf:"$block"})}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToElement({model:"signBox",view:{name:"div",classes:"sign-box"}}),e.for("dataDowncast").elementToElement({model:"signBox",view:{name:"div",classes:"sign-box"}}),e.for("editingDowncast").elementToElement({model:"signBox",view:(e,t)=>Xu(t.createContainerElement("div",{class:"sign-box"}),t,{label:"sign box widget"})}),e.for("upcast").elementToElement({model:(e,t)=>t.createElement("authorImage",{class:"sign-author-img",src:e.getAttribute("src")}),view:{name:"img",classes:"sign-author-img"}}),e.for("dataDowncast").elementToElement({model:"authorImage",view:(e,t)=>{const i=e.getAttribute("src");return t.createEditableElement("img",{class:"sign-author-img",src:i})}}),e.for("editingDowncast").elementToElement({model:"authorImage",view:(e,t)=>{const i=e.getAttribute("src");return t.createEditableElement("img",{class:"sign-author-img",src:i})}}),e.for("upcast").elementToElement({model:"signDescription",view:{name:"span",classes:"sign-description"}}),e.for("dataDowncast").elementToElement({model:"signDescription",view:{name:"span",classes:"sign-description"}}),e.for("editingDowncast").elementToElement({model:"signDescription",view:(e,t)=>nm(t.createEditableElement("span",{class:"sign-description"}),t)}),e.for("upcast").elementToElement({model:"signBoldDescription",view:{name:"strong",classes:"sign-bold-desc"}}),e.for("dataDowncast").elementToElement({model:"signBoldDescription",view:{name:"strong",classes:"sign-bold-desc"}}),e.for("editingDowncast").elementToElement({model:"signBoldDescription",view:(e,t)=>nm(t.createEditableElement("strong",{class:"sign-bold-desc"}),t)})}}class lk extends Ye{init(){console.log("TemplateTagsUI#init() got called");const e=this.editor,t=e.t;e.ui.componentFactory.add("signBox",i=>{const n=e.commands.get("addSign"),s=new Ch(i);return s.set({label:t("add sign"),withText:!0,tooltip:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>e.execute("addSign")),s})}}class ck extends Ou{}ck.builtinPlugins=[class extends Ye{static get requires(){return[Pm,ju,Fm,Im,$m,ff]}static get pluginName(){return"Essentials"}},class extends Ye{static get requires(){return[pf]}static get pluginName(){return"CKFinderUploadAdapter"}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(pf).createUploadAdapter=t=>new kf(t,e,this.editor.t))}},class extends Ye{static get requires(){return[Zy,ek]}static get pluginName(){return"CodeBlock"}},class extends Ye{static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&Cf(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&Cf(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&Cf(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&Cf(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")})}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const e=Tf(this.editor,"bold");Af(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),Af(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=Tf(this.editor,"italic");Af(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),Af(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=Tf(this.editor,"code");Af(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=Tf(this.editor,"strikethrough");Af(this.editor,this,/(~~)([^~]+)(~~)$/g,e)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter(e=>e.match(/^heading[1-6]$/)).forEach(t=>{const i=t[7],n=new RegExp(`^(#{${i}})\\s$`);Cf(this.editor,this,n,()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&Cf(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){this.editor.commands.get("codeBlock")&&Cf(this.editor,this,/^```$/,"codeBlock")}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&Cf(this.editor,this,/^---$/,"horizontalLine")}},class extends Ye{static get requires(){return[Ef,Sf]}static get pluginName(){return"Bold"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[Rf,If]}static get pluginName(){return"Italic"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[Vf,Of]}static get pluginName(){return"Underline"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[Nf,Mf]}static get pluginName(){return"Strikethrough"}},class extends Ye{static get requires(){return[Ff,Df]}static get pluginName(){return"Code"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[zf,Lf]}static get pluginName(){return"Subscript"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[Hf,jf]}static get pluginName(){return"Superscript"}},class extends Ye{static get requires(){return[Kf,Gf]}static get pluginName(){return"BlockQuote"}},class extends Ye{static get requires(){return[tg,ig]}static get pluginName(){return"Heading"}},class extends Ye{static get requires(){return[_g,bm,Pg]}static get pluginName(){return"Image"}isImageWidget(e){return dg(e)}},class extends Ye{static get requires(){return[Rg]}static get pluginName(){return"ImageCaption"}},class extends Ye{static get requires(){return[Hg,jg]}static get pluginName(){return"ImageStyle"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[ng]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t;e.plugins.get(ng).register("image",{ariaLabel:t("Image toolbar"),items:e.config.get("image.toolbar")||[],getRelatedElement:ug})}},class extends Ye{static get pluginName(){return"ImageUpload"}static get requires(){return[tp,Ug,Kg]}},class extends Ye{static get requires(){return[bw,kw,vw]}static get pluginName(){return"ImageResize"}},class extends Ye{static get requires(){return[Op,Dp,Hp]}static get pluginName(){return"Link"}},class extends Ye{static get requires(){return[fw,pw]}static get pluginName(){return"List"}},Xf,class extends Ye{static get requires(){return[Ew,Rw]}static get pluginName(){return"Alignment"}},class extends Ye{static get requires(){return[tb,cb,fb,bb]}static get pluginName(){return"Font"}},class extends Ye{static get pluginName(){return"PasteFromOffice"}static get requires(){return[Fu]}init(){const e=this.editor,t=e.editing.view.document,i=[];i.push(new jw(t)),i.push(new Bw(t)),e.plugins.get("ClipboardPipeline").on("inputTransformation",(e,t)=>{if(t.isTransformedWithPasteFromOffice)return;const n=t.dataTransfer.getData("text/html"),s=i.find(e=>e.isActive(n));s&&(s.execute(t),t.isTransformedWithPasteFromOffice=!0)},{priority:"high"})}},
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class extends Ye{static get requires(){return[pf]}static get pluginName(){return"SimpleUploadAdapter"}init(){const e=this.editor.config.get("simpleUpload");e&&(e.uploadUrl?this.editor.plugins.get(pf).createUploadAdapter=t=>new vf(t,e):Object(l.b)("simple-upload-adapter-missing-uploadurl"))}},class extends Ye{static get requires(){return[Tb,Rb,Eb,bm]}static get pluginName(){return"MediaEmbed"}},class extends Ye{static get requires(){return[Ob,Ib]}static get pluginName(){return"RemoveFormat"}},class extends Ye{static get requires(){return[Q_,ev,iv,cv,av,nv,bm]}static get pluginName(){return"Table"}},class extends Ye{static get requires(){return[ng]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ng),n=e.config.get("table.contentToolbar"),s=e.config.get("table.tableToolbar");n&&i.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:uv}),s&&i.register("table",{ariaLabel:t("Table toolbar"),items:s,getRelatedElement:dv})}},class extends Ye{static get pluginName(){return"TableProperties"}static get requires(){return[Sv,ny]}},class extends Ye{static get pluginName(){return"TableCellProperties"}static get requires(){return[vy,ly]}},class extends Ye{static get pluginName(){return"Indent"}static get requires(){return[ky,xy]}},class extends Ye{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}init(){const e=this.editor,t=e.config.get("indentBlock"),i=!t.classes||!t.classes.length,n=Object.assign({direction:"forward"},t),s=Object.assign({direction:"backward"},t);i?(e.data.addStyleProcessorRules(Su),this._setupConversionUsingOffset(e.conversion),e.commands.add("indentBlock",new Ty(e,new Py(n))),e.commands.add("outdentBlock",new Ty(e,new Py(s)))):(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new Ty(e,new Ey(n))),e.commands.add("outdentBlock",new Ty(e,new Ey(s))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),n=e.commands.get("outdent"),s=e.config.get("heading.options");(s&&s.map(e=>e.model)||Sy).forEach(e=>{t.isRegistered(e)&&t.extend(e,{allowAttributes:"blockIndent"})}),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),n.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:e=>e.getStyle(t)}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:e=>({key:"style",value:{[t]:e}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}},class extends Ye{static get requires(){return[Iy,Vy]}static get pluginName(){return"Highlight"}}
/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends Ye{static get requires(){return[Ly,Hy]}static get pluginName(){return"TodoList"}},class extends Ye{static get requires(){return[ik,ok]}static get pluginName(){return"ImageTitle"}},class extends Ye{static get requires(){return[ak,lk]}}];let hk=[];function dk(e){let t=null;if(document.cookie&&""!==document.cookie){let i=document.cookie.split(";");for(let n=0;n<i.length;n++){let s=i[n].trim();if(s.substring(0,e.length+1)===e+"="){t=decodeURIComponent(s.substring(e.length+1));break}}}return t}document.addEventListener("DOMContentLoaded",()=>{let e=document.querySelectorAll(".django_ckeditor_5");for(let t=0;t<e.length;++t){let i=e[t].id+"_script";document.querySelector(`[for$="${e[t].id}"]`).style.float="none";let n=JSON.parse(document.getElementById(i).textContent);n.simpleUpload={uploadUrl:"/ckeditor5/image_upload/",headers:{"X-CSRFToken":dk("csrftoken")}},ck.create(e[t],n).then(e=>{hk.push(e)}).catch(e=>{})}window.editors=hk,window.ClassicEditor=ck})}]);
//# sourceMappingURL=bundle.js.map