>>8^n[(r^t)&255]}return r=(r^-1)>>>0,r.toString(16).padStart(8,`0`)}async function Cee(e){return e?(await Promise.all(e.map(async e=>e===`EDITOR_STYLES`?wee():(await window.fetch(e)).text()))).join(` `).trim():``}function wee(){let e=[],t=[];for(let n of Array.from(document.styleSheets))if(n.ownerNode.hasAttribute(`data-cke`))for(let r of Array.from(n.cssRules))r.cssText.indexOf(`.ck-content`)===-1?r.cssText.indexOf(`:root`)!==-1&&t.push(r.cssText):e.push(r.cssText);return e.length||console.warn(`The editor stylesheet could not be found in the document. Check your webpack config - style-loader should use data-cke=true attribute for the editor stylesheet.`),[...t,...e].join(` `).trim()}function Qi(e){let t=[{name:`address`,isVoid:!1},{name:`article`,isVoid:!1},{name:`aside`,isVoid:!1},{name:`blockquote`,isVoid:!1},{name:`details`,isVoid:!1},{name:`dialog`,isVoid:!1},{name:`dd`,isVoid:!1},{name:`div`,isVoid:!1},{name:`dl`,isVoid:!1},{name:`dt`,isVoid:!1},{name:`fieldset`,isVoid:!1},{name:`figcaption`,isVoid:!1},{name:`figure`,isVoid:!1},{name:`footer`,isVoid:!1},{name:`form`,isVoid:!1},{name:`h1`,isVoid:!1},{name:`h2`,isVoid:!1},{name:`h3`,isVoid:!1},{name:`h4`,isVoid:!1},{name:`h5`,isVoid:!1},{name:`h6`,isVoid:!1},{name:`header`,isVoid:!1},{name:`hgroup`,isVoid:!1},{name:`hr`,isVoid:!0},{name:`li`,isVoid:!1},{name:`main`,isVoid:!1},{name:`nav`,isVoid:!1},{name:`ol`,isVoid:!1},{name:`p`,isVoid:!1},{name:`section`,isVoid:!1},{name:`table`,isVoid:!1},{name:`tbody`,isVoid:!1},{name:`td`,isVoid:!1},{name:`th`,isVoid:!1},{name:`thead`,isVoid:!1},{name:`tfoot`,isVoid:!1},{name:`tr`,isVoid:!1},{name:`ul`,isVoid:!1}],n=t.map(e=>e.name).join(`|`),r=e.replace(RegExp(`?(${n})( .*?)?>`,`g`),`
$&
`).replace(/
]*>/g,`$&
`).split(`
`),i=0,a=!1;return r.map(e=>(a=Dee(e,a),!e.length&&!a?``:Tee(e,t)?$i(e,i++):Eee(e,t)?$i(e,--i):a===`middle`||a===`last`?$i(e,0):$i(e,i))).join(``).trimEnd()}function Tee(e,t){return t.some(t=>!(t.isVoid||!RegExp(`<${t.name}( .*?)?>`).test(e)))}function Eee(e,t){return t.some(t=>RegExp(`${t.name}>`).test(e))}function $i(e,t,n=` `){return`${n.repeat(Math.max(0,t))}${e}\n`}function Dee(e,t){let n=//.test(e),r=/<\/pre>/.test(e);return n&&r?!1:n?`first`:r?`last`:t===`first`||t===`middle`?`middle`:!1}function ea(e){return!!e&&e.length==1&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(e)}function ta(e){return!!e&&e.length==1&&/[\ud800-\udbff]/.test(e)}function na(e){return!!e&&e.length==1&&/[\udc00-\udfff]/.test(e)}function ra(e,t){return ta(e.charAt(t-1))&&na(e.charAt(t))}function ia(e,t){return ea(e.charAt(t))}const aa=sa();function oa(e,t){let n=String(e).matchAll(aa);return Array.from(n).some(e=>e.indexe.source).join(`|`)+`)`,r=`${t}|${n}(?:\u{200D}${n})*`;return new RegExp(r,`ug`)}function ca(e){if(!e)return null;let t=la(e);return t?Xi(t):null}function la(e){let t=e.split(`.`);return t.length==3?t[1]:null}function ua(e,t){return(e.removeFeatures||[]).includes(t)}function da(e){if(!e)return null;let[,t,n]=e.trim().match(/([.,\d]+)(%|px)$/)||[],r=Number.parseFloat(t);return Number.isNaN(r)?null:{value:r,unit:n}}function fa(e,t,n){return n===`px`?{value:t.value,unit:`px`}:{value:t.value/e*100,unit:`%`}}var pa=class extends Fi{_parentElement;constructor(e=[]){super(e,{idProperty:`viewUid`}),this.on(`add`,(e,t,n)=>{this._renderViewIntoCollectionParent(t,n)}),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(let e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!ma(e))throw new w(`ui-viewcollection-delegate-wrong-events`,this);return{to:t=>{for(let n of this)for(let r of e)n.delegate(r).to(t);this.on(`add`,(n,r)=>{for(let n of e)r.delegate(n).to(t)}),this.on(`remove`,(n,r)=>{for(let n of e)r.stopDelegating(n,t)})}}}_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)}};function ma(e){return e.every(e=>typeof e==`string`)}const ha=E();var ga=class extends ha{ns;tag;text;attributes;children;eventListeners;_isRendered;_revertData;constructor(e){super(),Object.assign(this,Oa(Da(e))),this._isRendered=!1,this._revertData=null}render(){let e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData=Ha(),this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new w(`ui-template-revert-not-applied`,[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){function*e(t){if(t.children)for(let n of t.children)Ra(n)?yield n:za(n)&&(yield*e(n))}yield*e(this)}static bind(e,t){return{to(n,r){return new va({eventNameOrFunction:n,attribute:n,observable:e,emitter:t,callback:r})},if(n,r,i){return new ya({observable:e,emitter:t,attribute:n,valueIfTrue:r,callback:i})}}}static extend(e,t){if(e._isRendered)throw new w(`template-extend-render`,[this,e]);Ia(e,Oa(Da(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new w(`ui-template-wrong-syntax`,this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return 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(``),ba(this.text)?this._bindToObservable({schema:this.text,updater:wa(t),data:e}):t.textContent=this.text.join(``),t}_renderAttributes(e){if(!this.attributes)return;let t=e.node,n=e.revertData;for(let r in this.attributes){let i=t.getAttribute(r),a=this.attributes[r];n&&(n.attributes[r]=i);let o=Va(a)?a[0].ns:null;if(ba(a)){let s=Va(a)?a[0].value:a;n&&Ua(r)&&s.unshift(i),this._bindToObservable({schema:s,updater:Ta(t,r,o),data:e})}else if(r==`style`&&typeof a[0]!=`string`)this._renderStyleAttribute(a[0],e);else{n&&i&&Ua(r)&&a.unshift(i);let e=a.map(e=>e&&(e.value||e)).reduce((e,t)=>e.concat(t),[]).reduce(Pa,``);La(e)||t.setAttributeNS(o,r,e)}}}_renderStyleAttribute(e,t){let n=t.node;for(let r in e){let i=e[r];ba(i)?this._bindToObservable({schema:[i],updater:Ea(n,r),data:t}):xa(r)?n.style.setProperty(r,i):n.style[r]=i}}_renderElementChildren(e){let t=e.node,n=e.intoFragment?document.createDocumentFragment():t,r=e.isApplying,i=0;for(let a of this.children)if(Ba(a)){if(!r){a.setParent(t);for(let e of a)n.appendChild(e.element)}}else if(Ra(a))r||(a.isRendered||a.render(),n.appendChild(a.element));else if(vr(a))n.appendChild(a);else if(r){let t=e.revertData,r=Ha();t.children.push(r),a._renderNode({intoFragment:!1,node:n.childNodes[i++],isApplying:!0,revertData:r})}else n.appendChild(a.render());e.intoFragment&&t.appendChild(n)}_setUpListeners(e){if(this.eventListeners)for(let t in this.eventListeners){let n=this.eventListeners[t].map(n=>{let[r,i]=t.split(`@`);return n.activateDomEventListener(r,i,e)});e.revertData&&e.revertData.bindings.push(n)}}_bindToObservable({schema:e,updater:t,data:n}){let r=n.revertData;Ca(e,t,n);let i=e.filter(e=>!La(e)).filter(e=>e.observable).map(r=>r.activateAttributeListener(e,t,n));r&&r.bindings.push(i)}_revertTemplateFromNode(e,t){for(let e of t.bindings)for(let t of e)t();if(t.text){e.textContent=t.text;return}let n=e;for(let e in t.attributes){let r=t.attributes[e];r===null?n.removeAttribute(e):n.setAttribute(e,r)}for(let e=0;eCa(e,t,n);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,r),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,r)}}},va=class extends _a{eventNameOrFunction;constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,n){let r=(e,n)=>{(!t||n.target.matches(t))&&(typeof this.eventNameOrFunction==`function`?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,e,r),()=>{this.emitter.stopListening(n.node,e,r)}}},ya=class extends _a{valueIfTrue;constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return La(super.getValue(e))?!1:this.valueIfTrue||!0}};function ba(e){return e?(e.value&&(e=e.value),Array.isArray(e)?e.some(ba):e instanceof _a):!1}function xa(e){return/^--[a-zA-Z_-][\w-]*$/.test(e)}function Sa(e,t){return e.map(e=>e instanceof _a?e.getValue(t):e)}function Ca(e,t,{node:n}){let r=Sa(e,n),i;i=e.length==1&&e[0]instanceof ya?r[0]:r.reduce(Pa,``),La(i)?t.remove():t.set(i)}function wa(e){return{set(t){e.textContent=t},remove(){e.textContent=``}}}function Ta(e,t,n){return{set(r){e.setAttributeNS(n,t,r)},remove(){e.removeAttributeNS(n,t)}}}function Ea(e,t){return{set(n){xa(t)?e.style.setProperty(t,n):e.style[t]=n},remove(){xa(t)?e.style.removeProperty(t):e.style[t]=null}}}function Da(e){return Lt(e,e=>{if(e&&(e instanceof _a||za(e)||Ra(e)||Ba(e)))return e})}function Oa(e){if(typeof e==`string`?e=ja(e):e.text&&Ma(e),e.on&&(e.eventListeners=Aa(e.on),delete e.on),!e.text){e.attributes&&ka(e.attributes);let t=[];if(e.children)if(Ba(e.children))t.push(e.children);else for(let n of e.children)za(n)||Ra(n)||vr(n)?t.push(n):t.push(new ga(n));e.children=t}return e}function ka(e){for(let t in e)e[t].value&&(e[t].value=A(e[t].value)),Na(e,t)}function Aa(e){for(let t in e)Na(e,t);return e}function ja(e){return{text:[e]}}function Ma(e){e.text=A(e.text)}function Na(e,t){e[t]=A(e[t])}function Pa(e,t){return La(t)?e:La(e)?t:`${e} ${t}`}function Fa(e,t){for(let n in t)e[n]?e[n].push(...t[n]):e[n]=t[n]}function Ia(e,t){if(t.attributes&&(e.attributes||={},Fa(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||={},Fa(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 w(`ui-template-extend-children-mismatch`,e);let n=0;for(let r of t.children)Ia(e.children[n++],r)}}function La(e){return!e&&e!==0}function Ra(e){return e instanceof P}function za(e){return e instanceof ga}function Ba(e){return e instanceof pa}function Va(e){return Xe(e[0])&&e[0].ns}function Ha(){return{children:[],bindings:[],attributes:{}}}function Ua(e){return e==`class`||e==`style`}const Wa=br(D());var P=class extends Wa{element;isRendered;locale;t;template;_viewCollections;_unboundChildren;_bindTemplate;constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Fi,this._unboundChildren=this.createCollection(),this._viewCollections.on(`add`,(t,n)=>{n.locale=e,n.t=e&&e.t}),this.decorate(`render`)}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=ga.bind(this,this)}createCollection(e){let t=new pa(e);return this._viewCollections.add(t),t}registerChild(e){pr(e)||(e=[e]);for(let t of e)this._unboundChildren.add(t)}deregisterChild(e){pr(e)||(e=[e]);for(let t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new ga(e)}extendTemplate(e){ga.extend(this.template,e)}render(){if(this.isRendered)throw new w(`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)}};const Ga={POLITE:`polite`,ASSERTIVE:`assertive`};var Ka=class{editor;view;constructor(e){this.editor=e,e.once(`ready`,()=>{for(let e of Object.values(Ga))this.announce(``,e)})}announce(e,t=Ga.POLITE){let n=this.editor;if(!n.ui.view)return;this.view||(this.view=new qa(n.locale),n.ui.view.body.add(this.view));let{politeness:r,isUnsafeHTML:i}=typeof t==`string`?{politeness:t}:t,a=this.view.regionViews.find(e=>e.politeness===r);a||(a=new Ja(n,r),this.view.regionViews.add(a)),a.announce({announcement:e,isUnsafeHTML:i})}},qa=class extends P{regionViews;constructor(e){super(e),this.regionViews=this.createCollection(),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-aria-live-announcer`]},children:this.regionViews})}},Ja=class extends P{politeness;_domConverter;_pruneAnnouncementsInterval;constructor(e,t){super(e.locale),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`,()=>{this._pruneAnnouncementsInterval!==null&&(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({announcement:e,isUnsafeHTML:t}){if(!e.trim().length)return;let n=document.createElement(`li`);t?this._domConverter.setContentOf(n,e):n.innerText=e,this._listElement.appendChild(n)}get _listElement(){return this.element.querySelector(`ul`)}};function Ya({emitter:e,activator:t,callback:n,contextElements:r,listenerOptions:i}){e.listenTo(document,`mousedown`,(e,i)=>{if(!t())return;let a=typeof i.composedPath==`function`?i.composedPath():[],o=typeof r==`function`?r():r;for(let e of o)if(e.contains(i.target)||a.includes(e))return;n()},i)}function Xa(e){class t extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...e){super(...e),this.set(`_isCssTransitionsDisabled`,!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.template&&this.extendTemplate({attributes:{class:[this.bindTemplate.if(`_isCssTransitionsDisabled`,`ck-transitions-disabled`)]}})}}return t}function Za(e){class t extends e{_onDragBound=this._onDrag.bind(this);_onDragEndBound=this._onDragEnd.bind(this);_lastDraggingCoordinates={x:0,y:0};constructor(...e){super(...e),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(u.document,`mouseup`,this._onDragEndBound),this.listenTo(u.document,`touchend`,this._onDragEndBound),this.listenTo(u.document,`mousemove`,this._onDragBound),this.listenTo(u.document,`touchmove`,this._onDragBound)}_detachDragListeners(){this.stopListening(u.document,`mouseup`,this._onDragEndBound),this.stopListening(u.document,`touchend`,this._onDragEndBound),this.stopListening(u.document,`mousemove`,this._onDragBound),this.stopListening(u.document,`touchmove`,this._onDragBound)}_onDragStart(e,t){if(!this._isHandleElementPressed(t))return;this._attachDragListeners();let n=0,r=0;t instanceof MouseEvent?(n=t.clientX,r=t.clientY):(n=t.touches[0].clientX,r=t.touches[0].clientY),this._lastDraggingCoordinates={x:n,y:r},this.isDragging=!0}_onDrag(e,t){if(!this.isDragging){this._detachDragListeners();return}let n=0,r=0;t instanceof MouseEvent?(n=t.clientX,r=t.clientY):(n=t.touches[0].clientX,r=t.touches[0].clientY),t.preventDefault(),this.fire(`drag`,{deltaX:Math.round(n-this._lastDraggingCoordinates.x),deltaY:Math.round(r-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:n,y:r}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(e){return this.dragHandleElement?this.dragHandleElement===e.target||e.target instanceof HTMLElement&&this.dragHandleElement.contains(e.target):!1}}return t}function Qa({view:e}){e.listenTo(e.element,`submit`,(t,n)=>{n.preventDefault(),e.fire(`submit`)},{useCapture:!0})}function $a({keystrokeHandler:e,focusTracker:t,gridItems:n,numberOfColumns:r,uiLanguageDirection:i}){let a=typeof r==`number`?()=>r:r;e.set(`arrowright`,o((e,t)=>i===`rtl`?c(e,t.length):s(e,t.length))),e.set(`arrowleft`,o((e,t)=>i===`rtl`?s(e,t.length):c(e,t.length))),e.set(`arrowup`,o((e,t)=>{let n=e-a();return n<0&&(n=e+a()*Math.floor(t.length/a()),n>t.length-1&&(n-=a())),n})),e.set(`arrowdown`,o((e,t)=>{let n=e+a();return n>t.length-1&&(n=e%a()),n}));function o(e){return r=>{let i=n.find(e=>e.element===t.focusedElement),a=e(n.getIndex(i),n);n.get(a).focus(),r.stopPropagation(),r.preventDefault()}}function s(e,t){return e===t-1?0:e+1}function c(e,t){return e===0?t-1:e-1}}var eo=class extends P{id;constructor(e){super(e),this.set(`text`,void 0),this.set(`for`,void 0),this.id=`ck-editor__label_${he()}`;let t=this.bindTemplate;this.setTemplate({tag:`label`,attributes:{class:[`ck`,`ck-label`],id:this.id,for:t.to(`for`)},children:[{text:t.to(`text`)}]})}},to=class extends P{constructor(e,t){super(e);let n=e.t,r=new eo;r.text=n(`Help Contents. To close this dialog press ESC.`),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-accessibility-help-dialog__content`],"aria-labelledby":r.id,role:`document`,tabindex:-1},children:[mr(document,`p`,{},n(`Below, you can find a list of keyboard shortcuts that can be used in the editor.`)),...this._createCategories(Array.from(t.values())),r]})}focus(){this.element.focus()}_createCategories(e){return e.map(e=>{let t=[mr(document,`h3`,{},e.label),...Array.from(e.groups.values()).map(e=>this._createGroup(e)).flat()];return e.description&&t.splice(1,0,mr(document,`p`,{},e.description)),mr(document,`section`,{},t)})}_createGroup(e){let t=e.keystrokes.sort((e,t)=>e.label.localeCompare(t.label)).map(e=>this._createGroupRow(e)).flat(),n=[mr(document,`dl`,{},t)];return e.label&&n.unshift(mr(document,`h4`,{},e.label)),n}_createGroupRow(e){let t=this.locale.t,n=mr(document,`dt`),r=mr(document,`dd`),i=ro(e.keystroke),a=[];for(let e of i)a.push(e.map(no).join(``));return n.innerHTML=e.label,r.innerHTML=a.join(`, `)+(e.mayRequireFn&&p.isMac?` ${t(`(may require Fn)`)}`:``),[n,r]}};function no(e){return bi(e).split(`+`).map(e=>`${e}`).join(`+`)}function ro(e){return typeof e==`string`?[[e]]:typeof e[0]==`string`?[e]:e}const io=D();var F=class extends io{editor;_disableStack=new Set;constructor(e){super(),this.editor=e,this.set(`isEnabled`,!0)}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on(`set:isEnabled`,ao,{priority:`highest`}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off(`set:isEnabled`,ao),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}};function ao(e){e.return=!1,e.stop()}const oo=D();var I=class extends oo{editor;_isEnabledBasedOnSelection;_affectsData;_disableStack;static get _throwErrorWhenUsedAsAPlugin(){return!0}constructor(e){super(),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;let n=e.model.document.selection,r=n.getFirstPosition().root.rootName!=`$graveyard`&&e.model.canEditAt(n);(e.isReadOnly||this._isEnabledBasedOnSelection&&!r)&&(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),this._disableStack.size==1&&(this.on(`set:isEnabled`,so,{priority:`highest`}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off(`set:isEnabled`,so),this.refresh())}execute(...e){}destroy(){this.stopListening()}};function so(e){e.return=!1,e.stop()}var co=class extends I{_childCommandsDefinitions=[];refresh(){}execute(...e){let t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){_e(this._childCommandsDefinitions,{command:e,priority:t.priority||`normal`}),e.on(`change:isEnabled`,()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){let e=this._childCommandsDefinitions.find(({command:e})=>e.isEnabled);return e&&e.command}},lo=class{_commands;constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){let n=this.get(e);if(!n)throw new w(`commandcollection-command-not-found`,this,{commandName:e});return n.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(let e of this.commands())e.destroy()}};const uo=E();var fo=class extends uo{_context;_plugins=new Map;_availablePlugins;_contextPlugins;constructor(e,t=[],n=[]){super(),this._context=e,this._availablePlugins=new Map;for(let e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(let[e,t]of n)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(let e of this._plugins)typeof e[0]==`function`&&(yield e)}get(e){let t=this._plugins.get(e);if(!t){let t=e;throw typeof e==`function`&&(t=e.pluginName||e.name),new w(`plugincollection-plugin-not-loaded`,this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}async init(e,t=[],n=[]){let r=this,i=this._context;d(e),p(e);let a=[...f(e.filter(e=>!l(e,t)))];ee(a,n);let o=v(a);return await y(o,`init`),await y(o,`afterInit`),o;function s(e){return typeof e==`function`}function c(e){return s(e)&&!!e.isContextPlugin}function l(e,t){return t.some(t=>t===e||u(e)===t||u(t)===e)}function u(e){return s(e)?e.pluginName||e.name:e}function d(e,t=new Set){e.forEach(e=>{s(e)&&(t.has(e)||(t.add(e),e.pluginName&&!r._availablePlugins.has(e.pluginName)&&r._availablePlugins.set(e.pluginName,e),e.requires&&d(e.requires,t)))})}function f(e,t=new Set){return e.map(e=>s(e)?e:r._availablePlugins.get(e)).reduce((e,n)=>t.has(n)?e:(t.add(n),n.requires&&(p(n.requires,n),f(n.requires,t).forEach(t=>e.add(t))),e.add(n)),new Set)}function p(e,t=null){e.map(e=>s(e)?e:r._availablePlugins.get(e)||e).forEach(e=>{m(e),h(e,t),g(e,t),_(e,t)})}function m(e){if(typeof e==`function`&&e._throwErrorWhenUsedAsAPlugin)throw new w(`plugincollection-plugin-invalid-constructor`,i,{name:e.name})}function h(e,t){if(!s(e))throw t?new w(`plugincollection-soft-required`,i,{missingPlugin:e,requiredBy:u(t)}):new w(`plugincollection-plugin-not-found`,i,{plugin:e})}function g(e,t){if(c(t)&&!c(e))throw new w(`plugincollection-context-required`,i,{plugin:u(e),requiredBy:u(t)})}function _(e,n){if(n&&l(e,t))throw new w(`plugincollection-required`,i,{plugin:u(e),requiredBy:u(n)})}function v(e){return e.map(e=>{let t=r._contextPlugins.get(e);return t||=new e(i),r._add(e,t),t})}function y(e,t){return e.reduce((e,n)=>!n[t]||r._contextPlugins.has(n)?e:e.then(n[t].bind(n)),Promise.resolve())}function ee(e,t){for(let n of t){if(typeof n!=`function`)throw new w(`plugincollection-replace-plugin-invalid-type`,null,{pluginItem:n});let t=n.pluginName;if(!t)throw new w(`plugincollection-replace-plugin-missing-name`,null,{pluginItem:n});if(n.requires&&n.requires.length)throw new w(`plugincollection-plugin-for-replacing-cannot-have-dependencies`,null,{pluginName:t});let i=r._availablePlugins.get(t);if(!i)throw new w(`plugincollection-plugin-for-replacing-not-exist`,null,{pluginName:t});let a=e.indexOf(i);if(a===-1){if(r._contextPlugins.has(i))return;throw new w(`plugincollection-plugin-for-replacing-not-loaded`,null,{pluginName:t})}if(i.requires&&i.requires.length)throw new w(`plugincollection-replaced-plugin-cannot-have-dependencies`,null,{pluginName:t});e.splice(a,1,n),r._availablePlugins.set(t,n)}}}destroy(){let e=[];for(let[,t]of this)typeof t.destroy==`function`&&!this._contextPlugins.has(t)&&e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);let n=e.pluginName;if(n){if(this._plugins.has(n))throw new w(`plugincollection-plugin-name-conflict`,null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:e});this._plugins.set(n,t)}}},po=class{config;plugins;locale;t;editors;static defaultConfig;static builtinPlugins;_contextOwner=null;constructor(e){let{translations:t,...n}=e||{};this.config=new hr(n,this.constructor.defaultConfig);let r=this.constructor.builtinPlugins;this.config.define(`plugins`,r),this.plugins=new fo(this,r);let i=this.config.get(`language`)||{};this.locale=new Mi({uiLanguage:typeof i==`string`?i:i.ui,contentLanguage:this.config.get(`language.content`),translations:t}),this.t=this.locale.t,this.editors=new Fi}initPlugins(){let e=this.config.get(`plugins`)||[],t=this.config.get(`substitutePlugins`)||[];for(let n of e.concat(t)){if(typeof n!=`function`)throw new w(`context-initplugins-constructor-only`,null,{Plugin:n});if(n.isContextPlugin!==!0)throw new w(`context-initplugins-invalid-plugin`,null,{Plugin:n})}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 w(`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(){let e={};for(let 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=>{let n=new this(e);t(n.initPlugins().then(()=>n))})}static get _throwErrorWhenUsedAsAPlugin(){return!0}};const mo=D();var ho=class extends mo{context;constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}},go=class extends N{editor;constructor(e){super(),this.editor=e}set(e,t,n={}){if(typeof t==`string`){let e=t;t=(t,n)=>{this.editor.execute(e),n()}}super.set(e,t,n)}};const _o=new WeakMap;let vo=!1;function yo({view:e,element:t,text:n,isDirectHost:r=!0,keepOnFocus:i=!1}){let a=e.document;_o.has(a)||(_o.set(a,new Map),a.registerPostFixer(e=>wo(_o.get(a),e)),a.on(`change:isComposing`,()=>{e.change(e=>wo(_o.get(a),e))},{priority:`high`})),t.is(`editableElement`)&&t.on(`change:placeholder`,(e,t,n)=>o(n)),t.placeholder?o(t.placeholder):n&&o(n),n&&Aee();function o(n){let o={text:n,isDirectHost:r,keepOnFocus:i,hostElement:r?t:null};_o.get(a).set(t,o),e.change(e=>wo([[t,o]],e))}}function bo(e,t){let n=t.document;_o.has(n)&&e.change(e=>{let r=_o.get(n),i=r.get(t);e.removeAttribute(`data-placeholder`,i.hostElement),So(e,i.hostElement),r.delete(t)})}function xo(e,t){return t.hasClass(`ck-placeholder`)?!1:(e.addClass(`ck-placeholder`,t),!0)}function So(e,t){return t.hasClass(`ck-placeholder`)?(e.removeClass(`ck-placeholder`,t),!0):!1}function Co(e,t){if(!e.isAttached()||Oee(e))return!1;let n=e.document,r=n.selection.anchor;return n.isComposing&&r&&r.parent===e?!1:t||!n.isFocused?!0:!!r&&r.parent!==e}function Oee(e){for(let t of e.getChildren())if(!t.is(`uiElement`))return!0;return!1}function wo(e,t){let n=[],r=!1;for(let[i,a]of e)a.isDirectHost&&(n.push(i),To(t,i,a)&&(r=!0));for(let[i,a]of e){if(a.isDirectHost)continue;let e=kee(i);e!==a.hostElement&&a.hostElement&&(t.removeAttribute(`data-placeholder`,a.hostElement),So(t,a.hostElement),a.hostElement=null,r=!0),e&&(n.includes(e)||(a.hostElement=e,To(t,i,a)&&(r=!0)))}return r}function To(e,t,n){let{text:r,isDirectHost:i,hostElement:a}=n,o=!1;return a.getAttribute(`data-placeholder`)!==r&&(e.setAttribute(`data-placeholder`,r,a),o=!0),(i||t.childCount==1)&&Co(a,n.keepOnFocus)?xo(e,a)&&(o=!0):So(e,a)&&(o=!0),o}function kee(e){if(e.childCount){let t=e.getChild(0);if(t.is(`element`)&&!t.is(`uiElement`)&&!t.is(`attributeElement`))return t}return null}function Aee(){vo||T(`enableViewPlaceholder-deprecated-text-option`),vo=!0}var Eo=class{is(){throw Error(`is() method is abstract`)}};const jee=E(Eo);var Do=class extends jee{document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if((e=this.parent.getChildIndex(this))==-1)throw new w(`view-node-not-found-in-parent`,this);return e}get nextSibling(){let e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){let e=this.index;return e!==null&&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(){let e=[],t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){let t=[],n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?`push`:`unshift`](n),n=n.parent;return t}getCommonAncestor(e,t={}){let n=this.getAncestors(t),r=e.getAncestors(t),i=0;for(;n[i]==r[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;let t=this.getPath(),n=e.getPath(),r=fr(t,n);switch(r){case`prefix`:return!0;case`extension`:return!1;default:return t[r]e.data.length)throw new w(`view-textproxy-wrong-offsetintext`,this);if(n<0||t+n>e.data.length)throw new w(`view-textproxy-wrong-length`,this);this.data=e.data.substring(t,t+n),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(e={}){let t=[],n=e.includeSelf?this.textNode:this.parent;for(;n!==null;)t[e.parentFirst?`push`:`unshift`](n),n=n.parent;return t}};ko.prototype.is=function(e){return e===`$textProxy`||e===`view:$textProxy`||e===`textProxy`||e===`view:textProxy`};var Ao=class e{_consumables=new Map;add(e,t){let n;if(e.is(`$text`)||e.is(`documentFragment`)){this._consumables.set(e,!0);return}this._consumables.has(e)?n=this._consumables.get(e):(n=new jo(e),this._consumables.set(e,n)),n.add(t?Mo(t):e._getConsumables())}test(e,t){let n=this._consumables.get(e);return n===void 0?null:e.is(`$text`)||e.is(`documentFragment`)?n:n.test(Mo(t))}consume(e,t){if(e.is(`$text`)||e.is(`documentFragment`))return this.test(e,t)?(this._consumables.set(e,!1),!0):!1;let n=this._consumables.get(e);return n===void 0?!1:n.consume(Mo(t))}revert(e,t){let n=this._consumables.get(e);n!==void 0&&(e.is(`$text`)||e.is(`documentFragment`)?this._consumables.set(e,!0):n.revert(Mo(t)))}static createFrom(t,n){if(n||=new e,t.is(`$text`))n.add(t);else if(t.is(`element`)||t.is(`documentFragment`)){n.add(t);for(let r of t.getChildren())e.createFrom(r,n)}return n}},jo=class{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(let[t,n]of e.attributes)if(n){let e=this._attributes.get(t);(!e||typeof e==`boolean`)&&(e=new Map,this._attributes.set(t,e)),e.set(n,!0)}else if(t==`style`||t==`class`)throw new w(`viewconsumable-invalid-attribute`,this);else this._attributes.set(t,!0)}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(let[t,n]of e.attributes){let e=this._attributes.get(t);if(e===void 0)return null;if(e===!1)return!1;if(e!==!0){if(n){let t=e.get(n);if(t===void 0)return null;if(!t)return!1}else for(let t of e.values())if(!t)return!1}}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(let[t,n]of e.attributes){let e=this._attributes.get(t);if(typeof e==`boolean`)for(let[e]of this.element._getConsumables(t,n).attributes)this._attributes.set(e,!1);else if(n)for(let[,r]of this.element._getConsumables(t,n).attributes)e.set(r,!1);else for(let t of e.keys())e.set(t,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(let[t,n]of e.attributes){let e=this._attributes.get(t);if(e===!1){this._attributes.set(t,!0);continue}if(!(e===void 0||e===!0))if(n)e.get(n)===!1&&e.set(n,!0);else for(let t of e.keys())e.set(t,!0)}}};function Mo(e){let t=[];return`attributes`in e&&e.attributes&&No(t,e.attributes),`classes`in e&&e.classes&&No(t,e.classes,`class`),`styles`in e&&e.styles&&No(t,e.styles,`style`),{name:e.name||!1,attributes:t}}function No(e,t,n){if(typeof t==`string`){e.push(n?[n,t]:[t]);return}for(let r of t)Array.isArray(r)?e.push(r):e.push(n?[n,r]:[r])}var Po=class{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)(typeof t==`string`||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(let t of e)for(let e of this._patterns){let n=this._isElementMatching(t,e);if(n)return{element:t,pattern:e,match:n}}return null}matchAll(...e){let t=[];for(let n of e)for(let e of this._patterns){let r=this._isElementMatching(n,e);r&&t.push({element:n,pattern:e,match:r})}return t.length>0?t:null}getElementName(){if(this._patterns.length!==1)return null;let e=this._patterns[0],t=e.name;return typeof e!=`function`&&t&&!(t instanceof RegExp)?t:null}_isElementMatching(e,t){if(typeof t==`function`){let n=t(e);return!n||typeof n!=`object`?n:Mo(n)}let n={};if(t.name&&(n.name=Io(t.name,e.name),!n.name))return null;let r=[];return t.attributes&&!Ro(t.attributes,e,r)||t.classes&&!zo(t.classes,e,r)||t.styles&&!Bo(t.styles,e,r)?null:(r.length&&(n.attributes=r),n)}};function Fo(e,t){return e===!0||e===t||e instanceof RegExp&&!!String(t).match(e)}function Io(e,t){return e instanceof RegExp?!!t.match(e):e===t}function Lo(e,t){if(Array.isArray(e))return e.map(e=>typeof e!=`object`||e instanceof RegExp?t?[t,e,!0]:[e,!0]:((e.key===void 0||e.value===void 0)&&T(`matcher-pattern-missing-key-or-value`,e),t?[t,e.key,e.value]:[e.key,e.value]));if(typeof e!=`object`||e instanceof RegExp)return[t?[t,e,!0]:[e,!0]];let n=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t?[t,r,e[r]]:[r,e[r]]);return n}function Ro(e,t,n){let r;return typeof e==`object`&&!(e instanceof RegExp)&&!Array.isArray(e)?(e.style!==void 0&&T(`matcher-pattern-deprecated-attributes-style-key`,e),e.class!==void 0&&T(`matcher-pattern-deprecated-attributes-class-key`,e)):r=[`class`,`style`],t._collectAttributesMatch(Lo(e),n,r)}function zo(e,t,n){return t._collectAttributesMatch(Lo(e,`class`),n)}function Bo(e,t,n){return t._collectAttributesMatch(Lo(e,`style`),n)}var Vo=class{_styles;_cachedStyleNames=null;_cachedExpandedStyleNames=null;_styleProcessor;constructor(e){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();let t=Uo(e);for(let[e,n]of t)this._styleProcessor.toNormalizedForm(e,n,this._styles);return this}has(e){if(this.isEmpty)return!1;let t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);return Array.isArray(t)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,Xe(e))for(let[t,n]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,n,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){let t={};for(let n of A(e)){let e=Wo(n),r=Je(this._styles,e);if(r)Go(t,e,r);else{let e=this.getAsString(n);e!==void 0&&this._styleProcessor.toNormalizedForm(n,e,t)}}Object.keys(t).length&&(Ko(this._styles,t),this._cachedStyleNames=null,this._cachedExpandedStyleNames=null)}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]&&!Xe(this._styles[e]))return this._styles[e];let t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);if(Array.isArray(t))return t[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map(([e])=>e),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(let t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){let e=[],t=Object.keys(this._styles);for(let n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_clone(){let e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){let n=[];for(let r of this.getStyleNames(!0))if(Fo(e,r)){if(t===!0){n.push(r);continue}Fo(t,this.getAsString(r))&&n.push(r)}return n.length?n:void 0}_getConsumables(e){let t=[];if(e){t.push(e);for(let n of this._styleProcessor.getRelatedStyles(e))t.push(n)}else for(let e of this.getStyleNames()){for(let n of this._styleProcessor.getRelatedStyles(e))t.push(n);t.push(e)}return t}_canMergeFrom(e){for(let t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(let t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(let t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}},Ho=class{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(Xe(t)){Go(n,Wo(e),t);return}if(this._normalizers.has(e)){let{path:r,value:i}=this._normalizers.get(e)(t);Go(n,r,i)}else Go(n,e,t)}getNormalized(e,t){if(!e)return wn({},t);if(t[e]!==void 0)return t[e];if(this._extractors.has(e)){let n=this._extractors.get(e);if(typeof n==`string`)return Je(t,n);let r=n(e,t);if(r)return r}return Je(t,Wo(e))}getReducedForm(e,t){let n=this.getNormalized(e,t);return n===void 0?[]:this._reducers.has(e)?this._reducers.get(e)(n):[[e,n]]}getStyleNames(e){let t=new Set;for(let n of this._consumables.keys()){let r=this.getNormalized(n,e);r&&(typeof r!=`object`||Object.keys(r).length)&&t.add(n)}for(let n of Object.keys(e))t.add(n);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(let n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}};function Uo(e){let t=null,n=0,r=0,i=null,a=new Map;if(e===``)return a;e.charAt(e.length-1)!=`;`&&(e+=`;`);for(let o=0;oe!=`style`&&e!=`class`).map(e=>`${e[0]}="${e[1]}"`).sort().join(` `);return this.name+(e==``?``:` class="${e}"`)+(t?` style="${t}"`:``)+(n==``?``:` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}toJSON(){let e=super.toJSON();if(e.name=this.name,e.type=`Element`,this._attrs.size&&(e.attributes=Object.fromEntries(this.getAttributes())),this._children.length>0){e.children=[];for(let t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){let t=[];if(e)for(let n of this.getChildren())t.push(n._clone(e));let n=new this.constructor(this.document,this.name,this._attrs,t);return n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange(`children`,this,{index:e});let n=0,r=Yo(this.document,t);for(let t of r)t.parent!==null&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange(`children`,this,{index:e});for(let n=e;nt&&e.selection.editableElement==this),this.listenTo(e.selection,`change`,()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}toJSON(){let e=super.toJSON();return e.type=`EditableElement`,e.isReadOnly=this.isReadOnly,e.isFocused=this.isFocused,e}};es.prototype.is=function(e,t){return t?t===this.name&&(e===`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`};const ts=Symbol(`rootName`);var ns=class extends es{constructor(e,t){super(e,t),this.rootName=`main`}get rootName(){return this.getCustomProperty(ts)}set rootName(e){this._setCustomProperty(ts,e)}toJSON(){return this.rootName}set _name(e){this.name=e}};ns.prototype.is=function(e,t){return t?t===this.name&&(e===`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`};var rs=class{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new w(`view-tree-walker-no-start-position`,null);if(e.direction&&e.direction!=`forward`&&e.direction!=`backward`)throw new w(`view-tree-walker-unknown-direction`,e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=L._createAt(e.startPosition):this._position=L._createAt(e.boundaries[e.direction==`backward`?`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,n;do n=this.position,t=this.next();while(!t.done&&e(t.value));t.done||(this._position=n)}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 this.direction==`forward`?this._next():this._previous()}_next(){let e=this.position.clone(),t=this.position,n=e.parent;if(n.parent===null&&e.offset===n.childCount||n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let r;if(n&&n.is(`view:$text`)){if(e.isAtEnd)return this._position=L._createAfter(n),this._next();r=n.data[e.offset]}else r=n.getChild(e.offset);if(typeof r==`string`){let r;r=this.singleCharacters?1:(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset;let i=new ko(n,e.offset,r);return e.offset+=r,this._position=e,this._formatReturnValue(`text`,i,t,e,r)}if(r&&r.is(`view:element`)){if(!this.shallow)e=new L(r,0);else{if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}return this._position=e,this._formatReturnValue(`elementStart`,r,t,e,1)}if(r&&r.is(`view:$text`)){if(this.singleCharacters)return e=new L(r,0),this._position=e,this._next();let n=r.data.length,i;return r==this._boundaryEndParent?(n=this.boundaries.end.offset,i=new ko(r,0,n),e=L._createAfter(i)):(i=new ko(r,0,r.data.length),e.offset++),this._position=e,this._formatReturnValue(`text`,i,t,e,n)}return e=L._createAfter(n),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue(`elementEnd`,n,t,e)}_previous(){let e=this.position.clone(),t=this.position,n=e.parent;if(n.parent===null&&e.offset===0||n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let r;if(n.is(`view:$text`)){if(e.isAtStart)return this._position=L._createBefore(n),this._previous();r=n.data[e.offset-1]}else r=n.getChild(e.offset-1);if(typeof r==`string`){let r;if(this.singleCharacters)r=1;else{let t=n===this._boundaryStartParent?this.boundaries.start.offset:0;r=e.offset-t}e.offset-=r;let i=new ko(n,e.offset,r);return this._position=e,this._formatReturnValue(`text`,i,t,e,r)}if(r&&r.is(`view:element`))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue(`elementStart`,r,t,e,1)):(e=new L(r,r.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue(`elementEnd`,r,t,e));if(r&&r.is(`view:$text`)){if(this.singleCharacters)return e=new L(r,r.data.length),this._position=e,this._previous();let n=r.data.length,i;if(r==this._boundaryStartParent){let t=this.boundaries.start.offset;i=new ko(r,t,r.data.length-t),n=i.data.length,e=L._createBefore(i)}else i=new ko(r,0,r.data.length),e.offset--;return this._position=e,this._formatReturnValue(`text`,i,t,e,n)}return e=L._createBefore(n),this._position=e,this._formatReturnValue(`elementStart`,n,t,e,1)}_formatReturnValue(e,t,n,r,i){return t.is(`view:$textProxy`)&&(t.offsetInText+t.data.length==t.textNode.data.length&&(this.direction==`forward`&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(r=L._createAfter(t.textNode),this._position=r):n=L._createAfter(t.textNode)),t.offsetInText===0&&(this.direction==`backward`&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(r=L._createBefore(t.textNode),this._position=r):n=L._createBefore(t.textNode))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:r,length:i}}}},L=class e extends Eo{parent;offset;constructor(e,t){super(),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 this.offset===0}get isAtEnd(){let 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 es);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(t){let n=e._createAt(this),r=n.offset+t;return n.offset=r<0?0:r,n}getLastMatchingPosition(e,t={}){t.startPosition=this;let n=new rs(t);return n.skip(e),n.position}getAncestors(){return this.parent.is(`documentFragment`)?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){let t=this.getAncestors(),n=e.getAncestors(),r=0;for(;t[r]==n[r]&&t[r];)r++;return r===0?null:t[r-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return this.compareWith(e)==`before`}isAfter(e){return this.compareWith(e)==`after`}compareWith(e){if(this.root!==e.root)return`different`;if(this.isEqual(e))return`same`;let t=this.parent.is(`node`)?this.parent.getPath():[],n=e.parent.is(`node`)?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);let r=fr(t,n);switch(r){case`prefix`:return`before`;case`extension`:return`after`;default:return t[r]0?new this(n,r):new this(r,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){let t=e.is(`$textProxy`)?e.offsetSize:1;return this._createFromPositionAndShift(L._createBefore(e),t)}};R.prototype.is=function(e){return e===`range`||e===`view:range`};function is(e){return!!(e.item.is(`attributeElement`)||e.item.is(`uiElement`))}const as=E(Eo);var os=class e extends as{_ranges;_lastRangeBackward;_isFake;_fakeSelectionLabel;constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel=``,e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;let e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;let e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return this.rangeCount===1&&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(let e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(let t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?e.clone():null}getLastRange(){let e=null;for(let t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?e.clone():null}getFirstPosition(){let e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){let e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(let t of this._ranges){let n=!1;for(let r of e._ranges)if(t.isEqual(r)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;let t=dr(this.getRanges());if(t!=dr(e.getRanges()))return!1;if(t==0)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let n=!1;for(let r of e.getRanges())if(r=r.getTrimmed(),t.start.isEqual(r.start)&&t.end.isEqual(r.end)){n=!0;break}if(!n)return!1}return!0}getSelectedElement(){return this.rangeCount===1?this.getFirstRange().getContainedElement():null}setTo(...t){let[n,r,i]=t;if(typeof r==`object`&&(i=r,r=void 0),n===null)this._setRanges([]),this._setFakeOptions(i);else if(n instanceof e||n instanceof cs)this._setRanges(n.getRanges(),n.isBackward),this._setFakeOptions({fake:n.isFake,label:n.fakeSelectionLabel});else if(n instanceof R)this._setRanges([n],i&&i.backward),this._setFakeOptions(i);else if(n instanceof L)this._setRanges([new R(n)]),this._setFakeOptions(i);else if(n instanceof Do){let e=!!i&&!!i.backward,t;if(r===void 0)throw new w(`view-selection-setto-required-second-parameter`,this);t=r==`in`?R._createIn(n):r==`on`?R._createOn(n):new R(L._createAt(n,r)),this._setRanges([t],e),this._setFakeOptions(i)}else if(pr(n))this._setRanges(n,i&&i.backward),this._setFakeOptions(i);else throw new w(`view-selection-setto-not-selectable`,this);this.fire(`change`)}setFocus(e,t){if(this.anchor===null)throw new w(`view-selection-setfocus-no-ranges`,this);let n=L._createAt(e,t);if(n.compareWith(this.focus)==`same`)return;let r=this.anchor;this._ranges.pop(),n.compareWith(r)==`before`?this._addRange(new R(n,r),!0):this._addRange(new R(r,n)),this.fire(`change`)}toJSON(){let e={ranges:Array.from(this.getRanges()).map(e=>e.toJSON())};return this.isBackward&&(e.isBackward=!0),this.isFake&&(e.isFake=!0),e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(let t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||``}_addRange(e,t=!1){if(!(e instanceof R))throw new w(`view-selection-add-range-not-range`,this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(let t of this._ranges)if(e.isIntersecting(t))throw new w(`view-selection-range-intersects`,this,{addedRange:e,intersectingRange:t});this._ranges.push(new R(e.start,e.end))}};os.prototype.is=function(e){return e===`selection`||e===`view:selection`};const ss=E(Eo);var cs=class extends ss{_selection;constructor(...e){super(),this._selection=new os,this._selection.delegate(`change`).to(this),e.length&&this._selection.setTo(...e)}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)}toJSON(){return this._selection.toJSON()}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}};cs.prototype.is=function(e){return e===`selection`||e==`documentSelection`||e==`view:selection`||e==`view:documentSelection`};var ls=class extends pe{startRange;_eventPhase;_currentTarget;constructor(e,t,n){super(e,t),this.startRange=n,this._eventPhase=`none`,this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}};const us=Symbol(`bubblingEmitter`),ds=Symbol(`bubblingCallbacks`),fs=Symbol(`bubblingContexts`);function ps(e){class t extends e{fire(e,...t){try{let n=e instanceof pe?e:new pe(this,e),r=_s(this),i=ys(this);if(ms(n,`capturing`,this),hs(r,`$capture`,n,...t))return n.return;let a=n.startRange||this.selection.getFirstRange(),o=a?a.getContainedElement():null,s=o?bs(i,o):!1,c=o||xs(a);if(ms(n,`atTarget`,c),!s){if(hs(r,`$text`,n,...t))return n.return;ms(n,`bubbling`,c)}for(;c;){if(c.is(`element`)&&hs(r,c,n,...t))return n.return;c=c.parent,ms(n,`bubbling`,c)}return ms(n,`bubbling`,this),hs(r,`$document`,n,...t),n.return}catch(e){w.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,n){let r=A(n.context||`$document`),i=_s(this),a=vs(this);for(let e of r)typeof e==`function`&&ys(this).add(e);let o=gs(this,r,t);a.set(t,o),this.listenTo(i,e,o,n)}_removeEventListener(e,t){let n=_s(this),r=vs(this),i=r.get(t);i&&(r.delete(t),this.stopListening(n,e,i))}}return t}function ms(e,t,n){e instanceof ls&&(e._eventPhase=t,e._currentTarget=n)}function hs(e,t,n,...r){return e.fire(n,{currentTarget:t,eventArgs:r}),!!n.stop.called}function gs(e,t,n){return function(r,i){let{currentTarget:a,eventArgs:o}=i;if(typeof a==`string`){t.includes(a)&&n.call(e,r,...o);return}if(a.is(`rootElement`)&&t.includes(`$root`)){n.call(e,r,...o);return}if(t.includes(a.name)){n.call(e,r,...o);return}for(let i of t)if(typeof i==`function`&&i(a)){n.call(e,r,...o);return}}}function _s(e){return e[us]||(e[us]=new(E())),e[us]}function vs(e){return e[ds]||(e[ds]=new Map),e[ds]}function ys(e){return e[fs]||(e[fs]=new Set),e[fs]}function bs(e,t){for(let n of e)if(n(t))return!0;return!1}function xs(e){if(!e)return null;let t=e.start.parent,n=e.end.parent,r=t.getPath(),i=n.getPath();return r.length>i.length?t:n}const Ss=ps(D());var Cs=class extends Ss{selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new cs,this.roots=new Fi({idProperty:`rootName`}),this.stylesProcessor=e,this.set(`isReadOnly`,!1),this.set(`isFocused`,!1),this.set(`isSelecting`,!1),this.set(`isComposing`,!1)}getRoot(e=`main`){return this.roots.get(e)}getRoots(){return Array.from(this.roots)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do for(let n of this._postFixers)if(t=n(e),t)break;while(t)}},ws=class extends Jo{static DEFAULT_PRIORITY=10;_priority=10;_id=null;_clonesGroup=null;constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=Ts}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new w(`attribute-element-get-elements-with-same-id-no-id`,this);return new Set(this._clonesGroup)}isSimilar(e){return this.id!==null||e.id!==null?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}toJSON(){let e=super.toJSON();return e.type=`AttributeElement`,e}_clone(e=!1){let t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}};ws.prototype.is=function(e,t){return t?t===this.name&&(e===`attributeElement`||e===`view:attributeElement`||e===`element`||e===`view:element`):e===`attributeElement`||e===`view:attributeElement`||e===`element`||e===`view:element`||e===`node`||e===`view:node`};function Ts(){if(Es(this))return null;let e=this.parent;for(;e&&e.is(`attributeElement`);){if(Es(e)>1)return null;e=e.parent}return!e||Es(e)>1?null:this.childCount}function Es(e){return Array.from(e.getChildren()).filter(e=>!e.is(`uiElement`)).length}var Ds=class extends Jo{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=Os}toJSON(){let e=super.toJSON();return e.type=`EmptyElement`,e}_insertChild(e,t){if(t&&(t instanceof Do||Array.from(t).length>0))throw new w(`view-emptyelement-cannot-add`,[this,t]);return 0}};Ds.prototype.is=function(e,t){return t?t===this.name&&(e===`emptyElement`||e===`view:emptyElement`||e===`element`||e===`view:element`):e===`emptyElement`||e===`view:emptyElement`||e===`element`||e===`view:element`||e===`node`||e===`view:node`};function Os(){return null}var ks=class extends Jo{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=js}_insertChild(e,t){if(t&&(t instanceof Do||Array.from(t).length>0))throw new w(`view-uielement-cannot-add`,[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){let t=e.createElement(this.name);for(let e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}toJSON(){let e=super.toJSON();return e.type=`UIElement`,e}};ks.prototype.is=function(e,t){return t?t===this.name&&(e===`uiElement`||e===`view:uiElement`||e===`element`||e===`view:element`):e===`uiElement`||e===`view:uiElement`||e===`element`||e===`view:element`||e===`node`||e===`view:node`};function As(e){e.document.on(`arrowKey`,(t,n)=>Ms(t,n,e.domConverter),{priority:`low`})}function js(){return null}function Ms(e,t,n){if(t.keyCode==k.arrowright){let e=t.domTarget.ownerDocument.defaultView.getSelection(),r=e.rangeCount==1&&e.getRangeAt(0).collapsed;if(r||t.shiftKey){let t=e.focusNode,i=e.focusOffset,a=n.domPositionToView(t,i);if(a===null)return;let o=!1,s=a.getLastMatchingPosition(e=>(e.item.is(`uiElement`)&&(o=!0),!!(e.item.is(`uiElement`)||e.item.is(`attributeElement`))));if(o){let t=n.viewPositionToDom(s);r?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}var Ns=class extends Jo{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=Ps}toJSON(){let e=super.toJSON();return e.type=`RawElement`,e}_insertChild(e,t){if(t&&(t instanceof Do||Array.from(t).length>0))throw new w(`view-rawelement-cannot-add`,[this,t]);return 0}render(e,t){}};Ns.prototype.is=function(e,t){return t?t===this.name&&(e===`rawElement`||e===`view:rawElement`||e===`element`||e===`view:element`):e===`rawElement`||e===`view:rawElement`||e===this.name||e===`view:`+this.name||e===`element`||e===`view:element`||e===`node`||e===`view:node`};function Ps(){return null}const Fs=E(Eo);var Is=class extends Fs{document;_children=[];_customProperties=new Map;constructor(e,t){super(),this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}toJSON(){let e=[];for(let t of this._children)e.push(t.toJSON());return e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange(`children`,this,{index:e});let n=0,r=Ls(this.document,t);for(let t of r)t.parent!==null&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange(`children`,this,{index:e});for(let n=e;ntypeof t==`string`?new Oo(e,t):t instanceof ko?new Oo(e,t.data):t))}var Rs=class{document;_cloneGroups=new Map;_slotFactory=null;constructor(e){this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new Is(this.document,e)}createText(e){return new Oo(this.document,e)}createAttributeElement(e,t,n={}){let r=new ws(this.document,e,t);return typeof n.priority==`number`&&(r._priority=n.priority),n.id&&(r._id=n.id),n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createContainerElement(e,t,n={},r={}){let i;Fee(n)?r=n:i=n;let a=new Qo(this.document,e,t,i);return r.renderUnsafeAttributes&&a._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),a}createEditableElement(e,t,n={}){let r=new es(this.document,e,t);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createEmptyElement(e,t,n={}){let r=new Ds(this.document,e,t);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createUIElement(e,t,n){let r=new ks(this.document,e,t);return n&&(r.render=n),r}createRawElement(e,t,n,r={}){let i=new Ns(this.document,e,t);return n&&(i.render=n),r.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),i}setAttribute(e,t,n,r){r===void 0?n._setAttribute(e,t):r._setAttribute(e,t,n)}removeAttribute(e,t,n){n===void 0?t._removeAttribute(e):n._removeAttribute(e,t)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){xn(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof L?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){let t=e.parent;if(!t.is(`containerElement`))throw new w(`view-writer-break-non-container-element`,this.document);if(!t.parent)throw new w(`view-writer-break-root`,this.document);if(e.isAtStart)return L._createBefore(t);if(!e.isAtEnd){let n=t._clone(!1);this.insert(L._createAfter(t),n);let r=new R(e,L._createAt(t,`end`)),i=new L(n,0);this.move(r,i)}return L._createAfter(t)}mergeAttributes(e){let t=e.offset,n=e.parent;if(n.is(`$text`))return e;if(n.is(`attributeElement`)&&n.childCount===0){let e=n.parent,t=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new L(e,t))}let r=n.getChild(t-1),i=n.getChild(t);if(!r||!i)return e;if(r.is(`$text`)&&i.is(`$text`))return Us(r,i);if(r.is(`attributeElement`)&&i.is(`attributeElement`)&&r.isSimilar(i)){let e=r.childCount;return r._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new L(r,e))}return e}mergeContainers(e){let t=e.nodeBefore,n=e.nodeAfter;if(!t||!n||!t.is(`containerElement`)||!n.is(`containerElement`))throw new w(`view-writer-merge-containers-invalid-position`,this.document);let r=t.getChild(t.childCount-1),i=r instanceof Oo?L._createAt(r,`end`):L._createAt(t,`end`);return this.move(R._createIn(n),L._createAt(t,`end`)),this.remove(R._createOn(n)),i}insert(e,t){t=pr(t)?[...t]:[t],Ws(t,this.document);let n=t.reduce((e,t)=>{let n=e[e.length-1],r=!t.is(`uiElement`);return!n||n.breakAttributes!=r?e.push({breakAttributes:r,nodes:[t]}):n.nodes.push(t),e},[]),r=null,i=e;for(let{nodes:e,breakAttributes:t}of n){let n=this._insertNodes(i,e,t);r||=n.start,i=n.end}return r?new R(r,i):new R(e)}remove(e){let t=e instanceof R?e:R._createOn(e);if(Ks(t,this.document),t.isCollapsed)return new Is(this.document);let{start:n,end:r}=this._breakAttributesRange(t,!0),i=n.parent,a=r.offset-n.offset,o=i._removeChildren(n.offset,a);for(let e of o)this._removeFromClonedElementsGroup(e);let s=this.mergeAttributes(n);return t.start=s,t.end=s.clone(),new Is(this.document,o)}clear(e,t){Ks(e,this.document);let n=e.getWalker({direction:`backward`,ignoreElementEnd:!0});for(let r of n){let n=r.item,i;if(n.is(`element`)&&t.isSimilar(n))i=R._createOn(n);else if(!r.nextPosition.isAfter(e.start)&&n.is(`$textProxy`)){let e=n.getAncestors().find(e=>e.is(`element`)&&t.isSimilar(e));e&&(i=R._createIn(e))}i&&(i.end.isAfter(e.end)&&(i.end=e.end),i.start.isBefore(e.start)&&(i.start=e.start),this.remove(i))}}move(e,t){let n;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);let r=t.parent,i=r.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=r.childCount-i}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof ws))throw new w(`view-writer-wrap-invalid-attribute`,this.document);if(Ks(e,this.document),e.isCollapsed){let n=e.start;n.parent.is(`element`)&&!zs(n.parent)&&(n=n.getLastMatchingPosition(e=>e.item.is(`uiElement`))),n=this._wrapPosition(n,t);let r=this.document.selection;return r.isCollapsed&&r.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new R(n)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof ws))throw new w(`view-writer-unwrap-invalid-attribute`,this.document);if(Ks(e,this.document),e.isCollapsed)return e;let{start:n,end:r}=this._breakAttributesRange(e,!0),i=n.parent,a=this._unwrapChildren(i,n.offset,r.offset,t),o=this.mergeAttributes(a.start);return o.isEqual(a.start)||a.end.offset--,new R(o,this.mergeAttributes(a.end))}rename(e,t){let n=new Qo(this.document,e,t.getAttributes());return this.insert(L._createAfter(t),n),this.move(R._createIn(t),L._createAt(n,0)),this.remove(R._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}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 R(e,t)}createRangeOn(e){return R._createOn(e)}createRangeIn(e){return R._createIn(e)}createSelection(...e){return new os(...e)}createSlot(e=`children`){if(!this._slotFactory)throw new w(`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,n){let r;if(r=n?Bs(e):e.parent.is(`$text`)?e.parent.parent:e.parent,!r)throw new w(`view-writer-invalid-position-container`,this.document);let i;i=n?this._breakAttributes(e,!0):e.parent.is(`$text`)?Hs(e):e;let a=r._insertChild(i.offset,t);for(let e of t)this._addToClonedElementsGroup(e);let o=i.getShiftedBy(a),s=this.mergeAttributes(i);return s.isEqual(i)||o.offset--,new R(s,this.mergeAttributes(o))}_wrapChildren(e,t,n,r){let i=t,a=[];for(;i!1,e.parent._insertChild(e.offset,n);let r=new R(e,e.getShiftedBy(1));this.wrap(r,t);let i=new L(n.parent,n.index);n._remove();let a=i.nodeBefore,o=i.nodeAfter;return a&&a.is(`view:$text`)&&o&&o.is(`view:$text`)?Us(a,o):Vs(i)}_breakAttributesRange(e,t=!1){let n=e.start,r=e.end;if(Ks(e,this.document),e.isCollapsed){let n=this._breakAttributes(e.start,t);return new R(n,n)}let i=this._breakAttributes(r,t),a=i.parent.childCount,o=this._breakAttributes(n,t);return i.offset+=i.parent.childCount-a,new R(o,i)}_breakAttributes(e,t=!1){let n=e.offset,r=e.parent;if(e.parent.is(`emptyElement`))throw new w(`view-writer-cannot-break-empty-element`,this.document);if(e.parent.is(`uiElement`))throw new w(`view-writer-cannot-break-ui-element`,this.document);if(e.parent.is(`rawElement`))throw new w(`view-writer-cannot-break-raw-element`,this.document);if(!t&&r.is(`$text`)&&Gs(r.parent)||Gs(r))return e.clone();if(r.is(`$text`))return this._breakAttributes(Hs(e),t);if(n==r.childCount){let e=new L(r.parent,r.index+1);return this._breakAttributes(e,t)}else if(n===0){let e=new L(r.parent,r.index);return this._breakAttributes(e,t)}else{let e=r.index+1,i=r._clone();r.parent._insertChild(e,i),this._addToClonedElementsGroup(i);let a=r.childCount-n,o=r._removeChildren(n,a);i._appendChild(o);let s=new L(r.parent,e);return this._breakAttributes(s,t)}}_addToClonedElementsGroup(e){if(!e.root.is(`rootElement`))return;if(e.is(`element`))for(let t of e.getChildren())this._addToClonedElementsGroup(t);let t=e.id;if(!t)return;let n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is(`element`))for(let t of e.getChildren())this._removeFromClonedElementsGroup(t);let t=e.id;if(!t)return;let n=this._cloneGroups.get(t);n&&n.delete(e)}};function zs(e){return Array.from(e.getChildren()).some(e=>!e.is(`uiElement`))}function Bs(e){let t=e.parent;for(;!Gs(t);){if(!t)return;t=t.parent}return t}function Nee(e,t){return e.priorityt.priority?!1:e.getIdentity()n instanceof e))throw new w(`view-writer-insert-invalid-node-type`,t);n.is(`$text`)||Ws(n.getChildren(),t)}}function Gs(e){return e&&(e.is(`containerElement`)||e.is(`documentFragment`))}function Ks(e,t){let n=Bs(e.start),r=Bs(e.end);if(!n||!r||n!==r)throw new w(`view-writer-invalid-range-container`,t)}function Fee(e){return xn(e)}const qs=e=>e.createTextNode(`\xA0`),Js=e=>{let t=e.createElement(`span`);return t.dataset.ckeFiller=`true`,t.innerText=`\xA0`,t},Ys=e=>{let t=e.createElement(`br`);return t.dataset.ckeFiller=`true`,t},Iee=7,Xs=``.repeat(7);function Zs(e){return typeof e==`string`?e.substr(0,7)===Xs:jr(e)&&e.data.substr(0,7)===Xs}function Qs(e){return e.data.length==7&&Zs(e)}function $s(e){let t=typeof e==`string`?e:e.data;return Zs(e)?t.slice(7):t}function ec(e){e.document.on(`arrowKey`,tc,{priority:`low`})}function tc(e,t){if(t.keyCode==k.arrowleft){let e=t.domTarget.ownerDocument.defaultView.getSelection();if(e.rangeCount==1&&e.getRangeAt(0).collapsed){let t=e.getRangeAt(0).startContainer,n=e.getRangeAt(0).startOffset;Zs(t)&&n<=7&&e.collapse(t,0)}}}const nc=D();var rc=class extends nc{domDocuments=new Set;domConverter;markedAttributes=new Set;markedChildren=new Set;markedTexts=new Set;selection;_inlineFiller=null;_fakeSelectionContainer=null;constructor(e,t){super(),this.domConverter=e,this.selection=t,this.set(`isFocused`,!1),this.set(`isSelecting`,!1),this.set(`isComposing`,!1),p.isBlink&&!p.isAndroid&&this.on(`change:isSelecting`,()=>{this.isSelecting||this.render()})}markToSync(e,t){if(e===`text`)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if(e===`attributes`)this.markedAttributes.add(t);else if(e===`children`)this.markedChildren.add(t);else throw new w(`view-renderer-unknown-type`,this)}}render(){if(this.isComposing&&!p.isAndroid)return;let e=null,t=p.isBlink&&!p.isAndroid?!this.isSelecting:!0;for(let e of this.markedChildren)this._updateChildrenMappings(e);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=L._createBefore(e.parent)));for(let e of this.markedAttributes)this._updateAttrs(e);for(let t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(let t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){let t=this.domConverter.viewPositionToDom(e),n=t.parent.ownerDocument;Zs(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=ac(n,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){let t=this.domConverter.mapViewToDom(e);if(!t)return;let n=Array.from(t.childNodes),r=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),i=this._diffNodeLists(n,r),a=this._findUpdateActions(i,n,r,oc);if(a.indexOf(`update`)!==-1){let t={equal:0,insert:0,delete:0};for(let i of a)if(i===`update`){let i=t.equal+t.insert,a=t.equal+t.delete,o=e.getChild(i);o&&!o.is(`uiElement`)&&!o.is(`rawElement`)&&this._updateElementMappings(o,n[a]),ei(r[i]),t.equal++}else t[i]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){let e=this.selection.getFirstPosition();return e.parent.is(`$text`)?L._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;let e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&jr(t.parent)&&Zs(t.parent))}_removeInlineFiller(){let e=this._inlineFiller;if(!Zs(e))throw new w(`view-renderer-filler-was-lost`,this);Qs(e)?e.remove():e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;let e=this.selection.getFirstPosition(),t=e.parent,n=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is(`element`)||!ic(t))return!1;let r=e.nodeBefore,i=e.nodeAfter;return!(r instanceof Oo||i instanceof Oo||n===t.getFillerOffset()&&(!r||!r.is(`element`,`br`))||p.isAndroid&&(r||i))}_updateText(e,t){let n=this.domConverter.findCorrespondingDomText(e),r=this.domConverter.viewToDom(e).data,i=t.inlineFillerPosition;i&&i.parent==e.parent&&i.offset==e.index&&(r=Xs+r),this._updateTextNode(n,r)}_updateAttrs(e){let t=this.domConverter.mapViewToDom(e);if(t){for(let n of Array.from(t.attributes)){let r=n.name;e.hasAttribute(r)||this.domConverter.removeDomElementAttribute(t,r)}for(let n of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e)}}_updateChildren(e,t){let n=this.domConverter.mapViewToDom(e);if(!n)return;if(p.isAndroid){let e=null;for(let t of Array.from(n.childNodes)){if(e&&jr(e)&&jr(t)){n.normalize();break}e=t}}let r=t.inlineFillerPosition,i=n.childNodes,a=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));r&&r.parent===e&&ac(n.ownerDocument,a,r.offset);let o=this._diffNodeLists(i,a),s=this._findUpdateActions(o,i,a,sc),c=0,l=new Set;for(let e of s)e===`delete`?(l.add(i[c]),ei(i[c])):(e===`equal`||e===`update`)&&c++;c=0;for(let e of s)e===`insert`?(Kr(n,c,a[c]),c++):e===`update`?(this._updateTextNode(i[c],a[c].data),c++):e===`equal`&&(this._markDescendantTextToSync(this.domConverter.domToView(a[c])),c++);for(let e of l)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=uc(e,this._fakeSelectionContainer),oe(e,t,cc.bind(null,this.domConverter))}_findUpdateActions(e,t,n,r){if(e.indexOf(`insert`)===-1||e.indexOf(`delete`)===-1)return e;let i=[],a=[],o=[],s={equal:0,insert:0,delete:0};for(let c of e)c===`insert`?o.push(n[s.equal+s.insert]):c===`delete`?a.push(t[s.equal+s.delete]):(i=i.concat(oe(a,o,r).map(e=>e===`equal`?`update`:e)),i.push(`equal`),a=[],o=[]),s[c]++;return i.concat(oe(a,o,r).map(e=>e===`equal`?`update`:e))}_updateTextNode(e,t){let n=e.data;n!=t&&(p.isAndroid&&this.isComposing&&n.replace(/\u00A0/g,` `)==t.replace(/\u00A0/g,` `)||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){let n=ne(e.data,t);for(let t of n)t.type===`insert`?e.insertData(t.index,t.values.join(``)):e.deleteData(t.index,t.howMany)}_markDescendantTextToSync(e){if(e){if(e.is(`$text`))this.markedTexts.add(e);else if(e.is(`element`))for(let t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(p.isBlink&&!p.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}let e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&p.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){let t=e.ownerDocument;this._fakeSelectionContainer||=dc(t);let n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!n.parentElement||n.parentElement!=e)&&e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||`\xA0`;let r=t.getSelection(),i=t.createRange();r.removeAllRanges(),i.selectNodeContents(n),r.addRange(i)}_updateDomSelection(e){let t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;let n=this.domConverter.viewPositionToDom(this.selection.anchor),r=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(n.parent,n.offset,r.parent,r.offset),p.isGecko&&lc(r,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;let t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){let t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||n.anchorNode!==t&&!t.contains(n.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(let e of this.domDocuments){let t=e.getSelection();if(t.rangeCount){let n=e.activeElement,r=this.domConverter.mapDomToView(n);n&&r&&t.removeAllRanges()}}}_removeFakeSelection(){let e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){let e=this.selection.editableElement;e&&this.domConverter.focus(e)}}};function ic(e){if(e.getAttribute(`contenteditable`)==`false`)return!1;let t=e.findAncestor(e=>e.hasAttribute(`contenteditable`));return!t||t.getAttribute(`contenteditable`)==`true`}function ac(e,t,n){let r=t instanceof Array?t:t.childNodes,i=r[n];if(jr(i))return i.data=Xs+i.data,i;{let i=e.createTextNode(Xs);return Array.isArray(t)?r.splice(n,0,i):Kr(t,n,i),i}}function oc(e,t){return vr(e)&&vr(t)&&!jr(e)&&!jr(t)&&!qr(e)&&!qr(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function sc(e,t){return vr(e)&&vr(t)&&jr(e)&&jr(t)}function cc(e,t,n){return t===n?!0:jr(t)&&jr(n)?t.data===n.data:!!(e.isBlockFiller(t)&&e.isBlockFiller(n))}function lc(e,t){let n=e.parent,r=e.offset;if(jr(n)&&Qs(n)&&(r=Gr(n)+1,n=n.parentNode),n.nodeType!=Node.ELEMENT_NODE||r!=n.childNodes.length-1)return;let i=n.childNodes[r];i&&i.tagName==`BR`&&t.addRange(t.getRangeAt(0))}function uc(e,t){let n=Array.from(e);return n.length==0||!t||n[n.length-1]==t&&n.pop(),n}function dc(e){let 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}const fc=Ys(u.document),pc=qs(u.document),mc=Js(u.document),hc=`data-ck-unsafe-attribute-`,gc=`data-ck-unsafe-element`;var _c=class{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new Po;_inlineObjectElementMatcher=new Po;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:n=`editing`}={}){this.document=e,this.renderingMode=n,this.blockFillerMode=t||(n===`editing`?`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`.split(`.`),this.inlineObjectElements=[`object`,`iframe`,`input`,`button`,`textarea`,`select`,`option`,`video`,`embed`,`audio`,`img`,`canvas`],this.unsafeElements=[`script`,`style`],this._domDocument=this.renderingMode===`editing`?u.document:u.document.implementation.createHTMLDocument(``)}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new os(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){let t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(let t of e.children)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,n){return this.renderingMode===`data`?!0:(e=e.toLowerCase(),e.startsWith(`on`)||e===`srcdoc`?!1:n===`img`&&(e===`src`||e===`srcset`)||n===`source`&&e===`srcset`?!0:!t.replace(/\s+/g,``).match(/^(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if(this.renderingMode===`data`){e.innerHTML=t;return}let n=new DOMParser().parseFromString(t,`text/html`),r=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)r.appendChild(i[0]);let a=n.createTreeWalker(r,NodeFilter.SHOW_ELEMENT),o=[],s;for(;s=a.nextNode();)o.push(s);for(let e of o){for(let t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));let t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(Ec(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(r)}viewToDom(e,t={}){if(e.is(`$text`)){let t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}else{let n=e;if(this.mapViewToDom(n))if(n.getCustomProperty(`editingPipeline:doNotReuseOnce`))this._elementsWithTemporaryCustomProperties.add(n);else return this.mapViewToDom(n);let r;if(n.is(`documentFragment`))r=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(r,n);else if(n.is(`uiElement`))return r=n.name===`$comment`?this._domDocument.createComment(n.getCustomProperty(`$rawContent`)):n.render(this._domDocument,this),t.bind&&this.bindElements(r,n),r;else{this._shouldRenameElement(n.name)?(Ec(n.name),r=this._createReplacementDomElement(n.name)):r=n.hasAttribute(`xmlns`)?this._domDocument.createElementNS(n.getAttribute(`xmlns`),n.name):this._domDocument.createElement(n.name),n.is(`rawElement`)&&n.render(r,this),t.bind&&this.bindElements(r,n);for(let e of n.getAttributeKeys())this.setDomElementAttribute(r,e,n.getAttribute(e),n)}if(t.withChildren!==!1)for(let e of this.viewChildrenToDom(n,t))r instanceof HTMLTemplateElement?r.content.appendChild(e):r.appendChild(e);return r}}setDomElementAttribute(e,t,n,r){let i=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||r&&r.shouldRenderUnsafeAttribute(t);if(i||T(`domconverter-unsafe-attribute-detected`,{domElement:e,key:t,value:n}),!Jr(t)){T(`domconverter-invalid-attribute-detected`,{domElement:e,key:t,value:n});return}e.hasAttribute(t)&&!i?e.removeAttribute(t):e.hasAttribute(hc+t)&&i&&e.removeAttribute(hc+t),e.setAttribute(i?t:hc+t,n)}removeDomElementAttribute(e,t){t!=gc&&(e.removeAttribute(t),e.removeAttribute(hc+t))}*viewChildrenToDom(e,t={}){let n=e.getFillerOffset&&e.getFillerOffset(),r=0;for(let i of e.getChildren()){n===r&&(yield this._getBlockFiller());let e=i.is(`element`)&&!!i.getCustomProperty(`dataPipeline:transparentRendering`)&&!j(i.getAttributes());if(e&&this.renderingMode==`data`)if(i.is(`rawElement`)){let e=this._domDocument.createElement(i.name);i.render(e,this),yield*[...e.childNodes]}else yield*this.viewChildrenToDom(i,t);else e&&T(`domconverter-transparent-rendering-unsupported-in-editing-pipeline`,{viewElement:i}),yield this.viewToDom(i,t);r++}n===r&&(yield this._getBlockFiller())}viewRangeToDom(e){let t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),r=this._domDocument.createRange();return r.setStart(t.parent,t.offset),r.setEnd(n.parent,n.offset),r}viewPositionToDom(e){let t=e.parent;if(t.is(`$text`)){let n=this.findCorrespondingDomText(t);if(!n)return null;let r=e.offset;return Zs(n)&&(r+=7),n.data&&r>n.data.length&&(r=n.data.length),{parent:n,offset:r}}else{let n,r,i;if(e.offset===0){if(n=this.mapViewToDom(t),!n)return null;i=n.childNodes[0]}else{let t=e.nodeBefore;if(r=t.is(`$text`)?this.findCorrespondingDomText(t):this.mapViewToDom(t),!r)return null;n=r.parentNode,i=r.nextSibling}if(jr(i)&&Zs(i))return{parent:i,offset:7};let a=r?Gr(r)+1:0;return{parent:n,offset:a}}}domToView(e,t={}){let n=[],r=this._domToView(e,t,n),i=r.next().value;return!i||(r.next(),this._processDomInlineNodes(null,n,t),this.blockFillerMode==`br`&&wc(i))||i.is(`$text`)&&i.data.length==0?null:i}*domChildrenToView(e,t={},n=[]){let r=[];r=e instanceof HTMLTemplateElement?[...e.content.childNodes]:[...e.childNodes];for(let i=0;i{let{scrollLeft:t,scrollTop:n}=e;i.push([t,n])}),t.focus({preventScroll:!0}),yc(t,e=>{let[t,n]=i.shift();e.scrollLeft=t,e.scrollTop=n}),u.window.scrollTo(n,r)}_clearDomSelection(){let e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;let t=e.ownerDocument.defaultView.getSelection(),n=this.domSelectionToView(t);n&&n.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 this.blockFillerMode==`br`?e.isEqualNode(fc):Tc(e,this.blockElements)?!0:e.isEqualNode(mc)||bc(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;let t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch{return!1}let n=t.collapsed;return t.detach(),n}getHostViewElement(e){let t=Tr(e);for(t.pop();t.length;){let e=t.pop(),n=this._domToViewMapping.get(e);if(n&&(n.is(`uiElement`)||n.is(`rawElement`)))return n}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(let e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty(`editingPipeline:doNotReuseOnce`);this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case`nbsp`:return qs(this._domDocument);case`markedNbsp`:return Js(this._domDocument);case`br`:return Ys(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(jr(e)&&Zs(e)&&t<7||this.isElement(e)&&Zs(e.childNodes[t]))return!1;let n=this.mapDomToView(e);return!(n&&(n.is(`uiElement`)||n.is(`rawElement`)))}*_domToView(e,t,n){if(this.blockFillerMode!=`br`&&Tc(e,this.blockElements))return null;let r=this.getHostViewElement(e);if(r)return r;if(qr(e)&&t.skipComments)return null;if(jr(e)){if(Qs(e))return null;{let t=e.data;if(t===``)return null;let r=new Oo(this.document,t);return n.push(r),r}}else{let r=this.mapDomToView(e);if(r)return this._isInlineObjectElement(r)&&n.push(r),r;if(this.isDocumentFragment(e))r=new Is(this.document),t.bind&&this.bindDocumentFragments(e,r);else{r=this._createViewElement(e,t),t.bind&&this.bindElements(e,r);let i=e.attributes;if(i)for(let e=i.length,t=0;t0?t[e-1]:null,c=e+1e.is(`element`)&&t.includes(e.name))}function yc(e,t){let n=e;for(;n;)t(n),n=n.parentElement}function bc(e,t){return e.isEqualNode(pc)&&xc(e,t)&&e.parentNode.childNodes.length===1}function xc(e,t){let n=e.parentNode;return!!n&&!!n.tagName&&t.includes(n.tagName.toLowerCase())}function Sc(e,t,n){return t==`\xA0`&&e&&e.is(`element`)&&e.childCount==1&&n.includes(e.name)}function Cc(e,t){return t==`\xA0`&&e&&e.is(`element`,`span`)&&e.childCount==1&&e.hasAttribute(`data-cke-filler`)}function wc(e){return e.is(`element`,`br`)&&e.hasAttribute(`data-cke-filler`)}function Tc(e,t){return e.tagName===`BR`&&xc(e,t)&&e.parentNode.childNodes.length===1}function Ec(e){e===`script`&&T(`domconverter-unsafe-script-element-detected`),e===`style`&&T(`domconverter-unsafe-style-element-detected`)}function Dc(e){if(!p.isGecko||!e.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;try{Object.prototype.toString.call(t)}catch{return!0}return!1}const Oc=br();var kc=class extends Oc{view;document;_isEnabled=!1;constructor(e){super(),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()}checkShouldIgnoreEventFromTarget(e){return e&&e.nodeType===3&&(e=e.parentNode),!e||e.nodeType!==1?!1:e.matches(`[data-cke-ignore-events], [data-cke-ignore-events] *`)}},Ac=class{view;document;domEvent;domTarget;constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,fn(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}},jc=class extends kc{useCapture=!1;usePassive=!1;observe(e){(typeof this.domEventType==`string`?[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,n){this.isEnabled&&this.document.fire(e,new Ac(this.view,t,n))}},Mc=class extends jc{domEventType=[`keydown`,`keyup`];onDomEvent(e){let t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return vi(this)}};this.fire(e.type,e,t)}},Nc=class extends kc{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Kt(e=>{this.document.fire(`selectionChangeDone`,e)},200)}observe(){let e=this.document;e.on(`arrowKey`,(t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()},{context:`$capture`}),e.on(`arrowKey`,(t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)},{priority:`lowest`})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){let t=this.document.selection,n=new os(t.getRanges(),{backward:t.isBackward,fake:!1});(e==k.arrowleft||e==k.arrowup)&&n.setTo(n.getFirstPosition()),(e==k.arrowright||e==k.arrowdown)&&n.setTo(n.getLastPosition());let r={oldSelection:t,newSelection:n,domSelection:null};this.document.fire(`selectionChange`,r),this._fireSelectionChangeDoneDebounced(r)}},Pc=class extends kc{domConverter;_config;_domElements;_mutationObserver;constructor(e){super(e),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(let e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(let 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(e.length===0)return;let t=this.domConverter,n=new Set,r=new Set;for(let n of e){let e=t.mapDomToView(n.target);e&&(e.is(`uiElement`)||e.is(`rawElement`)||n.type===`childList`&&!this._isBogusBrMutation(n)&&r.add(e))}for(let i of e){let e=t.mapDomToView(i.target);if(!(e&&(e.is(`uiElement`)||e.is(`rawElement`)))&&i.type===`characterData`){let e=t.findCorrespondingViewText(i.target);e&&!r.has(e.parent)?n.add(e):!e&&Zs(i.target)&&r.add(t.mapDomToView(i.target.parentNode))}}let i=[];for(let e of n)i.push({type:`text`,node:e});for(let e of r){let n=t.mapViewToDom(e);Pn(Array.from(e.getChildren()),Array.from(t.domChildrenToView(n,{withChildren:!1})),Fc)||i.push({type:`children`,node:e})}i.length&&this.document.fire(`mutations`,{mutations:i})}_isBogusBrMutation(e){let t=null;return e.nextSibling===null&&e.removedNodes.length===0&&e.addedNodes.length==1&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is(`element`,`br`)}};function Fc(e,t){if(!Array.isArray(e))return e===t?!0:e.is(`$text`)&&t.is(`$text`)?e.data===t.data:!1}var Ic=class extends jc{_renderTimeoutId=null;_isFocusChanging=!1;domEventType=[`focus`,`blur`];constructor(e){super(e),this.useCapture=!0;let 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){let t=this.document.selection.editableElement;(t===null||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&=(clearTimeout(this._renderTimeoutId),null)}},Lc=class extends kc{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(Pc),this.focusObserver=e.getObserver(Ic),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=Kt(e=>{this.document.fire(`selectionChangeDone`,e)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Kt(()=>this.document.isSelecting=!1,5e3),this.view.document.on(`change:isFocused`,(e,t,n)=>{if(n&&this._pendingSelectionChange.size){for(let e of Array.from(this._pendingSelectionChange))this._handleSelectionChange(e);this._pendingSelectionChange.clear()}})}observe(e){let t=e.ownerDocument,n=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},r=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,`selectstart`,n,{priority:`highest`}),this.listenTo(e,`keydown`,r,{priority:`highest`,useCapture:!0}),this.listenTo(e,`keyup`,r,{priority:`highest`,useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,`mouseup`,r,{priority:`highest`,useCapture:!0}),this.listenTo(t,`selectionchange`,()=>{this.document.isComposing&&!p.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;let t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();let n=this.domConverter.domSelectionToView(t);if(n.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(!Rc(n))this.view.forceRender();else if(this.selection.isSimilar(n))this.view.forceRender();else{let e={oldSelection:this.selection,newSelection:n,domSelection:t};this.document.fire(`selectionChange`,e),this._fireSelectionChangeDoneDebounced(e)}}}_clearInfiniteLoop(){this._loopbackCounter=0}};function Rc(e){return Array.from(e.getRanges()).flatMap(e=>[e.start.root,e.end.root]).every(e=>e&&e.is(`rootElement`))}var zc=class extends jc{domEventType=[`compositionstart`,`compositionupdate`,`compositionend`];constructor(e){super(e);let t=this.document;t.on(`compositionstart`,()=>{t.isComposing=!0}),t.on(`compositionend`,()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}},Bc=class{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?Vc(e):null,this._native=e}get files(){return this._files||=Vc(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,n){this._native.setDragImage(e,t,n)}get isCanceled(){return this._native.dropEffect==`none`||!!this._native.mozUserCancelled}};function Vc(e){let t=Array.from(e.files||[]),n=Array.from(e.items||[]);return t.length?t:n.filter(e=>e.kind===`file`).map(e=>e.getAsFile())}var Hc=class extends jc{domEventType=`beforeinput`;onDomEvent(e){let t=e.getTargetRanges(),n=this.view,r=n.document,i=null,a=null,o=[];if(e.dataTransfer&&(i=new Bc(e.dataTransfer)),e.data===null?i&&(a=i.getData(`text/plain`)):a=e.data,r.selection.isFake)o=Array.from(r.selection.getRanges()),e.preventDefault();else if(t.length)o=t.map(t=>{let r=n.domConverter.domPositionToView(t.startContainer,t.startOffset),i=n.domConverter.domPositionToView(t.endContainer,t.endOffset);if(r&&Zs(t.startContainer)&&t.startOffset<7){e.preventDefault();let n=7-t.startOffset;r=r.getLastMatchingPosition(e=>!!(e.item.is(`attributeElement`)||e.item.is(`uiElement`)||e.item.is(`$textProxy`)&&n--),{direction:`backward`,singleCharacters:!0})}if(Uc(t.endContainer,t.endOffset)&&e.preventDefault(),r)return n.createRange(r,i);if(i)return n.createRange(i)}).filter(e=>!!e);else if(p.isAndroid){let t=e.target.ownerDocument.defaultView.getSelection();o=Array.from(n.domConverter.domSelectionToView(t).getRanges())}if(p.isAndroid&&e.inputType==`insertCompositionText`&&a&&a.endsWith(`
`)){this.fire(e.type,e,{inputType:`insertParagraph`,targetRanges:[n.createRange(o[0].end)]});return}if([`insertText`,`insertReplacementText`].includes(e.inputType)&&a&&a.includes(`
`)){let t=a.split(/\n{1,2}/g),n=o;e.preventDefault();for(let a=0;a{if(this.isEnabled&&xi(t.keyCode)){let n=new ls(this.document,`arrowKey`,this.document.selection.getFirstRange());this.document.fire(n,t),n.stop.called&&e.stop()}})}observe(){}stopObserving(){}},Gc=class extends kc{constructor(e){super(e);let t=this.document;t.on(`keydown`,(e,n)=>{if(!this.isEnabled||n.keyCode!=k.tab||n.ctrlKey)return;let r=new ls(t,`tab`,t.selection.getFirstRange());t.fire(r,n),r.stop.called&&e.stop()})}observe(){}stopObserving(){}};const Kc=D();var qc=class extends Kc{document;domConverter;domRoots=new Map;_renderer;_initialDomRootAttributes=new WeakMap;_observers=new Map;_writer;_ongoingChange=!1;_postFixersInProgress=!1;_renderingDisabled=!1;_hasChangedSinceTheLastRendering=!1;constructor(e){super(),this.document=new Cs(e),this.domConverter=new _c(this.document),this.set(`isRenderingInProgress`,!1),this.set(`hasDomSelection`,!1),this._renderer=new rc(this.domConverter,this.document.selection),this._renderer.bind(`isFocused`,`isSelecting`,`isComposing`).to(this.document,`isFocused`,`isSelecting`,`isComposing`),this._writer=new Rs(this.document),this.addObserver(Pc),this.addObserver(Ic),this.addObserver(Lc),this.addObserver(Mc),this.addObserver(Nc),this.addObserver(zc),this.addObserver(Wc),this.addObserver(Hc),this.addObserver(Gc),ec(this),As(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}),p.isiOS&&this.listenTo(this.document,`blur`,(e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,`mutations`,(e,{mutations:t})=>{t.forEach(e=>this._renderer.markToSync(e.type,e.node))},{priority:`low`}),this.listenTo(this.document,`mutations`,()=>{this.forceRender()},{priority:`lowest`})}attachDomRoot(e,t=`main`){let n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();let r={};for(let{name:t,value:i}of Array.from(e.attributes))r[t]=i,t===`class`?this._writer.addClass(i.split(` `),n):n.hasAttribute(t)||this._writer.setAttribute(t,i,n);this._initialDomRootAttributes.set(e,r);let i=()=>{this._writer.setAttribute(`contenteditable`,(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass(`ck-read-only`,n):this._writer.removeClass(`ck-read-only`,n)};i(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync(`children`,n),this._renderer.markToSync(`attributes`,n),this._renderer.domDocuments.add(e.ownerDocument),n.on(`change:children`,(e,t)=>this._renderer.markToSync(`children`,t)),n.on(`change:attributes`,(e,t)=>this._renderer.markToSync(`attributes`,t)),n.on(`change:text`,(e,t)=>this._renderer.markToSync(`text`,t)),n.on(`change:isReadOnly`,()=>this.change(i)),n.on(`change`,()=>{this._hasChangedSinceTheLastRendering=!0});for(let n of this._observers.values())n.observe(e,t)}detachDomRoot(e){let t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:e})=>t.removeAttribute(e));let n=this._initialDomRootAttributes.get(t);for(let e in n)t.setAttribute(e,n[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(let e of this._observers.values())e.stopObserving(t)}getDomRoot(e=`main`){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(let[e,n]of this.domRoots)t.observe(n,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(let e of this._observers.values())e.disable()}enableObservers(){for(let e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:n=20,ancestorOffset:r=20}={}){let i=this.document.selection.getFirstRange();if(!i)return;let a=Rt({alignToTop:e,forceScroll:t,viewportOffset:n,ancestorOffset:r});typeof n==`number`&&(n={top:n,bottom:n,left:n,right:n});let o={target:this.domConverter.viewRangeToDom(i),viewportOffset:n,ancestorOffset:r,alignToTop:e,forceScroll:t};this.fire(`scrollToTheSelection`,o,a),ni(o)}focus(){if(!this.document.isFocused){let e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new w(`cannot-change-view-tree`,this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;let t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire(`render`)),t}catch(e){w.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Ic).flush(),this.change(()=>{})}destroy(){for(let e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}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 R(e,t)}createRangeOn(e){return R._createOn(e)}createRangeIn(e){return R._createIn(e)}createSelection(...e){return new os(...e)}_disableRendering(e){this._renderingDisabled=e,e==0&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}},Jc=class{is(){throw Error(`is() method is abstract`)}},Yc=class extends Jc{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new w(`model-textproxy-wrong-offsetintext`,this);if(n<0||t+n>e.offsetSize)throw new w(`model-textproxy-wrong-length`,this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get startOffset(){return this.textNode.startOffset===null?null:this.textNode.startOffset+this.offsetInText}get offsetSize(){return this.data.length}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){let e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){let t=[],n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?`push`:`unshift`](n),n=n.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()}};Yc.prototype.is=function(e){return e===`$textProxy`||e===`model:$textProxy`||e===`textProxy`||e===`model:textProxy`};var Xc=class{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new w(`model-tree-walker-no-start-position`,null);let t=e.direction||`forward`;if(t!=`forward`&&t!=`backward`)throw new w(`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=z._createAt(this.boundaries[this.direction==`backward`?`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,n,r,i;do r=this.position,i=this._visitedParent,{done:t,value:n}=this.next();while(!t&&e(n));t||(this._position=r,this._visitedParent=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(),this._visitedParent=e.parent}next(){return this.direction==`forward`?this._next():this._previous()}_next(){let e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===n.maxOffset||n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let r=Qc(t,n),i=r||$c(t,n,r);if(i&&i.is(`model:element`)){if(!this.shallow)t.path.push(0),this._visitedParent=i;else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,Zc(`elementStart`,i,e,t,1)}if(i&&i.is(`model:$text`)){let r;if(this.singleCharacters)r=1;else{let e=i.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),r=t.offset-e}let i=new Yc(a,t.offset-a.startOffset-r,r);return t.offset-=r,this._position=t,Zc(`text`,i,e,t,r)}return t.path.pop(),this._position=t,this._visitedParent=n.parent,Zc(`elementStart`,n,e,t,1)}};function Zc(e,t,n,r,i){return{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:r,length:i}}}var z=class e extends Jc{root;path;stickiness;constructor(e,t,n=`toNone`){if(super(),!e.is(`element`)&&!e.is(`documentFragment`))throw new w(`model-position-root-invalid`,e);if(!Array.isArray(t)||t.length===0)throw new w(`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=n}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;t1)return!1;if(t===1)return tl(e,this,n);if(t===-1)return tl(this,e,n)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?nl(this.path,t):nl(e.path,t)}hasSameParentAs(e){return this.root===e.root?fr(this.getParentPath(),e.getParentPath())==`same`:!1}getTransformedByOperation(t){let n;switch(t.type){case`insert`:n=this._getTransformedByInsertOperation(t);break;case`move`:case`remove`:case`reinsert`:n=this._getTransformedByMoveOperation(t);break;case`split`:n=this._getTransformedBySplitOperation(t);break;case`merge`:n=this._getTransformedByMergeOperation(t);break;default:n=e._createAt(this);break}return n}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){let t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&this.stickiness==`toNext`?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(t){let n=t.movedRange,r=n.containsPosition(this)||n.start.isEqual(this),i;return r?(i=this._getCombined(t.sourcePosition,t.targetPosition),t.sourcePosition.isBefore(t.targetPosition)&&(i=i._getTransformedByDeletion(t.deletionPosition,1))):i=this.isEqual(t.deletionPosition)?e._createAt(t.deletionPosition):this._getTransformedByMove(t.deletionPosition,t.graveyardPosition,1),i}_getTransformedByDeletion(t,n){let r=e._createAt(this);if(this.root!=t.root)return r;if(fr(t.getParentPath(),this.getParentPath())==`same`){if(t.offsetthis.offset)return null;r.offset-=n}}else if(fr(t.getParentPath(),this.getParentPath())==`prefix`){let e=t.path.length-1;if(t.offset<=this.path[e]){if(t.offset+n>this.path[e])return null;r.path[e]-=n}}return r}_getTransformedByInsertion(t,n){let r=e._createAt(this);if(this.root!=t.root)return r;if(fr(t.getParentPath(),this.getParentPath())==`same`)(t.offset=t;){if(e.path[r]+i!==n.maxOffset)return!1;i=1,r--,n=n.parent}return!0}var B=class e extends Jc{start;end;constructor(e,t){super(),this.start=z._createAt(e),this.end=t?z._createAt(t):z._createAt(e),this.start.stickiness=this.isCollapsed?`toNone`:`toNext`,this.end.stickiness=this.isCollapsed?`toNone`:`toPrevious`}*[Symbol.iterator](){yield*new Xc({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return fr(this.start.getParentPath(),this.end.getParentPath())==`same`}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);let n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&r}containsItem(e){let t=z._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(t){let n=[];return this.isIntersecting(t)?(this.containsPosition(t.start)&&n.push(new e(this.start,t.start)),this.containsPosition(t.end)&&n.push(new e(t.end,this.end))):n.push(new e(this.start,this.end)),n}getIntersection(t){if(this.isIntersecting(t)){let n=this.start,r=this.end;return this.containsPosition(t.start)&&(n=t.start),this.containsPosition(t.end)&&(r=t.end),new e(n,r)}return null}getJoined(t,n=!1){let r=this.isIntersecting(t);if(r||=this.start.isBefore(t.start)?n?this.end.isTouching(t.start):this.end.isEqual(t.start):n?t.end.isTouching(this.start):t.end.isEqual(this.start),!r)return null;let i=this.start,a=this.end;return t.start.isBefore(i)&&(i=t.start),t.end.isAfter(a)&&(a=t.end),new e(i,a)}getMinimalFlatRanges(){let t=[],n=this.start.getCommonPath(this.end).length,r=z._createAt(this.start),i=r.parent;for(;r.path.length>n+1;){let n=i.maxOffset-r.offset;n!==0&&t.push(new e(r,r.getShiftedBy(n))),r.path=r.path.slice(0,-1),r.offset++,i=i.parent}for(;r.path.length<=this.end.path.length;){let n=this.end.path[r.path.length-1],i=n-r.offset;i!==0&&t.push(new e(r,r.getShiftedBy(i))),r.offset=n,r.path.push(0)}return t}getWalker(e={}){return e.boundaries=this,new Xc(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;let t=new Xc(e);for(let e of t)yield e.item}*getPositions(e={}){e.boundaries=this;let t=new Xc(e);yield t.position;for(let e of t)yield e.nextPosition}getTransformedByOperation(t){switch(t.type){case`insert`:return this._getTransformedByInsertOperation(t);case`move`:case`remove`:case`reinsert`:return this._getTransformedByMoveOperation(t);case`split`:return[this._getTransformedBySplitOperation(t)];case`merge`:return[this._getTransformedByMergeOperation(t)]}return[new e(this.start,this.end)]}getTransformedByOperations(t){let n=[new e(this.start,this.end)];for(let e of t)for(let t=0;t0?new this(n,r):new this(r,n)}static _createIn(e){return new this(z._createAt(e,0),z._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(z._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new w(`range-create-from-ranges-empty-array`,null);if(e.length==1)return e[0].clone();let t=e[0];e.sort((e,t)=>e.start.isAfter(t.start)?1:-1);let n=e.indexOf(t),r=new this(t.start,t.end);for(let t=n-1;t>=0&&e[t].end.isEqual(r.start);t--)r.start=z._createAt(e[t].start);for(let t=n+1;t{if(t.viewPosition)return;let n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new w(`mapping-model-position-view-parent-not-found`,this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)},{priority:`low`}),this.on(`viewToModelPosition`,(e,t)=>{if(t.modelPosition)return;let n=this.findMappedViewAncestor(t.viewPosition),r=this._viewToModelMapping.get(n),i=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=z._createAt(r,i)},{priority:`low`})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){let n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(let t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){let t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){let n=this._markerNameToElements.get(t)||new Set;n.add(e);let r=this._elementToMarkerNames.get(e)||new Set;r.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,r)}unbindElementFromMarkerName(e,t){let n=this._markerNameToElements.get(t);n&&(n.delete(e),n.size==0&&this._markerNameToElements.delete(t));let r=this._elementToMarkerNames.get(e);r&&(r.delete(t),r.size==0&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){let e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(let[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 B(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new R(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){let t={viewPosition:e,mapper:this};return this.fire(`viewToModelPosition`,t),t.modelPosition}toViewPosition(e,t={}){let n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire(`modelToViewPosition`,n),n.viewPosition}markerNameToElements(e){let t=this._markerNameToElements.get(e);if(!t)return null;let n=new Set;for(let e of t)if(e.is(`attributeElement`))for(let t of e.getElementsWithSameId())n.add(t);else n.add(e);return n}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,n){if(n!=e)return this._toModelOffset(e.parent,e.index,n)+this._toModelOffset(e,t,e);if(e.is(`$text`))return t;let r=0;for(let n=0;n0;){let e=t.pop(),r=e.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(e.name);if(r)n+=r(e);else if(this._viewToModelMapping.has(e))n+=1;else if(e.is(`$text`))n+=e.data.length;else if(e.is(`uiElement`))continue;else for(let n of e.getChildren())t.push(n)}return n}findPositionIn(e,t){if(t===0)return this._moveViewPositionToTextNode(new L(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){let n=this._cache.getClosest(e,t);return this._findPositionStartingFrom(n.viewPosition,n.modelOffset,t,e,!0)}else return this._findPositionStartingFrom(new L(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,n,r,i){let a=e.parent,o=e.offset;if(a.is(`$text`))return new L(a,n-t);let s,c=t,l=0;for(;c{this._clearCacheInsideParent(t,n.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,n,r){let i=this._cachedMapping.get(n),a=i.cacheMap.get(r);if(a){let n=e.getChild(t-1),r=a.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(a.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(n,r);return}let o={viewPosition:new L(e,t),modelOffset:r};i.maxModelOffset=r>i.maxModelOffset?r:i.maxModelOffset,i.cacheMap.set(r,o);let s=i.cacheList.length-1;for(;s>=0&&i.cacheList[s].modelOffset>r;)s--;if(i.cacheList.splice(s+1,0,o),t>0){let n=e.getChild(t-1);this._nodeToCacheListIndex.set(n,s+1)}}getClosest(e,t){let n=this._cachedMapping.get(e),r;return r=n?t>n.maxModelOffset?n.cacheList[n.cacheList.length-1]:n.cacheMap.get(t)||this._findInCacheList(n.cacheList,t):this.startTracking(e),{modelOffset:r.modelOffset,viewPosition:r.viewPosition.clone()}}startTracking(e){let t={viewPosition:new L(e,0),modelOffset:0},n={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,n),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(t==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{let n=e.getChild(t-1);this._clearCacheAfter(n)}}_clearCacheAll(e){let 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]))}_clearCacheAfter(e){let t=this._nodeToCacheListIndex.get(e);if(t===void 0){let t=e.parent;this._cachedMapping.has(t)||this._clearCacheInsideParent(t.parent,t.index);return}let n=e.parent;for(;!this._cachedMapping.has(n);)n=n.parent;this._clearCacheFromCacheIndex(n,t)}_clearCacheFromCacheIndex(e,t){t===0&&(t=1);let n=this._cachedMapping.get(e),r=n.cacheList[t-1];if(!r)return;n.maxModelOffset=r.modelOffset;let i=n.cacheList.splice(t);for(let e of i){n.cacheMap.delete(e.modelOffset);let t=e.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(t)}}_findInCacheList(e,t){let n=0,r=e.length-1,i=r-n>>1,a=e[i];for(;n>1),a=e[i];return a.modelOffset<=t?a:e[i-1]}},cl=class{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=ll(t),e instanceof Yc&&(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=ll(t),e instanceof Yc&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=ll(t),e instanceof Yc&&(e=this._getSymbolForTextProxy(e));let n=this._consumable.get(e);if(n===void 0)return null;let r=n.get(t);return r===void 0?null:r}revert(e,t){t=ll(t),e instanceof Yc&&(e=this._getSymbolForTextProxy(e));let n=this.test(e,t);return n===!1?(this._consumable.get(e).set(t,!0),!0):n===!0?!1:null}verifyAllConsumed(e){let t=[];for(let[n,r]of this._consumable)for(let[i,a]of r){let r=i.split(`:`)[0];a&&e==r&&t.push({event:i,item:n.name||n.description})}if(t.length)throw new w(`conversion-model-consumable-not-consumed`,null,{items:t})}_getSymbolForTextProxy(e){let t=null,n=this._textProxyRegistry.get(e.startOffset);if(n){let r=n.get(e.endOffset);r&&(t=r.get(e.parent))}return t||=this._addSymbolForTextProxy(e),t}_addSymbolForTextProxy(e){let t=e.startOffset,n=e.endOffset,r=e.parent,i=Symbol(`$textProxy:`+e.data),a,o;return a=this._textProxyRegistry.get(t),a||(a=new Map,this._textProxyRegistry.set(t,a)),o=a.get(n),o||(o=new Map,a.set(n,o)),o.set(r,i),i}};function ll(e){let t=e.split(`:`);return t[0]==`insert`?t[0]:t[0]==`addMarker`||t[0]==`removeMarker`?e:t.length>1?t[0]+`:`+t[1]:t[0]}function ul([e,t],[n,r]){if(t.end.compareWith(r.start)!==`after`)return 1;if(t.start.compareWith(r.end)!==`before`)return-1;switch(t.start.compareWith(r.start)){case`before`:return 1;case`after`:return-1;default:switch(t.end.compareWith(r.end)){case`before`:return-1;case`after`:return 1;default:return n.localeCompare(e)}}}const dl=E();var fl=class extends dl{_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){let r=e.getRefreshedItems(),i=this._createConversionApi(n,r);for(let t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,i);let a=this._reduceChanges(e.getChanges(),r);for(let e of a)e.type===`insert`?this._convertInsert(B._createFromPositionAndShift(e.position,e.length),i):e.type===`reinsert`?this._convertReinsert(B._createFromPositionAndShift(e.position,e.length),i):e.type===`remove`?this._convertRemove(e.position,e.length,e.name,i):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,i);i.mapper.flushDeferredBindings();for(let e of i.mapper.flushUnboundMarkerNames()){let n=t.get(e).getRange();this._convertMarkerRemove(e,n,i),this._convertMarkerAdd(e,n,i)}let o=e.getMarkersToAdd().sort((e,t)=>ul([e.name,e.range],[t.name,t.range]));for(let e of o)this._convertMarkerAdd(e.name,e.range,i);i.consumable.verifyAllConsumed(`insert`)}convert(e,t,n,r={}){let i=this._createConversionApi(n,void 0,r);this._convertInsert(e,i);for(let[e,n]of Array.from(t).sort(ul))this._convertMarkerAdd(e,n,i);i.consumable.verifyAllConsumed(`insert`)}convertSelection(e,t,n){let r=this._createConversionApi(n);this.fire(`cleanSelection`,{selection:e},r);let i=e.getFirstPosition().root;if(!r.mapper.toViewElement(i))return;let a=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(r.consumable,e,a),this.fire(`selection`,{selection:e},r),e.isCollapsed){for(let t of a)if(r.consumable.test(e,`addMarker:`+t.name)){let n=t.getRange();if(!pl(e.getFirstPosition(),t,r.mapper))continue;let i={item:e,markerName:t.name,markerRange:n};this.fire(`addMarker:${t.name}`,i,r)}for(let t of e.getAttributeKeys())if(r.consumable.test(e,`attribute:`+t)){let n={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,n,r)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(let n of e.getWalker({shallow:!0}))this._testAndFire(`insert`,hl(n),t)}_convertRemove(e,t,n,r){this.fire(`remove:${n}`,{position:e,length:t},r)}_convertAttribute(e,t,n,r,i){this._addConsumablesForRange(i.consumable,e,`attribute:${t}`);for(let a of e){let e={item:a.item,range:B._createFromPositionAndShift(a.previousPosition,a.length),attributeKey:t,attributeOldValue:n,attributeNewValue:r};this._testAndFire(`attribute:${t}`,e,i)}}_convertReinsert(e,t){let n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(let e of n.map(hl))this.fire(`remove:${e.item.is(`element`)?e.item.name:`$text`}`,{position:e.range.start,length:e.item.offsetSize,reconversion:!0},t),this._testAndFire(`insert`,{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if(t.root.rootName==`$graveyard`)return;let r=`addMarker:${e}`;if(n.consumable.add(t,r),this.fire(r,{markerName:e,markerRange:t},n),n.consumable.consume(t,r)){this._addConsumablesForRange(n.consumable,t,r);for(let i of t.getItems()){if(!n.consumable.test(i,r))continue;let a={item:i,range:B._createOn(i),markerName:e,markerRange:t};this.fire(r,a,n)}}}_convertMarkerRemove(e,t,n){t.root.rootName!=`$graveyard`&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e,t){let n={changes:e,refreshedItems:t};return this.fire(`reduceChanges`,n),n.changes}_addConsumablesForInsert(e,t){for(let n of t){let t=n.item;if(e.test(t,`insert`)===null){e.add(t,`insert`);for(let n of t.getAttributeKeys())e.add(t,`attribute:`+n)}}return e}_addConsumablesForRange(e,t,n){for(let r of t.getItems())e.add(r,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,`selection`);for(let r of n)e.add(t,`addMarker:`+r.name);for(let n of t.getAttributeKeys())e.add(t,`attribute:`+n);return e}_testAndFire(e,t,n){let r=ml(e,t),i=t.item.is(`$textProxy`)?n.consumable._getSymbolForTextProxy(t.item):t.item,a=this._firedEventsMap.get(n),o=a.get(i);if(!o)a.set(i,new Set([r]));else if(!o.has(r))o.add(r);else return;this.fire(r,t,n)}_testAndFireAddAttributes(e,t){let n={item:e,range:B._createOn(e)};for(let e of n.item.getAttributeKeys())n.attributeKey=e,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(e),this._testAndFire(`attribute:${e}`,n,t)}_createConversionApi(e,t=new Set,n={}){let r={...this._conversionApi,consumable:new cl,writer:e,options:n,convertItem:e=>this._convertInsert(B._createOn(e),r),convertChildren:e=>this._convertInsert(B._createIn(e),r,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,r),canReuseView:e=>!t.has(r.mapper.toModelElement(e))};return this._firedEventsMap.set(r,new Map),r}};function pl(e,t,n){let r=t.getRange(),i=Array.from(e.getAncestors());return i.shift(),i.reverse(),!i.some(e=>{if(r.containsItem(e))return!!n.toViewElement(e).getCustomProperty(`addHighlight`)})}function ml(e,t){return`${e}:${t.item.is(`element`)?t.item.name:`$text`}`}function hl(e){return{item:e.item,range:B._createFromPositionAndShift(e.previousPosition,e.length)}}var gl=class extends Jc{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=Ui(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){let e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){let e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){let e=[],t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){let t=[],n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?`push`:`unshift`](n),n=n.parent;return t}getCommonAncestor(e,t={}){let n=this.getAncestors(t),r=e.getAncestors(t),i=0;for(;n[i]==r[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;let t=this.getPath(),n=e.getPath(),r=fr(t,n);switch(r){case`prefix`:return!0;case`extension`:return!1;default:return t[r](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=Ui(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}};gl.prototype.is=function(e){return e===`node`||e===`model:node`};const Lee=E(Jc);var _l=class e extends Lee{_lastRangeBackward=!1;_attrs=new Map;_ranges=[];constructor(...e){super(),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){let e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){let e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return this._ranges.length===1?this._ranges[0].isCollapsed:!1}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(let t of this._ranges){let n=!1;for(let r of e._ranges)if(t.isEqual(r)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(let e of this._ranges)yield new B(e.start,e.end)}getFirstRange(){let e=null;for(let t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?new B(e.start,e.end):null}getLastRange(){let e=null;for(let t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?new B(e.start,e.end):null}getFirstPosition(){let e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){let e=this.getLastRange();return e?e.end.clone():null}setTo(...t){let[n,r,i]=t;if(typeof r==`object`&&(i=r,r=void 0),n===null)this._setRanges([]);else if(n instanceof e)this._setRanges(n.getRanges(),n.isBackward);else if(n&&typeof n.getRanges==`function`)this._setRanges(n.getRanges(),n.isBackward);else if(n instanceof B)this._setRanges([n],!!i&&!!i.backward);else if(n instanceof z)this._setRanges([new B(n)]);else if(n instanceof gl){let e=!!i&&!!i.backward,t;if(r==`in`)t=B._createIn(n);else if(r==`on`)t=B._createOn(n);else if(r!==void 0)t=new B(z._createAt(n,r));else throw new w(`model-selection-setto-required-second-parameter`,[this,n]);this._setRanges([t],e)}else if(pr(n))this._setRanges(n,i&&!!i.backward);else throw new w(`model-selection-setto-not-selectable`,[this,n])}_setRanges(e,t=!1){let n=Array.from(e),r=n.some(t=>{if(!(t instanceof B))throw new w(`model-selection-set-ranges-not-range`,[this,e]);return this._ranges.every(e=>!e.isEqual(t))});n.length===this._ranges.length&&!r||(this._replaceAllRanges(n),this._lastRangeBackward=!!t,this.fire(`change:range`,{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new w(`model-selection-setfocus-no-ranges`,[this,e]);let n=z._createAt(e,t);if(n.compareWith(this.focus)==`same`)return;let r=this.anchor;this._ranges.length&&this._popRange(),n.compareWith(r)==`before`?(this._pushRange(new B(n,r)),this._lastRangeBackward=!0):(this._pushRange(new B(r,n)),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 this.rangeCount===1?this.getFirstRange().getContainedElement():null}*getSelectedBlocks(){let e=new WeakSet;for(let t of this.getRanges()){let n=yl(t.start,e);zee(n,t)&&(yield n);let r=t.getWalker();for(let n of r){let i=n.item;n.type==`elementEnd`&&Ree(i,e,t)?yield i:n.type==`elementStart`&&i.is(`model:element`)&&i.root.document.model.schema.isBlock(i)&&r.jumpTo(z._createAt(i,`end`))}let i=yl(t.end,e);Bee(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){let t=z._createAt(e,0),n=z._createAt(e,`end`);return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}toJSON(){let e={ranges:Array.from(this.getRanges()).map(e=>e.toJSON())},t=Object.fromEntries(this.getAttributes());return Object.keys(t).length&&(e.attributes=t),this.isBackward&&(e.isBackward=!0),e}_pushRange(e){this._checkRange(e),this._ranges.push(new B(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}};_l.prototype.is=function(e){return e===`selection`||e===`model:selection`};function vl(e,t){return t.has(e)?!1:(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function Ree(e,t,n){return vl(e,t)&&bl(e,n)}function yl(e,t){let n=e.parent.root.document.model.schema,r=e.parent.getAncestors({parentFirst:!0,includeSelf:!0}),i=!1,a=r.find(e=>i?!1:(i=n.isLimit(e),!i&&vl(e,t)));return r.forEach(e=>t.add(e)),a}function bl(e,t){let n=Vee(e);return n?!t.containsRange(B._createOn(n),!0):!0}function zee(e,t){return e?t.isCollapsed||e.isEmpty?!0:t.start.isTouching(z._createAt(e,e.maxOffset))?!1:bl(e,t):!1}function Bee(e,t){return e?t.isCollapsed||e.isEmpty?!0:t.end.isTouching(z._createAt(e,0))?!1:bl(e,t):!1}function Vee(e){let t=e.root.document.model.schema,n=e.parent;for(;n;){if(t.isBlock(n))return n;n=n.parent}}const Hee=E(B);var xl=class e extends Hee{constructor(e,t){super(e,t),Uee.call(this)}detach(){this.stopListening()}toRange(){return new B(this.start,this.end)}static fromRange(t){return new e(t.start,t.end)}};xl.prototype.is=function(e){return e===`liveRange`||e===`model:liveRange`||e==`range`||e===`model:range`};function Uee(){this.listenTo(this.root.document.model,`applyOperation`,(e,t)=>{let n=t[0];n.isDocumentOperation&&Wee.call(this,n)},{priority:`low`})}function Wee(e){let t=this.getTransformedByOperation(e),n=B._createFromRanges(t),r=!n.isEqual(this),i=Gee(this,e),a=null;if(r){n.root.rootName==`$graveyard`&&(a=e.type==`remove`?e.sourcePosition:e.deletionPosition);let t=this.toRange();this.start=n.start,this.end=n.end,this.fire(`change:range`,t,{deletionPosition:a})}else i&&this.fire(`change:content`,this.toRange(),{deletionPosition:a})}function Gee(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}var Sl=class e extends gl{_data;constructor(e,t){super(t),this._data=e||``}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){let e=super.toJSON();return e.data=this.data,e}_clone(){return new e(this.data,this.getAttributes())}static fromJSON(t){return new e(t.data,t.attributes)}};Sl.prototype.is=function(e){return e===`$text`||e===`model:$text`||e===`text`||e===`model:text`||e===`node`||e===`model:node`};const Cl=`selection:`,wl=E(Jc);var Tl=class extends wl{_selection;constructor(e){super(),this._selection=new El(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)}toJSON(){return this._selection.toJSON()}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_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 Cl+e}static _isStoreAttributeKey(e){return e.startsWith(Cl)}};Tl.prototype.is=function(e){return e===`selection`||e==`model:selection`||e==`documentSelection`||e==`model:documentSelection`};var El=class extends _l{markers=new Fi({idProperty:`name`});_model;_document;_attributePriority=new Map;_selectionRestorePosition=null;_hasChangedRange=!1;_overriddenGravityRegister=new Set;_observedMarkers=new Set;constructor(e){super(),this._model=e.model,this._document=e,this.listenTo(this._model,`applyOperation`,(e,t)=>{let n=t[0];!n.isDocumentOperation||n.type==`marker`||n.type==`rename`||n.type==`noop`||(this._ranges.length==0&&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`,()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,`update`,(e,t,n,r)=>{this._updateMarker(t,r)}),this.listenTo(this._document,`change`,(e,t)=>{kl(this._model,t)})}get isCollapsed(){return this._ranges.length===0?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;ee.toJSON())),e}_validateSelectionRanges(e){for(let t of e)if(!this._document._validateSelectionRange(t))throw new w(`document-selection-wrong-position`,this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;let t=xl.fromRange(e);return t.on(`change:range`,(e,n,r)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=r.deletionPosition;let e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;let e=[],t=!1;for(let t of this._model.markers){let n=t.name.split(`:`,1)[0];if(!this._observedMarkers.has(n))continue;let r=t.getRange();for(let n of this.getRanges())r.containsRange(n,!n.isCollapsed)&&e.push(t)}let n=Array.from(this.markers);for(let n of e)this.markers.has(n)||(this.markers.add(n),t=!0);for(let n of Array.from(this.markers))e.includes(n)||(this.markers.remove(n),t=!0);t&&this.fire(`change:marker`,{oldMarkers:n,directChange:!1})}_updateMarker(e,t){let n=e.name.split(`:`,1)[0];if(!this._observedMarkers.has(n))return;let r=!1,i=Array.from(this.markers),a=this.markers.has(e);if(!t)a&&(this.markers.remove(e),r=!0);else{let n=!1;for(let e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){n=!0;break}n&&!a?(this.markers.add(e),r=!0):!n&&a&&(this.markers.remove(e),r=!0)}r&&this.fire(`change:marker`,{oldMarkers:i,directChange:!1})}_updateAttributes(e){let t=Ui(this._getSurroundingAttributes()),n=Ui(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(let[e,t]of this._attributePriority)t==`low`&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);let r=[];for(let[e,t]of this.getAttributes())(!n.has(e)||n.get(e)!==t)&&r.push(e);for(let[e]of n)this.hasAttribute(e)||r.push(e);r.length>0&&this.fire(`change:attribute`,{attributeKeys:r,directChange:!1})}_setAttribute(e,t,n=!0){let r=n?`normal`:`low`;return r==`low`&&this._attributePriority.get(e)==`normal`||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,r),!0)}_removeAttribute(e,t=!0){let n=t?`normal`:`low`;return n==`low`&&this._attributePriority.get(e)==`normal`||(this._attributePriority.set(e,n),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){let t=new Set;for(let[t,n]of this.getAttributes())e.get(t)!==n&&this._removeAttribute(t,!1);for(let[n,r]of e)this._setAttribute(n,r,!1)&&t.add(n);return t}*getStoredAttributes(){let e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(let t of e.getAttributeKeys())t.startsWith(Cl)&&(yield[t.substr(10),e.getAttribute(t)])}_getSurroundingAttributes(){let e=this.getFirstPosition(),t=this._model.schema;if(e.root.rootName==`$graveyard`)return null;let n=null;if(this.isCollapsed){let r=e.textNode?e.textNode:e.nodeBefore,i=e.textNode?e.textNode:e.nodeAfter;this.isGravityOverridden||(n=Dl(r,t)),n||=Dl(i,t),!this.isGravityOverridden&&!n&&(n=Dl(r,t,`backward`)),n||=Dl(i,t,`forward`),n||=this.getStoredAttributes()}else{let e=this.getFirstRange();for(let r of e){if(r.item.is(`element`)&&t.isObject(r.item)){n=Dl(r.item,t);break}if(r.type==`text`){n=r.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){let t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}};function Dl(e,t,n=`self`){if(!e)return null;for(let r of Ol(e,n)){if(!r)return null;if(r instanceof Sl)return r.getAttributes();if(!t.isInline(r))continue;let e=t.isObject(r),n=[];for(let[i,a]of r.getAttributes())t.checkAttribute(`$text`,i)&&(!e||t.getAttributeProperties(i).copyFromObject!==!1)&&n.push([i,a]);return n}return null}function*Ol(e,t){if(t==`self`)yield e;else{let n=e;for(;n;)n=t==`backward`?n.previousSibling:n.nextSibling,yield n}return null}function kl(e,t){let n=e.document.differ;for(let r of n.getChanges()){if(r.type!=`insert`)continue;let n=r.position.parent;r.length===n.maxOffset&&e.enqueueChange(t,e=>{let t=Array.from(n.getAttributeKeys()).filter(e=>e.startsWith(Cl));for(let r of t)e.removeAttribute(r,n)})}}var Al=class{_nodes=[];_offsetToNode=[];constructor(e){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;let t=this._nodes[e];if(!t)throw new w(`model-nodelist-index-out-of-bounds`,this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;let t=this._offsetToNode[e];if(!t)throw new w(`model-nodelist-offset-out-of-bounds`,this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){let n=[];for(let e of t){if(!(e instanceof gl))throw new w(`model-nodelist-insertnodes-not-node`,this);n.push(e)}let r=this.indexToOffset(e);Ji(this._nodes,n,e),Ji(this._offsetToNode,jl(n),r);for(let t=e;te.index!==null),this._offsetToNode=this._offsetToNode.filter(e=>e.index!==null);let t=0;for(let e=0;ee.toJSON())}};function jl(e){let t=[],n=0;for(let r of e)for(let e=0;e0){e.children=[];for(let t of this._children)e.children.push(t.toJSON())}return e}_clone(t=!1){let n=t?Pl(this._children):void 0;return new e(this.name,this.getAttributes(),n)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){let n=Nl(t);for(let e of n)e.parent!==null&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){let n=this._children._removeNodes(e,t);for(let e of n)e.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(let t of e)t.parent=null}static fromJSON(t){let n;if(t.children){n=[];for(let r of t.children)r.name?n.push(e.fromJSON(r)):n.push(Sl.fromJSON(r))}return new e(t.name,t.attributes,n)}};Ml.prototype.is=function(e,t){return t?t===this.name&&(e===`element`||e===`model:element`):e===`element`||e===`model:element`||e===`node`||e===`model:node`};function Nl(e){if(typeof e==`string`)return[new Sl(e)];pr(e)||(e=[e]);let t=[];for(let n of e)typeof n==`string`?t.push(new Sl(n)):n instanceof Yc?t.push(new Sl(n.data,n.getAttributes())):t.push(n);return t}function Pl(e){let t=[];for(let n of e)t.push(n._clone(!0));return t}var Fl=class{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(let t of this._dispatchers)e(t);return this}},Il=class extends Fl{elementToElement(e){return this.add(ou(e))}elementToStructure(e){return this.add(su(e))}attributeToElement(e){return this.add(cu(e))}attributeToAttribute(e){return this.add(lu(e))}markerToElement(e){return this.add(uu(e))}markerToHighlight(e){return this.add(fu(e))}markerToData(e){return this.add(du(e))}};function Ll(){return(e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;let r=n.writer,i=n.mapper.toViewPosition(t.range.start),a=r.createText(t.item.data);r.insert(i,a)}}function Rl(){return(e,t,n)=>{n.convertAttributes(t.item),!t.reconversion&&t.item.is(`element`)&&!t.item.isEmpty&&n.convertChildren(t.item)}}function zl(){return(e,t,n)=>{if(t.reconversion)return;let r=n.mapper.toViewPosition(t.position),i=t.position.getShiftedBy(t.length),a=n.mapper.toViewPosition(i,{isPhantom:!0});Jl(n.writer.createRange(r,a).getTrimmed(),n)}}function Bl(e,t){let n=e.createAttributeElement(`span`,t.attributes);return t.classes&&n._addClass(t.classes),typeof t.priority==`number`&&(n._priority=t.priority),n._id=t.id,n}function Vl(){return(e,t,n)=>{let r=t.selection;if(r.isCollapsed||!n.consumable.consume(r,`selection`))return;let i=[];for(let e of r.getRanges())i.push(n.mapper.toViewRange(e));n.writer.setSelection(i,{backward:r.isBackward})}}function Hl(){return(e,t,n)=>{let r=t.selection;if(!r.isCollapsed||!n.consumable.consume(r,`selection`))return;let i=n.writer,a=r.getFirstPosition(),o=n.mapper.toViewPosition(a),s=i.breakAttributes(o);i.setSelection(s)}}function Ul(){return(e,t,n)=>{let r=n.writer,i=r.document.selection;for(let e of i.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&n.writer.mergeAttributes(e.start);r.setSelection(null)}}function Wl(e){return(t,n,r)=>{if(!r.consumable.test(n.item,t.name))return;let i=e(n.attributeOldValue,r,n),a=e(n.attributeNewValue,r,n);if(!i&&!a)return;r.consumable.consume(n.item,t.name);let o=r.writer,s=o.document.selection;if(n.item instanceof _l||n.item instanceof Tl)o.wrap(s.getFirstRange(),a);else{let e=r.mapper.toViewRange(n.range);n.attributeOldValue!==null&&i&&(e=o.unwrap(e,i)),n.attributeNewValue!==null&&a&&o.wrap(e,a)}}}function Gl(e,t=Du){return(n,r,i)=>{if(!t(r.item,i.consumable,{preflight:!0}))return;let a=e(r.item,i,r);if(!a)return;t(r.item,i.consumable);let o=r.reconversion&&Yl(r.item,i)||i.mapper.toViewPosition(r.range.start);i.mapper.bindElements(r.item,a),i.writer.insert(o,a),i.convertAttributes(r.item),Tu(a,r.item.getChildren(),i,{reconversion:r.reconversion})}}function Kl(e,t){return(n,r,i)=>{if(!t(r.item,i.consumable,{preflight:!0}))return;let a=new Map;i.writer._registerSlotFactory(Su(r.item,a,i));let o=e(r.item,i,r);if(i.writer._clearSlotFactory(),!o)return;Cu(r.item,a,i),t(r.item,i.consumable);let s=r.reconversion&&Yl(r.item,i)||i.mapper.toViewPosition(r.range.start);i.mapper.bindElements(r.item,o),i.writer.insert(s,o),i.convertAttributes(r.item),wu(o,a,i,{reconversion:r.reconversion})}}function ql(e){return(t,n,r)=>{n.isOpening=!0;let i=e(n,r);n.isOpening=!1;let a=e(n,r);if(!i||!a)return;let{markerRange:o,markerName:s}=n;if(o.isCollapsed&&!r.consumable.consume(o,t.name))return;for(let e of o)if(!r.consumable.consume(e.item,t.name))return;let c=r.mapper,l=r.writer;l.setCustomProperty(`markerBoundaryType`,`start`,i),l.setCustomProperty(`markerBoundaryName`,s,i),l.setCustomProperty(`markerBoundaryType`,`end`,a),l.setCustomProperty(`markerBoundaryName`,s,a);let u=(e,t)=>{let n=c.markerNameToElements(e);if(n){for(let e of n)if(e.getCustomProperty(`markerBoundaryType`)===t)return c.toModelPosition(l.createPositionBefore(e))}return null};if(!o.isCollapsed){let e=c.toViewPosition(o.end).getLastMatchingPosition(({item:e})=>{if(!e.is(`uiElement`)||e.getCustomProperty(`markerBoundaryType`)!==`end`)return!1;let t=e.getCustomProperty(`markerBoundaryName`),n=u(t,`start`);if(!n)return!1;let r=n.compareWith(o.start);return r===`same`?t.localeCompare(s)>0:r===`after`});l.insert(e,a),c.bindElementToMarker(a,s)}let d=c.toViewPosition(o.start).getLastMatchingPosition(({item:e})=>{if(!e.is(`uiElement`))return!1;let t=e.getCustomProperty(`markerBoundaryType`);if(!t)return!1;if(t===`end`)return!0;let n=e.getCustomProperty(`markerBoundaryName`),r=u(n,`end`);if(!r)return o.isCollapsed;if(o.isCollapsed)return!0;let i=r.compareWith(o.end);return i===`same`?n.localeCompare(s)<0:i===`after`});l.insert(d,i),c.bindElementToMarker(i,s),t.stop()}}function Jl(e,t){let n=t.writer.remove(e);for(let e of t.writer.createRangeIn(n).getItems())t.mapper.unbindViewElement(e,{defer:!0});return e.start}function Yl(e,t){let n=t.mapper.toViewElement(e);return n&&Jl(t.writer.createRangeOn(n),t)}function Xl(){return(e,t,n)=>{let r=n.mapper.markerNameToElements(t.markerName);if(r){for(let e of r)n.mapper.unbindElementFromMarkerName(e,t.markerName),n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function Zl(e){return(t,n,r)=>{let i=e(n.markerName,r);if(!i)return;let a=n.markerRange;r.consumable.consume(a,t.name)&&(Ql(a,!1,r,n,i),Ql(a,!0,r,n,i),t.stop())}}function Ql(e,t,n,r,i){let a=t?e.start:e.end,o=a.nodeAfter&&a.nodeAfter.is(`element`)?a.nodeAfter:null,s=a.nodeBefore&&a.nodeBefore.is(`element`)?a.nodeBefore:null;if(o||s){let e,a;t&&o||!t&&!s?(e=o,a=!0):(e=s,a=!1);let c=n.mapper.toViewElement(e);if(c){$l(c,t,a,n,r,i);return}}eu(n.mapper.toViewPosition(a),t,n,r,i)}function $l(e,t,n,r,i,a){let o=`data-${a.group}-${t?`start`:`end`}-${n?`before`:`after`}`,s=e.hasAttribute(o)?e.getAttribute(o).split(`,`):[];s.unshift(a.name),r.writer.setAttribute(o,s.join(`,`),e),r.mapper.bindElementToMarker(e,i.markerName)}function eu(e,t,n,r,i){let a=`${i.group}-${t?`start`:`end`}`,o=i.name?{name:i.name}:null,s=n.writer.createUIElement(a,o);n.writer.insert(e,s),n.mapper.bindElementToMarker(s,r.markerName)}function tu(e){return(t,n,r)=>{let i=e(n.markerName,r);if(!i)return;let a=r.mapper.markerNameToElements(n.markerName);if(!a)return;for(let e of a)r.mapper.unbindElementFromMarkerName(e,n.markerName),e.is(`containerElement`)?(o(`data-${i.group}-start-before`,e),o(`data-${i.group}-start-after`,e),o(`data-${i.group}-end-before`,e),o(`data-${i.group}-end-after`,e)):r.writer.clear(r.writer.createRangeOn(e),e);r.writer.clearClonedElementsGroup(n.markerName),t.stop();function o(e,t){if(t.hasAttribute(e)){let n=new Set(t.getAttribute(e).split(`,`));n.delete(i.name),n.size==0?r.writer.removeAttribute(e,t):r.writer.setAttribute(e,Array.from(n).join(`,`),t)}}}}function nu(e){return(t,n,r)=>{if(!r.consumable.test(n.item,t.name))return;let i=e(n.attributeOldValue,r,n),a=e(n.attributeNewValue,r,n);if(!i&&!a)return;r.consumable.consume(n.item,t.name);let o=r.mapper.toViewElement(n.item),s=r.writer;if(!o)throw new w(`conversion-attribute-to-attribute-on-text`,r.dispatcher,n);if(n.attributeOldValue!==null&&i){let e=i.value;i.key==`style`&&(e=typeof i.value==`string`?new Vo(s.document.stylesProcessor).setTo(i.value).getStylesEntries().map(([e])=>e):Object.keys(i.value)),s.removeAttribute(i.key,e,o)}if(n.attributeNewValue!==null&&a){let e=a.value;a.key==`style`&&typeof a.value==`string`&&(e=Object.fromEntries(new Vo(s.document.stylesProcessor).setTo(a.value).getStylesEntries())),s.setAttribute(a.key,e,!1,o)}}}function ru(e){return(t,n,r)=>{if(!n.item||!(n.item instanceof _l||n.item instanceof Tl)&&!n.item.is(`$textProxy`))return;let i=vu(e,n,r);if(!i||!r.consumable.consume(n.item,t.name))return;let a=r.writer,o=Bl(a,i),s=a.document.selection;if(n.item instanceof _l||n.item instanceof Tl)a.wrap(s.getFirstRange(),o);else{let e=r.mapper.toViewRange(n.range),t=a.wrap(e,o);for(let e of t.getItems())if(e.is(`attributeElement`)&&e.isSimilar(o)){r.mapper.bindElementToMarker(e,n.markerName);break}}}}function iu(e){return(t,n,r)=>{if(!n.item||!(n.item instanceof Ml))return;let i=vu(e,n,r);if(!i||!r.consumable.test(n.item,t.name))return;let a=r.mapper.toViewElement(n.item);if(a&&a.getCustomProperty(`addHighlight`)){r.consumable.consume(n.item,t.name);for(let e of B._createIn(n.item))r.consumable.consume(e.item,t.name);a.getCustomProperty(`addHighlight`)(a,i,r.writer),r.mapper.bindElementToMarker(a,n.markerName)}}}function au(e){return(t,n,r)=>{if(n.markerRange.isCollapsed)return;let i=vu(e,n,r);if(!i)return;let a=Bl(r.writer,i),o=r.mapper.markerNameToElements(n.markerName);if(o){for(let e of o)r.mapper.unbindElementFromMarkerName(e,n.markerName),e.is(`attributeElement`)?r.writer.unwrap(r.writer.createRangeOn(e),a):e.getCustomProperty(`removeHighlight`)(e,i.id,r.writer);r.writer.clearClonedElementsGroup(n.markerName),t.stop()}}}function ou(e){let t=pu(e.model),n=mu(e.view,`container`);return t.attributes.length&&(t.children=!0),r=>{r.on(`insert:${t.name}`,Gl(n,xu(t)),{priority:e.converterPriority||`normal`}),(t.children||t.attributes.length)&&r.on(`reduceChanges`,bu(t),{priority:`low`})}}function su(e){let t=pu(e.model),n=mu(e.view,`container`);return t.children=!0,r=>{if(r._conversionApi.schema.checkChild(t.name,`$text`))throw new w(`conversion-element-to-structure-disallowed-text`,r,{elementName:t.name});r.on(`insert:${t.name}`,Kl(n,xu(t)),{priority:e.converterPriority||`normal`}),r.on(`reduceChanges`,bu(t),{priority:`low`})}}function cu(e){e=Rt(e);let t=e.model;typeof t==`string`&&(t={key:t});let n=`attribute:${t.key}`;if(t.name&&(n+=`:`+t.name),t.values)for(let n of t.values)e.view[n]=mu(e.view[n],`attribute`);else e.view=mu(e.view,`attribute`);let r=gu(e);return t=>{t.on(n,Wl(r),{priority:e.converterPriority||`normal`})}}function lu(e){e=Rt(e);let t=e.model;typeof t==`string`&&(t={key:t});let n=`attribute:${t.key}`;if(t.name&&(n+=`:`+t.name),t.values)for(let n of t.values)e.view[n]=_u(e.view[n]);else e.view=_u(e.view);let r=gu(e);return t=>{t.on(n,nu(r),{priority:e.converterPriority||`normal`})}}function uu(e){let t=mu(e.view,`ui`);return n=>{n.on(`addMarker:${e.model}`,ql(t),{priority:e.converterPriority||`normal`}),n.on(`removeMarker:${e.model}`,Xl(),{priority:e.converterPriority||`normal`})}}function du(e){e=Rt(e);let t=e.model,n=e.view;return n||=n=>({group:t,name:n.substr(e.model.length+1)}),r=>{r.on(`addMarker:${t}`,Zl(n),{priority:e.converterPriority||`normal`}),r.on(`removeMarker:${t}`,tu(n),{priority:e.converterPriority||`normal`})}}function fu(e){return t=>{t.on(`addMarker:${e.model}`,ru(e.view),{priority:e.converterPriority||`normal`}),t.on(`addMarker:${e.model}`,iu(e.view),{priority:e.converterPriority||`normal`}),t.on(`removeMarker:${e.model}`,au(e.view),{priority:e.converterPriority||`normal`})}}function pu(e){return typeof e==`string`&&(e={name:e}),{name:e.name,attributes:e.attributes?A(e.attributes):[],children:!!e.children}}function mu(e,t){return typeof e==`function`?e:((n,r)=>hu(e,r,t))}function hu(e,t,n){typeof e==`string`&&(e={name:e});let r,i=t.writer,a=Object.assign({},e.attributes);if(n==`container`)r=i.createContainerElement(e.name,a);else if(n==`attribute`){let t={priority:e.priority||ws.DEFAULT_PRIORITY};r=i.createAttributeElement(e.name,a,t)}else r=i.createUIElement(e.name,a);if(e.styles){let t=Object.keys(e.styles);for(let n of t)i.setStyle(n,e.styles[n],r)}if(e.classes){let t=e.classes;if(typeof t==`string`)i.addClass(t,r);else for(let e of t)i.addClass(e,r)}return r}function gu(e){return e.model.values?((t,n,r)=>{let i=e.view[t];return i?i(t,n,r):null}):e.view}function _u(e){return typeof e==`string`?t=>({key:e,value:t}):typeof e==`object`?e.value?()=>e:t=>({key:e.key,value:t}):e}function vu(e,t,n){let r=typeof e==`function`?e(t,n):{...e};return r?(r.priority||=10,r.id||=t.markerName,r):null}function yu(e){return(t,n)=>{if(!t.is(`element`,e.name))return!1;if(n.type==`attribute`){if(e.attributes.includes(n.attributeKey))return!0}else if(e.children)return!0;return!1}}function bu(e){let t=yu(e);return(e,n)=>{let r=[];n.reconvertedElements||=new Set;for(let e of n.changes){let i=e.type==`attribute`?e.range.start.nodeAfter:e.position.parent;if(!i||!t(i,e)||e.type==`reinsert`){r.push(e);continue}if(e.type==`insert`&&e.action==`rename`&&n.refreshedItems.add(e.position.nodeAfter),!n.reconvertedElements.has(i)){n.reconvertedElements.add(i);let e=z._createBefore(i),t=r.length;for(let n=r.length-1;n>=0;n--){let i=r[n],a=(i.type==`attribute`?i.range.start:i.position).compareWith(e);if(a==`before`||i.type==`remove`&&a==`same`)break;t=n}r.splice(t,0,{type:`reinsert`,name:i.name,position:e,length:1})}}n.changes=r}}function xu(e){return(t,n,r={})=>{let i=[`insert`];for(let n of e.attributes)t.hasAttribute(n)&&i.push(`attribute:${n}`);return i.every(e=>n.test(t,e))?(r.preflight||i.forEach(e=>n.consume(t,e)),!0):!1}}function Su(e,t,n){return(r,i)=>{let a=r.createContainerElement(`$slot`),o=null;if(i===`children`)o=Array.from(e.getChildren());else if(typeof i==`function`)o=Array.from(e.getChildren()).filter(e=>i(e));else throw new w(`conversion-slot-mode-unknown`,n.dispatcher,{modeOrFilter:i});return t.set(a,o),a}}function Cu(e,t,n){let r=Array.from(t.values()).flat(),i=new Set(r);if(i.size!=r.length)throw new w(`conversion-slot-filter-overlap`,n.dispatcher,{element:e});if(i.size!=e.childCount)throw new w(`conversion-slot-filter-incomplete`,n.dispatcher,{element:e})}function wu(e,t,n,r){n.mapper.on(`modelToViewPosition`,o,{priority:`highest`});let i=null,a=null;for([i,a]of t)Tu(e,a,n,r),n.writer.setCustomProperty(`$structureSlotParent`,!0,i.parent),n.writer.move(n.writer.createRangeIn(i),n.writer.createPositionBefore(i)),n.writer.remove(i);n.mapper.off(`modelToViewPosition`,o);function o(e,t){let n=t.modelPosition.nodeAfter,r=a.indexOf(n);r<0||(t.viewPosition=t.mapper.findPositionIn(i,r))}}function Tu(e,t,n,r){for(let i of t)Eu(e.root,i,n,r)||n.convertItem(i)}function Eu(e,t,n,r){let{writer:i,mapper:a}=n;if(!r.reconversion)return!1;let o=a.toViewElement(t);return!o||o.root==e||!n.canReuseView(o)?!1:(i.move(i.createRangeOn(o),a.toViewPosition(z._createBefore(t))),!0)}function Du(e,t,{preflight:n}={}){return n?t.test(e,`insert`):t.consume(e,`insert`)}function Ou(e){let{schema:t,document:n}=e.model;for(let r of n.getRoots())if(r.isEmpty&&!t.checkChild(r,`$text`)&&t.checkChild(r,`paragraph`))return e.insertElement(`paragraph`,r),!0;return!1}function ku(e,t,n){let r=n.createContext(e);return!(!n.checkChild(r,`paragraph`)||!n.checkChild(r.push(`paragraph`),t))}function Au(e,t){let n=t.createElement(`paragraph`);return t.insert(n,e),t.createPositionAt(n,0)}var ju=class extends Fl{elementToElement(e){return this.add(Fu(e))}elementToAttribute(e){return this.add(Iu(e))}attributeToAttribute(e){return this.add(Lu(e))}elementToMarker(e){return this.add(Ru(e))}dataToMarker(e){return this.add(zu(e))}};function Mu(){return(e,t,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){let{modelRange:e,modelCursor:r}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=r}}}function Nu(){return(e,t,{schema:n,consumable:r,writer:i})=>{let a=t.modelCursor;if(!r.test(t.viewItem))return;if(!n.checkChild(a,`$text`)){if(!ku(a,`$text`,n)||t.viewItem.data.trim().length==0)return;a=Au(a,i)}r.consume(t.viewItem);let o=i.createText(t.viewItem.data);i.insert(o,a),t.modelRange=i.createRange(a,a.getShiftedBy(o.offsetSize)),t.modelCursor=t.modelRange.end}}function Pu(e,t){return(n,r)=>{let i=r.newSelection,a=[];for(let e of i.getRanges())a.push(t.toModelRange(e));let o=e.createSelection(a,{backward:i.isBackward});o.isEqual(e.document.selection)||e.change(e=>{e.setSelection(o)})}}function Fu(e){e=Rt(e);let t=Hu(e),n=Vu(e.view),r=n?`element:${n}`:`element`;return n=>{n.on(r,t,{priority:e.converterPriority||`normal`})}}function Iu(e){e=Rt(e),Gu(e);let t=Ku(e,!1),n=Vu(e.view),r=n?`element:${n}`:`element`;return n=>{n.on(r,t,{priority:e.converterPriority||`low`})}}function Lu(e){e=Rt(e);let t=null;(typeof e.view==`string`||e.view.key)&&(t=Wu(e)),Gu(e,t);let n=Ku(e,!0);return t=>{t.on(`element`,n,{priority:e.converterPriority||`low`})}}function Ru(e){let t=Yu(e.model);return Fu({...e,model:t})}function zu(e){e=Rt(e),e.model||=t=>t?e.view+`:`+t:e.view;let t={view:e.view,model:e.model},n=Hu(Xu(t,`start`)),r=Hu(Xu(t,`end`));return i=>{i.on(`element:${e.view}-start`,n,{priority:e.converterPriority||`normal`}),i.on(`element:${e.view}-end`,r,{priority:e.converterPriority||`normal`});let a=ge.low,o=ge.highest,s=ge.get(e.converterPriority)/o;i.on(`element`,Bu(t),{priority:a+s})}}function Bu(e){return(t,n,r)=>{let i=`data-${e.view}`;if(!r.consumable.test(n.viewItem,{attributes:i+`-end-after`})&&!r.consumable.test(n.viewItem,{attributes:i+`-start-after`})&&!r.consumable.test(n.viewItem,{attributes:i+`-end-before`})&&!r.consumable.test(n.viewItem,{attributes:i+`-start-before`}))return;n.modelRange||Object.assign(n,r.convertChildren(n.viewItem,n.modelCursor)),r.consumable.consume(n.viewItem,{attributes:i+`-end-after`})&&a(n.modelRange.end,n.viewItem.getAttribute(i+`-end-after`).split(`,`)),r.consumable.consume(n.viewItem,{attributes:i+`-start-after`})&&a(n.modelRange.end,n.viewItem.getAttribute(i+`-start-after`).split(`,`)),r.consumable.consume(n.viewItem,{attributes:i+`-end-before`})&&a(n.modelRange.start,n.viewItem.getAttribute(i+`-end-before`).split(`,`)),r.consumable.consume(n.viewItem,{attributes:i+`-start-before`})&&a(n.modelRange.start,n.viewItem.getAttribute(i+`-start-before`).split(`,`));function a(t,i){for(let a of i){let i=e.model(a,r),o=r.writer.createElement(`$marker`,{"data-name":i});r.writer.insert(o,t),n.modelCursor.isEqual(t)?n.modelCursor=n.modelCursor.getShiftedBy(1):n.modelCursor=n.modelCursor._getTransformedByInsertion(t,1),n.modelRange=n.modelRange._getTransformedByInsertion(t,1)[0]}}}}function Vu(e){return typeof e==`string`?e:typeof e==`object`&&typeof e.name==`string`?e.name:null}function Hu(e){let t=new Po(e.view);return(n,r,i)=>{let a=t.match(r.viewItem);if(!a)return;let o=a.match;if(o.name=!0,!i.consumable.test(r.viewItem,o))return;let s=Uu(e.model,r.viewItem,i);s&&i.safeInsert(s,r.modelCursor)&&(i.consumable.consume(r.viewItem,o),i.convertChildren(r.viewItem,s),i.updateConversionResult(s,r))}}function Uu(e,t,n){return e instanceof Function?e(t,n):n.writer.createElement(e)}function Wu(e){typeof e.view==`string`&&(e.view={key:e.view});let t=e.view.key,n=e.view.value===void 0?/[\s\S]*/:e.view.value,r;return r=t==`class`||t==`style`?{[t==`class`?`classes`:`styles`]:n}:{attributes:{[t]:n}},e.view.name&&(r.name=e.view.name),e.view=r,t}function Gu(e,t=null){let n=t===null?!0:e=>e.getAttribute(t);e.model={key:typeof e.model==`object`?e.model.key:e.model,value:typeof e.model!=`object`||e.model.value===void 0?n:e.model.value}}function Ku(e,t){let n=new Po(e.view);return(r,i,a)=>{if(!i.modelRange&&t)return;let o=n.match(i.viewItem);if(!o||(qu(e.view,i.viewItem)?o.match.name=!0:delete o.match.name,!a.consumable.test(i.viewItem,o.match)))return;let s=e.model.key,c=typeof e.model.value==`function`?e.model.value(i.viewItem,a,i):e.model.value;c!=null&&(i.modelRange||Object.assign(i,a.convertChildren(i.viewItem,i.modelCursor)),Ju(i.modelRange,{key:s,value:c},t,a)&&(a.consumable.test(i.viewItem,{name:!0})&&(o.match.name=!0),a.consumable.consume(i.viewItem,o.match)))}}function qu(e,t){let n=typeof e==`function`?e(t):e;return typeof n==`object`&&!Vu(n)?!1:!n.classes&&!n.attributes&&!n.styles}function Ju(e,t,n,r){let i=!1;for(let a of Array.from(e.getItems({shallow:n})))r.schema.checkAttribute(a,t.key)&&(i=!0,!a.hasAttribute(t.key)&&r.writer.setAttribute(t.key,t.value,a));return i}function Yu(e){return(t,n)=>{let r=typeof e==`string`?e:e(t,n);return n.writer.createElement(`$marker`,{"data-name":r})}}function Xu(e,t){return{view:`${e.view}-${t}`,model:(t,n)=>{let r=t.getAttribute(`name`),i=e.model(r,n);return n.writer.createElement(`$marker`,{"data-name":i})}}}const Zu=D();var Qu=class extends Zu{model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new qc(t),this.mapper=new ol,this.downcastDispatcher=new fl({mapper:this.mapper,schema:e.schema});let n=this.model.document,r=n.selection,i=this.model.markers;this.listenTo(this.model,`_beforeChanges`,()=>{this.view._disableRendering(!0)},{priority:`highest`}),this.listenTo(this.model,`_afterChanges`,()=>{this.view._disableRendering(!1)},{priority:`lowest`}),this.listenTo(n,`change`,()=>{this.view.change(e=>{this.downcastDispatcher.convertChanges(n.differ,i,e),this.downcastDispatcher.convertSelection(r,i,e)})},{priority:`low`}),this.listenTo(this.view.document,`selectionChange`,Pu(this.model,this.mapper)),this.downcastDispatcher.on(`insert:$text`,Ll(),{priority:`lowest`}),this.downcastDispatcher.on(`insert`,Rl(),{priority:`lowest`}),this.downcastDispatcher.on(`remove`,zl(),{priority:`low`}),this.downcastDispatcher.on(`cleanSelection`,Ul()),this.downcastDispatcher.on(`selection`,Vl(),{priority:`low`}),this.downcastDispatcher.on(`selection`,Hl(),{priority:`low`}),this.view.document.roots.bindTo(this.model.document.roots).using(e=>{if(e.rootName==`$graveyard`)return null;let t=new ns(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){let t=typeof e==`string`?e:e.name,n=this.model.markers.get(t);if(!n)throw new w(`editingcontroller-reconvertmarker-marker-not-exist`,this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(n)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}};const $u=D();var ed=class extends $u{_sourceDefinitions={};_attributeProperties=Object.create(null);_customChildChecks=new Map;_customAttributeChecks=new Map;_genericCheckSymbol=Symbol(`$generic`);_compiledDefinitions;constructor(){super(),this.decorate(`checkChild`),this.decorate(`checkAttribute`),this.on(`checkAttribute`,(e,t)=>{t[0]=new td(t[0])},{priority:`highest`}),this.on(`checkChild`,(e,t)=>{t[0]=new td(t[0]),t[1]=this.getDefinition(t[1])},{priority:`highest`})}register(e,t){if(this._sourceDefinitions[e])throw new w(`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 w(`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=typeof e==`string`?e:`is`in e&&(e.is(`$text`)||e.is(`$textProxy`))?`$text`:e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){let t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){let t=this.getDefinition(e);return t?!!(t.isLimit||t.isObject):!1}isObject(e){let t=this.getDefinition(e);return t?!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent):!1}isInline(e){let t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){let t=this.getDefinition(e);return t?!!(t.isSelectable||t.isObject):!1}isContent(e){let t=this.getDefinition(e);return t?!!(t.isContent||t.isObject):!1}checkChild(e,t){return t?this._checkContextMatch(e,t):!1}checkAttribute(e,t){let n=this.getDefinition(e.last);if(!n)return!1;let r=this._evaluateAttributeChecks(e,t);return r===void 0?n.allowAttributes.includes(t):r}checkMerge(e,t){if(e instanceof z){let t=e.nodeBefore,n=e.nodeAfter;if(!(t instanceof Ml))throw new w(`schema-check-merge-no-element-before`,this);if(!(n instanceof Ml))throw new w(`schema-check-merge-no-element-after`,this);return this.checkMerge(t,n)}if(this.isLimit(e)||this.isLimit(t))return!1;for(let n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e,t){let n=t===void 0?this._genericCheckSymbol:t,r=this._customChildChecks.get(n)||[];r.push(e),this._customChildChecks.set(n,r)}addAttributeCheck(e,t){let n=t===void 0?this._genericCheckSymbol:t,r=this._customAttributeChecks.get(n)||[];r.push(e),this._customAttributeChecks.set(n,r)}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;for(t=e instanceof z?e.parent:(e instanceof B?[e]:Array.from(e.getRanges())).reduce((e,t)=>{let n=t.getCommonAncestor();return e?e.getCommonAncestor(n,{includeSelf:!0}):n},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){let n=[...e.getFirstPosition().getAncestors(),new Sl(``,e.getAttributes())];return this.checkAttribute(n,t)}else{let n=e.getRanges();for(let e of n)for(let n of e)if(this.checkAttribute(n.item,t))return!0}return!1}*getValidRanges(e,t,n={}){e=vd(e);for(let r of e)yield*this._getValidRangesForRange(r,t,n)}getNearestSelectionRange(e,t=`both`){if(e.root.rootName==`$graveyard`)return null;if(this.checkChild(e,`$text`))return new B(e);let n,r,i=e.getAncestors().reverse().find(e=>this.isLimit(e))||e.root;(t==`both`||t==`backward`)&&(n=new Xc({boundaries:B._createIn(i),startPosition:e,direction:`backward`})),(t==`both`||t==`forward`)&&(r=new Xc({boundaries:B._createIn(i),startPosition:e}));for(let e of _d(n,r)){let t=e.walker==n?`elementEnd`:`elementStart`,r=e.value;if(r.type==t&&this.isObject(r.item))return B._createOn(r.item);if(this.checkChild(r.nextPosition,`$text`))return new B(r.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){let r=n.model;for(let[i,a]of Object.entries(t))r.schema.checkAttribute(e,i)&&n.setAttribute(i,a,e)}removeDisallowedAttributes(e,t){for(let n of e)if(n.is(`$text`))yd(this,n,t);else{let e=B._createIn(n).getPositions();for(let n of e){let e=n.nodeBefore||n.parent;yd(this,e,t)}}}getAttributesWithProperty(e,t,n){let r={};for(let[i,a]of e.getAttributes()){let e=this.getAttributeProperties(i);e[t]!==void 0&&(n===void 0||n===e[t])&&(r[i]=a)}return r}createContext(e){return new td(e)}_clearCache(){this._compiledDefinitions=null}_compile(){let e={},t=this._sourceDefinitions,n=Object.keys(t);for(let r of n)e[r]=nd(t[r],r);let r=Object.values(e);for(let t of r)rd(e,t),id(e,t),ad(e,t),od(e,t);for(let t of r)sd(e,t);for(let t of r)cd(e,t);for(let t of r)ld(e,t);for(let t of r)dd(e,t);for(let t of r)fd(e,t);this._compiledDefinitions=ud(e)}_checkContextMatch(e,t){let n=e.last,r=this._evaluateChildChecks(e,t);if(r=r===void 0?t.allowIn.includes(n.name):r,!r)return!1;let i=this.getDefinition(n),a=e.trimLast();return i?a.length==0?!0:this._checkContextMatch(a,i):!1}_evaluateChildChecks(e,t){let n=this._customChildChecks.get(this._genericCheckSymbol)||[],r=this._customChildChecks.get(t.name)||[];for(let i of[...n,...r]){let n=i(e,t);if(n!==void 0)return n}}_evaluateAttributeChecks(e,t){let n=this._customAttributeChecks.get(this._genericCheckSymbol)||[],r=this._customAttributeChecks.get(t)||[];for(let i of[...n,...r]){let n=i(e,t);if(n!==void 0)return n}}*_getValidRangesForRange(e,t,n){let r=e.start,i=e.start;for(let a of e.getItems({shallow:!0})){if(a.is(`element`))if(n.includeEmptyRanges&&a.isEmpty){let e=this.createContext(a);this.checkChild(e,`$text`)&&this.checkAttribute(e.push(`$text`),t)&&(yield B._createIn(a))}else yield*this._getValidRangesForRange(B._createIn(a),t,n);this.checkAttribute(a,t)||(r.isEqual(i)||(yield new B(r,i)),r=z._createAfter(a)),i=z._createAfter(a)}r.isEqual(i)||(yield new B(r,i))}findOptimalInsertionRange(e,t){let n=e.getSelectedElement();if(n&&this.isObject(n)&&!this.isInline(n))return t==`before`||t==`after`?new B(z._createAt(n,t)):B._createOn(n);let r=j(e.getSelectedBlocks());if(!r)return new B(e.focus);if(r.isEmpty)return new B(z._createAt(r,0));let i=z._createAfter(r);return e.focus.isTouching(i)?new B(i):new B(z._createBefore(r))}},td=class e{_items;constructor(t){if(t instanceof e)return t;let n;n=typeof t==`string`?[t]:Array.isArray(t)?t:t.getAncestors({includeSelf:!0}),this._items=n.map(gd)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(t){let n=new e([t]);return n._items=[...this._items,...n._items],n}trimLast(){let t=new e([]);return t._items=this._items.slice(0,-1),t}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(` `).endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(` `).startsWith(e)}};function nd(e,t){let n={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 pd(e,n),md(e,n,`allowIn`),md(e,n,`allowChildren`),md(e,n,`disallowIn`),md(e,n,`disallowChildren`),md(e,n,`allowContentOf`),md(e,n,`allowWhere`),md(e,n,`allowAttributes`),md(e,n,`disallowAttributes`),md(e,n,`allowAttributesOf`),md(e,n,`inheritTypesFrom`),hd(e,n),n}function rd(e,t){for(let n of t.allowIn){let r=e[n];r?r.allowChildren.add(t.name):t.allowIn.delete(n)}}function id(e,t){for(let n of t.allowChildren){let r=e[n];r?r.allowIn.add(t.name):t.allowChildren.delete(n)}}function ad(e,t){for(let n of t.disallowIn){let r=e[n];r?r.disallowChildren.add(t.name):t.disallowIn.delete(n)}}function od(e,t){for(let n of t.disallowChildren){let r=e[n];r?r.disallowIn.add(t.name):t.disallowChildren.delete(n)}}function sd(e,t){for(let e of t.disallowChildren)t.allowChildren.delete(e);for(let e of t.disallowIn)t.allowIn.delete(e);for(let e of t.disallowAttributes)t.allowAttributes.delete(e)}function cd(e,t){for(let n of t.allowContentOf){let r=e[n];r&&(r.disallowChildren.forEach(n=>{t.allowChildren.has(n)||(t.disallowChildren.add(n),e[n].disallowIn.add(t.name))}),r.allowChildren.forEach(n=>{t.disallowChildren.has(n)||(t.allowChildren.add(n),e[n].allowIn.add(t.name))}))}}function ld(e,t){for(let n of t.allowWhere){let r=e[n];r&&(r.disallowIn.forEach(n=>{t.allowIn.has(n)||(t.disallowIn.add(n),e[n].disallowChildren.add(t.name))}),r.allowIn.forEach(n=>{t.disallowIn.has(n)||(t.allowIn.add(n),e[n].allowChildren.add(t.name))}))}}function ud(e){let t={};for(let n of Object.values(e))t[n.name]={name:n.name,isBlock:!!n.isBlock,isContent:!!n.isContent,isInline:!!n.isInline,isLimit:!!n.isLimit,isObject:!!n.isObject,isSelectable:!!n.isSelectable,allowIn:Array.from(n.allowIn).filter(t=>!!e[t]),allowChildren:Array.from(n.allowChildren).filter(t=>!!e[t]),allowAttributes:Array.from(n.allowAttributes)};return t}function dd(e,t){for(let n of t.allowAttributesOf){let r=e[n];if(!r)return;r.allowAttributes.forEach(e=>{t.disallowAttributes.has(e)||t.allowAttributes.add(e)})}}function fd(e,t){for(let n of t.inheritTypesFrom){let r=e[n];if(r){let e=Object.keys(r).filter(e=>e.startsWith(`is`));for(let n of e)n in t||(t[n]=r[n])}}}function pd(e,t){for(let n of e){let e=Object.keys(n).filter(e=>e.startsWith(`is`));for(let r of e)t[r]=!!n[r]}}function md(e,t,n){for(let r of e){let e=r[n];typeof e==`string`&&(e=[e]),Array.isArray(e)&&e.forEach(e=>t[n].add(e))}}function hd(e,t){for(let n of e){let e=n.inheritAllFrom;e&&(t.allowContentOf.add(e),t.allowWhere.add(e),t.allowAttributesOf.add(e),t.inheritTypesFrom.add(e))}}function gd(e){return typeof e==`string`||e.is(`documentFragment`)?{name:typeof e==`string`?e:`$documentFragment`,*getAttributeKeys(){},getAttribute(){}}:{name:e.is(`element`)?e.name:`$text`,*getAttributeKeys(){yield*e.getAttributeKeys()},getAttribute(t){return e.getAttribute(t)}}}function*_d(e,t){let n=!1;for(;!n;){if(n=!0,e){let t=e.next();t.done||(n=!1,yield{walker:e,value:t.value})}if(t){let e=t.next();e.done||(n=!1,yield{walker:t,value:e.value})}}}function*vd(e){for(let t of e)yield*t.getMinimalFlatRanges()}function yd(e,t,n){for(let r of t.getAttributeKeys())e.checkAttribute(t,r)||n.removeAttribute(r,t)}const bd=E();var xd=class extends bd{conversionApi;_splitParts=new Map;_cursorParents=new Map;_modelCursor=null;_emptyElementsToKeep=new Set;constructor(e){super(),this.conversionApi={...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,n=[`$root`]){this.fire(`viewCleanup`,e),this._modelCursor=Cd(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=Ao.createFrom(e),this.conversionApi.store={};let{modelRange:r}=this._convertItem(e,this._modelCursor),i=t.createDocumentFragment();if(r){this._removeEmptyElements();let e=this._modelCursor.parent,n=e._removeChildren(0,e.childCount);i._insertChild(0,n),i.markers=Sd(i,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,i}_convertItem(e,t){let n={viewItem:e,modelCursor:t,modelRange:null};if(e.is(`element`)?this.fire(`element:${e.name}`,n,this.conversionApi):e.is(`$text`)?this.fire(`text`,n,this.conversionApi):this.fire(`documentFragment`,n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof B))throw new w(`view-conversion-dispatcher-incorrect-result`,this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is(`position`)?t:z._createAt(t,0),r=new B(n);for(let t of Array.from(e.getChildren())){let e=this._convertItem(t,n);e.modelRange instanceof B&&(r.end=e.modelRange.end,n=e.modelCursor)}return{modelRange:r,modelCursor:n}}_safeInsert(e,t){let n=this._splitToAllowedParent(e,t);return n?(this.conversionApi.writer.insert(e,n.position),!0):!1}_updateConversionResult(e,t){let n=this._getSplitParts(e),r=this.conversionApi.writer;t.modelRange||=r.createRange(r.createPositionBefore(e),r.createPositionAfter(n[n.length-1]));let i=this._cursorParents.get(e);i?t.modelCursor=r.createPositionAt(i,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){let{schema:n,writer:r}=this.conversionApi,i=n.findAllowedParent(t,e);if(i){if(i===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(i)&&(i=null)}if(!i)return ku(t,e,n)?{position:Au(t,r)}:null;let a=this.conversionApi.writer.split(t,i),o=[];for(let e of a.range.getWalker())if(e.type==`elementEnd`)o.push(e.item);else{let t=o.pop(),n=e.item;this._registerSplitPair(t,n)}let s=a.range.end.parent;return this._cursorParents.set(e,s),{position:a.position,cursorParent:s}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);let n=this._splitParts.get(e);this._splitParts.set(t,n),n.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(){let e=new Map;for(let t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){let n=e.get(t.parent)||[];n.push(t),this._splitParts.delete(t),e.set(t.parent,n)}for(let[t,n]of e)t._removeChildrenArray(n);e.size&&this._removeEmptyElements()}};function Sd(e,t){let n=new Set,r=new Map,i=B._createIn(e).getItems();for(let e of i)e.is(`element`,`$marker`)&&n.add(e);for(let e of n){let n=e.getAttribute(`data-name`),i=t.createPositionBefore(e);r.has(n)?r.get(n).end=i.clone():r.set(n,new B(i.clone())),t.remove(e)}return r}function Cd(e,t){let n;for(let r of new td(e)){let e={};for(let t of r.getAttributeKeys())e[t]=r.getAttribute(t);let i=t.createElement(r.name,e);n&&t.insert(i,n),n=z._createAt(i,0)}return n}var wd=class{getHtml(e){let t=u.document.implementation.createHTMLDocument(``).createElement(`div`);return t.appendChild(e),t.innerHTML}},Td=class{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new _c(e,{renderingMode:`data`}),this.htmlWriter=new wd}toData(e){let t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){let t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e==`marked`?`markedNbsp`:`nbsp`}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`${e}`);let t=this.domParser.parseFromString(e,`text/html`),n=t.createDocumentFragment(),r=t.body.childNodes;for(;r.length>0;)n.appendChild(r[0]);return n}};const Kee=E();var Ed=class extends Kee{model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new ol,this.downcastDispatcher=new fl({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on(`insert:$text`,Ll(),{priority:`lowest`}),this.downcastDispatcher.on(`insert`,Rl(),{priority:`lowest`}),this.upcastDispatcher=new xd({schema:e.schema}),this.viewDocument=new Cs(t),this.stylesProcessor=t,this.htmlProcessor=new Td(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Rs(this.viewDocument),this.upcastDispatcher.on(`text`,Nu(),{priority:`lowest`}),this.upcastDispatcher.on(`element`,Mu(),{priority:`lowest`}),this.upcastDispatcher.on(`documentFragment`,Mu(),{priority:`lowest`}),D().prototype.decorate.call(this,`init`),D().prototype.decorate.call(this,`set`),D().prototype.decorate.call(this,`get`),D().prototype.decorate.call(this,`toView`),D().prototype.decorate.call(this,`toModel`),this.on(`init`,()=>{this.fire(`ready`)},{priority:`lowest`}),this.on(`ready`,()=>{this.model.enqueueChange({isUndoable:!1},Ou)},{priority:`lowest`})}get(e={}){let{rootName:t=`main`,trim:n=`empty`}=e;if(!this._checkIfRootsExists([t]))throw new w(`datacontroller-get-non-existent-root`,this);let r=this.model.document.getRoot(t);return r.isAttached()||T(`datacontroller-get-detached-root`,this),n===`empty`&&!this.model.hasContent(r,{ignoreWhitespaces:!0})?``:this.stringify(r,e)}stringify(e,t={}){let n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){let n=this.viewDocument,r=this._viewWriter;this.mapper.clearBindings();let i=B._createIn(e),a=new Is(n);this.mapper.bindElements(e,a);let o=e.is(`documentFragment`)?e.markers:qee(e);return this.downcastDispatcher.convert(i,o,r,t),a}init(e){if(this.model.document.version)throw new w(`datacontroller-init-document-not-empty`,this);let t={};if(typeof e==`string`?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new w(`datacontroller-init-non-existent-root`,this);return this.model.enqueueChange({isUndoable:!1},e=>{for(let n of Object.keys(t)){let r=this.model.document.getRoot(n);e.insert(this.parse(t[n],r),r,0)}}),Promise.resolve()}set(e,t={}){let n={};if(typeof e==`string`?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new w(`datacontroller-set-non-existent-root`,this);this.model.enqueueChange(t.batchType||{},e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(let t of Object.keys(n)){let r=this.model.document.getRoot(t);e.remove(e.createRangeIn(r)),e.insert(this.parse(n[t],r),r,0)}})}parse(e,t=`$root`){let n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t=`$root`){return this.model.change(n=>this.upcastDispatcher.convert(e,n,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(let t of e)if(!this.model.document.getRoot(t))return!1;return!0}};function qee(e){let t=[],n=e.root.document;if(!n)return new Map;let r=B._createIn(e);for(let e of n.model.markers){let n=e.getRange(),i=n.isCollapsed,a=n.start.isEqual(r.start)||n.end.isEqual(r.end);if(i&&a)t.push([e.name,n]);else{let i=r.getIntersection(n);i&&t.push([e.name,i])}}return new Map(t)}var Dd=class{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=A(e),this._createConversionHelpers({name:`downcast`,dispatchers:this._downcast,isDowncast:!0}),this._upcast=A(t),this._createConversionHelpers({name:`upcast`,dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){let n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new w(`conversion-add-alias-dispatcher-not-registered`,this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new w(`conversion-for-unknown-group`,this);return this._helpers.get(e)}elementToElement(e){this.for(`downcast`).elementToElement(e);for(let{model:t,view:n}of Od(e))this.for(`upcast`).elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for(`downcast`).attributeToElement(e);for(let{model:t,view:n}of Od(e))this.for(`upcast`).elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for(`downcast`).attributeToAttribute(e);for(let{model:t,view:n}of Od(e))this.for(`upcast`).attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new w(`conversion-group-exists`,this);let r=n?new Il(t):new ju(t);this._helpers.set(e,r)}};function*Od(e){if(e.model.values)for(let t of e.model.values){let n={key:e.model.key,value:t},r=e.view[t];yield*kd(n,r,e.upcastAlso?e.upcastAlso[t]:void 0)}else yield*kd(e.model,e.view,e.upcastAlso)}function*kd(e,t,n){if(yield{model:e,view:t},n)for(let t of A(n))yield{model:e,view:t}}var Ad=class{namespaces;domParser;domConverter;htmlWriter;skipComments=!0;constructor(e,t={}){this.namespaces=t.namespaces||[],this.domParser=new DOMParser,this.domConverter=new _c(e,{renderingMode:`data`}),this.htmlWriter=new wd}toData(e){let t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){let t=this._toDom(e);return this.domConverter.domToView(t,{keepOriginalCase:!0,skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e==`marked`?`markedNbsp`:`nbsp`}_toDom(e){e=``xmlns:${e}="nsp"`).join(` `)}>${e}`;let t=this.domParser.parseFromString(e,`text/xml`),n=t.querySelector(`parsererror`);if(n)throw Error(`Parse error - `+n.textContent);let r=t.createDocumentFragment(),i=t.documentElement.childNodes;for(;i.length>0;)r.appendChild(i[0]);return r}},jd=class{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=this.baseVersion!==null,this.batch=null}_validate(){}toJSON(){let 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 Md(e,t){let n=Id(t),r=n.reduce((e,t)=>e+t.offsetSize,0),i=e.parent;Rd(e);let a=e.index;return i._insertChild(a,n),Ld(i,a+n.length),Ld(i,a),new B(e,e.getShiftedBy(r))}function Nd(e){if(!e.isFlat)throw new w(`operation-utils-remove-range-not-flat`,this);let t=e.start.parent;Rd(e.start),Rd(e.end);let n=t._removeChildren(e.start.index,e.end.index-e.start.index);return Ld(t,e.start.index),n}function Pd(e,t){if(!e.isFlat)throw new w(`operation-utils-move-range-not-flat`,this);let n=Nd(e);return t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),Md(t,n)}function Fd(e,t,n){Rd(e.start),Rd(e.end);for(let r of e.getItems({shallow:!0})){let e=r.is(`$textProxy`)?r.textNode:r;n===null?e._removeAttribute(t):e._setAttribute(t,n),Ld(e.parent,e.index)}Ld(e.end.parent,e.end.index)}function Id(e){let t=[];function n(e){if(typeof e==`string`)t.push(new Sl(e));else if(e instanceof Yc)t.push(new Sl(e.data,e.getAttributes()));else if(e instanceof gl)t.push(e);else if(pr(e))for(let t of e)n(t)}n(e);for(let e=1;ee.maxOffset)throw new w(`move-operation-nodes-do-not-exist`,this);if(e===t&&n=n&&this.targetPosition.path[e]e._clone(!0))),n=new e(this.position,t,this.baseVersion);return n.shouldReceiveAttributes=this.shouldReceiveAttributes,n}getReversed(){let e=this.position.root.document.graveyard,t=new z(e,[0]);return new Bd(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){let e=this.position.parent;if(!e||e.maxOffsete._clone(!0))),Md(this.position,e)}toJSON(){let e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return`InsertOperation`}static fromJSON(t,n){let r=[];for(let e of t.nodes)e.name?r.push(Ml.fromJSON(e)):r.push(Sl.fromJSON(e));let i=new e(z.fromJSON(t.position,n),r,t.baseVersion);return i.shouldReceiveAttributes=t.shouldReceiveAttributes,i}},Hd=class e extends jd{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,n,r,i){super(i),this.splitPosition=e.clone(),this.splitPosition.stickiness=`toNext`,this.howMany=t,this.insertionPosition=n,this.graveyardPosition=r?r.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness=`toNext`)}get type(){return`split`}get moveTargetPosition(){let e=this.insertionPosition.path.slice();return e.push(0),new z(this.insertionPosition.root,e)}get movedRange(){let e=this.splitPosition.getShiftedBy(1/0);return new B(this.splitPosition,e)}get affectedSelectable(){let e=[B._createFromPositionAndShift(this.splitPosition,0),B._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(B._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new e(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){let e=this.splitPosition.root.document.graveyard,t=new z(e,[0]);return new Ud(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){let e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset1&&e.sourcePosition.isEqual(t.deletionPosition)?this._setRelation(e,t,`firstToMoveMerged`):e.howMany>1&&e.sourcePosition.getShiftedBy(e.howMany-1).isEqual(t.deletionPosition)&&this._setRelation(e,t,`lastToMoveMerged`):t instanceof Bd&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,`insertBefore`):this._setRelation(e,t,`insertAfter`));else if(e instanceof Hd){if(t instanceof Ud)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,`splitBefore`);else if(t instanceof Bd)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,`splitBefore`);else{let n=B._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){let r=n.end.offset-e.splitPosition.offset,i=e.splitPosition.offset-n.start.offset;this._setRelation(e,t,{howMany:r,offset:i})}}}else if(e instanceof Ud)t instanceof Ud?(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 Hd?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,`splitAtSource`):t instanceof Bd&&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 Wd){let n=e.newRange;if(!n)return;if(t instanceof Ud){let r=n.start.isEqual(t.targetPosition),i=n.start.isEqual(t.deletionPosition),a=n.end.isEqual(t.deletionPosition),o=n.end.isEqual(t.sourcePosition);(r||i||a||o)&&this._setRelation(e,t,{wasInLeftElement:r,wasStartBeforeMergedElement:i,wasEndBeforeMergedElement:a,wasInRightElement:o})}}}getContext(e,t,n){return{aIsStrong:n,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){let t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){let n=this.originalOperations.get(t),r=this._history.getUndoneOperation(n);if(!r)return null;let i=this.originalOperations.get(e),a=this._relations.get(i);return a&&a.get(r)||null}_setRelation(e,t,n){let r=this.originalOperations.get(e),i=this.originalOperations.get(t),a=this._relations.get(r);a||(a=new Map,this._relations.set(r,a)),a.set(i,n)}};function af(e,t){for(let n of e)n.baseVersion=t++}function of(e,t){for(let n=0;n{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){let r=e.range.getDifference(t.range).map(t=>new Gd(t,e.key,e.oldValue,e.newValue,0)),i=e.range.getIntersection(t.range);return i&&n.aIsStrong&&r.push(new Gd(i,t.key,t.newValue,e.newValue,0)),r.length==0?[new Kd(0)]:r}else return[e]}),V(Gd,Vd,(e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){let n=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map(t=>new Gd(t,e.key,e.oldValue,e.newValue,e.baseVersion));if(t.shouldReceiveAttributes){let r=cf(t,e.key,e.oldValue);r&&n.unshift(r)}return n}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]});function cf(e,t,n){let r=e.nodes.getNode(0).getAttribute(t);return r==n?null:new Gd(new B(e.position,e.position.getShiftedBy(e.howMany)),t,r,n,0)}V(Gd,Ud,(e,t)=>{let n=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&n.push(B._createFromPositionAndShift(t.graveyardPosition,1));let r=e.range._getTransformedByMergeOperation(t);return r.isCollapsed||n.push(r),n.map(t=>new Gd(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),V(Gd,Bd,(e,t)=>lf(e.range,t).map(t=>new Gd(t,e.key,e.oldValue,e.newValue,e.baseVersion)));function lf(e,t){let n=B._createFromPositionAndShift(t.sourcePosition,t.howMany),r=null,i=[];n.containsRange(e,!0)?r=e:e.start.hasSameParentAs(n.start)?(i=e.getDifference(n),r=e.getIntersection(n)):i=[e];let a=[];for(let e of i){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);let n=t.getMovedRangeStart(),r=e.start.hasSameParentAs(n),i=e._getTransformedByInsertion(n,t.howMany,r);a.push(...i)}return r&&a.push(r._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]),a}V(Gd,Hd,(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)){let n=e.clone();return n.range=new B(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness=`toPrevious`,[e,n]}return e.range=e.range._getTransformedBySplitOperation(t),[e]}),V(Vd,Gd,(e,t)=>{let n=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){let r=cf(e,t.key,t.newValue);r&&n.push(r)}return n}),V(Vd,Vd,(e,t,n)=>(e.position.isEqual(t.position)&&n.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e])),V(Vd,Bd,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),V(Vd,Hd,(e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e])),V(Vd,Ud,(e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e])),V(Wd,Vd,(e,t)=>(e.oldRange&&=e.oldRange._getTransformedByInsertOperation(t)[0],e.newRange&&=e.newRange._getTransformedByInsertOperation(t)[0],[e])),V(Wd,Wd,(e,t,n)=>{if(e.name==t.name)if(n.aIsStrong)e.oldRange=t.newRange?t.newRange.clone():null;else return[new Kd(0)];return[e]}),V(Wd,Ud,(e,t)=>(e.oldRange&&=e.oldRange._getTransformedByMergeOperation(t),e.newRange&&=e.newRange._getTransformedByMergeOperation(t),[e])),V(Wd,Bd,(e,t)=>{let n=[e];if(e.oldRange&&=B._createFromRanges(e.oldRange._getTransformedByMoveOperation(t)),e.newRange){let r=e.newRange._getTransformedByMoveOperation(t);e.newRange=r[0];for(let t=1;t{if(e.oldRange&&=e.oldRange._getTransformedBySplitOperation(t),e.newRange){if(n.abRelation){let r=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)?n.abRelation.wasStartBeforeMergedElement?e.newRange.start=z._createAt(t.insertionPosition):n.abRelation.wasInLeftElement?e.newRange.start=z._createAt(e.newRange.start):e.newRange.start=z._createAt(t.moveTargetPosition):e.newRange.start=r.start,e.newRange.end.isEqual(t.splitPosition)?e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?e.newRange.end=z._createAt(t.insertionPosition):n.abRelation.wasInRightElement?e.newRange.end=z._createAt(t.moveTargetPosition):e.newRange.end=z._createAt(e.newRange.end):e.newRange.end=r.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]}),V(Ud,Vd,(e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e])),V(Ud,Ud,(e,t,n)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition))if(n.bWasUndone){let n=t.graveyardPosition.path.slice();return n.push(0),e.sourcePosition=new z(t.graveyardPosition.root,n),e.howMany=0,[e]}else return[new Kd(0)];if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!n.bWasUndone&&n.abRelation!=`splitAtSource`){let r=e.targetPosition.root.rootName==`$graveyard`,i=t.targetPosition.root.rootName==`$graveyard`;if(i&&!r||!(r&&!i)&&n.aIsStrong){let n=t.targetPosition._getTransformedByMergeOperation(t),r=e.targetPosition._getTransformedByMergeOperation(t);return[new Bd(n,e.howMany,r,0)]}else return[new Kd(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)||!n.aIsStrong)&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),V(Ud,Bd,(e,t,n)=>{let r=B._createFromPositionAndShift(t.sourcePosition,t.howMany);return t.type==`remove`&&!n.bWasUndone&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&r.containsPosition(e.sourcePosition)?[new Kd(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness=`toNone`:t.targetPosition.isEqual(e.sourcePosition)&&n.abRelation==`mergeSourceAffected`?e.sourcePosition.stickiness=`toNext`:t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness=`toNone`,e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&n.abRelation==`mergeTargetWasBefore`?(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])}),V(Ud,Hd,(e,t,n)=>{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)&&(t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition)||n.abRelation==`mergeTargetNotMoved`))return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e];if(e.sourcePosition.isEqual(t.splitPosition)){if(n.abRelation==`mergeSourceNotMoved`)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if(n.abRelation==`mergeSameElement`||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]}),V(Bd,Vd,(e,t)=>{let n=B._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]}),V(Bd,Bd,(e,t,n)=>{let r=B._createFromPositionAndShift(e.sourcePosition,e.howMany),i=B._createFromPositionAndShift(t.sourcePosition,t.howMany),a=n.aIsStrong,o=!n.aIsStrong;n.abRelation==`insertBefore`||n.baRelation==`insertAfter`?o=!0:(n.abRelation==`insertAfter`||n.baRelation==`insertBefore`)&&(o=!1);let s;if(s=e.targetPosition.isEqual(t.targetPosition)&&o?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),uf(e,t)&&uf(t,e))return[t.getReversed()];if(r.containsPosition(t.targetPosition)&&r.containsRange(i,!0))return r.start=r.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),r.end=r.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),df([r],s);if(i.containsPosition(e.targetPosition)&&i.containsRange(r,!0))return r.start=r.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),r.end=r.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),df([r],s);let c=fr(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if(c==`prefix`||c==`extension`)return r.start=r.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),r.end=r.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),df([r],s);e.type==`remove`&&t.type!=`remove`&&!n.aWasUndone&&!n.forceWeakRemove?a=!0:e.type!=`remove`&&t.type==`remove`&&!n.bWasUndone&&!n.forceWeakRemove&&(a=!1);let l=[],u=r.getDifference(i);for(let e of u){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);let n=fr(e.start.getParentPath(),t.getMovedRangeStart().getParentPath())==`same`,r=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,n);l.push(...r)}let d=r.getIntersection(i);return d!==null&&a&&(d.start=d.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),d.end=d.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),l.length===0?l.push(d):l.length==1?i.start.isBefore(r.start)||i.start.isEqual(r.start)?l.unshift(d):l.push(d):l.splice(1,0,d)),l.length===0?[new Kd(e.baseVersion)]:df(l,s)}),V(Bd,Hd,(e,t,n)=>{let r=e.targetPosition.clone();if((!e.targetPosition.isEqual(t.insertionPosition)||!t.graveyardPosition||n.abRelation==`moveTargetAfter`)&&(r=e.targetPosition._getTransformedBySplitOperation(t)),e.sourcePosition.isEqual(t.insertionPosition)&&n.abRelation==`firstToMoveMerged`)return e.howMany++,e.targetPosition=r,[e];let i=B._createFromPositionAndShift(e.sourcePosition,e.howMany);if(i.end.isEqual(t.insertionPosition))return(!t.graveyardPosition||n.abRelation==`lastToMoveMerged`)&&e.howMany++,e.targetPosition=r,[e];if(i.start.hasSameParentAs(t.splitPosition)&&i.containsPosition(t.splitPosition)){let e=new B(t.splitPosition,i.end);return e=e._getTransformedBySplitOperation(t),df([new B(i.start,t.splitPosition),e],r)}e.targetPosition.isEqual(t.splitPosition)&&n.abRelation==`insertAtSource`&&(r=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&n.abRelation==`insertBetween`&&(r=e.targetPosition);let a=[i._getTransformedBySplitOperation(t)];if(t.graveyardPosition){let r=i.start.isEqual(t.graveyardPosition)||i.containsPosition(t.graveyardPosition);e.howMany>1&&r&&!n.aWasUndone&&a.push(B._createFromPositionAndShift(t.insertionPosition,1))}return df(a,r)}),V(Bd,Ud,(e,t,n)=>{let r=B._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&r.containsPosition(t.sourcePosition)){if(e.type==`remove`&&!n.forceWeakRemove){if(!n.aWasUndone){let n=[],r=t.graveyardPosition.clone(),i=t.targetPosition._getTransformedByMergeOperation(t),a=e.targetPosition.getTransformedByOperation(t);e.howMany>1&&(n.push(new Bd(e.sourcePosition,e.howMany-1,a,0)),r=r._getTransformedByMove(e.sourcePosition,a,e.howMany-1),i=i._getTransformedByMove(e.sourcePosition,a,e.howMany-1));let o=t.deletionPosition._getCombined(e.sourcePosition,a),s=new Bd(r,1,o,0),c=s.getMovedRangeStart().path.slice();c.push(0);let l=new z(s.targetPosition.root,c);i=i._getTransformedByMove(r,o,1);let u=new Bd(i,t.howMany,l,0);return n.push(s),n.push(u),n}}else if(e.howMany==1)return n.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new Kd(0)]}let i=B._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]}),V(qd,Vd,(e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e])),V(qd,Ud,(e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness=`toNext`,[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e])),V(qd,Bd,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),V(qd,qd,(e,t,n)=>{if(e.position.isEqual(t.position))if(n.aIsStrong)e.oldName=t.newName;else return[new Kd(0)];return[e]}),V(qd,Hd,(e,t)=>{let n=e.position.path;return fr(n,t.splitPosition.getParentPath())==`same`&&!t.graveyardPosition?[e,new qd(e.position.getShiftedBy(1),e.oldName,e.newName,0)]:(e.position=e.position._getTransformedBySplitOperation(t),[e])}),V(Jd,Jd,(e,t,n)=>{if(e.root===t.root&&e.key===t.key)if(n.aIsStrong)e.oldValue=t.newValue;else return[new Kd(0)];return[e]}),V(Yd,Yd,(e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new Kd(0)]:[e]),V(Hd,Vd,(e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!n.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){let n=t.graveyardPosition.path.slice();n.push(0);let r=new Hd(new z(t.graveyardPosition.root,n),0,Hd.getInsertionPosition(new z(t.graveyardPosition.root,n)),null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Hd.getInsertionPosition(e.splitPosition),e.graveyardPosition=r.insertionPosition.clone(),e.graveyardPosition.stickiness=`toNext`,[r,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=Hd.getInsertionPosition(e.splitPosition),e.graveyardPosition&&=e.graveyardPosition._getTransformedByMergeOperation(t),[e]}),V(Hd,Bd,(e,t,n)=>{let r=B._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){let i=r.start.isEqual(e.graveyardPosition)||r.containsPosition(e.graveyardPosition);if(!n.bWasUndone&&i){let n=e.splitPosition._getTransformedByMoveOperation(t),r=e.graveyardPosition._getTransformedByMoveOperation(t),i=r.path.slice();i.push(0);let a=new z(r.root,i);return[new Bd(n,e.howMany,a,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}let i=e.splitPosition.isEqual(t.targetPosition);if(i&&(n.baRelation==`insertAtSource`||n.abRelation==`splitBefore`))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Hd.getInsertionPosition(e.splitPosition),[e];if(i&&n.abRelation&&n.abRelation.howMany){let{howMany:t,offset:r}=n.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(r),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&r.containsPosition(e.splitPosition)){let n=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=n,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition||e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new Kd(0)];if(n.abRelation==`splitBefore`)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){let r=e.splitPosition.root.rootName==`$graveyard`,i=t.splitPosition.root.rootName==`$graveyard`;if(i&&!r||!(r&&!i)&&n.aIsStrong){let n=[];return t.howMany&&n.push(new Bd(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&n.push(new Bd(e.splitPosition,e.howMany,e.moveTargetPosition,0)),n}else return[new Kd(0)]}if(e.graveyardPosition&&=e.graveyardPosition._getTransformedBySplitOperation(t),e.splitPosition.isEqual(t.insertionPosition)&&n.abRelation==`splitBefore`)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&n.baRelation==`splitBefore`){let n=t.insertionPosition.path.slice();n.push(0);let r=new z(t.insertionPosition.root,n);return[e,new Bd(e.insertionPosition,1,r,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{let n=t[0];n.isDocumentOperation&&hf.call(this,n)},{priority:`low`})}function hf(e){let t=this.getTransformedByOperation(e);if(!this.isEqual(t)){let e=this.toPosition();this.path=t.path,this.root=t.root,this.fire(`change`,e)}}var gf=class{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){typeof e==`string`&&(e=e===`transparent`?{isUndoable:!1}:{},T(`batch-constructor-deprecated-string-type`));let{isUndoable:t=!0,isLocal:n=!0,isUndo:r=!1,isTyping:i=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=r,this.isTyping=i}get baseVersion(){for(let e of this.operations)if(e.baseVersion!==null)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}},_f=class e{static _statesPriority=[void 0,`refresh`,`rename`,`move`];_markerCollection;_changesInElement=new Map;_elementsSnapshots=new Map;_elementChildrenSnapshots=new Map;_elementState=new Map;_changedMarkers=new Map;_changedRoots=new Map;_changeCount=0;_cachedChanges=null;_cachedChangesWithGraveyard=null;_refreshedItems=new Set;constructor(e){this._markerCollection=e}get isEmpty(){return this._changesInElement.size==0&&this._changedMarkers.size==0&&this._changedRoots.size==0}bufferOperation(e){let 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(let 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;let e=this._isInInsertedElement(t.sourcePosition.parent),n=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),n||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);let r=B._createFromPositionAndShift(t.sourcePosition,t.howMany);for(let e of r.getItems({shallow:!0}))this._setElementState(e,`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);let e=B._createFromPositionAndShift(t.position,1);for(let t of this._markerCollection.getMarkersIntersectingRange(e)){let e=t.getData();this.bufferMarkerChange(t.name,e,e)}this._setElementState(t.position.nodeAfter,`rename`);break}case`split`:{let e=t.splitPosition.parent;if(!this._isInInsertedElement(e)){this._markRemove(e,t.splitPosition.offset,t.howMany);let n=B._createFromPositionAndShift(t.splitPosition,t.howMany);for(let e of n.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`:{let e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);let n=t.graveyardPosition.parent;this._markInsert(n,t.graveyardPosition.offset,1),this._setElementState(e,`move`);let r=t.targetPosition.parent;if(!this._isInInsertedElement(r)){this._markInsert(r,t.targetPosition.offset,e.maxOffset);let n=B._createFromPositionAndShift(t.sourcePosition,t.howMany);for(let e of n.getItems({shallow:!0}))this._setElementState(e,`move`)}break}case`detachRoot`:case`addRoot`:{let e=t.affectedSelectable;if(!e._isLoaded||e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case`addRootAttribute`:case`removeRootAttribute`:case`changeRootAttribute`:{if(!t.root._isLoaded)return;let e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){t.range&&t.range.root.is(`rootElement`)&&!t.range.root._isLoaded&&(t.range=null),n.range&&n.range.root.is(`rootElement`)&&!n.range.root._isLoaded&&(n.range=null);let r=this._changedMarkers.get(e);r?r.newMarkerData=n:(r={newMarkerData:n,oldMarkerData:t},this._changedMarkers.set(e,r)),r.oldMarkerData.range==null&&n.range==null&&this._changedMarkers.delete(e)}getMarkersToRemove(){let e=[];for(let[t,n]of this._changedMarkers)n.oldMarkerData.range!=null&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){let e=[];for(let[t,n]of this._changedMarkers)n.newMarkerData.range!=null&&e.push({name:t,range:n.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(let{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){let n=e.range&&!t.range,r=!e.range&&t.range,i=e.range&&t.range&&!e.range.isEqual(t.range);if(n||r||i)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(let e of this._changesInElement.keys()){let n=this._changesInElement.get(e).sort((e,t)=>e.offset===t.offset?e.type==t.type?0:e.type==`remove`?-1:1:e.offsete.position.root==t.position.root?e.position.isEqual(t.position)?e.changeCount-t.changeCount:e.position.isBefore(t.position)?-1:1:e.position.root.rootNamee);for(let e of t)delete e.changeCount,e.type==`attribute`&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(xf),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{let t={...e};return t.state!==void 0&&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`);let t=B._createOn(e);for(let e of this._markerCollection.getMarkersIntersectingRange(t)){let t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(let t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(let t of this._markerCollection)if(t.getRange().root==e){let e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e)){this._changedRoots.set(e,{name:e,state:t?`attached`:`detached`});return}let n=this._changedRoots.get(e);n.state===void 0?n.state=t?`attached`:`detached`:(delete n.state,n.attributes===void 0&&this._changedRoots.delete(e))}_bufferRootAttributeChange(e,t,n,r){let i=this._changedRoots.get(e)||{name:e},a=i.attributes||{};if(a[t]){let e=a[t];r===e.oldValue?delete a[t]:e.newValue=r}else a[t]={oldValue:n,newValue:r};Object.entries(a).length===0?(delete i.attributes,i.state===void 0&&this._changedRoots.delete(e)):(i.attributes=a,this._changedRoots.set(e,i))}_markInsert(e,t,n){if(e.root.is(`rootElement`)&&!e.root._isLoaded)return;let r={type:`insert`,offset:t,howMany:n,count:this._changeCount++};this._markChange(e,r)}_markRemove(e,t,n){if(e.root.is(`rootElement`)&&!e.root._isLoaded)return;let r={type:`remove`,offset:t,howMany:n,count:this._changeCount++};this._markChange(e,r),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){if(e.root.is(`rootElement`)&&!e.root._isLoaded)return;let t={type:`attribute`,offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);let n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let e=0;er&&this._elementState.set(t,n)}_getDiffActionForNode(e,t){if(!e.is(`element`)||!this._elementsSnapshots.has(e))return t;let n=this._elementState.get(e);return!n||n==`move`?t:n}_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;let t=yf(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(let e of t)this._elementsSnapshots.set(e.node,e)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(let n of t){let r=e.offset+e.howMany,i=n.offset+n.howMany;if(e.type==`insert`&&(n.type==`insert`&&(e.offset<=n.offset?n.offset+=e.howMany:e.offsetn.offset){if(r>i){let e={type:`attribute`,offset:i,howMany:r-i,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offseti?(e.nodesToHandle=r-i,e.offset=i):e.nodesToHandle=0);if(n.type==`remove`&&e.offsetn.offset){let i={type:`attribute`,offset:n.offset,howMany:r-n.offset,count:this._changeCount++};this._handleChange(i,t),t.push(i),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}n.type==`attribute`&&(e.offset>=n.offset&&r<=i?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&r>=i&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n,r,i){let a={type:`insert`,position:z._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++,action:n};return n!=`insert`&&i&&(a.before={name:i.name,attributes:new Map(i.attributes)}),a}_getRemoveDiff(e,t,n,r){return{type:`remove`,action:n,position:z._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){let r=[];n=new Map(n);for(let[i,a]of t){let t=n.has(i)?n.get(i):null;t!==a&&r.push({type:`attribute`,position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:a,attributeNewValue:t,changeCount:this._changeCount++}),n.delete(i)}for(let[t,i]of n)r.push({type:`attribute`,position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:i,changeCount:this._changeCount++});return r}_isInInsertedElement(e){let t=e.parent;if(!t)return!1;let n=this._changesInElement.get(t),r=e.startOffset;if(n){for(let e of n)if(e.type==`insert`&&r>=e.offset&&rr){for(let t=0;t1500)for(let t=0;tthis._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 w(`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,t=this.version){if(!this._operations.length)return[];let n=this._operations[0];e===void 0&&(e=n.baseVersion);let r=t-1;for(let[t,n]of this._gaps)e>t&&et&&rthis.lastOperation.baseVersion)return[];let i=this._baseVersionToOperationIndex.get(e);i===void 0&&(i=0);let a=this._baseVersionToOperationIndex.get(r);return a===void 0&&(a=this._operations.length-1),this._operations.slice(i,a+1)}getOperation(e){let t=this._baseVersionToOperationIndex.get(e);if(t!==void 0)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}},Cf=class extends Ml{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,n=`main`){super(t),this._document=e,this.rootName=n}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}};Cf.prototype.is=function(e,t){return t?t===this.name&&(e===`rootElement`||e===`model:rootElement`||e===`element`||e===`model:element`):e===`rootElement`||e===`model:rootElement`||e===`element`||e===`model:element`||e===`node`||e===`model:node`};const wf=`$graveyard`,Tf=E();var Ef=class extends Tf{model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new Sf,this.selection=new Tl(this),this.roots=new Fi({idProperty:`rootName`}),this.differ=new _f(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot(`$root`,wf),this.listenTo(e,`applyOperation`,(e,t)=>{let n=t[0];n.isDocumentOperation&&this.differ.bufferOperation(n)},{priority:`high`}),this.listenTo(e,`applyOperation`,(e,t)=>{let n=t[0];n.isDocumentOperation&&this.history.addOperation(n)},{priority:`low`}),this.listenTo(this.selection,`change`,()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,`update`,(e,t,n,r,i)=>{let a={...t.getData(),range:r};this.differ.bufferMarkerChange(t.name,i,a),n===null&&t.on(`change`,(e,n)=>{let r=t.getData();this.differ.bufferMarkerChange(t.name,{...r,range:n},r)})}),this.registerPostFixer(e=>{let t=!1;for(let n of this.roots)!n.isAttached()&&!n.isEmpty&&(e.remove(e.createRangeIn(n)),t=!0);for(let n of this.model.markers)n.getRange().root.isAttached()||(e.removeMarker(n),t=!0);return t})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(wf)}createRoot(e=`$root`,t=`main`){if(this.roots.get(t))throw new w(`model-document-createroot-name-exists`,this,{name:t});let n=new Cf(this,e,t);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e=`main`){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(e=>e.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){let e=see(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(){let e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){let e=this._getDefaultRoot(),t=this.model,n=t.schema,r=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(r)||t.createRange(r)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&Df(e.start)&&Df(e.end)}_callPostFixers(e){let t=!1;do for(let n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break;while(t)}};function Df(e){let t=e.textNode;if(t){let n=t.data,r=e.offset-t.startOffset;return!ra(n,r)&&!ia(n,r)}return!0}const Of=E(),kf=E(Jc);var Af=class extends Of{_markers=new Map;[Symbol.iterator](){return this._markers.values()}has(e){let t=e instanceof jf?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,r=!1){let i=e instanceof jf?e.name:e;if(i.includes(`,`))throw new w(`markercollection-incorrect-marker-name`,this);let a=this._markers.get(i);if(a){let e=a.getData(),o=a.getRange(),s=!1;return o.isEqual(t)||(a._attachLiveRange(xl.fromRange(t)),s=!0),n!=a.managedUsingOperations&&(a._managedUsingOperations=n,s=!0),typeof r==`boolean`&&r!=a.affectsData&&(a._affectsData=r,s=!0),s&&this.fire(`update:${i}`,a,o,t,e),a}let o=new jf(i,xl.fromRange(t),n,r);return this._markers.set(i,o),this.fire(`update:${i}`,o,null,t,{...o.getData(),range:null}),o}_remove(e){let t=e instanceof jf?e.name:e,n=this._markers.get(t);return n?(this._markers.delete(t),this.fire(`update:${t}`,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0):!1}_refresh(e){let t=e instanceof jf?e.name:e,n=this._markers.get(t);if(!n)throw new w(`markercollection-refresh-marker-not-exists`,this);let r=n.getRange();this.fire(`update:${t}`,n,r,r,n.getData())}*getMarkersAtPosition(e){for(let t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(let t of this)t.getRange().getIntersection(e)!==null&&(yield t)}destroy(){for(let e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(let t of this._markers.values())t.name.startsWith(e+`:`)&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}},jf=class extends kf{name;_managedUsingOperations;_affectsData;_liveRange;constructor(e,t,n,r){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=r}get managedUsingOperations(){if(!this._liveRange)throw new w(`marker-destroyed`,this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new w(`marker-destroyed`,this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new w(`marker-destroyed`,this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new w(`marker-destroyed`,this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new w(`marker-destroyed`,this);return this._liveRange.toRange()}toJSON(){return{name:this.name,range:this._liveRange?.toJSON(),usingOperations:this._managedUsingOperations,affectsData:this._affectsData}}_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}};jf.prototype.is=function(e){return e===`marker`||e===`model:marker`};var Mf=class extends jd{sourcePosition;howMany;constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return`detach`}get affectedSelectable(){return null}toJSON(){let e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new w(`detach-operation-on-document-node`,this)}_execute(){Nd(B._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return`DetachOperation`}},Nf=class e extends Jc{markers=new Map;_children=new Al;constructor(e){super(),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 this.childCount===0}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(let n of e)t=t.getChildAtOffset(n);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){let e=[];for(let t of this._children)e.push(t.toJSON());return e}static fromJSON(t){let n=[];for(let e of t)e.name?n.push(Ml.fromJSON(e)):n.push(Sl.fromJSON(e));return new e(n)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){let n=Pf(t);for(let e of n)e.parent!==null&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){let n=this._children._removeNodes(e,t);for(let e of n)e.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(let t of e)t.parent=null}};Nf.prototype.is=function(e){return e===`documentFragment`||e===`model:documentFragment`};function Pf(e){return typeof e==`string`?[new Sl(e)]:(pr(e)||(e=[e]),Array.from(e).map(e=>typeof e==`string`?new Sl(e):e instanceof Yc?new Sl(e.data,e.getAttributes()):e))}var Ff=class{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Sl(e,t)}createElement(e,t){return new Ml(e,t)}createDocumentFragment(){return new Nf}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,n=0){if(this._assertWriterUsedCorrectly(),e instanceof Sl&&e.data==``)return;let r=z._createAt(t,n);if(e.parent)if(Bf(e.root,r.root)){this.move(B._createOn(e),r);return}else if(e.root.document)throw new w(`model-writer-insert-forbidden-move`,this);else this.remove(e);let i=r.root.document?r.root.document.version:null,a=new Vd(r,e instanceof Nf?e._removeChildren(0,e.childCount):e,i);if(e instanceof Sl&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),e instanceof Nf)for(let[t,n]of e.markers){let e=z._createAt(n.root,0),i={range:new B(n.start._getCombined(e,r),n.end._getCombined(e,r)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,i):this.addMarker(t,i)}}insertText(e,t,n,r){t instanceof Nf||t instanceof Ml||t instanceof z?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,r)}insertElement(e,t,n,r){t instanceof Nf||t instanceof Ml||t instanceof z?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,r)}append(e,t){this.insert(e,t,`end`)}appendText(e,t,n){t instanceof Nf||t instanceof Ml?this.insert(this.createText(e),t,`end`):this.insert(this.createText(e,t),n,`end`)}appendElement(e,t,n){t instanceof Nf||t instanceof Ml?this.insert(this.createElement(e),t,`end`):this.insert(this.createElement(e,t),n,`end`)}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof B){let r=n.getMinimalFlatRanges();for(let n of r)If(this,e,t,n)}else Lf(this,e,t,n)}setAttributes(e,t){for(let[n,r]of Ui(e))this.setAttribute(n,r,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof B){let n=t.getMinimalFlatRanges();for(let t of n)If(this,e,null,t)}else Lf(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();let t=e=>{for(let t of e.getAttributeKeys())this.removeAttribute(t,e)};if(!(e instanceof B))t(e);else for(let n of e.getItems())t(n)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof B))throw new w(`writer-move-invalid-range`,this);if(!e.isFlat)throw new w(`writer-move-range-not-flat`,this);let r=z._createAt(t,n);if(r.isEqual(e.start))return;if(this._addOperationForAffectedMarkers(`move`,e),!Bf(e.root,r.root))throw new w(`writer-move-different-document`,this);let i=e.root.document?e.root.document.version:null,a=new Bd(e.start,e.end.offset-e.start.offset,r,i);this.batch.addOperation(a),this.model.applyOperation(a)}remove(e){this._assertWriterUsedCorrectly();let t=(e instanceof B?e:B._createOn(e)).getMinimalFlatRanges().reverse();for(let e of t)this._addOperationForAffectedMarkers(`move`,e),zf(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();let t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers(`merge`,e),!(t instanceof Ml))throw new w(`writer-merge-no-element-before`,this);if(!(n instanceof Ml))throw new w(`writer-merge-no-element-after`,this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){let t=e.nodeBefore,n=e.nodeAfter;this.move(B._createIn(n),z._createAt(t,`end`)),this.remove(n)}_merge(e){let t=z._createAt(e.nodeBefore,`end`),n=z._createAt(e.nodeAfter,0),r=e.root.document.graveyard,i=new z(r,[0]),a=e.root.document.version,o=new Ud(n,e.nodeAfter.maxOffset,t,i,a);this.batch.addOperation(o),this.model.applyOperation(o)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Ml))throw new w(`writer-rename-not-element-instance`,this);let n=e.root.document?e.root.document.version:null,r=new qd(z._createBefore(e),e.name,t,n);this.batch.addOperation(r),this.model.applyOperation(r)}split(e,t){this._assertWriterUsedCorrectly();let n=e.parent;if(!n.parent)throw new w(`writer-split-element-no-parent`,this);if(t||=n.parent,!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new w(`writer-split-invalid-limit-element`,this);let r,i;do{let t=n.root.document?n.root.document.version:null,a=n.maxOffset-e.offset,o=Hd.getInsertionPosition(e),s=new Hd(e,a,o,null,t);this.batch.addOperation(s),this.model.applyOperation(s),!r&&!i&&(r=n,i=e.parent.nextSibling),e=this.createPositionAfter(e.parent),n=e.parent}while(n!==t);return{position:e,range:new B(z._createAt(r,`end`),z._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new w(`writer-wrap-range-not-flat`,this);let n=t instanceof Ml?t:new Ml(t);if(n.childCount>0)throw new w(`writer-wrap-element-not-empty`,this);if(n.parent!==null)throw new w(`writer-wrap-element-attached`,this);this.insert(n,e.start);let r=new B(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(r,z._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new w(`writer-unwrap-element-no-parent`,this);this.move(B._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!=`boolean`)throw new w(`writer-addmarker-no-usingoperation`,this);let n=t.usingOperation,r=t.range,i=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new w(`writer-addmarker-marker-exists`,this);if(!r)throw new w(`writer-addmarker-no-range`,this);return n?(Rf(this,e,null,r,i),this.model.markers.get(e)):this.model.markers._set(e,r,n,i)}updateMarker(e,t){this._assertWriterUsedCorrectly();let n=typeof e==`string`?e:e.name,r=this.model.markers.get(n);if(!r)throw new w(`writer-updatemarker-marker-not-exists`,this);if(!t){T(`writer-updatemarker-reconvert-using-editingcontroller`,{markerName:n}),this.model.markers._refresh(r);return}let i=typeof t.usingOperation==`boolean`,a=typeof t.affectsData==`boolean`,o=a?t.affectsData:r.affectsData;if(!i&&!t.range&&!a)throw new w(`writer-updatemarker-wrong-options`,this);let s=r.getRange(),c=t.range?t.range:s;if(i&&t.usingOperation!==r.managedUsingOperations){t.usingOperation?Rf(this,n,null,c,o):(Rf(this,n,s,null,o),this.model.markers._set(n,c,void 0,o));return}r.managedUsingOperations?Rf(this,n,s,c,o):this.model.markers._set(n,c,void 0,o)}removeMarker(e){this._assertWriterUsedCorrectly();let t=typeof e==`string`?e:e.name;if(!this.model.markers.has(t))throw new w(`writer-removemarker-no-marker`,this);let n=this.model.markers.get(t);if(!n.managedUsingOperations){this.model.markers._remove(t);return}let r=n.getRange();Rf(this,t,r,null,n.affectsData)}addRoot(e,t=`$root`){this._assertWriterUsedCorrectly();let n=this.model.document.getRoot(e);if(n&&n.isAttached())throw new w(`writer-addroot-root-exists`,this);let r=this.model.document,i=new Yd(e,t,!0,r,r.version);return this.batch.addOperation(i),this.model.applyOperation(i),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();let t=typeof e==`string`?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new w(`writer-detachroot-no-root`,this);for(let e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(let e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));let n=this.model.document,r=new Yd(t.rootName,t.name,!1,n,n.version);this.batch.addOperation(r),this.model.applyOperation(r)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),typeof e==`string`)this._setSelectionAttribute(e,t);else for(let[t,n]of Ui(e))this._setSelectionAttribute(t,n)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),typeof e==`string`)this._removeSelectionAttribute(e);else for(let t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){let n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){let r=Tl._getStoreAttributeKey(e);this.setAttribute(r,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){let t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){let n=Tl._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new w(`writer-incorrect-use`,this)}_addOperationForAffectedMarkers(e,t){for(let n of this.model.markers){if(!n.managedUsingOperations)continue;let r=n.getRange(),i=!1;if(e===`move`){let e=t;i=e.containsPosition(r.start)||e.start.isEqual(r.start)||e.containsPosition(r.end)||e.end.isEqual(r.end)}else{let e=t,n=e.nodeBefore,a=e.nodeAfter,o=r.start.parent==n&&r.start.isAtEnd,s=r.end.parent==a&&r.end.offset==0,c=r.end.nodeAfter==a,l=r.start.nodeAfter==a;i=o||s||c||l}i&&this.updateMarker(n.name,{range:r})}}};function If(e,t,n,r){let i=e.model,a=i.document,o=r.start,s,c,l;for(let e of r.getWalker({shallow:!0}))l=e.item.getAttribute(t),s&&c!=l&&(c!=n&&u(),o=s),s=e.nextPosition,c=l;s instanceof z&&s!=o&&c!=n&&u();function u(){let r=new B(o,s),l=r.root.document?a.version:null,u=new Gd(r,t,c,n,l);e.batch.addOperation(u),i.applyOperation(u)}}function Lf(e,t,n,r){let i=e.model,a=i.document,o=r.getAttribute(t),s,c;if(o!=n){if(r.root===r)c=new Jd(r,t,o,n,r.document?a.version:null);else{s=new B(z._createBefore(r),e.createPositionAfter(r));let i=s.root.document?a.version:null;c=new Gd(s,t,o,n,i)}e.batch.addOperation(c),i.applyOperation(c)}}function Rf(e,t,n,r,i){let a=e.model,o=a.document,s=new Wd(t,n,r,a.markers,!!i,o.version);e.batch.addOperation(s),a.applyOperation(s)}function zf(e,t,n,r){let i;if(e.root.document){let n=r.document;i=new Bd(e,t,new z(n.graveyard,[0]),n.version)}else i=new Mf(e,t);n.addOperation(i),r.applyOperation(i)}function Bf(e,t){return e===t||e instanceof Cf&&t instanceof Cf}function Vf(e){e.document.registerPostFixer(t=>Hf(t,e))}function Hf(e,t){let n=t.document.selection,r=t.schema,i=[],a=!1;for(let e of n.getRanges()){let t=Uf(e,r);t&&!t.isEqual(e)?(i.push(t),a=!0):i.push(e)}return a&&e.setSelection(Jf(i),{backward:n.isBackward}),!1}function Uf(e,t){return e.isCollapsed?Wf(e,t):Gf(e,t)}function Wf(e,t){let n=e.start,r=t.getNearestSelectionRange(n);if(!r){let e=n.getAncestors().reverse().find(e=>t.isObject(e));return e?B._createOn(e):null}if(!r.isCollapsed)return r;let i=r.start;return n.isEqual(i)?null:new B(i)}function Gf(e,t){let{start:n,end:r}=e,i=t.checkChild(n,`$text`),a=t.checkChild(r,`$text`),o=t.getLimitElement(n),s=t.getLimitElement(r);if(o===s){if(i&&a)return null;if(qf(n,r,t)){let e=n.nodeAfter&&t.isSelectable(n.nodeAfter)?null:t.getNearestSelectionRange(n,`forward`),i=r.nodeBefore&&t.isSelectable(r.nodeBefore)?null:t.getNearestSelectionRange(r,`backward`);return new B(e?e.start:n,i?i.end:r)}}let c=o&&!o.is(`rootElement`),l=s&&!s.is(`rootElement`);if(c||l){let e=n.nodeAfter&&r.nodeBefore&&n.nodeAfter.parent===r.nodeBefore.parent,i=c&&(!e||!Yf(n.nodeAfter,t)),a=l&&(!e||!Yf(r.nodeBefore,t)),u=n,d=r;return i&&(u=z._createBefore(Kf(o,t))),a&&(d=z._createAfter(Kf(s,t))),new B(u,d)}return null}function Kf(e,t){let n=e,r=n;for(;t.isLimit(r)&&r.parent;)n=r,r=r.parent;return n}function qf(e,t,n){let r=e.nodeAfter&&!n.isLimit(e.nodeAfter)||n.checkChild(e,`$text`),i=t.nodeBefore&&!n.isLimit(t.nodeBefore)||n.checkChild(t,`$text`);return r||i}function Jf(e){let t=[...e],n=new Set,r=1;for(;r!n.has(t))}function Yf(e,t){return e&&t.isSelectable(e)}function Xf(e,t,n={}){if(t.isCollapsed)return;let r=t.getFirstRange();if(r.root.rootName==`$graveyard`)return;let i=e.schema,a=e.document.selection,o=fp(t,a,r),s=Array.from(a.getAttributes()),c=!!a.getFirstRange()?.start.parent.isEmpty;e.change(e=>{if(!n.doNotResetEntireContent&&lp(i,t)){cp(e,t);return}let a={};if(!n.doNotAutoparagraph){let e=t.getSelectedElement();e&&Object.assign(a,i.getAttributesWithProperty(e,`copyOnReplace`,!0))}let l,u;n.doNotFixSelection?(l=pf.fromPosition(r.start,`toPrevious`),u=pf.fromPosition(r.end,`toNext`)):[l,u]=Zf(r),l.isTouching(u)||e.remove(e.createRange(l,u)),n.leaveUnmerged||($f(e,l,u),i.removeDisallowedAttributes(l.parent.getChildren(),e)),up(e,t,l),!n.doNotAutoparagraph&&ap(i,l)&&sp(e,l,t,a),o&&dp(e,s,c),l.detach(),u.detach()})}function Zf(e){let t=e.root.document.model,n=e.start,r=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){let n=Qf(r);if(n&&r.isTouching(t.createPositionAt(n,0))){let n=t.createSelection(e);t.modifySelection(n,{direction:`backward`});let i=n.getLastPosition(),a=t.createRange(i,r);t.hasContent(a,{ignoreMarkers:!0})||(r=i)}}return[pf.fromPosition(n,`toPrevious`),pf.fromPosition(r,`toNext`)]}function Qf(e){let t=e.parent,n=t.root.document.model.schema,r=t.getAncestors({parentFirst:!0,includeSelf:!0});for(let e of r){if(n.isLimit(e))return null;if(n.isBlock(e))return e}}function $f(e,t,n){let r=e.model;if(!rp(e.model.schema,t,n))return;let[i,a]=ip(t,n);!i||!a||(!r.hasContent(i,{ignoreMarkers:!0})&&r.hasContent(a,{ignoreMarkers:!0})?tp(e,t,n,i.parent):ep(e,t,n,i.parent))}function ep(e,t,n,r){let i=t.parent,a=n.parent;if(!(i==r||a==r)){for(t=e.createPositionAfter(i),n=e.createPositionBefore(a),n.isEqual(t)||e.insert(a,t),e.merge(t);n.parent.isEmpty;){let t=n.parent;n=e.createPositionBefore(t),e.remove(t)}rp(e.model.schema,t,n)&&ep(e,t,n,r)}}function tp(e,t,n,r){let i=t.parent,a=n.parent;if(!(i==r||a==r)){for(t=e.createPositionAfter(i),n=e.createPositionBefore(a),n.isEqual(t)||e.insert(i,n);t.parent.isEmpty;){let n=t.parent;t=e.createPositionBefore(n),e.remove(n)}n=e.createPositionBefore(a),np(e,n),rp(e.model.schema,t,n)&&tp(e,t,n,r)}}function np(e,t){let n=t.nodeBefore,r=t.nodeAfter;n.name!=r.name&&e.rename(n,r.name),e.clearAttributes(n),e.setAttributes(Object.fromEntries(r.getAttributes()),n),e.merge(t)}function rp(e,t,n){let r=t.parent,i=n.parent;return r==i||e.isLimit(r)||e.isLimit(i)?!1:op(t,n,e)}function ip(e,t){let n=e.getAncestors(),r=t.getAncestors(),i=0;for(;n[i]&&n[i]==r[i];)i++;return[n[i],r[i]]}function ap(e,t){let n=e.checkChild(t,`$text`),r=e.checkChild(t,`paragraph`);return!n&&r}function op(e,t,n){let r=new B(e,t);for(let e of r.getWalker())if(n.isLimit(e.item))return!1;return!0}function sp(e,t,n,r={}){let i=e.createElement(`paragraph`);e.model.schema.setAllowedAttributes(i,r,e),e.insert(i,t),up(e,n,e.createPositionAt(i,0))}function cp(e,t){let n=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(n)),sp(e,e.createPositionAt(n,0),t)}function lp(e,t){let n=e.getLimitElement(t);if(!t.containsEntireContent(n))return!1;let r=t.getFirstRange();return r.start.parent==r.end.parent?!1:e.checkChild(n,`paragraph`)}function up(e,t,n){t instanceof Tl?e.setSelection(n):t.setTo(n)}function dp(e,t,n){if(!t.length)return;let r=e.model.document.selection;if(r.anchor.parent.isEmpty&&!n)for(let[n,i]of t)e.model.schema.getAttributeProperties(n).isFormatting&&e.model.schema.checkAttributeInSelection(r,n)&&e.setSelectionAttribute(n,i)}function fp(e,t,n){if(e instanceof Tl)return!0;if(t.isCollapsed){let e=t.getFirstPosition();return e.isEqual(n.start)||e.isEqual(n.end)}return!!t.getFirstRange()?.isIntersecting(n)}function pp(e,t){return e.change(e=>{let n=e.createDocumentFragment(),r=t.getFirstRange();if(!r||r.isCollapsed)return n;let i=r.start.root,a=r.start.getCommonPath(r.end),o=i.getNodeByPath(a),s;s=r.start.parent==r.end.parent?r:e.createRange(e.createPositionAt(o,r.start.path[a.length]),e.createPositionAt(o,r.end.path[a.length]+1));let c=s.end.offset-s.start.offset;for(let t of s.getItems({shallow:!0}))t.is(`$textProxy`)?e.appendText(t.data,t.getAttributes(),n):e.append(e.cloneElement(t,!0),n);if(s!=r){let t=r._getTransformedByMove(s.start,e.createPositionAt(n,0),c)[0],i=e.createRange(e.createPositionAt(n,0),t.start);mp(e.createRange(t.end,e.createPositionAt(n,`end`)),e),mp(i,e)}return n})}function mp(e,t){let n=[];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=>{n.push(e.start.parent),t.remove(e)}),n.forEach(e=>{let n=e;for(;n.parent&&n.isEmpty;){let e=t.createRangeOn(n);n=n.parent,t.remove(e)}})}function hp(e,t,n){return e.change(r=>{let i=n||e.document.selection;i.isCollapsed||e.deleteContent(i,{doNotAutoparagraph:!0});let a=new gp(e,r,i.anchor),o=[],s;if(t.is(`documentFragment`)){if(t.markers.size){let e=[];for(let[n,r]of t.markers){let{start:t,end:i}=r,a=t.isEqual(i);e.push({position:t,name:n,isCollapsed:a},{position:i,name:n,isCollapsed:a})}e.sort(({position:e},{position:t})=>e.isBefore(t)?1:-1);for(let{position:n,name:i,isCollapsed:a}of e){let e=null,s=null,c=n.parent===t&&n.isAtStart,l=n.parent===t&&n.isAtEnd;!c&&!l?(e=r.createElement(`$marker`),r.insert(e,n)):a&&(s=c?`start`:`end`),o.push({name:i,element:e,collapsed:s})}}s=t.getChildren()}else s=[t];a.handleNodes(s);let c=a.getSelectionRange();if(t.is(`documentFragment`)&&o.length){let e=c?xl.fromRange(c):null,t={};for(let e=o.length-1;e>=0;e--){let{name:n,element:i,collapsed:s}=o[e],c=!t[n];if(c&&(t[n]=[]),i){let e=r.createPositionAt(i,`before`);t[n].push(e),r.remove(i)}else{let e=a.getAffectedRange();if(!e){s&&t[n].push(a.position);continue}s?t[n].push(e[s]):t[n].push(c?e.start:e.end)}}for(let[e,[n,i]]of Object.entries(t))n&&i&&n.root===i.root&&n.root.document&&!r.model.markers.has(e)&&r.addMarker(e,{usingOperation:!0,affectsData:!0,range:new B(n,i)});e&&(c=e.toRange(),e.detach())}c&&(i instanceof Tl?r.setSelection(c):i.setTo(c));let l=a.getAffectedRange()||e.createRange(i.anchor);return a.destroy(),l})}var gp=class{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesAndChildrenOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,n){this.model=e,this.writer=t,this.position=n,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(let t of Array.from(e))t.offsetSize>0&&this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesAndChildrenOf,this.writer),this.model._config?.get(`experimentalFlags.modelInsertContentDeepSchemaVerification`)!==!1&&this._removeDisallowedChildren(this._filterAttributesAndChildrenOf),this._filterAttributesAndChildrenOf=[]}_removeDisallowedChildren(e){let t=Array.from(e);for(let e of t){if(!e.is(`element`))continue;let n=[],r=[],i=this.writer.createRangeIn(e).getWalker({ignoreElementEnd:!0});for(let{item:e}of i){let a=e.parent;this.schema.checkChild(a,e)||(e.is(`element`)&&!this.schema.isObject(e)?(r.push(e),t.push(a)):n.push(e),i.jumpTo(this.writer.createPositionAfter(e)))}for(let e of r)this.writer.unwrap(e);for(let e of n)this.writer.remove(e)}}_updateLastNodeFromAutoParagraph(e){let t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new w(`insertcontent-invalid-insertion-position`,this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?B._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new B(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(!this._checkAndSplitToAllowedPosition(e)){this.schema.isObject(e)||this._handleDisallowedNode(e);return}e=this._appendToFragment(e),this._firstNode||=e,this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;let e=pf.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 w(`insertcontent-wrong-position`,this,{node:e,position:this.position});return this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),e.parent||(e=this._documentFragmentPosition.nodeBefore),this.schema.isObject(e)&&!this.schema.checkChild(this.position,`$text`)?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesAndChildrenOf.push(e),e}_setAffectedBoundaries(e){this._affectedStart||=pf.fromPosition(e,`toPrevious`),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=pf.fromPosition(e,`toNext`))}_mergeOnLeft(){let e=this._firstNode;if(!(e instanceof Ml)||!this._canMergeLeft(e))return;let t=pf._createBefore(e);t.stickiness=`toNext`;let n=pf.fromPosition(this.position,`toNext`);this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=pf._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=pf._createAt(t.nodeBefore,`end`,`toNext`)),this.position=n.toPosition(),n.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_mergeOnRight(){let e=this._lastNode;if(!(e instanceof Ml)||!this._canMergeRight(e))return;let t=pf._createAfter(e);if(t.stickiness=`toNext`,!this.position.isEqual(t))throw new w(`insertcontent-invalid-insertion-position`,this);this.position=z._createAt(t.nodeBefore,`end`);let n=pf.fromPosition(this.position,`toPrevious`);this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=pf._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=pf._createAt(t.nodeBefore,0,`toPrevious`)),this.position=n.toPosition(),n.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_canMergeLeft(e){let t=e.previousSibling;return t instanceof Ml&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){let t=e.nextSibling;return t instanceof Ml&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();let 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){let 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){let e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{let 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){let n=this.schema.createContext(e);return this.schema.checkChild(n,t)||this.schema.checkChild(n,`paragraph`)&&this.schema.checkChild(n.push(`paragraph`),t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}};function _p(e,t,n,r={}){if(!e.schema.isObject(t))throw new w(`insertobject-element-not-an-object`,e,{object:t});let i=n||e.document.selection,a=i;r.findOptimalPosition&&e.schema.isBlock(t)&&(a=e.createSelection(e.schema.findOptimalInsertionRange(i,r.findOptimalPosition)));let o=j(i.getSelectedBlocks()),s={};return o&&Object.assign(s,e.schema.getAttributesWithProperty(o,`copyOnReplace`,!0)),e.change(n=>{a.isCollapsed||e.deleteContent(a,{doNotAutoparagraph:!0});let i=t,o=a.anchor.parent,c=e.schema.createContext(o);!e.schema.checkChild(c,t)&&e.schema.checkChild(c,`paragraph`)&&e.schema.checkChild(c.push(`paragraph`),t)&&(i=n.createElement(`paragraph`),n.insert(t,i)),e.schema.setAllowedAttributes(i,s,n);let l=e.insertContent(i,a);return l.isCollapsed||r.setSelection&&vp(n,t,r.setSelection,s),l})}function vp(e,t,n,r){let i=e.model;if(n==`on`){e.setSelection(t,`on`);return}if(n!=`after`)throw new w(`insertobject-invalid-place-parameter-value`,i);let a=t.nextSibling;if(i.schema.isInline(t)){e.setSelection(t,`after`);return}!(a&&i.schema.checkChild(a,`$text`))&&i.schema.checkChild(t.parent,`paragraph`)&&(a=e.createElement(`paragraph`),i.schema.setAllowedAttributes(a,r,e),i.insertContent(a,e.createPositionAfter(t))),a&&e.setSelection(a,0)}function yp(e,t,n={}){let r=e.schema,i=n.direction!=`backward`,a=n.unit?n.unit:`character`,o=!!n.treatEmojiAsSingleUnit,s=t.focus,c=new Xc({boundaries:Cp(s,i),singleCharacters:!0,direction:i?`forward`:`backward`}),l={walker:c,schema:r,isForward:i,unit:a,treatEmojiAsSingleUnit:o},u;for(;u=c.next();){if(u.done)return;let n=bp(l,u.value);if(n){t instanceof Tl?e.change(e=>{e.setSelectionFocus(n)}):t.setFocus(n);return}}}function bp(e,t){let{isForward:n,walker:r,unit:i,schema:a,treatEmojiAsSingleUnit:o}=e,{type:s,item:c,nextPosition:l}=t;if(s==`text`)return e.unit===`word`?Sp(r,n):xp(r,i,o);if(s==(n?`elementStart`:`elementEnd`)){if(a.isSelectable(c))return z._createAt(c,n?`after`:`before`);if(a.checkChild(l,`$text`))return l}else{if(a.isLimit(c)){r.skip(()=>!0);return}if(a.checkChild(l,`$text`))return l}}function xp(e,t,n){let r=e.position.textNode;if(r){let i=r.data,a=e.position.offset-r.startOffset;for(;ra(i,a)||t==`character`&&ia(i,a)||n&&oa(i,a);)e.next(),a=e.position.offset-r.startOffset}return e.position}function Sp(e,t){let n=e.position.textNode;for(n||=t?e.position.nodeAfter:e.position.nodeBefore;n&&n.is(`$text`);){let r=e.position.offset-n.startOffset;if(Tp(n,r,t))n=t?e.position.nodeAfter:e.position.nodeBefore;else if(wp(n.data,r,t))break;else e.next()}return e.position}function Cp(e,t){let n=e.root,r=z._createAt(n,t?`end`:0);return t?new B(e,r):new B(r,e)}function wp(e,t,n){let r=t+(n?0:-1);return` ,.?!:;"-()`.includes(e.charAt(r))}function Tp(e,t,n){return t===(n?e.offsetSize:0)}const Ep=D();var Dp=class extends Ep{markers;document;schema;_config;_pendingChanges;_currentWriter;constructor(e){super(),this.markers=new Af,this.document=new Ef(this),this.schema=new ed,this._config=e,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(`$inlineRoot`,{allowContentOf:`$block`,allowAttributesOf:`$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`,`$inlineRoot`],allowChildren:`$text`,isLimit:!0}),this.schema.register(`$documentFragment`,{allowContentOf:[`$root`,`$inlineRoot`],allowChildren:`$text`,isLimit:!0}),this.schema.register(`$marker`),this.schema.addChildCheck(()=>!0,`$marker`),Vf(this),this.document.registerPostFixer(Ou),this.on(`insertContent`,(e,[t,n])=>{e.return=hp(this,t,n)}),this.on(`insertObject`,(e,[t,n,r])=>{e.return=_p(this,t,n,r)}),this.on(`canEditAt`,e=>{let t=!this.document.isReadOnly;e.return=t,t||e.stop()})}change(e){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new gf,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){w.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?typeof e==`function`?(t=e,e=new gf):e instanceof gf||(e=new gf(e)):e=new gf,this._pendingChanges.push({batch:e,callback:t}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(e){w.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,n,...r){let i=Op(t,n);return this.fire(`insertContent`,[e,i,n,...r])}insertObject(e,t,n,r,...i){let a=Op(t,n);return this.fire(`insertObject`,[e,a,r,r,...i])}deleteContent(e,t){Xf(this,e,t)}modifySelection(e,t){yp(this,e,t)}getSelectedContent(e){return pp(this,e)}hasContent(e,t={}){let n;n=e.is(`selection`)?Array.from(e.getRanges()):e.is(`range`)?[e]:[B._createIn(e)];for(let e of n)if(this._rangeHasContent(e,t))return!0;return!1}_rangeHasContent(e,t){if(e.isCollapsed)return!1;let{ignoreWhitespaces:n=!1,ignoreMarkers:r=!1}=t;if(!r){for(let t of this.markers.getMarkersIntersectingRange(e))if(t.affectsData)return!0}for(let t of e.getItems())if(this.schema.isContent(t))if(t.is(`$textProxy`)){if(!n||t.data.search(/\S/)!==-1)return!0}else return!0;return!1}canEditAt(e){let t=Op(e);return this.fire(`canEditAt`,[t])}createPositionFromPath(e,t,n){return new z(e,t,n)}createPositionAt(e,t){return z._createAt(e,t)}createPositionAfter(e){return z._createAfter(e)}createPositionBefore(e){return z._createBefore(e)}createRange(e,t){return new B(e,t)}createRangeIn(e){return B._createIn(e)}createRangeOn(e){return B._createOn(e)}createSelection(...e){return new _l(...e)}createBatch(e){return new gf(e)}createOperationFromJSON(e){return Zd.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){let e=[];this.fire(`_beforeChanges`);try{for(;this._pendingChanges.length;){let t=this._pendingChanges[0].batch;this._currentWriter=new Ff(this,t);let n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),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 Op(e,t){if(e)return e instanceof _l||e instanceof Tl?e:e instanceof gl?t||t===0?new _l(e,t):e.is(`rootElement`)?new _l(e,`in`):new _l(e,`on`):new _l(e)}var kp=class extends jc{domEventType=`click`;onDomEvent(e){this.fire(e.type,e)}},Ap=class extends jc{domEventType=[`mousedown`,`mouseup`,`mouseover`,`mouseout`];onDomEvent(e){this.fire(e.type,e)}},jp=class extends jc{domEventType=[`touchstart`,`touchend`,`touchmove`];onDomEvent(e){this.fire(e.type,e)}},Mp=class extends jc{domEventType=[`pointerdown`,`pointerup`,`pointermove`];onDomEvent(e){this.fire(e.type,e)}},Np=class{document;constructor(e){this.document=e}createDocumentFragment(e){return new Is(this.document,e)}createElement(e,t,n){return new Jo(this.document,e,t,n)}createText(e){return new Oo(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){let t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){let n=e.parent;if(n){let r=n.getChildIndex(e);return this.removeChildren(r,1,n),this.insertChild(r,t,n),!0}return!1}unwrapElement(e){let t=e.parent;if(t){let n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){let n=new Jo(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){xn(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}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 R(e,t)}createRangeOn(e){return R._createOn(e)}createRangeIn(e){return R._createIn(e)}createSelection(...e){return new os(...e)}};const Pp=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Fp=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Ip=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Lp=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Rp=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,zp=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Bp=new Set(`black.silver.gray.white.maroon.red.purple.fuchsia.green.lime.olive.yellow.navy.blue.teal.aqua.orange.aliceblue.antiquewhite.aquamarine.azure.beige.bisque.blanchedalmond.blueviolet.brown.burlywood.cadetblue.chartreuse.chocolate.coral.cornflowerblue.cornsilk.crimson.cyan.darkblue.darkcyan.darkgoldenrod.darkgray.darkgreen.darkgrey.darkkhaki.darkmagenta.darkolivegreen.darkorange.darkorchid.darkred.darksalmon.darkseagreen.darkslateblue.darkslategray.darkslategrey.darkturquoise.darkviolet.deeppink.deepskyblue.dimgray.dimgrey.dodgerblue.firebrick.floralwhite.forestgreen.gainsboro.ghostwhite.gold.goldenrod.greenyellow.grey.honeydew.hotpink.indianred.indigo.ivory.khaki.lavender.lavenderblush.lawngreen.lemonchiffon.lightblue.lightcoral.lightcyan.lightgoldenrodyellow.lightgray.lightgreen.lightgrey.lightpink.lightsalmon.lightseagreen.lightskyblue.lightslategray.lightslategrey.lightsteelblue.lightyellow.limegreen.linen.magenta.mediumaquamarine.mediumblue.mediumorchid.mediumpurple.mediumseagreen.mediumslateblue.mediumspringgreen.mediumturquoise.mediumvioletred.midnightblue.mintcream.mistyrose.moccasin.navajowhite.oldlace.olivedrab.orangered.orchid.palegoldenrod.palegreen.paleturquoise.palevioletred.papayawhip.peachpuff.peru.pink.plum.powderblue.rosybrown.royalblue.saddlebrown.salmon.sandybrown.seagreen.seashell.sienna.skyblue.slateblue.slategray.slategrey.snow.springgreen.steelblue.tan.thistle.tomato.turquoise.violet.wheat.whitesmoke.yellowgreen.activeborder.activecaption.appworkspace.background.buttonface.buttonhighlight.buttonshadow.buttontext.captiontext.graytext.highlight.highlighttext.inactiveborder.inactivecaption.inactivecaptiontext.infobackground.infotext.menu.menutext.scrollbar.threeddarkshadow.threedface.threedhighlight.threedlightshadow.threedshadow.window.windowframe.windowtext.rebeccapurple.currentcolor.transparent`.split(`.`));function Vp(e){return e.startsWith(`#`)?Pp.test(e):e.startsWith(`rgb`)?Fp.test(e)||Ip.test(e):e.startsWith(`hsl`)?Lp.test(e)||Rp.test(e):Bp.has(e.toLowerCase())}const Hp=[`none`,`hidden`,`dotted`,`dashed`,`solid`,`double`,`groove`,`ridge`,`inset`,`outset`];function Up(e){return Hp.includes(e)}const Wp=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function Gp(e){return Wp.test(e)}const Kp=/^[+-]?[0-9]*([.][0-9]+)?%$/;function qp(e){return Kp.test(e)}const Jp=[`auto`,`cover`,`contain`];function Yp(e){return Jp.includes(e)||Gp(e)||qp(e)}const Xp=[`repeat-x`,`repeat-y`,`repeat`,`space`,`round`,`no-repeat`];function Zp(e){return Xp.includes(e)}const Qp=[`center`,`top`,`bottom`,`left`,`right`];function $p(e){return Qp.includes(e)}const em=[`fixed`,`scroll`,`local`];function tm(e){return em.includes(e)}const nm=[`border-box`,`padding-box`,`content-box`];function rm(e){return nm.includes(e)}const im=[`border-box`,`padding-box`,`content-box`,`text`];function am(e){return im.includes(e)}const om=/^url\(/;function sm(e){return om.test(e)}function cm(e=``){if(e===``)return{top:void 0,right:void 0,bottom:void 0,left:void 0};let t=fm(e),n=t[0],r=t[2]||n,i=t[1]||n;return{top:n,bottom:r,right:i,left:t[3]||i}}function lm(e){return t=>{let{top:n,right:r,bottom:i,left:a}=t,o=[];return[n,r,a,i].every(e=>!!e)?o.push([e,um(t)]):(n&&o.push([e+`-top`,n]),r&&o.push([e+`-right`,r]),i&&o.push([e+`-bottom`,i]),a&&o.push([e+`-left`,a])),o}}function um({top:e,right:t,bottom:n,left:r}){let i=[];return r===t?n===e?t===e?i.push(e):i.push(e,t):i.push(e,t,n):i.push(e,t,n,r),i.join(` `)}function dm(e){return t=>({path:e,value:cm(t)})}function fm(e){let t=e.trim().slice(0,1500).matchAll(zp);return Array.from(t).map(e=>e[0])}const pm={image:`none`,repeat:`repeat`,position:`0% 0%`,size:`auto`,origin:`padding-box`,clip:`border-box`,attachment:`scroll`},mm=[`linear-gradient`,`repeating-linear-gradient`,`radial-gradient`,`repeating-radial-gradient`,`conic-gradient`,`repeating-conic-gradient`,`url`];function hm(e){e.setNormalizer(`background-color`,_m());for(let t in pm)e.setNormalizer(`background-${t}`,vm(`background.${t}`)),e.setReducer(`background-${t}`,ym(`background-${t}`));e.setNormalizer(`background`,gm()),e.setReducer(`background`,bm()),e.setStyleRelation(`background`,[`background-color`,`background-image`,`background-repeat`,`background-position`,`background-size`,`background-attachment`,`background-origin`,`background-clip`])}function gm(){return e=>{let t=Dm(e);return t.length||t.push({...km(),color:e}),{path:`background`,value:Em(t)}}}function _m(){return e=>({path:`background.color`,value:e})}function vm(e){return t=>({path:e,value:jm(t)})}function ym(e){return t=>[[e,t.join(`, `)]]}function bm(){return e=>{let t=e;return Object.keys(pm).every(e=>{let n=t[e];return n!==void 0&&(!Array.isArray(n)||n.length>0)})?xm(t):Sm(t)}}function xm(e){let t=[],n=wm(e).map(e=>Cm(e).trim()).filter(Boolean).join(`, `);return n&&t.push([`background`,n]),t}function Sm(e){let t=[];for(let n in pm){let r=e[n];Array.isArray(r)&&t.push([`background-${n}`,r.join(`, `)])}return e.color!==void 0&&t.push([`background-color`,e.color]),t}function Cm(e){let t=[];e.image&&e.image!==pm.image&&t.push(e.image);let n=e.position.join(` `),r=!n||n===pm.position;r||t.push(n);let i=e.size.join(` `);!i||i===pm.size||(r&&t.push(`0% 0%`),t.push(`/`,i));let a=e.repeat.join(` `);a&&a!==pm.repeat&&t.push(a),e.attachment&&e.attachment!==pm.attachment&&t.push(e.attachment);let o=e.origin===pm.origin,s=e.clip===pm.clip;return(!o||!s)&&(t.push(e.origin),e.clip!==e.origin&&t.push(e.clip)),e.color&&t.push(e.color),t.join(` `)}function wm(e){let t=Tm(e),n=Array.from({length:t},(t,n)=>{let r=km();return e.image?.[n]&&(r.image=e.image[n]),e.position?.[n]&&(r.position=e.position[n].split(` `)),e.size?.[n]&&(r.size=e.size[n].split(` `)),e.repeat?.[n]&&(r.repeat=e.repeat[n].split(` `)),e.attachment?.[n]&&(r.attachment=e.attachment[n]),e.origin?.[n]&&(r.origin=e.origin[n]),e.clip?.[n]&&(r.clip=e.clip[n]),r});return e.color&&(n.at(-1).color=e.color),n}function Tm(e){let t=0;for(let n of Object.values(e))Array.isArray(n)&&n.length>t&&(t=n.length);return t}function Em(e){let t={image:[],position:[],size:[],repeat:[],attachment:[],origin:[],clip:[]};for(let n of e)t.position.push(n.position.join(` `)),t.size.push(n.size.join(` `)),t.repeat.push(n.repeat.join(` `)),t.image.push(n.image),t.attachment.push(n.attachment),t.origin.push(n.origin),t.clip.push(n.clip);return e.at(-1)?.color&&(t.color=e.at(-1).color),t}function Dm(e){return jm(e).map(Om).filter(e=>e!==null)}function Om(e){let t={},{value:n,image:r}=Am(e),i=fm(n);r&&(t.image=r);for(let e=0;e{let{color:t,style:n,width:r}=Bm(e);return{path:`border`,value:{color:cm(t),style:cm(n),width:cm(r)}}}}function Pm(e){return t=>{let{color:n,style:r,width:i}=Bm(t),a={};return n!==void 0&&(a.color={[e]:n}),r!==void 0&&(a.style={[e]:r}),i!==void 0&&(a.width={[e]:i}),{path:`border`,value:a}}}function Fm(e){return t=>({path:`border`,value:Im(t,e)})}function Im(e,t){return{[t]:cm(e)}}function Lm(e,t){return n=>({path:`border`,value:{[e]:{[t]:n}}})}function Rm(e){return(t,n)=>{if(n.border)return zm(n.border,e)}}function zm(e,t){let n={};return e.width&&e.width[t]&&(n.width=e.width[t]),e.style&&e.style[t]&&(n.style=e.style[t]),e.color&&e.color[t]&&(n.color=e.color[t]),n}function Bm(e){let t={},n=fm(e);for(let e of n)Gp(e)||/thin|medium|thick/.test(e)?t.width=e:Up(e)?t.style=e:t.color=e;return t}function Vm(){return t=>{let n=zm(t,`top`),r=zm(t,`right`),i=zm(t,`bottom`),a=zm(t,`left`),o=[n,r,i,a],s={width:e(o,`width`),style:e(o,`style`),color:e(o,`color`)},c=Um(s,`all`);return c.length?c:[...Object.entries(s).reduce((e,[t,n])=>(n&&(e.push([`border-${t}`,n]),o.forEach(e=>delete e[t])),e),[]),...Um(n,`top`),...Um(r,`right`),...Um(i,`bottom`),...Um(a,`left`)]};function e(e,t){return e.map(e=>e[t]).reduce((e,t)=>e==t?e:null)}}function Hm(e){return t=>Um(t,e)}function Um(e,t){let n=[];if(e&&e.width&&n.push(`width`),e&&e.style&&n.push(`style`),e&&e.color&&n.push(`color`),n.length==3){let r=n.map(t=>e[t]).join(` `);return[t==`all`?[`border`,r]:[`border-${t}`,r]]}return t==`all`?[]:n.map(n=>[`border-${t}-${n}`,e[n]])}function Wm(e){e.setNormalizer(`margin`,dm(`margin`)),e.setNormalizer(`margin-top`,e=>({path:`margin.top`,value:e})),e.setNormalizer(`margin-right`,e=>({path:`margin.right`,value:e})),e.setNormalizer(`margin-bottom`,e=>({path:`margin.bottom`,value:e})),e.setNormalizer(`margin-left`,e=>({path:`margin.left`,value:e})),e.setReducer(`margin`,lm(`margin`)),e.setStyleRelation(`margin`,[`margin-top`,`margin-right`,`margin-bottom`,`margin-left`])}function Gm(e){e.setNormalizer(`padding`,dm(`padding`)),e.setNormalizer(`padding-top`,e=>({path:`padding.top`,value:e})),e.setNormalizer(`padding-right`,e=>({path:`padding.right`,value:e})),e.setNormalizer(`padding-bottom`,e=>({path:`padding.bottom`,value:e})),e.setNormalizer(`padding-left`,e=>({path:`padding.left`,value:e})),e.setReducer(`padding`,lm(`padding`)),e.setStyleRelation(`padding`,[`padding-top`,`padding-right`,`padding-bottom`,`padding-left`])}const Km={container:Qo,attribute:ws,empty:Ds,ui:ks,raw:Ns},qm={setContentOf:(e,t)=>{e.innerHTML=t}},Jm=(()=>{let e=function(t,n={}){if(!(t instanceof qc))throw TypeError(`View needs to be an instance of module:engine/view/view~EditingView.`);let r=t.document,i=!!n.withoutSelection,a=n.rootName||`main`,o=r.getRoot(a),s={showType:n.showType,showPriority:n.showPriority,renderUIElements:n.renderUIElements,renderRawElements:n.renderRawElements,ignoreRoot:!0,domConverter:n.domConverter,skipListItemIds:n.skipListItemIds};return i?e._stringify(o,null,s):e._stringify(o,r.selection,s)};return e._stringify=Xm,e})(),Ym=(()=>{let e=function(t,n,r={}){if(!(t instanceof qc))throw TypeError(`View needs to be an instance of module:engine/view/view~EditingView.`);let i=t.document,a=r.rootName||`main`,o=i.getRoot(a);t.change(t=>{let r=e._parse(n,{rootElement:o});r.view&&r.selection&&t.setSelection(r.selection)})};return e._parse=Zm,e})();function Xm(e,t=null,n={}){let r;return r=t instanceof L||t instanceof R?new cs(t):t,new $m(e,r,n).stringify()}function Zm(e,t={}){let n=new Cs(new Ho);t.order=t.order||[];let r=new Qm({sameSelectionCharacters:t.sameSelectionCharacters}),i=new Ad(n,{namespaces:Object.keys(Km)});t.inlineObjectElements&&i.domConverter.inlineObjectElements.push(...t.inlineObjectElements);let a=i.toView(e);if(a=eh(a),t.rootElement){let e=t.rootElement,n=a._removeChildren(0,a.childCount);e._removeChildren(0,e.childCount),e._appendChild(n),a=e}let o=r._parseView(a,t.order);if(a.is(`documentFragment`)&&a.childCount===1&&(a=a.getChild(0)),o.length){let e=new cs(o,{backward:!!t.lastRangeBackward});return{view:a,selection:e}}return a.parent&&a._remove(),a}var Qm=class{sameSelectionCharacters;_positions;constructor(e){this.sameSelectionCharacters=!!e.sameSelectionCharacters}_parseView(e,t){this._positions=[],this._getPositions(e);let n=this._createRanges();if(t.length){if(t.length!=n.length)throw Error(`Parse error - there are ${n.length} ranges found, but ranges order array contains ${t.length} elements.`);n=this._sortRanges(n,t)}return n}_getPositions(e){if(e.is(`documentFragment`)||e.is(`element`)){let t=[...e.getChildren()];for(let e of t)this._getPositions(e)}if(e.is(`$text`)){let t=RegExp(`[{}\\]\\[]`,`g`),n=e.data,r,i=0,a=[];for(;r=t.exec(n);){let e=r.index,t=r[0];a.push({bracket:t,textOffset:e-i}),i++}n=n.replace(t,``),e._data=n;let o=e.index,s=e.parent;n||e._remove();for(let t of a)if(n)if(this.sameSelectionCharacters||!this.sameSelectionCharacters&&(t.bracket==`{`||t.bracket==`}`))this._positions.push({bracket:t.bracket,position:new L(e,t.textOffset)});else{if(!this.sameSelectionCharacters&&t.textOffset!==0&&t.textOffset!==n.length)throw Error(`Parse error - range delimiter '${t.bracket}' is placed inside text node.`);let e=t.textOffset===0?o:o+1;this._positions.push({bracket:t.bracket,position:new L(s,e)})}else{if(!this.sameSelectionCharacters&&t.bracket==`{`||t.bracket==`}`)throw Error(`Parse error - text range delimiter '${t.bracket}' is placed inside empty text node. `);this._positions.push({bracket:t.bracket,position:new L(s,o)})}}}_sortRanges(e,t){let n=[],r=0;for(let i of t){if(e[i-1]===void 0)throw Error(`Parse error - provided ranges order is invalid.`);n[i-1]=e[r],r++}return n}_createRanges(){let e=[],t=null;for(let n of this._positions){if(!t&&(n.bracket==`]`||n.bracket==`}`))throw Error(`Parse error - end of range was found '${n.bracket}' but range was not started before.`);if(t&&(n.bracket==`[`||n.bracket==`{`))throw Error(`Parse error - start of range was found '${n.bracket}' but one range is already started.`);n.bracket==`[`||n.bracket==`{`?t=new R(n.position,n.position):(t.end=n.position,e.push(t),t=null)}if(t!==null)throw Error(`Parse error - range was started but no end delimiter was found.`);return e}},$m=class{root;selection;ranges;showType;showPriority;showAttributeElementId;ignoreRoot;sameSelectionCharacters;renderUIElements;renderRawElements;domConverter;skipListItemIds;constructor(e,t,n){this.root=e,this.selection=t,this.ranges=[],t&&(this.ranges=[...t.getRanges()]),this.showType=!!n.showType,this.showPriority=!!n.showPriority,this.showAttributeElementId=!!n.showAttributeElementId,this.ignoreRoot=!!n.ignoreRoot,this.sameSelectionCharacters=!!n.sameSelectionCharacters,this.renderUIElements=!!n.renderUIElements,this.renderRawElements=!!n.renderRawElements,this.domConverter=n.domConverter||qm,this.skipListItemIds=n.skipListItemIds===void 0?!0:!!n.skipListItemIds}stringify(){let e=``;return this._walkView(this.root,t=>{e+=t}),this.skipListItemIds&&(e=e.replaceAll(/ data-list-item-id="[^"]+"/g,``)),e}_walkView(e,t){let n=this.ignoreRoot&&this.root===e;if(e.is(`element`)||e.is(`documentFragment`)){if(e.is(`element`)&&!n&&t(this._stringifyElementOpen(e)),this.renderUIElements&&e.is(`uiElement`))t(e.render(document,this.domConverter).innerHTML);else if(this.renderRawElements&&e.is(`rawElement`)){let n=document.createElement(`div`);e.render(n,this.domConverter),t(n.innerHTML)}else{let n=0;t(this._stringifyElementRanges(e,n));for(let r of e.getChildren())this._walkView(r,t),n++,t(this._stringifyElementRanges(e,n))}e.is(`element`)&&!n&&t(this._stringifyElementClose(e))}e.is(`$text`)&&t(this._stringifyTextRanges(e))}_stringifyElementRanges(e,t){let n=``,r=``,i=``;for(let a of this.ranges)a.start.parent==e&&a.start.offset===t&&(a.isCollapsed?i+=`[]`:n+=`[`),a.end.parent===e&&a.end.offset===t&&!a.isCollapsed&&(r+=`]`);return r+i+n}_stringifyTextRanges(e){let t=e.data.length,n=e.data.split(``),r,i;this.sameSelectionCharacters?(r=`[`,i=`]`):(r=`{`,i=`}`),n[t]=``;let a=n.map(e=>({letter:e,start:``,end:``,collapsed:``}));for(let n of this.ranges){let o=n.start,s=n.end;o.parent==e&&o.offset>=0&&o.offset<=t&&(n.isCollapsed?a[s.offset].collapsed+=r+i:a[o.offset].start+=r),s.parent==e&&s.offset>=0&&s.offset<=t&&!n.isCollapsed&&(a[s.offset].end+=i)}return a.map(e=>e.end+e.collapsed+e.start+e.letter).join(``)}_stringifyElementOpen(e){let t=this._stringifyElementPriority(e),n=this._stringifyElementId(e);return`<${[[this._stringifyElementType(e),e.name].filter(e=>e!==``).join(`:`),t,n,this._stringifyElementAttributes(e)].filter(e=>e!==``).join(` `)}>`}_stringifyElementClose(e){return`${[this._stringifyElementType(e),e.name].filter(e=>e!==``).join(`:`)}>`}_stringifyElementType(e){if(this.showType){for(let t in Km)if(e instanceof Km[t])return t}return``}_stringifyElementPriority(e){return this.showPriority&&e.is(`attributeElement`)?`view-priority="${e.priority}"`:``}_stringifyElementId(e){return this.showAttributeElementId&&e.is(`attributeElement`)&&e.id?`view-id="${e.id}"`:``}_stringifyElementAttributes(e){let t=[],n=[...e.getAttributeKeys()].sort();for(let r of n){let n;n=r===`class`?[...e.getClassNames()].sort().join(` `):r===`style`?[...e.getStyleNames()].sort().map(t=>`${t}:${e.getStyle(t).replace(/"/g,`"`)}`).join(`;`):e.getAttribute(r),t.push(`${r}="${n}"`)}return t.join(` `)}};function eh(e){if(e.is(`element`)||e.is(`documentFragment`)){let t=e.is(`documentFragment`)?new Is(e.document):th(e.document,e);for(let n of[...e.getChildren()]){if(t.is(`emptyElement`))throw Error(`Parse error - cannot parse inside ViewEmptyElement.`);if(t.is(`uiElement`))throw Error(`Parse error - cannot parse inside UIElement.`);if(t.is(`rawElement`))throw Error(`Parse error - cannot parse inside RawElement.`);t._appendChild(eh(n))}return t}return e}function th(e,t){let n=nh(t),r=Km[n.type],i=r?new r(e,n.name):new Jo(e,n.name);i.is(`attributeElement`)&&(n.priority!==null&&(i._priority=n.priority),n.id!==null&&(i._id=n.id));for(let e of t.getAttributeKeys())i._setAttribute(e,t.getAttribute(e));return i}function nh(e){let t=e.name.split(`:`),n=ih(e.getAttribute(`view-priority`)),r=e.hasAttribute(`view-id`)?e.getAttribute(`view-id`):null;if(e._removeAttribute(`view-priority`),e._removeAttribute(`view-id`),t.length==1)return{name:t[0],type:n===null?null:`attribute`,priority:n,id:r};let i=rh(t[0]);if(i)return{name:t[1],type:i,priority:n,id:r};throw Error(`Parse error - cannot parse element's name: ${e.name}.`)}function rh(e){return e in Km?e:null}function ih(e){let t=parseInt(e,10);return isNaN(t)?null:t}const ah=(()=>{let e=function(t,n={}){if(!(t instanceof Dp))throw TypeError(`Model needs to be an instance of module:engine/model/model~Model.`);let r=n.rootName||`main`,i=t.document.getRoot(r);return e._stringify(i,n.withoutSelection?null:t.document.selection,n.convertMarkers?t.markers:null)};return e._stringify=sh,e})(),oh=(()=>{let e=function(t,n,r={}){if(!(t instanceof Dp))throw TypeError(`Model needs to be an instance of module:engine/model/model~Model.`);let i,a=null,o=t.document.getRoot(r.rootName||`main`),s=e._parse(n,t.schema,{lastRangeBackward:r.lastRangeBackward,selectionAttributes:r.selectionAttributes,context:[o.name],inlineObjectElements:r.inlineObjectElements});`model`in s?(i=s.model,a=s.selection):i=s,r.batchType===void 0?t.change(c):t.enqueueChange(r.batchType,c);function c(e){if(e.remove(e.createRangeIn(o)),e.insert(i,o),e.setSelection(null),e.removeSelectionAttribute(t.document.selection.getAttributeKeys()),a){let t=[];for(let e of a.getRanges()){let n=new z(o,e.start.path),r=new z(o,e.end.path);t.push(new B(n,r))}e.setSelection(t,{backward:a.isBackward}),r.selectionAttributes&&e.setSelectionAttribute(a.getAttributes())}}};return e._parse=ch,e})();function sh(e,t=null,n=null){let r=new Dp,i=new ol,a=null,o;if(e instanceof Cf||e instanceof Nf)o=r.createRangeIn(e);else if(e.parent)o=new B(r.createPositionBefore(e),r.createPositionAfter(e));else{let t=new Nf(e);o=r.createRangeIn(t)}t instanceof _l||t instanceof Tl?a=t:(t instanceof B||t instanceof z)&&(a=new _l(t));let s=new qc(new Ho),c=s.document,l=new ns(c,`div`);l.rootName=`main`,c.roots.add(l);let u=new fl({mapper:i,schema:r.schema});i.bindElements(e.root,l),u.on(`insert:$text`,Ll()),u.on(`insert`,Rl(),{priority:`lowest`}),u.on(`attribute`,(e,t,n)=>{(t.item instanceof _l||t.item instanceof Tl||t.item.is(`$textProxy`))&&Wl((e,{writer:n})=>n.createAttributeElement(`model-text-with-attributes`,{[t.attributeKey]:ph(e)}))(e,t,n)}),u.on(`insert`,Gl(e=>{let t=mh(e.getAttributes(),ph);return new Qo(c,e.name,t)})),u.on(`selection`,Vl()),u.on(`selection`,Hl()),u.on(`addMarker`,ql((e,{writer:t})=>{let n=e.markerName+`:`+(e.isOpening?`start`:`end`);return t.createUIElement(n)}));let d=new Map;if(n)for(let e of Array.from(n).sort((e,t)=>e.namel.convert(a.root,e,n.context||`$root`));if(r.bindElements(u,a.root),u.childCount==1&&(u=u.getChild(0)),o){let e=[];for(let t of o.getRanges())e.push(r.toModelRange(t));s=new _l(e,{backward:o.isBackward});for(let[e,t]of Ui(n.selectionAttributes||[]))s.setAttribute(e,t)}return s?{model:u,selection:s}:u}function lh(e){return(t,n,r)=>{let i=r.convertChildren(n.viewItem,n.modelCursor);e.bindElements(n.modelCursor.parent,n.viewItem),n=Object.assign(n,i),t.stop()}}function uh(e){return(t,n,r)=>{let i=n.viewItem.name;if(!r.schema.checkChild(n.modelCursor,i))throw Error(`Element '${i}' was not allowed in given position.`);let a=mh(n.viewItem.getAttributes(),fh),o=r.writer.createElement(n.viewItem.name,a);r.writer.insert(o,n.modelCursor),e.bindElements(o,n.viewItem),r.convertChildren(n.viewItem,o),n.modelRange=B._createOn(o),n.modelCursor=n.modelRange.end,t.stop()}}function dh(){return(e,t,n)=>{if(!n.schema.checkChild(t.modelCursor,`$text`))throw Error(`Text was not allowed in given position.`);let r;if(t.viewItem.is(`element`)){let e=mh(t.viewItem.getAttributes(),fh),i=t.viewItem.getChild(0);r=n.writer.createText(i.data,e)}else r=n.writer.createText(t.viewItem.data);n.writer.insert(r,t.modelCursor),t.modelRange=B._createFromPositionAndShift(t.modelCursor,r.offsetSize),t.modelCursor=t.modelRange.end,e.stop()}}function fh(e){try{return JSON.parse(e)}catch{return e}}function ph(e){return xn(e)?JSON.stringify(e):e}function*mh(e,t){for(let[n,r]of e)yield[n,t(r)]}function hh(e){let t=``;for(let n of e)t+=` ${n[0]}=${JSON.stringify(n[1])}`;return t}function gh(e){let t={};for(let n of e)t[n[0]]=n[1];return JSON.stringify(t)}const _h=Symbol(`_treeDump`);function vh(e,t){console.log(e,t);let n=``;for(let t of e.roots)n+=t.printTree()+`
`;e[_h][t]=n.substr(0,n.length-1);let r=e[_h].length-20;r>0&&(e[_h][r-1]=null)}function yh(e){e[_h]=[]}function bh(e,t){console.log(`--------------------`),e[_h][t]?console.log(e[_h][t]):console.log(`Tree log unavailable for given version: `+t)}var xh=class{_model;_logSeparator;_operationsToReplay;constructor(e,t,n){this._model=e,this._logSeparator=t,this.setStringifiedOperations(n)}setStringifiedOperations(e){if(e===``){this._operationsToReplay=[];return}this._operationsToReplay=e.split(this._logSeparator).map(e=>JSON.parse(e))}getOperationsToReplay(){return this._operationsToReplay}play(e=1e3){let t=this;return new Promise((n,r)=>{i();function i(){t.applyNextOperation().then(t=>{if(t)return n();setTimeout(i,e)}).catch(e=>{r(e)})}})}applyOperations(e){if(!(e<=0))return this.applyNextOperation().then(t=>{if(!t)return this.applyOperations(e-1)})}applyAllOperations(){return this.applyNextOperation().then(e=>{if(!e)return this.applyAllOperations()})}applyNextOperation(){let e=this._model;return new Promise(t=>{e.enqueueChange(n=>{let r=this._operationsToReplay.shift();if(!r)return t(!0);let i=Zd.fromJSON(r,e.document);n.batch.addOperation(i),e.applyOperation(i),t(!1)})})}},Sh=class{crashes=[];state=`initializing`;_crashNumberLimit;_now=Date.now;_minimumNonErrorTimePeriod;_boundErrorHandler;_listeners;constructor(e){if(this.crashes=[],this._crashNumberLimit=typeof e.crashNumberLimit==`number`?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod=typeof e.minimumNonErrorTimePeriod==`number`?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{let t=`error`in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw 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,...t){let n=this._listeners[e]||[];for(let e of n)e.apply(this,[null,...t])}_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()});let n=this._shouldRestart();this.state=`crashed`,this._fire(`stateChange`),this._fire(`error`,{error:e,causesRestart:n}),n?this._restart():(this.state=`crashedPermanently`,this._fire(`stateChange`))}}_shouldReactToError(e){return e.is&&e.is(`CKEditorError`)&&e.context!==void 0&&e.context!==null&&this.state===`ready`&&this._isErrorComingFromThisItem(e)}_shouldRestart(){return this.crashes.length<=this._crashNumberLimit?!0:(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}};function Ch(e,t=new Set){let n=[e],r=new Set,i=0;for(;n.length>i;){let e=n[i++];if(!(r.has(e)||!wh(e)||t.has(e)))if(r.add(e),Symbol.iterator in e)try{for(let t of e)n.push(t)}catch{}else for(let t in e)t!==`defaultValue`&&n.push(e[t])}return r}function wh(e){let t=Object.prototype.toString.call(e),n=typeof e;return!(n===`number`||n===`boolean`||n===`string`||n===`symbol`||n===`function`||t===`[object Date]`||t===`[object RegExp]`||t===`[object Module]`||e==null||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function Th(e,t,n=new Set){if(e===t&&Eh(e))return!0;let r=Ch(e,n),i=Ch(t,n);for(let e of r)if(i.has(e))return!0;return!1}function Eh(e){return typeof e==`object`&&!!e}function Dh(e,t,n){let r=t.root,i=t.roots||Object.create(null);n&&!i[n]&&(i[n]=r||Object.create(null));let a=Oh(e),o=kh(t,a,n),s=Array.from(new Set([...a?Object.keys(e):[],...Object.keys(i),...Object.keys(o)]));for(let e of s){let n=i[e]||Object.create(null);n.initialData=``,n.placeholder??=Ah(t,`placeholder`,e),n.label??=Ah(t,`label`,e),i[e]=n}t.roots=i}function Oh(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!jh(e)}function kh(e,t,n){return t||!n?e.initialData||Object.create(null):{[n]:e.initialData}}function Ah(e,t,n){let r=e[t];if(r)return typeof r==`string`?r:r[n]}function jh(e){return jn(e)}var Mh=class extends Sh{_editor=null;_lifecyclePromise=null;_throttledSave;_data;_lastDocumentVersion;_elementOrData;_editorAttachTo=null;_isSingleRootEditor=!0;_isUsingConfigBasedCreator=!1;_editables={};_config;_excludedProps;constructor(e,t={}){super(t),this._throttledSave=qt(this._save.bind(this),typeof t.saveInterval==`number`?t.saveInterval:5e3),e&&(this._creator=((t,n)=>n===void 0?e.create(t):e.create(t,n))),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(()=>{this._isUsingConfigBasedCreator?Dh(this._isSingleRootEditor?``:{},this._config,this._isSingleRootEditor?`main`:!1):Dh(this._isSingleRootEditor?this._editorAttachTo||``:this._editables,this._config,this._isSingleRootEditor?`main`:!1);let e={...this._config,extraPlugins:this._config.extraPlugins||[],_watchdogInitialData:this._data};e.extraPlugins.push(Nh);let t={};for(let[n,r]of Object.entries(this._data.roots)){let i=e.roots[n]||Object.create(null);i.initialData=``,i.modelElement=r.modelElement,this._isUsingConfigBasedCreator&&(this._editables[n]?.isConnected?i.element=this._editables[n]:r.isLoaded&&!i.element&&Object.assign(i,Fh(r.attributes))),r.isLoaded?i.lazyLoad=!1:delete i.modelAttributes,t[n]=i}if(e.roots=t,delete e.initialData,delete e.root,this._isUsingConfigBasedCreator)return this.create(e,e.context);let n=this._isSingleRootEditor?this._editorAttachTo||``:this._editables;return this.create(n,e,e.context)}).then(()=>{this._fire(`restart`)})}create(e=this._isUsingConfigBasedCreator?this._config:this._elementOrData,t=this._isUsingConfigBasedCreator?void 0:this._config,n){let r=this._detectConfigBasedCreator(e,t),i=r?void 0:e,a=r?e:t,o=r?t:n;return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>{if(super._startErrorHandling(),this._isUsingConfigBasedCreator=r,this._elementOrData=i,this._config=this._cloneEditorConfiguration(a||{}),this._config.context=o,r){this._editorAttachTo=null;let e=this._config.roots?Object.keys(this._config.roots).length:0,t=this._config.initialData,n=t&&typeof t==`object`;this._isSingleRootEditor=!n&&e<=1}else this._editorAttachTo=Ph(i)?i:null,this._isSingleRootEditor=Ph(i)||typeof i==`string`;return r?this._creator(this._config):this._creator(i,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._editorAttachTo||(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();let e=this._editor;return this._editor=null,e.model.document.off(`change:data`,this._throttledSave),this._destructor(e)})}_save(){let e=this._editor.model.document.version;try{this._data=this._getData(),this._editorAttachTo||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,`An error happened during restoring editor data. Editor will be restored from the previously saved data.`)}}_setExcludedProperties(e){this._excludedProps=e}_getData(){let e=this._editor,t=e.model.document.roots.filter(e=>e.isAttached()&&e.rootName!=`$graveyard`),{plugins:n}=e,r=n.has(`CommentsRepository`)&&n.get(`CommentsRepository`),i=n.has(`TrackChanges`)&&n.get(`TrackChanges`),a={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach(e=>{a.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),modelElement:e.name,isLoaded:e._isLoaded}});for(let t of e.model.markers)t._affectsData&&(a.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return r&&(a.commentThreads=JSON.stringify(r.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),i&&(a.suggestions=JSON.stringify(i.getSuggestions({toJSON:!0,skipNotAttached:!0}))),a}_getEditables(){let e={};for(let t of this.editor.model.document.getRootNames()){let n=this.editor.ui.getEditableElement(t);n&&(e[t]=n)}return e}_isErrorComingFromThisItem(e){return Th(this._editor,e.context,this._excludedProps)}_detectConfigBasedCreator(e,t){if(typeof e==`string`||Ph(e)||t&&typeof t==`object`&&!(`destroy`in t)&&Object.keys(t).length>0)return!1;if(e&&typeof e==`object`){let t=Object.values(e);if(t.length>0&&t.every(e=>typeof e==`string`||Ph(e)))return!1}return!0}_cloneEditorConfiguration(e){return Lt(e,(e,t)=>{if(Ph(e)||t===`context`)return e})}},Nh=class{editor;_data;constructor(e){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){let n=e.createElement(t.name,t.attributes);if(t.children)for(let r of t.children)n._appendChild(this._createNode(e,r));return n}else return e.createText(t.data,t.attributes)}_restoreEditorData(e){let t=this.editor;Object.entries(this._data.roots).forEach(([n,{content:r,attributes:i}])=>{let a=JSON.parse(r),o=JSON.parse(i),s=t.model.document.getRoot(n);for(let[t,n]of o)e.setAttribute(t,n,s);for(let t of a){let n=this._createNode(e,t);e.insert(n,s,`end`)}}),Object.entries(this._data.markers).forEach(([n,r])=>{let{document:i}=t.model,{rangeJSON:{start:a,end:o},...s}=r,c=i.getRoot(a.root),l=e.createPositionFromPath(c,a.path,a.stickiness),u=e.createPositionFromPath(c,o.path,o.stickiness),d=e.createRange(l,u);e.addMarker(n,{range:d,...s})})}_restoreCollaborationData(){let e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);if(this.editor.plugins.has(`CommentsRepository`)){let t=this.editor.plugins.get(`CommentsRepository`);for(let e of t.getCommentThreads())t._removeCommentThread({threadId:e.id});e.forEach(e=>{let t=this.editor.config.get(`collaboration.channelId`);this.editor.plugins.get(`CommentsRepository`).addCommentThread({channelId:t,...e})})}if(this.editor.plugins.has(`TrackChangesEditing`)){let e=this.editor.plugins.get(`TrackChangesEditing`);for(let t of e.getSuggestions())e._removeSuggestion(t);t.forEach(t=>{e.addSuggestionData(t)})}}};function Ph(e){return jn(e)}function Fh(e){let{$rootEditableOptions:t}=Object.fromEntries(JSON.parse(e));return!t||typeof t!=`object`?{}:{...t.placeholder&&{placeholder:t.placeholder},...t.label&&{label:t.label},...t.element&&{element:t.element}}}const Ih=Symbol(`MainQueueId`);var Lh=class extends Sh{_watchdogs=new Map;_watchdogConfig;_context=null;_contextProps=new Set;_actionQueues=new Rh;_contextConfig;_item;constructor(e,t={}){super(t),this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty(()=>{this.state===`initializing`&&(this.state=`ready`,this._fire(`stateChange`))})}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(Ih,()=>(this._contextConfig=e,this._create()))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){let t=zh(e);return Promise.all(t.map(e=>this._actionQueues.enqueue(e.id,()=>{if(this.state===`destroyed`)throw Error(`Cannot add items to destroyed watchdog.`);if(!this._context)throw Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw Error(`Item with the given id is already added: '${e.id}'.`);if(e.type===`editor`)return t=new Mh(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`,(n,{error:r,causesRestart:i})=>{this._fire(`itemError`,{itemId:e.id,error:r}),i&&this._actionQueues.enqueue(e.id,()=>new Promise(n=>{let r=()=>{t.off(`restart`,r),this._fire(`itemRestart`,{itemId:e.id}),n()};t.on(`restart`,r)}))}),e.sourceElementOrData===void 0?t.create(e.config,this._context):t.create(e.sourceElementOrData,e.config,this._context);throw Error(`Not supported item type: '${e.type}'.`)})))}remove(e){let t=zh(e);return Promise.all(t.map(e=>this._actionQueues.enqueue(e,()=>{let t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))}destroy(){return this._actionQueues.enqueue(Ih,()=>(this.state=`destroyed`,this._fire(`stateChange`),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(Ih,()=>(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=Ch(this._context),Promise.all(Array.from(this._watchdogs.values()).map(e=>(e._setExcludedProperties(this._contextProps),e._isUsingConfigBasedCreator?e.create(void 0,this._context):e.create(void 0,void 0,this._context))))))}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling();let 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){let t=this._watchdogs.get(e);if(!t)throw Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(let t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return Th(this._context,e.context)}},Rh=class{_onEmptyCallbacks=[];_queues=new Map;_activeActions=0;onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){let n=e===Ih;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());let r=(n?Promise.all(this._queues.values()):Promise.all([this._queues.get(Ih),this._queues.get(e)])).then(t),i=r.catch(()=>{});return this._queues.set(e,i),r.finally(()=>{this._activeActions--,this._queues.get(e)===i&&this._activeActions===0&&this._onEmptyCallbacks.forEach(e=>e())})}};function zh(e){return Array.isArray(e)?e:[e]}var Bh=class{editor;_entries=[];_frameStack=[];_errors=new Set;_maxEntries;_errorCallback;_filterCallback;_maxEntriesCallback;static get pluginName(){return`ActionsRecorder`}static get isOfficialPlugin(){return!0}constructor(e){this.editor=e,e.config.define(`actionsRecorder.maxEntries`,1e3);let t=e.config.get(`actionsRecorder`);this._maxEntries=t.maxEntries,this._filterCallback=t.onFilter,this._errorCallback=t.onError,this._maxEntriesCallback=t.onMaxEntries||this._maxEntriesDefaultHandler,this._tapCommands(),this._tapOperationApply(),this._tapModelMethods(),this._tapModelSelection(),this._tapComponentFactory(),this._tapViewDocumentEvents()}getEntries(){return this._entries.slice()}flushEntries(){this._entries=[]}_enterFrame(e,t){let n={timeStamp:new Date().toISOString(),...this._frameStack.length&&{parentEntry:this._frameStack.at(-1)},action:e,params:t?.map(e=>Hh(e)),before:this._buildStateSnapshot()};return(!this._filterCallback||this._filterCallback(n,this._entries))&&this._entries.push(n),this._frameStack.push(n),n}_leaveFrame(e,t,n){let r=this._frameStack.pop();!r||r!==e||(t!==void 0&&(r.result=Hh(t)),n&&(r.error=Hh(n)),r.after=this._buildStateSnapshot(),n&&this._callErrorCallback(n),this._frameStack.length==0&&this._errors.clear(),this._entries.length>=this._maxEntries&&this._maxEntriesCallback())}_buildStateSnapshot(){let{model:e,isReadOnly:t,editing:n}=this.editor;return{documentVersion:e.document.version,editorReadOnly:t,editorFocused:n.view.document.isFocused,modelSelection:Hh(e.document.selection)}}_tapCommands(){for(let[e,t]of this.editor.commands)this._tapCommand(e,t);Vh(this.editor.commands,`add`,{before:(e,[t,n])=>(this._tapCommand(t,n),!1)})}_tapOperationApply(){Vh(this.editor.model,`applyOperation`,{before:(e,[t])=>t.baseVersion===null?!1:(e.callFrame=this._enterFrame(`model.applyOperation`,[t]),!0),after:e=>{this._leaveFrame(e.callFrame)},error:(e,t)=>{this._leaveFrame(e.callFrame,void 0,t)}})}_tapModelMethods(){for(let e of[`insertContent`,`insertObject`,`deleteContent`])Vh(this.editor.model,e,{before:(t,...n)=>(t.callFrame=this._enterFrame(`model.${e}`,n),!0),after:(e,t)=>{this._leaveFrame(e.callFrame,t)},error:(e,t)=>{this._leaveFrame(e.callFrame,void 0,t)}})}_tapModelSelection(){this._tapFireMethod(this.editor.model.document.selection,[`change:range`,`change:attribute`,`change:marker`],{eventSource:`model-selection`})}_tapCommand(e,t){Vh(t,`execute`,{before:(t,n)=>(t.callFrame=this._enterFrame(`commands.${e}:execute`,n),!0),after:(e,t)=>{this._leaveFrame(e.callFrame,t)},error:(e,t)=>{this._leaveFrame(e.callFrame,void 0,t)}})}_tapComponentFactory(){Vh(this.editor.ui.componentFactory,`create`,{before:(e,[t])=>(e.componentName=t,e.callFrame=this._enterFrame(`component-factory.create:${t}`),!0),after:(e,t)=>{let n={...e,eventSource:`component.${e.componentName}`};typeof t.fire==`function`&&this._tapFireMethod(t,[`execute`],n),typeof t.panelView?.fire==`function`&&this._tapFireMethod(t.panelView,[`execute`],n),typeof t.buttonView?.actionView?.fire==`function`&&this._tapFireMethod(t.buttonView.actionView,[`execute`],n),this._leaveFrame(e.callFrame)},error:(e,t)=>{this._leaveFrame(e.callFrame,void 0,t)}})}_tapViewDocumentEvents(){this._tapFireMethod(this.editor.editing.view.document,[`click`,`mousedown`,`mouseup`,`pointerdown`,`pointerup`,`focus`,`blur`,`keydown`,`keyup`,`selectionChange`,`compositionstart`,`compositionend`,`beforeinput`,`mutations`,`enter`,`delete`,`insertText`,`paste`,`copy`,`cut`,`dragstart`,`drop`],{eventSource:`observers`})}_tapFireMethod(e,t,n={}){Vh(e,`fire`,{before:(e,[n,...r])=>{let i=typeof n==`string`?n:n.name;return t.includes(i)?(e.callFrame=this._enterFrame(`${e.eventSource}:${i}`,r),!0):!1},after:(e,t)=>{this._leaveFrame(e.callFrame,t)},error:(e,t)=>{this._leaveFrame(e.callFrame,void 0,t)}},n)}_callErrorCallback(e){if(!(!this._errorCallback||this._errors.has(e))){this._errors.add(e);try{this._errorCallback(e,this.getEntries())}catch(e){console.error(`ActionsRecorder onError callback error:`,e)}}}_maxEntriesDefaultHandler(){this._entries.shift()}};function Vh(e,t,n,r={}){let i=e[t];i[Symbol.for(`Tapped method`)]||(e[t]=(...t)=>{let a=Object.assign({},r),o;try{o=n.before?.(a,t);let r=i.apply(e,t);return o&&n.after?.(a,r),r}catch(e){throw o&&n.error?.(a,e),e}},e[t][Symbol.for(`Tapped method`)]=i)}function Hh(e,t=new WeakSet){if(!e||[`boolean`,`number`,`string`].includes(typeof e))return e;if(typeof e.toJSON==`function`){let n=e.toJSON();if(xn(n)||Array.isArray(n)||[`string`,`number`,`boolean`].includes(typeof n))return Hh(n,t)}if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(Wh(e)||typeof e!=`object`)return{type:typeof e,constructor:e.constructor?.name||`unknown`,string:String(e)};if(e instanceof File||e instanceof Blob||e instanceof FormData||e instanceof DataTransfer)return String(e);if(t.has(e))return;if(t.add(e),Array.isArray(e))return e.length?e.map(e=>Hh(e,t)):void 0;let n={},r=[];e.domEvent&&(r.push(`domEvent`,`domTarget`,`view`,`document`),n.domEvent=Uh(e.domEvent),n.target=Hh(e.target),e.dataTransfer&&(n.dataTransfer={types:e.dataTransfer.types,htmlData:e.dataTransfer.getData(`text/html`),files:Hh(e.dataTransfer.files)}));for(let[i,a]of Object.entries(e)){if(i.startsWith(`_`)||r.includes(i)||typeof a==`function`)continue;let e=Hh(a,t);e!==void 0&&(n[i]=e)}if(Symbol.iterator in e){let r=Array.from(e[Symbol.iterator]()).map(e=>Hh(e,t));r.length&&(n._items=r)}return Object.keys(n).length?n:void 0}function Uh(e){let t={type:e.type,target:n(e.target)};e instanceof MouseEvent&&(t={...t,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey}),e instanceof KeyboardEvent&&(t={...t,key:e.key,code:e.code,keyCode:e.keyCode,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,repeat:e.repeat}),e instanceof InputEvent&&(t={...t,data:e.data,inputType:e.inputType,isComposing:e.isComposing}),e instanceof PointerEvent&&(t={...t,isPrimary:e.isPrimary});function n(e){return e?e instanceof Element?{tagName:e.tagName,className:e.className,id:e.id}:e instanceof Window||e instanceof Document?{type:e.constructor.name}:{}:null}return t}function Wh(e){return e&&typeof e.is==`function`}const Gh=`contentEditing`,Kh=`common`;var qh=class{keystrokeInfos=new Map;_editor;constructor(e){this._editor=e;let t=e.config.get(`menuBar.isVisible`),n=e.locale.t;this.addKeystrokeInfoCategory({id:Gh,label:n(`Content editing keystrokes`),description:n(`These keyboard shortcuts allow for quick access to content editing features.`)});let r=[{label:n(`Close contextual balloons, dropdowns, and dialogs`),keystroke:`Esc`},{label:n(`Open the accessibility help dialog`),keystroke:`Alt+0`},{label:n(`Move focus between form fields (inputs, buttons, etc.)`),keystroke:[[`Tab`],[`Shift+Tab`]]},{label:n(`Move focus to the toolbar, navigate between toolbars`),keystroke:`Alt+F10`,mayRequireFn:!0},{label:n(`Navigate through the toolbar or menu bar`),keystroke:[[`arrowup`],[`arrowright`],[`arrowdown`],[`arrowleft`]]},{label:n(`Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content.`),keystroke:[[`Enter`],[`Space`]]}];t&&r.push({label:n(`Move focus to the menu bar, navigate between menu bars`),keystroke:`Alt+F9`,mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:`navigation`,label:n(`User interface and content navigation keystrokes`),description:n(`Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface.`),groups:[{id:`common`,keystrokes:r}]})}addKeystrokeInfoCategory({id:e,label:t,description:n,groups:r}){this.keystrokeInfos.set(e,{id:e,label:t,description:n,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:Kh}),r&&r.forEach(t=>{this.addKeystrokeInfoGroup({categoryId:e,...t})})}addKeystrokeInfoGroup({categoryId:e=Gh,id:t,label:n,keystrokes:r}){let i=this.keystrokeInfos.get(e);if(!i)throw new w(`accessibility-unknown-keystroke-info-category`,this._editor,{groupId:t,categoryId:e});i.groups.set(t,{id:t,label:n,keystrokes:r||[]})}addKeystrokeInfos({categoryId:e=Gh,groupId:t=Kh,keystrokes:n}){if(!this.keystrokeInfos.has(e))throw new w(`accessibility-unknown-keystroke-info-category`,this._editor,{categoryId:e,keystrokes:n});let r=this.keystrokeInfos.get(e);if(!r.groups.has(t))throw new w(`accessibility-unknown-keystroke-info-group`,this._editor,{groupId:t,categoryId:e,keystrokes:n});r.groups.get(t).keystrokes.push(...n)}};function Jh(e){return{sessionId:eg(),pageSessionId:tg(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:Yh(e),plugins:Xh(e.plugins),distribution:Qh(),env:$h(),integration:Object.create(null),menuBar:{isVisible:!!e.config.get(`menuBar.isVisible`)},language:{ui:e.locale.uiLanguage,content:e.locale.contentLanguage},toolbar:{main:Zh(e.config.get(`toolbar`)),block:Zh(e.config.get(`blockToolbar`)),balloon:Zh(e.config.get(`balloonToolbar`))}}}function Yh(e){return Object.getPrototypeOf(e).constructor.editorName}function Xh(e){return Array.from(e).filter(([e])=>!!e.pluginName).map(([e])=>{let{pluginName:t,isContextPlugin:n,isOfficialPlugin:r,isPremiumPlugin:i}=e;return{isContext:!!n,isOfficial:!!r,isPremium:!!i,name:t}})}function Zh(e){if(!e)return;let t=Array.isArray(e)?{items:e}:e,n=i(t.items||[]);return{isMultiline:n.includes(`-`),shouldNotGroupWhenFull:!!t.shouldNotGroupWhenFull,items:r(n)};function r(e){return e.filter(e=>e!==`|`&&e!==`-`)}function i(e){return e.flatMap(e=>typeof e==`string`?[e]:i(e.items))}}function Qh(){return{channel:window[Symbol.for(`cke distribution`)]||`sh`}}function $h(){let e=`unknown`,t=`unknown`;return p.isMac?e=`mac`:p.isWindows?e=`windows`:p.isiOS?e=`ios`:p.isAndroid&&(e=`android`),p.isGecko?t=`gecko`:p.isBlink?t=`blink`:p.isSafari&&(t=`safari`),{os:e,browser:t}}function eg(){return localStorage.getItem(`__ckeditor-session-id`)||localStorage.setItem(`__ckeditor-session-id`,he()),localStorage.getItem(`__ckeditor-session-id`)}function tg(){return u.window.CKEDITOR_PAGE_SESSION_ID=u.window.CKEDITOR_PAGE_SESSION_ID||he(),u.window.CKEDITOR_PAGE_SESSION_ID}const ng=D();var rg=class extends ng{static get editorName(){return`Editor`}accessibility;commands;config;conversion;data;editing;locale;model;plugins;keystrokes;t;static defaultConfig;static builtinPlugins;_context;_readOnlyLocks;_registeredRootsAttributesKeys=new Set;static get _throwErrorWhenUsedAsAPlugin(){return!0}constructor(e={}){if(super(),typeof e!=`object`||Array.isArray(e))throw new w(`editor-config-invalid-type`);if(`sanitizeHtml`in e)throw new w(`editor-config-sanitizehtml-not-supported`);let t=this.constructor,{translations:n,...r}=t.defaultConfig||{},{translations:i=n,...a}=e,o=e.language||r.language;this._context=e.context||new po({language:o,translations:i}),this._context._addEditor(this,!e.context);let s=Array.from(t.builtinPlugins||[]);this.config=new hr(a,r),this.config.define(`plugins`,s),this.config.define(this._context._getEditorConfig()),l(this.config),this.plugins=new fo(this,s,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new lo,this.set(`state`,`initializing`),this.once(`ready`,()=>this.state=`ready`,{priority:`high`}),this.once(`destroy`,()=>this.state=`destroyed`,{priority:`high`}),this.model=new Dp(this.config),this.on(`change:isReadOnly`,()=>{this.model.document.isReadOnly=this.isReadOnly});let c=new Ho;this.data=new Ed(this.model,c),this.editing=new Qu(this.model,c),this.editing.view.document.bind(`isReadOnly`).to(this),this.conversion=new Dd([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 go(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new qh(this),u(this);function l(e){let t=e.get(`licenseKey`);if(!t&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(t=window.CKEDITOR_GLOBAL_LICENSE_KEY,e.set(`licenseKey`,t)),!t)throw new w(`license-key-missing`)}function u(e){let t=e.config.get(`licenseKey`),n=window[Symbol.for(`cke distribution`)]||`sh`;function r(t,n){e.enableReadOnlyMode(Symbol(`invalidLicense`)),e._showLicenseError(t,n)}function i(e){return[`exp`,`jti`,`vc`].every(t=>t in e)}function a(e){return Object.getOwnPropertyNames(e).sort().filter(t=>t!=`vc`&&e[t]!=null).map(t=>e[t])}function o(e){let{hostname:t}=new URL(window.location.href);if(e.includes(t))return!0;let n=t.split(`.`);return e.filter(e=>e.includes(`*`)).map(e=>e.split(`.`)).filter(e=>e.length<=n.length).map(e=>Array(n.length-e.length).fill(e[0]===`*`?`*`:``).concat(e)).some(e=>n.every((t,n)=>e[n]===t||e[n]===`*`))}function s(e){let t=e[0].toUpperCase()+e.slice(1),n=e===`evaluation`?`an`:`a`;console.info(`%cCKEditor 5 ${t} License`,`color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;`),console.warn(`⚠️ You are using ${n} ${e} license of CKEditor 5${e===`trial`?` which is for evaluation purposes only`:``}. For production usage, please obtain a production license at https://portal.ckeditor.com/`)}if(t==`GPL`){n==`cloud`&&r(`distributionChannel`);return}let c=ca(t);if(!c){r(`invalid`);return}if(!i(c)){r(`invalid`);return}if(c.distributionChannel&&!A(c.distributionChannel).includes(n)){r(`distributionChannel`);return}if(Zi(a(c))!=c.vc.toLowerCase()){r(`invalid`);return}if(new Date(c.exp*1e3)0&&!o(l)){r(`domainLimit`);return}if([`evaluation`,`trial`].includes(c.licenseType)&&c.exp*1e3{r(`evaluationLimit`)},6e5);e.on(`destroy`,()=>{clearTimeout(t)})}c.usageEndpoint&&e.once(`ready`,()=>{let n={requestId:he(),requestTime:Math.round(Date.now()/1e3),license:t,editor:ig(e)};e._sendUsageRequest(c.usageEndpoint,n).then(e=>{let{status:t,message:n}=e;n&&console.warn(n),t!=`ok`&&r(`usageLimit`)},()=>{ye(`license-key-validation-endpoint-not-reachable`,{url:c.usageEndpoint})})},{priority:`high`})}}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new w(`editor-isreadonly-has-no-setter`)}enableReadOnlyMode(e){if(typeof e!=`string`&&typeof e!=`symbol`)throw new w(`editor-read-only-lock-id-invalid`,null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),this._readOnlyLocks.size===1&&this.fire(`change:isReadOnly`,`isReadOnly`,!0,!1))}disableReadOnlyMode(e){if(typeof e!=`string`&&typeof e!=`symbol`)throw new w(`editor-read-only-lock-id-invalid`,null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),this._readOnlyLocks.size===0&&this.fire(`change:isReadOnly`,`isReadOnly`,!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}async initPlugins(){let e=this.config,t=e.get(`plugins`),n=e.get(`removePlugins`)||[],r=e.get(`extraPlugins`)||[],i=e.get(`substitutePlugins`)||[],a=await this.plugins.init(t.concat(r),n,i);return o(this),a;function o(e){let t=e.config.get(`licenseKey`);if(t===`GPL`)return;let n=ca(t);if(!n)return;let r=[...e.plugins].map(([e])=>e).find(e=>!e.pluginName||!e.licenseFeatureCode?!1:ua(n,e.licenseFeatureCode));r&&(e.enableReadOnlyMode(Symbol(`invalidLicense`)),e._showLicenseError(`pluginNotAllowed`,r.pluginName))}}async destroy(){this.state==`initializing`&&await new Promise(e=>this.once(`ready`,e)),this.fire(`destroy`),this.stopListening(),this.commands.destroy(),await this.plugins.destroy(),this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy(),await this._context._removeEditor(this)}execute(e,...t){try{return this.commands.execute(e,...t)}catch(e){w.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}registerRootAttribute(e){this._registeredRootsAttributesKeys.has(e)||(this._registeredRootsAttributesKeys.add(e),this.editing.model.schema.extend(`$root`,{allowAttributes:e}))}getRootAttributes(e=`main`){let t=this.model.document.getRoot(e);if(!t)throw new w(`get-root-attributes-missing-root`,this,{rootName:e});let n={};for(let e of this._registeredRootsAttributesKeys)n[e]=t.hasAttribute(e)?t.getAttribute(e):null;return n}static create(...e){throw Error(`This is an abstract method.`)}static Context=po;static EditorWatchdog=Mh;static ContextWatchdog=Lh;_showLicenseError(e,t){setTimeout(()=>{if(e==`invalid`)throw new w(`invalid-license-key`);if(e==`expired`)throw new w(`license-key-expired`);if(e==`domainLimit`)throw new w(`license-key-domain-limit`);if(e==`pluginNotAllowed`){let e=t.replace(/(Editing|UI)$/,``);throw new w(`license-key-plugin-not-allowed`,null,{pluginName:this.plugins.has(e)?e:t})}if(e==`featureNotAllowed`)throw new w(`license-key-feature-not-allowed`,null,{featureName:t});if(e==`evaluationLimit`)throw new w(`license-key-evaluation-limit`);if(e==`trialLimit`)throw new w(`license-key-trial-limit`);if(e==`developmentLimit`)throw new w(`license-key-development-limit`);if(e==`usageLimit`)throw new w(`license-key-usage-limit`);if(e==`distributionChannel`)throw new w(`license-key-invalid-distribution-channel`)},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){let n=new Headers({"Content-Type":`application/json`}),r=await fetch(new URL(e),{method:`POST`,headers:n,body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP Response: ${r.status}`);return r.json()}};function ig(e){let t=Jh(e);function n(e,n){if(Je(t,e)!==void 0)throw new w(`editor-usage-data-path-already-set`,{path:e});On(t,e,n)}return e.fire(`collectUsageData`,{setUsageData:n}),t}function ag(e){if(!An(e.updateSourceElement))throw new w(`attachtoform-missing-elementapi-interface`,e);let t=e.sourceElement;if(og(t)&&t.form){let n,r=t.form,i=()=>e.updateSourceElement();An(r.submit)&&(n=r.submit,r.submit=()=>{i(),n.apply(r)}),r.addEventListener(`submit`,i),e.on(`destroy`,()=>{r.removeEventListener(`submit`,i),n&&(r.submit=n)})}}function og(e){return!!e&&e.tagName.toLowerCase()===`textarea`}function sg(e){class t extends e{sourceElement;updateSourceElement(e){if(!this.sourceElement)throw new w(`editor-missing-sourceelement`,this);let t=this.config.get(`updateSourceElementOnDestroy`),n=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!n){Ur(this.sourceElement,``);return}let r=typeof e==`string`?e:this.data.get();Ur(this.sourceElement,r)}}return t}function cg(e,t){if(t.ckeditorInstance)throw new w(`editor-source-element-already-used`,e);t.ckeditorInstance=e,e.once(`destroy`,()=>{delete t.ckeditorInstance})}const lg=[[`description`,`$description`],[`title`,`$title`]];function ug(e){let t=e.config.get(`roots`);for(let[n,r]of Object.entries(t)){let t=null;for(let[e,n]of lg)r[e]==null||r.modelAttributes&&n in r.modelAttributes||(t||={...r.modelAttributes},t[n]=r[e]);t&&e.config.set(`roots.${n}.modelAttributes`,t)}let n=e.config.get(`roots`),r=!1;for(let t of Object.values(n))for(let n of Object.keys(t.modelAttributes||{}))e.registerRootAttribute(n),r=!0;r&&e.data.once(`init`,()=>{e.model.enqueueChange({isUndoable:!1},t=>{for(let[r,i]of Object.entries(n)){let n=e.model.document.getRoot(r);if(n)for(let[e,r]of Object.entries(i.modelAttributes||{}))r!==null&&t.setAttribute(e,r,n)}})})}function dg(e,t,n=`main`,r=!1){let i=t.get(`root`),a=t.get(`roots`)||Object.create(null);if(!xn(a))throw new w(`editor-create-roots-not-plain-object`,null);if(i){if(!n)throw new w(`editor-create-multi-root-with-main`,null);if(n in a)throw new w(`editor-create-roots-with-main`,null)}n&&!a[n]&&(a[n]=i||Object.create(null));let o=mg(e),s=gg(t,o,n),c=Array.from(new Set([...o?Object.keys(e):[],...Object.keys(a),...Object.keys(s)]));for(let n of c){let i=a[n]||Object.create(null),c=o?e[n]:e;if(!r&&xg(c)){if(i.element)throw new w(`editor-create-root-element-overspecified`,null);i.element=c}if(r&&xg(i.element)&&(T(`editor-create-root-element-not-supported`),i.element=void 0),i.initialData===void 0)if(s[n]===void 0){let e=xg(i.element)?i.element:void 0;i.initialData=hg(c||e||r&&t.get(`attachTo`)||``)}else if(c&&!xg(c))throw new w(`editor-create-initial-data-overspecified`,null);else i.initialData=s[n];else if(c&&!xg(c))throw new w(`editor-create-root-initial-data-overspecified`,null);else if(s[n]!==void 0)throw new w(`editor-create-legacy-initial-data-overspecified`,null);i.placeholder??=_g(t,`placeholder`,n),i.label??=_g(t,`label`,n),i.modelElement||=`$root`,i.element=vg(i.element),a[n]=i}if(r&&xg(e)){if(t.get(`attachTo`))throw new w(`editor-create-attachto-overspecified`,null);t.set(`attachTo`,e)}if(!r&&t.get(`attachTo`))throw new w(`editor-create-attachto-ignored`,null);t.set(`roots`,a)}function fg(e,t){return typeof e==`string`||xg(e)||t&&Object.keys(t).length?{sourceElementOrData:e,editorConfig:t}:{sourceElementOrData:``,editorConfig:e}}function pg(e,t){return t&&Object.keys(t).length||Object.keys(e).length==0||Object.values(e).every(e=>typeof e==`string`||xg(e))?{sourceElementsOrData:e,editorConfig:t}:{sourceElementsOrData:{},editorConfig:e}}function mg(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&!xg(e)}function hg(e){return xg(e)?Er(e):e}function gg(e,t,n){return t||!n?e.get(`initialData`)||Object.create(null):{[n]:e.get(`initialData`)}}function _g(e,t,n){let r=e.get(t);if(r)return typeof r==`string`?r:r[n]}function vg(e){if(e==null)return;if(xg(e))return bg(e.tagName),e;if(typeof e==`string`)return bg(e),{name:e};let{name:t,classes:n,styles:r,attributes:i}=e;t!==void 0&&bg(t);let{class:a,style:o,...s}=i||{},c=!!i&&`class`in i,l=!!r&&Object.keys(r).length>0,u=l&&!!o;u&&T(`editor-root-element-styles-overspecified`);let d=[...yg(n),...yg(a)],f={...s};return c&&(f.class=``),u?f.style=``:o&&(f.style=o),{...t!==void 0&&{name:t},...d.length&&{classes:d},...l&&{styles:r},...Object.keys(f).length&&{attributes:f}}}function yg(e){return e?A(e).flatMap(e=>e.split(/\s+/)).filter(Boolean):[]}function bg(e){if(typeof e!=`string`||!/^[A-Za-z][A-Za-z0-9_-]*$/.test(e))throw new w(`editor-wrong-element-name`,null,{name:e});if([`textarea`,`input`].includes(e.toLowerCase()))throw new w(`editor-wrong-element`,null)}function xg(e){return jn(e)}function Sg(e){let t=e.model.schema,n=e.model.document;for(let e of n.roots)if(!(e===n.graveyard||!e.isAttached())&&!t.isLimit(e))throw new w(`editor-root-element-is-not-limit`,null,{rootName:e.rootName,elementName:e.name})}function Cg(e,t){let n=e.model.document.getRoot(t);return e.model.schema.checkChild(n,`$block`)}var wg=class extends ho{_actions;static get pluginName(){return`PendingActions`}static get isOfficialPlugin(){return!0}init(){this.set(`hasAny`,!1),this._actions=new Fi({idProperty:`_id`}),this._actions.delegate(`add`,`remove`).to(this)}add(e){if(typeof e!=`string`)throw new w(`pendingactions-add-invalid-message`,this);let t=new(D());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]()}},Tg=``,Eg=``,Dg=``,Og=``,kg=``,Ag=``,jg=``,Mg=``,Ng=``,Pg=``,Fg=``,Ig=``,Lg=``,Rg=``,zg=``,Bg=``,Vg=``,Hg=``,Ug=``,Wg=``,Gg=``,Kg=``,qg=``,Jg=``,Yg=``,Xg=``,Zg=``,Qg=``,$g=``,e_=``,t_=``,n_=``,r_=``,i_=``,a_=``,Jee=``,o_=``,s_=``,c_=``,Yee=``,l_=``,Xee=``,Zee=``,Qee=``,u_=``,$ee=``,d_=``,f_=``,ete=``,p_=``,m_=``,tte=``,h_=``,g_=``,nte=``,rte=``,ite=``,ate=``,ote=``,ste=``,__=``,v_=``,y_=``,cte=``,b_=``,lte=``,x_=``,S_=``,ute=``,dte=``,fte=``,pte=``,mte=``,hte=``,gte=``,C_=``,w_=``,T_=``,E_=``,D_=``,_te=``,O_=``,k_=``,vte=``,yte=``,A_=``,j_=``,M_=``,N_=``,P_=``,F_=``,I_=``,L_=``,R_=``,z_=``,B_=``,V_=``,H_=``,U_=``,W_=``,G_=``,K_=``,q_=``,J_=``,Y_=``,X_=``,Z_=``,Q_=``,$_=``,ev=``,tv=``,nv=``,rv=``,iv=``,av=``,ov=``,sv=``,cv=``,lv=``,bte=``,xte=``,uv=``,dv=``,fv=``,pv=``,mv=``,hv=``,gv=``,_v=``,vv=``,yv=``,bv=``,xv=``,Sv=``,Cv=``,wv=``,Tv=``,Ev=``,Dv=``,Ov=``,kv=``,Av=``,Ste=``,Cte=``,jv=``,Mv=``,wte=``,Nv=``,Pv=`
`,Fv=``,Iv=``,Lv=``,Rv=``,zv=``,Bv=``,Vv=``,Hv=``,Uv=`
`,Wv=``,Gv=``,Kv=`
`,qv=``,Jv=``,Yv=``,Xv=``,Zv=``,Qv=``,$v=``,ey=``,ty=``,ny=``,ry=``,iy=`
`,ay=``,oy=``,sy=``,cy=``,ly=``,uy=``,dy=``,fy=``,py=``,my=``,hy=``,gy=``,_y=``,vy=``,Tte=``,yy=``,by=``,xy=``,Sy=``,Ete=`
`,Dte=``,Cy=``,wy=``,Ote=``,kte=``,Ty=``,Ate=``,jte=``,Ey=``,Mte=``,Nte=``,Pte=``,Dy=``,Oy=``,ky=``,Ay=``,jy=``,My=``,Ny=``,Py=``,Fy=`
`,Iy=``,Ly=class e extends P{static presentationalAttributeNames=`alignment-baseline.baseline-shift.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-rendering.cursor.direction.display.dominant-baseline.fill.fill-opacity.fill-rule.filter.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.image-rendering.letter-spacing.lighting-color.marker-end.marker-mid.marker-start.mask.opacity.overflow.paint-order.pointer-events.shape-rendering.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.text-anchor.text-decoration.text-overflow.text-rendering.transform.unicode-bidi.vector-effect.visibility.white-space.word-spacing.writing-mode`.split(`.`);constructor(){super();let 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){let t=new DOMParser().parseFromString(this.content.trim(),`image/svg+xml`).querySelector(`svg`);if(!t)throw new w(`ui-iconview-invalid-svg`,this);let n=t.getAttribute(`viewBox`);n&&(this.viewBox=n);for(let{name:n,value:r}of Array.from(t.attributes))e.presentationalAttributeNames.includes(n)&&this.element.setAttribute(n,r);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;t.childNodes.length>0;)this.element.appendChild(t.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(`.ck-icon__fill`).forEach(e=>{e.style.fill=this.fillColor})}},Ry=class extends P{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});let 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`)}]})}},H=class extends P{children;labelView;iconView;keystrokeView;_focusDelayed=null;constructor(e,t=new Ry){super(e);let n=this.bindTemplate,r=he();this.set(`_ariaPressed`,!1),this.set(`_ariaChecked`,!1),this.set(`ariaLabel`,void 0),this.set(`ariaLabelledBy`,`ck-editor__aria-label_${r}`),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 Ly,this.iconView.extendTemplate({attributes:{class:`ck-button__icon`}}),this.iconView.bind(`content`).to(this,`icon`),this.keystrokeView=this._createKeystrokeView(),this.bind(`_tooltipString`).to(this,`tooltip`,this,`label`,this,`keystroke`,this._getTooltipString.bind(this));let i={tag:`button`,attributes:{class:[`ck`,`ck-button`,n.to(`class`),n.if(`isEnabled`,`ck-disabled`,e=>!e),n.if(`isVisible`,`ck-hidden`,e=>!e),n.to(`isOn`,e=>e?`ck-on`:`ck-off`),n.if(`withText`,`ck-button_with-text`),n.if(`withKeystroke`,`ck-button_with-keystroke`)],role:n.to(`role`),type:n.to(`type`,e=>e||`button`),tabindex:n.to(`tabindex`),"aria-checked":n.to(`_ariaChecked`),"aria-pressed":n.to(`_ariaPressed`),"aria-label":n.to(`ariaLabel`),"aria-labelledby":n.to(`ariaLabelledBy`),"aria-disabled":n.if(`isEnabled`,!0,e=>!e),"data-cke-tooltip-text":n.to(`_tooltipString`),"data-cke-tooltip-position":n.to(`tooltipPosition`)},children:this.children,on:{click:n.to(e=>{this.isEnabled?this.fire(`execute`):e.preventDefault()})}};this.bind(`_ariaPressed`).to(this,`isOn`,this,`isToggleable`,this,`role`,(e,t,n)=>!t||zy(n)?!1:String(!!e)),this.bind(`_ariaChecked`).to(this,`isOn`,this,`isToggleable`,this,`role`,(e,t,n)=>!t||!zy(n)?!1:String(!!e)),p.isSafari&&(this._focusDelayed||=Yi(()=>this.focus(),0),i.on.mousedown=n.to(()=>{this._focusDelayed()}),i.on.mouseup=n.to(()=>{this._focusDelayed.cancel()})),this.setTemplate(i)}render(){super.render(),this.icon&&this.children.add(this.iconView),this.on(`change:icon`,(e,t,n,r)=>{n&&!r?this.children.add(this.iconView,0):!n&&r&&this.children.remove(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(){let e=new P;return e.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-button__keystroke`]},children:[{text:this.bindTemplate.to(`keystroke`,e=>bi(e))}]}),e}_getTooltipString(e,t,n){return e?typeof e==`string`?e:(n&&=bi(n),e instanceof Function?e(t,n):`${t}${n?` (${n})`:``}`):``}};function zy(e){switch(e){case`radio`:case`checkbox`:case`option`:case`switch`:case`menuitemcheckbox`:case`menuitemradio`:return!0;default:return!1}}var By=class extends P{children;iconView;constructor(e,t={}){super(e);let n=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`,n.to(`class`)]},children:this.children}),t.icon&&(this.iconView=new Ly,this.iconView.content=t.icon,this.children.add(this.iconView));let r=new P(e);r.setTemplate({tag:`h2`,attributes:{class:[`ck`,`ck-form__header__label`],role:`presentation`},children:[{text:n.to(`label`)}]}),this.children.add(r)}};const Vy=E();var Hy=class extends Vy{focusables;focusTracker;keystrokeHandler;actions;constructor(e){if(super(),this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,e.actions&&e.keystrokeHandler)for(let t in e.actions){let n=e.actions[t];typeof n==`string`&&(n=[n]);for(let r of n)e.keystrokeHandler.set(r,(e,n)=>{this[t](),n()},e.keystrokeHandlerOptions)}this.on(`forwardCycle`,()=>this.focusFirst(),{priority:`low`}),this.on(`backwardCycle`,()=>this.focusLast(),{priority:`low`})}get first(){return this.focusables.find(Uy)||null}get last(){return this.focusables.filter(Uy).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return this.focusTracker.focusedElement===null?null:(this.focusables.find((t,n)=>{let r=t.element===this.focusTracker.focusedElement;return r&&(e=n),r}),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){let e=this.next;if(e&&this.focusables.getIndex(e)===this.current){this.fire(`forwardCycle`);return}e===this.first?this.fire(`forwardCycle`):this._focus(e,1)}focusPrevious(){let e=this.previous;if(e&&this.focusables.getIndex(e)===this.current){this.fire(`backwardCycle`);return}e===this.last?this.fire(`backwardCycle`):this._focus(e,-1)}chain(e){let t=()=>this.current===null?null:this.focusables.get(this.current);this.listenTo(e,`forwardCycle`,e=>{let n=t();this.focusNext(),n!==t()&&e.stop()},{priority:`low`}),this.listenTo(e,`backwardCycle`,e=>{let n=t();this.focusPrevious(),n!==t()&&e.stop()},{priority:`low`})}unchain(e){this.stopListening(e)}_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){let t=this.focusables.length;if(!t)return null;let n=this.current;if(n===null)return this[e===1?`first`:`last`];let r=this.focusables.get(n),i=(n+t+e)%t;do{let n=this.focusables.get(i);if(Uy(n)){r=n;break}i=(i+t+e)%t}while(i!==n);return r}};function Uy(e){return Wy(e)&&Yr(e.element)}function Wy(e){return`focus`in e&&typeof e.focus==`function`}function Gy(e){return Wy(e)&&`focusCycler`in e&&e.focusCycler instanceof Hy}var Ky=class extends P{children;keystrokes;focusCycler;_focusTracker;_focusables;constructor(e){super(e),this.children=this.createCollection(),this.keystrokes=new N,this._focusTracker=new M,this._focusables=new pa,this.focusCycler=new Hy({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(let t of e){let e=new H(this.locale),n;for(n in e.on(`execute`,()=>t.onExecute()),t.onCreate&&t.onCreate(e),t)n!=`onExecute`&&n!=`onCreate`&&e.set(n,t[n]);this.children.add(e)}this._updateFocusCyclableItems()}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}},qy=class extends P{children;constructor(e){super(e),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 Jy={SCREEN_CENTER:`screen-center`,EDITOR_CENTER:`editor-center`,EDITOR_TOP_SIDE:`editor-top-side`,EDITOR_TOP_CENTER:`editor-top-center`,EDITOR_BOTTOM_CENTER:`editor-bottom-center`,EDITOR_ABOVE_CENTER:`editor-above-center`,EDITOR_BELOW_CENTER:`editor-below-center`},Yy=Wr(`px`),Xy=Za(P);var Zy=class e extends Xy{parts;headerView;closeButtonView;actionsView;static defaultOffset=15;contentView;keystrokes;focusTracker;wasMoved=!1;_getDomRootElement;_getViewportOffset;_focusables;_focusCycler;constructor(e,{getDomRootElement:t,getViewportOffset:n,keystrokeHandlerOptions:r}){super(e);let i=this.bindTemplate,a=e.t;this.set(`className`,``),this.set(`ariaLabel`,a(`Editor dialog`)),this.set(`isModal`,!1),this.set(`position`,Jy.SCREEN_CENTER),this.set(`_isVisible`,!1),this.set(`_isTransparent`,!1),this.set(`_top`,0),this.set(`_left`,0),this._getDomRootElement=t,this._getViewportOffset=n,this.decorate(`moveTo`),this.parts=this.createCollection(),this.keystrokes=new N,this.focusTracker=new M,this._focusables=new pa,this._focusCycler=new Hy({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:`shift + tab`,focusNext:`tab`},keystrokeHandlerOptions:r}),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-dialog-overlay`,i.if(`isModal`,`ck-dialog-overlay__transparent`,e=>!e),i.if(`_isVisible`,`ck-hidden`,e=>!e)],tabindex:`-1`},children:[{tag:`div`,attributes:{tabindex:`-1`,class:[`ck`,`ck-dialog`,i.if(`isModal`,`ck-dialog_modal`),i.to(`className`)],role:`dialog`,"aria-label":i.to(`ariaLabel`),style:{top:i.to(`_top`,e=>Yy(e)),left:i.to(`_left`,e=>Yy(e)),visibility:i.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,{deltaX:t,deltaY:n})=>{this.wasMoved=!0,this.moveBy(t,n)}),this.listenTo(u.window,`resize`,()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.listenTo(u.document,`scroll`,()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.on(`change:_isVisible`,(e,t,n)=>{n&&(this._isTransparent=!0,setTimeout(()=>{this.updatePosition(),this._isTransparent=!1,this.focus()},10))}),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView&&!this.isModal?this.headerView.element:null}setupParts({icon:e,title:t,hasCloseButton:n=!0,content:r,actionButtons:i}){t&&(this.headerView=new By(this.locale,{icon:e}),n&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=t,this.ariaLabel=t,this.parts.add(this.headerView,0)),r&&(r instanceof P&&(r=[r]),this.contentView=new qy(this.locale),this.contentView.children.addMany(r),this.parts.add(this.contentView)),i&&(this.actionsView=new Ky(this.locale),this.actionsView.setButtons(i),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){let n=this._getViewportRect(),r=this._getDialogRect();e+r.width>n.right&&(e=n.right-r.width),e{this._focusables.add(e),this.focusTracker.add(e.element),Gy(e)&&this._focusCycler.chain(e.focusCycler)})}_createCloseButton(){let e=new H(this.locale),t=this.locale.t;return e.set({label:t(`Close`),tooltip:!0,icon:s_}),e.on(`execute`,()=>this.fire(`close`,{source:`closeButton`})),e}},Qy=class e extends F{view;static _visibleDialogPlugin;_onHide;static get pluginName(){return`Dialog`}static get isOfficialPlugin(){return!0}constructor(e){super(e);let 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(),e._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`,()=>{e._visibleDialogPlugin&&e._visibleDialogPlugin._hide()}),this.on(`hide`,()=>{this._onHide&&=(this._onHide(this),void 0)},{priority:`low`})}_initFocusToggler(){let e=this.editor;e.keystrokes.set(`Ctrl+F6`,(t,n)=>{!this.isOpen||this.view.isModal||(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),n())})}_initMultiRootIntegration(){let e=this.editor.model;e.document.on(`change:data`,()=>{if(!this.view)return;let t=e.document.differ.getChangedRoots();for(let e of t)e.state&&this.view.updatePosition()})}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:t,icon:n,title:r,hasCloseButton:i=!0,content:a,actionButtons:o,className:s,isModal:c,position:l,onHide:u,getRootName:d,keystrokeHandlerOptions:f}){let p=this.editor;this.view=new Zy(p.locale,{getDomRootElement:()=>{let e=d?.()??this.editor.model.document.selection.anchor.root.rootName;return!e||!p.editing.view.domRoots.has(e)?null:p.editing.view.getDomRoot(e)??null},getViewportOffset:()=>p.ui.viewportOffset,keystrokeHandlerOptions:f});let m=this.view;m.on(`close`,()=>{this.hide()}),p.ui.view.body.add(m),p.keystrokes.listenTo(m.element),l||=c?Jy.SCREEN_CENTER:Jy.EDITOR_CENTER,c&&this._lockBodyScroll(),m.set({position:l,_isVisible:!0,className:s,isModal:c}),m.setupParts({icon:n,title:r,hasCloseButton:i,content:a,actionButtons:o}),this.id=t,u&&(this._onHide=u),this.isOpen=!0,e._visibleDialogPlugin=this}hide(){e._visibleDialogPlugin&&e._visibleDialogPlugin.fire(`hide:${e._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;let t=this.editor,n=this.view;n.isModal&&this._unlockBodyScroll(),n.contentView&&n.contentView.reset(),t.ui.view.body.remove(n),t.ui.focusTracker.remove(n.element),t.keystrokes.stopListening(n.element),n.destroy(),t.editing.view.focus(),this.id=null,this.isOpen=!1,e._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add(`ck-dialog-scroll-locked`)}_unlockBodyScroll(){document.documentElement.classList.remove(`ck-dialog-scroll-locked`)}},$y=class extends H{_checkIconHolderView=new eb;constructor(e,t=new Ry){super(e,t),this.set({hasCheckSpace:!1,_hasCheck:this.isToggleable});let n=this.bindTemplate;this.extendTemplate({attributes:{class:[`ck-list-item-button`,n.if(`isToggleable`,`ck-list-item-button_toggleable`)]}}),this.bind(`_hasCheck`).to(this,`hasCheckSpace`,this,`isToggleable`,(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,n)=>{let{children:r,_checkIconHolderView:i}=this;n?r.add(i,0):r.remove(i)})}},eb=class extends P{children;_checkIconView=this._createCheckIconView();constructor(){super();let 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,n)=>{let{children:r,_checkIconView:i}=this;n&&!r.has(i)?r.add(i):!n&&r.has(i)&&r.remove(i)})}_createCheckIconView(){let e=new Ly;return e.content=l_,e.extendTemplate({attributes:{class:`ck-list-item-button__check-icon`}}),e}},U=class extends $y{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:`menuitem`}),this.extendTemplate({attributes:{class:[`ck-menu-bar__menu__item__button`]}})}},tb=class extends F{contentView=null;static get requires(){return[Qy]}static get pluginName(){return`AccessibilityHelp`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t;e.ui.componentFactory.add(`accessibilityHelp`,()=>{let e=this._createButton(H);return e.set({tooltip:!0,withText:!1,label:t(`Accessibility help`)}),e}),e.ui.componentFactory.add(`menuBar:accessibilityHelp`,()=>{let e=this._createButton(U);return e.label=t(`Accessibility`),e}),e.keystrokes.set(`Alt+0`,(e,t)=>{this._toggleDialog(),t()}),this._setupRootLabels()}_createButton(e){let t=this.editor,n=t.plugins.get(`Dialog`),r=t.locale,i=new e(r);return i.set({keystroke:`Alt+0`,icon:Tg,isToggleable:!0}),i.on(`execute`,()=>this._toggleDialog()),i.bind(`isOn`).to(n,`id`,e=>e===`accessibilityHelp`),i}_setupRootLabels(){let e=this.editor,t=e.editing.view,n=e.t;e.ui.on(`ready`,()=>{t.change(e=>{for(let n of t.document.roots)r(e,n)}),e.on(`addRoot`,(n,i)=>{let a=e.editing.view.document.getRoot(i.rootName);t.change(e=>r(e,a))},{priority:`low`})});function r(e,t){let r=[t.getAttribute(`aria-label`),n(`Press %0 for help.`,[bi(`Alt+0`)])].filter(e=>e).join(`. `);e.setAttribute(`aria-label`,r,t)}}_toggleDialog(){let e=this.editor,t=e.plugins.get(`Dialog`),n=e.locale.t;this.contentView||=new to(e.locale,e.accessibility.keystrokeInfos),t.id===`accessibilityHelp`?t.hide():t.show({id:`accessibilityHelp`,className:`ck-accessibility-help-dialog`,title:n(`Accessibility help`),icon:Tg,hasCloseButton:!0,content:this.contentView})}},nb=class e extends pa{locale;_bodyCollectionContainer;static _bodyWrapper;constructor(e,t=[]){super(t),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new ga({tag:`div`,attributes:{class:[`ck`,`ck-reset_all`,`ck-body`,`ck-rounded-corners`],dir:this.locale.uiLanguageDirection,role:`application`},children:this}).render(),(!e._bodyWrapper||!e._bodyWrapper.isConnected)&&(e._bodyWrapper=mr(document,`div`,{class:`ck-body-wrapper`}),document.body.appendChild(e._bodyWrapper)),e._bodyWrapper.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove(),e._bodyWrapper&&!e._bodyWrapper.childElementCount&&(e._bodyWrapper.remove(),delete e._bodyWrapper)}};const rb=Wr(`px`),ib={top:-99999,left:-99999,name:`arrowless`,config:{withArrow:!1}};var ab=class e extends P{content;_pinWhenIsVisibleCallback;_resizeObserver;constructor(e){super(e);let 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_${e}`),t.if(`isVisible`,`ck-balloon-panel_visible`),t.if(`withArrow`,`ck-balloon-panel_with-arrow`),t.to(`class`)],style:{top:t.to(`top`,rb),left:t.to(`left`,rb)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(t){let n=ob(t.target);if(n&&!Yr(n))return!1;this.show();let r=e.defaultPositions,i=Object.assign({},{element:this.element,positions:[r.southArrowNorth,r.southArrowNorthMiddleWest,r.southArrowNorthMiddleEast,r.southArrowNorthWest,r.southArrowNorthEast,r.northArrowSouth,r.northArrowSouthMiddleWest,r.northArrowSouthMiddleEast,r.northArrowSouthWest,r.northArrowSouthEast,r.viewportStickyNorth],limiter:u.document.body,fitInViewport:!0},t),a=e._getOptimalPosition(i)||ib,o=parseInt(a.left),s=parseInt(a.top),c=a.name,{withArrow:l=!0}=a.config||{};return this.top=s,this.left=o,this.position=c,this.withArrow=l,!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=ob(e.target),n=e.limiter?ob(e.limiter):u.document.body;if(this.listenTo(u.document,`scroll`,(r,i)=>{let a=i.target,o=t&&a.contains(t),s=n&&a.contains(n);(o||s||!t||!n)&&this.attachTo(e)},{useCapture:!0}),this.listenTo(u.window,`resize`,()=>{this.attachTo(e)}),!this._resizeObserver&&(t&&jr(t)&&(t=t.parentElement),t)){let e=()=>{Yr(t)||this.unpin()};this._resizeObserver=new Hr(t,e)}return!0}_stopPinning(){this.stopListening(u.document,`scroll`),this.stopListening(u.window,`resize`),this._resizeObserver&&=(this._resizeObserver.destroy(),null)}static generatePositions(t={}){let{sideOffset:n=e.arrowSideOffset,heightOffset:r=e.arrowHeightOffset,stickyVerticalOffset:i=e.stickyVerticalOffset,config:a}=t;return{northWestArrowSouthWest:(e,t)=>({top:o(e,t),left:e.left-n,name:`arrow_sw`,...a&&{config:a}}),northWestArrowSouthMiddleWest:(e,t)=>({top:o(e,t),left:e.left-t.width*.25-n,name:`arrow_smw`,...a&&{config:a}}),northWestArrowSouth:(e,t)=>({top:o(e,t),left:e.left-t.width/2,name:`arrow_s`,...a&&{config:a}}),northWestArrowSouthMiddleEast:(e,t)=>({top:o(e,t),left:e.left-t.width*.75+n,name:`arrow_sme`,...a&&{config:a}}),northWestArrowSouthEast:(e,t)=>({top:o(e,t),left:e.left-t.width+n,name:`arrow_se`,...a&&{config:a}}),northArrowSouthWest:(e,t)=>({top:o(e,t),left:e.left+e.width/2-n,name:`arrow_sw`,...a&&{config:a}}),northArrowSouthMiddleWest:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width*.25-n,name:`arrow_smw`,...a&&{config:a}}),northArrowSouth:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width/2,name:`arrow_s`,...a&&{config:a}}),northArrowSouthMiddleEast:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width*.75+n,name:`arrow_sme`,...a&&{config:a}}),northArrowSouthEast:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width+n,name:`arrow_se`,...a&&{config:a}}),northEastArrowSouthWest:(e,t)=>({top:o(e,t),left:e.right-n,name:`arrow_sw`,...a&&{config:a}}),northEastArrowSouthMiddleWest:(e,t)=>({top:o(e,t),left:e.right-t.width*.25-n,name:`arrow_smw`,...a&&{config:a}}),northEastArrowSouth:(e,t)=>({top:o(e,t),left:e.right-t.width/2,name:`arrow_s`,...a&&{config:a}}),northEastArrowSouthMiddleEast:(e,t)=>({top:o(e,t),left:e.right-t.width*.75+n,name:`arrow_sme`,...a&&{config:a}}),northEastArrowSouthEast:(e,t)=>({top:o(e,t),left:e.right-t.width+n,name:`arrow_se`,...a&&{config:a}}),southWestArrowNorthWest:e=>({top:s(e),left:e.left-n,name:`arrow_nw`,...a&&{config:a}}),southWestArrowNorthMiddleWest:(e,t)=>({top:s(e),left:e.left-t.width*.25-n,name:`arrow_nmw`,...a&&{config:a}}),southWestArrowNorth:(e,t)=>({top:s(e),left:e.left-t.width/2,name:`arrow_n`,...a&&{config:a}}),southWestArrowNorthMiddleEast:(e,t)=>({top:s(e),left:e.left-t.width*.75+n,name:`arrow_nme`,...a&&{config:a}}),southWestArrowNorthEast:(e,t)=>({top:s(e),left:e.left-t.width+n,name:`arrow_ne`,...a&&{config:a}}),southArrowNorthWest:e=>({top:s(e),left:e.left+e.width/2-n,name:`arrow_nw`,...a&&{config:a}}),southArrowNorthMiddleWest:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width*.25-n,name:`arrow_nmw`,...a&&{config:a}}),southArrowNorth:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width/2,name:`arrow_n`,...a&&{config:a}}),southArrowNorthMiddleEast:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width*.75+n,name:`arrow_nme`,...a&&{config:a}}),southArrowNorthEast:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width+n,name:`arrow_ne`,...a&&{config:a}}),southEastArrowNorthWest:e=>({top:s(e),left:e.right-n,name:`arrow_nw`,...a&&{config:a}}),southEastArrowNorthMiddleWest:(e,t)=>({top:s(e),left:e.right-t.width*.25-n,name:`arrow_nmw`,...a&&{config:a}}),southEastArrowNorth:(e,t)=>({top:s(e),left:e.right-t.width/2,name:`arrow_n`,...a&&{config:a}}),southEastArrowNorthMiddleEast:(e,t)=>({top:s(e),left:e.right-t.width*.75+n,name:`arrow_nme`,...a&&{config:a}}),southEastArrowNorthEast:(e,t)=>({top:s(e),left:e.right-t.width+n,name:`arrow_ne`,...a&&{config:a}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-r,name:`arrow_e`,...a&&{config:a}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+r,name:`arrow_w`,...a&&{config:a}}),viewportStickyNorth:(e,t,n)=>{let r=new O(u.document.body).getIntersection(n.getVisible());if(!r)return null;let o=r.getVisible();return!e.getIntersection(o)||!(o.top-e.top-ithis._showBalloon(),50,{leading:!0});_lastFocusedEditableElement=null;_balloonClass;constructor(e,t={}){super(),this.editor=e,this._balloonClass=t.balloonClass,e.on(`ready`,()=>this._handleEditorReady())}destroy(){let e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){let e=this.editor;this._isEnabled()&&e.ui.view&&(e.ui.focusTracker.on(`change:isFocused`,(e,t,n)=>{this._updateLastFocusedEditableElement(),n?this._showBalloon():this._hideBalloon()}),e.ui.focusTracker.on(`change:focusedElement`,(e,t,n)=>{this._updateLastFocusedEditableElement(),n&&this._showBalloon()}),e.ui.on(`update`,()=>{this._showBalloonThrottled()}))}_getNormalizedConfig(){return{side:this.editor.locale.contentLanguageDirection===`ltr`?`right`:`left`,position:`border`,verticalOffset:0,horizontalOffset:5}}_showBalloon(){let e=this._getBalloonAttachOptions();e&&(this._balloonView||=this._createBalloonView(),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_createBalloonView(){let e=this.editor,t=new ab,n=this._createBadgeContent();return t.content.add(n),this._balloonClass&&(t.class=this._balloonClass),e.ui.view.body.add(t),t}_getBalloonAttachOptions(){if(!this._lastFocusedEditableElement)return null;let e=this._getNormalizedConfig(),t=e.side===`right`?lb(this._lastFocusedEditableElement,e):ub(this._lastFocusedEditableElement,e);return{target:this._lastFocusedEditableElement,positions:[t]}}_updateLastFocusedEditableElement(){let e=this.editor,t=e.ui.focusTracker.isFocused,n=e.ui.focusTracker.focusedElement;if(!t||!n){this._lastFocusedEditableElement=null;return}let r=Array.from(e.ui.getEditableElementsNames()).map(t=>e.ui.getEditableElement(t));r.includes(n)?this._lastFocusedEditableElement=n:this._lastFocusedEditableElement=r[0]}};function lb(e,t){return db(e,t,(e,n)=>e.left+e.width-n.width-t.horizontalOffset)}function ub(e,t){return db(e,t,e=>e.left+t.horizontalOffset)}function db(e,t,n){return(r,i)=>{let a=new O(e);if(a.width<350||a.height<50)return null;let o;o=t.position===`inside`?a.bottom-i.height:a.bottom-i.height/2,o-=t.verticalOffset;let s=n(a,i),c=r.clone().moveTo(s,o).getIntersection(i.clone().moveTo(s,o)).getVisible();return!c||c.getArea()e.preventDefault())}}]})}},mb=class extends H{toggleSwitchView;constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:`ck-switchbutton`}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){let e=new P;return e.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-button__toggle`]},children:[{tag:`span`,attributes:{class:[`ck`,`ck-button__toggle__inner`]}}]}),e}};const hb=yb(H),gb=yb($y);var _b=class extends hb{},vb=class extends gb{};function yb(e){class t extends e{_fileInputView;constructor(...e){super(...e),this._fileInputView=new bb(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)}}return t}var bb=class extends P{constructor(e){super(e),this.set(`acceptedType`,void 0),this.set(`allowMultipleFiles`,!1);let 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?.files?.length&&this.fire(`done`,this.element.files),this.element.value=``})}})}open(){this.element.click()}},xb=class extends P{buttonView;children;constructor(e,t){super(e);let n=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`,n.if(`isCollapsed`,`ck-collapsible_collapsed`)]},children:[this.buttonView,{tag:`div`,attributes:{class:[`ck`,`ck-collapsible__children`],role:`region`,hidden:n.if(`isCollapsed`,`hidden`),"aria-labelledby":n.to(`_collapsibleAriaLabelUid`)},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){let e=new H(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:b_}),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}};function Sb(e,t){let n=e.t,r={Black:n(`Black`),"Dim grey":n(`Dim grey`),Grey:n(`Grey`),"Light grey":n(`Light grey`),White:n(`White`),Red:n(`Red`),Orange:n(`Orange`),Yellow:n(`Yellow`),"Light green":n(`Light green`),Green:n(`Green`),Aquamarine:n(`Aquamarine`),Turquoise:n(`Turquoise`),"Light blue":n(`Light blue`),Blue:n(`Blue`),Purple:n(`Purple`)};return t.map(e=>{let t=r[e.label];return t&&t!=e.label&&(e.label=t),e})}function Cb(e){return e.map(wb).filter(e=>!!e)}function wb(e){return typeof e==`string`?{model:e,label:e,hasBorder:!1,view:{name:`span`,styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:e.hasBorder===void 0?!1:e.hasBorder,view:{name:`span`,styles:{color:`${e.color}`}}}}var Tb=class extends H{constructor(e){super(e);let t=this.bindTemplate;this.set(`color`,void 0),this.set(`hasBorder`,!1),this.icon=m_,this.extendTemplate({attributes:{style:{backgroundColor:t.to(`color`,e=>p.isMediaForcedColors?null:e)},class:[`ck`,`ck-color-grid__tile`,t.if(`hasBorder`,`ck-color-selector__color-tile_bordered`)]}})}render(){super.render(),this.iconView.fillColor=`hsl(0, 0%, 100%)`}},Eb=class extends P{columns;items;focusTracker;keystrokes;constructor(e,t){super(e);let n=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t?.columns||5;let r={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set(`selectedColor`,void 0),this.items=this.createCollection(),this.focusTracker=new M,this.keystrokes=new N,this.items.on(`add`,(e,t)=>{t.isOn=t.color===this.selectedColor}),n.forEach(e=>{let t=new Tb;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on(`execute`,()=>{this.fire(`execute`,{value:e.color,hasBorder:e.options.hasBorder,label:e.label})}),this.items.add(t)}),this.setTemplate({tag:`div`,children:this.items,attributes:{class:[`ck`,`ck-color-grid`],style:r}}),this.on(`change:selectedColor`,(e,t,n)=>{for(let e of this.items)e.isOn=e.color===n})}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(let e of this.items)this.focusTracker.add(e.element);this.items.on(`add`,(e,t)=>{this.focusTracker.add(t.element)}),this.items.on(`remove`,(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element),$a({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale?.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}};const Db={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],olive:[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]};for(let e in Db)Object.freeze(Db[e]);var Ob=Object.freeze(Db),kb=jb,Ab={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function jb(e){var t,n=[],r=1,i;if(typeof e==`number`||typeof e==`number`)return{space:`rgb`,values:[e>>>16,(e&65280)>>>8,e&255],alpha:1};if(e=String(e).toLowerCase(),Ob[e])n=Ob[e].slice(),i=`rgb`;else if(e===`transparent`)r=0,i=`rgb`,n=[0,0,0];else if(e[0]===`#`){var a=e.slice(1),o=a.length,s=o<=4;r=1,s?(n=[parseInt(a[0]+a[0],16),parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16)],o===4&&(r=parseInt(a[3]+a[3],16)/255)):(n=[parseInt(a[0]+a[1],16),parseInt(a[2]+a[3],16),parseInt(a[4]+a[5],16)],o===8&&(r=parseInt(a[6]+a[7],16)/255)),n[0]||=0,n[1]||=0,n[2]||=0,i=`rgb`}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(e)){i=t[1].replace(/a$/,``);var c=i===`cmyk`?4:i===`gray`?1:3;n=t[2].trim().split(/\s*[,\/]\s*|\s+/),i===`color`&&(i=n.shift()),n=n.map(function(e,t){if(e[e.length-1]===`%`)return e=parseFloat(e)/100,t===3?e:i===`rgb`?e*255:i[0]===`h`||i[0]===`l`&&!t?e*100:i===`lab`?e*125:i===`lch`?t<2?e*150:e*360:i[0]===`o`&&!t?e:i===`oklab`?e*.4:i===`oklch`?t<2?e*.4:e*360:e;if(i[t]===`h`||t===2&&i[i.length-1]===`h`){if(Ab[e]!==void 0)return Ab[e];if(e.endsWith(`deg`))return parseFloat(e);if(e.endsWith(`turn`))return parseFloat(e)*360;if(e.endsWith(`grad`))return parseFloat(e)*360/400;if(e.endsWith(`rad`))return parseFloat(e)*180/Math.PI}return e===`none`?0:parseFloat(e)}),r=n.length>c?n.pop():1}else/[0-9](?:\s|\/|,)/.test(e)&&(n=e.match(/([0-9]+)/g).map(function(e){return parseFloat(e)}),i=e.match(/([a-z])/gi)?.join(``)?.toLowerCase()||`rgb`);return{space:i,values:n,alpha:r}}const Mb={};for(let e of Object.keys(Ob))Mb[Ob[e]]=e;const W={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`},oklab:{channels:3,labels:[`okl`,`oka`,`okb`]},lch:{channels:3,labels:`lch`},oklch:{channels:3,labels:[`okl`,`okc`,`okh`]},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`]}},Nb=(6/29)**3;function Pb(e){let t=e>.0031308?1.055*e**(1/2.4)-.055:e*12.92;return Math.min(Math.max(0,t),1)}function Fb(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(let e of Object.keys(W)){if(!(`channels`in W[e]))throw Error(`missing channels property: `+e);if(!(`labels`in W[e]))throw Error(`missing channel labels property: `+e);if(W[e].labels.length!==W[e].channels)throw Error(`channel and label counts mismatch: `+e);let{channels:t,labels:n}=W[e];delete W[e].channels,delete W[e].labels,Object.defineProperty(W[e],"channels",{value:t}),Object.defineProperty(W[e],"labels",{value:n})}W.rgb.hsl=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s,c;switch(a){case i:s=0;break;case t:s=(n-r)/o;break;case n:s=2+(r-t)/o;break;case r:s=4+(t-n)/o;break}s=Math.min(s*60,360),s<0&&(s+=360);let l=(i+a)/2;return c=a===i?0:l<=.5?o/(a+i):o/(2-a-i),[s,c*100,l*100]},W.rgb.hsv=function(e){let t,n,r,i,a,o=e[0]/255,s=e[1]/255,c=e[2]/255,l=Math.max(o,s,c),u=l-Math.min(o,s,c),d=function(e){return(l-e)/6/u+1/2};if(u===0)i=0,a=0;else{switch(a=u/l,t=d(o),n=d(s),r=d(c),l){case o:i=r-n;break;case s:i=1/3+t-r;break;case c:i=2/3+n-t;break}i<0?i+=1:i>1&&--i}return[i*360,a*100,l*100]},W.rgb.hwb=function(e){let t=e[0],n=e[1],r=e[2],i=W.rgb.hsl(e)[0],a=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[i,a*100,r*100]},W.rgb.oklab=function(e){let t=Fb(e[0]/255),n=Fb(e[1]/255),r=Fb(e[2]/255),i=Math.cbrt(.4122214708*t+.5363325363*n+.0514459929*r),a=Math.cbrt(.2119034982*t+.6806995451*n+.1073969566*r),o=Math.cbrt(.0883024619*t+.2817188376*n+.6299787005*r),s=.2104542553*i+.793617785*a-.0040720468*o,c=1.9779984951*i-2.428592205*a+.4505937099*o,l=.0259040371*i+.7827717662*a-.808675766*o;return[s*100,c*100,l*100]},W.rgb.cmyk=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(1-t,1-n,1-r),a=(1-t-i)/(1-i)||0,o=(1-n-i)/(1-i)||0,s=(1-r-i)/(1-i)||0;return[a*100,o*100,s*100,i*100]};function Ib(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}W.rgb.keyword=function(e){let t=Mb[e];if(t)return t;let n=1/0,r;for(let t of Object.keys(Ob)){let i=Ob[t],a=Ib(e,i);aNb?n**(1/3):7.787*n+16/116,r=r>Nb?r**(1/3):7.787*r+16/116,i=i>Nb?i**(1/3):7.787*i+16/116,[116*r-16,500*(n-r),200*(r-i)]},W.hsl.rgb=function(e){let t=e[0]/360,n=e[1]/100,r=e[2]/100,i,a;if(n===0)return a=r*255,[a,a,a];let o=r<.5?r*(1+n):r+n-r*n,s=2*r-o,c=[0,0,0];for(let e=0;e<3;e++)i=t+1/3*-(e-1),i<0&&i++,i>1&&i--,a=6*i<1?s+(o-s)*6*i:2*i<1?o:3*i<2?s+(o-s)*(2/3-i)*6:s,c[e]=a*255;return c},W.hsl.hsv=function(e){let t=e[0],n=e[1]/100,r=e[2]/100,i=n,a=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=a<=1?a:2-a;let o=(r+n)/2;return[t,(r===0?2*i/(a+i):2*n/(r+n))*100,o*100]},W.hsv.rgb=function(e){let t=e[0]/60,n=e[1]/100,r=e[2]/100,i=Math.floor(t)%6,a=t-Math.floor(t),o=255*r*(1-n),s=255*r*(1-n*a),c=255*r*(1-n*(1-a));switch(r*=255,i){case 0:return[r,c,o];case 1:return[s,r,o];case 2:return[o,r,c];case 3:return[o,s,r];case 4:return[c,o,r];case 5:return[r,o,s]}},W.hsv.hsl=function(e){let t=e[0],n=e[1]/100,r=e[2]/100,i=Math.max(r,.01),a,o;o=(2-n)*r;let s=(2-n)*i;return a=n*i,a/=s<=1?s:2-s,a||=0,o/=2,[t,a*100,o*100]},W.hwb.rgb=function(e){let t=e[0]/360,n=e[1]/100,r=e[2]/100,i=n+r,a;i>1&&(n/=i,r/=i);let o=Math.floor(6*t),s=1-r;a=6*t-o,o&1&&(a=1-a);let c=n+a*(s-n),l,u,d;switch(o){default:case 6:case 0:l=s,u=c,d=n;break;case 1:l=c,u=s,d=n;break;case 2:l=n,u=s,d=c;break;case 3:l=n,u=c,d=s;break;case 4:l=c,u=n,d=s;break;case 5:l=s,u=n,d=c;break}return[l*255,u*255,d*255]},W.cmyk.rgb=function(e){let t=e[0]/100,n=e[1]/100,r=e[2]/100,i=e[3]/100,a=1-Math.min(1,t*(1-i)+i),o=1-Math.min(1,n*(1-i)+i),s=1-Math.min(1,r*(1-i)+i);return[a*255,o*255,s*255]},W.xyz.rgb=function(e){let t=e[0]/100,n=e[1]/100,r=e[2]/100,i,a,o;return i=t*3.2404542+n*-1.5371385+r*-.4985314,a=t*-.969266+n*1.8760108+r*.041556,o=t*.0556434+n*-.2040259+r*1.0572252,i=Pb(i),a=Pb(a),o=Pb(o),[i*255,a*255,o*255]},W.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];return t/=95.047,n/=100,r/=108.883,t=t>Nb?t**(1/3):7.787*t+16/116,n=n>Nb?n**(1/3):7.787*n+16/116,r=r>Nb?r**(1/3):7.787*r+16/116,[116*n-16,500*(t-n),200*(n-r)]},W.xyz.oklab=function(e){let t=e[0]/100,n=e[1]/100,r=e[2]/100,i=Math.cbrt(.8189330101*t+.3618667424*n-.1288597137*r),a=Math.cbrt(.0329845436*t+.9293118715*n+.0361456387*r),o=Math.cbrt(.0482003018*t+.2643662691*n+.633851707*r),s=.2104542553*i+.793617785*a-.0040720468*o,c=1.9779984951*i-2.428592205*a+.4505937099*o,l=.0259040371*i+.7827717662*a-.808675766*o;return[s*100,c*100,l*100]},W.oklab.oklch=function(e){return W.lab.lch(e)},W.oklab.xyz=function(e){let t=e[0]/100,n=e[1]/100,r=e[2]/100,i=(.999999998*t+.396337792*n+.215803758*r)**3,a=(1.000000008*t-.105561342*n-.063854175*r)**3,o=(1.000000055*t-.089484182*n-1.291485538*r)**3,s=1.227013851*i-.55779998*a+.281256149*o,c=-.040580178*i+1.11225687*a-.071676679*o,l=-.076381285*i-.421481978*a+1.58616322*o;return[s*100,c*100,l*100]},W.oklab.rgb=function(e){let t=e[0]/100,n=e[1]/100,r=e[2]/100,i=(t+.3963377774*n+.2158037573*r)**3,a=(t-.1055613458*n-.0638541728*r)**3,o=(t-.0894841775*n-1.291485548*r)**3,s=Pb(4.0767416621*i-3.3077115913*a+.2309699292*o),c=Pb(-1.2684380046*i+2.6097574011*a-.3413193965*o),l=Pb(-.0041960863*i-.7034186147*a+1.707614701*o);return[s*255,c*255,l*255]},W.oklch.oklab=function(e){return W.lch.lab(e)},W.lab.xyz=function(e){let t=e[0],n=e[1],r=e[2],i,a,o;a=(t+16)/116,i=n/500+a,o=a-r/200;let s=a**3,c=i**3,l=o**3;return a=s>Nb?s:(a-16/116)/7.787,i=c>Nb?c:(i-16/116)/7.787,o=l>Nb?l:(o-16/116)/7.787,i*=95.047,a*=100,o*=108.883,[i,a,o]},W.lab.lch=function(e){let t=e[0],n=e[1],r=e[2],i;return i=Math.atan2(r,n)*360/2/Math.PI,i<0&&(i+=360),[t,Math.sqrt(n*n+r*r),i]},W.lch.lab=function(e){let t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},W.rgb.ansi16=function(e,t=null){let[n,r,i]=e,a=t===null?W.rgb.hsv(e)[2]:t;if(a=Math.round(a/50),a===0)return 30;let o=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return a===2&&(o+=60),o},W.hsv.ansi16=function(e){return W.rgb.ansi16(W.hsv.rgb(e),e[2])},W.rgb.ansi256=function(e){let t=e[0],n=e[1],r=e[2];return t>>4==n>>4&&n>>4==r>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},W.ansi16.rgb=function(e){e=e[0];let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let n=(Math.trunc(e>50)+1)*.5;return[(t&1)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},W.ansi256.rgb=function(e){if(e=e[0],e>=232){let t=(e-232)*10+8;return[t,t,t]}e-=16;let t;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},W.rgb.hex=function(e){let t=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return`000000`.slice(t.length)+t},W.hex.rgb=function(e){let t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let n=t[0];t[0].length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},W.rgb.hcg=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.max(Math.max(t,n),r),a=Math.min(Math.min(t,n),r),o=i-a,s,c=o<1?a/(1-o):0;return s=o<=0?0:i===t?(n-r)/o%6:i===n?2+(r-t)/o:4+(t-n)/o,s/=6,s%=1,[s*360,o*100,c*100]},W.hsl.hcg=function(e){let t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n),i=0;return r<1&&(i=(n-.5*r)/(1-r)),[e[0],r*100,i*100]},W.hsv.hcg=function(e){let t=e[1]/100,n=e[2]/100,r=t*n,i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],r*100,i*100]},W.hcg.rgb=function(e){let t=e[0]/360,n=e[1]/100,r=e[2]/100;if(n===0)return[r*255,r*255,r*255];let i=[0,0,0],a=t%1*6,o=a%1,s=1-o,c=0;switch(Math.floor(a)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return c=(1-n)*r,[(n*i[0]+c)*255,(n*i[1]+c)*255,(n*i[2]+c)*255]},W.hcg.hsv=function(e){let t=e[1]/100,n=t+e[2]/100*(1-t),r=0;return n>0&&(r=t/n),[e[0],r*100,n*100]},W.hcg.hsl=function(e){let t=e[1]/100,n=e[2]/100*(1-t)+.5*t,r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],r*100,n*100]},W.hcg.hwb=function(e){let t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],(n-t)*100,(1-n)*100]},W.hwb.hcg=function(e){let t=e[1]/100,n=1-e[2]/100,r=n-t,i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],r*100,i*100]},W.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},W.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},W.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},W.gray.hsl=function(e){return[0,0,e[0]]},W.gray.hsv=W.gray.hsl,W.gray.hwb=function(e){return[0,100,e[0]]},W.gray.cmyk=function(e){return[0,0,0,e[0]]},W.gray.lab=function(e){return[e[0],0,0]},W.gray.hex=function(e){let t=Math.round(e[0]/100*255)&255,n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return`000000`.slice(n.length)+n},W.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};function Lb(){let e={},t=Object.keys(W);for(let{length:n}=t,r=0;r0;){let e=n.pop(),r=Object.keys(W[e]);for(let{length:i}=r,a=0;a1&&(t=n),e(t))};return`conversion`in e&&(t.conversion=e.conversion),t}function Gb(e){let t=function(...t){let n=t[0];if(n==null)return n;n.length>1&&(t=n);let r=e(t);if(typeof r==`object`)for(let{length:e}=r,t=0;te||t);let i=this.bindTemplate;this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-labeled-field-view`,i.to(`class`),i.if(`isEnabled`,`ck-disabled`,e=>!e),i.if(`isEmpty`,`ck-labeled-field-view_empty`),i.if(`isFocused`,`ck-labeled-field-view_focused`),i.if(`placeholder`,`ck-labeled-field-view_placeholder`),i.if(`errorText`,`ck-error`)]},children:[{tag:`div`,attributes:{class:[`ck`,`ck-labeled-field-view__input-wrapper`]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){let t=new eo(this.locale);return t.for=e,t.bind(`text`).to(this,`label`),t}_createStatusView(e){let t=new P(this.locale),n=this.bindTemplate;return t.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-labeled-field-view__status`,n.if(`errorText`,`ck-labeled-field-view__status_error`),n.if(`_statusText`,`ck-hidden`,e=>!e)],id:e,role:n.if(`errorText`,`alert`)},children:[{text:n.to(`_statusText`)}]}),t}focus(e){this.fieldView.focus(e)}},$b=class extends P{focusTracker;constructor(e){super(e),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 M,this.bind(`isFocused`).to(this.focusTracker),this.set(`isEmpty`,!0);let t=this.bindTemplate;this.setTemplate({tag:`input`,attributes:{class:[`ck`,`ck-input`,t.if(`isFocused`,`ck-input_focused`),t.if(`isEmpty`,`ck-input-text_empty`),t.if(`hasError`,`ck-error`)],id:t.to(`id`),placeholder:t.to(`placeholder`),tabindex:t.to(`tabIndex`),readonly:t.to(`isReadOnly`),"aria-invalid":t.if(`hasError`,!0),"aria-describedby":t.to(`ariaDescribedById`),"aria-label":t.to(`ariaLabel`)},on:{input:t.to((...e)=>{this.fire(`input`,...e),this._updateIsEmpty()}),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on(`change:value`,(e,t,n)=>{this._setDomElementValue(n),this._updateIsEmpty()})}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value=``,this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=ex(this.element)}_setDomElementValue(e){this.element.value=!e&&e!==0?``:e}};function ex(e){return!e.value}var tx=class extends $b{constructor(e){super(e),this.set(`inputMode`,`text`);let t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to(`inputMode`)}})}},nx=class extends tx{constructor(e){super(e),this.extendTemplate({attributes:{type:`text`,class:[`ck-input-text`]}})}},rx=class extends tx{constructor(e,{min:t,max:n,step:r}={}){super(e);let i=this.bindTemplate;this.set(`min`,t),this.set(`max`,n),this.set(`step`,r),this.extendTemplate({attributes:{type:`number`,class:[`ck-input-number`],min:i.to(`min`),max:i.to(`max`),step:i.to(`step`)}})}},ix=class extends $b{_resizeObserver;_isUpdateAutoGrowHeightPending=!1;constructor(e){super(e);let t=Wr(`px`);this.set(`minRows`,2),this.set(`maxRows`,5),this.set(`_height`,null),this.set(`resize`,`none`),this._resizeObserver=null,this.on(`change:minRows`,this._validateMinMaxRows.bind(this)),this.on(`change:maxRows`,this._validateMinMaxRows.bind(this));let n=this.bindTemplate;this.template.tag=`textarea`,this.extendTemplate({attributes:{class:[`ck-textarea`],style:{height:n.to(`_height`,e=>e?t(e):null),resize:n.to(`resize`)},rows:n.to(`minRows`)}})}render(){super.render();let e=!1;this.on(`input`,()=>{this._updateAutoGrowHeight(!0),this.fire(`update`)}),this.on(`change:value`,()=>{u.window.requestAnimationFrame(()=>{if(!Yr(this.element)){this._isUpdateAutoGrowHeightPending=!0;return}this._updateAutoGrowHeight(),this.fire(`update`)})}),this._resizeObserver=new Hr(this.element,t=>{let n=!!t.contentRect.width&&!!t.contentRect.height;!e&&n&&this._isUpdateAutoGrowHeightPending&&u.window.requestAnimationFrame(()=>{this._updateAutoGrowHeight(),this.fire(`update`)}),e=n})}destroy(){this._resizeObserver&&this._resizeObserver.destroy()}reset(){super.reset(),this._updateAutoGrowHeight(),this.fire(`update`)}_updateAutoGrowHeight(e){let t=this.element;if(!t.offsetParent){this._isUpdateAutoGrowHeightPending=!0;return}this._isUpdateAutoGrowHeightPending=!1;let n=ax(t,`1`),r=ax(t,t.value),i=n.ownerDocument.defaultView.getComputedStyle(n),a=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=Dr(n),s=parseFloat(i.lineHeight),c=o.top+o.bottom,l=new O(n).height,u=Math.round((r.scrollHeight-a)/s),d=this.maxRows*s+a+c,f=u===1?l:this.minRows*s+a+c;this._height=Math.min(Math.max(Math.max(u,this.minRows)*s+a+c,f),d),e&&(t.scrollTop=t.scrollHeight),n.remove(),r.remove()}_validateMinMaxRows(){if(this.minRows>this.maxRows)throw new w(`ui-textarea-view-min-rows-greater-than-max-rows`,{textareaView:this,minRows:this.minRows,maxRows:this.maxRows})}};function ax(e,t){let n=e.cloneNode();return n.style.position=`absolute`,n.style.top=`-99999px`,n.style.left=`-99999px`,n.style.height=`auto`,n.style.overflow=`hidden`,n.style.width=e.ownerDocument.defaultView.getComputedStyle(e).width,n.tabIndex=-1,n.rows=1,n.value=t,e.parentNode.insertBefore(n,e),n}var ox=class extends P{children;constructor(e){super(e);let t=this.bindTemplate;this.set(`isVisible`,!1),this.set(`position`,`se`),this.children=this.createCollection(),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-reset`,`ck-dropdown__panel`,t.to(`position`,e=>`ck-dropdown__panel_${e}`),t.if(`isVisible`,`ck-dropdown__panel-visible`)],tabindex:`-1`},children:this.children,on:{selectstart:t.to(e=>{let t=e.target;t instanceof Element&&t.tagName.toLocaleLowerCase()===`input`||e.preventDefault()})}})}focus(){if(this.children.length){let e=this.children.first;typeof e.focus==`function`?e.focus():T(`ui-dropdown-panel-focus-child-missing-focus`,{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){let e=this.children.last;typeof e.focusLast==`function`?e.focusLast():e.focus()}}},sx=class e extends P{buttonView;panelView;focusTracker;keystrokes;listView;toolbarView;menuView;constructor(e,t,n){super(e);let r=this.bindTemplate;this.buttonView=t,this.panelView=n,this.set(`isOpen`,!1),this.set(`isEnabled`,!0),this.set(`class`,void 0),this.set(`id`,void 0),this.set(`panelPosition`,`auto`),this.panelView.bind(`isVisible`).to(this,`isOpen`),this.keystrokes=new N,this.focusTracker=new M,this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-dropdown`,r.to(`class`),r.if(`isEnabled`,`ck-disabled`,e=>!e)],id:r.to(`id`),"aria-describedby":r.to(`ariaDescribedById`)},children:[t,n]}),t.extendTemplate({attributes:{class:[`ck-dropdown__button`],"data-cke-tooltip-disabled":r.to(`isOpen`)}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,`open`,()=>{this.isOpen=!this.isOpen}),this.on(`change:isOpen`,(t,n,r)=>{if(r)if(this.panelPosition===`auto`){let t=e._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=t?t.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition}),this.keystrokes.listenTo(this.element);let t=(e,t)=>{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`,t),this.keystrokes.set(`esc`,t)}focus(){this.buttonView.focus()}get _panelPositions(){let{south:t,north:n,southEast:r,southWest:i,northEast:a,northWest:o,southMiddleEast:s,southMiddleWest:c,northMiddleEast:l,northMiddleWest:u}=e.defaultPanelPositions;return this.locale.uiLanguageDirection===`rtl`?[i,r,c,s,t,o,a,u,l,n]:[r,i,s,c,t,a,o,l,u,n]}get _defaultPanelPositionName(){return this.locale.uiLanguageDirection===`rtl`?`sw`:`se`}static 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-(t.width-e.width)*3/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-(t.width-e.width)*3/4,name:`nmw`})};static _getOptimalPosition=Xr},cx=class extends H{arrowView;constructor(e){super(e),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(){let e=new Ly;return e.content=b_,e.extendTemplate({attributes:{class:`ck-dropdown__arrow`}}),e}},lx=class extends H{id;constructor(e,t,n){super(e),this.id=t,this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:`menuitem`,label:n}),this.extendTemplate({attributes:{class:[`ck-dropdown-menu-list__nested-menu__item__button`]}})}},ux=class extends $y{arrowView;constructor(e){super(e);let t=this.bindTemplate;this.set({withText:!0,role:`menuitem`}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:[`ck-dropdown-menu-list__nested-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(){let e=new Ly;return e.content=b_,e.extendTemplate({attributes:{class:`ck-dropdown-menu-list__nested-menu__button__arrow`}}),e}},dx=class extends P{children;constructor(e){super(e);let 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()}},fx=class extends P{constructor(e){super(e),this.setTemplate({tag:`li`,attributes:{class:[`ck`,`ck-list__separator`]}})}},px=class extends P{labelView;items;children;constructor(e,t=new eo){super(e);let n=this.bindTemplate,r=new mx(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,r]),r.set({role:`group`,ariaLabelledBy:t.id}),r.focusTracker.destroy(),r.keystrokes.destroy(),this.items=r.items,this.setTemplate({tag:`li`,attributes:{role:`presentation`,class:[`ck`,`ck-list__group`,n.if(`isVisible`,`ck-hidden`,e=>!e)]},children:this.children})}focus(){if(this.items){let e=this.items.find(e=>!(e instanceof fx));e&&e.focus()}}},mx=class extends P{focusables;items;focusTracker;keystrokes;_focusCycler;_listItemGroupToChangeListeners=new WeakMap;constructor(e){super(e);let t=this.bindTemplate;this.focusables=new pa,this.items=this.createCollection(),this.focusTracker=new M,this.keystrokes=new N,this._focusCycler=new Hy({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(let e of this.items)e instanceof px?this._registerFocusableItemsGroup(e):e instanceof dx&&this._registerFocusableListItem(e);this.items.on(`change`,(e,t)=>{for(let e of t.removed)e instanceof px?this._deregisterFocusableItemsGroup(e):e instanceof dx&&this._deregisterFocusableListItem(e);for(let e of Array.from(t.added).reverse())e instanceof px?this._registerFocusableItemsGroup(e,t.index):this._registerFocusableListItem(e,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,n)=>{for(let e of n.removed)this._deregisterFocusableListItem(e);for(let t of Array.from(n.added).reverse())this._registerFocusableListItem(t,this.items.getIndex(e)+n.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach((e,n)=>{let r=t===void 0?void 0:t+n;this._registerFocusableListItem(e,r)});let n=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,n),e.items.on(`change`,n)}_deregisterFocusableItemsGroup(e){for(let t of e.items)this._deregisterFocusableListItem(t);e.items.off(`change`,this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}},hx=class extends mx{constructor(e){super(e);let t=this.bindTemplate;this.role=`menu`,this.set(`isVisible`,!0),this.extendTemplate({attributes:{class:[`ck-dropdown-menu-list`,t.if(`isVisible`,`ck-hidden`,e=>!e)]}})}};const gx={eastSouth:e=>({top:e.top,left:e.right-5,name:`es`}),eastNorth:(e,t)=>({top:e.top-t.height+e.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+e.height,left:e.left-t.width+5,name:`wn`})};var _x=class extends dx{childView;constructor(e,t,n){super(e);let r=this.bindTemplate;this.childView=n,this.children.add(n),this.extendTemplate({attributes:{class:[`ck-dropdown-menu-list__nested-menu__item`]},on:{mouseenter:r.to(`mouseenter`)}}),t&&(this.delegate(`mouseenter`).to(t),n instanceof lx&&n.delegate(`execute`).to(t))}};const vx={toggleMenusAndFocusItemsOnHover(e){e.on(`menu:mouseenter`,t=>{let[n]=t.path;t.source.focus();for(let r of e.menus){let e=n instanceof _x&&n.childView===r;r.isOpen=(t.path.includes(r)||e)&&r.isEnabled}})},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on(`menu:change:isOpen`,(t,n,r)=>{if(!r)return;let i=t.source;for(let t of e.menus)i.parentMenuView===t.parentMenuView&&i!==t&&(t.isOpen=!1)})}},yx={openOnArrowRightKey(e){let t=e.locale.uiLanguageDirection===`rtl`?`arrowleft`:`arrowright`;e.keystrokes.set(t,(t,n)=>{e.focusTracker.focusedElement!==e.buttonView.element||!e.isEnabled||(e.isOpen||=!0,e.panelView.focus(),n())})},openOnButtonClick(e){e.buttonView.on(`execute`,()=>{e.isEnabled&&(e.isOpen=!0)})},openAndFocusOnEnterKeyPress(e){e.keystrokes.set(`enter`,(t,n)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen=!0,e.panelView.focus(),n())})},closeOnArrowLeftKey(e){let t=e.locale.uiLanguageDirection===`rtl`?`arrowright`:`arrowleft`;e.keystrokes.set(t,(t,n)=>{e.isOpen&&(e.focus(),e.isOpen=!1,n())})},closeOnEscKey(e){e.keystrokes.set(`esc`,(t,n)=>{e.isOpen&&(e.focus(),e.isOpen=!1,n())})},closeOnParentClose(e,t){t.on(`change:isOpen`,(n,r,i)=>{!i&&n.source===t&&(e.isOpen=!1)})}};var bx=class extends ab{constructor(e){super(e);let t=this.bindTemplate;this.set({isVisible:!1,position:`se`,class:null,top:0,left:0}),this.extendTemplate({tag:`div`,attributes:{class:[`ck-reset`,`ck-dropdown-menu__nested-menu__panel`],tabindex:`-1`},on:{selectstart:t.to(e=>{e.target.tagName.toLocaleLowerCase()!==`input`&&e.preventDefault()})}})}focus(e=1){let{content:t}=this;t.length&&(e===1?t.first.focus():t.last.focus())}},xx=class e extends P{static DELEGATED_EVENTS=[`mouseenter`,`execute`,`change:isOpen`];id;buttonView;panelView;listView;focusTracker;keystrokes;_bodyCollection;constructor(e,t,n,r,i){super(e),this._bodyCollection=t,this.id=n,this.set({isOpen:!1,isEnabled:!0,panelPosition:`w`,class:void 0,parentMenuView:null}),this.keystrokes=new N,this.focusTracker=new M,this.buttonView=new ux(e),this.buttonView.delegate(`mouseenter`).to(this),this.buttonView.bind(`isOn`,`isEnabled`).to(this,`isOpen`,`isEnabled`),this.buttonView.label=r,this.panelView=new bx(e),this.panelView.isVisible=!0,this.listView=new hx(e),this.listView.bind(`ariaLabel`).to(this.buttonView,`label`),this.panelView.content.add(this.listView);let a=this.bindTemplate;this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-dropdown-menu-list__nested-menu`,a.to(`class`),a.if(`isEnabled`,`ck-disabled`,e=>!e)],role:`presentation`},children:[this.buttonView]}),this.parentMenuView=i,this.parentMenuView&&this._handleParentMenuView(),this._attachBehaviors()}get _panelPositions(){let{westSouth:e,eastSouth:t,westNorth:n,eastNorth:r}=gx;return this.locale.uiLanguageDirection===`ltr`?[t,r,e,n]:[e,n,t,r]}render(){super.render(),this.panelView.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.focusTracker.add(this.listView),this.keystrokes.listenTo(this.element),this._mountPanelOnOpen()}destroy(){this._removePanelFromBody(),this.panelView.destroy(),super.destroy()}focus(){this.buttonView.focus()}_handleParentMenuView(){this.delegate(...e.DELEGATED_EVENTS).to(this.parentMenuView),yx.closeOnParentClose(this,this.parentMenuView)}_attachBehaviors(){yx.openOnButtonClick(this),yx.openAndFocusOnEnterKeyPress(this),yx.openOnArrowRightKey(this),yx.closeOnEscKey(this),yx.closeOnArrowLeftKey(this)}_mountPanelOnOpen(){let{panelView:e}=this;this.on(`change:isOpen`,(t,n,r)=>{if(t.source===this){if(!r&&this._bodyCollection.has(e)){this._removePanelFromBody();return}r&&!this._bodyCollection.has(e)&&this._addPanelToBody()}})}_removePanelFromBody(){let{panelView:e,keystrokes:t}=this;this._bodyCollection.has(e)&&(this._bodyCollection.remove(e),t.stopListening(e.element))}_addPanelToBody(){let{panelView:e,buttonView:t,keystrokes:n}=this;this._bodyCollection.has(e)||(this._bodyCollection.add(e),n.listenTo(e.element),e.pin({positions:this._panelPositions,limiter:u.document.body,element:e.element,target:t.element,fitInViewport:!0}))}},Sx=class extends hx{_definition;_cachedMenus=[];_cachedButtons=[];_bodyCollection;constructor(e,t,n){super(e),this._bodyCollection=t,this._definition=n,this.set(`menuPanelClass`,void 0)}get menus(){return Array.from(this._cachedMenus.values())}get buttons(){return Array.from(this._cachedButtons.values())}render(){this._createStructure(this._definition,null),super.render(),vx.toggleMenusAndFocusItemsOnHover(this),vx.closeMenuWhenAnotherOnTheSameLevelOpens(this)}closeMenus(){this.menus.forEach(e=>{e.isOpen=!1})}_createStructure(e,t){let n=[];for(let r of e){let e;`menu`in r?(e=new xx(this.locale,this._bodyCollection,r.id,r.menu,t),e.panelView.bind(`class`).to(this,`menuPanelClass`),t||e.delegate(...xx.DELEGATED_EVENTS).to(this,e=>`menu:${e}`),this._cachedMenus.push(e),this._createStructure(r.children,e)):(e=new lx(this.locale,r.id,r.label),t||e.delegate(`execute`).to(this,`menu:execute`),this._cachedButtons.push(e));let i=new _x(this.locale,t,e);t||i.delegate(`mouseenter`).to(this,`menu:mouseenter`),n.push(i)}(t?t.listView:this).items.addMany(n)}},Cx=class extends P{constructor(e){super(e),this.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-toolbar__separator`]}})}},wx=class extends P{constructor(e){super(e),this.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-toolbar__line-break`]}})}};function Tx(e){return e.bindTemplate.to(t=>{t.target===e.element&&t.preventDefault()})}function Ex(e){if(Array.isArray(e))return{items:e,removeItems:[]};let t={items:[],removeItems:[]};return e?{...t,...e}:t}const Dx={alignLeft:Gg,bold:Zg,importExport:U_,paragraph:Lv,plus:Hv,text:wy,threeVerticalDots:Ty,pilcrow:Bv,dragIndicator:y_};var Ox=class extends P{options;items;focusTracker;keystrokes;itemsView;children;focusables;_focusCycler;_behavior;constructor(e,t){super(e);let n=this.bindTemplate,r=this.t;this.options=t||{},this.set(`ariaLabel`,r(`Editor toolbar`)),this.set(`maxWidth`,`auto`),this.set(`role`,`toolbar`),this.set(`isGrouping`,!!this.options.shouldGroupWhenFull),this.items=this.createCollection(),this.focusTracker=new M,this.keystrokes=new N,this.set(`class`,void 0),this.set(`isCompact`,!1),this.set(`isVertical`,!1),this.itemsView=new kx(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();let i=e.uiLanguageDirection===`rtl`;this._focusCycler=new Hy({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[i?`arrowright`:`arrowleft`,`arrowup`],focusNext:[i?`arrowleft`:`arrowright`,`arrowdown`]}});let a=[`ck`,`ck-toolbar`,n.to(`class`),n.if(`isCompact`,`ck-toolbar_compact`),n.if(`isGrouping`,`ck-toolbar_grouping`),n.if(`isVertical`,`ck-toolbar_vertical`)];this.options.shouldGroupWhenFull&&this.options.isFloating&&a.push(`ck-toolbar_floating`),this.setTemplate({tag:`div`,attributes:{class:a,role:n.to(`role`),"aria-label":n.to(`ariaLabel`),style:{maxWidth:n.to(`maxWidth`)},tabindex:-1},children:this.children,on:{mousedown:Tx(this)}}),this._behavior=this.options.shouldGroupWhenFull?new jx(this):new Ax(this)}render(){super.render(),this.focusTracker.add(this.element);for(let 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,n){this.items.addMany(this._buildItemsFromConfig(e,t,n))}switchBehavior(e){this._behavior.type!==e&&(this._behavior.destroy(),this.itemsView.children.clear(),this.focusables.clear(),e===`dynamic`?(this._behavior=new jx(this),this._behavior.render(this),this._behavior.refreshItems()):(this._behavior=new Ax(this),this._behavior.render(this)))}_buildItemsFromConfig(e,t,n){let r=Ex(e),i=n||r.removeItems;return this._cleanItemsConfiguration(r.items,t,i).map(e=>Xe(e)?this._createNestedToolbarDropdown(e,t,i):e===`|`?new Cx:e===`-`?new wx:t.create(e)).filter(e=>!!e)}_cleanItemsConfiguration(e,t,n){let r=e.filter((e,r,i)=>e===`|`?!0:n.indexOf(e)===-1?e===`-`?this.options.shouldGroupWhenFull?(T(`toolbarview-line-break-ignored-when-grouping-items`,i),!1):!0:!Xe(e)&&!t.has(e)?(T(`toolbarview-item-unavailable`,{item:e}),!1):!0:!1);return this._cleanSeparatorsAndLineBreaks(r)}_cleanSeparatorsAndLineBreaks(e){let t=e=>e!==`-`&&e!==`|`,n=e.length,r=e.findIndex(t);if(r===-1)return[];let i=n-e.slice().reverse().findIndex(t);return e.slice(r,i).filter((e,n,r)=>t(e)?!0:!(n>0&&r[n-1]===e))}_createNestedToolbarDropdown(e,t,n){let{label:r,icon:i,items:a,tooltip:o=!0,withText:s=!1}=e;if(a=this._cleanItemsConfiguration(a,t,n),!a.length)return null;let c=this.locale,l=Nx(c);return r||T(`toolbarview-nested-toolbar-dropdown-missing-label`,e),l.class=`ck-toolbar__nested-toolbar-dropdown`,l.buttonView.set({label:r,tooltip:o,withText:!!s}),i===!1?l.buttonView.withText=!0:l.buttonView.icon=Dx[i]||i||Ty,Fx(l,()=>l.toolbarView._buildItemsFromConfig(a,t,n)),l}},kx=class extends P{children;constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-toolbar__items`]},children:this.children})}},Ax=class{type=`static`;constructor(e){e.isGrouping=!1,e.itemsView.children.bindTo(e.items).using(e=>e),e.focusables.bindTo(e.items).using(e=>Wy(e)?e:null)}render(){}destroy(){}},jx=class{type=`dynamic`;view;viewChildren;viewFocusables;viewItemsView;viewFocusTracker;viewLocale;ungroupedItems;groupedItems;groupedItemsDropdown;resizeObserver=null;cachedPadding=null;shouldUpdateGroupingOnNextResize=!1;viewElement;constructor(e){this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.view.isGrouping=!0,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)=>{let n=t.index,r=Array.from(t.added);for(let e of t.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=n;ethis.ungroupedItems.length?this.groupedItems.add(t,e-this.ungroupedItems.length):this.ungroupedItems.add(t,e)}this._updateGrouping()})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.viewChildren.length>1&&(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last)),this.resizeObserver.destroy()}refreshItems(){let e=this.view;if(e.items.length){for(let t=0;tr.right-this.cachedPadding:n.left{(!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 Cx),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(){let e=this.viewLocale,t=e.t,n=Nx(e);return n.class=`ck-toolbar__grouped-dropdown`,n.panelPosition=e.uiLanguageDirection===`ltr`?`sw`:`se`,Fx(n,this.groupedItems),n.buttonView.set({label:t(`Show more items`),tooltip:!0,tooltipPosition:e.uiLanguageDirection===`rtl`?`se`:`sw`,icon:Ty}),n}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{Wy(e)&&this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}},Mx=class extends P{children;actionView;arrowView;keystrokes;focusTracker;constructor(e,t){super(e);let n=this.bindTemplate;this.set(`class`,void 0),this.set(`labelStyle`,void 0),this.set(`icon`,void 0),this.set(`isEnabled`,!0),this.set(`isOn`,!1),this.set(`isToggleable`,!1),this.set(`isVisible`,!0),this.set(`keystroke`,void 0),this.set(`withKeystroke`,!1),this.set(`label`,void 0),this.set(`tabindex`,-1),this.set(`tooltip`,!1),this.set(`tooltipPosition`,`s`),this.set(`type`,`button`),this.set(`withText`,!1),this.children=this.createCollection(),this.actionView=this._createActionView(t),this.arrowView=this._createArrowView(),this.keystrokes=new N,this.focusTracker=new M,this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-splitbutton`,n.to(`class`),n.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){let t=e||new H;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(){let e=new H,t=e.bindTemplate;return e.icon=b_,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 Nx(e,t=cx){let n=typeof t==`function`?new t(e):t,r=new sx(e,n,new ox(e));return n.bind(`isEnabled`).to(r),n instanceof Mx?n.arrowView.bind(`isOn`).to(r,`isOpen`):n.bind(`isOn`).to(r,`isOpen`),Ite(r),r}function Fte(e,t,n,r={}){e.menuView=new Sx(e.locale,t,n),e.focusTracker.add(e.menuView),e.isOpen?Px(e,r):e.once(`change:isOpen`,()=>{Px(e,r)},{priority:`highest`})}function Px(e,t){let n=e.menuView,r=e.locale.t;n.delegate(`menu:execute`).to(e,`execute`),n.listenTo(e,`change:isOpen`,(e,t,r)=>{r||n.closeMenus()},{priority:`low`}),e.panelView.children.add(n);for(let t of n.menus)e.focusTracker.add(t);n.ariaLabel=t.ariaLabel||r(`Dropdown menu`)}function Fx(e,t,n={}){e.extendTemplate({attributes:{class:[`ck-toolbar-dropdown`]}}),e.isOpen?Ix(e,t,n):e.once(`change:isOpen`,()=>Ix(e,t,n),{priority:`highest`}),n.enableActiveItemFocusOnDropdownOpen&&zx(e,()=>e.toolbarView.items.find(e=>e.isOn))}function Ix(e,t,n){let r=e.locale,i=r.t,a=e.toolbarView=new Ox(r),o=typeof t==`function`?t():t;a.ariaLabel=n.ariaLabel||i(`Dropdown toolbar`),n.maxWidth&&(a.maxWidth=n.maxWidth),n.class&&(a.class=n.class),n.isCompact&&(a.isCompact=n.isCompact),n.isVertical&&(a.isVertical=!0),o instanceof pa?a.items.bindTo(o).using(e=>e):a.items.addMany(o),e.panelView.children.add(a),e.focusTracker.add(a),a.items.delegate(`execute`).to(e)}function Lx(e,t,n={}){e.isOpen?Rx(e,t,n):e.once(`change:isOpen`,()=>Rx(e,t,n),{priority:`highest`}),zx(e,()=>e.listView.items.find(e=>e instanceof dx?e.children.first.isOn:!1))}function Rx(e,t,n){let r=e.locale,i=e.listView=new mx(r),a=typeof t==`function`?t():t;i.ariaLabel=n.ariaLabel,i.role=n.role,Kx(e,i.items,a,r),e.panelView.children.add(i),i.items.delegate(`execute`).to(e)}function zx(e,t){e.on(`change:isOpen`,()=>{if(!e.isOpen)return;let n=t();n&&(typeof n.focus==`function`?n.focus():T(`ui-dropdown-focus-child-on-open-child-missing-focus`,{view:n}))},{priority:ge.low-10})}function Ite(e){Lte(e),Vx(e),Hx(e),Ux(e),Wx(e),Gx(e)}function Lte(e){Ya({emitter:e,activator:()=>e.isRendered&&e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>[e.element,...Bx(e.focusTracker).filter(t=>!e.element.contains(t))]})}function Bx(e){return[...e.elements,...e.externalViews.flatMap(e=>Bx(e.focusTracker))]}function Vx(e){e.on(`execute`,t=>{t.source instanceof mb||(e.isOpen=!1)})}function Hx(e){e.focusTracker.on(`change:isFocused`,(t,n,r)=>{r||!e.isOpen||(e.isOpen=!1)})}function Ux(e){e.keystrokes.set(`arrowdown`,(t,n)=>{e.isOpen&&(e.panelView.focus(),n())}),e.keystrokes.set(`arrowup`,(t,n)=>{e.isOpen&&(e.panelView.focusLast(),n())})}function Wx(e){e.on(`change:isOpen`,(t,n,r)=>{r||e.focusTracker.elements.some(e=>e.contains(u.document.activeElement))&&e.buttonView.focus()})}function Gx(e){e.on(`change:isOpen`,(t,n,r)=>{r&&e.panelView.focus()},{priority:`low`})}function Kx(e,t,n,r){qx(t),t.bindTo(n).using(t=>{if(t.type===`separator`)return new fx(r);if(t.type===`group`){let n=new px(r);return n.set({label:t.label}),Kx(e,n.items,t.items,r),n.items.delegate(`execute`).to(e),n}else if(t.type===`button`||t.type===`switchbutton`){let e=t.model.role===`menuitemcheckbox`||t.model.role===`menuitemradio`,n=new dx(r),i;return t.type===`button`?(i=new $y(r,t.labelView),i.set({isToggleable:e})):i=new mb(r),i.bind(...Object.keys(t.model)).to(t.model),i.delegate(`execute`).to(n),n.children.add(i),n}return null})}function qx(e){let t=0,n=e=>!(e instanceof dx)||!(e.children.first instanceof $y)?null:e.children.first,r=e=>{let t=n(e);return!t||!t.isToggleable?null:t},i=t=>{for(let r of e){let e=n(r);e&&(e.hasCheckSpace=t)}};e.on(`change`,(e,a)=>{let o=t>0;for(let e of a.removed)r(e)&&t--;for(let e of a.added){let r=n(e);r&&(r.isToggleable&&t++,r.hasCheckSpace=t>0)}let s=t>0;o!==s&&i(s)})}const Jx=(e,t,n)=>{let r=new nx(e.locale);return r.set({id:t,ariaDescribedById:n}),r.bind(`isReadOnly`).to(e,`isEnabled`,e=>!e),r.bind(`hasError`).to(e,`errorText`,e=>!!e),r.on(`input`,()=>{e.errorText=null}),e.bind(`isEmpty`,`isFocused`,`placeholder`).to(r),r},Yx=(e,t,n)=>{let r=new rx(e.locale);return r.set({id:t,ariaDescribedById:n,inputMode:`numeric`}),r.bind(`isReadOnly`).to(e,`isEnabled`,e=>!e),r.bind(`hasError`).to(e,`errorText`,e=>!!e),r.on(`input`,()=>{e.errorText=null}),e.bind(`isEmpty`,`isFocused`,`placeholder`).to(r),r},Xx=(e,t,n)=>{let r=new ix(e.locale);return r.set({id:t,ariaDescribedById:n}),r.bind(`isReadOnly`).to(e,`isEnabled`,e=>!e),r.bind(`hasError`).to(e,`errorText`,e=>!!e),r.on(`input`,()=>{e.errorText=null}),e.bind(`isEmpty`,`isFocused`,`placeholder`).to(r),r},Zx=(e,t,n)=>{let r=Nx(e.locale);return r.set({id:t,ariaDescribedById:n}),r.bind(`isEnabled`).to(e),r},Qx=(e,t=0,n=1)=>e>n?n:eMath.round(n*e)/n;360/(Math.PI*2);const eS=e=>cS(tS(e)),tS=e=>(e[0]===`#`&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?$x(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?$x(parseInt(e.substring(6,8),16)/255,2):1}),nS=e=>sS(aS(e)),rS=({h:e,s:t,v:n,a:r})=>{let i=(200-t)*n/100;return{h:$x(e),s:$x(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:$x(i/2),a:$x(r,2)}},iS=e=>{let{h:t,s:n,l:r}=rS(e);return`hsl(${t}, ${n}%, ${r}%)`},aS=({h:e,s:t,v:n,a:r})=>{e=e/360*6,t/=100,n/=100;let i=Math.floor(e),a=n*(1-t),o=n*(1-(e-i)*t),s=n*(1-(1-e+i)*t),c=i%6;return{r:$x([n,o,a,a,s,n][c]*255),g:$x([s,n,n,o,a,a][c]*255),b:$x([a,a,s,n,n,o][c]*255),a:$x(r,2)}},oS=e=>{let t=e.toString(16);return t.length<2?`0`+t:t},sS=({r:e,g:t,b:n,a:r})=>{let i=r<1?oS($x(r*255)):``;return`#`+oS(e)+oS(t)+oS(n)+i},cS=({r:e,g:t,b:n,a:r})=>{let i=Math.max(e,t,n),a=i-Math.min(e,t,n),o=a?i===e?(t-n)/a:i===t?2+(n-e)/a:4+(e-t)/a:0;return{h:$x(60*(o<0?o+6:o)),s:$x(i?a/i*100:0),v:$x(i/255*100),a:r}},lS=(e,t)=>{if(e===t)return!0;for(let n in e)if(e[n]!==t[n])return!1;return!0},uS=(e,t)=>e.toLowerCase()===t.toLowerCase()?!0:lS(tS(e),tS(t)),dS={},fS=e=>{let t=dS[e];return t||(t=document.createElement(`template`),t.innerHTML=e,dS[e]=t),t},pS=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};let mS=!1;const hS=e=>`touches`in e,gS=e=>mS&&!hS(e)?!1:(mS||=hS(e),!0),_S=(e,t)=>{let n=hS(t)?t.touches[0]:t,r=e.el.getBoundingClientRect();pS(e.el,`move`,e.getMove({x:Qx((n.pageX-(r.left+window.pageXOffset))/r.width),y:Qx((n.pageY-(r.top+window.pageYOffset))/r.height)}))},vS=(e,t)=>{let n=t.keyCode;n>40||e.xy&&n<37||n<33||(t.preventDefault(),pS(e.el,`move`,e.getMove({x:n===39?.01:n===37?-.01:n===34?.05:n===33?-.05:n===35?1:n===36?-1:0,y:n===40?.01:n===38?-.01:0},!0)))};var yS=class{constructor(e,t,n,r){let i=fS(``);e.appendChild(i.content.cloneNode(!0));let a=e.querySelector(`[part=${t}]`);a.addEventListener(`mousedown`,this),a.addEventListener(`touchstart`,this),a.addEventListener(`keydown`,this),this.el=a,this.xy=r,this.nodes=[a.firstChild,a]}set dragging(e){let t=e?document.addEventListener:document.removeEventListener;t(mS?`touchmove`:`mousemove`,this),t(mS?`touchend`:`mouseup`,this)}handleEvent(e){switch(e.type){case`mousedown`:case`touchstart`:if(e.preventDefault(),!gS(e)||!mS&&e.button!=0)return;this.el.focus(),_S(this,e),this.dragging=!0;break;case`mousemove`:case`touchmove`:e.preventDefault(),_S(this,e);break;case`mouseup`:case`touchend`:this.dragging=!1;break;case`keydown`:vS(this,e);break}}style(e){e.forEach((e,t)=>{for(let n in e)this.nodes[t].style.setProperty(n,e[n])})}},bS=class extends yS{constructor(e){super(e,`hue`,`aria-label="Hue" aria-valuemin="0" aria-valuemax="360"`,!1)}update({h:e}){this.h=e,this.style([{left:`${e/360*100}%`,color:iS({h:e,s:100,v:100,a:1})}]),this.el.setAttribute(`aria-valuenow`,`${$x(e)}`)}getMove(e,t){return{h:t?Qx(this.h+e.x*360,0,360):360*e.x}}},xS=class extends yS{constructor(e){super(e,`saturation`,`aria-label="Color"`,!0)}update(e){this.hsva=e,this.style([{top:`${100-e.v}%`,left:`${e.s}%`,color:iS(e)},{"background-color":iS({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute(`aria-valuetext`,`Saturation ${$x(e.s)}%, Brightness ${$x(e.v)}%`)}getMove(e,t){return{s:t?Qx(this.hsva.s+e.x*100,0,100):e.x*100,v:t?Qx(this.hsva.v-e.y*100,0,100):Math.round(100-e.y*100)}}},SS=`:host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}`,CS=`[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}`,wS=`[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}`;const TS=Symbol(`same`),ES=Symbol(`color`),DS=Symbol(`hsva`),OS=Symbol(`update`),kS=Symbol(`parts`),AS=Symbol(`css`),jS=Symbol(`sliders`);var MS=class extends HTMLElement{static get observedAttributes(){return[`color`]}get[AS](){return[SS,CS,wS]}get[jS](){return[xS,bS]}get color(){return this[ES]}set color(e){if(!this[TS](e)){let t=this.colorModel.toHsva(e);this[OS](t),this[ES]=e}}constructor(){super();let e=fS(``),t=this.attachShadow({mode:`open`});t.appendChild(e.content.cloneNode(!0)),t.addEventListener(`move`,this),this[kS]=this[jS].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty(`color`)){let e=this.color;delete this.color,this.color=e}else this.color||=this.colorModel.defaultColor}attributeChangedCallback(e,t,n){let r=this.colorModel.fromAttr(n);this[TS](r)||(this.color=r)}handleEvent(e){let t=this[DS],n={...t,...e.detail};this[OS](n);let r;!lS(n,t)&&!this[TS](r=this.colorModel.fromHsva(n))&&(this[ES]=r,pS(this,`color-changed`,{value:r}))}[TS](e){return this.color&&this.colorModel.equal(e,this.color)}[OS](e){this[DS]=e,this[kS].forEach(t=>t.update(e))}};const NS={defaultColor:`#000`,toHsva:eS,fromHsva:({h:e,s:t,v:n})=>nS({h:e,s:t,v:n,a:1}),equal:uS,fromAttr:e=>e};var PS=class extends MS{get colorModel(){return NS}},FS=class extends P{hexInputRow;_debounceColorPickerEvent;_config;constructor(e,t={}){super(e),this.set({color:``,_hexColor:``}),this.hexInputRow=this._createInputRow();let n=this.createCollection();t.hideInput||n.add(this.hexInputRow),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-color-picker`],tabindex:-1},children:n}),this._config=t,this._debounceColorPickerEvent=Kt(e=>{this.set(`color`,e),this.fire(`colorSelected`,{color:this.color})},150,{leading:!0}),this.on(`set:color`,(e,t,n)=>{e.return=Kb(n,this._config.format||`hsl`)}),this.on(`change:color`,()=>{this._hexColor=IS(this.color)}),this.on(`change:_hexColor`,()=>{document.activeElement!==this.picker&&this.picker.setAttribute(`color`,this._hexColor),IS(this.color)!=IS(this._hexColor)&&(this.color=this._hexColor)})}render(){if(super.render(),Jb(`hex-color-picker`,PS),this.picker=u.document.createElement(`hex-color-picker`),this.picker.setAttribute(`class`,`hex-color-picker`),this.picker.setAttribute(`tabindex`,`-1`),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);let e=document.createElement(`style`);e.textContent=`[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}`,this.picker.shadowRoot.appendChild(e)}this.picker.addEventListener(`color-changed`,e=>{let t=e.detail.value;this._debounceColorPickerEvent(t)})}focus(){!this._config.hideInput&&(p.isGecko||p.isiOS||p.isSafari||p.isBlink)&&this.hexInputRow.children.get(1).focus(),this.slidersView.first.focus()}_createSlidersView(){let e=[...this.picker.shadowRoot.children].filter(e=>e.getAttribute(`role`)===`slider`).map(e=>new LS(e));this.slidersView=this.createCollection(),e.forEach(e=>{this.slidersView.add(e)})}_createInputRow(){let e=this._createColorInput();return new zS(this.locale,e)}_createColorInput(){let e=new Qb(this.locale,Jx),{t}=this.locale;return e.set({label:t(`HEX`),class:`color-picker-hex-input`}),e.fieldView.bind(`value`).to(this,`_hexColor`,t=>e.isFocused?e.fieldView.value:t.startsWith(`#`)?t.substring(1):t),e.fieldView.on(`input`,()=>{let t=e.fieldView.element.value;if(t){let e=BS(t);e&&this._debounceColorPickerEvent(e)}}),e}isValid(){let{t:e}=this.locale;return this._config.hideInput?!0:(this.resetValidationStatus(),this.hexInputRow.getParsedColor()?!0:(this.hexInputRow.inputView.errorText=e(`Please enter a valid color (e.g. "ff0000").`),!1))}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}};function IS(e){let t=qb(e);return t||=`#000`,t.length===4&&(t=`#`+[t[1],t[1],t[2],t[2],t[3],t[3]].join(``)),t.toLowerCase()}var LS=class extends P{constructor(e){super(),this.element=e}focus(){this.element.focus()}},RS=class extends P{constructor(e){super(e),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-color-picker__hash-view`]},children:`#`})}},zS=class extends P{children;inputView;constructor(e,t){super(e),this.inputView=t,this.children=this.createCollection([new RS,this.inputView]),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-color-picker__row`]},children:this.children})}getParsedColor(){return BS(this.inputView.fieldView.element.value)}};function BS(e){if(!e)return null;let t=e.trim().replace(/^#/,``);return![3,4,6,8].includes(t.length)||!/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(t)?null:`#${t}`}const VS=D(Fi);var HS=class extends VS{constructor(e){super(e),this.set(`isEmpty`,!0),this.on(`change`,()=>{this.set(`isEmpty`,this.length===0)})}add(e,t){return this.find(t=>t.color===e.color)?this:super.add(e,t)}hasColor(e){return!!this.find(t=>t.color===e)}},US=class extends P{items;colorDefinitions;focusTracker;columns;documentColors;documentColorsCount;staticColorsGrid;documentColorsGrid;colorPickerButtonView;removeColorButtonView;_focusables;_documentColorsLabel;_removeButtonLabel;_colorPickerLabel;constructor(e,{colors:t,columns:n,removeButtonLabel:r,documentColorsLabel:i,documentColorsCount:a,colorPickerLabel:o,focusTracker:s,focusables:c}){super(e);let l=this.bindTemplate;this.set(`isVisible`,!0),this.focusTracker=s,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=n,this.documentColors=new HS,this.documentColorsCount=a,this._focusables=c,this._removeButtonLabel=r,this._colorPickerLabel=o,this._documentColorsLabel=i,this.setTemplate({tag:`div`,attributes:{class:[`ck-color-grids-fragment`,l.if(`isVisible`,`ck-hidden`,e=>!e)]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){let n=e.document,r=this.documentColorsCount;this.documentColors.clear();for(let i of n.getRoots()){let n=e.createRangeIn(i);for(let e of n.getItems())if(e.is(`$textProxy`)&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=r))return}}updateSelectedColors(){let e=this.documentColorsGrid,t=this.staticColorsGrid,n=this.selectedColor;t.selectedColor=n,e&&(e.selectedColor=n)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){let e=ga.bind(this.documentColors,this.documentColors),t=new P(this.locale);t.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-color-grid__label`,e.if(`isEmpty`,`ck-hidden`)]},children:[{text:this._documentColorsLabel}]}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new H,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:p_,class:`ck-color-selector__color-picker`}),this.colorPickerButtonView.on(`execute`,()=>{this.fire(`colorPicker:show`)})}_createRemoveColorButton(){let e=new H;return e.set({withText:!0,icon:S_,label:this._removeButtonLabel}),e.class=`ck-color-selector__remove-color`,e.on(`execute`,()=>{this.fire(`execute`,{value:null,source:`removeColorButton`})}),e.render(),e}_createStaticColorsGrid(){let e=new Eb(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on(`execute`,(e,t)=>{this.fire(`execute`,{value:t.value,source:`staticColorsGrid`})}),e}_createDocumentColorsGrid(){let e=ga.bind(this.documentColors,this.documentColors),t=new Eb(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if(`isEmpty`,`ck-hidden`)}}),t.items.bindTo(this.documentColors).using(e=>{let t=new Tb;return t.set({color:e.color,hasBorder:e.options?.hasBorder}),e.label&&t.set({label:e.label,tooltip:!0}),t.on(`execute`,()=>{this.fire(`execute`,{value:e.color,source:`documentColorsGrid`})}),t}),this.documentColors.on(`change:isEmpty`,(e,n,r)=>{r&&(t.selectedColor=null)}),t}_addColorToDocumentColors(e){let t=this.colorDefinitions.find(t=>t.color===e);t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}},WS=class extends P{items;colorPickerView;saveButtonView;cancelButtonView;actionBarView;focusTracker;keystrokes;_focusables;_colorPickerViewConfig;constructor(e,{focusTracker:t,focusables:n,keystrokes:r,colorPickerViewConfig:i}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=r,this.set(`isVisible`,!1),this.set(`selectedColor`,void 0),this._focusables=n,this._colorPickerViewConfig=i;let a=this.bindTemplate,{saveButtonView:o,cancelButtonView:s}=this._createActionButtons();this.saveButtonView=o,this.cancelButtonView=s,this.actionBarView=this._createActionBarView({saveButtonView:o,cancelButtonView:s}),this.setTemplate({tag:`div`,attributes:{class:[`ck-color-picker-fragment`,a.if(`isVisible`,`ck-hidden`,e=>!e)]},children:this.items})}render(){super.render();let e=new FS(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,`change:selectedColor`,(t,n,r)=>{e.color=r}),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set(`enter`,e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire(`execute`,{value:this.selectedColor}),e.stopPropagation(),e.preventDefault())})}_stopPropagationOnArrowsKeys(){let e=e=>e.stopPropagation();this.keystrokes.set(`arrowright`,e),this.keystrokes.set(`arrowleft`,e),this.keystrokes.set(`arrowup`,e),this.keystrokes.set(`arrowdown`,e)}_addColorPickersElementsToFocusTracker(){for(let e of this.colorPickerView.slidersView)this.focusTracker.add(e.element),this._focusables.add(e);let e=this.colorPickerView.hexInputRow.children.get(1);e.element&&(this.focusTracker.add(e.element),this._focusables.add(e)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:e,cancelButtonView:t}){let n=new P,r=this.createCollection();return r.add(e),r.add(t),n.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-color-selector_action-bar`]},children:r}),n}_createActionButtons(){let e=this.locale,t=e.t,n=new H(e),r=new H(e);return n.set({icon:l_,class:`ck-button-save`,type:`button`,withText:!1,label:t(`Accept`)}),r.set({icon:s_,class:`ck-button-cancel`,type:`button`,withText:!1,label:t(`Cancel`)}),n.on(`execute`,()=>{this.colorPickerView.isValid()&&this.fire(`execute`,{source:`colorPickerSaveButton`,value:this.selectedColor})}),r.on(`execute`,()=>{this.fire(`colorPicker:cancel`)}),{saveButtonView:n,cancelButtonView:r}}_executeUponColorChange(){this.colorPickerView.on(`colorSelected`,(e,t)=>{this.fire(`execute`,{value:t.color,source:`colorPicker`}),this.set(`selectedColor`,t.color)})}},GS=class extends P{focusTracker;keystrokes;items;colorGridsFragmentView;colorPickerFragmentView;_focusCycler;_focusables;_colorPickerViewConfig;constructor(e,{colors:t,columns:n,removeButtonLabel:r,documentColorsLabel:i,documentColorsCount:a,colorPickerLabel:o,colorPickerViewConfig:s}){super(e),this.items=this.createCollection(),this.focusTracker=new M,this.keystrokes=new N,this._focusables=new pa,this._colorPickerViewConfig=s,this._focusCycler=new Hy({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:`shift + tab`,focusNext:`tab`}}),this.colorGridsFragmentView=new US(e,{colors:t,columns:n,removeButtonLabel:r,documentColorsLabel:i,documentColorsCount:a,colorPickerLabel:o,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new WS(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:s}),this.set(`_isColorGridsFragmentVisible`,!0),this.set(`_isColorPickerFragmentVisible`,!1),this.set(`selectedColor`,void 0),this.colorGridsFragmentView.bind(`isVisible`).to(this,`_isColorGridsFragmentVisible`),this.colorPickerFragmentView.bind(`isVisible`).to(this,`_isColorPickerFragmentVisible`),this.on(`change:selectedColor`,(e,t,n)=>{this.colorGridsFragmentView.set(`selectedColor`,n),this.colorPickerFragmentView.set(`selectedColor`,n)}),this.colorGridsFragmentView.on(`change:selectedColor`,(e,t,n)=>{this.set(`selectedColor`,n)}),this.colorPickerFragmentView.on(`change:selectedColor`,(e,t,n)=>{this.set(`selectedColor`,n)}),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-color-selector`]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){!this.colorPickerFragmentView.colorPickerView||this._isColorPickerFragmentVisible||(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsFragmentView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate(`execute`).to(this),this.colorGridsFragmentView.delegate(`colorPicker:show`).to(this))}_appendColorPickerFragment(){this.items.length!==2&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on(`execute`,()=>{this.showColorPickerFragment()}),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate(`execute`).to(this),this.colorPickerFragmentView.delegate(`colorPicker:cancel`).to(this))}},KS=class{editor;_components=new Map;constructor(e){this.editor=e}*names(){for(let e of this._components.values())yield e.originalName}add(e,t){this._components.set(qS(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new w(`componentfactory-item-missing`,this,{name:e});return this._components.get(qS(e)).callback(this.editor.locale)}has(e){return this._components.has(qS(e))}};function qS(e){return String(e).toLowerCase()}const JS=`ck-tooltip`,YS=br();var XS=class e extends YS{tooltipTextView;balloonPanelView;static defaultBalloonPositions=ab.generatePositions({heightOffset:5,sideOffset:13});_currentElementWithTooltip=null;_currentTooltipPosition=null;_mutationObserver=null;_pinTooltipDebounced;_unpinTooltipDebounced;_watchdogExcluded;static _editors=new Set;static _instance=null;constructor(t){if(super(),e._editors.add(t),e._instance)return e._instance;e._instance=this,this.tooltipTextView=new P(t.locale),this.tooltipTextView.set(`text`,``),this.tooltipTextView.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-tooltip__text`]},children:[{text:this.tooltipTextView.bindTemplate.to(`text`)}]}),this.balloonPanelView=new ab(t.locale),this.balloonPanelView.class=JS,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=$S(()=>{this._updateTooltipPosition()}),this._pinTooltipDebounced=Kt(this._pinTooltip,600),this._unpinTooltipDebounced=Kt(this._unpinTooltip,400),this.listenTo(u.document,`keydown`,this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(u.document,`mouseenter`,this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(u.document,`mouseleave`,this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(u.document,`focus`,this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(u.document,`blur`,this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(u.document,`scroll`,this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(t){let n=t.ui.view&&t.ui.view.body;e._editors.delete(t),this.stopListening(t.ui),n&&n.has(this.balloonPanelView)&&n.remove(this.balloonPanelView),e._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),e._instance=null)}static getPositioningFunctions(t){let n=e.defaultBalloonPositions;return{s:[n.southArrowNorth,n.southArrowNorthEast,n.southArrowNorthWest],n:[n.northArrowSouth],e:[n.eastArrowWest],w:[n.westArrowEast],sw:[n.southArrowNorthEast],se:[n.southArrowNorthWest]}[t]}_onKeyDown(e,t){t.key===`Escape`&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){let n=ZS(t);if(!n){e.name===`focus`&&this._unpinTooltip();return}if(n===this._currentElementWithTooltip){this._unpinTooltipDebounced.cancel();return}this._unpinTooltip(),e.name===`focus`&&!n.matches(`:hover`)||n.matches(`[data-cke-tooltip-instant]`)?this._pinTooltip(n,QS(n)):this._pinTooltipDebounced(n,QS(n))}_onLeaveOrBlur(e,{target:t,relatedTarget:n}){if(e.name===`mouseleave`){if(!jn(t))return;let e=this.balloonPanelView.element,r=e&&(e===n||e.contains(n)),i=!r&&t===e;if(r){this._unpinTooltipDebounced.cancel();return}if(!i&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;let a=ZS(t),o=ZS(n);(i||a&&a!==o)&&(this._pinTooltipDebounced.cancel(),this._currentElementWithTooltip&&this._currentElementWithTooltip.matches(`[data-cke-tooltip-instant]`)||a&&a.matches(`[data-cke-tooltip-instant]`)?this._unpinTooltip():this._unpinTooltipDebounced())}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._pinTooltipDebounced.cancel(),this._unpinTooltipDebounced()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(t,{text:n,position:r,cssClass:i}){this._unpinTooltip();let a=j(e._editors.values()).ui.view.body;a.has(this.balloonPanelView)||a.add(this.balloonPanelView),this.tooltipTextView.text=n,this.balloonPanelView.class=[JS,i].filter(e=>e).join(` `),this.balloonPanelView.pin({target:t,positions:e.getPositioningFunctions(r)}),this._mutationObserver.attach(t);for(let t of e._editors)this.listenTo(t.ui,`update`,this._updateTooltipPosition.bind(this),{priority:`low`});this._currentElementWithTooltip=t,this._currentTooltipPosition=r}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(let t of e._editors)this.stopListening(t.ui,`update`);this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text=``,this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;let t=QS(this._currentElementWithTooltip);if(!Yr(this._currentElementWithTooltip)||!t.text){this._unpinTooltip();return}this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:e.getPositioningFunctions(t.position)})}};function ZS(e){return jn(e)?e.closest(`[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])`):null}function QS(e){return{text:e.dataset.ckeTooltipText,position:e.dataset.ckeTooltipPosition||`s`,cssClass:e.dataset.ckeTooltipClass||``}}function $S(e){let t=new MutationObserver(()=>{e()});return{attach(e){t.observe(e,{attributes:!0,attributeFilter:[`data-cke-tooltip-text`,`data-cke-tooltip-position`]})},detach(){t.disconnect()}}}var eC=class extends cb{licenseTypeMessage={evaluation:`For evaluation purposes only`,trial:`For evaluation purposes only`,development:`For development purposes only`};constructor(e){super(e,{balloonClass:`ck-evaluation-badge-balloon`})}_isEnabled(){let e=nC(this.editor.config.get(`licenseKey`));return!!(e&&this.licenseTypeMessage[e])}_createBadgeContent(){let e=nC(this.editor.config.get(`licenseKey`));return new tC(this.editor.locale,this.licenseTypeMessage[e])}_getNormalizedConfig(){let e=super._getNormalizedConfig(),t=this.editor.config.get(`ui.poweredBy`)||{};return{position:t.position||e.position,side:(t.side||e.side)===`left`?`right`:`left`,verticalOffset:e.verticalOffset,horizontalOffset:e.horizontalOffset}}},tC=class extends P{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 nC(e){if(e==`GPL`)return`GPL`;let t=Xi(e.split(`.`)[1]);return t?t.licenseType||`production`:null}var rC=class extends dx{constructor(e,t){super(e);let n=this.bindTemplate;this.extendTemplate({attributes:{class:[`ck-menu-bar__menu__item`]},on:{mouseenter:n.to(`mouseenter`)}}),this.delegate(`mouseenter`).to(t)}};const iC={toggleMenusAndFocusItemsOnHover(e){e.on(`menu:mouseenter`,t=>{if(!(!e.isFocusBorderEnabled&&!e.isOpen)){if(e.isOpen)for(let n of e.menus){let e=t.path[0],r=e instanceof rC&&e.children.first===n;n.isOpen=(t.path.includes(n)||r)&&n.isEnabled}t.source.focus()}})},focusCycleMenusOnArrows(e){let t=e.locale.uiLanguageDirection===`rtl`;e.on(`menu:arrowright`,e=>{n(e.source,t?-1:1)}),e.on(`menu:arrowleft`,e=>{n(e.source,t?1:-1)});function n(t,n){let r=e.children.getIndex(t),i=t.isOpen,a=e.children.length,o=e.children.get((r+a+n)%a);t.isOpen=!1,i&&(o.isOpen=!0),o.buttonView.focus()}},closeMenusWhenTheBarCloses(e){e.on(`change:isOpen`,()=>{e.isOpen||e.menus.forEach(e=>{e.isOpen=!1})})},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on(`menu:change:isOpen`,(t,n,r)=>{r&&e.menus.filter(e=>t.source.parentMenuView===e.parentMenuView&&t.source!==e&&e.isOpen).forEach(e=>{e.isOpen=!1})})},closeOnClickOutside(e){Ya({emitter:e,activator:()=>e.isOpen,callback:()=>e.close(),contextElements:()=>e.children.map(e=>e.element)})},enableFocusHighlightOnInteraction(e){let t=!1;e.on(`change:isOpen`,(n,r,i)=>{i||(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})}},aC={openAndFocusPanelOnArrowDownKey(e){e.keystrokes.set(`arrowdown`,(t,n)=>{e.isEnabled&&e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen||=!0,e.panelView.focus(),n())})},openOnArrowRightKey(e){let t=e.locale.uiLanguageDirection===`rtl`?`arrowleft`:`arrowright`;e.keystrokes.set(t,(t,n)=>{e.focusTracker.focusedElement!==e.buttonView.element||!e.isEnabled||(e.isOpen||=!0,e.panelView.focus(),n())})},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,n)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen=!0,e.panelView.focus(),n())})},closeOnArrowLeftKey(e){let t=e.locale.uiLanguageDirection===`rtl`?`arrowright`:`arrowleft`;e.keystrokes.set(t,(t,n)=>{e.isOpen&&(e.isOpen=!1,e.focus(),n())})},closeOnEscKey(e){e.keystrokes.set(`esc`,(t,n)=>{e.isOpen&&(e.isOpen=!1,e.focus(),n())})},closeOnParentClose(e){e.parentMenuView.on(`change:isOpen`,(t,n,r)=>{!r&&t.source===e.parentMenuView&&(e.isOpen=!1)})}},oC={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`})},sC=[{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:`fullscreen`,items:[`menuBar:fullscreen`]},{groupId:`restrictedEditing`,items:[`menuBar:restrictedEditing`]}]},{menuId:`insert`,label:`Insert`,groups:[{groupId:`insertMainWidgets`,items:[`menuBar:insertImage`,`menuBar:ckbox`,`menuBar:ckfinder`,`menuBar:insertTable`,`menuBar:insertTableLayout`]},{groupId:`insertInline`,items:[`menuBar:link`,`menuBar:insertFootnote`,`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`]},{groupId:`restrictedEditingException`,items:[`menuBar:restrictedEditingException:inline`,`menuBar:restrictedEditingException:block`]}]},{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:lineHeight`,`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`,`menuBar:toggleAi`,`menuBar:aiQuickActions`]},{groupId:`tools`,items:[`menuBar:trackChanges`,`menuBar:commentsArchive`]}]},{menuId:`help`,label:`Help`,groups:[{groupId:`help`,items:[`menuBar:accessibilityHelp`]}]}];function cC(e){let t;return t=!(`items`in e)||!e.items?{items:Rt(sC),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...e}:{items:e.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...e},t}function lC({normalizedConfig:e,locale:t,componentFactory:n,extraItems:r}){let i=Rt(e);return dC(e,i,r),uC(e,i),dC(e,i,i.addItems),pC(e,i,n),mC(e,i),gC(i,t),i}function uC(e,t){let n=t.removeItems,r=[];t.items=t.items.filter(({menuId:e})=>n.includes(e)?(r.push(e),!1):!0),_C(t.items,e=>{e.groups=e.groups.filter(({groupId:e})=>n.includes(e)?(r.push(e),!1):!0);for(let t of e.groups)t.items=t.items.filter(e=>{let t=SC(e);return n.includes(t)?(r.push(t),!1):!0})});for(let t of n)r.includes(t)||T(`menu-bar-item-could-not-be-removed`,{menuBarConfig:e,itemName:t})}function dC(e,t,n){let r=[];if(n.length!=0){for(let e of n){let n=bC(e.position),i=xC(e.position);if(vC(e))if(!i)n===`start`?(t.items.unshift(e.menu),r.push(e)):n===`end`&&(t.items.push(e.menu),r.push(e));else{let a=t.items.findIndex(e=>e.menuId===i);a==-1?fC(t,e.menu,i,n)&&r.push(e):n===`before`?(t.items.splice(a,0,e.menu),r.push(e)):n===`after`&&(t.items.splice(a+1,0,e.menu),r.push(e))}else yC(e)?_C(t.items,t=>{if(t.menuId===i)n===`start`?(t.groups.unshift(e.group),r.push(e)):n===`end`&&(t.groups.push(e.group),r.push(e));else{let a=t.groups.findIndex(e=>e.groupId===i);a!==-1&&(n===`before`?(t.groups.splice(a,0,e.group),r.push(e)):n===`after`&&(t.groups.splice(a+1,0,e.group),r.push(e)))}}):fC(t,e.item,i,n)&&r.push(e)}for(let t of n)r.includes(t)||T(`menu-bar-item-could-not-be-added`,{menuBarConfig:e,addedItemConfig:t})}}function fC(e,t,n,r){let i=!1;return _C(e.items,e=>{for(let{groupId:a,items:o}of e.groups){if(i)return;if(a===n)r===`start`?(o.unshift(t),i=!0):r===`end`&&(o.push(t),i=!0);else{let e=o.findIndex(e=>SC(e)===n);e!==-1&&(r===`before`?(o.splice(e,0,t),i=!0):r===`after`&&(o.splice(e+1,0,t),i=!0))}}}),i}function pC(e,t,n){_C(t.items,r=>{for(let i of r.groups)i.items=i.items.filter(i=>{let a=typeof i==`string`&&!n.has(i);return a&&!t.isUsingDefaultConfig&&T(`menu-bar-item-unavailable`,{menuBarConfig:e,parentMenuConfig:Rt(r),componentName:i}),!a})})}function mC(e,t){let n=t.isUsingDefaultConfig,r=!1;if(t.items=t.items.filter(t=>t.groups.length?!0:(hC(e,t,n),!1)),!t.items.length){hC(e,e,n);return}_C(t.items,t=>{t.groups=t.groups.filter(e=>e.items.length?!0:(r=!0,!1));for(let i of t.groups)i.items=i.items.filter(t=>CC(t)&&!t.groups.length?(hC(e,t,n),r=!0,!1):!0)}),r&&mC(e,t)}function hC(e,t,n){n||T(`menu-bar-menu-empty`,{menuBarConfig:e,emptyMenuConfig:t})}function gC(e,t){let n=t.t,r={File:n({string:`File`,id:`MENU_BAR_MENU_FILE`}),Edit:n({string:`Edit`,id:`MENU_BAR_MENU_EDIT`}),View:n({string:`View`,id:`MENU_BAR_MENU_VIEW`}),Insert:n({string:`Insert`,id:`MENU_BAR_MENU_INSERT`}),Format:n({string:`Format`,id:`MENU_BAR_MENU_FORMAT`}),Tools:n({string:`Tools`,id:`MENU_BAR_MENU_TOOLS`}),Help:n({string:`Help`,id:`MENU_BAR_MENU_HELP`}),Text:n({string:`Text`,id:`MENU_BAR_MENU_TEXT`}),Font:n({string:`Font`,id:`MENU_BAR_MENU_FONT`})};_C(e.items,e=>{e.label in r&&(e.label=r[e.label])})}function _C(e,t){if(Array.isArray(e))for(let t of e)n(t);function n(e){t(e);for(let t of e.groups)for(let e of t.items)CC(e)&&n(e)}}function vC(e){return typeof e==`object`&&`menu`in e}function yC(e){return typeof e==`object`&&`group`in e}function bC(e){return e.startsWith(`start`)?`start`:e.startsWith(`end`)?`end`:e.startsWith(`after`)?`after`:`before`}function xC(e){let t=e.match(/^[^:]+:(.+)/);return t?t[1]:null}function SC(e){return typeof e==`string`?e:e.menuId}function CC(e){return typeof e==`object`&&`menuId`in e}const wC=D();var TC=class extends wC{editor;componentFactory;focusTracker;tooltipManager;poweredBy;evaluationBadge;ariaLiveAnnouncer;isReady=!1;_editableElementsMap=new Map;_focusableToolbarDefinitions=[];_extraMenuBarElements=[];_lastFocusedForeignElement=null;_domEmitter;constructor(e){super();let t=e.editing.view;this.editor=e,this.componentFactory=new KS(e),this.focusTracker=new M,this.tooltipManager=new XS(e),this.poweredBy=new fb(e),this.evaluationBadge=new eC(e),this.ariaLiveAnnouncer=new Ka(e),this._initViewportOffset(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(),this._initVisualViewportSupport()}get element(){return null}update(){this.fire(`update`)}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy(),this.evaluationBadge.destroy();for(let e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[],this._domEmitter&&this._domEmitter.stopListening()}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||=this.editor,this.focusTracker.add(t);let n=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?n():this.once(`ready`,n)}removeEditableElement(e){let t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(e=`main`){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e,t={}){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)}initMenuBar(e){let t=e.element;this.focusTracker.add(t),this.editor.keystrokes.listenTo(t);let n=cC(this.editor.config.get(`menuBar`)||{});e.fillFromConfig(n,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set(`Esc`,(e,n)=>{t.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),n())}),this.editor.keystrokes.set(`Alt+F9`,(n,r)=>{t.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),e.isFocusBorderEnabled=!0,e.focus(),r())})}_readViewportOffsetFromConfig(){let e=this.editor,t=e.config.get(`ui.viewportOffset`);if(t)return t;let n=e.config.get(`toolbar.viewportTopOffset`);return n?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:n}):{top:0}}_initFocusTracking(){let e=this.editor,t;e.keystrokes.set(`Alt+F10`,(e,n)=>{this._saveLastFocusedForeignElement();let r=this._getCurrentFocusedToolbarDefinition();(!r||!t)&&(t=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{let r=this._getCurrentFocusedToolbarDefinition();r&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):e.editing.view.focus(),r.options.afterBlur&&r.options.afterBlur(),n())})}_saveLastFocusedForeignElement(){let 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(){let e=[];for(let t of this._focusableToolbarDefinitions){let{toolbarView:n,options:r}=t;(Yr(n.element)||r.beforeFocus)&&e.push(t)}return e.sort((e,t)=>EC(e)-EC(t)),e}_getCurrentFocusedToolbarDefinition(){for(let e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){let{toolbarView:t,options:{beforeFocus:n}}=e;return n&&n(),Yr(t.element)?(t.focus(),!0):!1}_handleScrollToTheSelection(e,t){let n={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=n.top,t.viewportOffset.bottom+=n.bottom,t.viewportOffset.left+=n.left,t.viewportOffset.right+=n.right}_bindBodyCollectionWithFocusTracker(){let e=this.view.body;for(let 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)})}_initViewportOffset(e){this.on(`set:viewportOffset`,(e,t,n)=>{let r=this._getVisualViewportTopOffset(n);n.visualTop!==r&&(e.return={...n,visualTop:r})}),this.set(`viewportOffset`,e)}_initVisualViewportSupport(){if(!u.window.visualViewport)return;let e=()=>{let e=this._getVisualViewportTopOffset(this.viewportOffset);this.viewportOffset.visualTop!==e&&(this.viewportOffset={...this.viewportOffset,visualTop:e})};this._domEmitter=new(br()),this._domEmitter.listenTo(u.window.visualViewport,`scroll`,e),this._domEmitter.listenTo(u.window.visualViewport,`resize`,e)}_getVisualViewportTopOffset(e){let t=ti().top,n=e.top||0;return t>n?0:n-t}};function EC(e){let{toolbarView:t,options:n}=e,r=10;return Yr(t.element)&&r--,n.isContextual&&(r-=2),r}var DC=class extends P{body;menuBarView;toolbar;constructor(e){super(e),this.body=new nb(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}},OC=class extends DC{top;main;_voiceLabelView;constructor(e){super(e),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-reset`,`ck-editor`,`ck-rounded-corners`],role:`application`,dir:e.uiLanguageDirection,lang:e.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:`div`,attributes:{class:[`ck`,`ck-editor__top`,`ck-reset_all`],role:`presentation`},children:this.top},{tag:`div`,attributes:{class:[`ck`,`ck-editor__main`],role:`presentation`},children:this.main}]})}_createVoiceLabel(){let e=this.t,t=new eo;return t.text=e(`Rich Text Editor`),t.extendTemplate({attributes:{class:`ck-voice-label`}}),t}},kC=class extends P{name=null;_editingView;_editableElement;_hasExternalElement;constructor(e,t,n){super(e);let{name:r,classes:i,styles:a,attributes:o}=(AC(n)?void 0:n)||{};this.set(`isFocused`,!1),this.set(`isInlineRoot`,!1),this.setTemplate({tag:r||`div`,attributes:{...o,class:[`ck`,`ck-content`,`ck-editor__editable`,`ck-rounded-corners`,this.bindTemplate.if(`isInlineRoot`,`ck-editor__editable_inline-root`),...i?A(i):[]],...a&&{style:a},lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this._editableElement=AC(n)?n:void 0,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(){let e=this._editingView;e.isRenderingInProgress?n(this):t(this);function t(t){e.change(n=>{let r=e.document.getRoot(t.name);n.addClass(t.isFocused?`ck-focused`:`ck-blurred`,r),n.removeClass(t.isFocused?`ck-blurred`:`ck-focused`,r)})}function n(r){e.once(`change:isRenderingInProgress`,(e,i,a)=>{a?n(r):t(r)})}}};function AC(e){return jn(e)}var jC=class extends kC{_options;constructor(e,t,n,r={}){super(e,t,n),this._options=r,this.extendTemplate({attributes:{role:`textbox`,class:`ck-editor__editable_inline`}})}render(){super.render();let e=this._editingView;e.change(t=>{let n=e.document.getRoot(this.name);t.setAttribute(`aria-label`,this.getEditableAriaLabel(),n)})}getEditableAriaLabel(){let e=this.locale.t,t=this._options.label,n=this._editableElement,r=this.name;if(typeof t==`string`)return t;if(typeof t==`object`)return t[r];if(typeof t==`function`)return t(this);if(n){let e=n.getAttribute(`aria-label`);if(e)return e}return e(`Rich Text Editor. Editing area: %0`,r)}},MC=class extends P{children;constructor(e,t={}){super(e);let n=this.bindTemplate;this.set(`class`,[`ck`,`ck-form__row`,...A(t.class||[])]),this.children=this.createCollection(),t.children&&t.children.forEach(e=>this.children.add(e)),this.set(`_role`,null),this.set(`_ariaLabelledBy`,null),t.labelView&&this.set({_role:`group`,_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:`div`,attributes:{class:n.to(`class`,e=>e.join(` `)),role:n.to(`_role`),"aria-labelledby":n.to(`_ariaLabelledBy`)},children:this.children})}},NC=class extends P{constructor(e){super(e);let t=this.bindTemplate;this.setTemplate({tag:`iframe`,attributes:{class:[`ck`,`ck-reset_all`],sandbox:`allow-same-origin allow-scripts`},on:{load:t.to(`loaded`)}})}render(){return new Promise(e=>(this.on(`loaded`,e),super.render()))}},PC=class extends P{labelView;inputView;statusView;constructor(e,t){super(e);let n=`ck-input-${he()}`,r=`ck-status-${he()}`;this.set(`label`,void 0),this.set(`value`,void 0),this.set(`isReadOnly`,!1),this.set(`errorText`,null),this.set(`infoText`,null),this.labelView=this._createLabelView(n),this.inputView=this._createInputView(t,n,r),this.statusView=this._createStatusView(r),this.bind(`_statusText`).to(this,`errorText`,this,`infoText`,(e,t)=>e||t);let i=this.bindTemplate;this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-labeled-input`,i.if(`isReadOnly`,`ck-disabled`)]},children:[this.labelView,this.inputView,this.statusView]})}_createLabelView(e){let t=new eo(this.locale);return t.for=e,t.bind(`text`).to(this,`label`),t}_createInputView(e,t,n){let r=new e(this.locale,n);return r.id=t,r.ariaDescribedById=n,r.bind(`value`).to(this),r.bind(`isReadOnly`).to(this),r.bind(`hasError`).to(this,`errorText`,e=>!!e),r.on(`input`,()=>{this.errorText=null}),r}_createStatusView(e){let t=new P(this.locale),n=this.bindTemplate;return t.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-labeled-input__status`,n.if(`errorText`,`ck-labeled-input__status_error`),n.if(`_statusText`,`ck-hidden`,e=>!e)],id:e,role:n.if(`errorText`,`alert`)},children:[{text:n.to(`_statusText`)}]}),t}select(){this.inputView.select()}focus(){this.inputView.focus()}};function FC(e,t){let n=0,r=0;for(let i of t){let t=i,a=t.items,o=e&&!!t.label.match(e);t.labelView.highlightText(o?e:null);for(let t of a){let n=t.children.first,r=n.labelView;if(!e)t.isVisible=!0,r.highlightText(null);else{let i=!!n.label.match(e);r.highlightText(i?e:null),t.isVisible=o||i}}let s=a.filter(e=>e.isVisible).length;n+=t.items.length,r+=o?t.items.length:s,t.isVisible=o||!!s}return{resultsCount:r,totalItemsCount:n}}var IC=class extends ho{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,t={}){this._showNotification({message:e,type:`success`,namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:`info`,namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:`warning`,namespace:t.namespace,title:t.title})}_showNotification(e){let t=e.namespace?`show:${e.type}:${e.namespace}`:`show:${e.type}`;this.fire(t,{message:e.message,type:e.type,title:e.title||``})}};const LC=D();var RC=class extends LC{constructor(e,t){super(),t&&fn(this,t),e&&this.set(e)}};const zC=Wr(`px`);var BC=class extends F{positionLimiter;visibleStack;_viewToStack=new Map;_idToStack=new Map;_view=null;_rotatorView=null;_fakePanelsView=null;static get pluginName(){return`ContextualBalloon`}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.positionLimiter=()=>{let 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 w(`contextualballoon-add-view-exist`,[this,e]);let t=e.stackId||`main`;if(!this._idToStack.has(t)){this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,(!this._visibleStack||e.singleViewMode)&&this.showStack(t);return}let n=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),n.set(e.view,e),this._viewToStack.set(e.view,n),n===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new w(`contextualballoon-remove-view-not-exist`,[this,e]);let t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(t.size===1?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),t.size===1?(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})),Object.assign({},e,{viewportOffsetConfig:{...this.editor.ui.viewportOffset,top:this.editor.ui.viewportOffset.visualTop}})),e}showStack(e){this.visibleStack=e;let t=this._idToStack.get(e);if(!t)throw new w(`contextualballoon-showstack-stack-not-exist`,this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new ab(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(){let e=Array.from(this._idToStack.values()),t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){let e=Array.from(this._idToStack.values()),t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){let e=new VC(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,n)=>n<2?``:t(`%0 of %1`,[Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1,n])),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(){let e=new HC(this.editor.locale,this.view);return e.bind(`numberOfPanels`).to(this,`_numberOfStacks`,this,`_singleViewMode`,(e,t)=>!t&&e>=2?Math.min(e-1,2):0),e.listenTo(this.view,`change:top`,()=>e.updatePosition()),e.listenTo(this.view,`change:left`,()=>e.updatePosition()),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t=``,withArrow:n=!0,singleViewMode:r=!1}){this.view.class=t,this.view.withArrow=n,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),r&&(this._singleViewMode=!0)}},VC=class extends P{focusTracker;buttonPrevView;buttonNextView;content;constructor(e){super(e);let t=e.t,n=this.bindTemplate;this.set(`isNavigationVisible`,!0),this.focusTracker=new M,this.buttonPrevView=this._createButtonView(t(`Previous`),Wv),this.buttonNextView=this._createButtonView(t(`Next`),gv),this.content=this.createCollection(),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-balloon-rotator`],"z-index":`-1`},children:[{tag:`div`,attributes:{class:[`ck-balloon-rotator__navigation`,n.to(`isNavigationVisible`,e=>e?``:`ck-hidden`)]},children:[this.buttonPrevView,{tag:`span`,attributes:{class:[`ck-balloon-rotator__counter`]},children:[{text:n.to(`counter`)}]},this.buttonNextView]},{tag:`div`,attributes:{class:`ck-balloon-rotator__content`},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){let n=new H(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n}},HC=class extends P{content;_balloonPanelView;constructor(e,t){super(e);let n=this.bindTemplate;this.set(`top`,0),this.set(`left`,0),this.set(`height`,0),this.set(`width`,0),this.set(`numberOfPanels`,0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:`div`,attributes:{class:[`ck-fake-panel`,n.to(`numberOfPanels`,e=>e?``:`ck-hidden`)],style:{top:n.to(`top`,zC),left:n.to(`left`,zC),width:n.to(`width`,zC),height:n.to(`height`,zC)}},children:this.content}),this.on(`change:numberOfPanels`,(e,t,n,r)=>{n>r?this._addPanels(n-r):this._removePanels(r-n),this.updatePosition()})}_addPanels(e){for(;e--;){let e=new P;e.setTemplate({tag:`div`}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){let e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){let{top:e,left:t}=this._balloonPanelView,{width:n,height:r}=new O(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:n,height:r})}}};const UC=Wr(`px`);var WC=class extends P{content;contentPanelElement;_contentPanelPlaceholder;constructor(e){super(e);let 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 ga({tag:`div`,attributes:{class:[`ck`,`ck-sticky-panel__placeholder`],style:{display:t.to(`isSticky`,e=>e?`block`:`none`),height:t.to(`isSticky`,e=>e?UC(this._contentPanelRect.height):null)}}}).render(),this.contentPanelElement=new ga({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?UC(this._contentPanelPlaceholder.getBoundingClientRect().width):null),top:t.to(`_stickyTopOffset`,e=>e&&UC(e)),bottom:t.to(`_stickyBottomOffset`,e=>e&&UC(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(u.document,`scroll`,()=>{this.checkIfShouldBeSticky()},{useCapture:!0}),this.listenTo(this,`change:isActive`,()=>{this.checkIfShouldBeSticky()}),u.window.visualViewport&&(this.listenTo(u.window.visualViewport,`scroll`,()=>{this.checkIfShouldBeSticky()}),this.listenTo(u.window.visualViewport,`resize`,()=>{this.checkIfShouldBeSticky()}))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive){this._unstick();return}let e=new O(this.limiterElement),t=e.getVisible();if(t){let e=new O(u.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,t=t.getIntersection(e)}let{left:n,top:r}=ti();if(e.moveBy(n,r),t&&t.moveBy(n,r),t&&e.topt.height){let n=Math.max(e.bottom-t.bottom,0)+this.limiterBottomOffset;this._contentPanelRect.height+n+1{this.reset(),this.focus(),this.fire(`reset`)}),this.resetButtonView.bind(`isVisible`).to(this.fieldView,`isEmpty`,e=>!e),this.fieldWrapperChildren.add(this.resetButtonView),this.extendTemplate({attributes:{class:`ck-search__query_with-reset`}}))}reset(){this.fieldView.reset(),this._viewConfig.showResetButton&&(this.resetButtonView.isVisible=!1)}},KC=class extends P{constructor(){super();let e=this.bindTemplate;this.set({isVisible:!1,primaryText:``,secondaryText:``}),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-search__info`,e.if(`isVisible`,`ck-hidden`,e=>!e)],tabindex:-1},children:[{tag:`span`,children:[{text:[e.to(`primaryText`)]}]},{tag:`span`,children:[{text:[e.to(`secondaryText`)]}]}]})}focus(){this.element.focus()}},qC=class extends P{focusTracker;children;_focusCycler;constructor(e){super(e),this.children=this.createCollection(),this.focusTracker=new M,this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-search__results`],tabindex:-1},children:this.children}),this._focusCycler=new Hy({focusables:this.children,focusTracker:this.focusTracker})}render(){super.render();for(let e of this.children)this.focusTracker.add(e.element)}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}},JC=class extends P{focusTracker;keystrokes;resultsView;filteredView;infoView;queryView;focusCycler;_config;constructor(e,t){super(e),this._config=t,this.filteredView=t.filteredView,this.queryView=this._createSearchTextQueryView(),this.focusTracker=new M,this.keystrokes=new N,this.resultsView=new qC(e),this.children=this.createCollection(),this.focusableChildren=this.createCollection([this.queryView,this.resultsView]),this.set(`isEnabled`,!0),this.set(`resultsCount`,0),this.set(`totalItemsCount`,0),t.infoView&&t.infoView.instance?this.infoView=t.infoView.instance:(this.infoView=new KC,this._enableDefaultInfoViewBehavior(),this.on(`render`,()=>{this.search(``)})),this.resultsView.children.addMany([this.infoView,this.filteredView]),this.focusCycler=new Hy({focusables:this.focusableChildren,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:`shift + tab`,focusNext:`tab`}}),this.on(`search`,(e,{resultsCount:t,totalItemsCount:n})=>{this.resultsCount=t,this.totalItemsCount=n}),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-search`,t.class||null],tabindex:`-1`},children:this.children})}render(){super.render(),this.children.addMany([this.queryView,this.resultsView]);let e=e=>e.stopPropagation();for(let e of this.focusableChildren)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element),this.keystrokes.set(`arrowright`,e),this.keystrokes.set(`arrowleft`,e),this.keystrokes.set(`arrowup`,e),this.keystrokes.set(`arrowdown`,e)}focus(){this.queryView.focus()}reset(){this.queryView.reset(),this.search(``),this.filteredView.element.scrollTo(0,0)}search(e){let t=e?new RegExp(Bn(e),`ig`):null,n=this.filteredView.filter(t);this.fire(`search`,{query:e,...n})}_createSearchTextQueryView(){let e=new GC(this.locale,this._config.queryView);return this.listenTo(e.fieldView,`input`,()=>{this.search(e.fieldView.element.value)}),e.on(`reset`,()=>this.reset()),e.bind(`isEnabled`).to(this),e}_enableDefaultInfoViewBehavior(){let e=this.locale.t,t=this.infoView;this.on(`search`,(r,i)=>{if(i.resultsCount)t.set({isVisible:!1});else{let r=this._config.infoView&&this._config.infoView.text,a,o;i.totalItemsCount?r?.notFound?(a=r.notFound.primary,o=r.notFound.secondary):(a=e(`No results found`),o=``):r?.noSearchableItems?(a=r.noSearchableItems.primary,o=r.noSearchableItems.secondary):(a=e(`No searchable items`),o=``),t.set({primaryText:n(a,i),secondaryText:n(o,i),isVisible:!0})}});function n(e,{query:t,resultsCount:n,totalItemsCount:r}){return typeof e==`function`?e(t,n,r):e}}},YC=class e extends JC{_config;constructor(e,t){super(e,t),this._config=t;let n=Wr(`px`);this.extendTemplate({attributes:{class:[`ck-autocomplete`]}});let r=this.resultsView.bindTemplate;this.resultsView.set(`isVisible`,!1),this.resultsView.set(`_position`,`s`),this.resultsView.set(`_width`,0),this.resultsView.extendTemplate({attributes:{class:[r.if(`isVisible`,`ck-hidden`,e=>!e),r.to(`_position`,e=>`ck-search__results_${e}`)],style:{width:r.to(`_width`,n)}}}),this.focusTracker.on(`change:isFocused`,(e,n,r)=>{this._updateResultsVisibility(),r?this.resultsView.element.scrollTop=0:t.resetOnBlur&&this.queryView.reset()}),this.on(`search`,()=>{this._updateResultsVisibility(),this._updateResultsViewWidthAndPosition()}),this.keystrokes.set(`esc`,(e,t)=>{this.resultsView.isVisible&&(this.queryView.focus(),this.resultsView.isVisible=!1,t())}),this.listenTo(u.document,`scroll`,()=>{this._updateResultsViewWidthAndPosition()}),this.on(`change:isEnabled`,()=>{this._updateResultsVisibility()}),this.filteredView.on(`execute`,(e,{value:t})=>{this.focus(),this.reset(),this.queryView.fieldView.value=this.queryView.fieldView.element.value=t,this.resultsView.isVisible=!1}),this.resultsView.on(`change:isVisible`,()=>{this._updateResultsViewWidthAndPosition()})}_updateResultsViewWidthAndPosition(){if(!this.resultsView.isVisible)return;this.resultsView._width=new O(this.queryView.fieldView.element).width;let t=e._getOptimalPosition({element:this.resultsView.element,target:this.queryView.element,fitInViewport:!0,positions:e.defaultResultsPositions});this.resultsView._position=t?t.name:`s`}_updateResultsVisibility(){let e=this._config.queryMinChars===void 0?0:this._config.queryMinChars,t=this.queryView.fieldView.element.value.length;this.resultsView.isVisible=this.focusTracker.isFocused&&this.isEnabled&&t>=e}static defaultResultsPositions=[(e=>({top:e.bottom,left:e.left,name:`s`})),((e,t)=>({top:e.top-t.height,left:e.left,name:`n`}))];static _getOptimalPosition=Xr},XC=class extends P{constructor(){super(),this.set(`text`,void 0),this.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-highlighted-text`]}}),this.on(`render`,()=>{this.on(`change:text`,()=>{this._updateInnerHTML(Rn(this.text||``))}),this._updateInnerHTML(Rn(this.text||``))})}highlightText(e){this._updateInnerHTML(ZC(this.text||``,e))}_updateInnerHTML(e){this.element.innerHTML=e||``}};function ZC(e,t){if(!t)return Rn(e);let n=[],r=0,i=t.exec(e);for(;i!==null;){let a=i.index;a!==r&&n.push({text:e.substring(r,a),isMatch:!1}),n.push({text:i[0],isMatch:!0}),r=t.lastIndex,i=t.exec(e)}return r!==e.length&&n.push({text:e.substring(r),isMatch:!1}),n.map(e=>(e.text=Rn(e.text),e)).map(e=>e.isMatch?`${e.text}`:e.text).join(``)}var QC=class extends XC{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});let e=this.bindTemplate;this.extendTemplate({attributes:{class:[`ck-button__label`],style:e.to(`style`),id:e.to(`id`)}})}},$C=class extends XC{id;constructor(){super(),this.set(`for`,void 0);let e=this.bindTemplate;this.id=`ck-editor__label_${he()}`,this.extendTemplate({attributes:{class:[`ck`,`ck-label`],id:this.id,for:e.to(`for`)}})}},ew=class extends P{constructor(){super(),this.set(`isVisible`,!1);let e=this.bindTemplate;this.setTemplate({tag:`span`,attributes:{class:[`ck`,`ck-spinner-container`,e.if(`isVisible`,`ck-hidden`,e=>!e)]},children:[{tag:`span`,attributes:{class:[`ck`,`ck-spinner`]}}]})}};const tw=Wr(`px`);var nw=class extends F{toolbarView;focusTracker;_balloonConfig;_resizeObserver=null;_balloon;_fireSelectionChangeDebounced;static get pluginName(){return`BalloonToolbar`}static get isOfficialPlugin(){return!0}static get requires(){return[BC]}constructor(e){super(e),this._balloonConfig=Ex(e.config.get(`balloonToolbar`)),this.toolbarView=this._createToolbarView(),this.focusTracker=new M,this._trackFocusableEditableElements(),this.focusTracker.add(this.toolbarView),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this.show(!0),afterBlur:()=>this.hide(),isContextual:!0}),this._balloon=e.plugins.get(BC),this._fireSelectionChangeDebounced=Kt(()=>this.fire(`_selectionChangeDebounced`),200),this.decorate(`show`)}init(){let e=this.editor,t=e.model.document.selection;this.listenTo(this.focusTracker,`change:isFocused`,(e,t,n)=>{!n&&this._isToolbarVisible?this.hide():n&&this.show()}),this.listenTo(t,`change:range`,(e,n)=>{(n.directChange||t.isCollapsed)&&this.hide(),this._fireSelectionChangeDebounced()}),this.listenTo(this,`_selectionChangeDebounced`,()=>{this.editor.editing.view.document.isFocused&&this.show()}),this._balloonConfig.shouldNotGroupWhenFull||this.listenTo(e,`ready`,()=>{let t=e.ui.view.editable.element;this._resizeObserver=new Hr(t,e=>{this.toolbarView.maxWidth=tw(e.contentRect.width*.9)})}),this.listenTo(this.toolbarView,`groupedItemsUpdate`,()=>{this._updatePosition()}),e.ui.once(`ready`,()=>{this.toolbarView.fillFromConfig(this._balloonConfig,this.editor.ui.componentFactory)})}get _isToolbarVisible(){return this._balloon.visibleView===this.toolbarView}_createToolbarView(){let e=this.editor.locale.t,t=!this._balloonConfig.shouldNotGroupWhenFull,n=new Ox(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return n.ariaLabel=e(`Editor contextual toolbar`),n.render(),n}show(e=!1){let t=this.editor,n=t.model.document.selection,r=t.model.schema;this._balloon.hasView(this.toolbarView)||n.isCollapsed&&!e||rw(n,r)||Array.from(this.toolbarView.items).every(e=>e.isEnabled!==void 0&&!e.isEnabled)||(this.listenTo(this.editor.ui,`update`,()=>{this._updatePosition()}),this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:`ck-toolbar-container`}))}hide(){this._balloon.hasView(this.toolbarView)&&(this.stopListening(this.editor.ui,`update`),this._balloon.remove(this.toolbarView))}_trackFocusableEditableElements(){let{editor:e,focusTracker:t}=this,{editing:n}=e;n.view.addObserver(class extends kc{observe(e){t.add(e)}stopObserving(e){t.remove(e)}})}_getBalloonPositionData(){let e=this.editor.editing.view,t=e.document,n=t.selection,r=t.selection.isBackward;return{target:()=>{let t=r?n.getFirstRange():n.getLastRange(),i=O.getDomRangeRects(e.domConverter.viewRangeToDom(t));return r?i[0]:(i.length>1&&i[i.length-1].width===0&&i.pop(),i[i.length-1])},positions:this._getBalloonPositions(r)}}_updatePosition(){this._isToolbarVisible&&this._balloon.updatePosition(this._getBalloonPositionData())}destroy(){super.destroy(),this.stopListening(),this._fireSelectionChangeDebounced.cancel(),this.toolbarView.destroy(),this.focusTracker.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getBalloonPositions(e){let t=p.isSafari&&p.isiOS?ab.generatePositions({heightOffset:Math.max(ab.arrowHeightOffset,Math.round(20/u.window.visualViewport.scale))}):ab.defaultPositions;return e?[t.northWestArrowSouth,t.northWestArrowSouthWest,t.northWestArrowSouthEast,t.northWestArrowSouthMiddleEast,t.northWestArrowSouthMiddleWest,t.southWestArrowNorth,t.southWestArrowNorthWest,t.southWestArrowNorthEast,t.southWestArrowNorthMiddleWest,t.southWestArrowNorthMiddleEast]:[t.southEastArrowNorth,t.southEastArrowNorthEast,t.southEastArrowNorthWest,t.southEastArrowNorthMiddleEast,t.southEastArrowNorthMiddleWest,t.northEastArrowSouth,t.northEastArrowSouthEast,t.northEastArrowSouthWest,t.northEastArrowSouthMiddleEast,t.northEastArrowSouthMiddleWest]}};function rw(e,t){return e.rangeCount===1?!1:[...e.getRanges()].every(e=>{let n=e.getContainedElement();return n&&t.isSelectable(n)})}const iw=Wr(`px`);var aw=class extends H{constructor(e){super(e);let t=this.bindTemplate;this.isVisible=!1,this.isToggleable=!0,this.set(`top`,0),this.set(`left`,0),this.extendTemplate({attributes:{class:`ck-block-toolbar-button`,style:{top:t.to(`top`,e=>iw(e)),left:t.to(`left`,e=>iw(e))}}})}};const ow=Wr(`px`);var sw=class extends F{toolbarView;panelView;buttonView;_resizeObserver=null;_blockToolbarConfig;static get pluginName(){return`BlockToolbar`}static get isOfficialPlugin(){return!0}constructor(e){super(e),this._blockToolbarConfig=Ex(this.editor.config.get(`blockToolbar`)),this.toolbarView=this._createToolbarView(),this.panelView=this._createPanelView(),this.buttonView=this._createButtonView(),Ya({emitter:this.panelView,contextElements:[this.panelView.element,this.buttonView.element],activator:()=>this.panelView.isVisible,callback:()=>this._hidePanel()})}init(){let e=this.editor,t=e.t,n=t(`Click to edit block`),r=t(`Drag to move`),i=t(`Edit block`),a=e.plugins.has(`DragDropBlockToolbar`),o=a?`${n}\n${r}`:i;this.buttonView.label=o,a&&(this.buttonView.element.dataset.ckeTooltipClass=`ck-tooltip_multi-line`),this.listenTo(e.model.document.selection,`change:range`,(e,t)=>{t.directChange&&this._hidePanel()}),this.listenTo(e.ui,`update`,()=>this._updateButton()),this.listenTo(e,`change:isReadOnly`,()=>this._updateButton(),{priority:`low`}),this.listenTo(e.ui.focusTracker,`change:isFocused`,()=>this._updateButton()),this.listenTo(this.buttonView,`change:isVisible`,(e,t,n)=>{n?this.buttonView.listenTo(window,`resize`,()=>this._updateButton()):(this.buttonView.stopListening(window,`resize`),this._hidePanel())}),this._repositionButtonOnScroll(),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this._showPanel(),afterBlur:()=>this._hidePanel()}),e.ui.once(`ready`,()=>{this.toolbarView.fillFromConfig(this._blockToolbarConfig,this.editor.ui.componentFactory);for(let e of this.toolbarView.items)e.on(`execute`,()=>this._hidePanel(!0),{priority:`high`})})}destroy(){super.destroy(),this.panelView.destroy(),this.buttonView.destroy(),this.toolbarView.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_createToolbarView(){let e=this.editor.locale.t,t=!this._blockToolbarConfig.shouldNotGroupWhenFull,n=new Ox(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return n.ariaLabel=e(`Editor block content toolbar`),n}_createPanelView(){let e=this.editor,t=new ab(e.locale);return t.content.add(this.toolbarView),t.class=`ck-toolbar-container`,e.ui.view.body.add(t),this.toolbarView.keystrokes.set(`Esc`,(e,t)=>{this._hidePanel(!0),t()}),t}_createButtonView(){let e=this.editor,t=e.t,n=new aw(e.locale),r=this._blockToolbarConfig.icon,i=Dx[r]||r||Dx.dragIndicator;return n.set({label:t(`Edit block`),icon:i,withText:!1}),n.bind(`isOn`).to(this.panelView,`isVisible`),n.bind(`tooltip`).to(this.panelView,`isVisible`,e=>!e),this.listenTo(n,`execute`,()=>{this.panelView.isVisible?this._hidePanel(!0):this._showPanel()}),this.listenTo(n,`change:isEnabled`,(e,t,n)=>{!n&&this.panelView.isVisible&&this._hidePanel(!1)}),e.ui.view.body.add(n),n}_updateButton(){let e=this.editor,t=e.model,n=e.editing.view;if(!e.ui.focusTracker.isFocused){this._hideButton();return}if(!e.model.canEditAt(e.model.document.selection)){this._hideButton();return}let r=Array.from(t.document.selection.getSelectedBlocks())[0];if(!r||Array.from(this.toolbarView.items).every(e=>!e.isEnabled)){this._hideButton();return}let i=n.domConverter.mapViewToDom(e.editing.mapper.toViewElement(r));this.buttonView.isVisible=!0,this._setupToolbarResize(),this._attachButtonToElement(i),this.panelView.isVisible&&this._showPanel()}_hideButton(){this.buttonView.isVisible=!1}_showPanel(){if(!this.buttonView.isVisible)return;let e=this.panelView.isVisible;this.panelView.show();let t=this._getSelectedEditableElement();this.toolbarView.maxWidth=this._getToolbarMaxWidth(t),this.panelView.pin({target:this.buttonView.element,limiter:t}),e||this.toolbarView.items.get(0).focus()}_getSelectedEditableElement(){let e=this.editor.model.document.selection.getFirstRange().root.rootName;return this.editor.ui.getEditableElement(e)}_hidePanel(e){this.panelView.isVisible=!1,e&&this.editor.editing.view.focus()}_repositionButtonOnScroll(){let{buttonView:e}=this,t=!1,n=(e,n)=>{if(t)return;let r=this._getSelectedEditableElement();n.target!==u.document&&!Tr(r).includes(n.target)||(t=!0,u.window.requestAnimationFrame(()=>{this._updateButton(),t=!1}))};e.on(`change:isVisible`,(t,r,i)=>{i?e.listenTo(u.document,`scroll`,n,{useCapture:!0,usePassive:!0}):e.stopListening(u.document,`scroll`,n)})}_attachButtonToElement(e){let t=this.buttonView.element,n=this._getSelectedEditableElement(),r=window.getComputedStyle(e),i=new O(n),a=parseInt(r.paddingTop,10),o=parseInt(r.lineHeight,10)||parseInt(r.fontSize,10)*1.2,s=new O(t),c=new O(e),l;l=this.editor.locale.uiLanguageDirection===`ltr`?i.left-s.width:i.right;let u=c.top+a+(o-s.height)/2;s.moveTo(l,u);let d=s.toAbsoluteRect();this.buttonView.top=d.top,this.buttonView.left=d.left,this._clipButtonToViewport(this.buttonView,n)}_clipButtonToViewport(e,t){let n=new O(e.element),r=new O(t).getVisible(),i=(...t)=>{e.element.style.clipPath=t.length?`polygon(${t.join(`,`)})`:``},a=t=>{e.isEnabled=!t,e.element.style.pointerEvents=t?`none`:``};if(r&&r.bottom=n.height),i(`0 0`,`100% 0`,`100% calc(100% - ${ow(e)})`,`0 calc(100% - ${ow(e)}`)}else if(r&&r.top>n.top){let e=Math.min(n.height,r.top-n.top);a(e>=n.height),i(`0 ${ow(e)}`,`100% ${ow(e)}`,`100% 100%`,`0 100%`)}else a(!1),i()}_setupToolbarResize(){let e=this._getSelectedEditableElement();this._blockToolbarConfig.shouldNotGroupWhenFull||(this._resizeObserver&&this._resizeObserver.element!==e&&(this._resizeObserver.destroy(),this._resizeObserver=null),this._resizeObserver||=new Hr(e,()=>{this.toolbarView.maxWidth=this._getToolbarMaxWidth(e)}))}_getToolbarMaxWidth(e){let t=new O(e),n=new O(this.buttonView.element),r=this.editor.locale.uiLanguageDirection===`rtl`?n.left-t.right+n.width:t.left-n.left;return ow(t.width+r)}},cw=class extends $y{arrowView;constructor(e){super(e);let 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(){let e=new Ly;return e.content=b_,e.extendTemplate({attributes:{class:`ck-menu-bar__menu__button__arrow`}}),e}},lw=class extends P{children;constructor(e){super(e);let 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_${e}`),t.if(`isVisible`,`ck-hidden`,e=>!e)],tabindex:`-1`},children:this.children,on:{selectstart:t.to(e=>{e.target.tagName.toLocaleLowerCase()!==`input`&&e.preventDefault()})}})}focus(e=1){this.children.length&&(e===1?this.children.first.focus():this.children.last.focus())}},uw=class e extends P{buttonView;panelView;focusTracker;keystrokes;constructor(e){super(e);let t=this.bindTemplate;this.buttonView=new cw(e),this.buttonView.delegate(`mouseenter`).to(this),this.buttonView.bind(`isOn`,`isEnabled`).to(this,`isOpen`,`isEnabled`),this.panelView=new lw(e),this.panelView.bind(`isVisible`).to(this,`isOpen`),this.keystrokes=new N,this.focusTracker=new M,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),aC.closeOnEscKey(this),this._closeOnDisabled(),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(aC.openOnButtonClick(this),aC.openOnArrowRightKey(this),aC.closeOnArrowLeftKey(this),aC.openAndFocusOnEnterKeyPress(this),aC.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),aC.openAndFocusPanelOnArrowDownKey(this),aC.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set(`arrowright`,(e,t)=>{this.fire(`arrowright`),t()}),this.keystrokes.set(`arrowleft`,(e,t)=>{this.fire(`arrowleft`),t()})}_closeOnDisabled(){this.on(`change:isEnabled`,(e,t,n)=>{n||(this.isOpen=!1)})}_repositionPanelOnOpen(){this.on(`change:isOpen`,(t,n,r)=>{if(!r)return;let i=e._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=i?i.name:this._defaultMenuPositionName})}focus(){this.buttonView.focus()}get _panelPositions(){let{southEast:e,southWest:t,northEast:n,northWest:r,westSouth:i,eastSouth:a,westNorth:o,eastNorth:s}=oC;return this.locale.uiLanguageDirection===`ltr`?this.parentMenuView?[a,s,i,o]:[e,t,n,r]:this.parentMenuView?[i,o,a,s]:[t,e,r,n]}get _defaultMenuPositionName(){return this.locale.uiLanguageDirection===`ltr`?this.parentMenuView?`es`:`se`:this.parentMenuView?`ws`:`sw`}static _getOptimalPosition=Xr},dw=class extends mx{constructor(e){super(e),this.role=`menu`,this.items.on(`change`,this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){let e=Array.from(this.items).some(e=>{let t=fw(e);return t&&t.isToggleable});this.items.forEach(t=>{let n=fw(t);n&&(n.hasCheckSpace=e)})}};function fw(e){return e instanceof dx?e.children.map(e=>pw(e)?e.buttonView:e).find(e=>e instanceof $y):null}function pw(e){return typeof e==`object`&&`buttonView`in e&&e.buttonView instanceof H}var mw=class extends vb{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 hw=[`mouseenter`,`arrowleft`,`arrowright`,`change:isOpen`];var gw=class extends P{children;menus=[];constructor(e){super(e);let t=e.t,n=this.bindTemplate;this.set({isOpen:!1,isFocusBorderEnabled:!1}),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-menu-bar`,n.if(`isFocusBorderEnabled`,`ck-menu-bar_focus-border-enabled`)],"aria-label":t(`Editor menu bar`),role:`menubar`},children:this.children})}fillFromConfig(e,t,n=[]){let r=this.locale,i=lC({normalizedConfig:e,locale:r,componentFactory:t,extraItems:n}).items.map(e=>this._createMenu({componentFactory:t,menuDefinition:e}));this.children.addMany(i)}render(){super.render(),iC.toggleMenusAndFocusItemsOnHover(this),iC.closeMenusWhenTheBarCloses(this),iC.closeMenuWhenAnotherOnTheSameLevelOpens(this),iC.focusCycleMenusOnArrows(this),iC.closeOnClickOutside(this),iC.enableFocusHighlightOnInteraction(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(let e of this.children)e.isOpen=!1;this.isOpen=!1}disable(){for(let e of this.children)e.isEnabled=!1}enable(){for(let e of this.children)e.isEnabled=!0}registerMenu(e,t=null){t?(e.delegate(...hw).to(t),e.parentMenuView=t):e.delegate(...hw).to(this,e=>`menu:`+e),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:n}){let r=this.locale,i=new uw(r);return this.registerMenu(i,n),i.buttonView.set({label:t.label}),i.once(`change:isOpen`,()=>{let n=new dw(r);n.ariaLabel=t.label,i.panelView.children.add(n),n.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:i,componentFactory:e}))}),i}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:n}){let r=this.locale,i=[];for(let a of e.groups){for(let e of a.items){let a=new rC(r,t);if(Xe(e))a.children.add(this._createMenu({componentFactory:n,menuDefinition:e,parentMenuView:t}));else{let r=this._createMenuItemContentFromFactory({componentName:e,componentFactory:n,parentMenuView:t});if(!r)continue;a.children.add(r)}i.push(a)}a!==e.groups[e.groups.length-1]&&i.push(new fx(r))}return i}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:n}){let r=n.create(e);return r instanceof uw||r instanceof U||r instanceof mw?(this._registerMenuTree(r,t),r.on(`execute`,()=>{this.close()}),r):(T(`menu-bar-component-unsupported`,{componentName:e,componentView:r}),null)}_registerMenuTree(e,t){if(!(e instanceof uw)){e.delegate(`mouseenter`).to(t);return}this.registerMenu(e,t);let n=e.panelView.children.filter(e=>e instanceof dw)[0];if(!n){e.delegate(`mouseenter`).to(t);return}let r=n.items.filter(e=>e instanceof dx);for(let t of r)this._registerMenuTree(t.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on(`menu:change:isOpen`,(t,n,r)=>{clearTimeout(e),r?this.isOpen=!0:e=setTimeout(()=>{this.isOpen=Array.from(this.children).some(e=>e.isOpen)},0)})}};const _w=D();var vw=class extends _w{total;_reader;_data;constructor(){super();let 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){let t=this._reader;return this.total=e.size,new Promise((n,r)=>{t.onload=()=>{let e=t.result;this._data=e,n(e)},t.onerror=()=>{r(`error`)},t.onabort=()=>{r(`aborted`)},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}};const yw=D();var bw=class extends F{loaders=new Fi;_loadersMap=new Map;_pendingAction=null;static get pluginName(){return`FileRepository`}static get isOfficialPlugin(){return!0}static get requires(){return[wg]}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 T(`filerepository-no-upload-adapter`),null;let t=new xw(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(let t of this.loaders)e+=t.uploaded;this.uploaded=e}),t.on(`change:uploadTotal`,()=>{let e=0;for(let t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e}),t}destroyLoader(e){let t=e instanceof xw?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((e,n)=>{e===t&&this._loadersMap.delete(n)})}_updatePendingAction(){let e=this.editor.plugins.get(wg);if(this.loaders.length){if(!this._pendingAction){let t=this.editor.t,n=e=>`${t(`Upload in progress`)} ${parseInt(e)}%.`;this._pendingAction=e.add(n(this.uploadedPercent)),this._pendingAction.bind(`message`).to(this,`uploadedPercent`,n)}}else e.remove(this._pendingAction),this._pendingAction=null}},xw=class extends yw{id;_filePromiseWrapper;_adapter;_reader;constructor(e,t){super(),this.id=he(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new vw,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(this.status!=`idle`)throw new w(`filerepository-read-wrong-status`,this);return this.status=`reading`,this.file.then(e=>this._reader.read(e)).then(e=>{if(this.status!==`reading`)throw this.status;return this.status=`idle`,e}).catch(e=>{throw e===`aborted`?(this.status=`aborted`,`aborted`):(this.status=`error`,this._reader.error?this._reader.error:e)})}upload(){if(this.status!=`idle`)throw new w(`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=>{throw this.status===`aborted`?`aborted`:(this.status=`error`,e)})}abort(){let e=this.status;this.status=`aborted`,this._filePromiseWrapper.isFulfilled?e==`reading`?this._reader.abort():e==`uploading`&&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){let t={};return t.promise=new Promise((n,r)=>{t.rejecter=r,t.isFulfilled=!1,e.then(e=>{t.isFulfilled=!0,n(e)}).catch(e=>{t.isFulfilled=!0,r(e)})}),t}},Sw=class extends F{static get requires(){return[bw]}static get pluginName(){return`Base64UploadAdapter`}static get licenseFeatureCode(){return`B64A`}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){this.editor.plugins.get(bw).createUploadAdapter=e=>new Cw(e)}},Cw=class{loader;reader;constructor(e){this.loader=e}upload(){return new Promise((e,t)=>{let n=this.reader=new window.FileReader;n.addEventListener(`load`,()=>{e({default:n.result})}),n.addEventListener(`error`,e=>{t(e)}),n.addEventListener(`abort`,()=>{t()}),this.loader.file.then(e=>{n.readAsDataURL(e)})})}abort(){this.reader.abort()}},ww=class extends F{static get requires(){return[bw]}static get pluginName(){return`SimpleUploadAdapter`}static get licenseFeatureCode(){return`SUA`}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){let e=this.editor.config.get(`simpleUpload`);if(e){if(!e.uploadUrl){T(`simple-upload-adapter-missing-uploadurl`);return}this.editor.plugins.get(bw).createUploadAdapter=t=>new Tw(t,e)}}},Tw=class{loader;options;xhr;constructor(e,t){this.loader=e,this.options=t}upload(){return this.loader.file.then(e=>new Promise((t,n)=>{this._initRequest(),this._initListeners(t,n,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){let e=this.xhr=new XMLHttpRequest;e.open(`POST`,this.options.uploadUrl,!0),e.responseType=`json`}_initListeners(e,t,n){let r=this.xhr,i=this.loader,a=`Couldn't upload file: ${n.name}.`;r.addEventListener(`error`,()=>t(a)),r.addEventListener(`abort`,()=>t()),r.addEventListener(`load`,()=>{let n=r.response;if(!n||n.error)return t(n&&n.error&&n.error.message?n.error.message:a);let i=n.url?{default:n.url}:n.urls;e({...n,urls:i})}),r.upload&&r.upload.addEventListener(`progress`,e=>{e.lengthComputable&&(i.uploadTotal=e.total,i.uploaded=e.loaded)})}_sendRequest(e){let t=this.options.headers||{};typeof t==`function`&&(t=t(e));let n=this.options.withCredentials||!1;for(let e of Object.keys(t))this.xhr.setRequestHeader(e,t[e]);this.xhr.withCredentials=n;let r=new FormData;r.append(`upload`,e),this.xhr.send(r)}};const Ew=`ckCsrfToken`;function Dw(){let e=Ow(Ew);return(!e||e.length!=40)&&(e=Aw(40),kw(Ew,e)),e}function Ow(e){e=e.toLowerCase();let t=document.cookie.split(`;`);for(let n of t){let t=n.split(`=`);if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}function kw(e,t){document.cookie=encodeURIComponent(e)+`=`+encodeURIComponent(t)+`;path=/`}function Aw(e){let t=``,n=new Uint8Array(e);window.crypto.getRandomValues(n);for(let e=0;e.5?r.toUpperCase():r}return t}var jw=class extends F{static get requires(){return[bw]}static get pluginName(){return`CKFinderUploadAdapter`}static get isOfficialPlugin(){return!0}init(){let e=this.editor.config.get(`ckfinder.uploadUrl`);e&&(this.editor.plugins.get(bw).createUploadAdapter=t=>new Mw(t,e,this.editor.t))}},Mw=class{loader;url;t;xhr;constructor(e,t,n){this.loader=e,this.url=t,this.t=n}upload(){return this.loader.file.then(e=>new Promise((t,n)=>{this._initRequest(),this._initListeners(t,n,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){let e=this.xhr=new XMLHttpRequest;e.open(`POST`,this.url,!0),e.responseType=`json`}_initListeners(e,t,n){let r=this.xhr,i=this.loader,a=this.t,o=a(`Cannot upload file:`)+` ${n.name}.`;r.addEventListener(`error`,()=>t(o)),r.addEventListener(`abort`,()=>t()),r.addEventListener(`load`,()=>{let n=r.response;if(!n||!n.uploaded)return t(n&&n.error&&n.error.message?n.error.message:o);e({default:n.url})}),r.upload&&r.upload.addEventListener(`progress`,e=>{e.lengthComputable&&(i.uploadTotal=e.total,i.uploaded=e.loaded)})}_sendRequest(e){let t=new FormData;t.append(`upload`,e),t.append(`ckCsrfToken`,Dw()),this.xhr.send(t)}};const Nw=[`left`,`right`,`center`,`justify`];function Pw(e){return Nw.includes(e)}function Fw(e,t){return t.contentLanguageDirection==`rtl`?e===`right`:e===`left`}function Iw(e){let t=e.map(e=>{let t;return t=typeof e==`string`?{name:e}:e,t}).filter(e=>{let t=Nw.includes(e.name);return t||T(`alignment-config-name-not-recognized`,{option:e}),t}),n=t.filter(e=>!!e.className).length;if(n&&n{let i=r.slice(n+1);if(i.some(e=>e.name==t.name))throw new w(`alignment-config-name-already-defined`,{option:t,configuredOptions:e});if(t.className&&i.some(e=>e.className==t.className))throw new w(`alignment-config-classname-already-defined`,{option:t,configuredOptions:e})}),t}const Lw=`alignment`;var Rw=class extends I{refresh(){let e=this.editor.locale,t=j(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!t&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute(`alignment`)?this.value=t.getAttribute(`alignment`):this.value=e.contentLanguageDirection===`rtl`?`right`:`left`}execute(e={}){let t=this.editor,n=t.locale,r=t.model,i=r.document,a=e.value;r.change(e=>{let t=Array.from(i.selection.getSelectedBlocks()).filter(e=>this._canBeAligned(e)),r=t[0].getAttribute(`alignment`);Fw(a,n)||r===a||!a?zw(t,e):Bw(t,e,a)})}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,Lw)}};function zw(e,t){for(let n of e)t.removeAttribute(Lw,n)}function Bw(e,t,n){for(let r of e)t.setAttribute(Lw,n,r)}var Vw=class extends F{static get pluginName(){return`AlignmentEditing`}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(`alignment`,{options:Nw.map(e=>({name:e}))})}init(){let e=this.editor,t=e.locale,n=e.model.schema,r=Iw(e.config.get(`alignment.options`)).filter(e=>Pw(e.name)&&!Fw(e.name,t)),i=r.some(e=>!!e.className);n.extend(`$block`,{allowAttributes:`alignment`}),e.model.schema.setAttributeProperties(`alignment`,{isFormatting:!0,blockAlignment:Hw(t)}),i?e.conversion.attributeToAttribute(Kw(r)):e.conversion.for(`downcast`).attributeToAttribute(Uw(r));let a=Ww(r);for(let t of a)e.conversion.for(`upcast`).attributeToAttribute(t);let o=Gw(r);for(let t of o)e.conversion.for(`upcast`).attributeToAttribute(t);e.commands.add(`alignment`,new Rw(e))}};function Hw(e){let t={left:{value:`left`},right:{value:`right`},center:{value:`center`},justify:{value:`justify`}},n=e.contentLanguageDirection==`rtl`?`right`:`left`;return t[n].isDefault=!0,t}function Uw(e){let t={};for(let{name:n}of e)t[n]={key:`style`,value:{"text-align":n}};return{model:{key:`alignment`,values:e.map(e=>e.name)},view:t}}function Ww(e){let t=[];for(let{name:n}of e)t.push({view:{key:`style`,value:{"text-align":n}},model:{key:`alignment`,value:n}});return t}function Gw(e){let t=[];for(let{name:n}of e)t.push({view:{key:`align`,value:n},model:{key:`alignment`,value:n}});return t}function Kw(e){let t={};for(let n of e)t[n.name]={key:`class`,value:n.className};return{model:{key:`alignment`,values:e.map(e=>e.name)},view:t}}const qw=new Map([[`left`,Gg],[`right`,qg],[`center`,Ug],[`justify`,Wg]]);var Jw=class extends F{get localizedOptionTitles(){let e=this.editor.t;return{left:e(`Align left`),right:e(`Align right`),center:e(`Align center`),justify:e(`Justify`)}}static get pluginName(){return`AlignmentUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=Iw(e.config.get(`alignment.options`));t.map(e=>e.name).filter(Pw).forEach(e=>this._addButton(e)),this._addToolbarDropdown(t),this._addMenuBarMenu(t)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,t=>this._createButton(t,e))}_createButton(e,t,n={}){let r=this.editor,i=r.commands.get(`alignment`),a=new H(e);return a.set({label:this.localizedOptionTitles[t],icon:qw.get(t),tooltip:!0,isToggleable:!0,...n}),a.bind(`isEnabled`).to(i),a.bind(`isOn`).to(i,`value`,e=>e===t),this.listenTo(a,`execute`,()=>{r.execute(`alignment`,{value:t}),r.editing.view.focus()}),a}_addToolbarDropdown(e){let t=this.editor;t.ui.componentFactory.add(`alignment`,n=>{let r=Nx(n),i=n.uiLanguageDirection===`rtl`?`w`:`e`,a=n.t;Fx(r,()=>e.map(e=>this._createButton(n,e.name,{tooltipPosition:i})),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:a(`Text alignment toolbar`)}),r.buttonView.set({label:a(`Text alignment`),tooltip:!0}),r.extendTemplate({attributes:{class:`ck-alignment-dropdown`}});let o=n.contentLanguageDirection===`rtl`?qw.get(`right`):qw.get(`left`),s=t.commands.get(`alignment`);return r.buttonView.bind(`icon`).to(s,`value`,e=>qw.get(e)||o),r.bind(`isEnabled`).to(s,`isEnabled`),this.listenTo(r,`execute`,()=>{t.editing.view.focus()}),r})}_addMenuBarMenu(e){let t=this.editor;t.ui.componentFactory.add(`menuBar:alignment`,n=>{let r=t.commands.get(`alignment`),i=n.t,a=new uw(n),o=new dw(n);a.bind(`isEnabled`).to(r),o.set({ariaLabel:i(`Text alignment`),role:`menu`}),a.buttonView.set({label:i(`Text alignment`)});for(let i of e){let e=new rC(n,a),s=new U(n);s.delegate(`execute`).to(a),s.set({label:this.localizedOptionTitles[i.name],icon:qw.get(i.name),role:`menuitemcheckbox`,isToggleable:!0}),s.on(`execute`,()=>{t.execute(`alignment`,{value:i.name}),t.editing.view.focus()}),s.bind(`isOn`).to(r,`value`,e=>e===i.name),s.bind(`isEnabled`).to(r,`isEnabled`),e.children.add(s),o.items.add(e)}return a.panelView.children.add(o),a})}},Yw=class extends F{static get requires(){return[Vw,Jw]}static get pluginName(){return`Alignment`}static get isOfficialPlugin(){return!0}},Xw=class{model;limit;_isLocked;_size;_batch=null;_changeCallback;_selectionChangeCallback;constructor(e,t=20){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.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(`change:range`,this._selectionChangeCallback),this.model.document.selection.off(`change:attribute`,this._selectionChangeCallback)}_reset(e=!1){(!this.isLocked||e)&&(this._batch=null,this._size=0)}},Zw=class extends I{_buffer;constructor(e,t){super(e),this._buffer=new Xw(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){let t=this.editor.model,n=t.document,r=e.text||``,i=r.length,a=n.selection;if(e.selection?a=e.selection:e.range&&(a=t.createSelection(e.range)),!t.canEditAt(a))return;let o=e.resultRange;t.enqueueChange(this._buffer.batch,e=>{this._buffer.lock();let s=Array.from(n.selection.getAttributes());t.deleteContent(a),r&&t.insertContent(e.createText(r,s),a),o?e.setSelection(o):a.is(`documentSelection`)||e.setSelection(a),this._buffer.unlock(),this._buffer.input(i)})}};const Qw=[`insertText`,`insertReplacementText`],$w=[...Qw,`insertCompositionText`];var eT=class extends kc{focusObserver;constructor(e){super(e),this.focusObserver=e.getObserver(Ic);let t=p.isAndroid?$w:Qw,n=e.document;n.on(`beforeinput`,(r,i)=>{if(!this.isEnabled)return;let{data:a,targetRanges:o,inputType:s,domEvent:c,isComposing:l}=i;if(!t.includes(s))return;this.focusObserver.flush();let u=new pe(n,`insertText`);n.fire(u,new Ac(e,c,{text:a,selection:e.createSelection(o),isComposing:l})),u.stop.called&&r.stop()}),p.isAndroid||n.on(`compositionend`,(t,{data:r,domEvent:i})=>{this.isEnabled&&r&&n.fire(`insertText`,new Ac(e,i,{text:r,isComposing:!0}))},{priority:`low`})}observe(){}stopObserving(){}},tT=class extends F{_typingQueue;static get pluginName(){return`Input`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.model,n=e.editing.view,r=e.editing.mapper,i=t.document.selection;this._typingQueue=new nT(e),n.addObserver(eT);let a=new Zw(e,e.config.get(`typing.undoStep`)||20);e.commands.add(`insertText`,a),e.commands.add(`input`,a),this.listenTo(n.document,`beforeinput`,()=>{this._typingQueue.flush(`next beforeinput`)},{priority:`high`}),this.listenTo(n.document,`insertText`,(e,o)=>{let{text:s,selection:c}=o;if(n.document.selection.isFake&&c&&n.document.selection.isSimilar(c)&&o.preventDefault(),c&&Array.from(c.getRanges()).some(e=>!e.isCollapsed)&&o.preventDefault(),!a.isEnabled){o.preventDefault();return}let l;c&&(l=Array.from(c.getRanges()).filter(e=>e.root.is(`rootElement`)).map(e=>r.toModelRange(e)).map(e=>Uf(e,t.schema)||e)),(!l||!l.length)&&(l=Array.from(i.getRanges()));let u=s;if(p.isAndroid){let e=Array.from(l[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),l[0].start=l[0].start.getShiftedBy(e.length)):e.startsWith(u)&&(l[0].start=l[0].start.getShiftedBy(u.length),u=``)),u.length==0&&l[0].isCollapsed)return}let d={text:u,selection:t.createSelection(l)};this._typingQueue.push(d,!!o.isComposing),o.domEvent.defaultPrevented&&this._typingQueue.flush(`beforeinput default prevented`)}),p.isAndroid?this.listenTo(n.document,`keydown`,(e,r)=>{i.isCollapsed||r.keyCode!=229||!n.document.isComposing||rT(t,a)}):this.listenTo(n.document,`compositionstart`,()=>{i.isCollapsed||rT(t,a)},{priority:`high`}),this.listenTo(n.document,`mutations`,(e,{mutations:t})=>{if(this._typingQueue.hasAffectedElements())for(let{node:e}of t){let t=aT(e,r),n=r.toModelElement(t);if(this._typingQueue.isElementAffected(n)){this._typingQueue.flush(`mutations`);return}}}),this.listenTo(n.document,`compositionend`,()=>{this._typingQueue.flush(`before composition end`)},{priority:`high`}),this.listenTo(n.document,`compositionend`,()=>{this._typingQueue.flush(`after composition end`);let e=[];if(this._typingQueue.hasAffectedElements())for(let t of this._typingQueue.flushAffectedElements()){let n=r.toViewElement(t);n&&e.push({type:`children`,node:n})}(e.length||!p.isAndroid)&&n.document.fire(`mutations`,{mutations:e})},{priority:`lowest`})}destroy(){super.destroy(),this._typingQueue.destroy()}},nT=class{editor;flushDebounced=Kt(()=>this.flush(`timeout`),50);_queue=[];_isComposing=!1;_affectedElements=new Set;constructor(e){this.editor=e}destroy(){for(this.flushDebounced.cancel(),this._affectedElements.clear();this._queue.length;)this.shift()}get length(){return this._queue.length}push(e,t){let n={text:e.text};if(e.selection){n.selectionRanges=[];for(let t of e.selection.getRanges())n.selectionRanges.push(xl.fromRange(t)),this._affectedElements.add(t.start.parent)}this._queue.push(n),this._isComposing||=t,this.flushDebounced()}shift(){let e=this._queue.shift(),t={text:e.text};if(e.selectionRanges){let n=e.selectionRanges.map(e=>iT(e)).filter(e=>!!e);n.length&&(t.selection=this.editor.model.createSelection(n))}return t}flush(e){let t=this.editor,n=t.model,r=t.editing.view;if(this.flushDebounced.cancel(),!this._queue.length)return;let i=t.commands.get(`insertText`).buffer;n.enqueueChange(i.batch,()=>{for(i.lock();this._queue.length;){let e=this.shift();t.execute(`insertText`,e)}i.unlock(),this._isComposing||this._affectedElements.clear(),this._isComposing=!1}),r.scrollToTheSelection()}isElementAffected(e){return this._affectedElements.has(e)}hasAffectedElements(){return this._affectedElements.size>0}flushAffectedElements(){let e=Array.from(this._affectedElements);return this._affectedElements.clear(),e}};function rT(e,t){if(!t.isEnabled)return;let n=t.buffer;n.lock(),e.enqueueChange(n.batch,()=>{e.deleteContent(e.document.selection)}),n.unlock()}function iT(e){let t=e.toRange();return e.detach(),t.root.rootName==`$graveyard`?null:t}function aT(e,t){let n=e.is(`$text`)?e.parent:e;for(;!t.toModelElement(n);)n=n.parent;return n}var oT=class extends I{direction;_buffer;constructor(e,t){super(e),this.direction=t,this._buffer=new Xw(e.model,e.config.get(`typing.undoStep`)),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){let t=this.editor.model,n=t.document;t.enqueueChange(this._buffer.batch,r=>{this._buffer.lock();let i=r.createSelection(e.selection||n.selection);if(!t.canEditAt(i))return;let a=e.sequence||1,o=i.isCollapsed;if(i.isCollapsed&&t.modifySelection(i,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(a)){this._replaceEntireContentWithParagraph(r);return}if(this._shouldReplaceFirstBlockWithParagraph(i,a)){this.editor.execute(`paragraph`,{selection:i});return}if(i.isCollapsed)return;let s=0;i.getFirstRange().getMinimalFlatRanges().forEach(e=>{s+=dr(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),t.deleteContent(i,{doNotResetEntireContent:o,direction:this.direction}),this._buffer.input(s),r.setSelection(i),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;let t=this.editor.model,n=t.document.selection,r=t.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(r))||!t.schema.checkChild(r,`paragraph`))return!1;let i=r.getChild(0);return!(i&&i.is(`element`,`paragraph`))}_replaceEntireContentWithParagraph(e){let t=this.editor.model,n=t.document.selection,r=t.schema.getLimitElement(n),i=e.createElement(`paragraph`);e.remove(e.createRangeIn(r)),e.insert(i,r),e.setSelection(i,0)}_shouldReplaceFirstBlockWithParagraph(e,t){let n=this.editor.model;if(t>1||this.direction!=`backward`||!e.isCollapsed)return!1;let r=e.getFirstPosition(),i=n.schema.getLimitElement(r),a=i.getChild(0);return!(r.parent!=a||!e.containsEntireContent(a)||!n.schema.checkChild(i,`paragraph`)||a.name==`paragraph`)}};const sT=`word`,cT=`selection`,lT=`backward`,uT=`forward`,dT={deleteContent:{unit:cT,direction:lT},deleteContentBackward:{unit:`codePoint`,direction:lT},deleteWordBackward:{unit:sT,direction:lT},deleteHardLineBackward:{unit:cT,direction:lT},deleteSoftLineBackward:{unit:cT,direction:lT},deleteContentForward:{unit:`character`,direction:uT},deleteWordForward:{unit:sT,direction:uT},deleteHardLineForward:{unit:cT,direction:uT},deleteSoftLineForward:{unit:cT,direction:uT}};var fT=class extends kc{constructor(e){super(e);let t=e.document,n=0;t.on(`keydown`,()=>{n++}),t.on(`keyup`,()=>{n=0}),t.on(`beforeinput`,(r,i)=>{if(!this.isEnabled)return;let{targetRanges:a,domEvent:o,inputType:s}=i,c=dT[s];if(!c)return;let l={direction:c.direction,unit:c.unit,sequence:n};l.unit==cT&&(l.selectionToRemove=e.createSelection(a[0])),s===`deleteContentBackward`&&(p.isAndroid&&(l.sequence=1),mT(a)&&(l.unit=cT,l.selectionToRemove=e.createSelection(a)));let u=new ls(t,`delete`,a[0]);t.fire(u,new Ac(e,o,l)),u.stop.called&&r.stop()}),p.isBlink&&pT(this)}observe(){}stopObserving(){}};function pT(e){let t=e.view,n=t.document,r=null,i=!1;n.on(`keydown`,(e,{keyCode:t})=>{r=t,i=!1}),n.on(`keyup`,(s,{keyCode:c,domEvent:l})=>{let u=n.selection,d=e.isEnabled&&c==r&&a(c)&&!u.isCollapsed&&!i;if(r=null,d){let e=new ls(n,`delete`,u.getFirstRange()),r={unit:cT,direction:o(c),selectionToRemove:u};n.fire(e,new Ac(t,l,r))}}),n.on(`beforeinput`,(e,{inputType:t})=>{let n=dT[t];a(r)&&n&&n.direction==o(r)&&(i=!0)},{priority:`high`}),n.on(`beforeinput`,(e,{inputType:t,data:n})=>{r==k.delete&&t==`insertText`&&n==``&&e.stop()},{priority:`high`});function a(e){return e==k.backspace||e==k.delete}function o(e){return e==k.backspace?lT:uT}}function mT(e){if(e.length!=1||e[0].isCollapsed)return!1;let t=e[0].getWalker({direction:`backward`,singleCharacters:!0,ignoreElementEnd:!0}),n=0;for(let{nextPosition:e,item:r}of t){if(e.parent.is(`$text`)){let t=e.parent.data,r=e.offset;if(ra(t,r)||ia(t,r)||oa(t,r))continue;n++}else(r.is(`containerElement`)||r.is(`emptyElement`))&&n++;if(n>1)return!0}return!1}var hT=class extends F{_undoOnBackspace;static get pluginName(){return`Delete`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.editing.view,n=t.document,r=e.model.document;t.addObserver(fT),this._undoOnBackspace=!1;let i=new oT(e,`forward`);e.commands.add(`deleteForward`,i),e.commands.add(`forwardDelete`,i),e.commands.add(`delete`,new oT(e,`backward`)),this.listenTo(n,`delete`,(r,i)=>{n.isComposing||i.preventDefault();let{direction:a,sequence:o,selectionToRemove:s,unit:c}=i,l=a===`forward`?`deleteForward`:`delete`,u={sequence:o};if(c==`selection`){let t=Array.from(s.getRanges()).map(t=>e.editing.mapper.toModelRange(t)).map(t=>Uf(t,e.model.schema)||t);u.selection=e.model.createSelection(t)}else u.unit=c;e.execute(l,u),t.scrollToTheSelection()},{priority:`low`}),this.listenTo(n,`keydown`,(i,a)=>{if(n.isComposing||a.keyCode!=k.backspace||!r.selection.isCollapsed)return;let o=e.model.schema.getLimitElement(r.selection),s=e.model.createPositionAt(o,0);if(s.isTouching(r.selection.getFirstPosition())){a.preventDefault();let r=e.model.schema.getNearestSelectionRange(s,`forward`);if(!r)return;let i=t.createSelection(e.editing.mapper.toViewRange(r)),o=i.getFirstRange(),c=new ls(document,`delete`,o),l={unit:`selection`,direction:`backward`,selectionToRemove:i};n.fire(c,new Ac(t,a.domEvent,l))}}),this.editor.plugins.has(`UndoEditing`)&&(this.listenTo(n,`delete`,(t,n)=>{this._undoOnBackspace&&n.direction==`backward`&&n.sequence==1&&n.unit==`codePoint`&&(this._undoOnBackspace=!1,e.execute(`undo`),n.preventDefault(),t.stop())},{context:`$capture`}),this.listenTo(r,`change`,()=>{this._undoOnBackspace=!1}))}requestUndoOnBackspace(){this.editor.plugins.has(`UndoEditing`)&&(this._undoOnBackspace=!0)}},gT=class extends F{static get requires(){return[tT,hT]}static get pluginName(){return`Typing`}static get isOfficialPlugin(){return!0}};function _T(e,t){let n=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce((e,{item:r})=>r.is(`$text`)||r.is(`$textProxy`)?e+r.data:(n=t.createPositionAfter(r),``),``),range:t.createRange(n,e.end)}}const vT=D();var yT=class extends vT{model;testCallback;_hasMatch;constructor(e,t){super(),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(){let e=this.model.document;this.listenTo(e.selection,`change:range`,(t,{directChange:n})=>{if(n){if(!e.selection.isCollapsed){this.hasMatch&&(this.fire(`unmatched`),this._hasMatch=!1);return}this._evaluateTextBeforeSelection(`selection`)}}),this.listenTo(e,`change:data`,(e,t)=>{t.isUndo||!t.isLocal||this._evaluateTextBeforeSelection(`data`,{batch:t})})}_evaluateTextBeforeSelection(e,t={}){let n=this.model,r=n.document.selection,{text:i,range:a}=_T(n.createRange(n.createPositionAt(r.focus.parent,0),r.focus),n),o=this.testCallback(i);if(!o&&this.hasMatch&&this.fire(`unmatched`),this._hasMatch=!!o,o){let n=Object.assign(t,{text:i,range:a});typeof o==`object`&&Object.assign(n,o),this.fire(`matched:${e}`,n)}}},bT=class extends F{attributes;_overrideUid;_isNextGravityRestorationSkipped=!1;static get pluginName(){return`TwoStepCaretMovement`}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){let e=this.editor,t=e.model,n=e.editing.view,r=e.locale,i=t.document.selection;this.listenTo(n.document,`arrowKey`,(e,t)=>{if(!i.isCollapsed||t.shiftKey||t.altKey||t.ctrlKey)return;let n=t.keyCode==k.arrowright,a=t.keyCode==k.arrowleft;if(!n&&!a)return;let o=r.contentLanguageDirection,s=!1;s=o===`ltr`&&n||o===`rtl`&&a?this._handleForwardMovement(t):this._handleBackwardMovement(t),s===!0&&e.stop()},{context:`$text`,priority:`highest`}),this.listenTo(i,`change:range`,(e,t)=>{if(this._isNextGravityRestorationSkipped){this._isNextGravityRestorationSkipped=!1;return}this._isGravityOverridden&&(!t.directChange&&ET(i.getFirstPosition(),this.attributes)||this._restoreGravity())}),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){let t=this.attributes,n=this.editor.model,r=n.document.selection,i=r.getFirstPosition();return this._isGravityOverridden||i.isAtStart&&xT(r,t)?!1:ET(i,t)?(e&&wT(e),xT(r,t)&&ET(i,t,!0)?CT(n,t):this._overrideGravity(),!0):!1}_handleBackwardMovement(e){let t=this.attributes,n=this.editor.model,r=n.document.selection,i=r.getFirstPosition();return this._isGravityOverridden?(e&&wT(e),this._restoreGravity(),ET(i,t,!0)?CT(n,t):ST(n,t,i),!0):i.isAtStart?xT(r,t)?(e&&wT(e),ST(n,t,i),!0):!1:!xT(r,t)&&ET(i,t,!0)?(e&&wT(e),ST(n,t,i),!0):TT(i,t)?i.isAtEnd&&!xT(r,t)&&ET(i,t)?(e&&wT(e),ST(n,t,i),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):!1}_enableClickingAfterNode(){let e=this.editor,t=e.model,n=t.document.selection,r=e.editing.view.document;e.editing.view.addObserver(Ap),e.editing.view.addObserver(jp);let i=!1,a=!1;this.listenTo(r,`touchstart`,()=>{a=!1,i=!0}),this.listenTo(r,`mousedown`,()=>{a=!0}),this.listenTo(r,`selectionChange`,()=>{let e=this.attributes;if(!a&&!i||(a=!1,i=!1,!n.isCollapsed)||!xT(n,e))return;let r=n.getFirstPosition();ET(r,e)&&(r.isAtStart||ET(r,e,!0)?CT(t,e):this._isGravityOverridden||this._overrideGravity())})}_enableInsertContentSelectionAttributesFixer(){let e=this.editor.model,t=e.document.selection,n=this.attributes;this.listenTo(e,`insertContent`,()=>{let r=t.getFirstPosition();xT(t,n)&&ET(r,n)&&CT(e,n)},{priority:`low`})}_handleDeleteContentAfterNode(){let e=this.editor,t=e.model,n=t.document.selection,r=e.editing.view,i=!1,a=!1;this.listenTo(r.document,`delete`,(e,t)=>{i=t.direction===`backward`},{priority:`high`}),this.listenTo(t,`deleteContent`,()=>{if(!i)return;let e=n.getFirstPosition();a=xT(n,this.attributes)&&!TT(e,this.attributes)},{priority:`high`}),this.listenTo(t,`deleteContent`,()=>{i&&(i=!1,!a&&e.model.enqueueChange(()=>{let e=n.getFirstPosition();xT(n,this.attributes)&&ET(e,this.attributes)&&(e.isAtStart||ET(e,this.attributes,!0)?CT(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 xT(e,t){for(let n of t)if(e.hasAttribute(n))return!0;return!1}function ST(e,t,n){let r=n.nodeBefore;e.change(n=>{if(r){let t=[],i=e.schema.isObject(r)&&e.schema.isInline(r);for(let[n,a]of r.getAttributes())e.schema.checkAttribute(`$text`,n)&&(!i||e.schema.getAttributeProperties(n).copyFromObject!==!1)&&t.push([n,a]);n.setSelectionAttribute(t)}else n.removeSelectionAttribute(t)})}function CT(e,t){e.change(e=>{e.removeSelectionAttribute(t)})}function wT(e){e.preventDefault()}function TT(e,t){return ET(e.getShiftedBy(-1),t)}function ET(e,t,n=!1){let{nodeBefore:r,nodeAfter:i}=e;for(let e of t){let t=r?r.getAttribute(e):void 0,a=i?i.getAttribute(e):void 0;if(!(n&&(t===void 0||a===void 0))&&a!==t)return!0}return!1}const DT={copyright:{from:`(c)`,to:`©`},registeredTrademark:{from:`(r)`,to:`®`},trademark:{from:`(tm)`,to:`™`},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,`½`,null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,`⅓`,null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,`⅔`,null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,`¼`,null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,`¾`,null]},lessThanOrEqual:{from:`<=`,to:`≤`},greaterThanOrEqual:{from:`>=`,to:`≥`},notEqual:{from:`!=`,to:`≠`},arrowLeft:{from:`<-`,to:`←`},arrowRight:{from:`->`,to:`→`},horizontalEllipsis:{from:`...`,to:`…`},enDash:{from:/(^| )(--)( )$/,to:[null,`–`,null]},emDash:{from:/(^| )(---)( )$/,to:[null,`—`,null]},quotesPrimary:{from:PT(`"`),to:[null,`“`,null,`”`]},quotesSecondary:{from:PT(`'`),to:[null,`‘`,null,`’`]},quotesPrimaryEnGb:{from:PT(`'`),to:[null,`‘`,null,`’`]},quotesSecondaryEnGb:{from:PT(`"`),to:[null,`“`,null,`”`]},quotesPrimaryPl:{from:PT(`"`),to:[null,`„`,null,`”`]},quotesSecondaryPl:{from:PT(`'`),to:[null,`‚`,null,`’`]}},OT={symbols:[`copyright`,`registeredTrademark`,`trademark`],mathematical:[`oneHalf`,`oneThird`,`twoThirds`,`oneForth`,`threeQuarters`,`lessThanOrEqual`,`greaterThanOrEqual`,`notEqual`,`arrowLeft`,`arrowRight`],typography:[`horizontalEllipsis`,`enDash`,`emDash`],quotes:[`quotesPrimary`,`quotesSecondary`]},kT=[`symbols`,`mathematical`,`typography`,`quotes`];var AT=class extends F{static get requires(){return[hT,tT]}static get pluginName(){return`TextTransformation`}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(`typing`,{transformations:{include:kT}})}init(){let e=this.editor.model.document.selection;e.on(`change:range`,()=>{let t=e.anchor,n=!!t&&t.parent.is(`element`,`codeBlock`),r=e.hasAttribute(`code`);this.isEnabled=!(n||r)}),this._enableTransformationWatchers()}_enableTransformationWatchers(){let e=this.editor,t=e.model,n=e.plugins.get(`Delete`),r=FT(e.config.get(`typing.transformations`)),i=new yT(e.model,e=>{for(let t of r)if(t.from.test(e))return{normalizedTransformation:t}});i.on(`matched:data`,(e,r)=>{if(!r.batch.isTyping)return;let{from:i,to:a}=r.normalizedTransformation,o=i.exec(r.text),s=a(o.slice(1)),c=r.range,l=o.index;t.enqueueChange(e=>{for(let n=1;n{n.requestUndoOnBackspace()})})}),i.bind(`isEnabled`).to(this)}};function jT(e){return typeof e==`string`?RegExp(`(${Bn(e)})$`):e}function MT(e){return typeof e==`string`?()=>[e]:e instanceof Array?()=>e:e}function NT(e){return(e.textNode?e.textNode:e.nodeAfter).getAttributes()}function PT(e){return RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function FT(e){let t=e.extra||[],n=e.remove||[],r=e=>!n.includes(e);return IT(e.include.concat(t).filter(r)).filter(r).map(e=>typeof e==`string`&&DT[e]?DT[e]:e).filter(e=>typeof e==`object`).map(e=>({from:jT(e.from),to:MT(e.to)}))}function IT(e){let t=new Set;for(let n of e)if(typeof n==`string`&&OT[n])for(let e of OT[n])t.add(e);else t.add(n);return Array.from(t)}function LT(e,t,n,r){return r.createRange(RT(e,t,n,!0,r),RT(e,t,n,!1,r))}function RT(e,t,n,r,i){let a=e.textNode||(r?e.nodeBefore:e.nodeAfter),o=null;for(;a&&a.getAttribute(t)==n;)o=a,a=r?a.previousSibling:a.nextSibling;return o?i.createPositionAt(o,r?`before`:`after`):e}function zT(e,t,n,r){let i=e.editing.view,a=new Set;i.document.registerPostFixer(i=>{let o=e.model.document.selection,s=!1;if(o.hasAttribute(t)){let c=LT(o.getFirstPosition(),t,o.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(let e of l.getItems())e.is(`element`,n)&&!e.hasClass(r)&&(i.addClass(r,e),a.add(e),s=!0)}return s}),e.conversion.for(`editingDowncast`).add(e=>{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 t(){i.change(e=>{for(let t of a.values())e.removeClass(r,t),a.delete(t)})}})}function BT(e,t,n,r){let i,a=null;typeof r==`function`?i=r:(a=e.commands.get(r),i=()=>{e.execute(r)}),e.model.document.on(`change:data`,(o,s)=>{if(a&&!a.isEnabled||!t.isEnabled)return;let c=j(e.model.document.selection.getRanges());if(!c.isCollapsed||s.isUndo||!s.isLocal)return;let l=Array.from(e.model.document.differ.getChanges()),u=l[0];if(l.length!=1||u.type!==`insert`||u.name!=`$text`||u.length!=1)return;let d=u.position.parent;if(d.is(`element`,`codeBlock`)||d.is(`element`,`listItem`)&&typeof r!=`function`&&![`numberedList`,`bulletedList`,`todoList`].includes(r)||a&&a.value===!0)return;let f=d.getChild(0),p=e.model.createRangeOn(f);if(!p.containsRange(c)&&!c.end.isEqual(p.end))return;let m=n.exec(f.data.substr(0,c.end.offset));m&&e.model.enqueueChange(t=>{let n=e.model.document.selection,r=new xl(t.createPositionAt(d,0),t.createPositionAt(d,m[0].length));if(i({match:m})!==!1){let e=Array.from(n.getAttributes());t.remove(r);let i=n.getFirstRange(),a=t.createRangeIn(d);d.isEmpty&&!a.isEqual(i)&&!a.containsRange(i,!0)&&t.remove(d),VT(t,n,e)}r.detach(),e.model.enqueueChange(()=>{e.plugins.get(`Delete`).requestUndoOnBackspace()})})})}function VT(e,t,n){let r=e.model.schema,i=new td(t.getFirstPosition());r.checkChild(i,`$text`)&&(i=i.push(`$text`));for(let[t,a]of n)r.checkAttribute(i,t)&&e.setSelectionAttribute(t,a)}function HT(e,t,n,r){let i,a;n instanceof RegExp?i=n:a=n,a||=(e=>{let t,n=[],r=[];for(;(t=i.exec(e))!==null&&!(t&&t.length<4);){let{index:e,1:i,2:a,3:o}=t,s=i+a+o;e+=t[0].length-s.length;let c=[e,e+i.length],l=[e+i.length+a.length,e+i.length+a.length+o.length];n.push(c),n.push(l),r.push([e+i.length,e+i.length+a.length])}return{remove:n,format:r}}),e.model.document.on(`change:data`,(n,i)=>{if(i.isUndo||!i.isLocal||!t.isEnabled)return;let o=e.model,s=o.document.selection;if(!s.isCollapsed)return;let c=Array.from(o.document.differ.getChanges()),l=c[0];if(c.length!=1||l.type!==`insert`||l.name!=`$text`||l.length!=1)return;let u=s.focus,d=u.parent,{text:f,range:p}=Rte(o.createRange(o.createPositionAt(d,0),u),o),m=a(f),h=UT(p.start,m.format,o),g=UT(p.start,m.remove,o);h.length&&g.length&&o.enqueueChange(t=>{if(r(t,h)!==!1){for(let e of g.reverse())t.remove(e);o.enqueueChange(()=>{e.plugins.get(`Delete`).requestUndoOnBackspace()})}})})}function UT(e,t,n){return t.filter(e=>e[0]!==void 0&&e[1]!==void 0).map(t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1])))}function Rte(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce((e,r)=>!(r.is(`$text`)||r.is(`$textProxy`))||r.getAttribute(`code`)?(n=t.createPositionAfter(r),``):e+r.data,``),range:t.createRange(n,e.end)}}var zte=class extends F{static get requires(){return[hT]}static get pluginName(){return`Autoformat`}static get isOfficialPlugin(){return!0}afterInit(){let 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(){let e=this.editor.commands;if(e.get(`bulletedList`)&&BT(this.editor,this,/^[*-]\s$/,`bulletedList`),e.get(`numberedList`)){let t=e.get(`numberedList`),n=!!e.get(`listStart`);BT(this.editor,this,/^(\d+)[.|)]\s$/,({match:e})=>{if(!t.isEnabled||t.value===!0)return!1;this.editor.execute(`numberedList`,n?{additionalAttributes:{listStart:parseInt(e[1])}}:void 0)})}e.get(`todoList`)&&BT(this.editor,this,/^\[\s?\]\s$/,`todoList`),e.get(`checkTodoList`)&&BT(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute(`todoList`),this.editor.execute(`checkTodoList`)})}_addBasicStylesAutoformats(){let e=this.editor.commands;if(e.get(`bold`)){let e=WT(this.editor,`bold`);HT(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),HT(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get(`italic`)){let e=WT(this.editor,`italic`);HT(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),HT(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get(`code`)){let e=WT(this.editor,`code`);HT(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get(`strikethrough`)){let e=WT(this.editor,`strikethrough`);HT(this.editor,this,/(~~)([^~]+)(~~)$/g,e)}}_addHeadingAutoformats(){let e=this.editor.commands.get(`heading`);e&&e.modelElements.filter(e=>e.match(/^heading[1-6]$/)).forEach(t=>{let n=t[7],r=RegExp(`^(#{${n}})\\s$`);BT(this.editor,this,r,()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute(`heading`,{value:t})})})}_addBlockQuoteAutoformats(){this.editor.commands.get(`blockQuote`)&&BT(this.editor,this,/^>\s$/,`blockQuote`)}_addCodeBlockAutoformats(){let e=this.editor,t=e.model.document.selection;e.commands.get(`codeBlock`)&&BT(e,this,/^```$/,()=>{if(t.getFirstPosition().parent.is(`element`,`listItem`))return!1;this.editor.execute(`codeBlock`,{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get(`horizontalLine`)&&BT(this.editor,this,/^---$/,`horizontalLine`)}};function WT(e,t){return(n,r)=>{if(!e.commands.get(t).isEnabled)return!1;let i=e.model.schema.getValidRanges(r,t);for(let e of i)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}var Bte=class extends F{adapter;_debouncedSave;_lastDocumentVersion;_savePromise;_domEmitter;_config;_pendingActions;_makeImmediateSave;_action=null;static get pluginName(){return`Autosave`}static get isOfficialPlugin(){return!0}static get requires(){return[wg]}constructor(e){super(e);let t=e.config.get(`autosave`)||{},n=t.waitingTime||1e3;this.set(`state`,`synchronized`),this._debouncedSave=Kt(this._save.bind(this),n),this._lastDocumentVersion=e.model.document.version,this._savePromise=null,this._domEmitter=new(br()),this._config=t,this._pendingActions=e.plugins.get(wg),this._makeImmediateSave=!1}init(){let e=this.editor,t=e.model.document;this.listenTo(e,`ready`,()=>{this.listenTo(t,`change:data`,(e,t)=>{this._saveCallbacks.length&&t.isLocal&&(this.state===`synchronized`&&(this.state=`waiting`,this._setPendingAction()),this.state===`waiting`&&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(()=>{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(){let e=this.editor.t;this._action||=this._pendingActions.add(e(`Saving changes`))}get _saveCallbacks(){let e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}},GT=class extends I{attributeKey;constructor(e,t){super(e),this.attributeKey=t}refresh(){let e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){let t=this.editor.model,n=t.document.selection,r=e.forceValue===void 0?!this.value:e.forceValue;t.change(e=>{if(n.isCollapsed)r?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{let i=t.schema.getValidRanges(n.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(let t of i){let n=t,i=this.attributeKey;t.isCollapsed&&(n=t.start.parent,i=Tl._getStoreAttributeKey(this.attributeKey)),r?e.setAttribute(i,r,n):e.removeAttribute(i,n)}}})}_getValueFromFirstAllowedNode(){let e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(let e of n.getRanges())for(let n of e.getItems())if(t.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}};const KT=`bold`;var qT=class extends F{static get pluginName(){return`BoldEditing`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=this.editor.t;e.model.schema.extend(`$text`,{allowAttributes:KT}),e.model.schema.setAttributeProperties(KT,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:KT,view:`strong`,upcastAlso:[`b`,e=>{let t=e.getStyle(`font-weight`);return t&&(t==`bold`||Number(t)>=600)?{name:!0,styles:[`font-weight`]}:null}]}),e.commands.add(KT,new GT(e,KT)),e.keystrokes.set(`CTRL+B`,KT),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t(`Bold text`),keystroke:`CTRL+B`}]})}};function JT({editor:e,commandName:t,plugin:n,icon:r,label:i,keystroke:a}){return o=>{let s=e.commands.get(t),c=new o(e.locale);return c.set({label:i,icon:r,keystroke:a,isToggleable:!0}),c.bind(`isEnabled`).to(s,`isEnabled`),c.bind(`isOn`).to(s,`value`),c instanceof U?c.set({role:`menuitemcheckbox`}):c.set({tooltip:!0}),n.listenTo(c,`execute`,()=>{e.execute(t),e.editing.view.focus()}),c}}const YT=`bold`;var XT=class extends F{static get pluginName(){return`BoldUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:YT,plugin:this,icon:Zg,label:t(`Bold`),keystroke:`CTRL+B`});e.ui.componentFactory.add(YT,()=>n(H)),e.ui.componentFactory.add(`menuBar:bold`,()=>n(U))}},Vte=class extends F{static get requires(){return[qT,XT]}static get pluginName(){return`Bold`}static get isOfficialPlugin(){return!0}};const ZT=`code`;var QT=class extends F{static get pluginName(){return`CodeEditing`}static get isOfficialPlugin(){return!0}static get requires(){return[bT]}init(){let e=this.editor,t=this.editor.t;e.model.schema.extend(`$text`,{allowAttributes:ZT}),e.model.schema.setAttributeProperties(ZT,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:ZT,view:`code`}),e.commands.add(ZT,new GT(e,ZT)),e.plugins.get(bT).registerAttribute(ZT),zT(e,ZT,`code`,`ck-code_selected`),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t(`Move out of an inline code style`),keystroke:[[`arrowleft`,`arrowleft`],[`arrowright`,`arrowright`]]}]})}};const $T=`code`;var eE=class extends F{static get pluginName(){return`CodeUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:$T,plugin:this,icon:f_,label:t(`Code`)});e.ui.componentFactory.add($T,()=>n(H)),e.ui.componentFactory.add(`menuBar:code`,()=>n(U))}},Hte=class extends F{static get requires(){return[QT,eE]}static get pluginName(){return`Code`}static get isOfficialPlugin(){return!0}};const tE=`italic`;var nE=class extends F{static get pluginName(){return`ItalicEditing`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=this.editor.t;e.model.schema.extend(`$text`,{allowAttributes:tE}),e.model.schema.setAttributeProperties(tE,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:tE,view:`i`,upcastAlso:[`em`,{styles:{"font-style":`italic`}}]}),e.commands.add(tE,new GT(e,tE)),e.keystrokes.set(`CTRL+I`,tE),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t(`Italic text`),keystroke:`CTRL+I`}]})}};const rE=`italic`;var iE=class extends F{static get pluginName(){return`ItalicUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:rE,plugin:this,icon:J_,keystroke:`CTRL+I`,label:t(`Italic`)});e.ui.componentFactory.add(rE,()=>n(H)),e.ui.componentFactory.add(`menuBar:italic`,()=>n(U))}},Ute=class extends F{static get requires(){return[nE,iE]}static get pluginName(){return`Italic`}static get isOfficialPlugin(){return!0}};const aE=`strikethrough`;var oE=class extends F{static get pluginName(){return`StrikethroughEditing`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=this.editor.t;e.model.schema.extend(`$text`,{allowAttributes:aE}),e.model.schema.setAttributeProperties(aE,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:aE,view:`s`,upcastAlso:[`del`,`strike`,{styles:{"text-decoration":`line-through`}}]}),e.commands.add(aE,new GT(e,aE)),e.keystrokes.set(`CTRL+SHIFT+X`,`strikethrough`),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t(`Strikethrough text`),keystroke:`CTRL+SHIFT+X`}]})}};const sE=`strikethrough`;var cE=class extends F{static get pluginName(){return`StrikethroughUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:sE,plugin:this,icon:fy,keystroke:`CTRL+SHIFT+X`,label:t(`Strikethrough`)});e.ui.componentFactory.add(sE,()=>n(H)),e.ui.componentFactory.add(`menuBar:strikethrough`,()=>n(U))}},Wte=class extends F{static get requires(){return[oE,cE]}static get pluginName(){return`Strikethrough`}static get isOfficialPlugin(){return!0}};const lE=`subscript`;var uE=class extends F{static get pluginName(){return`SubscriptEditing`}static get isOfficialPlugin(){return!0}init(){let e=this.editor;e.model.schema.extend(`$text`,{allowAttributes:lE}),e.model.schema.setAttributeProperties(lE,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:lE,view:`sub`,upcastAlso:[{styles:{"vertical-align":`sub`}}]}),e.commands.add(lE,new GT(e,lE))}};const dE=`subscript`;var fE=class extends F{static get pluginName(){return`SubscriptUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:dE,plugin:this,icon:my,label:t(`Subscript`)});e.ui.componentFactory.add(dE,()=>n(H)),e.ui.componentFactory.add(`menuBar:subscript`,()=>n(U))}},Gte=class extends F{static get requires(){return[uE,fE]}static get pluginName(){return`Subscript`}static get isOfficialPlugin(){return!0}};const pE=`superscript`;var mE=class extends F{static get pluginName(){return`SuperscriptEditing`}static get isOfficialPlugin(){return!0}init(){let e=this.editor;e.model.schema.extend(`$text`,{allowAttributes:pE}),e.model.schema.setAttributeProperties(pE,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:pE,view:`sup`,upcastAlso:[{styles:{"vertical-align":`super`}}]}),e.commands.add(pE,new GT(e,pE))}};const hE=`superscript`;var gE=class extends F{static get pluginName(){return`SuperscriptUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:hE,plugin:this,icon:hy,label:t(`Superscript`)});e.ui.componentFactory.add(hE,()=>n(H)),e.ui.componentFactory.add(`menuBar:superscript`,()=>n(U))}},Kte=class extends F{static get requires(){return[mE,gE]}static get pluginName(){return`Superscript`}static get isOfficialPlugin(){return!0}};const _E=`underline`;var vE=class extends F{static get pluginName(){return`UnderlineEditing`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=this.editor.t;e.model.schema.extend(`$text`,{allowAttributes:_E}),e.model.schema.setAttributeProperties(_E,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:_E,view:`u`,upcastAlso:{styles:{"text-decoration":`underline`}}}),e.commands.add(_E,new GT(e,_E)),e.keystrokes.set(`CTRL+U`,`underline`),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t(`Underline text`),keystroke:`CTRL+U`}]})}};const yE=`underline`;var bE=class extends F{static get pluginName(){return`UnderlineUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.locale.t,n=JT({editor:e,commandName:yE,plugin:this,icon:Dy,label:t(`Underline`),keystroke:`CTRL+U`});e.ui.componentFactory.add(yE,()=>n(H)),e.ui.componentFactory.add(`menuBar:underline`,()=>n(U))}},qte=class extends F{static get requires(){return[vE,bE]}static get pluginName(){return`Underline`}static get isOfficialPlugin(){return!0}};function*xE(e,t){for(let n of t)n&&e.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}var SE=class extends I{execute(){this.editor.model.change(e=>{this.enterBlock(e),this.fire(`afterExecute`,{writer:e})})}enterBlock(e){let t=this.editor.model,n=t.document.selection,r=t.schema,i=n.isCollapsed,a=n.getFirstRange(),o=a.start.parent,s=a.end.parent;if(r.isLimit(o)||r.isLimit(s))return!i&&o==s&&t.deleteContent(n),!1;if(i){let t=xE(e.model.schema,n.getAttributes());return CE(e,a.start),e.setSelectionAttribute(t),!0}else{let r=!(a.start.isAtStart&&a.end.isAtEnd),i=o==s;if(t.deleteContent(n,{leaveUnmerged:r}),r){if(i)return CE(e,n.focus),!0;e.setSelection(s,0)}}return!1}};function CE(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const Jte={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};var wE=class extends kc{constructor(e){super(e);let t=this.document,n=!1;t.on(`keydown`,(e,t)=>{n=t.shiftKey}),t.on(`beforeinput`,(r,i)=>{if(!this.isEnabled)return;let a=i.inputType;p.isSafari&&n&&a==`insertParagraph`&&(a=`insertLineBreak`);let o=i.domEvent,s=Jte[a];if(!s)return;let c=new ls(t,`enter`,i.targetRanges[0]);t.fire(c,new Ac(e,o,{isSoft:s.isSoft})),c.stop.called&&r.stop()})}observe(){}stopObserving(){}},TE=class extends F{static get pluginName(){return`Enter`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.editing.view,n=t.document,r=this.editor.t;t.addObserver(wE),e.commands.add(`enter`,new SE(e)),this.listenTo(n,`enter`,(r,i)=>{n.isComposing||i.preventDefault(),!i.isSoft&&(e.execute(`enter`),t.scrollToTheSelection())},{priority:`low`}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:r(`Insert a hard break (a new paragraph)`),keystroke:`Enter`}]})}},EE=class extends I{execute(){let e=this.editor.model,t=e.document;e.change(n=>{Xte(e,n,t.selection),this.fire(`afterExecute`,{writer:n})})}refresh(){let e=this.editor.model,t=e.document;this.isEnabled=Yte(e.schema,t.selection)}};function Yte(e,t){if(t.rangeCount>1)return!1;let n=t.anchor;if(!n||!e.checkChild(n,`softBreak`))return!1;let r=t.getFirstRange(),i=r.start.parent,a=r.end.parent;return!((OE(i,e)||OE(a,e))&&i!==a)}function Xte(e,t,n){let r=n.isCollapsed,i=n.getFirstRange(),a=i.start.parent,o=i.end.parent,s=a==o;if(r)DE(e,t,i.end,n.getAttributes());else{let r=!(i.start.isAtStart&&i.end.isAtEnd);e.deleteContent(n,{leaveUnmerged:r}),s?DE(e,t,n.focus,n.getAttributes()):r&&t.setSelection(o,0)}}function DE(e,t,n,r){let i=Array.from(xE(e.schema,r)),a=t.createElement(`softBreak`,i);e.insertContent(a,n),t.setSelection(a,`after`)}function OE(e,t){return e.is(`rootElement`)?!1:t.isLimit(e)||OE(e.parent,t)}var kE=class extends F{static get pluginName(){return`ShiftEnter`}static get isOfficialPlugin(){return!0}init(){let e=this.editor,t=e.model.schema,n=e.conversion,r=e.editing.view,i=r.document,a=this.editor.t;t.register(`softBreak`,{allowWhere:`$text`,allowAttributesOf:`$text`,isInline:!0}),n.for(`upcast`).elementToElement({model:`softBreak`,view:`br`}),n.for(`downcast`).elementToElement({model:`softBreak`,view:(e,{writer:t})=>t.createEmptyElement(`br`)}),r.addObserver(wE),e.commands.add(`shiftEnter`,new EE(e)),e.model.document.registerPostFixer(e=>Zte(e)),this.listenTo(i,`enter`,(t,n)=>{i.isComposing||n.preventDefault(),n.isSoft&&(e.execute(`shiftEnter`),r.scrollToTheSelection())},{priority:`low`}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:a(`Insert a soft break (a <br> element)`),keystroke:`Shift+Enter`}]})}};function Zte(e){let t=new Set;for(let n of e.model.document.differ.getChanges())n.type==`insert`||n.type==`remove`?n.position.parent.is(`element`)&&t.add(n.position.parent):n.type==`attribute`&&n.range.start.parent.is(`element`)&&t.add(n.range.start.parent);let n=!1;for(let r of t)for(let t of r.getChildren()){if(!t.is(`element`,`softBreak`))continue;let r=t.nextSibling;if(!r||r.is(`element`))continue;let i=Array.from(t.getAttributes()).filter(([e,t])=>!Qte(r,e,t));for(let[r]of i)e.removeAttribute(r,t),n=!0}return n}function Qte(e,t,n){return e?.getAttribute(t)===n}var AE=class extends I{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){let t=this.editor.model,n=t.schema,r=t.document.selection,i=Array.from(r.getSelectedBlocks()),a=e.forceValue===void 0?!this.value:e.forceValue;t.change(e=>{if(!a)this._removeQuote(e,i.filter(jE));else{let t=i.filter(e=>jE(e)||NE(n,e));this._applyQuote(e,t)}})}_getValue(){let e=this.editor.model.document.selection,t=j(e.getSelectedBlocks());return!!(t&&jE(t))}_checkEnabled(){if(this.value)return!0;let e=this.editor.model.document.selection,t=this.editor.model.schema,n=j(e.getSelectedBlocks());return n?NE(t,n):!1}_removeQuote(e,t){ME(e,t).reverse().forEach(t=>{if(t.start.isAtStart&&t.end.isAtEnd){e.unwrap(t.start.parent);return}if(t.start.isAtStart){let n=e.createPositionBefore(t.start.parent);e.move(t,n);return}t.end.isAtEnd||e.split(t.end);let n=e.createPositionAfter(t.end.parent);e.move(t,n)})}_applyQuote(e,t){let n=[];ME(e,t).reverse().forEach(t=>{let r=jE(t.start);r||(r=e.createElement(`blockQuote`),e.wrap(t,r)),n.push(r)}),n.reverse().reduce((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n)}};function jE(e){return e.parent.name==`blockQuote`?e.parent:null}function ME(e,t){let n,r=0,i=[];for(;r{let r=e.model.document.differ.getChanges();for(let e of r)if(e.type==`insert`){let r=e.position.nodeAfter;if(!r)continue;if(r.is(`element`,`blockQuote`)&&r.isEmpty)return n.remove(r),!0;if(r.is(`element`,`blockQuote`)&&!t.checkChild(e.position,r))return n.unwrap(r),!0;if(r.is(`element`)){let e=n.createRangeIn(r);for(let r of e.getItems())if(r.is(`element`,`blockQuote`)&&!t.checkChild(n.createPositionBefore(r),r))return n.unwrap(r),!0}}else if(e.type==`remove`){let t=e.position.parent;if(t.is(`element`,`blockQuote`)&&t.isEmpty)return n.remove(t),!0}return!1});let n=this.editor.editing.view.document,r=e.model.document.selection,i=e.commands.get(`blockQuote`);this.listenTo(n,`enter`,(t,n)=>{!r.isCollapsed||!i.value||r.getLastPosition().parent.isEmpty&&(e.execute(`blockQuote`),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())},{context:`blockquote`}),this.listenTo(n,`delete`,(t,n)=>{if(n.direction!=`backward`||!r.isCollapsed||!i.value)return;let a=r.getLastPosition().parent;a.isEmpty&&!a.previousSibling&&(e.execute(`blockQuote`),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())},{context:`blockquote`})}},FE=class extends F{static get pluginName(){return`BlockQuoteUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor;e.ui.componentFactory.add(`blockQuote`,()=>{let e=this._createButton(H);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add(`menuBar:blockQuote`,()=>{let e=this._createButton(U);return e.set({role:`menuitemcheckbox`}),e})}_createButton(e){let t=this.editor,n=t.locale,r=t.commands.get(`blockQuote`),i=new e(t.locale),a=n.t;return i.set({label:a(`Block quote`),icon:qv,isToggleable:!0}),i.bind(`isEnabled`).to(r,`isEnabled`),i.bind(`isOn`).to(r,`value`),this.listenTo(i,`execute`,()=>{t.execute(`blockQuote`),t.editing.view.focus()}),i}},$te=class extends F{static get requires(){return[PE,FE]}static get pluginName(){return`BlockQuote`}static get isOfficialPlugin(){return!0}};const ene=E();var IE=class extends ene{_stack=[];add(e,t){let n=this._stack,r=n[0];this._insertDescriptor(e);let i=n[0];r!==i&&!LE(r,i)&&this.fire(`change:top`,{oldDescriptor:r,newDescriptor:i,writer:t})}remove(e,t){let n=this._stack,r=n[0];this._removeDescriptor(e);let i=n[0];r!==i&&!LE(r,i)&&this.fire(`change:top`,{oldDescriptor:r,newDescriptor:i,writer:t})}_insertDescriptor(e){let t=this._stack,n=t.findIndex(t=>t.id===e.id);if(LE(e,t[n]))return;n>-1&&t.splice(n,1);let r=0;for(;t[r]&&RE(t[r],e);)r++;t.splice(r,0,e)}_removeDescriptor(e){let t=this._stack,n=t.findIndex(t=>t.id===e);n>-1&&t.splice(n,1)}};function LE(e,t){return e&&t&&e.priority==t.priority&&zE(e.classes)==zE(t.classes)}function RE(e,t){return e.priority>t.priority?!0:e.priorityzE(t.classes)}function zE(e){return Array.isArray(e)?e.sort().join(`,`):e}const BE=`ck-widget`,VE=`ck-widget_selected`;function HE(e){return e.is(`element`)?!!e.getCustomProperty(`widget`):!1}function UE(e,t,n={}){if(!e.is(`containerElement`))throw new w(`widget-to-widget-wrong-element-type`,null,{element:e});return t.setAttribute(`contenteditable`,`false`,e),t.addClass(BE,e),t.setCustomProperty(`widget`,!0,e),e.getFillerOffset=QE,t.setCustomProperty(`widgetLabel`,[],e),n.label&&qE(e,n.label),n.hasSelectionHandle&&$E(e,t),KE(e,t),e}function WE(e,t,n){if(t.classes&&n.addClass(A(t.classes),e),t.attributes)for(let r in t.attributes)n.setAttribute(r,t.attributes[r],e)}function GE(e,t,n){if(t.classes&&n.removeClass(A(t.classes),e),t.attributes)for(let r in t.attributes)n.removeAttribute(r,e)}function KE(e,t,n=WE,r=GE){let i=new IE;i.on(`change:top`,(t,i)=>{i.oldDescriptor&&r(e,i.oldDescriptor,i.writer),i.newDescriptor&&n(e,i.newDescriptor,i.writer)}),t.setCustomProperty(`addHighlight`,(e,t,n)=>i.add(t,n),e),t.setCustomProperty(`removeHighlight`,(e,t,n)=>i.remove(t,n),e)}function qE(e,t){e.getCustomProperty(`widgetLabel`).push(t)}function JE(e){return e.getCustomProperty(`widgetLabel`).reduce((e,t)=>typeof t==`function`?e?e+`. `+t():t():e?e+`. `+t:t,``)}function YE(e,t,n={}){return t.addClass([`ck-editor__editable`,`ck-editor__nested-editable`],e),n.withAriaRole!==!1&&t.setAttribute(`role`,`textbox`,e),e.isReadOnly||t.setAttribute(`tabindex`,`-1`,e),n.label&&t.setAttribute(`aria-label`,n.label,e),t.setAttribute(`contenteditable`,e.isReadOnly?`false`:`true`,e),e.on(`change:isReadOnly`,(n,r,i)=>{t.setAttribute(`contenteditable`,i?`false`:`true`,e),i?t.removeAttribute(`tabindex`,e):t.setAttribute(`tabindex`,`-1`,e)}),e.on(`change:isFocused`,(n,r,i)=>{i?t.addClass(`ck-editor__nested-editable_focused`,e):t.removeClass(`ck-editor__nested-editable_focused`,e)}),KE(e,t),e}function XE(e,t){let n=e.getSelectedElement();if(n){let r=sD(e);if(r)return t.createRange(t.createPositionAt(n,r))}return t.schema.findOptimalInsertionRange(e)}function ZE(e,t){return(n,r)=>{let{mapper:i,viewPosition:a}=r,o=i.findMappedViewAncestor(a);if(!t(o))return;let s=i.toModelElement(o);r.modelPosition=e.createPositionAt(s,a.isAtStart?`before`:`after`)}}function QE(){return null}function $E(e,t){let n=t.createUIElement(`div`,{class:`ck ck-widget__selection-handle`},function(e){let t=this.toDomElement(e),n=new Ly;return n.set(`content`,v_),n.render(),t.appendChild(n.element),t});t.insert(t.createPositionAt(e,0),n),t.addClass([`ck-widget_with-selection-handle`],e)}function eD(e){let t=e=>{let{width:t,paddingLeft:n,paddingRight:r}=e.ownerDocument.defaultView.getComputedStyle(e);return parseFloat(t)-(parseFloat(n)||0)-(parseFloat(r)||0)},n=e.parentElement;if(!n)return 0;let r=t(n),i=0,a=n;for(;isNaN(r);){if(a=a.parentElement,++i>5)return 0;r=t(a)}return r}function tD(e,t=new O(e)){let n=eD(e);return n?t.width/n*100:0}const nD=`widget-type-around`;function rD(e,t,n){return!!e&&HE(e)&&!n.isInline(t)}function iD(e){return e.closest(`.ck-widget__type-around__button`)}function aD(e){return e.classList.contains(`ck-widget__type-around__button_before`)?`before`:`after`}function oD(e,t){let n=e.closest(`.ck-widget`);return t.mapDomToView(n)}function sD(e){return e.getAttribute(nD)}const cD=[`before`,`after`],lD=new DOMParser().parseFromString($v,`image/svg+xml`).firstChild,uD=`ck-widget__type-around_disabled`;var dD=class extends F{_currentFakeCaretModelElement=null;static get pluginName(){return`WidgetTypeAround`}static get isOfficialPlugin(){return!0}static get requires(){return[TE,hT]}init(){let e=this.editor,t=e.editing.view;this.on(`change:isEnabled`,(n,r,i)=>{t.change(e=>{for(let n of t.document.roots)i?e.removeClass(uD,n):e.addClass(uD,n)}),i||e.model.change(e=>{e.removeSelectionAttribute(nD)})}),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){let n=this.editor,r=n.editing.view,i=n.model.schema.getAttributesWithProperty(e,`copyOnReplace`,!0);n.execute(`insertParagraph`,{position:n.model.createPositionAt(e,t),attributes:i}),r.focus(),r.scrollToTheSelection()}_listenToIfEnabled(e,t,n,r){this.listenTo(e,t,(...e)=>{this.isEnabled&&n(...e)},r)}_insertParagraphAccordingToFakeCaretPosition(){let e=this.editor.model.document.selection,t=sD(e);if(!t)return!1;let n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){let e=this.editor,t=e.model.schema,n=e.locale.t,r={before:n(`Insert paragraph before block`),after:n(`Insert paragraph after block`)};e.editing.downcastDispatcher.on(`insert`,(e,i,a)=>{let o=a.mapper.toViewElement(i.item);o&&rD(o,i.item,t)&&(fD(a.writer,r,o),o.getCustomProperty(`widgetLabel`).push(()=>this.isEnabled?n(`Press Enter to type after or press Shift + Enter to type before the widget`):``))},{priority:`low`})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){let e=this.editor,t=e.model,n=t.document.selection,r=t.schema,i=e.editing.view;this._listenToIfEnabled(i.document,`arrowKey`,(e,t)=>{this._handleArrowKeyPress(e,t)},{context:[HE,`$text`],priority:`high`}),this._listenToIfEnabled(n,`change:range`,(t,n)=>{n.directChange&&e.model.change(e=>{e.removeSelectionAttribute(nD)})}),this._listenToIfEnabled(t.document,`change:data`,()=>{let t=n.getSelectedElement();t&&rD(e.editing.mapper.toViewElement(t),t,r)||e.model.change(e=>{e.removeSelectionAttribute(nD)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,`selection`,(e,t,n)=>{let i=n.writer;if(this._currentFakeCaretModelElement){let e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(i.removeClass(cD.map(a),e),this._currentFakeCaretModelElement=null)}let o=t.selection.getSelectedElement();if(!o)return;let s=n.mapper.toViewElement(o);if(!rD(s,o,r))return;let c=sD(t.selection);c&&(i.addClass(a(c),s),this._currentFakeCaretModelElement=o)}),this._listenToIfEnabled(e.ui.focusTracker,`change:isFocused`,(t,n,r)=>{r||e.model.change(e=>{e.removeSelectionAttribute(nD)})});function a(e){return`ck-widget_type-around_show-fake-caret_${e}`}}_handleArrowKeyPress(e,t){let n=this.editor,r=n.model,i=r.document.selection,a=r.schema,o=n.editing.view;if(t.shiftKey)return;let s=t.keyCode,c=wi(s,n.locale.contentLanguageDirection),l=o.document.selection.getSelectedElement(),u=n.editing.mapper.toModelElement(l),d;rD(l,u,a)?d=this._handleArrowKeyPressOnSelectedWidget(c):i.isCollapsed?d=this._handleArrowKeyPressWhenSelectionNextToAWidget(c):t.shiftKey||(d=this._handleArrowKeyPressWhenNonCollapsedSelection(c)),d&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){let t=this.editor.model,n=t.document.selection,r=sD(n);return t.change(t=>{if(r){if(r!==(e?`after`:`before`))return t.removeSelectionAttribute(nD),!0}else return t.setSelectionAttribute(nD,e?`after`:`before`),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){let t=this.editor,n=t.model,r=n.schema,i=t.plugins.get(`Widget`),a=i._getObjectElementNextToSelection(e);return rD(t.editing.mapper.toViewElement(a),a,r)?(n.change(t=>{i._setSelectionOverElement(a),t.setSelectionAttribute(nD,e?`before`:`after`)}),!0):!1}_handleArrowKeyPressWhenNonCollapsedSelection(e){let t=this.editor,n=t.model,r=n.schema,i=t.editing.mapper,a=n.document.selection,o=e?a.getLastPosition().nodeBefore:a.getFirstPosition().nodeAfter;return rD(i.toViewElement(o),o,r)?(n.change(t=>{t.setSelection(o,`on`),t.setSelectionAttribute(nD,e?`after`:`before`)}),!0):!1}_enableInsertingParagraphsOnButtonClick(){let e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,`mousedown`,(n,r)=>{let i=iD(r.domTarget);if(!i)return;let a=aD(i),o=oD(i,t.domConverter),s=e.editing.mapper.toModelElement(o);this._insertParagraph(s,a),r.preventDefault(),n.stop()})}_enableInsertingParagraphsOnEnterKeypress(){let e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,`enter`,(n,r)=>{if(n.eventPhase!=`atTarget`)return;let i=t.getSelectedElement(),a=e.editing.mapper.toViewElement(i),o=e.model.schema,s;this._insertParagraphAccordingToFakeCaretPosition()?s=!0:rD(a,i,o)&&(this._insertParagraph(i,r.isSoft?`before`:`after`),s=!0),s&&(r.preventDefault(),n.stop())},{context:HE})}_enableInsertingParagraphsOnTypingKeystroke(){let e=this.editor.editing.view.document;this._listenToIfEnabled(e,`insertText`,(t,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.selection=e.selection)},{priority:`high`}),p.isAndroid?this._listenToIfEnabled(e,`keydown`,(e,t)=>{t.keyCode==229&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(e,`compositionstart`,()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:`highest`})}_enableDeleteIntegration(){let e=this.editor,t=e.editing.view,n=e.model,r=n.schema;this._listenToIfEnabled(t.document,`delete`,(t,i)=>{if(t.eventPhase!=`atTarget`)return;let a=sD(n.document.selection);if(!a)return;let o=i.direction,s=n.document.selection.getSelectedElement(),c=a===`before`,l=o==`forward`;if(c===l)e.execute(`delete`,{selection:n.createSelection(s,`on`)});else{let t=r.getNearestSelectionRange(n.createPositionAt(s,a),o);if(t)if(!t.isCollapsed)n.change(n=>{n.setSelection(t),e.execute(l?`deleteForward`:`delete`)});else{let i=n.createSelection(t.start);if(n.modifySelection(i,{direction:o}),!i.focus.isEqual(t.start))n.change(n=>{n.setSelection(t),e.execute(l?`deleteForward`:`delete`)});else{let e=hD(r,t.start.parent);n.deleteContent(n.createSelection(e,`on`),{doNotAutoparagraph:!0})}}}i.preventDefault(),t.stop()},{context:HE})}_enableInsertContentIntegration(){let e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,`insertContent`,(e,[r,i])=>{if(i&&!i.is(`documentSelection`))return;let a=sD(n);if(a)return e.stop(),t.change(e=>{let i=n.getSelectedElement(),o=t.createPositionAt(i,a),s=e.createSelection(o),c=t.insertContent(r,s);return e.setSelection(s),c})},{priority:`high`})}_enableInsertObjectIntegration(){let e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,`insertObject`,(e,n)=>{let[,r,i={}]=n;if(r&&!r.is(`documentSelection`))return;let a=sD(t);a&&(i.findOptimalPosition=a,n[3]=i)},{priority:`high`})}_enableDeleteContentIntegration(){let e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,`deleteContent`,(e,[n])=>{n&&!n.is(`documentSelection`)||sD(t)&&e.stop()},{priority:`high`})}};function fD(e,t,n){let r=e.createUIElement(`div`,{class:`ck ck-reset_all ck-widget__type-around`},function(e){let n=this.toDomElement(e);return pD(n,t),mD(n),n});e.insert(e.createPositionAt(n,`end`),r)}function pD(e,t){for(let n of cD){let r=new ga({tag:`div`,attributes:{class:[`ck`,`ck-widget__type-around__button`,`ck-widget__type-around__button_${n}`],title:t[n],"aria-hidden":`true`},children:[e.ownerDocument.importNode(lD,!0)]});e.appendChild(r.render())}}function mD(e){let t=new ga({tag:`div`,attributes:{class:[`ck`,`ck-widget__type-around__fake-caret`]}});e.appendChild(t.render())}function hD(e,t){let n=t;for(let r of t.getAncestors({parentFirst:!0})){if(r.childCount>1||e.isLimit(r))break;n=r}return n}function gD(e){let t=e.model;return(n,r)=>{let i=r.keyCode==k.arrowup,a=r.keyCode==k.arrowdown,o=r.shiftKey,s=t.document.selection;if(!i&&!a)return;let c=a,l=_D(e,s,c);if(l){if(l.isCollapsed&&(s.isCollapsed||o))return;(l.isCollapsed||bD(e,l,c))&&(t.change(e=>{let n=c?l.end:l.start;if(o){let r=t.createSelection(s.anchor);r.setFocus(n),e.setSelection(r)}else e.setSelection(n)}),n.stop(),r.preventDefault(),r.stopPropagation())}}}function _D(e,t,n){let r=e.model;if(n){let e=t.focus,n=vD(r,e,`forward`);if(!n)return;let i=r.createRange(e,n),a=yD(r.schema,i,`backward`);if(a)return r.createRange(e,a)}else{let e=t.focus,n=vD(r,e,`backward`);if(!n)return;let i=r.createRange(n,e),a=yD(r.schema,i,`forward`);if(a)return r.createRange(a,e)}}function vD(e,t,n){let r=e.schema,i=e.createRangeIn(t.root),a=n==`forward`?`elementStart`:`elementEnd`;for(let{previousPosition:e,item:o,type:s}of i.getWalker({startPosition:t,direction:n})){if(r.isLimit(o)&&!r.isInline(o))return e;if(s==a&&r.isBlock(o))return null}return null}function yD(e,t,n){let r=n==`backward`?t.end:t.start;if(e.checkChild(r,`$text`))return r;for(let{nextPosition:r}of t.getWalker({direction:n}))if(e.checkChild(r,`$text`))return r}function bD(e,t,n){let r=e.model,i=e.view.domConverter;if(n){let e=r.createSelection(t.start);r.modifySelection(e),!e.focus.isAtEnd&&!t.start.isEqual(e.focus)&&(t=r.createRange(e.focus,t.end))}let a=e.mapper.toViewRange(t),o=i.viewRangeToDom(a),s=O.getDomRangeRects(o),c;for(let e of s){if(c===void 0){c=Math.round(e.bottom);continue}if(Math.round(e.top)>=c)return!1;c=Math.max(c,Math.round(e.bottom))}return!0}var xD=class extends F{_previouslySelected=new Set;static get pluginName(){return`Widget`}static get isOfficialPlugin(){return!0}static get requires(){return[dD,hT]}init(){let e=this.editor,t=e.editing.view,n=t.document,r=e.t;this.editor.editing.downcastDispatcher.on(`selection`,(t,n,r)=>{let i=r.writer,a=n.selection;if(a.isCollapsed)return;let o=a.getSelectedElement();if(!o)return;let s=e.editing.mapper.toViewElement(o);HE(s)&&r.consumable.consume(a,`selection`)&&i.setSelection(i.createRangeOn(s),{fake:!0,label:JE(s)})}),this.editor.editing.downcastDispatcher.on(`selection`,(e,t,n)=>{this._clearPreviouslySelectedWidgets(n.writer);let r=n.writer,i=r.document.selection,a=null;for(let e of i.getRanges())for(let t of e){let e=t.item;HE(e)&&!ED(e,a)&&(r.addClass(VE,e),this._previouslySelected.add(e),a=e)}},{priority:`low`}),t.addObserver(Ap),t.addObserver(Mp),this.listenTo(n,`mousedown`,(...e)=>this._onMousedown(...e)),this.listenTo(n,`pointerdown`,(...e)=>this._onPointerdown(...e)),this.listenTo(n,`arrowKey`,(...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)},{context:[HE,`$text`]}),this.listenTo(n,`arrowKey`,(...e)=>{this._preventDefaultOnArrowKeyPress(...e)},{context:`$root`}),this.listenTo(n,`arrowKey`,gD(this.editor.editing),{context:`$text`}),this.listenTo(n,`delete`,(e,t)=>{this._handleDelete(t.direction==`forward`)&&(t.preventDefault(),e.stop())},{context:`$root`}),this.listenTo(n,`tab`,(e,n)=>{this._selectNextEditable(n.shiftKey?`backward`:`forward`)&&(t.scrollToTheSelection(),n.preventDefault(),e.stop())},{context:e=>HE(e)||e.is(`editableElement`),priority:`low`}),this.listenTo(n,`keydown`,(e,t)=>{t.keystroke==k.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())},{context:e=>e.is(`editableElement`),priority:`low`}),e.accessibility.addKeystrokeInfoGroup({id:`widget`,label:r(`Keystrokes that can be used when a widget is selected (for example: image, table, etc.)`),keystrokes:[{label:r(`Move focus from an editable area back to the parent widget`),keystroke:`Esc`},{label:r(`Insert a new paragraph directly after a widget`),keystroke:`Enter`},{label:r(`Insert a new paragraph directly before a widget`),keystroke:`Shift+Enter`},{label:r(`Move the caret to allow typing directly before a widget`),keystroke:[[`arrowup`],[`arrowleft`]]},{label:r(`Move the caret to allow typing directly after a widget`),keystroke:[[`arrowdown`],[`arrowright`]]}]})}_onMousedown(e,t){let n=t.target;n&&t.domEvent.detail>=3&&this._selectBlockContent(n)&&t.preventDefault()}_onPointerdown(e,t){if(!t.domEvent.isPrimary||iD(t.domTarget))return;let n=this.editor,r=n.editing.view,i=r.document,a=t.target;if(!a)return;if(!HE(a)){let e=wD(a);if(!e)return;if(HE(e))a=e;else{let e=TD(r,t);if(e&&HE(e))a=e;else return}}(p.isAndroid||p.isiOS)&&t.preventDefault(),i.isFocused||r.focus();let o=n.editing.mapper.toModelElement(a);this._setSelectionOverElement(o)}_selectBlockContent(e){let t=this.editor,n=t.model,r=t.editing.mapper,i=n.schema,a=r.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),o=DD(r.toModelElement(a),n.schema);return o?(n.change(e=>{let t=i.isLimit(o)?null:OD(e.createPositionAfter(o),i),n=e.createPositionAt(o,0),r=t?e.createPositionAt(t,0):e.createPositionAt(o,`end`);e.setSelection(e.createRange(n,r))}),!0):!1}_handleSelectionChangeOnArrowKeyPress(e,t){let n=t.keyCode,r=this.editor.model,i=r.schema,a=r.document.selection,o=a.getSelectedElement(),s=Si(n,this.editor.locale.contentLanguageDirection),c=s==`down`||s==`right`,l=s==`up`||s==`down`;if(!t.shiftKey&&!a.isCollapsed){if(SD(a,i)){let n=c?a.getLastPosition():a.getFirstPosition(),o=i.getNearestSelectionRange(n,c?`forward`:`backward`);o&&(r.change(e=>{e.setSelection(o)}),t.preventDefault(),e.stop())}return}let u=CD(r,c),d=r.createSelection(u);if(r.modifySelection(d,{direction:c?`forward`:`backward`}),d.isEqual(u))return;d.focus.isTouching(u.focus)&&i.checkChild(d.focus.parent,`$text`)&&(c?!d.focus.isAtEnd:!d.focus.isAtStart)&&r.modifySelection(d,{direction:c?`forward`:`backward`});let f=c?u.focus.nodeBefore:u.focus.nodeAfter,p=d.focus.nodeBefore,m=d.focus.nodeAfter,h=c?p:m;if(t.shiftKey)(o&&i.isObject(o)||h&&i.isObject(h)||f&&i.isObject(f))&&(r.change(e=>{e.setSelection(d)}),t.preventDefault(),e.stop());else if(h&&i.isObject(h)){if(i.isInline(h)&&l)return;r.change(e=>{e.setSelection(h,`on`)}),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){let n=this.editor.model,r=n.schema,i=n.document.selection.getSelectedElement();i&&r.isObject(i)&&(t.preventDefault(),e.stop())}_handleDelete(e){let t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t)||!t.isCollapsed)return;let n=this._getObjectElementNextToSelection(e);if(n)return this.editor.model.change(e=>{let r=t.anchor.parent;for(;r.isEmpty;){let t=r;r=t.parent,e.remove(t)}this._setSelectionOverElement(n)}),!0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){let t=this.editor.model,n=t.schema,r=t.document.selection,i=t.createSelection(r);if(t.modifySelection(i,{direction:e?`forward`:`backward`}),i.isEqual(r))return null;let a=e?i.focus.nodeBefore:i.focus.nodeAfter;return a&&n.isObject(a)?a:null}_clearPreviouslySelectedWidgets(e){for(let t of this._previouslySelected)e.removeClass(VE,t);this._previouslySelected.clear()}_selectNextEditable(e){let t=this.editor.editing,n=t.view,r=this.editor.model,i=n.document.selection,a=r.document.selection,o;if(a.rangeCount>1){let n=a.isBackward?a.getFirstRange():a.getLastRange();o=t.mapper.toViewPosition(e==`forward`?n.end:n.start)}else o=e==`forward`?i.getFirstPosition():i.getLastPosition();let s=this._findNextFocusRange(o,e);return s?(r.change(e=>{e.setSelection(s)}),!0):!1}_findNextFocusRange(e,t){let n=this.editor.editing,r=n.view,i=this.editor.model,a=r.document.selection,o=a.editableElement,s=o.getPath(),c=a.getSelectedElement();c&&!HE(c)&&(c=null);let l=t==`forward`?r.createRange(e,r.createPositionAt(e.root,`end`)):r.createRange(r.createPositionAt(e.root,0),e);for(let{nextPosition:e}of l.getWalker({direction:t})){let r=e.parent;if(HE(r)&&r!=c){let e=n.mapper.toModelElement(r);if(!i.schema.isBlock(e))continue;if(fr(s,r.getPath())!=`extension`)return i.createRangeOn(e)}else if(r.is(`editableElement`)){if(r==o&&!c)continue;let a=n.mapper.toModelPosition(e),l=i.schema.getNearestSelectionRange(a,t);if(!l)continue;return r==o&&c||fr(s,r.getPath())==`extension`?l:i.createRangeIn(i.schema.getLimitElement(l))}}return null}_selectAncestorWidget(){let e=this.editor,t=e.editing.mapper,n=e.editing.view.document.selection.getFirstPosition().parent,r=(n.is(`$text`)?n.parent:n).findAncestor(HE);if(!r)return!1;let i=t.toModelElement(r);return i?(e.model.change(e=>{e.setSelection(i,`on`)}),!0):!1}};function SD(e,t){let n=e.getFirstPosition(),r=e.getLastPosition(),i=n.nodeAfter,a=r.nodeBefore;return!!i&&t.isObject(i)||!!a&&t.isObject(a)}function CD(e,t){let n=e.document.selection,r=n.getSelectedElement(),i=sD(n);return r&&i==`before`?e.createSelection(r,`before`):r&&i==`after`?e.createSelection(r,`after`):e.createSelection(n.getRanges(),{backward:r&&e.schema.isObject(r)?!t:n.isBackward})}function wD(e){let t=e;for(;t;){if(t.is(`editableElement`)||HE(t))return t;t=t.parent}return null}function TD(e,t){let n=Or(t.domEvent),r=null;if(r=n?e.domConverter.domRangeToView(n):e.createRange(e.createPositionAt(t.target,0)),!r)return null;let i=r.start;if(!i.parent)return null;let a=i.parent;return i.parent.is(`editableElement`)&&(i.isAtEnd&&i.nodeBefore?a=i.nodeBefore:i.isAtStart&&i.nodeAfter&&(a=i.nodeAfter)),a.is(`$text`)?a.parent:a}function ED(e,t){return t?Array.from(e.getAncestors()).includes(t):!1}function DD(e,t){for(let n of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(n,`$text`))return n;if(t.isLimit(n)&&!t.isObject(n))break}return null}function OD(e,t){let n=new Xc({startPosition:e});for(let{item:e}of n){if(t.isLimit(e)||!e.is(`element`))return null;if(t.checkChild(e,`$text`))return e}return null}var kD=class extends F{_toolbarDefinitions=new Map;_balloon;static get requires(){return[BC]}static get pluginName(){return`WidgetToolbarRepository`}static get isOfficialPlugin(){return!0}init(){let e=this.editor;if(e.plugins.has(`BalloonToolbar`)){let t=e.plugins.get(`BalloonToolbar`);this.listenTo(t,`show`,t=>{MD(e.editing.view.document.selection)&&t.stop()},{priority:`high`})}this._balloon=this.editor.plugins.get(`ContextualBalloon`),this.on(`change:isEnabled`,()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui,`update`,()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui.focusTracker,`change:isFocused`,()=>{this._updateToolbarsVisibility()},{priority:`low`})}destroy(){super.destroy();for(let e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:n,getRelatedElement:r,balloonClassName:i=`ck-toolbar-container`,positions:a}){if(!n.length){T(`widget-toolbar-no-items`,{toolbarId:e});return}let o=this.editor,s=o.t,c=new Ox(o.locale);if(c.ariaLabel=t||s(`Widget toolbar`),this._toolbarDefinitions.has(e))throw new w(`widget-toolbar-duplicated`,this,{toolbarId:e});let l={view:c,getRelatedElement:r,balloonClassName:i,itemsConfig:n,positions:a,initialized:!1};o.ui.addToolbar(c,{isContextual:!0,beforeFocus:()=>{let e=r(o.editing.view.document.selection);e&&this._showToolbar(l,e)},afterBlur:()=>{this._hideToolbar(l)}}),this._toolbarDefinitions.set(e,l)}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(let r of this._toolbarDefinitions.values()){let i=r.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!i)this._isToolbarInBalloon(r)&&this._hideToolbar(r);else if(!this.editor.ui.focusTracker.isFocused)this._isToolbarVisible(r)&&this._hideToolbar(r);else{let a=i.getAncestors().length;a>e&&(e=a,t=i,n=r)}}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,`change:visibleView`)}_showToolbar(e,t){this._isToolbarVisible(e)?AD(this.editor,t,e.positions):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:jD(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,`change:visibleView`,()=>{for(let t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){let n=t.getRelatedElement(this.editor.editing.view.document.selection);AD(this.editor,n,e.positions)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}};function AD(e,t,n){let r=e.plugins.get(`ContextualBalloon`),i=jD(e,t,n);r.updatePosition(i)}function jD(e,t,n){let r=e.editing.view,i=ab.defaultPositions;return{target:r.domConverter.mapViewToDom(t),positions:n||[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}function MD(e){let t=e.getSelectedElement();return!!(t&&HE(t))}const ND=D();var PD=class extends ND{_referenceCoordinates;_options;_originalWidth;_originalHeight;_originalWidthPercents;_aspectRatio;constructor(e){super(),this.set(`activeHandlePosition`,null),this.set(`proposedWidthPercents`,null),this.set(`proposedWidth`,null),this.set(`proposedHeight`,null),this.set(`proposedHandleHostWidth`,null),this.set(`proposedHandleHostHeight`,null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,n){let r=new O(t);this.activeHandlePosition=LD(e),this._referenceCoordinates=FD(t,RD(this.activeHandlePosition)),this._originalWidth=r.width,this._originalHeight=r.height,this._aspectRatio=r.width/r.height;let i=n.style.width;i&&i.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(i):this._originalWidthPercents=tD(n,r)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}};function FD(e,t){let n=new O(e),r=t.split(`-`),i={x:r[1]==`right`?n.right:n.left,y:r[0]==`bottom`?n.bottom:n.top};return i.x+=e.ownerDocument.defaultView.scrollX,i.y+=e.ownerDocument.defaultView.scrollY,i}function ID(e){return`ck-widget__resizer__handle-${e}`}function LD(e){for(let t of[`top-left`,`top-right`,`bottom-right`,`bottom-left`])if(e.classList.contains(ID(t)))return t}function RD(e){let t=e.split(`-`),n={top:`bottom`,bottom:`top`,left:`right`,right:`left`};return`${n[t[0]]}-${n[t[1]]}`}var zD=class extends P{constructor(){super();let e=this.bindTemplate;this.setTemplate({tag:`div`,attributes:{class:[`ck`,`ck-size-view`,e.to(`_viewPosition`,e=>e?`ck-orientation-${e}`:``)],style:{display:e.if(`_isVisible`,`none`,e=>!e)}},children:[{text:e.to(`_label`)}]})}_bindToState(e,t){this.bind(`_isVisible`).to(t,`proposedWidth`,t,`proposedHeight`,(e,t)=>e!==null&&t!==null),this.bind(`_label`).to(t,`proposedHandleHostWidth`,t,`proposedHandleHostHeight`,t,`proposedWidthPercents`,(t,n,r)=>e.unit===`px`?`${t}×${n}`:`${r}%`),this.bind(`_viewPosition`).to(t,`activeHandlePosition`,t,`proposedHandleHostWidth`,t,`proposedHandleHostHeight`,(e,t,n)=>t<50||n<50?`above-center`:e)}_dismiss(){this.unbind(),this._isVisible=!1}};const BD=D();var VD=class extends BD{_state;_sizeView;_options;_viewResizerWrapper=null;_initialViewWidth;constructor(e){super(),this._options=e,this.set(`isEnabled`,!0),this.set(`isSelected`,!1),this.bind(`isVisible`).to(this,`isEnabled`,this,`isSelected`,(e,t)=>e&&t),this.decorate(`begin`),this.decorate(`cancel`),this.decorate(`commit`),this.decorate(`updateSize`),this.on(`commit`,e=>{!this.state.proposedWidth&&!this.state.proposedWidthPercents&&(this._cleanup(),e.stop())},{priority:`high`})}get state(){return this._state}show(){this._options.editor.editing.view.change(e=>{e.removeClass(`ck-hidden`,this._viewResizerWrapper)})}hide(){this._options.editor.editing.view.change(e=>{e.addClass(`ck-hidden`,this._viewResizerWrapper)})}attach(){let e=this,t=this._options.viewElement;this._options.editor.editing.view.change(n=>{let r=n.createUIElement(`div`,{class:`ck ck-reset_all ck-widget__resizer`},function(t){let n=this.toDomElement(t);return e._appendHandles(n),e._appendSizeUI(n),n});n.insert(n.createPositionAt(t,`end`),r),n.addClass(`ck-widget_with-resizer`,t),this._viewResizerWrapper=r,this.isVisible||this.hide()}),this.on(`change:isVisible`,()=>{this.isVisible?(this.show(),this.redraw()):this.hide()})}begin(e){this._state=new PD(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle(`width`),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){let t=this._proposeNewSize(e);this._options.editor.editing.view.change(e=>{let n=this._options.unit||`%`,r=(n===`%`?t.widthPercents:t.width)+n;e.setStyle(`width`,r,this._options.viewElement)});let n=this._getHandleHost(),r=new O(n),i=Math.round(r.width),a=Math.round(r.height),o=new O(n);t.width=Math.round(o.width),t.height=Math.round(o.height),this.redraw(r),this.state.update({...t,handleHostWidth:i,handleHostHeight:a})}commit(){let e=this._options.unit||`%`,t=(e===`%`?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change(()=>{this._cleanup(),this._options.onCommit(t)})}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){let t=this._domResizerWrapper;if(!WD(t))return;let n=t.parentElement,r=this._getHandleHost(),i=this._viewResizerWrapper,a=[i.getStyle(`width`),i.getStyle(`height`),i.getStyle(`left`),i.getStyle(`top`)],o;if(n.isSameNode(r)){let t=e||new O(r);o=[t.width+`px`,t.height+`px`,void 0,void 0]}else o=[r.offsetWidth+`px`,r.offsetHeight+`px`,r.offsetLeft+`px`,r.offsetTop+`px`];fr(a,o)!==`same`&&this._options.editor.editing.view.change(e=>{e.setStyle({width:o[0],height:o[1],left:o[2],top:o[3]},i)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains(`ck-widget__resizer__handle`)}_cleanup(){this._sizeView._dismiss(),this._options.editor.editing.view.change(e=>{e.setStyle(`width`,this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){let t=this.state,n=UD(e),r=this._options.isCentered?this._options.isCentered(this):!0,i={x:t._referenceCoordinates.x-(n.x+t.originalWidth),y:n.y-t.originalHeight-t._referenceCoordinates.y};r&&t.activeHandlePosition.endsWith(`-right`)&&(i.x=n.x-(t._referenceCoordinates.x+t.originalWidth)),r&&(i.x*=2);let a=Math.abs(t.originalWidth+i.x),o=Math.abs(t.originalHeight+i.y);return(a/t.aspectRatio>o?`width`:`height`)==`width`?o=a/t.aspectRatio:a=o*t.aspectRatio,{width:Math.round(a),height:Math.round(o),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a*100)/100,100)}}_getResizeHost(){let e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){let e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){for(let t of[`top-left`,`top-right`,`bottom-right`,`bottom-left`])e.appendChild(new ga({tag:`div`,attributes:{class:`ck-widget__resizer__handle ${HD(t)}`}}).render())}_appendSizeUI(e){this._sizeView=new zD,this._sizeView.render(),e.appendChild(this._sizeView.element)}};function HD(e){return`ck-widget__resizer__handle-${e}`}function UD(e){return{x:e.pageX,y:e.pageY}}function WD(e){return e&&e.ownerDocument&&e.ownerDocument.contains(e)}var GD=class extends F{_resizers=new Map;_observer;_redrawSelectedResizerThrottled;static get pluginName(){return`WidgetResize`}static get isOfficialPlugin(){return!0}init(){let e=this.editor.editing,t=u.window.document;this.set(`selectedResizer`,null),this.set(`_activeResizer`,null),e.view.addObserver(Ap),this._observer=new(br()),this.listenTo(e.view.document,`mousedown`,this._mouseDownListener.bind(this),{priority:`high`}),this._observer.listenTo(t,`mousemove`,this._mouseMoveListener.bind(this)),this._observer.listenTo(t,`mouseup`,this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=qt(()=>this.redrawSelectedResizer(),200),this.editor.ui.on(`update`,this._redrawSelectedResizerThrottled),this.editor.model.document.on(`change`,()=>{for(let[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())},{priority:`lowest`}),this._observer.listenTo(u.window,`resize`,this._redrawSelectedResizerThrottled);let n=this.editor.editing.view.document.selection;n.on(`change`,()=>{let e=n.getSelectedElement(),t=this.getResizerByViewElement(e)||null;t?this.select(t):this.deselect()})}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(let e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){let t=new VD(e),n=this.editor.plugins;if(t.attach(),n.has(`WidgetToolbarRepository`)){let e=n.get(`WidgetToolbarRepository`);t.on(`begin`,()=>{e.forceDisabled(`resize`)},{priority:`lowest`}),t.on(`cancel`,()=>{e.clearForceDisabled(`resize`)},{priority:`highest`}),t.on(`commit`,()=>{e.clearForceDisabled(`resize`)},{priority:`highest`})}this._resizers.set(e.viewElement,t);let r=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(r)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(let t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){let n=t.domTarget;VD.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n)||null,this._activeResizer&&(this._activeResizer.begin(n),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&=(this._activeResizer.commit(),null)}},KD=class extends P{focusTracker=new M;keystrokes=new N;idInputView;backButtonView;saveButtonView;children;_validators;_focusables=new pa;_focusCycler;constructor(e,t){super(e),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.idInputView=this._createIdInput(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new MC(e,{children:[this.idInputView,this.saveButtonView],class:[`ck-form__row_with-submit`,`ck-form__row_large-top-padding`]})),this.keystrokes.set(`Esc`,(e,t)=>{this.fire(`cancel`),t()}),this._focusCycler=new Hy({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:`shift + tab`,focusNext:`tab`}}),this.setTemplate({tag:`form`,attributes:{class:[`ck`,`ck-form`,`ck-bookmark-form`,`ck-responsive-form`],tabindex:`-1`},children:this.children})}render(){super.render(),Qa({view:this}),[this.backButtonView,this.idInputView,this.saveButtonView].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.idInputView.focus()}isValid(){this.resetFormStatus();for(let e of this._validators){let t=e(this);if(t)return this.idInputView.errorText=t,!1}return!0}resetFormStatus(){this.idInputView.errorText=null}_createBackButton(){let e=this.locale.t,t=new H(this.locale);return t.set({class:`ck-button-back`,label:e(`Back`),icon:Wv,tooltip:!0}),t.delegate(`execute`).to(this,`cancel`),t}_createSaveButton(){let e=this.locale.t,t=new H(this.locale);return t.set({label:e(`Save`),withText:!0,type:`submit`,class:`ck-button-action ck-button-bold`}),t}_createHeaderView(){let e=this.locale.t,t=new By(this.locale,{label:e(`Bookmark`)});return t.children.add(this.backButtonView,0),t}_createIdInput(){let e=this.locale.t,t=new Qb(this.locale,Jx);return t.label=e(`Bookmark name`),t.infoText=e(`Enter the bookmark name without spaces.`),t.class=`ck-labeled-field-view_full-width`,t}get id(){let{element:e}=this.idInputView.fieldView;return e?e.value.trim():null}};function qD(e){return!(!e||typeof e!=`string`||/\s/.test(e))}var JD=class extends I{refresh(){let e=this.editor.model.document.selection,t=this._getPositionToInsertBookmark(e);this.isEnabled=!!t}execute(e){if(!e)return;let{bookmarkId:t}=e;if(!qD(t)){T(`insert-bookmark-command-executed-with-invalid-name`);return}let n=this.editor,r=n.model,i=r.document.selection;r.change(e=>{let a=this._getPositionToInsertBookmark(i);if(!r.schema.checkChild(a,`bookmark`)){let e=n.execute(`insertParagraph`,{position:a});if(!e)return;a=e}let o=e.createElement(`bookmark`,{...Object.fromEntries(i.getAttributes()),bookmarkId:t});r.insertObject(o,a,null,{setSelection:`on`})})}_getPositionToInsertBookmark(e){let t=this.editor.model,n=t.schema,r=e.getFirstRange(),i=r.start;if(YD(i,n))return i;for(let{previousPosition:e,item:i}of r){if(i.is(`element`)&&n.checkChild(i,`$text`)&&YD(i,n))return t.createPositionAt(i,0);if(YD(e,n))return e}return null}};function YD(e,t){return t.checkChild(e,`bookmark`)?!0:t.checkChild(e,`paragraph`)?t.checkChild(`paragraph`,`bookmark`):!1}var XD=class extends I{refresh(){let e=this.editor.model.document.selection,t=ZD(e);this.isEnabled=!!t,this.value=t?t.getAttribute(`bookmarkId`):void 0}execute(e){if(!e)return;let{bookmarkId:t}=e;if(!qD(t)){T(`update-bookmark-command-executed-with-invalid-name`);return}let n=this.editor.model,r=n.document.selection,i=ZD(r);i&&n.change(e=>{e.setAttribute(`bookmarkId`,t,i)})}};function ZD(e){let t=e.getSelectedElement();return t&&t.is(`element`,`bookmark`)?t:null}var QD=class extends F{_bookmarkElements=new Map;static get pluginName(){return`BookmarkEditing`}static get licenseFeatureCode(){return`BKM`}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define(`bookmark`,{toolbar:[`bookmarkPreview`,`|`,`editBookmark`,`removeBookmark`]})}init(){let{editor:e}=this;this._defineSchema(),this._defineConverters(),e.commands.add(`insertBookmark`,new JD(e)),e.commands.add(`updateBookmark`,new XD(e)),this.listenTo(e.model.document,`change:data`,()=>{this._trackBookmarkElements()})}getElementForBookmarkId(e){for(let[t,n]of this._bookmarkElements)if(n==e)return t;return null}getAllBookmarkNames(){return new Set(this._bookmarkElements.values())}_defineSchema(){this.editor.model.schema.register(`bookmark`,{inheritAllFrom:`$inlineObject`,allowAttributes:`bookmarkId`,disallowAttributes:[`linkHref`,`htmlA`]})}_defineConverters(){let{editor:e}=this,{conversion:t,t:n}=e;e.data.htmlProcessor.domConverter.registerInlineObjectMatcher(e=>$D(e)),e.editing.view.domConverter.registerInlineObjectMatcher(e=>$D(e,!1)),t.for(`dataDowncast`).elementToElement({model:{name:`bookmark`,attributes:[`bookmarkId`]},view:(e,{writer:t})=>t.createEmptyElement(`a`,{id:e.getAttribute(`bookmarkId`)})}),t.for(`editingDowncast`).elementToElement({model:{name:`bookmark`,attributes:[`bookmarkId`]},view:(e,{writer:t})=>{let r=e.getAttribute(`bookmarkId`),i=t.createContainerElement(`a`,{id:r,class:`ck-bookmark`},[this._createBookmarkUIElement(t)]);return t.setCustomProperty(`bookmark`,!0,i),this._bookmarkElements.set(e,r),UE(i,t,{label:()=>`${r} ${n(`bookmark widget`)}`})}}),t.for(`upcast`).add(t=>t.on(`element:a`,eO(e)))}_createBookmarkUIElement(e){return e.createUIElement(`span`,{class:`ck-bookmark__icon`},function(e){let t=this.toDomElement(e),n=new Ly;return n.set({content:Qg,isColorInherited:!1}),n.render(),t.appendChild(n.element),t})}_trackBookmarkElements(){this._bookmarkElements.forEach((e,t)=>{t.root.rootName===`$graveyard`&&this._bookmarkElements.delete(t)})}};function $D(e,t=!0){if(e.name!==`a`||t&&!e.isEmpty)return null;let n=e.hasAttribute(`id`),r=e.hasAttribute(`name`),i=e.hasAttribute(`href`);return n&&!i?{name:!0,attributes:[`id`]}:r&&!i?{name:!0,attributes:[`name`]}:null}function eO(e){return(t,n,r)=>{let i=n.viewItem,a=$D(i,!1);if(!a||!r.consumable.test(i,a)||!tO(e)&&!i.isEmpty)return;let o=r.writer,s=i.getAttribute(`id`),c=i.getAttribute(`name`),l=s||c,u=o.createElement(`bookmark`,{bookmarkId:l});if(!r.safeInsert(u,n.modelCursor))return;r.consumable.consume(i,a),s===c&&r.consumable.consume(i,{attributes:[`name`]}),r.updateConversionResult(u,n);let{modelCursor:d,modelRange:f}=r.convertChildren(i,n.modelCursor);n.modelCursor=d,n.modelRange=o.createRange(n.modelRange.start,f.end)}}function tO(e){let t=e.config.get(`bookmark.enableNonEmptyAnchorConversion`);return t===void 0?!0:t}const nO=`bookmark-ui`;var rO=class extends F{formView=null;_balloon;static get requires(){return[QD,BC,kD]}static get pluginName(){return`BookmarkUI`}static get isOfficialPlugin(){return!0}init(){let e=this.editor;this._balloon=e.plugins.get(BC),e.plugins.has(`LinkUI`)&&this._registerLinkProvider(),this._registerComponents(),e.conversion.for(`editingDowncast`).markerToHighlight({model:nO,view:{classes:[`ck-fake-bookmark-selection`]}}),e.conversion.for(`editingDowncast`).markerToElement({model:nO,view:(e,{writer:t})=>{if(!e.markerRange.isCollapsed)return null;let n=t.createUIElement(`span`);return t.addClass([`ck-fake-bookmark-selection`,`ck-fake-bookmark-selection_collapsed`],n),n}})}afterInit(){let e=this.editor,t=e.locale.t,n=this.editor.plugins.get(kD),r=ab.defaultPositions;n.register(`bookmark`,{ariaLabel:t(`Bookmark toolbar`),items:e.config.get(`bookmark.toolbar`),getRelatedElement:aO,balloonClassName:`ck-bookmark-balloon ck-toolbar-container`,positions:[r.southArrowNorth,r.southArrowNorthMiddleWest,r.southArrowNorthMiddleEast,r.southArrowNorthWest,r.southArrowNorthEast,r.northArrowSouth,r.northArrowSouthMiddleWest,r.northArrowSouthMiddleEast,r.northArrowSouthWest,r.northArrowSouthEast,r.viewportStickyNorth]})}destroy(){super.destroy(),this.formView&&this.formView.destroy()}_createViews(){this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createFormView(){let e=this.editor,t=e.locale,n=t.t,r=e.commands.get(`insertBookmark`),i=e.commands.get(`updateBookmark`),a=[r,i],o=new(Xa(KD))(t,iO(e));return o.idInputView.fieldView.bind(`value`).to(i,`value`),o.saveButtonView.bind(`label`).to(i,`value`,e=>n(e?`Save`:`Insert`)),o.idInputView.bind(`isEnabled`).toMany(a,`isEnabled`,(...e)=>e.some(e=>e)),o.saveButtonView.bind(`isEnabled`).toMany(a,`isEnabled`,(...e)=>e.some(e=>e)),this.listenTo(o,`cancel`,()=>{this._hideFormView()}),this.listenTo(o,`submit`,()=>{if(o.isValid()){let t=o.id;this._getSelectedBookmarkElement()?e.execute(`updateBookmark`,{bookmarkId:t}):e.execute(`insertBookmark`,{bookmarkId:t}),this._hideFormView()}}),this.listenTo(o.idInputView,`change:errorText`,()=>{e.ui.update()}),o}_registerLinkProvider(){let e=this.editor.locale.t,t=this.editor.plugins.get(`LinkUI`),n=this.editor.plugins.get(QD);t.registerLinksListProvider({label:e(`Bookmarks`),emptyListPlaceholder:e(`No bookmarks available.`),navigate:({href:e})=>this._scrollToBookmark(e),getListItems:()=>Array.from(n.getAllBookmarkNames()).sort((e,t)=>e.localeCompare(t)).map(e=>({id:e,href:`#${e}`,label:e,icon:e_})),getItem:t=>{let r=[...n.getAllBookmarkNames()].find(e=>`#${e}`===t);return r?{href:t,label:r,icon:t_,tooltip:e(`Scroll to bookmark`)}:null}})}_scrollToBookmark(e){let t=this.editor.plugins.get(QD).getElementForBookmarkId(e.slice(1));return t?(this.editor.model.change(e=>{e.setSelection(t,`on`)}),this.editor.editing.view.scrollToTheSelection({alignToTop:!0,forceScroll:!0}),!0):!1}_registerComponents(){let e=this.editor;e.ui.componentFactory.add(`bookmark`,()=>{let e=this._createBookmarkButton(H);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add(`menuBar:bookmark`,()=>this._createBookmarkButton(U)),e.ui.componentFactory.add(`bookmarkPreview`,t=>{let n=e.commands.get(`updateBookmark`),r=new eo(t);return r.extendTemplate({attributes:{class:[`ck-bookmark-toolbar__preview`]}}),r.bind(`text`).to(n,`value`),r}),e.ui.componentFactory.add(`editBookmark`,t=>{let n=e.commands.get(`updateBookmark`),r=new H(t),i=t.t;return r.set({label:i(`Edit bookmark`),icon:Rv,tooltip:!0}),r.bind(`isEnabled`).to(n),this.listenTo(r,`execute`,()=>{this._showFormView()}),r}),e.ui.componentFactory.add(`removeBookmark`,t=>{let n=e.commands.get(`delete`),r=new H(t),i=t.t;return r.set({label:i(`Remove bookmark`),icon:Qv,tooltip:!0}),r.bind(`isEnabled`).to(n),this.listenTo(r,`execute`,()=>{e.execute(`delete`),e.editing.view.focus()}),r})}_createBookmarkButton(e){let t=this.editor,n=t.locale,r=new e(n),i=t.commands.get(`insertBookmark`),a=t.commands.get(`updateBookmark`),o=n.t;return r.set({label:o(`Bookmark`),icon:$g}),this.listenTo(r,`execute`,()=>{t.editing.view.scrollToTheSelection(),this._showFormView()}),r.bind(`isEnabled`).toMany([i,a],`isEnabled`,(...e)=>e.some(e=>e)),r.bind(`isOn`).to(a,`value`,e=>!!e),r}_enableUserBalloonInteractions(){this.editor.keystrokes.set(`Esc`,(e,t)=>{this._isFormVisible&&(this._hideFormView(),t())}),Ya({emitter:this.formView,activator:()=>this._isFormInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideFormView(!1)}})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;let e=this.editor.commands.get(`updateBookmark`);this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.backButtonView.isVisible=e.isEnabled,this.formView.idInputView.fieldView.value=e.value||``,this._balloon.visibleView===this.formView&&this.formView.idInputView.fieldView.select(),this.formView.enableCssTransitions()}_removeFormView(e=!0){this.formView.saveButtonView.focus(),this.formView.idInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection()}_showFormView(){this.formView||this._createViews(),this._getSelectedBookmarkElement()||this._showFakeVisualSelection(),this._addFormView(),this._balloon.showStack(`main`),this._startUpdatingUI()}_hideFormView(e=!0){if(!this._isFormInPanel)return;let t=this.editor;this.stopListening(t.ui,`update`),this.stopListening(this._balloon,`change:visibleView`),e&&t.editing.view.focus(),this._removeFormView(e),this._hideFakeVisualSelection()}_startUpdatingUI(){let e=this.editor,t=e.editing.view.document,n=this._getSelectedBookmarkElement(),r=a(),i=()=>{let e=this._getSelectedBookmarkElement(),t=a();n&&!e||!n&&t!==r?this._hideFormView():this._isFormVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=e,r=t};function a(){return t.selection.focus.getAncestors().reverse().find(e=>e.is(`element`))}this.listenTo(e.ui,`update`,i),this.listenTo(this._balloon,`change:visibleView`,i)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}_getBalloonPositionData(){let e=this.editor.editing.view,t=this.editor.model,n,r=this._getSelectedBookmarkElement();if(t.markers.has(nO)){let t=Array.from(this.editor.editing.mapper.markerNameToElements(nO)),r=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(r)}else r&&(n=()=>{let t=this.editor.editing.mapper,n=e.domConverter,i=t.toViewElement(r);return n.mapViewToDom(i)});if(n)return{target:n}}_getSelectedBookmarkElement(){let e=this.editor.model.document.selection.getSelectedElement();return e&&e.is(`element`,`bookmark`)?e:null}_showFakeVisualSelection(){let e=this.editor.model;e.change(t=>{let n=e.document.selection.getFirstRange();if(e.markers.has(nO))t.updateMarker(nO,{range:n});else if(n.start.isAtEnd){let r=n.start.getLastMatchingPosition(({item:t})=>!e.schema.isContent(t),{boundaries:n});t.addMarker(nO,{usingOperation:!1,affectsData:!1,range:t.createRange(r,n.end)})}else t.addMarker(nO,{usingOperation:!1,affectsData:!1,range:n})})}_hideFakeVisualSelection(){let e=this.editor.model;e.markers.has(nO)&&e.change(e=>{e.removeMarker(nO)})}};function iO(e){let{t}=e,n=e.plugins.get(QD);return[e=>{if(!e.id)return t(`Bookmark must not be empty.`)},e=>{if(e.id&&/\s/.test(e.id))return t(`Bookmark name cannot contain space characters.`)},r=>{let i=e.model.document.selection.getSelectedElement(),a=n.getElementForBookmarkId(r.id);if(i!==a&&a)return t(`Bookmark name already exists.`)}]}function aO(e){let t=e.getSelectedElement();return!t||!HE(t)||!t.getCustomProperty(`bookmark`)?null:t}var oO=class extends F{static get pluginName(){return`Bookmark`}static get requires(){return[QD,rO,xD]}static get isOfficialPlugin(){return!0}},sO=class extends F{static get pluginName(){return`CKBoxUI`}static get isOfficialPlugin(){return!0}afterInit(){let e=this.editor;e.commands.get(`ckbox`)&&(e.ui.componentFactory.add(`ckbox`,()=>this._createFileToolbarButton()),e.ui.componentFactory.add(`menuBar:ckbox`,()=>this._createFileMenuBarButton()),e.plugins.has(`ImageInsertUI`)&&e.plugins.get(`ImageInsertUI`).registerIntegration({name:`assetManager`,observable:()=>e.commands.get(`ckbox`),buttonViewCreator:()=>this._createImageToolbarButton(),formViewCreator:()=>this._createImageDropdownButton(),menuBarButtonViewCreator:e=>this._createImageMenuBarButton(e?`insertOnly`:`insertNested`)}))}_createButton(e){let t=this.editor,n=t.locale,r=new e(n),i=t.commands.get(`ckbox`);return r.bind(`isOn`,`isEnabled`).to(i,`value`,`isEnabled`),r.on(`execute`,()=>{t.execute(`ckbox`)}),r}_createFileToolbarButton(){let e=this.editor.locale.t,t=this._createButton(H);return t.icon=a_,t.label=e(`Open file manager`),t.tooltip=!0,t}_createImageToolbarButton(){let e=this.editor.locale.t,t=this.editor.plugins.get(`ImageInsertUI`),n=this._createButton(H);return n.icon=z_,n.bind(`label`).to(t,`isImageSelected`,t=>e(t?`Replace image with file manager`:`Insert image with file manager`)),n.tooltip=!0,n}_createImageDropdownButton(){let e=this.editor.locale.t,t=this.editor.plugins.get(`ImageInsertUI`),n=this._createButton(H);return n.icon=z_,n.withText=!0,n.bind(`label`).to(t,`isImageSelected`,t=>e(t?`Replace with file manager`:`Insert with file manager`)),n.on(`execute`,()=>{t.dropdownView.isOpen=!1}),n}_createFileMenuBarButton(){let e=this.editor.locale.t,t=this._createButton(U);return t.icon=a_,t.withText=!0,t.label=e(`File`),t}_createImageMenuBarButton(e){let t=this.editor.locale.t,n=this.editor.locale.t,r=this._createButton(U);switch(r.icon=z_,r.withText=!0,e){case`insertOnly`:r.label=t(`Image`);break;case`insertNested`:r.label=n(`With file manager`);break}return r}};function cO(e){return e=e.replace(/&/g,`&`).replace(//g,`>`).replace(/\r?\n\r?\n/g,`