1/*! For license information please see 4234.074e9ad3.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkdeveloper=self.webpackChunkdeveloper||[]).push([[4234],{64234:(e,t,i)=>{i.r(t),i.d(t,{default:()=>wy});var n,s=i(80045),o=i(64467),r=i(89379),a=i(44414),l=i(9950);const c=["rangeJSON"],u=["translations"],h=["translations"],d=["translations"];const m=new Array(256).fill("").map((e,t)=>("0"+t.toString(16)).slice(-2));function f(e){return!!e&&/^\d+\.\d+\.\d+/.test(e)}function g(e){return!!e&&["nightly","alpha","internal","nightly-","staging"].some(t=>e.includes(t))}function p(e){if(g(e))return 3;const{major:t}=function(e){if(!f(e))throw new Error("Invalid semantic version: ".concat(e||"<blank>","."));const[t,i,n]=e.split(".");return{major:Number.parseInt(t,10),minor:Number.parseInt(i,10),patch:Number.parseInt(n,10)}}(e);switch(!0){case t>=44:return 3;case t>=38:return 2;default:return 1}}function _(){const{CKEDITOR_VERSION:e,CKEDITOR:t}=window;return function(e){return f(e)||g(e)}(e)?{source:t?"cdn":"npm",version:e}:null}function w(e,t){switch(t||(t=function(){const e=_();return e?p(e.version):null}()||void 0),t){case 1:case 2:return void 0===e;case 3:return"GPL"===e;default:return!1}}var b=Object.defineProperty,v=(e,t,i)=>((e,t,i)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!==typeof t?t+"":t,i);const y=class e{constructor(e,t){v(this,"_lifecycle"),v(this,"_element"),v(this,"_releaseLock",null),v(this,"_value",null),v(this,"_afterMountCallbacks",[]),v(this,"_state",{destroyedBeforeInitialization:!1,mountingInProgress:null}),v(this,"release",function(e){let t=null;return function(){return t||(t={current:e(...arguments)}),t.current}}(()=>{const{_releaseLock:e,_state:t,_element:i,_lifecycle:n}=this;t.mountingInProgress?t.mountingInProgress.then(()=>n.unmount({element:i,mountResult:this.value})).catch(e=>{console.error("Semaphore unmounting error:",e)}).then(e.resolve).then(()=>{this._value=null}):(t.destroyedBeforeInitialization=!0,e.resolve())})),this._element=e,this._lifecycle=t,this._lock()}get value(){return this._value}unsafeSetValue(e){this._value=e,this._afterMountCallbacks.forEach(t=>t(e)),this._afterMountCallbacks=[]}runAfterMount(e){const{_value:t,_afterMountCallbacks:i}=this;t?e(t):i.push(e)}_lock(){const{_semaphores:t}=e,{_state:i,_element:n,_lifecycle:s}=this,o=t.get(n)||Promise.resolve(null),r=function(){const e={resolve:null,promise:null};return e.promise=new Promise(t=>{e.resolve=t}),e}();this._releaseLock=r;const a=o.then(()=>i.destroyedBeforeInitialization?Promise.resolve(void 0):(i.mountingInProgress=s.mount().then(e=>(e&&this.unsafeSetValue(e),e)),i.mountingInProgress)).then(async e=>{e&&s.afterMount&&await s.afterMount({element:n,mountResult:e})}).then(()=>r.promise).catch(e=>{console.error("Semaphore mounting error:",e)}).then(()=>{t.get(n)===a&&t.delete(n)});t.set(n,a)}};v(y,"_semaphores",new Map);let A=y;const k="$__CKEditorReactContextMetadata";const E=l.createContext(null),C=e=>t=>(e=>!!e&&"object"===typeof e&&"status"in e&&["initializing","initialized","error"].includes(e.status))(t)&&t.status===e,P=C("initializing"),T=(x="react",D={version:"9.5.0",frameworkVersion:l.version},function(e){w(e.config.get("licenseKey"))||e.on("collectUsageData",(e,t)=>{let{setUsageData:i}=t;i("integration.".concat(x),D)})});var x,D;function S(e){return w(e.licenseKey)?e:function(e,t){const i=e.extraPlugins||[];return(0,r.A)((0,r.A)({},e),{},{extraPlugins:[...i,...t.filter(e=>!i.includes(e))]})}(e,[T])}const I="Lock from React integration (@ckeditor/ckeditor5-react)";class O extends l.Component{constructor(e){super(e),v(this,"domContainer",l.createRef()),v(this,"editorSemaphore",null),this._checkVersion()}_checkVersion(){const{CKEDITOR_VERSION:e}=window;if(!e)return console.warn('Cannot find the "CKEDITOR_VERSION" in the "window" scope.');const[t]=e.split(".").map(Number);t>=42||e.startsWith("0.0.0")||console.warn("The <CKEditor> component requires using CKEditor 5 in version 42+ or nightly build.")}get _semaphoreValue(){const{editorSemaphore:e}=this;return e?e.value:null}get watchdog(){const{_semaphoreValue:e}=this;return e?e.watchdog:null}get editor(){const{_semaphoreValue:e}=this;return e?e.instance:null}shouldComponentUpdate(e){const{props:t,editorSemaphore:i}=this;return e.id!==t.id||(e.disableWatchdog!==t.disableWatchdog||(i&&(i.runAfterMount(i=>{let{instance:n}=i;this._shouldUpdateEditorData(t,e,n)&&n.data.set(e.data)}),"disabled"in e&&i.runAfterMount(t=>{let{instance:i}=t;
2e.disabled?i.enableReadOnlyMode(I):i.disableReadOnlyMode(I)})),!1))}componentDidMount(){P(this.context)||this._initLifeCycleSemaphore()}componentDidUpdate(){P(this.context)||this._initLifeCycleSemaphore()}componentWillUnmount(){this._unlockLifeCycleSemaphore()}_unlockLifeCycleSemaphore(){this.editorSemaphore&&(this.editorSemaphore.release(),this.editorSemaphore=null)}_initLifeCycleSemaphore(){this._unlockLifeCycleSemaphore(),this.editorSemaphore=new A(this.domContainer.current,{mount:async()=>this._initializeEditor(),afterMount:e=>{let{mountResult:t}=e;const{onReady:i}=this.props;i&&null!==this.domContainer.current&&i(t.instance)},unmount:async e=>{let{element:t,mountResult:i}=e;const{onAfterDestroy:n}=this.props;try{await this._destroyEditor(i),t.innerHTML=""}finally{n&&n(i.instance)}}})}render(){return l.createElement("div",{ref:this.domContainer})}async _initializeEditor(){if(this.props.disableWatchdog){return{instance:await this._createEditor(this.domContainer.current,this._getConfig()),watchdog:null}}const e=(()=>{return e=this.context,C("initialized")(e)&&"ready"===e.watchdog.state?new F(this.context.watchdog):new this.props.editor.EditorWatchdog(this.props.editor,this.props.watchdogConfig);var e})(),t={current:0};return e.setCreator(async(i,n)=>{var s;const{editorSemaphore:o}=this,{onAfterDestroy:r}=this.props;t.current>0&&r&&(null==(s=null==o?void 0:o.value)?void 0:s.instance)&&r(o.value.instance);const a=await this._createEditor(i,n);return o&&t.current>0&&(o.unsafeSetValue({instance:a,watchdog:e}),setTimeout(()=>{this.props.onReady&&this.props.onReady(e.editor)})),t.current++,a}),e.on("error",(e,t)=>{let{error:i,causesRestart:n}=t;(this.props.onError||console.error)(i,{phase:"runtime",willEditorRestart:n})}),await e.create(this.domContainer.current,this._getConfig()).catch(e=>{(this.props.onError||console.error)(e,{phase:"initialization",willEditorRestart:!1})}),{watchdog:e,instance:e.editor}}_createEditor(e,t){const{contextItemMetadata:i}=this.props;return i&&(t=function(e,t){return(0,r.A)((0,r.A)({},t),{},{[k]:e})}(i,t)),this.props.editor.create(e,S(t)).then(e=>{"disabled"in this.props&&this.props.disabled&&e.enableReadOnlyMode(I);const t=e.model.document,i=e.editing.view.document;return t.on("change:data",t=>{this.props.onChange&&this.props.onChange(t,e)}),i.on("focus",t=>{this.props.onFocus&&this.props.onFocus(t,e)}),i.on("blur",t=>{this.props.onBlur&&this.props.onBlur(t,e)}),e})}async _destroyEditor(e){const{watchdog:t,instance:i}=e;return new Promise((e,n)=>{setTimeout(async()=>{try{if(t)return await t.destroy(),e();if(i)return await i.destroy(),e();e()}catch(s){console.error(s),n(s)}})})}_shouldUpdateEditorData(e,t,i){return e.data!==t.data&&i.data.get()!==t.data}_getConfig(){const e=this.props.config||{};return this.props.data&&e.initialData&&console.warn("Editor data should be provided either using `config.initialData` or `content` property. The config value takes precedence over `content` property and will be used when both are specified."),(0,r.A)((0,r.A)({},e),{},{initialData:e.initialData||this.props.data||""})}}v(O,"contextType",E);class F{constructor(e){v(this,"_contextWatchdog"),v(this,"_id"),v(this,"_creator"),this._contextWatchdog=e,this._id=function(){const[e,t,i,n]=crypto.getRandomValues(new Uint32Array(4));return"e"+m[255&e]+m[e>>8&255]+m[e>>16&255]+m[e>>24&255]+m[255&t]+m[t>>8&255]+m[t>>16&255]+m[t>>24&255]+m[255&i]+m[i>>8&255]+m[i>>16&255]+m[i>>24&255]+m[255&n]+m[n>>8&255]+m[n>>16&255]+m[n>>24&255]}()}setCreator(e){this._creator=e}create(e,t){return this._contextWatchdog.add({sourceElementOrData:e,config:t,creator:this._creator,id:this._id,type:"editor"})}on(e,t){this._contextWatchdog.on("itemError",(e,i)=>{let{itemId:n,error:s}=i;n===this._id&&t(null,{error:s,causesRestart:void 0})})}destroy(){return"ready"===this._contextWatchdog.state?this._contextWatchdog.remove(this._id):Promise.resolve()}get editor(){return this._contextWatchdog.getItem(this._id)}}function B(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return e=>{t.forEach(t=>{"function"===typeof t?t(e):null!=t&&(t.current=e)})}}const M=(0,l.memo)((0,l.forwardRef)((e,t)=>{let{id:i,semaphore:n,rootName:s}=e;const o=(0,l.useRef)(null);return(0,l.useEffect)(()=>{let e,t;return n.runAfterMount(i=>{let{instance:n}=i;if(!o.current)return;t=n;const{ui:r,model:a}=t,l=a.document.getRoot(s);l&&t.ui.getEditableElement(s)&&t.detachEditable(l),e=r.view.createEditable(s,o.current),r.addEditable(e),n.editing.view.forceRender()}),()=>{if(t&&"destroyed"!==t.state&&o.current){const e=t.model.document.getRoot(s);e&&t.detachEditable(e)}}},[n.revision]),l.createElement("div",{key:n.revision,id:i,ref:B(t,o)})}));M.displayName="EditorEditable";(0,l.forwardRef)((e,t)=>{let{editor:i}=e;const n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{const e=n.current;if(!i||!e)return;const t=i.ui.view.toolbar.element;return e.appendChild(t),()=>{e.contains(t)&&e.removeChild(t)}},[i&&i.id]),l.createElement("div",{ref:B(n,t)})}).displayName="EditorToolbarWrapper";var R="object"==typeof i.g&&i.g&&i.g.Object===Object&&i.g,V="object"==typeof self&&self&&self.Object===Object&&self,N=R||V||Function("return this")(),L=N.Symbol,j=Object.prototype,W=j.hasOwnProperty,q=j.toString,U=L?L.toStringTag:void 0;var z=Object.prototype.toString;var H=L?L.toStringTag:void 0;
vendor: 2,925 bytes, line 2
2function $(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":H&&H in Object(e)?function(e){var t=W.call(e,U),i=e[U];try{e[U]=void 0;var n=!0}catch(o){}var s=q.call(e);return n&&(t?e[U]=i:delete e[U]),s}(e):function(e){return z.call(e)}(e)}function K(e){return null!=e&&"object"==typeof e}function G(e){return"symbol"==typeof e||K(e)&&"[object Symbol]"==$(e)}var J=Array.isArray,Z=L?L.prototype:void 0,Q=Z?Z.toString:void 0;function Y(e){if("string"==typeof e)return e;if(J(e))return 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}(e,Y)+"";if(G(e))return Q?Q.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var X=/\s/;var ee=/^\s+/;function te(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&X.test(e.charAt(t)););return t}(e)+1).replace(ee,""):e}function ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var ne=/^[-+]0x[0-9a-f]+$/i,se=/^0b[01]+$/i,oe=/^0o[0-7]+$/i,re=parseInt;function ae(e){if("number"==typeof e)return e;if(G(e))return NaN;if(ie(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ie(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=te(e);var i=se.test(e);return i||oe.test(e)?re(e.slice(2),i?2:8):ne.test(e)?NaN:+e}function le(e){return e}function ce(e){if(!ie(e))return!1;var t=$(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var ue=N["__core-js_shared__"],he=function(){var e=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var de=Function.prototype.toString;function me(e){if(null!=e){try{return de.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var fe=/^\[object .+?Constructor\]$/,ge=Function.prototype,pe=Object.prototype,_e=ge.toString,we=pe.hasOwnProperty,be=RegExp("^"+_e.call(we).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ve(e){return!(!ie(e)||(t=e,he&&he in t))&&(ce(e)?be:fe).test(me(e));var t}function ye(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return ve(i)?i:void 0}var Ae=ye(N,"WeakMap"),ke=Object.create,Ee=function(){function e(){}return function(t){if(!ie(t))return{};if(ke)return ke(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}();function Ce(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i<n;)t[i]=e[i];return t}var Pe=Date.now;var Te=function(){try{var e=ye(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),xe=function(e){var t=0,i=0;return function(){var n=Pe(),s=16-(n-i);if(i=n,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Te?function(e,t){return Te(e,"toString",{configurable:!0,enumerable:!1,value:(i=t,function(){return i}),writable:!0});var i}:le);var De=/^(?:0|[1-9]\d*)$/;function Se(e,t){var i=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==i||"symbol"!=i&&De.test(e))&&e>-1&&e%1==0&&e<t}
vendor: 10,824 bytes, line 2
2function Ie(e,t,i){"__proto__"==t&&Te?Te(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function Oe(e,t){return e===t||e!==e&&t!==t}var Fe=Object.prototype.hasOwnProperty;function Be(e,t,i){var n=e[t];Fe.call(e,t)&&Oe(n,i)&&(void 0!==i||t in e)||Ie(e,t,i)}function Me(e,t,i,n){var s=!i;i||(i={});for(var o=-1,r=t.length;++o<r;){var a=t[o],l=void 0;void 0===l&&(l=e[a]),s?Ie(i,a,l):Be(i,a,l)}return i}var Re=Math.max;function Ve(e,t){return xe(function(e,t,i){return t=Re(void 0===t?e.length-1:t,0),function(){for(var n=arguments,s=-1,o=Re(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),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)}(e,this,a)}}(e,t,le),e+"")}function Ne(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Le(e){return null!=e&&Ne(e.length)&&!ce(e)}function je(e){return Ve(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&&function(e,t,i){if(!ie(i))return!1;var n=typeof t;return!!("number"==n?Le(i)&&Se(t,i.length):"string"==n&&t in i)&&Oe(i[t],e)}(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 We=Object.prototype;function qe(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||We)}function Ue(e){return K(e)&&"[object Arguments]"==$(e)}var ze=Object.prototype,He=ze.hasOwnProperty,$e=ze.propertyIsEnumerable,Ke=Ue(function(){return arguments}())?Ue:function(e){return K(e)&&He.call(e,"callee")&&!$e.call(e,"callee")};var Ge="object"==typeof exports&&exports&&!exports.nodeType&&exports,Je=Ge&&"object"==typeof module&&module&&!module.nodeType&&module,Ze=Je&&Je.exports===Ge?N.Buffer:void 0,Qe=(Ze?Ze.isBuffer:void 0)||function(){return!1},Ye={};function Xe(e){return function(t){return e(t)}}Ye["[object Float32Array]"]=Ye["[object Float64Array]"]=Ye["[object Int8Array]"]=Ye["[object Int16Array]"]=Ye["[object Int32Array]"]=Ye["[object Uint8Array]"]=Ye["[object Uint8ClampedArray]"]=Ye["[object Uint16Array]"]=Ye["[object Uint32Array]"]=!0,Ye["[object Arguments]"]=Ye["[object Array]"]=Ye["[object ArrayBuffer]"]=Ye["[object Boolean]"]=Ye["[object DataView]"]=Ye["[object Date]"]=Ye["[object Error]"]=Ye["[object Function]"]=Ye["[object Map]"]=Ye["[object Number]"]=Ye["[object Object]"]=Ye["[object RegExp]"]=Ye["[object Set]"]=Ye["[object String]"]=Ye["[object WeakMap]"]=!1;var et="object"==typeof exports&&exports&&!exports.nodeType&&exports,tt=et&&"object"==typeof module&&module&&!module.nodeType&&module,it=tt&&tt.exports===et&&R.process,nt=function(){try{var e=tt&&tt.require&&tt.require("util").types;return e||it&&it.binding&&it.binding("util")}catch(t){}}(),st=nt&&nt.isTypedArray,ot=st?Xe(st):function(e){return K(e)&&Ne(e.length)&&!!Ye[$(e)]},rt=Object.prototype.hasOwnProperty;function at(e,t){var i=J(e),n=!i&&Ke(e),s=!i&&!n&&Qe(e),o=!i&&!n&&!s&&ot(e),r=i||n||s||o,a=r?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],l=a.length;for(var c in e)!t&&!rt.call(e,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Se(c,l))||a.push(c);return a}function lt(e,t){return function(i){return e(t(i))}}var ct=lt(Object.keys,Object),ut=Object.prototype.hasOwnProperty;function ht(e){return Le(e)?at(e):function(e){if(!qe(e))return ct(e);var t=[];for(var i in Object(e))ut.call(e,i)&&"constructor"!=i&&t.push(i);return t}(e)}var dt=Object.prototype.hasOwnProperty;function mt(e){if(!ie(e))return function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t}(e);var t=qe(e),i=[];for(var n in e)("constructor"!=n||!t&&dt.call(e,n))&&i.push(n);return i}function ft(e){return Le(e)?at(e,!0):mt(e)}var gt=je(function(e,t){Me(t,ft(t),e)}),pt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_t=/^\w*$/;function wt(e,t){if(J(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!G(e))||(_t.test(e)||!pt.test(e)||null!=t&&e in Object(t))}var bt=ye(Object,"create");var vt=Object.prototype.hasOwnProperty;var yt=Object.prototype.hasOwnProperty;function At(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])}}function kt(e,t){for(var i=e.length;i--;)if(Oe(e[i][0],t))return i;return-1}At.prototype.clear=function(){this.__data__=bt?bt(null):{},this.size=0},At.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},At.prototype.get=function(e){var t=this.__data__;if(bt){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return vt.call(t,e)?t[e]:void 0},At.prototype.has=function(e){var t=this.__data__;return bt?void 0!==t[e]:yt.call(t,e)},At.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=bt&&void 0===t?"__lodash_hash_undefined__":t,this};var Et=Array.prototype.splice;function Ct(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])}}Ct.prototype.clear=function(){this.__data__=[],this.size=0},Ct.prototype.delete=function(e){var t=this.__data__,i=kt(t,e);return!(i<0)&&(i==t.length-1?t.pop():Et.call(t,i,1),--this.size,!0)},Ct.prototype.get=function(e){var t=this.__data__,i=kt(t,e);return i<0?void 0:t[i][1]},Ct.prototype.has=function(e){return kt(this.__data__,e)>-1},Ct.prototype.set=function(e,t){var i=this.__data__,n=kt(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};var Pt=ye(N,"Map");function Tt(e,t){var i=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?i["string"==typeof t?"string":"hash"]:i.map}function xt(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])}}xt.prototype.clear=function(){this.size=0,this.__data__={hash:new At,map:new(Pt||Ct),string:new At}},xt.prototype.delete=function(e){var t=Tt(this,e).delete(e);return this.size-=t?1:0,t},xt.prototype.get=function(e){return Tt(this,e).get(e)},xt.prototype.has=function(e){return Tt(this,e).has(e)},xt.prototype.set=function(e,t){var i=Tt(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function Dt(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(Dt.Cache||xt),i}Dt.Cache=xt;var St=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,It=/\\(\\)?/g,Ot=function(e){var t=Dt(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(St,function(e,i,n,s){t.push(n?s.replace(It,"$1"):i||e)}),t});function Ft(e){return null==e?"":Y(e)}function Bt(e,t){return J(e)?e:wt(e,t)?[e]:Ot(Ft(e))}function Mt(e){if("string"==typeof e||G(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Rt(e,t){for(var i=0,n=(t=Bt(t,e)).length;null!=e&&i<n;)e=e[Mt(t[i++])];return i&&i==n?e:void 0}function Vt(e,t,i){var n=null==e?void 0:Rt(e,t);return void 0===n?i:n}function Nt(e,t){for(var i=-1,n=t.length,s=e.length;++i<n;)e[s+i]=t[i];return e}var Lt=lt(Object.getPrototypeOf,Object),jt=Function.prototype,Wt=Object.prototype,qt=jt.toString,Ut=Wt.hasOwnProperty,zt=qt.call(Object);function Ht(e){if(!K(e)||"[object Object]"!=$(e))return!1;var t=Lt(e);if(null===t)return!0;var i=Ut.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&qt.call(i)==zt}function $t(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 Kt=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function Gt(e){return Kt.test(e)}var Jt="\\ud800-\\udfff",Zt="["+Jt+"]",Qt="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Yt="\\ud83c[\\udffb-\\udfff]",Xt="[^"+Jt+"]",ei="(?:\\ud83c[\\udde6-\\uddff]){2}",ti="[\\ud800-\\udbff][\\udc00-\\udfff]",ii="(?:"+Qt+"|"+Yt+")"+"?",ni="[\\ufe0e\\ufe0f]?",si=ni+ii+("(?:\\u200d(?:"+[Xt,ei,ti].join("|")+")"+ni+ii+")*"),oi="(?:"+[Xt+Qt+"?",Qt,ei,ti,Zt].join("|")+")",ri=RegExp(Yt+"(?="+Yt+")|"+oi+si,"g");function ai(e){return Gt(e)?function(e){return e.match(ri)||[]}(e):function(e){return e.split("")}(e)}var li,ci=(li="toUpperCase",function(e){var t=Gt(e=Ft(e))?ai(e):void 0,i=t?t[0]:e.charAt(0),n=t?function(e,t,i){var n=e.length;return $t(e,t,i=void 0===i?n:i)}(t,1).join(""):e.slice(1);return i[li]()+n});function ui(e){var t=this.__data__=new Ct(e);this.size=t.size}ui.prototype.clear=function(){this.__data__=new Ct,this.size=0},ui.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},ui.prototype.get=function(e){return this.__data__.get(e)},ui.prototype.has=function(e){return this.__data__.has(e)},ui.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Ct){var n=i.__data__;if(!Pt||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new xt(n)}return i.set(e,t),this.size=i.size,this};var hi="object"==typeof exports&&exports&&!exports.nodeType&&exports,di=hi&&"object"==typeof module&&module&&!module.nodeType&&module,mi=di&&di.exports===hi?N.Buffer:void 0,fi=mi?mi.allocUnsafe:void 0;function gi(e,t){if(t)return e.slice();var i=e.length,n=fi?fi(i):new e.constructor(i);return e.copy(n),n}function pi(){return[]}var _i=Object.prototype.propertyIsEnumerable,wi=Object.getOwnPropertySymbols,bi=wi?function(e){return null==e?[]:(e=Object(e),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}(wi(e),function(t){return _i.call(e,t)}))}:pi;var vi=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Nt(t,bi(e)),e=Lt(e);return t}:pi;function yi(e,t,i){var n=t(e);return J(e)?n:Nt(n,i(e))}function Ai(e){return yi(e,ht,bi)}function ki(e){return yi(e,ft,vi)}var Ei=ye(N,"DataView"),Ci=ye(N,"Promise"),Pi=ye(N,"Set"),Ti="[object Map]",xi="[object Promise]",Di="[object Set]",Si="[object WeakMap]",Ii="[object DataView]",Oi=me(Ei),Fi=me(Pt),Bi=me(Ci),Mi=me(Pi),Ri=me(Ae),Vi=$;(Ei&&Vi(new Ei(new ArrayBuffer(1)))!=Ii||Pt&&Vi(new Pt)!=Ti||Ci&&Vi(Ci.resolve())!=xi||Pi&&Vi(new Pi)!=Di||Ae&&Vi(new Ae)!=Si)&&(Vi=function(e){var t=$(e),i="[object Object]"==t?e.constructor:void 0,n=i?me(i):"";if(n)switch(n){case Oi:return Ii;case Fi:return Ti;case Bi:return xi;case Mi:return Di;case Ri:return Si}return t});var Ni=Object.prototype.hasOwnProperty;var Li=N.Uint8Array;function ji(e){var t=new e.constructor(e.byteLength);return new Li(t).set(new Li(e)),t}var Wi=/\w*$/;
vendor: 4,262 bytes, line 2
2var qi=L?L.prototype:void 0,Ui=qi?qi.valueOf:void 0;function zi(e,t){var i=t?ji(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function Hi(e,t,i){var n,s=e.constructor;switch(t){case"[object ArrayBuffer]":return ji(e);case"[object Boolean]":case"[object Date]":return new s(+e);case"[object DataView]":return function(e,t){var i=t?ji(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}(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 zi(e,i);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,Wi.exec(e));return t.lastIndex=e.lastIndex,t}(e);case"[object Symbol]":return n=e,Ui?Object(Ui.call(n)):{}}}function $i(e){return"function"!=typeof e.constructor||qe(e)?{}:Ee(Lt(e))}var Ki=nt&&nt.isMap,Gi=Ki?Xe(Ki):function(e){return K(e)&&"[object Map]"==Vi(e)};var Ji=nt&&nt.isSet,Zi=Ji?Xe(Ji):function(e){return K(e)&&"[object Set]"==Vi(e)},Qi="[object Arguments]",Yi="[object Function]",Xi="[object Object]",en={};function tn(e,t,i,n,s,o){var r,a=1&t,l=2&t,c=4&t;if(i&&(r=s?i(e,n,s,o):i(e)),void 0!==r)return r;if(!ie(e))return e;var u=J(e);if(u){if(r=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&Ni.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(e),!a)return Ce(e,r)}else{var h=Vi(e),d=h==Yi||"[object GeneratorFunction]"==h;if(Qe(e))return gi(e,a);if(h==Xi||h==Qi||d&&!s){if(r=l||d?{}:$i(e),!a)return l?function(e,t){return Me(e,vi(e),t)}(e,function(e,t){return e&&Me(t,ft(t),e)}(r,e)):function(e,t){return Me(e,bi(e),t)}(e,function(e,t){return e&&Me(t,ht(t),e)}(r,e))}else{if(!en[h])return s?e:{};r=Hi(e,h,a)}}o||(o=new ui);var m=o.get(e);if(m)return m;o.set(e,r),Zi(e)?e.forEach(function(n){r.add(tn(n,t,i,n,e,o))}):Gi(e)&&e.forEach(function(n,s){r.set(s,tn(n,t,i,s,e,o))});var f=u?void 0:(c?l?ki:Ai:l?ft:ht)(e);return function(e,t){for(var i=-1,n=null==e?0:e.length;++i<n&&!1!==t(e[i],i,e););}(f||e,function(n,s){f&&(n=e[s=n]),Be(r,s,tn(n,t,i,s,e,o))}),r}en[Qi]=en["[object Array]"]=en["[object ArrayBuffer]"]=en["[object DataView]"]=en["[object Boolean]"]=en["[object Date]"]=en["[object Float32Array]"]=en["[object Float64Array]"]=en["[object Int8Array]"]=en["[object Int16Array]"]=en["[object Int32Array]"]=en["[object Map]"]=en["[object Number]"]=en[Xi]=en["[object RegExp]"]=en["[object Set]"]=en["[object String]"]=en["[object Symbol]"]=en["[object Uint8Array]"]=en["[object Uint8ClampedArray]"]=en["[object Uint16Array]"]=en["[object Uint32Array]"]=!0,en["[object Error]"]=en[Yi]=en["[object WeakMap]"]=!1;function nn(e){return tn(e,4)}function sn(e){return tn(e,5)}function on(e,t){return tn(e,5,t="function"==typeof t?t:void 0)}function rn(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new xt;++t<i;)this.add(e[t])}function an(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}rn.prototype.add=rn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},rn.prototype.has=function(e){return this.__data__.has(e)};function ln(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),u=o.get(t);if(c&&u)return c==t&&u==e;var h=-1,d=!0,m=2&i?new rn:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var f=e[h],g=t[h];if(n)var p=r?n(g,f,h,t,e,o):n(f,g,h,e,t,o);if(void 0!==p){if(p)continue;d=!1;break}if(m){if(!an(t,function(e,t){if(r=t,!m.has(r)&&(f===e||s(f,e,i,n,o)))return m.push(t);var r})){d=!1;break}}else if(f!==g&&!s(f,g,i,n,o)){d=!1;break}}return o.delete(e),o.delete(t),d}function cn(e){var t=-1,i=Array(e.size);return e.forEach(function(e,n){i[++t]=[n,e]}),i}function un(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var hn=L?L.prototype:void 0,dn=hn?hn.valueOf:void 0;var mn=Object.prototype.hasOwnProperty;var fn="[object Arguments]",gn="[object Array]",pn="[object Object]",_n=Object.prototype.hasOwnProperty;function wn(e,t,i,n,s,o){var r=J(e),a=J(t),l=r?gn:Vi(e),c=a?gn:Vi(t),u=(l=l==fn?pn:l)==
2pn,h=(c=c==fn?pn:c)==pn,d=l==c;if(d&&Qe(e)){if(!Qe(t))return!1;r=!0,u=!1}if(d&&!u)return o||(o=new ui),r||ot(e)?ln(e,t,i,n,s,o):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 Li(e),new Li(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Oe(+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=cn;case"[object Set]":var l=1&n;if(a||(a=un),e.size!=t.size&&!l)return!1;var c=r.get(e);if(c)return c==t;n|=2,r.set(e,t);var u=ln(a(e),a(t),n,s,o,r);return r.delete(e),u;case"[object Symbol]":if(dn)return dn.call(e)==dn.call(t)}return!1}(e,t,l,i,n,s,o);if(!(1&i)){var m=u&&_n.call(e,"__wrapped__"),f=h&&_n.call(t,"__wrapped__");if(m||f){var g=m?e.value():e,p=f?t.value():t;return o||(o=new ui),s(g,p,i,n,o)}}return!!d&&(o||(o=new ui),function(e,t,i,n,s,o){var r=1&i,a=Ai(e),l=a.length;if(l!=Ai(t).length&&!r)return!1;for(var c=l;c--;){var u=a[c];if(!(r?u in t:mn.call(t,u)))return!1}var h=o.get(e),d=o.get(t);if(h&&d)return h==t&&d==e;var m=!0;o.set(e,t),o.set(t,e);for(var f=r;++c<l;){var g=e[u=a[c]],p=t[u];if(n)var _=r?n(p,g,u,t,e,o):n(g,p,u,e,t,o);if(!(void 0===_?g===p||s(g,p,i,n,o):_)){m=!1;break}f||(f="constructor"==u)}if(m&&!f){var w=e.constructor,b=t.constructor;w==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b||(m=!1)}return o.delete(e),o.delete(t),m}(e,t,i,n,s,o))}function bn(e,t,i,n,s){return e===t||(null==e||null==t||!K(e)&&!K(t)?e!==e&&t!==t:wn(e,t,i,n,bn,s))}function vn(e){return e===e&&!ie(e)}function yn(e,t){return function(i){return null!=i&&(i[e]===t&&(void 0!==t||e in Object(i)))}}function An(e){var t=function(e){for(var t=ht(e),i=t.length;i--;){var n=t[i],s=e[n];t[i]=[n,s,vn(s)]}return t}(e);return 1==t.length&&t[0][2]?yn(t[0][0],t[0][1]):function(i){return i===e||function(e,t,i,n){var s=i.length,o=s;if(null==e)return!o;for(e=Object(e);s--;){var r=i[s];if(r[2]?r[1]!==e[r[0]]:!(r[0]in e))return!1}for(;++s<o;){var a=(r=i[s])[0],l=e[a],c=r[1];if(r[2]){if(void 0===l&&!(a in e))return!1}else if(!bn(c,l,3,n,new ui))return!1}return!0}(i,0,t)}}function kn(e,t){return null!=e&&t in Object(e)}function En(e,t){return null!=e&&function(e,t,i){for(var n=-1,s=(t=Bt(t,e)).length,o=!1;++n<s;){var r=Mt(t[n]);if(!(o=null!=e&&i(e,r)))break;e=e[r]}return o||++n!=s?o:!!(s=null==e?0:e.length)&&Ne(s)&&Se(r,s)&&(J(e)||Ke(e))}(e,t,kn)}function Cn(e){return wt(e)?(t=Mt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Rt(t,e)}}(e);var t}function Pn(e){return"function"==typeof e?e:null==e?le:"object"==typeof e?J(e)?(t=e[0],i=e[1],wt(t)&&vn(i)?yn(Mt(t),i):function(e){var n=Vt(e,t);return void 0===n&&n===i?En(e,t):bn(i,n,3)}):An(e):Cn(e);var t,i}var Tn=function(e,t,i){for(var n=-1,s=Object(e),o=i(e),r=o.length;r--;){var a=o[++n];if(!1===t(s[a],a,s))break}return e};var xn=function(){return N.Date.now()},Dn=Math.max,Sn=Math.min;function In(e,t,i){var n,s,o,r,a,l,c=0,u=!1,h=!1,d=!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){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function g(){var e=xn();if(f(e))return p(e);a=setTimeout(g,function(e){var i=t-(e-l);return h?Sn(i,o-(e-c)):i}(e))}function p(e){return a=void 0,d&&n?m(e):(n=s=void 0,r)}function _(){var e=xn(),i=f(e);if(n=arguments,s=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(g,t),u?m(e):r}(l);if(h)return clearTimeout(a),a=setTimeout(g,t),m(l)}return void 0===a&&(a=setTimeout(g,t)),r}return t=ae(t)||0,ie(i)&&(u=!!i.leading,o=(h="maxWait"in i)?Dn(ae(i.maxWait)||0,t):o,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},_.flush=function(){return void 0===a?r:p(xn())},_}function On(e,t,i){(void 0!==i&&!Oe(e[t],i)||void 0===i&&!(t in e))&&Ie(e,t,i)}function Fn(e,t){if(("constructor"!==t||"function"!==typeof e[t])&&"__proto__"!=t)return e[t]}function Bn(e,t,i,n,s,o,r){var a=Fn(e,i),l=Fn(t,i),c=r.get(l);if(c)On(e,i,c);else{var u,h=o?o(a,l,i+"",e,t,r):void 0,d=void 0===h;if(d){var m=J(l),f=!m&&Qe(l),g=!m&&!f&&ot(l);h=l,m||f||g?J(a)?h=a:K(u=a)&&Le(u)?h=Ce(a):f?(d=!1,h=gi(l,!0)):g?(d=!1,h=zi(l,!0)):h=[]:Ht(l)||Ke(l)?(h=a,Ke(a)?h=function(e){return Me(e,ft(e))}(a):ie(a)&&!ce(a)||(h=$i(l))):d=!1}d&&(r.set(l,h),s(h,l,n,o,r),r.delete(l)),On(e,i,h)}}function Mn(e,t,i,n,s){e!==t&&Tn(t,function(o,r){if(s||(s=new ui),ie(o))Bn(e,t,r,i,Mn,n,s);else{var a=n?n(Fn(e,r),o,r+"",e,t,s):void 0;void 0===a&&(a=o),On(e,r,a)}},ft)}var Rn=/[\\^$.*+?()[\]{}|]/g,Vn=RegExp(Rn.source);function Nn(e){return"string"==typeof e||!J(e)&&K(e)&&"[object String]"==$(e)}function Ln(e){return K(e)&&1===e.nodeType&&!Ht(e)}function jn(e,t){return bn(e,t)}function Wn(e,t,i){var n=(i="function"==typeof i?i:void 0)?i(e,t):void 0;return void 0===n?bn(e,t,void 0,i):!!n}function qn(e,t){var i={};return t=Pn(t),function(e,t){e&&Tn(e,t,ht)}(e,function(e,n,s){Ie(i,n,t(e,n,s))}),i}var Un=je(function(e,t,i){Mn(e,t,i)});function zn(e,t){return null==(e=function(e,t){return t.length<2?e:Rt(e,$t(t,0,-1))}(e,t=Bt(t,e)))||delete e[Mt(function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}(t))]}function Hn(e,t,i){return null==e?e:function(e,t,i){if(!ie(e))return e;for(var n=-1,s=(t=Bt(t,e)).length,o=s-1,r=e;null!=r&&++n<s;){var a=Mt(t[n]),l=i;if("__proto__"===a||"constructor"===a||"prototype"===a)return e;if(n!=o){var c=r[a];void 0===(l=void 0)&&(l=ie(c)?c:Se(t[n+1])?[]:{})}Be(r,a,l),r=r[a]}return e}(e,t,i)}function $n(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return ie(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),In(e,t,{leading:n,maxWait:t,trailing:s})}function Kn(e,t){return null==e||zn(e,t)}let Gn;try{Gn={window:window,document:document}}catch(by){Gn={window:{},document:{}}}var Jn=Gn;function Zn(){try{return navigator.userAgent.toLowerCase()}catch(by){return""}}
2const Qn=Zn(),Yn={isMac:Xn(Qn),isWindows:es(Qn),isGecko:ts(Qn),isSafari:is(Qn),isiOS:ns(Qn),isAndroid:ss(Qn),isBlink:os(Qn)};function Xn(e){return e.indexOf("macintosh")>-1}function es(e){return e.indexOf("windows")>-1}function ts(e){return!!e.match(/gecko\/\d+/)}function is(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}function ns(e){return!!e.match(/iphone|ipad/i)||Xn(e)&&navigator.maxTouchPoints>0}function ss(e){return e.indexOf("android")>-1}function os(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}function rs(e,t,i,n){i=i||function(e,t){return e===t};const s=Array.isArray(e)?e:Array.prototype.slice.call(e),o=Array.isArray(t)?t:Array.prototype.slice.call(t),r=function(e,t,i){const n=as(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=ls(e,n),o=ls(t,n),r=as(s,o,i),a=e.length-r,l=t.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(s,o,i),a=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}(r,o.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}(o,r);return a}function as(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 ls(e,t){return e.slice(t).reverse()}function cs(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 cs.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,u={},h={};function d(n){const s=(void 0!==h[n-1]?h[n-1]:-1)+1,c=void 0!==h[n+1]?h[n+1]:-1,d=s>c?-1:1;u[n+d]&&(u[n]=u[n+d].slice(0)),u[n]||(u[n]=[]),u[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++,u[n].push("equal");return m}let m,f=0;do{for(m=-f;m<c;m++)h[m]=d(m);for(m=c+f;m>c;m--)h[m]=d(m);h[c]=d(c),f++}while(h[c]!==l);return u[c].slice(1)}cs.fastDiff=rs;class us{constructor(e,t){(0,o.A)(this,"source",void 0),(0,o.A)(this,"name",void 0),(0,o.A)(this,"path",void 0),(0,o.A)(this,"stop",void 0),(0,o.A)(this,"off",void 0),(0,o.A)(this,"return",void 0),this.source=e,this.name=t,this.path=[],this.stop=function e(){e.called=!0},this.off=function e(){e.called=!0}}}const hs=new Array(256).fill("").map((e,t)=>("0"+t.toString(16)).slice(-2));function ds(){const[e,t,i,n]=crypto.getRandomValues(new Uint32Array(4));return"e"+hs[255&e]+hs[e>>8&255]+hs[e>>16&255]+hs[e>>24&255]+hs[255&t]+hs[t>>8&255]+hs[t>>16&255]+hs[t>>24&255]+hs[255&i]+hs[i>>8&255]+hs[i>>16&255]+hs[i>>24&255]+hs[255&n]+hs[n>>8&255]+hs[n>>16&255]+hs[n>>24&255]}const ms={get(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"normal";return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function fs(e,t){const i=ms.get(t.priority);let n=0,s=e.length;for(;n<s;){const t=n+s>>1;ms.get(e[t].priority)<i?s=t:n=t+1}e.splice(n,0,t)}class gs extends Error{constructor(e,t,i){super(function(e,t){const i=new WeakSet,n=(e,t)=>{if("object"===typeof t&&null!==t){if(i.has(t))return"[object ".concat(t.constructor.name,"]");i.add(t)}return t},s=t?" ".concat(JSON.stringify(t,n)):"",o=_s(e);return e+s+o}(e,i)),(0,o.A)(this,"context",void 0),(0,o.A)(this,"data",void 0),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 gs(e.message,t);throw i.stack=e.stack,i}}function ps(e,t){console.warn(...ws(e,t))}function _s(e){return"\nRead more: ".concat("https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html","#error-").concat(e)}function ws(e,t){const i=_s(e);return t?[e,t,i]:[e,i]}const bs=new Date(2025,2,5);if(globalThis.CKEDITOR_VERSION)throw new gs("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION="44.3.0";const vs=Symbol("listeningTo"),ys=Symbol("emitterId"),As=Symbol("delegations"),ks=Es(Object);function Es(e){if(!e)return ks;return class extends e{on(e,t,i){this.listenTo(this,e,t,i)}once(e,t,i){var n=this;let s=!1;this.listenTo(this,e,function(e){if(!s){s=!0,e.off();for(var i=arguments.length,o=new Array(i>1?i-1:0),r=1;r<i;r++)o[r-1]=arguments[r];t.call(n,e,...o)}},i)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,i){let n,s,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this[vs]||(this[vs]={});const r=this[vs];Ps(e)||Cs(e);const a=Ps(e);(n=r[a])||(n=r[a]={emitter:e,callbacks:{}}),(s=n.callbacks[t])||(s=n.callbacks[t]=[]),s.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,o)}stopListening(e,t,i){const n=this[vs];let s=e&&Ps(e);const o=n&&s?n[s]:void 0,r=o&&t?o.callbacks[t]:void 0;if(!(!n||e&&!o||t&&!r))if(i){Is(this,e,t,i);-1!==r.indexOf(i)&&(1===r.length?delete o.callbacks[t]:Is(this,e,t,i))}else if(r){for(;i=r.pop();)Is(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[vs]}}fire(e){try{const s=e instanceof us?e:new us(this,e),o=s.name;let r=function(e,t){if(!e._events)return null;let i=t;do{const t=e._events[i];if(t&&t.callbacks&&t.callbacks.length)return t.callbacks;const n=i.lastIndexOf(":");i=n>-1?i.substring(0,n):""}while(i);return null}(this,o);s.path.push(this);for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];if(r){r=r.slice();for(let e=0;e<r.length;e++){const t=r[e].callback;
2if(t.call(this,s,...i),s.off.called&&(delete s.off.called,this._removeEventListener(o,t)),s.stop.called)break}}const a=this[As];if(a){const e=a.get(o),t=a.get("*");e&&Ss(e,s,i),t&&Ss(t,s,i)}return s.return}catch(s){gs.rethrowUnexpectedError(s,this)}}delegate(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return{to:(e,i)=>{this[As]||(this[As]=new Map),t.forEach(t=>{const n=this[As].get(t);n?n.set(e,i):this[As].set(t,new Map([[e,i]]))})}}}stopDelegating(e,t){if(this[As])if(e)if(t){const i=this[As].get(e);i&&i.delete(t)}else this[As].delete(e);else this[As].clear()}_addEventListener(e,t,i){!function(e,t){const i=Ts(e);if(i[t])return;let n=t,s=null;const o=[];for(;""!==n&&!i[n];)i[n]=xs(),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=Ds(this,e),s={callback:t,priority:ms.get(i.priority)};for(const o of n)fs(o,s)}_removeEventListener(e,t){const i=Ds(this,e);for(const n of i)for(let e=0;e<n.length;e++)n[e].callback==t&&(n.splice(e,1),e--)}}}
2function Cs(e,t){e[ys]||(e[ys]=t||ds())}function Ps(e){return e[ys]}function Ts(e){return e._events||Object.defineProperty(e,"_events",{value:{}}),e._events}function xs(){return{callbacks:[],childEvents:[]}}function Ds(e,t){const i=Ts(e)[t];if(!i)return[];let n=[i.callbacks];for(let s=0;s<i.childEvents.length;s++){const t=Ds(e,i.childEvents[s]);n=n.concat(t)}return n}function Ss(e,t,i){for(let[n,s]of e){s?"function"==typeof s&&(s=s(t.name)):s=t.name;const e=new us(t.source,s);e.path=[...t.path],n.fire(e,...i)}}function Is(e,t,i,n){t._removeEventListener?t._removeEventListener(i,n):e._removeEventListener.call(t,i,n)}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(e=>{Es[e]=ks.prototype[e]});const Os=Symbol("observableProperties"),Fs=Symbol("boundObservables"),Bs=Symbol("boundProperties"),Ms=Symbol("decoratedMethods"),Rs=Symbol("decoratedOriginal"),Vs=Ns(Es());function Ns(e){if(!e)return Vs;return class extends e{constructor(){super(...arguments),(0,o.A)(this,Os,void 0),(0,o.A)(this,Ms,void 0),(0,o.A)(this,Bs,void 0),(0,o.A)(this,Fs,void 0)}set(e,t){if(ie(e))return void Object.keys(e).forEach(t=>{this.set(t,e[t])},this);Ls(this);const i=this[Os];if(e in this&&!i.has(e))throw new gs("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:".concat(e),e,t,n);void 0===s&&(s=t),n===s&&i.has(e)||(i.set(e,s),this.fire("change:".concat(e),e,s,n))}}),this[e]=t}bind(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!t.length||!qs(t))throw new gs("observable-bind-wrong-properties",this);if(new Set(t).size!==t.length)throw new gs("observable-bind-duplicate-properties",this);Ls(this);const n=this[Bs];t.forEach(e=>{if(n.has(e))throw new gs("observable-bind-rebind",this)});const s=new Map;return t.forEach(e=>{const t={property:e,to:[]};n.set(e,t),s.set(e,t)}),{to:js,toMany:Ws,_observable:this,_bindProperties:t,_to:[],_bindings:s}}unbind(){if(!this[Os])return;const e=this[Bs],t=this[Fs];for(var i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];if(n.length){if(!qs(n))throw new gs("observable-unbind-wrong-properties",this);n.forEach(i=>{const n=e.get(i);n&&(n.to.forEach(e=>{let[i,s]=e;const o=t.get(i),r=o[s];r.delete(n),r.size||delete o[s],Object.keys(o).length||(t.delete(i),this.stopListening(i,"change"))}),e.delete(i))})}else t.forEach((e,t)=>{this.stopListening(t,"change")}),t.clear(),e.clear()}decorate(e){Ls(this);const t=this[e];if(!t)throw new gs("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,(e,i)=>{e.return=t.apply(this,i)}),this[e]=function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return this.fire(e,i)},this[e][Rs]=t,this[Ms]||(this[Ms]=[]),this[Ms].push(e)}stopListening(e,t,i){if(!e&&this[Ms]){for(const e of this[Ms])this[e]=this[e][Rs];delete this[Ms]}super.stopListening(e,t,i)}}}function Ls(e){e[Os]||(Object.defineProperty(e,Os,{value:new Map}),Object.defineProperty(e,Fs,{value:new Map}),Object.defineProperty(e,Bs,{value:new Map}))}function js(){const e=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!t.length)throw new gs("observable-bind-to-parse-error",null);const n={to:[]};let s;"function"==typeof t[t.length-1]&&(n.callback=t.pop());return t.forEach(e=>{if("string"==typeof e)s.properties.push(e);else{if("object"!=typeof e)throw new gs("observable-bind-to-parse-error",null);s={observable:e,properties:[]},n.to.push(s)}}),n}(...arguments),t=Array.from(this._bindings.keys()),i=t.length;if(!e.callback&&e.to.length>1)throw new gs("observable-bind-to-no-callback",this);if(i>1&&e.callback)throw new gs("observable-bind-to-extra-callback",this);var n;e.to.forEach(e=>{if(e.properties.length&&e.properties.length!==i)throw new gs("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)}),this._to=e.to,e.callback&&(this._bindings.get(t[0]).callback=e.callback),n=this._observable,this._to.forEach(e
2=>{const t=n[Fs];let i;t.get(e.observable)||n.listenTo(e.observable,"change",(s,o)=>{i=t.get(e.observable)[o],i&&i.forEach(e=>{Us(n,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[Fs],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=>{Us(this._observable,e)})}function Ws(e,t,i){if(this._bindings.size>1)throw new gs("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 qs(e){return e.every(e=>"string"==typeof e)}function Us(e,t){const i=e[Bs].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)}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(e=>{Ns[e]=Vs.prototype[e]});class zs{constructor(){(0,o.A)(this,"_replacedElements",void 0),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(e=>{let{element:t,newElement:i}=e;t.style.display="",i&&i.remove()}),this._replacedElements=[]}}function Hs(e){let t=0;for(const i of e)t++;return t}function $s(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"}function Ks(e){return!(!e||!e[Symbol.iterator])}function Gs(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];const s=i&&i.xmlns,o=s?e.createElementNS(s,t):e.createElement(t);for(const r in i)o.setAttribute(r,i[r]);!Nn(n)&&Ks(n)||(n=[n]);for(let r of n)Nn(r)&&(r=e.createTextNode(r)),o.appendChild(r);return o}class Js{constructor(e,t){(0,o.A)(this,"_config",void 0),this._config=Object.create(null),t&&this.define(Zs(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){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Ht(t))return void this._setObjectToTarget(e,t,n);const s=t.split(".");t=s.pop();for(const o of s)Ht(e[o])||(e[o]=Object.create(null)),e=e[o];if(Ht(i))return Ht(e[t])||(e[t]=Object.create(null)),e=e[t],void this._setObjectToTarget(e,i,n);n&&"undefined"!=typeof e[t]||(e[t]=i)}_getFromSource(e,t){const i=t.split(".");t=i.pop();for(const n of i){if(!Ht(e[n])){e=null;break}e=e[n]}return e?Zs(e[t]):void 0}_setObjectToTarget(e,t,i){Object.keys(t).forEach(n=>{this._setToTarget(e,n,t[n],i)})}}function Zs(e){return on(e,Qs)}function Qs(e){return Ln(e)||"function"===typeof e?e:void 0}function Ys(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}function Xs(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const eo=to(Es());function to(e){if(!e)return eo;return class extends e{listenTo(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(Ys(e)||Xs(e)){const s={capture:!!n.useCapture,passive:!!n.usePassive},o=this._getProxyEmitter(e,s)||new io(e,s);this.listenTo(o,t,i,n)}else super.listenTo(e,t,i,n)}stopListening(e,t,i){if(Ys(e)||Xs(e)){const n=this._getAllProxyEmitters(e);for(const e of n)this.stopListening(e,t,i)}else super.stopListening(e,t,i)}_getProxyEmitter(e,t){return function(e,t){const i=e[vs];return i&&i[t]?i[t].emitter:null}(this,no(e,t))}_getAllProxyEmitters(e){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map(t=>this._getProxyEmitter(e,t)).filter(e=>!!e)}}}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(e
2=>{to[e]=eo.prototype[e]});class io extends(Es()){constructor(e,t){super(),(0,o.A)(this,"_domNode",void 0),(0,o.A)(this,"_options",void 0),(0,o.A)(this,"_domListeners",void 0),Cs(this,no(e,t)),this._domNode=e,this._options=t}attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t}detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()}_addEventListener(e,t,i){this.attach(e),Es().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){Es().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=t=>{this.fire(e,t)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function no(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=ds())}(e);for(const n of Object.keys(t).sort())t[n]&&(i+="-"+n);return i}function so(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}function oo(e){if(!e.target)return null;const t=e.target.ownerDocument,i=e.clientX,n=e.clientY;let s=null;return t.caretRangeFromPoint&&t.caretRangeFromPoint(i,n)?s=t.caretRangeFromPoint(i,n):e.rangeParent&&(s=t.createRange(),s.setStart(e.rangeParent,e.rangeOffset),s.collapse(!0)),s}function ro(e){return"[object Text]"==Object.prototype.toString.call(e)}function ao(e){return"[object Range]"==Object.prototype.toString.apply(e)}function lo(e){return e&&e.parentNode?e.offsetParent===Jn.document.body?null:e.offsetParent:null}const co=["top","right","bottom","left","width","height"];class uo{constructor(e){(0,o.A)(this,"top",void 0),(0,o.A)(this,"right",void 0),(0,o.A)(this,"bottom",void 0),(0,o.A)(this,"left",void 0),(0,o.A)(this,"width",void 0),(0,o.A)(this,"height",void 0),(0,o.A)(this,"_source",void 0);const t=ao(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),fo(e)||t)if(t){const t=uo.getDomRangeRects(e);ho(this,uo.getBoundingRect(t))}else ho(this,e.getBoundingClientRect());else if(Xs(e)){const{innerWidth:t,innerHeight:i}=e;ho(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else ho(this,e)}clone(){return new uo(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),width:0,height:0};if(t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0)return null;{const e=new uo(t);return e._source=this._source,e}}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(mo(e))return t;let i,n=e,s=e.parentNode||e.commonAncestorContainer;for(;s&&!mo(s);){const e="visible"===po(s);n instanceof HTMLElement&&"absolute"===go(n)&&(i=n);const o=go(s);if(e||i&&("relative"===o&&e||"relative"!==o)){n=s,s=s.parentNode;continue}const r=new uo(s),a=t.getIntersection(r);if(!a)return null;a.getArea()<t.getArea()&&(t=a),n=s,s=s.parentNode}return t}isEqual(e){for(const t of co)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!(!t||!t.isEqual(e))}toAbsoluteRect(){const{scrollX:e,scrollY:t}=Jn.window,i=this.clone().moveBy(e,t);if(fo(i._source)){const e=lo(i._source);e&&function(e,t){const i=new uo(t),n=so(t);let s=0,o=0;s-=i.left,o-=i.top,s+=t.scrollLeft,o+=t.scrollTop,s-=n.left,o-=n.top,e.moveBy(s,o)}(i,e)}return i}excludeScrollbarsAndBorders(){const e=this._source;let t,i,n;if(Xs(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=so(e);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 n of i)t.push(new uo(n));else{let i=e.startContainer;ro(i)&&(i=i.parentNode);const n=new uo(i.getBoundingClientRect());n.right=n.left,n.width=0,t.push(n)}return t}
2static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const 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 uo(t))}}function ho(e,t){for(const i of co)e[i]=t[i]}function mo(e){return!!fo(e)&&e===e.ownerDocument.body}function fo(e){return null!==e&&"object"===typeof e&&1===e.nodeType&&"function"===typeof e.getBoundingClientRect}function go(e){return e instanceof HTMLElement?e.ownerDocument.defaultView.getComputedStyle(e).position:"static"}function po(e){return e instanceof HTMLElement?e.ownerDocument.defaultView.getComputedStyle(e).overflow:"visible"}class _o{constructor(e,t){(0,o.A)(this,"_element",void 0),(0,o.A)(this,"_callback",void 0),_o._observerInstance||_o._createObserver(),this._element=e,this._callback=t,_o._addElementCallback(e,t),_o._observerInstance.observe(e)}get element(){return this._element}destroy(){_o._deleteElementCallback(this._element,this._callback)}static _addElementCallback(e,t){_o._elementCallbacks||(_o._elementCallbacks=new Map);let i=_o._elementCallbacks.get(e);i||(i=new Set,_o._elementCallbacks.set(e,i)),i.add(t)}static _deleteElementCallback(e,t){const i=_o._getElementCallbacks(e);i&&(i.delete(t),i.size||(_o._elementCallbacks.delete(e),_o._observerInstance.unobserve(e))),_o._elementCallbacks&&!_o._elementCallbacks.size&&(_o._observerInstance=null,_o._elementCallbacks=null)}static _getElementCallbacks(e){return _o._elementCallbacks?_o._elementCallbacks.get(e):null}static _createObserver(){_o._observerInstance=new Jn.window.ResizeObserver(e=>{for(const t of e){const e=_o._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}})}}function wo(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function bo(e){return t=>t+e}function vo(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function yo(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function Ao(e){return e&&e.nodeType===Node.COMMENT_NODE}function ko(e){return!!e&&(ro(e)?ko(e.parentElement):!!e.getClientRects&&!!e.getClientRects().length)}function Eo(e){let{element:t,target:i,positions:n,limiter:s,fitInViewport:o,viewportOffsetConfig:r}=e;ce(i)&&(i=i()),ce(s)&&(s=s());const a=lo(t),l=function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new uo(Jn.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(r),c=new uo(t),u=Co(i,l);let h;if(!u||!l.getIntersection(u))return null;const d={targetRect:u,elementRect:c,positionedElementAncestor:a,viewportRect:l};if(s||o){if(s){const e=Co(s,l);e&&(d.limiterRect=e)}h=function(e,t){const{elementRect:i}=t,n=i.getArea(),s=e.map(e=>new Po(e,t)).filter(e=>!!e.name);let o=0,r=null;for(const a of s){const{limiterIntersectionArea:e,viewportIntersectionArea:t}=a;if(e===n)return a;const i=t**2+e**2;i>o&&(o=i,r=a)}return r}(n,d)}else h=new Po(n[0],d);return h}function Co(e,t){const i=new uo(e).getVisible();return i?i.getIntersection(t):null}(0,o.A)(_o,"_observerInstance",null),(0,o.A)(_o,"_elementCallbacks",null);class Po{constructor(e,t){(0,o.A)(this,"name",void 0),(0,o.A)(this,"config",void 0),(0,o.A)(this,"_positioningFunctionCoordinates",void 0),(0,o.A)(this,"_options",void 0),(0,o.A)(this,"_cachedRect",void 0),(0,o.A)(this,"_cachedAbsoluteRect",void 0);const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:n,top:s,name:r,config:a}=i;this.name=r,this.config=a,this._positioningFunctionCoordinates={left:n,top:s},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;return e?e.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=this._rect.toAbsoluteRect()),this._cachedAbsoluteRect}}function To(e){const t=e.parentNode;t&&t.removeChild(e)}
2function xo(e){let{window:t,rect:i,alignToTop:n,forceScroll:s,viewportOffset:o}=e;const r=i.clone().moveBy(0,o.bottom),a=i.clone().moveBy(0,-o.top),l=new uo(t).excludeScrollbarsAndBorders(),c=n&&s,u=[a,r].every(e=>l.contains(e));let{scrollX:h,scrollY:d}=t;const m=h,f=d;c?d-=l.top-i.top+o.top:u||(Io(a,l)?d-=l.top-i.top+o.top:So(r,l)&&(d+=n?i.top-l.top-o.top:i.bottom-l.bottom+o.bottom)),u||(Oo(i,l)?h-=l.left-i.left+o.left:Fo(i,l)&&(h+=i.right-l.right+o.right)),h==m&&d===f||t.scrollTo(h,d)}function Do(e){let{parent:t,getRect:i,alignToTop:n,forceScroll:s,ancestorOffset:o=0,limiterElement:r}=e;const a=Bo(t),l=n&&s;let c,u,h;const d=r||a.document.body;for(;t!=d;)u=i(),c=new uo(t).excludeScrollbarsAndBorders(),h=c.contains(u),l?t.scrollTop-=c.top-u.top+o:h||(Io(u,c)?t.scrollTop-=c.top-u.top+o:So(u,c)&&(t.scrollTop+=n?u.top-c.top-o:u.bottom-c.bottom+o)),h||(Oo(u,c)?t.scrollLeft-=c.left-u.left+o:Fo(u,c)&&(t.scrollLeft+=u.right-c.right+o)),t=t.parentNode}function So(e,t){return e.bottom>t.bottom}function Io(e,t){return e.top<t.top}function Oo(e,t){return e.left<t.left}function Fo(e,t){return e.right>t.right}function Bo(e){return ao(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function Mo(e){if(ao(e)){let t=e.commonAncestorContainer;return ro(t)&&(t=t.parentNode),t}return e.parentNode}function Ro(e,t){const i=Bo(e),n=new uo(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new uo(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const Vo={ctrl:"\u2303",cmd:"\u2318",alt:"\u2325",shift:"\u21e7"},No={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},Lo={37:"\u2190",38:"\u2191",39:"\u2192",40:"\u2193",9:"\u21e5",33:"Page Up",34:"Page Down"},jo=$o(),Wo=Object.fromEntries(Object.entries(jo).map(e=>{let t,[i,n]=e;return t=n in Lo?Lo[n]:i.charAt(0).toUpperCase()+i.slice(1),[n,t]}));function qo(e){let t;if("string"==typeof e){if(t=jo[e.toLowerCase()],!t)throw new gs("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?jo.alt:0)+(e.ctrlKey?jo.ctrl:0)+(e.shiftKey?jo.shift:0)+(e.metaKey?jo.cmd:0);return t}function Uo(e){return"string"==typeof e&&(e=function(e){return e.split("+").map(e=>e.trim())}(e)),e.map(e=>"string"==typeof e?function(e){if(e.endsWith("!"))return qo(e.slice(0,-1));const t=qo(e);return(Yn.isMac||Yn.isiOS)&&t==jo.ctrl?jo.cmd:t}(e):e).reduce((e,t)=>t+e,0)}function zo(e,t){let i=Uo(e);const n=Yn.isMac||Yn.isiOS;return Object.entries(n?Vo:No).reduce((e,t)=>{let[n,s]=t;return 0!=(i&jo[n])&&(i&=~jo[n],e+=s),e},"")+(i?Wo[i]:"")}function Ho(e,t){const i="ltr"===t;switch(e){case jo.arrowleft:return i?"left":"right";case jo.arrowright:return i?"right":"left";case jo.arrowup:return"up";case jo.arrowdown:return"down"}}function $o(){const e={pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){e[String.fromCharCode(t).toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return Object.assign(e,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),e}const Ko=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig"];function Go(e){return Ko.includes(e)?"rtl":"ltr"}function Jo(e){return Array.isArray(e)?e:[e]}function Zo(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3?arguments[3]:void 0;if("number"!==typeof i)throw new gs("translation-service-quantity-not-a-number",null,{quantity:i});const s=n||Jn.window.CKEDITOR_TRANSLATIONS,o=function(e){return Object.keys(e).length}(s);1===o&&(e=Object.keys(s)[0]);const r=t.id||t.string;if(0===o||!function(e,t,i){return!!i[e]&&!!i[e].dictionary[t]}(e,r,s))return 1!==i?t.plural:t.string;const a=s[e].dictionary,l=s[e].getPluralForm||(e=>1===e?0:1),c=a[r];if("string"===typeof c)return c;return c[Number(l(i))]}Jn.window.CKEDITOR_TRANSLATIONS||(Jn.window.CKEDITOR_TRANSLATIONS={});class Qo{constructor(){let{uiLanguage:e="en",contentLanguage:t,translations:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,o.A)(this,"uiLanguage",void 0),(0,o.A)(this,"uiLanguageDirection",void 0),(0,o.A)(this,"contentLanguage",void 0),(0,o.A)(this,"contentLanguageDirection",void 0),(0,o.A)(this,"t",void 0),(0,o.A)(this,"translations",void 0),this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=Go(this.uiLanguage),this.contentLanguageDirection=Go(this.contentLanguage),this.translations=function(e){return Array.isArray(e)?e.reduce((e,t)=>
2Un(e,t)):e}(i),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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];t=Jo(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)}(Zo(this.uiLanguage,e,i,this.translations),t)}}class Yo extends(Es()){constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),(0,o.A)(this,"_items",void 0),(0,o.A)(this,"_itemMap",void 0),(0,o.A)(this,"_idProperty",void 0),(0,o.A)(this,"_bindToCollection",void 0),(0,o.A)(this,"_bindToExternalToInternalMap",void 0),(0,o.A)(this,"_bindToInternalToExternalMap",void 0),(0,o.A)(this,"_skippedIndexesFromExternal",void 0);const i=Ks(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 n of e)this._items.push(n),this._itemMap.set(this._getItemIdBeforeAdding(n),n)}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 gs("collection-add-item-invalid-index",this);let i=0;for(const n of e){const e=this._getItemIdBeforeAdding(n),s=t+i;this._items.splice(s,0,n),this._itemMap.set(e,n),this.fire("add",n,s),i++}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 gs("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 t&&this._itemMap.has(t)}}getIndex(e){let t;return t="string"==typeof e?this._itemMap.get(e):e,t?this._items.indexOf(t):-1}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)}forEach(e,t){this._items.forEach(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 gs("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:e=>{this._setUpBindToBinding(t=>new e(t))},using:e=>{"function"==typeof e?this._setUpBindToBinding(e):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 n of t)i(0,n,t.getIndex(n));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 gs("collection-add-invalid-id",this);if(this.get(i))throw new gs("collection-add-item-already-exists",this)}else e[t]=i=ds();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 gs("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]()}}function Xo(e){const t=e.next();return t.done?null:t.value}class er extends(to(Ns())){constructor(){super(),(0,o.A)(this,"_elements",new Set),(0,o.A)(this,"_externalViews",new Set),(0,o.A)(this,"_blurTimeout",null),this.set("isFocused",!1),this.set("focusedElement",null)}get elements(){return Array.from(this._elements.values())}get externalViews(){return Array.from(this._externalViews.values())}add(e){if(ir(e))this._addElement(e);else if(tr(e))this._addView(e);else{if(!e.element)throw new gs("focustracker-add-view-missing-element",{focusTracker:this,view:e});this._addElement(e.element)}}remove(e){ir(e)?this._removeElement(e):tr(e)?this._removeView(e):this._removeElement(e.element)}_addElement(e){if(this._elements.has(e))throw new gs("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",()=>{const t=this.externalViews.find(t=>function(e,t){if(nr(e,t))return!0;return!!t.focusTracker.externalViews.find(t=>nr(e,t))}(e,t));t?this._focus(t.element):this._focus(e)},{useCapture:!0}),this.listenTo(e,"blur",()=>{this._blur()},{useCapture:!0}),this._elements.add(e)}_removeElement(e){this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e)),e===this.focusedElement&&this._blur()}_addView(e){e.element&&this._addElement(e.element),this.listenTo(e.focusTracker,"change:focusedElement",()=>{e.focusTracker.focusedElement?e.element&&this._focus(e.element):this._blur()}),this._externalViews.add(e)}_removeView(e){e.element&&this._removeElement(e.element),this.stopListening(e.focusTracker),this._externalViews.delete(e)}destroy(){this.stopListening(),this._elements.clear(),this._externalViews.clear(),this.isFocused=!1,this.focusedElement=null}_focus(e){this._clearBlurTimeout(),this.focusedElement=e,this.isFocused=!0}_blur(){if(this.elements.find(e=>e.contains(document.activeElement)))return;this.externalViews.find(e=>
2e.focusTracker.isFocused&&!e.focusTracker._blurTimeout)||(this._clearBlurTimeout(),this._blurTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0))}_clearBlurTimeout(){clearTimeout(this._blurTimeout),this._blurTimeout=null}}function tr(e){return"focusTracker"in e&&e.focusTracker instanceof er}function ir(e){return Ln(e)}function nr(e,t){return!!t.element&&t.element.contains(document.activeElement)&&e.contains(t.element)}class sr{constructor(){(0,o.A)(this,"_listener",void 0),this._listener=new(to())}listenTo(e){this._listener.listenTo(e,"keydown",(e,t)=>{this._listener.fire("_keydown:"+qo(t),t)})}set(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=Uo(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,(e,n)=>{i.filter&&!i.filter(n)||(t(n,()=>{n.preventDefault(),n.stopPropagation(),e.stop()}),e.return=!0)},{priority:s})}press(e){return!!this._listener.fire("_keydown:"+qo(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}function or(e){return Ks(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function rr(e,t,i){const n=e.length,s=t.length;for(let o=n-1;o>=i;o--)e[o+s]=e[o];for(let o=0;o<s;o++)e[i+o]=t[o]}function ar(e,t){let i;function n(){for(var s=arguments.length,o=new Array(s),r=0;r<s;r++)o[r]=arguments[r];n.cancel(),i=setTimeout(()=>e(...o),t)}return n.cancel=()=>{clearTimeout(i)},n}function lr(e){try{if(!e.startsWith("ey"))return null;const t=atob(e.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(t)}catch(by){return null}}function cr(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 ur(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}const hr=mr();function dr(e,t){const i=String(e).matchAll(hr);return Array.from(i).some(e=>e.index<t&&t<e.index+e[0].length)}function mr(){const e=/(?:\uD83C[\uDDE6-\uDDFF]){2}/.source,t="(?:"+[/(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED8\uDEDC-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8])(?:\uDB40[\uDC20-\uDC7E])+(?:\uDB40\uDC7F)/,/(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED8\uDEDC-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8
2E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8])\uFE0F?\u20E3/,/(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED8\uDEDC-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8])\uFE0F/,/(?=(?:[\xA6\xA9\xAE\xB0\u0482\u058D\u058E\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u09FA\u0B70\u0BF3-\u0BF8\u0BFA\u0C7F\u0D4F\u0D79\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116\u2117\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u214A\u214C\u214D\u214F\u218A\u218B\u2195-\u2199\u219C-\u219F\u21A1\u21A2\u21A4\u21A5\u21A7-\u21AD\u21AF-\u21CD\u21D0\u21D1\u21D3\u21D5-\u21F3\u2300-\u2307\u230C-\u231F\u2322-\u2328\u232B-\u237B\u237D-\u239A\u23B4-\u23DB\u23E2-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u25B6\u25B8-\u25C0\u25C2-\u25F7\u2600-\u266E\u2670-\u2767\u2794-\u27BF\u2800-\u28FF\u2B00-\u2B2F\u2B45\u2B46\u2B4D-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA828-\uA82B\uA836\uA837\uA839\uAA77-\uAA79\uFBC3-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFD-\uFDFF\uFFE4\uFFE8\uFFED\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFDC\uDFE1-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEEF\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838\uDD4F|\uD83B[\uDCAC\uDD2E]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFA]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]))(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED8\uDEDC-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8
2E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8])(?:\uD83C[\uDFFB-\uDFFF])*/].map(e=>e.source).join("|")+")",i="".concat(e,"|").concat(t,"(?:\u200d").concat(t,")*");return new RegExp(i,"ug")}const fr=new WeakMap;let gr=!1;function pr(e){let{view:t,element:i,text:n,isDirectHost:s=!0,keepOnFocus:o=!1}=e;const r=t.document;function a(e){const n={text:e,isDirectHost:s,keepOnFocus:o,hostElement:s?i:null};fr.get(r).set(i,n),t.change(e=>_r([[i,n]],e))}fr.has(r)||(fr.set(r,new Map),r.registerPostFixer(e=>_r(fr.get(r),e)),r.on("change:isComposing",()=>{t.change(e=>_r(fr.get(r),e))},{priority:"high"})),i.is("editableElement")&&i.on("change:placeholder",(e,t,i)=>a(i)),i.placeholder?a(i.placeholder):n&&a(n),n&&function(){gr||ps("enableplaceholder-deprecated-text-option");gr=!0}()}function _r(e,t){const i=[];let n=!1;for(const[s,o]of e)o.isDirectHost&&(i.push(s),wr(t,s,o)&&(n=!0));for(const[s,o]of e){if(o.isDirectHost)continue;const e=br(s);e&&(i.includes(e)||(o.hostElement=e,wr(t,s,o)&&(n=!0)))}return n}function wr(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(function(e){for(const t of e.getChildren())if(!t.is("uiElement"))return!0;return!1}(e))return!1;const i=e.document,n=i.selection.anchor;return(!i.isComposing||!n||n.parent!==e)&&(!!t||!i.isFocused||!!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):function(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}(e,o)&&(r=!0),r}function br(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}let vr=class{is(){throw new Error("is() method is abstract")}},yr=class extends(Es(vr)){constructor(e){super(),(0,o.A)(this,"document",void 0),(0,o.A)(this,"parent",void 0),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new gs("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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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=$s(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,i){this.fire("change:".concat(e),t,i),this.parent&&this.parent._fireChange(e,t,i)}toJSON(){const e=nn(this);return delete e.parent,e}};yr.prototype.is=function(e){return"node"===e||"view:node"===e};let Ar=class e extends yr{constructor(e,t){super(e),(0,o.A)(this,"_textData",void 0),this._textData=t}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(t){return t instanceof e&&(this===t||this.data===t.data)}_clone(){return new e(this.document,this.data)}};Ar.prototype.is=function(e){return"$text"===e||"view:$text"===e||"text"===e||"view:text"===e||"node"===e||"view:node"===e};let kr=class extends vr{constructor(e,t,i){if(super(),(0,o.A)(this,"textNode",void 0),(0,o.A)(this,"data",void 0),(0,o.A)(this,"offsetInText",void 0),this.textNode=e,t<0||t>e.data.length)throw new gs("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new gs("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}getAncestors(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}};kr.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class Er{constructor(){(0,o.A)(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 Cr(e),this._consumables.set(e,i)),i.add(t?Pr(t):e._getConsumables()))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(Pr(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return!!this.test(e,t)&&(this._consumables.set(e,!1),!0);const i=this._consumables.get(e);return void 0!==i&&i.consume(Pr(t))}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(Pr(t)))}static createFrom(e,t){if(t||(t=new Er),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const i of e.getChildren())Er.createFrom(i,t)}return t}}class Cr{constructor(e){(0,o.A)(this,"element",void 0),(0,o.A)(this,"_canConsumeName",null),(0,o.A)(this,"_attributes",new Map),this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes)if(i){let e=this._attributes.get(t);e&&"boolean"!=typeof e||(e=new Map,this._attributes.set(t,e)),e.set(i,!0)}else{if("style"==t||"class"==t)throw new gs("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,i]of e.attributes){const e=this._attributes.get(t);if(void 0===e)return null;if(!1===e)return!1;if(!0!==e)if(i){const t=e.get(i);if(void 0===t)return null;if(!t)return!1}else for(const t of e.values())if(!t)return!1}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,i]of e.attributes){const e=this._attributes.get(t);if("boolean"==typeof e)for(const[n]of this.element._getConsumables(t,i).attributes)this._attributes.set(n,!1);else if(i)for(const[,n]of this.element._getConsumables(t,i).attributes)e.set(n,!1);else for(const t of e.keys())e.set(t,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes){const e=this._attributes.get(t);if(!1!==e){if(void 0!==e&&!0!==e)if(i){!1===e.get(i)&&e.set(i,!0)}else for(const t of e.keys())e.set(t,!0)}else this._attributes.set(t,!0)}}}function Pr(e){const t=[];return"attributes"in e&&e.attributes&&Tr(t,e.attributes),"classes"in e&&e.classes&&Tr(t,e.classes,"class"),"styles"in e&&e.styles&&Tr(t,e.styles,"style"),{name:e.name||!1,attributes:t}}function Tr(e,t,i){if("string"!=typeof t)for(const n of t)Array.isArray(n)?e.push(n):e.push(i?[i,n]:[n]);else e.push(i?[i,t]:[t])}class xr{constructor(){(0,o.A)(this,"_patterns",[]),this.add(...arguments)}add(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(let n of t)("string"==typeof n||n instanceof RegExp)&&(n={name:n}),this._patterns.push(n)}match(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(const n of t)for(const e of this._patterns){const t=this._isElementMatching(n,e);if(t)return{element:n,pattern:e,match:t}}return null}matchAll(){const e=[];for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];for(const s of i)for(const t of this._patterns){const i=this._isElementMatching(s,t);i&&e.push({element:s,pattern:t,match:i})}return e.length>0?e: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}_isElementMatching(e,t){if("function"==typeof t){const i=t(e);return i&&"object"==typeof i?Pr(i):i}const i={};if(t.name&&(i.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!i.name))return null;const n=[];return t.attributes&&!function(e,t,i){let n;"object"!==typeof e||e instanceof RegExp||Array.isArray(e)?n=["class","style"]:(void 0!==e.style&&ps("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&ps("matcher-pattern-deprecated-attributes-class-key",e));return t._collectAttributesMatch(Sr(e),i,n)}(t.attributes,e,n)||t.classes&&!function(e,t,i){return t._collectAttributesMatch(Sr(e,"class"),i)}
2(t.classes,e,n)||t.styles&&!function(e,t,i){return t._collectAttributesMatch(Sr(e,"style"),i)}(t.styles,e,n)?null:(n.length&&(i.attributes=n),i)}}function Dr(e,t){return!0===e||e===t||e instanceof RegExp&&!!String(t).match(e)}function Sr(e,t){if(Array.isArray(e))return e.map(e=>"object"!==typeof e||e instanceof RegExp?t?[t,e,!0]:[e,!0]:(void 0!==e.key&&void 0!==e.value||ps("matcher-pattern-missing-key-or-value",e),t?[t,e.key,e.value]:[e.key,e.value]));if("object"!==typeof e||e instanceof RegExp)return[t?[t,e,!0]:[e,!0]];const i=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&i.push(t?[t,n,e[n]]:[n,e[n]]);return i}class Ir{constructor(e){(0,o.A)(this,"_styles",void 0),(0,o.A)(this,"_cachedStyleNames",null),(0,o.A)(this,"_cachedExpandedStyleNames",null),(0,o.A)(this,"_styleProcessor",void 0),this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=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);for(const[i,n]of t)this._styleProcessor.toNormalizedForm(i,n,this._styles);return this}has(e){if(this.isEmpty)return!1;const t=this._styleProcessor.getReducedForm(e,this._styles).find(t=>{let[i]=t;return i===e});return Array.isArray(t)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,ie(e))for(const[i,n]of Object.entries(e))this._styleProcessor.toNormalizedForm(i,n,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){for(const t of Jo(e)){this._cachedStyleNames=null,this._cachedExpandedStyleNames=null;const e=Fr(t);Kn(this._styles,e),delete this._styles[t],this._cleanEmptyObjectsOnPath(e)}}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]&&!ie(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find(t=>{let[i]=t;return i===e});return Array.isArray(t)?t[1]:void 0}getStyleNames(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isEmpty?[]:e?(this._cachedExpandedStyleNames=this._cachedExpandedStyleNames||this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames=this._cachedStyleNames||this.getStylesEntries().map(e=>{let[t]=e;return t}),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const i=[];
2for(const n of this.getStyleNames(!0))if(Dr(e,n)){if(!0===t){i.push(n);continue}Dr(t,this.getAsString(n))&&i.push(n)}return i.length?i:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const i of this._styleProcessor.getRelatedStyles(e))t.push(i)}else for(const i of this.getStyleNames()){for(const e of this._styleProcessor.getRelatedStyles(i))t.push(e);t.push(i)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=Vt(this._styles,i);if(!n)return;!Object.keys(n).length&&this.remove(i)}}class Or{constructor(){(0,o.A)(this,"_normalizers",void 0),(0,o.A)(this,"_extractors",void 0),(0,o.A)(this,"_reducers",void 0),(0,o.A)(this,"_consumables",void 0),this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(ie(t))Br(i,Fr(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:s,value:o}=n(t);Br(i,s,o)}else Br(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 Vt(t,i);const n=i(e,t);if(n)return n}return Vt(t,Fr(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]]}getStyleNames(e){const t=new Set;for(const i of this._consumables.keys()){const n=this.getNormalized(i,e);n&&("object"!=typeof n||Object.keys(n).length)&&t.add(i)}for(const i of Object.keys(e))t.add(i);return Array.from(t)}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 Fr(e){return e.replace("-",".")}function Br(e,t,i){let n=i;ie(i)&&(n=Un({},Vt(e,t),i)),Hn(e,t,n)}class Mr{constructor(){(0,o.A)(this,"_set",new Set)}get isEmpty(){return 0==this._set.size}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){this.clear();for(const t of e.split(/\s+/))t&&this._set.add(t);return this}set(e){for(const t of Jo(e))t&&this._set.add(t)}remove(e){for(const t of Jo(e))this._set.delete(t)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.keys())if(!e.has(t))return!1;return!0}_clone(){const e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){const t=[];if(!0===e){for(const e of this._set.keys())t.push(e);return t}if("string"==typeof e){for(const i of e.split(/\s+/)){if(!this._set.has(i))return;t.push(i)}return t}for(const i of this._set.keys())i.match(e)&&t.push(i);return t.length?t:void 0}_getConsumables(e){return e?[e]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(e){for(const t of e._set.keys())this._set.has(t)||this._set.add(t)}_isMatching(e){for(const t of e._set.keys())if(!this._set.has(t))return!1;return!0}}let Rr=class e extends yr{get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,i,n){super(e),(0,o.A)(this,"name",void 0),(0,o.A)(this,"_unsafeAttributesToRender",[]),(0,o.A)(this,"_attrs",void 0),(0,o.A)(this,"_children",void 0),(0,o.A)(this,"_customProperties",new Map),this.name=t,this._attrs=this._parseAttributes(i),this._children=[],n&&this._insertChild(0,n)}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())"class"!=e&&"style"!=e&&(yield e)}*getAttributes(){for(const[e,t]of this._attrs.entries())yield[e,String(t)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,t){return!!this._attrs.has(e)&&(void 0===t||(Nr(this.name,e)||Vr(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t))}isSimilar(t){if(!(t instanceof e))return!1;if(this===t)return!0;
2if(this.name!=t.name)return!1;if(this._attrs.size!==t._attrs.size)return!1;for(const[e,i]of this._attrs){const n=t._attrs.get(e);if(void 0===n)return!1;if("string"==typeof i||"string"==typeof n){if(n!==i)return!1}else if(!i.isSimilar(n))return!1}return!0}hasClass(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(const n of t)if(!this._classes||!this._classes.has(n))return!1;return!0}getClassNames(){const e=this._classes?this._classes.keys():[],t=e[Symbol.iterator]();return Object.assign(e,{next:t.next.bind(t)})}getStyle(e){return this._styles&&this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles&&this._styles.getNormalized(e)}getStyleNames(e){return this._styles?this._styles.getStyleNames(e):[]}hasStyle(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(const n of t)if(!this._styles||!this._styles.has(n))return!1;return!0}findAncestor(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=new xr(...t);let s=this.parent;for(;s&&!s.is("documentFragment");){if(n.match(s))return s;s=s.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=this._classes?this._classes.keys().sort().join(","):"",t=this._styles&&String(this._styles),i=Array.from(this._attrs).filter(e=>{let[t]=e;return"style"!=t&&"class"!=t}).map(e=>"".concat(e[0],'="').concat(e[1],'"')).sort().join(" ");return this.name+(""==e?"":' class="'.concat(e,'"'))+(t?' style="'.concat(t,'"'):"")+(""==i?"":" ".concat(i))}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=[];if(e)for(const n of this.getChildren())t.push(n._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let i=0;const n=function(e,t){if("string"==typeof t)return[new Ar(e,t)];Ks(t)||(t=[t]);const i=[];for(const n of t)"string"==typeof n?i.push(new Ar(e,n)):n instanceof kr?i.push(new Ar(e,n.data)):i.push(n);return i}(this.document,t);for(const s of n)null!==s.parent&&s._remove(),s.parent=this,s.document=this.document,this._children.splice(e,0,s),e++,i++;return i}_removeChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this._fireChange("children",this,{index:e});for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_setAttribute(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(this._fireChange("attributes",this),Nr(this.name,e)||Vr(this.name,e)){let n=this._attrs.get(e);n||(n=Nr(this.name,e)?new Ir(this.document.stylesProcessor):new Mr,this._attrs.set(e,n)),i?n.setTo(String(t)):Nr(this.name,e)?Array.isArray(t)?n.set(t[0],t[1]):n.set(t):n.set("string"==typeof t?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),void 0!==t&&(Nr(this.name,e)||Vr(this.name,e))){const i=this._attrs.get(e);return!!i&&(Vr(this.name,e)&&"string"==typeof t&&(t=t.split(/\s+/)),i.remove(t),!!i.isEmpty&&this._attrs.delete(e))}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){"string"!=typeof e?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,i){for(const[n,s,o]of e){let e=!1,r=!1;for(const[a,l]of this._attrs)if(!(i&&i.includes(a)||!Dr(n,a)))if(e=!0,"string"==typeof l){if(Dr(s,l))t.push([a]),r=!0;else if(!(n instanceof RegExp))return!1}else{const e=l._getTokensMatch(s,o||!0);if(e){r=!0;for(const i of e)t.push([a,i])}else if(!(n instanceof RegExp))return!1}if(!e||!r)return!1}return!0}_getConsumables(e,t){const i=[];if(e){const n=this._attrs.get(e);if(void 0!==n)if("string"==typeof n)i.push([e]);else for(const s of n._getConsumables(t))i.push([e,s])}else for(const[n,s]of this._attrs)if("string"==typeof s)i.push([n]);else for(const e of s._getConsumables())i.push([n,e]);return{name:!e,attributes:i}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[t,i]of e._attrs){const e=this._attrs.get(t);if(void 0!==e)if("string"==typeof e||"string"==typeof i){if(e!==i)return!1}else if(!e._canMergeFrom(i))return!1}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[t,i]of e._attrs){const e=this._attrs.get(t);void 0===e||"string"==typeof e||"string"==typeof i?this._setAttribute(t,i):e._mergeFrom(i)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[t,i]of e._attrs){const e=this._attrs.get(t);if(void 0===e)return!1;if("string"==typeof e||"string"==typeof i){if(e!==i)return!1}else if(!e._isMatching(i))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[t,i]of e._attrs){const e=this._attrs.get(t);"string"==typeof e||"string"==typeof i?this._attrs.delete(t):(e.remove(i.keys()),e.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const t=or(e);for(const[i,n]of t)if(null===n)t.delete(i);else if(Nr(this.name,i)){const e=n instanceof Ir?n._clone():new Ir(this.document.stylesProcessor).setTo(String(n));t.set(i,e)}else if(Vr(this.name,i)){const e=n instanceof Mr?n._clone():(new Mr).setTo(String(n));t.set(i,e)}else"string"!=typeof n&&t.set(i,String(n));return t}};function Vr(e,t){return"class"==t||"a"==e&&"rel"==t}function Nr(e,t){return"style"==t}Rr.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Lr extends Rr{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=jr}}function jr(){const e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const i of e)if(!i.is("uiElement"))return null;return this.childCount}Lr.prototype.is=function(e,t){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};class Wr extends(Ns(Lr)){constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),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})}destroy(){this.stopListening()}}Wr.prototype.is=function(e,t){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};const qr=Symbol("rootName");class Ur extends Wr{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(qr)}set rootName(e){this._setCustomProperty(qr,e)}set _name(e){this.name=e}}Ur.prototype.is=function(e,t){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};let zr=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if((0,o.A)(this,"direction",void 0),(0,o.A)(this,"boundaries",void 0),(0,o.A)(this,"singleCharacters",void 0),(0,o.A)(this,"shallow",void 0),(0,o.A)(this,"ignoreElementEnd",void 0),(0,o.A)(this,"_position",void 0),(0,o.A)(this,"_boundaryStartParent",void 0),(0,o.A)(this,"_boundaryEndParent",void 0),!e.boundaries&&!e.startPosition)throw new gs("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new gs("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Hr._createAt(e.startPosition):this._position=Hr._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}get position(){return this._position}skip(e){let t,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=i)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone()}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,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i&&i.is("view:$text")){if(e.isAtEnd)return this._position=Hr._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);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 kr(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",s,t,e,n)}if(n&&n.is("view:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Hr(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n&&n.is("view:$text")){if(this.singleCharacters)return e=new Hr(n,0),this._position=e,this._next();let i,s=n.data.length;return n==this._boundaryEndParent?(s=this.boundaries.end.offset,i=new kr(n,0,s),e=Hr._createAfter(i)):(i=new kr(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,s)}return e=Hr._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,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i.is("view:$text")){if(e.isAtStart)return this._position=Hr._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);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 kr(i,e.offset,n);return this._position=e,this._formatReturnValue("text",s,t,e,n)}if(n&&n.is("view:element"))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Hr(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n&&n.is("view:$text")){if(this.singleCharacters)return e=new Hr(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 kr(n,t,n.data.length-t),s=i.data.length,e=Hr._createBefore(i)}else i=new kr(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,s)}return e=Hr._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,s){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Hr._createAfter(t.textNode):(n=Hr._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Hr._createBefore(t.textNode):(n=Hr._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}},Hr=class e extends vr{constructor(e,t){super(),(0,o.A)(this,"parent",void 0),(0,o.A)(this,"offset",void 0),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 Wr);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(t){const i=e._createAt(this),n=i.offset+t;return i.offset=n<0?0:n,i}getLastMatchingPosition(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.startPosition=this;const i=new zr(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]}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=$s(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]<i[n]?"before":"after"}}getWalker(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.startPosition=this,new zr(e)}clone(){return new e(this.parent,this.offset)}static _createAt(t,i){if(t instanceof e)return new this(t.parent,t.offset);{const n=t;if("end"==i)i=n.is("$text")?n.data.length:n.childCount;else{if("before"==i)return this._createBefore(n);if("after"==i)return this._createAfter(n);if(0!==i&&!i)throw new gs("view-createpositionat-offset-required",n)}return new e(n,i)}}static _createAfter(t){if(t.is("$textProxy"))return new e(t.textNode,t.offsetInText+t.data.length);if(!t.parent)throw new gs("view-position-after-root",t,{root:t});return new e(t.parent,t.index+1)}static _createBefore(t){if(t.is("$textProxy"))return new e(t.textNode,t.offsetInText);if(!t.parent)throw new gs("view-position-before-root",t,{root:t});return new e(t.parent,t.index)}};Hr.prototype.is=function(e){return"position"===e||"view:position"===e};let $r=class e extends vr{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(),(0,o.A)(this,"start",void 0),(0,o.A)(this,"end",void 0),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new zr({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 t=this.start.getLastMatchingPosition(Kr,{direction:"backward"}),i=this.end.getLastMatchingPosition(Kr);return t.parent.is("$text")&&t.isAtStart&&(t=Hr._createBefore(t.parent)),i.parent.is("$text")&&i.isAtEnd&&(i=Hr._createAfter(i.parent)),new e(t,i)}getTrimmed(){let t=this.start.getLastMatchingPosition(Kr);if(t.isAfter(this.end)||t.isEqual(this.end))return new e(t,t);let i=this.end.getLastMatchingPosition(Kr,{direction:"backward"});const n=t.nodeAfter,s=i.nodeBefore;return n&&n.is("$text")&&(t=new Hr(n,0)),s&&s.is("$text")&&(i=new Hr(s,s.data.length)),new e(t,i)}isEqual(e){return this==e||this.start.isEqual(e.sta
2rt)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[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(t){const i=[];return this.isIntersecting(t)?(this.containsPosition(t.start)&&i.push(new e(this.start,t.start)),this.containsPosition(t.end)&&i.push(new e(t.end,this.end))):i.push(this.clone()),i}getIntersection(t){if(this.isIntersecting(t)){let i=this.start,n=this.end;return this.containsPosition(t.start)&&(i=t.start),this.containsPosition(t.end)&&(n=t.end),new e(i,n)}return null}getWalker(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.boundaries=this,new zr(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 e(this.start,this.end)}getItems(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){t.boundaries=e,t.ignoreElementEnd=!0;const i=new zr(t);for(const e of i)yield e.item}()}getPositions(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){t.boundaries=e;const i=new zr(t);yield i.position;for(const e of i)yield e.nextPosition}()}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}static _createFromParentsAndOffsets(e,t,i,n){return new this(new Hr(e,t),new Hr(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(Hr._createBefore(e),t)}};function Kr(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}$r.prototype.is=function(e){return"range"===e||"view:range"===e};let Gr=class e extends(Es(vr)){constructor(){super(),(0,o.A)(this,"_ranges",void 0),(0,o.A)(this,"_lastRangeBackward",void 0),(0,o.A)(this,"_isFake",void 0),(0,o.A)(this,"_fakeSelectionLabel",void 0),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",arguments.length&&this.setTo(...arguments)}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 i of this.getRanges()){i=i.getTrimmed();let t=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),i.start.isEqual(n.start)&&i.end.isEqual(n.end)){t=!0;break}if(!t)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];let[s,o,r]=i;if("object"==typeof o&&(r=o,o=void 0),null===s)this._setRanges([]),this._setFakeOptions(r);else if(s instanceof e||s instanceof Jr)this._setRanges(s.getRanges(),s.isBackward),this._setFakeOptions({fake:s.isFake,label:s.fakeSelectionLabel});else if(s instanceof $r)this._setRanges([s],r&&r.backward),this._setFakeOptions(r);else if(s instanceof Hr)this._setRanges([new $r(s)]),this._setFakeOptions(r);else if(s instanceof yr){const e=!!r&&!!r.backward;let t;if(void 0===o)throw new gs("view-selection-setto-required-second-parameter",this);t="in"==o?$r._createIn(s):"on"==o?$r._createOn(s):new $r(Hr._createAt(s,o)),this._setRanges([t],e),this._setFakeOptions(r)}else{if(!Ks(s))throw new gs("view-selection-setto-not-selectable",this);this._setRanges(s,r&&r.backward),this._setFakeOptions(r)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new gs("view-selection-setfocus-no-ranges",this);const i=Hr._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new $r(i,n),!0):this._addRange(new $r(n,i)),this.fire("change")}_setRanges(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e=Array.from(e),this._ranges=[];for(const i of e)this._addRange(i);this._lastRangeBackward=!!t}_setFakeOptions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(e instanceof $r))throw new gs("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 gs("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new $r(e.start,e.end))}};Gr.prototype.is=function(e){return"selection"===e||"view:selection"===e};let Jr=class extends(Es(vr)){constructor(){super(),(0,o.A)(this,"_selection",void 0),this._selection=new Gr,this._selection.delegate("change").to(this),arguments.length&&this._selection.setTo(...arguments)}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)}_setTo(){this._selection.setTo(...arguments)}_setFocus(e,t){this._selection.setFocus(e,t)}};Jr.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class Zr extends us{constructor(e,t,i){super(e,t),(0,o.A)(this,"startRange",void 0),(0,o.A)(this,"_eventPhase",void 0),(0,o.A)(this,"_currentTarget",void 0),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Qr=Symbol("bubbling contexts");function Yr(e){return class extends e{fire(e){try{const s=e instanceof us?e:new us(this,e),o=ia(this);if(!o.size)return;Xr(s,"capturing",this);for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];if(ea(o,"$capture",s,...i))return s.return;const r=s.startRange||this.selection.getFirstRange(),a=r?r.getContainedElement():null,l=!!a&&Boolean(ta(o,a));let c=a||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}(r);if(Xr(s,"atTarget",c),!l){if(ea(o,"$text",s,...i))return s.return;Xr(s,"bubbling",c)}for(;c;){if(c.is("rootElement")){if(ea(o,"$root",s,...i))return s.return}else if(c.is("element")&&ea(o,c.name,s,...i))return s.return;if(ea(o,c,s,...i))return s.return;c=c.parent,Xr(s,"bubbling",c)}return Xr(s,"bubbling",this),ea(o,"$document",s,...i),s.return}catch(s){gs.rethrowUnexpectedError(s,this)}}_addEventListener(e,t,i){const n=Jo(i.context||"$document"),s=ia(this);for(const o of n){let n=s.get(o);n||(n=new(Es()),s.set(o,n)),this.listenTo(n,e,t,i)}}_removeEventListener(e,t){const i=ia(this);for(const n of i.values())this.stopListening(n,e,t)}}}{const e=Yr(Object);["fire","_addEventListener","_removeEventListener"].forEach(t=>{Yr[t]=e.prototype[t]})}function Xr(e,t,i){e instanceof Zr&&(e._eventPhase=t,e._currentTarget=i)}function ea(e,t,i){const n="string"==typeof t?e.get(t):ta(e,t);if(!n)return!1;for(var s=arguments.length,o=new Array(s>3?s-3:0),r=3;r<s;r++)o[r-3]=arguments[r];return n.fire(i,...o),i.stop.called}function ta(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function ia(e){return e[Qr]||(e[Qr]=new Map),e[Qr]}let na=class extends(Yr(Ns())){constructor(e){super(),(0,o.A)(this,"selection",void 0),(0,o.A)(this,"roots",void 0),(0,o.A)(this,"stylesProcessor",void 0),(0,o.A)(this,"_postFixers",new Set),this.selection=new Jr,this.roots=new Yo({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}
2destroy(){this.roots.forEach(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)}};class sa extends Rr{constructor(e,t,i,n){super(e,t,i,n),(0,o.A)(this,"_priority",10),(0,o.A)(this,"_id",null),(0,o.A)(this,"_clonesGroup",null),this.getFillerOffset=oa}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new gs("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canSubtractAttributesOf(e)}}function oa(){if(ra(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(ra(e)>1)return null;e=e.parent}return!e||ra(e)>1?null:this.childCount}function ra(e){return Array.from(e.getChildren()).filter(e=>!e.is("uiElement")).length}(0,o.A)(sa,"DEFAULT_PRIORITY",10),sa.prototype.is=function(e,t){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};class aa extends Rr{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=la}_insertChild(e,t){if(t&&(t instanceof yr||Array.from(t).length>0))throw new gs("view-emptyelement-cannot-add",[this,t]);return 0}}function la(){return null}aa.prototype.is=function(e,t){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};class ca extends Rr{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ha}_insertChild(e,t){if(t&&(t instanceof yr||Array.from(t).length>0))throw new gs("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const i of this.getAttributeKeys())t.setAttribute(i,this.getAttribute(i));return t}}function ua(e){e.document.on("arrowKey",(t,i)=>function(e,t,i){if(t.keyCode==jo.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)}}}}(0,i,e.domConverter),{priority:"low"})}function ha(){return null}ca.prototype.is=function(e,t){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};class da extends Rr{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ma}_insertChild(e,t){if(t&&(t instanceof yr||Array.from(t).length>0))throw new gs("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function ma(){return null}da.prototype.is=function(e,t){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};let fa=class extends(Es(vr)){constructor(e,t){super(),(0,o.A)(this,"document",void 0),(0,o.A)(this,"_children",[]),(0,o.A)(this,"_customProperties",new Map),this.document=e,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}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_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,{index:e});let i=0;const n=function(e,t){if("string"==typeof t)return[new Ar(e,t)];Ks(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new Ar(e,t):t instanceof kr?new Ar(e,t.data):t)}(this.document,t);for(const s of n)null!==s.parent&&s._remove(),s.parent=this,this._children.splice(e,0,s),e++,i++;return i}_removeChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this._fireChange("children",this,{index:e});for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_fireChange(e,t,i){this.fire("change:".concat(e),t,i)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}};fa.prototype.is=function(e){return"documentFragment"===e||"view:documentFragment"===e};class ga{constructor(e){(0,o.A)(this,"document",void 0),(0,o.A)(this,"_cloneGroups",new Map),(0,o.A)(this,"_slotFactory",null),this.document=e}setSelection(){this.document.selection._setTo(...arguments)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new fa(this.document,e)}createText(e){return new Ar(this.document,e)}createAttributeElement(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new sa(this.document,e,t);return"number"===typeof i.priority&&(n._priority=i.priority),i.id&&(n._id=i.id),i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createContainerElement(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=null;Ht(i)?n=i:s=i;const o=new Lr(this.document,e,t,s);return n.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),o}createEditableElement(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new Wr(this.document,e,t);return i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createEmptyElement(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new aa(this.document,e,t);return i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createUIElement(e,t,i){const n=new ca(this.document,e,t);return i&&(n.render=i),n}createRawElement(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=new da(this.document,e,t);return i&&(s.render=i),n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}setAttribute(e,t,i,n){void 0!==n?n._setAttribute(e,t,i):i._setAttribute(e,t)}removeAttribute(e,t,i){void 0!==i?i._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){Ht(e)&&void 0===i?t._setStyle(e):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 Hr?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new gs("view-writer-break-non-container-element",this.document);if(!t.parent)throw new gs("view-writer-break-root",this.document);if(e.isAtStart)return Hr._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(Hr._createAfter(t),i);const n=new $r(e,Hr._createAt(t,"end")),s=new Hr(i,0);this.move(n,s)}return Hr._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 Hr(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 va(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 Hr(n,e))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!t||!i||!t.is("containerElement")||!i.is("containerElement"))throw new gs("view-writer-merge-containers-invalid-position",this.document);const n=t.getChild(t.childCount-1),s=n instanceof Ar?Hr._createAt(n,"end"):Hr._createAt(t,"end");return this.move($r._createIn(i),Hr._createAt(t,"end")),this.remove($r._createOn(i)),s}insert(e,t){Aa(t=Ks(t)?[...t]:[t],this.document);const i=t.reduce((e,t)=>
2{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e},[]);let n=null,s=e;for(const{nodes:o,breakAttributes:r}of i){const e=this._insertNodes(s,o,r);n||(n=e.start),s=e.end}return n?new $r(n,s):new $r(e)}remove(e){const t=e instanceof $r?e:$r._createOn(e);if(Ea(t,this.document),t.isCollapsed)return new fa(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 l of r)this._removeFromClonedElementsGroup(l);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new fa(this.document,r)}clear(e,t){Ea(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=$r._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=$r._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 sa))throw new gs("view-writer-wrap-invalid-attribute",this.document);if(Ea(e,this.document),e.isCollapsed){let i=e.start;i.parent.is("element")&&!function(e){return Array.from(e.getChildren()).some(e=>!e.is("uiElement"))}(i.parent)&&(i=i.getLastMatchingPosition(e=>e.item.is("uiElement"))),i=this._wrapPosition(i,t);const n=this.document.selection;return n.isCollapsed&&n.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new $r(i)}return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof sa))throw new gs("view-writer-unwrap-invalid-attribute",this.document);if(Ea(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 $r(r,a)}rename(e,t){const i=new Lr(this.document,e,t.getAttributes());return this.insert(Hr._createAfter(t),i),this.move($r._createIn(t),Hr._createAt(i,0)),this.remove($r._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Hr._createAt(e,t)}createPositionAfter(e){return Hr._createAfter(e)}createPositionBefore(e){return Hr._createBefore(e)}createRange(e,t){return new $r(e,t)}createRangeOn(e){return $r._createOn(e)}createRangeIn(e){return $r._createIn(e)}createSelection(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Gr(...t)}createSlot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"children";if(!this._slotFactory)throw new gs("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,s;if(n=i?pa(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new gs("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?ba(e):e;const o=n._insertChild(s.offset,t);for(const c of t)this._addToClonedElementsGroup(c);const r=s.getShiftedBy(o),a=this.mergeAttributes(s);a.isEqual(s)||r.offset--;const l=this.mergeAttributes(r);return new $r(a,l)}_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");if(r&&t._canMergeAttributesFrom(n))t._mergeAttributesFrom(n),o.push(new Hr(e,s));else if(i||!r||_a(n,t)){const i=n._clone();t._remove(),i._appendChild(t),e._insertChild(s,i),this._addToClonedElementsGroup(i),o.push(new Hr(e,s))}else this._wrapChildren(t,0,t.childCount,n);s++}let r=0;for(const a of o){if(a.offset-=r,a.offset==t)continue;this.mergeAttributes(a).isEqual(a)||(r++,i--)}return $r._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 Hr(e,s),new Hr(e,s+r)),s+=r,i+=r-1;continue}t._canSubtractAttributesOf(n)?(t._subtractAttributesOf(n),o.push(new Hr(e,s),new Hr(e,s+1)),s++):(this._unwrapChildren(t,0,t.childCount,n),s++)}else s++}
2let r=0;for(const a of o){if(a.offset-=r,a.offset==t||a.offset==i)continue;this.mergeAttributes(a).isEqual(a)||(r++,i--)}return $r._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 $r(r,a)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return wa(e.clone());e.parent.is("$text")&&(e=ba(e));const i=this.createAttributeElement("_wrapPosition-fake-element");i._priority=Number.POSITIVE_INFINITY,i.isSimilar=()=>!1,e.parent._insertChild(e.offset,i);const n=new $r(e,e.getShiftedBy(1));this.wrap(n,t);const s=new Hr(i.parent,i.index);i._remove();const o=s.nodeBefore,r=s.nodeAfter;return o&&o.is("view:$text")&&r&&r.is("view:$text")?va(o,r):wa(s)}_breakAttributesRange(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e.start,n=e.end;if(Ea(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new $r(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 $r(r,s)}_breakAttributes(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new gs("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new gs("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new gs("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&ka(n.parent))return e.clone();if(ka(n))return e.clone();if(n.is("$text"))return this._breakAttributes(ba(e),t);if(i==n.childCount){const e=new Hr(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Hr(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 Hr(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const n of e.getChildren())this._addToClonedElementsGroup(n);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 n of e.getChildren())this._removeFromClonedElementsGroup(n);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function pa(e){let t=e.parent;for(;!ka(t);){if(!t)return;t=t.parent}return t}function _a(e,t){return e.priority<t.priority||!(e.priority>t.priority)&&e.getIdentity()<t.getIdentity()}function wa(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new Hr(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new Hr(i,0):e}function ba(e){if(e.offset==e.parent.data.length)return new Hr(e.parent.parent,e.parent.index+1);if(0===e.offset)return new Hr(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 Ar(e.root.document,t)),new Hr(e.parent.parent,e.parent.index+1)}function va(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new Hr(e,i)}const ya=[Ar,sa,Lr,aa,da,ca];function Aa(e,t){for(const i of e){if(!ya.some(e=>i instanceof e))throw new gs("view-writer-insert-invalid-node-type",t);i.is("$text")||Aa(i.getChildren(),t)}}function ka(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function Ea(e,t){const i=pa(e.start),n=pa(e.end);if(!i||!n||i!==n)throw new gs("view-writer-invalid-range-container",t)}const Ca=e=>e.createTextNode("\xa0"),Pa=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText="\xa0",t},Ta=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},xa="\u2060".repeat(7);function Da(e){return"string"==typeof e?e.substr(0,7)===xa:ro(e)&&e.data.substr(0,7)===xa}function Sa(e){return 7==e.data.length&&Da(e)}function Ia(e){const t="string"==typeof e?e:e.data;return Da(e)?t.slice(7):t}function Oa(e,t){if(t.keyCode==jo.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;Da(t)&&i<=7&&e.collapse(t,0)}}}class Fa extends(Ns()){constructor(e,t){super(),(0,o.A)(this,"domDocuments",new Set),(0,o.A)(this,"domConverter",void 0),(0,o.A)(this,"markedAttributes",new Set),(0,o.A)(this,"markedChildren",new Set),(0,o.A)(this,"markedTexts",new Set),(0,o.A)(this,"selection",void 0),(0,o.A)(this,"_inlineFiller",null),(0,o.A)(this,"_fakeSelectionContainer",null),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),Yn.isBlink&&!Yn.isA
2ndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}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 gs("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!Yn.isAndroid)return;let e=null;const t=!(Yn.isBlink&&!Yn.isAndroid)||!this.isSelecting;for(const i of this.markedChildren)this._updateChildrenMappings(i);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=Hr._createBefore(e.parent)));for(const i of this.markedAttributes)this._updateAttrs(i);for(const i of this.markedChildren)this._updateChildren(i,{inlineFillerPosition:e});for(const i of this.markedTexts)!this.markedChildren.has(i.parent)&&this.domConverter.mapViewToDom(i.parent)&&this._updateText(i,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;Da(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Ba(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findUpdateActions(s,i,n,Ma);if(-1!==o.indexOf("update")){const t={equal:0,insert:0,delete:0};for(const s of o)if("update"===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]),To(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")?Hr._createBefore(e.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&&ro(t.parent)&&Da(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!Da(e))throw new gs("view-renderer-filler-was-lost",this);Sa(e)?e.remove():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;const n=e.nodeBefore,s=e.nodeAfter;return!(n instanceof Ar||s instanceof Ar)&&(!!(i!==t.getFillerOffset()||n&&n.is("element","br"))&&(!Yn.isAndroid||!n&&!s))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const s=t.inlineFillerPosition;s&&s.parent==e.parent&&s.offset==e.index&&(n=xa+n),this._updateTextNode(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const i of Array.from(t.attributes)){const n=i.name;e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}for(const i of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e)}}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(Yn.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&ro(e)&&ro(t)){i.normalize();break}e=t}}const n=t.inlineFillerPosition,s=i.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&Ba(i.ownerDocument,o,n.offset);const r=this._diffNodeLists(s,o),a=this._findUpdateActions(r,s,o,Ra);let l=0;const c=new Set;for(const u of a)"delete"===u?(c.add(s[l]),To(s[l])):"equal"!==u&&"update"!==u||l++;l=0;for(const u of a)"insert"===u?(yo(i,l,o[l]),l++):"update"===u?(this._updateTextNode(s[l],o[l].data),l++):"equal"===u&&(this._markDescendantTextToSync(this.domConverter.domToView(o[l])),l++);for(const u of c)u.parentNode||this.domConverter.unbindDomElement(u)}_diffNodeLists(e,t){return e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;const n=i[i.length-1];n==t&&i.pop();return i}(e,this._fakeSelectionContainer),cs(e,t,Va.bind(null,this.domConverter))}
2_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let s=[],o=[],r=[];const a={equal:0,insert:0,delete:0};for(const l of e)"insert"===l?r.push(i[a.equal+a.insert]):"delete"===l?o.push(t[a.equal+a.delete]):(s=s.concat(cs(o,r,n).map(e=>"equal"===e?"update":e)),s.push("equal"),o=[],r=[]),a[l]++;return s.concat(cs(o,r,n).map(e=>"equal"===e?"update":e))}_updateTextNode(e,t){const i=e.data;i!=t&&(Yn.isAndroid&&this.isComposing&&i.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const i=rs(e.data,t);for(const n of i)"insert"===n.type?e.insertData(n.index,n.values.join("")):e.deleteData(n.index,n.howMany)}_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(Yn.isBlink&&!Yn.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;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._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&Yn.isAndroid||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="\xa0",t}(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||"\xa0";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.setBaseAndExtent(i.parent,i.offset,n.parent,n.offset),Yn.isGecko&&function(e,t){let i=e.parent,n=e.offset;ro(i)&&Sa(i)&&(n=vo(i)+1,i=i.parentNode);if(i.nodeType!=Node.ELEMENT_NODE||n!=i.childNodes.length-1)return;const s=i.childNodes[n];s&&"BR"==s.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){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Ba(e,t,i){const n=t instanceof Array?t:t.childNodes,s=n[i];if(ro(s))return s.data=xa+s.data,s;{const s=e.createTextNode(xa);return Array.isArray(t)?n.splice(i,0,s):yo(t,i,s),s}}function Ma(e,t){return Ys(e)&&Ys(t)&&!ro(e)&&!ro(t)&&!Ao(e)&&!Ao(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Ra(e,t){return Ys(e)&&Ys(t)&&ro(e)&&ro(t)}function Va(e,t,i){return t===i||(ro(t)&&ro(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}const Na=Ta(Jn.document),La=Ca(Jn.document),ja=Pa(Jn.document),Wa="data-ck-unsafe-attribute-",qa="data-ck-unsafe-element";class Ua{constructor(e){let{blockFillerMode:t,renderingMode:i="editing"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,o.A)(this,"document",void 0),(0,o.A)(this,"renderingMode",void 0),(0,o.A)(this,"blockFillerMode",void 0),(0,o.A)(this,"preElements",void 0),(0,o.A)(this,"blockElements",void 0),(0,o.A)(this,"inlineObjectElements",void 0),(0,o.A)(this,"unsafeElements",void 0),(0,o.A)(this,"_domDocument",void 0),(0,o.A)(this,"_domToViewMapping",new WeakMap),(0,o.A)(this,"_viewToDomMapping",new WeakMap),(0,o.A)(this,"_fakeSelectionMapping",new WeakMap),(0,o.A)(this,"_rawContentElementMatcher",new xr),(0,o.A)(this,"_inlineObjectElementMatcher",new xr),(0,o.A)(this,"_elementsWithTemporaryCustomProperties",new Set),this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?Jn.document:Jn.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Gr(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.children)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||("source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),s=i.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);const o=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=o.nextNode();)r.push(a);for(const l of r){for(const t of l.getAttributeNames())this.setDomElementAttribute(l,t,l.getAttribute(t));const e=l.tagName.toLowerCase();this._shouldRenameElement(e)&&(Za(e),l.replaceWith(this._createReplacementDomElement(e,l)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{const i=e;if(this.mapViewToDom(i)){if(!i.getCustomProperty("editingPipeline:doNotReuseOnce"))return this.mapViewToDom(i);this._elementsWithTemporaryCustomProperties.add(i)}let n;if(i.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,i);else{if(i.is("uiElement"))return n="$comment"===i.name?this._domDocument.createComment(i.getCustomProperty("$rawContent")):i.render(this._domDocument,this),t.bind&&this.bindElements(n,i),n;this._shouldRenameElement(i.name)?(Za(i.name),n=this._createReplacementDomElement(i.name)):n=i.hasAttribute("xmlns")?this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(n,this),t.bind&&this.bindElements(n,i);for(const e of i.getAttributeKeys())this.setDomElementAttribute(n,e,i.getAttribute(e),i)}if(!1!==t.withChildren)for(const e of this.viewChildrenToDom(i,t))n instanceof HTMLTemplateElement?n.content.appendChild(e):n.appendChild(e);return n}}setDomElementAttribute(e,t,i,n){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);s||ps("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),function(e){try{Jn.document.createAttribute(e)}catch(t){return!1}return!0}(t)?(e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(Wa+t)&&s&&e.removeAttribute(Wa+t),e.setAttribute(s?t:Wa+t,i)):ps("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=qa&&(e.removeAttribute(t),e.removeAttribute(Wa+t))}viewChildrenToDom(e){var t=this;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){const n=e.getFillerOffset&&e.getFillerOffset();let s=0;for(const o of e.getChildren()){n===s&&(yield t._getBlockFiller());const e=o.is("element")&&!!o.getCustomProperty("dataPipeline:transparentRendering")&&!Xo(o.getAttributes());if(e&&"data"==t.renderingMode)if(o.is("rawElement")){const e=t._domDocument.createElement(o.name);o.render(e,t),yield*[...e.childNodes]}else yield*t.viewChildrenToDom(o,i);else e&&ps("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield t.viewToDom(o,i);s++}n===s&&(yield t._getBlockFiller())}()}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.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 Da(i)&&(n+=7),{parent:i,offset:n}}{let i,n,s;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;
2s=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!n)return null;i=n.parentNode,s=n.nextSibling}if(ro(s)&&Da(s))return{parent:s,offset:7};return{parent:i,offset:n?vo(n)+1:0}}}domToView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],n=this._domToView(e,t,i),s=n.next().value;return s?(n.next(),this._processDomInlineNodes(null,i,t),"br"==this.blockFillerMode&&Ga(s)||s.is("$text")&&0==s.data.length?null:s):null}domChildrenToView(e){var t=this;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return function*(){let s=[];s=e instanceof HTMLTemplateElement?[...e.content.childNodes]:[...e.childNodes];for(let o=0;o<s.length;o++){const r=s[o],a=t._domToView(r,i,n),l=a.next().value;null!==l&&(t._isBlockViewElement(l)&&t._processDomInlineNodes(e,n,i),"br"==t.blockFillerMode&&Ga(l)||(yield l),a.next())}t._processDomInlineNodes(e,n,i)}()}domSelectionToView(e){if(function(e){if(!Yn.isGecko)return!1;if(!e.rangeCount)return!1;const t=e.getRangeAt(0).startContainer;try{Object.prototype.toString.call(t)}catch(i){return!0}return!1}(e))return new Gr([]);if(1===e.rangeCount){let t=e.getRangeAt(0).startContainer;ro(t)&&(t=t.parentNode);const i=this.fakeSelectionToView(t);if(i)return i}const t=this.isDomSelectionBackward(e),i=[];for(let n=0;n<e.rangeCount;n++){const t=e.getRangeAt(n),s=this.domRangeToView(t);s&&i.push(s)}return new Gr(i,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),i=this.domPositionToView(e.endContainer,e.endOffset);return t&&i?new $r(t,i):null}domPositionToView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,vo(e));const i=this.mapDomToView(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return Hr._createBefore(i);if(ro(e)){if(Sa(e))return this.domPositionToView(e.parentNode,vo(e));const i=this.findCorrespondingViewText(e);let n=t;return i?(Da(e)&&(n-=7,n=n<0?0:n),new Hr(i,n)):null}if(0===t){const t=this.mapDomToView(e);if(t)return new Hr(t,0)}else{const i=e.childNodes[t-1];if(ro(i)&&Sa(i)||i&&this.isBlockFiller(i))return this.domPositionToView(i.parentNode,vo(i));const n=ro(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(n&&n.parent)return new Hr(n.parent,n.index+1)}return null}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(Sa(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){const t=e.nextSibling;return t instanceof Ar?t:null}}else{const t=this.mapDomToView(e.parentNode);if(t){const e=t.getChild(0);return e instanceof Ar?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}=Jn.window,n=[];za(t,e=>{const{scrollLeft:t,scrollTop:i}=e;n.push([t,i])}),t.focus(),za(t,e=>{const[t,i]=n.shift();e.scrollLeft=t,e.scrollTop=i}),Jn.window.scrollTo(e,i)}}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(Na):!!Ja(e,this.blockElements)||(e.isEqualNode(ja)||function(e,t){const i=e.isEqualNode(La);return i&&Ha(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements))}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch(by){return!1}const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=function(e){const t=[];let i=e;for(;i&&i.nodeType!=Node.DOCUMENT_NODE;)t.unshift(i),i=i.parentNode;return t}(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)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return Ca(this._domDocument);case"markedNbsp":return Pa(this._domDocument);case"br":return Ta(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(ro(e)&&Da(e)&&t<7)return!1;if(this.isElement(e)&&Da(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}*_domToView(e,t,i){if("br"!=this.blockFillerMode&&Ja(e,this.blockElements))return null;const n=this.getHostViewElement(e);
2if(n)return n;if(Ao(e)&&t.skipComments)return null;if(ro(e)){if(Sa(e))return null;{const t=e.data;if(""===t)return null;const n=new Ar(this.document,t);return i.push(n),n}}{let n=this.mapDomToView(e);if(n)return this._isInlineObjectElement(n)&&i.push(n),n;if(this.isDocumentFragment(e))n=new fa(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const s=e.attributes;if(s)for(let e=s.length,t=0;t<e;t++)n._setAttribute(s[t].name,s[t].value);if(this._isViewElementWithRawContent(n,t))return n._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(n)||i.push(n),n;if(Ao(e))return n._setCustomProperty("$rawContent",e.data),n}yield n;const s=[];if(!1!==t.withChildren)for(const i of this.domChildrenToView(e,t,s))n._appendChild(i);if(this._isInlineObjectElement(n))i.push(n),this._processDomInlineNodes(null,s,t);else for(const e of s)i.push(e)}}_processDomInlineNodes(e,t,i){if(!t.length)return;if(e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let n=!1;for(let s=0;s<t.length;s++){const e=t[s];if(!e.is("$text")){n=!1;continue}let o,r=!1;if(this._isPreFormatted(e))o=Ia(e.data);else{o=e.data.replace(/[ \n\t\r]{1,}/g," "),r=/[^\S\u00A0]/.test(o.charAt(o.length-1));const a=s>0?t[s-1]:null,l=s+1<t.length?t[s+1]:null,c=!a||a.is("element")&&"br"==a.name||n,u=!l&&!Da(e.data);!1!==i.withChildren&&(c&&(o=o.replace(/^ /,"")),u&&(o=o.replace(/ $/,""))),o=Ia(o),"br"!=this.blockFillerMode&&e.parent&&(Ka(e.parent,o)?(o="",e.parent.parent&&(e.parent.parent._setCustomProperty("$hasBlockFiller",!0),e.parent._remove())):$a(e.parent,o,this.blockElements)&&(o="",e.parent._setCustomProperty("$hasBlockFiller",!0))),o=o.replace(/ \u00A0/g," ");const h=l&&l.is("element")&&"br"!=l.name,d=l&&l.is("$text")&&" "==l.data.charAt(0);(/[ \u00A0]\u00A0$/.test(o)||!l||h||d)&&(o=o.replace(/\u00A0$/," ")),(c||a&&a.is("element")&&"br"!=a.name)&&(o=o.replace(/^\u00A0/," "))}0==o.length&&e.parent?(e._remove(),t.splice(s,1),s--):(e._data=o,n=r)}t.length=0}_processDataFromViewText(e){let t=e.data;if(this._isPreFormatted(e))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t="\xa0"+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+"\xa0")}return t.replace(/ {2}/g," \xa0")}_nodeEndsWithSpace(e){if(this._isPreFormatted(e))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_isPreFormatted(e){if(function(e,t){return e.getAncestors().some(e=>e.is("element")&&t.includes(e.name))}(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(t.is("element")&&t.hasStyle("white-space")&&"inherit"!==t.getStyle("white-space"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const i=new zr({startPosition:t?Hr._createAfter(e):Hr._createBefore(e),direction:t?"forward":"backward"});for(const{item:n}of i){if(n.is("$textProxy"))return n;if(!n.is("element")||!n.getCustomProperty("dataPipeline:transparentRendering")){if(n.is("element","br"))return null;if(this._isInlineObjectElement(n))return n;if(n.is("containerElement"))return null}}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if(Ao(e))return new ca(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Rr(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(qa,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function za(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function Ha(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function $a(e,t,i){return"\xa0"==t&&e&&e.is("element")&&1==e.childCount&&i.includes(e.name)}function Ka(e,t){return"\xa0"==t&&e&&e.is("element","span")&&1==e.childCount&&e.hasAttribute("data-cke-filler")}function Ga(e){return e.is("element","br")&&e.hasAttribute("data-cke-filler")}function Ja(e,t){return"BR"===e.tagName&&Ha(e,t)&&1===e.parentNode.childNodes.length}function Za(e){"script"===e&&ps("domconverter-unsafe-script-element-detected"),"style"===e&&ps("domconverter-unsafe-style-element-detected")}class Qa extends(to()){constructor(e){super(),(0,o.A)(this,"view",void 0),(0,o.A)(this,"document",void 0),(0,o.A)(this,"_isEnabled",!1),this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}
2checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class Ya{constructor(e,t,i){(0,o.A)(this,"view",void 0),(0,o.A)(this,"document",void 0),(0,o.A)(this,"domEvent",void 0),(0,o.A)(this,"domTarget",void 0),this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,gt(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class Xa extends Qa{constructor(){super(...arguments),(0,o.A)(this,"useCapture",!1),(0,o.A)(this,"usePassive",!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,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new Ya(this.view,t,i))}}class el extends Xa{constructor(){super(...arguments),(0,o.A)(this,"domEventType",["keydown","keyup"])}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return qo(this)}};this.fire(e.type,e,t)}}class tl extends Qa{constructor(e){super(e),(0,o.A)(this,"_fireSelectionChangeDoneDebounced",void 0),this._fireSelectionChangeDoneDebounced=In(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"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new Gr(t.getRanges(),{backward:t.isBackward,fake:!1});e!=jo.arrowleft&&e!=jo.arrowup||i.setTo(i.getFirstPosition()),e!=jo.arrowright&&e!=jo.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}let il=class extends Qa{constructor(e){super(e),(0,o.A)(this,"domConverter",void 0),(0,o.A)(this,"_config",void 0),(0,o.A)(this,"_domElements",void 0),(0,o.A)(this,"_mutationObserver",void 0),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)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 Set,n=new Set;for(const o of e){const e=t.mapDomToView(o.target);e&&(e.is("uiElement")||e.is("rawElement")||"childList"!==o.type||this._isBogusBrMutation(o)||n.add(e))}for(const o of e){const e=t.mapDomToView(o.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===o.type){const e=t.findCorrespondingViewText(o.target);e&&!n.has(e.parent)?i.add(e):!e&&Da(o.target)&&n.add(t.mapDomToView(o.target.parentNode))}}const s=[];for(const o of i)s.push({type:"text",node:o});for(const o of n){const e=t.mapViewToDom(o);Wn(Array.from(o.getChildren()),Array.from(t.domChildrenToView(e,{withChildren:!1})),nl)||s.push({type:"children",node:o})}s.length&&this.document.fire("mutations",{mutations:s})}_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")}};function nl(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}class sl extends Xa{constructor(e){super(e),(0,o.A)(this,"_renderTimeoutId",null),(0,o.A)(this,"_isFocusChanging",!1),(0,o.A)(this,"domEventType",["focus","blur"]),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(e,t)=>this._handleBlur(t)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const t=this.document.selection.editableElement;null!==t&&t!==e.target||(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class ol extends Qa{constructor(e){super(e),(0,o.A)(this,"mutationObserver",void 0),(0,o.A)(this,"focusObserver",void 0),(0,o.A)(this,"selection",void 0),(0,o.A)(this,"domConverter",void 0),(0,o.A)(this,"_documents",void 0),(0,o.A)(this,"_fireSelectionChangeDoneDebounced",void 0),(0,o.A)(this,"_clearInfiniteLoopInterval",void 0),(0,o.A)(this,"_documentIsSelectingInactivityTimeoutDebounced",void 0),(0,o.A)(this,"_loopbackCounter",void 0),this.mutationObserver=e.getObserver(il),this.focusObserver=e.getObserver(sl),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=In(e=>{this.document.fire("selectionChangeDone",e)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=In(()=>this.document.isSelecting=!1,5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>
2{this.document.isComposing&&!Yn.isAndroid||(this._handleSelectionChange(t),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(t)},{priority:"lowest"}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;const t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(t);if(0!=i.rangeCount){if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.selection.isEqual(i)||!this.domConverter.isDomSelectionCorrect(t))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.selection.isSimilar(i))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:i,domSelection:t};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class rl extends Xa{constructor(e){super(e),(0,o.A)(this,"domEventType",["compositionstart","compositionupdate","compositionend"]);const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0},{priority:"low"}),t.on("compositionend",()=>{t.isComposing=!1},{priority:"low"})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class al{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,o.A)(this,"_files",void 0),(0,o.A)(this,"_native",void 0),this._files=t.cacheFiles?ll(e):null,this._native=e}get files(){return this._files||(this._files=ll(this._native)),this._files}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}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function ll(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter(e=>"file"===e.kind).map(e=>e.getAsFile())}class cl extends Xa{constructor(){super(...arguments),(0,o.A)(this,"domEventType","beforeinput")}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,n=i.document;let s=null,o=null,r=[];if(e.dataTransfer&&(s=new al(e.dataTransfer)),null!==e.data?o=e.data:s&&(o=s.getData("text/plain")),n.selection.isFake)r=Array.from(n.selection.getRanges());else if(t.length)r=t.map(e=>{const t=i.domConverter.domPositionToView(e.startContainer,e.startOffset),n=i.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?i.createRange(t,n):n?i.createRange(n):void 0}).filter(e=>!!e);
2else if(Yn.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();r=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(Yn.isAndroid&&"insertCompositionText"==e.inputType&&o&&o.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(r[0].end)]});else{if("insertText"==e.inputType&&o&&o.includes("\n")){const t=o.split(/\n{1,2}/g);let i=r;for(let o=0;o<t.length;o++){const r=t[o];""!=r&&(this.fire(e.type,e,{data:r,dataTransfer:s,targetRanges:i,inputType:e.inputType,isComposing:e.isComposing}),i=[n.selection.getFirstRange()]),o+1<t.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:i}),i=[n.selection.getFirstRange()])}return}this.fire(e.type,e,{data:o,dataTransfer:s,targetRanges:r,inputType:e.inputType,isComposing:e.isComposing})}}}class ul extends Qa{constructor(e){super(e),this.document.on("keydown",(e,t)=>{if(this.isEnabled&&((i=t.keyCode)==jo.arrowright||i==jo.arrowleft||i==jo.arrowup||i==jo.arrowdown)){const i=new Zr(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i})}observe(){}stopObserving(){}}class hl extends Qa{constructor(e){super(e);const t=this.document;t.on("keydown",(e,i)=>{if(!this.isEnabled||i.keyCode!=jo.tab||i.ctrlKey)return;const n=new Zr(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()})}observe(){}stopObserving(){}}let dl=class extends(Ns()){constructor(e){super(),(0,o.A)(this,"document",void 0),(0,o.A)(this,"domConverter",void 0),(0,o.A)(this,"domRoots",new Map),(0,o.A)(this,"_renderer",void 0),(0,o.A)(this,"_initialDomRootAttributes",new WeakMap),(0,o.A)(this,"_observers",new Map),(0,o.A)(this,"_writer",void 0),(0,o.A)(this,"_ongoingChange",!1),(0,o.A)(this,"_postFixersInProgress",!1),(0,o.A)(this,"_renderingDisabled",!1),(0,o.A)(this,"_hasChangedSinceTheLastRendering",!1),this.document=new na(e),this.domConverter=new Ua(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Fa(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new ga(this.document),this.addObserver(il),this.addObserver(sl),this.addObserver(ol),this.addObserver(el),this.addObserver(tl),this.addObserver(rl),this.addObserver(ul),this.addObserver(cl),this.addObserver(hl),this.document.on("arrowKey",Oa,{priority:"low"}),ua(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0}),this.listenTo(this.document,"change:isFocused",()=>{this._hasChangedSinceTheLastRendering=!0}),Yn.isiOS&&this.listenTo(this.document,"blur",(e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(e,t)=>{let{mutations:i}=t;i.forEach(e=>this._renderer.markToSync(e.type,e.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"main";const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:o,value:r}of Array.from(e.attributes))n[o]=r,"class"===o?this._writer.addClass(r.split(" "),i):i.hasAttribute(o)||this._writer.setAttribute(o,r,i);this._initialDomRootAttributes.set(e,n);const s=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),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 o of this._observers.values())o.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);
2Array.from(t.attributes).forEach(e=>{let{name:i}=e;return t.removeAttribute(i)});const i=this._initialDomRootAttributes.get(t);for(const n in i)t.setAttribute(n,i[n]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const n of this._observers.values())n.stopObserving(t)}getDomRoot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"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[i,n]of this.domRoots)t.observe(n,i);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(){let{alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:n=20}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s=this.document.selection.getFirstRange();if(!s)return;const o=sn({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"===typeof i&&(i={top:i,bottom:i,left:i,right:i});const r={target:this.domConverter.viewRangeToDom(s),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",r,o),function(e){let{target:t,viewportOffset:i=0,ancestorOffset:n=0,alignToTop:s,forceScroll:o}=e;const r=Bo(t);let a=r,l=null;for(i=function(e){return"number"===typeof e?{top:e,bottom:e,left:e,right:e}:e}(i);a;){let e;e=Mo(a==r?t:l),Do({parent:e,getRect:()=>
2Ro(t,a),alignToTop:s,ancestorOffset:n,forceScroll:o});let c=Ro(t,a);const u=Ro(e,a);if(c.height>u.height){const e=c.getIntersection(u);e&&(c=e)}if(xo({window:a,rect:c,viewportOffset:i,alignToTop:s,forceScroll:o}),a.parent!=a){if(l=a.frameElement,a=a.parent,!l)return}else a=null}}(r)}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 gs("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(t){gs.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(sl).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Hr._createAt(e,t)}createPositionAfter(e){return Hr._createAfter(e)}createPositionBefore(e){return Hr._createBefore(e)}createRange(e,t){return new $r(e,t)}createRangeOn(e){return $r._createOn(e)}createRangeIn(e){return $r._createIn(e)}createSelection(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Gr(...t)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}};class ml{is(){throw new Error("is() method is abstract")}}class fl extends ml{constructor(e,t,i){if(super(),(0,o.A)(this,"textNode",void 0),(0,o.A)(this,"data",void 0),(0,o.A)(this,"offsetInText",void 0),this.textNode=e,t<0||t>e.offsetSize)throw new gs("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new gs("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}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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()}}fl.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class gl{constructor(e){if((0,o.A)(this,"direction",void 0),(0,o.A)(this,"boundaries",void 0),(0,o.A)(this,"singleCharacters",void 0),(0,o.A)(this,"shallow",void 0),(0,o.A)(this,"ignoreElementEnd",void 0),(0,o.A)(this,"_position",void 0),(0,o.A)(this,"_boundaryStartParent",void 0),(0,o.A)(this,"_boundaryEndParent",void 0),(0,o.A)(this,"_visitedParent",void 0),!e||!e.boundaries&&!e.startPosition)throw new gs("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new gs("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=_l._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}get position(){return this._position}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)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone(),this._visitedParent=e.parent}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,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const n=wl(t,i),s=n||bl(t,i,n);if(s&&s.is("model:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=s;return this._position=t,pl("elementStart",s,e,t,1)}if(s&&s.is("model:$text")){let n;if(this.singleCharacters)n=1;else{let e=s.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<e&&(e=this.boundaries.end.offset),n=e-t.offset}const o=t.offset-s.startOffset,r=new fl(s,o,n);return t.offset+=n,this._position=t,pl("text",r,e,t,n)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=i.parent,this.ignoreElementEnd?this._next():pl("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,value:void 0};if(i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const n=t.parent,s=wl(t,n),o=s||vl(t,n,s);if(o&&o.is("model:element"))return t.offset--,this.shallow?(this._position=t,pl("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this._position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():pl("elementEnd",o,e,t));if(o&&o.is("model:$text")){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 fl(o,s-n,n);return t.offset-=n,this._position=t,pl("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,pl("elementStart",i,e,t,1)}}function pl(e,t,i,n,s){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}class _l extends ml{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"toNone";if(super(),(0,o.A)(this,"root",void 0),(0,o.A)(this,"path",void 0),(0,o.A)(this,"stickiness",void 0),!e.is("element")&&!e.is("documentFragment"))throw new gs("model-position-root-invalid",e);if(!Array.isArray(t)||0===t.length)throw new gs("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.getChildAtOffset(this.path[t]),!e)throw new gs("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new gs("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return wl(this,this.parent)}get nodeAfter(){const e=this.parent;return bl(this,e,wl(this,e))}get nodeBefore(){const e=this.parent;return vl(this,e,wl(this,e))}get isAtStart(){return 0===this.offset}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=$s(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"}}
2getLastMatchingPosition(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.startPosition=this;const i=new gl(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=$s(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){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let i=0;i<t;i++){const t=this.path[i]-e.path[i];if(t<-1||t>1)return!1;if(1===t)return yl(e,this,i);if(-1===t)return yl(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?Al(this.path,t):Al(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==$s(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=_l._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)?_l._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=_l._createAt(this);if(this.root!=e.root)return i;if("same"==$s(e.getParentPath(),this.getParentPath())){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;i.offset-=t}}else if("prefix"==$s(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=_l._createAt(this);if(this.root!=e.root)return i;if("same"==$s(e.getParentPath(),this.getParentPath()))(e.offset<this.offset||e.offset==this.offset&&"toPrevious"!=this.stickiness)&&(i.offset+=t);else if("prefix"==$s(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 _l._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=_l._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){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"toNone";if(e.is("model:position"))return new _l(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 gs("model-createpositionat-offset-required",[this,e])}if(!n.is("element")&&!n.is("documentFragment"))throw new gs("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 gs("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 gs("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 _l(t.graveyard,e.path);return i.stickiness=e.stickiness,i}if(!t.getRoot(e.root))throw new gs("model-position-fromjson-no-root",t,{rootName:e.root});return new _l(t.getRoot(e.root),e.path,e.stickiness)}}function wl(e,t){const i=t.getChildAtOffset(e.offset);return i&&i.is("$text")&&i.startOffset<e.offset?i:null}function bl(e,t,i){return null!==i?null:t.getChildAtOffset(e.offset)}function vl(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset)-1)}function yl(e,t,i){return i+1!==e.path.length&&(!!Al(t.path,i+1)&&!!function(e,t){let i=e.parent,n=e.path.length-1,s=0;for(;n>=t;){if(e.path[n]+s!==i.maxOffset)return!1;s=1,n--,i=i.parent}return!0}(e,i+1))}function Al(e,t){for(;t<e.length;){if(0!==e[t])return!1;t++}return!0}_l.prototype.is=function(e){return"position"===e||"model:position"===e};class kl extends ml{constructor(e,t){super(),(0,o.A)(this,"start",void 0),(0,o.A)(this,"end",void 0),this.start=_l._createAt(e),this.end=t?_l._createAt(t):_l._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new gl({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return"same"==$s(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){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[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=_l._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}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 kl(this.start,e.start)),this.containsPosition(e.end)&&t.pu
2sh(new kl(e.end,this.end))):t.push(new kl(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 kl(t,i)}return null}getJoined(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],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 kl(n,s)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,i=_l._createAt(this.start);let n=i.parent;for(;i.path.length>t+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new kl(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 kl(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.boundaries=this,new gl(e)}getItems(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){t.boundaries=e,t.ignoreElementEnd=!0;const i=new gl(t);for(const e of i)yield e.item}()}getPositions(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){t.boundaries=e;const i=new gl(t);yield i.position;for(const e of i)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 kl(this.start,this.end)]}getTransformedByOperations(e){const t=[new kl(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 i=0;i<t.length;i++){const e=t[i];for(let n=i+1;n<t.length;n++){const i=t[n];(e.containsRange(i)||i.containsRange(e)||e.isEqual(i))&&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){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[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 kl(t,i)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new kl(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=_l._createAt(i),t.offset=0):(e.deletionPosition.isEqual(t)||(i=e.deletionPosition),t=e.targetPosition),new kl(t,i)):new kl(t,i)}_getTransformedByInsertion(e,t){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&this.containsPosition(e))return[new kl(this.start,e),new kl(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const i=new kl(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,t),i.end=i.end._getTransformedByInsertion(e,t),[i]}}_getTransformedByMove(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.isCollapsed){const n=this.start._getTransformedByMove(e,t,i);return[new kl(n)]}const s=kl._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 kl(n,s)]}let r;const a=this.getDifference(s);let l=null;const c=this.getIntersection(s);if(1==a.length?l=new kl(a[0].start._getTransformedByDeletion(e,i),a[0].end._getTransformedByDeletion(e,i)):2==a.length&&(l=new kl(this.start,this.end._getTransformedByDeletion(e,i))),r=l?l._getTransformedByInsertion(o,i,null!==c||n):[],c){const e=new kl(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 kl(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(_l._createAt(e,0),_l._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(_l._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new gs("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort((e,t)=>
2e.start.isAfter(t.start)?1:-1);const i=e.indexOf(t),n=new this(t.start,t.end);for(let s=i-1;s>=0&&e[s].end.isEqual(n.start);s--)n.start=_l._createAt(e[s].start);for(let s=i+1;s<e.length&&e[s].start.isEqual(n.end);s++)n.end=_l._createAt(e[s].end);return n}static fromJSON(e,t){return new this(_l.fromJSON(e.start,t),_l.fromJSON(e.end,t))}}kl.prototype.is=function(e){return"range"===e||"model:range"===e};class El extends(Es()){constructor(){super(),(0,o.A)(this,"_modelToViewMapping",new WeakMap),(0,o.A)(this,"_viewToModelMapping",new WeakMap),(0,o.A)(this,"_viewToModelLengthCallbacks",new Map),(0,o.A)(this,"_markerNameToElements",new Map),(0,o.A)(this,"_elementToMarkerNames",new Map),(0,o.A)(this,"_deferredBindingRemovals",new Map),(0,o.A)(this,"_unboundMarkerNames",new Set),(0,o.A)(this,"_cache",new Cl),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new gs("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});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=_l._createAt(n,s)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const n of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(n);if(t.defer)this._deferredBindingRemovals.set(e,e.root);else{this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i)}}unbindModelElement(e){const t=this.toViewElement(e);if(this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e){this._viewToModelMapping.delete(t)&&this._cache.stopTracking(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}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new kl(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new $r(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){const t={modelPosition:e,mapper:this,isPhantom:(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isPhantom};return this.fire("modelToViewPosition",t),t.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const n of t)if(n.is("attributeElement"))for(const e of n.getElementsWithSameId())i.add(e);else i.add(n);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._toModelOff
2set(e,t,e)}if(e.is("$text"))return t;let n=0;for(let s=0;s<t;s++)n+=this.getModelLength(e.getChild(s));return n}getModelLength(e){const t=[e];let i=0;for(;t.length>0;){const e=t.pop(),n=e.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(e.name);if(n)i+=n(e);else if(this._viewToModelMapping.has(e))i+=1;else if(e.is("$text"))i+=e.data.length;else{if(e.is("uiElement"))continue;for(const i of e.getChildren())t.push(i)}}return i}findPositionIn(e,t){if(0===t)return this._moveViewPositionToTextNode(new Hr(e,0));if(0==this._viewToModelLengthCallbacks.size&&this._viewToModelMapping.has(e)){const i=this._cache.getClosest(e,t);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,t,e,!0)}return this._findPositionStartingFrom(new Hr(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,i,n,s){let o,r=e.parent,a=e.offset;if(r.is("$text"))return new Hr(r,i-t);let l=t,c=0;for(;l<i;)if(o=r.getChild(a),o)c=this.getModelLength(o),l+=c,a++,s&&this._cache.save(r,a,n,l);else{if(r==n)throw new gs("mapping-model-offset-not-found",this,{modelOffset:i,viewContainer:n});a=r.parent.getChildIndex(r)+1,r=r.parent}return l==i?this._moveViewPositionToTextNode(new Hr(r,a)):this._findPositionStartingFrom(new Hr(o,0),l-c,i,n,s)}_moveViewPositionToTextNode(e){const t=e.nodeBefore,i=e.nodeAfter;return t&&t.is("view:$text")?new Hr(t,t.data.length):i&&i.is("view:$text")?new Hr(i,0):e}}class Cl extends(Es()){constructor(){super(...arguments),(0,o.A)(this,"_cachedMapping",new WeakMap),(0,o.A)(this,"_nodeToCacheListIndex",new WeakMap),(0,o.A)(this,"_invalidateOnChildrenChangeCallback",(e,t,i)=>{this._clearCacheInsideParent(t,i.index)}),(0,o.A)(this,"_invalidateOnTextChangeCallback",(e,t)=>{this._clearCacheStartingBefore(t)})}save(e,t,i,n){const s=this._cachedMapping.get(i),o=s.cacheMap.get(n);if(o){const i=e.getChild(t-1),n=o.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(o.viewPosition.nodeBefore):0;return void this._nodeToCacheListIndex.set(i,n)}const r={viewPosition:new Hr(e,t),modelOffset:n};s.maxModelOffset=n>s.maxModelOffset?n:s.maxModelOffset,s.cacheMap.set(n,r);let a=s.cacheList.length-1;for(;a>=0&&s.cacheList[a].modelOffset>n;)a--;if(s.cacheList.splice(a+1,0,r),t>0){const i=e.getChild(t-1);this._nodeToCacheListIndex.set(i,a+1)}}getClosest(e,t){const i=this._cachedMapping.get(e);let n;if(i)if(t>i.maxModelOffset)n=i.cacheList[i.cacheList.length-1];else{const e=i.cacheMap.get(t);n=e||this._findInCacheList(i.cacheList,t)}else n=this.startTracking(e);const s=this._hoistViewPosition(n.viewPosition);return{modelOffset:n.modelOffset,viewPosition:s}}_hoistViewPosition(e){for(;e.parent.parent&&!this._cachedMapping.has(e.parent)&&e.isAtEnd;){const t=e.parent.parent,i=t.getChildIndex(e.parent)+1;e=new Hr(t,i)}return e}startTracking(e){const t={viewPosition:new Hr(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),t}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(0==t)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheStartingBefore(e);else{const i=e.getChild(t-1);this._clearCacheStartingBefore(i)}}_clearCacheAll(e){const t=this._cachedMapping.get(e);t.maxModelOffset>0&&(t.maxModelOffset=0,t.cacheList.length=1,t.cacheMap.clear(),t.cacheMap.set(0,t.cacheList[0]))}_clearCacheStartingBefore(e){const t=this._nodeToCacheListIndex.get(e);if(void 0===t){const t=e.parent;return void(this._cachedMapping.has(t)||this._clearCacheStartingBefore(t))}let i=e.parent;for(;!this._cachedMapping.has(i);)i=i.parent;this._clearCacheFromIndex(i,t)}_clearCacheFromIndex(e,t){0===t&&(t=1);const i=this._cachedMapping.get(e),n=i.cacheList[t-1];if(!n)return;i.maxModelOffset=n.modelOffset;const s=i.cacheList.splice(t);for(const o of s){i.cacheMap.delete(o.modelOffset);const e=o.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(e)}}_findInCacheList(e,t){let i=0,n=e.length-1,s=n-i>>1,o=e[s];for(;i<n;)o.modelOffset<t?i=s+1:n=s-1,s=i+(n-i>>1),o=e[s];return o.modelOffset<=t?o:e[s-1]}}class Pl{constructor(){(0,o.A)(this,"_consumable",new Map),(0,o.A)(this,"_textProxyRegistry",new Map)}
2add(e,t){t=Tl(t),e instanceof fl&&(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=Tl(t),e instanceof fl&&(e=this._getSymbolForTextProxy(e)),!!this.test(e,t)&&(this._consumable.get(e).set(t,!1),!0)}test(e,t){t=Tl(t),e instanceof fl&&(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=Tl(t),e instanceof fl&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return!1===i?(this._consumable.get(e).set(t,!0),!0):!0!==i&&null}verifyAllConsumed(e){const t=[];for(const[i,n]of this._consumable)for(const[s,o]of n){const n=s.split(":")[0];o&&e==n&&t.push({event:s,item:i.name||i.description})}if(t.length)throw new gs("conversion-model-consumable-not-consumed",null,{items:t})}_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)),t}_addSymbolForTextProxy(e){const t=e.startOffset,i=e.endOffset,n=e.parent,s=Symbol("$textProxy:"+e.data);let o,r;return o=this._textProxyRegistry.get(t),o||(o=new Map,this._textProxyRegistry.set(t,o)),r=o.get(i),r||(r=new Map,o.set(i,r)),r.set(n,s),s}}function Tl(e){const t=e.split(":");return"insert"==t[0]?t[0]:"addMarker"==t[0]||"removeMarker"==t[0]?e:t.length>1?t[0]+":"+t[1]:t[0]}class xl extends(Es()){constructor(e){super(),(0,o.A)(this,"_conversionApi",void 0),(0,o.A)(this,"_firedEventsMap",void 0),this._conversionApi=(0,r.A)({dispatcher:this},e),this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=this._createConversionApi(i,e.getRefreshedItems());for(const o of e.getMarkersToRemove())this._convertMarkerRemove(o.name,o.range,n);const s=this._reduceChanges(e.getChanges());for(const o of s)"insert"===o.type?this._convertInsert(kl._createFromPositionAndShift(o.position,o.length),n):"reinsert"===o.type?this._convertReinsert(kl._createFromPositionAndShift(o.position,o.length),n):"remove"===o.type?this._convertRemove(o.position,o.length,o.name,n):this._convertAttribute(o.range,o.attributeKey,o.attributeOldValue,o.attributeNewValue,n);n.mapper.flushDeferredBindings();for(const o of n.mapper.flushUnboundMarkerNames()){const e=t.get(o).getRange();this._convertMarkerRemove(o,e,n),this._convertMarkerAdd(o,e,n)}for(const o of e.getMarkersToAdd())this._convertMarkerAdd(o.name,o.range,n);n.consumable.verifyAllConsumed("insert")}convert(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=this._createConversionApi(i,void 0,n);this._convertInsert(e,s);for(const[o,r]of t)this._convertMarkerAdd(o,r,s);s.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const s=e.getFirstPosition().root;if(!n.mapper.toViewElement(s))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,o),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of o)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!Dl(e.getFirstPosition(),t,n.mapper))continue;const s={item:e,markerName:t.name,markerRange:i};this.fire("addMarker:".concat(t.name),s,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire("attribute:".concat(t,":$text"),i,n)}}}_convertInsert(e,t){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const i of e.getWalker({shallow:!0}))this._testAndFire("insert",Sl(i),t)}_convertRemove(e,t,i,n){this.fire("remove:".concat(i),{position:e,length:t},n)}_convertAttribute(e,t,i,n,s){this._addConsumablesForRange(s.consumable,e,"attribute:".concat(t));for(const o of e){const e={item:o.item,range:kl._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire("attribute:".concat(t),e,s)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const n of i.map(Sl))this._testAndFire("insert",(0,r.A)((0,r.A)({},n),{},{reconversion:!0}),t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n="addMarker:".concat(e);
2if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const s of t.getItems()){if(!i.consumable.test(s,n))continue;const o={item:s,range:kl._createOn(s),markerName:e,markerRange:t};this.fire(n,o,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire("removeMarker:".concat(e),{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n);return e}_testAndFire(e,t,i){const n=function(e,t){const i=t.item.is("element")?t.item.name:"$text";return"".concat(e,":").concat(i)}(e,t),s=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(i),r=o.get(s);if(r){if(r.has(n))return;r.add(n)}else o.set(s,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:kl._createOn(e)};for(const n of i.item.getAttributeKeys())i.attributeKey=n,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(n),this._testAndFire("attribute:".concat(n),i,t)}_createConversionApi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=(0,r.A)((0,r.A)({},this._conversionApi),{},{consumable:new Pl,writer:e,options:i,convertItem:e=>this._convertInsert(kl._createOn(e),n),convertChildren:e=>this._convertInsert(kl._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))});return this._firedEventsMap.set(n,new Map),n}}function Dl(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 Sl(e){return{item:e.item,range:kl._createFromPositionAndShift(e.previousPosition,e.length)}}let Il=class extends ml{constructor(e){super(),(0,o.A)(this,"parent",null),(0,o.A)(this,"_attrs",void 0),(0,o.A)(this,"_index",null),(0,o.A)(this,"_startOffset",null),this._attrs=or(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return null===this.startOffset?null:this.startOffset+this.offsetSize}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 null!==this.parent&&this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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=$s(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}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=or(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}};Il.prototype.is=function(e){return"node"===e||"model:node"===e};class Ol extends(Es(ml)){constructor(){super(),(0,o.A)(this,"_lastRangeBackward",!1),(0,o.A)(this,"_attrs",new Map),(0,o.A)(this,"_ranges",[]),arguments.length&&this.setTo(...arguments)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}
2get 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 kl(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 kl(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 kl(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(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];let[n,s,o]=t;if("object"==typeof s&&(o=s,s=void 0),null===n)this._setRanges([]);else if(n instanceof Ol)this._setRanges(n.getRanges(),n.isBackward);else if(n&&"function"==typeof n.getRanges)this._setRanges(n.getRanges(),n.isBackward);else if(n instanceof kl)this._setRanges([n],!!o&&!!o.backward);else if(n instanceof _l)this._setRanges([new kl(n)]);else if(n instanceof Il){const e=!!o&&!!o.backward;let t;if("in"==s)t=kl._createIn(n);else if("on"==s)t=kl._createOn(n);else{if(void 0===s)throw new gs("model-selection-setto-required-second-parameter",[this,n]);t=new kl(_l._createAt(n,s))}this._setRanges([t],e)}else{if(!Ks(n))throw new gs("model-selection-setto-not-selectable",[this,n]);this._setRanges(n,o&&!!o.backward)}}_setRanges(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=Array.from(e),n=i.some(t=>{if(!(t instanceof kl))throw new gs("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(e=>!e.isEqual(t))});(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new gs("model-selection-setfocus-no-ranges",[this,e]);const i=_l._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 kl(i,n)),this._lastRangeBackward=!0):(this._pushRange(new kl(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()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=Ml(t.start,e);Vl(i,t)&&(yield i);const n=t.getWalker();for(const o of n){const i=o.item;"elementEnd"==o.type&&Bl(i,e,t)?yield i:"elementStart"==o.type&&i.is("model:element")&&i.root.document.model.schema.isBlock(i)&&n.jumpTo(_l._createAt(i,"end"))}const s=Ml(t.end,e);Nl(s,t)&&(yield s)}}containsEntireContent(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.anchor.root;const t=_l._createAt(e,0),i=_l._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new kl(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new gs("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){this._removeAllRanges();for(const t of e)this._pushRange(t)}
2_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}function Fl(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function Bl(e,t,i){return Fl(e,t)&&Rl(e,i)}function Ml(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&&Fl(e,t)));return n.forEach(e=>t.add(e)),o}function Rl(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}}(e);if(!i)return!0;return!t.containsRange(kl._createOn(i),!0)}function Vl(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(_l._createAt(e,e.maxOffset))&&Rl(e,t))}function Nl(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(_l._createAt(e,0))&&Rl(e,t))}Ol.prototype.is=function(e){return"selection"===e||"model:selection"===e};class Ll extends(Es(kl)){constructor(e,t){super(e,t),jl.call(this)}detach(){this.stopListening()}toRange(){return new kl(this.start,this.end)}static fromRange(e){return new Ll(e.start,e.end)}}function jl(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&Wl.call(this,i)},{priority:"low"})}function Wl(e){const t=this.getTransformedByOperation(e),i=kl._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})}Ll.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};class ql extends Il{constructor(e,t){super(t),(0,o.A)(this,"_data",void 0),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new ql(this.data,this.getAttributes())}static fromJSON(e){return new ql(e.data,e.attributes)}}ql.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};const Ul="selection:";class zl extends(Es(ml)){constructor(e){super(),(0,o.A)(this,"_selection",void 0),this._selection=new Hl(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)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(){this._selection.setTo(...arguments)}_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 Ul+e}static _isStoreAttributeKey(e){return e.startsWith(Ul)}}zl.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class Hl extends Ol{constructor(e){super(),(0,o.A)(this,"markers",new Yo({idProperty:"name"})),(0,o.A)(this,"_model",void 0),(0,o.A)(this,"_document",void 0),(0,o.A)(this,"_attributePriority",new Map),(0,o.A)(this,"_selectionRestorePosition",null),(0,o.A)(this,"_hasChangedRange",!1),(0,o.A)(this,"_overriddenGravityRegister",new Set),(0,o.A)(this,"_observedMarkers",new Set),this._model=e.model,this._document=e,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",()=>
2{this._validateSelectionRanges(this.getRanges())}),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(Ul));for(const n of t)e.removeAttribute(n,i)})}}(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(){super.setTo(...arguments),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=ds();return this._overriddenGravityRegister.add(e),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new gs("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()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new gs("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=Ll.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 n of this._model.markers){const t=n.name.split(":",1)[0];if(!this._observedMarkers.has(t))continue;const i=n.getRange();for(const s of this.getRanges())i.containsRange(s,!s.isCollapsed)&&e.push(n)}const i=Array.from(this.markers);for(const n of e)this.markers.has(n)||(this.markers.add(n),t=!0);for(const n of Array.from(this.markers))e.includes(n)||(this.markers.remove(n),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=or(this._getSurroundingAttributes()),i=or(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[s,o]of this._attributePriority)"low"==o&&(this._attrs.delete(s),this._attributePriority.delete(s));this._setAttributesTo(t);const n=[];for(const[s,o]of this.getAttributes())i.has(s)&&i.get(s)===o||n.push(s);for(const[s]of i)this.hasAttribute(s)||n.push(s);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t){const i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?"normal":"low";if("low"==i&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,i),!0)}_removeAttribute(e){const t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?"normal":"low";return("low"!=t||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,t),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[i,n]of this.getAttributes())e.get(i)!==n&&this._removeAttribute(i,!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(Ul)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;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=$l(n,t)),i||(i=$l(s,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=$l(e,t)}if(!i){let e=s;for(;e&&!i;)e=e.nextSibling,i=$l(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=$l(n.item,t);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)}
2}function $l(e,t){if(!e)return null;if(e instanceof fl||e instanceof ql)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,s]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,s]);return i}class Kl{constructor(e){(0,o.A)(this,"_nodes",[]),(0,o.A)(this,"_offsetToNode",[]),e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new gs("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;const t=this._offsetToNode[e];if(!t)throw new gs("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}
2_insertNodes(e,t){const i=[];for(const s of t){if(!(s instanceof Il))throw new gs("model-nodelist-insertnodes-not-node",this);i.push(s)}let n=this.indexToOffset(e);rr(this._nodes,i,e),rr(this._offsetToNode,function(e){const t=[];let i=0;for(const n of e)for(let e=0;e<n.offsetSize;e++)t[i++]=n;return t}(i),n);for(let s=e;s<this._nodes.length;s++)this._nodes[s]._index=s,this._nodes[s]._startOffset=n,n+=this._nodes[s].offsetSize}_removeNodes(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(0==t)return[];let i=this.indexToOffset(e);const n=this._nodes.splice(e,t),s=n[n.length-1],o=s.startOffset+s.offsetSize-i;this._offsetToNode.splice(i,o);for(const r of n)r._index=null,r._startOffset=null;for(let r=e;r<this._nodes.length;r++)this._nodes[r]._index=r,this._nodes[r]._startOffset=i,i+=this._nodes[r].offsetSize;return n}_removeNodesArray(e){if(0==e.length)return;for(const i of e)i._index=null,i._startOffset=null;this._nodes=this._nodes.filter(e=>null!==e.index),this._offsetToNode=this._offsetToNode.filter(e=>null!==e.index);let t=0;for(let i=0;i<this._nodes.length;i++)this._nodes[i]._index=i,this._nodes[i]._startOffset=t,t+=this._nodes[i].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}class Gl extends Il{constructor(e,t,i){super(t),(0,o.A)(this,"name",void 0),(0,o.A)(this,"_children",new Kl),this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(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.getChildAtOffset(i);return t}findAncestor(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).includeSelf?this:this.parent;for(;t;){if(t.name===e)return t;t=t.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(){const e=arguments.length>0&&void 0!==arguments[0]&&arguments[0]?function(e){const t=[];for(const i of e)t.push(i._clone(!0));return t}(this._children):void 0;return new Gl(this.name,this.getAttributes(),e)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new ql(e)];Ks(e)||(e=[e]);const t=[];for(const i of e)"string"==typeof i?t.push(new ql(i)):i instanceof fl?t.push(new ql(i.data,i.getAttributes())):t.push(i);return t}(t);for(const n of i)null!==n.parent&&n._remove(),n.parent=this;this._children._insertNodes(e,i)}_removeChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=this._children._removeNodes(e,t);for(const n of i)n.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(Gl.fromJSON(i)):t.push(ql.fromJSON(i))}return new Gl(e.name,e.attributes,t)}}Gl.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e};class Jl{constructor(e){(0,o.A)(this,"_dispatchers",void 0),this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Zl extends Jl{elementToElement(e){return this.add(function(e){const t=Xl(e.model),i=ec(e.view,"container");t.attributes.length&&(t.children=!0);return n=>{n.on("insert:".concat(t.name),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lc;return(i,n,s)=>{if(!t(n.item,s.consumable,{preflight:!0}))return;const o=e(n.item,s,n);if(!o)return;t(n.item,s.consumable);const r=s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,o),s.writer.insert(r,o),s.convertAttributes(n.item),rc(o,n.item.getChildren(),s,{reconversion:n.reconversion})}}(i,oc(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",sc(t),{priority:"low"})}}(e))}
2elementToStructure(e){return this.add(function(e){const t=Xl(e.model),i=ec(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new gs("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var s,o;n.on("insert:".concat(t.name),(s=i,o=oc(t),(e,t,i)=>{if(!o(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,s)=>{const o=n.createContainerElement("$slot");let r=null;if("children"===s)r=Array.from(e.getChildren());else{if("function"!=typeof s)throw new gs("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:s});r=Array.from(e.getChildren()).filter(e=>s(e))}return t.set(o,r),o}}(t.item,n,i));const r=s(t.item,i,t);if(i.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new gs("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(s.size!=e.childCount)throw new gs("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),o(t.item,i.consumable);const a=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,r),i.writer.insert(a,r),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let s=null,o=null;for([s,o]of t)rc(e,o,i,n),i.writer.move(i.writer.createRangeIn(s),i.writer.createPositionBefore(s)),i.writer.remove(s);function r(e,t){const i=t.modelPosition.nodeAfter,n=o.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(s,n))}i.mapper.off("modelToViewPosition",r)}(r,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",sc(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=sn(e);let t=e.model;"string"==typeof t&&(t={key:t});let i="attribute:".concat(t.key);t.name&&(i+=":"+t.name);if(t.values)for(const s of t.values)e.view[s]=ec(e.view[s],"attribute");else e.view=ec(e.view,"attribute");const n=tc(e);return t=>{t.on(i,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const s=e(i.attributeOldValue,n,i),o=e(i.attributeNewValue,n,i);if(!s&&!o)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof Ol||i.item instanceof zl)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)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=sn(e);let t=e.model;"string"==typeof t&&(t={key:t});let i="attribute:".concat(t.key);t.name&&(i+=":"+t.name);if(t.values)for(const s of t.values)e.view[s]=ic(e.view[s]);else e.view=ic(e.view);const n=tc(e);return t=>{var s;t.on(i,(s=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=s(t.attributeOldValue,i,t),o=s(t.attributeNewValue,i,t);if(!n&&!o)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new gs("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n){let e=n.value;"style"==n.key&&(e="string"==typeof n.value?new Ir(a.document.stylesProcessor).setTo(n.value).getStylesEntries().map(e=>{let[t]=e;return t}):Object.keys(n.value)),a.removeAttribute(n.key,e,r)}if(null!==t.attributeNewValue&&o){let e=o.value;"style"==o.key&&"string"==typeof o.value&&(e=Object.fromEntries(new Ir(a.document.stylesProcessor).setTo(o.value).getStylesEntries())),a.setAttribute(o.key,e,!1,r)}}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=ec(e.view,"ui");return i=>{var n;i.on("addMarker:".concat(e.model),(n=t,(e,t,i)=>{t.isOpening=!0;const s=n(t,i);t.isOpening=!1;const o=n(t,i);if(!s||!o)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const n of r)if(!i.consumable.consume(n.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),s),i.mapper.bindElementToMarker(s,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),i.mapper.bindElementToMarker(o,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),i.on("removeMarker:".concat(e.model),(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:".concat(e.model),(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof Ol||t.item instanceof zl)&&!t.item.is("$textProxy"))return;const s=nc(i,t,n);if(!s)return;if(!n.consumable.consume(t.item,e.name))return;const o=n.writer,r=Ql(o,s),a=o.document.selection;if(t.item instanceof Ol||t.item instanceof zl)o.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=o.wrap(e,r);for(const s of i.getItems())if(s.is("attributeElement")&&s.isSimilar(r)){n.mapper.bindElementToMarker(s,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on("addMarker:".concat(e.model),function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof Gl))return;const s=nc(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 kl._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:".concat(e.model),function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const s=nc(e,i,n);if(!s)return;
2const o=Ql(n.writer,s),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)if(n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement"))n.writer.unwrap(n.writer.createRangeOn(e),o);else{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){e=sn(e);const t=e.model;let i=e.view;i||(i=i=>({group:t,name:i.substr(e.model.length+1)}));return n=>{var s;n.on("addMarker:".concat(t),(s=i,(e,t,i)=>{const n=s(t.markerName,i);if(!n)return;const o=t.markerRange;i.consumable.consume(o,e.name)&&(Yl(o,!1,i,t,n),Yl(o,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on("removeMarker:".concat(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-".concat(s.group,"-start-before"),e),r("data-".concat(s.group,"-start-after"),e),r("data-".concat(s.group,"-end-before"),e),r("data-".concat(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)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Ql(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"===typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function Yl(e,t,i,n,s){const o=t?e.start:e.end,r=o.nodeAfter&&o.nodeAfter.is("element")?o.nodeAfter:null,a=o.nodeBefore&&o.nodeBefore.is("element")?o.nodeBefore:null;if(r||a){let e,o;t&&r||!t&&!a?(e=r,o=!0):(e=a,o=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,s,o){const r="data-".concat(o.group,"-").concat(t?"start":"end","-").concat(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)}(l,t,o,i,n,s)}!function(e,t,i,n,s){const o="".concat(s.group,"-").concat(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)}function Xl(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?Jo(e.attributes):[],children:!!e.children}}function ec(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||sa.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 tc(e){return e.model.values?(t,i,n)=>{const s=e.view[t];return s?s(t,i,n):null}:e.view}function ic(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function nc(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}function sc(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const s of i.changes){const e="attribute"==s.type?s.range.start.nodeAfter:s.position.parent;if(e&&t(e,s)){if(!i.reconvertedElements.has(e)){i.reconvertedElements.add(e);const t=_l._createBefore(e);let s=n.length;for(let e=n.length-1;e>=0;e--){const i=n[e],o=("attribute"==i.type?i.range.start:i.position).c
2ompareWith(t);if("before"==o||"remove"==i.type&&"same"==o)break;s=e}n.splice(s,0,{type:"remove",name:e.name,position:t,length:1},{type:"reinsert",name:e.name,position:t,length:1})}}else n.push(s)}i.changes=n}}function oc(e){return function(t,i){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=["insert"];for(const o of e.attributes)t.hasAttribute(o)&&s.push("attribute:".concat(o));return!!s.every(e=>i.test(t,e))&&(n.preflight||s.forEach(e=>i.consume(t,e)),!0)}}function rc(e,t,i,n){for(const s of t)ac(e.root,s,i,n)||i.convertItem(s)}function ac(e,t,i,n){const{writer:s,mapper:o}=i;if(!n.reconversion)return!1;const r=o.toViewElement(t);return!(!r||r.root==e)&&(!!i.canReuseView(r)&&(s.move(s.createRangeOn(r),o.toViewPosition(_l._createBefore(t))),!0))}function lc(e,t){let{preflight:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return i?t.test(e,"insert"):t.consume(e,"insert")}function cc(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function uc(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function hc(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class dc extends Jl{elementToElement(e){return this.add(mc(e))}elementToAttribute(e){return this.add(function(e){e=sn(e),pc(e);const t=_c(e,!1),i=fc(e.view),n=i?"element:".concat(i):"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=sn(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,i="undefined"==typeof e.view.value?/[\s\S]*/:e.view.value;let n;if("class"==t||"style"==t){const e="class"==t?"classes":"styles";n={[e]:i}}else n={attributes:{[t]:i}};e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));pc(e,t);const i=_c(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return mc((0,r.A)((0,r.A)({},e),{},{model:t}))}(e))}dataToMarker(e){return this.add(function(e){e=sn(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=gc(wc(t,"start")),n=gc(wc(t,"end"));return s=>{s.on("element:".concat(e.view,"-start"),i,{priority:e.converterPriority||"normal"}),s.on("element:".concat(e.view,"-end"),n,{priority:e.converterPriority||"normal"});const o=ms.low,r=ms.highest,a=ms.get(e.converterPriority)/r;s.on("element",function(e){return(t,i,n)=>{const s="data-".concat(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]}}(n.consumable.test(i.viewItem,{attributes:s+"-end-after"})||n.consumable.test(i.viewItem,{attributes:s+"-start-after"})||n.consumable.test(i.viewItem,{attributes:s+"-end-before"})||n.consumable.test(i.viewItem,{attributes:s+"-start-before"}))&&(i.modelRange||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(",")))}}(t),{priority:o+a})}}(e))}}function mc(e){const t=gc(e=sn(e)),i=fc(e.view),n=i?"element:".concat(i):"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function fc(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function gc(e){const t=new xr(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 pc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,s="object"!=typeof e.model||"undefined"==typeof e.model.value?i:e.model.value;e.model={key:n,value:s}}function _c(e,t){const i=new xr(e.view);return(n,s,o)=>
2{if(!s.modelRange&&t)return;const r=i.match(s.viewItem);if(!r)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!fc(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;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(s.viewItem,o):e.model.value;if(null===l)return;s.modelRange||Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor));const c=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);c&&(o.consumable.test(s.viewItem,{name:!0})&&(r.match.name=!0),o.consumable.consume(s.viewItem,r.match))}}function wc(e,t){return{view:"".concat(e.view,"-").concat(t),model:(t,i)=>{const n=t.getAttribute("name"),s=e.model(n,i);return i.writer.createElement("$marker",{"data-name":s})}}}function bc(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.selection,n=t.schema,s=[];let o=!1;for(const r of i.getRanges()){const e=vc(r,n);e&&!e.isEqual(r)?(s.push(e),o=!0):s.push(r)}o&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n<t.length;){const e=t[n],s=t.slice(0,n);for(const[o,r]of s.entries())if(!i.has(o))if(e.isEqual(r))i.add(o);else if(e.isIntersecting(r)){i.add(o),i.add(n);const s=e.getJoined(r);t.push(s)}n++}return t.filter((e,t)=>!i.has(t))}(s),{backward:i.isBackward});return!1}(t,e))}function vc(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find(e=>t.isObject(e));return e?kl._createOn(e):null}if(!n.isCollapsed)return n;const s=n.start;if(i.isEqual(s))return null;return new kl(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 kl(o,r)}}
2const 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||!Ac(i.nodeAfter,t)),o=c&&(!e||!Ac(n.nodeBefore,t));let u=i,h=n;return s&&(u=_l._createBefore(yc(r,t))),o&&(h=_l._createAfter(yc(a,t))),new kl(u,h)}return null}(e,t)}function yc(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function Ac(e,t){return e&&t.isSelectable(e)}class kc extends(Ns()){constructor(e,t){super(),(0,o.A)(this,"model",void 0),(0,o.A)(this,"view",void 0),(0,o.A)(this,"mapper",void 0),(0,o.A)(this,"downcastDispatcher",void 0),this.model=e,this.view=new dl(t),this.mapper=new El,this.downcastDispatcher=new xl({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.selection,s=this.model.markers;var r,a,l;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.listenTo(this.view.document,"beforeinput",(r=this.mapper,a=this.model.schema,l=this.view,(e,t)=>{if(!l.document.isComposing||Yn.isAndroid)for(let i=0;i<t.targetRanges.length;i++){const e=t.targetRanges[i],n=r.toModelRange(e),s=vc(n,a);s&&!s.isEqual(n)&&(t.targetRanges[i]=r.toViewRange(s))}}),{priority:"high"}),this.downcastDispatcher.on("insert:$text",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))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("insert",(e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)},{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 l of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(l,{defer:!0})},{priority:"low"}),this.downcastDispatcher.on("cleanSelection",(e,t,i)=>{const n=i.writer,s=n.document.selection;for(const o of s.getRanges())o.isCollapsed&&o.end.parent.isAttached()&&i.writer.mergeAttributes(o.start);n.setSelection(null)}),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 o of n.getRanges())s.push(i.mapper.toViewRange(o));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 Ur(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new gs("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(i)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}class Ec extends(Ns()){constructor(){super(),(0,o.A)(this,"_sourceDefinitions",{}),(0,o.A)(this,"_attributeProperties",Object.create(null)),(0,o.A)(this,"_customChildChecks",new Map),(0,o.A)(this,"_customAttributeChecks",new Map),(0,o.A)(this,"_genericCheckSymbol",Symbol("$generic")),(0,o.A)(this,"_compiledDefinitions",void 0),this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new Cc(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new Cc(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new gs("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 gs("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:"is"in e&&(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(e,t)}checkAttribute(e,t){const i=this.getDefinition(e.last);if(!i)return!1;const n=this._evaluateAttributeChecks(e,t);return void 0!==n?n:i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof _l){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof Gl))throw new gs("schema-check-merge-no-element-before",this);if(!(i instanceof Gl))throw new gs("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e,t){const i=void 0!==t?t:this._genericCheckSymbol,n=this._customChildChecks.get(i)||[];n.push(e),this._customChildChecks.set(i,n)}addAttributeCheck(e,t){const i=void 0!==t?t:this._genericCheckSymbol,n=this._customAttributeChecks.get(i)||[];n.push(e),this._customAttributeChecks.set(i,n)}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let t;if(e instanceof _l)t=e.parent;else{t=(e instanceof kl?[e]:Array.from(e.getRanges())).reduce((e,t)=>
2{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 ql("",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){let t,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"both";if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new kl(e);const s=e.getAncestors().reverse().find(e=>this.isLimit(e))||e.root;"both"!=n&&"backward"!=n||(t=new gl({boundaries:kl._createIn(s),startPosition:e,direction:"backward"})),"both"!=n&&"forward"!=n||(i=new gl({boundaries:kl._createIn(s),startPosition:e}));for(const o 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})}}}(t,i)){const e=o.walker==t?"elementEnd":"elementStart",i=o.value;if(i.type==e&&this.isObject(i.item))return kl._createOn(i.item);if(this.checkChild(i.nextPosition,"$text"))return new kl(i.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}setAllowedAttributes(e,t,i){const n=i.model;for(const[s,o]of Object.entries(t))n.schema.checkAttribute(e,s)&&i.setAttribute(s,o,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Nc(this,i,t);else{const e=kl._createIn(i).getPositions();for(const i of e){Nc(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const n={};for(const[s,o]of e.getAttributes()){const e=this.getAttributeProperties(s);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[s]=o))}return n}createContext(e){return new Cc(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const s of i)e[s]=Pc(t[s],s);const n=Object.values(e);for(const s of n)Tc(e,s),xc(e,s),Dc(e,s),Sc(e,s);for(const s of n)Ic(e,s);for(const s of n)Oc(e,s);for(const s of n)Fc(e,s);for(const s of n)Bc(e,s);for(const s of n)Mc(e,s);this._compiledDefinitions=function(e){const t={};for(const i of Object.values(e))t[i.name]={name:i.name,isBlock:!!i.isBlock,isContent:!!i.isContent,isInline:!!i.isInline,isLimit:!!i.isLimit,isObject:!!i.isObject,isSelectable:!!i.isSelectable,allowIn:Array.from(i.allowIn).filter(t=>!!e[t]),allowChildren:Array.from(i.allowChildren).filter(t=>!!e[t]),allowAttributes:Array.from(i.allowAttributes)};return t}(e)}_checkContextMatch(e,t){const i=e.last;let n=this._evaluateChildChecks(e,t);if(n=void 0!==n?n:t.allowIn.includes(i.name),!n)return!1;const s=this.getDefinition(i),o=e.trimLast();return!!s&&(0==o.length||this._checkContextMatch(o,s))}_evaluateChildChecks(e,t){const i=this._customChildChecks.get(this._genericCheckSymbol)||[],n=this._customChildChecks.get(t.name)||[];for(const s of[...i,...n]){const i=s(e,t);if(void 0!==i)return i}}_evaluateAttributeChecks(e,t){const i=this._customAttributeChecks.get(this._genericCheckSymbol)||[],n=this._customAttributeChecks.get(t)||[];for(const s of[...i,...n]){const i=s(e,t);if(void 0!==i)return i}}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const s of e.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(kl._createIn(s),t)),this.checkAttribute(s,t)||(i.isEqual(n)||(yield new kl(i,n)),i=_l._createAfter(s)),n=_l._createAfter(s);i.isEqual(n)||(yield new kl(i,n))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return"before"==t||"after"==t?new kl(_l._createAt(i,t)):kl._createOn(i);const n=Xo(e.getSelectedBlocks());if(!n)return new kl(e.focus);if(n.isEmpty)return new kl(_l._createAt(n,0));const s=_l._createAfter(n);return e.focus.isTouching(s)?new kl(s):new kl(_l._createBefore(n))}}class Cc{constructor(e){if((0,o.A)(this,"_items",void 0),e instanceof Cc)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(Vc)}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 Cc([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new Cc([]);return e._items=this._items.slice(0,-1),e}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}
2endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function Pc(e,t){const i={name:t,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};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),Rc(e,i,"allowIn"),Rc(e,i,"allowChildren"),Rc(e,i,"disallowIn"),Rc(e,i,"disallowChildren"),Rc(e,i,"allowContentOf"),Rc(e,i,"allowWhere"),Rc(e,i,"allowAttributes"),Rc(e,i,"disallowAttributes"),Rc(e,i,"allowAttributesOf"),Rc(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.add(e),t.allowWhere.add(e),t.allowAttributesOf.add(e),t.inheritTypesFrom.add(e))}}(e,i),i}function Tc(e,t){for(const i of t.allowIn){const n=e[i];n?n.allowChildren.add(t.name):t.allowIn.delete(i)}}function xc(e,t){for(const i of t.allowChildren){const n=e[i];n?n.allowIn.add(t.name):t.allowChildren.delete(i)}}function Dc(e,t){for(const i of t.disallowIn){const n=e[i];n?n.disallowChildren.add(t.name):t.disallowIn.delete(i)}}function Sc(e,t){for(const i of t.disallowChildren){const n=e[i];n?n.disallowIn.add(t.name):t.disallowChildren.delete(i)}}function Ic(e,t){for(const i of t.disallowChildren)t.allowChildren.delete(i);for(const i of t.disallowIn)t.allowIn.delete(i);for(const i of t.disallowAttributes)t.allowAttributes.delete(i)}function Oc(e,t){for(const i of t.allowContentOf){const n=e[i];n&&(n.disallowChildren.forEach(i=>{t.allowChildren.has(i)||(t.disallowChildren.add(i),e[i].disallowIn.add(t.name))}),n.allowChildren.forEach(i=>{t.disallowChildren.has(i)||(t.allowChildren.add(i),e[i].allowIn.add(t.name))}))}}function Fc(e,t){for(const i of t.allowWhere){const n=e[i];n&&(n.disallowIn.forEach(i=>{t.allowIn.has(i)||(t.disallowIn.add(i),e[i].disallowChildren.add(t.name))}),n.allowIn.forEach(i=>{t.disallowIn.has(i)||(t.allowIn.add(i),e[i].allowChildren.add(t.name))}))}}function Bc(e,t){for(const i of t.allowAttributesOf){const n=e[i];if(!n)return;n.allowAttributes.forEach(e=>{t.disallowAttributes.has(e)||t.allowAttributes.add(e)})}}function Mc(e,t){for(const i of t.inheritTypesFrom){const n=e[i];if(n){const e=Object.keys(n).filter(e=>e.startsWith("is"));for(const i of e)i in t||(t[i]=n[i])}}}function Rc(e,t,i){for(const n of e){let e=n[i];"string"==typeof e&&(e=[e]),Array.isArray(e)&&e.forEach(e=>t[i].add(e))}}function Vc(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 Nc(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class Lc extends(Es()){constructor(e){super(),(0,o.A)(this,"conversionApi",void 0),(0,o.A)(this,"_splitParts",new Map),(0,o.A)(this,"_cursorParents",new Map),(0,o.A)(this,"_modelCursor",null),(0,o.A)(this,"_emptyElementsToKeep",new Set),this.conversionApi=(0,r.A)((0,r.A)({},e),{},{consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)})}convert(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:["$root"];this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new Cc(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const s=t.createElement(n.name,e);i&&t.insert(s,i),i=_l._createAt(s,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=Er.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(n){this._removeEmptyElements();const e=this._modelCursor.parent,i=e._removeChildren(0,e.childCount);s._insertChild(0,i),s.markers=function(e,t){const i=new Set,n=new Map,s=kl._createIn(e).getItems();for(const o of s)o.is("element","$marker")&&i.add(o);for(const o of i){const e=o.getAttribute("data-name"),i=t.createPositionBefore(o);n.has(e)?n.get(e).end=i.clone():n.set(e,new kl(i.clone())),t.remove(o)}return n}(s,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire("element:".concat(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 kl))throw new gs("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:_l._createAt(t,0);const n=new kl(i);for(const s of Array.from(e.getChildren())){const e=this._convertItem(s,i);e.modelRange instanceof kl&&(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 uc(t,e,i)?{position:hc(t,n)}:null;const o=this.conversionApi.writer.split(t,s),r=[];for(const l of o.range.getWalker())if("elementEnd"==l.type)r.push(l.item);else{const e=r.pop(),t=l.item;this._registerSplitPair(e,t)}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}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;
2for(const t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){const i=e.get(t.parent)||[];i.push(t),this._splitParts.delete(t),e.set(t.parent,i)}for(const[t,i]of e)t._removeChildrenArray(i);e.size&&this._removeEmptyElements()}}class jc{getHtml(e){const t=Jn.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class Wc{constructor(e){(0,o.A)(this,"domParser",void 0),(0,o.A)(this,"domConverter",void 0),(0,o.A)(this,"htmlWriter",void 0),(0,o.A)(this,"skipComments",!0),this.domParser=new DOMParser,this.domConverter=new Ua(e,{renderingMode:"data"}),this.htmlWriter=new jc}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e="<body>".concat(e,"</body>"));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}}class qc extends(Es()){constructor(e,t){super(),(0,o.A)(this,"model",void 0),(0,o.A)(this,"mapper",void 0),(0,o.A)(this,"downcastDispatcher",void 0),(0,o.A)(this,"upcastDispatcher",void 0),(0,o.A)(this,"viewDocument",void 0),(0,o.A)(this,"stylesProcessor",void 0),(0,o.A)(this,"htmlProcessor",void 0),(0,o.A)(this,"processor",void 0),(0,o.A)(this,"_viewWriter",void 0),this.model=e,this.mapper=new El,this.downcastDispatcher=new xl({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))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("insert",(e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)},{priority:"lowest"}),this.upcastDispatcher=new Lc({schema:e.schema}),this.viewDocument=new na(t),this.stylesProcessor=t,this.htmlProcessor=new Wc(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new ga(this.viewDocument),this.upcastDispatcher.on("text",(e,t,i)=>{let{schema:n,consumable:s,writer:o}=i,r=t.modelCursor;if(!s.test(t.viewItem))return;if(!n.checkChild(r,"$text")){if(!uc(r,"$text",n))return;if(0==t.viewItem.data.trim().length)return;r=hc(r,o)}s.consume(t.viewItem);const a=o.createText(t.viewItem.data);o.insert(a,r),t.modelRange=o.createRange(r,r.getShiftedBy(a.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"}),Ns().prototype.decorate.call(this,"init"),Ns().prototype.decorate.call(this,"set"),Ns().prototype.decorate.call(this,"get"),Ns().prototype.decorate.call(this,"toView"),Ns().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},cc)},{priority:"lowest"})}get(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new gs("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||ps("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.toView(e,t);return this.processor.toData(i)}toView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const s=kl._createIn(e),o=new fa(i);this.mapper.bindElements(e,o);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=kl._createIn(e);for(const s of i.model.markers){const e=s.getRange(),i=e.isCollapsed,o=e.start.isEqual(n.start)||e.end.isEqual(n.end);if(i&&o)t.push([s.name,e]);else{const i=n.getIntersection(e);
2i&&t.push([s.name,i])}}return t.sort((e,t)=>{let[i,n]=e,[s,o]=t;if("after"!==n.end.compareWith(o.start))return 1;if("before"!==n.start.compareWith(o.end))return-1;switch(n.start.compareWith(o.start)){case"before":return 1;case"after":return-1;default:switch(n.end.compareWith(o.end)){case"before":return 1;case"after":return-1;default:return s.localeCompare(i)}}}),new Map(t)}(e);return this.downcastDispatcher.convert(s,r,n,t),o}init(e){if(this.model.document.version)throw new gs("datacontroller-init-document-not-empty",this);let t={};if("string"===typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new gs("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},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=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};if("string"===typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new gs("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}})}parse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$root";const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$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.getRoot(t))return!1;return!0}}class Uc{constructor(e,t){(0,o.A)(this,"_helpers",new Map),(0,o.A)(this,"_downcast",void 0),(0,o.A)(this,"_upcast",void 0),this._downcast=Jo(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=Jo(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 gs("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new gs("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of zc(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 zc(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 zc(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers(e){let{name:t,dispatchers:i,isDowncast:n}=e;if(this._helpers.has(t))throw new gs("conversion-group-exists",this);const s=n?new Zl(i):new dc(i);this._helpers.set(t,s)}}function*zc(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*Hc(i,n,s)}else yield*Hc(e.model,e.view,e.upcastAlso)}function*Hc(e,t,i){if(yield{model:e,view:t},i)for(const n of Jo(i))yield{model:e,view:n}}class $c{constructor(e){(0,o.A)(this,"baseVersion",void 0),(0,o.A)(this,"isDocumentOperation",void 0),(0,o.A)(this,"batch",void 0),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,t){return new this(e.baseVersion)}}function Kc(e,t){const i=Zc(t),n=i.reduce((e,t)=>
2e+t.offsetSize,0),s=e.parent;Yc(e);const o=e.index;return s._insertChild(o,i),Qc(s,o+i.length),Qc(s,o),new kl(e,e.getShiftedBy(n))}function Gc(e){if(!e.isFlat)throw new gs("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Yc(e.start),Yc(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Qc(t,e.start.index),i}function Jc(e,t){if(!e.isFlat)throw new gs("operation-utils-move-range-not-flat",this);const i=Gc(e);return Kc(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Zc(e){const t=[];!function e(i){if("string"==typeof i)t.push(new ql(i));else if(i instanceof fl)t.push(new ql(i.data,i.getAttributes()));else if(i instanceof Il)t.push(i);else if(Ks(i))for(const t of i)e(t)}(e);for(let i=1;i<t.length;i++){const e=t[i],n=t[i-1];e instanceof ql&&n instanceof ql&&Xc(e,n)&&(t.splice(i-1,2,new ql(n.data+e.data,n.getAttributes())),i--)}return t}function Qc(e,t){const i=e.getChild(t-1),n=e.getChild(t);if(i&&n&&i.is("$text")&&n.is("$text")&&Xc(i,n)){const s=new ql(i.data+n.data,i.getAttributes());e._removeChildren(t-1,2),e._insertChild(t-1,s)}}function Yc(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 ql(t.data.substr(0,n),t.getAttributes()),r=new ql(t.data.substr(n),t.getAttributes());i._insertChild(s,[o,r])}}function Xc(e,t){const i=e.getAttributes(),n=t.getAttributes();for(const s of i){if(s[1]!==t.getAttribute(s[0]))return!1;n.next()}return n.next().done}class eu extends $c{constructor(e,t,i,n){super(n),(0,o.A)(this,"sourcePosition",void 0),(0,o.A)(this,"howMany",void 0),(0,o.A)(this,"targetPosition",void 0),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"}get affectedSelectable(){return[kl._createFromPositionAndShift(this.sourcePosition,this.howMany),kl._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new eu(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 eu(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 gs("move-operation-nodes-do-not-exist",this);if(e===t&&i<n&&n<i+this.howMany)throw new gs("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&"prefix"==$s(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 gs("move-operation-node-into-itself",this)}}_execute(){Jc(kl._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=_l.fromJSON(e.sourcePosition,t),n=_l.fromJSON(e.targetPosition,t);return new this(i,e.howMany,n,e.baseVersion)}}class tu extends $c{constructor(e,t,i){super(i),(0,o.A)(this,"position",void 0),(0,o.A)(this,"nodes",void 0),(0,o.A)(this,"shouldReceiveAttributes",void 0),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new Kl(Zc(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new Kl([...this.nodes].map(e=>e._clone(!0))),t=new tu(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new _l(e,[0]);return new eu(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new gs("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new Kl([...e].map(e=>e._clone(!0))),Kc(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 s of e.nodes)s.name?i.push(Gl.fromJSON(s)):i.push(ql.fromJSON(s));const n=new tu(_l.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class iu extends $c{constructor(e,t,i,n,s){super(s),(0,o.A)(this,"splitPosition",void 0),(0,o.A)(this,"howMany",void 0),(0,o.A)(this,"insertionPosition",void 0),(0,o.A)(this,"graveyardPosition",void 0),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 _l(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new kl(this.splitPosition,e)}get affectedSelectable(){const e=[kl._createFromPositionAndShift(this.splitPosition,0),kl._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(kl._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new iu(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new _l(e,[0]);return new nu(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 gs("split-operation-position-invalid",this);if(!e.parent)throw new gs("split-operation-split-in-root",this);if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new gs("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new gs("split-operation-graveyard-position-invalid",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)Jc(kl._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const t=e._clone();Kc(this.insertionPosition,t)}Jc(new kl(_l._createAt(e,this.splitPosition.offset),_l._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 _l(e.root,t,"toPrevious")}static fromJSON(e,t){const i=_l.fromJSON(e.splitPosition,t),n=_l.fromJSON(e.insertionPosition,t),s=e.graveyardPosition?_l.fromJSON(e.graveyardPosition,t):null;return new this(i,e.howMany,n,s,e.baseVersion)}}class nu extends $c{constructor(e,t,i,n,s){super(s),(0,o.A)(this,"sourcePosition",void 0),(0,o.A)(this,"howMany",void 0),(0,o.A)(this,"targetPosition",void 0),(0,o.A)(this,"graveyardPosition",void 0),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 _l(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new kl(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[kl._createOn(e),kl._createFromPositionAndShift(this.targetPosition,0),kl._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new nu(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 _l(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new iu(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new gs("merge-operation-source-position-invalid",this);if(!t.parent)throw new gs("merge-operation-target-position-invalid",this);if(this.howMany!=e.maxOffset)throw new gs("merge-operation-how-many-invalid",this)}_execute(){const e=this.sourcePosition.parent;Jc(kl._createIn(e),this.targetPosition),Jc(kl._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=_l.fromJSON(e.sourcePosition,t),n=_l.fromJSON(e.targetPosition,t),s=_l.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,n,s,e.baseVersion)}}class su extends $c{constructor(e,t,i,n,s,r){super(r),(0,o.A)(this,"name",void 0),(0,o.A)(this,"oldRange",void 0),(0,o.A)(this,"newRange",void 0),(0,o.A)(this,"affectsData",void 0),(0,o.A)(this,"_markers",void 0),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"}get affectedSelectable(){const e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new su(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new su(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}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 su(e.name,e.oldRange?kl.fromJSON(e.oldRange,t):null,e.newRange?kl.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class ou extends $c{constructor(e,t,i,n,s){super(s),(0,o.A)(this,"range",void 0),(0,o.A)(this,"key",void 0),(0,o.A)(this,"oldValue",void 0),(0,o.A)(this,"newValue",void 0),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"}get affectedSelectable(){return this.range.clone()}clone(){return new ou(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new ou(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 gs("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!jn(e.getAttribute(this.key),this.oldValue))throw new gs("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 gs("attribute-operation-attribute-exists",this,{node:e,ke
2y:this.key})}}_execute(){jn(this.oldValue,this.newValue)||function(e,t,i){Yc(e.start),Yc(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),Qc(e.parent,e.index)}Qc(e.end.parent,e.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new ou(kl.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class ru extends $c{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new ru(this.baseVersion)}getReversed(){return new ru(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class au extends $c{constructor(e,t,i,n){super(n),(0,o.A)(this,"position",void 0),(0,o.A)(this,"oldName",void 0),(0,o.A)(this,"newName",void 0),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=i}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new au(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new au(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof Gl))throw new gs("rename-operation-wrong-position",this);if(e.name!==this.oldName)throw new gs("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 au(_l.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class lu extends $c{constructor(e,t,i,n,s){super(s),(0,o.A)(this,"root",void 0),(0,o.A)(this,"key",void 0),(0,o.A)(this,"oldValue",void 0),(0,o.A)(this,"newValue",void 0),this.root=e,this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new lu(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new lu(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new gs("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 gs("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 gs("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 gs("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new lu(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class cu extends $c{constructor(e,t,i,n,s){if(super(s),(0,o.A)(this,"rootName",void 0),(0,o.A)(this,"elementName",void 0),(0,o.A)(this,"isAdd",void 0),(0,o.A)(this,"_document",void 0),this.rootName=e,this.elementName=t,this.isAdd=i,this._document=n,!this._document.getRoot(this.rootName)){this._document.createRoot(this.elementName,this.rootName)._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new cu(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new cu(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new cu(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}const uu={};uu[ou.className]=ou,uu[tu.className]=tu,uu[su.className]=su,uu[eu.className]=eu,uu[ru.className]=ru,uu[$c.className]=$c,uu[au.className]=au,uu[lu.className]=lu,uu[cu.className]=cu,uu[iu.className]=iu,uu[nu.className]=nu;class hu{static fromJSON(e,t){return uu[e.__className].fromJSON(e,t)}}const du=new Map;function mu(e,t,i){let n=du.get(e);n||(n=new Map,du.set(e,n)),n.set(t,i)}function fu(e){return[e]}function gu(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=function(e,t){const i=du.get(e);return i&&i.has(t)?i.get(t):fu}(e.constructor,t.constructor);try{return n(e=e.clone(),t,i)}catch(by){throw by}}function pu(e,t,i){e=e.slice(),t=t.slice();const n=new _u(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 l of e)o.set(l,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=gu(i,r,n.getContext(i,r,!0)),c=gu(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)}return bu(e),bu(t),wu(e,r.nextBaseVersionB),wu(t,r.nextBaseVersionA),{operationsA:e,operationsB:t,originalOperations:s}}class _u{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(0,o.A)(this,"originalOperations",void 0),(0,o.A)(this,"_history",void 0),(0,o.A)(this,"_useRelations",void 0),(0,o.A)(this,"_forceWeakRemove",void 0),(0,o.A)(this,"_relations",void 0),this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!i,this._relations=new Map}setOriginalOperations(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=t?this.originalOperations.get(t):null;for(const n of e)this.originalOperations.set(n,i||n)}updateRelation(e,t){if(e instanceof eu)t instanceof nu?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"):t instanceof eu&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof iu){if(t instanceof nu)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof eu)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const i=kl._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})}}}else if(e instanceof nu)t instanceof nu?(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")):t instanceof iu?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof eu&&t.howMany>0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof su){const i=e.newRange;if(!i)return;if(t instanceof nu){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})}}}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 wu(e,t){for(const i of e)i.baseVersion=t++}function bu(e){const t=new Map;for(let i=0;i<e.length;i++){const n=e[i];n instanceof su&&(-1!==n.baseVersion?t.set(n.name,{op:n,ranges:n.newRange?[n.newRange]:[]}):(n.newRange&&t.get(n.name).ranges.push(n.newRange),e.splice(i,1),i--))}for(const{op:i,ranges:n}of t.values())n.length?i.newRange=kl._createFromRanges(n):i.newRange=null}function vu(e,t,i){const n=e.nodes.getNode(0).getAttribute(t);if(n==i)return null;const s=new kl(e.position,e.position.getShiftedBy(e.howMany));return new ou(s,t,n,i,0)}function yu(e,t){return null===e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany)}function Au(e,t){const i=[];for(let n=0;n<e.length;n++){const s=e[n],o=new eu(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}mu(ou,ou,(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 ou(t,e.key,e.oldValue,e.newValue,0)),s=e.range.getIntersection(t.range);return s&&i.aIsStrong&&n.push(new ou(s,t.key,t.newValue,e.newValue,0)),0==n.length?[new ru(0)]:n}return[e]}),mu(ou,tu,(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 ou(t,e.key,e.oldValue,e.newValue,e.baseVersion));if(t.shouldReceiveAttributes){const n=vu(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]}),mu(ou,nu,(e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(kl._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map(t=>new ou(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),mu(ou,eu,(e,t)=>{const i=function(e,t){const i=kl._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 r of s){r=r._getTransformedByDeletion(t.sourcePosition,t.howMany);const e=t.getMovedRangeStart(),i=r.start.hasSameParentAs(e),n=r._getTransformedByInsertion(e,t.howMany,i);o.push(...n)}n&&o.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return o}(e.range,t);return i.map(t=>new ou(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),mu(ou,iu,(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 kl(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]}),mu(tu,ou,(e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=vu(e,t.ke
2y,t.newValue);n&&i.push(n)}return i}),mu(tu,tu,(e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e])),mu(tu,eu,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),mu(tu,iu,(e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e])),mu(tu,nu,(e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e])),mu(su,tu,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e])),mu(su,su,(e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new ru(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]}),mu(su,nu,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e])),mu(su,eu,(e,t)=>{const i=[e];if(e.oldRange&&(e.oldRange=kl._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){const n=e.newRange._getTransformedByMoveOperation(t);e.newRange=n[0];for(let t=1;t<n.length;t++){const s=e.clone();s.oldRange=null,s.newRange=n[t],s.baseVersion=-1,i.push(s)}}return i}),mu(su,iu,(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=_l._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement?e.newRange.start=_l._createAt(t.moveTargetPosition):e.newRange.start=n.start,e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=_l._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=_l._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]}),mu(nu,tu,(e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e])),mu(nu,nu,(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 _l(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new ru(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;if(s&&!n||!(n&&!s)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new eu(i,e.howMany,n,0)]}return[new ru(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]}),mu(nu,eu,(e,t,i)=>{const n=kl._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new ru(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(e.sourcePosition)&&"mergeSourceAffected"==i.abRelation?e.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness="toNone",e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&"mergeTargetWasBefore"==i.abRelation?(e.targetPosition.stickiness="toPrevious",e.howMany+=t.howMany):(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.sourcePosition.stickiness="toPrevious",e.targetPosition.stickiness="toNext",e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])}),mu(nu,iu,(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)){if
2(t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition)||"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]}),mu(eu,tu,(e,t)=>{const i=kl._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]}),mu(eu,eu,(e,t,i)=>{const n=kl._createFromPositionAndShift(e.sourcePosition,e.howMany),s=kl._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),yu(e,t)&&yu(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),Au([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()),Au([n],o);const l=$s(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),Au([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=[],u=n.getDifference(s);for(const d of u){d.start=d.start._getTransformedByDeletion(t.sourcePosition,t.howMany),d.end=d.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const e="same"==$s(d.start.getParentPath(),t.getMovedRangeStart().getParentPath()),i=d._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,e);c.push(...i)}const h=n.getIntersection(s);return null!==h&&r&&(h.start=h.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),h.end=h.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(h):1==c.length?s.start.isBefore(n.start)||s.start.isEqual(n.start)?c.unshift(h):c.push(h):c.splice(1,0,h)),0===c.length?[new ru(e.baseVersion)]:Au(c,o)}),mu(eu,iu,(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=kl._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 kl(t.splitPosition,s.end);e=e._getTransformedBySplitOperation(t);return Au([new kl(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(kl._createFromPositionAndShift(t.insertionPosition,1))}return Au(o,n)}),mu(eu,nu,(e,t,i)=>{const n=kl._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 ru(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),s=t.targetPosition._getTransformedByMergeOperation(t);const o=e.targetPosition.getTransformedByOperation(t);e.howMany>1&&(i.push(new eu(e.sourcePosition,e.howMany-1,o,0)),n=n._getTransformedByMove(e.sourcePosition,o,e.howMany-1),s=s._getTransformedByMove(e.sourcePosition,o,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,o),a=new eu(n,1,r,0),l=a.getMovedRangeStart().path.slice();l.push(0);const c=new _l(a.targetPosition.root,l);s=s._getTransformedByMove(n,r,1);const u=new eu(s,t.howMany,c,0);return i.push(a),i.push(u),i}const s=kl._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]}),mu(au,tu,(e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e])),mu(au,nu,(e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e])),mu(au,eu,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),mu(au,au,(e,t,i)=>
2{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new ru(0)];e.oldName=t.newName}return[e]}),mu(au,iu,(e,t)=>{if("same"==$s(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new au(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]}),mu(lu,lu,(e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new ru(0)];e.oldValue=t.newValue}return[e]}),mu(cu,cu,(e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new ru(0)]:[e]),mu(iu,tu,(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])),mu(iu,nu,(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 _l(t.graveyardPosition.root,i),s=iu.getInsertionPosition(new _l(t.graveyardPosition.root,i)),o=new iu(n,0,s,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=iu.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=iu.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),mu(iu,eu,(e,t,i)=>{const n=kl._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 _l(n.root,s);return[new eu(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=iu.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.
2insertionPosition=iu.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=iu.getInsertionPosition(e.splitPosition),[e]}),mu(iu,iu,(e,t,i)=>{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new ru(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new ru(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;if(s&&!n||!(n&&!s)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new eu(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new eu(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new ru(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 _l(t.insertionPosition.root,i);return[e,new eu(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=iu.getInsertionPosition(e.splitPosition),[e]});class ku extends(Es(_l)){constructor(e,t){if(super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:"toNone"),!this.root.is("rootElement"))throw new gs("model-liveposition-root-not-rootelement",e);Eu.call(this)}detach(){this.stopListening()}toPosition(){return new _l(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}function Eu(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&Cu.call(this,i)},{priority:"low"})}function Cu(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)}}ku.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class Pu{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,o.A)(this,"operations",void 0),(0,o.A)(this,"isUndoable",void 0),(0,o.A)(this,"isLocal",void 0),(0,o.A)(this,"isUndo",void 0),(0,o.A)(this,"isTyping",void 0),"string"===typeof e&&(e="transparent"===e?{isUndoable:!1}:{},ps("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=s}get type(){return ps("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}class Tu{constructor(e){(0,o.A)(this,"_markerCollection",void 0),(0,o.A)(this,"_changesInElement",new Map),(0,o.A)(this,"_elementsSnapshots",new Map),(0,o.A)(this,"_elementChildrenSnapshots",new Map),(0,o.A)(this,"_elementState",new Map),(0,o.A)(this,"_changedMarkers",new Map),(0,o.A)(this,"_changedRoots",new Map),(0,o.A)(this,"_changeCount",0),(0,o.A)(this,"_cachedChanges",null),(0,o.A)(this,"_cachedChangesWithGraveyard",null),(0,o.A)(this,"_refreshedItems",new Set),this._markerCollection=e}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRo
2ots.size}bufferOperation(e){const t=e;switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const n=kl._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const t of n.getItems({shallow:!0}))this._setElementState(t,"move");break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=kl._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const e=t.splitPosition.parent;if(!this._isInInsertedElement(e)){this._markRemove(e,t.splitPosition.offset,t.howMany);const i=kl._createFromPositionAndShift(t.splitPosition,t.howMany);for(const e of i.getItems({shallow:!0}))this._setElementState(e,"move")}this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&(this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1),this._setElementState(t.graveyardPosition.nodeAfter,"move"));break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1),this._setElementState(e,"move");const n=t.targetPosition.parent;if(!this._isInInsertedElement(n)){this._markInsert(n,t.targetPosition.offset,e.maxOffset);const i=kl._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const e of i.getItems({shallow:!0}))this._setElementState(e,"move")}break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(e=>{let[t,i]=e;return{name:t,data:{oldRange:i.oldMarkerData.range,newRange:i.newMarkerData.range}}})}hasDataChanges(){if(this.getChanges().length)return!0;if(this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,n=!e.range&&t.range,s=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||s)return!0}}return!1}getChanges(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const i of this._changesInElement.keys()){const e=this._changesInElement.get(i).sort((e,t)=>
2e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offset<t.offset?-1:1),n=this._elementChildrenSnapshots.get(i),s=Du(i.getChildren()),o=Su(n.length,e);let r=0,a=0;for(const l of o)if("i"===l){const e=this._getDiffActionForNode(s[r].node,"insert"),n=this._elementsSnapshots.get(s[r].node),o=this._getInsertDiff(i,r,e,s[r],n);t.push(o),r++}else if("r"===l){const e=this._getDiffActionForNode(n[a].node,"remove"),s=this._getRemoveDiff(i,r,e,n[a]);t.push(s),a++}else if("a"===l){const e=n[a].attributes,o=s[r].attributes;let l;if("$text"==s[r].name)l=new kl(_l._createAt(i,r),_l._createAt(i,r+1));else{const e=i.offsetToIndex(r);l=new kl(_l._createAt(i,r),_l._createAt(i.getChild(e),0))}const c=this._getAttributesDiff(l,e,o);t.push(...c),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 i=1,n=0;i<t.length;i++){const e=t[n],s=t[i],o="remove"==e.type&&"remove"==s.type&&"$text"==e.name&&"$text"==s.name&&e.position.isEqual(s.position),r="insert"==e.type&&"insert"==s.type&&"$text"==e.name&&"$text"==s.name&&e.position.parent==s.position.parent&&e.position.offset+e.length==s.position.offset,a="attribute"==e.type&&"attribute"==s.type&&e.position.parent==s.position.parent&&e.range.isFlat&&s.range.isFlat&&e.position.offset+e.length==s.position.offset&&e.attributeKey==s.attributeKey&&e.attributeOldValue==s.attributeOldValue&&e.attributeNewValue==s.attributeNewValue;o||r||a?(e.length++,a&&(e.range.end=e.range.end.getShiftedBy(1)),t[i]=null):n=i}t=t.filter(e=>e);for(const i of t)delete i.changeCount,"attribute"==i.type&&(delete i.position,delete i.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(Iu),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}
2getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t=(0,r.A)({},e);return void 0!==t.state&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");const t=kl._createOn(e);for(const i of this._markerCollection.getMarkersIntersectingRange(t)){const e=i.getData();this.bufferMarkerChange(i.name,e,e)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const e=t.getData();this.bufferMarkerChange(t.name,(0,r.A)((0,r.A)({},e),{},{range:null}),e)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const s=this._changedRoots.get(e)||{name:e},o=s.attributes||{};if(o[t]){const e=o[t];n===e.oldValue?delete o[t]:e.newValue=n}else o[t]={oldValue:i,newValue:n};0===Object.entries(o).length?(delete s.attributes,void 0===s.state&&this._changedRoots.delete(e)):(s.attributes=o,this._changedRoots.set(e,s))}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let n=0;n<i.length;n++)i[n].howMany<1&&(i.splice(n,1),n--)}_setElementState(e,t){if(!e.is("element"))return;const i=Tu._statesPriority.indexOf(this._elementState.get(e));Tu._statesPriority.indexOf(t)>i&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element"))return t;if(!this._elementsSnapshots.has(e))return t;const i=this._elementState.get(e);return i&&"move"!=i?i:t}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;const t=Du(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const i of t)this._elementsSnapshots.set(i.node,i)}_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;
2const 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,n,s){const o={type:"insert",position:_l._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++,action:i};return"insert"!=i&&s&&(o.before={name:s.name,attributes:new Map(s.attributes)}),o}_getRemoveDiff(e,t,i,n){return{type:"remove",action:i,position:_l._createAt(e,t),name:n.name,attributes:new Map(n.attributes),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[s,o]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:null,attributeNewValue:o,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 s of i)if("insert"==s.type&&n>=s.offset&&n<s.offset+s.howMany)return!0;return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,i){const n=new kl(_l._createAt(e,t),_l._createAt(e,t+i));for(const s of n.getItems({shallow:!0}))s.is("element")&&(this._changesInElement.delete(s),this._removeAllNestedChanges(s,0,s.maxOffset))}}function xu(e){return{node:e,name:e.is("$text")?"$text":e.name,attributes:new Map(e.getAttributes())}}function Du(e){const t=[];for(const i of e)if(i.is("$text"))for(let e=0;e<i.data.length;++e)t.push(xu(i));else t.push(xu(i));return t}function Su(e,t){const i=[];let n=0,s=0;for(const o of t){if(o.offset>n){for(let e=0;e<o.offset-n;e++)i.push("e");s+=o.offset-n}if("insert"==o.type){for(let e=0;e<o.howMany;e++)i.push("i");n=o.offset+o.howMany}else if("remove"==o.type){for(let e=0;e<o.howMany;e++)i.push("r");n=o.offset,s+=o.howMany}else{if(o.howMany>1500)for(let e=0;e<o.howMany;e++)i.push("a");else i.push(..."a".repeat(o.howMany).split(""));n=o.offset+o.howMany,s+=o.howMany}}if(s<e)for(let o=0;o<e-s-n;o++)i.push("e");return i}function Iu(e){const t="position"in e&&"$graveyard"==e.position.root.rootName,i="range"in e&&"$graveyard"==e.range.root.rootName;return!t&&!i}(0,o.A)(Tu,"_statesPriority",[void 0,"refresh","rename","move"]);class Ou{constructor(){(0,o.A)(this,"_operations",[]),(0,o.A)(this,"_undoPairs",new Map),(0,o.A)(this,"_undoneOperations",new Set),(0,o.A)(this,"_baseVersionToOperationIndex",new Map),(0,o.A)(this,"_version",0),(0,o.A)(this,"_gaps",new Map)}get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new gs("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.version;if(!this._operations.length)return[];const i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[r,a]of this._gaps)e>r&&e<a&&(e=a),n>r&&n<a&&(n=r-1);if(n<i.baseVersion||e>this.lastOperation.baseVersion)return[];let s=this._baseVersionToOperationIndex.get(e);void 0===s&&(s=0);let o=this._baseVersionToOperationIndex.get(n);return void 0===o&&(o=this._operations.length-1),this._operations.slice(s,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}
2setOperationAsUndone(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)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class Fu extends Gl{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"main";super(t),(0,o.A)(this,"rootName",void 0),(0,o.A)(this,"_document",void 0),(0,o.A)(this,"_isAttached",!0),(0,o.A)(this,"_isLoaded",!0),this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}Fu.prototype.is=function(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};const Bu="$graveyard";class Mu extends(Es()){constructor(e){super(),(0,o.A)(this,"model",void 0),(0,o.A)(this,"history",void 0),(0,o.A)(this,"selection",void 0),(0,o.A)(this,"roots",void 0),(0,o.A)(this,"differ",void 0),(0,o.A)(this,"isReadOnly",void 0),(0,o.A)(this,"_postFixers",void 0),(0,o.A)(this,"_hasSelectionChangedFromTheLastChangeBlock",void 0),this.model=e,this.history=new Ou,this.selection=new zl(this),this.roots=new Yo({idProperty:"rootName"}),this.differ=new Tu(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Bu),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.history.addOperation(i)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(e,t,i,n,s)=>{const o=(0,r.A)((0,r.A)({},t.getData()),{},{range:n});this.differ.bufferMarkerChange(t.name,s,o),null===i&&t.on("change",(e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,(0,r.A)((0,r.A)({},n),{},{range:i}),n)})}),this.registerPostFixer(e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Bu)}createRoot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"$root",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"main";if(this.roots.get(t))throw new gs("model-document-createroot-name-exists",this,{name:t});const i=new Fu(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return this.roots.get(e)}getRootNames(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.getRoots(e).map(e=>e.rootName)}getRoots(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=nn(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(){const e=this.getRoots();return e.length?e[0]: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 e.start.isValid()&&e.end.isValid()&&Ru(e.start)&&Ru(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 Ru(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!cr(i,n)&&!ur(i,n)}return!0}class Vu extends(Es()){constructor(){super(...arguments),(0,o.A)(this,"_markers",new Map)}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Nu?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const s=e instanceof Nu?e.name:e;if(s.includes(","))throw new gs("markercollection-incorrect-marker-name",this);const o=this._markers.get(s);if(o){const e=o.getData(),r=o.getRange();let a=!1;return r.isEqual(t)||(o._attachLiveRange(Ll.fromRange(t)),a=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,a=!0),"boolean"===typeof n&&n!=o.affectsData&&(o._affectsData=n,a=!0),a&&this.fire("update:".concat(s),o,r,t,e),o}const a=Ll.fromRange(t),l=new Nu(s,a,i,n);return this._markers.set(s,l),this.fire("update:".concat(s),l,null,t,(0,r.A)((0,r.A)({},l.getData()),{},{range:null})),l}_remove(e){const t=e instanceof Nu?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire("update:".concat(t),i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof Nu?e.name:e,i=this._markers.get(t);if(!i)throw new gs("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire("update:".concat(t),i,n,n,i.getData())}*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()}}class Nu extends(Es(ml)){constructor(e,t,i,n){super(),(0,o.A)(this,"name",void 0),(0,o.A)(this,"_managedUsingOperations",void 0),(0,o.A)(this,"_affectsData",void 0),(0,o.A)(this,"_liveRange",void 0),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new gs("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new gs("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}
2getStart(){if(!this._liveRange)throw new gs("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new gs("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new gs("marker-destroyed",this);return this._liveRange.toRange()}_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}}Nu.prototype.is=function(e){return"marker"===e||"model:marker"===e};class Lu extends $c{constructor(e,t){super(null),(0,o.A)(this,"sourcePosition",void 0),(0,o.A)(this,"howMany",void 0),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new gs("detach-operation-on-document-node",this)}_execute(){Gc(kl._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class ju extends ml{constructor(e){super(),(0,o.A)(this,"markers",new Map),(0,o.A)(this,"_children",new Kl),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 nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(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.getChildAtOffset(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(Gl.fromJSON(i)):t.push(ql.fromJSON(i));return new ju(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new ql(e)];Ks(e)||(e=[e]);return Array.from(e).map(e=>"string"==typeof e?new ql(e):e instanceof fl?new ql(e.data,e.getAttributes()):e)}(t);for(const n of i)null!==n.parent&&n._remove(),n.parent=this;this._children._insertNodes(e,i)}_removeChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=this._children._removeNodes(e,t);for(const n of i)n.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}ju.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class Wu{constructor(e,t){(0,o.A)(this,"model",void 0),(0,o.A)(this,"batch",void 0),this.model=e,this.batch=t}createText(e,t){return new ql(e,t)}createElement(e,t){return new Gl(e,t)}createDocumentFragment(){return new ju}cloneElement(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e._clone(t)}insert(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this._assertWriterUsedCorrectly(),e instanceof ql&&""==e.data)return;const n=_l._createAt(t,i);if(e.parent){if($u(e.root,n.root))return void this.move(kl._createOn(e),n);if(e.root.document)throw new gs("model-writer-insert-forbidden-move",this);this.remove(e)}const s=n.root.document?n.root.document.version:null,o=e instanceof ju?e._removeChildren(0,e.childCount):e,r=new tu(n,o,s);if(e instanceof ql&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof ju)for(const[a,l]of e.markers){const e=_l._createAt(l.root,0),t={range:new kl(l.start._getCombined(e,n),l.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(a)?this.updateMarker(a,t):this.addMarker(a,t)}}insertText(e,t,i,n){t instanceof ju||t instanceof Gl||t instanceof _l?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof ju||t instanceof Gl||t instanceof _l?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 ju||t instanceof Gl?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof ju||t instanceof Gl?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof kl){const n=i.getMinimalFlatRanges();for(const i of n)qu(this,e,t,i)}else Uu(this,e,t,i)}setAttributes(e,t){for(const[i,n]of or(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof kl){const i=t.getMinimalFlatRanges();for(const t of i)qu(this,e,null,t)}else Uu(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof kl)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof kl))throw new gs("writer-move-invalid-range",this);if(!e.isFlat)throw new gs("writer-move-range-not-flat",this);const n=_l._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!$u(e.root,n.root))throw new gs("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,o=new eu(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 kl?e:kl._createOn(e)).getMinimalFlatRanges().reverse();for(const i of t)this._addOperationForAffectedMarkers("move",i),Hu(i.start,i.end.offset-i.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof Gl))throw new gs("writer-merge-no-element-before",this);if(!(i instanceof Gl))throw new gs("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(){return this.model.createSelection(...arguments)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(kl._createIn(i),_l._createAt(t,"end")),this.remove(i)}_merge(e){const t=_l._createAt(e.nodeBefore,"end"),i=_l._createAt(e.nodeAfter,0),n=e.root.document.graveyard,s=new _l(n,[0]),o=e.root.document.version,r=new nu(i,e.nodeAfter.maxOffset,t,s,o);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Gl))throw new gs("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new au(_l._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 gs("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new gs("writer-split-invalid-limit-element",this);do{const t=s.root.document?s.root.document.version:null,o=s.maxOffset-e.offset,r=iu.getInsertionPosition(e),a=new iu(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 kl(_l._createAt(i,"end"),_l._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new gs("writer-wrap-range-not-flat",this);const i=t instanceof Gl?t:new Gl(t);if(i.childCount>0)throw new gs("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new gs("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new kl(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,_l._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new gs("writer-unwrap-element-no-parent",this);this.move(kl._createIn(e),this.createPositionAfter(e)),this.remove(e)}
2addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new gs("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 gs("writer-addmarker-marker-exists",this);if(!n)throw new gs("writer-addmarker-no-range",this);return i?(zu(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 gs("writer-updatemarker-marker-not-exists",this);if(!t)return ps("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),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 gs("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;s&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?zu(this,i,null,l,r):(zu(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?zu(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new gs("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);zu(this,t,i.getRange(),null,i.affectsData)}addRoot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$root";this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new gs("writer-addroot-root-exists",this);const n=this.model.document,s=new cu(e,t,!0,n,n.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new gs("writer-detachroot-no-root",this);for(const s of this.model.markers)s.getRange().root===t&&this.removeMarker(s);for(const s of t.getAttributeKeys())this.removeAttribute(s,t);this.remove(this.createRangeIn(t));const i=this.model.document,n=new cu(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}setSelection(){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...arguments)}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[i,n]of or(e))this._setSelectionAttribute(i,n)}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=zl._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=zl._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new gs("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){const e=t;s=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,o=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==o&&0==n.end.offset,l=n.end.nodeAfter==o,c=n.start.nodeAfter==o;s=r||a||l||c}s&&this.updateMarker(i.name,{range:n})}}}function qu(e,t,i,n){const s=e.model,o=s.document;let r,a,l,c=n.start;for(const h of n.getWalker({shallow:!0}))l=h.item.getAttribute(t),r&&a!=l&&(a!=i&&u(),c=r),r=h.nextPosition,a=l;function u(){const n=new kl(c,r),l=n.root.document?o.version:null,u=new ou(n,t,a,i,l);e.batch.addOperation(u),s.applyOperation(u)}r instanceof _l&&r!=c&&a!=i&&u()}function Uu(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 lu(n,t,r,i,e)}else{a=new kl(_l._createBefore(n),e.createPositionAfter(n));const s=a.root.document?o.version:null;l=new ou(a,t,r,i,s)}e.batch.addOperation(l),s.applyOperation(l)}}function zu(e,t,i,n,s){const o=e.model,r=o.document,a=new su(t,i,n,o.markers,!!s,r.version);e.batch.addOperation(a),o.applyOperation(a)}function Hu(e,t,i,n){let s;if(e.root.document){const i=n.document,o=new _l(i.graveyard,[0]);s=new eu(e,t,o,i.version)}else s=new Lu(e,t);i.addOperation(s),n.applyOperation(s)}function $u(e,t){return e===t||e instanceof Fu&&t instanceof Fu}function Ku(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};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)),Qu(e,e.createPositionAt(i,0),t)}(e,t);const o={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(o,s.getAttributesWithProperty(e,"copyOnReplace",!0))}const[r,a]=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 s of n){if(i.isLimit(s))return null;if(i.isBlock(s))return s}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const s=i.getLastPosition(),o=t.createRange(s,n);t.hasContent(o,{ignoreMarkers:!0})||(n=s)}}return[ku.fromPosition(i,"toPrevious"),ku.fromPosition(n,"toNext")]}(n);r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!Zu(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})?Ju(e,t,i,s.parent):Gu(e,t,i,s.parent)}(e,r,a),s.removeDisallowedAttributes(r.parent.getChildren(),e)),Yu(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(s,r)&&Qu(e,r,t,o),r.detach(),a.detach()})}function Gu(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(o,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}
2Zu(e.model.schema,t,i)&&Gu(e,t,i,n)}}function Ju(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(s,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(o),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)}(e,i),Zu(e.model.schema,t,i)&&Ju(e,t,i,n)}}function Zu(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 kl(e,t);for(const s of n.getWalker())if(i.isLimit(s.item))return!1;return!0}(t,i,e))}function Qu(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=e.createElement("paragraph");e.model.schema.setAllowedAttributes(s,n,e),e.insert(s,t),Yu(e,i,e.createPositionAt(s,0))}function Yu(e,t,i){t instanceof zl?e.setSelection(i):t.setTo(i)}function Xu(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)}})}class eh{constructor(e,t,i){(0,o.A)(this,"model",void 0),(0,o.A)(this,"writer",void 0),(0,o.A)(this,"position",void 0),(0,o.A)(this,"canMergeWith",void 0),(0,o.A)(this,"schema",void 0),(0,o.A)(this,"_documentFragment",void 0),(0,o.A)(this,"_documentFragmentPosition",void 0),(0,o.A)(this,"_firstNode",null),(0,o.A)(this,"_lastNode",null),(0,o.A)(this,"_lastAutoParagraph",null),(0,o.A)(this,"_filterAttributesOf",[]),(0,o.A)(this,"_affectedStart",null),(0,o.A)(this,"_affectedEnd",null),(0,o.A)(this,"_nodeToSelect",null),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)}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 gs("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?kl._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new kl(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){this._checkAndSplitToAllowedPosition(e)?(this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this.schema.isObject(e)||this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=ku.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()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new gs("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=ku.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=ku.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof Gl))return;if(!this._canMergeLeft(e))return;const t=ku._createBefore(e);t.stickiness="toNext";const i=ku.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=ku._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=ku._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 Gl))return;if(!this._canMergeRight(e))return;const t=ku._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new gs("insertcontent-invalid-insertion-position",this);this.position=_l._createAt(t.nodeBefore,"end");const i=ku.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=ku._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=ku._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 Gl&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof Gl&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();const e=this.writer.createElement("paragraph");this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0)}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}
2else 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 this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)||this.schema.checkChild(e,"paragraph")&&this.schema.checkChild("paragraph",t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function th(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!e.schema.isObject(t))throw new gs("insertobject-element-not-an-object",e,{object:t});const s=i||e.document.selection;let o=s;n.findOptimalPosition&&e.schema.isBlock(t)&&(o=e.createSelection(e.schema.findOptimalInsertionRange(s,n.findOptimalPosition)));const r=Xo(s.getSelectedBlocks()),a={};return r&&Object.assign(a,e.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),e.change(i=>{o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});let s=t;const r=o.anchor.parent;!e.schema.checkChild(r,t)&&e.schema.checkChild(r,"paragraph")&&e.schema.checkChild("paragraph",t)&&(s=i.createElement("paragraph"),i.insert(t,s)),e.schema.setAllowedAttributes(s,a,i);const l=e.insertContent(s,o);return l.isCollapsed||n.setSelection&&function(e,t,i,n){const s=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new gs("insertobject-invalid-place-parameter-value",s);let o=t.nextSibling;if(s.schema.isInline(t))return void e.setSelection(t,"after");const r=o&&s.schema.checkChild(o,"$text");!r&&s.schema.checkChild(t.parent,"paragraph")&&(o=e.createElement("paragraph"),s.schema.setAllowedAttributes(o,n,e),s.insertContent(o,e.createPositionAfter(t)));o&&e.setSelection(o,0)}(i,t,n.setSelection,a),l})}function ih(e,t){const{isForward:i,walker:n,unit:s,schema:o,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;i||(i=t?e.position.nodeAfter:e.position.nodeBefore);for(;i&&i.is("$text");){const n=e.position.offset-i.startOffset;if(oh(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(sh(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const s=n.data;let o=e.position.offset-n.startOffset;for(;cr(s,o)||"character"==t&&ur(s,o)||i&&dr(s,o);)e.next(),o=e.position.offset-n.startOffset}return e.position}(n,s,r);if(a==(i?"elementStart":"elementEnd")){if(o.isSelectable(l))return _l._createAt(l,i?"after":"before");if(o.checkChild(c,"$text"))return c}else{if(o.isLimit(l))return void n.skip(()=>!0);if(o.checkChild(c,"$text"))return c}}function nh(e,t){const i=e.root,n=_l._createAt(i,t?"end":0);return t?new kl(e,n):new kl(n,e)}function sh(e,t,i){const n=t+(i?0:-1);return' ,.?!:;"-()'.includes(e.charAt(n))}function oh(e,t,i){return t===(i?e.offsetSize:0)}let rh=class extends(Ns()){constructor(){super(),(0,o.A)(this,"markers",void 0),(0,o.A)(this,"document",void 0),(0,o.A)(this,"schema",void 0),(0,o.A)(this,"_pendingChanges",void 0),(0,o.A)(this,"_currentWriter",void 0),this.markers=new Vu,this.document=new Mu(this),this.schema=new Ec,this._pendingChanges=[],this._currentWriter=null,["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("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),bc(this),this.document.registerPostFixer(cc),this.on("insertContent",(e,t)=>{let[i,n]=t;e.return=function(e,t,i){return e.change(n=>{const s=i||e.document.selection;s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});const o=new eh(e,n,s.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:s}=n,o=t.isEqual(s);e.push({position:t,name:i,isCollapsed:o},{position:s,name:i,isCollapsed:o})}e.sort((e,t)=>
2{let{position:i}=e,{position:n}=t;return i.isBefore(n)?1:-1});for(const{position:i,name:s,isCollapsed:o}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?o&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:s,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];o.handleNodes(a);let l=o.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?Ll.fromRange(l):null,t={};for(let i=r.length-1;i>=0;i--){const{name:e,element:s,collapsed:a}=r[i],l=!t[e];if(l&&(t[e]=[]),s){const i=n.createPositionAt(s,"before");t[e].push(i),n.remove(s)}else{const i=o.getAffectedRange();if(!i){a&&t[e].push(o.position);continue}a?t[e].push(i[a]):t[e].push(l?i.start:i.end)}}for(const[i,[s,o]]of Object.entries(t))s&&o&&s.root===o.root&&s.root.document&&!n.model.markers.has(i)&&n.addMarker(i,{usingOperation:!0,affectsData:!0,range:new kl(s,o)});e&&(l=e.toRange(),e.detach())}l&&(s instanceof zl?n.setSelection(l):s.setTo(l));const c=o.getAffectedRange()||e.createRange(s.anchor);return o.destroy(),c})}(this,i,n)}),this.on("insertObject",(e,t)=>{let[i,n,s]=t;e.return=th(this,i,n,s)}),this.on("canEditAt",e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()})}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new Pu,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(t){gs.rethrowUnexpectedError(t,this)}}enqueueChange(e,t){try{e?"function"===typeof e?(t=e,e=new Pu):e instanceof Pu||(e=new Pu(e)):e=new Pu,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(i){gs.rethrowUnexpectedError(i,this)}}applyOperation(e){e._execute()}insertContent(e,t,i){const n=ah(t,i);for(var s=arguments.length,o=new Array(s>3?s-3:0),r=3;r<s;r++)o[r-3]=arguments[r];return this.fire("insertContent",[e,n,i,...o])}insertObject(e,t,i,n){const s=ah(t,i);for(var o=arguments.length,r=new Array(o>4?o-4:0),a=4;a<o;a++)r[a-4]=arguments[a];return this.fire("insertObject",[e,s,n,n,...r])}deleteContent(e,t){Ku(this,e,t)}modifySelection(e,t){!function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=e.schema,s="backward"!=i.direction,o=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new gl({boundaries:nh(a,s),singleCharacters:!0,direction:s?"forward":"backward"}),c={walker:l,schema:n,isForward:s,unit:o,treatEmojiAsSingleUnit:r};let u;for(;u=l.next();){if(u.done)return;const i=ih(c,u.value);if(i)return void(t instanceof zl?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);Xu(e.createRange(t.end,e.createPositionAt(i,"end")),e),Xu(s,e)}return i})}(this,e)}hasContent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=e instanceof kl?e:kl._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:s=!1}=t;if(!s)for(const o of this.markers.getMarkersIntersectingRange(i))if(o.affectsData)return!0;for(const o of i.getItems())if(this.schema.isContent(o)){if(!o.is("$textProxy"))return!0;if(!n)return!0;if(-1!==o.data.search(/\S/))return!0}return!1}canEditAt(e){const t=ah(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new _l(e,t,i)}createPositionAt(e,t){return _l._createAt(e,t)}createPositionAfter(e){return _l._createAfter(e)}createPositionBefore(e){return _l._createBefore(e)}createRange(e,t){return new kl(e,t)}createRangeIn(e){return kl._createIn(e)}createRangeOn(e){return kl._createOn(e)}createSelection(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Ol(...t)}createBatch(e){return new Pu(e)}createOperationFromJSON(e){return hu.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;
2){const t=this._pendingChanges[0].batch;this._currentWriter=new Wu(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}};function ah(e,t){if(e)return e instanceof Ol||e instanceof zl?e:e instanceof Il?t||0===t?new Ol(e,t):e.is("rootElement")?new Ol(e,"in"):new Ol(e,"on"):new Ol(e)}class lh extends Xa{constructor(){super(...arguments),(0,o.A)(this,"domEventType","click")}onDomEvent(e){this.fire(e.type,e)}}class ch extends Xa{constructor(){super(...arguments),(0,o.A)(this,"domEventType",["mousedown","mouseup","mouseover","mouseout"])}onDomEvent(e){this.fire(e.type,e)}}class uh extends Xa{constructor(){super(...arguments),(0,o.A)(this,"domEventType",["touchstart","touchend","touchmove"])}onDomEvent(e){this.fire(e.type,e)}}class hh{constructor(e){(0,o.A)(this,"document",void 0),this.document=e}createDocumentFragment(e){return new fa(this.document,e)}createElement(e,t,i){return new Rr(this.document,e,t,i)}createText(e){return new Ar(this.document,e)}clone(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[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 Rr(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){Ht(e)&&void 0===i?t._setStyle(e):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 Hr._createAt(e,t)}createPositionAfter(e){return Hr._createAfter(e)}createPositionBefore(e){return Hr._createBefore(e)}createRange(e,t){return new $r(e,t)}createRangeOn(e){return $r._createOn(e)}createRangeIn(e){return $r._createIn(e)}createSelection(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Gr(...t)}}class dh{constructor(e){if((0,o.A)(this,"crashes",[]),(0,o.A)(this,"state","initializing"),(0,o.A)(this,"_crashNumberLimit",void 0),(0,o.A)(this,"_now",Date.now),(0,o.A)(this,"_minimumNonErrorTimePeriod",void 0),(0,o.A)(this,"_boundErrorHandler",void 0),(0,o.A)(this,"_listeners",void 0),this.crashes=[],this._crashNumberLimit="number"===typeof e.crashNumberLimit?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"===typeof e.minimumNonErrorTimePeriod?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter(e=>e!==t)}_fire(e){const t=this._listeners[e]||[];for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];for(const o of t)o.apply(this,[null,...n])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}
2_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function mh(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;const i=[e],n=new Set;let s=0;for(;i.length>s;){const e=i[s++];if(!n.has(e)&&fh(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch(o){}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function fh(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||void 0===e||null===e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function gh(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(e===t&&("object"===typeof(n=e)&&null!==n))return!0;var n;const s=mh(e,i),o=mh(t,i);for(const r of s)if(o.has(r))return!0;return!1}class ph extends dh{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),(0,o.A)(this,"_editor",null),(0,o.A)(this,"_lifecyclePromise",null),(0,o.A)(this,"_throttledSave",void 0),(0,o.A)(this,"_data",void 0),(0,o.A)(this,"_lastDocumentVersion",void 0),(0,o.A)(this,"_elementOrData",void 0),(0,o.A)(this,"_initUsingData",!0),(0,o.A)(this,"_editables",{}),(0,o.A)(this,"_config",void 0),(0,o.A)(this,"_excludedProps",void 0),this._throttledSave=$n(this._save.bind(this),"number"===typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>e.create(t,i)),this._destructor=e=>e.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then(()=>(this.state="initializing",this._fire("stateChange"),this._destroy())).catch(e=>{console.error("An error happened during the editor destroying.",e)}).then(()=>{const e={},t=[],i=this._config.rootsAttributes||{},n={};for(const[o,r]of Object.entries(this._data.roots))r.isLoaded?(e[o]="",n[o]=i[o]||{}):t.push(o);const s=(0,r.A)((0,r.A)({},this._config),{},{extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:n,_watchdogInitialData:this._data});return delete s.initialData,s.extraPlugins.push(_h),this._initUsingData?this.create(e,s,s.context):Ln(this._elementOrData)?this.create(this._elementOrData,s,s.context):this.create(this._editables,s,s.context)}).then(()=>{this._fire("restart")})}create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._elementOrData,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._config,i=arguments.length>2?arguments[2]:void 0;return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData="string"==typeof e||Object.keys(e).length>0&&"string"==typeof Object.values(e)[0],this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config))).then(e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")}).finally(()=>{this._lifecyclePromise=null}),this._lifecyclePromise}destroy(){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())).finally(()=>{this._lifecyclePromise=null}),this._lifecyclePromise}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)})}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(t){console.error(t,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter(e=>e.isAttached()&&"$graveyard"!=e.rootName),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),s=i.has("TrackChanges")&&i.get("TrackChanges"),o={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};
2t.forEach(e=>{o.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}});for(const r of e.model.markers)r._affectsData&&(o.markers[r.name]={rangeJSON:r.getRange().toJSON(),usingOperation:r._managedUsingOperations,affectsData:r._affectsData});return n&&(o.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),s&&(o.suggestions=JSON.stringify(s.getSuggestions({toJSON:!0,skipNotAttached:!0}))),o}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return gh(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return on(e,(e,t)=>Ln(e)||"context"===t?e:void 0)}}class _h{constructor(e){(0,o.A)(this,"editor",void 0),(0,o.A)(this,"_data",void 0),this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},e=>{this._restoreCollaborationData(),this._restoreEditorData(e)}),this.editor.data.fire("ready")},{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach(i=>{let[n,{content:s,attributes:o}]=i;const r=JSON.parse(s),a=JSON.parse(o),l=t.model.document.getRoot(n);for(const[t,c]of a)e.setAttribute(t,c,l);for(const t of r){const i=this._createNode(e,t);e.insert(i,l,"end")}}),Object.entries(this._data.markers).forEach(i=>{let[n,o]=i;const{document:a}=t.model,{rangeJSON:{start:l,end:u}}=o,h=(0,s.A)(o,c),d=a.getRoot(l.root),m=e.createPositionFromPath(d,l.path,l.stickiness),f=e.createPositionFromPath(d,u.path,u.stickiness),g=e.createRange(m,f);e.addMarker(n,(0,r.A)({range:g},h))})}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach(e=>{const t=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");if(i.hasCommentThread(e.threadId)){i.getCommentThread(e.threadId).remove()}i.addCommentThread((0,r.A)({channelId:t},e))}),t.forEach(e=>{const t=this.editor.plugins.get("TrackChangesEditing");if(t.hasSuggestion(e.id)){t.getSuggestion(e.id).attributes=e.attributes}else t.addSuggestionData(e)})}}const wh=Symbol("MainQueueId");class bh{constructor(){(0,o.A)(this,"_onEmptyCallbacks",[]),(0,o.A)(this,"_queues",new Map),(0,o.A)(this,"_activeActions",0)}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===wh;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(wh),this._queues.get(e)])).then(t),s=n.catch(()=>{});return this._queues.set(e,s),n.finally(()=>{this._activeActions--,this._queues.get(e)===s&&0===this._activeActions&&this._onEmptyCallbacks.forEach(e=>e())})}}function vh(e){return Array.isArray(e)?e:[e]}class yh extends(Ns()){constructor(e){super(),(0,o.A)(this,"editor",void 0),(0,o.A)(this,"_disableStack",new Set),this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Ah,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Ah),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function Ah(e){e.return=!1,e.stop()}class kh extends(Ns()){constructor(e){super(),(0,o.A)(this,"editor",void 0),(0,o.A)(this,"_isEnabledBasedOnSelection",void 0),(0,o.A)(this,"_affectsData",void 0),(0,o.A)(this,"_disableStack",void 0),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())},{priority:"highest"}),this.on("execute",e=>{this.isEnabled||e.stop()},{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Eh,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Eh),this.refresh())}execute(){}destroy(){this.stopListening()}}function Eh(e){e.return=!1,e.stop()}class Ch extends kh{constructor(){super(...arguments),(0,o.A)(this,"_childCommandsDefinitions",[])}refresh(){}execute(){const e=this._getFirstEnabledCommand();for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return!!e&&e.execute(i)}registerChildCommand(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};fs(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find(e=>{let{command:t}=e;return t.isEnabled});return e&&e.command}}class Ph extends(Es()){constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];super(),(0,o.A)(this,"_context",void 0),(0,o.A)(this,"_plugins",new Map),(0,o.A)(this,"_availablePlugins",void 0),(0,o.A)(this,"_contextPlugins",void 0),this._context=e,this._availablePlugins=new Map;for(const n of t)n.pluginName&&this._availablePlugins.set(n.pluginName,n);this._contextPlugins=new Map;for(const[n,s]of i)this._contextPlugins.set(n,s),this._contextPlugins.set(s,n),n.pluginName&&this._availablePlugins.set(n.pluginName,n)}*[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 gs("plugincollection-
2plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const n=this,s=this._context;!function e(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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),h(e);const o=[...function e(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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&&(h(n.requires,n),e(n.requires,i).forEach(e=>t.add(e))),t.add(n)),new Set)}(e.filter(e=>!c(e,t)))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new gs("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new gs("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new gs("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=n._availablePlugins.get(t);if(!s)throw new gs("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 gs("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new gs("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=>{let t=n._contextPlugins.get(e);return t=t||new e(s),n._add(e,t),t})}(o);return d(r,"init").then(()=>d(r,"afterInit")).then(()=>r);function a(e){return"function"===typeof e}function l(e){return a(e)&&!!e.isContextPlugin}function c(e,t){return t.some(t=>t===e||(u(e)===t||u(t)===e))}function u(e){return a(e)?e.pluginName||e.name:e}function h(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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 gs("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:u(t)});throw new gs("plugincollection-plugin-not-found",s,{plugin:e})}(e,i),function(e,t){if(!l(t))return;if(l(e))return;throw new gs("plugincollection-context-required",s,{plugin:u(e),requiredBy:u(t)})}(e,i),function(e,i){if(!i)return;if(!c(e,t))return;throw new gs("plugincollection-required",s,{plugin:u(e),requiredBy:u(i)})}(e,i)})}function d(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 gs("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Th{constructor(e){(0,o.A)(this,"config",void 0),(0,o.A)(this,"plugins",void 0),(0,o.A)(this,"locale",void 0),(0,o.A)(this,"t",void 0),(0,o.A)(this,"editors",void 0),(0,o.A)(this,"_contextOwner",null);const t=e||{},{translations:i}=t,n=(0,s.A)(t,u);this.config=new Js(n,this.constructor.defaultConfig);const r=this.constructor.builtinPlugins;this.config.define("plugins",r),this.plugins=new Ph(this,r);const a=this.config.get("language")||{};this.locale=new Qo({uiLanguage:"string"===typeof a?a:a.ui,contentLanguage:this.config.get("language.content"),translations:i}),this.t=this.locale.t,this.editors=new Yo}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 gs("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new gs("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 gs("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))})}}(0,o.A)(Th,"defaultConfig",void 0),(0,o.A)(Th,"builtinPlugins",void 0);class xh extends(Ns()){constructor(e){super(),(0,o.A)(this,"context",void 0),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class Dh{constructor(){(0,o.A)(this,"_commands",void 0),this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e){const t=this.get(e);if(!t)throw new gs("commandcollection-command-not-found",this,{commandName:e});for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return t.execute(...n)}*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()}}class Sh extends sr{constructor(e){super(),(0,o.A)(this,"editor",void 0),this.editor=e}set(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}const Ih="contentEditing",Oh="common";class Fh{constructor(e){(0,o.A)(this,"keystrokeInfos",new Map),(0,o.A)(this,"_editor",void 0),this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Ih,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const n=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&n.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:n}]})}addKeystrokeInfoCategory(e){let{id:t,label:i,description:n,groups:s}=e;this.keystrokeInfos.set(t,{id:t,label:i,description:n,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:t,id:Oh}
2),s&&s.forEach(e=>{this.addKeystrokeInfoGroup((0,r.A)({categoryId:t},e))})}addKeystrokeInfoGroup(e){let{categoryId:t=Ih,id:i,label:n,keystrokes:s}=e;const o=this.keystrokeInfos.get(t);if(!o)throw new gs("accessibility-unknown-keystroke-info-category",this._editor,{groupId:i,categoryId:t});o.groups.set(i,{id:i,label:n,keystrokes:s||[]})}addKeystrokeInfos(e){let{categoryId:t=Ih,groupId:i=Oh,keystrokes:n}=e;if(!this.keystrokeInfos.has(t))throw new gs("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:t,keystrokes:n});const s=this.keystrokeInfos.get(t);if(!s.groups.has(i))throw new gs("accessibility-unknown-keystroke-info-group",this._editor,{groupId:i,categoryId:t,keystrokes:n});s.groups.get(i).keystrokes.push(...n)}}function Bh(e){return Object.getPrototypeOf(e).constructor.editorName}function Mh(e){if(!e)return;const t=Array.isArray(e)?{items:e}:e,i=function e(t){return t.flatMap(t=>"string"===typeof t?[t]:e(t.items))}(t.items||[]);return{isMultiline:i.includes("-"),shouldNotGroupWhenFull:!!t.shouldNotGroupWhenFull,items:(n=i,n.filter(e=>"|"!==e&&"-"!==e))};var n}function Rh(){let e="unknown",t="unknown";return Yn.isMac?e="mac":Yn.isWindows?e="windows":Yn.isiOS?e="ios":Yn.isAndroid&&(e="android"),Yn.isGecko?t="gecko":Yn.isBlink?t="blink":Yn.isSafari&&(t="safari"),{os:e,browser:t}}function Vh(){return localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",ds()),localStorage.getItem("__ckeditor-session-id")}function Nh(){return Jn.window.CKEDITOR_PAGE_SESSION_ID=Jn.window.CKEDITOR_PAGE_SESSION_ID||ds(),Jn.window.CKEDITOR_PAGE_SESSION_ID}class Lh extends(Ns()){static get editorName(){return"Editor"}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(super(),(0,o.A)(this,"accessibility",void 0),(0,o.A)(this,"commands",void 0),(0,o.A)(this,"config",void 0),(0,o.A)(this,"conversion",void 0),(0,o.A)(this,"data",void 0),(0,o.A)(this,"editing",void 0),(0,o.A)(this,"locale",void 0),(0,o.A)(this,"model",void 0),(0,o.A)(this,"plugins",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"t",void 0),(0,o.A)(this,"_context",void 0),(0,o.A)(this,"_readOnlyLocks",void 0),"sanitizeHtml"in e)throw new gs("editor-config-sanitizehtml-not-supported");const t=this.constructor,i=t.defaultConfig||{},{translations:n}=i,r=(0,s.A)(i,h),{translations:a=n}=e,l=(0,s.A)(e,d),c=e.language||r.language;this._context=e.context||new Th({language:c,translations:a}),this._context._addEditor(this,!e.context);const u=Array.from(t.builtinPlugins||[]);this.config=new Js(l,r),this.config.define("plugins",u),this.config.define(this._context._getEditorConfig()),function(e){let t=e.get("licenseKey");!t&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(t=window.CKEDITOR_GLOBAL_LICENSE_KEY,e.set("licenseKey",t));if(!t)throw new gs("license-key-missing")}(this.config),this.plugins=new Ph(this,u,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Dh,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new rh,this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const m=new Or;this.data=new qc(this.model,m),this.editing=new kc(this.model,m),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Uc([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 Sh(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new Fh(this),function(e){const t=e.config.get("licenseKey"),i=window[Symbol.for("cke distribution")]||"sh";function n(t){e.enableReadOnlyMode(Symbol("invalidLicense")),e._showLicenseError(t)}if("GPL"==t)return void("cloud"==i&&n("distributionChannel"));const s=function(e){const t=e.split(".");return 3!=t.length?null:t[1]}(t);if(!s)return void n("invalid");const o=lr(s);if(!o)return void n("invalid");if(!function(e){return["exp","jti","vc"].every(t=>t in e)}(o))return void n("invalid");if(o.distributionChannel&&!Jo(o.distributionChannel).includes(i))return void n("distributionChannel");
2if(function(e){const t=Array.isArray(e)?e:[e],i=function(){const e=[];for(let t=0;t<256;t++){let i=t;for(let e=0;e<8;e++)1&i?i=3988292384^i>>>1:i>>>=1;e[t]=i}return e}();let n=-1;const s=t.map(e=>Array.isArray(e)?e.join(""):String(e)).join("");for(let o=0;o<s.length;o++)n=n>>>8^i[255&(n^s.charCodeAt(o))];return n=(-1^n)>>>0,n.toString(16).padStart(8,"0")}(function(e){return Object.getOwnPropertyNames(e).sort().filter(t=>"vc"!=t&&null!=e[t]).map(t=>e[t])}(o))!=o.vc.toLowerCase())return void n("invalid");if(new Date(1e3*o.exp)<bs)return void n("expired");const r=o.licensedHosts;if(r&&r.length>0&&!function(e){const{hostname:t}=new URL(window.location.href);if(e.includes(t))return!0;const i=t.split(".");return e.filter(e=>e.includes("*")).map(e=>e.split(".")).filter(e=>e.length<=i.length).map(e=>Array(i.length-e.length).fill("*"===e[0]?"*":"").concat(e)).some(e=>i.every((t,i)=>e[i]===t||"*"===e[i]))}(r))return void n("domainLimit");if(["evaluation","trial"].includes(o.licenseType)&&1e3*o.exp<Date.now())return void n("expired");if(["development","evaluation","trial"].includes(o.licenseType)){const{licenseType:e}=o,t=e[0].toUpperCase()+e.slice(1),i="evaluation"===e?"an":"a";console.info("%cCKEditor 5 ".concat(t," License"),"color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;"),console.warn("\u26a0\ufe0f You are using ".concat(i," ").concat(e," license of CKEditor 5")+"".concat("trial"===e?" which is for evaluation purposes only":"",". ")+"For production usage, please obtain a production license at https://portal.ckeditor.com/")}if(["evaluation","trial"].includes(o.licenseType)){const t=o.licenseType,i=setTimeout(()=>{n("".concat(t,"Limit"))},6e5);e.on("destroy",()=>{clearTimeout(i)})}o.usageEndpoint&&e.once("ready",()=>{const i={requestId:ds(),requestTime:Math.round(Date.now()/1e3),license:t,editor:jh(e)};e._sendUsageRequest(o.usageEndpoint,i).then(e=>{const{status:t,message:i}=e;i&&console.warn(i),"ok"!=t&&n("usageLimit")},()=>{var e,t;e="license-key-validation-endpoint-not-reachable",t={url:o.usageEndpoint},console.error(...ws(e,t))})},{priority:"high"})}(this)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new gs("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!==typeof e&&"symbol"!==typeof e)throw new gs("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),1===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if("string"!==typeof e&&"symbol"!==typeof e)throw new gs("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}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{for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return this.commands.execute(e,...i)}catch(s){gs.rethrowUnexpectedError(s,this)}}focus(){this.editing.view.focus()}static create(){throw new Error("This is an abstract method.")}_showLicenseError(e,t){setTimeout(()=>{if("invalid"==e)throw new gs("invalid-license-key");if("expired"==e)throw new gs("license-key-expired");
2if("domainLimit"==e)throw new gs("license-key-domain-limit");if("featureNotAllowed"==e)throw new gs("license-key-plugin-not-allowed",null,{pluginName:t});if("evaluationLimit"==e)throw new gs("license-key-evaluation-limit");if("trialLimit"==e)throw new gs("license-key-trial-limit");if("developmentLimit"==e)throw new gs("license-key-development-limit");if("usageLimit"==e)throw new gs("license-key-usage-limit");if("distributionChannel"==e)throw new gs("license-key-invalid-distribution-channel")},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const i=new Headers({"Content-Type":"application/json"}),n=await fetch(new URL(e),{method:"POST",headers:i,body:JSON.stringify(t)});if(!n.ok)throw new Error("HTTP Response: ".concat(n.status));return n.json()}}function jh(e){const t=function(e){return{sessionId:Vh(),pageSessionId:Nh(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:Bh(e),plugins:(t=e.plugins,Array.from(t).filter(e=>{let[t]=e;return!!t.pluginName}).map(e=>{let[t]=e;const{pluginName:i,isContextPlugin:n,isOfficialPlugin:s,isPremiumPlugin:o}=t;return{isContext:!!n,isOfficial:!!s,isPremium:!!o,name:i}})),distribution:{channel:window[Symbol.for("cke distribution")]||"sh"},env:Rh(),integration:Object.create(null),menuBar:{isVisible:!!e.config.get("menuBar.isVisible")},language:{ui:e.locale.uiLanguage,content:e.locale.contentLanguage},toolbar:{main:Mh(e.config.get("toolbar")),block:Mh(e.config.get("blockToolbar")),balloon:Mh(e.config.get("balloonToolbar"))}};var t}(e);return e.fire("collectUsageData",{setUsageData:function(e,i){if(void 0!==Vt(t,e))throw new gs("editor-usage-data-path-already-set",{path:e});Hn(t,e,i)}}),t}function Wh(e){return class extends e{constructor(){super(...arguments),(0,o.A)(this,"sourceElement",void 0)}updateSourceElement(e){if(!this.sourceElement)throw new gs("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!i)return void wo(this.sourceElement,"");const n="string"===typeof e?e:this.data.get();wo(this.sourceElement,n)}}}(0,o.A)(Lh,"defaultConfig",void 0),(0,o.A)(Lh,"builtinPlugins",void 0),(0,o.A)(Lh,"Context",Th),(0,o.A)(Lh,"EditorWatchdog",ph),(0,o.A)(Lh,"ContextWatchdog",class extends dh{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),(0,o.A)(this,"_watchdogs",new Map),(0,o.A)(this,"_watchdogConfig",void 0),(0,o.A)(this,"_context",null),(0,o.A)(this,"_contextProps",new Set),(0,o.A)(this,"_actionQueues",new bh),(0,o.A)(this,"_contextConfig",void 0),(0,o.A)(this,"_item",void 0),this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty(()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))})}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._actionQueues.enqueue(wh,()=>(this._contextConfig=e,this._create()))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=vh(e);return Promise.all(t.map(e=>this._actionQueues.enqueue(e.id,()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw new Error("Item with the given id is already added: '".concat(e.id,"'."));if("editor"===e.type)return t=new ph(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",(i,n)=>{let{error:s,causesRestart:o}=n;this._fire("itemError",{itemId:e.id,error:s}),o&&this._actionQueues.enqueue(e.id,()=>new Promise(i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))}),t.create(e.sourceElementOrData,e.config,this._context);throw new Error("Not supported item type: '".concat(e.type,"'."))})))}remove(e){const t=vh(e);return Promise.all(t.map(e=>this._actionQueues.enqueue(e,()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))}destroy(){return this._actionQueues.enqueue(wh,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(wh,()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch(e=>{console.error("An error happened during destroying the context or items.",e)}).then(()=>this._create()).then(()=>this._fire("restart"))))}_create(){return Promise.resolve().then(()=>(this._startErrorHandling(),this._creator(this._contextConfig))).then(e=>(this._context=e,this._contextProps=mh(this._context),Promise.all(Array.from(this._watchdogs.values()).map(e=>(e._setExcludedProperties(this._contextProps),e.create(void 0,void 0,this._context))))))}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map(e=>e.destroy())).then(()=>this._destructor(e))})}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error("Item with the given id was not registered: ".concat(e,"."));return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return gh(this._context,e.context)}}),Wh.updateSourceElement=Wh(Object).prototype.updateSourceElement;class qh extends xh{constructor(){super(...arguments),(0,o.A)(this,"_actions",void 0)}static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}init(){this.set("hasAny",!1),this._actions=new Yo({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!==typeof e)throw new gs("pendingactions-add-invalid-message",this);const t=new(Ns());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]()}}const Uh='<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.
26 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>',zh='<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>',Hh='<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>',$h='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.66 9.118a.693.693 0 0 1 .956.032l3.65 3.411 2.422-2.238a.695.695 0 0 1 .945 0L17.5 13.6V2.5h-15v11.1l4.16-4.482ZM17.8 1c.652 0 1.2.47 1.2 1.1v14.362c0 .64-.532 1.038-1.184 1.038H2.184C1.532 17.5 1 17.103 1 16.462V2.1C1 1.47 1.537 1 2.2 1h15.6Zm-5.655 6a2.128 2.128 0 0 1 .157-2.364A2.133 2.133 0 1 1 12.145 7Z"/></svg>',Kh='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037h9.494a2.97 2.97 0 0 1-.414-.287 2.998 2.998 0 0 1-1.055-2.03 3.003 3.003 0 0 1 .693-2.185l.383-.455-.02.018-3.65-3.41a.695.695 0 0 0-.957-.034L1.5 13.6V2.5h15v5.535a2.97 2.97 0 0 1 1.412.932l.088.105V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.713 2.803a2.146 2.146 0 0 0-2.049 1.992 2.14 2.14 0 0 0 1.28 2.096 2.13 2.13 0 0 0 2.644-3.11 2.134 2.134 0 0 0-1.875-.978Z"/><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.784.784 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79Z"/><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.784.784 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79Z"/></svg>',Gh='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.035 1C2.446 1 2 1.54 2 2.098V10.5h1.5v-8h13v8H18V2.098C18 1.539 17.48 1 16.9 1H3.035Zm10.453 2.61a1.885 1.885 0 0 0-1.442.736 1.89 1.89 0 0 0 1.011 2.976 1.903 1.903 0 0 0 2.253-1.114 1.887 1.887 0 0 0-1.822-2.598ZM7.463 8.163a.611.611 0 0 0-.432.154L5.071 10.5h5.119L7.88 8.348a.628.628 0 0 0-.417-.185Zm6.236 1.059a.62.62 0 0 0-.42.164L12.07 10.5h2.969l-.92-1.113a.618.618 0 0 0-.42-.165ZM.91 11.5a.91.91 0 0 0-.91.912v6.877c0 .505.405.91.91.91h18.178a.91.91 0 0 0 .912-.91v-6.877a.908.908 0 0 0-.912-.912H.91ZM3.668 13h1.947l2.135 5.7H5.898l-.28-.946H3.601l-.278.945H1.516L3.668 13Zm4.947 0h1.801v4.3h2.7v1.4h-4.5V13h-.001Zm4.5 0h5.4v1.4h-1.798v4.3h-1.701v-4.3h-1.9V13h-.001Zm-8.517 1.457-.614 2.059h1.262l-.648-2.059Z"/></svg>',Jh='<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>',Zh='<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>',Qh='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M19 4.5 14 0H3v12.673l.868-1.041c.185-.222.4-.402.632-.54V1.5h8v5h5v7.626a2.24 2.24 0 0 1 1.5.822V4.5ZM14 5V2l3.3 3H14Zm-3.692 12.5c.062.105.133.206.213.303L11.52 19H8v-.876a2.243 2.243 0 0 0 1.82-.624h.488Zm7.518-.657a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Zm-15.056-.38a.75.75 0 0 1-.096-1.056l2.346-2.815a.95.95 0 0 1 1.46 0l2.346 2.815a.75.75 0 1 1-1.152.96L6.5 14.96V20H5v-5.04l-1.174 1.408a.75.75 0 0 1-1.056.096Z"/></svg>',Yh='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.5 5.5H7v5h3.5a2.5 2.5 0 1 0 0-5zM5 3h6.5v.025a5 5 0 0 1 0 9.95V13H7v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"/></svg>',Xh='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 0 0-1 1v6H3a1 1 0 1 0 0 2h6v6a1 1 0 1 0 2 0v-6h6a1 1 0 1 0 0-2h-6V3a1 1 0 0 0-1-1Z"/></svg>',ed='<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 13Z"/><path d="m12.09 17-.534-1.292.848-1.971.545 1.319L12.113 17h-.023Zm1.142-5.187.545 1.319L15.5 9.13l1.858 4.316h-3.45l.398.965h3.467L18.887 17H20l-3.873-9h-1.254l-1.641 3.813Z"/></svg>',td='<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>',id='<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>',nd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.999 2H15a1 1 0 0 1 0 2h-1.004v13a1 1 0 1 1-2 0V4H8.999v13a1 1 0 1 1-2 0v-7A4 4 0 0 1 3 6a4 4 0 0 1 3.999-4z"/></svg>',sd='<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>',od='<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>',rd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M5 16.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 16.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/></svg>',ad='<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.7
25.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>',ld='<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>',cd='<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>',ud='<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>',hd='<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>',dd='<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>',md='<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>';class fd extends(Ns()){constructor(){super(),(0,o.A)(this,"total",void 0),(0,o.A)(this,"_reader",void 0),(0,o.A)(this,"_data",void 0);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()}}class gd extends yh{constructor(){super(...arguments),(0,o.A)(this,"loaders",new Yo),(0,o.A)(this,"_loadersMap",new Map),(0,o.A)(this,"_pendingAction",null)}static get pluginName(){return"FileRepository"}static get isOfficialPlugin(){return!0}static get requires(){return[qh]}init(){this.loaders.on("change",()=>this._updatePendingAction()),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 ps("filerepository-no-upload-adapter"),null;
2const t=new pd(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 pd?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(qh);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>"".concat(t("Upload in progress")," ").concat(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}}class pd extends(Ns()){constructor(e,t){super(),(0,o.A)(this,"id",void 0),(0,o.A)(this,"_filePromiseWrapper",void 0),(0,o.A)(this,"_adapter",void 0),(0,o.A)(this,"_reader",void 0),this.id=ds(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new fd,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 gs("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 gs("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}}var _d,wd,bd,vd,yd,Ad,kd,Ed;function Cd(){return wd?_d:(wd=1,_d={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],ol
vendor: 10,550 bytes, line 2
2ive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]})}function Pd(){if(vd)return bd;vd=1;const e=Cd(),t={};for(const s of Object.keys(e))t[e[s]]=s;const i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};bd=i;for(const s of Object.keys(i)){if(!("channels"in i[s]))throw new Error("missing channels property: "+s);if(!("labels"in i[s]))throw new Error("missing channel labels property: "+s);if(i[s].labels.length!==i[s].channels)throw new Error("channel and label counts mismatch: "+s);const{channels:e,labels:t}=i[s];delete i[s].channels,delete i[s].labels,Object.defineProperty(i[s],"channels",{value:e}),Object.defineProperty(i[s],"labels",{value:t})}function n(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}return i.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.min(t,i,n),o=Math.max(t,i,n),r=o-s;let a,l;o===s?a=0:t===o?a=(i-n)/r:i===o?a=2+(n-t)/r:n===o&&(a=4+(t-i)/r),a=Math.min(60*a,360),a<0&&(a+=360);const c=(s+o)/2;return l=o===s?0:c<=.5?r/(o+s):r/(2-o-s),[a,100*l,100*c]},i.rgb.hsv=function(e){let t,i,n,s,o;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),u=c-Math.min(r,a,l),h=function(e){return(c-e)/6/u+.5};return 0===u?(s=0,o=0):(o=u/c,t=h(r),i=h(a),n=h(l),r===c?s=n-i:a===c?s=1/3+t-n:l===c&&(s=2/3+i-t),s<0?s+=1:s>1&&(s-=1)),[360*s,100*o,100*c]},i.rgb.hwb=function(e){const t=e[0],n=e[1];let s=e[2];const o=i.rgb.hsl(e)[0],r=1/255*Math.min(t,Math.min(n,s));return s=1-1/255*Math.max(t,Math.max(n,s)),[o,100*r,100*s]},i.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.min(1-t,1-i,1-n);return[100*((1-t-s)/(1-s)||0),100*((1-i-s)/(1-s)||0),100*((1-n-s)/(1-s)||0),100*s]},i.rgb.keyword=function(i){const s=t[i];if(s)return s;let o,r=1/0;for(const t of Object.keys(e)){const s=n(i,e[t]);s<r&&(r=s,o=t)}return o},i.keyword.rgb=function(t){return e[t]},i.rgb.xyz=function(e){let t=e[0]/255,i=e[1]/255,n=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;return[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},i.rgb.lab=function(e){const t=i.rgb.xyz(e);let n=t[0],s=t[1],o=t[2];n/=95.047,s/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,s=s>.008856?s**(1/3):7.787*s+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;return[116*s-16,500*(n-s),200*(s-o)]},i.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let s,o,r;if(0===i)return r=255*n,[r,r,r];s=n<.5?n*(1+i):n+i-n*i;const a=2*n-s,l=[0,0,0];for(let c=0;c<3;c++)o=t+1/3*-(c-1),o<0&&o++,o>1&&o--,r=6*o<1?a+6*(s-a)*o:2*o<1?s:3*o<2?a+(s-a)*(2/3-o)*6:a,l[c]=255*r;return l},i.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,s=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,s*=o<=1?o:2-o;return[t,100*(0===n?2*s/(o+s):2*i/(n+i)),100*((n+i)/2)]},i.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const s=Math.floor(t)%6,o=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,s){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},i.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,s=Math.max(n,.01);let o,r;r=(2-i)*n;const a=(2-i)*s;return o=i*s,o/=a<=1?a:2-a,o=o||0,r/=2,[t,100*o,100*r]},i.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const s=i+n;let o;s>1&&(i/=s,n/=s);const r=Math.floor(6*t),a=1-n;o=6*t-r,0!==(1&r)&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(r){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},i.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,s=e[3]/100;return[255*(1-Math.min(1,t*(1-s)+s)),255*(1-Math.min(1,i*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s))]},i.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let s,o,r;return s=3.2406*t+-1.5372*i+-.4986*n,o=-.9689*t+1.8758*i+.0415*n,r=.0557*t+-.204*i+1.057*n,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),r=Math.min(Math.max(0,r),1),[255*s,255*o,255*r]},i.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},i.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const s=i**3,o=t**3,r=n**3;return i=s>.008856?s:(i-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,n=r>.008856?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},i.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let s;s=360*Math.atan2(n,i)/2/Math.PI,s<0&&(s+=360);return[t,Math.sqrt(i*i+n*n),s]},i.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},i.rgb.ansi16=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const[n,s,o]=e;let r=null===t?i.rgb.hsv(e)[2]:t;if(r=Math.round(r/50),0===r)return 30;let a=30+(Math.round(o/255)<<2|Math.round(s/255)<<1|Math.round(n/255));return 2===r&&(a+=60),a},i.hsv.ansi16=function(e){return i.rgb.ansi16(i.hsv.rgb(e),e[2])},i.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t===i&&i===n)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},i.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},i.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},i.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},i.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map(e=>e+e).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},i.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),r=s-o;let a,l;return a=r<1?o/(1-r):0,l=r<=0?0:s===t?(i-n)/r%6:s===i?2+(n-t)/r:4+(t-i)/r,l/=6,l%=1,[360*l,100*r,100*a]},i.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let s=0;return n<1&&(s=(i-.5*n)/(1-n)),[e[0],100*n,100*s]},i.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let s=0;return n<1&&(s=(i-n)/(1-n)),[e[0],100*n,100*s]},i.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const s=[0,0,0],o=t%1*6,r=o%1,a=1-r;let l=0;switch(Math.floor(o)){case 0:s[0]=1,s[1]=r,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=r;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=r,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-i)*n,[255*(i*s[0]+l),255*(i*s[1]+l),255*(i*s[2]+l)]},i.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},i.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},i.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},i.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let s=0;return n<1&&(s=(i-n)/(1-n)),[e[0],100*n,100*s]},i.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},i.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},i.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},i.gray.hsl=function(e){return[0,0,e[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(e){return[0,100,e[0]]},i.gray.cmyk=function(e){return[0,0,0,e[0]]},i.gray.lab=function(e){return[e[0],0,0]},i.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},i.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]},bd}function Td(){if(Ad)return yd;Ad=1;const e=Pd();function t(t){const i=function(){const t={},i=Object.keys(e);for(let e=i.length,n=0;n<e;n++)t[i[n]]={distance:-1,parent:null};return t}(),n=[t];for(i[t].distance=0;n.length;){const t=n.pop(),s=Object.keys(e[t]);for(let e=s.length,o=0;o<e;o++){const e=s[o],r=i[e];-1===r.distance&&(r.distance=i[t].distance+1,r.parent=t,n.unshift(e))}}return i}function i(e,t){return function(i){return t(e(i))}}function n(t,n){const s=[n[t].parent,t];let o=e[n[t].parent][t],r=n[t].parent;for(;n[r].parent;)s.unshift(n[r].parent),o=i(e[n[r].parent][r],o),r=n[r].parent;return o.conversion=s,o}return yd=function(e){const i=t(e),s={},o=Object.keys(i);for(let t=o.length,r=0;r<t;r++){const e=o[r];null!==i[e].parent&&(s[e]=n(e,i))}return s}}Cd(),function(){if(Ed)return kd;Ed=1;const e=Pd(),t=Td(),i={};Object.keys(e).forEach(n=>{i[n]={},Object.defineProperty(i[n],"channels",{value:e[n].channels}),Object.defineProperty(i[n],"labels",{value:e[n].labels});const s=t(n);
2Object.keys(s).forEach(e=>{const t=s[e];i[n][e]=function(e){const t=function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];const s=i[0];if(void 0===s||null===s)return s;s.length>1&&(i=s);const o=e(i);if("object"===typeof o)for(let e=o.length,r=0;r<e;r++)o[r]=Math.round(o[r]);return o};return"conversion"in e&&(t.conversion=e.conversion),t}(t),i[n][e].raw=function(e){const t=function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];const s=i[0];return void 0===s||null===s?s:(s.length>1&&(i=s),e(i))};return"conversion"in e&&(t.conversion=e.conversion),t}(t)})}),kd=i}();class xd extends Yo{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{idProperty:"viewUid"}),(0,o.A)(this,"_parentElement",void 0),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 t of this)this._renderViewIntoCollectionParent(t)}delegate(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(!t.length||!t.every(e=>"string"==typeof e))throw new gs("ui-viewcollection-delegate-wrong-events",this);return{to:e=>{for(const i of this)for(const n of t)i.delegate(n).to(e);this.on("add",(i,n)=>{for(const s of t)n.delegate(s).to(e)}),this.on("remove",(i,n)=>{for(const s of t)n.stopDelegating(s,e)})}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}remove(e){return super.remove(e)}}class Dd extends(Es()){constructor(e){super(),(0,o.A)(this,"ns",void 0),(0,o.A)(this,"tag",void 0),(0,o.A)(this,"text",void 0),(0,o.A)(this,"attributes",void 0),(0,o.A)(this,"children",void 0),(0,o.A)(this,"eventListeners",void 0),(0,o.A)(this,"_isRendered",void 0),(0,o.A)(this,"_revertData",void 0),Object.assign(this,Ld(Nd(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,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new gs("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)Hd(i)?yield i:$d(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new Id({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,s)=>new Od({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:s})}}static extend(e,t){if(e._isRendered)throw new gs("template-extend-render",[this,e]);Ud(e,Ld(Nd(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new gs("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(""),Fd(this.text)?this._bindToObservable({schema:this.text,updater:Md(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const n in this.attributes){const s=t.getAttribute(n),o=this.attributes[n];i&&(i.attributes[n]=s);const r=Gd(o)?o[0].ns:null;if(Fd(o)){const a=Gd(o)?o[0].value:o;i&&Zd(n)&&a.unshift(s),this._bindToObservable({schema:a,updater:Rd(t,n,r),data:e})}else if("style"==n&&"string"!==typeof o[0])this._renderStyleAttribute(o[0],e);else{i&&s&&Zd(n)&&o.unshift(s);const e=o.map(e=>e&&e.value||e).reduce((e,t)=>e.concat(t),[]).reduce(Wd,"");zd(e)||t.setAttributeNS(r,n,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const s=e[n];Fd(s)?this._bindToObservable({schema:[s],updater:Vd(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(Kd(o)){if(!n){o.setParent(t);for(const e of o)i.appendChild(e.element)}}else if(Hd(o))n||(o.isRendered||o.render(),i.appendChild(o.element));else if(Ys(o))i.appendChild(o);else if(n){const t=e.revertData,n=Jd();t.children.push(n),o._renderNode({intoFragment:!1,node:i.childNodes[s++],isApplying:!0,revertData:n})}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(e){let{schema:t,updater:i,data:n}=e;const s=n.revertData;Bd(t,i,n);const o=t.filter(e=>!zd(e)).filter(e=>e.observable).map(e=>e.activateAttributeListener(t,i,n));s&&s.bindings.push(o)}_revertTemplateFromNode(e,t){for(const n of t.bindings)for(const e of n)e();if(t.text)return void(e.textContent=t.text);const i=e;for(const n in t.attributes){const e=t.attributes[n];null===e?i.removeAttribute(n):i.setAttribute(n,e)}for(let n=0;n<t.children.length;++n)this._revertTemplateFromNode(i.childNodes[n],t.children[n])}}class Sd{constructor(e){(0,o.A)(this,"attribute",void 0),(0,o.A)(this,"observable",void 0),(0,o.A)(this,"emitter",void 0),(0,o.A)(this,"callback",void 0),this.attribute=e.attribute,this.observable=e.observable,this.emitter=e.emitter,this.callback=e.callback}getValue(e){const t=this.observable[this.attribute];return this.callback?this.callback(t,e):t}activateAttributeListener(e,t,i){const n=()=>Bd(e,t,i);return this.emitter.listenTo(this.observable,"change:".concat(this.attribute),n),()=>{this.emitter.stopListening(this.observable,"change:".concat(this.attribute),n)}}}class Id extends Sd{constructor(e){super(e),(0,o.A)(this,"eventNameOrFunction",void 0),this.eventNameOrFunction=e.eventNameOrFunction}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 Od extends Sd{constructor(e){super(e),(0,o.A)(this,"valueIfTrue",void 0),this.valueIfTrue=e.valueIfTrue}getValue(e){return!zd(super.getValue(e))&&(this.valueIfTrue||!0)}}function Fd(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(Fd):e instanceof Sd)}function Bd(e,t,i){let{node:n}=i;const s=function(e,t){return e.map(e=>e instanceof Sd?e.getValue(t):e)}(e,n);let o;o=1==e.length&&e[0]instanceof Od?s[0]:s.reduce(Wd,""),zd(o)?t.remove():t.set(o)}function Md(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function Rd(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function Vd(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function Nd(e){return on(e,e=>{if(e&&(e instanceof Sd||$d(e)||Hd(e)||Kd(e)))return e})}function Ld(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=Jo(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)jd(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=Jo(e[t].value)),jd(e,t)}(e.attributes);const t=[];if(e.children)if(Kd(e.children))t.push(e.children);else for(const i of e.children)$d(i)||Hd(i)||Ys(i)?t.push(i):t.push(new Dd(i));e.children=t}return e}
2function jd(e,t){e[t]=Jo(e[t])}function Wd(e,t){return zd(t)?e:zd(e)?t:"".concat(e," ").concat(t)}function qd(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function Ud(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),qd(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),qd(e.eventListeners,t.eventListeners)),t.text&&e.text.push(...t.text),t.children&&t.children.length){if(e.children.length!=t.children.length)throw new gs("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)Ud(e.children[i++],n)}}function zd(e){return!e&&0!==e}function Hd(e){return e instanceof Qd}function $d(e){return e instanceof Dd}function Kd(e){return e instanceof xd}function Gd(e){return ie(e[0])&&e[0].ns}function Jd(){return{children:[],bindings:[],attributes:{}}}function Zd(e){return"class"==e||"style"==e}class Qd extends(to(Ns())){constructor(e){super(),(0,o.A)(this,"element",void 0),(0,o.A)(this,"isRendered",void 0),(0,o.A)(this,"locale",void 0),(0,o.A)(this,"t",void 0),(0,o.A)(this,"template",void 0),(0,o.A)(this,"_viewCollections",void 0),(0,o.A)(this,"_unboundChildren",void 0),(0,o.A)(this,"_bindTemplate",void 0),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Yo,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",(t,i)=>{i.locale=e,i.t=e&&e.t}),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Dd.bind(this,this)}createCollection(e){const t=new xd(e);return this._viewCollections.add(t),t}registerChild(e){Ks(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){Ks(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new Dd(e)}extendTemplate(e){Dd.extend(this.template,e)}render(){if(this.isRendered)throw new gs("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)}}function Yd(e){let{emitter:t,activator:i,callback:n,contextElements:s,listenerOptions:o}=e;t.listenTo(document,"mousedown",(e,t)=>{if(!i())return;const o="function"==typeof t.composedPath?t.composedPath():[],r="function"==typeof s?s():s;for(const i of r)if(i.contains(t.target)||o.includes(i))return;n()},o)}function Xd(e){return class extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(){super(...arguments),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}function em(e){let{view:t}=e;t.listenTo(t.element,"submit",(e,i)=>{i.preventDefault(),t.fire("submit")},{useCapture:!0})}class tm extends Qd{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",e.if("isVisible","ck-hidden",e=>!e),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox"),"aria-hidden":!0}})}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");t&&(this.viewBox=t);for(const{name:i,value:n}of Array.from(e.attributes))tm.presentationalAttributeNames.includes(i)&&this.element.setAttribute(i,n);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach(e
2=>{e.style.fill=this.fillColor})}}(0,o.A)(tm,"presentationalAttributeNames",["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"]);class im extends Qd{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:e.to("style"),id:e.to("id")},children:[{text:e.to("text")}]})}}class nm extends Qd{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new im;super(e),(0,o.A)(this,"children",void 0),(0,o.A)(this,"labelView",void 0),(0,o.A)(this,"iconView",void 0),(0,o.A)(this,"keystrokeView",void 0),(0,o.A)(this,"_focusDelayed",null);const i=this.bindTemplate,n=ds();this.set("_ariaPressed",!1),this.set("_ariaChecked",!1),this.set("ariaLabel",void 0),this.set("ariaLabelledBy","ck-editor__aria-label_".concat(n)),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(t),this.iconView=new tm,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const s={tag:"button",attributes:{class:["ck","ck-button",i.to("class"),i.if("isEnabled","ck-disabled",e=>!e),i.if("isVisible","ck-hidden",e=>!e),i.to("isOn",e=>e?"ck-on":"ck-off"),i.if("withText","ck-button_with-text"),i.if("withKeystroke","ck-button_with-keystroke")],role:i.to("role"),type:i.to("type",e=>e||"button"),tabindex:i.to("tabindex"),"aria-checked":i.to("_ariaChecked"),"aria-pressed":i.to("_ariaPressed"),"aria-label":i.to("ariaLabel"),"aria-labelledby":i.to("ariaLabelledBy"),"aria-disabled":i.if("isEnabled",!0,e=>!e),"data-cke-tooltip-text":i.to("_tooltipString"),"data-cke-tooltip-position":i.to("tooltipPosition")},children:this.children,on:{click:i.to(e=>{this.isEnabled?this.fire("execute"):e.preventDefault()})}};this.bind("_ariaPressed").to(this,"isOn",this,"isToggleable",this,"role",(e,t,i)=>!(!t||sm(i))&&String(!!e)),this.bind("_ariaChecked").to(this,"isOn",this,"isToggleable",this,"role",(e,t,i)=>!(!t||!sm(i))&&String(!!e)),Yn.isSafari&&(this._focusDelayed||(this._focusDelayed=ar(()=>this.focus(),0)),s.on.mousedown=i.to(()=>{this._focusDelayed()}),s.on.mouseup=i.to(()=>{this._focusDelayed.cancel()})),this.setTemplate(s)}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_setupLabelView(e){return e.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),e}_createKeystrokeView(){const e=new Qd;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",e=>zo(e))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=zo(i)),e instanceof Function?e(t,i):"".concat(t).concat(i?" (".concat(i,")"):"")):""}}function sm(e){switch(e){case"radio":case"checkbox":case"option":case"switch":case"menuitemcheckbox":case"menuitemradio":return!0;default:return!1}}class om extends Qd{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),(0,o.A)(this,"children",void 0),(0,o.A)(this,"iconView",void 0);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}),t.icon&&(this.iconView=new tm,this.iconView.content=t.icon,this.children.add(this.iconView));const n=new Qd(e);n.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(n)}}class rm extends(Es()){constructor(e){if(super(),(0,o.A)(this,"focusables",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokeHandler",void 0),(0,o.A)(this,"actions",void 0),this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,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()},e.keystrokeHandlerOptions)}this.on("forwardCycle",()=>this.focusFirst(),{priority:"low"}),this.on("backwardCycle",()=>this.focusLast(),{priority:"low"})}get first(){return this.focusables.find(am)||null}get last(){return this.focusables.filter(am).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-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,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;e&&this.focusables.getIndex(e)===this.current||e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;e&&this.focusables.getIndex(e)===this.current||e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}chain(e){const t=()=>null===this.current?null:this.focusables.get(this.current);this.listenTo(e,"forwardCycle",e=>{const i=t();this.focusNext(),i!==t()&&e.stop()},{priority:"low"}),this.listenTo(e,"backwardCycle",e=>{const i=t();this.focusPrevious(),i!==t()&&e.stop()},{priority:"low"})}unchain(e){this.stopListening(e)}
2_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){const t=this.focusables.length;if(!t)return null;const i=this.current;if(null===i)return this[1===e?"first":"last"];let n=this.focusables.get(i),s=(i+t+e)%t;do{const i=this.focusables.get(s);if(am(i)){n=i;break}s=(s+t+e)%t}while(s!==i);return n}}function am(e){return lm(e)&&ko(e.element)}function lm(e){return!(!("focus"in e)||"function"!=typeof e.focus)}function cm(e){return class extends e{constructor(){super(...arguments),(0,o.A)(this,"_onDragBound",this._onDrag.bind(this)),(0,o.A)(this,"_onDragEndBound",this._onDragEnd.bind(this)),(0,o.A)(this,"_lastDraggingCoordinates",{x:0,y:0}),this.on("render",()=>{this._attachListeners()}),this.set("isDragging",!1)}_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(Jn.document,"mouseup",this._onDragEndBound),this.listenTo(Jn.document,"touchend",this._onDragEndBound),this.listenTo(Jn.document,"mousemove",this._onDragBound),this.listenTo(Jn.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(Jn.document,"mouseup",this._onDragEndBound),this.stopListening(Jn.document,"touchend",this._onDragEndBound),this.stopListening(Jn.document,"mousemove",this._onDragBound),this.stopListening(Jn.document,"touchmove",this._onDragBound)}_onDragStart(e,t){if(!this._isHandleElementPressed(t))return;this._attachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),this._lastDraggingCoordinates={x:i,y:n},this.isDragging=!0}_onDrag(e,t){if(!this.isDragging)return void this._detachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),t.preventDefault(),this.fire("drag",{deltaX:Math.round(i-this._lastDraggingCoordinates.x),deltaY:Math.round(n-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:i,y:n}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(e){return!!this.dragHandleElement&&(this.dragHandleElement===e.target||e.target instanceof HTMLElement&&this.dragHandleElement.contains(e.target))}}}class um extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"focusCycler",void 0),(0,o.A)(this,"_focusTracker",void 0),(0,o.A)(this,"_focusables",void 0),this.children=this.createCollection(),this.keystrokes=new sr,this._focusTracker=new er,this._focusables=new xd,this.focusCycler=new rm({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(e){for(const t of e){const e=new nm(this.locale);let i;for(i in e.on("execute",()=>t.onExecute()),t.onCreate&&t.onCreate(e),t)"onExecute"!=i&&"onCreate"!=i&&e.set(i,t[i]);this.children.add(e)}this._updateFocusCyclableItems()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}}class hm extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}reset(){for(;this.children.length;)this.children.remove(0)}}const dm="screen-center",mm="editor-center",fm="editor-top-side",gm="editor-top-center",pm="editor-bottom-center",_m="editor-above-center",wm="editor-below-center",bm=bo("px");class vm extends(cm(Qd)){constructor(e,t){let{getCurrentDomRoot:i,getViewportOffset:n,keystrokeHandlerOptions:s}=t;super(e),(0,o.A)(this,"parts",void 0),(0,o.A)(this,"headerView",void 0),(0,o.A)(this,"closeButtonView",void 0),(0,o.A)(this,"actionsView",void 0),(0,o.A)(this,"contentView",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"wasMoved",!1),(0,o.A)(this,"_getCurrentDomRoot",void 0),(0,o.A)(this,"_getViewportOffset",void 0),(0,o.A)(this,"_focusables",void 0),(0,o.A)(this,"_focusCycler",void 0);const r=this.bindTemplate,a=e.t;this.set("className",""),this.set("ariaLabel",a("Editor dialog")),this.set("isModal",!1),this.set("position",dm),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=i,this._getViewportOffset=n,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new sr,this.focusTracker=new er,this._focusables=new xd,this._focusCycler=new rm({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"},keystrokeHandlerOptions:s}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",r.if("isModal","ck-dialog-overlay__transparent",e=>!e),r.if("_isVisible","ck-hidden",e=>!e)],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",r.if("isModal","ck-dialog_modal"),r.to("className")],role:"dialog","aria-label":r.to("ariaLabel"),style:{to
2p:r.to("_top",e=>bm(e)),left:r.to("_left",e=>bm(e)),visibility:r.if("_isTransparent","hidden")}},children:this.parts}]})}render(){super.render(),this.keystrokes.set("Esc",(e,t)=>{e.defaultPrevented||(this.fire("close",{source:"escKeyPress"}),t())}),this.on("drag",(e,t)=>{let{deltaX:i,deltaY:n}=t;this.wasMoved=!0,this.moveBy(i,n)}),this.listenTo(Jn.window,"resize",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.listenTo(Jn.document,"scroll",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.on("change:_isVisible",(e,t,i)=>{i&&(this._isTransparent=!0,setTimeout(()=>{this.updatePosition(),this._isTransparent=!1,this.focus()},10))}),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView&&!this.isModal?this.headerView.element:null}setupParts(e){let{icon:t,title:i,hasCloseButton:n=!0,content:s,actionButtons:o}=e;i&&(this.headerView=new om(this.locale,{icon:t}),n&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=i,this.ariaLabel=i,this.parts.add(this.headerView,0)),s&&(s instanceof Qd&&(s=[s]),this.contentView=new hm(this.locale),this.contentView.children.addMany(s),this.parts.add(this.contentView)),o&&(this.actionsView=new um(this.locale),this.actionsView.setButtons(o),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),n=this._getDialogRect();e+n.width>i.right&&(e=i.right-n.width),e<i.left&&(e=i.left),t<i.top&&(t=i.top),this._moveTo(e,t)}_moveTo(e,t){this._left=e,this._top=t}moveBy(e,t){this.moveTo(this._left+e,this._top+t)}_moveOffScreen(){this._moveTo(-9999,-9999)}updatePosition(){if(!this.element||!this.element.parentNode)return;const e=this._getViewportRect();let t,i=this.position;this._getCurrentDomRoot()?t=this._getVisibleDomRootRect(e):i=dm;const n=vm.defaultOffset,s=this._getDialogRect();switch(i){case fm:if(t){const e="ltr"===this.locale.contentLanguageDirection?t.right-s.width-n:t.left+n;this.moveTo(e,t.top+n)}else this._moveOffScreen();break;case mm:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),Math.round(t.top+t.height/2-s.height/2)):this._moveOffScreen();break;case dm:this.moveTo(Math.round((e.width-s.width)/2),Math.round((e.height-s.height)/2));break;case gm:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.top+n):this._moveOffScreen();break;case pm:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.bottom-s.height-n):this._moveOffScreen();break;case _m:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.top-s.height-n):this._moveOffScreen();break;case wm:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.bottom+n):this._moveOffScreen()}}_getVisibleDomRootRect(e){let t=new uo(this._getCurrentDomRoot()).getVisible();return t?(t=e.getIntersection(t),t||null):null}_getDialogRect(){return new uo(this.element.firstElementChild)}_getViewportRect(){const e=new uo(Jn.window);if(this.isModal)return e;const t=(0,r.A)({top:0,bottom:0,left:0,right:0},this._getViewportOffset());return e.top+=t.top,e.height-=t.top,e.bottom-=t.bottom,e.height-=t.bottom,e.left+=t.left,e.right-=t.right,e.width-=t.left+t.right,e}_updateFocusCyclableItems(){const e=[];if(this.contentView)for(const t of this.contentView.children)lm(t)&&e.push(t);this.actionsView&&e.push(this.actionsView),this.closeButtonView&&e.push(this.closeButtonView),e.forEach(e=>{var t;this._focusables.add(e),this.focusTracker.add(e.element),lm(t=e)&&"focusCycler"in t&&t.focusCycler instanceof rm&&this._focusCycler.chain(e.focusCycler)})}_createCloseButton(){const e=new nm(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:zh}),e.on("execute",()=>this.fire("close",{source:"closeButton"})),e}}(0,o.A)(vm,"defaultOffset",15);class ym extends yh{static get pluginName(){return"Dialog"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"view",void 0),(0,o.A)(this,"_onHide",void 0);const t=e.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set({id:null,isOpen:!1}),e.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:t("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}destroy(){super.destroy(),ym._visibleDialogPlugin===this&&this._unlockBodyScroll()}_initShowHideListeners(){this.on("show",(e,t)=>{this._show(t)}),this.on("show",(e,t)=>{t.onShow&&t.onShow(this)},{priority:"low"}),this.on("hide",()=>{ym._visibleDialogPlugin&&ym._visibleDialogPlugin._hide()}),this.on("hide",()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)},{priority:"low"})}_initFocusToggler(){const e=this.editor;e.keystrokes.set("Ctrl+F6",(t,i)=>{this.isOpen&&!this.view.isModal&&(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),i())})}_initMultiRootIntegration(){const e=this.editor.model;e.document.on("change:data",()=>{if(!this.view)return;
2const t=e.document.differ.getChangedRoots();for(const e of t)e.state&&this.view.updatePosition()})}show(e){this.hide(),this.fire("show:".concat(e.id),e)}_show(e){let{id:t,icon:i,title:n,hasCloseButton:s=!0,content:o,actionButtons:r,className:a,isModal:l,position:c,onHide:u,keystrokeHandlerOptions:h}=e;const d=this.editor;this.view=new vm(d.locale,{getCurrentDomRoot:()=>d.editing.view.getDomRoot(d.model.document.selection.anchor.root.rootName),getViewportOffset:()=>d.ui.viewportOffset,keystrokeHandlerOptions:h});const m=this.view;m.on("close",()=>{this.hide()}),d.ui.view.body.add(m),d.keystrokes.listenTo(m.element),c||(c=l?dm:mm),l&&this._lockBodyScroll(),m.set({position:c,_isVisible:!0,className:a,isModal:l}),m.setupParts({icon:i,title:n,hasCloseButton:s,content:o,actionButtons:r}),this.id=t,u&&(this._onHide=u),this.isOpen=!0,ym._visibleDialogPlugin=this}hide(){ym._visibleDialogPlugin&&ym._visibleDialogPlugin.fire("hide:".concat(ym._visibleDialogPlugin.id))}_hide(){if(!this.view)return;const e=this.editor,t=this.view;t.isModal&&this._unlockBodyScroll(),t.contentView&&t.contentView.reset(),e.ui.view.body.remove(t),e.ui.focusTracker.remove(t.element),e.keystrokes.stopListening(t.element),t.destroy(),e.editing.view.focus(),this.id=null,this.isOpen=!1,ym._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add("ck-dialog-scroll-locked")}_unlockBodyScroll(){document.documentElement.classList.remove("ck-dialog-scroll-locked")}}(0,o.A)(ym,"_visibleDialogPlugin",void 0);class Am extends nm{constructor(e){super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:new im),(0,o.A)(this,"_checkIconHolderView",new km),this.set({hasCheckSpace:!1,_hasCheck:this.isToggleable});const t=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-list-item-button",t.if("isToggleable","ck-list-item-button_toggleable")]}}),this.bind("_hasCheck").to(this,"hasCheckSpace",this,"isToggleable",(e,t)=>e||t)}render(){super.render(),this._hasCheck&&this.children.add(this._checkIconHolderView,0),this._watchCheckIconHolderMount()}_watchCheckIconHolderMount(){this._checkIconHolderView.bind("isOn").to(this,"isOn",e=>this.isToggleable&&e),this.on("change:_hasCheck",(e,t,i)=>{const{children:n,_checkIconHolderView:s}=this;i?n.add(s,0):n.remove(s)})}}class km extends Qd{constructor(){super(),(0,o.A)(this,"children",void 0),(0,o.A)(this,"_checkIconView",this._createCheckIconView());const e=this.bindTemplate;this.children=this.createCollection(),this.set("isOn",!1),this.setTemplate({tag:"span",children:this.children,attributes:{class:["ck","ck-list-item-button__check-holder",e.to("isOn",e=>e?"ck-on":"ck-off")]}})}render(){super.render(),this.isOn&&this.children.add(this._checkIconView,0),this._watchCheckIconMount()}_watchCheckIconMount(){this.on("change:isOn",(e,t,i)=>{const{children:n,_checkIconView:s}=this;i&&!n.has(s)?n.add(s):!i&&n.has(s)&&n.remove(s)})}_createCheckIconView(){const e=new tm;return e.content=Hh,e.extendTemplate({attributes:{class:"ck-list-item-button__check-icon"}}),e}}class Em extends Am{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class Cm extends Qd{constructor(e){super(e),(0,o.A)(this,"id",void 0),this.set("text",void 0),this.set("for",void 0),this.id="ck-editor__label_".concat(ds());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")}]})}}class Pm extends Qd{constructor(e,t){super(e);const i=e.t,n=new Cm;n.text=i("Help Contents. To close this dialog press ESC."),this.setTemplate({tag:"div",attributes:{class:["ck","ck-accessibility-help-dialog__content"],"aria-labelledby":n.id,role:"document",tabindex:-1},children:[Gs(document,"p",{},i("Below, you can find a list of keyboard shortcuts that can be used in the editor.")),...this._createCategories(Array.from(t.values())),n]})}focus(){this.element.focus()}_createCategories(e){return e.map(e=>{const t=[Gs(document,"h3",{},e.label),...Array.from(e.groups.values()).map(e=>this._createGroup(e)).flat()];return e.description&&t.splice(1,0,Gs(document,"p",{},e.description)),Gs(document,"section",{},t)})}_createGroup(e){const t=e.keystrokes.sort((e,t)=>
2e.label.localeCompare(t.label)).map(e=>this._createGroupRow(e)).flat(),i=[Gs(document,"dl",{},t)];return e.label&&i.unshift(Gs(document,"h4",{},e.label)),i}_createGroupRow(e){const t=this.locale.t,i=Gs(document,"dt"),n=Gs(document,"dd"),s=function(e){if("string"===typeof e)return[[e]];if("string"===typeof e[0])return[e];return e}(e.keystroke),o=[];for(const r of s)o.push(r.map(Tm).join(""));return i.innerHTML=e.label,n.innerHTML=o.join(", ")+(e.mayRequireFn&&Yn.isMac?" ".concat(t("(may require <kbd>Fn</kbd>)")):""),[i,n]}}function Tm(e){return zo(e).split("+").map(e=>"<kbd>".concat(e,"</kbd>")).join("+")}var xm='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 6.628a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"/><path d="M8.5 9.125a.3.3 0 0 0-.253-.296L5.11 8.327a.75.75 0 1 1 .388-1.449l4.04.716c.267.072.624.08.893.009l4.066-.724a.75.75 0 1 1 .388 1.45l-3.132.5a.3.3 0 0 0-.253.296v1.357a.3.3 0 0 0 .018.102l1.615 4.438a.75.75 0 0 1-1.41.513l-1.35-3.71a.3.3 0 0 0-.281-.197h-.209a.3.3 0 0 0-.282.198l-1.35 3.711a.75.75 0 0 1-1.41-.513l1.64-4.509a.3.3 0 0 0 .019-.103V9.125Z"/><path clip-rule="evenodd" d="M10 18.5a8.5 8.5 0 1 1 0-17 8.5 8.5 0 0 1 0 17Zm0 1.5c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10Z"/></svg>';class Dm extends yh{constructor(){super(...arguments),(0,o.A)(this,"contentView",null)}static get requires(){return[ym]}static get pluginName(){return"AccessibilityHelp"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("accessibilityHelp",()=>{const e=this._createButton(nm);return e.set({tooltip:!0,withText:!1,label:t("Accessibility help")}),e}),e.ui.componentFactory.add("menuBar:accessibilityHelp",()=>{const e=this._createButton(Em);return e.label=t("Accessibility"),e}),e.keystrokes.set("Alt+0",(e,t)=>{this._toggleDialog(),t()}),this._setupRootLabels()}_createButton(e){const t=this.editor,i=t.plugins.get("Dialog"),n=new e(t.locale);return n.set({keystroke:"Alt+0",icon:xm,isToggleable:!0}),n.on("execute",()=>this._toggleDialog()),n.bind("isOn").to(i,"id",e=>"accessibilityHelp"===e),n}_setupRootLabels(){const e=this.editor,t=e.editing.view,i=e.t;function n(e,t){const n=[t.getAttribute("aria-label"),i("Press %0 for help.",[zo("Alt+0")])].filter(e=>e).join(". ");e.setAttribute("aria-label",n,t)}e.ui.on("ready",()=>{t.change(e=>{for(const i of t.document.roots)n(e,i)}),e.on("addRoot",(i,s)=>{const o=e.editing.view.document.getRoot(s.rootName);t.change(e=>n(e,o))},{priority:"low"})})}_toggleDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.contentView||(this.contentView=new Pm(e.locale,e.accessibility.keystrokeInfos)),"accessibilityHelp"===t.id?t.hide():t.show({id:"accessibilityHelp",className:"ck-accessibility-help-dialog",title:i("Accessibility help"),icon:xm,hasCloseButton:!0,content:this.contentView})}}class Sm extends xd{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]),(0,o.A)(this,"locale",void 0),(0,o.A)(this,"_bodyCollectionContainer",void 0),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new Dd({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection,role:"application"},children:this}).render(),Sm._bodyWrapper&&Sm._bodyWrapper.isConnected||(Sm._bodyWrapper=Gs(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(Sm._bodyWrapper)),Sm._bodyWrapper.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove(),Sm._bodyWrapper&&!Sm._bodyWrapper.childElementCount&&(Sm._bodyWrapper.remove(),delete Sm._bodyWrapper)}}(0,o.A)(Sm,"_bodyWrapper",void 0);class Im extends nm{constructor(e){super(e),(0,o.A)(this,"toggleSwitchView",void 0),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 Qd;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}class Om extends(Bm(nm)){}class Fm extends(Bm(Am)){}function Bm(e){return class extends e{constructor(){super(...arguments),(0,o.A)(this,"buttonView",void 0),(0,o.A)(this,"_fileInputView",void 0),this.buttonView=this,this._fileInputView=new Mm(this.locale),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",()=>{this._fileInputView.open()}),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}render(){super.render(),this.children.add(this._fileInputView)}}}class Mm extends Qd{constructor(e){super(e),this.set("acceptedType",void 0),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()}}var Rm='<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>';class Vm extends Qd{constructor(e,t){super(e),(0,o.A)(this,"buttonView",void 0),(0,o.A)(this,"children",void 0);const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.i
2d}focus(){this.buttonView.focus()}_createButtonView(){const e=new nm(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:Rm}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",e=>String(e))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",e=>!e),e.on("execute",()=>{this.isCollapsed=!this.isCollapsed}),e}}class Nm extends Qd{constructor(e,t){super(e),(0,o.A)(this,"fieldView",void 0),(0,o.A)(this,"labelView",void 0),(0,o.A)(this,"statusView",void 0),(0,o.A)(this,"fieldWrapperChildren",void 0);const i="ck-labeled-field-view-".concat(ds()),n="ck-labeled-field-view-status-".concat(ds());this.fieldView=t(this,i,n),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(n),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),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.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new Cm(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Qd(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(e){this.fieldView.focus(e)}}class Lm extends Qd{constructor(e){var t;super(e),t=this,(0,o.A)(this,"focusTracker",void 0),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new er,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const i=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",i.if("isFocused","ck-input_focused"),i.if("isEmpty","ck-input-text_empty"),i.if("hasError","ck-error")],id:i.to("id"),placeholder:i.to("placeholder"),tabindex:i.to("tabIndex"),readonly:i.to("isReadOnly"),"aria-invalid":i.if("hasError",!0),"aria-describedby":i.to("ariaDescribedById"),"aria-label":i.to("ariaLabel")},on:{input:i.to(function(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];t.fire("input",...i),t._updateIsEmpty()}),change:i.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()})}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class jm extends Lm{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class Wm extends jm{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class qm extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0);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_".concat(e)),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to(e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()})}})}focus(){if(this.children.length){const e=this.children.first;"function"===typeof e.focus?e.focus():ps("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;"function"===typeof e.focusLast?e.focusLast():e.focus()}}}class Um extends Qd{constructor(e,t,i){super(e),(0,o.A)(this,"buttonView",void 0),(0,o.A)(this,"panelView",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"listView",void 0),(0,o.A)(this,"toolbarView",void 0),(0,o.A)(this,"menuView",void 0);const n=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new sr,this.focusTracker=new er,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"],"data-cke-tooltip-disabled":n.to("isOpen")}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",()=>{this.isOpen=!this.isOpen}),this.on("change:isOpen",(e,t,i)=>{if(i)if("auto"===this.panelPosition){const e=Um._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=e?e.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition}),this.keystrokes.listenTo(this.element);const e=(e,t)=>
2{this.isOpen&&(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}=Um.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]}get _defaultPanelPositionName(){return"rtl"===this.locale.uiLanguageDirection?"sw":"se"}}(0,o.A)(Um,"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"})}),(0,o.A)(Um,"_getOptimalPosition",Eo);class zm extends nm{constructor(e){super(e),(0,o.A)(this,"arrowView",void 0),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",e=>String(e))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new tm;return e.content=Rm,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class Hm extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0);const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",e=>!e)],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class $m extends Qd{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class Km extends Qd{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Cm;super(e),(0,o.A)(this,"labelView",void 0),(0,o.A)(this,"items",void 0),(0,o.A)(this,"children",void 0);const i=this.bindTemplate,n=new Gm(e);this.set({label:"",isVisible:!0}),this.labelView=t,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,n]),n.set({role:"group",ariaLabelledBy:t.id}),n.focusTracker.destroy(),n.keystrokes.destroy(),this.items=n.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",e=>!e)]},children:this.children})}focus(){if(this.items){const e=this.items.find(e=>!(e instanceof $m));e&&e.focus()}}}class Gm extends Qd{constructor(e){super(e),(0,o.A)(this,"focusables",void 0),(0,o.A)(this,"items",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"_focusCycler",void 0),(0,o.A)(this,"_listItemGroupToChangeListeners",new WeakMap);const t=this.bindTemplate;this.focusables=new xd,this.items=this.createCollection(),this.focusTracker=new er,this.keystrokes=new sr,this._focusCycler=new rm({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:t.to("role"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy")},children:this.items})}render(){super.render();for(const e of this.items)e instanceof Km?this._registerFocusableItemsGroup(e):e instanceof Hm&&this._registerFocusableListItem(e);this.items.on("change",(e,t)=>{for(const i of t.removed)i instanceof Km?this._deregisterFocusableItemsGroup(i):i instanceof Hm&&this._deregisterFocusableListItem(i);for(const i of Array.from(t.added).reverse())i instanceof Km?this._registerFocusableItemsGroup(i,t.index):this._registerFocusableListItem(i,t.index)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(e,t){this.focusTracker.add(e.element),this.focusables.add(e,t)}_deregisterFocusableListItem(e){this.focusTracker.remove(e.element),this.focusables.remove(e)}_getOnGroupItemsChangeCallback(e){return(t,i)=>{for(const e of i.removed)this._deregisterFocusableListItem(e);for(const n of Array.from(i.added).reverse())this._registerFocusableListItem(n,this.items.getIndex(e)+i.index)}}
2_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach((e,i)=>{const n="undefined"!==typeof t?t+i:void 0;this._registerFocusableListItem(e,n)});const i=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,i),e.items.on("change",i)}_deregisterFocusableItemsGroup(e){for(const t of e.items)this._deregisterFocusableListItem(t);e.items.off("change",this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}}const Jm=bo("px"),Zm={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class Qm extends Qd{constructor(e){super(e),(0,o.A)(this,"content",void 0),(0,o.A)(this,"_pinWhenIsVisibleCallback",void 0),(0,o.A)(this,"_resizeObserver",void 0);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",void 0),this._pinWhenIsVisibleCallback=null,this._resizeObserver=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",e=>"ck-balloon-panel_".concat(e)),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Jm),left:t.to("left",Jm)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){const t=Ym(e.target);if(t&&!ko(t))return!1;this.show();const i=Qm.defaultPositions,n=Object.assign({},{element:this.element,positions:[i.southArrowNorth,i.southArrowNorthMiddleWest,i.southArrowNorthMiddleEast,i.southArrowNorthWest,i.southArrowNorthEast,i.northArrowSouth,i.northArrowSouthMiddleWest,i.northArrowSouthMiddleEast,i.northArrowSouthWest,i.northArrowSouthEast,i.viewportStickyNorth],limiter:Jn.document.body,fitInViewport:!0},e),s=Qm._getOptimalPosition(n)||Zm,o=parseInt(s.left),r=parseInt(s.top),a=s.name,l=s.config||{},{withArrow:c=!0}=l;return this.top=r,this.left=o,this.position=a,this.withArrow=c,!0}pin(e){this.unpin(),this._startPinning(e)&&(this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback))}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){if(!this.attachTo(e))return!1;let t=Ym(e.target);const i=e.limiter?Ym(e.limiter):Jn.document.body;if(this.listenTo(Jn.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(Jn.window,"resize",()=>{this.attachTo(e)}),!this._resizeObserver&&(t&&ro(t)&&(t=t.parentElement),t)){const e=()=>{ko(t)||this.unpin()};this._resizeObserver=new _o(t,e)}return!0}_stopPinning(){this.stopListening(Jn.document,"scroll"),this.stopListening(Jn.window,"resize"),this._resizeObserver&&(this._resizeObserver.destroy(),this._resizeObserver=null)}static generatePositions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{sideOffset:t=Qm.arrowSideOffset,heightOffset:i=Qm.arrowHeightOffset,stickyVerticalOffset:n=Qm.stickyVerticalOffset,config:s}=e;return{northWestArrowSouthWest:(e,i)=>(0,r.A)({top:o(e,i),left:e.left-t,name:"arrow_sw"},s&&{config:s}),northWestArrowSouthMiddleWest:(e,i)=>(0,r.A)({top:o(e,i),left:e.left-.25*i.width-t,name:"arrow_smw"},s&&{config:s}),northWestArrowSouth:(e,t)=>(0,r.A)({top:o(e,t),left:e.left-t.width/2,name:"arrow_s"},s&&{config:s}),northWestArrowSouthMiddleEast:(e,i)=>(0,r.A)({top:o(e,i),left:e.left-.75*i.width+t,name:"arrow_sme"},s&&{config:s}),northWestArrowSouthEast:(e,i)=>(0,r.A)({top:o(e,i),left:e.left-i.width+t,name:"arrow_se"},s&&{config:s}),northArrowSouthWest:(e,i)=>(0,r.A)({top:o(e,i),left:e.left+e.width/2-t,name:"arrow_sw"},s&&{config:s}),northArrowSouthMiddleWest:(e,i)=>(0,r.A)({top:o(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw"},s&&{config:s}),northArrowSouth:(e,t)=>(0,r.A)({top:o(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s"},s&&{config:s}),northArrowSouthMiddleEast:(e,i)=>
2(0,r.A)({top:o(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme"},s&&{config:s}),northArrowSouthEast:(e,i)=>(0,r.A)({top:o(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se"},s&&{config:s}),northEastArrowSouthWest:(e,i)=>(0,r.A)({top:o(e,i),left:e.right-t,name:"arrow_sw"},s&&{config:s}),northEastArrowSouthMiddleWest:(e,i)=>(0,r.A)({top:o(e,i),left:e.right-.25*i.width-t,name:"arrow_smw"},s&&{config:s}),northEastArrowSouth:(e,t)=>(0,r.A)({top:o(e,t),left:e.right-t.width/2,name:"arrow_s"},s&&{config:s}),northEastArrowSouthMiddleEast:(e,i)=>(0,r.A)({top:o(e,i),left:e.right-.75*i.width+t,name:"arrow_sme"},s&&{config:s}),northEastArrowSouthEast:(e,i)=>(0,r.A)({top:o(e,i),left:e.right-i.width+t,name:"arrow_se"},s&&{config:s}),southWestArrowNorthWest:e=>(0,r.A)({top:a(e),left:e.left-t,name:"arrow_nw"},s&&{config:s}),southWestArrowNorthMiddleWest:(e,i)=>(0,r.A)({top:a(e),left:e.left-.25*i.width-t,name:"arrow_nmw"},s&&{config:s}),southWestArrowNorth:(e,t)=>(0,r.A)({top:a(e),left:e.left-t.width/2,name:"arrow_n"},s&&{config:s}),southWestArrowNorthMiddleEast:(e,i)=>(0,r.A)({top:a(e),left:e.left-.75*i.width+t,name:"arrow_nme"},s&&{config:s}),southWestArrowNorthEast:(e,i)=>(0,r.A)({top:a(e),left:e.left-i.width+t,name:"arrow_ne"},s&&{config:s}),southArrowNorthWest:e=>(0,r.A)({top:a(e),left:e.left+e.width/2-t,name:"arrow_nw"},s&&{config:s}),southArrowNorthMiddleWest:(e,i)=>(0,r.A)({top:a(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw"},s&&{config:s}),southArrowNorth:(e,t)=>(0,r.A)({top:a(e),left:e.left+e.width/2-t.width/2,name:"arrow_n"},s&&{config:s}),southArrowNorthMiddleEast:(e,i)=>(0,r.A)({top:a(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme"},s&&{config:s}),southArrowNorthEast:(e,i)=>(0,r.A)({top:a(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne"},s&&{config:s}),southEastArrowNorthWest:e=>(0,r.A)({top:a(e),left:e.right-t,name:"arrow_nw"},s&&{config:s}),southEastArrowNorthMiddleWest:(e,i)=>(0,r.A)({top:a(e),left:e.right-.25*i.width-t,name:"arrow_nmw"},s&&{config:s}),southEastArrowNorth:(e,t)=>(0,r.A)({top:a(e),left:e.right-t.width/2,name:"arrow_n"},s&&{config:s}),southEastArrowNorthMiddleEast:(e,i)=>(0,r.A)({top:a(e),left:e.right-.75*i.width+t,name:"arrow_nme"},s&&{config:s}),southEastArrowNorthEast:(e,i)=>(0,r.A)({top:a(e),left:e.right-i.width+t,name:"arrow_ne"},s&&{config:s}),westArrowEast:(e,t)=>(0,r.A)({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e"},s&&{config:s}),eastArrowWest:(e,t)=>(0,r.A)({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w"},s&&{config:s}),viewportStickyNorth:(e,t,i,o)=>{const a=o||i;return e.getIntersection(a)?a.height-e.height>n?null:{top:a.top+n,left:e.left+e.width/2-t.width/2,name:"arrowless",config:(0,r.A)({withArrow:!1},s)}:null}};function o(e,t){return e.top-t.height-i}function a(e){return e.bottom+i}}}function Ym(e){return Ln(e)?e:ao(e)?e.commonAncestorContainer:"function"==typeof e?Ym(e()):null}n=Qm,(0,o.A)(Qm,"arrowSideOffset",25),(0,o.A)(Qm,"arrowHeightOffset",10),(0,o.A)(Qm,"stickyVerticalOffset",20),(0,o.A)(Qm,"_getOptimalPosition",Eo),(0,o.A)(Qm,"defaultPositions",n.generatePositions());class Xm extends Qd{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class ef extends Qd{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function tf(e){if(Array.isArray(e))return{items:e,removeItems:[]};const t={items:[],removeItems:[]};return e?(0,r.A)((0,r.A)({},t),e):t}const nf=(()=>({alignLeft:td,bold:Uh,importExport:Qh,paragraph:Yh,plus:Xh,text:ed,threeVerticalDots:od,pilcrow:nd,dragIndicator:rd}))();class sf extends Qd{constructor(e,t){super(e),(0,o.A)(this,"options",void 0),(0,o.A)(this,"items",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"itemsView",void 0),(0,o.A)(this,"children",void 0),(0,o.A)(this,"focusables",void 0),(0,o.A)(this,"_focusCycler",void 0),(0,o.A)(this,"_behavior",void 0);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.set("role","toolbar"),this.items=this.createCollection(),this.focusTracker=new er,this.keystrokes=new sr,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new of(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const s="rtl"===e.uiLanguageDirection;this._focusCycler=new rm({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[s?"arrowright":"arrowleft","arrowup"],focusNext:[s?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var a;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:i.to("role"),"aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(a=this,a.bindTemplate.to(e=>{e.target===a.element&&e.preventDefault()}))}}),this._behavior=this.options.shouldGroupWhenFull?new af(this):new rf(this)}render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e);this.items.on("add",(e,t)=>{this.focusTracker.add(t)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t)}),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t,i){this.items.addMany(this._buildItemsFromConfig(e,t,i))}_buildItemsFromConfig(e,t,i){const n=tf(e),s=i||n.removeItems;return this._cleanItemsConfiguration(n.items,t,s).map(e=>ie(e)?this._createNestedToolbarDropdown(e,t,s):"|"===e?new Xm:"-"===e?new ef:t.create(e)).filter(e=>!!e)}_cleanItemsConfiguration(e,t,i){const n=e.filter((e,n,s)=>"|"===e||-1===i.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(ps("toolbarview-line-break-ignored-when-grouping-items",s),!1):!(!ie(e)&&!t.has(e))||(ps("toolbarview-item-unavailable",{item:e}),!1)));return this._cleanSeparatorsAndLineBreaks(n)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t);if(-1===n)return[];const 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)})}_createNestedToolbarDropdown(e,t,i){let{label:n,icon:s,items:o,tooltip:r=!0,withText:a=!1}=e;if(o=this._cleanItemsConfiguration(o,t,i),!o.length)return null;const l=cf(this.locale);return n||ps("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:n,tooltip:r,withText:!!a}),!1!==s?l.buttonView.icon=nf[s]||s||od:l.buttonView.withText=!0,uf(l,()=>l.toolbarView._buildItemsFromConfig(o,t,i)),l}}class of extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class rf{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=>lm(e)?e:null),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class af{constructor(e){(0,o.A)(this,"view",void 0),(0,o.A)(this,"viewChildren",void 0),(0,o.A)(this,"viewFocusables",void 0),(0,o.A)(this,"viewItemsView",void 0),(0,o.A)(this,"viewFocusTracker",void 0),(0,o.A)(this,"viewLocale",void 0),(0,o.A)(this,"ungroupedItems",void 0),(0,o.A)(this,"groupedItems",void 0),(0,o.A)(this,"groupedItemsDropdown",void 0),(0,o.A)(this,"resizeObserver",null),(0,o.A)(this,"cac
2hedPadding",null),(0,o.A)(this,"shouldUpdateGroupingOnNextResize",!1),(0,o.A)(this,"viewElement",void 0),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(),e.itemsView.children.bindTo(this.ungroupedItems).using(e=>e),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",(e,t)=>{const i=t.index,n=Array.from(t.added);for(const s of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(s):this.ungroupedItems.remove(s);for(let s=i;s<i+n.length;s++){const e=n[s-i];s>this.ungroupedItems.length?this.groupedItems.add(e,s-this.ungroupedItems.length):this.ungroupedItems.add(e,s)}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(!ko(this.viewElement))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 uo(e.lastChild),n=new uo(e);if(!this.cachedPadding){const i=Jn.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 _o(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 Xm),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=cf(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",uf(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:od}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{lm(e)&&this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class lf extends Qd{constructor(e,t){super(e),(0,o.A)(this,"children",void 0),(0,o.A)(this,"actionView",void 0),(0,o.A)(this,"arrowView",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"focusTracker",void 0);const i=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(t),this.arrowView=this._createArrowView(),this.keystrokes=new sr,this.focusTracker=new er,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.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())})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(e){const t=e||new nm;return e||t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const e=new nm,t=e.bindTemplate;return e.icon=Rm,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",e=>String(e))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}function cf(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zm;const i="function"==typeof t?new t(e):t,n=new qm(e),s=new Um(e,i,n);return i.bind("isEnabled").to(s),i instanceof lf?i.arrowView.bind("isOn").to(s,"isOpen"):i.bind("isOn").to(s,"isOpen"),function(e){(function(e){Yd({emitter:e,activator:()=>e.isRendered&&e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>
2[e.element,...gf(e.focusTracker).filter(t=>!e.element.contains(t))]})})(e),function(e){e.on("execute",t=>{t.source instanceof Im||(e.isOpen=!1)})}(e),function(e){e.focusTracker.on("change:isFocused",(t,i,n)=>{!n&&e.isOpen&&(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())})}(e),function(e){e.on("change:isOpen",(t,i,n)=>{if(n)return;e.focusTracker.elements.some(e=>e.contains(Jn.document.activeElement))&&e.buttonView.focus()})}(e),function(e){e.on("change:isOpen",(t,i,n)=>{n&&e.panelView.focus()},{priority:"low"})}(e)}(s),s}function uf(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?hf(e,t,i):e.once("change:isOpen",()=>hf(e,t,i),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&ff(e,()=>e.toolbarView.items.find(e=>e.isOn))}function hf(e,t,i){const n=e.locale,s=n.t,o=e.toolbarView=new sf(n),r="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel||s("Dropdown toolbar"),i.maxWidth&&(o.maxWidth=i.maxWidth),i.class&&(o.class=i.class),i.isCompact&&(o.isCompact=i.isCompact),i.isVertical&&(o.isVertical=!0),r instanceof xd?o.items.bindTo(r).using(e=>e):o.items.addMany(r),e.panelView.children.add(o),e.focusTracker.add(o),o.items.delegate("execute").to(e)}function df(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e.isOpen?mf(e,t,i):e.once("change:isOpen",()=>mf(e,t,i),{priority:"highest"}),ff(e,()=>e.listView.items.find(e=>e instanceof Hm&&e.children.first.isOn))}function mf(e,t,i){const n=e.locale,s=e.listView=new Gm(n),o="function"==typeof t?t():t;s.ariaLabel=i.ariaLabel,s.role=i.role,pf(e,s.items,o,n),e.panelView.children.add(s),s.items.delegate("execute").to(e)}function ff(e,t){e.on("change:isOpen",()=>{if(!e.isOpen)return;const i=t();i&&("function"===typeof i.focus?i.focus():ps("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))},{priority:ms.low-10})}function gf(e){return[...e.elements,...e.externalViews.flatMap(e=>gf(e.focusTracker))]}function pf(e,t,i,n){t.on("change",()=>{const e=[...t].reduce((e,t)=>(t instanceof Hm&&t.children.first instanceof Am&&e.push(t.children.first),e),[]),i=e.some(e=>e.isToggleable);e.forEach(e=>{e.hasCheckSpace=i})}),t.bindTo(i).using(t=>{if("separator"===t.type)return new $m(n);if("group"===t.type){const i=new Km(n);return i.set({label:t.label}),pf(e,i.items,t.items,n),i.items.delegate("execute").to(e),i}if("button"===t.type||"switchbutton"===t.type){const e="menuitemcheckbox"===t.model.role||"menuitemradio"===t.model.role,
2i=new Hm(n);let s;return"button"===t.type?(s=new Am(n),s.set({isToggleable:e})):s=new Im(n),s.bind(...Object.keys(t.model)).to(t.model),s.delegate("execute").to(i),i.children.add(s),i}return null})}const _f=(e,t,i)=>{const n=new Wm(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};class wf{constructor(e){(0,o.A)(this,"editor",void 0),(0,o.A)(this,"_components",new Map),this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(bf(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new gs("componentfactory-item-missing",this,{name:e});return this._components.get(bf(e)).callback(this.editor.locale)}has(e){return this._components.has(bf(e))}}function bf(e){return String(e).toLowerCase()}const vf="ck-tooltip";class yf extends(to()){constructor(e){if(super(),(0,o.A)(this,"tooltipTextView",void 0),(0,o.A)(this,"balloonPanelView",void 0),(0,o.A)(this,"_currentElementWithTooltip",null),(0,o.A)(this,"_currentTooltipPosition",null),(0,o.A)(this,"_mutationObserver",null),(0,o.A)(this,"_pinTooltipDebounced",void 0),(0,o.A)(this,"_unpinTooltipDebounced",void 0),(0,o.A)(this,"_watchdogExcluded",void 0),yf._editors.add(e),yf._instance)return yf._instance;yf._instance=this,this.tooltipTextView=new Qd(e.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new Qm(e.locale),this.balloonPanelView.class=vf,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=function(e){const t=new MutationObserver(()=>{e()});return{attach(e){t.observe(e,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){t.disconnect()}}}(()=>{this._updateTooltipPosition()}),this._pinTooltipDebounced=In(this._pinTooltip,600),this._unpinTooltipDebounced=In(this._unpinTooltip,400),this.listenTo(Jn.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(Jn.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Jn.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Jn.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Jn.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Jn.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;yf._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),yf._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),yf._instance=null)}static getPositioningFunctions(e){const t=yf.defaultBalloonPositions;return{s:[t.southArrowNorth,t.southArrowNorthEast,t.southArrowNorthWest],n:[t.northArrowSouth],e:[t.eastArrowWest],w:[t.westArrowEast],sw:[t.southArrowNorthEast],se:[t.southArrowNorthWest]}[e]}_onKeyDown(e,t){"Escape"===t.key&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,t){let{target:i}=t;const n=Af(i);n?n!==this._currentElementWithTooltip?(this._unpinTooltip(),"focus"===e.name&&!n.matches(":hover")||n.matches("[data-cke-tooltip-instant]")?this._pinTooltip(n,kf(n)):this._pinTooltipDebounced(n,kf(n))):this._unpinTooltipDebounced.cancel():"focus"===e.name&&this._unpinTooltip()}_onLeaveOrBlur(e,t){let{target:i,relatedTarget:n}=t;if("mouseleave"===e.name){if(!Ln(i))return;const e=this.balloonPanelView.element,t=e&&(e===n||e.contains(n)),s=!t&&i===e;if(t)return void this._unpinTooltipDebounced.cancel();if(!s&&this._currentElementWithTooltip&&i!==this._currentElementWithTooltip)return;const o=Af(i),r=Af(n);(s||o&&o!==r)&&(this._pinTooltipDebounced.cancel(),this._currentElementWithTooltip&&this._currentElementWithTooltip.matches("[data-cke-tooltip-instant]")||o&&o.matches("[data-cke-tooltip-instant]")?this._unpinTooltip():this._unpinTooltipDebounced())}else{if(this._currentElementWithTooltip&&i!==this._currentElementWithTooltip)return;this._pinTooltipDebounced.cancel(),this._unpinTooltipDebounced()}}_onScroll(e,t){let{target:i}=t;this._currentElementWithTooltip&&(i.contains(this.balloonPanelView.element)&&i.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,t){let{text:i,position:n,cssClass:s}=t;this._unpinTooltip();const o=Xo(yf._editors.values()).ui.view.body;o.has(this.balloonPanelView)||o.add(this.balloonPanelView),this.tooltipTextView.text=i,this.balloonPanelView.class=[vf,s].filter(e=>e).join(" "),this.balloonPanelView.pin({target:e,positions:yf.getPositioningFunctions(n)}),this._mutationObserver.attach(e);for(const r of yf._editors)this.listenTo(r.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=n}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of yf._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;const e=kf(this._currentElementWithTooltip);ko(this._currentElementWithTooltip)&&e.text?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:yf.getPositioningFunctions(e.position)}):this._unpinTooltip()}}function Af(e){return Ln(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function kf(e){return{text:e.dataset.ckeTooltipText,position:e.dataset.ckeTooltipPosition||"s",cssClass:e.dataset.ckeTooltipClass||""}}(0,o.A)(yf,"defaultBalloonPositions",Qm.generatePositions({heightOffset:5,sideOffset:13})),(0,o.A)(yf,"_editors",new Set),(0,o.A)(yf,"_instance",null);class Ef extends(to()){constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),(0,o.A)(this,"editor",void 0),(0,o.A)(this,"_balloonView",null),(0,o.A)(this,"_showBalloonThrottled",$n(()=>this._showBalloon(),50,{leading:!0})),(0,o.A)(this,"_lastFocusedEditableElement",null),(0,o.A)(this,"_balloonClass",void 0),this.editor=e,this._balloonClass=t.balloonClass,e.on("ready",()=>this._handleEditorReady())}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;this._isEnabled()&&e.ui.view&&(e.ui.focusTracker.on("change:isFocused",(e,t,i)=>{this._updateLastFocusedEditableElement(),i?this._showBalloon():this._hideBalloon()}),e.ui.focusTracker.on("change:focusedElement",(e,t,i)=>{this._updateLastFocusedEditableElement(),i&&this._showBalloon()}),e.ui.on("update",()=>{this._showBalloonThrottled()}))}_getNormalizedConfig(){return{side:"ltr"===this.editor.locale.contentLanguageDirection?"right":"left",position:"border",verticalOffset:0,horizontalOffset:5}}_showBalloon(){const e=this._getBalloonAttachOptions();e&&(this._balloonView||(this._balloonView=this._createBalloonView()),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_createBalloonView(){const e=this.editor,t=new Qm,i=this._createBadgeContent();return t.content.add(i),this._balloonClass&&(t.class=this._balloonClass),e.ui.view.body.add(t),t}_getBalloonAttachOptions(){if(!this._lastFocusedEditableElement)return null;const e=this._getNormalizedConfig(),t="right"===e.side?Cf(this._lastFocusedEditableElement,i=e,(e,t)=>e.left+e.width-t.width-i.horizontalOffset):function(e,t){return Cf(e,t,e=>e.left+t.horizontalOffset)}(this._lastFocusedEditableElement,e);var i;return{target:this._lastFocusedEditableElement,positions:[t]}}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i)return void(this._lastFocusedEditableElement=null);const n=Array.from(e.ui.getEditableElementsNames()).map(t=>e.ui.getEditableElement(t));n.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=n[0]}}function Cf(e,t,i){return(n,s)=>{const o=new uo(e);if(o.width<350||o.height<50)return null;let r;r="inside"===t.position?o.bottom-s.height:o.bottom-s.height/2,r-=t.verticalOffset;const a=i(o,s),l=n.clone().moveTo(a,r).getIntersection(s.clone().moveTo(a,r)).getVisible();return!l||l.getArea()<s.getArea()?null:{top:r,left:a,name:"position_".concat(t.position,"-side_").concat(t.side),config:{withArrow:!1}
2}}}class Pf extends Ef{constructor(e){super(e,{balloonClass:"ck-powered-by-balloon"})}_isEnabled(){const e=this.editor;if(e.config.get("ui.poweredBy.forceVisible"))return!0;const t=e.config.get("licenseKey");if("GPL"==t)return!0;const i=lr(t.split(".")[1]);return!i||!i.whiteLabel}_createBadgeContent(){return new Tf(this.editor.locale,this._getNormalizedConfig().label)}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{},i=t.position||e.position,n="inside"===i?5:e.verticalOffset;return{position:i,side:t.side||e.side,label:void 0===t.label?"Powered by":t.label,verticalOffset:void 0!==t.verticalOffset?t.verticalOffset:n,horizontalOffset:void 0!==t.horizontalOffset?t.horizontalOffset:e.horizontalOffset,forceVisible:!!t.forceVisible}}}class Tf extends Qd{constructor(e,t){super(e);const i=new tm,n=this.bindTemplate;i.set({content:'<svg xmlns="http://www.w3.org/2000/svg" width="53" height="10" viewBox="0 0 53 10"><path fill="#1C2331" d="M31.724 1.492a15.139 15.139 0 0 0 .045 1.16 2.434 2.434 0 0 0-.687-.34 3.68 3.68 0 0 0-1.103-.166 2.332 2.332 0 0 0-1.14.255 1.549 1.549 0 0 0-.686.87c-.15.41-.225.98-.225 1.712 0 .939.148 1.659.444 2.161.297.503.792.754 1.487.754.452.015.9-.094 1.294-.316.296-.174.557-.4.771-.669l.14.852h1.282V.007h-1.623v1.485ZM31 6.496a1.77 1.77 0 0 1-.494.061.964.964 0 0 1-.521-.127.758.758 0 0 1-.296-.466 3.984 3.984 0 0 1-.093-.992 4.208 4.208 0 0 1 .098-1.052.753.753 0 0 1 .307-.477 1.08 1.08 0 0 1 .55-.122c.233-.004.466.026.69.089l.483.144v2.553c-.11.076-.213.143-.307.2a1.73 1.73 0 0 1-.417.189ZM35.68 0l-.702.004c-.322.002-.482.168-.48.497l.004.581c.002.33.164.493.486.49l.702-.004c.322-.002.481-.167.48-.496L36.165.49c-.002-.33-.164-.493-.486-.491ZM36.145 2.313l-1.612.01.034 5.482 1.613-.01-.035-5.482ZM39.623.79 37.989.8 38 2.306l-.946.056.006 1.009.949-.006.024 2.983c.003.476.143.844.419 1.106.275.26.658.39 1.148.387.132 0 .293-.01.483-.03.19-.02.38-.046.57-.08.163-.028.324-.068.482-.119l-.183-1.095-.702.004a.664.664 0 0 1-.456-.123.553.553 0 0 1-.14-.422l-.016-2.621 1.513-.01-.006-1.064-1.514.01-.01-1.503ZM46.226 2.388c-.41-.184-.956-.274-1.636-.27-.673.004-1.215.101-1.627.29-.402.179-.72.505-.888.91-.18.419-.268.979-.264 1.68.004.688.1 1.24.285 1.655.172.404.495.724.9.894.414.18.957.268 1.63.264.68-.004 1.224-.099 1.632-.284.4-.176.714-.501.878-.905.176-.418.263-.971.258-1.658-.004-.702-.097-1.261-.28-1.677a1.696 1.696 0 0 0-.888-.9Zm-.613 3.607a.77.77 0 0 1-.337.501 1.649 1.649 0 0 1-1.317.009.776.776 0 0 1-.343-.497 4.066 4.066 0 0 1-.105-1.02 4.136 4.136 0 0 1 .092-1.03.786.786 0 0 1 .337-.507 1.59 1.59 0 0 1 1.316-.008.79.79 0 0 1 .344.502c.078.337.113.683.105 1.03.012.343-.019.685-.092 1.02ZM52.114 2.07a2.67 2.67 0 0 0-1.128.278c-.39.191-.752.437-1.072.73l-.157-.846-1.273.008.036 5.572 1.623-.01-.024-3.78c.35-.124.646-.22.887-.286.26-.075.53-.114.8-.118l.45-.003.144-1.546-.286.001ZM22.083 7.426l-1.576-2.532a2.137 2.137 0 0 0-.172-.253 1.95 1.95 0 0 0-.304-.29.138.138 0 0 1 .042-.04 1.7 1.7 0 0 0 .328-.374l1.75-2.71c.01-.015.025-.028.024-.048-.01-.01-.021-.007-.031-.007L20.49 1.17a.078.078 0 0 0-.075.045l-.868 1.384c-.23.366-.46.732-.688 1.099a.108.108 0 0 1-.112.06c-.098-.005-.196-.001-.294-.002-.018 0-.038.006-.055-.007.002-.02.002-.039.005-.058a4.6 4.6 0 0 0 .046-.701V1.203c0-.02-.009-.032-.03-.03h-.033L16.93 1.17c-.084 0-.073-.01-.073.076v6.491c-.001.018.006.028.025.027h1.494c.083 0 .072.007.072-.071v-2.19c0-.055-.003-.11-.004-.166a3.366 3.366 0 0 0-.05-.417h.06c.104 0 .209.002.313-.002a.082.082 0 0 1 .084.05c.535.913 1.07 1.824 1.607 2.736a.104.104 0 0 0 .103.062c.554-.003 1.107-.002 1.66-.002l.069-.003-.019-.032-.188-.304ZM27.112 6.555c-.005-.08-.004-.08-.082-.08h-2.414c-.053 0-.106-.003-.159-.011a.279.279 0 0 1-.246-.209.558.558 0 0 1-.022-.15c0-.382 0-.762-.002-1.143 0-.032.007-.049.042-.044h2.504c.029.003.037-.012.034-.038V3.814c0-.089.013-.078-.076-.078h-2.44c-.07 0-.062.003-.062-.06v-.837c0-.047.004-.093.013-.14a.283.283 0 0 1 .241-.246.717.717 0 0 1 .146-.011h2.484c.024.002.035-.009.036-.033l.003-.038.03-.496c.01-.183.024-.365.034-.548.005-.085.003-.087-.082-.094-.218-.018-.437-.038-.655-.05a17.845 17.845 0 0 0-.657-.026 72.994 72.994 0 0 0-1.756-.016 1.7 1.7 0 0 0-.471.064 1.286 1.286 0 0 0-.817.655c-.099.196-.149.413-.145.633v3.875c0 .072.003.144.011.216a1.27 1.27 0 0 0 .711 1.029c.228.113.48.167.734.158.757-.005 1.515.002 2.272-.042.274-.016.548-.034.82-.053.03-.002.043-.008.04-.041-.008-.104-.012-.208-.019-.312a69.964 69.964 0 0 1-.05-.768ZM16.14 7.415l-.127-1.075c-.004-.03-.014-.04-.044-.037a13.125 13.125 0 0 1-.998.073c-.336.01-.672.02-1.008.016-.116-.001-.233-.014-.347-.039a.746.746 0 0 1-.45-.262c-.075-.1-.132-.211-.167-.33a3.324 3.324 0 0 1-.126-.773 9.113 9.113 0 0 1-.015-.749c0-.285.022-.57.065-.852.023-.158.066-.312.127-.46a.728.728 0 0 1 .518-.443 1.64 1.64 0 0 1 .397-.048c.628-.001 1.255.003 1.882.05.022.001.033-.006.036-.026l.003-.031.06-.55c.019-.177.036-.355.057-.532.004-.034-.005-.046-.04-.056a5.595 5.595 0 0 0-1.213-.21 10.783 10.783 0 0 0-.708-.02c-.24-.003-.48.01-.719.041a3.477 3.477 0 0 0-.625.14 1.912 1.912 0 0 0-.807.497c-.185.2-.33.433-.424.688a4.311 4.311 0 0 0-.24 1.096c-.031.286-.045.572-.042.86-.006.43.024.86.091 1.286.04.25.104.497.193.734.098.279.26.53.473.734.214.205.473.358.756.446.344.11.702.17 1.063.177a8.505 8.505 0 0 0 1.578-.083 6.11 6.11 0 0 0 .766-.18c.03-.008.047-.023.037-.057a.157.157 0 0 1-.003-.025Z"/>
2<path fill="#AFE229" d="M6.016 6.69a1.592 1.592 0 0 0-.614.21c-.23.132-.422.32-.56.546-.044.072-.287.539-.287.539l-.836 1.528.009.006c.038.025.08.046.123.063.127.046.26.07.395.073.505.023 1.011-.007 1.517-.003.29.009.58.002.869-.022a.886.886 0 0 0 .395-.116.962.962 0 0 0 .312-.286c.056-.083.114-.163.164-.249.24-.408.48-.816.718-1.226.075-.128.148-.257.222-.386l.112-.192a1.07 1.07 0 0 0 .153-.518l-1.304.023s-1.258-.005-1.388.01Z"/><path fill="#771BFF" d="m2.848 9.044.76-1.39.184-.352c-.124-.067-.245-.14-.367-.21-.346-.204-.706-.384-1.045-.6a.984.984 0 0 1-.244-.207c-.108-.134-.136-.294-.144-.46-.021-.409-.002-.818-.009-1.227-.003-.195 0-.39.003-.585.004-.322.153-.553.427-.713l.833-.488c.22-.13.44-.257.662-.385.05-.029.105-.052.158-.077.272-.128.519-.047.76.085l.044.028c.123.06.242.125.358.196.318.178.635.357.952.537.095.056.187.117.275.184.194.144.254.35.266.578.016.284.007.569.006.853-.001.28.004.558 0 .838.592-.003 1.259 0 1.259 0l.723-.013c-.003-.292-.007-.584-.007-.876 0-.524.015-1.048-.016-1.571-.024-.42-.135-.8-.492-1.067a5.02 5.02 0 0 0-.506-.339A400.52 400.52 0 0 0 5.94.787C5.722.664 5.513.524 5.282.423 5.255.406 5.228.388 5.2.373 4.758.126 4.305-.026 3.807.21c-.097.046-.197.087-.29.14A699.896 699.896 0 0 0 .783 1.948c-.501.294-.773.717-.778 1.31-.004.36-.009.718-.001 1.077.016.754-.017 1.508.024 2.261.016.304.07.6.269.848.127.15.279.28.448.382.622.4 1.283.734 1.92 1.11l.183.109Z"/></svg>\n',isColorInherited:!1}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/powered-by-ckeditor/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...t?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[t]}]:[],i],on:{dragstart:n.to(e=>e.preventDefault())}}]})}}class xf extends Ef{constructor(e){super(e,{balloonClass:"ck-evaluation-badge-balloon"}),(0,o.A)(this,"licenseTypeMessage",{evaluation:"For evaluation purposes only",trial:"For evaluation purposes only",development:"For development purposes only"})}_isEnabled(){const e=Sf(this.editor.config.get("licenseKey"));return Boolean(e&&this.licenseTypeMessage[e])}_createBadgeContent(){const e=Sf(this.editor.config.get("licenseKey"));return new Df(this.editor.locale,this.licenseTypeMessage[e])}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{};return{position:t.position||e.position,side:"left"===(t.side||e.side)?"right":"left",verticalOffset:e.verticalOffset,horizontalOffset:e.horizontalOffset}}}class Df extends Qd{constructor(e,t){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-evaluation-badge"],"aria-hidden":!0},children:[{tag:"span",attributes:{class:["ck","ck-evaluation-badge__label"]},children:[t]}]})}}function Sf(e){if("GPL"==e)return"GPL";const t=lr(e.split(".")[1]);return t?t.licenseType||"production":null}const If={POLITE:"polite",ASSERTIVE:"assertive"};class Of{constructor(e){(0,o.A)(this,"editor",void 0),(0,o.A)(this,"view",void 0),this.editor=e,e.once("ready",()=>{for(const e of Object.values(If))this.announce("",e)})}announce(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:If.POLITE;const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new Ff(i.locale),i.ui.view.body.add(this.view));const{politeness:n,isUnsafeHTML:s}="string"===typeof t?{politeness:t}:t;let o=this.view.regionViews.find(e=>e.politeness===n);o||(o=new Bf(i,n),this.view.regionViews.add(o)),o.announce({announcement:e,isUnsafeHTML:s})}}class Ff extends Qd{constructor(e){super(e),(0,o.A)(this,"regionViews",void 0),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class Bf extends Qd{constructor(e,t){super(e.locale),(0,o.A)(this,"politeness",void 0),(0,o.A)(this,"_domConverter",void 0),(0,o.A)(this,"_pruneAnnouncementsInterval",void 0),this.setTemplate({tag:"div",attributes:{"aria-live":t,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),e.on("destroy",()=>{null!==this._pruneAnnouncementsInterval&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)}),this.politeness=t,this._domConverter=e.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval(()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()},5e3)}announce(e){let{announcement:t,isUnsafeHTML:i}=e;if(!t.trim().length)return;const n=document.createElement("li");i?this._domConverter.setContentOf(n,t):n.innerText=t,this._listElement.appendChild(n)}get _listElement(){return this.element.querySelector("ul")}}class Mf extends Hm{constructor(e,t){super(e);const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:i.to("mouseenter")}}),this.delegate("mouseenter").to(t)}}const Rf={toggleMenusAndFocusItemsOnHover(e){e.on("menu:mouseenter",t=>{if(e.isFocusBorderEnabled||e.isOpen){if(e.isOpen)for(const i of e.menus){const e=t.path[0],n=e instanceof Mf&&e.children.first===i;i.isOpen=(t.path.includes(i)||n)&&i.isEnabled}
2t.source.focus()}})},focusCycleMenusOnArrows(e){const t="rtl"===e.locale.uiLanguageDirection;function i(t,i){const n=e.children.getIndex(t),s=t.isOpen,o=e.children.length,r=e.children.get((n+o+i)%o);t.isOpen=!1,s&&(r.isOpen=!0),r.buttonView.focus()}e.on("menu:arrowright",e=>{i(e.source,t?-1:1)}),e.on("menu:arrowleft",e=>{i(e.source,t?1:-1)})},closeMenusWhenTheBarCloses(e){e.on("change:isOpen",()=>{e.isOpen||e.menus.forEach(e=>{e.isOpen=!1})})},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on("menu:change:isOpen",(t,i,n)=>{n&&e.menus.filter(e=>t.source.parentMenuView===e.parentMenuView&&t.source!==e&&e.isOpen).forEach(e=>{e.isOpen=!1})})},closeOnClickOutside(e){Yd({emitter:e,activator:()=>e.isOpen,callback:()=>e.close(),contextElements:()=>e.children.map(e=>e.element)})},enableFocusHighlightOnInteraction(e){let t=!1;e.on("change:isOpen",(i,n,s)=>{s||(t||(e.isFocusBorderEnabled=!1),t=!1)}),e.listenTo(e.element,"keydown",()=>{t=!0},{useCapture:!0}),e.listenTo(e.element,"keyup",()=>{t=!1},{useCapture:!0}),e.listenTo(e.element,"focus",()=>{t&&(e.isFocusBorderEnabled=!0)},{useCapture:!0})}},Vf={openAndFocusPanelOnArrowDownKey(e){e.keystrokes.set("arrowdown",(t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())})},openOnArrowRightKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowleft":"arrowright";e.keystrokes.set(t,(t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&e.isEnabled&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())})},openOnButtonClick(e){e.buttonView.on("execute",()=>{e.isOpen=!0})},toggleOnButtonClick(e){e.buttonView.on("execute",()=>{e.isOpen=!e.isOpen})},openAndFocusOnEnterKeyPress(e){e.keystrokes.set("enter",(t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen=!0,e.panelView.focus(),i())})},closeOnArrowLeftKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowright":"arrowleft";e.keystrokes.set(t,(t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())})},closeOnEscKey(e){e.keystrokes.set("esc",(t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())})},closeOnParentClose(e){e.parentMenuView.on("change:isOpen",(t,i,n)=>{n||t.source!==e.parentMenuView||(e.isOpen=!1)})}},Nf={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"}),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"}),eastSouth:e=>({top:e.top,left:e.right-5,name:"es"}),eastNorth:(e,t)=>({top:e.top-t.height,left:e.right-5,name:"en"}),westSouth:(e,t)=>({top:e.top,left:e.left-t.width+5,name:"ws"}),westNorth:(e,t)=>({top:e.top-t.height,left:e.left-t.width+5,name:"wn"})},Lf=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditingEnhanced",items:["menuBar:sourceEditingEnhanced"]},{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"previewMergeFields",items:["menuBar:previewMergeFields"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:insertImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable"]},{groupId:"insertInline",items:["menuBar:link","menuBar:bookmark","menuBar:comment","menuBar:insertMergeField","menuBar:emoji"]},{groupId:"insertMinorWidgets",items:["menuBar:mediaEmbed","menuBar:insertTemplate","menuBar:specialCharacters","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]}
2,{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:multiLevelList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function jf(e){let{normalizedConfig:t,locale:i,componentFactory:n,extraItems:s}=e;const o=sn(t);return Wf(t,o,s),function(e,t){const i=t.removeItems,n=[];t.items=t.items.filter(e=>{let{menuId:t}=e;return!i.includes(t)||(n.push(t),!1)}),Hf(t.items,e=>{e.groups=e.groups.filter(e=>{let{groupId:t}=e;return!i.includes(t)||(n.push(t),!1)});for(const t of e.groups)t.items=t.items.filter(e=>{const t=Zf(e);return!i.includes(t)||(n.push(t),!1)})});for(const s of i)n.includes(s)||ps("menu-bar-item-could-not-be-removed",{menuBarConfig:e,itemName:s})}(t,o),Wf(t,o,o.addItems),function(e,t,i){Hf(t.items,n=>{for(const s of n.groups)s.items=s.items.filter(s=>{const o="string"===typeof s&&!i.has(s);return o&&!t.isUsingDefaultConfig&&ps("menu-bar-item-unavailable",{menuBarConfig:e,parentMenuConfig:sn(n),componentName:s}),!o})})}(t,o,n),Uf(t,o),function(e,t){const i=t.t,n={File:i({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:i({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:i({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:i({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:i({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:i({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:i({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:i({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:i({string:"Font",id:"MENU_BAR_MENU_FONT"})};Hf(e.items,e=>{e.label in n&&(e.label=n[e.label])})}(o,i),o}function Wf(e,t,i){const n=[];if(0!=i.length){for(const e of i){const i=Gf(e.position),s=Jf(e.position);if($f(e))if(s){const o=t.items.findIndex(e=>e.menuId===s);if(-1!=o)"before"===i?(t.items.splice(o,0,e.menu),n.push(e)):"after"===i&&(t.items.splice(o+1,0,e.menu),n.push(e));else{qf(t,e.menu,s,i)&&n.push(e)}}else"start"===i?(t.items.unshift(e.menu),n.push(e)):"end"===i&&(t.items.push(e.menu),n.push(e));else if(Kf(e))Hf(t.items,t=>{if(t.menuId===s)"start"===i?(t.groups.unshift(e.group),n.push(e)):"end"===i&&(t.groups.push(e.group),n.push(e));else{const o=t.groups.findIndex(e=>e.groupId===s);-1!==o&&("before"===i?(t.groups.splice(o,0,e.group),n.push(e)):"after"===i&&(t.groups.splice(o+1,0,e.group),n.push(e)))}});else{qf(t,e.item,s,i)&&n.push(e)}}for(const t of i)n.includes(t)||ps("menu-bar-item-could-not-be-added",{menuBarConfig:e,addedItemConfig:t})}}function qf(e,t,i,n){let s=!1;return Hf(e.items,e=>{for(const{groupId:o,items:r}of e.groups){if(s)return;if(o===i)"start"===n?(r.unshift(t),s=!0):"end"===n&&(r.push(t),s=!0);else{const e=r.findIndex(e=>Zf(e)===i);-1!==e&&("before"===n?(r.splice(e,0,t),s=!0):"after"===n&&(r.splice(e+1,0,t),s=!0))}}}),s}function Uf(e,t){const i=t.isUsingDefaultConfig;let n=!1;t.items=t.items.filter(t=>!!t.groups.length||(zf(e,t,i),!1)),t.items.length?(Hf(t.items,t=>{t.groups=t.groups.filter(e=>!!e.items.length||(n=!0,!1));for(const s of t.groups)s.items=s.items.filter(t=>!(Qf(t)&&!t.groups.length)||(zf(e,t,i),n=!0,!1))}),n&&Uf(e,t)):zf(e,e,i)}function zf(e,t,i){i||ps("menu-bar-menu-empty",{menuBarConfig:e,emptyMenuConfig:t})}function Hf(e,t){if(Array.isArray(e))for(const n of e)i(n);function i(e){t(e);for(const t of e.groups)for(const e of t.items)Qf(e)&&i(e)}}function $f(e){return"object"===typeof e&&"menu"in e}function Kf(e){return"object"===typeof e&&"group"in e}function Gf(e){return e.startsWith("start")?"start":e.startsWith("end")?"end":e.startsWith("after")?"after":"before"}function Jf(e){const t=e.match(/^[^:]+:(.+)/);return t?t[1]:null}function Zf(e){return"string"===typeof e?e:e.menuId}function Qf(e){return"object"===typeof e&&"menuId"in e}class Yf extends(Ns()){constructor(e){super(),(0,o.A)(this,"editor",void 0),(0,o.A)(this,"componentFactory",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"tooltipManager",void 0),(0,o.A)(this,"poweredBy",void 0),(0,o.A)(this,"evaluationBadge",void 0),(0,o.A)(this,"ariaLiveAnnouncer",void 0),(0,o.A)(this,"isReady",!1),(0,o.A)(this,"_editableElementsMap",new Map),(0,o.A)(this,"_focusableToolbarDefinitions",[]),(0,o.A)(this,"_extraMenuBarElements",[]),(0,o.A)(this,"_lastFocusedForeignElement",null);const t=e.editing.view;this.editor=e,this.componentFactory=new wf(e),this.focusTracker=new er,this.tooltipManager=new yf(e),this.poweredBy=new Pf(e),this.evaluationBadge=new xf(e),this.ariaLiveAnnouncer=new Of(e),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.once("ready",()=>{this._bindBodyCollectionWithFocusTracker(),this.isReady=!0}),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking()}
2get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy(),this.evaluationBadge.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[]}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const i=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?i():this.once("ready",i)}removeEditableElement(e){const t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.isRendered?(this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)):e.once("render",()=>{this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)}),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}extendMenuBar(e){this._extraMenuBarElements.push(e)}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_initMenuBar(e){const t=e.element;this.focusTracker.add(t),this.editor.keystrokes.listenTo(t);const i=function(e){let t;return t="items"in e&&e.items?(0,r.A)({items:e.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1},e):(0,r.A)({items:sn(Lf),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0},e),t}(this.editor.config.get("menuBar")||{});e.fillFromConfig(i,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set("Esc",(e,i)=>{t.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),i())}),this.editor.keystrokes.set("Alt+F9",(i,n)=>{t.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),e.isFocusBorderEnabled=!0,e.focus(),n())})}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:i}):{top:0}}_initFocusTracking(){const e=this.editor;let t;e.keystrokes.set("Alt+F10",(e,i)=>{this._saveLastFocusedForeignElement();const n=this._getCurrentFocusedToolbarDefinition();n&&t||(t=this._getFocusableCandidateToolbarDefinitions());for(let s=0;s<t.length;s++){const e=t.shift();if(t.push(e),e!==n&&this._focusFocusableCandidateToolbar(e)){n&&n.options.afterBlur&&n.options.afterBlur();break}}i()}),e.keystrokes.set("Esc",(t,i)=>{const n=this._getCurrentFocusedToolbarDefinition();n&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):e.editing.view.focus(),n.options.afterBlur&&n.options.afterBlur(),i())})}_saveLastFocusedForeignElement(){const e=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(e)&&!Array.from(this.editor.editing.view.domRoots.values()).includes(e)&&(this._lastFocusedForeignElement=e)}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:n}=t;(ko(i.element)||n.beforeFocus)&&e.push(t)}return e.sort((e,t)=>Xf(e)-Xf(t)),e}_getCurrentFocusedToolbarDefinition(){for(const e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){const{toolbarView:t,options:{beforeFocus:i}}=e;return i&&i(),!!ko(t.element)&&(t.focus(),!0)}_handleScrollToTheSelection(e,t){const i=(0,r.A)({top:0,bottom:0,left:0,right:0},this.viewportOffset);t.viewportOffset.top+=i.top,t.viewportOffset.bottom+=i.bottom,t.viewportOffset.left+=i.left,t.viewportOffset.right+=i.right}_bindBodyCollectionWithFocusTracker(){const e=this.view.body;for(const t of e)this.focusTracker.add(t.element);e.on("add",(e,t)=>{this.focusTracker.add(t.element)}),e.on("remove",(e,t)=>{this.focusTracker.remove(t.element)})}}function Xf(e){const{toolbarView:t,options:i}=e;let n=10;return ko(t.element)&&n--,i.isContextual&&n--,n}class eg extends Qd{constructor(e){super(e),(0,o.A)(this,"body",void 0),(0,o.A)(this,"menuBarView",void 0),this.body=new Sm(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class tg extends eg{constructor(e){super(e),(0,o.A)(this,"top",void 0),(0,o.A)(this,"main",void 0),(0,o.A)(this,"_voiceLabelView",void 0),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createV
2oiceLabel(),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 Cm;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class ig extends Qd{constructor(e,t,i){super(e),(0,o.A)(this,"name",null),(0,o.A)(this,"_editingView",void 0),(0,o.A)(this,"_editableElement",void 0),(0,o.A)(this,"_hasExternalElement",void 0),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),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()}get hasExternalElement(){return this._hasExternalElement}_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)}}class ng extends ig{constructor(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(e,t,i),(0,o.A)(this,"_options",void 0),this._options=n,this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView;e.change(t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this.getEditableAriaLabel(),i)})}getEditableAriaLabel(){const e=this.locale.t,t=this._options.label,i=this._editableElement,n=this.name;if("string"==typeof t)return t;if("object"===typeof t)return t[n];if("function"===typeof t)return t(this);if(i){const e=i.getAttribute("aria-label");if(e)return e}return e("Rich Text Editor. Editing area: %0",n)}}class sg extends xh{static get pluginName(){return"Notification"}static get isOfficialPlugin(){return!0}init(){this.on("show:warning",(e,t)=>{window.alert(t.message)},{priority:"lowest"})}showSuccess(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=e.namespace?"show:".concat(e.type,":").concat(e.namespace):"show:".concat(e.type);this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class og extends(Ns()){constructor(e,t){super(),t&>(this,t),e&&this.set(e)}}const rg=bo("px");class ag extends yh{static get pluginName(){return"ContextualBalloon"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"positionLimiter",void 0),(0,o.A)(this,"visibleStack",void 0),(0,o.A)(this,"_viewToStack",new Map),(0,o.A)(this,"_idToStack",new Map),(0,o.A)(this,"_view",null),(0,o.A)(this,"_rotatorView",null),(0,o.A)(this,"_fakePanelsView",null),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.decorate("getPositionOptions"),this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new gs("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 gs("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.getPositionOptions()),this._fakePanelsView.updatePosition()}getPositionOptions(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:this.editor.ui.viewportOffset})),e}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new gs("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Qm(this.editor.locale),this.editor.ui.view.body.add(this._view),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(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 lg(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 cg(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(e){let{view:t,balloonClassName:i="",withArrow:n=!0,singleViewMode:s=!1}=e;this.view.class=i,this.view.withArrow=n,this._rotatorView.showView(t),this.visibleView=t,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),s&&(this._singleViewMode=!0)}}class lg extends Qd{constructor(e){super(e),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"buttonPrevView",void 0),(0,o.A)(this,"buttonNextView",void 0),(0,o.A)(this,"content",void 0);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new er,this.buttonPrevView=this._createButtonView(t("Previous"),Jh),this.buttonNextView=this._createButtonView(t("Next"),Zh),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)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new nm(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class cg extends Qd{constructor(e,t){super(e),(0,o.A)(this,"content",void 0),(0,o.A)(this,"_balloonPanelView",void 0);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=>
2e?"":"ck-hidden")],style:{top:i.to("top",rg),left:i.to("left",rg),width:i.to("width",rg),height:i.to("height",rg)}},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 Qd;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 uo(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}const ug=bo("px");class hg extends Qd{constructor(e){super(e),(0,o.A)(this,"content",void 0),(0,o.A)(this,"contentPanelElement",void 0),(0,o.A)(this,"_contentPanelPlaceholder",void 0);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("_isStickyToTheBottomOfLimiter",!1),this.set("_stickyTopOffset",null),this.set("_stickyBottomOffset",null),this.content=this.createCollection(),this._contentPanelPlaceholder=new Dd({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",e=>e?"block":"none"),height:t.to("isSticky",e=>e?ug(this._contentPanelRect.height):null)}}}).render(),this.contentPanelElement=new Dd({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheBottomOfLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",e=>e?ug(this._contentPanelPlaceholder.getBoundingClientRect().width):null),top:t.to("_stickyTopOffset",e=>e?ug(e):e),bottom:t.to("_stickyBottomOffset",e=>e?ug(e):e),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this.contentPanelElement]})}render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(Jn.document,"scroll",()=>{this.checkIfShouldBeSticky()},{useCapture:!0}),this.listenTo(this,"change:isActive",()=>{this.checkIfShouldBeSticky()})}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const e=new uo(this.limiterElement);let t=e.getVisible();if(t){const e=new uo(Jn.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,t=t.getIntersection(e)}if(t&&e.top<t.top){const i=t.top;if(i+this._contentPanelRect.height+this.limiterBottomOffset>t.bottom){const i=Math.max(e.bottom-t.bottom,0)+this.limiterBottomOffset;e.bottom-i>e.top+this._contentPanelRect.height?this._stickToBottomOfLimiter(i):this._unstick()}else this._contentPanelRect.height+this.limiterBottomOffset<e.height?this._stickToTopOfAncestors(i):this._unstick()}else this._unstick()}_stickToTopOfAncestors(e){this.isSticky=!0,this._isStickyToTheBottomOfLimiter=!1,this._stickyTopOffset=e,this._stickyBottomOffset=null,this._marginLeft=ug(-Jn.window.scrollX)}_stickToBottomOfLimiter(e){this.isSticky=!0,this._isStickyToTheBottomOfLimiter=!0,this._stickyTopOffset=null,this._stickyBottomOffset=e,this._marginLeft=ug(-Jn.window.scrollX)}_unstick(){this.isSticky=!1,this._isStickyToTheBottomOfLimiter=!1,this._stickyTopOffset=null,this._stickyBottomOffset=null,this._marginLeft=null}get _contentPanelRect(){return new uo(this.contentPanelElement)}}class dg extends Am{constructor(e){super(e),(0,o.A)(this,"arrowView",void 0);const t=this.bindTemplate;this.set({withText:!0,role:"menuitem"}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__button"],"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",e=>String(e)),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new tm;return e.content=Rm,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}}class mg extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0);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-menu-bar__menu__panel",t.to("position",e=>"ck-menu-bar__menu__panel_position_".concat(e)),t.if("isVisible","ck-hidden",e=>!e)],tabindex:"-1"},children:this.children,on:{selectstart:t.to(e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()})}})}focus(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.children.length&&(1===e?this.children.first.focus():this.children.last.focus())}}class fg extends Qd{constructor(e){super(e),(0,o.A)(this,"buttonView",void 0),(0,o.A)(this,"panelView",void 0),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0);const t=this.bindTemplate;this.buttonView=new dg(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new mg(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new sr,this.focusTracker=new er,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",t.to("class"),t.if("isEnabled","ck-disabled",e=>!e),t.if("parentMenuView","ck-menu-bar__menu_top-level",e=>!e)]},children:[this.buttonView,this.panelView]})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),Vf.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Vf.openOnButtonClick(this),Vf.openOnArrowRightKey(this),Vf.closeOnArrowLeftKey(this),Vf.openAndFocusOnEnterKeyPress(this),Vf.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Vf.openAndFocusPanelOnArrowDownKey(this),Vf.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",(e,t)=>{this.fire("arrowright"),t()}),this.keystrokes.set("arrowleft",(e,t)=>{this.fire("arrowleft"),t()})}_repositionPanelOnOpen(){this.on("change:isOpen",(e,t,i)=>{if(!i)return;const n=fg._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=n?n.name:this._defaultMenuPositionName})}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:n,westSouth:s,eastSouth:o,westNorth:r,eastNorth:a}=Nf;return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?[o,a,s,r]:[e,t,i,n]:this.parentMenuView?[s,r,o,a]:[t,e,n,i]}get _defaultMenuPositionName(){return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?"es":"se":this.parentMenuView?"ws":"sw"}}(0,o.A)(fg,"_getOptimalPosition",Eo);class gg extends Gm{constructor(e){super(e),this.role="menu",this.items.on("change",this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){const e=Array.from(this.items).some(e=>{const t=pg(e);return t&&t.isToggleable});
2this.items.forEach(t=>{const i=pg(t);i&&(i.hasCheckSpace=e)})}}function pg(e){return e instanceof Hm?e.children.map(e=>function(e){return"object"===typeof e&&"buttonView"in e&&e.buttonView instanceof nm}(e)?e.buttonView:e).find(e=>e instanceof Am):null}class _g extends Fm{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const wg=["mouseenter","arrowleft","arrowright","change:isOpen"];class bg extends Qd{constructor(e){super(e),(0,o.A)(this,"children",void 0),(0,o.A)(this,"menus",[]);const t=e.t,i=this.bindTemplate;this.set({isOpen:!1,isFocusBorderEnabled:!1}),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar",i.if("isFocusBorderEnabled","ck-menu-bar_focus-border-enabled")],"aria-label":t("Editor menu bar"),role:"menubar"},children:this.children})}fillFromConfig(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const n=jf({normalizedConfig:e,locale:this.locale,componentFactory:t,extraItems:i}).items.map(e=>this._createMenu({componentFactory:t,menuDefinition:e}));this.children.addMany(n)}render(){super.render(),Rf.toggleMenusAndFocusItemsOnHover(this),Rf.closeMenusWhenTheBarCloses(this),Rf.closeMenuWhenAnotherOnTheSameLevelOpens(this),Rf.focusCycleMenusOnArrows(this),Rf.closeOnClickOutside(this),Rf.enableFocusHighlightOnInteraction(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const e of this.children)e.isOpen=!1}registerMenu(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t?(e.delegate(...wg).to(t),e.parentMenuView=t):e.delegate(...wg).to(this,e=>"menu:"+e),e._attachBehaviors(),this.menus.push(e)}_createMenu(e){let{componentFactory:t,menuDefinition:i,parentMenuView:n}=e;const s=this.locale,o=new fg(s);return this.registerMenu(o,n),o.buttonView.set({label:i.label}),o.once("change:isOpen",()=>{const e=new gg(s);e.ariaLabel=i.label,o.panelView.children.add(e),e.items.addMany(this._createMenuItems({menuDefinition:i,parentMenuView:o,componentFactory:t}))}),o}_createMenuItems(e){let{menuDefinition:t,parentMenuView:i,componentFactory:n}=e;const s=this.locale,o=[];for(const r of t.groups){for(const e of r.items){const t=new Mf(s,i);if(ie(e))t.children.add(this._createMenu({componentFactory:n,menuDefinition:e,parentMenuView:i}));else{const s=this._createMenuItemContentFromFactory({componentName:e,componentFactory:n,parentMenuView:i});if(!s)continue;t.children.add(s)}o.push(t)}r!==t.groups[t.groups.length-1]&&o.push(new $m(s))}return o}_createMenuItemContentFromFactory(e){let{componentName:t,parentMenuView:i,componentFactory:n}=e;const s=n.create(t);return s instanceof fg||s instanceof Em||s instanceof _g?(this._registerMenuTree(s,i),s.on("execute",()=>{this.close()}),s):(ps("menu-bar-component-unsupported",{componentName:t,componentView:s}),null)}_registerMenuTree(e,t){if(!(e instanceof fg))return void e.delegate("mouseenter").to(t);this.registerMenu(e,t);const i=e.panelView.children.filter(e=>e instanceof gg)[0];if(!i)return void e.delegate("mouseenter").to(t);const n=i.items.filter(e=>e instanceof Hm);for(const s of n)this._registerMenuTree(s.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",(t,i,n)=>{clearTimeout(e),n?this.isOpen=!0:e=setTimeout(()=>{this.isOpen=Array.from(this.children).some(e=>e.isOpen)},0)})}}class vg{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;(0,o.A)(this,"model",void 0),(0,o.A)(this,"limit",void 0),(0,o.A)(this,"_isLocked",void 0),(0,o.A)(this,"_size",void 0),(0,o.A)(this,"_batch",null),(0,o.A)(this,"_changeCallback",void 0),(0,o.A)(this,"_selectionChangeCallback",void 0),this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&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({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("
2change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isLocked&&!e||(this._batch=null,this._size=0)}}class yg extends kh{constructor(e,t){super(e),(0,o.A)(this,"_buffer",void 0),this._buffer=new vg(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.editor.model,i=t.document,n=e.text||"",s=n.length;let o=i.selection;if(e.selection?o=e.selection:e.range&&(o=t.createSelection(e.range)),!t.canEditAt(o))return;const r=e.resultRange;t.enqueueChange(this._buffer.batch,e=>{this._buffer.lock();const a=Array.from(i.selection.getAttributes());t.deleteContent(o),n&&t.insertContent(e.createText(n,a),o),r?e.setSelection(r):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(s)})}}const Ag=["insertText","insertReplacementText"],kg=[...Ag,"insertCompositionText"];class Eg extends Qa{constructor(e){super(e),(0,o.A)(this,"focusObserver",void 0),this.focusObserver=e.getObserver(sl);const t=Yn.isAndroid?kg:Ag,i=e.document;i.on("beforeinput",(n,s)=>{if(!this.isEnabled)return;const{data:o,targetRanges:r,inputType:a,domEvent:l}=s;if(!t.includes(a))return;this.focusObserver.flush();const c=new us(i,"insertText");i.fire(c,new Ya(e,l,{text:o,selection:e.createSelection(r)})),c.stop.called&&n.stop()}),Yn.isAndroid||i.on("compositionend",(t,n)=>{let{data:s,domEvent:o}=n;this.isEnabled&&s&&i.fire("insertText",new Ya(e,o,{text:s}))},{priority:"lowest"})}observe(){}stopObserving(){}}class Cg extends yh{constructor(){super(...arguments),(0,o.A)(this,"_compositionQueue",void 0)}static get pluginName(){return"Input"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.editing.mapper,s=t.document.selection;this._compositionQueue=new Pg(e),i.addObserver(Eg);const o=new yg(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(i.document,"insertText",(o,r)=>{i.document.isComposing||r.preventDefault(),Yn.isAndroid&&i.document.isComposing&&this._compositionQueue.flush("next beforeinput");const{text:a,selection:l}=r;let c;c=l?Array.from(l.getRanges()).map(e=>n.toModelRange(e)):Array.from(s.getRanges());let u=a;if(Yn.isAndroid){const e=Array.from(c[0].getItems()).reduce((e,t)=>e+(t.is("$textProxy")?t.data:""),"");if(e&&(e.length<=u.length?u.startsWith(e)&&(u=u.substring(e.length),c[0].start=c[0].start.getShiftedBy(e.length)):e.startsWith(u)&&(c[0].start=c[0].start.getShiftedBy(u.length),u="")),0==u.length&&c[0].isCollapsed)return}const h={text:u,selection:t.createSelection(c)};Yn.isAndroid&&i.document.isComposing?this._compositionQueue.push(h):(e.execute("insertText",h),i.scrollToTheSelection())}),Yn.isAndroid?this.listenTo(i.document,"keydown",(e,n)=>{!s.isCollapsed&&229==n.keyCode&&i.document.isComposing&&Tg(t,o)}):this.listenTo(i.document,"compositionstart",()=>{s.isCollapsed||Tg(t,o)}),Yn.isAndroid?(this.listenTo(i.document,"mutations",(e,t)=>{let{mutations:s}=t;if(i.document.isComposing)for(const{node:i}of s){const e=xg(i,n),t=n.toModelElement(e);if(this._compositionQueue.isComposedElement(t))return void this._compositionQueue.flush("mutations")}}),this.listenTo(i.document,"compositionend",()=>{this._compositionQueue.flush("composition end")}),this.listenTo(i.document,"compositionend",()=>{const e=[];for(const t of this._compositionQueue.flushComposedElements()){const i=n.toViewElement(t);i&&e.push({type:"children",node:i})}e.length&&i.document.fire("mutations",{mutations:e})},{priority:"lowest"})):this.listenTo(i.document,"compositionend",()=>{i.document.fire("mutations",{mutations:[]})},{priority:"lowest"})}destroy(){super.destroy(),this._compositionQueue.destroy()}}class Pg{constructor(e){(0,o.A)(this,"editor",void 0),(0,o.A)(this,"flushDebounced",In(()=>this.flush("timeout"),50)),(0,o.A)(this,"_queue",[]),(0,o.A)(this,"_compositionElements",new Set),this.editor=e}destroy(){for(this.flushDebounced.cancel(),this._compositionElements.clear();this._queue.length;)this.shift()}get length(){return this._queue.length}push(e){const t={text:e.text};
2if(e.selection){t.selectionRanges=[];for(const i of e.selection.getRanges())t.selectionRanges.push(Ll.fromRange(i)),this._compositionElements.add(i.start.parent)}this._queue.push(t),this.flushDebounced()}shift(){const e=this._queue.shift(),t={text:e.text};if(e.selectionRanges){const i=e.selectionRanges.map(e=>function(e){const t=e.toRange();if(e.detach(),"$graveyard"==t.root.rootName)return null;return t}(e)).filter(e=>!!e);i.length&&(t.selection=this.editor.model.createSelection(i))}return t}flush(e){const t=this.editor,i=t.model,n=t.editing.view;if(this.flushDebounced.cancel(),!this._queue.length)return;const s=t.commands.get("insertText").buffer;i.enqueueChange(s.batch,()=>{for(s.lock();this._queue.length;){const e=this.shift();t.execute("insertText",e)}s.unlock()}),n.scrollToTheSelection()}isComposedElement(e){return this._compositionElements.has(e)}flushComposedElements(){const e=Array.from(this._compositionElements);return this._compositionElements.clear(),e}}function Tg(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,()=>{e.deleteContent(e.document.selection)}),i.unlock()}function xg(e,t){let i=e.is("$text")?e.parent:e;for(;!t.toModelElement(i);)i=i.parent;return i}class Dg extends kh{constructor(e,t){super(e),(0,o.A)(this,"direction",void 0),(0,o.A)(this,"_buffer",void 0),this.direction=t,this._buffer=new vg(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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);if(!t.canEditAt(s))return;const o=e.sequence||1,r=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),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;
2s.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||!s.is("element","paragraph")}_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))}}const Sg="word",Ig="selection",Og="backward",Fg="forward",Bg={deleteContent:{unit:Ig,direction:Og},deleteContentBackward:{unit:"codePoint",direction:Og},deleteWordBackward:{unit:Sg,direction:Og},deleteHardLineBackward:{unit:Ig,direction:Og},deleteSoftLineBackward:{unit:Ig,direction:Og},deleteContentForward:{unit:"character",direction:Fg},deleteWordForward:{unit:Sg,direction:Fg},deleteHardLineForward:{unit:Ig,direction:Fg},deleteSoftLineForward:{unit:Ig,direction:Fg}};class Mg extends Qa{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",()=>{i++}),t.on("keyup",()=>{i=0}),t.on("beforeinput",(n,s)=>{if(!this.isEnabled)return;const{targetRanges:o,domEvent:r,inputType:a}=s,l=Bg[a];if(!l)return;const c={direction:l.direction,unit:l.unit,sequence:i};c.unit==Ig&&(c.selectionToRemove=e.createSelection(o[0])),"deleteContentBackward"===a&&(Yn.isAndroid&&(c.sequence=1),function(e){if(1!=e.length||e[0].isCollapsed)return!1;const t=e[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let i=0;for(const{nextPosition:n,item:s}of t){if(n.parent.is("$text")){const e=n.parent.data,t=n.offset;if(cr(e,t)||ur(e,t)||dr(e,t))continue;i++}else(s.is("containerElement")||s.is("emptyElement"))&&i++;if(i>1)return!0}return!1}(o)&&(c.unit=Ig,c.selectionToRemove=e.createSelection(o)));const u=new Zr(t,"delete",o[0]);t.fire(u,new Ya(e,r,c)),u.stop.called&&n.stop()}),Yn.isBlink&&function(e){const t=e.view,i=t.document;let n=null,s=!1;function o(e){return e==jo.backspace||e==jo.delete}function r(e){return e==jo.backspace?Og:Fg}i.on("keydown",(e,t)=>{let{keyCode:i}=t;n=i,s=!1}),i.on("keyup",(a,l)=>{let{keyCode:c,domEvent:u}=l;const h=i.selection,d=e.isEnabled&&c==n&&o(c)&&!h.isCollapsed&&!s;if(n=null,d){const e=h.getFirstRange(),n=new Zr(i,"delete",e),s={unit:Ig,direction:r(c),selectionToRemove:h};i.fire(n,new Ya(t,u,s))}}),i.on("beforeinput",(e,t)=>{let{inputType:i}=t;const a=Bg[i];o(n)&&a&&a.direction==r(n)&&(s=!0)},{priority:"high"}),i.on("beforeinput",(e,t)=>{let{inputType:i,data:s}=t;n==jo.delete&&"insertText"==i&&"\x7f"==s&&e.stop()},{priority:"high"})}(this)}observe(){}stopObserving(){}}class Rg extends yh{constructor(){super(...arguments),(0,o.A)(this,"_undoOnBackspace",void 0)}static get pluginName(){return"Delete"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(Mg),this._undoOnBackspace=!1;const s=new Dg(e,"forward");e.commands.add("deleteForward",s),e.commands.add("forwardDelete",s),e.commands.add("delete",new Dg(e,"backward")),this.listenTo(i,"delete",(n,s)=>{i.isComposing||s.preventDefault();const{direction:o,sequence:r,selectionToRemove:a,unit:l}=s,c="forward"===o?"deleteForward":"delete",u={sequence:r};if("selection"==l){const t=Array.from(a.getRanges()).map(t=>e.editing.mapper.toModelRange(t));u.selection=e.model.createSelection(t)}else u.unit=l;e.execute(c,u),t.scrollToTheSelection()},{priority:"low"}),this.listenTo(i,"keydown",(t,s)=>{if(i.isComposing||s.keyCode!=jo.backspace||!n.selection.isCollapsed)return;const o=e.model.schema.getLimitElement(n.selection);e.model.createPositionAt(o,0).isTouching(n.selection.getFirstPosition())&&s.preventDefault()}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",(t,i)=>
2{this._undoOnBackspace&&"backward"==i.direction&&1==i.sequence&&"codePoint"==i.unit&&(this._undoOnBackspace=!1,e.execute("undo"),i.preventDefault(),t.stop())},{context:"$capture"}),this.listenTo(n,"change",()=>{this._undoOnBackspace=!1}))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Vg extends yh{static get requires(){return[Cg,Rg]}static get pluginName(){return"Typing"}static get isOfficialPlugin(){return!0}}function Ng(e,t){let i=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce((e,n)=>{let{item:s}=n;return s.is("$text")||s.is("$textProxy")?e+s.data:(i=t.createPositionAfter(s),"")},""),range:t.createRange(i,e.end)}}class Lg extends(Ns()){constructor(e,t){super(),(0,o.A)(this,"model",void 0),(0,o.A)(this,"testCallback",void 0),(0,o.A)(this,"_hasMatch",void 0),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()}get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",(t,i)=>{let{directChange:n}=i;n&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))}),this.listenTo(e,"change:data",(e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})})}_evaluateTextBeforeSelection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.model,n=i.document.selection,s=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:o,range:r}=Ng(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:".concat(e),i)}}}class jg extends yh{static get pluginName(){return"TwoStepCaretMovement"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"attributes",void 0),(0,o.A)(this,"_overrideUid",void 0),(0,o.A)(this,"_isNextGravityRestorationSkipped",!1),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==jo.arrowright,o=t.keyCode==jo.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.listenTo(s,"change:range",(e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&$g(s.getFirstPosition(),this.attributes)||this._restoreGravity())}),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return!this._isGravityOverridden&&((!s.isAtStart||!Wg(n,t))&&(!!$g(s,t)&&(zg(e),Wg(n,t)&&$g(s,t,!0)?Ug(i,t):this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return this._isGravityOverridden?(zg(e),this._restoreGravity(),$g(s,t,!0)?Ug(i,t):qg(i,t,s),!0):s.isAtStart?!!Wg(n,t)&&(zg(e),qg(i,t,s),!0):!Wg(n,t)&&$g(s,t,!0)?(zg(e),qg(i,t,s),!0):!!Hg(s,t)&&(s.isAtEnd&&!Wg(n,t)&&$g(s,t)?(zg(e),qg(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view.document;e.editing.view.addObserver(ch),e.editing.view.addObserver(uh);let s=!1,o=!1;this.listenTo(n,"touchstart",()=>{o=!1,s=!0}),this.listenTo(n,"mousedown",()=>{o=!0}),this.listenTo(n,"selectionChange",()=>{const e=this.attributes;if(!o&&!s)return;if(o=!1,s=!1,!i.isCollapsed)return;if(!Wg(i,e))return;const n=i.getFirstPosition();$g(n,e)&&(n.isAtStart||$g(n,e,!0)?Ug(t,e):this._isGravityOverridden||this._overrideGravity())})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",()=>{const n=t.getFirstPosition();Wg(t,i)&&$g(n,i)&&Ug(e,i)},{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let s=!1,o=!1;this.listenTo(n.document,"delete",(e,t)=>{s="backward"===t.direction},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{if(!s)return;const e=i.getFirstPosition();o=Wg(i,this.attributes)&&!Hg(e,this.attributes)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{s&&(s=!1,o||e.model.enqueueChange(()=>{const e=i.getFirstPosition();Wg(i,this.attributes)&&$g(e,this.attributes)&&(e.isAtStart||$g(e,this.attributes,!0)?Ug(t,this.attributes):this._isGravityOverridden||this._overrideGravity())}))},{priority:"low"})}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 Wg(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function qg(e,t,i){const n=i.nodeBefore;e.change(i=>
2{if(n){const t=[],s=e.schema.isObject(n)&&e.schema.isInline(n);for(const[i,o]of n.getAttributes())!e.schema.checkAttribute("$text",i)||s&&!1===e.schema.getAttributeProperties(i).copyFromObject||t.push([i,o]);i.setSelectionAttribute(t)}else i.removeSelectionAttribute(t)})}function Ug(e,t){e.change(e=>{e.removeSelectionAttribute(t)})}function zg(e){e.preventDefault()}function Hg(e,t){return $g(e.getShiftedBy(-1),t)}function $g(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{nodeBefore:n,nodeAfter:s}=e;for(const o of t){const e=n?n.getAttribute(o):void 0,t=s?s.getAttribute(o):void 0;if((!i||void 0!==e&&void 0!==t)&&t!==e)return!0}return!1}const Kg={copyright:{from:"(c)",to:"\xa9"},registeredTrademark:{from:"(r)",to:"\xae"},trademark:{from:"(tm)",to:"\u2122"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"\xbd",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"\u2153",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"\u2154",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"\xbc",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"\xbe",null]},lessThanOrEqual:{from:"<=",to:"\u2264"},greaterThanOrEqual:{from:">=",to:"\u2265"},notEqual:{from:"!=",to:"\u2260"},arrowLeft:{from:"<-",to:"\u2190"},arrowRight:{from:"->",to:"\u2192"},horizontalEllipsis:{from:"...",to:"\u2026"},enDash:{from:/(^| )(--)( )$/,to:[null,"\u2013",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"\u2014",null]},quotesPrimary:{from:Xg('"'),to:[null,"\u201c",null,"\u201d"]},quotesSecondary:{from:Xg("'"),to:[null,"\u2018",null,"\u2019"]},quotesPrimaryEnGb:{from:Xg("'"),to:[null,"\u2018",null,"\u2019"]},quotesSecondaryEnGb:{from:Xg('"'),to:[null,"\u201c",null,"\u201d"]},quotesPrimaryPl:{from:Xg('"'),to:[null,"\u201e",null,"\u201d"]},quotesSecondaryPl:{from:Xg("'"),to:[null,"\u201a",null,"\u2019"]}},Gg={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},Jg=["symbols","mathematical","typography","quotes"];function Zg(e){return"string"==typeof e?new RegExp("(".concat((t=Ft(t=e))&&Vn.test(t)?t.replace(Rn,"\\$&"):t,")$")):e;var t}function Qg(e){return"string"==typeof e?()=>[e]:e instanceof Array?()=>e:e}function Yg(e){return(e.textNode?e.textNode:e.nodeAfter).getAttributes()}function Xg(e){return new RegExp("(^|\\s)(".concat(e,")([^").concat(e,"]*)(").concat(e,")$"))}function ep(e,t,i,n){return n.createRange(tp(e,t,i,!0,n),tp(e,t,i,!1,n))}function tp(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}function ip(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=ep(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"})})}function np(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=Xo(e.model.document.selection.getRanges());if(!l.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const c=Array.from(e.model.document.differ.getChanges()),u=c[0];if(1!=c.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const h=u.position.parent;if(h.is("element","codeBlock"))return;if(h.is("element","listItem")&&"function"!==typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(o&&!0===o.value)return;const d=h.getChild(0),m=e.model.createRangeOn(d);if(!m.containsRange(l)&&!l.end.isEqual(m.end))return;const f=i.exec(d.data.substr(0,l.end.offset));f&&e.model.enqueueChange(t=>{const i=t.createPositionAt(h,0),n=t.createPositionAt(h,f[0].length),o=new Ll(i,n);if(!1!==s({match:f})){t.remove(o);const i=e.model.document.selection.getFirstRange(),n=t.createRangeIn(h);!h.isEmpty||n.isEqual(i)||n.containsRange(i,!0)||t.remove(h)}o.detach(),e.model.enqueueChange(()=>{e.plugins.get("Delete").requestUndoOnBackspace()})})})}function sp(e,t,i,n){let s,o;
2i 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(s.isUndo||!s.isLocal||!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 u=a.focus,h=u.parent,{text:d,range:m}=function(e,t){let i=e.start;const n=Array.from(e.getItems()).reduce((e,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(i=t.createPositionAfter(n),""):e+n.data,"");return{text:n,range:t.createRange(i,e.end)}}(r.createRange(r.createPositionAt(h,0),u),r),f=o(d),g=op(m.start,f.format,r),p=op(m.start,f.remove,r);g.length&&p.length&&r.enqueueChange(t=>{if(!1!==n(t,g)){for(const e of p.reverse())t.remove(e);r.enqueueChange(()=>{e.plugins.get("Delete").requestUndoOnBackspace()})}})})}function op(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 rp(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)}}class ap extends kh{constructor(e,t){super(e),(0,o.A)(this,"attributeKey",void 0),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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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 n of i.getRanges())for(const e of n.getItems())if(t.checkAttribute(e,this.attributeKey))return e.hasAttribute(this.attributeKey);return!1}}const lp="bold";class cp extends yh{static get pluginName(){return"BoldEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:lp}),e.model.schema.setAttributeProperties(lp,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:lp,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(lp,new ap(e,lp)),e.keystrokes.set("CTRL+B",lp),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function up(e){let{editor:t,commandName:i,plugin:n,icon:s,label:o,keystroke:r}=e;return e=>{const a=t.commands.get(i),l=new e(t.locale);return l.set({label:o,icon:s,keystroke:r,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),l.bind("isOn").to(a,"value"),l instanceof Em?l.set({role:"menuitemcheckbox"}):l.set({tooltip:!0}),n.listenTo(l,"execute",()=>{t.execute(i),t.editing.view.focus()}),l}}const hp="bold";class dp extends yh{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=up({editor:e,commandName:hp,plugin:this,icon:Uh,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(hp,()=>i(nm)),e.ui.componentFactory.add("menuBar:"+hp,()=>i(Em))}}const mp="code";class fp extends yh{static get pluginName(){return"CodeEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[jg]}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:mp}),e.model.schema.setAttributeProperties(mp,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:mp,view:"code"}),e.commands.add(mp,new ap(e,mp)),e.plugins.get(jg).registerAttribute(mp),ip(e,mp,"code","ck-code_selected"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}const gp="code";class pp extends yh{static get pluginName(){return"CodeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=up({editor:e,commandName:gp,plugin:this,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>',label:t("Code")});e.ui.componentFactory.add(gp,()=>
2i(nm)),e.ui.componentFactory.add("menuBar:"+gp,()=>i(Em))}}const _p="italic";class wp extends yh{static get pluginName(){return"ItalicEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:_p}),e.model.schema.setAttributeProperties(_p,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:_p,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(_p,new ap(e,_p)),e.keystrokes.set("CTRL+I",_p),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const bp="italic";class vp extends yh{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=up({editor:e,commandName:bp,plugin:this,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",label:t("Italic")});e.ui.componentFactory.add(bp,()=>i(nm)),e.ui.componentFactory.add("menuBar:"+bp,()=>i(Em))}}function*yp(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class Ap extends kh{execute(){this.editor.model.change(e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})})}enterBlock(e){const t=this.editor.model,i=t.document.selection,n=t.schema,s=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,a=o.end.parent;if(n.isLimit(r)||n.isLimit(a))return s||r!=a||t.deleteContent(i),!1;if(s){const t=yp(e.model.schema,i.getAttributes());return kp(e,o.start),e.setSelectionAttribute(t),!0}{const n=!(o.start.isAtStart&&o.end.isAtEnd),s=r==a;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(s)return kp(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function kp(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const Ep={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class Cp extends Qa{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",(e,t)=>{i=t.shiftKey}),t.on("beforeinput",(n,s)=>{if(!this.isEnabled)return;let o=s.inputType;Yn.isSafari&&i&&"insertParagraph"==o&&(o="insertLineBreak");const r=s.domEvent,a=Ep[o];if(!a)return;const l=new Zr(t,"enter",s.targetRanges[0]);t.fire(l,new Ya(e,r,{isSoft:a.isSoft})),l.stop.called&&n.stop()})}observe(){}stopObserving(){}}class Pp extends yh{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,n=this.editor.t;t.addObserver(Cp),e.commands.add("enter",new Ap(e)),this.listenTo(i,"enter",(n,s)=>{i.isComposing||s.preventDefault(),s.isSoft||(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class Tp extends kh{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=yp(e.schema,i.getAttributes());xp(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?xp(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((Dp(s,e)||Dp(o,e))&&s!==o)return!1;return!0}(e.schema,t.selection)}}function xp(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function Dp(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Dp(e.parent,t))}class Sp extends yh{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,s=n.document,o=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,t)=>
2{let{writer:i}=t;return i.createEmptyElement("br")}}),n.addObserver(Cp),e.commands.add("shiftEnter",new Tp(e)),this.listenTo(s,"enter",(t,i)=>{s.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Insert a soft break (a <code><br></code> element)"),keystroke:"Shift+Enter"}]})}}class Ip extends kh{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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=>Op(e)||Bp(i,e));this._applyQuote(e,t)}else this._removeQuote(e,s.filter(Op))})}_getValue(){const e=Xo(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Op(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Xo(e.getSelectedBlocks());return!!i&&Bp(t,i)}_removeQuote(e,t){Fp(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=[];Fp(e,t).reverse().forEach(t=>{let n=Op(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 Op(e){return"blockQuote"==e.parent.name?e.parent:null}function Fp(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 Bp(e,t){const i=e.checkChild(t.parent,"blockQuote"),n=e.checkChild(["$root","blockQuote"],t);return i&&n}class Mp extends yh{static get pluginName(){return"BlockQuoteEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Pp,Rg]}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new Ip(e)),t.register("blockQuote",{inheritAllFrom:"$container"}),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"})}}class Rp extends yh{static get pluginName(){return"BlockQuoteUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("blockQuote",()=>{const e=this._createButton(nm);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:blockQuote",()=>{const e=this._createButton(Em);return e.set({role:"menuitemcheckbox"}),e})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("blockQuote"),s=new e(t.locale),o=i.t;return s.set({label:o("Block quote"),icon:sd,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value"),this.listenTo(s,"execute",()=>{t.execute("blockQuote"),t.editing.view.focus()}),s}}class Vp extends(Es()){constructor(){super(...arguments),(0,o.A)(this,"_stack",[])}add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const s=i[0];n===s||Np(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||Np(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(Np(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&Lp(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 Np(e,t){return e&&t&&e.priority==t.priority&&jp(e.classes)==jp(t.classes)}function Lp(e,t){return e.priority>t.priority||!(e.priority<t.priority)&&jp(e.classes)>jp(t.classes)}function jp(e){return Array.isArray(e)?e.sort().join(","):e}var Wp='<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>';const qp="ck-widget_selected";function Up(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function zp(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};
2if(!e.is("containerElement"))throw new gs("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=Gp,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){const i=e.getCustomProperty("widgetLabel");i.push(t)}(e,i.label),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 tm;return i.set("content",Wp),i.render(),t.appendChild(i.element),t});t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Hp,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$p;const s=new Vp;s.on("change:top",(t,s)=>{s.oldDescriptor&&n(e,s.oldDescriptor,s.writer),s.newDescriptor&&i(e,s.newDescriptor,s.writer)});const o=(e,t,i)=>s.add(t,i),r=(e,t,i)=>s.remove(t,i);t.setCustomProperty("addHighlight",o,e),t.setCustomProperty("removeHighlight",r,e)}(e,t),e}function Hp(e,t,i){if(t.classes&&i.addClass(Jo(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function $p(e,t,i){if(t.classes&&i.removeClass(Jo(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function Kp(e,t){const i=e.getSelectedElement();if(i){const n=Qp(e);if(n)return t.createRange(t.createPositionAt(i,n))}return t.schema.findOptimalInsertionRange(e)}function Gp(){return null}const Jp="widget-type-around";function Zp(e,t,i){return!!e&&Up(e)&&!i.isInline(t)}function Qp(e){return e.getAttribute(Jp)}const Yp=["before","after"],Xp=(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,e_="ck-widget__type-around_disabled";class t_ extends yh{constructor(){super(...arguments),(0,o.A)(this,"_currentFakeCaretModelElement",null)}static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[Pp,Rg]}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(e_,i):e.addClass(e_,i)}),s||e.model.change(e=>{e.removeSelectionAttribute(Jp)})}),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view,s=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:s}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){var s=this;this.listenTo(e,t,function(){s.isEnabled&&i(...arguments)},n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Qp(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,s,o)=>{const r=o.mapper.toViewElement(s.item);if(r&&Zp(r,s.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 Yp){const n=new Dd({tag:"div",attributes:{class:["ck","ck-widget__type-around__button","ck-widget__type-around__button_".concat(i)],title:t[i],"aria-hidden":"true"},children:[e.ownerDocument.importNode(Xp,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new Dd({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i});e.insert(e.createPositionAt(i,"end"),n)}(o.writer,n,r);r.getCustomProperty("widgetLabel").push(()=>
2this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):"")}},{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_".concat(e)}this._listenToIfEnabled(s.document,"arrowKey",(e,t)=>{this._handleArrowKeyPress(e,t)},{context:[Up,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(t,i)=>{i.directChange&&e.model.change(e=>{e.removeSelectionAttribute(Jp)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const t=i.getSelectedElement();if(t){if(Zp(e.editing.mapper.toViewElement(t),t,n))return}e.model.change(e=>{e.removeSelectionAttribute(Jp)})}),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(Yp.map(o),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!Zp(a,r,n))return;const l=Qp(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(Jp)})})}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,s=n.document.selection,o=n.schema,r=i.editing.view,a=function(e,t){const i=Ho(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;Zp(l,i.editing.mapper.toModelElement(l),o)?c=this._handleArrowKeyPressOnSelectedWidget(a):s.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=Qp(t.document.selection);return t.change(t=>{if(!i)return t.setSelectionAttribute(Jp,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(Jp),!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!!Zp(t.editing.mapper.toViewElement(o),o,n)&&(i.change(t=>{s._setSelectionOverElement(o),t.setSelectionAttribute(Jp,e?"before":"after")}),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,s=t.editing.mapper,o=i.document.selection,r=e?o.getLastPosition().nodeBefore:o.getFirstPosition().nodeAfter;return!!Zp(s.toViewElement(r),r,n)&&(i.change(t=>{t.setSelection(r,"on"),t.setSelectionAttribute(Jp,e?"after":"before")}),!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:Zp(o,s,r)&&(this._insertParagraph(s,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())},{context:Up})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",(t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)},{priority:"high"}),Yn.isAndroid?this._listenToIfEnabled(e,"keydown",(e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(e,"compositionstart",()=>{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=Qp(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);
2if(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}(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:Up})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(e,n)=>{let[s,o]=n;if(o&&!o.is("documentSelection"))return;const r=Qp(i);return r?(e.stop(),t.change(e=>{const n=i.getSelectedElement(),o=t.createPositionAt(n,r),a=e.createSelection(o),l=t.insertContent(s,a);return e.setSelection(a),l})):void 0},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(e,i)=>{const[,n,s={}]=i;if(n&&!n.is("documentSelection"))return;const o=Qp(t);o&&(s.findOptimalPosition=o,i[3]=s)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(e,i)=>{let[n]=i;if(n&&!n.is("documentSelection"))return;Qp(t)&&e.stop()},{priority:"high"})}}function i_(e){const t=e.model;return(i,n)=>{const s=n.keyCode==jo.arrowup,o=n.keyCode==jo.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}(a,l))return;const c=function(e,t,i){const n=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=n_(n,e,"forward");if(!i)return null;const s=n.createRange(e,i),o=s_(n.schema,s,"backward");return o?n.createRange(e,o):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=n_(n,e,"backward");if(!i)return null;const s=n.createRange(i,e),o=s_(n.schema,s,"forward");return o?n.createRange(o,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(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=uo.getDomRangeRects(r);let l;for(const c of a)if(void 0!==l){if(Math.round(c.top)>=l)return!1;l=Math.max(l,Math.round(c.bottom))}else l=Math.round(c.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 n_(e,t,i){const n=e.schema,s=e.createRangeIn(t.root),o="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:r,item:a,type:l}of s.getWalker({startPosition:t,direction:i})){if(n.isLimit(a)&&!n.isInline(a))return r;if(l==o&&n.isBlock(a))return null}return null}function s_(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:s}of t.getWalker({direction:i}))if(e.checkChild(s,"$text"))return s;return null}class o_ extends yh{constructor(){super(...arguments),(0,o.A)(this,"_previouslySelected",new Set)}static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[t_,Rg]}init(){var e=this;const t=this.editor,i=t.editing.view,n=i.document,s=t.t;this.editor.editing.downcastDispatcher.on("selection",(e,i,n)=>{const s=n.writer,o=i.selection;if(o.isCollapsed)return;const r=o.getSelectedElement();if(!r)return;const a=t.editing.mapper.toViewElement(r);var l;Up(a)&&(n.consumable.consume(o,"selection")&&s.setSelection(s.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce((e,t)=>"function"===typeof t?e?e+". "+t():t():e?e+". "+t:t,""))}))}),this.editor.editing.downcastDispatcher.on("selection",(e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,s=n.document.selection;let o=null;for(const r of s.getRanges())for(const e of r){const t=e.item;Up(t)&&!r_(t,o)&&(n.addClass(qp,t),this._previouslySelected.add(t),o=t)}},{priority:"low"}),i.addObserver(ch),this.listenTo(n,"mousedown",function(){return e._onMousedown(...arguments)}),this.listenTo(n,"arrowKey",function(){e._handleSelectionChangeO
2nArrowKeyPress(...arguments)},{context:[Up,"$text"]}),this.listenTo(n,"arrowKey",function(){e._preventDefaultOnArrowKeyPress(...arguments)},{context:"$root"}),this.listenTo(n,"arrowKey",i_(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",(e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())},{context:"$root"}),this.listenTo(n,"tab",(e,t)=>{"atTarget"==e.eventPhase&&(t.shiftKey||this._selectFirstNestedEditable()&&(t.preventDefault(),e.stop()))},{context:Up,priority:"low"}),this.listenTo(n,"tab",(e,t)=>{t.shiftKey&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())},{priority:"low"}),this.listenTo(n,"keydown",(e,t)=>{t.keystroke==jo.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())},{priority:"low"}),t.accessibility.addKeystrokeInfoGroup({id:"widget",label:s("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:s("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:s("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:s("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:s("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:s("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,n=i.editing.view,s=n.document;let o=t.target;if(!o)return;if(t.domEvent.detail>=3)return void(this._selectBlockContent(o)&&t.preventDefault());if(!Up(o)){const e=function(e){let t=e;for(;t;){if(t.is("editableElement")||Up(t))return t;t=t.parent}return null}(o);if(!e)return;if(Up(e))o=e;else{const e=function(e,t){const i=oo(t.domEvent);let n=null;n=i?e.domConverter.domRangeToView(i):e.createRange(e.createPositionAt(t.target,0));if(!n)return null;const s=n.start;if(!s.parent)return null;let o=s.parent;s.parent.is("editableElement")&&(s.isAtEnd&&s.nodeBefore?o=s.nodeBefore:s.isAtStart&&s.nodeAfter&&(o=s.nodeAfter));if(o.is("$text"))return o.parent;return o}(n,t);if(!e||!Up(e))return;o=e}}Yn.isAndroid&&t.preventDefault(),s.isFocused||n.focus();const r=i.editing.mapper.toModelElement(o);this._setSelectionOverElement(r)}_selectBlockContent(e){const t=this.editor,i=t.model,n=t.editing.mapper,s=i.schema,o=n.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),r=function(e,t){for(const i of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(i,"$text"))return i;if(t.isLimit(i)&&!t.isObject(i))break}return null}(n.toModelElement(o),i.schema);return!!r&&(i.change(e=>{const t=s.isLimit(r)?null:function(e,t){const i=new gl({startPosition:e});for(const{item:n}of i){if(t.isLimit(n)||!n.is("element"))return null;if(t.checkChild(n,"$text"))return n}return null}(e.createPositionAfter(r),s),i=e.createPositionAt(r,0),n=t?e.createPositionAt(t,0):e.createPositionAt(r,"end");e.setSelection(e.createRange(i,n))}),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,s=n.schema,o=n.document.selection,r=o.getSelectedElement(),a=Ho(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(r&&s.isObject(r)){const i=l?o.getLastPosition():o.getFirstPosition(),r=s.getNearestSelectionRange(i,l?"forward":"backward");return void(r&&(n.change(e=>{e.setSelection(r)}),t.preventDefault(),e.stop()))}if(!o.isCollapsed&&!t.shiftKey){const i=o.getFirstPosition(),r=o.getLastPosition(),a=i.nodeAfter,c=r.no
2deBefore;return void((a&&s.isObject(a)||c&&s.isObject(c))&&(n.change(e=>{e.setSelection(l?r:i)}),t.preventDefault(),e.stop()))}if(!o.isCollapsed)return;const u=this._getObjectElementNextToSelection(l);if(u&&s.isObject(u)){if(s.isInline(u)&&c)return;this._setSelectionOverElement(u),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){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;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);if(t.modifySelection(s,{direction:e?"forward":"backward"}),s.isEqual(n))return null;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(qp,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,t=this.editor.editing.view.document;for(const i of t.selection.getFirstRange().getItems())if(i.is("editableElement")){const t=e.editing.mapper.toModelElement(i);if(!t)continue;const n=e.model.createPositionAt(t,0),s=e.model.schema.getNearestSelectionRange(n,"forward");return e.model.change(e=>{e.setSelection(s)}),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,n=(i.is("$text")?i.parent:i).findAncestor(Up);if(!n)return!1;const s=t.toModelElement(n);return!!s&&(e.model.change(e=>{e.setSelection(s,"on")}),!0)}}function r_(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class a_ extends Xa{constructor(e){super(e),(0,o.A)(this,"domEventType",["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"]);const t=this.document;function i(e){return(i,n)=>{n.preventDefault();const s=n.dropRange?[n.dropRange]:null,o=new us(t,e);t.fire(o,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:s,target:n.target,domEvent:n.domEvent}),o.stop.called&&n.stopPropagation()}}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="clipboardData"in e?e.clipboardData:e.dataTransfer,i="drop"==e.type||"paste"==e.type,n={dataTransfer:new al(t,{cacheFiles:i})};if("drop"==e.type||"dragover"==e.type){const t=oo(e);n.dropRange=t&&this.view.domConverter.domRangeToView(t)}this.fire(e.type,e,n)}}const l_=["figcaption","li"],c_=["ol","ul"];function u_(e,t){if(t.is("$text")||t.is("$textProxy"))return t.data;if(t.is("element","img")&&t.hasAttribute("alt"))return t.getAttribute("alt");if(t.is("element","br"))return"\n";let i="",n=null;for(const s of t.getChildren())i+=d_(s,n)+u_(e,s),n=s;if(t.is("rawElement")){const n=document.createElement("div");t.render(n,e),i+=h_(n)}return i}function h_(e){let t="";if(e.nodeType===Node.TEXT_NODE)return e.textContent;if("BR"===e.tagName)return"\n";for(const i of e.childNodes)t+=h_(i);return t}function d_(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||c_.includes(e.name)&&c_.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?l_.includes(e.name)||l_.includes(t.name)?"\n":e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")||t.is("element")&&t.getCustomProperty("dataPipeline:transparentRendering")?"":"\n\n":"":""}class m_ extends yh{constructor(){super(...arguments),(0,o.A)(this,"_markersToCopy",new Map)}static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e=>e.model.getSelectedContent(e.model.document.selection);return this.editor.model.change(n=>{const s=n.model.document.selection;n.setSelection(t);const o=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),r=i(n),a=this._removeFakeMarkersInsideElement(n,r);for(const[e,t]of Object.entries(o)){a[e]||(a[e]=n.createRangeIn(r));for(const e of t)n.remove(e)}r.markers.clear();for(const[e,t]of Object.entries(a))r.markers.set(e,t);return n.setSelection(s),r})}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(e=>{const n=this._insertFakeMarkersElements(e,i),s=t(e),o=this._removeFakeMarkersInsideElement(e,s);for(const t of Object.values(n).flat())e.remove(t);for(const[t,i]of Object.entries(o))e.model.markers.has(t)||e.addMarker(t,{usingOperation:!0,affectsData:!0,range:i});return s})}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}
2_forceMarkersCopy(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0};const n=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:n}=i;return"all"===n||n.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const n=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,i){const n=Array.from(t.getRanges()),s=new Set(n.flatMap(t=>Array.from(e.model.markers.getMarkersIntersectingRange(t))));return Array.from(s).filter(e=>{if(!this._isMarkerCopyable(e.name,i))return!1;const{copyPartiallySelected:t}=this._getMarkerClipboardConfig(e.name);if(!t){const t=e.getRange();return n.some(e=>e.containsRange(t,!0))}return!0}).map(e=>({name:"dragstart"===i?this._getUniqueMarkerName(e.name):e.name,range:e.getRange()}))}_getPasteMarkersFromRangeMap(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(e=>{let[n,s]=e;if(!this._hasMarkerConfiguration(n))return[{name:n,range:s}];if(this._isMarkerCopyable(n,t)){const e=this._getMarkerClipboardConfig(n),t=i.markers.has(n)&&"$graveyard"===i.markers.get(n).getRange().root.rootName;return(e.duplicateOnPaste||t)&&(n=this._getUniqueMarkerName(n)),[{name:n,range:s}]}return[]})}_insertFakeMarkersElements(e,t){const i={},n=t.flatMap(e=>{const{start:t,end:i}=e.range;return[{position:t,marker:e,type:"start"},{position:i,marker:e,type:"end"}]}).sort((e,t)=>{let{position:i}=e,{position:n}=t;return i.isBefore(n)?1:-1});for(const{position:s,marker:o,type:r}of n){const t=e.createElement("$marker",{"data-name":o.name,"data-type":r});i[o.name]||(i[o.name]=[]),i[o.name].push(t),e.insert(t,s)}return i}_removeFakeMarkersInsideElement(e,t){return qn(this._getAllFakeMarkersFromElement(e,t).reduce((t,i)=>{const n=i.markerElement&&e.createPositionBefore(i.markerElement);let s=t[i.name],o=!1;if(s&&s.start&&s.end){this._getMarkerClipboardConfig(i.name).duplicateOnPaste?t[this._getUniqueMarkerName(i.name)]=t[i.name]:o=!0,s=null}return o||(t[i.name]=(0,r.A)((0,r.A)({},s),{},{[i.type]:n})),i.markerElement&&e.remove(i.markerElement),t},{}),i=>new kl(i.start||e.createPositionFromPath(t,[0]),i.end||e.createPositionAt(t,"end")))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap(e=>{let{item:t}=e;if(!t.is("element","$marker"))return[];const i=t.getAttribute("data-name"),n=t.getAttribute("data-type");return[{markerElement:t,name:i,type:n}]}),n=[],s=[];for(const o of i){if("end"===o.type){i.some(e=>e.name===o.name&&"start"===e.type)||n.push({markerElement:null,name:o.name,type:"start"})}if("start"===o.type){i.some(e=>e.name===o.name&&"end"===e.type)||s.unshift({markerElement:null,name:o.name,type:"end"})}}return[...n,...i,...s]}_getUniqueMarkerName(e){const t=e.split(":"),i=ds().substring(1,6);return 3===t.length?"".concat(t.slice(0,2).join(":"),":").concat(i):"".concat(t.join(":"),":").concat(i)}}class f_ extends yh{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[m_]}init(){this.editor.editing.view.addObserver(a_),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===i},()=>{const s=n._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:i})})}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",(t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()},{priority:"highest"}),this.listenTo(n,"clipboardInput",(e,t)=>{const n=t.dataTransfer;let s;if(t.content)s=t.content;else{let e="";n.getData("text/html")?e=function(e){return e.replace(/<span(?: class="Apple-converted-s
2pace"|)>(\s+)<\/span>/g,(e,t)=>1==t.length?" ":t).replace(/<!--[\s\S]*?-->/g,"")}(n.getData("text/html")):n.getData("text/plain")&&(e=function(e){return((e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("</p><p>")||e.includes("<br>"))&&(e="<p>".concat(e,"</p>")),e}(n.getData("text/plain"))),s=this.editor.data.htmlProcessor.toView(e)}const o=new us(this,"inputTransformation"),r=n.getData("application/ckeditor5-editor-id")||null;this.fire(o,{content:s,dataTransfer:n,sourceEditorId:r,targetRanges:t.targetRanges,method:t.method}),o.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,sourceEditorId:i.sourceEditorId,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(e,t)=>{t.resultRange=s._pasteFragmentWithMarkers(t.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",(t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(t,n)=>{const s=e.data.toView(n.content,{isClipboardPipeline:!0});i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:s,method:n.method})},{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",u_(e.data.htmlProcessor.domConverter,n.content)),n.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}const g_=bo("px");class p_ extends Qd{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",e=>!e)],style:{left:e.to("left",e=>g_(e)),top:e.to("top",e=>g_(e)),width:e.to("width",e=>g_(e))}}})}}class __ extends yh{constructor(){super(...arguments),(0,o.A)(this,"removeDropMarkerDelayed",ar(()=>this.removeDropMarker(),40)),(0,o.A)(this,"_updateDropMarkerThrottled",$n(e=>this._updateDropMarker(e),40)),(0,o.A)(this,"_reconvertMarkerThrottled",$n(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0)),(0,o.A)(this,"_dropTargetLineView",new p_),(0,o.A)(this,"_domEmitter",new(to())),(0,o.A)(this,"_scrollables",new Map)}static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,n,s,o){this.removeDropMarkerDelayed.cancel();const r=w_(this.editor,e,t,i,n,s,o);if(r)return o&&o.containsRange(r)?this.removeDropMarker():void this._updateDropMarkerThrottled(r)}getFinalDropRange(e,t,i,n,s,o){const r=w_(this.editor,e,t,i,n,s,o);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(e=>{e.removeMarker("drop-target")})}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),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,i)=>
2{let{writer:n}=i;if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(n);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_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})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(e){const t=this.toDomElement(e);return t.append("\u2060",e.createElement("span"),"\u2060"),t})}_updateDropTargetLine(e){const t=this.editor.editing,i=e.start.nodeBefore,n=e.start.nodeAfter,s=e.start.parent,o=i?t.mapper.toViewElement(i):null,r=o?t.view.domConverter.mapViewToDom(o):null,a=n?t.mapper.toViewElement(n):null,l=a?t.view.domConverter.mapViewToDom(a):null,c=t.mapper.toViewElement(s);if(!c)return;const u=t.view.domConverter.mapViewToDom(c),h=this._getScrollableRect(c),{scrollX:d,scrollY:m}=Jn.window,f=r?new uo(r):null,g=l?new uo(l):null,p=new uo(u).excludeScrollbarsAndBorders(),_=f?f.bottom:p.top,w=g?g.top:p.bottom,b=Jn.window.getComputedStyle(u),v=_<=w?(_+w)/2:w;if(h.top<v&&v<h.bottom){const e=p.left+parseFloat(b.paddingLeft),t=p.right-parseFloat(b.paddingRight),i=Math.max(e+d,h.left),n=Math.min(t+d,h.right);this._dropTargetLineView.set({isVisible:!0,left:i,top:v+m,width:n-i})}else this._dropTargetLineView.isVisible=!1}_getScrollableRect(e){const t=e.root.rootName;let i;if(this._scrollables.has(t))i=this._scrollables.get(t).domElement;else{i=function(e){let t=e;do{t=t.parentElement;const e=Jn.window.getComputedStyle(t).overflowY;if("auto"==e||"scroll"==e)break}while("BODY"!=t.tagName);return t}(this.editor.editing.view.domConverter.mapViewToDom(e)),this._domEmitter.listenTo(i,"scroll",this._reconvertMarkerThrottled,{usePassive:!0});const n=new _o(i,this._reconvertMarkerThrottled);this._scrollables.set(t,{domElement:i,resizeObserver:n})}return new uo(i).excludeScrollbarsAndBorders()}}function w_(e,t,i,n,s,o,r){const a=e.model,l=e.editing.mapper;let c=A_(e,t);for(;c;){if(!o)if(a.schema.checkChild(c,"$text")){if(i){const t=i[0].start,o=l.toModelPosition(t);if(!r||Array.from(r.getItems({shallow:!0})).every(e=>a.schema.checkChild(o,e))){if(a.schema.checkChild(o,"$text"))return a.createRange(o);if(t)return v_(e,A_(e,t.parent),n,s)}}}else if(a.schema.isInline(c))return v_(e,c,n,s);if(a.schema.isBlock(c))return v_(e,c,n,s);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter(t=>t.is("element")&&!b_(e,t));let i=0,o=t.length;if(0==o)return a.createRange(a.createPositionAt(c,"end"));for(;i<o-1;){const r=Math.floor((i+o)/2);"before"==y_(e,t[r],n,s)?o=r:i=r}return v_(e,t[i],n,s)}c=c.parent}return null}function b_(e,t){const i=e.editing.mapper,n=e.editing.view.domConverter,s=i.toViewElement(t);if(!s)return!0;const o=n.mapViewToDom(s);return"none"!=Jn.window.getComputedStyle(o).float}function v_(e,t,i,n){const s=e.model;return s.createRange(s.createPositionAt(t,y_(e,t,i,n)))}function y_(e,t,i,n){const s=e.editing.mapper,o=e.editing.view.domConverter,r=s.toViewElement(t),a=o.mapViewToDom(r),l=new uo(a);return e.model.schema.isInline(t)?i<(l.left+l.right)/2?"before":"after":n<(l.top+l.bottom)/2?"before":"after"}function A_(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)}class k_ extends yh{constructor(){super(...arguments),(0,o.A)(this,"_isBlockDragging",!1),(0,o.A)(this,"_domEmitter",new(to()))}static get pluginName(){return"DragDropBlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(this.listenTo(e,"change:isReadOnly",(e,t,i)=>{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),Yn.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",(e,t)=>this._handleBlockDragStart(t)),this._domEmitter.listenTo(Jn.document,"dragover",(e,t)=>this._handleBlockDragging(t)),this._domEmitter.listenTo(Jn.document,"drop",(e,t)=>this._handleBlockDragging(t)),this._domEmitter.listenTo(Jn.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",(e,i,n)=>{t.setAttribute("draggable",n?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,s=Array.from(i.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change(e=>e.setSelection(o)),this._isBlockDragging=!0,n.focus(),n.getObserver(a_).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),s=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&s.getObserver(a_).onDomEvent((0,r.A)((0,r.A)({},e),{},{type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()}))}_handleBlockDragEnd(){this._isBlockDragging=!1}}class E_ extends yh{constructor(){super(...arguments),(0,o.A)(this,"_draggedRange",void 0),(0,o.A)(this,"_draggingUid",void 0),(0,o.A)(this,"_draggableElement",void 0),(0,o.A)(this,"_clearDraggableAttributesDelayed",ar(()=>this._clearDraggableAttributes(),40)),(0,o.A)(this,"_blockMode",!1),(0,o.A)(this,"_domEmitter",new(to())),(0,o.A)(this,"_previewContainer",void 0)}static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[f_,o_,__,k_]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(a_),t.addObserver(ch),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),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)}),Yn.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=e.plugins.get(__);this.listenTo(n,"dragstart",(e,i)=>{if(i.target&&i.target.is("editableElement"))return void i.preventDefault();if(this._prepareDraggedRange(i.target),!this._draggedRange)return void i.preventDefault();this._draggingUid=ds(),i.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",i.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const n=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(i.dataTransfer,n,"dragstart");
2const{dataTransfer:s,domTarget:o,domEvent:r}=i,{clientX:a}=r;this._updatePreview({dataTransfer:s,domTarget:o,clientX:a}),i.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(n,"dragend",(e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)},{priority:"low"}),this._domEmitter.listenTo(Jn.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(n,"dragenter",()=>{this.isEnabled&&i.focus()}),this.listenTo(n,"dragleave",()=>{s.removeDropMarkerDelayed()}),this.listenTo(n,"dragging",(e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:n}=t.domEvent;s.updateDropMarker(t.target,t.targetRanges,i,n,this._blockMode,this._draggedRange),this._draggedRange||(t.dataTransfer.dropEffect="copy"),Yn.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(__);this.listenTo(t,"clipboardInput",(t,n)=>{if("drop"!=n.method)return;const{clientX:s,clientY:o}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,s,o,this._blockMode,this._draggedRange);if(!r)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==C_(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(r)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(f_);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"==C_(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(Yn.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let o=P_(s.target);if(Yn.isBlink&&!e.isReadOnly&&!o&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&Up(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",()=>{Yn.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})}_finalizeDragging(e){const t=this.editor,i=t.model;if(t.plugins.get(__).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change(e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,s=e?P_(e):null;if(s){const e=t.editing.mapper.toModelElement(s);if(this._draggedRange=Ll.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const o=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==o.length)return void(this._draggedRange=Ll.fromRange(r));const a=T_(i,o);if(o.length>1)this._draggedRange=Ll.fromRange(a),this._blockMode=!0;else if(1==o.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=Ll.fromRange(e?a:r),this._blockMode=e}i.change(e=>e.setSelection(this._draggedRange.toRange()))}_updatePreview(e){let{dataTransfer:t,domTarget:i,clientX:n}=e;const s=this.editor.editing.view,o=s.document.selection.editableElement,r=s.domConverter.mapViewToDom(o),a=Jn.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=Gs(Jn.document,"div",{style:"position: fixed; left: -999999px;"}),Jn.document.body.appendChild(this._previewContainer));const l=new uo(r);if(r.contains(i))return;const c=parseFloat(a.paddingLeft),u=Gs(Jn.document,"div");
2u.className="ck ck-content",u.style.width=a.width,u.style.paddingLeft="".concat(l.left-n+c,"px"),Yn.isiOS&&(u.style.backgroundColor="white"),s.domConverter.setContentOf(u,t.getData("text/html")),t.setDragImage(u,0,0),this._previewContainer.appendChild(u)}}function C_(e){return Yn.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function P_(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(Up);if(Up(e))return e;const t=e.findAncestor(e=>Up(e)||e.is("editableElement"));return Up(t)?t:null}function T_(e,t){const i=t[0],n=t[t.length-1],s=i.getCommonAncestor(n),o=e.createPositionBefore(i),r=e.createPositionAfter(n);if(s&&s.is("element")&&!e.schema.isLimit(s)){const t=e.createRangeOn(s),i=o.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return T_(e,[s])}return e.createRange(o,r)}class x_ extends yh{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[f_]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=t.document.selection;i.addObserver(a_),e.plugins.get(f_).on("contentInsertion",(e,i)=>{(function(e,t){let i=t.createRangeIn(e);if(1==e.childCount){const n=e.getChild(0);n.is("element")&&t.schema.isBlock(n)&&!t.schema.isObject(n)&&!t.schema.isLimit(n)&&(i=t.createRangeIn(n))}for(const n of i.getItems()){if(!t.schema.isInline(n))return!1;if(Array.from(n.getAttributeKeys()).find(e=>t.schema.getAttributeProperties(e).isFormatting))return!1}return!0})(i.content,t)&&t.change(e=>{const s=Array.from(n.getAttributes()).filter(e=>{let[i]=e;return t.schema.getAttributeProperties(i).isFormatting});n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),s.push(...n.getAttributes());const o=e.createRangeIn(i.content);for(const i of o.getItems())for(const n of s)t.schema.checkAttribute(i,n[0])&&e.setAttribute(n[0],n[1],i)})})}}class D_ extends yh{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[m_,f_,E_,x_]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}function S_(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const n of i)"Plain text"===n.label&&(n.label=t("Plain text")),void 0===n.class&&(n.class="language-".concat(n.language));return i}function I_(e,t,i){const n={};for(const s of e)if("class"===t){n[s[t].split(" ").shift()]=s[i]}else n[s[t]]=s[i];return n}function O_(e){return e.data.match(/^(\s*)/)[0]}function F_(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const n=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:s}of n){let t=s.is("$textProxy")?s.textNode:s;const n=t.parent;if(!n.is("element","codeBlock")||t.is("element","softBreak"))continue;for(;t.previousSibling&&!t.previousSibling.is("element","softBreak");)t=t.previousSibling;const o=t.is("$text")?t.startOffset+O_(t).length:t.startOffset,r=e.createPositionAt(n,o);i.every(e=>!e.isEqual(r))&&i.push(r)}return i}function B_(e){const t=Xo(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function M_(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}function R_(e,t,i,n){const s=I_(t,"language","label"),o=i.getAttribute("language");if(o in s){const t=s[o];return e("enter"===n?"Entering %0 code snippet":"Leaving %0 code snippet",t)}return e("enter"===n?"Entering code snippet":"Leaving code snippet")}function V_(e,t){for(e.textNode&&(e=t.createPositionBefore(e.textNode));e.nodeBefore&&!e.nodeBefore.is("element","softBreak");)e=t.createPositionBefore(e.nodeBefore);const i=e.nodeAfter;return i&&i.is("$text")?i:null}class N_ extends kh{constructor(e){super(e),(0,o.A)(this,"_lastLanguage",void 0),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.editor,i=t.model,n=i.document.selection,s=S_(t)[0],o=Array.from(n.getSelectedBlocks()),r=void 0==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,s.language);i.change(e=>{r?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)})}_getValue(){const e=Xo(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=Xo(e.getSelectedBlocks());return!!i&&M_(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,s=t.filter(e=>M_(n,e));for(const o of s)e.rename(o,"codeBlock"),e.setAttribute("language",i,o),n.removeDisallowedAttributes([o],e),Array.from(o.getChildren()).filter(e=>
2!n.checkChild(o,e)).forEach(t=>e.remove(t));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 n of i){const t=e.createRangeOn(n);for(const i of Array.from(t.getItems()).reverse())if(i.is("element","softBreak")&&i.parent.is("element","codeBlock")){const{position:t}=e.split(e.createPositionBefore(i)),n=t.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(i)}e.rename(n,"paragraph"),e.removeAttribute("language",n)}}}class L_ extends kh{constructor(e){super(e),(0,o.A)(this,"_indentSequence",void 0),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=F_(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}})}_checkEnabled(){return!!this._indentSequence&&B_(this.editor.model.document.selection)}}class j_ extends kh{constructor(e){super(e),(0,o.A)(this,"_indentSequence",void 0),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(()=>{const t=F_(e);for(const i of t){const t=W_(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!B_(e.document.selection)&&F_(e).some(t=>W_(e,t,this._indentSequence))}}function W_(e,t,i){const n=V_(t,e);if(!n)return null;const s=O_(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 q_(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=I_(t,"language","class"),s=I_(t,"language","label");return(t,o,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(o.item,"insert"))return;const u=o.item.getAttribute("language"),h=l.toViewPosition(e.createPositionBefore(o.item)),d={};i&&(d["data-language"]=s[u],d.spellcheck="false");const m=n[u]?{class:n[u]}:void 0,f=a.createContainerElement("code",m),g=a.createContainerElement("pre",d,f);a.insert(h,g),l.bindElements(o.item,f)}}const U_="paragraph";class z_ extends yh{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Sp]}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,s=S_(e);e.commands.add("codeBlock",new N_(e)),e.commands.add("indentCodeBlock",new L_(e)),e.commands.add("outdentCodeBlock",new j_(e)),this.listenTo(n.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),t.addAttributeCheck((e,i)=>{const n=e.getItem(e.length-2);if(t.getAttributeProperties(i).isFormatting&&n&&"codeBlock"==n.name)return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",q_(i,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",q_(i,s)),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=I_(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;
2if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=s;if(!a.test(o,{name:!0}))return;const c=l.createElement("codeBlock"),u=[...o.getClassNames()];u.length||u.push("");for(const n of u){const e=i[n];if(e){l.setAttribute("language",e,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,s)),e.data.upcastDispatcher.on("text",(e,t,i)=>{let{consumable:n,writer:s}=i,o=t.modelCursor;if(!n.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;n.consume(t.viewItem);const r=t.viewItem.data.split("\n").map(e=>s.createText(e)),a=r[r.length-1];for(const l of r)if(s.insert(l,o),o=o.getShiftedBy(l.offsetSize),l!==a){const e=s.createElement("softBreak");s.insert(e,o),o=s.createPositionAfter(e)}t.modelRange=s.createRange(t.modelCursor,o),t.modelCursor=o}),e.data.upcastDispatcher.on("element:pre",(e,t,i)=>{let{consumable:n}=i;const s=t.viewItem;if(s.findAncestor("pre"))return;const o=Array.from(s.getChildren()),r=o.find(e=>e.is("element","code"));if(r)for(const a of o)a!==r&&a.is("$text")&&n.consume(a,{name:!0})},{priority:"high"}),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 hh(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)}),e.plugins.has("ClipboardPipeline")&&e.plugins.get(f_).on("contentInsertion",(i,n)=>{const s=e.model,o=s.document.selection;o.anchor.parent.is("element","codeBlock")&&s.change(e=>{const i=e.createRangeIn(n.content);for(const n of[...i.getItems()])n.is("node")&&!t.checkChild(o.anchor,n)&&e.remove(n)})}),this.listenTo(i,"getSelectedContent",(e,n)=>{let[s]=n;const o=s.anchor;!s.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(s.focus)&&i.change(i=>{const n=e.return;if(o.parent.is("element")&&(n.childCount>1||s.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(n,t);const s=i.createDocumentFragment();return i.append(t,s),void(e.return=s)}const r=n.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)})})}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),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,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!$_(r))return!1;return e.model.change(t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,U_),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)}),s.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||!r.previousSibling)return!1;if($_(r)&&$_(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(H_(r)&&$_(r.previousSibling)&&$_(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(H_(r)&&$_(r.previousSibling)&&H_(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&$_(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change(t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,U_),e.model.schema.removeDisallowedAttributes([i],t)}),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document;let n;const s=V_(i.selection.getLastPosition(),t);s&&s.is("$text")&&(n=O_(s));e.model.change(t=>{e.execute("shiftEnter"),n&&t.insertText(n,i.selection.anchor)})}(e),i.preventDefault(),t.stop())},{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,n=S_(this.editor);let s=null;e.document.selection.on("change:range",()=>{const o=e.document.selection.focus.parent;t&&s!==o&&o.is("element")&&(s&&s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(R_(i,n,s,"leave")),o.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(R_(i,n,o,"enter")),s=o)})}}function H_(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function $_(e){return e&&e.is("element","softBreak")}class K_ extends yh{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=S_(e),s=this._getLanguageListItemDefinitions(n),o=e.commands.get("codeBlock");i.add("codeBlock",i=>{const n=cf(i,lf),r=n.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:hd,isToggleable:!0}),r.bind("isOn").to(o,"value",e=>!!e),r.on("execute",()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()}),n.on("execute",t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),n.class="ck-code-block-dropdown",n.bind("isEnabled").to(o),df(n,s,{role:"menu",ariaLabel:a}),n}),i.add("menuBar:codeBlock",i=>{const n=new fg(i);n.buttonView.set({role:"menuitem",label:t("Code block"),icon:hd}),n.bind("isEnabled").to(o);const r=new gg(i);r.set({ariaLabel:t("Insert code block")});for(const t of s){const s=new Mf(i,n),a=new Em(i);a.bind(...Object.keys(t.model)).to(t.model),a.set({isToggleable:!0,role:"menuitemcheckbox"}),a.delegate("execute").to(n),a.on("execute",()=>{e.execute("codeBlock",{language:t.model._codeBlockLanguage,forceValue:o.value!=t.model._codeBlockLanguage}),e.editing.view.focus()}),s.children.add(a),r.items.add(s)}return n.panelView.children.add(r),n})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new Yo;for(const n of e){const e={type:"button",model:new og({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",t=>t===e.model._codeBlockLanguage),i.add(e)}return i}}class G_ extends Yf{constructor(e,t){super(e),(0,o.A)(this,"view",void 0),(0,o.A)(this,"_toolbarConfig",void 0),(0,o.A)(this,"_elementReplacer",void 0),this.view=t,this._toolbarConfig=tf(e.config.get("toolbar")),this._elementReplacer=new zs,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}
2get 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),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),i.menuBarView&&this._initMenuBar(i.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",e=>{let{top:t}=e;return t||0}),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let s;const o=e.config.get("placeholder");o&&(s="string"===typeof o?o:o[this.view.editable.name]),!s&&n&&"textarea"===n.tagName.toLowerCase()&&(s=n.getAttribute("placeholder")),s&&(i.placeholder=s),pr({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:e}=this.view,t=this.editor.plugins.get("ContextualBalloon");t.on("getPositionOptions",t=>{const i=t.return;if(!i||!e.isSticky||!e.element)return;const n=new uo(e.element).height,s="function"===typeof i.target?i.target():i.target,o="function"===typeof i.limiter?i.limiter():i.limiter;if(s&&o&&new uo(s).height>=new uo(o).height-n)return;const a=(0,r.A)({},i.viewportOffsetConfig),l=(a.top||0)+n;t.return=(0,r.A)((0,r.A)({},i),{},{viewportOffsetConfig:(0,r.A)((0,r.A)({},a),{},{top:l})})},{priority:"low"});const i=()=>{t.visibleView&&t.updatePosition()};this.listenTo(e,"change:isSticky",i),this.listenTo(this.editor.ui,"change:viewportOffset",i)}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new uo(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout(()=>{this.stopListening(n,"change:isSticky",e)},20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const e=this.view.stickyPanel,t=this.editor.plugins.get("Dialog");t.on("show",()=>{const i=t.view;i.on("moveTo",(t,n)=>{if(!e.isSticky||i.wasMoved||i.isModal)return;const s=new uo(e.contentPanelElement);n[1]<s.bottom+vm.defaultOffset&&(n[1]=s.bottom+vm.defaultOffset)},{priority:"high"})},{priority:"low"})}}class J_ extends tg{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(e),(0,o.A)(this,"stickyPanel",void 0),(0,o.A)(this,"toolbar",void 0),(0,o.A)(this,"editable",void 0),this.stickyPanel=new hg(e),this.toolbar=new sf(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),i.useMenuBar&&(this.menuBarView=new bg(e)),this.editable=new ng(e,t,void 0,{label:i.label})}render(){super.render(),this.menuBarView?this.stickyPanel.content.addMany([this.menuBarView,this.toolbar]):this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class Z_ extends(Wh(Lh)){static get editorName(){return"ClassicEditor"}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Q_(e)&&void 0!==t.initialData)throw new gs("editor-create-initial-data",null);super(t),(0,o.A)(this,"ui",void 0),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Q_(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),Q_(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),s=new J_(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i,useMenuBar:n.isVisible,label:this.config.get("label")});this.ui=new G_(this,s),function(e){if(!ce(e.updateSourceElement))throw new gs("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,s=()=>e.updateSourceElement();ce(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)})}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(i=>{const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init(Q_(e)?e:null)).then(()=>n.data.init(n.config.get("initialData"))).then(()=>n.fire("ready")).then(()=>n))})}}function Q_(e){return Ln(e)}class Y_ extends kh{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;
2let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!X_(e.schema,i))do{if(i=i.parent,!i)return}while(!X_(e.schema,i));e.change(e=>{e.setSelection(i,"in")})}}function X_(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const ew=Uo("Ctrl+A");class tw extends yh{static get pluginName(){return"SelectAllEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new Y_(e)),this.listenTo(i,"keydown",(t,i)=>{qo(i)===ew&&(e.execute("selectAll"),i.preventDefault())}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class iw extends yh{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",()=>{const e=this._createButton(nm);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:selectAll",()=>this._createButton(Em))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),s=new e(t.locale),o=i.t;return s.set({label:o("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"}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),s}}class nw extends yh{static get requires(){return[tw,iw]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}class sw extends kh{constructor(e){super(e),(0,o.A)(this,"_stack",[]),(0,o.A)(this,"_createdBatches",new WeakSet),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",(e,t)=>{t[1]=(0,r.A)({},t[1]);const i=t[1];i.batchType||(i.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(e.data,"set",(e,t)=>{t[1].batchType.isUndoable||this.clearStack()})}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}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 l of r){const e=l.filter(e=>e.root!=s.graveyard).filter(e=>!rw(e,a));e.length&&(ow(e),o.push(e[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 o of s){const e=o.baseVersion+1,s=Array.from(n.history.getOperations(e)),r=pu([o.getReversed()],s,{useRelations:!0,document:this.editor.model.document,forceWeakRemove:!0}).operationsA;for(let a of r){const e=a.affectedSelectable;e&&!i.canEditAt(e)&&(a=new ru(a.baseVersion)),t.addOperation(a),i.applyOperation(a),n.history.setOperationAsUndone(o,a)}}}}function ow(e){e.sort((e,t)=>
2e.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 rw(e,t){return t.some(t=>t!==e&&t.containsRange(e,!0))}class aw extends sw{execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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({isUndo:!0});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()}}class lw extends sw{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});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()}}class cw extends yh{constructor(){super(...arguments),(0,o.A)(this,"_undoCommand",void 0),(0,o.A)(this,"_redoCommand",void 0),(0,o.A)(this,"_batchRegistry",new WeakSet)}static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._undoCommand=new aw(e),this._redoCommand=new lw(e),e.commands.add("undo",this._und
2oCommand),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)||(this._batchRegistry.add(n),n.isUndoable&&(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))},{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"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class uw extends yh{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?ld:ad,s="ltr"==t.uiLanguageDirection?ad:ld;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",s)}_addButtonsToFactory(e,t,i,n){const s=this.editor;s.ui.componentFactory.add(e,()=>{const s=this._createButton(nm,e,t,i,n);return s.set({tooltip:!0}),s}),s.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(Em,e,t,i,n))}_createButton(e,t,i,n,s){const o=this.editor,r=o.locale,a=o.commands.get(t),l=new e(r);return l.set({label:i,icon:s,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",()=>{o.execute(t),o.editing.view.focus()}),l}}class hw extends yh{static get requires(){return[cw,uw]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}class dw extends kh{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=Xo(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&mw(t,e.schema)}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change(e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&mw(n,t.schema)&&e.rename(n,"paragraph")})}}function mw(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class fw extends kh{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;return t.canEditAt(n)?t.change(e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return null;const s=e.createElement("paragraph");return i&&t.schema.setAllowedAttributes(s,i,e),t.insertContent(s,n),e.setSelection(s,"in"),e.createPositionAt(s,0)}):null}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const s=e.parent,o=i.schema.checkChild(s,"$text");return s.isEmpty||o&&e.isAtEnd?i.createPositionAfter(s):!s.isEmpty&&o&&e.isAtStart?i.createPositionBefore(s):t.split(e,n).position}}class gw extends yh{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new dw(e)),e.commands.add("insertParagraph",new fw(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,t)=>{let{writer:i}=t;return gw.paragraphLikeElements.has(e.name)?e.isEmpty?null:i.createElement("paragraph"):null},view:/.+/,converterPriority:"low"})}}(0,o.A)(gw,"paragraphLikeElements",new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]));class pw extends kh{constructor(e,t){super(e),(0,o.A)(this,"modelElements",void 0),this.modelElements=t}refresh(){const e=Xo(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>_w(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=>_w(e,n,t.schema));for(const t of s)t.is("element",n)||e.rename(t,n)})}}function _w(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const ww="paragraph";class bw extends yh{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}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[gw]}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
2:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new pw(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",ww)&&0===s.childCount&&n.writer.rename(s,ww)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:ms.low+1})}}class vw extends yh{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}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 Yo,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new og({label:e.title,class:e.class,role:"menuitemradio",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 u=cf(t);return df(u,r,{ariaLabel:s,role:"menu"}),u.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),u.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),u.bind("isEnabled").toMany(c,"isEnabled",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t.some(e=>e)}),u.buttonView.bind("label").to(a,"value",l,"value",(e,t)=>{const i=t?"paragraph":e;return"boolean"===typeof i?n:o[i]?o[i]:n}),u.buttonView.bind("ariaLabel").to(a,"value",l,"value",(e,t)=>{const i=t?"paragraph":e;return"boolean"===typeof i?s:o[i]?"".concat(o[i],", ").concat(s):s}),this.listenTo(u,"execute",t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()}),u}),e.ui.componentFactory.add("menuBar:heading",n=>{const s=new fg(n),o=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[o],l=new gg(n);s.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),s.buttonView.set({label:t("Heading")}),s.panelView.children.add(l);for(const t of i){const i=new Mf(n,s),c=new Em(n);i.children.add(c),l.items.add(i),c.set({isToggleable:!0,label:t.title,role:"menuitemradio",class:t.class}),c.delegate("execute").to(s),c.on("execute",()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()}),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(o,"value",e=>e===t.model)}return s.bind("isEnabled").toMany(a,"isEnabled",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t.some(e=>e)}),s})}}function yw(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function Aw(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return s(e);return("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:s(e)};function s(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function kw(e,t){const i=Xo(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function Ew(e){return e&&e.endsWith("px")?parseInt(e):null}function Cw(e){const t=Ew(e.getStyle("width")),i=Ew(e.getStyle("height"));return!(!t||!i)}const Pw=/^(image|image-inline)$/;class Tw extends yh{constructor(){super(...arguments),(0,o.A)(this,"_domEmitter",new(to()))}static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=this.editor,o=s.model,a=o.document.selection,l=xw(s,t||a,i);e=(0,r.A)((0,r.A)({},Object.fromEntries(a.getAttributes())),e);for(const r in e)o.schema.checkAttribute(l,r)||delete e[r];return o.change(i=>{const{setImageSizes:s=!0}=n,r=i.createElement(l,e);return o.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==l?void 0:"auto"}),r.parent?(s&&this.setImageNaturalSizeAttributes(r),r):null})}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change(i=>{const n=new Jn.window.Image;this._domEmitter.listenTo(n,"load",()=>{e.getAttribute("width")||e.getAttribute("height")||this.editor.model.enqueueChange(i.batch,t=>
2{t.setAttribute("width",n.naturalWidth,e),t.setAttribute("height",n.naturalHeight,e)}),this._domEmitter.stopListening(n,"load")}),n.src=t}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:Pw})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){const i=xw(e,t,null);if("imageBlock"==i){const i=function(e,t){const i=Kp(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return zp(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?"".concat(t," ").concat(i):i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&Up(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function xw(e,t,i){const n=e.model.schema,s=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===s?"imageInline":"auto"!==s?"imageBlock":t.is("selection")?kw(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class Dw extends kh{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,s=i.getClosestSelectedImageElement(n.document.selection);n.change(t=>{t.setAttribute("alt",e.newValue,s)})}}class Sw extends yh{static get requires(){return[Tw]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new Dw(this.editor))}}class Iw extends Qd{constructor(e){super(e),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"labeledInput",void 0),(0,o.A)(this,"saveButtonView",void 0),(0,o.A)(this,"cancelButtonView",void 0),(0,o.A)(this,"_focusables",void 0),(0,o.A)(this,"_focusCycler",void 0);const t=this.locale.t;this.focusTracker=new er,this.keystrokes=new sr,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),Hh,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),zh,"ck-button-cancel","cancel"),this._focusables=new xd,this._focusCycler=new rm({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),em({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const s=new nm(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}
2_createLabeledInputView(){const e=this.locale.t,t=new Nm(this.locale,_f);return t.label=e("Text alternative"),t}}function Ow(e){const t=e.editing.view,i=Qm.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class Fw extends yh{constructor(){super(...arguments),(0,o.A)(this,"_balloon",void 0),(0,o.A)(this,"_form",void 0)}static get requires(){return[ag]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&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 nm(i);return s.set({label:t("Change image text alternative"),icon:Gh,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>!!e),this.listenTo(s,"execute",()=>{this._showForm()}),s})}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Xd(Iw))(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",()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=Ow(e);t.updatePosition(i)}}(e):this._hideForm(!0)}),Yd({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();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:Ow(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class Bw extends yh{static get requires(){return[Sw,Fw]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function Mw(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);null===i.attributeNewValue?(s.removeAttribute("srcset",r),s.removeAttribute("sizes",r)):i.attributeNewValue&&(s.setAttribute("srcset",i.attributeNewValue,r),s.setAttribute("sizes","100vw",r))};return e=>{e.on("attribute:srcset:".concat(t),i)}}function Rw(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);s.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on("attribute:".concat(i,":").concat(t),n)}}class Vw extends Qa{observe(e){this.listenTo(e,"load",(e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class Nw extends kh{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&ps("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&ps("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=Jo(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((t,o)=>{const a=i.getSelectedElement();if("string"===typeof t&&(t={src:t}),o&&a&&n.isImage(a)){const i=this.editor.model.createPositionAfter(a);n.insertImage((0,r.A)((0,r.A)({},t),s),i,e.imageType)}else e.breakBlock?n.insertImage((0,r.A)((0,r.A)({},t),s),i.getFirstPosition(),e.imageType):n.insertImage((0,r.A)((0,r.A)({},t),s),null,e.imageType)})}}class Lw extends kh{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change(n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)})}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class jw extends yh{static get requires(){return[Tw]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Vw),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new Nw(e),n=new Lw(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class Ww extends yh{static get requires(){return[Tw]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function s(t,n,s,o){let r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];t.on("attribute:".concat(n,":").concat(e),(t,n,a)=>
2{if(!a.consumable.consume(n.item,t.name))return;const l=a.writer,c=a.mapper.toViewElement(n.item),u=i.findViewImgElement(c);null!==n.attributeNewValue?l.setAttribute(s,n.attributeNewValue,u):l.removeAttribute(s,u);const h=n.item.getAttribute("width"),d=n.item.getAttribute("height"),m=h&&d;if(m&&r&&l.setAttribute("loading","lazy",u),n.item.hasAttribute("sources"))return;const f=n.item.hasAttribute("resizedWidth");("imageInline"!==e||f||o)&&m&&l.setStyle("aspect-ratio","".concat(h,"/").concat(d),u)})}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>Cw(e)?Ew(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>Cw(e)?Ew(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add(e=>{s(e,"width","width",!0,!0),s(e,"height","height",!0,!0)}),t.conversion.for("dataDowncast").add(e=>{s(e,"width","width",!1),s(e,"height","height",!1)})}}class qw extends kh{constructor(e,t){super(e),(0,o.A)(this,"_modelElementName",void 0),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection),o=Object.fromEntries(s.getAttributes());return o.src||o.uploadId?i.change(t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter(e=>e.getRange().containsItem(s)),l=n.insertImage(o,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:s,newElement:l}}):null}}class Uw extends yh{static get requires(){return[Tw]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add(e=>{e.on("attribute:placeholder",(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const s=n.writer,o=n.mapper.toViewElement(t.item),r=i.findViewImgElement(o);t.attributeNewValue?(s.addClass("image_placeholder",r),s.setStyle("background-image","url(".concat(t.attributeNewValue,")"),r),s.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(s.removeClass("image_placeholder",r),s.removeStyle("background-image",r))})})}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,s=e.plugins.get("ImageUtils");n.addObserver(Vw),this.listenTo(n.document,"imageLoaded",(e,o)=>{const r=n.domConverter.mapDomToView(o.target);if(!r)return;const a=s.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},e=>{e.removeAttribute("placeholder",l)})})}}class zw extends yh{static get requires(){return[jw,Ww,Tw,Uw,f_]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new qw(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");
2i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,t)=>{let{writer:i}=t;return yw(i)}}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,i)=>{let{writer:s}=i;return n.toImageWidget(yw(s),s,t("image widget"))}}),i.for("downcast").add(Rw(n,"imageBlock","src")).add(Rw(n,"imageBlock","alt")).add(Mw(n,"imageBlock")),i.for("upcast").elementToElement({view:Aw(e,"imageBlock"),model:(e,t)=>{let{writer:i}=t;return i.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=e.findViewImgElement(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const o=Xo(n.convertItem(s,i.modelCursor).modelRange.getItems());o?(n.convertChildren(i.viewItem,o),n.updateConversionResult(o,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===kw(t.schema,l)){const e=new hh(i.document),t=r.map(t=>e.createElement("figure",{class:"image"},t));o.content=e.createDocumentFragment(t)}}),this.listenTo(s,"contentInsertion",(e,i)=>{"paste"===i.method&&t.change(e=>{const t=e.createRangeIn(i.content);for(const i of t.getItems())i.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(i)})})}}class Hw extends Qd{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];super(e),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"_focusables",void 0),(0,o.A)(this,"_focusCycler",void 0),(0,o.A)(this,"children",void 0),this.focusTracker=new er,this.keystrokes=new sr,this._focusables=new xd,this.children=this.createCollection(),this._focusCycler=new rm({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const i of t)this.children.add(i),this._focusables.add(i),i instanceof Vm&&this._focusables.addMany(i.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),em({view:this});for(const t of this._focusables)this.focusTracker.add(t.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)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class $w extends yh{static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Tw]}constructor(e){super(e),(0,o.A)(this,"dropdownView",void 0),(0,o.A)(this,"_integrations",new Map),e.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",()=>{this.isImageSelected=i.isImage(t.getSelectedElement())});const n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n),e.ui.componentFactory.add("menuBar:insertImage",e=>this._createMenuBarComponent(e))}registerIntegration(e){let{name:t,observable:i,buttonViewCreator:n,formViewCreator:s,menuBarButtonViewCreator:o,requiresForm:r=!1,override:a=!1}=e;this._integrations.has(t)&&!a&&ps("image-insert-integration-exists",{name:t}),this._integrations.set(t,{observable:i,buttonViewCreator:n,menuBarButtonViewCreator:o,formViewCreator:s,requiresForm:r})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let s;const o=n[0];if(1==n.length){if(!o.requiresForm)return o.buttonViewCreator(!0);s=o.buttonViewCreator(!0)}else{const t=o.buttonViewCreator(!1);s=new lf(e,t),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",e=>i(e?"Replace image":"Insert image"))}const r=this.dropdownView=cf(e,s),a=n.map(e=>{let{observable:t}=e;return"function"==typeof t?t():t});return r.bind("isEnabled").toMany(a,"isEnabled",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t.some(e=>e)}),r.once("change:isOpen",()=>{const e=n.flatMap(e=>{let{formViewCreator:t}=e;return t(1==n.length)}),i=new Hw(t.locale,e);r.panelView.children.add(i)}),r}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const n=i.flatMap(e=>{let{menuBarButtonViewCreator:t}=e;return t(1==i.length)}),s=new fg(e),o=new gg(e);s.panelView.children.add(o),s.buttonView.set({icon:$h,label:t("Image")});for(const r of n){const t=new Mf(e,s);t.children.add(r),o.items.add(t),r.delegate("execute").to(s)}return s}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return ps("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||ps("image-insert-unknown-integration",{item:i});return t.length||ps("image-insert-integrations-not-registered"),t}}class Kw extends yh{static get requires(){return[zw,o_,Bw,$w]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class Gw extends yh{static get requires(){return[jw,Ww,Tw,Uw,f_]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;
2e.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new qw(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,t)=>{let{writer:i}=t;return i.createEmptyElement("img")}}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,i)=>{let{writer:s}=i;return n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(s),s,t("image widget"))}}),i.for("downcast").add(Rw(n,"imageInline","src")).add(Rw(n,"imageInline","alt")).add(Mw(n,"imageInline")),i.for("upcast").elementToElement({view:Aw(e,"imageInline"),model:(e,t)=>{let{writer:i}=t;return i.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===kw(t.schema,l)){const e=new hh(i.document),t=r.map(t=>1===t.childCount?(Array.from(t.getAttributes()).forEach(i=>e.setAttribute(...i,n.findViewImgElement(t))),t.getChild(0)):t);o.content=e.createDocumentFragment(t)}}),this.listenTo(s,"contentInsertion",(e,i)=>{"paste"===i.method&&t.change(e=>{const t=e.createRangeIn(i.content);for(const i of t.getItems())i.is("element","imageInline")&&n.setImageNaturalSizeAttributes(i)})})}}class Jw extends yh{static get requires(){return[Gw,o_,Bw,$w]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}function Zw(e){const t=e.map(e=>e.replace("+","\\+"));return new RegExp("^image\\/(".concat(t.join("|"),")$"))}function Qw(e){return new Promise((t,i)=>{const n=e.getAttribute("src");fetch(n).then(e=>e.blob()).then(e=>{const i=Yw(e,n),s=i.replace("image/",""),o="image.".concat(s),r=new File([e],o,{type:i});t(r)}).catch(e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise((t,i)=>{const n=Jn.document.createElement("img");n.addEventListener("load",()=>{const e=Jn.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})}(e).then(t=>{const i=Yw(t,e),n=i.replace("image/",""),s="image.".concat(n);return new File([t],s,{type:i})})}(n).then(t).catch(i):i(e))})}function Yw(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class Xw extends yh{static get pluginName(){return"ImageUploadUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("uploadImage",()=>this._createToolbarButton()),e.ui.componentFactory.add("imageUpload",()=>this._createToolbarButton()),e.ui.componentFactory.add("menuBar:uploadImage",()=>this._createMenuBarButton("standalone")),e.plugins.has("ImageInsertUI")&&e.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),o=Zw(s),r=new e(t.locale),a=i.t;return r.set({acceptedType:s.map(e=>"image/".concat(e)).join(","),allowMultipleFiles:!0,label:a("Upload from computer"),icon:Kh}),r.bind("isEnabled").to(n),r.on("done",(e,i)=>{const n=Array.from(i).filter(e=>o.test(e.type));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())}),r}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),n=this._createButton(Om);return n.tooltip=!0,n.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",(t,i)=>e(i?t?"Replace image from computer":"Upload image from computer":"You have no image upload permissions.")),n}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(Om);return i.withText=!0,i.bind("label").to(t,"isImageSelected",t=>e(t?"Replace from computer":"Upload from computer")),i.on("execute",()=>{t.dropdownView.isOpen=!1}),i}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createButton(_g);switch(i.withText=!0,e){case"standalone":i.label=t("Image from computer");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("From computer")}return i}}class eb extends yh{static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"placeholder",void 0),(0,o.A)(this,"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("ImageUtils"),a=n.plugins.get(gd),l=o?t.attributeNewValue:null,c=this.placeholder,u=n.editing.mapper.toViewElement(s),h=i.writer;if("reading"==l)return tb(u,h),void ib(r,c,u,h);if("uploading"==l){const e=a.loaders.get(o);return tb(u,h),void(e?(nb(u,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)})})}(u,h,e,n.editing.view),function(e,t,i,n){if(n.data){const s=e.findViewImgElement(t);i.setAttribute("src",n.data,s)}}(r,u,h,e)):ib(r,c,u,h))}"complete"==l&&a.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)}(u,h,n.editing.view),function(e,t){ob(e,t,"progressBar")}(u,h),nb(u,h),function(e,t){t.removeClass("ck-appear",e)}(u,h)}),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function tb(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function ib(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const s=e.findViewImgElement(i);s.getAttribute("src")!==t&&n.setAttribute("src",t,s),sb(i,"placeholder")||n.insert(n.createPositionAfter(s),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function nb(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),ob(e,t,"placeholder")}
2function sb(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function ob(e,t,i){const n=sb(e,i);n&&t.remove(t.createRangeOn(n))}class rb extends kh{constructor(e){super(e),this.set("isAccessAllowed",!0)}refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=Jo(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((e,t)=>{const o=i.getSelectedElement();if(t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);this._uploadImage(e,s,t)}else this._uploadImage(e,s)})}_uploadImage(e,t,i){const n=this.editor,s=n.plugins.get(gd).createLoader(e),o=n.plugins.get("ImageUtils");s&&o.insertImage((0,r.A)((0,r.A)({},t),{},{uploadId:s.id}),i)}}class ab extends yh{static get requires(){return[gd,sg,f_,Tw]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"_uploadImageElements",void 0),(0,o.A)(this,"_uploadedImages",new Map),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(gd),s=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline"),r=Zw(e.config.get("image.upload.types")),a=new rb(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add(e=>e.on("element:img",(e,t,i)=>{if(!i.consumable.test(t.viewItem,{attributes:["data-ck-upload-id"]}))return;const s=t.viewItem.getAttribute("data-ck-upload-id");if(!s)return;const[o]=Array.from(t.modelRange.getItems({shallow:!0})),r=n.loaders.get(s);o&&(i.writer.setAttribute("uploadId",s,o),i.consumable.consume(t.viewItem,{attributes:["data-ck-upload-id"]}),r&&r.data&&i.writer.setAttribute("uploadStatus",r.status,o))},{priority:"low"})),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&&r.test(e.type));if(!s.length)return;t.stop(),e.model.change(t=>{i.targetRanges&&t.setSelection(i.targetRanges.map(t=>e.editing.mapper.toModelRange(t))),e.execute("uploadImage",{file:s})});if(!e.commands.get("uploadImage").isAccessAllowed){const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("You have no image upload permissions."),{namespace:"image"})}}),this.listenTo(o,"inputTransformation",(t,i)=>{const o=Array.from(e.editing.view.createRangeIn(i.content)).map(e=>e.item).filter(e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src"))&&(!!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||!!t.getAttribute("src").match(/^blob:/g))}(s,e)&&!e.getAttribute("uploadProcessed")).map(e=>({promise:Qw(e),imageElement:e}));if(!o.length)return;const r=new hh(e.editing.view.document);for(const e of o){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.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}).reverse(),s=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,o="$graveyard"==t.position.root.rootName;for(const t of lb(e,i)){const i=t.getAttribute("uploadId");if(!i)continue;const r=n.loaders.get(i);if(r)if(o){if(!s.has(i)){Array.from(this._uploadImageElements.get(i)).every(e=>"$graveyard"==e.root.rootName)&&r.abort()}}else s.add(i),this._uploadImageElements.has(i)?this._uploadImageElements.get(i).add(t):this._uploadImageElements.set(i,new Set([t])),"idle"==r.status&&this._readAndUpload(r);else!o&&this._uploadedImages.has(i)&&e.model.enqueueChange({isUndoable:!1},e=>{e.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:this._uploadedImages.get(i),imageElement:t})})}}}),this.on("uploadComplete",(e,t)=>{let{imageElement:i,data:n}=t;const o=n.urls?n.urls:n;this.editor.model.change(e=>{e.setAttribute("src",o.default,i),this._parseAndSetSrcsetAttributeOnImage(o,i,e),s.setImageNaturalSizeAttributes(i)})},{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageBlock")),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageInline"))}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,s=t.plugins.get(gd),o=t.plugins.get(sg),r=t.plugins.get("ImageUtils"),a=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},t=>{const i=a.get(e.id);for(const e of i)t.setAttribute("uploadStatus","reading",e)}),e.read().then(()=>{const s=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Uploading image"));for(const n of a.get(e.id)){if(Yn.isSafari){const e=t.editing.mapper.toViewElement(n),i=r.findViewImgElement(e);t.editing.view.once("render",()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n})}i.enqueueChange({isUndoable:!1},e=>
2{e.setAttribute("uploadStatus","uploading",n)})}return s}).then(s=>{i.enqueueChange({isUndoable:!1},i=>{for(const t of a.get(e.id))i.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:s,imageElement:t});t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Image upload complete")),this._uploadedImages.set(e.id,s)}),l()}).catch(s=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw s;"error"==e.status&&s&&o.showWarning(s,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},t=>{for(const i of a.get(e.id))"$graveyard"!==i.root.rootName&&t.remove(i)}),l()});function l(){i.enqueueChange({isUndoable:!1},t=>{for(const i of a.get(e.id))t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i);a.delete(e.id)}),s.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=>"".concat(e[t]," ").concat(t,"w")).join(", ");if(""!=s){const e={srcset:s};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,n=i.get(gd),s=i.get(Tw);t.for("dataDowncast").add(t=>{t.on("attribute:uploadId:".concat(e),(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n.loaders.get(t.attributeNewValue);if(!o||!o.data)return null;const r=i.mapper.toViewElement(t.item),a=s.findViewImgElement(r);a&&(i.consumable.consume(t.item,e.name),i.writer.setAttribute("data-ck-upload-id",o.id,a))})})}}function lb(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter(e=>i.isImage(e.item)).map(e=>e.item)}class cb extends yh{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new Ch(e)),e.commands.add("outdent",new Ch(e))}}class ub extends yh{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?dd:md,s="ltr"==t.uiLanguageDirection?md:dd;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,()=>{const n=this._createButton(nm,e,t,i);return n.set({tooltip:!0}),n}),n.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(Em,e,t,i))}_createButton(e,t,i,n){const s=this.editor,o=s.commands.get(t),r=new e(s.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(o,"isEnabled"),this.listenTo(r,"execute",()=>{s.execute(t),s.editing.view.focus()}),r}}class hb{constructor(){(0,o.A)(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;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,s=n.document.selection;for(const o of this._definitions){const e=n.createAttributeElement("a",o.attributes,{priority:5});o.classes&&n.addClass(o.classes,e);for(const t in o.styles)n.setStyle(t,o.styles[t],e);n.setCustomProperty("link",!0,e),o.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(s.getFirstRange(),e):n.wrap(i.mapper.toViewRange(t.range),e):n.unwrap(i.mapper.toViewRange(t.range),e)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",(e,t,i)=>{let{writer:n,mapper:s}=i;const o=s.toViewElement(t.item),r=Array.from(o.getChildren()).find(e=>e.is("element","a"));if(r)for(const a of this._definitions){const e=or(a.attributes);if(a.callback(t.attributeNewValue)){for(const[t,i]of e)"class"===t?n.addClass(i,r):n.setAttribute(t,i,r);a.classes&&n.addClass(a.classes,r);for(const e in a.styles)n.setStyle(e,a.styles[e],r)}else{for(const[t,i]of e)"class"===t?n.removeClass(i,r):n.removeAttribute(t,r);a.classes&&n.removeClass(a.classes,r);for(const e in a.styles)n.removeStyle(e,r)}}})}}}const db=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,mb=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,fb=/^((\w+:(\/{2,})?)|(\W))/i,gb=["https?","ftps?","mailto"],pb="Ctrl+K";
2function _b(e,t){let{writer:i}=t;const n=i.createAttributeElement("a",{href:e},{priority:5});return i.setCustomProperty("link",!0,n),n}function wb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gb;const i=String(e),n=t.join("|");return function(e,t){const i=e.replace(db,"");return!!i.match(t)}(i,new RegExp("".concat("^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("<protocols>",n)),"i"))?i:"#"}function bb(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function vb(e,t){const i=(n=e,mb.test(n)?"mailto:":t);var n;const s=!!i&&!yb(e);return e&&s?i+e:e}function yb(e){return fb.test(e)}function Ab(e){window.open(e,"_blank","noopener")}function kb(e){const t=e.plugins.has("BookmarkEditing")?e.plugins.get("BookmarkEditing"):null;return{isScrollableToTarget:function(e){return!!e&&e.startsWith("#")&&!!t&&!!t.getElementForBookmarkId(e.slice(1))},scrollToTarget:function(i){const n=i.slice(1),s=t.getElementForBookmarkId(n);e.model.change(e=>{e.setSelection(s,"on")}),e.editing.view.scrollToTheSelection({alignToTop:!0,forceScroll:!0})}}}class Eb extends kh{constructor(){super(...arguments),(0,o.A)(this,"manualDecorators",new Yo),(0,o.A)(this,"automaticDecorators",new hb)}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||Xo(t.getSelectedBlocks());bb(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const n of this.manualDecorators)n.value=this._getDecoratorStateFromModel(n.id)}execute(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.editor.model,n=i.document.selection,s=[],o=[];for(const r in t)t[r]?s.push(r):o.push(r);i.change(t=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=Cb(n);let l=ep(r,"linkHref",n.getAttribute("linkHref"),i);n.getAttribute("linkHref")===a&&(l=this._updateLinkContent(i,t,l,e)),t.setAttribute("linkHref",e,l),s.forEach(e=>{t.setAttribute(e,!0,l)}),o.forEach(e=>{t.removeAttribute(e,l)}),t.setSelection(t.createPositionAfter(l.end.nodeBefore))}else if(""!==e){const o=or(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 c of l){let r=c;if(1===l.length){const s=Cb(n);n.getAttribute("linkHref")===s&&(r=this._updateLinkContent(i,t,c,e),t.setSelection(t.createSelection(r)))}t.setAttribute("linkHref",e,r),s.forEach(e=>{t.setAttribute(e,!0,r)}),o.forEach(e=>{t.removeAttribute(e,r)})}}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return bb(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}_updateLinkContent(e,t,i,n){const s=t.createText(n,{linkHref:n});return e.insertContent(s,i)}}function Cb(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const i=t[0];return i.is("$text")||i.is("$textProxy")?i.data:null}}class Pb extends kh{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();bb(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"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?[ep(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)})}}class Tb extends(Ns()){constructor(e){let{id:t,label:i,attributes:n,classes:s,styles:r,defaultValue:a}=e;super(),(0,o.A)(this,"id",void 0),(0,o.A)(this,"defaultValue",void 0),(0,o.A)(this,"label",void 0),(0,o.A)(this,"attributes",void 0),(0,o.A)(this,"classes",void 0),(0,o.A)(this,"styles",void 0),this.id=t,this.set("value",void 0),this.defaultValue=a,this.label=i,this.attributes=n,this.classes=s,this.styles=r}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const xb="automatic",Db=/^(https?:)?\/\//;class Sb extends yh{static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[jg,Cg,f_]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:_b}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>_b(wb(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new Eb(e)),e.commands.add("unlink",new Pb(e));const i=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};
2return t.forEach(e=>("label"in e&&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".concat(ci(i))});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(e=>e.mode===xb)),this._enableManualDecorators(i.filter(e=>"manual"===e.mode));e.plugins.get(jg).registerAttribute("linkHref"),ip(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:xb,callback:e=>!!e&&Db.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});const n=new Tb(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,t,i)=>{let{writer:s,schema:o}=t,{item:r}=i;if((r.is("selection")||o.isInline(r))&&e){const e=s.createAttributeElement("a",n.attributes,{priority:5});n.classes&&s.addClass(n.classes,e);for(const t in n.styles)s.setStyle(t,n.styles[t],e);return s.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:(0,r.A)({name:"a"},n._createPattern()),model:{key:n.id}})})}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=kb(e);function n(e){i.isScrollableToTarget(e)?i.scrollToTarget(e):Ab(e)}this.listenTo(t,"click",(e,t)=>{if(!(Yn.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let i=t.domTarget;if("a"!=i.tagName.toLowerCase()&&(i=i.closest("a")),!i)return;const s=i.getAttribute("href");s&&(e.stop(),t.preventDefault(),n(s))},{context:"$capture"}),this.listenTo(t,"keydown",(t,i)=>{const s=e.commands.get("link").value;!!s&&i.keyCode===jo.enter&&i.altKey&&(t.stop(),n(s))})}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",(i,n)=>{let{attributeKeys:s}=n;s.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change(t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter(e=>e.startsWith("link"))))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(e,n)=>{t.change(e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=vb(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}})})}}class Ib extends Qd{constructor(e,t,i){super(e),(0,o.A)(this,"focusTracker",new er),(0,o.A)(this,"keystrokes",new sr),(0,o.A)(this,"urlInputView",void 0),(0,o.A)(this,"saveButtonView",void 0),(0,o.A)(this,"cancelButtonView",void 0),(0,o.A)(this,"_manualDecoratorSwitches",void 0),(0,o.A)(this,"children",void 0),(0,o.A)(this,"_validators",void 0),(0,o.A)(this,"_focusables",new xd),(0,o.A)(this,"_focusCycler",void 0);const n=e.t;this._validators=i,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Hh,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),zh,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new rm({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const s=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&s.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:s,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((e,t)=>
2(e[t.name]=t.isOn,e),{})}render(){super.render(),em({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)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}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}_createUrlInput(){const e=this.locale.t,t=new Nm(this.locale,_f);return t.fieldView.inputMode="url",t.label=e("Link URL"),t}_createButton(e,t,i,n){const s=new nm(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 Im(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 Qd;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}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class Ob extends Qd{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;super(e),(0,o.A)(this,"focusTracker",new er),(0,o.A)(this,"keystrokes",new sr),(0,o.A)(this,"previewButtonView",void 0),(0,o.A)(this,"unlinkButtonView",void 0),(0,o.A)(this,"editButtonView",void 0),(0,o.A)(this,"_focusables",new xd),(0,o.A)(this,"_focusCycler",void 0),(0,o.A)(this,"_linkConfig",void 0),(0,o.A)(this,"_options",void 0);const n=e.t;this._options=i,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(n("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(n("Edit link"),id,"edit"),this.set("href",void 0),this._linkConfig=t,this._focusCycler=new rm({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)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new nm(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new nm(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",e=>e&&wb(e,this._linkConfig.allowedProtocols)),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to(e=>{this._options&&this._options.isScrollableToTarget(this.href)?(e.preventDefault(),this._options.scrollToTarget(this.href)):Ab(this.href)})}}),e.bind("tooltip").to(this,"href",e=>this._options&&this._options.isScrollableToTarget(e)?i("Scroll to target"):i("Open link in new tab")),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}}const Fb="link-ui";class Bb extends yh{constructor(){super(...arguments),(0,o.A)(this,"actionsView",null),(0,o.A)(this,"formView",null),(0,o.A)(this,"_balloon",void 0)}static get requires(){return[ag]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.editing.view.addObserver(lh),this._balloon=e.plugins.get(ag),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:Fb,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Fb,view:(e,t)=>
2{let{writer:i}=t;if(!e.markerRange.isCollapsed)return null;const n=i.createUIElement("span");return i.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],n),n}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:pb},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new Ob(e.locale,e.config.get("link"),kb(e)),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(pb,(e,t)=>{this._addFormView(),t()}),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new(Xd(Ib))(e.locale,t,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isEnabled").to(t,"isEnabled"),n.saveButtonView.bind("isEnabled").to(t,"isEnabled"),this.listenTo(n,"submit",()=>{if(n.isValid()){const{value:t}=n.urlInputView.fieldView.element,s=vb(t,i);e.execute("link",s,n.getDecoratorSwitchesState()),this._closeFormView()}}),this.listenTo(n.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(n,"cancel",()=>{this._closeFormView()}),n.keystrokes.set("Esc",(e,t)=>{this._closeFormView(),t()}),n}_createToolbarLinkButton(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const e=this._createButton(nm);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:link",()=>{const e=this._createButton(Em);return e.set({role:"menuitemcheckbox"}),e})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),s=new e(t.locale),o=i.t;return s.set({label:o("Link"),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>',keystroke:pb,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>!!e),this.listenTo(s,"execute",()=>this._showUI(!0)),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(pb,(t,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)})}_enableUserBalloonInteractions(){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())}),Yd({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_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.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.formView||this._createViews(),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._startUpd
2atingUI()}_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.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n;if(t.markers.has(Fb)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(Fb)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&Up(i))return Mb(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=Mb(i.start),s=Mb(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(Fb))t.updateMarker(Fb,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(t=>{let{item:i}=t;return!e.schema.isContent(i)},{boundaries:i});t.addMarker(Fb,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(Fb,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Fb)&&e.change(e=>{e.removeMarker(Fb)})}}function Mb(e){return e.getAncestors().find(e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t})||null}const Rb=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 Vb extends yh{static get requires(){return[Rg,Sb]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}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(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?ep(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,s=n.getFirstPosition(),o=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,s)||t);r&&(r=r.getJoined(this._expandLinkRange(i,o)||t)),r&&(r.start.isBefore(s)||r.end.isAfter(o))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");n.on("inputTransformation",(e,n)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const o=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(Rb);a&&a[2]===r&&(t.change(e=>{this._selectEntireLinks(e,o),s.execute(r)}),e.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new Lg(e.model,e=>{let t=e;if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(t))return;t=t.slice(0,-1),"!.:,;?".includes(t[t.length-1])&&(t=t.slice(0,-1));const i=Nb(t);return i?{url:i,removedTrailingCharacters:e.length-t.length}:void 0});t.on("matched:data",(t,i)=>{const{batch:n,range:s,url:o,removedTrailingCharacters:r}=i;if(!n.isTyping)return;const a=s.end.getShiftedBy(-r),l=a.getShiftedBy(-o.length),c=e.model.createRange(l,a);
2this._applyAutoLink(o,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}=Ng(e,t),s=Nb(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,n=vb(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&yb(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{n.requestUndoOnBackspace()})})}}function Nb(e){const t=Rb.exec(e);return t?t[2]:null}class Lb{constructor(e,t){(0,o.A)(this,"_startElement",void 0),(0,o.A)(this,"_referenceIndent",void 0),(0,o.A)(this,"_isForward",void 0),(0,o.A)(this,"_includeSelf",void 0),(0,o.A)(this,"_sameAttributes",void 0),(0,o.A)(this,"_sameIndent",void 0),(0,o.A)(this,"_lowerIndent",void 0),(0,o.A)(this,"_higherIndent",void 0),this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=Jo(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){return Xo(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of new jb(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(i<this._referenceIndent){if(!this._lowerIndent)break;this._referenceIndent=i}else if(i>this._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some(e=>t.getAttribute(e)!==this._startElement.getAttribute(e)))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}class jb{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"forward";(0,o.A)(this,"_node",void 0),(0,o.A)(this,"_isForward",void 0),(0,o.A)(this,"_previousNodesByIndent",[]),(0,o.A)(this,"_previous",null),(0,o.A)(this,"_previousNodeIndent",null),this._node=e,this._isForward="forward"===t}[Symbol.iterator](){return this}next(){if(!Ub(this._node))return{done:!0,value:void 0};const e=this._node.getAttribute("listIndent");let t=null;if(this._previous){const i=this._previousNodeIndent;e>i?this._previousNodesByIndent[i]=this._previous:e<i?(t=this._previousNodesByIndent[e]||null,this._previousNodesByIndent.length=e):t=this._previous}const i={node:this._node,previous:this._previous,previousNodeInList:t};return this._previous=this._node,this._previousNodeIndent=e,this._node=this._isForward?this._node.nextSibling:this._node.previousSibling,{value:i,done:!1}}}class Wb{constructor(e){(0,o.A)(this,"_listHead",void 0),this._listHead=e}[Symbol.iterator](){return new jb(this._listHead)}}class qb{static next(){return ds()}}function Ub(e){return!!e&&e.is("element")&&e.hasAttribute("listItemId")}function zb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return[...Hb(e,(0,r.A)((0,r.A)({},t),{},{direction:"backward"})),...Hb(e,(0,r.A)((0,r.A)({},t),{},{direction:"forward"}))]}function Hb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i="forward"==t.direction,n=Array.from(new Lb(e,(0,r.A)((0,r.A)({},t),{},{includeSelf:i,sameIndent:!0,sameAttributes:"listItemId"})));return i?n:n.reverse()}function $b(e,t){const i=new Lb(e,(0,r.A)({sameIndent:!0,sameAttributes:"listType"},t)),n=new Lb(e,(0,r.A)({sameIndent:!0,sameAttributes:"listType",includeSelf:!0,direction:"forward"},t));return[...Array.from(i).reverse(),...n]}function Kb(e){return!Lb.first(e,{sameIndent:!0,sameAttributes:"listItemId"})}function Gb(e){return!Lb.first(e,{direction:"forward",sameIndent:!0,sameAttributes:"listItemId"})}function Jb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=Jo(e);const i=!1!==t.withNested,n=new Set;for(const s of e)for(const e of zb(s,{higherIndent:i}))n.add(e);return tv(n)}function Zb(e,t){const i=Hb(e,{direction:"forward"}),n=qb.next();for(const s of i)t.setAttribute("listItemId",n,s);return i}function Qb(e,t,i){const n={};for(const[o,r]of t.getAttributes())o.startsWith("list")&&(n[o]=r);const s=Hb(e,{direction:"forward"});for(const o of s)i.setAttributes(n,o);return s}function Yb(e,t){let{expand:i,indentBy:n=1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=Jo(e);const s=i?Jb(e):e;for(const o of s){const e=o.getAttribute("listIndent")+n;e<0?Xb(o,t):t.setAttribute("listIndent",e,o)}return s}function Xb(e,t){e=Jo(e);for(const i of e)i.is("element","listItem")&&t.rename(i,"paragraph");for(const i of e)for(const e of i.getAttributeKeys())e.startsWith("list")&&t.removeAttribute(e,i);return e}function ev(e){if(!e.length)return!1;const t=e[0].getAttribute("listItemId");return!!t&&!e.some(e=>e.getAttribute("listItemId")!=t)}function tv(e){return Array.from(e).filter(e=>"$graveyard"!==e.root.rootName).sort((e,t)=>
2e.index-t.index)}function iv(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function nv(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function sv(e,t,i){return Hb(t,{direction:"forward"}).pop().index>e.index?Qb(e,t,i):[]}class ov extends kh{constructor(e,t){super(e),(0,o.A)(this,"_direction",void 0),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=rv(e.document.selection);e.change(e=>{const i=[];ev(t)&&!Kb(t[0])?("forward"==this._direction&&i.push(...Yb(t,e)),i.push(...Zb(t[0],e))):"forward"==this._direction?i.push(...Yb(t,e,{expand:!0})):i.push(...function(e,t){const i=Jb(e=Jo(e)),n=new Set,s=Math.min(...i.map(e=>e.getAttribute("listIndent"))),o=new Map;for(const r of i)o.set(r,Lb.first(r,{lowerIndent:!0}));for(const r of i){if(n.has(r))continue;n.add(r);const e=r.getAttribute("listIndent")-1;if(e<0)Xb(r,t);else{if(r.getAttribute("listIndent")==s){const e=sv(r,o.get(r),t);for(const t of e)n.add(t);if(e.length)continue}t.setAttribute("listIndent",e,r)}}return tv(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=Lb.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)})}_fireAfterExecute(e){this.fire("afterExecute",tv(new Set(e)))}_checkEnabled(){let e=rv(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(ev(e)&&!Kb(e[0]))return!0;e=Jb(e),t=e[0];const i=Lb.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function rv(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex(e=>!Ub(e));return-1!=i&&(t.length=i),t}class av extends kh{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(e),(0,o.A)(this,"type",void 0),(0,o.A)(this,"_listWalkerOptions",void 0),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.editor.model,i=t.document,n=iv(t),s=Array.from(i.selection.getSelectedBlocks()).filter(e=>t.schema.checkAttribute(e,"listType")||nv(e,t.schema)),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change(a=>{if(o){const e=s[s.length-1],t=Hb(e,{direction:"forward"}),i=[];t.length>1&&i.push(...Zb(t[1],a)),i.push(...Xb(s,a)),i.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:s}of new jb(e.nextSibling)){const e=s.getAttribute("listIndent");if(0==e)break;e<n&&(n=e);const o=e-n;t.setAttribute("listIndent",o,s),i.push(s)}return i}(e,a)),this._fireAfterExecute(i)}else if((n||i.selection.isCollapsed)&&Ub(s[0])){const t=$b(n||s[0],this._listWalkerOptions);for(const i of t)a.setAttributes((0,r.A)((0,r.A)({},e.additionalAttributes),{},{listType:this.type}),i);this._fireAfterExecute(t)}else{const i=[];for(const n of s)if(n.hasAttribute("listType"))for(const t of Jb(n,{withNested:!1}))t.getAttribute("listType")!=this.type&&(a.setAttributes((0,r.A)((0,r.A)({},e.additionalAttributes),{},{listType:this.type}),t),i.push(t));else!n.is("element","listItem")&&nv(n,t.schema)&&a.rename(n,"listItem"),a.setAttributes((0,r.A)((0,r.A)({},e.additionalAttributes),{},{listIndent:0,listItemId:qb.next(),listType:this.type}),n),i.push(n);this._fireAfterExecute(i)}})}_fireAfterExecute(e){this.fire("afterExecute",tv(new Set(e)))}_getValue(){const e=this.editor.model.document.selection,t=Array.from(e.getSelectedBlocks());if(!t.length)return!1;for(const i of t)if(i.getAttribute("listType")!=this.type)return!1;return!0}_checkEnabled(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=Array.from(i.getSelectedBlocks());if(!n.length)return!1;if(this.value)return!0;for(const s of n)if(t.checkAttribute(s,"listType")||nv(s,t))return!0;return!1}}class lv extends kh{constructor(e,t){super(e),(0,o.A)(this,"_direction",void 0),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){let{shouldMergeOnBlocksContentLevel:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.editor.model,i=t.document.selection,n=[];t.change(s=>{const{firstElement:o,lastElement:r}=this._getMergeSubjectElements(i,e),a=o.getAttribute("listIndent")||0,l=r.getAttribute("listIndent"),c=r.getAttribute("listItemId");if(a!=l){const e=(u=r,Array.from(new Lb(u,{direction:"forward",higherIndent:!0})));n.push(...Yb([r,...e],s,{indentBy:a-l,expand:a<l}))}var u;if(e){let e=i;i.isCollapsed&&(e=s.createSelection(s.createRange(s.createPositionAt(o,"end"),s.createPositionAt(r,0)))),t.deleteContent(e,{doNotResetEntireContent:i.isCollapsed});const a=e.getLastPosition().parent,l=a.nextSibling;n.push(a),l&&l!==r&&l.getAttribute("listItemId")==c&&n.push(...Qb(l,a,s))}else n.push(...Qb(r,o,s));this._fireAfterExecute(n)})}_fireAfterExecute(e){this.fire("afterExecute",tv(new Set(e)))}_checkEnabled(){const e=this.editor.model,t=e.document.selection,i=iv(e);if(t.isCollapsed||i){const e=i||t.getFirstPosition().parent;if(!Ub(e))return!1;const n="backward"==this._direction?e.previousSibling:e.nextSibling;if(!n)return!1;
2if(ev([e,n]))return!1}else{const e=t.getLastPosition(),i=t.getFirstPosition();if(e.parent===i.parent)return!1;if(!Ub(e.parent))return!1}return!0}_getMergeSubjectElements(e,t){const i=iv(this.editor.model);let n,s;if(e.isCollapsed||i){const o=i||e.getFirstPosition().parent,r=Kb(o);"backward"==this._direction?(s=o,n=r&&!t?Lb.first(o,{sameIndent:!0,lowerIndent:!0}):o.previousSibling):(n=o,s=o.nextSibling)}else n=e.getFirstPosition().parent,s=e.getLastPosition().parent;return{firstElement:n,lastElement:s}}}class cv extends kh{constructor(e,t){super(e),(0,o.A)(this,"_direction",void 0),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){this.editor.model.change(e=>{const t=Zb(this._getStartBlock(),e);this._fireAfterExecute(t)})}_fireAfterExecute(e){this.fire("afterExecute",tv(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&Ub(t)&&!Kb(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class uv extends yh{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(e){return function(e){e=Jo(e);const t=new Set;for(const i of e)for(const e of $b(i))t.add(e);return tv(t)}(e)}isFirstBlockOfListItem(e){return Kb(e)}isListItemBlock(e){return Ub(e)}expandListBlocksToCompleteItems(e){return Jb(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}isNumberedListType(e){return function(e){return"numbered"==e||"customNumbered"==e}(e)}}function hv(e){return e.is("element","ol")||e.is("element","ul")}function dv(e){return e.is("element","li")}function mv(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:pv(i,t);return e.createAttributeElement(gv(i),null,{priority:2*t/100-100,id:n})}function fv(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function gv(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function pv(e,t){return"list-".concat(e,"-").concat(t)}function _v(e,t,i){const n=e.nodeBefore;if(Ub(n)){let e=n;for(const{node:s}of new jb(e,"backward")){if(e=s,i.has(e))return;if(i.add(e),t.has(n))return}t.add(e)}else{const i=e.nodeAfter;Ub(i)&&t.add(i)}}function wv(){return(e,t,i)=>{const{writer:n,schema:s}=i;if(!t.modelRange)return;const o=Array.from(t.modelRange.getItems({shallow:!0})).filter(e=>s.checkAttribute(e,"listItemId"));if(!o.length)return;const r=qb.next(),a=function(e){let t=0,i=e.parent;for(;i;){if(dv(i))t++;else{const e=i.previousSibling;e&&dv(e)&&t++}i=i.parent}return t}(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=o[0].getAttribute("listType");c&&(l=c);const u={listItemId:r,listIndent:a,listType:l};for(const h of o)h.hasAttribute("listItemId")||n.setAttributes(u,h);o.length>1&&o[1].getAttribute("listItemId")!=u.listItemId&&i.keepEmptyElement(o[
20])}}function bv(e,t,i){let{dataPipeline:n}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=function(e){return(t,i)=>{const n=[];for(const s of e)t.hasAttribute(s)&&n.push("attribute:".concat(s));return!!n.every(e=>!1!==i.test(t,e))&&(n.forEach(e=>i.consume(t,e)),!0)}}(e);return(o,r,a)=>{const{writer:l,mapper:c,consumable:u}=a,h=r.item;if(!e.includes(r.attributeKey))return;if(!s(h,u))return;const d=function(e,t,i){const n=i.createRangeOn(e),s=t.toViewRange(n).getTrimmed();return s.end.nodeBefore}(h,c,i);yv(d,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(d,l);const m=function(e,t,i,n,s){let{dataPipeline:o}=s,r=n.createRangeOn(t);if(!Kb(e))return r;for(const a of i){if("itemMarker"!=a.scope)continue;const i=a.createElement(n,e,{dataPipeline:o});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),a.canInjectMarkerIntoElement&&a.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(r.start,i),r=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!a.createWrapperElement||!a.canWrapElement)continue;const s=a.createWrapperElement(n,e,{dataPipeline:o});n.setCustomProperty("listItemWrapper",!0,s),a.canWrapElement(e)?r=n.wrap(r,s):(r=n.wrap(n.createRangeOn(i),s),r=n.createRange(r.start,n.createPositionAfter(t)))}return r}(h,d,t,l,{dataPipeline:n});!function(e,t,i,n){if(!e.hasAttribute("listIndent"))return;const s=e.getAttribute("listIndent");let o=e;for(let r=s;r>=0;r--){const e=fv(n,r,o.getAttribute("listItemId")),s=mv(n,r,o.getAttribute("listType"));for(const t of i)"list"!=t.scope&&"item"!=t.scope||!o.hasAttribute(t.attributeName)||t.setAttributeOnDowncast(n,o.getAttribute(t.attributeName),"list"==t.scope?s:e);if(t=n.wrap(t,e),t=n.wrap(t,s),0==r)break;if(o=Lb.first(o,{lowerIndent:!0}),!o)break}}(h,m,t,l)}}function vv(e){let{dataPipeline:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(i,n)=>{let{writer:s}=n;if(!Av(i,e))return null;if(!t)return s.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=s.createContainerElement("p");return s.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function yv(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];s(t.createPositionBefore(e).getWalker({direction:"backward"})),s(t.createRangeIn(e).getWalker());for(const o of n)t.remove(o);function s(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function Av(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:zb(e);if(!Ub(e))return!1;for(const n of e.getAttributeKeys())if(!n.startsWith("selection:")&&"htmlEmptyBlock"!=n&&!t.includes(n))return!1;return i.length<2}const kv=["listType","listIndent","listItemId"];class Ev extends yh{static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Pp,Rg,uv,f_]}constructor(e){super(e),(0,o.A)(this,"_downcastStrategies",[]),e.config.define("list.multiBlock",!0)}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new gs("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:kv}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const n of kv)t.schema.setAttributeProperties(n,{copyOnReplace:!0});e.commands.add("numberedList",new av(e,"numbered")),e.commands.add("bulletedList",new av(e,"bulleted")),e.commands.add("customNumberedList",new av(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new av(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new ov(e,"forward")),e.commands.add("outde
2ntList",new ov(e,"backward")),e.commands.add("splitListItemBefore",new cv(e,"before")),e.commands.add("splitListItemAfter",new cv(e,"after")),i&&(e.commands.add("mergeListItemBackward",new lv(e,"backward")),e.commands.add("mergeListItemForward",new lv(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...kv,...this._downcastStrategies.map(e=>e.attributeName)]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",(n,s)=>{const o=e.model.document.selection;iv(e.model)||e.model.change(()=>{const r=o.getFirstPosition();if(o.isCollapsed&&"backward"==s.direction){if(!r.isAtStart)return;const i=r.parent;if(!Ub(i))return;if(Lb.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:Cv(e.model,"backward")})}else Gb(i)||e.execute("splitListItemAfter"),e.execute("outdentList");s.preventDefault(),n.stop()}else{if(o.isCollapsed&&!o.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:Cv(e.model,"forward")}),s.preventDefault(),n.stop()}})},{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",(i,n)=>{const s=t.document,o=s.selection.getFirstPosition().parent;if(s.selection.isCollapsed&&Ub(o)&&o.isEmpty&&!n.isSoft){const t=Kb(o),s=Gb(o);t&&s?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!s?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):s&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}},{context:"li"}),this.listenTo(n,"afterExecute",()=>{const t=i.get("splitListItemBefore");if(t.refresh(),!t.isEnabled)return;2===zb(e.model.document.selection.getLastPosition().parent).length&&t.execute()})}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),s=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,t)=>{let{writer:i}=t;return i.createElement(s,{listType:""})}}).elementToElement({view:"p",model:(e,t)=>{let{writer:i}=t;return e.parent&&e.parent.is("element","li")?i.createElement(s,{listType:""}):null},converterPriority:"high"}).add(e=>{e.on("element:li",wv())}),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:s,view:vv(i),converterPriority:"high"}).add(e=>{var n;e.on("attribute",bv(i,this._downcastStrategies,t)),e.on("remove",(n=t.schema,(e,t,i)=>{const{writer:s,mapper:o}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=o.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=o.toViewPosition(l,{isPhantom:!0}),u=s.createRange(a,c).getTrimmed().end.nodeBefore;u&&yv(u,s,o)}))}),e.conversion.for("dataDowncast").elementToElement({model:s,view:vv(i,{dataPipeline:!0}),converterPriority:"high"}).add(e=>{e.on("attribute",bv(i,this._downcastStrategies,t,{dataPipeline:!0}))});const o=(r=this._downcastStrategies,a=e.editing.view,(e,t)=>{if(t.modelPosition.offset>0)return;const i=t.modelPosition.parent;if(!Ub(i))return;if(!r.some(e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(i)))return;const n=t.mapper.toViewElement(i),s=a.createRangeIn(n),o=s.getWalker();let l=s.start;for(const{item:r}of o){if(r.is("element")&&t.mapper.toModelElement(r)||r.is("$textProxy"))break;r.is("element")&&r.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(r),o.skip(e=>{let{previousPosition:t}=e;return!t.isEqual(l)}))}t.viewPosition=l});var r,a;e.editing.mapper.on("modelToViewPosition",o),e.data.mapper.on("modelToViewPosition",o),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Set,l=new Set,c=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)_v(e.position,a,c),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):_v(e.position.getShiftedBy(e.length),a,c);else if("remove"==e.type&&e.attributes.has("listItemId"))_v(e.position,a,c);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(_v(e.range.start,a,c),null===e.attributeNewValue?(_v(e.range.start.getShiftedBy(1),a,c),o(t)&&r.push(t)):l.add(t)):Ub(t)&&o(t)&&r.push(t)}for(const e of a.values())r.push(...s(e,l));for(const e of new Set(r))t.reconvertItem(e)};function s(e,t){const n=[],s=new Set,a=[];for(const{node:l,previous:c}of new jb(e)){if(s.has(l))continue;const e=l.getAttribute("listIndent");c&&e<c.getAttribute("listIndent")&&(a.length=e+1),a[e]=Object.fromEntries(Array.from(l.getAttributes()).filter(e=>{let[t]=e;return i.includes(t)}));const u=Hb(l,{direction:"forward"});for(const i of u)s.add(i),(o(i,u)||r(i,a,t))&&n.push(i)}return n}function o(e,s){const o=t.mapper.toViewElement(e);
2if(!o)return!1;if(n.fire("checkElement",{modelElement:e,viewElement:o}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=Av(e,i,s);return!(!r||!o.is("element","p"))||!(r||!o.is("element","span"))}function r(e,i,s){if(s.has(e))return!1;const o=t.mapper.toViewElement(e);let r=i.length-1;for(let t=o.parent;!t.is("editableElement");t=t.parent){const e=dv(t),s=hv(t);if(!s&&!e)continue;const o="checkAttributes:".concat(e?"item":"list");if(n.fire(o,{viewElement:t,modelAttributes:i[r]}))break;if(s&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",(e,t)=>{let{viewElement:i,modelAttributes:n}=t;i.id!=n.listItemId&&(e.return=!0,e.stop())}),this.on("checkAttributes:list",(e,t)=>{let{viewElement:i,modelAttributes:n}=t;i.name==gv(n.listType)&&i.id==pv(n.listType,n.listIndent)||(e.return=!0,e.stop())})}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer(i=>function(e,t,i,n){const s=e.document.differ.getChanges(),o=new Set,r=new Set,a=n.editor.config.get("list.multiBlock");let l=!1;for(const u of s){if("insert"==u.type&&"$text"!=u.name){const n=u.position.nodeAfter;if(!e.schema.checkAttribute(n,"listItemId"))for(const e of Array.from(n.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,n),l=!0);_v(u.position,r,o),u.attributes.has("listItemId")||_v(u.position.getShiftedBy(u.length),r,o);for(const{item:t,previousPosition:i}of e.createRangeIn(n))Ub(t)&&_v(i,r,o)}else"remove"==u.type?_v(u.position,r,o):"attribute"==u.type&&i.includes(u.attributeKey)&&
2(_v(u.range.start,r,o),null===u.attributeNewValue&&_v(u.range.start.getShiftedBy(1),r,o));if(!a&&"attribute"==u.type&&kv.includes(u.attributeKey)){const e=u.range.start.nodeAfter;null===u.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),l=!0):null===u.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),l=!0)}}const c=new Set;for(const u of r.values())l=n.fire("postFixer",{listNodes:new Wb(u),listHead:u,writer:t,seenIds:c})||l;return l}(e,i,t,this)),this.on("postFixer",(e,t)=>{let{listNodes:i,writer:n}=t;e.return=function(e,t){let i=0,n=-1,s=null,o=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===s?(s=e-i,a=i):(s>e&&(s=e),a=e-s),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),o=!0,n=a}else s=null,i=e+1,n=e}return o}(i,n)||e.return},{priority:"high"}),this.on("postFixer",(e,t)=>{let{listNodes:i,writer:n,seenIds:s}=t;e.return=function(e,t,i){const n=new Set;let s=!1;for(const{node:o}of e){if(n.has(o))continue;let e=o.getAttribute("listType"),r=o.getAttribute("listItemId");if(t.has(r)&&(r=qb.next()),t.add(r),o.is("element","listItem"))o.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,o),s=!0);else for(const t of Hb(o,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=qb.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),s=!0)}return s}(i,s,n)||e.return},{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,i)=>{let[n,s]=i;const o=n.is("documentFragment")?Array.from(n.getChildren()):[n];if(!o.length)return;const r=(s?e.createSelection(s):e.document.selection).getFirstPosition();let a;if(Ub(r.parent))a=r.parent;else{if(!Ub(r.nodeBefore)||!Ub(r.nodeAfter))return;a=r.nodeBefore}e.change(e=>{const t=a.getAttribute("listType"),i=a.getAttribute("listIndent"),n=o[0].getAttribute("listIndent")||0,s=Math.max(i-n,0);for(const r of o){const i=Ub(r);a.is("element","listItem")&&r.is("element","paragraph")&&e.rename(r,"listItem"),e.setAttributes({listIndent:(i?r.getAttribute("listIndent"):0)+s,listItemId:i?r.getAttribute("listItemId"):qb.next(),listType:t},r)}})}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",(t,i)=>{e.change(e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty){t.slice(0,-1).every(Ub)&&e.remove(n)}if("copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());ev(t)&&Xb(t,e)}})})}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function Cv(e,t){const i=e.document.selection;if(!i.isCollapsed)return!iv(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,s=n.previousSibling;return!e.schema.isObject(s)&&(!!s.isEmpty||ev([n,s]))}function Pv(e,t,i,n){e.ui.componentFactory.add(t,()=>{const s=Tv(nm,e,t,i,n);return s.set({tooltip:!0,isToggleable:!0}),s}),e.ui.componentFactory.add("menuBar:".concat(t),()=>{const s=Tv(Em,e,t,i,n);return s.set({role:"menuitemcheckbox",isToggleable:!0}),s})}function Tv(e,t,i,n,s){const o=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:s}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",()=>{t.execute(i),t.editing.view.focus()}),r}class xv extends yh{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||Pv(this.editor,"numberedList",e("Numbered List"),ud),this.editor.ui.componentFactory.has("bulletedList")||Pv(this.editor,"bulletedList",e("Bulleted List"),cd)}}const Dv=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:vy,typeAttribute:yy,listType:Ay}of Dv);function Sv(e,t){const 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)};return e=>{e.on("attribute:url:media",i)}}function Iv(e,t,i,n){return e.createContainerElement("figure",{class:"media"},[t.getMediaViewElement(e,i,n),e.createSlot()])}function Ov(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function Fv(e,t,i,n){e.change(s=>{const o=s.createElement("media",{url:t});e.insertObject(o,i,null,{setSelection:"on",findOptimalPosition:n?"auto":void 0})})}class Bv extends kh{refresh(){const e=this.editor.model,t=e.document.selection,i=Ov(t);this.value=i?i.getAttribute("url"):void 0,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){const i=Kp(e,t);let n=i.start.parent;n.isEmpty&&!t.schema.isLimit(n)&&(n=n.parent);return t.schema.checkChild(n,"media")}(t,e)}execute(e){const t=this.editor.model,i=t.document.selection,n=Ov(i);n?t.change(t=>{t.setAttribute("url",e,n)}):Fv(t,e,i,!0)}}class Mv{constructor(e,t){(0,o.A)(this,"locale",void 0),(0,o.A)(this,"providerDefinitions",void 0);const i=t.providers,n=t.extraProviders||[],s=new Set(t.removeProviders),r=i.concat(n).filter(e=>{const t=e.name;return t?!s.has(t):(ps("media-embed-no-provider-name",{provider:e}),!1)});this.locale=e,this.providerDefinitions=r}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,i){return this._getMedia(t).getViewElement(e,i)}_getMedia(e){if(!e)return new Rv(this.locale);e=e.trim();for(const t of this.providerDefinitions){const i=t.html,n=Jo(t.url);for(const t of n){const n=this._getUrlMatches(e,t);if(n)return new Rv(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 Rv{constructor(e,t,i,n){(0,o.A)(this,"url",void 0),(0,o.A)(this,"_locale",void 0),(0,o.A)(this,"_match",void 0),(0,o.A)(this,"_previewRenderer",void 0),this.url=this._getValidUrl(t),this._locale=e,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,(e,t)=>{t.setContentOf(e,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 tm,t=this._locale.t;e.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.
2637 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>',e.viewBox="0 0 64 42";return new Dd({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":t("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}class Vv extends yh{static get pluginName(){return"MediaEmbedEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"registry",void 0),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:[/^dailymotion\.com\/video\/(\w+)/,/^dai.ly\/(\w+)/],html:e=>{const t=e[1];return'<div style="position: relative; padding-bottom: 100%; height: 0; ">'+'<iframe src="https://www.dailymotion.com/embed/video/'.concat(t,'" ')+'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=>{const t=e[1];return'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;">'+'<iframe src="https://open.spotify.com/embed/'.concat(t,'" ')+'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-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/shorts\/([\w-]+)(?:\?t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:e=>{const t=e[1],i=e[2];return'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">'+'<iframe src="https://www.youtube.com/embed/'.concat(t).concat(i?"?start=".concat(i):"",'" ')+'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=>{const t=e[1];return'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">'+'<iframe src="https://player.vimeo.com/video/'.concat(t,'" ')+'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+)/,/^instagram\.com\/reel\/(\w+)/]},{name:"twitter",url:[/^twitter\.com/,/^x\.com/]},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new Mv(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 Bv(e)),t.register("media",{inheritAllFrom
2:"$blockObject",allowAttributes:["url"]}),n.for("dataDowncast").elementToStructure({model:"media",view:(e,t)=>{let{writer:i}=t;const n=e.getAttribute("url");return Iv(i,r,n,{elementName:o,renderMediaPreview:!!n&&s})}}),n.for("dataDowncast").add(Sv(r,{elementName:o,renderMediaPreview:s})),n.for("editingDowncast").elementToStructure({model:"media",view:(e,t)=>{let{writer:n}=t;const s=e.getAttribute("url");return function(e,t,i){return t.setCustomProperty("media",!0,e),zp(e,t,{label:i})}(Iv(n,r,s,{elementName:o,renderForEditingView:!0}),n,i("media widget"))}}),n.for("editingDowncast").add(Sv(r,{elementName:o,renderForEditingView:!0})),n.for("upcast").elementToElement({view:e=>["oembed",o].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,t)=>{let{writer:i}=t;const n=e.getAttribute("url");return r.hasMedia(n)?i.createElement("media",{url:n}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,t)=>{let{writer:i}=t;const n=e.getAttribute("data-oembed-url");return r.hasMedia(n)?i.createElement("media",{url:n}):null}}).add(e=>{e.on("element:figure",(e,t,i)=>{if(!i.consumable.consume(t.viewItem,{name:!0,classes:"media"}))return;const{modelRange:n,modelCursor:s}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=n,t.modelCursor=s;Xo(n.getItems())||i.consumable.revert(t.viewItem,{name:!0,classes:"media"})})})}}const Nv=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class Lv extends yh{static get requires(){return[D_,Rg,hw]}static get pluginName(){return"AutoMediaEmbed"}static get isOfficialPlugin(){return!0}constructor(e){super(e),(0,o.A)(this,"_timeoutId",void 0),(0,o.A)(this,"_positionToInsert",void 0),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",()=>{const e=t.selection.getFirstRange(),i=ku.fromPosition(e.start);i.stickiness="toPrevious";const n=ku.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&&(Jn.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(Vv).registry,s=new Ll(e,t),o=s.getWalker({ignoreElementEnd:!0});let r="";for(const a of o)a.item.is("$textProxy")&&(r+=a.item.data);if(r=r.trim(),!r.match(Nv))return void s.detach();if(!n.hasMedia(r))return void s.detach();i.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=ku.fromPosition(e),this._timeoutId=Jn.window.setTimeout(()=>{i.model.change(e=>{this._timeoutId=null,e.remove(s),s.detach();let t=null;"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),Fv(i.model,r,t,!1),this._positionToInsert.detach(),this._positionToInsert=null}),i.plugins.get(Rg).requestUndoOnBackspace()},100)):s.detach()}}class jv extends Qd{constructor(e,t){super(t),(0,o.A)(this,"focusTracker",void 0),(0,o.A)(this,"keystrokes",void 0),(0,o.A)(this,"urlInputView",void 0),(0,o.A)(this,"_validators",void 0),(0,o.A)(this,"_urlInputViewInfoDefault",void 0),(0,o.A)(this,"_urlInputViewInfoTip",void 0),this.focusTracker=new er,this.keystrokes=new sr,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView]})}render(){super.render(),em({view:this}),this.focusTracker.add(this.urlInputView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.urlInputView.focus()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.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 Nm(this.locale,_f),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.inputMode="url",i.on("input",()=>{t.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=i.element.value.trim()}),t}}class Wv extends yh{constructor(){super(...arguments),(0,o.A)(this,"_formView",void 0)}static get requires(){return[Vv,ym]}static get pluginName(){return"MediaEmbedUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("mediaEmbed",()=>{const e=this.editor.locale.t,t=this._createDialogButton(nm);return t.tooltip=!0,t.label=e("Insert media"),t}),e.ui.componentFactory.add("menuBar:mediaEmbed",()=>{const e=this.editor.locale.t,t=this._createDialogButton(Em);return t.label=e("Media"),t})}_createDialogButton(e){const t=this.editor,i=new e(t.locale),n=t.commands.get("mediaEmbed"),s=this.editor.plugins.get("Dialog");return i.icon='<svg viewBox="0 0 22 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.587 1.5c-.612 0-.601-.029-.601.551v14.84c0 .59-.01.559.591.559h18.846c.602 0 .591.03.591-.56V2.052c0-.58.01-.55-.591-.55H1.587Zm.701.971h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-14.24 1h13.008v12H4.467l.029-12Zm-2.208
21h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003v1H2.288v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h1.003l-.029 1h-.974v-1Zm16.448 0h1.003v1h-1.003v-1Zm-16.448 2h.974v1h-.974v-1Zm16.448 0h1.003v1h-1.003v-1Z"/><path d="M8.374 6.648a.399.399 0 0 1 .395-.4.402.402 0 0 1 .2.049l5.148 2.824a.4.4 0 0 1 0 .7l-5.148 2.824a.403.403 0 0 1-.595-.35V6.648Z"/></svg>',i.bind("isEnabled").to(n,"isEnabled"),i.on("execute",()=>{"mediaEmbed"===s.id?s.hide():this._showDialog()}),i}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.commands.get("mediaEmbed"),n=e.locale.t;if(!this._formView){const t=e.plugins.get(Vv).registry;this._formView=new(Xd(jv))(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.")}]}(e.t,t),e.locale),this._formView.on("submit",()=>this._handleSubmitForm())}t.show({id:"mediaEmbed",title:n("Insert media"),content:this._formView,isModal:!0,onShow:()=>{this._formView.url=i.value||"",this._formView.resetFormStatus(),this._formView.urlInputView.fieldView.select()},actionButtons:[{label:n("Cancel"),withText:!0,onExecute:()=>t.hide()},{label:n("Accept"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSubmitForm()}]})}_handleSubmitForm(){const e=this.editor,t=e.plugins.get("Dialog");this._formView.isValid()&&(e.execute("mediaEmbed",this._formView.url),t.hide(),e.editing.view.focus())}}const qv={"(":")","[":"]","{":"}"};class Uv extends kh{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,s=n.id,o=e.range||i.getFirstRange();if(!t.canEditAt(o))return;const r=e.text||s,a=Hv({_text:r,id:s},n);if(!s.startsWith(e.marker))throw new gs("mentioncommand-incorrect-id",this);t.change(e=>{const n=or(i.getAttributes()),s=new Map(n.entries());s.set("mention",a);const l=t.insertContent(e.createText(r,s),o),c=l.start.nodeBefore,u=l.end.nodeAfter,h=u&&u.is("$text")&&u.data.startsWith(" ");let d=!1;if(c&&u&&c.is("$text")&&u.is("$text")){const e=c.data.slice(-1),t=e in qv,i=t&&u.data.startsWith(qv[e]);d=t&&i}d||h||t.insertContent(e.createText(" ",n),o.start.getShiftedBy(r.length))})}}class zv extends yh{static get pluginName(){return"MentionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",attributes:"data-mention",classes:"mention"},model:{key:"mention",value:e=>$v(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:Gv}),e.conversion.for("downcast").add(Kv),i.registerPostFixer(e=>function(e,t,i){const n=t.differ.getChanges();let s=!1;for(const o of n){if("attribute"==o.type)continue;const t=o.position;if("$text"==o.name){const i=t.textNode&&t.textNode.nextSibling;s=Zv(t.textNode,e)||s,s=Zv(i,e)||s,s=Zv(t.nodeBefore,e)||s,s=Zv(t.nodeAfter,e)||s}if("$text"!=o.name&&"insert"==o.type){const i=t.nodeAfter;for(const t of e.createRangeIn(i).getItems())s=Zv(t,e)||s}if("insert"==o.type&&i.isInline(o.name)){const i=t.nodeAfter&&t.nodeAfter.nextSibling;s=Zv(t.nodeBefore,e)||s,s=Zv(i,e)||s}}return s}(e,i,t.schema)),i.registerPostFixer(e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const s of i)if("attribute"===s.type&&"mention"!=s.attributeKey){const t=s.range.start.nodeBefore,i=s.range.end.nodeAfter;for(const o of[t,i])Jv(o)&&o.getAttribute(s.attributeKey)!=s.attributeNewValue&&(e.setAttribute(s.attributeKey,s.attributeNewValue,o),n=!0)}return n}(e,i)),i.registerPostFixer(e=>function(e,t){const i=t.selection,n=i.focus;if(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))return e.removeSelectionAttribute("mention"),!0;return!1}(e,i)),e.commands.add("mention",new Uv(e))}}function Hv(e,t){return Object.assign({uid:ds()},e,t||{})}function $v(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(!n)return;return Hv({id:i,_text:n.data},t)}function Kv(e){e.on("attribute:mention",(e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const s=t.range.start;(s.textNode||s.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)},{priority:"highest"})}
2function Gv(e,t){let{writer:i}=t;if(!e)return;const n={class:"mention","data-mention":e.id},s={id:e.uid,priority:20};return i.createAttributeElement("span",n,s)}function Jv(e){if(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))return!1;return e.data!=e.getAttribute("mention")._text}function Zv(e,t){return!!Jv(e)&&(t.removeAttribute("mention",e),!0)}class Qv extends Gm{constructor(e){super(e),(0,o.A)(this,"selected",void 0),(0,o.A)(this,"position",void 0),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e<this.items.length?t=e:e<0&&(t=this.items.length-1);const i=this.items.get(t);this.selected!==i&&(this.selected&&this.selected.removeHighlight(),i.highlight(),this.selected=i,this._isItemVisibleInScrolledArea(i)||(this.element.scrollTop=i.element.offsetTop))}executeSelected(){this.selected.fire("execute")}_isItemVisibleInScrolledArea(e){return new uo(this.element).contains(new uo(e.element))}}class Yv extends Qd{constructor(e,t){super(e),(0,o.A)(this,"domElement",void 0),this.template=void 0,this.domElement=t,this.domElement.classList.add("ck-button"),this.set("isOn",!1),this.on("change:isOn",(e,t,i)=>{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))}),this.listenTo(this.domElement,"click",()=>{this.fire("execute")})}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class Xv extends Hm{constructor(){super(...arguments),(0,o.A)(this,"item",void 0),(0,o.A)(this,"marker",void 0)}highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const ey=[jo.arrowup,jo.arrowdown,jo.esc],ty=[jo.enter,jo.tab];class iy extends yh{static get pluginName(){return"MentionUI"}static get isOfficialPlugin(){return!0}static get requires(){return[ag]}constructor(e){super(e),(0,o.A)(this,"_mentionsView",void 0),(0,o.A)(this,"_mentionsConfigurations",void 0),(0,o.A)(this,"_balloon",void 0),(0,o.A)(this,"_items",new Yo),(0,o.A)(this,"_lastRequested",void 0),(0,o.A)(this,"_requestFeedDebounced",void 0),this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=In(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||ty,i=ey.concat(t);this._balloon=e.plugins.get(ag),e.editing.view.document.on("keydown",(e,n)=>{var s;s=n.keyCode,i.includes(s)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==jo.arrowdown&&this._mentionsView.selectNext(),n.keyCode==jo.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==jo.esc&&this._hideUIAndRemoveMarker())},{priority:"highest"}),Yd({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const s of n){const{feed:e,marker:t,dropdownLimit:i}=s;if(!ay(t))throw new gs("mentionconfig-incorrect-marker",null,{marker:t});const n={marker:t,feedCallback:"function"==typeof e?e.bind(this.editor):ry(e),itemRenderer:s.itemRenderer,dropdownLimit:i};this._mentionsConfigurations.set(t,n)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",()=>{this._hideUIAndRemoveMarker()}),this.on("requestFeed:response",(e,t)=>this._handleFeedResponse(t)),this.on("requestFeed:error",()=>this._hideUIAndRemoveMarker())}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new Qv(e);return t.items.bindTo(this._items).using(i=>{const{item:n,marker:s}=i,{dropdownLimit:o}=this._mentionsConfigurations.get(s),r=o||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new Xv(e),l=this._renderItem(n,s);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=s,a.on("execute",()=>{t.fire("execute",{item:n,marker:s})}),a}),t.on("execute",(e,t)=>{const i=this.editor,n=i.model,s=t.item,o=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:s,text:s.text,marker:o,range:c}),i.editing.view.focus()}),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then(i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})}).catch(t=>{this.fire("requestFeed:error",{error:t}),ps("mention-feed-callback-error",{marker:e})}):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map(e=>(0,r.A)((0,r.A)({},e),{},{pattern:oy(e.marker,e.minimumCharacters||0)})),n=new Lg(t.model,function(e){const t=t=>{const i=sy(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const s=t.substring(n);return i.pattern.test(s)};return t}(i));n.on("matched",(e,n)=>{const s=sy(i,n.text),o=t.model.document.selection.focus,r=t.model.createPositionAt(o.parent,s.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(o)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=oy(e.marker,0),s=t.substring(i);return s.match(n)[2]}(s,n.text),l=s.marker.length+a.length,c=o.getShiftedBy(-l),u=o.getShiftedBy(-a.length),h=t.model.createRange(c,u);if(ly(t)){const e=t.model.markers.get("mention");t.model.change(t=>{t.updateMarker(e,{range:h})})}else t.model.change(e=>{e.addMarker("mention",{range:h,usingOperation:!1,affectsData:!1})});this._requestFeedDebounced(s.marker,a)}),n.on("unmatched",()=>{this._hideUIAndRemoveMarker()});const s=t.commands.get("mention");return n.bind("isEnabled").to(s),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!ly(this.editor))return;this._items.clear();for(const s of t){const e="object"!=typeof s?{id:s,text:s}:s;this._items.add({item:e,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),ly(this.editor)&&this.editor.model.change(e=>e.removeMarker("mention")),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,s=e.id;const o=this._getItemRenderer(t);if(o){const t=o(e);"string"!=typeof t?n=new Yv(i.locale,t):s=t}if(!n){const e=new nm(i.locale);e.label=s,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,s=n.view.domConverter,o=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=o.toViewRange(t);return uo.getDomRangeRects(s.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:ny(t,i.locale.uiLanguageDirection)}}}function ny(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}
2}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function sy(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function oy(e,t){const i=0==t?"*":"{".concat(t,",}");e=e.replace(/[.*+?^${}()\-|[\]\\]/g,"\\$&");const n="(?:^|[ ".concat("\\(\\[{\"'","])(").concat(e,")(").concat(".").concat(i,")$");return new RegExp(n,"u")}function ry(e){return t=>e.filter(e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase()))}function ay(e){return!!e}function ly(e){return e.model.markers.has("mention")}const cy="removeFormat";class uy extends yh{static get pluginName(){return"RemoveFormatUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add(cy,()=>{const e=this._createButton(nm);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:".concat(cy),()=>this._createButton(Em))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get(cy),s=new e(t.locale),o=i.t;return s.set({label:o("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>'}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute(cy),t.editing.view.focus()}),s}}class hy extends kh{refresh(){const e=this.editor.model;this.isEnabled=!!Xo(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=>!!Xo(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 n of e.getSelectedBlocks())i(n)&&(yield n);i(e)&&(yield e)}*_getFormattingAttributes(e,t){for(const[i]of e.getAttributes()){const e=t.getAttributeProperties(i);e&&e.isFormatting&&(yield i)}}}class dy extends yh{static get pluginName(){return"RemoveFormatEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("removeFormat",new hy(e))}}class my extends kh{execute(){this.editor.model.change(e=>{var t;const i=this.editor.model.document.selection,n=null===(t=i.anchor)||void 0===t?void 0:t.findAncestor("spoilerContent");if(n){const t=n.parent;return e.remove(t.getChild(0)),e.unwrap(t),void e.unwrap(n)}const s=e.createElement("spoiler"),o=e.createElement("spoilerTitle"),r=e.createElement("spoilerContent"),a=Array.from(i.getSelectedBlocks());if(a.length>0){const t=e.createRange(e.createPositionBefore(a[0]),e.createPositionAfter(a[a.length-1]));for(const i of a)e.insert(e.cloneElement(i,!0),r,"end");e.remove(t)}
2else e.appendElement("paragraph",r);e.append(o,s),e.append(r,s),this.editor.model.insertObject(s,null,null,{}),this.editor.model.document.selection._setTo(e.createPositionAt(r,"end"))})}refresh(){const e=this.editor.model,t=e.document.selection.getFirstPosition(),i=t&&e.schema.findAllowedParent(t,"spoiler"),n=!(null===t||void 0===t||!t.findAncestor("spoiler"));this.isEnabled=null!==i,this.value=n}}class fy extends Z_{}(0,o.A)(fy,"builtinPlugins",[Vb,class extends yh{static get requires(){return[Rg]}static get pluginName(){return"Autoformat"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&np(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&np(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&np(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&np(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=rp(this.editor,"bold");sp(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),sp(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=rp(this.editor,"italic");sp(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),sp(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=rp(this.editor,"code");sp(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=rp(this.editor,"strikethrough");sp(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("^(#{".concat(i,"})\\s$"));np(this.editor,this,n,()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&np(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&np(e,this,/^```$/,()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&np(this.editor,this,/^---$/,"horizontalLine")}},class extends yh{static get pluginName(){return"Autosave"}static get isOfficialPlugin(){return!0}static get requires(){return[qh]}constructor(e){super(e),(0,o.A)(this,"adapter",void 0),(0,o.A)(this,"_debouncedSave",void 0),(0,o.A)(this,"_lastDocumentVersion",void 0),(0,o.A)(this,"_savePromise",void 0),(0,o.A)(this,"_domEmitter",void 0),(0,o.A)(this,"_config",void 0),(0,o.A)(this,"_pendingActions",void 0),(0,o.A)(this,"_makeImmediateSave",void 0),(0,o.A)(this,"_action",null);const t=e.config.get("autosave")||{},i=t.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=In(this._save.bind(this),i),this._lastDocumentVersion=e.model.document.version,this._savePromise=null,this._domEmitter=new(to()),this._config=t,this._pendingActions=e.plugins.get(qh),this._makeImmediateSave=!1}init(){const e=this.editor,t=e.model.document;this.listenTo(e,"ready",()=>{this.listenTo(t,"change:data",(e,t)=>{this._saveCallbacks.length&&t.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())})}),this.listenTo(e,"destroy",()=>this._flush(),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",(e,t)=>{this._pendingActions.hasAny&&(t.returnValue=this._pendingActions.first.message)})}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then(()=>Promise.all(this._saveCallbacks.map(e=>e(this.editor)))).finally(()=>{this._savePromise=null}).then(()=>
2{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)}).catch(e=>{throw this.state="error",this.state="saving",this._debouncedSave(),e}),this._savePromise)}_setPendingAction(){const e=this.editor.t;this._action||(this._action=this._pendingActions.add(e("Saving changes")))}get _saveCallbacks(){const e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}},class extends yh{static get requires(){return[Mp,Rp]}static get pluginName(){return"BlockQuote"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[cp,dp]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[fp,pp]}static get pluginName(){return"Code"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[z_,K_]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[Dm,D_,Pp,nw,Sp,Vg,hw]}static get pluginName(){return"Essentials"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[bw,vw]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[Kw,Jw]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}},class extends yh{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[ab,Xw,eb]}},class extends yh{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[cb,ub]}},class extends yh{static get requires(){return[wp,vp]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[Sb,Bb,Vb]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return[Ev,xv]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}},gw,class extends yh{static get requires(){return[dy,uy]}static get pluginName(){return"RemoveFormat"}static get isOfficialPlugin(){return!0}},class extends yh{static get requires(){return["Delete","Input"]}static get pluginName(){return"TextTransformation"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("typing",{transformations:{include:Jg}})}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTransformationWatchers()}_enableTransformationWatchers(){const e=this.editor,t=e.model,i=e.plugins.get("Delete"),n=function(e){const t=e.extra||[],i=e.remove||[],n=e=>!i.includes(e);return function(e){const t=new Set;for(const i of e)if("string"==typeof i&&Gg[i])for(const e of Gg[i])t.add(e);else t.add(i);return Array.from(t)}(e.include.concat(t).filter(n)).filter(n).map(e=>"string"==typeof e&&Kg[e]?Kg[e]:e).filter(e=>"object"===typeof e).map(e=>({from:Zg(e.from),to:Qg(e.to)}))}(e.config.get("typing.transformations")),s=new Lg(e.model,e=>{for(const t of n){if(t.from.test(e))return{normalizedTransformation:t}}});s.on("matched:data",(e,n)=>{if(!n.batch.isTyping)return;const{from:s,to:o}=n.normalizedTransformation,r=s.exec(n.text),a=o(r.slice(1)),l=n.range;let c=r.index;t.enqueueChange(e=>{for(let i=1;i<r.length;i++){const n=r[i],s=a[i-1];if(null==s){c+=n.length;continue}const o=l.start.getShiftedBy(c),u=t.createRange(o,o.getShiftedBy(n.length)),h=Yg(o);t.insertContent(e.createText(s,h),u),c+=s.length}t.enqueueChange(()=>{i.requestUndoOnBackspace()})})}),s.bind("isEnabled").to(this)}},hw,class extends yh{static get requires(){return[Vv,Wv,Lv,o_]}static get pluginName(){return"MediaEmbed"}static get isOfficialPlugin(){return!0}},class extends yh{toMentionAttribute(e,t){return $v(e,t)}static get pluginName(){return"Mention"}static get isOfficialPlugin(){return!0}static get requires(){return[zv,iy]}},function(e){e.conversion.for("upcast").elementToAttribute({view:{name:"span",classes:"mention",attributes:{"data-mention-link":!0,"data-mention-user-id":!0,"data-mention-username":!0}},model:{key:"mention",value:t=>e.plugins.get("Mention").toMentionAttribute(t,{id:"@".concat(t.getAttribute("data-mention-username")),userId:t.getAttribute("data-mention-user-id"),link:t.getAttribute("data-mention-link")})},converterPriority:"high"}),e.conversion.for("downcast").attributeToElement({model:"mention",view:(e,t)=>
2{let{writer:i}=t;if(e)return i.createAttributeElement("span",{class:"mention","data-mention-username":e.id.substring(1),"data-mention-user-id":e.userId,"data-mention-link":e.link},{priority:20,id:e.uid})},converterPriority:"high"})},class extends yh{_defineSchema(){const e=this.editor.model.schema;e.register("spoiler",{inheritAllFrom:"$blockObject",isSelectable:!1}),e.register("spoilerTitle",{isLimit:!0,allowIn:"spoiler",allowContentOf:"$block"}),e.register("spoilerContent",{allowIn:"spoiler",allowContentOf:"$root"})}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToElement({model:"spoiler",view:{name:"details"}}),e.for("dataDowncast").elementToElement({model:"spoiler",view:{name:"details"}}),e.for("editingDowncast").elementToElement({model:"spoiler",view:{name:"div",classes:"spoiler"}}),e.for("upcast").elementToElement({model:"spoilerTitle",view:{name:"summary"}}),e.for("dataDowncast").elementToElement({model:"spoilerTitle",view:{name:"summary"}}),e.for("editingDowncast").elementToElement({model:"spoilerTitle",view:{name:"div",classes:"spoiler__summary"}}),e.elementToElement({model:"spoilerContent",view:{name:"div"}})}init(){console.log("Spoiler initialized");const e=this.editor;this._defineSchema(),this._defineConverters(),e.commands.add("insertSpoiler",new my(e));const t=e.commands.get("insertSpoiler");e.ui.componentFactory.add("spoiler",()=>{const i=new nm;return i.set({label:"Spoiler",withText:!0}),t&&i.bind("isOn","isEnabled").to(t,"value","isEnabled"),this.listenTo(i,"execute",()=>{e.execute("insertSpoiler"),e.editing.view.focus()}),i});const i=this.editor.editing.view.document,n=e.model.document.selection;this.listenTo(i,"enter",(t,i)=>{var s;if(console.log("handling enter"),!n.isCollapsed)return;const o=n.getLastPosition().parent,r=null===(s=n.anchor)||void 0===s?void 0:s.findAncestor("spoiler");r&&o.isEmpty&&!o.nextSibling&&(e.model.change(t=>{t.remove(o);const i=t.createElement("paragraph");t.insert(i,t.createPositionAfter(r)),e.model.document.selection._setTo(t.createPositionAt(i,0))}),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())})}}]),(0,o.A)(fy,"defaultConfig",{toolbar:{items:["heading","|","removeFormat","|","bold","italic","link","bulletedList","numberedList","|","outdent","indent","|","spoiler","|","blockQuote","code","codeBlock","insertImage","|","undo","redo","|","mediaEmbed"]},image:{insert:{integrations:["upload"]}},mediaEmbed:{extraProviders:[{name:"vk",url:[/^vk\.com\/?(\S+)video-(\d+)_?(\d+)/,/^vk\.com\/?(\S+)video-(\d+)_?(\d+)%(\S+)/],html:e=>'<iframe src="https://vk.com/video_ext.php?oid=-'.concat(e[2],"&id=").concat(e[3],'" frameborder="0" allowfullscreen="1" allow="autoplay; encrypted-media; fullscreen; picture-in-picture" style="width:100%; aspect-ratio:16/9;"></iframe>')},{name:"rutube",url:/^rutube\.ru\/video\/(\w+)\/?/,html:e=>'<iframe src="https://rutube.ru/play/embed/'.concat(e[1],'/" frameBorder="0" allow="clipboard-write; autoplay" webkitAllowFullScreen mozallowfullscreen allowFullScreen style="width:100%; aspect-ratio:16/9;"></iframe>')}],removeProviders:["instagram","twitter","googleMaps","flickr","facebook","spotify","dailymotion","vimeo"],previewsInData:!0},language:"en"});class gy{constructor(e,t){(0,o.A)(this,"loader",void 0),(0,o.A)(this,"action",void 0),this.loader=e,this.action=t}async upload(){const e=await this.loader.file,{url:t}=await this.action(e);return{default:t}}}const py=e=>({id:"@".concat(e.userHandle),text:"@".concat(e.userName||e.userHandle),userName:e.userName,userId:e.userId,link:e.link}),_y=e=>{const t=document.createElement("button");t.classList.add("ck","ck-button","ck-button_with-text"),t.id="mention-list-item-id-".concat(e.userId),t.setAttribute("type","button"),t.setAttribute("tabindex","-1");const i=document.createElement("span");return i.classList.add("ck","ck-button__label"),i.textContent=e.id.substring(1),e.userName&&(i.textContent="".concat(e.userName||""," (").concat(e.id.substring(1),")")),t.appendChild(i),t},wy=e=>{let{initialValue:t,disabled:i=!1,autosaveKey:n,onImageUpload:s,onBlur:o,onChange:r,headerHeight:c=0,keepImages:u=!1,mentionables:h}=e;const d=(0,l.useMemo)(()=>{return s?[(e=s,function(t){t.plugins.get("FileRepository").createUploadAdapter=t=>new gy(t,e)})]:[];var e},[s]),m=(0,l.useRef)(null);return(0,l.useEffect)(()=>{var e;null!==(e=m.current)&&void 0!==e&&e.editor&&!isNaN(Number(c))&&(m.current.editor.ui.viewportOffset={top:c})},[c]),(0,a.jsx)(O,{editor:fy,ref:m,data:t,config:{licenseKey:"GPL",extraPlugins:d,mention:h&&{feeds:[{marker:"@",feed:"function"===typeof h?e=>Promise.resolve(h(e)).then(e=>e.map(py)):h.map(py),itemRenderer:_y}]},image:{insert:{integrations:["upload"]},upload:{types:["jpeg","png","bmp","gif"]}},toolbar:{removeItems:s?[]:["insertImage"]},ui:{viewportOffset:{top:c}},autosave:{waitingTime:1e3,async save(e){n&&localStorage.setItem(n,e.getData())}}},disabled:i,onReady:e=>{e.plugins.get("ClipboardPipeline").on("inputTransformation",(e,t)=>{if(u)return;const i=[],n=new hh(t.content.document),s=n.createRangeIn(t.content);for(const o of s)o.item.is("element","img")&&i.push(o.item);for(const o of i)n.remove(o)});const t=n&&localStorage.getItem(n);var i;t&&(null===(i=m.current)||void 0===i||null===(i=i.editor)||void 0===i||i.setData(t))},onBlur:(e,t)=>null===o||void 0===o?void 0:o(t),onChange:(e,t)=>
2null===r||void 0===r?void 0:r(t)})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.