`),e}function ix(e){return e.replace(/(\s+)<\/span>/g,(e,t)=>1==t.length?" ":t).replace(//g,"")}const nx=["figcaption","li"],sx=["ol","ul"];function ox(e,t){if(t.is("$text")||t.is("$textProxy"))return t.data;if(t.is("element","img")&&t.hasAttribute("alt"))return t.getAttribute("alt");if(t.is("element","br"))return"\n";let i="",n=null;for(const s of t.getChildren())i+=ax(s,n)+ox(e,s),n=s;if(t.is("rawElement")){const n=document.implementation.createHTMLDocument("").createElement("div");t.render(n,e),i+=rx(n)}return i}function rx(e){let t="";if(e.nodeType===Node.TEXT_NODE)return e.textContent;if("BR"===e.tagName)return"\n";for(const i of e.childNodes)t+=rx(i);return t}function ax(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||sx.includes(e.name)&&sx.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?nx.includes(e.name)||nx.includes(t.name)?"\n":e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")||t.is("element")&&t.getCustomProperty("dataPipeline:transparentRendering")?"":"\n\n":"":""}class lx extends $n{_markersToCopy=new Map;static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t,i=e=>e.model.getSelectedContent(e.model.document.selection)){return this.editor.model.change(n=>{const s=n.model.document.selection;n.setSelection(t);const o=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),r=i(n),a=this._removeFakeMarkersInsideElement(n,r);for(const[e,t]of Object.entries(o)){a[e]||=n.createRangeIn(r);for(const e of t)n.remove(e)}r.markers.clear();for(const[e,t]of Object.entries(a))r.markers.set(e,t);return n.setSelection(s),r})}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(e=>{const n=this._insertFakeMarkersElements(e,i),s=t(e),o=this._removeFakeMarkersInsideElement(e,s);for(const t of Object.values(n).flat())e.remove(t);for(const[t,i]of Object.entries(o))e.model.markers.has(t)||e.addMarker(t,{usingOperation:!0,affectsData:!0,range:i});return s})}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,i={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const n=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:n}=i;return"all"===n||n.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const n=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,i){const n=Array.from(t.getRanges()),s=new Set(n.flatMap(t=>Array.from(e.model.markers.getMarkersIntersectingRange(t))));return Array.from(s).filter(e=>{if(!this._isMarkerCopyable(e.name,i))return!1;const{copyPartiallySelected:t}=this._getMarkerClipboardConfig(e.name);if(!t){const t=e.getRange();return n.some(e=>e.containsRange(t,!0))}return!0}).map(e=>({name:"dragstart"===i?this._getUniqueMarkerName(e.name):e.name,range:e.getRange()}))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(([e,n])=>{if(!this._hasMarkerConfiguration(e))return[{name:e,range:n}];if(this._isMarkerCopyable(e,t)){const t=this._getMarkerClipboardConfig(e),s=i.markers.has(e)&&"$graveyard"===i.markers.get(e).getRange().root.rootName;return(t.duplicateOnPaste||s)&&(e=this._getUniqueMarkerName(e)),[{name:e,range:n}]}return[]})}_insertFakeMarkersElements(e,t){const i={},n=t.flatMap(e=>{const{start:t,end:i}=e.range;return[{position:t,marker:e,type:"start"},{position:i,marker:e,type:"end"}]}).sort(({position:e},{position:t})=>e.isBefore(t)?1:-1);for(const{position:t,marker:s,type:o}of n){const n=e.createElement("$marker",{"data-name":s.name,"data-type":o});i[s.name]||(i[s.name]=[]),i[s.name].push(n),e.insert(n,t)}return i}_removeFakeMarkersInsideElement(e,t){const i=this._getAllFakeMarkersFromElement(e,t).reduce((t,i)=>{const n=i.markerElement&&e.createPositionBefore(i.markerElement);let s=t[i.name],o=!1;if(s?.start&&s?.end){this._getMarkerClipboardConfig(i.name).duplicateOnPaste?t[this._getUniqueMarkerName(i.name)]=t[i.name]:o=!0,s=null}return o||(t[i.name]={...s,[i.type]:n}),i.markerElement&&e.remove(i.markerElement),t},{});return vt(i,i=>new yr(i.start||e.createPositionFromPath(t,[0]),i.end||e.createPositionAt(t,"end")))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap(({item:e})=>{if(!e.is("element","$marker"))return[];const t=e.getAttribute("data-name"),i=e.getAttribute("data-type");return[{markerElement:e,name:t,type:i}]}),n=[],s=[];for(const e of i){if("end"===e.type){i.some(t=>t.name===e.name&&"start"===t.type)||n.push({markerElement:null,name:e.name,type:"start"})}if("start"===e.type){i.some(t=>t.name===e.name&&"end"===t.type)||s.unshift({markerElement:null,name:e.name,type:"end"})}}return[...n,...i,...s]}_getUniqueMarkerName(e){const t=e.split(":"),i=A().substring(1,6);return 3===t.length?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}}class cx extends $n{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[lx]}init(){this.editor.editing.view.addObserver(ex),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===i},()=>{const s=n._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:i})})}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",(t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()},{priority:"highest"}),this.listenTo(n,"clipboardInput",(e,t)=>{const n=t.dataTransfer;let s;if(t.content)s=t.content;else{let e="";n.getData("text/html")?e=ix(n.getData("text/html")):n.getData("text/plain")&&(e=tx(n.getData("text/plain"))),s=this.editor.data.htmlProcessor.toView(e)}const o=new C(this,"inputTransformation"),r=n.getData("application/ckeditor5-editor-id")||null;this.fire(o,{content:s,dataTransfer:n,sourceEditorId:r,targetRanges:t.targetRanges,method:t.method}),o.stop.called&&e.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change(()=>{this.fire("contentInsertion",{content:n,method:i.method,sourceEditorId:i.sourceEditorId,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(e,t)=>{t.resultRange=s._pasteFragmentWithMarkers(t.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",(t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(t,n)=>{const s=e.data.toView(n.content,{isClipboardPipeline:!0});i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:s,method:n.method})},{priority:"low"}),this.listenTo(i,"clipboardOutput",(i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",ox(e.data.htmlProcessor.domConverter,n.content)),n.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}const ux=xi("px");class dx extends hh{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",e=>!e)],style:{left:e.to("left",e=>ux(e)),top:e.to("top",e=>ux(e)),width:e.to("width",e=>ux(e))}}})}}class hx extends $n{removeDropMarkerDelayed=In(()=>this.removeDropMarker(),40);_updateDropMarkerThrottled=it(e=>this._updateDropMarker(e),40);_reconvertMarkerThrottled=it(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0);_dropTargetLineView=new dx;_domEmitter=new(ni());_scrollables=new Map;static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,n,s,o){this.removeDropMarkerDelayed.cancel();const r=mx(this.editor,e,t,i,n,s,o);return r?o&&o.containsRange(r)||r&&!this.editor.model.canEditAt(r)?(this.removeDropMarker(),null):(this._updateDropMarkerThrottled(r),r):null}getFinalDropRange(e,t,i,n,s,o){const r=mx(this.editor,e,t,i,n,s,o);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(e=>{e.removeMarker("drop-target")})}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change(t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(e){const t=this.toDomElement(e);return t.append("",e.createElement("span"),""),t})}_updateDropTargetLine(t){const i=this.editor.editing,n=t.start.nodeBefore,s=t.start.nodeAfter,o=t.start.parent,r=n?i.mapper.toViewElement(n):null,a=r?i.view.domConverter.mapViewToDom(r):null,l=s?i.mapper.toViewElement(s):null,c=l?i.view.domConverter.mapViewToDom(l):null,u=i.mapper.toViewElement(o);if(!u)return;const d=i.view.domConverter.mapViewToDom(u),h=this._getScrollableRect(u),{scrollX:m,scrollY:g}=e.window,f=a?new pi(a):null,p=c?new pi(c):null,b=new pi(d).excludeScrollbarsAndBorders(),w=f?f.bottom:b.top,v=p?p.top:b.bottom,_=e.window.getComputedStyle(d),y=w<=v?(w+v)/2:v;if(h.topa.schema.checkChild(o,e))){if(a.schema.checkChild(o,"$text"))return a.createRange(o);if(t)return fx(e,bx(e,t.parent),n,s)}}}else if(a.schema.isInline(c))return fx(e,c,n,s);if(a.schema.isBlock(c))return fx(e,c,n,s);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter(t=>t.is("element")&&!gx(e,t));let i=0,o=t.length;if(0==o)return a.createRange(a.createPositionAt(c,"end"));for(;i{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),n.isAndroid&&this.forceDisabled("noAndroidSupport"),t.plugins.has("BlockToolbar")){const i=t.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(i,"dragstart",(e,t)=>this._handleBlockDragStart(t)),this._domEmitter.listenTo(e.document,"dragover",(e,t)=>this._handleBlockDragging(t)),this._domEmitter.listenTo(e.document,"drop",(e,t)=>this._handleBlockDragging(t)),this._domEmitter.listenTo(e.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&i.setAttribute("draggable","true"),this.on("change:isEnabled",(e,t,n)=>{i.setAttribute("draggable",n?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,s=Array.from(i.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change(e=>e.setSelection(o)),this._isBlockDragging=!0,n.focus(),n.getObserver(ex).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),s=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&s.getObserver(ex).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class vx extends $n{_draggedRange;_draggingUid;_draggableElement;_clearDraggableAttributesDelayed=In(()=>this._clearDraggableAttributes(),40);_blockMode=!1;_domEmitter=new(ni());_previewContainer;static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[cx,qk,hx,wx]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(ex),t.addObserver(Vc),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(e,t,i)=>{i||this._finalizeDragging(!1)}),n.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const t=this.editor,i=t.model,s=t.editing.view,o=s.document,r=t.plugins.get(hx);this.listenTo(o,"dragstart",(e,n)=>{if(n.target?.is("editableElement"))return void n.preventDefault();if(this._prepareDraggedRange(n.target),!this._draggedRange)return void n.preventDefault();this._draggingUid=A();const s=this.isEnabled&&t.model.canEditAt(this._draggedRange);n.dataTransfer.effectAllowed=s?"copyMove":"copy",n.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const o=i.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(n.dataTransfer,o,"dragstart");const{dataTransfer:r,domTarget:a,domEvent:l}=n,{clientX:c}=l;this._updatePreview({dataTransfer:r,domTarget:a,clientX:c}),n.stopPropagation(),s||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(o,"dragend",(e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)},{priority:"low"}),this._domEmitter.listenTo(e.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(o,"dragenter",()=>{this.isEnabled&&s.focus()}),this.listenTo(o,"dragleave",()=>{r.removeDropMarkerDelayed()}),this.listenTo(o,"dragging",(e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:s}=t.domEvent;r.updateDropMarker(t.target,t.targetRanges,i,s,this._blockMode,this._draggedRange)?(this._draggedRange||(t.dataTransfer.dropEffect="copy"),n.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()):t.dataTransfer.dropEffect="none"},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(hx);this.listenTo(t,"clipboardInput",(t,n)=>{if("drop"!=n.method)return;const{clientX:s,clientY:o}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,s,o,this._blockMode,this._draggedRange);if(!r)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==_x(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(r)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(cx);e.on("contentInsertion",(e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map(e=>this.editor.editing.mapper.toModelRange(e));this.editor.model.change(e=>e.setSelection(i))},{priority:"high"}),e.on("contentInsertion",(e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==_x(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"pointerdown",(s,o)=>{if(n.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=yx(o.target);if(n.isBlink&&!e.isReadOnly&&!r&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&pk(e)||(r=i.selection.editableElement)}r&&(t.change(e=>{e.setAttribute("draggable","true",r)}),this._draggableElement=e.editing.mapper.toModelElement(r))}),this.listenTo(i,"pointerup",()=>{n.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_finalizeDragging(e){const t=this.editor,i=t.model;if(t.plugins.get(hx).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop")}this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change(e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,s=e?yx(e):null;if(s){const e=t.editing.mapper.toModelElement(s);if(this._draggedRange=Fr.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const o=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==o.length)return void(this._draggedRange=Fr.fromRange(r));const a=kx(i,o);if(o.length>1)this._draggedRange=Fr.fromRange(a),this._blockMode=!0;else if(1==o.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=Fr.fromRange(e?a:r),this._blockMode=e}i.change(e=>e.setSelection(this._draggedRange.toRange()))}_updatePreview({dataTransfer:t,domTarget:i,clientX:s}){const o=this.editor.editing.view,r=o.document.selection.editableElement,a=o.domConverter.mapViewToDom(r),l=e.window.getComputedStyle(a);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=Qt(e.document,"div",{style:"position: fixed; left: -999999px;"}),e.document.body.appendChild(this._previewContainer));const c=Qt(e.document,"div");c.className="ck ck-content ck-clipboard-preview";const u=new pi(a),d=parseFloat(l.paddingLeft),h=parseFloat(l.paddingRight),m=parseFloat(l.width)-d-h;if(a.contains(i)){if(!n.isiOS)return;c.style.maxWidth=`${m}px`,c.style.padding="10px",c.style.minWidth="200px",c.style.minHeight="20px",c.style.boxSizing="border-box",c.style.backgroundColor="var(--ck-color-base-background)"}else if(n.isiOS)c.style.width=`${m}px`,c.style.backgroundColor="var(--ck-color-base-background)";else{const e=u.left-s+d;c.style.width=`${m+e}px`,c.style.paddingLeft=`${e}px`}o.domConverter.setContentOf(c,t.getData("text/html")),t.setDragImage(c,0,0),this._previewContainer.appendChild(c)}}function _x(e){return n.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function yx(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(pk);if(pk(e))return e;const t=e.findAncestor(e=>pk(e)||e.is("editableElement"));return pk(t)?t:null}function kx(e,t){const i=t[0],n=t[t.length-1],s=i.getCommonAncestor(n),o=e.createPositionBefore(i),r=e.createPositionAfter(n);if(s&&s.is("element")&&!e.schema.isLimit(s)){const t=e.createRangeOn(s),i=o.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return kx(e,[s])}return e.createRange(o,r)}class Cx extends $n{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[cx]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=t.document.selection;i.addObserver(ex),e.plugins.get(cx).on("contentInsertion",(e,i)=>{(function(e,t){let i=t.createRangeIn(e);if(1==e.childCount){const n=e.getChild(0);n.is("element")&&t.schema.isBlock(n)&&!t.schema.isObject(n)&&!t.schema.isLimit(n)&&(i=t.createRangeIn(n))}for(const e of i.getItems()){if(!t.schema.isInline(e))return!1;if(Array.from(e.getAttributeKeys()).find(e=>t.schema.getAttributeProperties(e).isFormatting))return!1}return!0})(i.content,t)&&t.change(e=>{const s=Array.from(n.getAttributes()).filter(([e])=>t.schema.getAttributeProperties(e).isFormatting);n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),s.push(...n.getAttributes());const o=e.createRangeIn(i.content);for(const i of o.getItems())for(const n of s)t.schema.checkAttribute(i,n[0])&&e.setAttribute(n[0],n[1],i)})})}}class xx extends $n{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[lx,cx,vx,Cx]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}const Ax={autoRefresh:!0},Tx=36e5;class Ex extends(Dt()){_refresh;_options;_tokenRefreshTimeout;_isDestroyed=!1;constructor(e,t={}){if(super(),!e)throw new I("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),this._refresh="function"==typeof e?e:()=>{return t=e,new Promise((e,i)=>{const n=new XMLHttpRequest;n.open("GET",t),n.addEventListener("load",()=>{const t=n.status,s=n.response;return t<200||t>299?i(new I("token-cannot-download-new-token",null)):e(s)}),n.addEventListener("error",()=>i(new Error("Network Error"))),n.addEventListener("abort",()=>i(new Error("Abort"))),n.send()});var t},this._options={...Ax,...t}}init(){return new Promise((e,t)=>{this.value?(this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)):this.refreshToken().then(e).catch(t)})}refreshToken(){const e=this._options.autoRefresh;return this._refresh().then(t=>(this._validateTokenValue(t),this.set("value",t),e&&this._registerRefreshTokenTimeout(),this)).catch(t=>{throw P("token-refresh-failed",{autoRefresh:e}),e&&this._registerRefreshTokenTimeout(5e3),t})}destroy(){this._isDestroyed=!0,clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t="string"==typeof e,i=!/^".*"$/.test(e),n=t&&3===e.split(".").length;if(!i||!n)throw new I("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(e){if(clearTimeout(this._tokenRefreshTimeout),this._isDestroyed)return;const t=e||this._getTokenRefreshTimeoutTime();this._tokenRefreshTimeout=setTimeout(()=>{this.refreshToken()},t)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));if(!t)return Tx;t>2147483647&&console.warn("Token expiration time exceeds 32-bit integer range. This might cause unpredictable token refresh timing. Token expiration time should always be provided in seconds.",{tokenExpireTime:t});return Math.floor((1e3*t-Date.now())/2)}catch{return Tx}}static create(e,t={}){return new Ex(e,t).init()}}const Sx=/^data:(\S*?);base64,/;class Ix extends(z()){file;xhr;_token;_apiAddress;constructor(e,t,i){if(super(),!e)throw new I("fileuploader-missing-file",null);if(!t)throw new I("fileuploader-missing-token",null);if(!i)throw new I("fileuploader-missing-api-address",null);this.file=function(e){if("string"!=typeof e)return!1;return!!e.match(Sx)?.length}(e)?function(e,t=512){try{const i=e.match(Sx)[1],n=atob(e.replace(Sx,"")),s=[];for(let e=0;ee(i)),this}onError(e){return this.once("error",(t,i)=>e(i)),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this.xhr,t=e=>()=>this.fire("error",e);e.addEventListener("error",t("Network Error")),e.addEventListener("abort",t("Abort")),e.upload&&e.upload.addEventListener("progress",e=>{e.lengthComputable&&this.fire("progress",{total:e.total,uploaded:e.loaded})}),e.addEventListener("load",()=>{const t=e.status,i=e.response;if(t<200||t>299)return this.fire("error",i.message||i.error)})}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise((i,n)=>{t.addEventListener("load",()=>{const e=t.status,s=t.response;return e<200||e>299?s.message?n(new I("fileuploader-uploading-data-failed",this,{message:s.message})):n(s.error):i(s)}),t.addEventListener("error",()=>n(new Error("Network Error"))),t.addEventListener("abort",()=>n(new Error("Abort"))),t.send(e)})}}class Px{_token;_apiAddress;constructor(e,t){if(!e)throw new I("uploadgateway-missing-token",null);if(!t)throw new I("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}upload(e){return new Ix(e,this._token,this._apiAddress)}}class Vx extends Xn{static get pluginName(){return"CloudServicesCore"}static get isOfficialPlugin(){return!0}createToken(e,t){return new Ex(e,t)}createUploadGateway(e,t){return new Px(e,t)}}class Ox extends Xn{tokenUrl;uploadUrl;webSocketUrl;bundleVersion;autoRefresh=!0;token=null;_tokens=new Map;static get pluginName(){return"CloudServices"}static get isOfficialPlugin(){return!0}static get requires(){return[Vx]}async init(){const e=this.context.config.get("cloudServices")||{};for(const[t,i]of Object.entries(e))this[t]=i;if(!this.tokenUrl)return void(this.token=null);const t=this.context.plugins.get("CloudServicesCore").createToken(this.tokenUrl,{autoRefresh:this.autoRefresh});try{this.token=await t.init(),this._tokens.set(this.tokenUrl,this.token)}catch(e){throw t.destroy(),e}}async registerTokenUrl(e){if(this._tokens.has(e))return this.getTokenFor(e);const t=this.context.plugins.get("CloudServicesCore"),i=await t.createToken(e,{autoRefresh:this.autoRefresh}).init();return this._tokens.set(e,i),i}getTokenFor(e){const t=this._tokens.get(e);if(!t)throw new I("cloudservices-token-not-registered",this);return t}destroy(){super.destroy();for(const e of this._tokens.values())e.destroy()}}function Rx(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function Bx(e,t,i){const n={};for(const s of e)if("class"===t){n[s[t].split(" ").shift()]=s[i]}else n[s[t]]=s[i];return n}function Lx(e){return e.data.match(/^(\s*)/)[0]}function Mx(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),s=n.reduce((t,i,s)=>(t.push(i),s!e.isEqual(r))&&i.push(r)}return i}function Nx(e){const t=fn(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function Dx(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}function zx(e,t,i,n){const s=Bx(t,"language","label"),o=i.getAttribute("language");if(o in s){const t=s[o];return e("enter"===n?"Entering %0 code snippet":"Leaving %0 code snippet",t)}return e("enter"===n?"Entering code snippet":"Leaving code snippet")}function Hx(e,t){for(e.textNode&&(e=t.createPositionBefore(e.textNode));e.nodeBefore&&!e.nodeBefore.is("element","softBreak");)e=t.createPositionBefore(e.nodeBefore);const i=e.nodeAfter;return i&&i.is("$text")?i:null}class qx extends Gn{_lastLanguage;constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,s=Rx(t)[0],o=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,s.language);i.change(e=>{r?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)})}_getValue(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());return!!!!e?.is("element","codeBlock")&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=fn(e.getSelectedBlocks());return!!i&&Dx(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,s=t.filter(e=>Dx(n,e));for(const t of s)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter(e=>!n.checkChild(t,e)).forEach(t=>e.remove(t));s.reverse().forEach((t,i)=>{const n=s[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))})}_removeCodeBlock(e,t){const i=t.filter(e=>e.is("element","codeBlock"));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class Ux extends Gn{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=Fx(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}})}_checkEnabled(){return!!this._indentSequence&&Nx(this.editor.model.document.selection)}}class Wx extends Gn{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(()=>{const t=Fx(e);for(const i of t){const t=$x(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!Nx(e.document.selection)&&Fx(e).some(t=>$x(e,t,this._indentSequence))}}function $x(e,t,i){const n=Hx(t,e);if(!n)return null;const s=Lx(n),o=s.lastIndexOf(i);if(o+i.length!==s.length)return null;if(-1===o)return null;const{parent:r,startOffset:a}=n;return e.createRange(e.createPositionAt(r,a+o),e.createPositionAt(r,a+o+i.length))}function jx(e,t,i=!1){const n=Bx(t,"language","class"),s=Bx(t,"language","label");return(t,o,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(o.item,"insert"))return;const u=o.item.getAttribute("language"),d=l.toViewPosition(e.createPositionBefore(o.item)),h={};i&&(h["data-language"]=s[u],h.spellcheck="false");const m=n[u]?{class:n[u]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",h,g);a.insert(d,f),l.bindElements(o.item,g)}}function Gx(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:s,mapper:o,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=o.toViewPosition(e.createPositionBefore(i.item));s.insert(a,s.createText("\n"))}}function Kx(e,t){const i=Bx(t,"class","language"),n=t[0].language;return(e,t,s)=>{const o=t.viewItem,r=o.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=s;if(!a.test(o,{name:!0}))return;const c=l.createElement("codeBlock"),u=[...o.getClassNames()];u.length||u.push("");for(const e of u){const t=i[e];if(t){a.consume(o,{classes:[e]}),l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),s.convertChildren(o,c),s.safeInsert(c,t.modelCursor)&&(a.consume(o,{name:!0}),s.updateConversionResult(c,t))}}function Jx(){return(e,t,{consumable:i,writer:n})=>{let s=t.modelCursor;if(!i.test(t.viewItem))return;if(!s.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map(e=>n.createText(e)),r=o[o.length-1];for(const e of o)if(n.insert(e,s),s=s.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,s),s=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,s),t.modelCursor=s}}function Qx(){return(e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const s=Array.from(n.getChildren()),o=s.find(e=>e.is("element","code"));if(o)for(const e of s)e!==o&&e.is("$text")&&i.consume(e,{name:!0})}}const Yx="paragraph";class Zx extends $n{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[ik]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"go",label:"Go"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,s=Rx(e);e.commands.add("codeBlock",new qx(e)),e.commands.add("indentCodeBlock",new Ux(e)),e.commands.add("outdentCodeBlock",new Wx(e)),this.listenTo(n.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),t.addAttributeCheck((e,i)=>{const n=e.getItem(e.length-2);if(t.getAttributeProperties(i).isFormatting&&n&&"codeBlock"==n.name)return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",jx(i,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",jx(i,s)),e.data.downcastDispatcher.on("insert:softBreak",Gx(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",Kx(0,s)),e.data.upcastDispatcher.on("text",(e,t,{consumable:i,writer:n})=>{let s=t.modelCursor;if(!i.test(t.viewItem))return;if(!s.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map(e=>n.createText(e)),r=o[o.length-1];for(const e of o)if(n.insert(e,s),s=s.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,s),s=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,s),t.modelCursor=s}),e.data.upcastDispatcher.on("element:pre",Qx(),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,n)=>{let s=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(s=e.editing.mapper.toModelRange(n.targetRanges[0])),!s.start.parent.is("element","codeBlock"))return;const o=n.dataTransfer.getData("text/plain"),r=new Oc(e.editing.view.document);n.content=Mx(r,o)}),e.plugins.has("ClipboardPipeline")&&e.plugins.get(cx).on("contentInsertion",(i,n)=>{const s=e.model,o=s.document.selection;o.anchor.parent.is("element","codeBlock")&&s.change(e=>{const i=e.createRangeIn(n.content);for(const n of[...i.getItems()])n.is("node")&&!t.checkChild(o.anchor,n)&&e.remove(n)})}),this.listenTo(i,"getSelectedContent",(e,[n])=>{const s=n.anchor;!n.isCollapsed&&s.parent.is("element","codeBlock")&&s.hasSameParentAs(n.focus)&&i.change(i=>{const o=e.return;if(s.parent.is("element")&&(o.childCount>1||n.containsEntireContent(s.parent))){const t=i.createElement("codeBlock",s.parent.getAttributes());i.append(o,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=o.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)})})}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",(t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!eA(r))return!1;return e.model.change(t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,Yx),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)}),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeBefore;let a;if(t||!n.selection.isCollapsed||!o.isAtEnd||!r||!r.previousSibling)return!1;if(eA(r)&&eA(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(Xx(r)&&eA(r.previousSibling)&&eA(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(Xx(r)&&eA(r.previousSibling)&&Xx(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&eA(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change(t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,Yx),e.model.schema.removeDisallowedAttributes([i],t)}),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document;let n;const s=Hx(i.selection.getLastPosition(),t);s&&s.is("$text")&&(n=Lx(s));e.model.change(t=>{e.execute("shiftEnter"),n&&t.insertText(n,i.selection.anchor)})}(e),i.preventDefault(),t.stop())},{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,n=Rx(this.editor);let s=null;e.document.selection.on("change:range",()=>{const o=e.document.selection.focus.parent;t&&s!==o&&o.is("element")&&(s&&s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(zx(i,n,s,"leave")),o.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(zx(i,n,o,"enter")),s=o)})}}function Xx(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function eA(e){return e&&e.is("element","softBreak")}class tA extends $n{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=Rx(e),s=this._getLanguageListItemDefinitions(n),o=e.commands.get("codeBlock");i.add("codeBlock",i=>{const n=ow(i,sw),r=n.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:mm,isToggleable:!0}),r.bind("isOn").to(o,"value",e=>!!e),r.on("execute",()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()}),n.on("execute",t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),n.class="ck-code-block-dropdown",n.bind("isEnabled").to(o),uw(n,s,{role:"menu",ariaLabel:a}),n}),i.add("menuBar:codeBlock",i=>{const n=new d_(i);n.buttonView.set({role:"menuitem",label:t("Code block"),icon:mm}),n.bind("isEnabled").to(o);const r=new h_(i);r.set({ariaLabel:t("Insert code block")});for(const t of s){const s=new hv(i,n),a=new Mp(i);a.bind(...Object.keys(t.model)).to(t.model),a.set({isToggleable:!0,role:"menuitemcheckbox"}),a.delegate("execute").to(n),a.on("execute",()=>{e.execute("codeBlock",{language:t.model._codeBlockLanguage,forceValue:o.value!=t.model._codeBlockLanguage}),e.editing.view.focus()}),s.children.add(a),r.items.add(s)}return n.panelView.children.add(r),n})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new gn;for(const n of e){const e={type:"button",model:new Hv({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",t=>t===e.model._codeBlockLanguage),i.add(e)}return i}}class iA extends $n{static get requires(){return[Zx,tA]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}}class nA extends $n{_uploadGateway;static get pluginName(){return"CloudServicesUploadAdapter"}static get isOfficialPlugin(){return!0}static get requires(){return["CloudServices",kd]}init(){const e=this.editor,t=e.plugins.get("CloudServices"),i=t.token,n=t.uploadUrl;if(!i)return;const s=e.plugins.get("CloudServicesCore");this._uploadGateway=s.createUploadGateway(i,n),e.plugins.get(kd).createUploadAdapter=e=>new sA(this._uploadGateway,e)}}class sA{uploadGateway;loader;fileUploader;constructor(e,t){this.uploadGateway=e,this.loader=t}upload(){return this.loader.file.then(e=>(this.fileUploader=this.uploadGateway.upload(e),this.fileUploader.on("progress",(e,t)=>{this.loader.uploadTotal=t.total,this.loader.uploaded=t.uploaded}),this.fileUploader.send()))}abort(){this.fileUploader.abort()}}class oA extends $n{static get pluginName(){return"EasyImage"}static get isOfficialPlugin(){return!0}static get requires(){return[nA,"ImageUpload"]}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")||e.plugins.has("ImageInlineEditing")||P("easy-image-image-feature-missing",e)}}class rA extends Pv{view;constructor(e,t){super(e),this.view=t}get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,i=e.editing.view,n=t.editable,s=i.document.getRoot();n.name=s.rootName,t.render();const o=n.element;this.setEditableElement(n.name,o),n.bind("isFocused").to(this.focusTracker),i.attachDomRoot(o),this._initPlaceholder(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.config.get("placeholder");if(n){const e="string"==typeof n?n:n[i.rootName];e&&(i.placeholder=e)}ns({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}class aA extends Ov{editable;menuBarView;constructor(e,t,i,n){super(e),this.editable=new Lv(e,t,i,{label:n}),this.menuBarView=new p_(e),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild(this.editable),this.registerChild(this.menuBarView)}}class lA extends(wd(fd)){static get editorName(){return"BalloonEditor"}ui;constructor(e,t={}){if(!cA(e)&&void 0!==t.initialData)throw new I("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return cA(e)?li(e):e}(e)),cA(e)&&(this.sourceElement=e,vd(this,e));const i=this.config.get("plugins");i.push(s_),this.config.set("plugins",i),this.config.define("balloonToolbar",this.config.get("toolbar")),this.model.document.createRoot();const n=new aA(this.locale,this.editing.view,this.sourceElement,this.config.get("label"));this.ui=new rA(this,n),bd(this)}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(cA(e)&&"TEXTAREA"===e.tagName)throw new I("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init()).then(()=>n.data.init(n.config.get("initialData"))).then(()=>n.fire("ready")).then(()=>n))})}}function cA(e){return xt(e)}class uA extends Pv{view;_toolbarConfig;_elementReplacer;constructor(e,t){super(e),this.view=t,this._toolbarConfig=Zb(e.config.get("toolbar")),this._elementReplacer=new $t,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,s=i.editable,o=n.document.getRoot();s.name=o.rootName,i.render();const r=s.element;this.setEditableElement(s.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),i.menuBarView&&this.initMenuBar(i.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",({visualTop:e})=>e||0),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let s;const o=e.config.get("placeholder");o&&(s="string"==typeof o?o:o[this.view.editable.name]),!s&&n&&"textarea"===n.tagName.toLowerCase()&&(s=n.getAttribute("placeholder")),s&&(i.placeholder=s),ns({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:e}=this.view,t=this.editor.plugins.get("ContextualBalloon");t.on("getPositionOptions",t=>{const i=t.return;if(!i||!e.isSticky||!e.element)return;const n=new pi(e.element).height,s="function"==typeof i.target?i.target():i.target,o="function"==typeof i.limiter?i.limiter():i.limiter;if(s&&o&&new pi(s).height>=new pi(o).height-n)return;const r={...i.viewportOffsetConfig},a=(r.top||0)+n;t.return={...i,viewportOffsetConfig:{...r,top:a}}},{priority:"low"});const i=()=>{t.visibleView&&t.updatePosition()};this.listenTo(e,"change:isSticky",i),this.listenTo(this.editor.ui,"change:viewportOffset",i)}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new pi(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout(()=>{this.stopListening(n,"change:isSticky",e)},20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const e=this.view.stickyPanel,t=this.editor.plugins.get("Dialog");t.on("show",()=>{const i=t.view;i.on("moveTo",(t,n)=>{if(!e.isSticky||i.wasMoved||i.isModal)return;const s=new pi(e.contentPanelElement);n[1]{const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init(mA(e)?e:null)).then(()=>n.data.init(n.config.get("initialData"))).then(()=>n.fire("ready")).then(()=>n))})}}function mA(e){return xt(e)}class gA extends Pv{view;constructor(e,t){super(e),this.view=t}init(){const e=this.editor,t=this.view,i=e.editing.view,n=t.editable,s=i.document.getRoot();n.name=s.rootName,t.render();const o=n.element;this.setEditableElement(n.name,o),t.editable.bind("isFocused").to(this.focusTracker),i.attachDomRoot(o),this._initPlaceholder(),this._initToolbar(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view;t.toolbar.fillFromConfig(e.config.get("toolbar"),this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.config.get("placeholder");if(n){const e="string"==typeof n?n:n[i.rootName];e&&(i.placeholder=e)}ns({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}class fA extends Ov{toolbar;editable;menuBarView;constructor(e,t,i={}){super(e),this.toolbar=new ew(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.menuBarView=new p_(e),this.editable=new Lv(e,t,i.editableElement,{label:i.label}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.menuBarView,this.toolbar,this.editable])}}class pA extends(wd(fd)){static get editorName(){return"DecoupledEditor"}ui;constructor(e,t={}){if(!bA(e)&&void 0!==t.initialData)throw new I("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return bA(e)?li(e):e}(e)),bA(e)&&(this.sourceElement=e,vd(this,e)),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new fA(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:i,label:this.config.get("label")});this.ui=new gA(this,n)}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(bA(e)&&"TEXTAREA"===e.tagName)throw new I("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init()).then(()=>n.data.init(n.config.get("initialData"))).then(()=>n.fire("ready")).then(()=>n))})}}function bA(e){return xt(e)}class wA extends Pv{view;_toolbarConfig;constructor(e,t){super(e),this.view=t,this._toolbarConfig=Zb(e.config.get("toolbar"))}get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,i=e.editing.view,n=t.editable,s=i.document.getRoot();n.name=s.rootName,t.render();const o=n.element;this.setEditableElement(n.name,o),n.bind("isFocused").to(this.focusTracker),i.attachDomRoot(o),this._initPlaceholder(),this._initToolbar(),t.menuBarView&&this.initMenuBar(t.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view,i=t.editable.element,n=t.toolbar;t.panel.bind("isVisible").to(this.focusTracker,"isFocused"),t.bind("viewportTopOffset").to(this,"viewportOffset",({visualTop:e})=>e||0),t.listenTo(e.ui,"update",()=>{t.panel.isVisible&&t.panel.pin({target:i,positions:t.panelPositions})}),n.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(n)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.config.get("placeholder");if(n){const e="string"==typeof n?n:n[i.rootName];e&&(i.placeholder=e)}ns({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}const vA=xi("px");class _A extends Ov{toolbar;panel;panelPositions;editable;_resizeObserver;constructor(e,t,i,n={}){super(e),this.toolbar=new ew(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull,isFloating:!0}),n.useMenuBar&&(this.menuBarView=new p_(e)),this.set("viewportTopOffset",0),this.panel=new Hp(e),this.panelPositions=this._getPanelPositions(),this.panel.extendTemplate({attributes:{class:"ck-toolbar-container"}}),this.editable=new Lv(e,t,i,{label:n.label}),this._resizeObserver=null}render(){super.render(),this.body.add(this.panel),this.registerChild(this.editable),this.menuBarView?this.panel.content.addMany([this.menuBarView,this.toolbar]):this.panel.content.add(this.toolbar);if(this.toolbar.options.shouldGroupWhenFull){const e=this.editable.element;this._resizeObserver=new ki(e,()=>{this.toolbar.maxWidth=vA(new pi(e).width)})}}destroy(){super.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getPanelPositionTop(e,t){let i;return i=e.top>t.height+this.viewportTopOffset?e.top-t.height:e.bottom>t.height+this.viewportTopOffset+50?this.viewportTopOffset:e.bottom,i}_getPanelPositions(){const e=[(e,t)=>({top:this._getPanelPositionTop(e,t),left:e.left,name:"toolbar_west",config:{withArrow:!1}}),(e,t)=>({top:this._getPanelPositionTop(e,t),left:e.left+e.width-t.width,name:"toolbar_east",config:{withArrow:!1}})];return"ltr"===this.locale.uiLanguageDirection?e:e.reverse()}}class yA extends(wd(fd)){static get editorName(){return"InlineEditor"}ui;constructor(e,t={}){if(!kA(e)&&void 0!==t.initialData)throw new I("editor-create-initial-data",null);super(t),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return kA(e)?li(e):e}(e)),this.model.document.createRoot(),kA(e)&&(this.sourceElement=e,vd(this,e));const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),s=new _A(this.locale,this.editing.view,this.sourceElement,{shouldToolbarGroupWhenFull:i,useMenuBar:n.isVisible,label:this.config.get("label")});this.ui=new wA(this,s),bd(this)}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(kA(e)&&"TEXTAREA"===e.tagName)throw new I("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init()).then(()=>n.data.init(n.config.get("initialData"))).then(()=>n.fire("ready")).then(()=>n))})}}function kA(e){return xt(e)}class CA extends Pv{view;_lastFocusedEditableElement;constructor(e,t){super(e),this.view=t,this._lastFocusedEditableElement=null}init(){this.view.render(),this.focusTracker.on("change:focusedElement",(e,t,i)=>{for(const e of Object.values(this.view.editables))i===e.element&&(this._lastFocusedEditableElement=e.element)}),this.focusTracker.on("change:isFocused",(e,t,i)=>{i||(this._lastFocusedEditableElement=null)});for(const e of Object.values(this.view.editables))this.addEditable(e);this._initToolbar(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}addEditable(e,t){const i=e.element;this.editor.editing.view.attachDomRoot(i,e.name),this.setEditableElement(e.name,i),e.bind("isFocused").to(this.focusTracker,"isFocused",this.focusTracker,"focusedElement",(e,t)=>!!e&&(t===i||this._lastFocusedEditableElement===i)),this._initPlaceholder(e,t)}removeEditable(e){const t=this.editor.editing.view;t.getDomRoot(e.name)&&t.detachDomRoot(e.name),e.unbind("isFocused"),this.removeEditableElement(e.name)}destroy(){super.destroy();for(const e of Object.values(this.view.editables))this.removeEditable(e);this.view.destroy()}_initToolbar(){const e=this.editor,t=this.view;t.toolbar.fillFromConfig(e.config.get("toolbar"),this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(e,t){if(!t){const i=this.editor.config.get("placeholder");i&&(t="string"==typeof i?i:i[e.name])}const i=this.editor.editing.view,n=i.document.getRoot(e.name);t&&(n.placeholder=t),ns({view:i,element:n,isDirectHost:!1,keepOnFocus:!0})}}class xA extends Ov{toolbar;editables;editable;menuBarView;_editingView;constructor(e,t,i,n={}){super(e),this._editingView=t,this.toolbar=new ew(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.menuBarView=new p_(e),this.editables={};for(const e of i){const t=n.editableElements?n.editableElements[e]:void 0;let{label:i}=n;"object"==typeof i&&(i=i[e]),this.createEditable(e,t,i)}this.editable=Object.values(this.editables)[0],this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}createEditable(e,t,i){const n=new Lv(this.locale,this._editingView,t,{label:i});return this.editables[e]=n,n.name=e,this.isRendered&&this.registerChild(n),n}removeEditable(e){const t=this.editables[e];this.isRendered&&this.deregisterChild(t),delete this.editables[e],t.destroy()}render(){super.render(),this.registerChild(Object.values(this.editables)),this.registerChild(this.toolbar),this.registerChild(this.menuBarView)}}class AA extends fd{static get editorName(){return"MultiRootEditor"}ui;sourceElements;_registeredRootsAttributesKeys=new Set;_readOnlyRootLocks=new Map;constructor(e,t={}){const i=Object.keys(e),n=0===i.length||"string"==typeof e[i[0]];if(n&&void 0!==t.initialData&&Object.keys(t.initialData).length>0)throw new I("editor-create-initial-data",null);if(super(t),this.sourceElements=n?{}:e,void 0===this.config.get("initialData")){const t={};for(const n of i)t[n]=TA(e[n]);this.config.set("initialData",t)}if(!n)for(const t of i)vd(this,e[t]);this.editing.view.document.roots.on("add",(e,t)=>{t.unbind("isReadOnly"),t.bind("isReadOnly").to(this.editing.view.document,"isReadOnly",e=>e||this._readOnlyRootLocks.has(t.rootName)),t.on("change:isReadOnly",(e,i,n)=>{const s=this.editing.view.createRangeIn(t);for(const e of s.getItems())e.is("editableElement")&&(e.unbind("isReadOnly"),e.isReadOnly=n)})});for(const e of i)this.model.document.createRoot("$root",e);if(this.config.get("lazyRoots"))for(const e of this.config.get("lazyRoots")){this.model.document.createRoot("$root",e)._isLoaded=!1}if(this.config.get("rootsAttributes")){const e=this.config.get("rootsAttributes");for(const[t,i]of Object.entries(e)){if(!this.model.document.getRoot(t))throw new I("multi-root-editor-root-attributes-no-root",null);for(const e of Object.keys(i))this.registerRootAttribute(e)}this.data.on("init",()=>{this.model.enqueueChange({isUndoable:!1},t=>{for(const[i,n]of Object.entries(e)){const e=this.model.document.getRoot(i);for(const[i,s]of Object.entries(n))null!==s&&t.setAttribute(i,s,e)}})})}const s={shouldToolbarGroupWhenFull:!this.config.get("toolbar.shouldNotGroupWhenFull"),editableElements:n?void 0:e,label:this.config.get("label")},o=new xA(this.locale,this.editing.view,i,s);this.ui=new CA(this,o),this.model.document.on("change:data",()=>{const e=this.model.document.differ.getChangedRoots();for(const t of e){const e=this.model.document.getRoot(t.name);"detached"==t.state&&this.fire("detachRoot",e)}for(const t of e){const e=this.model.document.getRoot(t.name);"attached"==t.state&&this.fire("addRoot",e)}}),this.listenTo(this.model,"canEditAt",(e,[t])=>{if(!t)return;let i=!1;for(const e of t.getRanges()){const t=e.root;if(this._readOnlyRootLocks.has(t.rootName)){i=!0;break}}i&&(e.return=!1,e.stop())},{priority:"high"}),this.decorate("loadRoot"),this.on("loadRoot",(e,[t])=>{const i=this.model.document.getRoot(t);if(!i)throw new I("multi-root-editor-load-root-no-root",this,{rootName:t});i._isLoaded&&(P("multi-root-editor-load-root-already-loaded"),e.stop())},{priority:"highest"}),function(e){const t=Un(e.config.get("licenseKey"));if(!t)return;Wn(t,"MRE")&&(e.enableReadOnlyMode(Symbol("invalidLicense")),e._showLicenseError("featureNotAllowed","Multi-root editor"))}(this)}destroy(){const e=this.config.get("updateSourceElementOnDestroy"),t={};for(const i of Object.keys(this.sourceElements))t[i]=e?this.getData({rootName:i}):"";return this.ui.destroy(),super.destroy().then(()=>{for(const e of Object.keys(this.sourceElements))Ci(this.sourceElements[e],t[e])})}addRoot(e,{data:t="",attributes:i={},elementName:n="$root",isUndoable:s=!1}={}){const o=s=>{const o=s.addRoot(e,n);t&&s.insert(this.data.parse(t,o),o,0);for(const e of Object.keys(i))this.registerRootAttribute(e),s.setAttribute(e,i[e],o)};s?this.model.change(o):this.model.enqueueChange({isUndoable:!1},o)}detachRoot(e,t=!1){t?this.model.change(t=>t.detachRoot(e)):this.model.enqueueChange({isUndoable:!1},t=>t.detachRoot(e))}createEditable(e,t,i){const n=this.ui.view.createEditable(e.rootName,void 0,i);return this.ui.addEditable(n,t),this.editing.view.forceRender(),n.element}detachEditable(e){const t=e.rootName,i=this.ui.view.editables[t];return this.ui.removeEditable(i),this.ui.view.removeEditable(t),i.element}loadRoot(e,{data:t="",attributes:i={}}={}){const n=this.model.document.getRoot(e);this.model.enqueueChange({isUndoable:!1},e=>{t&&e.insert(this.data.parse(t,n),n,0);for(const t of Object.keys(i))this.registerRootAttribute(t),e.setAttribute(t,i[t],n);n._isLoaded=!0,this.model.document.differ._bufferRootLoad(n)})}getFullData(e){const t={};for(const i of this.model.document.getRootNames())t[i]=this.data.get({...e,rootName:i});return t}getRootsAttributes(){const e={};for(const t of this.model.document.getRootNames())e[t]=this.getRootAttributes(t);return e}getRootAttributes(e){const t={},i=this.model.document.getRoot(e);for(const e of this._registeredRootsAttributesKeys)t[e]=i.hasAttribute(e)?i.getAttribute(e):null;return t}registerRootAttribute(e){this._registeredRootsAttributesKeys.has(e)||(this._registeredRootsAttributesKeys.add(e),this.editing.model.schema.extend("$root",{allowAttributes:e}))}disableRoot(e,t){if("$graveyard"==e)throw new I("multi-root-editor-cannot-disable-graveyard-root",this);const i=this._readOnlyRootLocks.get(e);if(i)i.add(t);else{this._readOnlyRootLocks.set(e,new Set([t]));this.editing.view.document.getRoot(e).isReadOnly=!0,Array.from(this.commands.commands()).forEach(e=>e.affectsData&&e.refresh())}}enableRoot(e,t){const i=this._readOnlyRootLocks.get(e);if(i&&i.has(t))if(1===i.size){this._readOnlyRootLocks.delete(e);this.editing.view.document.getRoot(e).isReadOnly=this.isReadOnly,Array.from(this.commands.commands()).forEach(e=>e.affectsData&&e.refresh())}else i.delete(t)}static create(e,t={}){return new Promise(i=>{for(const t of Object.values(e))if(EA(t)&&"TEXTAREA"===t.tagName)throw new I("editor-wrong-element",null);const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init()).then(()=>(n._verifyRootsWithInitialData(),n.data.init(n.config.get("initialData")))).then(()=>n.fire("ready")).then(()=>n))})}_verifyRootsWithInitialData(){const e=this.config.get("initialData");for(const t of this.model.document.getRootNames())if(!(t in e))throw new I("multi-root-editor-root-initial-data-mismatch",null);for(const t of Object.keys(e)){const e=this.model.document.getRoot(t);if(!e||!e.isAttached())throw new I("multi-root-editor-root-initial-data-mismatch",null)}}}function TA(e){return EA(e)?li(e):e}function EA(e){return xt(e)}var SA,IA={exports:{}};var PA,VA=(SA||(SA=1,PA=IA,((e,t)=>{PA.exports?PA.exports=t():e.fuzzysort=t()})(IA.exports,e=>{var t=e=>{"number"==typeof e?e=""+e:"string"!=typeof e&&(e="");var t=g(e);return s(e,{_targetLower:t._lower,_targetLowerCodes:t.lowerCodes,_bitflags:t.bitflags})};class i{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((e,t)=>e-t)}set indexes(e){return this._indexes=e}highlight(e,t){return((e,t="",i="")=>{for(var n="function"==typeof t?t:void 0,s=e.target,o=s.length,r=e.indexes,a="",l=0,c=0,u=!1,d=[],h=0;h{const n=new i;return n.target=e,n.obj=t.obj??P,n._score=t._score??S,n._indexes=t._indexes??[],n._targetLower=t._targetLower??"",n._targetLowerCodes=t._targetLowerCodes??P,n._nextBeginningIndexes=t._nextBeginningIndexes??P,n._bitflags=t._bitflags??0,n},o=e=>e===S?0:e>1?e:Math.E**(-2*((1-e)**.04307-1)),r=e=>0===e?S:e>1?e:1-Math.pow(Math.log(e)/-2+1,1/.04307),a=e=>{"number"==typeof e?e=""+e:"string"!=typeof e&&(e=""),e=e.trim();var t=g(e),i=[];if(t.containsSpace){var n=e.split(/\s+/);n=[...new Set(n)];for(var s=0;s{if(e.length>999)return t(e);var i=p.get(e);return void 0!==i||(i=t(e),p.set(e,i)),i},c=e=>{if(e.length>999)return a(e);var t=b.get(e);return void 0!==t||(t=a(e),b.set(e,t)),t},u=(e,t)=>{var i=[];i.total=e.length;var o=t?.limit||E;if(t?.key)for(var r=0;r=o)return i}}else if(t?.keys)for(r=0;r=0;--d)(h=A(a,t.keys[d]))?(T(h)||(h=l(h)),h._score=S,h._indexes.len=0,u[d]=h):u[d]=V;if(u.obj=a,u._score=S,i.push(u),i.length>=o)return i}else for(r=0;r=o))return i}return i},d=(e,t,n=!1,s=!1)=>{if(!1===n&&e.containsSpace)return h(e,t,s);for(var o=e._lower,r=e.lowerCodes,a=r[0],l=t._targetLowerCodes,c=r.length,u=l.length,d=0,m=0,g=0;;){if(a===l[m]){if(w[g++]=m,++d===c)break;a=r[d]}if(++m>=u)return P}d=0;var p=!1,b=0,_=t._nextBeginningIndexes;_===P&&(_=t._nextBeginningIndexes=f(t.target));var y=0;if((m=0===w[0]?0:_[w[0]-1])!==u)for(;;)if(m>=u){if(d<=0)break;if(++y>200)break;--d;var k=v[--b];m=_[k]}else if(r[d]===l[m]){if(v[b++]=m,++d===c){p=!0;break}++m}else m=_[m];var C=c<=1?-1:t._targetLower.indexOf(o,w[0]),x=!!~C,A=!!x&&(0===C||t._nextBeginningIndexes[C-1]===C);if(x&&!A)for(var T=0;T<_.length;T=_[T])if(!(T<=C)){for(var E=0;E{for(var t=0,i=0,n=1;n24&&(t*=10*(s-24))}else t*=1e3;return t-=(u-c)/2,x&&(t/=1+c*c*1),A&&(t/=1+c*c*1),t-=(u-c)/2};if(p)if(A){for(T=0;T{for(var n=new Set,s=0,o=P,r=0,a=e.spaceSearches,l=a.length,c=0,u=()=>{for(let e=c-1;e>=0;e--)t._nextBeginningIndexes[_[2*e+0]]=_[2*e+1]},h=!1,m=0;m=0&&w===t._nextBeginningIndexes[e];e--)t._nextBeginningIndexes[e]=b,_[2*c+0]=e,_[2*c+1]=w,c++}}s+=o._score/l,k[m]=o._score/l,o._indexes[0]s){if(i)for(m=0;me.replace(/\p{Script=Latin}+/gu,e=>e.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),g=e=>{for(var t=(e=m(e)).length,i=e.toLowerCase(),n=[],s=0,o=!1,r=0;r=97&&a<=122?a-97:a>=48&&a<=57?26:a<=127?30:31):o=!0}return{lowerCodes:n,bitflags:s,containsSpace:o,_lower:i}},f=e=>{for(var t=(e=m(e)).length,i=(e=>{for(var t=e.length,i=[],n=0,s=!1,o=!1,r=0;r=65&&a<=90,c=l||a>=97&&a<=122||a>=48&&a<=57,u=l&&!s||!o||!c;s=l,o=c,u&&(i[n++]=r)}return i})(e),n=[],s=i[0],o=0,r=0;rr?n[r]=s:(s=i[++o],n[r]=void 0===s?t:s);return n},p=new Map,b=new Map,w=[],v=[],_=[],y=[],k=[],C=[],x=[],A=(e,t)=>{var i=e[t];if(void 0!==i)return i;if("function"==typeof t)return t(e);var n=t;Array.isArray(t)||(n=t.split("."));for(var s=n.length,o=-1;e&&++o"object"==typeof e&&"number"==typeof e._bitflags,E=1/0,S=-E,I=[];I.total=0;var P=null,V=t(""),O=(()=>{var e=[],t=0,i={},n=i=>{for(var n=0,s=e[n],o=1;o>1]=e[n],o=1+(n<<1)}for(var a=n-1>>1;n>0&&s._score>1)e[n]=e[a];e[n]=s};return i.add=i=>{var n=t;e[t++]=i;for(var s=n-1>>1;n>0&&i._score>1)e[n]=e[s];e[n]=i},i.poll=i=>{if(0!==t){var s=e[0];return e[0]=e[--t],n(),s}},i.peek=i=>{if(0!==t)return e[0]},i.replaceTop=t=>{e[0]=t,n()},i})();return{single:(e,t)=>{if(!e||!t)return P;var i=c(e);T(t)||(t=l(t));var n=i.bitflags;return(n&t._bitflags)!==n?P:d(i,t)},go:(e,t,i)=>{if(!e)return i?.all?u(t,i):I;var s=c(e),o=s.bitflags,a=s.containsSpace,h=r(i?.threshold||0),m=i?.limit||E,g=0,f=0,p=t.length;function b(e){gO.peek()._score&&O.replaceTop(e))}if(i?.key)for(var w=i.key,v=0;v
-1e3&&y[e]>S&&(z=(y[e]+k[e])/4)>y[e]&&(y[e]=z),k[e]>y[e]&&(y[e]=k[e])}else x[M]=V;else x[M]=V;if(a){for(let e=0;e-1e3&&D>S&&(z=(D+q._score)/4)>D&&(D=z),q._score>D&&(D=q._score)}}if(N.obj=_,N._score=D,i?.scoreFn){if(!(D=i.scoreFn(N)))continue;D=r(D),N._score=D}D=0;--v)U[v]=O.poll();return U.total=g+f,U},prepare:t,cleanup:()=>{p.clear(),b.clear()}}})),IA.exports);function OA(e){const t=function(){try{return document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{return null}}();if(!t)return!1;const i=20,n=Math.floor(12.5);t.font=n+"px Arial, Sans-Serif",t.textBaseline="top",t.canvas.width=40,t.canvas.height=25,t.clearRect(0,0,40,25),t.fillStyle="#FF0000",t.fillText(e,0,22),t.fillStyle="#0000FF",t.fillText(e,i,22);const s=t.getImageData(0,0,i,25).data,o=s.length;let r=0;for(;r=o)return!1;const a=i+r/4%i,l=Math.floor(r/4/i),c=t.getImageData(a,l,1,1).data;return s[r]===c[0]&&s[r+2]===c[2]&&!(t.measureText(e).width>=i)}const RA={0:"default",1:"light",2:"medium-light",3:"medium",4:"medium-dark",5:"dark"},BA={"":16,"🫨":15.1,"🫠":14,"😶🌫️":13.1,"🧑💻":12.1,"🥰":11,"🤪":5,"⚕️":4,"🤣":3,"👋🏽":2,"😀":1,"😐":.7,"😂":.6};class LA extends $n{_emojiCanvas=null;static get pluginName(){return"EmojiUtils"}static get isOfficialPlugin(){return!0}init(){this._emojiCanvas=document.createElement("canvas").getContext("2d")}isEmojiSupported(e,t,i){return!!(e.version<=t)&&(!this.hasZwj(e.emoji)||this.isEmojiZwjSupported(e,i))}getEmojiSupportedVersionByOs(){for(const[e,t]of Object.entries(BA))if(LA._isEmojiSupported(e))return t;return 0}hasZwj(e){return e.includes("")}isEmojiZwjSupported(e,t){if(this.getNodeWidthUsingCanvas(t,e.emoji)<43.2)return!0;return this.getNodeWidth(t,e.emoji)<43.2}getNodeWidth(e,t){const i=document.createElement("span");i.textContent=t,e.appendChild(i);const n=i.offsetWidth;return e.removeChild(i),n}getNodeWidthUsingCanvas(e,t){const i=getComputedStyle(e);return this._emojiCanvas.font=[i.fontStyle,i.fontVariant,i.fontWeight,"24px",`"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", ${i.fontFamily}`].join(" "),Math.ceil(this._emojiCanvas.measureText(t).width)}createEmojiWidthTestingContainer(){const e=document.createElement("div");return e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.whiteSpace="nowrap",e.style.fontSize="24px",e}normalizeEmojiSkinTone(e){const t={...e,skins:{default:e.emoji}};return e.skins&&e.skins.forEach(e=>{const i=RA[e.tone];t.skins[i]=e.emoji}),t}isEmojiCategoryAllowed(e){return 2!==e.group}static _isEmojiSupported=OA}class MA extends $n{_items;_url;_repositoryPromise;static get requires(){return[LA]}static get pluginName(){return"EmojiRepository"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("emoji",{version:void 0,skinTone:"default",definitionsUrl:void 0,useCustomFont:!1}),this._url=this._getUrl(),this._repositoryPromise=new Promise(e=>{this._repositoryPromiseResolveCallback=e}),this._items=null}async init(){return this._warnAboutCdnUse(),await this._loadAndCacheEmoji(),this._items=this._getItems(),this._items?this._repositoryPromiseResolveCallback(!0):(P("emoji-repository-empty"),this._repositoryPromiseResolveCallback(!1))}getEmojiByQuery(e){if(!this._items)return[];return e.split(/\s/).filter(Boolean).some(e=>e.length>=2)?VA.go(e,this._items,{threshold:.6,keys:["emoticon","annotation",t=>e.split(/\s/).filter(Boolean).flatMap(e=>t.tags?.filter(t=>t.startsWith(e))).join()]}).map(e=>e.obj):[]}getEmojiCategories(){const e=this._getItems();if(!e)return[];const{t:t}=this.editor.locale,i=[{title:t("Smileys & Expressions"),icon:"😄",groupId:0},{title:t("Gestures & People"),icon:"👋",groupId:1},{title:t("Animals & Nature"),icon:"🐻",groupId:3},{title:t("Food & Drinks"),icon:"🍎",groupId:4},{title:t("Travel & Places"),icon:"🚘",groupId:5},{title:t("Activities"),icon:"🏀",groupId:6},{title:t("Objects"),icon:"💡",groupId:7},{title:t("Symbols"),icon:"🔵",groupId:8},{title:t("Flags"),icon:"🏁",groupId:9}],n=Ge(e,e=>e.group);return i.map(e=>({...e,items:n[e.groupId]}))}getSkinTones(){const{t:e}=this.editor.locale;return[{id:"default",icon:"👋",tooltip:e("Default skin tone")},{id:"light",icon:"👋🏻",tooltip:e("Light skin tone")},{id:"medium-light",icon:"👋🏼",tooltip:e("Medium Light skin tone")},{id:"medium",icon:"👋🏽",tooltip:e("Medium skin tone")},{id:"medium-dark",icon:"👋🏾",tooltip:e("Medium Dark skin tone")},{id:"dark",icon:"👋🏿",tooltip:e("Dark skin tone")}]}isReady(){return this._repositoryPromise}_getUrl(){const{definitionsUrl:e,version:t}=this.editor.config.get("emoji");if(!e||"cdn"===e){const e=new URL("https://cdn.ckeditor.com/ckeditor5/data/emoji/{version}/en.json".replace("{version}",(t||16).toString()));return e.searchParams.set("editorVersion",B),e}return t&&P("emoji-repository-redundant-version"),new URL(e)}_warnAboutCdnUse(){const e=this.editor,t=e.config.get("emoji"),i=e.config.get("licenseKey"),n=window[Symbol.for("cke distribution")];"GPL"!==i&&"cloud"!==n&&(t&&t.definitionsUrl||P("emoji-repository-cdn-use"))}_getItems(){const e=MA._results[this._url.href];return e&&e.length?e:null}async _loadAndCacheEmoji(){if(MA._results[this._url.href])return;const e=await fetch(this._url,{cache:"force-cache"}).then(e=>e.ok?e.json():[]).catch(()=>[]);MA._results[this._url.href]=this._normalizeEmoji(e)}_normalizeEmoji(e){const t=this.editor,i=t.config.get("emoji.useCustomFont"),n=t.plugins.get("EmojiUtils"),s=e.filter(e=>n.isEmojiCategoryAllowed(e));if(i)return s.map(e=>n.normalizeEmojiSkinTone(e));const o=n.getEmojiSupportedVersionByOs(),r=n.createEmojiWidthTestingContainer();document.body.appendChild(r);const a=s.filter(e=>n.isEmojiSupported(e,o,r)).map(e=>n.normalizeEmojiSkinTone(e));return r.remove(),a}static _results={}}const FA=":",NA=":__EMOJI_SHOW_ALL:",DA=":__EMOJI_HINT:";class zA extends $n{_emojiDropdownLimit;_skinTone;static get requires(){return[MA,F_,"Mention"]}static get pluginName(){return"EmojiMention"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.editor.config.define("emoji",{dropdownLimit:6}),this._emojiDropdownLimit=e.config.get("emoji.dropdownLimit"),this._skinTone=e.config.get("emoji.skinTone"),this._setupMentionConfiguration(e)}_setupMentionConfiguration(e){const t=e.config.get("mergeFields.prefix"),i=e.config.get("mention.feeds"),n=!!t&&t[0]===FA;if(i.filter(e=>!e._isEmojiMarker).some(e=>e.marker===FA)||n)return void P("emoji-config-marker-already-used",{marker:FA});if(i.some(e=>e._isEmojiMarker))return;const s={_isEmojiMarker:!0,marker:FA,dropdownLimit:this._emojiDropdownLimit,itemRenderer:this._customItemRendererFactory(this.editor.t),feed:this._queryEmojiCallbackFactory()};this.editor.config.set("mention.feeds",[...i,s])}async init(){const e=this.editor;this.emojiPickerPlugin=e.plugins.has("EmojiPicker")?e.plugins.get("EmojiPicker"):null,this.emojiRepositoryPlugin=e.plugins.get("EmojiRepository"),this._isEmojiRepositoryAvailable=await this.emojiRepositoryPlugin.isReady(),this._isEmojiRepositoryAvailable&&e.once("ready",this._overrideMentionExecuteListener.bind(this))}_customItemRendererFactory(e){return t=>{const i=document.createElement("button");i.classList.add("ck"),i.classList.add("ck-button"),i.classList.add("ck-button_with-text"),i.id=`mention-list-item-id${t.id.slice(0,-1)}`,i.type="button",i.tabIndex=-1;const n=document.createElement("span");return n.classList.add("ck"),n.classList.add("ck-button__label"),i.appendChild(n),t.id===DA?(i.classList.add("ck-list-item-button"),i.classList.add("ck-disabled"),n.textContent=e("Keep on typing to see the emoji.")):t.id===NA?n.textContent=e("Show all emoji..."):n.textContent=`${t.text} ${t.id}`,i}}_overrideMentionExecuteListener(){const e=this.editor;e.commands.get("mention").on("execute",(t,i)=>{const n=i[0];if(n.marker===FA&&(t.stop(),n.mention.id!==DA))if(n.mention.id===NA){const t=[...n.range.getItems()].filter(e=>e.is("$textProxy")).map(e=>e.data).reduce((e,t)=>e+t,"");e.model.change(t=>{e.model.deleteContent(t.createSelection(n.range))});const i=this.emojiPickerPlugin;i.showUI(t.slice(1)),setTimeout(()=>{i.emojiPickerView.focus()})}else e.execute("insertText",{text:n.mention.text,range:n.range})},{priority:"high"})}_queryEmojiCallbackFactory(){return e=>{if(e.startsWith(" "))return[];if(e.startsWith(FA))return[];if(!this._isEmojiRepositoryAvailable)return[];const t=this.emojiRepositoryPlugin.getEmojiByQuery(e).map(e=>{let t=e.skins[this._skinTone]||e.skins.default;return this.emojiPickerPlugin&&(t=e.skins[this.emojiPickerPlugin.skinTone]||e.skins.default),{id:`:${e.annotation}:`,text:t}});if(!this.emojiPickerPlugin)return t.slice(0,this._emojiDropdownLimit);const i={id:e.length>1?NA:DA};return[...t.slice(0,this._emojiDropdownLimit-1),i]}}}class HA extends Gn{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=t.checkChild(i.getFirstPosition(),"$text")}execute(e=""){this.editor.plugins.get("EmojiPicker").showUI(e)}}class qA extends hh{tiles;focusTracker;keystrokes;emojiCategories;cachedTiles;_getEmojiByQuery;constructor(t,{categoryName:i,emojiCategories:n,getEmojiByQuery:s,skinTone:o}){super(t),this.set("isEmpty",!0),this.set("categoryName",i),this.set("skinTone",o),this.tiles=this.createCollection(),this.cachedTiles=this.createCollection(),this.focusTracker=new bn,this.keystrokes=new yn,this._getEmojiByQuery=s,this.emojiCategories=n;const r=this.bindTemplate;this.setTemplate({tag:"div",children:[{tag:"div",attributes:{role:"grid",class:["ck","ck-emoji__grid"]},children:this.tiles}],attributes:{role:"tabpanel",class:["ck","ck-emoji__tiles",r.if("isEmpty","ck-hidden",e=>e)]}}),yh({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.tiles,numberOfColumns:()=>e.window.getComputedStyle(this.element.firstChild).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy(),this.focusTracker.destroy()}focus(){const e=this.tiles.first;e&&e.focus()}filter(e){const{matchingItems:t,allItems:i}=e?this._getItemsByQuery(e.source):this._getItemsByCategory();return this._updateGrid(t),this.set("isEmpty",0===t.length),{resultsCount:t.length,totalItemsCount:i.length}}_getItemsByQuery(e){return{matchingItems:this._getEmojiByQuery(e),allItems:this.emojiCategories.flatMap(e=>e.items)}}_getItemsByCategory(){const e=this.emojiCategories.find(e=>e.title===this.categoryName),{items:t}=e;return{matchingItems:t,allItems:t}}_updateGrid(e){[...this.tiles].forEach(e=>{this.focusTracker.remove(e),this.tiles.remove(e)}),e.map(e=>{const t=e.skins[this.skinTone]||e.skins.default;return this.cachedTiles.get(t)||this._createTile(t,e.annotation)}).forEach(e=>{this.tiles.add(e),this.focusTracker.add(e)})}_createTile(e,t){const i=new yp(this.locale);return i.viewUid=e,i.extendTemplate({attributes:{class:["ck-emoji__tile"]}}),i.set({label:e,tooltip:t,withText:!0,ariaLabel:t,ariaLabelledBy:void 0}),i.on("execute",()=>{this.fire("execute",{name:t,emoji:e})}),this.cachedTiles.add(i),i}}class UA extends hh{focusTracker;keystrokes;focusCycler;buttonViews;constructor(e,{emojiCategories:t,categoryName:i}){super(e),this.buttonViews=this.createCollection(t.map(e=>this._createCategoryButton(e))),this.focusTracker=new bn,this.keystrokes=new yn,this.focusCycler=new xp({focusables:this.buttonViews,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-emoji__categories-list"],role:"tablist"},children:this.buttonViews}),this.on("change:categoryName",(e,t,i,n)=>{const s=this.buttonViews.find(e=>e.tooltip===n);s&&(s.isOn=!1);this.buttonViews.find(e=>e.tooltip===i).isOn=!0}),this.set("categoryName",i)}render(){super.render(),this.buttonViews.forEach(e=>{this.focusTracker.add(e)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),this.buttonViews.destroy()}focus(){this.buttonViews.first.focus()}enableCategories(){this.buttonViews.forEach(e=>{e.isEnabled=!0})}disableCategories(){this.buttonViews.forEach(e=>{e.set({class:"",isEnabled:!1,isOn:!1})})}_createCategoryButton(e){const t=new yp,i=t.bindTemplate;return t.extendTemplate({attributes:{"aria-selected":i.to("isOn",e=>e.toString()),class:["ck-emoji__category-item"]}}),t.set({ariaLabel:e.title,label:e.icon,role:"tab",tooltip:e.title,withText:!0,ariaLabelledBy:void 0}),t.on("execute",()=>{this.categoryName=e.title}),t.on("change:isEnabled",()=>{t.isEnabled&&t.tooltip===this.categoryName&&(t.isOn=!0)}),t}}class WA extends hh{inputView;gridView;constructor(e,{gridView:t,resultsView:i}){super(e),this.gridView=t;const n=e.t;this.inputView=new Yv(this.locale,{queryView:{label:n("Find an emoji (min. 2 characters)"),creator:fw},filteredView:this.gridView,infoView:{instance:i}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search"],tabindex:"-1"},children:[this.inputView.queryView]}),this.inputView.delegate("search").to(this)}destroy(){super.destroy(),this.inputView.destroy()}search(e){const t=e?new RegExp(Pt(e),"ig"):null,i=this.gridView.filter(t);this.inputView.fire("search",{query:e,...i})}setInputValue(e){e?this.inputView.queryView.fieldView.value=e:this.inputView.queryView.fieldView.reset()}getInputValue(){return this.inputView.queryView.fieldView.element.value}focus(){this.inputView.focus()}}class $A extends hh{dropdownView;_skinTones;constructor(e,{skinTone:t,skinTones:i}){super(e),this.set("skinTone",t),this._skinTones=i;const n=(0,e.t)("Select skin tone"),s=ow(e),o=new gn;for(const{id:e,icon:t,tooltip:i}of this._skinTones){const n={type:"button",model:new Hv({value:e,label:t,ariaLabel:i,tooltip:i,tooltipPosition:"e",role:"menuitemradio",withText:!0,ariaLabelledBy:void 0})};n.model.bind("isOn").to(this,"skinTone",t=>t===e),o.add(n)}uw(s,o,{ariaLabel:n,role:"menu"}),s.buttonView.set({label:this._getSkinTone().icon,ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),this.dropdownView=s,this.listenTo(s,"execute",e=>{this.skinTone=e.source.value}),s.buttonView.bind("label").to(this,"skinTone",()=>this._getSkinTone().icon),s.buttonView.bind("ariaLabel").to(this,"skinTone",()=>`${this._getSkinTone().tooltip}, ${n}`),this.setTemplate({tag:"div",attributes:{class:["ck","ck-emoji__skin-tone"]},children:[s]})}focus(){this.dropdownView.buttonView.focus()}_getSkinTone(){return this._skinTones.find(e=>e.id===this.skinTone)}}class jA extends hh{items;focusTracker;keystrokes;focusCycler;searchView;toneView;categoriesView;gridView;infoView;constructor(e,{emojiCategories:t,getEmojiByQuery:i,skinTone:n,skinTones:s}){super(e);const o=t[0].title;this.gridView=new qA(e,{categoryName:o,emojiCategories:t,getEmojiByQuery:i,skinTone:n}),this.infoView=new Jv,this.searchView=new WA(e,{gridView:this.gridView,resultsView:this.infoView}),this.categoriesView=new UA(e,{emojiCategories:t,categoryName:o}),this.toneView=new $A(e,{skinTone:n,skinTones:s}),this.items=this.createCollection([this.searchView,this.toneView,this.categoriesView,this.gridView,this.infoView]),this.focusTracker=new bn,this.keystrokes=new yn,this.focusCycler=new xp({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",children:[{tag:"div",children:[this.searchView,this.toneView],attributes:{class:["ck","ck-emoji__search"]}},this.categoriesView,this.gridView,{tag:"div",children:[this.infoView],attributes:{class:["ck","ck-search__results"]}}],attributes:{tabindex:"-1",class:["ck","ck-emoji","ck-search"]}}),this._setupEventListeners()}render(){super.render(),this.focusTracker.add(this.searchView.element),this.focusTracker.add(this.toneView.element),this.focusTracker.add(this.categoriesView.element),this.focusTracker.add(this.gridView.element),this.focusTracker.add(this.infoView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.searchView.focus()}_setupEventListeners(){const e=this.locale.t;this.searchView.on("search",(e,t)=>{t.query?this.categoriesView.disableCategories():this.categoriesView.enableCategories()}),this.searchView.on("search",(t,i)=>{1===i.query.length?this.infoView.set({primaryText:e("Keep on typing to see the emoji."),secondaryText:e("The query must contain at least two characters."),isVisible:!0}):i.resultsCount?this.infoView.set({isVisible:!1}):this.infoView.set({primaryText:e('No emojis were found matching "%0".',i.query),secondaryText:e("Please try a different phrase or check the spelling."),isVisible:!0})}),this.searchView.on("search",()=>{this.fire("update"),this.gridView.element.scrollTo(0,0)}),this.categoriesView.on("change:categoryName",(e,t,i)=>{this.gridView.categoryName=i,this.searchView.search("")}),this.toneView.on("change:skinTone",(e,t,i)=>{this.gridView.skinTone=i,this.searchView.search(this.searchView.getInputValue())})}}class GA extends hh{backButtonView;focusTracker=new bn;keystrokes=new yn;children;_focusables=new qd;_focusCycler;constructor(e){super(e),this.backButtonView=this._createBackButton(),this.children=this.createCollection([this._createHeaderView()]),this._focusCycler=new xp({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form","ck-emoji-picker-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render();[...this.children.filter(Tp),this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element),Ep(e)&&this._focusCycler.chain(e.focusCycler)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:bf,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=this.locale.t,t=new Cp(this.locale,{label:e("Emoji picker")});return t.children.add(this.backButtonView,0),t}}const KA="emoji-picker";class JA extends $n{static get requires(){return[MA,Uv,Rp,F_]}static get pluginName(){return"EmojiPicker"}static get isOfficialPlugin(){return!0}async init(){const e=this.editor;if(this.balloonPlugin=e.plugins.get("ContextualBalloon"),this.emojiRepositoryPlugin=e.plugins.get("EmojiRepository"),!await this.emojiRepositoryPlugin.isReady())return;const t=new HA(e);e.commands.add("emoji",t),e.ui.componentFactory.add("emoji",()=>{const e=this._createButton(yp,t);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:emoji",()=>this._createButton(Mp,t)),this._setupConversion()}destroy(){super.destroy(),this.emojiPickerView&&this.emojiPickerView.destroy()}get skinTone(){return this.emojiPickerView?this.emojiPickerView.gridView.skinTone:this.editor.config.get("emoji.skinTone")}showUI(e=""){this._showFakeVisualSelection(),this.emojiPickerView||(this.emojiPickerView=this._createEmojiPickerView()),e&&this.emojiPickerView.searchView.setInputValue(e),this.emojiPickerView.searchView.search(e),this.emojiPickerFormView||(this.emojiPickerFormView=this._createEmojiPickerFormView()),this.balloonPlugin.hasView(this.emojiPickerFormView)||(this.emojiPickerFormView.backButtonView.isVisible=!!this.balloonPlugin.visibleView,this.balloonPlugin.add({view:this.emojiPickerFormView,position:this._getBalloonPositionData(),balloonClassName:"ck-emoji-picker-balloon"})),this.emojiPickerView.focus()}_createButton(e,t){const i=new e(this.editor.locale),n=this.editor.locale.t;return i.bind("isEnabled").to(t,"isEnabled"),i.set({label:n("Emoji"),icon:Rm,isToggleable:!0}),i.on("execute",()=>{this.editor.editing.view.scrollToTheSelection(),this.showUI()}),i}_createEmojiPickerView(){const e=new jA(this.editor.locale,{emojiCategories:this.emojiRepositoryPlugin.getEmojiCategories(),skinTone:this.editor.config.get("emoji.skinTone"),skinTones:this.emojiRepositoryPlugin.getSkinTones(),getEmojiByQuery:e=>this.emojiRepositoryPlugin.getEmojiByQuery(e)});return this.listenTo(e.gridView,"execute",(e,t)=>{const i=this.editor,n=t.emoji;this._hideUI(),i.execute("insertText",{text:n})}),e}_createEmojiPickerFormView(){const e=new GA(this.editor.locale);return e.children.add(this.emojiPickerView),this.listenTo(this.emojiPickerView,"update",()=>{this.balloonPlugin.visibleView===e&&this.balloonPlugin.updatePosition()}),this.listenTo(e,"cancel",()=>{this._hideUI()}),e.keystrokes.set("Esc",(e,t)=>{this._hideUI(),t()}),bh({emitter:e,contextElements:[this.balloonPlugin.view.element],callback:()=>{this._hideUI(!1)},activator:()=>this.balloonPlugin.visibleView===e}),e}_hideUI(e=!0){this.balloonPlugin.remove(this.emojiPickerFormView),this.emojiPickerView.searchView.setInputValue(""),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection()}_setupConversion(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:KA,view:{classes:["ck-fake-emoji-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:KA,view:(e,{writer:t})=>{if(!e.markerRange.isCollapsed)return null;const i=t.createUIElement("span");return t.addClass(["ck-fake-emoji-selection","ck-fake-emoji-selection_collapsed"],i),i}})}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;return{target:()=>e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(KA))t.updateMarker(KA,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(({item:t})=>!e.schema.isContent(t),{boundaries:i});t.addMarker(KA,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(KA,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(KA)&&e.change(e=>{e.removeMarker(KA)})}}class QA extends $n{static get requires(){return[zA,JA]}static get pluginName(){return"Emoji"}static get isOfficialPlugin(){return!0}}class YA extends Gn{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!ZA(e.schema,i))do{if(i=i.parent,!i)return}while(!ZA(e.schema,i));e.change(e=>{e.setSelection(i,"in")})}}function ZA(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const XA=Xi("Ctrl+A");class eT extends $n{static get pluginName(){return"SelectAllEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new YA(e)),this.listenTo(i,"keydown",(t,i)=>{Zi(i)===XA&&(e.execute("selectAll"),i.preventDefault())}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class tT extends $n{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",()=>{const e=this._createButton(yp);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:selectAll",()=>this._createButton(Mp))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),s=new e(t.locale),o=i.t;return s.set({label:o("Select all"),icon:If,keystroke:"Ctrl+A"}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),s}}class iT extends $n{static get requires(){return[eT,tT]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}class nT extends Gn{_stack=[];_createdBatches=new WeakSet;constructor(e){super(e),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",(e,t)=>{t[1]={...t[1]};const i=t[1];i.batchType||(i.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(e.data,"set",(e,t)=>{t[1].batchType.isUndoable||this.clearStack()})}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,s=n.document,o=[],r=e.map(e=>e.getTransformedByOperations(i)),a=r.flat();for(const e of r){const t=e.filter(e=>e.root!=s.graveyard).filter(e=>!oT(e,a));t.length&&(sT(t),o.push(t[0]))}o.length&&n.change(e=>{e.setSelection(o,{backward:t})})}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter(e=>e.isDocumentOperation);s.reverse();for(const e of s){const s=e.baseVersion+1,o=Array.from(n.history.getOperations(s)),r=El([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let s of r){const o=s.affectedSelectable;o&&!i.canEditAt(o)&&(s=new bl(s.baseVersion)),t.addOperation(s),i.applyOperation(s),n.history.setOperationAsUndone(e,s)}}}}function sT(e){e.sort((e,t)=>e.start.isBefore(t.start)?-1:1);for(let t=1;tt!==e&&t.containsRange(e,!0))}class rT extends nT{execute(e=null){const t=e?this._stack.findIndex(t=>t.batch==e):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(n,()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e)}),this.fire("revert",i.batch,n),this.refresh()}}class aT extends nT{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)}),this.fire("revert",e.batch,t),this.refresh()}}class lT extends $n{_undoCommand;_redoCommand;_batchRegistry=new WeakSet;static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._undoCommand=new rT(e),this._redoCommand=new aT(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",(e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,s=this._redoCommand.createdBatches.has(n),o=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(e,t,i)=>{this._redoCommand.addBatch(i)}),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class cT extends $n{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?up:yf,s="ltr"==t.uiLanguageDirection?yf:up;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",s)}_addButtonsToFactory(e,t,i,n){const s=this.editor;s.ui.componentFactory.add(e,()=>{const s=this._createButton(yp,e,t,i,n);return s.set({tooltip:!0}),s}),s.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(Mp,e,t,i,n))}_createButton(e,t,i,n,s){const o=this.editor,r=o.locale,a=o.commands.get(t),l=new e(r);return l.set({label:i,icon:s,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",()=>{o.execute(t),o.editing.view.focus()}),l}}class uT extends $n{static get requires(){return[lT,cT]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}class dT extends $n{static get requires(){return[Fp,xx,Zy,iT,ik,F_,uT]}static get pluginName(){return"Essentials"}static get isOfficialPlugin(){return!0}}class hT extends hh{children;_findInputView;_replaceInputView;_findButtonView;_findPrevButtonView;_findNextButtonView;_advancedOptionsCollapsibleView;_matchCaseSwitchView;_wholeWordsOnlySwitchView;_replaceButtonView;_replaceAllButtonView;_inputsDivView;_actionButtonsDivView;_focusTracker;_keystrokes;_focusables;focusCycler;constructor(e){super(e);const t=e.t;this.children=this.createCollection(),this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",(e,t)=>e>0&&!t),this._findInputView=this._createInputField(t("Find in text…")),this._findPrevButtonView=this._createButton({label:t("Previous result"),class:"ck-button-prev",icon:bf,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:t("Next result"),class:"ck-button-next",icon:bf,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(t("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:t("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:t("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:t("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new bn,this._keystrokes=new yn,this._focusables=new qd,this.focusCycler=new xp({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),_h({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createInputsDiv(){const e=this.locale,t=e.t,i=new hh(e);return this._findInputView.fieldView.on("input",()=>{this.isDirty=!0}),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findPrevious:e})=>e),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findNext:e})=>e),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:e},t)=>e&&t),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",(e,i)=>e||!i?"":t("Tip: Find some text first in order to replace it.")),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(!this._textToFind){const e=this.t;return void(this._findInputView.errorText=e("Text to find must not be empty."))}this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly})}_injectFindResultsCounter(){const e=this.locale,t=e.t,i=this.bindTemplate,n=new hh(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",(e,i)=>t("%0 of %1",[e,i])),n.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const s=()=>{const t=this._findInputView.fieldView.element;if(!t||!Ii(t))return;const i=new pi(n.element).width,s="ltr"===e.uiLanguageDirection?"paddingRight":"paddingLeft";t.style[s]=i?`calc( 2 * var(--ck-spacing-standard) + ${i}px )`:""};this.on("change:_resultsCounterText",s,{priority:"low"}),this.on("change:isDirty",s,{priority:"low"}),this._findInputView.template.children[0].children.push(n)}_createAdvancedOptionsCollapsible(){const e=this.locale.t,t=new Zp(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return t.set({label:e("Advanced options"),isCollapsed:!0}),t}_createActionButtonsDiv(){const e=new hh(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:e},t)=>e&&t),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replaceAll:e},t)=>e&&t),this._replaceButtonView.on("execute",()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})}),this._replaceAllButtonView.on("execute",()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()}),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),e.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),e}_createMatchCaseSwitch(){const e=this.locale.t,t=new Gp(this.locale);return t.set({label:e("Match case"),withText:!0}),t.bind("isOn").to(this,"_matchCase"),t.on("execute",()=>{this._matchCase=!this._matchCase,this.isDirty=!0}),t}_createWholeWordsOnlySwitch(){const e=this.locale.t,t=new Gp(this.locale);return t.set({label:e("Whole words only"),withText:!0}),t.bind("isOn").to(this,"_wholeWordsOnly"),t.on("execute",()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0}),t}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}_initKeystrokeHandling(){const e=e=>e.stopPropagation(),t=e=>{e.stopPropagation(),e.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",e=>{t(e),this._findNextButtonView.fire("execute")}),this._keystrokes.set("shift+f3",e=>{t(e),this._findPrevButtonView.fire("execute")}),this._keystrokes.set("enter",e=>{const i=e.target;i===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e)):i!==this._replaceInputView.fieldView.element||this.isDirty||(this._replaceButtonView.fire("execute"),t(e))}),this._keystrokes.set("shift+enter",e=>{e.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e))}),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e)}_createButton(e){const t=new yp(this.locale);return t.set(e),t}_createInputField(e,t){const i=new Ab(this.locale,fw);return i.label=e,i.class=t,i}}class mT extends $n{static get requires(){return[Rp]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}formView;constructor(e){super(e),e.config.define("findAndReplace.uiType","dialog"),this.formView=null}init(){const e=this.editor,t="dropdown"===e.config.get("findAndReplace.uiType"),i=e.commands.get("find"),n=this.editor.t;e.ui.componentFactory.add("findAndReplace",()=>{let n;return t?(n=this._createDropdown(),n.bind("isEnabled").to(i)):n=this._createDialogButtonForToolbar(),e.keystrokes.set("Ctrl+F",(t,s)=>{if(i.isEnabled){if(n instanceof Rb){const e=n.buttonView;e.isOn||e.fire("execute")}else n.isOn?e.plugins.get("Dialog").view.focus():n.fire("execute");s()}}),n}),t||e.ui.componentFactory.add("menuBar:findAndReplace",()=>this._createDialogButtonForMenuBar()),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const e=this.editor,t=e.locale.t,i=ow(e.locale);return i.once("change:isOpen",()=>{this.formView=this._createFormView(),this.formView.children.add(new Cp(e.locale,{label:t("Find and replace")}),0),i.panelView.children.add(this.formView)}),i.on("change:isOpen",(e,t,i)=>{i?this._setupFormView():this.fire("searchReseted")},{priority:"low"}),i.buttonView.set({icon:qm,label:t("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const e=this.editor,t=this._createButton(yp),i=e.plugins.get("Dialog");return t.set({tooltip:!0}),t.bind("isOn").to(i,"id",e=>"findAndReplace"===e),t.on("execute",()=>{t.isOn?i.hide():this._showDialog()}),t}_createDialogButtonForMenuBar(){const e=this._createButton(Mp),t=this.editor.plugins.get("Dialog"),i=this.editor.plugins.get("Dialog");return e.set({role:"menuitemcheckbox",isToggleable:!0}),e.bind("isOn").to(i,"id",e=>"findAndReplace"===e),e.on("execute",()=>{"findAndReplace"!==t.id?this._showDialog():t.hide()}),e}_createButton(e){const t=this.editor,i=t.commands.get("find"),n=new e(t.locale),s=t.locale.t;return n.bind("isEnabled").to(i),n.set({icon:qm,label:s("Find and replace"),keystroke:"CTRL+F"}),n}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.formView||(this.formView=this._createFormView()),t.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:Pp.EDITOR_TOP_SIDE,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const e=this.editor,t=new(wh(hT))(e.locale),i=e.commands,n=this.editor.plugins.get("FindAndReplaceEditing").state;t.bind("highlightOffset").to(n,"highlightedOffset"),t.listenTo(n.results,"change",()=>{t.matchCount=n.results.length});const s=i.get("findNext"),o=i.get("findPrevious"),r=i.get("replace"),a=i.get("replaceAll");return t.bind("_areCommandsEnabled").to(s,"isEnabled",o,"isEnabled",r,"isEnabled",a,"isEnabled",(e,t,i,n)=>({findNext:e,findPrevious:t,replace:i,replaceAll:n})),t.delegate("findNext","findPrevious","replace","replaceAll").to(this),t.on("change:isDirty",(e,t,i)=>{i&&this.fire("searchReseted")}),t}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class gT extends Gn{_state;constructor(e,t){super(e),this.isEnabled=!0,this.affectsData=!1,this._state=t}execute(e,{matchCase:t,wholeWords:i}={}){const{editor:n}=this,{model:s}=n,o=n.plugins.get("FindAndReplaceUtils");let r,a="";r="string"==typeof e?(...n)=>({results:o.findByTextCallback(e,{matchCase:t,wholeWords:i})(...n),searchText:e}):e;const l=r;r=(...e)=>{const t=l(...e);return t&&"searchText"in t&&(a=t.searchText),t};const c=s.document.getRootNames().reduce((e,t)=>o.updateFindResultFromRange(s.createRangeIn(s.document.getRoot(t)),s,r,e),null);return this._state.clear(s),this._state.results.addMany(c),this._state.highlightedResult=c.get(0),this._state.searchText=a,r&&(this._state.lastSearchCallback=r),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:c,findCallback:r}}}class fT extends(Dt()){constructor(e){super(),this.set("results",new gn),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",(t,{removed:i,index:n})=>{if(Array.from(i).length){let t=!1;if(e.change(n=>{for(const s of i)this.highlightedResult===s&&(t=!0),e.markers.has(s.marker.name)&&n.removeMarker(s.marker)}),t){const e=n>=this.results.length?0:n;this.highlightedResult=this.results.get(e)}}}),this.on("change:highlightedResult",()=>{this.refreshHighlightOffset(e)})}clear(e){this.searchText="",e.change(t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],n=e.markers.get(`findResultHighlighted:${i}`);n&&t.removeMarker(n)}[...this.results].forEach(({marker:e})=>{t.removeMarker(e)})}),this.results.clear()}refreshHighlightOffset(e){const{highlightedResult:t,results:i}=this;this.highlightedOffset=t?pT(e,[...i]).indexOf(t)+1:0}}function pT(e,t){const i={before:-1,same:0,after:1,different:1};return e.document.getRootNames().flatMap(e=>t.filter(t=>t.marker.getStart().root.rootName===e).sort((e,t)=>i[e.marker.getStart().compareWith(t.marker.getStart())]))}class bT extends Gn{_state;constructor(e,t){super(e),this.isEnabled=!0,this._state=t,this._isEnabledBasedOnSelection=!1}_replace(e,t){const{model:i}=this.editor,n=t.marker.getRange();i.canEditAt(n)&&i.change(s=>{if("$graveyard"===n.root.rootName)return void this._state.results.remove(t);let o={};for(const e of n.getItems())if(e.is("$text")||e.is("$textProxy")){o=e.getAttributes();break}i.insertContent(s.createText(e,o),n),this._state.results.has(t)&&this._state.results.remove(t)})}}class wT extends bT{execute(e,t){const i=Math.max(this._state.highlightedOffset-1,0);if(this._replace(e,t),this._state.results.length){const e=pT(this.editor.model,[...this._state.results]);this._state.highlightedResult=e[i%e.length]}}}class vT extends bT{execute(e,t){const{editor:i}=this,{model:n}=i,s=i.plugins.get("FindAndReplaceUtils"),o=t instanceof gn?t:n.document.getRootNames().reduce((e,i)=>s.updateFindResultFromRange(n.createRangeIn(n.document.getRoot(i)),n,s.findByTextCallback(t,this._state),e),null);o.length&&n.change(()=>{[...o].forEach(t=>{this._replace(e,t)})})}}class _T extends Gn{_state;constructor(e,t){super(e),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",()=>{this.isEnabled=this._state.results.length>1})}refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}}class yT extends _T{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class kT extends $n{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(e,t,i,n){const s=n||new gn;return t.change(n=>{[...e].forEach(({type:e,item:o})=>{if("elementStart"===e&&t.schema.checkChild(o,"$text")){let e=i({item:o,text:this.rangeToText(t.createRangeIn(o))});if(!e)return;"results"in e&&(e=e.results),e.forEach(e=>{const t=`findResult:${A()}`,i=n.addMarker(t,{usingOperation:!1,affectsData:!1,range:n.createRange(n.createPositionAt(o,e.start),n.createPositionAt(o,e.end))}),r=function(e,t){const i=e.find(({marker:e})=>t.getStart().isBefore(e.getStart()));return i?e.getIndex(i):e.length}(s,i);(e=>s.find(t=>{const{marker:i}=t,n=i.getRange(),s=e.getRange();return n.isEqual(s)}))(i)||s.add({id:t,label:e.label,marker:i},r)})}})}),s}rangeToText(e){return Array.from(e.getItems({shallow:!0})).reduce((e,t)=>t.is("$text")||t.is("$textProxy")?e+t.data:`${e}\n`,"")}findByTextCallback(e,t){let i="gu";t.matchCase||(i+="i");let n=`(${Pt(e)})`;if(t.wholeWords){const t="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+t).test(e)||(n=`(^|${t}|_)${n}`),new RegExp(t+"$").test(e)||(n=`${n}(?=_|${t}|$)`)}const s=new RegExp(n,i);return function({text:e}){return[...e.matchAll(s)].map(CT)}}}function CT(e){const t=e.length-1;let i=e.index;return 3===e.length&&(i+=e[1].length),{label:e[t],start:i,end:i+e[t].length}}class xT extends $n{static get requires(){return[kT]}static get pluginName(){return"FindAndReplaceEditing"}static get licenseFeatureCode(){return"FAR"}static get isPremiumPlugin(){return!0}static get isOfficialPlugin(){return!0}state;init(){this.state=new fT(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",(e,t,i,n)=>{const{model:s}=this.editor;s.change(e=>{if(n){const t=n.marker.name.split(":")[1],i=s.markers.get(`findResultHighlighted:${t}`);i&&e.removeMarker(i)}if(i){const t=i.marker.name.split(":")[1];e.addMarker(`findResultHighlighted:${t}`,{usingOperation:!1,affectsData:!1,range:i.marker.getRange()})}})});const e=tt(((e,t,i)=>{if(i){const e=this.editor.editing.view.domConverter,t=this.editor.editing.mapper.toViewRange(i.marker.getRange());Mi({target:e.viewRangeToDom(t),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel),this.on("change:_isSearchActive",(e,t,i)=>{i?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)})}find(e,t){return this._isSearchActive=!0,this.editor.execute("find",e,t),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new gT(this.editor,this.state)),this.editor.commands.add("findNext",new _T(this.editor,this.state)),this.editor.commands.add("findPrevious",new yT(this.editor,this.state)),this.editor.commands.add("replace",new wT(this.editor,this.state)),this.editor.commands.add("replaceAll",new vT(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":t}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result_selected"],attributes:{"data-find-result":t}}}})}_onDocumentChange=()=>{const e=new Set,t=new Set,i=this.editor.model,{results:n}=this.state,s=i.document.differ.getChanges(),o=i.document.differ.getChangedMarkers();s.forEach(n=>{n.position&&("$text"===n.name||n.position.nodeAfter&&i.schema.isInline(n.position.nodeAfter)?(e.add(n.position.parent),[...i.markers.getMarkersAtPosition(n.position)].forEach(e=>{t.add(e.name)})):"insert"===n.type&&n.position.nodeAfter&&e.add(n.position.nodeAfter))}),o.forEach(({name:e,data:{newRange:i}})=>{i&&"$graveyard"===i.start.root.rootName&&t.add(e)}),e.forEach(e=>{[...i.markers.getMarkersIntersectingRange(i.createRangeIn(e))].forEach(e=>t.add(e.name))}),t.forEach(e=>{n.has(e)&&(n.get(e)===this.state.highlightedResult&&(this.state.highlightedResult=null),n.remove(e))});const r=[],a=this.editor.plugins.get("FindAndReplaceUtils");e.forEach(e=>{const t=a.updateFindResultFromRange(i.createRangeOn(e),i,this.state.lastSearchCallback,n);r.push(...t)}),o.forEach(e=>{if(e.data.newRange){const t=a.updateFindResultFromRange(e.data.newRange,i,this.state.lastSearchCallback,n);r.push(...t)}}),!this.state.highlightedResult&&r.length?this.state.highlightedResult=r[0]:this.state.refreshHighlightOffset(i)}}class AT extends $n{static get requires(){return[xT,mT]}static get pluginName(){return"FindAndReplace"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get("FindAndReplaceUI"),t=this.editor.plugins.get("FindAndReplaceEditing"),i=t.state;e.on("findNext",(e,n)=>{n?(i.searchText=n.searchText,t.find(n.searchText,n)):this.editor.execute("findNext")}),e.on("findPrevious",(e,n)=>{n&&i.searchText!==n.searchText?t.find(n.searchText):this.editor.execute("findPrevious")}),e.on("replace",(e,n)=>{i.searchText!==n.searchText&&t.find(n.searchText);const s=i.highlightedResult;s&&this.editor.execute("replace",n.replaceText,s)}),e.on("replaceAll",(e,n)=>{i.searchText!==n.searchText&&t.find(n.searchText),this.editor.execute("replaceAll",n.replaceText,i.results)}),e.on("searchReseted",()=>{i.clear(this.editor.model),t.stop()})}}class TT extends Gn{attributeKey;constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,s=e.batch,o=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of s)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};s?t.enqueueChange(s,e=>{o(e)}):t.change(e=>{o(e)})}}const ET="fontSize",ST="fontFamily",IT="fontColor",PT="fontBackgroundColor";function VT(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function OT(e){return t=>t.getStyle(e).replace(/\s/g,"")}function RT(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}function BT({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:s,documentColorsLabel:o,documentColorsCount:r,colorPickerViewConfig:a}){const l=e.locale,c=new iv(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:s,documentColorsLabel:o,documentColorsCount:r,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}class LT extends TT{constructor(e){super(e,ST)}}function MT(e){return e.map(NT).filter(e=>void 0!==e)}function FT(e){return e.replace(/["']/g,"").split(",").map(e=>e.trim())}function NT(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=FT(e),i=t[0],n=t.map(DT).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function DT(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class zT extends $n{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(ST,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:ST}),e.model.schema.setAttributeProperties(ST,{isFormatting:!0,copyOnEnter:!0});const t=MT(e.config.get("fontFamily.options")).filter(e=>e.model),i=VT(ST,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(ST,new LT(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:ST,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:ST,value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:ST,value:e=>e.getAttribute("face")}})}}class HT extends $n{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(ST),s=t("Font Family"),o=function(e,t){const i=new gn;for(const n of e){const e={type:"button",model:new Hv({commandName:ST,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",e=>{if(e===n.model)return!0;if(!e||!n.model)return!1;return FT(e)[0].toLowerCase()===FT(n.model)[0].toLowerCase()}),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n);e.ui.componentFactory.add(ST,t=>{const i=ow(t);return uw(i,o,{role:"menu",ariaLabel:s}),i.buttonView.set({label:s,icon:$m,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()}),i}),e.ui.componentFactory.add(`menuBar:${ST}`,t=>{const i=new d_(t);i.buttonView.set({label:s,icon:$m}),i.bind("isEnabled").to(n);const r=new h_(t);for(const n of o){const s=new hv(t,i),o=new Mp(t);o.set({role:"menuitemradio",isToggleable:!0}),o.bind(...Object.keys(n.model)).to(n.model),o.delegate("execute").to(i),o.on("execute",()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()}),s.children.add(o),r.items.add(s)}return i.panelView.children.add(r),i})}_getLocalizedOptions(){const e=this.editor,t=e.t;return MT(e.config.get(ST).options).map(e=>("Default"===e.title&&(e.title=t("Default")),e))}}class qT extends $n{static get requires(){return[zT,HT]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class UT extends TT{constructor(e){super(e,ET)}}function WT(e){return e.map(e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&function(e){return e.title&&e.model&&e.view}(e))return jT(e);const t=function(e){return"string"==typeof e?$T[e]:$T[e.model]}(e);if(t)return jT(t);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new I("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},jT(e)}(e)}(e)).filter(e=>void 0!==e)}const $T={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function jT(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const GT=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class KT extends $n{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(ET,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:ET}),e.model.schema.setAttributeProperties(ET,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=WT(this.editor.config.get("fontSize.options")).filter(e=>e.model),n=VT(ET,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(ET,new UT(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter(e=>!Wc(String(e))&&!jc(String(e)));if(i.length)throw new I("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:ET,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:ET,value:e=>e.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:ET,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const s=GT.length-1,o=Math.min(Math.max(n,0),s);return GT[o]}}})}}class JT extends $n{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(ET),s=t("Font Size"),o=function(e,t){const i=new gn;for(const n of e){const e={type:"button",model:new Hv({commandName:ET,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",e=>e===n.model),i.add(e)}return i}(i,n);e.ui.componentFactory.add(ET,t=>{const i=ow(t);return uw(i,o,{role:"menu",ariaLabel:s}),i.buttonView.set({label:s,icon:jm,tooltip:!0}),i.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()}),i}),e.ui.componentFactory.add(`menuBar:${ET}`,t=>{const i=new d_(t);i.buttonView.set({label:s,icon:jm}),i.bind("isEnabled").to(n);const r=new h_(t);for(const n of o){const s=new hv(t,i),o=new Mp(t);o.set({role:"menuitemradio",isToggleable:!0}),o.bind(...Object.keys(n.model)).to(n.model),o.delegate("execute").to(i),o.on("execute",()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()}),s.children.add(o),r.items.add(s)}return i.panelView.children.add(r),i})}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return WT(e.config.get(ET).options).map(e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e})}}class QT extends $n{static get requires(){return[KT,JT]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return WT(e)}}class YT extends TT{constructor(e){super(e,IT)}}class ZT extends $n{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(IT,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:IT,value:OT("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:IT,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:IT,view:RT("color")}),e.commands.add(IT,new YT(e)),e.model.schema.extend("$text",{allowAttributes:IT}),e.model.schema.setAttributeProperties(IT,{isFormatting:!0,copyOnEnter:!0})}}class XT extends $n{commandName;componentName;icon;dropdownLabel;columns;constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:s}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),s=e.config.get(this.componentName),o=Xp(t,eb(s.colors)),r=s.documentColors,a=!1!==s.colorPicker;e.ui.componentFactory.add(this.componentName,t=>{const l=ow(t);let c=!1;const u=BT({dropdownView:l,colors:o.map(e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!!a&&(s.colorPicker||{})});return u.bind("selectedColor").to(n,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(n),u.on("execute",(t,i)=>{l.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(l.isOpen=!1)}),u.on("colorPicker:show",()=>{this._undoStepBatch=e.model.createBatch()}),u.on("colorPicker:cancel",()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()}),l.on("change:isOpen",(t,i,n)=>{c||(c=!0,l.colorSelectorView.appendUI()),n&&(0!==r&&u.updateDocumentColors(e.model,this.componentName),u.updateSelectedColors(),u.showColorGridsFragment())}),hw(l,()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find(e=>e.isOn)),l}),e.ui.componentFactory.add(`menuBar:${this.componentName}`,t=>{const s=new d_(t);s.buttonView.set({label:this.dropdownLabel,icon:this.icon}),s.bind("isEnabled").to(n);let a=!1;const l=new iv(t,{colors:o.map(e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!1});return l.bind("selectedColor").to(n,"value"),l.delegate("execute").to(s),l.on("execute",(t,i)=>{e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),e.editing.view.focus()}),s.on("change:isOpen",(t,i,n)=>{a||(a=!0,l.appendUI()),n&&(0!==r&&l.updateDocumentColors(e.model,this.componentName),l.updateSelectedColors(),l.showColorGridsFragment())}),s.panelView.children.add(l),s})}}class eE extends XT{constructor(e){const t=e.locale.t;super(e,{commandName:IT,componentName:IT,icon:Wm,dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class tE extends $n{static get requires(){return[ZT,eE]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class iE extends TT{constructor(e){super(e,PT)}}class nE extends $n{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(PT,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(ru),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:PT,value:OT("background-color")}}),e.conversion.for("downcast").attributeToElement({model:PT,view:RT("background-color")}),e.commands.add(PT,new iE(e)),e.model.schema.extend("$text",{allowAttributes:PT}),e.model.schema.setAttributeProperties(PT,{isFormatting:!0,copyOnEnter:!0})}}class sE extends XT{constructor(e){const t=e.locale.t;super(e,{commandName:PT,componentName:PT,icon:Um,dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class oE extends $n{static get requires(){return[nE,sE]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}class rE extends $n{static get requires(){return[qT,QT,tE,oE]}static get pluginName(){return"Font"}static get isOfficialPlugin(){return!0}}class aE{_placeholderMap;_wrapper=null;_document;_annotationsUIsData=null;_paginationBodyCollection=null;_hasLeftCollapseButton=!1;_collapseLeftSidebarButton=null;_resizeObserver=null;_sidebarsWidths={left:0,right:0};_keepLeftSidebarHidden=!1;_forceShowLeftSidebar=!1;_sourceEditingCallback=(e,t,i)=>{this.getWrapper().querySelector(".ck-fullscreen__document-outline-header").style.display=i?"none":""};_hiddenElements=new Map;_savedAncestorsScrollPositions=new Map;_showRevisionViewerCallback=null;_closeRevisionViewerCallback=null;_aiTabsData=null;constructor(t){this._placeholderMap=new Map,t.plugins.has("RevisionHistory")&&(this._showRevisionViewerCallback=t.config.get("revisionHistory").showRevisionViewerCallback,this._closeRevisionViewerCallback=t.config.get("revisionHistory").closeRevisionViewerCallback),this._editor=t,this._document=this._editor.sourceElement?this._editor.sourceElement.ownerDocument:e.document,this._editor.config.define("fullscreen.container",this._document.body),t.on("destroy",()=>{this._wrapper&&this.destroy(),this._resizeObserver&&this._resizeObserver.destroy()})}moveToFullscreen(e,t){const i=Qt(this._document,"div");i.setAttribute("data-ck-fullscreen-placeholder",t),e.replaceWith(i),this.getWrapper().querySelector(`[data-ck-fullscreen="${t}"]`).append(e),this._placeholderMap.set(t,{placeholderElement:i,movedElement:e})}restoreMovedElementLocation(e){if(!this._placeholderMap.has(e))return;const{placeholderElement:t,movedElement:i}=this._placeholderMap.get(e);t.replaceWith(i),t.remove(),this._placeholderMap.delete(e),0===this._placeholderMap.size&&this._destroyContainer()}getWrapper(){return this._wrapper||(this._wrapper=Qt(this._document,"div",{class:"ck ck-fullscreen__main-wrapper"}),this._wrapper.innerHTML='\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t',this._editor.config.get("fullscreen.container").appendChild(this._wrapper)),this._wrapper}enable(){if(this._saveAncestorsScrollPositions(this._editor.ui.getEditableElement()),this.defaultOnEnter(),this._editor.config.get("fullscreen.container")===this._document.body&&(this._document.body.classList.add("ck-fullscreen"),this._document.body.parentElement.classList.add("ck-fullscreen")),this._editor.plugins.has("PresenceListUI")&&this._generatePresenceListContainer(),this._editor.plugins.has("DocumentOutlineUI")&&this._generateDocumentOutlineContainer(),this._hasLeftCollapseButton&&this._generateCollapseButton(),this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled){const e=this._editor.plugins.get("PaginationRenderer");e.setupScrollableAncestor(),this._paginationBodyCollection=new Np(this._editor.locale),this._paginationBodyCollection.attachToDom(),e.linesRepository.setViewCollection(this._paginationBodyCollection),this._editor.once("destroy",()=>{this._paginationBodyCollection.detachFromDom()}),this.moveToFullscreen(this._paginationBodyCollection.bodyCollectionContainer,"body-wrapper")}this._editor.plugins.has("AnnotationsUIs")&&this._overrideAnnotationsUIs(),this._editor.plugins.has("RevisionHistory")&&(this._editor.plugins.get("RevisionHistory").isRevisionViewerOpen&&this._editor.config.get("revisionHistory.closeRevisionViewerCallback")(),this._overrideRevisionHistoryCallbacks()),this._editor.plugins.has("AITabs")&&this._handleAITabsTransfer(),this._editor.plugins.has("SourceEditing")&&this._editor.plugins.has("DocumentOutlineUI")&&this._editor.plugins.get("SourceEditing").on("change:isSourceEditingMode",this._sourceEditingCallback),this._editor.plugins.has("Dialog")&&this._registerFullscreenDialogPositionAdjustments();for(const e of this._editor.config.get("fullscreen.container").children)e===this._wrapper||e.classList.contains("ck-body-wrapper")||e.classList.contains("ckbox-wrapper")||"none"===e.style.display||(this._hiddenElements.set(e,e.style.display),e.style.display="none");this._sidebarsWidths={left:this._wrapper.querySelector(".ck-fullscreen__left-sidebar").scrollWidth,right:this._wrapper.querySelector(".ck-fullscreen__right-sidebar").scrollWidth},this._adjustVisibleElements(),this._setupResizeObserver(),this._editor.config.get("fullscreen.onEnterCallback")&&this._editor.config.get("fullscreen.onEnterCallback")(this.getWrapper())}disable(){this._editor.config.get("fullscreen.onLeaveCallback")&&this._editor.config.get("fullscreen.onLeaveCallback")(this.getWrapper()),this._document.body.classList.remove("ck-fullscreen"),this._document.body.parentElement.classList.remove("ck-fullscreen"),this._editor.plugins.has("DocumentOutlineUI")&&this._restoreDocumentOutlineDefaultContainer(),this._annotationsUIsData&&this._restoreAnnotationsUIs(),this._editor.plugins.has("RevisionHistory")&&this._restoreRevisionHistoryCallbacks(),this._editor.plugins.has("AITabs")&&this._restoreAITabs(),this._editor.plugins.has("SourceEditing")&&this._editor.plugins.has("DocumentOutlineUI")&&this._editor.plugins.get("SourceEditing").off("change:isSourceEditingMode",this._sourceEditingCallback);for(const e of this._placeholderMap.keys())this.restoreMovedElementLocation(e);this._destroyContainer(),this._editor.ui.view.toolbar&&this._editor.ui.view.toolbar.switchBehavior(!0===this._editor.config.get("toolbar.shouldNotGroupWhenFull")?"static":"dynamic");for(const[e,t]of this._savedAncestorsScrollPositions)e.scrollTo({left:t.scrollLeft,top:t.scrollTop,behavior:"instant"});if(this._savedAncestorsScrollPositions.clear(),this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled){const e=this._editor.plugins.get("PaginationRenderer");e.setupScrollableAncestor(),e.linesRepository.setViewCollection(this._editor.ui.view.body),this._paginationBodyCollection.detachFromDom(),this._paginationBodyCollection?.destroy()}this._editor.plugins.has("Dialog")&&this._unregisterFullscreenDialogPositionAdjustments(),this._keepLeftSidebarHidden=!1,this._resizeObserver?.destroy()}destroy(){for(const{placeholderElement:e,movedElement:t}of this._placeholderMap.values())e.remove(),t.remove();this._destroyContainer(),this._document.body.classList.remove("ck-fullscreen"),this._document.body.parentElement.classList.remove("ck-fullscreen")}defaultOnEnter(){return this.getWrapper()}_destroyContainer(){if(this._wrapper){this._wrapper.remove(),this._wrapper=null;for(const[e,t]of this._hiddenElements)e.style.display=t;this._hiddenElements.clear()}}_generatePresenceListContainer(){const e=this._editor.t,t=Qt(document,"div",{class:"ck ck-fullscreen__left-sidebar-item"});t.innerHTML='\n\t\t\t\n\t\t\t\n\t\t',t.firstElementChild.innerText=e("Connected users"),document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]')||document.querySelector('[data-ck-fullscreen="left-sidebar"]').appendChild(Qt(document,"div",{class:"ck ck-fullscreen__left-sidebar-sticky","data-ck-fullscreen":"left-sidebar-sticky"})),document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]').appendChild(t);const i=this._editor.plugins.get("PresenceListUI");this.moveToFullscreen(i.view.element,"presence-list"),this._hasLeftCollapseButton=!0}_generateDocumentOutlineContainer(){const e=this._editor.t,t=Qt(document,"div",{class:"ck-fullscreen__left-sidebar-item ck-fullscreen__left-sidebar-item--no-margin"});t.innerHTML='\n\t\t\t\n\t\t',t.firstElementChild.innerText=e("Document outline");const i=Qt(document,"div",{class:"ck ck-fullscreen__left-sidebar-item ck-fullscreen__document-outline-wrapper"});i.innerHTML='\n\t\t\t\n\t\t',document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]')||document.querySelector('[data-ck-fullscreen="left-sidebar"]').appendChild(Qt(document,"div",{class:"ck ck-fullscreen__left-sidebar-sticky","data-ck-fullscreen":"left-sidebar-sticky"})),document.querySelector('[data-ck-fullscreen="left-sidebar"]').appendChild(i),document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]').appendChild(t);const n=this._editor.plugins.get("DocumentOutlineUI");n.view.documentOutlineContainer=document.querySelector('[data-ck-fullscreen="left-sidebar"]'),this.moveToFullscreen(n.view.element,"document-outline"),this._hasLeftCollapseButton=!0}_restoreDocumentOutlineDefaultContainer(){const e=this._editor.plugins.get("DocumentOutlineUI");e.view.documentOutlineContainer=e.view.element}_generateCollapseButton(){const e=new yp(this._editor.locale),t=document.querySelector(".ck-fullscreen__left-sidebar"),i=this._editor.t;e.set({label:i("Toggle sidebar"),class:"ck-fullscreen__left-sidebar-toggle-button",tooltip:i("Hide left sidebar"),tooltipPosition:"se",icon:bf}),e.on("execute",()=>{t.classList.contains("ck-fullscreen__left-sidebar--collapsed")?(this._forceShowLeftSidebar=!0,this._keepLeftSidebarHidden=!1,this._showLeftSidebar()):(this._keepLeftSidebarHidden=!0,this._hideLeftSidebar()),this._editor.editing.view.focus()}),e.render(),this._collapseLeftSidebarButton=e,t.prepend(e.element)}_overrideAnnotationsUIs(){const e=this._editor.plugins.get("AnnotationsUIs");this._annotationsUIsData=new Map(e.uisData),e.deactivateAll();const t=this._editor.plugins.get("Sidebar");t.container?(this._switchAnnotationsUI("wideSidebar"),this.moveToFullscreen(t.container.firstElementChild,"right-sidebar"),t.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]'))):(t.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]')),this._switchAnnotationsUI("wideSidebar"),this.moveToFullscreen(t.container.firstElementChild,"right-sidebar"))}_restoreAnnotationsUIs(){const e=this._editor.plugins.get("Sidebar"),t=e.context.config.get("sidebar.container");t&&e.setContainer(t);const i=this._editor.plugins.get("AnnotationsUIs");i.deactivateAll();for(const[e,t]of[...this._annotationsUIsData])i.activate(e,t.filter);this._annotationsUIsData=null}_overrideRevisionHistoryCallbacks(){this._editor.config.set("revisionHistory.showRevisionViewerCallback",async()=>{const e=await this._showRevisionViewerCallback();return this._editor.plugins.has("DocumentOutlineUI")&&(this.getWrapper().querySelector(".ck-fullscreen__document-outline-header").style.display="none"),this.restoreMovedElementLocation("editable"),this.restoreMovedElementLocation("toolbar"),this.restoreMovedElementLocation("right-sidebar"),this._annotationsUIsData&&this._restoreAnnotationsUIs(),this._editor.ui.view.menuBarView&&this._editor.ui.view.menuBarView.disable(),this.moveToFullscreen(e.ui.getEditableElement(),"editable"),this.moveToFullscreen(e.ui.view.toolbar.element,"toolbar"),this.moveToFullscreen(this._editor.config.get("revisionHistory.viewerSidebarContainer"),"right-sidebar"),e}),this._editor.config.set("revisionHistory.closeRevisionViewerCallback",async()=>{this.restoreMovedElementLocation("toolbar"),this.restoreMovedElementLocation("editable"),this.restoreMovedElementLocation("right-sidebar"),this._editor.plugins.has("DocumentOutlineUI")&&(this.getWrapper().querySelector(".ck-fullscreen__document-outline-header").style.display=""),this.moveToFullscreen(this._editor.ui.getEditableElement(),"editable"),this.moveToFullscreen(this._editor.ui.view.toolbar.element,"toolbar"),await this._closeRevisionViewerCallback(),this._editor.plugins.has("AnnotationsUIs")&&this._overrideAnnotationsUIs(),this._editor.ui.view.menuBarView&&this._editor.ui.view.menuBarView.enable()})}_restoreRevisionHistoryCallbacks(){this._editor.config.set("revisionHistory.showRevisionViewerCallback",async()=>this._showRevisionViewerCallback()),this._editor.config.set("revisionHistory.closeRevisionViewerCallback",async()=>this._closeRevisionViewerCallback())}_registerFullscreenDialogPositionAdjustments(){const e=this._editor.plugins.get("Dialog");this._setNewDialogPosition(),e.on("change:isOpen",this.updateDialogPositionCallback,{priority:"highest"})}_unregisterFullscreenDialogPositionAdjustments(){const e=this._editor.plugins.get("Dialog"),t=e.view;t&&null===t.position&&(t.position=Pp.EDITOR_TOP_SIDE),t&&t.updatePosition(),e.off("change:isOpen",this.updateDialogPositionCallback)}updateDialogPositionCallback=this._updateDialogPosition.bind(this);_updateDialogPosition(e,t,i){i&&this._setNewDialogPosition()}_setNewDialogPosition(){const e=this._editor.plugins.get("Dialog").view;if(!e||e.position!==Pp.EDITOR_TOP_SIDE)return;const t=new pi(this._wrapper.querySelector(".ck-fullscreen__right-edge")).getVisible(),i=t?this._wrapper.querySelector(".ck-fullscreen__right-edge"):this._wrapper,n=new pi(i).getVisible(),s=new pi(document.querySelector(".ck-fullscreen__editable")).getVisible(),o=new pi(e.element.querySelector(".ck-dialog")).getVisible(),r=new pi(document.querySelector(".ck-fullscreen__editable-wrapper")).excludeScrollbarsAndBorders().getVisible().width-new pi(document.querySelector(".ck-fullscreen__editable-wrapper")).getVisible().width;if(n&&s&&o){e.position=null;const i=t?n.left-o.width-28:n.left+n.width-o.width-28+r;e.moveTo(i,s.top)}}_saveAncestorsScrollPositions(t){let i=t.parentElement;if(i)for(;i;){const t=i.style.overflowY||e.window.getComputedStyle(i).overflowY,n=i.style.overflowX||e.window.getComputedStyle(i).overflowX;("auto"===t||"scroll"===t||"auto"===n||"scroll"===n||"HTML"===i.tagName)&&this._savedAncestorsScrollPositions.set(i,{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}),i=i.parentElement}}_handleAITabsTransfer(){const e=this._editor.plugins.get("AITabs");this._aiTabsData={side:e.side,type:e.type},this.moveToFullscreen(e.view.element,"right-edge"),e.side="right",e.type="sidebar",e.view.element.addEventListener("transitionend",e=>this._handleAISidebarTransitions(e))}_handleAISidebarTransitions(e){const t=this._editor.plugins.get("AITabs");e.target===t.view.element&&e.propertyName.includes("width")&&this._adjustVisibleElements()}_restoreAITabs(){const e=this._editor.plugins.get("AITabs");e.side=this._aiTabsData?.side,e.type=this._aiTabsData?.type,this._aiTabsData=null,e.view.element.removeEventListener("transitionend",this._handleAISidebarTransitions)}_adjustVisibleElements(){const e=this._wrapper.querySelector(".ck-fullscreen__editable-wrapper");if(this._forceShowLeftSidebar)this._forceShowLeftSidebar=!1;else if(e.scrollWidth>e.clientWidth)this._hideLeftSidebar(),e.scrollWidth>e.clientWidth&&this._hideRightSidebar();else{let t=[...e.children].reduce((e,t)=>e+t.scrollWidth,0);t+this._sidebarsWidths.righte+t.scrollWidth,0)),t+this._sidebarsWidths.left[...i.values()].some(t=>t(e))):t.switchTo(e)}_setupResizeObserver(){const e=this._wrapper.querySelector(".ck-fullscreen__editable-wrapper");this._resizeObserver&&this._resizeObserver.destroy(),this._resizeObserver=new ki(e,()=>{this._adjustVisibleElements()})}_hideLeftSidebar(){const e=this._editor.t;if(this._collapseLeftSidebarButton){this._wrapper.querySelector(".ck-fullscreen__left-sidebar").classList.add("ck-fullscreen__left-sidebar--collapsed"),this._collapseLeftSidebarButton.icon=Em,this._collapseLeftSidebarButton.tooltip=e("Show left sidebar")}}_showLeftSidebar(){const e=this._editor.t;if(this._collapseLeftSidebarButton){this._wrapper.querySelector(".ck-fullscreen__left-sidebar").classList.remove("ck-fullscreen__left-sidebar--collapsed"),this._collapseLeftSidebarButton.icon=bf,this._collapseLeftSidebarButton.tooltip=e("Hide left sidebar")}}_hideRightSidebar(){this._wrapper.querySelector(".ck-fullscreen__right-sidebar").firstChild&&(this._switchAnnotationsUI("narrowSidebar"),this._wrapper.querySelector(".ck-fullscreen__right-sidebar").classList.add("ck-fullscreen__right-sidebar--collapsed"))}_showRightSidebar(){this._wrapper.querySelector(".ck-fullscreen__right-sidebar").firstChild&&(this._switchAnnotationsUI("wideSidebar"),this._wrapper.querySelector(".ck-fullscreen__right-sidebar").classList.remove("ck-fullscreen__right-sidebar--collapsed"))}}class lE extends aE{_editor;constructor(e){super(e),this._editor=e}defaultOnEnter(){const e=this._editor.ui,t=e.view;return this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled&&this.moveToFullscreen(e.getEditableElement().parentElement.querySelector(".ck-pagination-view"),"pagination-view"),this.moveToFullscreen(e.getEditableElement(),"editable"),this.moveToFullscreen(t.toolbar.element,"toolbar"),t.toolbar.switchBehavior(!0===this._editor.config.get("fullscreen.toolbar.shouldNotGroupWhenFull")?"static":"dynamic"),this.getWrapper().setAttribute("dir",t.element.getAttribute("dir")),this.getWrapper().classList.add("ck-rounded-corners"),this._editor.config.get("fullscreen.menuBar.isVisible")&&(t.menuBarView||(t.menuBarView=new p_(this._editor.locale),t.menuBarView.render(),e.initMenuBar(t.menuBarView)),this.moveToFullscreen(t.menuBarView.element,"menu-bar")),this.getWrapper()}}class cE extends aE{_editor;constructor(e){super(e),this._editor=e}defaultOnEnter(){return this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled&&this.moveToFullscreen(this._editor.ui.getEditableElement().parentElement.querySelector(".ck-pagination-view"),"pagination-view"),this.moveToFullscreen(this._editor.ui.getEditableElement(),"editable"),this.moveToFullscreen(this._editor.ui.view.toolbar.element,"toolbar"),this._editor.ui.view.toolbar.switchBehavior(!0===this._editor.config.get("fullscreen.toolbar.shouldNotGroupWhenFull")?"static":"dynamic"),this._editor.config.get("fullscreen.menuBar.isVisible")&&this.moveToFullscreen(this._editor.ui.view.menuBarView.element,"menu-bar"),this.getWrapper()}}class uE extends Gn{fullscreenHandler;constructor(e){super(e),this.affectsData=!1,this.isEnabled=!0,this.value=!1,!function(e){return"ClassicEditor"===e.constructor.editorName}(e)?!function(e){return"DecoupledEditor"===e.constructor.editorName}(e)?this.fullscreenHandler=new aE(e):this.fullscreenHandler=new cE(e):this.fullscreenHandler=new lE(e)}execute(){this.value?this._disableFullscreenMode():this._enableFullscreenMode()}_enableFullscreenMode(){this.fullscreenHandler.enable(),this.value=!0}_disableFullscreenMode(){this.fullscreenHandler.disable(),this.value=!1}}class dE extends $n{static get pluginName(){return"FullscreenEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("fullscreen.menuBar.isVisible",!0),e.config.define("fullscreen.toolbar.shouldNotGroupWhenFull",!0===e.config.get("toolbar.shouldNotGroupWhenFull"))}init(){this.editor.commands.add("toggleFullscreen",new uE(this.editor));const e=this.editor.locale.t;this.editor.keystrokes.set("Ctrl+Shift+F",(e,t)=>{this.editor.execute("toggleFullscreen"),n.isBlink||(this.editor.editing.view.document.isFocused=!1,this.editor.ui.view.toolbar.focusTracker.focusedElement=null),this.editor.editing.view.scrollToTheSelection(),this.editor.editing.view.focus(),t()}),this.editor.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Toggle fullscreen mode"),keystroke:"CTRL+SHIFT+F"}],categoryId:"navigation"})}}const hE="toggleFullscreen";class mE extends $n{static get requires(){return[dE]}static get pluginName(){return"FullscreenUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("fullscreen",()=>this._createButton(yp)),e.ui.componentFactory.add("menuBar:fullscreen",()=>this._createButton(Mp))}_createButton(e){const t=this.editor,i=t.t,s=t.commands.get(hE),o=new e(t.locale);return o.set({isToggleable:!0}),o.bind("isEnabled").to(s,"isEnabled"),o.bind("isOn").to(s,"value"),o instanceof Mp?o.set({role:"menuitemcheckbox",label:i("Fullscreen mode")}):(o.bind("icon").to(s,"value",e=>e?Jm:Km),o.bind("label").to(s,"value",e=>i(e?"Leave fullscreen mode":"Enter fullscreen mode")),o.set({tooltip:!0})),this.listenTo(o,"execute",()=>{t.execute(hE),n.isBlink||(this.editor.ui.view.toolbar.focusTracker.focusedElement=null),t.editing.view.scrollToTheSelection(),t.editing.view.focus()}),o}}class gE extends $n{static get requires(){return[dE,mE]}static get pluginName(){return"Fullscreen"}static get isOfficialPlugin(){return!0}}class fE extends Gn{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=fn(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&pE(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change(e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&pE(n,t.schema)&&e.rename(n,"paragraph")})}}function pE(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class bE extends Gn{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;return t.canEditAt(n)?t.change(e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return null;const s=e.createElement("paragraph");return i&&t.schema.setAllowedAttributes(s,i,e),t.insertContent(s,n),e.setSelection(s,"in"),e.createPositionAt(s,0)}):null}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const s=e.parent,o=i.schema.checkChild(s,"$text");return s.isEmpty||o&&e.isAtEnd?i.createPositionAfter(s):!s.isEmpty&&o&&e.isAtStart?i.createPositionBefore(s):t.split(e,n).position}}class wE extends $n{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new fE(e)),e.commands.add("insertParagraph",new bE(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>wE.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}static paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"])}class vE extends $n{static get requires(){return[wE]}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("paragraph",i=>{const n=new yp(i),s=e.commands.get("paragraph");return n.label=t("Paragraph"),n.icon=uf,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(s),n.bind("isOn").to(s,"value"),n.on("execute",()=>{e.execute("paragraph")}),n})}}class _E extends Gn{modelElements;constructor(e,t){super(e),this.modelElements=t}refresh(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>yE(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change(e=>{const s=Array.from(i.selection.getSelectedBlocks()).filter(e=>yE(e,n,t.schema));for(const t of s)t.is("element",n)||e.rename(t,n)})}}function yE(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const kE="paragraph";class CE extends $n{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[wE]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new _E(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(t,n)=>{const s=e.model.document.selection.getFirstPosition().parent,o=i.some(e=>s.is("element",e.model));o&&!s.is("element",kE)&&0===s.childCount&&n.writer.rename(s,kE)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:T.low+1})}}function xE(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map(e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e})}class AE extends $n{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=xE(e),n=t("Choose heading"),s=t("Heading");e.ui.componentFactory.add("heading",t=>{const o={},r=new gn,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new Hv({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",t=>t===e.model),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),o[e.model]=e.title}const u=ow(t);return uw(u,r,{ariaLabel:s,role:"menu"}),u.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),u.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),u.bind("isEnabled").toMany(c,"isEnabled",(...e)=>e.some(e=>e)),u.buttonView.bind("label").to(a,"value",l,"value",(e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?n:o[i]?o[i]:n}),u.buttonView.bind("ariaLabel").to(a,"value",l,"value",(e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?s:o[i]?`${o[i]}, ${s}`:s}),this.listenTo(u,"execute",t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()}),u}),e.ui.componentFactory.add("menuBar:heading",n=>{const s=new d_(n),o=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[o],l=new h_(n);s.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),s.buttonView.set({label:t("Heading")}),s.panelView.children.add(l);for(const t of i){const i=new hv(n,s),c=new Mp(n);i.children.add(c),l.items.add(i),c.set({isToggleable:!0,label:t.title,role:"menuitemradio",class:t.class}),c.delegate("execute").to(s),c.on("execute",()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()}),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(o,"value",e=>e===t.model)}return s.bind("isEnabled").toMany(a,"isEnabled",(...e)=>e.some(e=>e)),s})}}class TE extends $n{static get requires(){return[CE,AE]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}const EE=(()=>({heading1:Zm,heading2:Xm,heading3:eg,heading4:tg,heading5:ig,heading6:ng}))();class SE extends $n{init(){xE(this.editor).filter(e=>"paragraph"!==e.model).map(e=>this._createButton(e))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,i=>{const n=new yp(i),s=t.commands.get("heading");return n.label=e.title,n.icon=e.icon||EE[e.model],n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(s),n.bind("isOn").to(s,"value",t=>t==e.model),n.on("execute",()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()}),n})}}const IE=new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class PE extends $n{_bodyPlaceholder=new Map;static get pluginName(){return"Title"}static get isOfficialPlugin(){return!0}static get requires(){return["Paragraph"]}init(){const e=this.editor,t=e.model;t.schema.register("title",{isBlock:!0,allowIn:"$root"}),t.schema.register("title-content",{isBlock:!0,allowIn:"title",allowAttributes:["alignment"]}),t.schema.extend("$text",{allowIn:"title-content"}),t.schema.addAttributeCheck(e=>{if(e.endsWith("title-content $text"))return!1}),e.editing.mapper.on("modelToViewPosition",OE(e.editing.view)),e.data.mapper.on("modelToViewPosition",OE(e.editing.view)),e.conversion.for("downcast").elementToElement({model:"title-content",view:"h1"}),e.conversion.for("downcast").add(e=>e.on("insert:title",(e,t,i)=>{i.consumable.consume(t.item,e.name)})),e.data.upcastDispatcher.on("element:h1",VE,{priority:"high"}),e.data.upcastDispatcher.on("element:h2",VE,{priority:"high"}),e.data.upcastDispatcher.on("element:h3",VE,{priority:"high"}),t.document.registerPostFixer(e=>this._fixTitleContent(e)),t.document.registerPostFixer(e=>this._fixTitleElement(e)),t.document.registerPostFixer(e=>this._fixBodyElement(e)),t.document.registerPostFixer(e=>this._fixExtraParagraph(e)),this._attachPlaceholders(),this._attachTabPressHandling()}getTitle(e={}){const t=e.rootName?e.rootName:void 0,i=this._getTitleElement(t).getChild(0);return this.editor.data.stringify(i,e)}getBody(e={}){const t=this.editor,i=t.data,n=t.model,s=e.rootName?e.rootName:void 0,o=t.model.document.getRoot(s),r=t.editing.view,a=new uo(r.document),l=n.createRangeIn(o),c=a.createDocumentFragment(),u=n.createPositionAfter(o.getChild(0)),d=n.createRange(u,n.createPositionAt(o,"end")),h=new Map;for(const e of n.markers){const t=d.getIntersection(e.getRange());t&&h.set(e.name,t)}return i.mapper.clearBindings(),i.mapper.bindElements(o,c),i.downcastDispatcher.convert(l,h,a,e),a.remove(a.createRangeOn(c.getChild(0))),t.data.processor.toData(c)}_getTitleElement(e){const t=this.editor.model.document.getRoot(e);for(const e of t.getChildren())if(RE(e))return e}_fixTitleContent(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this._getTitleElement(i);if(!n||1===n.maxOffset)continue;const s=Array.from(n.getChildren());s.shift();for(const t of s)e.move(e.createRangeOn(t),n,"after"),e.rename(t,"paragraph");t=!0}return t}_fixTitleElement(e){let t=!1;const i=this.editor.model;for(const n of this.editor.model.document.getRoots()){const s=Array.from(n.getChildren()).filter(RE),o=s[0],r=n.getChild(0);if(r.is("element","title"))s.length>1&&(LE(s,e,i),t=!0);else{if(!o&&!IE.has(r.name)){const i=e.createElement("title");e.insert(i,n),e.insertElement("title-content",i),t=!0;continue}IE.has(r.name)?BE(r,e,i):e.move(e.createRangeOn(o),n,0),LE(s,e,i),t=!0}}return t}_fixBodyElement(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i);if(n.childCount<2){const s=e.createElement("paragraph");e.insert(s,n,1),this._bodyPlaceholder.set(i,s),t=!0}}return t}_fixExtraParagraph(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i),s=this._bodyPlaceholder.get(i);FE(s,n)&&(this._bodyPlaceholder.delete(i),e.remove(s),t=!0)}return t}_attachPlaceholders(){const e=this.editor,t=e.t,i=e.editing.view,n=e.sourceElement,s=e.config.get("title.placeholder")||t("Type your title"),o=e.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder")||t("Type or paste your content here.");e.editing.downcastDispatcher.on("insert:title-content",(e,t,n)=>{const o=n.mapper.toViewElement(t.item);o.placeholder=s,ns({view:i,element:o,keepOnFocus:!0})});const r=new Map;i.document.registerPostFixer(e=>{let t=!1;for(const n of i.document.roots){if(n.isEmpty)continue;const i=n.getChild(1),s=r.get(n.rootName);i!==s&&(s&&(rs(e,s),e.removeAttribute("data-placeholder",s)),e.setAttribute("data-placeholder",o,i),r.set(n.rootName,i),t=!0),t=as(i,!0)&&2===n.childCount&&"p"===i.name?!!os(e,i)||t:!!rs(e,i)||t}return t})}_attachTabPressHandling(){const e=this.editor,t=e.model;e.keystrokes.set("TAB",(e,i)=>{t.change(e=>{const n=t.document.selection,s=Array.from(n.getSelectedBlocks());if(1===s.length&&s[0].is("element","title-content")){const t=n.getFirstPosition().root.getChild(1);e.setSelection(t,0),i()}})}),e.keystrokes.set("SHIFT + TAB",(i,n)=>{t.change(i=>{const s=t.document.selection;if(!s.isCollapsed)return;const o=fn(s.getSelectedBlocks()),r=s.getFirstPosition(),a=e.model.document.getRoot(r.root.rootName),l=a.getChild(0);o===a.getChild(1)&&r.isAtStart&&(i.setSelection(l.getChild(0),0),n())})})}}function VE(e,t,i){const n=t.modelCursor,s=t.viewItem;if(!n.isAtStart||!n.parent.is("element","$root"))return;if(!i.consumable.consume(s,{name:!0}))return;const o=i.writer,r=o.createElement("title"),a=o.createElement("title-content");o.append(a,r),o.insert(r,n),i.convertChildren(s,a),i.updateConversionResult(r,t)}function OE(e){return(t,i)=>{const n=i.modelPosition.parent;if(!n.is("element","title"))return;const s=n.parent,o=i.mapper.toViewElement(s);i.viewPosition=e.createPositionAt(o,0),t.stop()}}function RE(e){return e.is("element","title")}function BE(e,t,i){const n=t.createElement("title");t.insert(n,e,"before"),t.insert(e,n,0),t.rename(e,"title-content"),i.schema.removeDisallowedAttributes([e],t)}function LE(e,t,i){let n=!1;for(const s of e)0!==s.index&&(ME(s,t,i),n=!0);return n}function ME(e,t,i){const n=e.getChild(0);n.isEmpty?t.remove(e):(t.move(t.createRangeOn(n),e,"before"),t.rename(n,"paragraph"),t.remove(e),i.schema.removeDisallowedAttributes([n],t))}function FE(e,t){return!(!e||!e.is("element","paragraph")||e.childCount)&&!(t.childCount<=2||t.getChild(t.childCount-1)!==e)}class NE extends Gn{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change(e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,s=t.getLastMatchingPosition(i,{direction:"backward"}),o=t.getLastMatchingPosition(i),r=e.createRange(s,o);n&&this.value!==n?(t.isEqual(o)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(o)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const s=t.schema.getValidRanges(i.getRanges(),"highlight");for(const t of s)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)}})}}class DE extends $n{static get pluginName(){return"HighlightEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-content-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-content-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-content-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-content-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-content-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-content-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new NE(e))}}class zE extends $n{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),Bm,null,e=>{e.bind("isEnabled").to(t,"isEnabled")})}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,HE(e.type),e.model,function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",t=>t===e.model),i.iconView.fillColor=e.color,i.isToggleable=!0})}_addButton(e,t,i,n,s){const o=this.editor;o.ui.componentFactory.add(e,e=>{const r=new yp(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",()=>{o.execute("highlight",{value:n}),o.editing.view.focus()}),s(r),r})}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,s=e[0],o=e.reduce((e,t)=>(e[t.model]=t,e),{});n.add("highlight",r=>{const a=t.commands.get("highlight"),l=ow(r,sw),c=l.buttonView;c.set({label:i("Highlight"),tooltip:!0,lastExecuted:s.model,commandValue:s.model,isToggleable:!0}),c.bind("icon").to(a,"value",e=>HE(u(e,"type"))),c.bind("color").to(a,"value",e=>u(e,"color")),c.bind("commandValue").to(a,"value",e=>u(e,"model")),c.bind("isOn").to(a,"value",e=>!!e),c.delegate("execute").to(l);function u(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return o[i][t]}return l.bind("isEnabled").to(a,"isEnabled"),lw(l,()=>{const t=e.map(e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",()=>{l.buttonView.set({lastExecuted:e.model})}),t});return t.push(new Jb),t.push(n.create("removeHighlight")),t},{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){const t=e.buttonView.actionView;t.iconView.bind("fillColor").to(e.buttonView,"color")}(l),c.on("execute",()=>{t.execute("highlight",{value:c.commandValue})}),this.listenTo(l,"execute",()=>{t.editing.view.focus()}),l})}_addMenuBarButton(e){const t=this.editor,i=t.t,n=t.commands.get("highlight");t.ui.componentFactory.add("menuBar:highlight",s=>{const o=new d_(s);o.buttonView.set({label:i("Highlight"),icon:HE("marker")}),o.bind("isEnabled").to(n),o.buttonView.iconView.fillColor="transparent";const r=new h_(s);for(const i of e){const e=new hv(s,o),a=new Mp(s);a.set({label:i.title,icon:HE(i.type),role:"menuitemradio",isToggleable:!0}),a.iconView.fillColor=i.color,a.delegate("execute").to(o),a.bind("isOn").to(n,"value",e=>e===i.model),a.on("execute",()=>{t.execute("highlight",{value:i.model}),t.editing.view.focus()}),e.children.add(a),r.items.add(e)}r.items.add(new Nb(s));const a=new hv(s,o),l=new Mp(s);return l.set({label:i("Remove highlight"),icon:Bm}),l.delegate("execute").to(o),l.on("execute",()=>{t.execute("highlight",{value:null}),t.editing.view.focus()}),a.children.add(l),r.items.add(a),o.panelView.children.add(r),o})}}function HE(e){return"marker"===e?Rg:hf}class qE extends $n{static get requires(){return[DE,zE]}static get pluginName(){return"Highlight"}static get isOfficialPlugin(){return!0}}class UE extends Gn{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=xk(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})})}}class WE extends $n{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),s=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",s),t.setCustomProperty("hr",!0,s),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),bk(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new UE(e))}}class $E extends $n{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",()=>{const e=this._createButton(yp);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:horizontalLine",()=>this._createButton(Mp))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("horizontalLine"),s=new e(t.locale),o=i.t;return s.set({label:o("Horizontal line"),icon:og}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("horizontalLine"),t.editing.view.focus()}),s}}class jE extends $n{static get requires(){return[WE,$E,qk]}static get pluginName(){return"HorizontalLine"}static get isOfficialPlugin(){return!0}}class GE extends Gn{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=KE(i);this.isEnabled=function(e,t,i){const n=function(e,t){const i=xk(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("rootElement"))return n.parent;return n}(e,i);return t.checkChild(n,"rawHtml")}(i,t,e),this.value=n?n.getAttribute("value")||"":null}execute(e){const t=this.editor.model,i=t.document.selection;t.change(n=>{let s;null!==this.value?s=KE(i):(s=n.createElement("rawHtml"),t.insertObject(s,null,null,{setSelection:"on"})),n.setAttribute("value",e,s)})}}function KE(e){const t=e.getSelectedElement();return t&&t.is("element","rawHtml")?t:null}class JE extends $n{_widgetButtonViewReferences=new Set;static get pluginName(){return"HtmlEmbedEditing"}static get licenseFeatureCode(){return"HE"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:e=>(P("html-embed-provide-sanitize-function"),{html:e,hasChanged:!1})})}init(){const e=this.editor;e.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),e.commands.add("htmlEmbed",new GE(e)),this._setupConversion()}_setupConversion(){const e=this.editor,t=e.t,i=e.editing.view,n=this._widgetButtonViewReferences,s=e.config.get("htmlEmbed");function o({editor:e,domElement:i,state:s,props:o}){i.textContent="";const a=i.ownerDocument;let l;if(s.isEditable){const e={isDisabled:!1,placeholder:o.textareaPlaceholder};l=r({domDocument:a,state:s,props:e}),i.append(l)}else if(s.showPreviews){const n={sanitizeHtml:o.sanitizeHtml};i.append(function({editor:e,domDocument:i,state:n,props:s}){const o=s.sanitizeHtml(n.getRawHtmlValue()),r=n.getRawHtmlValue().length>0?t("No preview available"):t("Empty snippet content"),a=Qt(i,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},r),l=Qt(i,"div",{class:"raw-html-embed__preview-content",dir:e.locale.contentLanguageDirection}),c=i.createRange(),u=c.createContextualFragment(o.html);l.appendChild(u);const d=Qt(i,"div",{class:"raw-html-embed__preview"},[a,l]);return d}({domDocument:a,state:s,props:n,editor:e}))}else{const e={isDisabled:!0,placeholder:o.textareaPlaceholder};i.append(r({domDocument:a,state:s,props:e}))}const c={onEditClick:o.onEditClick,onSaveClick:()=>{o.onSaveClick(l.value)},onCancelClick:o.onCancelClick};i.prepend(function({editor:e,domDocument:t,state:i,props:s}){const o=Qt(t,"div",{class:"raw-html-embed__buttons-wrapper"});if(i.isEditable){const t=QE(e,"save",s.onSaveClick),i=QE(e,"cancel",s.onCancelClick);o.append(t.element,i.element),n.add(t).add(i)}else{const t=QE(e,"edit",s.onEditClick);o.append(t.element),n.add(t)}return o}({editor:e,domDocument:a,state:s,props:c}))}function r({domDocument:e,state:t,props:i}){const n=Qt(e,"textarea",{placeholder:i.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return n.disabled=i.isDisabled,n.value=t.getRawHtmlValue(),n}this.editor.editing.view.on("render",()=>{for(const e of n){if(e.element&&e.element.isConnected)return;e.destroy(),n.delete(e)}},{priority:"lowest"}),e.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),e.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(e,{writer:t})=>t.createElement("rawHtml",{value:e.getCustomProperty("$rawContent")})}),e.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("div",{class:"raw-html-embed"},function(t){t.innerHTML=e.getAttribute("value")||""})}),e.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(n,{writer:r})=>{let a,l,c;const u=r.createRawElement("div",{class:"raw-html-embed__content-wrapper"},function(t){a=t,o({editor:e,domElement:t,state:l,props:c}),a.addEventListener("mousedown",()=>{if(l.isEditable){const t=e.model;t.document.selection.getSelectedElement()!==n&&t.change(e=>e.setSelection(n,"on"))}},!0)}),d={makeEditable(){l=Object.assign({},l,{isEditable:!0}),o({domElement:a,editor:e,state:l,props:c}),i.change(e=>{e.setAttribute("data-cke-ignore-events","true",u)}),a.querySelector("textarea").focus()},save(t){t!==l.getRawHtmlValue()?(e.execute("htmlEmbed",t),e.editing.view.focus()):this.cancel()},cancel(){l=Object.assign({},l,{isEditable:!1}),o({domElement:a,editor:e,state:l,props:c}),e.editing.view.focus(),i.change(e=>{e.removeAttribute("data-cke-ignore-events",u)})}};l={showPreviews:s.showPreviews,isEditable:!1,getRawHtmlValue:()=>n.getAttribute("value")||""},c={sanitizeHtml:s.sanitizeHtml,textareaPlaceholder:t("Paste raw HTML here..."),onEditClick(){d.makeEditable()},onSaveClick(e){d.save(e)},onCancelClick(){d.cancel()}};const h=r.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":t("HTML snippet"),dir:e.locale.uiLanguageDirection},u);return r.setCustomProperty("rawHtmlApi",d,h),r.setCustomProperty("rawHtml",!0,h),bk(h,r,{label:t("HTML snippet"),hasSelectionHandle:!0})}})}}function QE(e,t,i){const{t:n}=e.locale,s=new yp(e.locale),o=e.commands.get("htmlEmbed");return s.set({class:`raw-html-embed__${t}-button`,icon:df,tooltip:!0,tooltipPosition:"rtl"===e.locale.uiLanguageDirection?"e":"w"}),s.render(),"edit"===t?(s.set({icon:df,label:n("Edit source")}),s.bind("isEnabled").to(o)):"save"===t?(s.set({icon:am,label:n("Save changes")}),s.bind("isEnabled").to(o)):s.set({icon:sm,label:n("Cancel")}),s.on("execute",i),s}class YE extends $n{static get pluginName(){return"HtmlEmbedUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("htmlEmbed",()=>{const e=this._createButton(yp);return e.set({tooltip:!0,label:t("Insert HTML")}),e}),e.ui.componentFactory.add("menuBar:htmlEmbed",()=>{const e=this._createButton(Mp);return e.set({label:t("HTML snippet")}),e})}_createButton(e){const t=this.editor,i=t.commands.get("htmlEmbed"),n=new e(t.locale);return n.set({icon:rg}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",()=>{t.execute("htmlEmbed"),t.editing.view.focus();t.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()}),n}}class ZE extends $n{static get requires(){return[JE,YE,qk]}static get pluginName(){return"HtmlEmbed"}static get isOfficialPlugin(){return!0}}function XE(e,t,i,n){t&&tS(e,t,n),i&&eS(e,i,n)}function eS(e,t,i){if(t.attributes)for(const[n,s]of Object.entries(t.attributes))e.setAttribute(n,s,i);t.styles&&e.setStyle(t.styles,i),t.classes&&e.addClass(t.classes,i)}function tS(e,t,i){if(t.attributes)for(const[n]of Object.entries(t.attributes))e.removeAttribute(n,i);if(t.styles)for(const n of Object.keys(t.styles))e.removeStyle(n,i);t.classes&&e.removeClass(t.classes,i)}function iS(e,t){const i=Fe(e);let n="attributes";for(n in t)i[n]="classes"==n?Array.from(new Set([...e[n]||[],...t[n]])):{...e[n],...t[n]};return i}function nS(e,t,i,n,s){const o=t.getAttribute(i),r={};for(const e of["attributes","styles","classes"]){if(e!=n){o&&o[e]&&(r[e]=o[e]);continue}if("classes"==n){const t=new Set(o&&o.classes||[]);s(t),t.size&&(r[e]=Array.from(t));continue}const t=new Map(Object.entries(o&&o[e]||{}));s(t),t.size&&(r[e]=Object.fromEntries(t))}Object.keys(r).length?t.is("documentSelection")?e.setSelectionAttribute(i,r):e.setAttribute(i,r,t):o&&(t.is("documentSelection")?e.removeSelectionAttribute(i):e.removeAttribute(i,t))}function sS(e,t,i){for(const n of t.getItems({shallow:!0})){const t=n.getAttribute(e);t&&t.attributes&&Object.keys(t.attributes).length?Object.keys(t).length>1&&i.setAttribute(e,{attributes:t.attributes},n):i.removeAttribute(e,n)}}function oS(e){return Vt(e).replace(/ /g,"")}function rS(e){return`html${oS(e)}Attributes`}function aS({model:e}){return(t,i)=>i.writer.createElement(e,{htmlContent:t.getCustomProperty("$rawContent")})}function lS(e,{view:t,isInline:i}){const n=e.t;return(e,{writer:s})=>{const o=n("HTML object"),r=cS(t,e,s),a=e.getAttribute(rS(t));s.addClass("html-object-embed__content",r),a&&eS(s,a,r);return bk(s.createContainerElement(i?"span":"div",{class:"html-object-embed","data-html-object-embed-label":o},r),s,{label:o})}}function cS(e,t,i){return i.createRawElement(e,null,(e,i)=>{i.setContentOf(e,t.getAttribute("htmlContent"))})}function uS({view:e,model:t,allowEmpty:i},n){return t=>{t.on(`element:${e}`,(e,t,o)=>{let r=n.processViewAttributes(t.viewItem,o);if(r||o.consumable.test(t.viewItem,{name:!0})){if(r=r||{},o.consumable.consume(t.viewItem,{name:!0}),t.modelRange||(t=Object.assign(t,o.convertChildren(t.viewItem,t.modelCursor))),i&&t.modelRange.isCollapsed&&Object.keys(r).length){const e=o.writer.createElement("htmlEmptyElement");if(!o.safeInsert(e,t.modelCursor))return;const i=o.getSplitParts(e);return t.modelRange=o.writer.createRange(t.modelRange.start,o.writer.createPositionAfter(i[i.length-1])),o.updateConversionResult(e,t),void s(e,r,o)}for(const e of t.modelRange.getItems())s(e,r,o)}},{priority:"low"})};function s(e,i,n){if(n.schema.checkAttribute(e,t)){const s=iS(i,e.getAttribute(t)||{});n.writer.setAttribute(t,s,e)}}}function dS({model:e,view:t},i){return(n,{writer:s,consumable:o})=>{if(!n.hasAttribute(e))return null;const r=s.createContainerElement(t),a=n.getAttribute(e);return o.consume(n,`attribute:${e}`),eS(s,a,r),r.getFillerOffset=()=>null,i?bk(r,s):r}}function hS({priority:e,view:t}){return(i,n)=>{if(!i)return;const{writer:s}=n,o=s.createAttributeElement(t,null,{priority:e});return eS(s,i,o),o}}function mS({view:e},t){return i=>{i.on(`element:${e}`,(e,i,n)=>{if(!i.modelRange||i.modelRange.isCollapsed)return;const s=t.processViewAttributes(i.viewItem,n);s&&n.writer.setAttribute(rS(i.viewItem.name),s,i.modelRange)},{priority:"low"})}}function gS({view:e,model:t}){return i=>{i.on(`attribute:${rS(e)}:${t}`,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t;XE(i.writer,n,s,i.mapper.toViewElement(t.item))})}}const fS={block:[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"horizontalLine",view:"hr"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6","$text"],allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowIn:["$root","$container"],allowChildren:["paragraph","htmlP","htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlHr",view:"hr",isEmpty:!0,modelSchema:{inheritAllFrom:"$blockObject"}}],inline:[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref",attributeProperties:{isFormatting:!0}},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}]};class pS extends $n{_definitions=[];static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const e of fS.block)this.registerBlockElement(e);for(const e of fS.inline)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const n of this._getMatchingViewDefinitions(e)){if(t)for(const e of this._getReferences(n.model))i.add(e);i.add(n)}return i}getDefinitionsForModel(e){return this._definitions.filter(t=>t.model==e)}_getMatchingViewDefinitions(e){return this._definitions.filter(t=>t.view&&function(e,t){if("string"==typeof e)return e===t;if(e instanceof RegExp)return e.test(t);return!1}(e,t.view))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter(t=>t.model==e);for(const{modelSchema:n}of i)if(n)for(const i of t)for(const t of ln(n[i]||[])){const i=this._definitions.filter(e=>e.model==t);for(const n of i)t!==e&&(yield*this._getReferences(n.model),yield n)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter(([,t])=>t.model==e.model);if(0!=t.length)for(const[i,n]of t)this._definitions[i]=_t({},n,e,(e,t)=>Array.isArray(e)?e.concat(t):void 0);else this._definitions.push(e)}}class bS extends $n{_dataSchema;_allowedAttributes;_disallowedAttributes;_allowedElements;_disallowedElements;_dataInitialized;_coupledAttributes;constructor(e){super(e),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new vs,this._disallowedAttributes=new vs,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get isOfficialPlugin(){return!0}static get requires(){return[pS,qk]}loadAllowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=kS(t);this.allowElement(e),i.forEach(e=>this.allowAttributes(e))}}loadDisallowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=kS(t);0==i.length?this.disallowElement(e):i.forEach(e=>this.disallowAttributes(e))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return wS(e,this._disallowedAttributes,i),function(e,{attributes:t,classes:i,styles:n}){if(!t.length&&!i.length&&!n.length)return null;return{...t.length&&{attributes:vS(e,t)},...n.length&&{styles:_S(e,n)},...i.length&&{classes:i}}}(e,wS(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&"string"==typeof e.appliesToBlock)for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",()=>{this._fireRegisterEvent(e)},{priority:T.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)},{priority:T.highest+1})}_registerElementHandlers(){this.on("register",(e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else{if(!t.isInline)throw new I("data-filter-invalid-definition",null,t);this._registerInlineElement(t)}e.stop()},{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges();let n=!1;const s=this._getCoupledAttributesMap();for(const e of i){if("attribute"!=e.type||null!==e.attributeNewValue)continue;const i=s.get(e.attributeKey);if(i)for(const{item:s}of e.range.getWalker())for(const e of i)s.hasAttribute(e)&&(t.removeAttribute(e,s),n=!0)}return n}),this.listenTo(t,"change:attribute",(i,{attributeKeys:n})=>{const s=new Set,o=this._getCoupledAttributesMap();for(const e of n){if(t.hasAttribute(e))continue;const i=o.get(e);if(i)for(const e of i)t.hasAttribute(e)&&s.add(e)}0!=s.size&&e.change(e=>{for(const t of s)e.removeSelectionAttribute(t)})})}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges();let n=!1;for(const s of i)if("insert"===s.type&&"$text"!==s.name)for(const i of s.attributes.keys())i.startsWith("html")&&i.endsWith("Attributes")&&(e.schema.checkAttribute(s.name,i)||(t.removeAttribute(i,s.position.nodeAfter),n=!0));return n})}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:s,model:o}=e;i.register(o,e.modelSchema),s&&(i.extend(e.model,{allowAttributes:[rS(s),"htmlContent"]}),t.data.registerRawContentMatcher({name:s}),n.for("upcast").elementToElement({view:s,model:aS(e),converterPriority:T.low+2}),n.for("upcast").add(mS(e,this)),n.for("editingDowncast").elementToStructure({model:{name:o,attributes:[rS(s)]},view:lS(t,e)}),n.for("dataDowncast").elementToElement({model:o,view:(e,{writer:t})=>cS(s,e,t)}),n.for("dataDowncast").add(gS(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:s,model:o}=e;if(!i.isRegistered(e.model)){if(!e.modelSchema)return;if(i.register(e.model,e.modelSchema),!s)return;n.for("upcast").elementToElement({model:o,view:s,converterPriority:T.low+2}),n.for("downcast").elementToElement({model:o,view:(t,{writer:i})=>e.isEmpty?i.createEmptyElement(s):i.createContainerElement(s)})}s&&(i.extend(e.model,{allowAttributes:rS(s)}),n.for("upcast").add(mS(e,this)),n.for("downcast").add(gS(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,s=e.model;if(!e.appliesToBlock&&(i.extend("$text",{allowAttributes:s}),e.attributeProperties&&i.setAttributeProperties(s,e.attributeProperties),n.for("upcast").add(uS(e,this)),n.for("downcast").attributeToElement({model:s,view:hS(e)}),e.allowEmpty)){if(i.setAttributeProperties(s,{copyFromObject:!1}),!i.isRegistered("htmlEmptyElement")){i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"});const e=e=>Array.from(e.getAttributeKeys()).some(e=>e.startsWith("html"));t.model.document.registerPostFixer(i=>{const n=t.model.document.differ.getChanges(),s=new Set;for(const t of n)if("remove"!==t.type){if("attribute"===t.type&&null===t.attributeNewValue)for(const{item:i}of t.range)i.is("element","htmlEmptyElement")&&!e(i)&&s.add(i);if("insert"===t.type&&t.position.nodeAfter){const n=t.position.nodeAfter;for(const{item:t}of i.createRangeOn(n))t.is("element","htmlEmptyElement")&&!e(t)&&s.add(t)}}for(const e of s)i.remove(e);return s.size>0})}t.data.htmlProcessor.domConverter.registerInlineObjectMatcher(t=>t.name==e.view&&t.isEmpty&&Array.from(t.getAttributeKeys()).length?{name:!0}:null),n.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:dS(e,!0)}),n.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:dS(e)})}}}function wS(e,t,i){const n=t.matchAll(e)||[],s=e.document.stylesProcessor;return n.reduce((t,{match:n})=>{for(const[o,r]of n.attributes||[])if("style"==o){const n=r,o=s.getRelatedStyles(n).filter(e=>e.split("-").length>n.split("-").length).sort((e,t)=>t.split("-").length-e.split("-").length);for(const n of o)i.consume(e,{styles:[n]})&&t.styles.push(n);i.consume(e,{styles:[n]})&&t.styles.push(n)}else if("class"==o){const n=r;i.consume(e,{classes:[n]})&&t.classes.push(n)}else i.consume(e,{attributes:[o]})&&t.attributes.push(o);return t},{attributes:[],classes:[],styles:[]})}function vS(e,t){const i={};for(const n of t){const t=e.getAttribute(n);void 0!==t&&Si(n)&&(i[n]=t)}return i}function _S(e,t){const i=new ks(e.document.stylesProcessor);for(const n of t){const t=e.getStyle(n);void 0!==t&&i.set(n,t)}return Object.fromEntries(i.getStylesEntries())}function yS(e,t){const{name:i}=e,n=e[t];return wt(n)?Object.entries(n).map(([e,n])=>({name:i,[t]:{[e]:n}})):Array.isArray(n)?n.map(e=>({name:i,[t]:[e]})):[e]}function kS(e){const{name:t,attributes:i,classes:n,styles:s}=e,o=[];return i&&o.push(...yS({name:t,attributes:i},"attributes")),n&&o.push(...yS({name:t,classes:n},"classes")),s&&o.push(...yS({name:t,styles:s},"styles")),o}class CS extends $n{static get requires(){return[bS]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(bS);e.on("register:pre",(t,i)=>{if("codeBlock"!==i.model)return;const n=this.editor,s=n.model.schema,o=n.conversion;s.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),o.for("upcast").add(function(e){return t=>{t.on("element:code",(t,i,n)=>{const s=i.viewItem,o=s.parent;function r(t,s){const o=e.processViewAttributes(t,n);o&&n.writer.setAttribute(s,o,i.modelRange)}o&&o.is("element","pre")&&(r(o,"htmlPreAttributes"),r(s,"htmlContentAttributes"))},{priority:"low"})}}(e)),o.for("downcast").add(e=>{e.on("attribute:htmlPreAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item).parent;XE(i.writer,n,s,o)}),e.on("attribute:htmlContentAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item);XE(i.writer,n,s,o)})}),t.stop()})}}class xS extends $n{static get requires(){return[bS]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(bS).on("register",(e,t)=>{const i=t,n=this.editor,s=n.model.schema,o=n.conversion;if(!i.paragraphLikeModel)return;if(s.isRegistered(i.model)||s.isRegistered(i.paragraphLikeModel))return;const r={model:i.paragraphLikeModel,view:i.view};s.register(i.model,i.modelSchema),s.register(r.model,{inheritAllFrom:"$block"}),o.for("upcast").elementToElement({view:i.view,model:(e,{writer:t})=>this._hasBlockContent(e)?t.createElement(i.model):t.createElement(r.model),converterPriority:T.low+.5}),o.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),o.for("downcast").elementToElement({view:r.view,model:r.model}),this._addAttributeConversion(r),e.stop()})}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const n of t.createRangeIn(e).getItems())if(n.is("element")&&i.includes(n.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,n=t.plugins.get(bS);t.model.schema.extend(e.model,{allowAttributes:rS(e.view)}),i.for("upcast").add(mS(e,n)),i.for("downcast").add(gS(e))}}class AS extends $n{static get requires(){return[pS,Zy]}static get pluginName(){return"HeadingElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(pS),n=[];for(const e of t)"model"in e&&"view"in e&&(i.registerBlockElement({view:e.view,model:e.model}),n.push(e.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:n}}),i.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:n}})}}function TS(e,t,i){const n=e.createRangeOn(t);for(const{item:e}of n.getWalker())if(e.is("element",i))return e}class ES extends $n{static get requires(){return[bS]}static get pluginName(){return"ImageElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(bS);n.on("register:figure",()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",(t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("image"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)},{priority:"low"})}}(n))}),n.on("register:img",(s,o)=>{"imageBlock"!==o.model&&"imageInline"!==o.model||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:img",(t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlImgAttributes",o,i.modelRange)},{priority:"low"})}}(n)),i.for("downcast").add(e=>{function t(t){e.on(`attribute:${t}:imageInline`,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item);XE(i.writer,n,s,o)},{priority:"low"})}function i(t,i){e.on(`attribute:${i}:imageBlock`,(e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const{attributeOldValue:s,attributeNewValue:o}=i,r=n.mapper.toViewElement(i.item),a=TS(n.writer,r,t);a&&(XE(n.writer,s,o,a),n.consumable.consume(i.item,e.name))},{priority:"low"}),"a"===t&&e.on("attribute:linkHref:imageBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,"attribute:htmlLinkAttributes:imageBlock"))return;const n=i.mapper.toViewElement(t.item),s=TS(i.writer,n,"a");eS(i.writer,t.item.getAttribute("htmlLinkAttributes"),s)},{priority:"low"})}t("htmlImgAttributes"),i("img","htmlImgAttributes"),i("figure","htmlFigureAttributes"),i("a","htmlLinkAttributes")}),e.plugins.has("LinkImage")&&i.for("upcast").add(function(e,t){const i=t.plugins.get("ImageUtils");return t=>{t.on("element:a",(t,n,s)=>{const o=n.viewItem;if(!i.findViewImgElement(o))return;const r=n.modelCursor.parent;if(!r.is("element","imageBlock"))return;const a=e.processViewAttributes(o,s);a&&s.writer.setAttribute("htmlLinkAttributes",a,r)},{priority:"low"})}}(n,e)),s.stop())})}}class SS extends $n{static get requires(){return[bS]}static get pluginName(){return"MediaEmbedElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,n=this.editor.plugins.get(bS),s=this.editor.plugins.get(pS),o=e.config.get("mediaEmbed.elementName");s.registerBlockElement({model:"media",view:o}),n.on("register:figure",()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",(t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("media"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)},{priority:"low"})}}(n))}),n.on(`register:${o}`,(e,s)=>{"media"===s.model&&(t.extend("media",{allowAttributes:[rS(o),"htmlFigureAttributes"]}),i.for("upcast").add(function(e,t){const i=(i,n,s)=>{function o(t,i){const o=e.processViewAttributes(t,s);o&&s.writer.setAttribute(i,o,n.modelRange)}o(n.viewItem,rS(t))};return e=>{e.on(`element:${t}`,i,{priority:"low"})}}(n,o)),i.for("dataDowncast").add(function(e){return t=>{function i(e,i){t.on(`attribute:${i}:media`,(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const{attributeOldValue:s,attributeNewValue:o}=i,r=n.mapper.toViewElement(i.item),a=TS(n.writer,r,e);XE(n.writer,s,o,a)})}i(e,rS(e)),i("figure","htmlFigureAttributes")}}(o)),e.stop())})}}class IS extends $n{static get requires(){return[bS]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(bS);e.on("register:script",(t,i)=>{const n=this.editor,s=n.model.schema,o=n.conversion;s.register("htmlScript",i.modelSchema),s.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"script"}),o.for("upcast").elementToElement({view:"script",model:aS(i)}),o.for("upcast").add(mS(i,e)),o.for("downcast").elementToElement({model:"htmlScript",view:(e,{writer:t})=>cS("script",e,t)}),o.for("downcast").add(gS(i)),t.stop()})}}const PS=["width","max-width","min-width","height","min-height","max-height"];class VS extends $n{static get requires(){return[bS]}static get pluginName(){return"TableElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(bS),s=e.plugins.get("TableUtils");n.on("register:figure",()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",(t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("table"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)},{priority:"low"})}}(n))}),n.on("register:table",(o,r)=>{"table"===r.model&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:table",(t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem;n.consumable.consume(s,{classes:"table"}),o(s,"htmlTableAttributes");for(const e of s.getChildren())e.is("element","thead")&&o(e,"htmlTheadAttributes"),e.is("element","tbody")&&o(e,"htmlTbodyAttributes");function o(t,s){const o=e.processViewAttributes(t,n);o&&n.writer.setAttribute(s,o,i.modelRange)}},{priority:"low"})}}(n)),i.for("downcast").add(e=>{function t(t,i){e.on(`attribute:${i}:table`,(e,n,s)=>{if(!s.consumable.test(n.item,e.name))return;const o=s.mapper.toViewElement(n.item),r=TS(s.writer,o,t);if(r)if(s.consumable.consume(n.item,e.name),"htmlTableAttributes"===i&&o!==r){const e=OS(n.attributeOldValue),t=OS(n.attributeNewValue);XE(s.writer,e.tableAttributes,t.tableAttributes,r),XE(s.writer,e.figureAttributes,t.figureAttributes,o)}else XE(s.writer,n.attributeOldValue,n.attributeNewValue,r)})}t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes")}),e.model.document.registerPostFixer(function(e,t){return i=>{const n=e.document.differ.getChanges();let s=!1;for(const e of n){if("attribute"!=e.type||"headingRows"!=e.attributeKey)continue;const n=e.range.start.nodeAfter,o=n.getAttribute("htmlTheadAttributes"),r=n.getAttribute("htmlTbodyAttributes");o&&!e.attributeNewValue?(i.removeAttribute("htmlTheadAttributes",n),s=!0):r&&e.attributeNewValue==t.getRows(n)&&(i.removeAttribute("htmlTbodyAttributes",n),s=!0)}return s}}(e.model,s)),o.stop())})}}function OS(e){const t={},i={...e};if(!e||!("styles"in e))return{figureAttributes:t,tableAttributes:i};i.styles={};for(const[n,s]of Object.entries(e.styles))PS.includes(n)?t.styles={...t.styles,[n]:s}:i.styles={...i.styles,[n]:s};return{figureAttributes:t,tableAttributes:i}}class RS extends $n{static get requires(){return[bS]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(bS);e.on("register:style",(t,i)=>{const n=this.editor,s=n.model.schema,o=n.conversion;s.register("htmlStyle",i.modelSchema),s.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"style"}),o.for("upcast").elementToElement({view:"style",model:aS(i)}),o.for("upcast").add(mS(i,e)),o.for("downcast").elementToElement({model:"htmlStyle",view:(e,{writer:t})=>cS("style",e,t)}),o.for("downcast").add(gS(i)),t.stop()})}}class BS extends $n{static get requires(){return[bS]}static get pluginName(){return"ListElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(bS),s=e.plugins.get("ListEditing"),o=e.plugins.get("ListUtils"),r=["ul","ol","li"];s.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:eS}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:eS}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:eS}),n.on("register",(e,s)=>{if(!r.includes(s.view))return;if(e.stop(),t.checkAttribute("$block","htmlLiAttributes"))return;const o=r.map(e=>rS(e));t.extend("$listItem",{allowAttributes:o}),i.for("upcast").add(e=>{e.on("element:ul",LS("htmlUlAttributes",n),{priority:"low"}),e.on("element:ol",LS("htmlOlAttributes",n),{priority:"low"}),e.on("element:li",LS("htmlLiAttributes",n),{priority:"low"})})}),s.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:s}of t)if(s){if(s.getAttribute("listType")==n.getAttribute("listType")){const t=MS(s.getAttribute("listType")),o=s.getAttribute(t);!ct(n.getAttribute(t),o)&&i.model.schema.checkAttribute(n,t)&&(i.setAttribute(t,o,n),e.return=!0)}if(s.getAttribute("listItemId")==n.getAttribute("listItemId")){const t=s.getAttribute("htmlLiAttributes");!ct(n.getAttribute("htmlLiAttributes"),t)&&i.model.schema.checkAttribute(n,"htmlLiAttributes")&&(i.setAttribute("htmlLiAttributes",t,n),e.return=!0)}}}),s.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:n}of t){const t=n.getAttribute("listType");!o.isNumberedListType(t)&&n.getAttribute("htmlOlAttributes")&&(i.removeAttribute("htmlOlAttributes",n),e.return=!0),o.isNumberedListType(t)&&n.getAttribute("htmlUlAttributes")&&(i.removeAttribute("htmlUlAttributes",n),e.return=!0)}})}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",(t,i)=>{e.model.change(t=>{for(const n of i){const i=MS(n.getAttribute("listType"));e.model.schema.checkAttribute(n,i)&&t.setAttribute(i,{},n)}})})}}function LS(e,t){return(i,n,s)=>{const o=n.viewItem;n.modelRange||Object.assign(n,s.convertChildren(n.viewItem,n.modelCursor));const r=t.processViewAttributes(o,s);for(const t of n.modelRange.getItems({shallow:!0}))t.hasAttribute("listItemId")&&(t.hasAttribute("htmlUlAttributes")||t.hasAttribute("htmlOlAttributes")||s.writer.model.schema.checkAttribute(t,e)&&s.writer.setAttribute(e,r||{},t))}}function MS(e){return"numbered"===e||"customNumbered"==e?"htmlOlAttributes":"htmlUlAttributes"}class FS extends $n{static get requires(){return[bS]}static get pluginName(){return"HorizontalLineElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HorizontalLineEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(bS);n.on("register:hr",(e,s)=>{"horizontalLine"===s.model&&(t.extend("horizontalLine",{allowAttributes:["htmlHrAttributes"]}),i.for("upcast").add(mS(s,n)),i.for("downcast").add(e=>{e.on("attribute:htmlHrAttributes:horizontalLine",(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item),r=TS(i.writer,o,"hr");r&&(XE(i.writer,n,s,r),i.consumable.consume(t.item,e.name))},{priority:"low"})}),e.stop())})}}class NS extends $n{static get requires(){return[bS,pS]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(bS),t=this.editor.plugins.get(pS);e.on("register:$customElement",(i,n)=>{i.stop();const s=this.editor,o=s.model.schema,r=s.conversion,a=s.editing.view.domConverter.unsafeElements,l=s.data.htmlProcessor.domConverter.preElements;o.register(n.model,n.modelSchema),o.extend(n.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),s.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),r.for("upcast").elementToElement({view:/.*/,model:(i,o)=>{if("$comment"==i.name)return null;if(!function(e){try{document.createElement(e)}catch{return!1}return!0}(i.name))return null;if(t.getDefinitionsForView(i.name).size)return null;a.includes(i.name)||a.push(i.name),l.includes(i.name)||l.push(i.name);const r=o.writer.createElement(n.model,{htmlElementName:i.name}),c=e.processViewAttributes(i,o);let u;if(c&&o.writer.setAttribute("htmlCustomElementAttributes",c,r),i.is("element","template")&&i.getCustomProperty("$rawContent"))u=i.getCustomProperty("$rawContent");else{const e=new Oc(i.document).createDocumentFragment(i),t=s.data.htmlProcessor.domConverter.viewToDom(e),n=t.firstChild;for(;n.firstChild;)t.appendChild(n.firstChild);n.remove(),u=s.data.htmlProcessor.htmlWriter.getHtml(t)}o.writer.setAttribute("htmlContent",u,r);for(const{item:e}of s.editing.view.createRangeIn(i))o.consumable.consume(e,{name:!0});return r},converterPriority:"low"}),r.for("editingDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=t.createRawElement(i);return e.hasAttribute("htmlCustomElementAttributes")&&eS(t,e.getAttribute("htmlCustomElementAttributes"),n),n}}),r.for("dataDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=e.getAttribute("htmlContent"),s=t.createRawElement(i,null,(e,t)=>{t.setContentOf(e,n)});return e.hasAttribute("htmlCustomElementAttributes")&&eS(t,e.getAttribute("htmlCustomElementAttributes"),s),s}})})}}class DS extends $n{static get pluginName(){return"GeneralHtmlSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[bS,CS,xS,AS,ES,SS,IS,VS,RS,BS,FS,NS]}init(){const e=this.editor,t=e.plugins.get(bS);t.loadAllowedEmptyElementsConfig(e.config.get("htmlSupport.allowEmpty")||[]),t.loadAllowedConfig(e.config.get("htmlSupport.allow")||[]),t.loadDisallowedConfig(e.config.get("htmlSupport.disallow")||[])}afterInit(){const e=this.editor.commands.get("removeFormat");e?.registerCustomAttribute(e=>e.startsWith("html")&&e.endsWith("Attributes"),sS)}getGhsAttributeNameForElement(e){const t=this.editor.plugins.get("DataSchema"),i=Array.from(t.getDefinitionsForView(e,!1)),n=i.find(e=>e.isInline&&!i[0].isObject);return n?n.model:rS(e)}addModelHtmlClass(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of zS(n,i,s))nS(e,o,s,"classes",e=>{for(const i of ln(t))e.add(i)})})}removeModelHtmlClass(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of zS(n,i,s))nS(e,o,s,"classes",e=>{for(const i of ln(t))e.delete(i)})})}setModelHtmlAttributes(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of zS(n,i,s))nS(e,o,s,"attributes",e=>{for(const[i,n]of Object.entries(t))e.set(i,n)})})}removeModelHtmlAttributes(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of zS(n,i,s))nS(e,o,s,"attributes",e=>{for(const i of ln(t))e.delete(i)})})}setModelHtmlStyles(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of zS(n,i,s))nS(e,o,s,"styles",e=>{for(const[i,n]of Object.entries(t))e.set(i,n)})})}removeModelHtmlStyles(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of zS(n,i,s))nS(e,o,s,"styles",e=>{for(const i of ln(t))e.delete(i)})})}}function*zS(e,t,i){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)e.schema.checkAttributeInSelection(t,i)&&(yield t);else for(const n of function(e,t,i){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?e.schema.checkAttribute(t,i)?[e.createRangeOn(t)]:[]:e.schema.getValidRanges(e.createSelection(t).getRanges(),i)}(e,t,i))yield*n.getItems({shallow:!0})}class HS extends $n{static get pluginName(){return"HtmlComment"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=new Map;e.data.processor.skipComments=!1,e.model.schema.addAttributeCheck((e,t)=>{if(e.endsWith("$root")&&t.startsWith("$comment"))return!0}),e.conversion.for("upcast").elementToMarker({view:"$comment",model:e=>{const i=`$comment:${A()}`,n=e.getCustomProperty("$rawContent");return t.set(i,n),i}}),e.conversion.for("dataDowncast").markerToElement({model:"$comment",view:(e,{writer:t})=>{let i;for(const t of this.editor.model.document.getRootNames())if(i=this.editor.model.document.getRoot(t),i.hasAttribute(e.markerName))break;const n=e.markerName,s=i.getAttribute(n),o=t.createUIElement("$comment");return t.setCustomProperty("$rawContent",s,o),o}}),e.model.document.registerPostFixer(i=>{let n=!1;const s=e.model.document.differ.getChangedMarkers().filter(e=>e.name.startsWith("$comment:"));for(const e of s){const{oldRange:s,newRange:o}=e.data;if(!s||!o||s.root!=o.root){if(s){const t=s.root;t.hasAttribute(e.name)&&(i.removeAttribute(e.name,t),n=!0)}if(o){const s=o.root;"$graveyard"==s.rootName?(i.removeMarker(e.name),n=!0):s.hasAttribute(e.name)||(i.setAttribute(e.name,t.get(e.name)||"",s),n=!0)}}}return n}),e.data.on("set",()=>{for(const t of e.model.markers.getMarkersGroup("$comment"))this.removeHtmlComment(t.name)},{priority:"high"}),e.model.on("deleteContent",(t,[i])=>{for(const t of i.getRanges()){const i=e.model.schema.getLimitElement(t),n=e.model.createPositionAt(i,0),s=e.model.createPositionAt(i,"end");let o;o=n.isTouching(t.start)&&s.isTouching(t.end)?this.getHtmlCommentsInRange(e.model.createRange(n,s)):this.getHtmlCommentsInRange(t,{skipBoundaries:!0});for(const e of o)this.removeHtmlComment(e)}},{priority:"high"})}createHtmlComment(e,t){const i=A(),n=this.editor.model,s=n.document.getRoot(e.root.rootName),o=`$comment:${i}`;return n.change(i=>{const n=i.createRange(e);return i.addMarker(o,{usingOperation:!0,affectsData:!0,range:n}),i.setAttribute(o,t,s),o})}removeHtmlComment(e){const t=this.editor,i=t.model.markers.get(e);return!!i&&(t.model.change(e=>{e.removeMarker(i)}),!0)}getHtmlCommentData(e){const t=this.editor.model.markers.get(e);if(!t)return null;let i="";for(const t of this.editor.model.document.getRoots())if(t.hasAttribute(e)){i=t.getAttribute(e);break}return{content:i,position:t.getStart()}}getHtmlCommentsInRange(e,{skipBoundaries:t=!1}={}){const i=!t;return Array.from(this.editor.model.markers.getMarkersGroup("$comment")).filter(t=>function(e,t){const n=e.getRange().start;return(n.isAfter(t.start)||i&&n.isEqual(t.start))&&(n.isBefore(t.end)||i&&n.isEqual(t.end))}(t,e)).map(e=>e.name)}}class qS extends Qa{toView(e){if(!/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4)))return super.toView(e);let t="",i="";e=(e=e.trim().replace(/<\?xml\s[^?]*\?>/i,e=>(i=e,""))).trim().replace(/^]*?>/i,e=>(t=e,""));const n=this._toDom(e),s=this.domConverter.domToView(n,{skipComments:this.skipComments}),o=new Oc(s.document);o.setCustomProperty("$fullPageDocument",n.ownerDocument.documentElement.outerHTML,s);const r=Array.from(n.ownerDocument.querySelectorAll("head style"));return o.setCustomProperty("$fullPageHeadStyles",r,s),t&&o.setCustomProperty("$fullPageDocType",t,s),i&&o.setCustomProperty("$fullPageXmlDeclaration",i,s),s}toData(e){let t=super.toData(e);const i=e.getCustomProperty("$fullPageDocument"),n=e.getCustomProperty("$fullPageDocType"),s=e.getCustomProperty("$fullPageXmlDeclaration");return i&&(t=i.replace(/<\/body\s*>/,t+"$&"),n&&(t=n+"\n"+t),s&&(t=s+"\n"+t)),t}}class US extends $n{static get pluginName(){return"FullPage"}static get licenseFeatureCode(){return"FPH"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("htmlSupport.fullPage",{allowRenderStylesFromHead:!1,sanitizeCss:e=>(P("css-full-page-provide-sanitize-function"),{css:e,hasChanged:!1})}),e.data.processor=new qS(e.data.viewDocument)}init(){const e=this.editor,t=["$fullPageDocument","$fullPageDocType","$fullPageXmlDeclaration","$fullPageHeadStyles"];e.model.schema.extend("$root",{allowAttributes:t}),e.data.on("toModel",(i,[n])=>{const s=e.model.document.getRoot();e.model.change(e=>{for(const i of t){const t=n.getCustomProperty(i);t&&e.setAttribute(i,t,s)}}),WS(e)&&this._renderStylesFromHead(s)},{priority:"low"}),e.data.on("toView",(e,[i])=>{if(!i.is("rootElement"))return;const n=i,s=e.return;if(!n.hasAttribute("$fullPageDocument"))return;const o=new Oc(s.document);for(const e of t){const t=n.getAttribute(e);t&&o.setCustomProperty(e,t,s)}},{priority:"low"}),e.data.on("set",()=>{const i=e.model.document.getRoot();e.model.change(e=>{for(const n of t)i.hasAttribute(n)&&e.removeAttribute(n,i)})},{priority:"high"}),e.data.on("get",(e,t)=>{t[0]||(t[0]={}),t[0].trim=!1},{priority:"high"})}destroy(){super.destroy(),WS(this.editor)&&this._removeStyleElementsFromDom()}_removeStyleElementsFromDom(){const t=Array.from(e.document.querySelectorAll(`[data-full-page-style-id="${this.editor.id}"]`));for(const e of t)e.remove()}_renderStyleElementsInDom(t){const i=this.editor,n=t.getAttribute("$fullPageHeadStyles");if(!n)return;const s=i.config.get("htmlSupport.fullPage.sanitizeCss");for(const t of n){t.setAttribute("data-full-page-style-id",i.id);const n=s(t.innerText);n.hasChanged&&(t.innerText=n.css),e.document.head.append(t)}}_renderStylesFromHead(e){this._removeStyleElementsFromDom(),this._renderStyleElementsInDom(e)}}function WS(e){return e.config.get("htmlSupport.fullPage.allowRenderStylesFromHead")}const $S="htmlEmptyBlock";class jS extends $n{static get pluginName(){return"EmptyBlock"}static get isOfficialPlugin(){return!0}afterInit(){const{model:e,conversion:t,plugins:i,config:n}=this.editor,s=e.schema,o=n.get("htmlSupport.preserveEmptyBlocksInEditingView");s.extend("$block",{allowAttributes:[$S]}),s.extend("$container",{allowAttributes:[$S]}),s.isRegistered("tableCell")&&s.extend("tableCell",{allowAttributes:[$S]}),o?t.for("downcast").add(GS()):t.for("dataDowncast").add(GS()),t.for("upcast").add(function(e){return t=>{t.on("element",(t,i,n)=>{const{viewItem:s,modelRange:o}=i;if(!s.is("element")||!s.isEmpty||s.getCustomProperty("$hasBlockFiller"))return;const r=o&&o.start.nodeAfter;if(!r||!e.checkAttribute(r,$S))return;if(n.writer.setAttribute($S,!0,r),1!=r.childCount)return;const a=r.getChild(0);a.is("element","paragraph")&&e.checkAttribute(a,$S)&&n.writer.setAttribute($S,!0,a)},{priority:"lowest"})}}(s)),i.has("ClipboardPipeline")&&this._registerClipboardPastingHandler()}_registerClipboardPastingHandler(){const e=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"contentInsertion",(e,t)=>{t.sourceEditorId!==this.editor.id&&this.editor.model.change(e=>{for(const{item:i}of e.createRangeIn(t.content))i.is("element")&&i.hasAttribute($S)&&e.removeAttribute($S,i)})})}}function GS(){return e=>{e.on(`attribute:${$S}`,(e,t,i)=>{const{mapper:n,consumable:s}=i,{item:o}=t;if(!s.consume(o,e.name))return;const r=n.toViewElement(o);r&&t.attributeNewValue&&(r.getFillerOffset=()=>null)})}}function KS(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}function JS(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function QS(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return s(e);return("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:s(e)};function s(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function YS(e,t){const i=fn(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function ZS(e){return e&&e.endsWith("px")?parseInt(e):null}function XS(e){const t=ZS(e.getStyle("width")),i=ZS(e.getStyle("height"));return!(!t||!i)}const eI=/^(image|image-inline)$/;class tI extends $n{_domEmitter=new(ni());static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,n={}){const s=this.editor,o=s.model,r=o.document.selection,a=iI(s,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const t in e)o.schema.checkAttribute(a,t)||delete e[t];return o.change(i=>{const{setImageSizes:s=!0}=n,r=i.createElement(a,e);return o.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==a?void 0:"auto"}),r.parent?(s&&this.setImageNaturalSizeAttributes(r),r):null})}setImageNaturalSizeAttributes(t){const i=t.getAttribute("src");i&&(t.getAttribute("width")||t.getAttribute("height")||this.editor.model.change(n=>{const s=new e.window.Image;this._domEmitter.listenTo(s,"load",()=>{t.getAttribute("width")||t.getAttribute("height")||this.editor.model.enqueueChange(n.batch,e=>{e.setAttribute("width",s.naturalWidth,t),e.setAttribute("height",s.naturalHeight,t)}),this._domEmitter.stopListening(s,"load")}),s.src=i}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:eI})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){const i=iI(e,t,null);if("imageBlock"==i){const i=function(e,t){const i=xk(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return bk(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&pk(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function iI(e,t,i){const n=e.model.schema,s=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===s?"imageInline":"auto"!==s?"imageBlock":t.is("selection")?YS(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}const nI=new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class sI extends $n{static get requires(){return[xx,tI,uT,M_]}static get pluginName(){return"AutoImage"}static get isOfficialPlugin(){return!0}_timeoutId;_positionToInsert;constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const t=this.editor,i=t.model.document,n=t.plugins.get("ClipboardPipeline");this.listenTo(n,"inputTransformation",()=>{const e=i.selection.getFirstRange(),t=Ll.fromPosition(e.start);t.stickiness="toPrevious";const n=Ll.fromPosition(e.end);n.stickiness="toNext",i.once("change:data",()=>{this._embedImageBetweenPositions(t,n),t.detach(),n.detach()},{priority:"high"})}),t.commands.get("undo").on("execute",()=>{this._timeoutId&&(e.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedImageBetweenPositions(e,t){const i=this.editor,n=new Fr(e,t),s=n.getWalker({ignoreElementEnd:!0}),o=Object.fromEntries(i.model.document.selection.getAttributes()),r=this.editor.plugins.get("ImageUtils");let a="";for(const e of s)e.item.is("$textProxy")&&(a+=e.item.data);a=a.trim(),a.match(nI)?(this._positionToInsert=Ll.fromPosition(e),this._timeoutId=setTimeout(()=>{if(!i.commands.get("insertImage").isEnabled)return void n.detach();i.model.change(e=>{let t;this._timeoutId=null,e.remove(n),n.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert.toPosition()),r.insertImage({...o,src:a},t),this._positionToInsert.detach(),this._positionToInsert=null});i.plugins.get("Delete").requestUndoOnBackspace()},100)):n.detach()}}class oI extends Gn{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,s=i.getClosestSelectedImageElement(n.document.selection);n.change(t=>{t.setAttribute("alt",e.newValue,s)})}}class rI extends $n{static get requires(){return[tI]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new oI(this.editor))}}class aI extends hh{focusTracker;keystrokes;labeledInput;backButtonView;saveButtonView;children;_focusables;_focusCycler;constructor(e){super(e),this.focusTracker=new bn,this.keystrokes=new yn,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new Mv(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new qd,this.keystrokes.set("Esc",(e,t)=>{this.fire("cancel"),t()}),this._focusCycler=new xp({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-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),_h({view:this});[this.backButtonView,this.labeledInput,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()}_createBackButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:bf,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Cp(this.locale,{label:e("Text Alternative")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Ab(this.locale,fw);return t.label=e("Text alternative"),t.class="ck-labeled-field-view_full-width",t}}function lI(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=cI(e);t.updatePosition(i)}}function cI(e){const t=e.editing.view,i=Hp.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class uI extends $n{_balloon;_form;static get requires(){return[Uv]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",i=>{const n=e.commands.get("imageTextAlternative"),s=new yp(i);return s.set({label:t("Change image text alternative"),icon:Zf,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>!!e),this.listenTo(s,"execute",()=>{this._showForm()}),s})}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(wh(aI))(e.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this.listenTo(e.ui,"update",()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&lI(e):this._hideForm(!0)}),bh({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:cI(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class dI extends $n{static get requires(){return[rI,uI]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function hI(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=e.findViewImgElement(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const o=fn(n.convertItem(s,i.modelCursor).modelRange.getItems());o?(n.convertChildren(i.viewItem,o),n.updateConversionResult(o,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}function mI(e){const t=["srcset","media","type","sizes"],i=(i,n,s)=>{const o=n.viewItem;if(!s.consumable.test(o,{name:!0}))return;const r=new Map;for(const e of o.getChildren())if(e.is("element","source")){const i={};for(const n of t)e.hasAttribute(n)&&s.consumable.test(e,{attributes:n})&&(i[n]=e.getAttribute(n));Object.keys(i).length&&r.set(e,i)}const a=e.findViewImgElement(o);if(!a)return;let l=n.modelCursor.parent;if(!l.is("element","imageBlock")){const e=s.convertItem(a,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,l=fn(e.modelRange.getItems())}s.consumable.consume(o,{name:!0});for(const[e,t]of r)s.consumable.consume(e,{attributes:Object.keys(t)});r.size&&s.writer.setAttribute("sources",Array.from(r.values()),l),s.convertChildren(o,l)};return e=>{e.on("element:picture",i)}}function gI(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);null===i.attributeNewValue?(s.removeAttribute("srcset",r),s.removeAttribute("sizes",r)):i.attributeNewValue&&(s.setAttribute("srcset",i.attributeNewValue,r),s.setAttribute("sizes","100vw",r))};return e=>{e.on(`attribute:srcset:${t}`,i)}}function fI(e){const t=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o),a=i.attributeNewValue;if(a&&a.length){const e=[];let t=r.parent;for(;t&&t.is("attributeElement");){const i=t.parent;s.unwrap(s.createRangeOn(r),t),e.unshift(t),t=i}const i=r.parent.is("element","picture"),n=i?r.parent:s.createContainerElement("picture",null);i||s.insert(s.createPositionBefore(r),n),s.remove(s.createRangeIn(n)),s.insert(s.createPositionAt(n,"end"),a.map(e=>s.createEmptyElement("source",e))),s.move(s.createRangeOn(r),s.createPositionAt(n,"end"));for(const t of e)s.wrap(s.createRangeOn(n),t)}else if(r.parent.is("element","picture")){const e=r.parent;s.move(s.createRangeOn(r),s.createPositionBefore(e)),s.remove(e)}};return e=>{e.on("attribute:sources:imageBlock",t),e.on("attribute:sources:imageInline",t)}}function pI(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);s.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class bI extends Jo{observe(e){this.listenTo(e,"load",(e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class wI extends Gn{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&P("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&P("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=ln(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((t,o)=>{const r=i.getSelectedElement();if("string"==typeof t&&(t={src:t}),o&&r&&n.isImage(r)){const i=this.editor.model.createPositionAfter(r);n.insertImage({...t,...s},i,e.imageType)}else e.breakBlock?n.insertImage({...t,...s},i.getFirstPosition(),e.imageType):n.insertImage({...t,...s},null,e.imageType)})}}class vI extends Gn{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change(n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)})}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class _I extends $n{static get requires(){return[tI]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(bI),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new wI(e),n=new vI(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class yI extends $n{static get requires(){return[tI]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function s(t,n,s,o,r=!1){t.on(`attribute:${n}:${e}`,(t,n,a)=>{if(!a.consumable.consume(n.item,t.name))return;const l=a.writer,c=a.mapper.toViewElement(n.item),u=i.findViewImgElement(c);null!==n.attributeNewValue?l.setAttribute(s,n.attributeNewValue,u):l.removeAttribute(s,u);const d=n.item.getAttribute("width"),h=n.item.getAttribute("height"),m=d&&h;if(m&&r&&l.setAttribute("loading","lazy",u),n.item.hasAttribute("sources"))return;const g=n.item.hasAttribute("resizedWidth");("imageInline"!==e||g||o)&&m&&l.setStyle("aspect-ratio",`${d}/${h}`,u)})}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>XS(e)?ZS(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>XS(e)?ZS(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add(e=>{s(e,"width","width",!0,!0),s(e,"height","height",!0,!0)}),t.conversion.for("dataDowncast").add(e=>{s(e,"width","width",!1),s(e,"height","height",!1)}),t.conversion.for("upcast").add(e=>{e.on("element:img",(e,t,i)=>{const n=t.viewItem.getAttribute("width"),s=t.viewItem.getAttribute("height");n&&s&&i.consumable.consume(t.viewItem,{styles:["aspect-ratio"]})})})}}class kI extends Gn{_modelElementName;constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection),o=Object.fromEntries(s.getAttributes());return o.src||o.uploadId?i.change(t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter(e=>e.getRange().containsItem(s)),l=n.insertImage(o,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:s,newElement:l}}):null}}class CI extends $n{static get requires(){return[tI]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add(e=>{e.on("attribute:placeholder",(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const s=n.writer,o=n.mapper.toViewElement(t.item),r=i.findViewImgElement(o);t.attributeNewValue?(s.addClass("image_placeholder",r),s.setStyle("background-image",`url(${t.attributeNewValue})`,r),s.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(s.removeClass("image_placeholder",r),s.removeStyle("background-image",r))})})}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,s=e.plugins.get("ImageUtils");n.addObserver(bI),this.listenTo(n.document,"imageLoaded",(e,o)=>{const r=n.domConverter.mapDomToView(o.target);if(!r)return;const a=s.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},e=>{e.removeAttribute("placeholder",l)})})}}class xI extends $n{static get requires(){return[_I,yI,tI,CI,cx]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new kI(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>JS(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(JS(i),i,t("image widget"))}),i.for("downcast").add(pI(n,"imageBlock","src")).add(pI(n,"imageBlock","alt")).add(gI(n,"imageBlock")),i.for("upcast").elementToElement({view:QS(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(hI(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===YS(t.schema,l)){const e=new Oc(i.document),t=r.map(t=>e.createElement("figure",{class:"image"},t));o.content=e.createDocumentFragment(t)}}),this.listenTo(s,"contentInsertion",(e,i)=>{"paste"===i.method&&t.change(e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(e)})})}}class AI extends hh{focusTracker;keystrokes;_focusables;_focusCycler;children;constructor(e,t=[]){super(e),this.focusTracker=new bn,this.keystrokes=new yn,this._focusables=new qd,this.children=this.createCollection(),this._focusCycler=new xp({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const e of t)this.children.add(e),this._focusables.add(e),e instanceof Zp&&this._focusables.addMany(e.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),_h({view:this});for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class TI extends $n{static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[tI]}dropdownView;_integrations=new Map;constructor(e){super(e),e.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",()=>{this.isImageSelected=i.isImage(t.getSelectedElement())});const n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n),e.ui.componentFactory.add("menuBar:insertImage",e=>this._createMenuBarComponent(e))}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,menuBarButtonViewCreator:s,requiresForm:o=!1,override:r=!1}){this._integrations.has(e)&&!r&&P("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,menuBarButtonViewCreator:s,formViewCreator:n,requiresForm:o})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let s;const o=n[0];if(1==n.length){if(!o.requiresForm)return o.buttonViewCreator(!0);s=o.buttonViewCreator(!0)}else{const t=o.buttonViewCreator(!1);s=new sw(e,t),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",e=>i(e?"Replace image":"Insert image"))}const r=this.dropdownView=ow(e,s),a=n.map(({observable:e})=>"function"==typeof e?e():e);return r.bind("isEnabled").toMany(a,"isEnabled",(...e)=>e.some(e=>e)),r.once("change:isOpen",()=>{const e=n.flatMap(({formViewCreator:e})=>e(1==n.length)),i=new AI(t.locale,e);r.panelView.children.add(i)}),r}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const n=i.flatMap(({menuBarButtonViewCreator:e})=>e(1==i.length)),s=new d_(e),o=new h_(e);s.panelView.children.add(o),s.buttonView.set({icon:lg,label:t("Image")});for(const t of n){const i=new hv(e,s);i.children.add(t),o.items.add(i),t.delegate("execute").to(s)}return s}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return P("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||P("image-insert-unknown-integration",{item:i});return t.length||P("image-insert-integrations-not-registered"),t}}class EI extends $n{static get requires(){return[xI,qk,dI,TI]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class SI extends $n{static get requires(){return[_I,yI,tI,CI,cx]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new kI(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(KS(i),i,t("image widget"))}),i.for("downcast").add(pI(n,"imageInline","src")).add(pI(n,"imageInline","alt")).add(gI(n,"imageInline")),i.for("upcast").elementToElement({view:QS(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===YS(t.schema,l)){const e=new Oc(i.document),t=r.map(t=>1===t.childCount?(Array.from(t.getAttributes()).forEach(i=>e.setAttribute(...i,n.findViewImgElement(t))),t.getChild(0)):t);o.content=e.createDocumentFragment(t)}}),this.listenTo(s,"contentInsertion",(e,i)=>{"paste"===i.method&&t.change(e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageInline")&&n.setImageNaturalSizeAttributes(e)})})}}class II extends $n{static get requires(){return[SI,qk,dI,TI]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}class PI extends $n{static get requires(){return[EI,II]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}}class VI extends $n{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[tI]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class OI extends Gn{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(xI))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,s=n.getSelectedElement();if(!s){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(s),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(s):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)})}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),s=this.editor.plugins.get("ImageUtils");let o=i.getSelectedElement();const r=n._getSavedCaption(o);s.isInlineImage(o)&&(this.editor.execute("imageTypeBlock"),o=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,o),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),s=t.plugins.get("ImageCaptionUtils");let o,r=i.getSelectedElement();r?o=s.getCaptionFromImageModelElement(r):(o=s.getCaptionFromModelSelection(i),r=o.parent),n._saveCaption(r,o),e.setSelection(r,"on"),e.remove(o)}}class RI extends $n{static get requires(){return[tI,VI]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}_savedCaptionsMap;constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new OI(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),s=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const o=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,o),o.placeholder=s("Enter image caption"),ns({view:t,element:o,keepOnFocus:!0});const r=e.parent.getAttribute("alt");return Ck(o,n,{label:r?s("Caption for image: %0",[r]):s("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),s=e.commands.get("imageTypeBlock"),o=e=>{if(!e.return)return;const{oldElement:n,newElement:s}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(s,e)}const o=this._getSavedCaption(n);o&&this._saveCaption(s,o)};n&&this.listenTo(n,"execute",o,{priority:"low"}),s&&this.listenTo(s,"execute",o,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?jr.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",()=>{const s=t.document.differ.getChanges();for(const t of s){if("alt"!==t.attributeKey)continue;const s=t.range.start.nodeAfter;if(i.isBlockImage(s)){const t=n.getCaptionFromImageModelElement(s);if(!t)return;e.editing.reconvertItem(t)}}})}}class BI extends $n{static get requires(){return[VI]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",s=>{const o=e.commands.get("toggleImageCaption"),r=new yp(s);return r.set({icon:om,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.bind("label").to(o,"value",e=>n(e?"Toggle caption off":"Toggle caption on")),this.listenTo(r,"execute",()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change(e=>{e.addClass("image__caption_highlighted",i)})}e.editing.view.focus()}),r})}}class LI extends $n{static get requires(){return[RI,BI]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}}function MI(e){const t=e.map(e=>e.replace("+","\\+"));return new RegExp(`^image\\/(${t.join("|")})$`)}function FI(t){return new Promise((i,n)=>{const s=t.getAttribute("src");fetch(s).then(e=>e.blob()).then(e=>{const t=DI(e,s),n=t.replace("image/",""),o=new File([e],`image.${n}`,{type:t});i(o)}).catch(t=>t&&"TypeError"===t.name?function(t){return function(t){return new Promise((i,n)=>{const s=e.document.createElement("img");s.addEventListener("load",()=>{const t=e.document.createElement("canvas");t.width=s.width,t.height=s.height;t.getContext("2d").drawImage(s,0,0),t.toBlob(e=>e?i(e):n())}),s.addEventListener("error",()=>n()),s.src=t})}(t).then(e=>{const i=DI(e,t),n=i.replace("image/","");return new File([e],`image.${n}`,{type:i})})}(s).then(i).catch(n):n(t))})}function NI(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src"))&&(!!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||!!t.getAttribute("src").match(/^blob:/g))}function DI(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class zI extends $n{static get pluginName(){return"ImageUploadUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("uploadImage",()=>this._createToolbarButton()),e.ui.componentFactory.add("imageUpload",()=>this._createToolbarButton()),e.ui.componentFactory.add("menuBar:uploadImage",()=>this._createMenuBarButton("standalone")),e.plugins.has("ImageInsertUI")&&e.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),o=MI(s),r=new e(t.locale),a=i.t;return r.set({acceptedType:s.map(e=>`image/${e}`).join(","),allowMultipleFiles:!0,label:a("Upload from computer"),icon:cg}),r.bind("isEnabled").to(n),r.on("done",(e,i)=>{const n=Array.from(i).filter(e=>o.test(e.type));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())}),r}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),n=this._createButton(Kp);return n.tooltip=!0,n.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",(t,i)=>e(i?t?"Replace image from computer":"Upload image from computer":"You have no image upload permissions.")),n}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(Kp);return i.withText=!0,i.bind("label").to(t,"isImageSelected",t=>e(t?"Replace from computer":"Upload from computer")),i.on("execute",()=>{t.dropdownView.isOpen=!1}),i}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createButton(g_);switch(i.withText=!0,e){case"standalone":i.label=t("Image from computer");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("From computer")}return i}}class HI extends $n{static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}placeholder;constructor(e){super(e),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}uploadStatusChange=(e,t,i)=>{const n=this.editor,s=t.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(kd),l=o?t.attributeNewValue:null,c=this.placeholder,u=n.editing.mapper.toViewElement(s),d=i.writer;if("reading"==l)return qI(u,d),void UI(r,c,u,d);if("uploading"==l){const e=a.loaders.get(o);return qI(u,d),void(e?(WI(u,d),function(e,t,i,n){const s=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),s),i.on("change:uploadedPercent",(e,t,i)=>{n.change(e=>{e.setStyle("width",i+"%",s)})})}(u,d,e,n.editing.view),function(e,t,i,n){if(n.data){const s=e.findViewImgElement(t);i.setAttribute("src",n.data,s)}}(r,u,d,e)):UI(r,c,u,d))}"complete"==l&&a.loaders.get(o)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout(()=>{i.change(e=>e.remove(e.createRangeOn(n)))},3e3)}(u,d,n.editing.view),function(e,t){jI(e,t,"progressBar")}(u,d),WI(u,d),function(e,t){t.removeClass("ck-appear",e)}(u,d)}}function qI(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function UI(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const s=e.findViewImgElement(i);s.getAttribute("src")!==t&&n.setAttribute("src",t,s),$I(i,"placeholder")||n.insert(n.createPositionAfter(s),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function WI(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),jI(e,t,"placeholder")}function $I(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function jI(e,t,i){const n=$I(e,i);n&&t.remove(t.createRangeOn(n))}class GI extends Gn{constructor(e){super(e),this.set("isAccessAllowed",!0)}refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=ln(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((e,t)=>{const o=i.getSelectedElement();if(t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);this._uploadImage(e,s,t)}else this._uploadImage(e,s)})}_uploadImage(e,t,i){const n=this.editor,s=n.plugins.get(kd).createLoader(e),o=n.plugins.get("ImageUtils");s&&o.insertImage({...t,uploadId:s.id},i)}}class KI extends $n{static get requires(){return[kd,zv,cx,tI]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}_uploadImageElements;_uploadedImages=new Map;constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(kd),s=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline"),r=MI(e.config.get("image.upload.types")),a=new GI(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add(e=>e.on("element:img",(e,t,i)=>{if(!i.consumable.test(t.viewItem,{attributes:["data-ck-upload-id"]}))return;const s=t.viewItem.getAttribute("data-ck-upload-id");if(!s)return;const[o]=Array.from(t.modelRange.getItems({shallow:!0})),r=n.loaders.get(s);o&&(i.writer.setAttribute("uploadId",s,o),i.consumable.consume(t.viewItem,{attributes:["data-ck-upload-id"]}),r&&r.data&&i.writer.setAttribute("uploadStatus",r.status,o))},{priority:"low"})),this.listenTo(e.editing.view.document,"clipboardInput",(t,i)=>{if(JI(i.dataTransfer))return;const n=Array.from(i.dataTransfer.files).filter(e=>!!e&&r.test(e.type));if(!n.length)return;t.stop(),e.model.change(t=>{i.targetRanges&&t.setSelection(i.targetRanges.map(t=>e.editing.mapper.toModelRange(t))),e.execute("uploadImage",{file:n})});if(!e.commands.get("uploadImage").isAccessAllowed){const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("You have no image upload permissions."),{namespace:"image"})}}),this.listenTo(o,"inputTransformation",(t,i)=>{const o=Array.from(e.editing.view.createRangeIn(i.content)).map(e=>e.item).filter(e=>NI(s,e)&&!e.getAttribute("uploadProcessed")).map(e=>({promise:FI(e),imageElement:e}));if(!o.length)return;const r=new Oc(e.editing.view.document);for(const e of o){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}}),e.editing.view.document.on("dragover",(e,t)=>{t.preventDefault()}),t.on("change",()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),s=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,o="$graveyard"==t.position.root.rootName;for(const t of QI(e,i)){const i=t.getAttribute("uploadId"),r=t.getAttribute("uploadStatus");if(!i||"complete"==r)continue;const a=n.loaders.get(i);if(a)if(o){if(!s.has(i)){const e=Array.from(this._uploadImageElements.get(i)).every(e=>"$graveyard"==e.root.rootName);e&&a.abort()}}else s.add(i),this._uploadImageElements.has(i)?this._uploadImageElements.get(i).add(t):this._uploadImageElements.set(i,new Set([t])),"idle"==a.status&&this._readAndUpload(a);else!o&&this._uploadedImages.has(i)&&e.model.enqueueChange({isUndoable:!1},e=>{e.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:this._uploadedImages.get(i),imageElement:t})})}}}),this.on("uploadComplete",(e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change(e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e),s.setImageNaturalSizeAttributes(t)})},{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageBlock")),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageInline"))}_readAndUpload(e){const t=this.editor,i=t.model,s=t.locale.t,o=t.plugins.get(kd),r=t.plugins.get(zv),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},t=>{const i=l.get(e.id);for(const e of i)t.setAttribute("uploadStatus","reading",e)}),e.read().then(()=>{const o=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(s("Uploading image"));for(const s of l.get(e.id)){if(n.isSafari){const e=t.editing.mapper.toViewElement(s),i=a.findViewImgElement(e);t.editing.view.once("render",()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n})}i.enqueueChange({isUndoable:!1},e=>{e.setAttribute("uploadStatus","uploading",s)})}return o}).then(n=>{i.enqueueChange({isUndoable:!1},i=>{for(const t of l.get(e.id))i.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:n,imageElement:t});t.ui&&t.ui.ariaLiveAnnouncer.announce(s("Image upload complete")),this._uploadedImages.set(e.id,n)}),c()}).catch(n=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(s("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw n;"error"==e.status&&n&&r.showWarning(n,{title:s("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},t=>{for(const i of l.get(e.id))"$graveyard"!==i.root.rootName&&t.remove(i)}),c()});function c(){i.enqueueChange({isUndoable:!1},t=>{for(const i of l.get(e.id))t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i);l.delete(e.id)}),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const s=Object.keys(e).filter(e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0}).map(t=>`${e[t]} ${t}w`).join(", ");if(""!=s){const e={srcset:s};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,n=i.get(kd),s=i.get(tI);t.for("dataDowncast").add(t=>{t.on(`attribute:uploadId:${e}`,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n.loaders.get(t.attributeNewValue);if(!o||!o.data)return null;const r=i.mapper.toViewElement(t.item),a=s.findViewImgElement(r);a&&(i.consumable.consume(t.item,e.name),i.writer.setAttribute("data-ck-upload-id",o.id,a))})})}}function JI(e){return Array.from(e.types).includes("text/html")&&""!==e.getData("text/html")}function QI(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter(e=>i.isImage(e.item)).map(e=>e.item)}class YI extends $n{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[KI,zI,HI]}}class ZI extends hh{urlInputView;keystrokes;constructor(e){super(e),this.set("imageURLInputValue",""),this.set("isImageSelected",!1),this.set("isEnabled",!0),this.keystrokes=new yn,this.urlInputView=this._createUrlInputView(),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-url"],tabindex:"-1"},children:[this.urlInputView,{tag:"div",attributes:{class:["ck","ck-image-insert-url__action-row"]}}]})}render(){super.render(),_h({view:this}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy()}_createUrlInputView(){const e=this.locale,t=e.t,i=new Ab(e,fw);return i.bind("label").to(this,"isImageSelected",e=>t(e?"Update image URL":"Insert image via URL")),i.bind("isEnabled").to(this),i.fieldView.inputMode="url",i.fieldView.placeholder="https://example.com/image.png",i.fieldView.bind("value").to(this,"imageURLInputValue",e=>e||""),i.fieldView.on("input",()=>{this.imageURLInputValue=i.fieldView.element.value.trim()}),i}focus(){this.urlInputView.focus()}}class XI extends $n{_imageInsertUI;_formView;static get pluginName(){return"ImageInsertViaUrlUI"}static get isOfficialPlugin(){return!0}static get requires(){return[TI,Rp]}init(){this.editor.ui.componentFactory.add("insertImageViaUrl",()=>this._createToolbarButton()),this.editor.ui.componentFactory.add("menuBar:insertImageViaUrl",()=>this._createMenuBarButton("standalone"))}afterInit(){this._imageInsertUI=this.editor.plugins.get("ImageInsertUI"),this._imageInsertUI.registerIntegration({name:"url",observable:()=>this.editor.commands.get("insertImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createInsertUrlButton(e){const t=new e(this.editor.locale);return t.icon=ug,t.on("execute",()=>{this._showModal()}),t}_createToolbarButton(){const e=this.editor.locale.t,t=this._createInsertUrlButton(yp);return t.tooltip=!0,t.bind("label").to(this._imageInsertUI,"isImageSelected",t=>e(t?"Update image URL":"Insert image via URL")),t}_createDropdownButton(){const e=this.editor.locale.t,t=this._createInsertUrlButton(yp);return t.withText=!0,t.bind("label").to(this._imageInsertUI,"isImageSelected",t=>e(t?"Update image URL":"Insert via URL")),t}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createInsertUrlButton(Mp);switch(i.withText=!0,e){case"standalone":i.label=t("Image via URL");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("Via URL")}return i}_createInsertUrlView(){const e=this.editor,t=e.locale,i=e.commands.get("replaceImageSource"),n=e.commands.get("insertImage"),s=new ZI(t);return s.bind("isImageSelected").to(this._imageInsertUI),s.bind("isEnabled").toMany([n,i],"isEnabled",(...e)=>e.some(e=>e)),s}_showModal(){const e=this.editor,t=e.locale.t,i=e.plugins.get("Dialog");this._formView||(this._formView=this._createInsertUrlView(),this._formView.on("submit",()=>this._handleSave()));const n=e.commands.get("replaceImageSource");this._formView.imageURLInputValue=n.value||"",i.show({id:"insertImageViaUrl",title:t("Image via URL"),isModal:!0,content:this._formView,actionButtons:[{label:t("Cancel"),withText:!0,onExecute:()=>i.hide()},{label:this._imageInsertUI.isImageSelected?t("Save"):t("Insert"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSave()}]})}_handleSave(){this.editor.commands.get("replaceImageSource").isEnabled?this.editor.execute("replaceImageSource",{source:this._formView.imageURLInputValue}):this.editor.execute("insertImage",{source:this._formView.imageURLInputValue}),this.editor.plugins.get("Dialog").hide()}}class eP extends $n{static get pluginName(){return"ImageInsertViaUrl"}static get isOfficialPlugin(){return!0}static get requires(){return[XI,TI]}}class tP extends $n{static get pluginName(){return"ImageInsert"}static get isOfficialPlugin(){return!0}static get requires(){return[YI,eP,TI]}}class iP extends Gn{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("resizedWidth")?this.value={width:t.getAttribute("resizedWidth"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},s&&i.change(t=>{t.setAttribute("resizedWidth",e.width,s),t.removeAttribute("resizedHeight",s),n.setImageNaturalSizeAttributes(s)})}}class nP extends $n{static get requires(){return[tI]}static get pluginName(){return"ImageResizeEditing"}static get licenseFeatureCode(){return"IR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new iP(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0})),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0}))}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add(t=>t.on(`attribute:resizedWidth:${e}`,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,s),n.addClass("image_resized",s)):(n.removeStyle("width",s),n.removeClass("image_resized",s))})),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:e=>({key:"style",value:{height:e}})}),t.conversion.for("editingDowncast").add(t=>t.on(`attribute:resizedHeight:${e}`,(t,n,s)=>{if(!s.consumable.consume(n.item,t.name))return;const o=s.writer,r=s.mapper.toViewElement(n.item),a="imageInline"===e?i.findViewImgElement(r):r;null!==n.attributeNewValue?o.setStyle("height",n.attributeNewValue,a):o.removeStyle("height",a)})),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:e=>XS(e)?null:e.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:e=>XS(e)?null:e.getStyle("height")}}),t.conversion.for("upcast").add(t=>{t.on("element:"+("imageBlock"===e?"figure":"img"),(e,t,i)=>{i.consumable.consume(t.viewItem,{classes:["image_resized"]})})})}}const sP=(()=>({small:Xg,medium:Zg,large:Yg,custom:Jg,original:Qg}))();class oP extends $n{static get requires(){return[nP]}static get pluginName(){return"ImageResizeButtons"}static get isOfficialPlugin(){return!0}_resizeUnit;constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:s}=e;t.ui.componentFactory.add(i,i=>{const o=new yp(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!sP[s])throw new I("imageresizebuttons-missing-icon",t,e);if(o.set({label:a,icon:sP[s],tooltip:a,isToggleable:!0}),o.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&rP(e)){const e=t.plugins.get("ImageCustomResizeUI");this.listenTo(o,"execute",()=>{e._showForm(this._resizeUnit)})}else{const e=n?n+this._resizeUnit:null;o.bind("isOn").to(r,"value",r,"isEnabled",aP(e)),this.listenTo(o,"execute",()=>{t.execute("resizeImage",{width:e})})}return o})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find(e=>!e.value),s=s=>{const o=t.commands.get("resizeImage"),r=ow(s,Bb),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:sP.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(o,"value",e=>e&&e.width?e.width:this._getOptionLabelValue(n)),r.bind("isEnabled").to(this),uw(r,()=>this._getResizeDropdownListItemDefinitions(e,o),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",e=>{"onClick"in e.source?e.source.onClick():(t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus())}),r};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?rP(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):rP(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new gn,s=e.map(e=>rP(e)?{...e,valueWithUnits:"custom"}:e.value?{...e,valueWithUnits:`${e.value}${this._resizeUnit}`}:{...e,valueWithUnits:null});for(const e of s){let o=null;if(i.plugins.has("ImageCustomResizeUI")&&rP(e)){const n=i.plugins.get("ImageCustomResizeUI");o={type:"button",model:new Hv({label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{n._showForm(this._resizeUnit)}})};const r=Object.values(s).map(e=>e.valueWithUnits);o.model.bind("isOn").to(t,"value",t,"isEnabled",lP(r))}else o={type:"button",model:new Hv({commandName:"resizeImage",commandValue:e.valueWithUnits,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})},o.model.bind("isOn").to(t,"value",t,"isEnabled",aP(e.valueWithUnits));o.model.bind("isEnabled").to(t,"isEnabled"),n.add(o)}return n}}function rP(e){return"custom"===e.value}function aP(e){return(t,i)=>!(void 0===t||!i)&&(null===e&&t===e||null!==t&&t.width===e)}function lP(e){return(t,i)=>!e.some(e=>aP(e)(t,i))}const cP="image_resized";class uP extends $n{static get requires(){return[Zk,tI]}static get pluginName(){return"ImageResizeHandles"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(bI),this.listenTo(t.document,"imageLoaded",(n,s)=>{if(!s.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const o=e.editing.view.domConverter,r=o.domToView(s.target),a=i.getImageWidgetFromImageView(r);let l=this.editor.plugins.get(Zk).getResizerByViewElement(a);if(l)return void l.redraw();const c=e.editing.mapper,u=c.toModelElement(a);l=e.plugins.get(Zk).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:u,viewElement:a,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>o.mapViewToDom(c.toViewElement(u)),isCentered:()=>"alignCenter"==u.getAttribute("imageStyle"),onCommit(i){t.change(e=>{e.removeClass(cP,a)}),e.execute("resizeImage",{width:i})}}),l.on("updateSize",()=>{a.hasClass(cP)||t.change(e=>{e.addClass(cP,a)});const e="imageInline"===u.name?r:a;e.getStyle("height")&&t.change(t=>{t.removeStyle("height",e)})}),l.bind("isEnabled").to(this)})}}function dP(e){if(!e)return null;const[,t,i]=e.trim().match(/([.,\d]+)(%|px)$/)||[],n=Number.parseFloat(t);return Number.isNaN(n)?null:{value:n,unit:i}}function hP(e,t,i){return"px"===i?{value:t.value,unit:"px"}:{value:t.value/e*100,unit:"%"}}function mP(e){const{editing:t}=e,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);if(!i)return null;const n=t.mapper.toViewElement(i);return{model:i,view:n,dom:t.view.domConverter.mapViewToDom(n)}}function gP(e,t){const i=mP(e);if(!i)return null;const n=dP(i.model.getAttribute("resizedWidth")||null);if(!n)return null;if(n.unit===t)return n;return hP(Ek(i.dom),{value:new pi(i.dom).width},t)}class fP extends hh{focusTracker;keystrokes;unit;backButtonView;saveButtonView;labeledInput;children;_focusables;_focusCycler;_validators;constructor(e,t,i){super(e),this.focusTracker=new bn,this.keystrokes=new yn,this.unit=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new Mv(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new qd,this._validators=i,this.keystrokes.set("Esc",(e,t)=>{this.fire("cancel"),t()}),this._focusCycler=new xp({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-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),_h({view:this});[this.backButtonView,this.labeledInput,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()}_createBackButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:bf,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Cp(this.locale,{label:e("Image Resize")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Ab(this.locale,pw);return t.label=e("Resize image (in %0)",this.unit),t.class="ck-labeled-field-view_full-width",t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(null===e)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return null===e?null:`${e}${t}`}}function pP(e,t){const i=mP(e);if(!i)return null;const n=Ek(i.dom),s=dP(window.getComputedStyle(i.dom).minWidth)||{value:1};return{unit:t,lower:Math.max(.1,hP(n,s,t).value),upper:"px"===t?n:100}}class bP extends $n{_balloon;_form;static get requires(){return[Uv]}static get pluginName(){return"ImageCustomResizeUI"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(wh(fP))(t.locale,e,function(e){const t=e.t;return[e=>""===e.rawSize.trim()?t("The value must not be empty."):null===e.parsedSize?t("The value should be a plain number."):void 0]}(t)),this._form.render(),this.listenTo(this._form,"submit",()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))}),this.listenTo(this._form.labeledInput,"change:errorText",()=>{t.ui.update()}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),bh({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:cI(t)});const n=gP(t,e),s=n?n.value.toFixed(1):"",o=pP(t,e);i.fieldView.value=i.fieldView.element.value=s,o&&Object.assign(i.fieldView,{min:o.lower.toFixed(1),max:Math.ceil(o.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class wP extends $n{static get requires(){return[nP,uP,bP,oP]}static get pluginName(){return"ImageResize"}static get isOfficialPlugin(){return!0}}class vP extends Gn{_defaultStyles;_styles;constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map(e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]}))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change(t=>{const s=e.value,{setImageSizes:o=!0}=e;let r=n.getClosestSelectedImageElement(i.document.selection);s&&this.shouldConvertImageType(s,r)&&(this.editor.execute(n.isBlockImage(r)?"imageTypeInline":"imageTypeBlock",{setImageSizes:o}),r=n.getClosestSelectedImageElement(i.document.selection)),!s||this._styles.get(s).isDefault?t.removeAttribute("imageStyle",r):t.setAttribute("imageStyle",s,r),o&&n.setImageNaturalSizeAttributes(r)})}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const _P={get inline(){return{name:"inline",title:"In line",icon:jg,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:Wg,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:Gg,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:qg,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:$g,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:Kg,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:qg,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:$g,modelElements:["imageBlock"],className:"image-style-side"}}},yP=(()=>({full:Ug,left:Gg,right:Kg,center:qg,inlineLeft:Wg,inlineRight:$g,inline:jg}))(),kP=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function CP(e){P("image-style-configuration-definition-invalid",e)}const xP={normalizeStyles:function(e){const t=(e.configuredStyles.options||[]).map(e=>function(e){e="string"==typeof e?_P[e]?{..._P[e]}:{name:e}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(_P[e.name],e);"string"==typeof e.icon&&(e.icon=yP[e.icon]||e.icon);return e}(e)).filter(t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:s}=e;if(!(n&&n.length&&s))return CP({style:e}),!1;{const s=[t?"imageBlock":null,i?"imageInline":null];if(!n.some(e=>s.includes(e)))return P("image-style-missing-dependency",{style:e,missingPlugins:n.map(e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}(t,e));return t},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...kP]:[]},warnInvalidStyle:CP};function AP(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=EP(i.attributeNewValue,e),o=EP(i.attributeOldValue,e),r=n.mapper.toViewElement(i.item),a=n.writer;o&&a.removeClass(o.className,r),s&&a.addClass(s.className,r)}}function TP(e){const t={imageInline:e.filter(e=>!e.isDefault&&e.modelElements.includes("imageInline")),imageBlock:e.filter(e=>!e.isDefault&&e.modelElements.includes("imageBlock"))};return(e,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=fn(i.modelRange.getItems());if(o&&n.schema.checkAttribute(o,"imageStyle"))for(const e of t[o.name])n.consumable.consume(s,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,o)}}function EP(e,t){for(const i of t)if(i.name===e)return i}class SP extends $n{static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[tI]}normalizedStyles;init(){const e=this.editor,t=e.plugins.has("ImageBlockEditing"),i=e.plugins.has("ImageInlineEditing");e.config.define("image.styles",xP.getDefaultStylesConfiguration(t,i)),this.normalizedStyles=xP.normalizeStyles({configuredStyles:e.config.get("image.styles"),isBlockPluginLoaded:t,isInlinePluginLoaded:i}),this._setupConversion(t,i),this._setupPostFixer(),e.commands.add("imageStyle",new vP(e,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,s=AP(this.normalizedStyles),o=TP(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:figure",o,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:img",o,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(tI),n=new Map(this.normalizedStyles.map(e=>[e.name,e]));t.registerPostFixer(e=>{let s=!1;for(const o of t.differ.getChanges())if("insert"==o.type||"attribute"==o.type&&"imageStyle"==o.attributeKey){let t="insert"==o.type?o.position.nodeAfter:o.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),s=!0)}return s})}}class IP extends $n{static get requires(){return[SP]}static get pluginName(){return"ImageStyleUI"}static get isOfficialPlugin(){return!0}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=PP(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=PP([...t.filter(ie),...xP.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,n=>{let s;const{defaultItem:o,items:r,title:a}=e,l=r.filter(e=>t.find(({name:t})=>VP(t)===e)).map(e=>{const t=i.create(e);return e===o&&(s=t),t});r.length!==l.length&&xP.warnInvalidStyle({dropdown:e});const c=ow(n,sw),u=c.buttonView,d=u.arrowView;return lw(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),u.set({label:OP(a,s.label),class:null,tooltip:!0}),d.unbind("label"),d.set({label:a}),u.bind("icon").toMany(l,"isOn",(...e)=>{const t=e.findIndex(Qe);return t<0?s.icon:l[t].icon}),u.bind("label").toMany(l,"isOn",(...e)=>{const t=e.findIndex(Qe);return OP(a,t<0?s.label:l[t].label)}),u.bind("isOn").toMany(l,"isOn",(...e)=>e.some(Qe)),u.bind("class").toMany(l,"isOn",(...e)=>e.some(Qe)?"ck-splitbutton_flatten":void 0),u.on("execute",()=>{l.some(({isOn:e})=>e)?c.isOpen=!c.isOpen:s.fire("execute")}),c.bind("isEnabled").toMany(l,"isEnabled",(...e)=>e.some(Qe)),this.listenTo(c,"execute",()=>{this.editor.editing.view.focus()}),c})}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(VP(t),i=>{const n=this.editor.commands.get("imageStyle"),s=new yp(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>e===t),s.on("execute",this._executeCommand.bind(this,t)),s})}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function PP(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function VP(e){return`imageStyle:${e}`}function OP(e,t){return(e?e+": ":"")+t}class RP extends $n{static get requires(){return[SP,IP]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}}class BP extends $n{static get requires(){return[Wk,tI]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(Wk),n=e.plugins.get("ImageUtils");var s;i.register("image",{ariaLabel:t("Image toolbar"),items:(s=e.config.get("image.toolbar")||[],s.map(e=>ie(e)?e.name:e)),getRelatedElement:e=>n.getClosestSelectedImageWidget(e)})}}class LP extends $n{static get requires(){return[_I,tI]}static get pluginName(){return"PictureEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(mI(i)),t.for("downcast").add(fI(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",(t,{imageElement:i,data:n})=>{const s=n.sources;s&&e.model.change(e=>{e.setAttributes({sources:s},i)})})}}class MP extends $n{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new Jn(e)),e.commands.add("outdent",new Jn(e))}}class FP extends $n{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?mg:nf,s="ltr"==t.uiLanguageDirection?nf:mg;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,()=>{const n=this._createButton(yp,e,t,i);return n.set({tooltip:!0}),n}),n.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(Mp,e,t,i))}_createButton(e,t,i,n){const s=this.editor,o=s.commands.get(t),r=new e(s.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(o,"isEnabled"),this.listenTo(r,"execute",()=>{s.execute(t),s.editing.view.focus()}),r}}class NP extends $n{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[MP,FP]}}class DP extends Gn{_indentBehavior;constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change(e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}})}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter(e=>this._isIndentationChangeAllowed(e))}_isIndentationChangeAllowed(e){const t=this.editor;if(!t.model.schema.checkAttribute(e,"blockIndent"))return!1;if(!t.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!t.plugins.get("ListUtils").isListItemBlock(e)}}class zP{isForward;offset;unit;constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class HP{isForward;classes;constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const qP=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class UP extends $n{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new DP(e,new HP({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new DP(e,new HP({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(bu),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new DP(e,new zP({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new DP(e,new zP({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),n=e.commands.get("outdent"),s=e.config.get("heading.options"),o=s&&s.map(e=>e.model);(o||qP).forEach(e=>{t.isRegistered(e)&&t.extend(e,{allowAttributes:"blockIndent"})}),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),n.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:e=>{if(!e.is("element","li"))return e.getStyle(t)}}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:e=>({key:"style",value:{[t]:e}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}}function WP(e,t){return`${e}:${t=t||an(e)}`}function $P(e){const[t,i]=e.split(":");return{languageCode:t,textDirection:i}}class jP extends Gn{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const i=this.editor.model,n=i.document.selection,s=!!e&&WP(e,t);i.change(e=>{if(n.isCollapsed)s?e.setSelectionAttribute("language",s):e.removeSelectionAttribute("language");else{const t=i.schema.getValidRanges(n.getRanges(),"language");for(const i of t)s?e.setAttribute("language",s,i):e.removeAttribute("language",i)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.getAttribute("language")||!1;for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,"language"))return i.getAttribute("language")||!1;return!1}}class GP extends $n{static get pluginName(){return"TextPartLanguageEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new jP(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>WP(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},i)=>{if(!e)return;if(!i.item.is("$textProxy")&&!i.item.is("documentSelection"))return;const{languageCode:n,textDirection:s}=$P(e);return t.createAttributeElement("span",{lang:n,dir:s})}})}}class KP extends $n{static get pluginName(){return"TextPartLanguageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=t("Choose language"),n=t("Language");e.ui.componentFactory.add("textPartLanguage",t=>{const{definitions:s,titles:o}=this._getItemMetadata(),r=e.commands.get("textPartLanguage"),a=ow(t);return uw(a,s,{ariaLabel:n,role:"menu"}),a.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),a.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),a.bind("isEnabled").to(r,"isEnabled"),a.buttonView.bind("label").to(r,"value",e=>e&&o[e]||i),a.buttonView.bind("ariaLabel").to(r,"value",e=>{const t=e&&o[e];return t?`${t}, ${n}`:n}),this.listenTo(a,"execute",t=>{r.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()}),a}),e.ui.componentFactory.add("menuBar:textPartLanguage",i=>{const{definitions:s}=this._getItemMetadata(),o=e.commands.get("textPartLanguage"),r=new d_(i);r.buttonView.set({label:n});const a=new h_(i);a.set({ariaLabel:t("Language"),role:"menu"});for(const e of s){if("button"!=e.type){a.items.add(new Nb(i));continue}const t=new hv(i,r),n=new Mp(i);n.set({role:"menuitemradio",isToggleable:!0}),n.bind(...Object.keys(e.model)).to(e.model),n.delegate("execute").to(r),t.children.add(n),a.items.add(t)}return r.bind("isEnabled").to(o,"isEnabled"),r.panelView.children.add(a),r.on("execute",t=>{o.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()}),r})}_getItemMetadata(){const e=this.editor,t=new gn,i={},n=e.commands.get("textPartLanguage"),s=e.config.get("language.textPartLanguage"),o=(0,e.locale.t)("Remove language");t.add({type:"button",model:new Hv({label:o,languageCode:!1,withText:!0})}),t.add({type:"separator"});for(const e of s){const s={type:"button",model:new Hv({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},o=WP(e.languageCode,e.textDirection);s.model.bind("isOn").to(n,"value",e=>e===o),t.add(s),i[o]=e.title}return{definitions:t,titles:i}}}class JP extends $n{static get requires(){return[GP,KP]}static get pluginName(){return"TextPartLanguage"}static get isOfficialPlugin(){return!0}}class QP{_definitions=new Set;get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach(e=>this._definitions.add(e)):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",(e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,s=n.document.selection;for(const e of this._definitions){const o=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,o);for(const t in e.styles)n.setStyle(t,e.styles[t],o);n.setCustomProperty("link",!0,o),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(s.getFirstRange(),o):n.wrap(i.mapper.toViewRange(t.range),o):n.unwrap(i.mapper.toViewRange(t.range),o)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",(e,t,{writer:i,mapper:n})=>{const s=n.toViewElement(t.item),o=Array.from(s.getChildren()).find(e=>e.is("element","a"));if(o)for(const e of this._definitions){const n=Cn(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,o):i.setAttribute(e,t,o);e.classes&&i.addClass(e.classes,o);for(const t in e.styles)i.setStyle(t,e.styles[t],o)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,o):i.removeAttribute(e,o);e.classes&&i.removeClass(e.classes,o);for(const t in e.styles)i.removeStyle(t,o)}}})}}}const YP=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,ZP=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,XP=/^((\w+:(\/{2,})?)|(\W))/i,eV=["https?","ftps?","mailto"],tV="Ctrl+K";function iV(e){return e.is("attributeElement")&&!!e.getCustomProperty("link")}function nV(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function sV(e,t=eV){const i=String(e),n=t.join("|");return function(e,t){const i=e.replace(YP,"");return!!i.match(t)}(i,new RegExp(`${"^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("",n)}`,"i"))?i:"#"}function oV(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach(e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e)),t}function rV(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${Ot(i)}`});t.push(e)}return t}function aV(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function lV(e){return ZP.test(e)}function cV(e,t){const i=lV(e)?"mailto:":t,n=!!i&&!uV(e);return e&&n?i+e:e}function uV(e){return XP.test(e)}function dV(e){window.open(e,"_blank","noopener")}function hV(e){let t="";for(const i of e.getItems()){if(!i.is("$text")&&!i.is("$textProxy"))return;t+=i.data}return t}class mV extends Gn{manualDecorators=new gn;automaticDecorators=new QP;restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||fn(t.getSelectedBlocks());aV(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={},i){const n=this.editor.model,s=n.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);n.change(t=>{const a=i=>{t.setAttribute("linkHref",e,i),o.forEach(e=>t.setAttribute(e,!0,i)),r.forEach(e=>t.removeAttribute(e,i))},l=(s,o)=>{const r=hV(s);if(!r)return s;let l=i;if(l||(l=o&&o==r?e:r),l!=r){const e=t.createDocumentFragment();for(const i of s.getItems()){const n=i;t.append(t.createText(n.data,n.getAttributes()),e)}const i=t.createRangeIn(e),o=function(e,t){const i=b(e,t),n={equal:0,insert:0,delete:0},s=[];let o="",r="";for(const a of[...i,null])"insert"==a?r+=t[n.equal+n.insert]:"delete"==a?o+=e[n.equal+n.delete]:(o.length||r.length)&&(s.push({offset:n.equal,actual:o,expected:r}),o="",r=""),a&&n[a]++;return s}(r,l);let c=0;for(const{offset:e,actual:s,expected:r}of o){const o=e+c,l=t.createRange(i.start.getShiftedBy(o),i.start.getShiftedBy(o+s.length)),u=gV(l,i).getAttributes(),d=Array.from(u).filter(([e])=>n.schema.getAttributeProperties(e).isFormatting),h=t.createText(r,d);a(h),t.remove(l),t.insert(h,l.start),c+=r.length}return n.insertContent(e,s),t.createRange(s.start,s.start.getShiftedBy(l.length))}},c=e=>{const{plugins:i}=this.editor;if(t.setSelection(e.end),i.has("TwoStepCaretMovement"))i.get("TwoStepCaretMovement")._handleForwardMovement();else for(const e of["linkHref",...o,...r])t.removeSelectionAttribute(e)};if(s.isCollapsed){const r=s.getFirstPosition();if(s.hasAttribute("linkHref")){const e=s.getAttribute("linkHref"),t=ty(r,"linkHref",e,n),i=l(t,e);a(i||t),i&&c(i)}else if(""!==e){const a=Cn(s.getAttributes());a.set("linkHref",e),o.forEach(e=>{a.set(e,!0)});c(n.insertContent(t.createText(i||e,a),r))}}else{const e=Array.from(s.getRanges()),i=n.schema.getValidRanges(e,"linkHref"),o=[];for(const e of s.getSelectedBlocks())n.schema.checkAttribute(e,"linkHref")&&o.push(t.createRangeOn(e));const r=o.slice();for(const e of i)this._isRangeToUpdate(e,o)&&r.push(e);const c=e.map(e=>({start:Ll.fromPosition(e.start,"toPrevious"),end:Ll.fromPosition(e.end,"toNext")}));for(let e of r){e=l(e,(e.start.textNode||e.start.nodeAfter).getAttribute("linkHref"))||e,a(e)}t.setSelection(c.map(e=>{const t=e.start.toPosition(),i=e.end.toPosition();return e.start.detach(),e.end.detach(),n.createRange(t,i)}))}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return aV(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function gV(e,t){if(!e.isCollapsed)return fn(e.getItems());const i=e.start;return i.textNode?i.textNode:!i.nodeBefore||i.isEqual(t.start)?i.nodeAfter:i.nodeBefore}class fV extends Gn{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();aV(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change(e=>{const s=i.isCollapsed?[ty(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of s)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)})}}class pV extends(Dt()){id;defaultValue;label;attributes;classes;styles;constructor({id:e,label:t,attributes:i,classes:n,styles:s,defaultValue:o}){super(),this.id=e,this.set("value",void 0),this.defaultValue=o,this.label=t,this.attributes=i,this.classes=n,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const bV="automatic",wV=/^(https?:)?\/\//;class vV extends $n{_linkOpeners=[];static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[z_,A_,cx]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:nV}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>nV(sV(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new mV(e)),e.commands.add("unlink",new fV(e));const i=oV(e.t,rV(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(e=>e.mode===bV)),this._enableManualDecorators(i.filter(e=>"manual"===e.mode));e.plugins.get(z_).registerAttribute("linkHref"),ny(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:bV,callback:e=>!!e&&wV.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new pV(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:s})=>{if((s.is("selection")||i.isInline(s))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})})}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=e=>{this._linkOpeners.some(t=>t(e))||dV(e)};this.listenTo(t,"click",(e,t)=>{if(!(n.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let s=t.domTarget;if("a"!=s.tagName.toLowerCase()&&(s=s.closest("a")),!s)return;const o=s.getAttribute("href");o&&(e.stop(),t.preventDefault(),i(o))},{context:"$capture"}),this.listenTo(t,"keydown",(t,n)=>{const s=e.commands.get("link").value;!!s&&n.keyCode===Qi.enter&&n.altKey&&(t.stop(),i(s))})}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",(i,{attributeKeys:n})=>{n.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change(t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter(e=>e.startsWith("link"))))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(e,n)=>{t.change(e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=cV(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}})})}}class _V extends yp{constructor(e){super(e);const t=this.bindTemplate;this.set({href:void 0,withText:!0}),this.extendTemplate({attributes:{class:["ck-link-toolbar__preview"],href:t.to("href"),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to(e=>{if(this.href){const t=()=>e.preventDefault();this.fire("navigate",this.href,t)}})}}),this.template.tag="a"}}class yV extends hh{focusTracker=new bn;keystrokes=new yn;backButtonView;saveButtonView;displayedTextInputView;urlInputView;children;providersListChildren;_validators;_focusables=new qd;_focusCycler;constructor(e,t){super(e),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.displayedTextInputView=this._createDisplayedTextInput(),this.urlInputView=this._createUrlInput(),this.providersListChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView()]),this._createFormChildren(),this.listenTo(this.providersListChildren,"add",()=>{this.stopListening(this.providersListChildren,"add"),this.children.add(this._createProvidersListView())}),this._focusCycler=new xp({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-link-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),_h({view:this});[this.urlInputView,this.saveButtonView,...this.providersListChildren,this.backButtonView,this.displayedTextInputView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:bf,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({label:e("Insert"),tooltip:!1,withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Cp(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new zb(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using(e=>{const t=new Fb(this.locale);return t.children.add(e),t}),e}_createDisplayedTextInput(){const e=this.locale.t,t=new Ab(this.locale,fw);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new Ab(this.locale,fw);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new Mv(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new Mv(this.locale,{children:[this.urlInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding","ck-form__row_large-bottom-padding"]}))}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class kV extends hh{focusTracker=new bn;keystrokes=new yn;backButtonView;listView;listChildren;emptyListInformation;children;_focusables=new qd;_focusCycler;constructor(e){super(e),this.listChildren=this.createCollection(),this.backButtonView=this._createBackButton(),this.listView=this._createListView(),this.emptyListInformation=this._createEmptyLinksListItemView(),this.children=this.createCollection([this._createHeaderView(),this.emptyListInformation]),this.set("title",""),this.set("emptyListPlaceholder",""),this.set("hasItems",!1),this.listenTo(this.listChildren,"change",()=>{this.hasItems=this.listChildren.length>0}),this.on("change:hasItems",(e,t,i)=>{i?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))}),this.keystrokes.set("Esc",(e,t)=>{this.fire("cancel"),t()}),this._focusCycler=new xp({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-providers"],tabindex:"-1"},children:this.children})}render(){super.render();[this.listView,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createListView(){const e=new zb(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using(e=>{const t=new Fb(this.locale);return t.children.add(e),t}),e}_createBackButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:bf,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new Cp(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new hh(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}class CV extends hh{focusTracker=new bn;keystrokes=new yn;backButtonView;children;listChildren;_focusables=new qd;_focusCycler;constructor(e){super(e),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new xp({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-properties"],tabindex:"-1"},children:this.children}),this.keystrokes.set("Esc",(e,t)=>{this.fire("back"),t()})}render(){super.render();[...this.listChildren,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new yp(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:bf,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new Cp(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new zb(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using(e=>{const t=new Fb(this.locale);return t.children.add(e),t}),e}}class xV extends yp{arrowView;constructor(e){super(e),this.set({withText:!0}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-link__button"]}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new vp;return e.content=Dg,e}}const AV="link-ui";class TV extends $n{toolbarView=null;formView=null;linkProviderItemsView=null;propertiesView=null;_balloon;_linksProviders=new gn;static get requires(){return[Uv,vV]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;this.set("selectedLinkableText",void 0),e.editing.view.addObserver(Sc),this._balloon=e.plugins.get(Uv),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:AV,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:AV,view:(e,{writer:t})=>{if(!e.markerRange.isCollapsed)return null;const i=t.createUIElement("span");return t.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],i),i}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:tV},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.propertiesView&&this.propertiesView.destroy(),this.formView&&this.formView.destroy(),this.toolbarView&&this.toolbarView.destroy(),this.linkProviderItemsView&&this.linkProviderItemsView.destroy()}registerLinksListProvider(e){const t=this._linksProviders.filter(t=>(t.order||0)<=(e.order||0)).length;this._linksProviders.add(e,t)}_createViews(){const e=this.editor.commands.get("link");this.toolbarView=this._createToolbarView(),this.formView=this._createFormView(),e.manualDecorators.length&&(this.propertiesView=this._createPropertiesView()),this._enableUserBalloonInteractions()}_createToolbarView(){const e=this.editor,t=new ew(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let n=e.config.get("link.toolbar");return i.manualDecorators.length||(n=n.filter(e=>"linkProperties"!==e)),t.fillFromConfig(n,e.ui.componentFactory),t.keystrokes.set("Esc",(e,t)=>{this._hideUI(),t()}),t.keystrokes.set(tV,(e,t)=>{this._addFormView(),t()}),e.ui.addToolbar(t,{isContextual:!0,beforeFocus:()=>{this._getSelectedLinkElement()&&!this._isToolbarVisible&&this._showUI(!0)},afterBlur:()=>{this._hideUI(!1)}}),t}_createFormView(){const e=this.editor,t=e.locale.t,i=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),s=new(wh(yV))(e.locale,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return s.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",e=>void 0!==e),s.urlInputView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("label").to(i,"value",e=>t(e?"Update":"Insert")),this.listenTo(s,"submit",()=>{if(s.isValid()){const t=cV(s.urlInputView.fieldView.element.value,n),i=s.displayedTextInputView.fieldView.element.value;e.execute("link",t,this._getDecoratorSwitchesState(),i!==this.selectedLinkableText?i:void 0),this._closeFormView()}}),this.listenTo(s.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(s,"cancel",()=>{this._closeFormView()}),s.keystrokes.set("Esc",(e,t)=>{this._closeFormView(),t()}),s.providersListChildren.bindTo(this._linksProviders).using(e=>this._createLinksListProviderButton(e)),s}_createLinkProviderListView(e){return e.getListItems().map(({href:e,label:t,icon:i})=>{const n=new yp;return n.set({label:t,icon:i,tooltip:!1,withText:!0}),n.on("execute",()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=e,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),n})}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,n=new kV(t.locale),{emptyListPlaceholder:s,label:o}=e;return n.emptyListPlaceholder=s||i("No links available"),n.title=o,this.listenTo(n,"cancel",()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),n}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(wh(CV))(e.locale);return this.listenTo(i,"back",()=>{e.editing.view.focus(),this._removePropertiesView()}),i.listChildren.bindTo(t.manualDecorators).using(i=>{const n=new Gp(e.locale);return n.set({label:i.label,withText:!0}),n.bind("isOn").toMany([i,t],"value",(e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e),n.on("execute",()=>{i.set("value",!n.isOn),e.execute("link",t.value,this._getDecoratorSwitchesState())}),n}),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce((t,i)=>{const n=void 0===e.value&&void 0===i.value?i.defaultValue:i.value;return{...t,[i.id]:!!n}},{})}_registerEditingOpeners(){this.editor.plugins.get(vV)._registerLinkOpener(e=>{const t=this._getLinkProviderLinkByHref(e);if(!t)return!1;const{item:i,provider:n}=t;return!!n.navigate&&n.navigate(i)})}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const e=this._createButton(yp);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:link",()=>{const e=this._createButton(Mp);return e.set({role:"menuitemcheckbox"}),e}),e.ui.componentFactory.add("linkPreview",t=>{const i=new _V(t),n=e.config.get("link.allowedProtocols"),s=e.commands.get("link"),o=t.t;i.bind("isEnabled").to(s,"value",e=>!!e),i.bind("href").to(s,"value",e=>e&&sV(e,n));const r=e=>{if(!e)return i.label=void 0,i.icon=void 0,void(i.tooltip=o("Open link in new tab"));const t=this._getLinkProviderLinkByHref(e);if(t){const{label:e,tooltip:n,icon:s}=t.item;i.label=e,i.tooltip=n||!1,i.icon=s}else i.label=e,i.icon=void 0,i.tooltip=o("Open link in new tab")};return r(s.value),this.listenTo(s,"change:value",(e,t,i)=>{r(i)}),this.listenTo(i,"navigate",(e,t,i)=>{const n=this._getLinkProviderLinkByHref(t);if(!n)return;const{provider:s,item:o}=n,{navigate:r}=s;r&&r(o)&&(e.stop(),i())}),i}),e.ui.componentFactory.add("unlink",t=>{const i=e.commands.get("unlink"),n=new yp(t),s=t.t;return n.set({label:s("Unlink"),icon:dp,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{e.execute("unlink"),this._hideUI()}),n}),e.ui.componentFactory.add("editLink",t=>{const i=e.commands.get("link"),n=new yp(t),s=t.t;return n.set({label:s("Edit link"),icon:df,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{this._addFormView()}),n}),e.ui.componentFactory.add("linkProperties",t=>{const i=e.commands.get("link"),n=new yp(t),s=t.t;return n.set({label:s("Link properties"),icon:Vf,tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",(e,t,i)=>e&&!!t&&i.length>0),this.listenTo(n,"execute",()=>{this._addPropertiesView()}),n})}_createLinksListProviderButton(e){const t=this.editor.locale,i=new xV(t);return i.set({label:e.label}),this.listenTo(i,"execute",()=>{this._showLinksProviderView(e)}),i}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),s=new e(t.locale),o=i.t;return s.set({label:o("Link"),icon:vg,keystroke:tV,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>!!e),this.listenTo(s,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showUI(!0),this._getSelectedLinkElement()&&this._addFormView()}),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(tV,(t,i)=>{i(),e.commands.get("link").isEnabled&&(e.editing.view.scrollToTheSelection(),this._showUI(!0))})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(e,t)=>{this._isToolbarVisible&&!this.toolbarView.focusTracker.isFocused&&(this.toolbarView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),bh({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideUI(!1)}})}_addToolbarView(){this.toolbarView||this._createViews(),this._isToolbarInPanel||this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this.formView.backButtonView.isVisible=e.isEnabled&&!!e.value,this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.selectedLinkableText=this._getSelectedLinkableText(),this.formView.displayedTextInputView.fieldView.value=this.selectedLinkableText||"",this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_addPropertiesView(){this.propertiesView||this._createViews(),this._arePropertiesInPanel||(this.propertiesView.disableCssTransitions(),this._balloon.add({view:this.propertiesView,position:this._getBalloonPositionData()}),this.propertiesView.enableCssTransitions(),this.propertiesView.focus())}_showLinksProviderView(e){this.linkProviderItemsView&&this._removeLinksProviderView(),this.linkProviderItemsView=this._createLinkProviderItemsView(e),this._addLinkProviderItemsView(e)}_addLinkProviderItemsView(e){this.linkProviderItemsView.listChildren.clear(),this.linkProviderItemsView.listChildren.addMany(this._createLinkProviderListView(e)),this._balloon.add({view:this.linkProviderItemsView,position:this._getBalloonPositionData()}),this.linkProviderItemsView.focus()}_closeFormView(){const e=this.editor.commands.get("link");this.selectedLinkableText=void 0,void 0!==e.value?this._removeFormView():this._hideUI()}_removePropertiesView(){this._arePropertiesInPanel&&this._balloon.remove(this.propertiesView)}_removeLinksProviderView(){this._isLinksListInPanel&&this._balloon.remove(this.linkProviderItemsView)}_removeFormView(e=!0){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.displayedTextInputView.fieldView.reset(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._isToolbarVisible?this._addFormView():this._addToolbarView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addToolbarView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(e=!0){const t=this.editor;this._isUIInPanel&&(this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeLinksProviderView(),this._removePropertiesView(),this._removeFormView(e),this._isToolbarInPanel&&this._balloon.remove(this.toolbarView),this._hideFakeVisualSelection())}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=o();const s=()=>{const e=this._getSelectedLinkElement(),t=o();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function o(){return t.selection.focus.getAncestors().reverse().find(e=>e.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _arePropertiesInPanel(){return!!this.propertiesView&&this._balloon.hasView(this.propertiesView)}get _isLinksListInPanel(){return!!this.linkProviderItemsView&&this._balloon.hasView(this.linkProviderItemsView)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isToolbarInPanel(){return!!this.toolbarView&&this._balloon.hasView(this.toolbarView)}get _isPropertiesVisible(){return!!this.propertiesView&&this._balloon.visibleView===this.propertiesView}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}get _isToolbarVisible(){return!!this.toolbarView&&this._balloon.visibleView===this.toolbarView}get _isUIInPanel(){return this._arePropertiesInPanel||this._isLinksListInPanel||this._isFormInPanel||this._isToolbarInPanel}get _isUIVisible(){return this._isPropertiesVisible||this._isLinksListInPanel||this._isFormVisible||this._isToolbarVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;if(this.editor.model.markers.has(AV)){const t=this.editor.editing.mapper.markerNameToElements(AV);if(t){const i=Array.from(t),n=e.createRange(e.createPositionBefore(i[0]),e.createPositionAfter(i[i.length-1]));return{target:e.domConverter.viewRangeToDom(n)}}}return{target:()=>{const i=this._getSelectedLinkElement();return i?e.domConverter.mapViewToDom(i):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&pk(i))return EV(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=EV(i.start),s=EV(i.end);return n&&n==s&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return hV(e.document.selection.getFirstRange());const n=t.view.createRangeOn(i);return hV(t.mapper.toModelRange(n))}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find(t=>t.href===e);if(i)return{provider:t,item:i}}return null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(AV))t.updateMarker(AV,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(({item:t})=>!e.schema.isContent(t),{boundaries:i});t.addMarker(AV,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(AV,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(AV)&&e.change(e=>{e.removeMarker(AV)})}}function EV(e){return e.getAncestors().find(e=>iV(e))||null}const SV=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63}))|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class IV extends $n{static get requires(){return[M_,vV]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?ty(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,s=n.getFirstPosition(),o=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,s)||t);r&&(r=r.getJoined(this._expandLinkRange(i,o)||t)),r&&(r.start.isBefore(s)||r.end.isAfter(o))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");n.on("inputTransformation",(e,n)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const o=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(SV);a&&a[2]===r&&(t.change(e=>{this._selectEntireLinks(e,o),s.execute(r)}),e.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new D_(e.model,e=>{let t=e;if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(t))return;t=t.slice(0,-1),"!.:,;?".includes(t[t.length-1])&&(t=t.slice(0,-1));const i=PV(t);return i?{url:i,removedTrailingCharacters:e.length-t.length}:void 0});t.on("matched:data",(t,i)=>{const{batch:n,range:s,url:o,removedTrailingCharacters:r}=i;if(!n.isTyping)return;const a=s.end.getShiftedBy(-r),l=a.getShiftedBy(-o.length),c=e.model.createRange(l,a);this._applyAutoLink(o,c)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{const e=t.document.selection.getFirstPosition();let i;i=e.parent.previousSibling?.is("element")?t.createRangeIn(e.parent.previousSibling):t.createRange(t.createPositionAt(e.parent,0),e),this._checkAndApplyAutoLinkOnRange(i)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=N_(e,t),s=PV(i);if(s){const e=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=cV(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&uV(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{n.requestUndoOnBackspace()})})}}function PV(e){const t=SV.exec(e);return t?t[2]:null}class VV extends $n{static get requires(){return[vV,TV,IV]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}}class OV extends $n{static get requires(){return["ImageEditing","ImageUtils",vV]}static get pluginName(){return"LinkImageEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(function(e){const t=e.plugins.has("ImageInlineEditing"),i=e.plugins.get("ImageUtils");return e=>{e.on("element:a",(e,n,s)=>{const o=n.viewItem,r=i.findViewImgElement(o);if(!r)return;const a=r.findAncestor(e=>i.isBlockImageView(e));if(t&&!a)return;const l={attributes:["href"]};if(!s.consumable.consume(o,l))return;const c=o.getAttribute("href");if(!c)return;let u=n.modelCursor.parent;if(!u.is("element","imageBlock")){const e=s.convertItem(r,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,u=n.modelCursor.nodeBefore}u&&u.is("element","imageBlock")&&s.writer.setAttribute("linkHref",c,u)},{priority:"high"})}}(e)),e.conversion.for("downcast").add(function(e){const t=e.plugins.get("ImageUtils");return e=>{e.on("attribute:linkHref:imageBlock",(e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const s=n.mapper.toViewElement(i.item),o=n.writer,r=Array.from(s.getChildren()).find(e=>e.is("element","a")),a=t.findViewImgElement(s),l=a.parent.is("element","picture")?a.parent:a;if(r)i.attributeNewValue?o.setAttribute("href",i.attributeNewValue,r):(o.move(o.createRangeOn(l),o.createPositionAt(s,0)),o.remove(r));else{const e=o.createContainerElement("a",{href:i.attributeNewValue});o.insert(o.createPositionAt(s,0),e),o.move(o.createRangeOn(l),o.createPositionAt(e,0))}},{priority:"high"})}}(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,t=e.commands.get("link").automaticDecorators;t.length&&e.conversion.for("downcast").add(t.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(RV(i)),e.conversion.for("upcast").add(BV(e,i))}}function RV(e){return t=>{t.on(`attribute:${e.id}:imageBlock`,(t,i,n)=>{const s=n.mapper.toViewElement(i.item),o=Array.from(s.getChildren()).find(e=>e.is("element","a"));if(o){if(i.attributeOldValue){for(const t in e.attributes)n.writer.removeAttribute(t,o);e.classes&&n.writer.removeClass(e.classes,o);for(const t in e.styles)n.writer.removeStyle(t,o)}if(i.attributeNewValue){for(const[t,i]of Cn(e.attributes))n.writer.setAttribute(t,i,o);e.classes&&n.writer.addClass(e.classes,o);for(const t in e.styles)n.writer.setStyle(t,e.styles[t],o)}}})}}function BV(e,t){const i=e.plugins.has("ImageInlineEditing"),n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",(e,s,o)=>{const r=s.viewItem,a=n.findViewImgElement(r);if(!a)return;const l=a.findAncestor(e=>n.isBlockImageView(e));if(i&&!l)return;const c=new vs(t._createPattern()).match(r);if(!c)return;if(!o.consumable.consume(r,c.match))return;const u=s.modelCursor.nodeBefore||s.modelCursor.parent;o.writer.setAttribute(t.id,!0,u)},{priority:"high"})}}class LV extends $n{static get requires(){return[vV,TV,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(t,i)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(i.preventDefault(),t.stop())},{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",i=>{const n=new yp(i),s=e.plugins.get("LinkUI"),o=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:vg,keystroke:tV,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(o,"isEnabled"),n.bind("isOn").to(o,"value",e=>!!e),this.listenTo(n,"execute",()=>{this._isSelectedLinkedImage(e.model.document.selection)?s._addToolbarView():s._showUI(!0)}),n})}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}class MV extends $n{static get requires(){return[OV,LV]}static get pluginName(){return"LinkImage"}static get isOfficialPlugin(){return!0}}class FV{_startElement;_referenceIndent;_isForward;_includeSelf;_sameAttributes;_sameIndent;_lowerIndent;_higherIndent;constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=ln(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){return fn(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of new NV(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some(e=>t.getAttribute(e)!==this._startElement.getAttribute(e)))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}class NV{_node;_isForward;_previousNodesByIndent=[];_previous=null;_previousNodeIndent=null;constructor(e,t="forward"){this._node=e,this._isForward="forward"===t}[Symbol.iterator](){return this}next(){if(!HV(this._node))return{done:!0,value:void 0};const e=this._node.getAttribute("listIndent");let t=null;if(this._previous){const i=this._previousNodeIndent;e>i?this._previousNodesByIndent[i]=this._previous:ee.getAttribute("listIndent"))),o=new Map;for(const e of i)o.set(e,FV.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)eO(e,t);else{if(e.getAttribute("listIndent")==s){const i=aO(e,o.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return nO(n)}function eO(e,t){e=ln(e);for(const i of e)i.is("element","listItem")&&t.rename(i,"paragraph");for(const i of e)for(const e of i.getAttributeKeys())e.startsWith("list")&&t.removeAttribute(e,i);return e}function tO(e){if(!e.length)return!1;const t=e[0].getAttribute("listItemId");return!!t&&!e.some(e=>e.getAttribute("listItemId")!=t)}function iO(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:s}of new NV(e.nextSibling)){const e=s.getAttribute("listIndent");if(0==e)break;e"$graveyard"!==e.root.rootName).sort((e,t)=>e.index-t.index)}function sO(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function oO(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function rO(e){return"numbered"==e||"customNumbered"==e}function aO(e,t,i){return UV(t,{direction:"forward"}).pop().index>e.index?YV(e,t,i):[]}class lO extends Gn{_direction;constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=cO(e.document.selection);e.change(e=>{const i=[];tO(t)&&!jV(t[0])?("forward"==this._direction&&i.push(...ZV(t,e)),i.push(...QV(t[0],e))):"forward"==this._direction?i.push(...ZV(t,e,{expand:!0})):i.push(...XV(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=FV.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)})}_fireAfterExecute(e){this.fire("afterExecute",nO(new Set(e)))}_checkEnabled(){let e=cO(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(tO(e)&&!jV(e[0]))return!0;e=KV(e),t=e[0];const i=FV.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function cO(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex(e=>!HV(e));return-1!=i&&(t.length=i),t}class uO extends Gn{type;_listWalkerOptions;constructor(e,t,i={}){super(e),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=sO(t),s=Array.from(i.selection.getSelectedBlocks()).filter(e=>t.schema.checkAttribute(e,"listType")||oO(e,t.schema)),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change(r=>{if(o){const e=s[s.length-1],t=UV(e,{direction:"forward"}),i=[];t.length>1&&i.push(...QV(t[1],r)),i.push(...eO(s,r)),i.push(...iO(e,r)),this._fireAfterExecute(i)}else if((n||i.selection.isCollapsed)&&HV(s[0])){const t=$V(n||s[0],this._listWalkerOptions);for(const i of t)r.setAttributes({...e.additionalAttributes,listType:this.type},i);this._fireAfterExecute(t)}else{const i=[];for(const n of s)if(n.hasAttribute("listType"))for(const t of KV(n,{withNested:!1}))t.getAttribute("listType")!=this.type&&(r.setAttributes({...e.additionalAttributes,listType:this.type},t),i.push(t));else!n.is("element","listItem")&&oO(n,t.schema)&&r.rename(n,"listItem"),r.setAttributes({...e.additionalAttributes,listIndent:0,listItemId:zV.next(),listType:this.type},n),i.push(n);this._fireAfterExecute(i)}})}_fireAfterExecute(e){this.fire("afterExecute",nO(new Set(e)))}_getValue(){const e=this.editor.model.document.selection,t=Array.from(e.getSelectedBlocks());if(!t.length)return!1;for(const e of t)if(e.getAttribute("listType")!=this.type)return!1;return!0}_checkEnabled(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=Array.from(i.getSelectedBlocks());if(!n.length)return!1;if(this.value)return!0;for(const e of n)if(t.checkAttribute(e,"listType")||oO(e,t))return!0;return!1}}class dO extends Gn{_direction;constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute({shouldMergeOnBlocksContentLevel:e=!1}={}){const t=this.editor.model,i=t.document.selection,n=[];t.change(s=>{const{firstElement:o,lastElement:r}=this._getMergeSubjectElements(i,e),a=o.getAttribute("listIndent")||0,l=r.getAttribute("listIndent"),c=r.getAttribute("listItemId");if(a!=l){const e=WV(r);n.push(...ZV([r,...e],s,{indentBy:a-l,expand:a{const t=QV(this._getStartBlock(),e);this._fireAfterExecute(t)})}_fireAfterExecute(e){this.fire("afterExecute",nO(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&HV(t)&&!jV(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class mO extends $n{static get pluginName(){return"ListItemBoldIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[WO]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(WO);e.plugins.has("BoldEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("bold","listItemBold"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemBold",setAttributeOnDowncast(e,t,i,s){t&&(e.addClass("ck-list-marker-bold",i),!n.isSafari||s&&s.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-bold","0",i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("BoldEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemBold"}),t.schema.setAttributeProperties("listItemBold",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemBold"),e.conversion.for("upcast").attributeToAttribute({model:"listItemBold",view:{name:"li",classes:"ck-list-marker-bold"}}))}}class gO extends $n{static get pluginName(){return"ListItemItalicIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[WO]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(WO);e.plugins.has("ItalicEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("italic","listItemItalic"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemItalic",setAttributeOnDowncast(e,t,i,s){t&&(e.addClass("ck-list-marker-italic",i),!n.isSafari||s&&s.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-italic","0",i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("ItalicEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemItalic"}),t.schema.setAttributeProperties("listItemItalic",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemItalic"),e.conversion.for("upcast").attributeToAttribute({model:"listItemItalic",view:{name:"li",classes:"ck-list-marker-italic"}}))}}class fO extends $n{static get pluginName(){return"ListItemFontSizeIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[WO]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(WO);if(!e.plugins.has("FontSizeEditing")||!this.editor.config.get("list.enableListItemMarkerFormatting"))return;const s=WT(e.config.get("fontSize.options"));t.registerFormatAttribute("fontSize","listItemFontSize"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontSize",setAttributeOnDowncast(e,t,i,o){if(t){const r=s.find(e=>e.model==t);r&&r.view&&"string"!=typeof r.view?r.view.styles?(e.addClass("ck-list-marker-font-size",i),e.setStyle("--ck-content-list-marker-font-size",r.view.styles["font-size"],i)):r.view.classes&&(e.addClass(`ck-list-marker-font-size-${t}`,i),!n.isSafari||o&&o.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-font-size","0",i)):(e.addClass("ck-list-marker-font-size",i),e.setStyle("--ck-content-list-marker-font-size",t,i))}}})}afterInit(){const e=this.editor,t=e.model;if(!e.plugins.has("FontSizeEditing")||!this.editor.config.get("list.enableListItemMarkerFormatting"))return;t.schema.extend("$listItem",{allowAttributes:"listItemFontSize"}),t.schema.setAttributeProperties("listItemFontSize",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemFontSize"),e.conversion.for("upcast").elementToAttribute({model:{key:"listItemFontSize",value:e=>e.getStyle("--ck-content-list-marker-font-size")},view:{name:"li",classes:"ck-list-marker-font-size",styles:{"--ck-content-list-marker-font-size":/.*/}}});const i=WT(e.config.get("fontSize.options"));for(const t of i)t.model&&t.view&&e.conversion.for("upcast").elementToAttribute({model:{key:"listItemFontSize",value:t.model},view:{name:"li",classes:`ck-list-marker-font-size-${t.model}`}})}}class pO extends $n{static get pluginName(){return"ListItemFontColorIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[WO]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(WO);e.plugins.has("FontColorEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("fontColor","listItemFontColor"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontColor",setAttributeOnDowncast(e,t,i){t&&(e.addClass("ck-list-marker-color",i),e.setStyle("--ck-content-list-marker-color",t,i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("FontColorEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemFontColor"}),t.schema.setAttributeProperties("listItemFontColor",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemFontColor"),e.conversion.for("upcast").attributeToAttribute({model:{key:"listItemFontColor",value:e=>e.getStyle("--ck-content-list-marker-color")},view:{name:"li",classes:"ck-list-marker-color",styles:{"--ck-content-list-marker-color":/.*/}}}))}}class bO extends $n{static get pluginName(){return"ListItemFontFamilyIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[WO]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(WO);e.plugins.has("FontFamilyEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("fontFamily","listItemFontFamily"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontFamily",setAttributeOnDowncast(e,t,i){t&&(e.addClass("ck-list-marker-font-family",i),e.setStyle("--ck-content-list-marker-font-family",t,i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("FontFamilyEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemFontFamily"}),t.schema.setAttributeProperties("listItemFontFamily",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemFontFamily"),e.conversion.for("upcast").attributeToAttribute({model:{key:"listItemFontFamily",value:e=>e.getStyle("--ck-content-list-marker-font-family")},view:{name:"li",classes:"ck-list-marker-font-family",styles:{"--ck-content-list-marker-font-family":/.*/}}}))}}class wO extends $n{_loadedFormatting={};static get pluginName(){return"ListFormatting"}static get isOfficialPlugin(){return!0}static get requires(){return[mO,gO,fO,pO,bO]}constructor(e){super(e),e.config.define("list.enableListItemMarkerFormatting",!0)}afterInit(){this.editor.config.get("list.enableListItemMarkerFormatting")&&this._registerPostfixerForListItemFormatting()}_registerPostfixerForListItemFormatting(){const e=this.editor.model;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges(),n=new Set;let s=!1;for(const e of i)if("attribute"===e.type)("listItemId"==e.attributeKey||"listType"==e.attributeKey||this._isInlineOrSelectionFormatting(e.attributeKey)||Object.values(this._loadedFormatting).includes(e.attributeKey))&&(HV(e.range.start.nodeAfter)?n.add(e.range.start.nodeAfter):HV(e.range.start.parent)&&n.add(e.range.start.parent));else if(HV(e.position.nodeAfter)&&n.add(e.position.nodeAfter),HV(e.position.nodeBefore)&&n.add(e.position.nodeBefore),HV(e.position.parent)&&n.add(e.position.parent),"insert"==e.type&&"$text"!=e.name){const i=t.createRangeIn(e.position.nodeAfter);for(const e of i.getItems())HV(e)&&n.add(e)}for(const i of n){const n=vO(e,i,Object.keys(this._loadedFormatting));for(const[e,o]of Object.entries(n)){const n=this._loadedFormatting[e];(o&&yO(t,i,n,o)||!o&&kO(t,i,n))&&(s=!0)}}return s})}registerFormatAttribute(e,t){this._loadedFormatting[e]=t}_isInlineOrSelectionFormatting(e){return e.replace(/^selection:/,"")in this._loadedFormatting}}function vO(e,t,i){if(jV(t))return _O(e,t,i);return _O(e,qV(t)[0],i)}function _O(e,t,i){if(!function(e){return["numbered","bulleted","customNumbered","customBulleted"].includes(e.getAttribute("listType"))}(t)||e.schema.isLimit(t))return Object.fromEntries(i.map(e=>[e]));if(t.isEmpty)return Object.fromEntries(i.map(e=>[e,t.getAttribute(`selection:${e}`)]));const n=new Set(i),s={},o=e.createRangeIn(t).getWalker({ignoreElementEnd:!0});for(const{item:t}of o){for(const i of n)if(e.schema.checkAttribute(t,i)){const e=t.getAttribute(i);void 0===e?(n.delete(i),s[i]=void 0):void 0===s[i]?s[i]=e:s[i]!==e&&(n.delete(i),s[i]=void 0)}else i in s||(s[i]=void 0);if(!n.size)break;e.schema.isLimit(t)&&o.jumpTo(e.createPositionAfter(t))}return s}function yO(e,t,i,n){const s=qV(t);let o=!1;for(const t of s)t.hasAttribute(i)&&t.getAttribute(i)===n||(e.setAttribute(i,n,t),o=!0);return o}function kO(e,t,i){const n=qV(t);let s=!1;for(const t of n)t.hasAttribute(i)&&(e.removeAttribute(i,t),s=!0);return s}class CO extends $n{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(e){return JV(e)}isFirstBlockOfListItem(e){return jV(e)}isListItemBlock(e){return HV(e)}expandListBlocksToCompleteItems(e,t={}){return KV(e,t)}isNumberedListType(e){return rO(e)}}function xO(e){return e.is("element","ol")||e.is("element","ul")}function AO(e){return e.is("element","li")}function TO(e){let t=0,i=e.parent;for(;i;){if(AO(i))t++;else{const e=i.previousSibling;e&&AO(e)&&t++}i=i.parent}return t}function EO(e,t,i,n=PO(i,t)){return e.createAttributeElement(IO(i),null,{priority:2*t/100-100,id:n})}function SO(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function IO(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function PO(e,t){return`list-${e}-${t}`}function VO(e,t,i){const n=e.nodeBefore;if(HV(n)){let e=n;for(const{node:s}of new NV(e,"backward")){if(e=s,i.has(e))return;if(i.add(e),t.has(n))return}t.add(e)}else{const i=e.nodeAfter;HV(i)&&t.add(i)}}function OO(e,t){let i=0,n=-1,s=null,o=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===s?(s=e-i,a=i):(s>e&&(s=e),a=e-s),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),o=!0,n=a}else s=null,i=e+1,n=e}return o}function RO(e,t,i){const n=new Set;let s=!1;for(const{node:o}of e){if(n.has(o))continue;let e=o.getAttribute("listType"),r=o.getAttribute("listItemId");if(t.has(r)&&(r=zV.next()),t.add(r),o.is("element","listItem"))o.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,o),s=!0);else for(const t of UV(o,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=zV.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),s=!0)}return s}function BO(){return(e,t,i)=>{const{writer:n,schema:s}=i;if(!t.modelRange)return;const o=Array.from(t.modelRange.getItems({shallow:!0})).filter(e=>s.checkAttribute(e,"listItemId"));if(!o.length)return;const r=t.viewItem.getAttribute("data-list-item-id")||zV.next();i.consumable.consume(t.viewItem,{attributes:"data-list-item-id"});const a=TO(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=o[0].getAttribute("listType");c&&(l=c);const u={listItemId:r,listIndent:a,listType:l};for(const e of o)e.hasAttribute("listItemId")||n.setAttributes(u,e);o.length>1&&o[1].getAttribute("listItemId")!=u.listItemId&&i.keepEmptyElement(o[0])}}function LO(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Set,l=new Set,c=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)VO(e.position,a,c),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):VO(e.position.getShiftedBy(e.length),a,c);else if("remove"==e.type&&e.attributes.has("listItemId"))VO(e.position,a,c);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(VO(e.range.start,a,c),null===e.attributeNewValue?(VO(e.range.start.getShiftedBy(1),a,c),o(t)&&r.push(t)):l.add(t)):HV(t)&&o(t)&&r.push(t)}for(const e of a.values())r.push(...s(e,l));for(const e of new Set(r))t.reconvertItem(e)};function s(e,t){const n=[],s=new Set,a=[];for(const{node:l,previous:c}of new NV(e)){if(s.has(l))continue;const e=l.getAttribute("listIndent");c&&ei.includes(e))),modelElement:l};const u=UV(l,{direction:"forward"});for(const e of u)s.add(e),(o(e,u)||r(e,a,t))&&n.push(e)}return n}function o(e,s){const o=t.mapper.toViewElement(e);if(!o)return!1;if(function(e){e=e.parent;for(;e.is("attributeElement")&&["ol","ul","li"].includes(e.name);)e=e.parent;if(e.getCustomProperty("$structureSlotParent")&&!t.mapper.toModelElement(e))return!0;return!1}(o))return!0;if(n.fire("checkElement",{modelElement:e,viewElement:o}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=qO(e,i,s);return!(!r||!o.is("element","p"))||!(r||!o.is("element","span"))}function r(e,i,s){if(s.has(e))return!1;const o=t.mapper.toViewElement(e);let r=i.length-1;for(let e=o.parent;!e.is("editableElement");e=e.parent){const t=AO(e),s=xO(e);if(!s&&!t)continue;const o="checkAttributes:"+(t?"item":"list");if(n.fire(o,{viewElement:e,modelAttributes:i[r].modelAttributes,modelReferenceElement:i[r].modelElement}))break;if(s&&(r--,r<0))return!1}return!0}}function MO(e,t,i,{dataPipeline:n}={}){const s=function(e,t){const i=t.filter(e=>!1===e.consume).map(e=>e.attributeName);return(t,n)=>{const s=[];for(const n of e)t.hasAttribute(n)&&!i.includes(n)&&s.push(`attribute:${n}`);return!!s.every(e=>!1!==n.test(t,e))&&(s.forEach(e=>n.consume(t,e)),!0)}}(e,t);return(o,r,a)=>{const{writer:l,mapper:c,consumable:u}=a,d=r.item;if(!e.includes(r.attributeKey))return;if(!s(d,u))return;const h={...a.options,dataPipeline:n},m=DO(d,c,i,l);HO(m,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(m,l);const g=function(e,t,i,n,{dataPipeline:s}){let o=n.createRangeOn(t);if(!jV(e))return o;for(const r of i){if("itemMarker"!=r.scope)continue;const i=r.createElement(n,e,{dataPipeline:s});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(o.start,i),o=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!r.createWrapperElement||!r.canWrapElement)continue;const a=r.createWrapperElement(n,e,{dataPipeline:s});n.setCustomProperty("listItemWrapper",!0,a),r.canWrapElement(e)?o=n.wrap(o,a):(o=n.wrap(n.createRangeOn(i),a),o=n.createRange(o.start,n.createPositionAfter(t)))}return o}(d,m,t,l,h);!function(e,t,i,n,s){if(!e.hasAttribute("listIndent"))return;const o=e.getAttribute("listIndent");let r=e;for(let e=o;e>=0;e--){const o=SO(n,e,r.getAttribute("listItemId")),a=EO(n,e,r.getAttribute("listType"));for(const e of i)"list"!=e.scope&&"item"!=e.scope||!r.hasAttribute(e.attributeName)||e.setAttributeOnDowncast(n,r.getAttribute(e.attributeName),"list"==e.scope?a:o,s,r);if(t=n.wrap(t,o),t=n.wrap(t,a),0==e)break;if(r=FV.first(r,{lowerIndent:!0}),!r)break}}(d,g,t,l,h)}}function FO(e){return(t,i,n)=>{const{writer:s,mapper:o}=n,r=t.name.split(":")[1];if(!e.checkAttribute(r,"listItemId"))return;const a=o.toViewPosition(i.position),l=i.position.getShiftedBy(i.length),c=o.toViewPosition(l,{isPhantom:!0}),u=s.createRange(a,c).getTrimmed().end.nodeBefore;u&&HO(u,s,o)}}function NO(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!qO(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const s=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,s),s}}function DO(e,t,i,n){const s=i.createRangeOn(e),o=t.toViewRange(s).getTrimmed().getWalker();for(const{item:e}of o)if(e.is("element")&&e.getCustomProperty("listItemMarker"))o.jumpTo(n.createPositionAfter(e));else if(e.is("element")&&!e.getCustomProperty("listItemWrapper"))return e}function zO(e,t){return(i,n)=>{if(n.modelPosition.offset>0)return;const s=n.modelPosition.parent;if(!HV(s))return;if(!e.some(e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(s)))return;const o=n.mapper.toViewElement(s),r=t.createRangeIn(o),a=r.getWalker();let l=r.start;for(const{item:e}of a){if(e.is("element")&&n.mapper.toModelElement(e)||e.is("$textProxy"))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&(l=t.createPositionAfter(e),a.skip(({previousPosition:e})=>!e.isEqual(l)))}n.viewPosition=l}}function HO(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];s(t.createPositionBefore(e).getWalker({direction:"backward"})),s(t.createRangeIn(e).getWalker());for(const e of n)t.remove(e);function s(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function qO(e,t,i=qV(e)){if(!HV(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&"htmlEmptyBlock"!=i&&!t.includes(i))return!1;return i.length<2}const UO=["listType","listIndent","listItemId"];class WO extends $n{_downcastStrategies=[];static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Zy,M_,CO,cx,wO]}constructor(e){super(e),e.config.define("list.multiBlock",!0)}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new I("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:UO}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const e of UO)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new uO(e,"numbered")),e.commands.add("bulletedList",new uO(e,"bulleted")),e.commands.add("customNumberedList",new uO(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new uO(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new lO(e,"forward")),e.commands.add("outdentList",new lO(e,"backward")),e.commands.add("splitListItemBefore",new hO(e,"before")),e.commands.add("splitListItemAfter",new hO(e,"after")),i&&(e.commands.add("mergeListItemBackward",new dO(e,"backward")),e.commands.add("mergeListItemForward",new dO(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration(),this._setupListItemIdConversionStrategy()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...UO,...this._downcastStrategies.map(e=>e.attributeName)]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",(n,s)=>{const o=e.model.document.selection;sO(e.model)||e.model.change(()=>{const r=o.getFirstPosition();if(o.isCollapsed&&"backward"==s.direction){if(!r.isAtStart)return;const i=r.parent;if(!HV(i))return;if(FV.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:$O(e.model,"backward")})}else GV(i)||e.execute("splitListItemAfter"),e.execute("outdentList");s.preventDefault(),n.stop()}else{if(o.isCollapsed&&!o.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:$O(e.model,"forward")}),s.preventDefault(),n.stop()}})},{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",(i,n)=>{const s=t.document,o=s.selection.getFirstPosition().parent;if(s.selection.isCollapsed&&HV(o)&&o.isEmpty&&!n.isSoft){const t=jV(o),s=GV(o);t&&s?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!s?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):s&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}},{context:"li"}),this.listenTo(n,"afterExecute",()=>{const t=i.get("splitListItemBefore");if(t.refresh(),!t.isEnabled)return;2===qV(e.model.document.selection.getLastPosition().parent).length&&t.execute()})}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),s=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,{writer:t})=>t.createElement(s,{listType:""})}).elementToElement({view:"p",model:(e,{writer:t})=>e.parent&&e.parent.is("element","li")?t.createElement(s,{listType:""}):null,converterPriority:"high"}).add(e=>{e.on("element:li",BO())}),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:s,view:NO(i),converterPriority:"high"}).add(e=>{e.on("attribute",MO(i,this._downcastStrategies,t)),e.on("remove",FO(t.schema))}),e.conversion.for("dataDowncast").elementToElement({model:s,view:NO(i,{dataPipeline:!0}),converterPriority:"high"}).add(e=>{e.on("attribute",MO(i,this._downcastStrategies,t,{dataPipeline:!0}))});const o=zO(this._downcastStrategies,e.editing.view);e.editing.mapper.on("modelToViewPosition",o),e.data.mapper.on("modelToViewPosition",o),this.listenTo(t.document,"change:data",LO(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",(e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())}),this.on("checkAttributes:list",(e,{viewElement:t,modelAttributes:i})=>{t.name==IO(i.listType)&&t.id==PO(i.listType,i.listIndent)||(e.return=!0,e.stop())})}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer(i=>function(e,t,i,n){const s=e.document.differ.getChanges(),o=new Set,r=new Set,a=n.editor.config.get("list.multiBlock");let l=!1;for(const n of s){if("insert"==n.type&&"$text"!=n.name){const s=n.position.nodeAfter;if(!e.schema.checkAttribute(s,"listItemId"))for(const e of Array.from(s.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,s),l=!0);VO(n.position,r,o),n.attributes.has("listItemId")||VO(n.position.getShiftedBy(n.length),r,o);for(const{item:t,previousPosition:i}of e.createRangeIn(s))HV(t)&&VO(i,r,o)}else"remove"==n.type?VO(n.position,r,o):"attribute"==n.type&&i.includes(n.attributeKey)&&(VO(n.range.start,r,o),null===n.attributeNewValue&&VO(n.range.start.getShiftedBy(1),r,o));if(!a&&"attribute"==n.type&&UO.includes(n.attributeKey)){const e=n.range.start.nodeAfter;null===n.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),l=!0):null===n.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),l=!0)}}const c=new Set;for(const e of r.values())l=n.fire("postFixer",{listNodes:new DV(e),listHead:e,writer:t,seenIds:c})||l;return l}(e,i,t,this)),this.on("postFixer",(e,{listNodes:t,writer:i})=>{e.return=OO(t,i)||e.return},{priority:"high"}),this.on("postFixer",(e,{listNodes:t,writer:i,seenIds:n})=>{e.return=RO(t,n,i)||e.return},{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const s=i.is("documentFragment")?Array.from(i.getChildren()):[i];if(!s.length)return;const o=(n?e.createSelection(n):e.document.selection).getFirstPosition();let r;if(HV(o.parent))r=o.parent;else{if(!HV(o.nodeBefore)||!HV(o.nodeAfter))return;r=o.nodeBefore}e.change(e=>{const t=r.getAttribute("listType"),i=r.getAttribute("listIndent"),n=s[0].getAttribute("listIndent")||0,o=Math.max(i-n,0);for(const i of s){const n=HV(i);r.is("element","listItem")&&i.is("element","paragraph")&&e.rename(i,"listItem"),e.setAttributes({listIndent:(n?i.getAttribute("listIndent"):0)+o,listItemId:n?i.getAttribute("listItemId"):zV.next(),listType:t},i)}})}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",(t,i)=>{e.change(e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty){t.slice(0,-1).every(HV)&&e.remove(n)}if("copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());tO(t)&&eO(t,e)}})})}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}_setupListItemIdConversionStrategy(){this.registerDowncastStrategy({scope:"item",attributeName:"listItemId",setAttributeOnDowncast(e,t,i,n){n&&(n.skipListItemIds||n.isClipboardPipeline)||e.setAttribute("data-list-item-id",t,i)}})}}function $O(e,t){const i=e.document.selection;if(!i.isCollapsed)return!sO(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,s=n.previousSibling;return!e.schema.isObject(s)&&(!!s.isEmpty||tO([n,s]))}function jO(e,t,i,n){e.ui.componentFactory.add(t,()=>{const s=GO(yp,e,t,i,n);return s.set({tooltip:!0,isToggleable:!0}),s}),e.ui.componentFactory.add(`menuBar:${t}`,()=>{const s=GO(Mp,e,t,i,n);return s.set({role:"menuitemcheckbox",isToggleable:!0}),s})}function GO(e,t,i,n,s){const o=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:s}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",()=>{t.execute(i),t.editing.view.focus()}),r}class KO extends $n{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||jO(this.editor,"numberedList",e("Numbered List"),Hg),this.editor.ui.componentFactory.has("bulletedList")||jO(this.editor,"bulletedList",e("Bulleted List"),nm)}}class JO extends $n{static get requires(){return[WO,KO]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}}class QO extends Gn{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter(e=>HV(e)&&rO(e.getAttribute("listType")));n=JV(n),t.change(t=>{for(const i of n)t.setAttribute("listStart",e>=0?e:1,i)})}_getValue(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());return e&&HV(e)&&rO(e.getAttribute("listType"))?e.getAttribute("listStart"):null}}const YO={},ZO={},XO={},eR=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of eR)YO[e]=i,ZO[e]=t,t&&(XO[t]=e);function tR(){return eR.map(e=>e.listStyle)}function iR(e){return YO[e]||null}function nR(e){return XO[e]||null}function sR(e){return ZO[e]||null}function oR(e){switch(e){case"lower-alpha":return"lower-latin";case"upper-alpha":return"upper-latin";default:return e}}class rR extends Gn{defaultType;_supportedTypes;constructor(e,t,i){super(e),this.defaultType=t,this._supportedTypes=i}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change(t=>{this._tryToConvertItemsToList(e);let n=Array.from(i.selection.getSelectedBlocks()).filter(e=>e.hasAttribute("listType"));if(n.length){n=JV(n);for(const i of n)t.setAttribute("listStyle",e.type||this.defaultType,i)}})}isStyleTypeSupported(e){return!this._supportedTypes||this._supportedTypes.includes(e)}_getValue(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());return HV(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=iR(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class aR extends Gn{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter(e=>HV(e)&&"numbered"==e.getAttribute("listType"));n=JV(n),t.change(t=>{for(const i of n)t.setAttribute("listReversed",!!e.reversed,i)})}_getValue(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());return HV(e)&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}function lR(e){return(t,i,n)=>{const{writer:s,schema:o,consumable:r}=n;if(!1===r.test(i.viewItem,e.viewConsumables))return;i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor));let a=!1;for(const t of i.modelRange.getItems({shallow:!0}))o.checkAttribute(t,e.attributeName)&&e.appliesToListItem(t)&&(t.hasAttribute(e.attributeName)||(s.setAttribute(e.attributeName,e.getAttributeOnUpcast(i.viewItem),t),a=!0));a&&r.consume(i.viewItem,e.viewConsumables)}}class cR extends $n{static get pluginName(){return"ListPropertiesUtils"}static get isOfficialPlugin(){return!0}getAllSupportedStyleTypes(){return tR()}getListTypeFromListStyleType(e){return iR(e)}getListStyleTypeFromTypeAttribute(e){return nR(e)}getTypeAttributeFromListStyleType(e){return sR(e)}}function uR(e){const{startIndex:t,reversed:i,styles:n}=e;return{styles:dR(n),startIndex:t||!1,reversed:i||!1}}function dR(e){const t={listTypes:["bulleted","numbered"],useAttribute:!1};return!0===e||(e?Array.isArray(e)||"string"==typeof e?t.listTypes=ln(e):(t.listTypes=e.listTypes?ln(e.listTypes):t.listTypes,t.useAttribute=!!e.useAttribute,e.listStyleTypes&&(t.listStyleTypes=e.listStyleTypes)):t.listTypes=[]),t}const hR="default";class mR extends $n{static get requires(){return[WO,cR]}static get pluginName(){return"ListPropertiesEditing"}static get licenseFeatureCode(){return"LP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}init(){const e=this.editor,t=e.model,i=e.plugins.get(WO),n=function(e){const t=[],i=uR(e);if(e.styles){const e=i.styles.useAttribute;t.push({attributeName:"listStyle",defaultValue:hR,viewConsumables:{styles:"list-style-type"},addCommand(t){let i=tR();e&&(i=i.filter(e=>!!sR(e))),t.commands.add("listStyle",new rR(t,hR,i))},appliesToListItem:e=>"numbered"==e.getAttribute("listType")||"bulleted"==e.getAttribute("listType"),hasValidAttribute(e){if(!this.appliesToListItem(e))return!e.hasAttribute("listStyle");if(!e.hasAttribute("listStyle"))return!1;const t=e.getAttribute("listStyle");return t==hR||iR(t)==e.getAttribute("listType")},setAttributeOnDowncast(t,i,n){if(i&&i!==hR){if(!e)return void t.setStyle("list-style-type",i,n);{const e=sR(i);if(e)return void t.setAttribute("type",e,n)}}t.removeStyle("list-style-type",n),t.removeAttribute("type",n)},getAttributeOnUpcast(e){const t=e.getStyle("list-style-type");if(t)return oR(t);const i=e.getAttribute("type");return i?nR(i):hR}})}e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(e){e.commands.add("listReversed",new aR(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listReversed")},setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")});e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(e){e.commands.add("listStart",new QO(e))},appliesToListItem:e=>rO(e.getAttribute("listType")),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listStart")},setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}});return t}(e.config.get("list.properties"));for(const s of n)s.addCommand(e),t.schema.extend("$listItem",{allowAttributes:s.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:s.attributeName,setAttributeOnDowncast(e,t,i){s.setAttributeOnDowncast(e,t,i)}});e.conversion.for("upcast").add(e=>{for(const t of n)e.on("element:ol",lR(t)),e.on("element:ul",lR(t))}),i.on("checkAttributes:list",(e,{viewElement:t,modelAttributes:i,modelReferenceElement:s})=>{for(const o of n)o.appliesToListItem(s)&&o.getAttributeOnUpcast(t)!=i[o.attributeName]&&(e.return=!0,e.stop())}),this.listenTo(e.commands.get("indentList"),"afterExecute",(e,i)=>{t.change(e=>{for(const t of i)for(const i of n)i.appliesToListItem(t)&&e.setAttribute(i.attributeName,i.defaultValue,t)})}),i.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:s}of t)for(const t of n)t.hasValidAttribute(s)||(t.appliesToListItem(s)?i.setAttribute(t.attributeName,t.defaultValue,s):i.removeAttribute(t.attributeName,s),e.return=!0)}),i.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:s,previousNodeInList:o}of t)if(o&&o.getAttribute("listType")==s.getAttribute("listType"))for(const t of n){const{attributeName:n}=t;if(!t.appliesToListItem(s))continue;const r=o.getAttribute(n);s.getAttribute(n)!=r&&(i.setAttribute(n,r,s),e.return=!0)}})}}class gR extends hh{children;stylesView=null;additionalPropertiesCollapsibleView=null;startIndexFieldView=null;reversedSwitchButtonView=null;focusTracker=new bn;keystrokes=new yn;focusables=new qd;focusCycler;constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:n}){super(e);const s=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new xp({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),i&&i.length?(this.stylesView=this._createStylesView(i,n),this.children.add(this.stylesView)):s.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),s.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:s},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);yh({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>e.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new hh(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){for(const e of this.children)if(e instanceof yp&&e.isOn)return void e.focus();this.children.first.focus()},i.focusTracker=new bn,i.keystrokes=new yn,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),this.stylesView?(this.additionalPropertiesCollapsibleView=new Zp(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",(...e)=>e.some(e=>e)),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",(e,t,i)=>{i||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)}),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new Ab(this.locale,pw);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",()=>{const i=t.fieldView.element,n=i.valueAsNumber;Number.isNaN(n)?t.errorText=e("Invalid start index value."):i.checkValidity()?this.fire("listStart",{startIndex:n}):t.errorText=e("Start index must be greater than 0.")}),t}_createReversedSwitchButton(){const e=this.locale.t,t=new Gp(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class fR extends $n{static get pluginName(){return"ListPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties"),n=uR(i),s=n.styles.listTypes;if(s.includes("bulleted")){const i=[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:Cg},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:_g},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:Tg}],s=t("Bulleted List"),o=t("Bulleted list styles toolbar"),r="bulletedList";e.ui.componentFactory.add(r,pR({editor:e,normalizedConfig:n,parentCommandName:r,buttonLabel:s,buttonIcon:nm,styleGridAriaLabel:o,styleDefinitions:i})),e.ui.componentFactory.add(`menuBar:${r}`,wR({editor:e,normalizedConfig:n,parentCommandName:r,buttonLabel:s,styleGridAriaLabel:o,styleDefinitions:i}))}if(s.includes("numbered")||i.startIndex||i.reversed){const i=[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:kg},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:yg},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:Ag},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:Sg},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:xg},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:Eg}],o=t("Numbered List"),r=t("Numbered list styles toolbar"),a="numberedList";e.ui.componentFactory.add(a,pR({editor:e,normalizedConfig:n,parentCommandName:a,buttonLabel:o,buttonIcon:Hg,styleGridAriaLabel:r,styleDefinitions:i})),s.includes("numbered")&&e.ui.componentFactory.add(`menuBar:${a}`,wR({editor:e,normalizedConfig:n,parentCommandName:a,buttonLabel:o,styleGridAriaLabel:r,styleDefinitions:i}))}}}function pR({editor:e,normalizedConfig:t,parentCommandName:i,buttonLabel:n,buttonIcon:s,styleGridAriaLabel:o,styleDefinitions:r}){const a=e.commands.get(i);return l=>{const c=ow(l,sw),u=c.buttonView;return c.bind("isEnabled").to(a),c.class="ck-list-styles-dropdown",u.on("execute",()=>{e.execute(i),e.editing.view.focus()}),u.set({label:n,icon:s,tooltip:!0,isToggleable:!0}),u.bind("isOn").to(a,"value",e=>!!e),c.once("change:isOpen",()=>{const n=function({editor:e,normalizedConfig:t,dropdownView:i,parentCommandName:n,styleDefinitions:s,styleGridAriaLabel:o}){const r=e.locale,a={...t,..."numberedList"!=n?{startIndex:!1,reversed:!1}:null},l=n.replace("List","");let c=null;if(t.styles.listTypes.includes(l)){const i=e.commands.get("listStyle"),o=bR({editor:e,parentCommandName:n,listStyleCommand:i}),r=t.styles.listStyleTypes;let a=s;if(r){const e=r[l];e&&(a=s.filter(t=>e.includes(t.type)))}const u=vR(i);c=a.filter(u).map(o)}const u=new gR(r,{styleGridAriaLabel:o,enabledProperties:a,styleButtonViews:c});t.styles.listTypes.includes(l)&&hw(i,()=>u.stylesView.children.find(e=>e.isOn));if(a.startIndex){const t=e.commands.get("listStart");u.startIndexFieldView.bind("isEnabled").to(t),u.startIndexFieldView.fieldView.bind("value").to(t),u.on("listStart",(t,i)=>e.execute("listStart",i))}if(a.reversed){const t=e.commands.get("listReversed");u.reversedSwitchButtonView.bind("isEnabled").to(t),u.reversedSwitchButtonView.bind("isOn").to(t,"value",e=>!!e),u.on("listReversed",()=>{const i=t.value;e.execute("listReversed",{reversed:!i})})}return u.delegate("execute").to(i),u}({editor:e,normalizedConfig:t,dropdownView:c,parentCommandName:i,styleGridAriaLabel:o,styleDefinitions:r});c.panelView.children.add(n)}),c.on("execute",()=>{e.editing.view.focus()}),c}}function bR({editor:e,listStyleCommand:t,parentCommandName:i}){const n=e.locale,s=e.commands.get(i);return({label:o,type:r,icon:a,tooltip:l})=>{const c=new yp(n);return c.set({label:o,icon:a,tooltip:l}),c.bind("isOn").to(t,"value",e=>e===r),c.on("execute",()=>{s.value?t.value===r?e.execute(i):t.value!==r&&e.execute("listStyle",{type:r}):e.model.change(()=>{e.execute("listStyle",{type:r})})}),c}}function wR({editor:e,normalizedConfig:t,parentCommandName:i,buttonLabel:n,styleGridAriaLabel:s,styleDefinitions:o}){return r=>{const a=new d_(r),l=e.commands.get(i),c=e.commands.get("listStyle"),u=vR(c),d=bR({editor:e,parentCommandName:i,listStyleCommand:c}),h=t.styles.listStyleTypes;let m=o;if(h){const e=h[l.type];e&&(m=o.filter(t=>e.includes(t.type)))}const g=m.filter(u).map(d),f=new gR(r,{styleGridAriaLabel:s,enabledProperties:{...t,startIndex:!1,reversed:!1},styleButtonViews:g});return f.delegate("execute").to(a),a.buttonView.set({label:n,icon:"bulletedList"===i?nm:Hg}),a.panelView.children.add(f),a.bind("isEnabled").to(l,"isEnabled"),a.on("execute",()=>{e.editing.view.focus()}),a}}function vR(e){return"function"==typeof e.isStyleTypeSupported?t=>e.isStyleTypeSupported(t.type):()=>!0}class _R extends $n{static get requires(){return[mR,fR]}static get pluginName(){return"ListProperties"}static get isOfficialPlugin(){return!0}}class yR extends Gn{constructor(e){super(e),this.on("execute",()=>{this.refresh()},{priority:"highest"})}refresh(){const e=this._getSelectedItems();this.value=this._getValue(e),this.isEnabled=!!e.length}execute(e={}){this.editor.model.change(t=>{const i=this._getSelectedItems(),n=void 0===e.forceValue?!this._getValue(i):e.forceValue;for(const e of i)n?t.setAttribute("todoListChecked",!0,e):t.removeAttribute("todoListChecked",e)})}_getValue(e){return e.every(e=>e.getAttribute("todoListChecked"))}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,s=[];t.checkAttribute(n,"todoListChecked")&&s.push(...qV(n));for(const e of i.getItems({shallow:!0}))t.checkAttribute(e,"todoListChecked")&&!s.includes(e)&&s.push(...qV(e));return s}}class kR extends Yo{domEventType=["change"];onDomEvent(e){if(e.target){const t=this.view.domConverter.mapDomToView(e.target);t&&t.is("element","input")&&"checkbox"==t.getAttribute("type")&&t.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",e)}}}const CR=Xi("Ctrl+Enter");class xR extends $n{static get pluginName(){return"TodoListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[WO]}init(){const e=this.editor,t=e.model,i=e.editing,n=e.plugins.get(WO),s=e.config.get("list.multiBlock")?"paragraph":"listItem";e.commands.add("todoList",new uO(e,"todo")),e.commands.add("checkTodoList",new yR(e)),i.view.addObserver(kR),t.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),t.schema.addAttributeCheck(e=>{const t=e.last;if(!t.getAttribute("listItemId")||"todo"!=t.getAttribute("listType"))return!1},"todoListChecked"),e.conversion.for("upcast").add(e=>{e.on("element:input",(e,t,i)=>{const n=t.modelCursor,s=n.parent,o=t.viewItem;if(!i.consumable.test(o,{name:!0}))return;if("checkbox"!=o.getAttribute("type")||!n.isAtStart||!s.hasAttribute("listType"))return;i.consumable.consume(o,{name:!0});const r=i.writer;r.setAttribute("listType","todo",s),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,s),t.modelRange=r.createRange(n)}),e.on("element:li",(e,t,i)=>{const{writer:n,schema:s}=i;if(!t.modelRange)return;const o=Array.from(t.modelRange.getItems({shallow:!0})).filter(e=>"todo"===e.getAttribute("listType")&&s.checkAttribute(e,"listItemId")).reduce((e,t)=>{const i=t.getAttribute("listItemId");return e.has(i)||e.set(i,qV(t)),e},new Map);for(const[,e]of o.entries())if(e.some(e=>e.getAttribute("todoListChecked")))for(const t of e)n.setAttribute("todoListChecked",!0,t)},{priority:"low"}),e.on("element:label",AR({name:"label",classes:"todo-list__label"})),e.on("element:label",AR({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),e.on("element:span",AR({name:"span",classes:"todo-list__label__description"})),e.on("element:ul",function(e){const t=new vs(e);return(e,i,n)=>{const s=t.match(i.viewItem);if(!s)return;const o=s.match;o.name=!1,n.consumable.consume(i.viewItem,o)}}({name:"ul",classes:"todo-list"}))}),e.conversion.for("downcast").elementToElement({model:s,view:(e,{writer:t})=>{if(TR(e,n.getListAttributeNames()))return t.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),n.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(e,t,i){"todo"==t?e.addClass("todo-list",i):e.removeClass("todo-list",i)}}),n.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(e,t,{dataPipeline:i}){if("todo"!=t.getAttribute("listType"))return null;const n=e.createUIElement("input",{type:"checkbox",...t.getAttribute("todoListChecked")?{checked:"checked"}:null,...i?{disabled:"disabled"}:{tabindex:"-1"}});if(i)return n;const s=e.createContainerElement("span",{contenteditable:"false"},n);return s.getFillerOffset=()=>null,s},canWrapElement:e=>TR(e,n.getListAttributeNames()),createWrapperElement(e,t,{dataPipeline:i}){const s=["todo-list__label"];return TR(t,n.getListAttributeNames())||s.push("todo-list__label_without-description"),e.createAttributeElement(i?"label":"span",{class:s.join(" ")})}}),n.on("checkElement",(e,{modelElement:t,viewElement:i})=>{const s=TR(t,n.getListAttributeNames());i.hasClass("todo-list__label__description")!=s&&(e.return=!0,e.stop())}),n.on("checkElement",(t,{modelElement:i,viewElement:n})=>{const s="todo"==i.getAttribute("listType")&&jV(i);let o=!1;const r=e.editing.view.createPositionBefore(n).getWalker({direction:"backward"});for(const{item:t}of r){if(t.is("element")&&e.editing.mapper.toModelElement(t))break;t.is("element","input")&&"checkbox"==t.getAttribute("type")&&(o=!0)}o!=s&&(t.return=!0,t.stop())}),n.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:s}of t){if(!s)continue;if(s.getAttribute("listItemId")!=n.getAttribute("listItemId"))continue;const t=s.hasAttribute("todoListChecked"),o=n.hasAttribute("todoListChecked");o&&!t?(i.removeAttribute("todoListChecked",n),e.return=!0):!o&&t&&(i.setAttribute("todoListChecked",!0,n),e.return=!0)}}),t.document.registerPostFixer(e=>{const i=t.document.differ.getChanges();let n=!1;for(const t of i)if("attribute"==t.type&&"listType"==t.attributeKey){const i=t.range.start.nodeAfter;"todo"==t.attributeOldValue&&i.hasAttribute("todoListChecked")&&(e.removeAttribute("todoListChecked",i),n=!0)}else if("insert"==t.type&&"$text"!=t.name)for(const{item:i}of e.createRangeOn(t.position.nodeAfter))i.is("element")&&"todo"!=i.getAttribute("listType")&&i.hasAttribute("todoListChecked")&&(e.removeAttribute("todoListChecked",i),n=!0);return n}),this.listenTo(i.view.document,"keydown",(t,i)=>{Zi(i)===CR&&(e.execute("checkTodoList"),t.stop())},{priority:"high"}),this.listenTo(i.view.document,"todoCheckboxChange",(e,t)=>{const n=t.target;if(!n||!n.is("element","input"))return;const s=i.view.createPositionAfter(n),o=i.mapper.toModelPosition(s).parent;o&&HV(o)&&"todo"==o.getAttribute("listType")&&this._handleCheckmarkChange(o)}),this.listenTo(i.view.document,"arrowKey",function(e,t){return(i,n)=>{const s=nn(n.keyCode,t.contentLanguageDirection),o=e.schema,r=e.document.selection;if(!r.isCollapsed)return;const a=r.getFirstPosition(),l=a.parent;if("right"==s&&a.isAtEnd){const t=o.getNearestSelectionRange(e.createPositionAfter(l),"forward");if(!t)return;const s=t.start.parent;s&&HV(s)&&"todo"==s.getAttribute("listType")&&(e.change(e=>e.setSelection(t)),n.preventDefault(),n.stopPropagation(),i.stop())}else if("left"==s&&a.isAtStart&&HV(l)&&"todo"==l.getAttribute("listType")){const t=o.getNearestSelectionRange(e.createPositionBefore(l),"backward");if(!t)return;e.change(e=>e.setSelection(t)),n.preventDefault(),n.stopPropagation(),i.stop()}}}(t,e.locale),{context:"$text"}),this.listenTo(i.mapper,"viewToModelPosition",(e,i)=>{const n=i.viewPosition.parent,s=n.is("attributeElement","li")&&0==i.viewPosition.offset,o=ER(n)&&i.viewPosition.offset<=1,r=n.is("element","span")&&"false"==n.getAttribute("contenteditable")&&ER(n.parent);if(!s&&!o&&!r)return;const a=i.modelPosition.nodeAfter;a&&"todo"==a.getAttribute("listType")&&(i.modelPosition=t.createPositionAt(a,0))},{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change(i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)})}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let n=null;t&&e.document.selection.on("change:range",()=>{const s=e.document.selection.focus.parent,o=SR(n),r=SR(s);o&&!r?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!o&&r&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),n=s})}}function AR(e){const t=new vs(e);return(e,i,n)=>{const s=t.match(i.viewItem);s&&n.consumable.consume(i.viewItem,s.match)&&Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor))}}function TR(e,t){return(e.is("element","paragraph")||e.is("element","listItem"))&&"todo"==e.getAttribute("listType")&&jV(e)&&function(e,t){for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return!0}(e,t)}function ER(e){return!!e&&e.is("attributeElement")&&e.hasClass("todo-list__label")}function SR(e){return!!e&&(!(!e.is("element","paragraph")&&!e.is("element","listItem"))&&"todo"==e.getAttribute("listType"))}class IR extends $n{static get pluginName(){return"TodoListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;jO(this.editor,"todoList",e("To-do List"),op)}}class PR extends $n{static get requires(){return[xR,IR]}static get pluginName(){return"TodoList"}static get isOfficialPlugin(){return!0}}class VR extends Gn{type;constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=Array.from(i.selection.getSelectedBlocks()).filter(e=>RR(e,t.schema)),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change(e=>{if(s){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,s=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)o>s.getAttribute("listIndent")&&(o=s.getAttribute("listIndent")),s.getAttribute("listIndent")==o&&e[t?"unshift":"push"](s),s=s[t?"previousSibling":"nextSibling"]}}function RR(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class BR extends Gn{_indentBy;constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change(e=>{const t=i[i.length-1];let n=t.nextSibling;for(;n&&"listItem"==n.name&&n.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(n),n=n.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)})}_checkEnabled(){const e=fn(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let n=e.previousSibling;for(;n&&n.is("element","listItem")&&n.getAttribute("listIndent")>=t;){if(n.getAttribute("listIndent")==t)return n.getAttribute("listType")==i;n=n.previousSibling}return!1}return!0}}function LR(e,t){const i=t.mapper,n=t.writer,s="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=jR,t}(n),r=n.createContainerElement(s,null);return n.insert(n.createPositionAt(r,0),o),i.bindElements(e,o),o}function MR(e,t,i,n){const s=t.parent,o=i.mapper,r=i.writer;let a=o.toViewPosition(n.createPositionBefore(e));const l=DR(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(l);a=r.breakContainer(r.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=o.toViewPosition(n.createPositionAt(c,"end"));const e=o.findMappedViewAncestor(a),t=zR(e);a=t?r.createPositionBefore(t):r.createPositionAt(e,"end")}else a=o.toViewPosition(n.createPositionBefore(e));if(a=NR(a),r.insert(a,s),c&&"listItem"==c.name){const e=o.toViewElement(c),i=r.createRange(r.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=r.breakContainer(r.createPositionBefore(e.item)),s=e.item.parent,o=r.createPositionAt(t,"end");FR(r,o.nodeBefore,o.nodeAfter),r.move(r.createRangeOn(s),o),i._position=n}}else{const i=s.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=o.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(t,"end")))}}FR(r,s,s.nextSibling),FR(r,s.previousSibling,s)}function FR(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function NR(e){return e.getLastMatchingPosition(e=>e.item.is("uiElement"))}function DR(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,s=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(i&&s==e||n&&s>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function zR(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}function HR(e,t){const i=[],n=e.parent,s={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},o=n.getAttribute("listIndent"),r=[...new mr(s)].filter(e=>e.item.is("element")).map(e=>e.item);for(const e of r){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")o)){if(e.getAttribute("listType")!==n.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==n.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==n.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==n.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}function qR(e){let t=[...e.document.selection.getSelectedBlocks()].filter(e=>e.is("element","listItem")).map(t=>{const i=e.change(e=>e.createPositionAt(t,0));return[...HR(i,"backward"),...HR(i,"forward")]}).flat();return t=[...new Set(t)],t}const UR=["disc","circle","square"],WR=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function $R(e){return UR.includes(e)?"bulleted":WR.includes(e)?"numbered":null}function jR(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Os.call(this)}class GR extends $n{static get pluginName(){return"LegacyListUtils"}static get isOfficialPlugin(){return!0}getListTypeFromListStyleType(e){return $R(e)}getSelectedListItems(e){return qR(e)}getSiblingNodes(e,t){return HR(e,t)}}function KR(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;s.consume(i.item,"insert"),s.consume(i.item,"attribute:listType"),s.consume(i.item,"attribute:listIndent");const o=i.item;MR(o,LR(o,n),n,e)}}const JR=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),s=i.writer;s.breakContainer(s.createPositionBefore(n)),s.breakContainer(s.createPositionAfter(n));const o=n.parent,r="numbered"==t.attributeNewValue?"ol":"ul";s.rename(r,o)},QR=(e,t,i)=>{i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,s=i.writer;FR(s,n,n.nextSibling),FR(s,n.previousSibling,n)};const YR=(e,t,i)=>{if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const n=i.writer,s=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=n.breakContainer(e),"li"==e.parent.name);){const t=e,i=n.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=n.remove(n.createRange(t,i));s.push(e)}e=n.createPositionAfter(e.parent)}if(s.length>0){for(let t=0;t0){const t=FR(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}FR(n,e.nodeBefore,e.nodeAfter)}}},ZR=(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),s=n.nodeBefore,o=n.nodeAfter;FR(i.writer,s,o)},XR=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),s=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",s,n);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,n),!i.safeInsert(n,t.modelCursor))return;const r=function(e,t,i){const{writer:n,schema:s}=i;let o=n.createPositionAfter(e);for(const r of t)if("ul"==r.name||"ol"==r.name)o=i.convertItem(r,o).modelCursor;else{const t=i.convertItem(r,n.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!s.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:sB(t.modelCursor),o=n.createPositionAfter(e))}return o}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,r),i.updateConversionResult(n,t)}},eB=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||rB(t))&&t._remove()}}},tB=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1;for(const t of e)i&&!rB(t)&&t._remove(),rB(t)&&(i=!0)}};function iB(e){return(t,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const t=i.mapper.toViewElement(n),s=t.getAncestors().find(rB),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==s){i.viewPosition=e.nextPosition;break}}}}}const nB=function(e,[t,i]){const n=this;let s,o=t.is("documentFragment")?t.getChild(0):t;if(s=i?n.createSelection(i):n.document.selection,o&&o.is("element","listItem")){const e=s.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}};function sB(e){const t=new mr({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function oB(e,t,i,n,s,o){const r=DR(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=s.mapper,l=s.writer,c=r?r.getAttribute("listIndent"):null;let u;if(r)if(c==e){const e=a.toViewElement(r).parent;u=l.createPositionAfter(e)}else{const e=o.createPositionAt(r,"end");u=a.toViewPosition(e)}else u=i;u=NR(u);for(const e of[...n.getChildren()])rB(e)&&(u=l.move(l.createRangeOn(e),u).end,FR(l,e,e.nextSibling),FR(l,e.previousSibling,e))}function rB(e){return e.is("element","ol")||e.is("element","ul")}class aB extends $n{static get pluginName(){return"LegacyListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Zy,M_,GR]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var n;e.model.document.registerPostFixer(t=>function(e,t){const i=e.document.differ.getChanges(),n=new Map;let s=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)o(n.position);else if("insert"==n.type&&"listItem"!=n.name){if("$text"!=n.name){const i=n.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),s=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),s=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),s=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),s=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),s=!0);for(const t of Array.from(e.createRangeIn(i)).filter(e=>e.item.is("element","listItem")))o(t.previousPosition)}o(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?o(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&o(n.range.start);for(const e of n.values())r(e),a(e);return s;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(n.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,n.has(e))return;n.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&n.set(t,t)}}function r(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>i){let r;null===n?(n=o-i,r=i):(n>o&&(n=o),r=o-n),t.setAttribute("listIndent",r,e),s=!0}else n=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],n=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const n=i[o];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),s=!0)}else i[o]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t)),i.mapper.registerViewToModelLength("li",lB),t.mapper.registerViewToModelLength("li",lB),i.mapper.on("modelToViewPosition",iB(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,s=i.parent,o=t.mapper;if("ul"==s.name||"ol"==s.name){if(i.isAtEnd){const e=o.toModelElement(i.nodeBefore),s=o.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(s)}else{const e=o.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==s.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=o.toModelElement(s);let a=1,l=i.nodeBefore;for(;l&&rB(l);)a+=o.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(r).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",iB(i.view)),e.conversion.for("editingDowncast").add(t=>{t.on("insert",YR,{priority:"high"}),t.on("insert:listItem",KR(e.model)),t.on("attribute:listType:listItem",JR,{priority:"high"}),t.on("attribute:listType:listItem",QR,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const s=n.mapper.toViewElement(i.item),o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r);o.remove(l),a&&a.nextSibling&&FR(o,a,a.nextSibling),oB(i.attributeOldValue+1,i.range.start,l.start,s,n,e),MR(i.item,s,n,e);for(const e of i.item.getChildren())n.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,n)=>{const s=n.mapper.toViewPosition(i.position).getLastMatchingPosition(e=>!e.item.is("element","li")).nodeAfter,o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r),c=o.remove(l);a&&a.nextSibling&&FR(o,a,a.nextSibling),oB(n.mapper.toModelElement(s).getAttribute("listIndent")+1,i.position,l.start,s,n,e);for(const e of o.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",ZR,{priority:"low"})}),e.conversion.for("dataDowncast").add(t=>{t.on("insert",YR,{priority:"high"}),t.on("insert:listItem",KR(e.model))}),e.conversion.for("upcast").add(e=>{e.on("element:ul",eB,{priority:"high"}),e.on("element:ol",eB,{priority:"high"}),e.on("element:li",tB,{priority:"high"}),e.on("element:li",XR)}),e.model.on("insertContent",nB,{priority:"high"}),e.commands.add("numberedList",new VR(e,"numbered")),e.commands.add("bulletedList",new VR(e,"bulleted")),e.commands.add("indentList",new BR(e,"forward")),e.commands.add("outdentList",new BR(e,"backward"));const s=i.view.document;this.listenTo(s,"enter",(e,t)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())},{context:"li"}),this.listenTo(s,"delete",(e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const s=n.parent;if("listItem"!==s.name)return;s.previousSibling&&"listItem"===s.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())},{context:"li"}),this.listenTo(e.editing.view.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function lB(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=lB(e);return t}class cB extends $n{static get requires(){return[aB,KO]}static get pluginName(){return"LegacyList"}static get isOfficialPlugin(){return!0}}class uB extends Gn{defaultType;constructor(e,t){super(e),this.defaultType=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){this._tryToConvertItemsToList(e);const t=this.editor.model,i=qR(t);i.length&&t.change(t=>{for(const n of i)t.setAttribute("listStyle",e.type||this.defaultType,n)})}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=$R(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class dB extends Gn{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=qR(t).filter(e=>"numbered"==e.getAttribute("listType"));t.change(t=>{for(const n of i)t.setAttribute("listReversed",!!e.reversed,n)})}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}class hB extends Gn{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=qR(t).filter(e=>"numbered"==e.getAttribute("listType"));t.change(t=>{for(const n of i)t.setAttribute("listStart",e>=0?e:1,n)})}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listStart"):null}}const mB="default";class gB extends $n{static get requires(){return[aB]}static get pluginName(){return"LegacyListPropertiesEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const e=this.editor,t=e.model,i=function(e){const t=[];e.styles&&t.push({attributeName:"listStyle",defaultValue:mB,addCommand(e){e.commands.add("listStyle",new uB(e,mB))},appliesToListItem:()=>!0,setAttributeOnDowncast(e,t,i){t&&t!==mB?e.setStyle("list-style-type",t,i):e.removeStyle("list-style-type",i)},getAttributeOnUpcast:e=>oR(e.getStyle("list-style-type"))||mB});e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,addCommand(e){e.commands.add("listReversed",new dB(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")});e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,addCommand(e){e.commands.add("listStart",new hB(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}});return t}(e.config.get("list.properties"));t.schema.extend("listItem",{allowAttributes:i.map(e=>e.attributeName)});for(const t of i)t.addCommand(e);var n;this.listenTo(e.commands.get("indentList"),"_executeCleanup",function(e,t){return(i,n)=>{const s=n[0],o=s.getAttribute("listIndent"),r=n.filter(e=>e.getAttribute("listIndent")===o);let a=null;s.previousSibling.getAttribute("listIndent")+1!==o&&(a=DR(s.previousSibling,{sameIndent:!0,direction:"backward",listIndent:o})),e.model.change(e=>{for(const i of r)for(const n of t)if(n.appliesToListItem(i)){const t=null==a?n.defaultValue:a.getAttribute(n.attributeName);e.setAttribute(n.attributeName,t,i)}})}}(e,i)),this.listenTo(e.commands.get("outdentList"),"_executeCleanup",function(e,t){return(i,n)=>{if(!(n=n.reverse().filter(e=>e.is("element","listItem"))).length)return;const s=n[0].getAttribute("listIndent"),o=n[0].getAttribute("listType");let r=n[0].previousSibling;if(r.is("element","listItem"))for(;r.getAttribute("listIndent")!==s;)r=r.previousSibling;else r=null;r||(r=n[n.length-1].nextSibling),r&&r.is("element","listItem")&&r.getAttribute("listType")===o&&e.model.change(e=>{const i=n.filter(e=>e.getAttribute("listIndent")===s);for(const n of i)for(const i of t)if(i.appliesToListItem(n)){const t=i.attributeName,s=r.getAttribute(t);e.setAttribute(t,s,n)}})}}(e,i)),this.listenTo(e.commands.get("bulletedList"),"_executeCleanup",bB(e)),this.listenTo(e.commands.get("numberedList"),"_executeCleanup",bB(e)),t.document.registerPostFixer(function(e,t){return i=>{let n=!1;const s=wB(e.model.document.differ.getChanges()).filter(e=>"todo"!==e.getAttribute("listType"));if(!s.length)return n;let o=s[s.length-1].nextSibling;if((!o||!o.is("element","listItem"))&&(o=s[0].previousSibling,o)){const e=s[0].getAttribute("listIndent");for(;o.is("element","listItem")&&o.getAttribute("listIndent")!==e&&(o=o.previousSibling,o););}for(const e of t){const t=e.attributeName;for(const r of s)if(e.appliesToListItem(r))if(r.hasAttribute(t)){const s=r.previousSibling;pB(s,r,e.attributeName)&&(i.setAttribute(t,s.getAttribute(t),r),n=!0)}else fB(o,r,e)?i.setAttribute(t,o.getAttribute(t),r):i.setAttribute(t,e.defaultValue,r),n=!0;else i.removeAttribute(t,r)}return n}}(e,i)),e.conversion.for("upcast").add((n=i,e=>{e.on("element:li",(e,t,i)=>{if(!t.modelRange)return;const s=t.viewItem.parent,o=t.modelRange.start.nodeAfter||t.modelRange.end.nodeBefore;for(const e of n)if(e.appliesToListItem(o)){const t=e.getAttributeOnUpcast(s);i.writer.setAttribute(e.attributeName,t,o)}},{priority:"low"})})),e.conversion.for("downcast").add(function(e){return i=>{for(const n of e)i.on(`attribute:${n.attributeName}:listItem`,(e,i,s)=>{const o=s.writer,r=i.item,a=DR(r.previousSibling,{sameIndent:!0,listIndent:r.getAttribute("listIndent"),direction:"backward"}),l=s.mapper.toViewElement(r);t(r,a)||o.breakContainer(o.createPositionBefore(l)),n.setAttributeOnDowncast(o,i.attributeNewValue,l.parent)},{priority:"low"})};function t(e,t){return t&&e.getAttribute("listType")===t.getAttribute("listType")&&e.getAttribute("listIndent")===t.getAttribute("listIndent")&&e.getAttribute("listStyle")===t.getAttribute("listStyle")&&e.getAttribute("listReversed")===t.getAttribute("listReversed")&&e.getAttribute("listStart")===t.getAttribute("listStart")}}(i)),this._mergeListAttributesWhileMergingLists(i)}afterInit(){const e=this.editor;e.commands.get("todoList")&&e.model.document.registerPostFixer(function(e){return t=>{const i=wB(e.model.document.differ.getChanges()).filter(e=>"todo"===e.getAttribute("listType")&&(e.hasAttribute("listStyle")||e.hasAttribute("listReversed")||e.hasAttribute("listStart")));if(!i.length)return!1;for(const e of i)t.removeAttribute("listStyle",e),t.removeAttribute("listReversed",e),t.removeAttribute("listStart",e);return!0}}(e))}_mergeListAttributesWhileMergingLists(e){const t=this.editor.model;let i;this.listenTo(t,"deleteContent",(e,[t])=>{const n=t.getFirstPosition(),s=t.getLastPosition();if(n.parent===s.parent)return;if(!n.parent.is("element","listItem"))return;const o=s.parent.nextSibling;if(!o||!o.is("element","listItem"))return;const r=DR(n.parent,{sameIndent:!0,listIndent:o.getAttribute("listIndent")});r&&r.getAttribute("listType")===o.getAttribute("listType")&&(i=r)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{i&&(t.change(t=>{const n=DR(i.nextSibling,{sameIndent:!0,listIndent:i.getAttribute("listIndent"),direction:"forward"});if(!n)return void(i=null);const s=[n,...HR(t.createPositionAt(n,0),"forward")];for(const n of s)for(const s of e)if(s.appliesToListItem(n)){const e=s.attributeName,o=i.getAttribute(e);t.setAttribute(e,o,n)}}),i=null)},{priority:"low"})}}function fB(e,t,i){if(!e)return!1;const n=e.getAttribute(i.attributeName);return!!n&&(n!=i.defaultValue&&e.getAttribute("listType")===t.getAttribute("listType"))}function pB(e,t,i){if(!e||!e.is("element","listItem"))return!1;if(t.getAttribute("listType")!==e.getAttribute("listType"))return!1;const n=e.getAttribute("listIndent");if(n<1||n!==t.getAttribute("listIndent"))return!1;const s=e.getAttribute(i);return!(!s||s===t.getAttribute(i))}function bB(e){return(t,i)=>{i=i.filter(e=>e.is("element","listItem")),e.model.change(e=>{for(const t of i)e.removeAttribute("listStyle",t)})}}function wB(e){const t=[];for(const i of e){const e=vB(i);e&&e.is("element","listItem")&&t.push(e)}return t}function vB(e){return"attribute"===e.type?e.range.start.nodeAfter:"insert"===e.type?e.position.nodeAfter:null}class _B extends $n{static get requires(){return[gB,fR]}static get pluginName(){return"LegacyListProperties"}static get isOfficialPlugin(){return!0}}const yB="todoListChecked";class kB extends Gn{_selectedElements;constructor(e){super(e),this._selectedElements=[],this.on("execute",()=>{this.refresh()},{priority:"highest"})}refresh(){this._selectedElements=this._getSelectedItems(),this.value=this._selectedElements.every(e=>!!e.getAttribute(yB)),this.isEnabled=!!this._selectedElements.length}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,s=[];t.checkAttribute(n,yB)&&s.push(n);for(const e of i.getItems())t.checkAttribute(e,yB)&&!s.includes(e)&&s.push(e);return s}execute(e={}){this.editor.model.change(t=>{for(const i of this._selectedElements){(void 0===e.forceValue?!this.value:e.forceValue)?t.setAttribute(yB,!0,i):t.removeAttribute(yB,i)}})}}const CB=(e,t,i)=>{const n=t.modelCursor,s=n.parent,o=t.viewItem;if("checkbox"!=o.getAttribute("type")||"listItem"!=s.name||!n.isAtStart)return;if(!i.consumable.consume(o,{name:!0}))return;const r=i.writer;r.setAttribute("listType","todo",s),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,s),t.modelRange=r.createRange(n)};function xB(e){return(t,i)=>{const n=i.modelPosition,s=n.parent;if(!s.is("element","listItem")||"todo"!=s.getAttribute("listType"))return;const o=TB(i.mapper.toViewElement(s),e);o&&(i.viewPosition=i.mapper.findPositionIn(o,n.offset))}}function AB(e,t,i,n){return t.createUIElement("label",{class:"todo-list__label",contenteditable:!1},function(t){const s=Qt(document,"input",{type:"checkbox",tabindex:"-1"});i&&s.setAttribute("checked","checked"),s.addEventListener("change",()=>n(e));const o=this.toDomElement(t);return o.appendChild(s),o})}function TB(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("containerElement","span")&&e.item.hasClass("todo-list__label__description"))return e.item}const EB=Xi("Ctrl+Enter");class SB extends $n{static get pluginName(){return"LegacyTodoListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[aB]}init(){const e=this.editor,{editing:t,data:i,model:n}=e;n.schema.extend("listItem",{allowAttributes:["todoListChecked"]}),n.schema.addAttributeCheck((e,t)=>{const i=e.last;if("todoListChecked"==t&&"listItem"==i.name&&"todo"!=i.getAttribute("listType"))return!1}),e.commands.add("todoList",new VR(e,"todo"));const s=new kB(e);var o,r;e.commands.add("checkTodoList",s),e.commands.add("todoListCheck",s),i.downcastDispatcher.on("insert:listItem",function(e){return(t,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;if("todo"!=i.item.getAttribute("listType"))return;const o=i.item;s.consume(o,"insert"),s.consume(o,"attribute:listType"),s.consume(o,"attribute:listIndent"),s.consume(o,"attribute:todoListChecked");const r=n.writer,a=LR(o,n);r.addClass("todo-list",a.parent);const l=r.createContainerElement("label",{class:"todo-list__label"}),c=r.createEmptyElement("input",{type:"checkbox",disabled:"disabled"}),u=r.createContainerElement("span",{class:"todo-list__label__description"});o.getAttribute("todoListChecked")&&r.setAttribute("checked","checked",c),r.insert(r.createPositionAt(a,0),l),r.insert(r.createPositionAt(l,0),c),r.insert(r.createPositionAfter(c),u),MR(o,a,n,e)}}(n),{priority:"high"}),i.upcastDispatcher.on("element:input",CB,{priority:"high"}),t.downcastDispatcher.on("insert:listItem",function(e,t){return(i,n,s)=>{const o=s.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;if("todo"!=n.item.getAttribute("listType"))return;const r=n.item;o.consume(r,"insert"),o.consume(r,"attribute:listType"),o.consume(r,"attribute:listIndent"),o.consume(r,"attribute:todoListChecked");const a=s.writer,l=LR(r,s),c=!!r.getAttribute("todoListChecked"),u=AB(r,a,c,t),d=a.createContainerElement("span",{class:"todo-list__label__description"});a.addClass("todo-list",l.parent),a.insert(a.createPositionAt(l,0),u),a.insert(a.createPositionAfter(u),d),MR(r,l,s,e)}}(n,e=>this._handleCheckmarkChange(e)),{priority:"high"}),t.downcastDispatcher.on("attribute:listType:listItem",(o=e=>this._handleCheckmarkChange(e),r=t.view,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),s=i.writer,a=function(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("uiElement","label"))return e.item}(n,r);if("todo"==t.attributeNewValue){const e=!!t.item.getAttribute("todoListChecked"),i=AB(t.item,s,e,o),r=s.createContainerElement("span",{class:"todo-list__label__description"}),a=s.createRangeIn(n),l=zR(n),c=NR(a.start),u=l?s.createPositionBefore(l):a.end,d=s.createRange(c,u);s.addClass("todo-list",n.parent),s.move(d,s.createPositionAt(r,0)),s.insert(s.createPositionAt(n,0),i),s.insert(s.createPositionAfter(i),r)}else if("todo"==t.attributeOldValue){const e=TB(n,r);s.removeClass("todo-list",n.parent),s.remove(a),s.move(s.createRangeIn(e),s.createPositionBefore(e)),s.remove(e)}})),t.downcastDispatcher.on("attribute:todoListChecked:listItem",function(e){return(t,i,n)=>{if("todo"!=i.item.getAttribute("listType"))return;if(!n.consumable.consume(i.item,"attribute:todoListChecked"))return;const{mapper:s,writer:o}=n,r=!!i.item.getAttribute("todoListChecked"),a=s.toViewElement(i.item).getChild(0),l=AB(i.item,o,r,e);o.insert(o.createPositionAfter(a),l),o.remove(a)}}(e=>this._handleCheckmarkChange(e))),t.mapper.on("modelToViewPosition",xB(t.view)),i.mapper.on("modelToViewPosition",xB(t.view)),this.listenTo(t.view.document,"arrowKey",function(e,t){return(i,n)=>{if("left"!=nn(n.keyCode,t.contentLanguageDirection))return;const s=e.schema,o=e.document.selection;if(!o.isCollapsed)return;const r=o.getFirstPosition(),a=r.parent;if("listItem"===a.name&&"todo"==a.getAttribute("listType")&&r.isAtStart){const t=s.getNearestSelectionRange(e.createPositionBefore(a),"backward");t&&e.change(e=>e.setSelection(t)),n.preventDefault(),n.stopPropagation(),i.stop()}}}(n,e.locale),{context:"li"}),this.listenTo(t.view.document,"keydown",(t,i)=>{Zi(i)===EB&&(e.execute("checkTodoList"),t.stop())},{priority:"high"});const a=new Set;this.listenTo(n,"applyOperation",(e,t)=>{const i=t[0];if("rename"==i.type&&"listItem"==i.oldName){const e=i.position.nodeAfter;e.hasAttribute("todoListChecked")&&a.add(e)}else if("changeAttribute"==i.type&&"listType"==i.key&&"todo"===i.oldValue)for(const e of i.range.getItems())e.hasAttribute("todoListChecked")&&"todo"!==e.getAttribute("listType")&&a.add(e)}),n.document.registerPostFixer(e=>{let t=!1;for(const i of a)e.removeAttribute("todoListChecked",i),t=!0;return a.clear(),t}),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change(i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)})}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let n=null;t&&e.document.selection.on("change:range",()=>{const s=e.document.selection.focus.parent,o=IB(n),r=IB(s);o&&!r?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!o&&r&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),n=s})}}function IB(e){return!!e&&e.is("element","listItem")&&"todo"===e.getAttribute("listType")}class PB extends $n{static get requires(){return[SB,IR]}static get pluginName(){return"LegacyTodoList"}static get isOfficialPlugin(){return!0}}class VB extends $n{static get pluginName(){return"AdjacentListsSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("listSeparator",{allowWhere:"$block",isBlock:!0}),e.conversion.for("upcast").add(e=>{e.on("element:ol",OB()),e.on("element:ul",OB())}).elementToElement({model:"listSeparator",view:"ck-list-separator"}),e.conversion.for("editingDowncast").elementToElement({model:"listSeparator",view:{name:"div",classes:["ck-list-separator","ck-hidden"]}}),e.conversion.for("dataDowncast").elementToElement({model:"listSeparator",view:(e,t)=>{const i=t.writer.createContainerElement("ck-list-separator");return t.writer.setCustomProperty("dataPipeline:transparentRendering",!0,i),i.getFillerOffset=()=>null,i}})}}function OB(){return(e,t,i)=>{const n=t.viewItem,s=n.nextSibling;if(!s)return;if(n.name!==s.name)return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor));const o=i.writer,r=o.createElement("listSeparator");if(!i.safeInsert(r,t.modelCursor))return;const a=i.getSplitParts(r);t.modelRange=o.createRange(t.modelRange.start,o.createPositionAfter(a[a.length-1])),i.updateConversionResult(r,t)}}function RB(e){if(e)throw e}var BB,LB;var MB=function(){if(LB)return BB;LB=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,n=Object.getOwnPropertyDescriptor,s=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},o=function(i){if(!i||"[object Object]"!==t.call(i))return!1;var n,s=e.call(i,"constructor"),o=i.constructor&&i.constructor.prototype&&e.call(i.constructor.prototype,"isPrototypeOf");if(i.constructor&&!s&&!o)return!1;for(n in i);return void 0===n||e.call(i,n)},r=function(e,t){i&&"__proto__"===t.name?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},a=function(t,i){if("__proto__"===i){if(!e.call(t,i))return;if(n)return n(t,i).value}return t[i]};return BB=function e(){var t,i,n,l,c,u,d=arguments[0],h=1,m=arguments.length,g=!1;for("boolean"==typeof d&&(g=d,d=arguments[1]||{},h=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});ht.length;let r;n&&t.push(s);try{r=e.apply(this,t)}catch(e){if(n&&i)throw e;return s(e)}n||(r&&r.then&&"function"==typeof r.then?r.then(o,s):r instanceof Error?s(r):o(r))}function s(e,...n){i||(i=!0,t(e,...n))}function o(e){s(null,e)}}(a,s)(...r):n(null,...r)}}(null,...t)},use:function(i){if("function"!=typeof i)throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}};return t}function DB(e){return e&&"object"==typeof e?"position"in e||"type"in e?HB(e.position):"start"in e||"end"in e?HB(e):"line"in e||"column"in e?zB(e):"":""}function zB(e){return qB(e&&e.line)+":"+qB(e&&e.column)}function HB(e){return zB(e&&e.start)+"-"+zB(e&&e.end)}function qB(e){return e&&"number"==typeof e?e:1}class UB extends Error{constructor(e,t,i){super(),"string"==typeof t&&(i=t,t=void 0);let n="",s={},o=!1;if(t&&(s="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?n=e:!s.cause&&e&&(o=!0,n=e.message,s.cause=e),!s.ruleId&&!s.source&&"string"==typeof i){const e=i.indexOf(":");-1===e?s.ruleId=i:(s.source=i.slice(0,e),s.ruleId=i.slice(e+1))}if(!s.place&&s.ancestors&&s.ancestors){const e=s.ancestors[s.ancestors.length-1];e&&(s.place=e.position)}const r=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=r?r.column:void 0,this.fatal=void 0,this.file="",this.message=n,this.line=r?r.line:void 0,this.name=DB(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&"string"==typeof s.cause.stack?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}UB.prototype.file="",UB.prototype.name="",UB.prototype.reason="",UB.prototype.message="",UB.prototype.stack="",UB.prototype.column=void 0,UB.prototype.line=void 0,UB.prototype.ancestors=void 0,UB.prototype.cause=void 0,UB.prototype.fatal=void 0,UB.prototype.place=void 0,UB.prototype.ruleId=void 0,UB.prototype.source=void 0;const WB={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');$B(e);let i,n=0,s=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(i){n=o+1;break}}else s<0&&(i=!0,s=o+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let r=-1,a=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1),a>-1&&(e.codePointAt(o)===t.codePointAt(a--)?a<0&&(s=o):(a=-1,s=r));n===s?s=r:s<0&&(s=e.length);return e.slice(n,s)},dirname:function(e){if($B(e),0===e.length)return".";let t,i=-1,n=e.length;for(;--n;)if(47===e.codePointAt(n)){if(t){i=n;break}}else t||(t=!0);return i<0?47===e.codePointAt(0)?"/":".":1===i&&47===e.codePointAt(0)?"//":e.slice(0,i)},extname:function(e){$B(e);let t,i=e.length,n=-1,s=0,o=-1,r=0;for(;i--;){const a=e.codePointAt(i);if(47!==a)n<0&&(t=!0,n=i+1),46===a?o<0?o=i:1!==r&&(r=1):o>-1&&(r=-1);else if(t){s=i+1;break}}if(o<0||n<0||0===r||1===r&&o===n-1&&o===s+1)return"";return e.slice(o,n)},join:function(...e){let t,i=-1;for(;++i2){if(n=s.lastIndexOf("/"),n!==s.length-1){n<0?(s="",o=0):(s=s.slice(0,n),o=s.length-1-s.lastIndexOf("/")),r=l,a=0;continue}}else if(s.length>0){s="",o=0,r=l,a=0;continue}t&&(s=s.length>0?s+"/..":"..",o=2)}else s.length>0?s+="/"+e.slice(r+1,l):s=e.slice(r+1,l),o=l-r-1;r=l,a=0}else 46===i&&a>-1?a++:a=-1}return s}(e,!t);0!==i.length||t||(i=".");i.length>0&&47===e.codePointAt(e.length-1)&&(i+="/");return t?"/"+i:i}(t)},sep:"/"};function $B(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const jB={cwd:function(){return"/"}};function GB(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function KB(e){if("string"==typeof e)e=new URL(e);else if(!GB(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let i=-1;for(;++i0){let[n,...o]=t;const r=i[s][1];FB(r)&&FB(n)&&(n=MB(!0,r,n)),i[s]=[e,n,...o]}}}}const nL=(new iL).freeze();function sL(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function oL(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function rL(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function aL(e){if(!FB(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function lL(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function cL(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new QB(e)}function uL(e,t){const i=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let n=0,s=i.indexOf(t);for(;-1!==s;)n++,s=i.indexOf(t,s+t.length);return n}const dL=CL(/[A-Za-z]/),hL=CL(/[\dA-Za-z]/),mL=CL(/[#-'*+\--9=?A-Z^-~]/);function gL(e){return null!==e&&(e<32||127===e)}const fL=CL(/\d/),pL=CL(/[\dA-Fa-f]/),bL=CL(/[!-/:-@[-`{-~]/);function wL(e){return null!==e&&e<-2}function vL(e){return null!==e&&(e<0||32===e)}function _L(e){return-2===e||-1===e||32===e}const yL=CL(/\p{P}|\p{S}/u),kL=CL(/\s/);function CL(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}const xL=function(e){if(null==e)return TL;if("function"==typeof e)return AL(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let i=-1;for(;++i":"")+")"})}return u;function u(){let c,u,d,h=EL;if((!t||o(s,a,l[l.length-1]||void 0))&&(h=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[SL,e];return null==e?EL:[e]}(i(s,l)),h[0]===IL))return h;if("children"in s&&s.children){const t=s;if(t.children&&h[0]!==PL)for(u=(n?t.children.length:-1)+r,d=l.concat(t);u>-1&&u0?{type:"text",value:o}:void 0),!1===o?n.lastIndex=i+1:(a!==i&&d.push({type:"text",value:e.value.slice(a,i)}),Array.isArray(o)?d.push(...o):o&&d.push(o),a=i+h[0].length,u=!0),!n.global)break;h=n.exec(e.value)}u?(a?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let i=t[0],n=i.indexOf(")");const s=uL(e,"(");let o=uL(e,")");for(;-1!==n&&s>o;)e+=i.slice(0,n+1),i=i.slice(n+1),n=i.indexOf(")"),o++;return[e,i]}(i+n);if(!r[0])return!1;const a={type:"link",title:null,url:o+t+r[0],children:[{type:"text",value:t+r[0]}]};return r[1]?[a,{type:"text",value:r[1]}]:a}function $L(e,t,i,n){return!(!jL(n,!0)||/[-\d_]$/.test(i))&&{type:"link",title:null,url:"mailto:"+t+"@"+i,children:[{type:"text",value:t+"@"+i}]}}function jL(e,t){const i=e.input.charCodeAt(e.index-1);return(0===e.index||kL(i)||yL(i))&&(!t||47!==i)}function GL(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}function KL(){this.buffer()}function JL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function QL(){this.buffer()}function YL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ZL(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=GL(this.sliceSerialize(e)).toLowerCase(),i.label=t}function XL(e){this.exit(e)}function eM(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=GL(this.sliceSerialize(e)).toLowerCase(),i.label=t}function tM(e){this.exit(e)}function iM(e,t,i,n){const s=i.createTracker(n);let o=s.move("[^");const r=i.enter("footnoteReference"),a=i.enter("reference");return o+=s.move(i.safe(i.associationId(e),{after:"]",before:o})),a(),r(),o+=s.move("]"),o}function nM(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,i,n,s){const o=n.createTracker(s);let r=o.move("[^");const a=n.enter("footnoteDefinition"),l=n.enter("label");r+=o.move(n.safe(n.associationId(e),{before:r,after:"]"})),l(),r+=o.move("]:"),e.children&&e.children.length>0&&(o.shift(4),r+=o.move((t?"\n":" ")+n.indentLines(n.containerFlow(e,o.current()),t?oM:sM)));return a(),r},footnoteReference:iM},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function sM(e,t,i){return 0===t?e:oM(e,t,i)}function oM(e,t,i){return(i?"":" ")+e}iM.peek=function(){return"["};const rM=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function aM(e){this.enter({type:"delete",children:[]},e)}function lM(e){this.exit(e)}function cM(e,t,i,n){const s=i.createTracker(n),o=i.enter("strikethrough");let r=s.move("~~");return r+=i.containerPhrasing(e,{...s.current(),before:r,after:"~"}),r+=s.move("~~"),o(),r}function uM(e){return e.length}function dM(e){return null==e?"":String(e)}function hM(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}cM.peek=function(){return"~"};const mM={}.hasOwnProperty;function gM(e,t){const i=t||{};function n(t,...i){let s=n.invalid;const o=n.handlers;if(t&&mM.call(t,e)){const i=String(t[e]);s=mM.call(o,i)?o[i]:n.unknown}if(s)return s.call(this,t,...i)}return n.handlers=i.handlers||{},n.invalid=i.invalid,n.unknown=i.unknown,n}const fM={}.hasOwnProperty;function pM(e,t){let i,n=-1;if(t.extensions)for(;++n"+(i?"":" ")+e}function _M(e,t){return yM(e,t.inConstruct,!0)&&!yM(e,t.notInConstruct,!1)}function yM(e,t,i){if("string"==typeof t&&(t=[t]),!t||0===t.length)return i;let n=-1;for(;++n",...l.current()})),c+=l.move(">")):(a=i.enter("destinationRaw"),c+=l.move(i.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=i.enter(`title${o}`),c+=l.move(" "+s),c+=l.move(i.safe(e.title,{before:c,after:s,...l.current()})),c+=l.move(s),a()),c+=l.move(")"),r(),c}function NM(e,t,i,n){const s=e.referenceType,o=i.enter("imageReference");let r=i.enter("label");const a=i.createTracker(n);let l=a.move("![");const c=i.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),r();const u=i.stack;i.stack=[],r=i.enter("reference");const d=i.safe(i.associationId(e),{before:l,after:"]",...a.current()});return r(),i.stack=u,o(),"full"!==s&&c&&c===d?"shortcut"===s?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(d+"]"),l}function DM(e,t,i){let n=e.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(n);)s+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++o\u007F]/.test(e.url))}function HM(e,t,i,n){const s=AM(i),o='"'===s?"Quote":"Apostrophe",r=i.createTracker(n);let a,l;if(zM(e,i)){const t=i.stack;i.stack=[],a=i.enter("autolink");let n=r.move("<");return n+=r.move(i.containerPhrasing(e,{before:n,after:">",...r.current()})),n+=r.move(">"),a(),i.stack=t,n}a=i.enter("link"),l=i.enter("label");let c=r.move("[");return c+=r.move(i.containerPhrasing(e,{before:c,after:"](",...r.current()})),c+=r.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=i.enter("destinationLiteral"),c+=r.move("<"),c+=r.move(i.safe(e.url,{before:c,after:">",...r.current()})),c+=r.move(">")):(l=i.enter("destinationRaw"),c+=r.move(i.safe(e.url,{before:c,after:e.title?" ":")",...r.current()}))),l(),e.title&&(l=i.enter(`title${o}`),c+=r.move(" "+s),c+=r.move(i.safe(e.title,{before:c,after:s,...r.current()})),c+=r.move(s),l()),c+=r.move(")"),a(),c}function qM(e,t,i,n){const s=e.referenceType,o=i.enter("linkReference");let r=i.enter("label");const a=i.createTracker(n);let l=a.move("[");const c=i.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),r();const u=i.stack;i.stack=[],r=i.enter("reference");const d=i.safe(i.associationId(e),{before:l,after:"]",...a.current()});return r(),i.stack=u,o(),"full"!==s&&c&&c===d?"shortcut"===s?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(d+"]"),l}function UM(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function WM(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}MM.peek=function(){return"<"},FM.peek=function(){return"!"},NM.peek=function(){return"!"},DM.peek=function(){return"`"},HM.peek=function(e,t,i){return zM(e,i)?"<":"["},qM.peek=function(){return"["};const $M=xL(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function jM(e,t,i,n){const s=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(i),o=i.enter("strong"),r=i.createTracker(n),a=r.move(s+s);let l=r.move(i.containerPhrasing(e,{after:s,before:a,...r.current()}));const c=l.charCodeAt(0),u=SM(n.before.charCodeAt(n.before.length-1),c,s);u.inside&&(l=TM(c)+l.slice(1));const d=l.charCodeAt(l.length-1),h=SM(n.after.charCodeAt(0),d,s);h.inside&&(l=l.slice(0,-1)+TM(d));const m=r.move(s+s);return o(),i.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},a+l+m}jM.peek=function(e,t,i){return i.options.strong||"*"};const GM={blockquote:function(e,t,i,n){const s=i.enter("blockquote"),o=i.createTracker(n);o.move("> "),o.shift(2);const r=i.indentLines(i.containerFlow(e,o.current()),vM);return s(),r},break:kM,code:function(e,t,i,n){const s=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(i),o=e.value||"",r="`"===s?"GraveAccent":"Tilde";if(CM(e,i)){const e=i.enter("codeIndented"),t=i.indentLines(o,xM);return e(),t}const a=i.createTracker(n),l=s.repeat(Math.max(function(e,t){const i=String(e);let n=i.indexOf(t),s=n,o=0,r=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==n;)n===s?++o>r&&(r=o):o=1,s=n+t.length,n=i.indexOf(t,s);return r}(o,s)+1,3)),c=i.enter("codeFenced");let u=a.move(l);if(e.lang){const t=i.enter(`codeFencedLang${r}`);u+=a.move(i.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),t()}if(e.lang&&e.meta){const t=i.enter(`codeFencedMeta${r}`);u+=a.move(" "),u+=a.move(i.safe(e.meta,{before:u,after:"\n",encode:["`"],...a.current()})),t()}return u+=a.move("\n"),o&&(u+=a.move(o+"\n")),u+=a.move(l),c(),u},definition:function(e,t,i,n){const s=AM(i),o='"'===s?"Quote":"Apostrophe",r=i.enter("definition");let a=i.enter("label");const l=i.createTracker(n);let c=l.move("[");return c+=l.move(i.safe(i.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=i.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(i.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=i.enter("destinationRaw"),c+=l.move(i.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),a(),e.title&&(a=i.enter(`title${o}`),c+=l.move(" "+s),c+=l.move(i.safe(e.title,{before:c,after:s,...l.current()})),c+=l.move(s),a()),r(),c},emphasis:IM,hardBreak:kM,heading:function(e,t,i,n){const s=Math.max(Math.min(6,e.depth||1),1),o=i.createTracker(n);if(LM(e,i)){const t=i.enter("headingSetext"),n=i.enter("phrasing"),r=i.containerPhrasing(e,{...o.current(),before:"\n",after:"\n"});return n(),t(),r+"\n"+(1===s?"=":"-").repeat(r.length-(Math.max(r.lastIndexOf("\r"),r.lastIndexOf("\n"))+1))}const r="#".repeat(s),a=i.enter("headingAtx"),l=i.enter("phrasing");o.move(r+" ");let c=i.containerPhrasing(e,{before:"# ",after:"\n",...o.current()});return/^[\t ]/.test(c)&&(c=TM(c.charCodeAt(0))+c.slice(1)),c=c?r+" "+c:r,i.options.closeAtx&&(c+=" "+r),l(),a(),c},html:MM,image:FM,imageReference:NM,inlineCode:DM,link:HM,linkReference:qM,list:function(e,t,i,n){const s=i.enter("list"),o=i.bulletCurrent;let r=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(i):UM(i);const a=e.ordered?"."===r?")":".":function(e){const t=UM(e),i=e.options.bulletOther;if(!i)return"*"===t?"-":"*";if("*"!==i&&"+"!==i&&"-"!==i)throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+i+"`) to be different");return i}(i);let l=!(!t||!i.bulletLastUsed)&&r===i.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==r&&"-"!==r||!t||t.children&&t.children[0]||"list"!==i.stack[i.stack.length-1]||"listItem"!==i.stack[i.stack.length-2]||"list"!==i.stack[i.stack.length-3]||"listItem"!==i.stack[i.stack.length-4]||0!==i.indexStack[i.indexStack.length-1]||0!==i.indexStack[i.indexStack.length-2]||0!==i.indexStack[i.indexStack.length-3]||(l=!0),WM(i)===r&&t){let t=-1;for(;++t-1?t.start:1)+(!1===i.options.incrementListMarker?0:t.children.indexOf(e))+o);let r=o.length+1;("tab"===s||"mixed"===s&&(t&&"list"===t.type&&t.spread||e.spread))&&(r=4*Math.ceil(r/4));const a=i.createTracker(n);a.move(o+" ".repeat(r-o.length)),a.shift(r);const l=i.enter("listItem"),c=i.indentLines(i.containerFlow(e,a.current()),function(e,t,i){if(t)return(i?"":" ".repeat(r))+e;return(i?o:o+" ".repeat(r-o.length))+e});return l(),c},paragraph:function(e,t,i,n){const s=i.enter("paragraph"),o=i.enter("phrasing"),r=i.containerPhrasing(e,n);return o(),s(),r},root:function(e,t,i,n){const s=e.children.some(function(e){return $M(e)});return(s?i.containerPhrasing:i.containerFlow).call(i,e,n)},strong:jM,text:function(e,t,i,n){return i.safe(e.value,n)},thematicBreak:function(e,t,i){const n=(WM(i)+(i.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(i));return i.options.ruleSpaces?n.slice(0,-1):n}},KM=[function(e,t,i,n){if("code"===t.type&&CM(t,n)&&("list"===e.type||e.type===t.type&&CM(e,n)))return!1;if("spread"in i&&"boolean"==typeof i.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&LM(t,n)))return;return i.spread?1:0}}];const JM=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],QM=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:JM},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:JM},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:JM},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:JM},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:JM},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:JM},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:JM},{atBreak:!0,character:"~"}],YM=document.createElement("i");function ZM(e){const t="&"+e+";";YM.innerHTML=t;const i=YM.textContent;return(59!==i.charCodeAt(i.length-1)||"semi"===e)&&(i!==t&&i)}function XM(e,t){const i=Number.parseInt(e,t);return i<9||11===i||i>13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||!(65535&~i)||65534==(65535&i)||i>1114111?"�":String.fromCodePoint(i)}const eF=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tF(e){return e.replace(eF,iF)}function iF(e,t,i){if(t)return t;if(35===i.charCodeAt(0)){const e=i.charCodeAt(1),t=120===e||88===e;return XM(i.slice(t?2:1),t?16:10)}return ZM(i)||e}function nF(e){return e.label||!e.identifier?e.label||"":tF(e.identifier)}function sF(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function oF(e,t,i,n){let s=n.join.length;for(;s--;){const o=n.join[s](e,t,i,n);if(!0===o||1===o)break;if("number"==typeof o)return"\n".repeat(1+o);if(!1===o)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const rF=/\r?\n|\r/g;function aF(e,t){const i=[];let n,s=0,o=0;for(;n=rF.exec(e);)r(e.slice(s,n.index)),i.push(n[0]),s=n.index+n[0].length,o++;return r(e.slice(s)),i.join("");function r(e){i.push(t(e,o,!e))}}function lF(e,t){return e-t}function cF(e,t){const i=/\\(?=[!-/:-@[-`{-~])/g,n=[],s=[],o=e+t;let r,a=-1,l=0;for(;r=i.exec(o);)n.push(r.index);for(;++a0&&("\r"===l||"\n"===l)&&"html"===u.type&&(o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=t.createTracker(i),c.move(o.join("")));let h=t.handle(u,e,t,{...c.current(),after:d,before:l});r&&r===h.slice(0,1)&&(h=TM(r.charCodeAt(0))+h.slice(1));const m=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,r=void 0,m&&(o.length>0&&m.before&&l===o[o.length-1].slice(-1)&&(o[o.length-1]=o[o.length-1].slice(0,-1)+TM(l.charCodeAt(0))),m.after&&(r=d)),c.move(h),o.push(h),l=h.slice(-1)}return n.pop(),o.join("")}(e,this,t)}function pF(e,t){return function(e,t,i){const n=t.indexStack,s=e.children||[],o=t.createTracker(i),r=[];let a=-1;for(n.push(-1);++a=c||e+1c&&(c=e[u].length);++ol[o])&&(l[o]=e)}t.push(r)}r[u]=t,a[u]=n}let d=-1;if("object"==typeof n&&"length"in n)for(;++dl[d]&&(l[d]=s),m[d]=s),h[d]=r}r.splice(1,0,h),a.splice(1,0,m),u=-1;const g=[];for(;++us?0:s+t:t>s?s:t,i=i>0?i:0,n.length<1e4)o=Array.from(n),o.unshift(t,i),e.splice(...o);else for(i&&e.splice(t,i);r0?(IF(e,e.length,0,t),e):t}const VF={}.hasOwnProperty;function OF(e){const t={};let i=-1;for(;++i0&&!i&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}function QF(e){const t=[];let i=-1,n=0,s=0;for(;++i55295&&o<57344){const t=e.charCodeAt(i+1);o<56320&&t>56319&&t<57344?(r=String.fromCharCode(o,t),s=1):r="�"}else r=String.fromCharCode(o);r&&(t.push(e.slice(n,i),encodeURIComponent(r)),n=i+s+1,r=""),s&&(i+=s,s=0)}return t.join("")+e.slice(n)}function YF(e,t,i){const n=[];let s=-1;for(;++s1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[i][1].end},h={...e[u][1].start};XF(d,-a),XF(h,a),o={type:a>1?"strongSequence":"emphasisSequence",start:d,end:{...e[i][1].end}},r={type:a>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},s={type:a>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[u][1].start}},n={type:a>1?"strong":"emphasis",start:{...o.start},end:{...r.end}},e[i][1].end={...o.start},e[u][1].start={...r.end},l=[],e[i][1].end.offset-e[i][1].start.offset&&(l=PF(l,[["enter",e[i][1],t],["exit",e[i][1],t]])),l=PF(l,[["enter",n,t],["enter",o,t],["exit",o,t],["enter",s,t]]),l=PF(l,YF(t.parser.constructs.insideSpan.null,e.slice(i+1,u),t)),l=PF(l,[["exit",s,t],["enter",r,t],["exit",r,t],["exit",n,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=PF(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,IF(e,i-1,u-i+3,l),u=i+l.length-c-2;break}u=-1;for(;++u=a?(e.exit("codeFencedFenceSequence"),_L(t)?tN(e,d,"whitespace")(t):d(t)):i(t)}function d(n){return null===n||wL(n)?(e.exit("codeFencedFence"),t(n)):i(n)}}};let o,r=0,a=0;return function(t){return function(t){const i=n.events[n.events.length-1];return r=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,o=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===o?(a++,e.consume(t),l):a<3?i(t):(e.exit("codeFencedFenceSequence"),_L(t)?tN(e,c,"whitespace")(t):c(t))}function c(i){return null===i||wL(i)?(e.exit("codeFencedFence"),n.interrupt?t(i):e.check(rN,m,w)(i)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(i))}function u(t){return null===t||wL(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):_L(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),tN(e,d,"whitespace")(t)):96===t&&t===o?i(t):(e.consume(t),u)}function d(t){return null===t||wL(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||wL(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===o?i(t):(e.consume(t),h)}function m(t){return e.attempt(s,w,g)(t)}function g(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),f}function f(t){return r>0&&_L(t)?tN(e,p,"linePrefix",r+1)(t):p(t)}function p(t){return null===t||wL(t)?e.check(rN,m,w)(t):(e.enter("codeFlowValue"),b(t))}function b(t){return null===t||wL(t)?(e.exit("codeFlowValue"),p(t)):(e.consume(t),b)}function w(i){return e.exit("codeFenced"),t(i)}}};const lN={name:"codeIndented",tokenize:function(e,t,i){const n=this;return function(t){return e.enter("codeIndented"),tN(e,s,"linePrefix",5)(t)};function s(e){const t=n.events[n.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):i(e)}function o(t){return null===t?a(t):wL(t)?e.attempt(cN,o,a)(t):(e.enter("codeFlowValue"),r(t))}function r(t){return null===t||wL(t)?(e.exit("codeFlowValue"),o(t)):(e.consume(t),r)}function a(i){return e.exit("codeIndented"),t(i)}}},cN={partial:!0,tokenize:function(e,t,i){const n=this;return s;function s(t){return n.parser.lazy[n.now().line]?i(t):wL(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):tN(e,o,"linePrefix",5)(t)}function o(e){const o=n.events[n.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):wL(e)?s(e):i(e)}}};const uN={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,i,n=e.length-4,s=3;if(!("lineEnding"!==e[s][1].type&&"space"!==e[s][1].type||"lineEnding"!==e[n][1].type&&"space"!==e[n][1].type))for(t=s;++t=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,t,i){const n=t||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-n,Number.POSITIVE_INFINITY);return i&&hN(this.left,i),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),hN(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),hN(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e=4?t(s):e.interrupt(n.parser.constructs.flow,i,t)(s)}}};function bN(e,t,i,n,s,o,r,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return function(t){if(60===t)return e.enter(n),e.enter(s),e.enter(o),e.consume(t),e.exit(o),d;if(null===t||32===t||41===t||gL(t))return i(t);return e.enter(n),e.enter(r),e.enter(a),e.enter("chunkString",{contentType:"string"}),g(t)};function d(i){return 62===i?(e.enter(o),e.consume(i),e.exit(o),e.exit(s),e.exit(n),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(i))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(a),d(t)):null===t||60===t||wL(t)?i(t):(e.consume(t),92===t?m:h)}function m(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function g(s){return u||null!==s&&41!==s&&!vL(s)?u999||null===d||91===d||93===d&&!a||94===d&&!l&&"_hiddenFootnoteSupport"in r.parser.constructs?i(d):93===d?(e.exit(o),e.enter(s),e.consume(d),e.exit(s),e.exit(n),t):wL(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||wL(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!_L(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function vN(e,t,i,n,s,o){let r;return function(t){if(34===t||39===t||40===t)return e.enter(n),e.enter(s),e.consume(t),e.exit(s),r=40===t?41:t,a;return i(t)};function a(i){return i===r?(e.enter(s),e.consume(i),e.exit(s),e.exit(n),t):(e.enter(o),l(i))}function l(t){return t===r?(e.exit(o),a(r)):null===t?i(t):wL(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),tN(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===r||null===t||wL(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===r||92===t?(e.consume(t),c):c(t)}}function _N(e,t){let i;return function n(s){if(wL(s))return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i=!0,n;if(_L(s))return tN(e,n,i?"linePrefix":"lineSuffix")(s);return t(s)}}const yN={name:"definition",tokenize:function(e,t,i){const n=this;let s;return function(t){return e.enter("definition"),function(t){return wN.call(n,e,o,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function o(t){return s=GL(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r):i(t)}function r(t){return vL(t)?_N(e,a)(t):a(t)}function a(t){return bN(e,l,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(kN,c,c)(t)}function c(t){return _L(t)?tN(e,u,"whitespace")(t):u(t)}function u(o){return null===o||wL(o)?(e.exit("definition"),n.parser.defined.push(s),t(o)):i(o)}}},kN={partial:!0,tokenize:function(e,t,i){return function(t){return vL(t)?_N(e,n)(t):i(t)};function n(t){return vN(e,s,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function s(t){return _L(t)?tN(e,o,"whitespace")(t):o(t)}function o(e){return null===e||wL(e)?t(e):i(e)}}};const CN={name:"hardBreakEscape",tokenize:function(e,t,i){return function(t){return e.enter("hardBreakEscape"),e.consume(t),n};function n(n){return wL(n)?(e.exit("hardBreakEscape"),t(n)):i(n)}}};const xN={name:"headingAtx",resolve:function(e,t){let i,n,s=e.length-2,o=3;"whitespace"===e[o][1].type&&(o+=2);s-2>o&&"whitespace"===e[s][1].type&&(s-=2);"atxHeadingSequence"===e[s][1].type&&(o===s-1||s-4>o&&"whitespace"===e[s-2][1].type)&&(s-=o+1===s?2:4);s>o&&(i={type:"atxHeadingText",start:e[o][1].start,end:e[s][1].end},n={type:"chunkText",start:e[o][1].start,end:e[s][1].end,contentType:"text"},IF(e,o,s-o+1,[["enter",i,t],["enter",n,t],["exit",n,t],["exit",i,t]]));return e},tokenize:function(e,t,i){let n=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),s(t)}(t)};function s(t){return 35===t&&n++<6?(e.consume(t),s):null===t||vL(t)?(e.exit("atxHeadingSequence"),o(t)):i(t)}function o(i){return 35===i?(e.enter("atxHeadingSequence"),r(i)):null===i||wL(i)?(e.exit("atxHeading"),t(i)):_L(i)?tN(e,o,"whitespace")(i):(e.enter("atxHeadingText"),a(i))}function r(t){return 35===t?(e.consume(t),r):(e.exit("atxHeadingSequence"),o(t))}function a(t){return null===t||35===t||vL(t)?(e.exit("atxHeadingText"),o(t)):(e.consume(t),a)}}};const AN=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],TN=["pre","script","style","textarea"],EN={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,i){const n=this;let s,o,r,a,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(a){return 33===a?(e.consume(a),u):47===a?(e.consume(a),o=!0,m):63===a?(e.consume(a),s=3,n.interrupt?t:B):dL(a)?(e.consume(a),r=String.fromCharCode(a),g):i(a)}function u(o){return 45===o?(e.consume(o),s=2,d):91===o?(e.consume(o),s=5,a=0,h):dL(o)?(e.consume(o),s=4,n.interrupt?t:B):i(o)}function d(s){return 45===s?(e.consume(s),n.interrupt?t:B):i(s)}function h(s){const o="CDATA[";return s===o.charCodeAt(a++)?(e.consume(s),6===a?n.interrupt?t:T:h):i(s)}function m(t){return dL(t)?(e.consume(t),r=String.fromCharCode(t),g):i(t)}function g(a){if(null===a||47===a||62===a||vL(a)){const l=47===a,c=r.toLowerCase();return l||o||!TN.includes(c)?AN.includes(r.toLowerCase())?(s=6,l?(e.consume(a),f):n.interrupt?t(a):T(a)):(s=7,n.interrupt&&!n.parser.lazy[n.now().line]?i(a):o?p(a):b(a)):(s=1,n.interrupt?t(a):T(a))}return 45===a||hL(a)?(e.consume(a),r+=String.fromCharCode(a),g):i(a)}function f(s){return 62===s?(e.consume(s),n.interrupt?t:T):i(s)}function p(t){return _L(t)?(e.consume(t),p):x(t)}function b(t){return 47===t?(e.consume(t),x):58===t||95===t||dL(t)?(e.consume(t),w):_L(t)?(e.consume(t),b):x(t)}function w(t){return 45===t||46===t||58===t||95===t||hL(t)?(e.consume(t),w):v(t)}function v(t){return 61===t?(e.consume(t),_):_L(t)?(e.consume(t),v):b(t)}function _(t){return null===t||60===t||61===t||62===t||96===t?i(t):34===t||39===t?(e.consume(t),l=t,y):_L(t)?(e.consume(t),_):k(t)}function y(t){return t===l?(e.consume(t),l=null,C):null===t||wL(t)?i(t):(e.consume(t),y)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||vL(t)?v(t):(e.consume(t),k)}function C(e){return 47===e||62===e||_L(e)?b(e):i(e)}function x(t){return 62===t?(e.consume(t),A):i(t)}function A(t){return null===t||wL(t)?T(t):_L(t)?(e.consume(t),A):i(t)}function T(t){return 45===t&&2===s?(e.consume(t),P):60===t&&1===s?(e.consume(t),V):62===t&&4===s?(e.consume(t),L):63===t&&3===s?(e.consume(t),B):93===t&&5===s?(e.consume(t),R):!wL(t)||6!==s&&7!==s?null===t||wL(t)?(e.exit("htmlFlowData"),E(t)):(e.consume(t),T):(e.exit("htmlFlowData"),e.check(SN,M,E)(t))}function E(t){return e.check(IN,S,M)(t)}function S(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||wL(t)?E(t):(e.enter("htmlFlowData"),T(t))}function P(t){return 45===t?(e.consume(t),B):T(t)}function V(t){return 47===t?(e.consume(t),r="",O):T(t)}function O(t){if(62===t){const i=r.toLowerCase();return TN.includes(i)?(e.consume(t),L):T(t)}return dL(t)&&r.length<8?(e.consume(t),r+=String.fromCharCode(t),O):T(t)}function R(t){return 93===t?(e.consume(t),B):T(t)}function B(t){return 62===t?(e.consume(t),L):45===t&&2===s?(e.consume(t),B):T(t)}function L(t){return null===t||wL(t)?(e.exit("htmlFlowData"),M(t)):(e.consume(t),L)}function M(i){return e.exit("htmlFlow"),t(i)}}},SN={partial:!0,tokenize:function(e,t,i){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),e.attempt(iN,t,i)}}},IN={partial:!0,tokenize:function(e,t,i){const n=this;return function(t){if(wL(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s;return i(t)};function s(e){return n.parser.lazy[n.now().line]?i(e):t(e)}}};const PN={name:"htmlText",tokenize:function(e,t,i){const n=this;let s,o,r;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),a};function a(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),_):63===t?(e.consume(t),w):dL(t)?(e.consume(t),C):i(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),o=0,m):dL(t)?(e.consume(t),b):i(t)}function c(t){return 45===t?(e.consume(t),h):i(t)}function u(t){return null===t?i(t):45===t?(e.consume(t),d):wL(t)?(r=u,O(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?V(e):45===e?d(e):u(e)}function m(t){const n="CDATA[";return t===n.charCodeAt(o++)?(e.consume(t),6===o?g:m):i(t)}function g(t){return null===t?i(t):93===t?(e.consume(t),f):wL(t)?(r=g,O(t)):(e.consume(t),g)}function f(t){return 93===t?(e.consume(t),p):g(t)}function p(t){return 62===t?V(t):93===t?(e.consume(t),p):g(t)}function b(t){return null===t||62===t?V(t):wL(t)?(r=b,O(t)):(e.consume(t),b)}function w(t){return null===t?i(t):63===t?(e.consume(t),v):wL(t)?(r=w,O(t)):(e.consume(t),w)}function v(e){return 62===e?V(e):w(e)}function _(t){return dL(t)?(e.consume(t),y):i(t)}function y(t){return 45===t||hL(t)?(e.consume(t),y):k(t)}function k(t){return wL(t)?(r=k,O(t)):_L(t)?(e.consume(t),k):V(t)}function C(t){return 45===t||hL(t)?(e.consume(t),C):47===t||62===t||vL(t)?x(t):i(t)}function x(t){return 47===t?(e.consume(t),V):58===t||95===t||dL(t)?(e.consume(t),A):wL(t)?(r=x,O(t)):_L(t)?(e.consume(t),x):V(t)}function A(t){return 45===t||46===t||58===t||95===t||hL(t)?(e.consume(t),A):T(t)}function T(t){return 61===t?(e.consume(t),E):wL(t)?(r=T,O(t)):_L(t)?(e.consume(t),T):x(t)}function E(t){return null===t||60===t||61===t||62===t||96===t?i(t):34===t||39===t?(e.consume(t),s=t,S):wL(t)?(r=E,O(t)):_L(t)?(e.consume(t),E):(e.consume(t),I)}function S(t){return t===s?(e.consume(t),s=void 0,P):null===t?i(t):wL(t)?(r=S,O(t)):(e.consume(t),S)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?i(t):47===t||62===t||vL(t)?x(t):(e.consume(t),I)}function P(e){return 47===e||62===e||vL(e)?x(e):i(e)}function V(n){return 62===n?(e.consume(n),e.exit("htmlTextData"),e.exit("htmlText"),t):i(n)}function O(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return _L(t)?tN(e,B,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):B(t)}function B(t){return e.enter("htmlTextData"),r(t)}}};const VN={name:"labelEnd",resolveAll:function(e){let t=-1;const i=[];for(;++t=3&&(null===o||wL(o))?(e.exit("thematicBreak"),t(o)):i(o)}function r(t){return t===n?(e.consume(t),s++,r):(e.exit("thematicBreakSequence"),_L(t)?tN(e,o,"whitespace")(t):o(t))}}};const DN={continuation:{tokenize:function(e,t,i){const n=this;return n.containerState._closeFlow=void 0,e.check(iN,s,o);function s(i){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,tN(e,t,"listItemIndent",n.containerState.size+1)(i)}function o(i){return n.containerState.furtherBlankLines||!_L(i)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,r(i)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(HN,t,r)(i))}function r(s){return n.containerState._closeFlow=!0,n.interrupt=void 0,tN(e,e.attempt(DN,t,i),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,i){const n=this,s=n.events[n.events.length-1];let o=s&&"linePrefix"===s[1].type?s[2].sliceSerialize(s[1],!0).length:0,r=0;return function(t){const s=n.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===s?!n.containerState.marker||t===n.containerState.marker:fL(t)){if(n.containerState.type||(n.containerState.type=s,e.enter(s,{_container:!0})),"listUnordered"===s)return e.enter("listItemPrefix"),42===t||45===t?e.check(NN,i,l)(t):l(t);if(!n.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(t)}return i(t)};function a(t){return fL(t)&&++r<10?(e.consume(t),a):(!n.interrupt||r<2)&&(n.containerState.marker?t===n.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):i(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||t,e.check(iN,n.interrupt?i:c,e.attempt(zN,d,u))}function c(e){return n.containerState.initialBlankLine=!0,o++,d(e)}function u(t){return _L(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):i(t)}function d(i){return n.containerState.size=o+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(i)}}},zN={partial:!0,tokenize:function(e,t,i){const n=this;return tN(e,function(e){const s=n.events[n.events.length-1];return!_L(e)&&s&&"listItemPrefixWhitespace"===s[1].type?t(e):i(e)},"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},HN={partial:!0,tokenize:function(e,t,i){const n=this;return tN(e,function(e){const s=n.events[n.events.length-1];return s&&"listItemIndent"===s[1].type&&s[2].sliceSerialize(s[1],!0).length===n.containerState.size?t(e):i(e)},"listItemIndent",n.containerState.size+1)}};const qN={name:"setextUnderline",resolveTo:function(e,t){let i,n,s,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){i=o;break}"paragraph"===e[o][1].type&&(n=o)}else"content"===e[o][1].type&&e.splice(o,1),s||"definition"!==e[o][1].type||(s=o);const r={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};e[n][1].type="setextHeadingText",s?(e.splice(n,0,["enter",r,t]),e.splice(s+1,0,["exit",e[i][1],t]),e[i][1].end={...e[s][1].end}):e[i][1]=r;return e.push(["exit",r,t]),e},tokenize:function(e,t,i){const n=this;let s;return function(t){let r,a=n.events.length;for(;a--;)if("lineEnding"!==n.events[a][1].type&&"linePrefix"!==n.events[a][1].type&&"content"!==n.events[a][1].type){r="paragraph"===n.events[a][1].type;break}if(!n.parser.lazy[n.now().line]&&(n.interrupt||r))return e.enter("setextHeadingLine"),s=t,function(t){return e.enter("setextHeadingLineSequence"),o(t)}(t);return i(t)};function o(t){return t===s?(e.consume(t),o):(e.exit("setextHeadingLineSequence"),_L(t)?tN(e,r,"lineSuffix")(t):r(t))}function r(n){return null===n||wL(n)?(e.exit("setextHeadingLine"),t(n)):i(n)}}};const UN={tokenize:function(e,t,i){const n=this;return tN(e,function(e){const s=n.events[n.events.length-1];return s&&"gfmFootnoteDefinitionIndent"===s[1].type&&4===s[2].sliceSerialize(s[1],!0).length?t(e):i(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function WN(e,t,i){const n=this;let s=n.events.length;const o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let r;for(;s--;){const e=n.events[s][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(s){if(!r||!r._balanced)return i(s);const a=GL(n.sliceSerialize({start:r.end,end:n.now()}));if(94!==a.codePointAt(0)||!o.includes(a.slice(1)))return i(s);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),t(s)}}function $N(e,t){let i=e.length;for(;i--;)if("labelImage"===e[i][1].type&&"enter"===e[i][0]){e[i][1];break}e[i+1][1].type="data",e[i+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},e[i+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[i+3][1].end),end:Object.assign({},e[i+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},r={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},a=[e[i+1],e[i+2],["enter",n,t],e[i+3],e[i+4],["enter",s,t],["exit",s,t],["enter",o,t],["enter",r,t],["exit",r,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",n,t]];return e.splice(i,e.length-i+1,...a),e}function jN(e,t,i){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let o,r=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),a};function a(t){return 94!==t?i(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(a){if(r>999||93===a&&!o||null===a||91===a||vL(a))return i(a);if(93===a){e.exit("chunkString");const o=e.exit("gfmFootnoteCallString");return s.includes(GL(n.sliceSerialize(o)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):i(a)}return vL(a)||(o=!0),r++,e.consume(a),92===a?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),r++,l):l(t)}}function GN(e,t,i){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let o,r,a=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):i(t)}function c(t){if(a>999||93===t&&!r||null===t||91===t||vL(t))return i(t);if(93===t){e.exit("chunkString");const i=e.exit("gfmFootnoteDefinitionLabelString");return o=GL(n.sliceSerialize(i)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return vL(t)||(r=!0),a++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),a++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s.includes(o)||s.push(o),tN(e,h,"gfmFootnoteDefinitionWhitespace")):i(t)}function h(e){return t(e)}}function KN(e,t,i){return e.check(iN,t,e.attempt(UN,t,i))}function JN(e){e.exit("gfmFootnoteDefinition")}function QN(e){let t=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:function(e,i,n){const s=this.previous,o=this.events;let r=0;return function(t){if(126===s&&"characterEscape"!==o[o.length-1][1].type)return n(t);return e.enter("strikethroughSequenceTemporary"),a(t)};function a(o){const l=EM(s);if(126===o)return r>1?n(o):(e.consume(o),r++,a);if(r<2&&!t)return n(o);const c=e.exit("strikethroughSequenceTemporary"),u=EM(o);return c._open=!u||2===u&&Boolean(l),c._close=!l||2===l&&Boolean(u),i(o)}},resolveAll:function(e,t){let i=-1;for(;++i0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let n=i.pop();for(;n;){for(const t of n)e.push(t);n=i.pop()}this.map.length=0}}function ZN(e,t){let i=!1;const n=[];for(;t-1;){const e=n.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const s=t>-1?n.events[t][1].type:null,o="tableHead"===s||"tableRow"===s?_:a;if(o===_&&n.parser.lazy[n.now().line])return i(e);return o(e)};function a(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return s=!0,r+=1,l(e)}(t)}function l(t){return null===t?i(t):wL(t)?r>1?(r=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):i(t):_L(t)?tN(e,l,"whitespace")(t):(r+=1,s&&(s=!1,o+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),s=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||vL(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return n.interrupt=!1,n.parser.lazy[n.now().line]?i(t):(e.enter("tableDelimiterRow"),s=!1,_L(t)?tN(e,h,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t))}function h(t){return 45===t||58===t?g(t):124===t?(s=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):v(t)}function m(t){return _L(t)?tN(e,g,"whitespace")(t):g(t)}function g(t){return 58===t?(r+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(r+=1,f(t)):null===t||wL(t)?w(t):v(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),p(t)):v(t)}function p(t){return 45===t?(e.consume(t),p):58===t?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(t))}function b(t){return _L(t)?tN(e,w,"whitespace")(t):w(t)}function w(i){return 124===i?h(i):(null===i||wL(i))&&s&&o===r?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(i)):v(i)}function v(e){return i(e)}function _(t){return e.enter("tableRow"),y(t)}function y(i){return 124===i?(e.enter("tableCellDivider"),e.consume(i),e.exit("tableCellDivider"),y):null===i||wL(i)?(e.exit("tableRow"),t(i)):_L(i)?tN(e,y,"whitespace")(i):(e.enter("data"),k(i))}function k(t){return null===t||124===t||vL(t)?(e.exit("data"),y(t)):(e.consume(t),92===t?C:k)}function C(t){return 92===t||124===t?(e.consume(t),k):k(t)}}function eD(e,t){let i,n,s,o=-1,r=!0,a=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const h=new YN;for(;++oi[2]+1){const t=i[2]+1,n=i[3]-i[2]-1;e.add(t,n,[])}}e.add(i[3]+1,0,[["exit",r,t]])}return void 0!==s&&(o.end=Object.assign({},nD(t.events,s)),e.add(s,0,[["exit",o,t]]),o=void 0),o}function iD(e,t,i,n,s){const o=[],r=nD(t.events,i);s&&(s.end=Object.assign({},r),o.push(["exit",s,t])),n.end=Object.assign({},r),o.push(["exit",n,t]),e.add(i+1,0,o)}function nD(e,t){const i=e[t],n="enter"===i[0]?"start":"end";return i[1][n]}const sD={name:"tasklistCheck",tokenize:function(e,t,i){const n=this;return function(t){if(null!==n.previous||!n._gfmTasklistFirstContentOfListItem)return i(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),s};function s(t){return vL(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),o):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),o):i(t)}function o(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),r):i(t)}function r(n){return wL(n)?t(n):_L(n)?e.check({tokenize:oD},t,i)(n):i(n)}}};function oD(e,t,i){return tN(e,function(e){return null===e?i(e):t(e)},"whitespace")}const rD={};function aD(e){const t=e||rD,i=this.data(),n=i.micromarkExtensions||(i.micromarkExtensions=[]),s=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),o=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);n.push(function(e){return OF([{text:UF},{document:{91:{name:"gfmFootnoteDefinition",tokenize:GN,continuation:{tokenize:KN},exit:JN}},text:{91:{name:"gfmFootnoteCall",tokenize:jN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:WN,resolveTo:$N}}},QN(e),{flow:{null:{name:"table",tokenize:XN,resolveAll:eD}}},{text:{91:sD}}])}(t)),s.push([{transforms:[UL],enter:{literalAutolink:FL,literalAutolinkEmail:NL,literalAutolinkHttp:NL,literalAutolinkWww:NL},exit:{literalAutolink:qL,literalAutolinkEmail:HL,literalAutolinkHttp:DL,literalAutolinkWww:zL}},{enter:{gfmFootnoteCallString:KL,gfmFootnoteCall:JL,gfmFootnoteDefinitionLabelString:QL,gfmFootnoteDefinition:YL},exit:{gfmFootnoteCallString:ZL,gfmFootnoteCall:XL,gfmFootnoteDefinitionLabelString:eM,gfmFootnoteDefinition:tM}},{canContainEols:["delete"],enter:{strikethrough:aM},exit:{strikethrough:lM}},{enter:{table:wF,tableData:kF,tableHeader:kF,tableRow:_F},exit:{codeText:CF,table:vF,tableData:yF,tableHeader:yF,tableRow:yF}},{exit:{taskListCheckValueChecked:TF,taskListCheckValueUnchecked:TF,paragraph:EF}}]),o.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:LL,notInConstruct:ML},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:LL,notInConstruct:ML},{character:":",before:"[ps]",after:"\\/",inConstruct:LL,notInConstruct:ML}]},nM(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:rM}],handlers:{delete:cM}},AF(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SF}}]}}(t))}const lD={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(i){if(null===i)return void e.consume(i);return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),tN(e,t,"linePrefix")},function(t){return e.enter("paragraph"),n(t)});let i;return t;function n(t){const n=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=n),i=n,s(t)}function s(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):wL(t)?(e.consume(t),e.exit("chunkText"),n):(e.consume(t),s)}}};const cD={tokenize:function(e){const t=this,i=[];let n,s,o,r=0;return a;function a(n){if(ro))return;const i=t.events.length;let s,a,l=i;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(s){a=t.events[l][1].end;break}s=!0}for(b(r),e=i;en;){const n=i[s];t.containerState=n[1],n[0].exit.call(t,e)}i.length=n}function w(){n.write([null]),s=void 0,n=void 0,t.containerState._closeFlow=void 0}}},uD={tokenize:function(e,t,i){return tN(e,e.attempt(this.parser.constructs.document,t,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};const dD={tokenize:function(e){const t=this,i=e.attempt(iN,function(n){if(null===n)return void e.consume(n);return e.enter("lineEndingBlank"),e.consume(n),e.exit("lineEndingBlank"),t.currentConstruct=void 0,i},e.attempt(this.parser.constructs.flowInitial,n,tN(e,e.attempt(this.parser.constructs.flow,n,e.attempt(fN,n)),"linePrefix")));return i;function n(n){if(null!==n)return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),t.currentConstruct=void 0,i;e.consume(n)}}};const hD={resolveAll:pD()},mD=fD("string"),gD=fD("text");function fD(e){return{resolveAll:pD("text"===e?bD:void 0),tokenize:function(t){const i=this,n=this.parser.constructs[e],s=t.attempt(n,o,r);return o;function o(e){return l(e)?s(e):r(e)}function r(e){if(null!==e)return t.enter("data"),t.consume(e),a;t.consume(e)}function a(e){return l(e)?(t.exit("data"),s(e)):(t.consume(e),a)}function l(e){if(null===e)return!0;const t=n[e];let s=-1;if(t)for(;++s-1){const e=r[0];"string"==typeof e?r[0]=e.slice(n):r.shift()}o>0&&r.push(e[s].slice(0,o))}return r}(r,e)}function h(){const{_bufferIndex:e,_index:t,line:i,column:s,offset:o}=n;return{_bufferIndex:e,_index:t,line:i,column:s,offset:o}}function m(){let e;for(;n._index0){const e=o.tokenStack[o.tokenStack.length-1];(e[1]||RD).call(o,void 0,e[0])}for(n.position={start:PD(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:PD(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d1:t}const FD=DD("end"),ND=DD("start");function DD(e){return function(t){const i=t&&t.position&&t.position[e]||{};if("number"==typeof i.line&&i.line>0&&"number"==typeof i.column&&i.column>0)return{line:i.line,column:i.column,offset:"number"==typeof i.offset&&i.offset>-1?i.offset:void 0}}}function zD(e){const t=ND(e),i=FD(e);if(t&&i)return{start:t,end:i}}function HD(e){const t=String(e),i=/\r?\n|\r/g;let n=i.exec(t),s=0;const o=[];for(;n;)o.push(qD(t.slice(s,n.index),s>0,!0),n[0]),s=n.index+n[0].length,n=i.exec(t);return o.push(qD(t.slice(s),s>0,!1)),o.join("")}function qD(e,t,i){let n=0,s=e.length;if(t){let t=e.codePointAt(n);for(;9===t||32===t;)n++,t=e.codePointAt(n)}if(i){let t=e.codePointAt(s-1);for(;9===t||32===t;)s--,t=e.codePointAt(s-1)}return s>n?e.slice(n,s):""}const UD={blockquote:function(e,t){const i={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,i),e.applyData(t,i)},break:function(e,t){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,i),[e.applyData(t,i),{type:"text",value:"\n"}]},code:function(e,t){const i=t.value?t.value+"\n":"",n={};t.lang&&(n.className=["language-"+t.lang]);let s={type:"element",tagName:"code",properties:n,children:[{type:"text",value:i}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s},delete:function(e,t){const i={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},emphasis:function(e,t){const i={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},footnoteReference:function(e,t){const i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),s=QF(n.toLowerCase()),o=e.footnoteOrder.indexOf(n);let r,a=e.footnoteCounts.get(n);void 0===a?(a=0,e.footnoteOrder.push(n),r=e.footnoteOrder.length):r=o+1,a+=1,e.footnoteCounts.set(n,a);const l={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+s,id:i+"fnref-"+s+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const i={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},html:function(e,t){if(e.options.allowDangerousHtml){const i={type:"raw",value:t.value};return e.patch(t,i),e.applyData(t,i)}},imageReference:function(e,t){const i=String(t.identifier).toUpperCase(),n=e.definitionById.get(i);if(!n)return LD(e,t);const s={src:QF(n.url||""),alt:t.alt};null!==n.title&&void 0!==n.title&&(s.title=n.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){const i={src:QF(t.url)};null!==t.alt&&void 0!==t.alt&&(i.alt=t.alt),null!==t.title&&void 0!==t.title&&(i.title=t.title);const n={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,n),e.applyData(t,n)},inlineCode:function(e,t){const i={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,i);const n={type:"element",tagName:"code",properties:{},children:[i]};return e.patch(t,n),e.applyData(t,n)},linkReference:function(e,t){const i=String(t.identifier).toUpperCase(),n=e.definitionById.get(i);if(!n)return LD(e,t);const s={href:QF(n.url||"")};null!==n.title&&void 0!==n.title&&(s.title=n.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){const i={href:QF(t.url)};null!==t.title&&void 0!==t.title&&(i.title=t.title);const n={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},listItem:function(e,t,i){const n=e.all(t),s=i?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const i=e.children;let n=-1;for(;!t&&++n0&&i.children.unshift({type:"text",value:" "}),i.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a0){const n={type:"element",tagName:"tbody",properties:{},children:e.wrap(i,!0)},o=ND(t.children[1]),r=FD(t.children[t.children.length-1]);o&&r&&(n.position={start:o,end:r}),s.push(n)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){const i={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},tableRow:function(e,t,i){const n=i?i.children:void 0,s=0===(n?n.indexOf(t):1)?"th":"td",o=i&&"table"===i.type?i.align:void 0,r=o?o.length:t.children.length;let a=-1;const l=[];for(;++a((e,t)=>{const i=(t,i)=>(e.set(i,t),t),n=s=>{if(e.has(s))return e.get(s);const[o,r]=t[s];switch(o){case 0:case-1:return i(r,s);case 1:{const e=i([],s);for(const t of r)e.push(n(t));return e}case 2:{const e=i({},s);for(const[t,i]of r)e[n(t)]=n(i);return e}case 3:return i(new Date(r),s);case 4:{const{source:e,flags:t}=r;return i(new RegExp(e,t),s)}case 5:{const e=i(new Map,s);for(const[t,i]of r)e.set(n(t),n(i));return e}case 6:{const e=i(new Set,s);for(const t of r)e.add(n(t));return e}case 7:{const{name:e,message:t}=r;return i(new $D[e](t),s)}case 8:return i(BigInt(r),s);case"BigInt":return i(Object(BigInt(r)),s);case"ArrayBuffer":return i(new Uint8Array(r).buffer,r);case"DataView":{const{buffer:e}=new Uint8Array(r);return i(new DataView(e),r)}}return i(new $D[o](r),s)};return n})(new Map,e)(0),GD="",{toString:KD}={},{keys:JD}=Object,QD=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const i=KD.call(e).slice(8,-1);switch(i){case"Array":return[1,GD];case"Object":return[2,GD];case"Date":return[3,GD];case"RegExp":return[4,GD];case"Map":return[5,GD];case"Set":return[6,GD];case"DataView":return[1,i]}return i.includes("Array")?[1,i]:i.includes("Error")?[7,i]:[2,i]},YD=([e,t])=>0===e&&("function"===t||"symbol"===t),ZD=(e,{json:t,lossy:i}={})=>{const n=[];return((e,t,i,n)=>{const s=(e,t)=>{const s=n.push(e)-1;return i.set(t,s),s},o=n=>{if(i.has(n))return i.get(n);let[r,a]=QD(n);switch(r){case 0:{let t=n;switch(a){case"bigint":r=8,t=n.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+a);t=null;break;case"undefined":return s([-1],n)}return s([r,t],n)}case 1:{if(a){let e=n;return"DataView"===a?e=new Uint8Array(n.buffer):"ArrayBuffer"===a&&(e=new Uint8Array(n)),s([a,[...e]],n)}const e=[],t=s([r,e],n);for(const t of n)e.push(o(t));return t}case 2:{if(a)switch(a){case"BigInt":return s([a,n.toString()],n);case"Boolean":case"Number":case"String":return s([a,n.valueOf()],n)}if(t&&"toJSON"in n)return o(n.toJSON());const i=[],l=s([r,i],n);for(const t of JD(n))!e&&YD(QD(n[t]))||i.push([o(t),o(n[t])]);return l}case 3:return s([r,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return s([r,{source:e,flags:t}],n)}case 5:{const t=[],i=s([r,t],n);for(const[i,s]of n)(e||!YD(QD(i))&&!YD(QD(s)))&&t.push([o(i),o(s)]);return i}case 6:{const t=[],i=s([r,t],n);for(const i of n)!e&&YD(QD(i))||t.push(o(i));return i}}const{message:l}=n;return s([r,{name:a,message:l}],n)};return o})(!(t||i),!!t,new Map,n)(e),n};var XD="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?jD(ZD(e,t)):structuredClone(e):(e,t)=>jD(ZD(e,t));function ez(e,t){const i=[{type:"text",value:"↩"}];return t>1&&i.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),i}function tz(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const iz={}.hasOwnProperty,nz={};function sz(e,t){e.position&&(t.position=zD(e))}function oz(e,t){let i=t;if(e&&e.data){const t=e.data.hName,n=e.data.hChildren,s=e.data.hProperties;if("string"==typeof t)if("element"===i.type)i.tagName=t;else{i={type:"element",tagName:t,properties:{},children:"children"in i?i.children:[i]}}"element"===i.type&&s&&Object.assign(i.properties,XD(s)),"children"in i&&i.children&&null!=n&&(i.children=n)}return i}function rz(e,t){const i=t.data||{},n=!("value"in t)||iz.call(i,"hProperties")||iz.call(i,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,n),e.applyData(t,n)}function az(e,t){const i=[];let n=-1;for(t&&i.push({type:"text",value:"\n"});++n0&&i.push({type:"text",value:"\n"}),i}function lz(e){let t=0,i=e.charCodeAt(t);for(;9===i||32===i;)t++,i=e.charCodeAt(t);return e.slice(t)}function cz(e,t){const i=function(e,t){const i=t||nz,n=new Map,s=new Map,o=new Map,r={...UD,...i.handlers},a={all:function(e){const t=[];if("children"in e){const i=e.children;let n=-1;for(;++n0&&d.push({type:"text",value:" "});let e="string"==typeof i?i:i(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof n?n:n(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const m=o[o.length-1];if(m&&"element"===m.type&&"p"===m.tagName){const e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...d)}else o.push(...d);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(o,!0)};e.patch(s,g),a.push(g)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...XD(r),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(i),o=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return s&&o.children.push({type:"text",value:"\n"},s),o}function uz(e,t){return e&&"run"in e?async function(i,n){const s=cz(i,{file:n,...t});await e.run(s,n)}:function(i,n){return cz(i,{file:n,...e||t})}}function dz(){return{type:"break"}}function hz(){return function(e){!function(e){OL(e,[/\r?\n|\r/g,dz])}(e)}}class mz{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}function gz(e,t){const i={},n={};for(const t of e)Object.assign(i,t.property),Object.assign(n,t.normal);return new mz(i,n,t)}function fz(e){return e.toLowerCase()}mz.prototype.normal={},mz.prototype.property={},mz.prototype.space=void 0;class pz{constructor(e,t){this.attribute=t,this.property=e}}pz.prototype.attribute="",pz.prototype.booleanish=!1,pz.prototype.boolean=!1,pz.prototype.commaOrSpaceSeparated=!1,pz.prototype.commaSeparated=!1,pz.prototype.defined=!1,pz.prototype.mustUseProperty=!1,pz.prototype.number=!1,pz.prototype.overloadedBoolean=!1,pz.prototype.property="",pz.prototype.spaceSeparated=!1,pz.prototype.space=void 0;let bz=0;const wz=Az(),vz=Az(),_z=Az(),yz=Az(),kz=Az(),Cz=Az(),xz=Az();function Az(){return 2**++bz}var Tz=Object.freeze({__proto__:null,boolean:wz,booleanish:vz,commaOrSpaceSeparated:xz,commaSeparated:Cz,number:yz,overloadedBoolean:_z,spaceSeparated:kz});const Ez=Object.keys(Tz);class Sz extends pz{constructor(e,t,i,n){let s=-1;if(super(e,t),Iz(this,"space",n),"number"==typeof i)for(;++s"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Oz(e,t){return t in e?e[t]:t}function Rz(e,t){return Oz(e,t.toLowerCase())}const Bz=Pz({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Cz,acceptCharset:kz,accessKey:kz,action:null,allow:null,allowFullScreen:wz,allowPaymentRequest:wz,allowUserMedia:wz,alt:null,as:null,async:wz,autoCapitalize:null,autoComplete:kz,autoFocus:wz,autoPlay:wz,blocking:kz,capture:null,charSet:null,checked:wz,cite:null,className:kz,cols:yz,colSpan:null,content:null,contentEditable:vz,controls:wz,controlsList:kz,coords:yz|Cz,crossOrigin:null,data:null,dateTime:null,decoding:null,default:wz,defer:wz,dir:null,dirName:null,disabled:wz,download:_z,draggable:vz,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:wz,formTarget:null,headers:kz,height:yz,hidden:_z,high:yz,href:null,hrefLang:null,htmlFor:kz,httpEquiv:kz,id:null,imageSizes:null,imageSrcSet:null,inert:wz,inputMode:null,integrity:null,is:null,isMap:wz,itemId:null,itemProp:kz,itemRef:kz,itemScope:wz,itemType:kz,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:wz,low:yz,manifest:null,max:null,maxLength:yz,media:null,method:null,min:null,minLength:yz,multiple:wz,muted:wz,name:null,nonce:null,noModule:wz,noValidate:wz,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:wz,optimum:yz,pattern:null,ping:kz,placeholder:null,playsInline:wz,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:wz,referrerPolicy:null,rel:kz,required:wz,reversed:wz,rows:yz,rowSpan:yz,sandbox:kz,scope:null,scoped:wz,seamless:wz,selected:wz,shadowRootClonable:wz,shadowRootDelegatesFocus:wz,shadowRootMode:null,shape:null,size:yz,sizes:null,slot:null,span:yz,spellCheck:vz,src:null,srcDoc:null,srcLang:null,srcSet:null,start:yz,step:null,style:null,tabIndex:yz,target:null,title:null,translate:null,type:null,typeMustMatch:wz,useMap:null,value:vz,width:yz,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kz,axis:null,background:null,bgColor:null,border:yz,borderColor:null,bottomMargin:yz,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:wz,declare:wz,event:null,face:null,frame:null,frameBorder:null,hSpace:yz,leftMargin:yz,link:null,longDesc:null,lowSrc:null,marginHeight:yz,marginWidth:yz,noResize:wz,noHref:wz,noShade:wz,noWrap:wz,object:null,profile:null,prompt:null,rev:null,rightMargin:yz,rules:null,scheme:null,scrolling:vz,standby:null,summary:null,text:null,topMargin:yz,valueType:null,version:null,vAlign:null,vLink:null,vSpace:yz,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:wz,disableRemotePlayback:wz,prefix:null,property:null,results:yz,security:null,unselectable:null},space:"html",transform:Rz}),Lz=Pz({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:xz,accentHeight:yz,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:yz,amplitude:yz,arabicForm:null,ascent:yz,attributeName:null,attributeType:null,azimuth:yz,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:yz,by:null,calcMode:null,capHeight:yz,className:kz,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:yz,diffuseConstant:yz,direction:null,display:null,dur:null,divisor:yz,dominantBaseline:null,download:wz,dx:null,dy:null,edgeMode:null,editable:null,elevation:yz,enableBackground:null,end:null,event:null,exponent:yz,externalResourcesRequired:null,fill:null,fillOpacity:yz,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Cz,g2:Cz,glyphName:Cz,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:yz,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:yz,horizOriginX:yz,horizOriginY:yz,id:null,ideographic:yz,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:yz,k:yz,k1:yz,k2:yz,k3:yz,k4:yz,kernelMatrix:xz,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:yz,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:yz,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:yz,overlineThickness:yz,paintOrder:null,panose1:null,path:null,pathLength:yz,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kz,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:yz,pointsAtY:yz,pointsAtZ:yz,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:xz,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:xz,rev:xz,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:xz,requiredFeatures:xz,requiredFonts:xz,requiredFormats:xz,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:yz,specularExponent:yz,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:yz,strikethroughThickness:yz,string:null,stroke:null,strokeDashArray:xz,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:yz,strokeOpacity:yz,strokeWidth:null,style:null,surfaceScale:yz,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:xz,tabIndex:yz,tableValues:null,target:null,targetX:yz,targetY:yz,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:xz,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:yz,underlineThickness:yz,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:yz,values:null,vAlphabetic:yz,vMathematical:yz,vectorEffect:null,vHanging:yz,vIdeographic:yz,version:null,vertAdvY:yz,vertOriginX:yz,vertOriginY:yz,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:yz,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Oz}),Mz=Pz({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Fz=Pz({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Rz}),Nz=Pz({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Dz=/[A-Z]/g,zz=/-[a-z]/g,Hz=/^data[-\w.:]+$/i;function qz(e,t){const i=fz(t);let n=t,s=pz;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&"data"===i.slice(0,4)&&Hz.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(zz,Wz);n="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!zz.test(e)){let i=e.replace(Dz,Uz);"-"!==i.charAt(0)&&(i="-"+i),t="data"+i}}s=Sz}return new s(n,t)}function Uz(e){return"-"+e.toLowerCase()}function Wz(e){return e.charAt(1).toUpperCase()}const $z=gz([Vz,Bz,Mz,Fz,Nz],"html"),jz=gz([Vz,Lz,Mz,Fz,Nz],"svg"),Gz="http://www.w3.org/1999/xhtml",Kz="http://www.w3.org/2000/svg",Jz={}.hasOwnProperty;function Qz(e,t){const i=function(e,t){switch(e.type){case"root":return function(e,t){const i=e.children||[];let n,s=0===i.length,o=-1;for(;++o";const t=document.createElement("template");return t.content.append(e),t.innerHTML}const eH=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],tH=/["&'<>`]/g,iH=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,nH=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,sH=/[|\\{}()[\]^$+*?.]/g,oH=new WeakMap;function rH(e,t){return e=e.replace(t.subset?function(e){let t=oH.get(e);t||(t=function(e){const t=[];let i=-1;for(;++i",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},dH=["cent","copy","divide","gt","lt","not","para","times"],hH={}.hasOwnProperty,mH={};let gH;for(gH in uH)hH.call(uH,gH)&&(mH[uH[gH]]=gH);const fH=/[^\dA-Za-z]/;function pH(e,t,i){let n,s=function(e,t,i){const n=""+e.toString(16).toUpperCase();return i&&t&&!aH.test(String.fromCharCode(t))?n:n+";"}(e,t,i.omitOptionalSemicolons);if((i.useNamedReferences||i.useShortestReferences)&&(n=function(e,t,i,n){const s=String.fromCharCode(e);if(hH.call(mH,s)){const e=mH[s],o="&"+e;return i&&cH.includes(e)&&!dH.includes(e)&&(!n||t&&61!==t&&fH.test(String.fromCharCode(t)))?o:o+";"}return""}(e,t,i.omitOptionalSemicolons,i.attribute)),(i.useShortestReferences||!n)&&i.useShortestReferences){const n=function(e,t,i){const n=""+String(e);return i&&t&&!lH.test(String.fromCharCode(t))?n:n+";"}(e,t,i.omitOptionalSemicolons);n.length|^->||--!>|"],_H=["<",">"];function yH(e){const t=[],i=String(e||"");let n=i.indexOf(","),s=0,o=!1;for(;!o;){-1===n&&(n=i.length,o=!0);const e=i.slice(s,n).trim();!e&&o||t.push(e),s=n+1,n=i.indexOf(",",s)}return t}function kH(e,t){const i=t||{};return(""===e[e.length-1]?[...e,""]:e).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()}function CH(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function xH(e){return e.join(" ").trim()}const AH=/[ \t\n\f\r]/g;function TH(e){return"object"==typeof e?"text"===e.type&&EH(e.value):EH(e)}function EH(e){return""===e.replace(AH,"")}const SH=VH(1),IH=VH(-1),PH=[];function VH(e){return function(t,i,n){const s=t?t.children:PH;let o=(i||0)+e,r=s[o];if(!n)for(;r&&TH(r);)o+=e,r=s[o];return r}}const OH={}.hasOwnProperty;function RH(e){return function(t,i,n){return OH.call(e,t.tagName)&&e[t.tagName](t,i,n)}}const BH=RH({body:function(e,t,i){const n=SH(i,t);return!n||"comment"!==n.type},caption:LH,colgroup:LH,dd:function(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&("dt"===n.tagName||"dd"===n.tagName)},dt:function(e,t,i){const n=SH(i,t);return Boolean(n&&"element"===n.type&&("dt"===n.tagName||"dd"===n.tagName))},head:LH,html:function(e,t,i){const n=SH(i,t);return!n||"comment"!==n.type},li:function(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&"li"===n.tagName},optgroup:function(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&"optgroup"===n.tagName},option:function(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&("option"===n.tagName||"optgroup"===n.tagName)},p:function(e,t,i){const n=SH(i,t);return n?"element"===n.type&&("address"===n.tagName||"article"===n.tagName||"aside"===n.tagName||"blockquote"===n.tagName||"details"===n.tagName||"div"===n.tagName||"dl"===n.tagName||"fieldset"===n.tagName||"figcaption"===n.tagName||"figure"===n.tagName||"footer"===n.tagName||"form"===n.tagName||"h1"===n.tagName||"h2"===n.tagName||"h3"===n.tagName||"h4"===n.tagName||"h5"===n.tagName||"h6"===n.tagName||"header"===n.tagName||"hgroup"===n.tagName||"hr"===n.tagName||"main"===n.tagName||"menu"===n.tagName||"nav"===n.tagName||"ol"===n.tagName||"p"===n.tagName||"pre"===n.tagName||"section"===n.tagName||"table"===n.tagName||"ul"===n.tagName):!i||!("element"===i.type&&("a"===i.tagName||"audio"===i.tagName||"del"===i.tagName||"ins"===i.tagName||"map"===i.tagName||"noscript"===i.tagName||"video"===i.tagName))},rp:MH,rt:MH,tbody:function(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&("tbody"===n.tagName||"tfoot"===n.tagName)},td:FH,tfoot:function(e,t,i){return!SH(i,t)},th:FH,thead:function(e,t,i){const n=SH(i,t);return Boolean(n&&"element"===n.type&&("tbody"===n.tagName||"tfoot"===n.tagName))},tr:function(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&"tr"===n.tagName}});function LH(e,t,i){const n=SH(i,t,!0);return!n||"comment"!==n.type&&!("text"===n.type&&TH(n.value.charAt(0)))}function MH(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&("rp"===n.tagName||"rt"===n.tagName)}function FH(e,t,i){const n=SH(i,t);return!n||"element"===n.type&&("td"===n.tagName||"th"===n.tagName)}const NH=RH({body:function(e){const t=SH(e,-1,!0);return!(t&&("comment"===t.type||"text"===t.type&&TH(t.value.charAt(0))||"element"===t.type&&("meta"===t.tagName||"link"===t.tagName||"script"===t.tagName||"style"===t.tagName||"template"===t.tagName)))},colgroup:function(e,t,i){const n=IH(i,t),s=SH(e,-1,!0);if(i&&n&&"element"===n.type&&"colgroup"===n.tagName&&BH(n,i.children.indexOf(n),i))return!1;return Boolean(s&&"element"===s.type&&"col"===s.tagName)},head:function(e){const t=new Set;for(const i of e.children)if("element"===i.type&&("base"===i.tagName||"title"===i.tagName)){if(t.has(i.tagName))return!1;t.add(i.tagName)}const i=e.children[0];return!i||"element"===i.type},html:function(e){const t=SH(e,-1);return!t||"comment"!==t.type},tbody:function(e,t,i){const n=IH(i,t),s=SH(e,-1);if(i&&n&&"element"===n.type&&("thead"===n.tagName||"tbody"===n.tagName)&&BH(n,i.children.indexOf(n),i))return!1;return Boolean(s&&"element"===s.type&&"tr"===s.tagName)}});const DH={name:[["\t\n\f\r &/=>".split(""),"\t\n\f\r \"&'/=>`".split("")],["\0\t\n\f\r \"&'/<=>".split(""),"\0\t\n\f\r \"&'/<=>`".split("")]],unquoted:[["\t\n\f\r &>".split(""),"\0\t\n\f\r \"&'<=>`".split("")],["\0\t\n\f\r \"&'<=>`".split(""),"\0\t\n\f\r \"&'<=>`".split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function zH(e,t,i){const n=qz(e.schema,t),s=e.settings.allowParseErrors&&"html"===e.schema.space?0:1,o=e.settings.allowDangerousCharacters?0:1;let r,a=e.quote;if(!n.overloadedBoolean||i!==n.attribute&&""!==i?!n.boolean&&!n.overloadedBoolean||"string"==typeof i&&i!==n.attribute&&""!==i||(i=Boolean(i)):i=!0,null==i||!1===i||"number"==typeof i&&Number.isNaN(i))return"";const l=bH(n.attribute,Object.assign({},e.settings.characterReferences,{subset:DH.name[s][o]}));return!0===i?l:(i=Array.isArray(i)?(n.commaSeparated?kH:xH)(i,{padLeft:!e.settings.tightCommaSeparatedLists}):String(i),e.settings.collapseEmptyAttributes&&!i?l:(e.settings.preferUnquoted&&(r=bH(i,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:DH.unquoted[s][o]}))),r!==i&&(e.settings.quoteSmart&&uL(i,a)>uL(i,e.alternative)&&(a=e.alternative),r=a+bH(i,Object.assign({},e.settings.characterReferences,{subset:("'"===a?DH.single:DH.double)[s][o],attribute:!0}))+a),l+(r?"="+r:r)))}const HH=["<","&"];function qH(e,t,i,n){return!i||"element"!==i.type||"script"!==i.tagName&&"style"!==i.tagName?bH(e.value,Object.assign({},n.settings.characterReferences,{subset:HH})):e.value}const UH=gM("type",{invalid:function(e){throw new Error("Expected node, not `"+e+"`")},unknown:function(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")},handlers:{comment:function(e,t,i,n){return n.settings.bogusComments?""+bH(e.value,Object.assign({},n.settings.characterReferences,{subset:vH}))+">":"\x3c!--"+e.value.replace(wH,function(e){return bH(e,Object.assign({},n.settings.characterReferences,{subset:_H}))})+"--\x3e"},doctype:function(e,t,i,n){return""},element:function(e,t,i,n){const s=n.schema,o="svg"!==s.space&&n.settings.omitOptionalTags;let r="svg"===s.space?n.settings.closeEmptyElements:n.settings.voids.includes(e.tagName.toLowerCase());const a=[];let l;"html"===s.space&&"svg"===e.tagName&&(n.schema=jz);const c=function(e,t){const i=[];let n,s=-1;if(t)for(n in t)if(null!==t[n]&&void 0!==t[n]){const s=zH(e,n,t[n]);s&&i.push(s)}for(;++s")),a.push(u),r||o&&BH(e,t,i)||a.push(""+e.tagName+">"),a.join("")},raw:function(e,t,i,n){return n.settings.allowDangerousHtml?e.value:qH(e,0,i,n)},root:function(e,t,i,n){return n.all(e)},text:qH}});const WH={},$H={},jH=[];function GH(e,t){const i=t||WH,n=i.quote||'"',s='"'===n?"'":'"';if('"'!==n&&"'"!==n)throw new Error("Invalid quote `"+n+"`, expected `'` or `\"`");return{one:KH,all:JH,settings:{omitOptionalTags:i.omitOptionalTags||!1,allowParseErrors:i.allowParseErrors||!1,allowDangerousCharacters:i.allowDangerousCharacters||!1,quoteSmart:i.quoteSmart||!1,preferUnquoted:i.preferUnquoted||!1,tightAttributes:i.tightAttributes||!1,upperDoctype:i.upperDoctype||!1,tightDoctype:i.tightDoctype||!1,bogusComments:i.bogusComments||!1,tightCommaSeparatedLists:i.tightCommaSeparatedLists||!1,tightSelfClosing:i.tightSelfClosing||!1,collapseEmptyAttributes:i.collapseEmptyAttributes||!1,allowDangerousHtml:i.allowDangerousHtml||!1,voids:i.voids||eH,characterReferences:i.characterReferences||$H,closeSelfClosing:i.closeSelfClosing||!1,closeEmptyElements:i.closeEmptyElements||!1},schema:"svg"===i.space?jz:$z,quote:n,alternative:s}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function KH(e,t,i){return UH(e,t,i,this)}function JH(e){const t=[],i=e&&e.children||jH;let n=-1;for(;++n","")}}function lq(){return e=>{PM(e,"element",e=>{"ul"!==e.tagName&&"ol"!==e.tagName&&"li"!==e.tagName||(e.children=e.children.filter(e=>"text"!==e.type||!!e.value.trim()),delete e.properties.className)})}}function cq(){return e=>{PM(e,["root","element"],e=>{if(!function(e){return("root"===e.type||"element"===e.type)&&e.children}(e))return;if(!e.children.some(e=>"raw"===e.type))return;const t=document.createElement("template");t.innerHTML=GH({type:"root",children:e.children},{allowDangerousHtml:!0}),e.children=Array.from(t.content.childNodes).map(e=>nq(e))})}}function uq(e){const t={...this.data("settings"),...e};this.parser=function(e){const i=!1===t.fragment?dq:hq;return nq(i(e))}}function dq(e){return(new DOMParser).parseFromString(e,"text/html")}function hq(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const mq=function(e,t,i,n,s){const o=gq(t);return!!bq(e)&&o.call(s,e,i,n)},gq=function(e){if(null==e)return pq;if("string"==typeof e)return function(e){return fq(t);function t(t){return t.tagName===e}}(e);if("object"==typeof e)return function(e){const t=[];let i=-1;for(;++il&&(l=e):e&&(void 0!==l&&l>-1&&a.push("\n".repeat(l)||" "),l=-1,a.push(e))}return a.join("")}function $q(e,t,i){return"element"===e.type?function(e,t,i){const n=Kq(e,i),s=e.children||[];let o,r,a=-1,l=[];if(qq(e))return l;Nq(e)||Hq(e)&&Lq(t,e,Hq)?r="\n":zq(e)?(o=2,r=2):Uq(e)&&(o=1,r=1);for(;++a0;){const e=t.codePointAt(i-1);if(void 0===e||10!==e&&13!==e)break;i--}return t.slice(0,i)}const Qq="language-";function Yq(e,t){const i=t.children;let n,s,o=-1;if("pre"===t.tagName)for(;++o1)for(;++tt&&"break"===e[i-1].type;)i--;return 0===t&&i===e.length?e:e.slice(t,i)}function sU(e,t){const i={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:nU(e.all(t))};return e.patch(t,i),i}function oU(e,t){const i=t.properties||{},n={type:"image",url:e.resolve(String(i.src||"")||null),title:i.title?String(i.title):null,alt:i.alt?String(i.alt):""};return e.patch(t,n),n}function rU(e,t){const i={type:"inlineCode",value:Wq(t)};return e.patch(t,i),i}function aU(e,t){const i=[],n=[],s=t||e.properties||{},o=lU(e),r=Math.min(Number.parseInt(String(s.size),10),0)||(s.multiple?4:1);let a=-1;for(;++a0?i:o,c=Math.min(l.length,r);for(a=-1;++a0&&(s.push(...t(o)),o=[]),s.push(i(e)))}return o.length>0&&(s.push(...t(o)),o=[]),s}function CU(e){const t=e.data&&e.data.hName;return t?mU({type:"element",tagName:t,properties:{},children:[]}):$M(e)}function xU(e){return XD({...e,children:[]})}function AU(e,t){const i=t.properties||{},n="video"===t.tagName?String(i.poster||""):"";let s=String(i.src||""),o=-1,r=!1,a=e.all(t);if(PM({type:"root",children:a},function(e){if("link"===e.type)return r=!0,IL}),r||vU(a))return a;for(;!s&&++o0){const n={type:"paragraph",children:i};return e.patch(t,n),n}}const EU=['"'];function SU(e,t){const i={type:"strong",children:e.all(t)};return e.patch(t,i),i}function IU(e,t){const i={type:"tableCell",children:e.all(t)};if(e.patch(t,i),t.properties){const e=t.properties.rowSpan,n=t.properties.colSpan;if(e||n){const t=i.data||(i.data={});e&&(t.hastUtilToMdastTemporaryRowSpan=e),n&&(t.hastUtilToMdastTemporaryColSpan=n)}}return i}function PU(){return{type:"tableCell",children:[]}}function VU(){return{type:"tableCell",children:[]}}function OU(){return{type:"tableRow",children:[]}}const RU={comment:function(e,t){const i={type:"html",value:"\x3c!--"+t.value+"--\x3e"};return e.patch(t,i),i},doctype:FU,root:function(e,t){let i=e.all(t);(e.options.document||vU(i))&&(i=_U(i));const n={type:"root",children:i};return e.patch(t,n),n},text:function(e,t){const i={type:"text",value:t.value};return e.patch(t,i),i}},BU={applet:FU,area:FU,basefont:FU,bgsound:FU,caption:FU,col:FU,colgroup:FU,command:FU,content:FU,datalist:FU,dialog:FU,element:FU,embed:FU,frame:FU,frameset:FU,isindex:FU,keygen:FU,link:FU,math:FU,menu:FU,menuitem:FU,meta:FU,nextid:FU,noembed:FU,noframes:FU,optgroup:FU,option:FU,param:FU,script:FU,shadow:FU,source:FU,spacer:FU,style:FU,svg:FU,template:FU,title:FU,track:FU,abbr:LU,acronym:LU,bdi:LU,bdo:LU,big:LU,blink:LU,button:LU,canvas:LU,cite:LU,data:LU,details:LU,dfn:LU,font:LU,ins:LU,label:LU,map:LU,marquee:LU,meter:LU,nobr:LU,noscript:LU,object:LU,output:LU,progress:LU,rb:LU,rbc:LU,rp:LU,rt:LU,rtc:LU,ruby:LU,slot:LU,small:LU,span:LU,sup:LU,sub:LU,tbody:LU,tfoot:LU,thead:LU,time:LU,address:MU,article:MU,aside:MU,body:MU,center:MU,div:MU,fieldset:MU,figcaption:MU,figure:MU,form:MU,footer:MU,header:MU,hgroup:MU,html:MU,legend:MU,main:MU,multicol:MU,nav:MU,picture:MU,section:MU,a:function(e,t){const i=t.properties||{},n=e.all(t),s={type:"link",url:e.resolve(String(i.href||"")||null),title:i.title?String(i.title):null,children:n};return e.patch(t,s),s},audio:AU,b:SU,base:function(e,t){e.baseFound||(e.frozenBaseUrl=String(t.properties&&t.properties.href||"")||void 0,e.baseFound=!0)},blockquote:function(e,t){const i={type:"blockquote",children:e.toFlow(e.all(t))};return e.patch(t,i),i},br:function(e,t){const i={type:"break"};return e.patch(t,i),i},code:rU,dir:bU,dl:function(e,t){const i=[],n=[];let s=-1;for(;++s0&&r.push({type:"listItem",spread:t.length>1,checked:null,children:t})}if(r.length>0){const i={type:"list",ordered:!1,start:null,spread:Xq(r),children:r};return e.patch(t,i),i}},dt:gU,dd:gU,del:Zq,em:iU,h1:sU,h2:sU,h3:sU,h4:sU,h5:sU,h6:sU,hr:function(e,t){const i={type:"thematicBreak"};return e.patch(t,i),i},i:iU,iframe:function(e,t){const i=t.properties||{},n=String(i.src||""),s=String(i.title||"");if(n&&s){const i={type:"link",title:null,url:e.resolve(n),children:[{type:"text",value:s}]};return e.patch(t,i),i}},img:oU,image:oU,input:function(e,t){const i=t.properties||{},n=String(i.value||i.placeholder||"");if(i.disabled||"hidden"===i.type||"file"===i.type)return;if("checkbox"===i.type||"radio"===i.type){const n={type:"text",value:i.checked?e.options.checked||"[x]":e.options.unchecked||"[ ]"};return e.patch(t,n),n}if("image"===i.type){const s=i.alt||n;if(s){const n={type:"image",url:e.resolve(String(i.src||"")||null),title:String(i.title||"")||null,alt:String(s)};return e.patch(t,n),n}return}let s=[];if(n)s=[[n,void 0]];else if("button"!==i.type&&"file"!==i.type&&"password"!==i.type&&"reset"!==i.type&&"submit"!==i.type&&i.list){const t=String(i.list),n=e.elementById.get(t);n&&"datalist"===n.tagName&&(s=aU(n,i))}if(0===s.length)return;if("password"===i.type&&(s[0]=["•".repeat(s[0][0].length),void 0]),"email"===i.type||"url"===i.type){const t=[];let n=-1;for(;++n1?s.charAt(1):s;return o&&"text"===o.type?o.value=a+o.value:n.unshift({type:"text",value:a}),r&&"text"===r.type?r.value+=l:n.push({type:"text",value:l}),n},s:Zq,samp:rU,select:function(e,t){const i=aU(t);let n=-1;const s=[];for(;++n0){const i={type:"text",value:s.join(", ")};return e.patch(t,i),i}},strike:Zq,strong:SU,summary:TU,table:function(e,t){if(e.inTable){const i={type:"text",value:Wq(t)};return e.patch(t,i),i}e.inTable=!0;const{align:i,headless:n}=function(e){const t={align:[null],headless:!0};let i=0,n=0;return PM(e,function(s){if("element"===s.type){if("table"===s.tagName&&e!==s)return PL;if("th"!==s.tagName&&"td"!==s.tagName||!s.properties)"thead"===s.tagName?t.headless=!1:"tr"===s.tagName&&(i++,n=0);else{if(!t.align[n]){const e=String(s.properties.align||"")||null;"center"!==e&&"left"!==e&&"right"!==e&&null!==e||(t.align[n]=e)}t.headless&&i<2&&"th"===s.tagName&&(t.headless=!1),n++}}}),t}(t),s=e.toSpecificContent(e.all(t),OU);n&&s.unshift({type:"tableRow",children:[]});let o=-1;for(;++o1||r>1){let e=o-1;for(;++er&&(r=e.length)}for(o=-1;++o0&&(t.children.unshift(...s),s=[]),n.push(t);else{const e=t;s.push(e)}}if(s.length>0){let e=n[n.length-1];e||(e=t(),n.push(e)),e.children.push(...s),s=[]}return n;function r(e){return e.type===i.type}}const $U={};function jU(e,t){const i=XD(e),n=t||$U,s=Bq({newlines:!0===n.newlines}),o=function(e){return{all:DU,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...BU,...e.handlers},inTable:!1,nodeHandlers:{...RU,...e.nodeHandlers},one:zU,options:e,patch:HU,qNesting:0,resolve:qU,toFlow:UU,toSpecificContent:WU}}(n);let r;s(i),PM(i,function(e){if(e&&"element"===e.type&&e.properties){const t=String(e.properties.id||"")||void 0;t&&!o.elementById.has(t)&&o.elementById.set(t,e)}});const a=o.one(i,void 0);if(a)if(Array.isArray(a)){r={type:"root",children:a}}else r=a;else r={type:"root",children:[]};return PM(r,function(e,t,i){if("text"===e.type&&void 0!==t&&i){const n=i.children[t-1];if(n&&n.type===e.type)return n.value+=e.value,i.children.splice(t,1),n.position&&e.position&&(n.position.end=e.position.end),t-1;if(e.value=e.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),!i||"heading"!==i.type&&"paragraph"!==i.type&&"root"!==i.type||(t||(e.value=e.value.replace(/^[\t ]+/,"")),t===i.children.length-1&&(e.value=e.value.replace(/[\t ]+$/,""))),!e.value)return i.children.splice(t,1),t}}),r}const GU={document:!0};function KU(e,t){return e&&"run"in e?async function(i,n){const s=jU(i,{...GU,...t});await e.run(s,n)}:function(t){return jU(t,{...GU,...e})}}function JU(e){const t=this;t.compiler=function(i){return dF(i,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}class QU{_processor;_keepRawTags=[];constructor(){this._buildProcessor()}keep(e){this._keepRawTags.push(e.toLowerCase()),this._buildProcessor()}parse(e){return this._processor.processSync(e).toString().trim()}_getRawTagsHandlers(){return this._keepRawTags.reduce((e,t)=>(e[t]=(e,t)=>{const i=GH(tq(t.tagName,t.properties),{allowDangerousHtml:!0,closeSelfClosing:!0}),n=i.indexOf(">"),s=i.slice(0,n+1),o=i.slice(n+1);return[{type:"html",value:s},...e.all(t),{type:"html",value:o}]},e),{})}_buildProcessor(){this._processor=nL().use(uq).use(YU).use(KU,{handlers:this._getRawTagsHandlers()}).use(aD,{singleTilde:!0}).use(hz).use(JU,{resourceLink:!0,emphasis:"_",rule:"-",handlers:{break:()=>"\n"},unsafe:[{character:"<"}]})}}function YU(){return function(e){PM(e,"element",(e,t,i)=>{null!==t&&"label"===e.tagName&&"element"===i.type&&"li"===i.tagName&&i.children.splice(t,1,...e.children)})}}class ZU{_htmlDP;_markdown2html;_html2markdown;constructor(e){this._htmlDP=new Qa(e),this._markdown2html=new aq,this._html2markdown=new QU}keepHtml(e){this._html2markdown.keep(e)}toView(e){const t=this._markdown2html.parse(e);return this._htmlDP.toView(t)}toData(e){const t=this._htmlDP.toData(e);return this._html2markdown.parse(t)}registerRawContentMatcher(e){this._htmlDP.registerRawContentMatcher(e)}useFillerType(){}}class XU extends $n{constructor(e){super(e),e.data.processor=new ZU(e.data.viewDocument)}static get pluginName(){return"Markdown"}static get isOfficialPlugin(){return!0}}const eW=["SPAN","BR","PRE","CODE"];class tW extends $n{_gfmDataProcessor;constructor(e){super(e),this._gfmDataProcessor=new ZU(e.data.viewDocument)}static get pluginName(){return"PasteFromMarkdownExperimental"}static get isOfficialPlugin(){return!0}static get requires(){return[cx]}init(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ClipboardPipeline");let n=!1;this.listenTo(t,"keydown",(e,t)=>{n=t.shiftKey}),this.listenTo(i,"inputTransformation",(e,t)=>{if(n)return;const i=t.dataTransfer.getData("text/html");if(!i){const e=t.dataTransfer.getData("text/plain");return void(t.content=this._gfmDataProcessor.toView(e))}const s=this._parseMarkdownFromHtml(i);s&&(t.content=this._gfmDataProcessor.toView(s))})}_parseMarkdownFromHtml(e){const t=this._removeOsSpecificTags(e);if(!this._containsOnlyAllowedFirstLevelTags(t))return null;const i=this._removeFirstLevelWrapperTagsAndBrs(t);return this._containsAnyRemainingHtmlTags(i)?null:this._replaceHtmlReservedEntitiesWithCharacters(i)}_removeOsSpecificTags(e){return e.replace(/^]*>/,"").trim().replace(/^/,"").replace(/<\/html>$/,"").trim().replace(/^/,"").replace(/<\/body>$/,"").trim().replace(/^/,"").replace(/$/,"").trim()}_containsOnlyAllowedFirstLevelTags(e){const t=new DOMParser,{body:i}=t.parseFromString(e,"text/html");return Array.from(i.children).map(e=>e.tagName).every(e=>eW.includes(e))}_removeFirstLevelWrapperTagsAndBrs(e){const t=new DOMParser,{body:i}=t.parseFromString(e,"text/html"),n=i.querySelectorAll("br");for(const e of n)e.replaceWith("\n");const s=i.querySelectorAll(":scope > *");for(const e of s){const t=e.cloneNode(!0);e.replaceWith(...t.childNodes)}return i.innerHTML}_containsAnyRemainingHtmlTags(e){return e.includes("<")}_replaceHtmlReservedEntitiesWithCharacters(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/ /g," ")}}function iW(e,t){const i=(i,n,s)=>{if(!s.consumable.consume(n.item,i.name))return;const o=n.attributeNewValue,r=s.writer,a=s.mapper.toViewElement(n.item),l=[...a.getChildren()].find(e=>e.getCustomProperty("media-content"));r.remove(l);const c=e.getMediaViewElement(r,o,t);r.insert(r.createPositionAt(a,0),c)};return e=>{e.on("attribute:url:media",i)}}function nW(e,t,i){return t.setCustomProperty("media",!0,e),bk(e,t,{label:i})}function sW(e){const t=e.getSelectedElement();return t&&oW(t)?t:null}function oW(e){return!!e.getCustomProperty("media")&&pk(e)}function rW(e,t,i,n){return e.createContainerElement("figure",{class:"media"},[t.getMediaViewElement(e,i,n),e.createSlot()])}function aW(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function lW(e,t,i,n){e.change(s=>{const o=s.createElement("media",{url:t});e.insertObject(o,i,null,{setSelection:"on",findOptimalPosition:n?"auto":void 0})})}class cW extends Gn{refresh(){const e=this.editor.model,t=e.document.selection,i=aW(t);this.value=i?i.getAttribute("url"):void 0,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){const i=xk(e,t);let n=i.start.parent;n.isEmpty&&!t.schema.isLimit(n)&&(n=n.parent);return t.schema.checkChild(n,"media")}(t,e)}execute(e){const t=this.editor.model,i=t.document.selection,n=aW(i);n?t.change(t=>{t.setAttribute("url",e,n)}):lW(t,e,i,!0)}}class uW{locale;providerDefinitions;constructor(e,t){const i=t.providers,n=t.extraProviders||[],s=new Set(t.removeProviders),o=i.concat(n).filter(e=>{const t=e.name;return t?!s.has(t):(P("media-embed-no-provider-name",{provider:e}),!1)});this.locale=e,this.providerDefinitions=o}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,i){return this._getMedia(t).getViewElement(e,i)}_getMedia(e){if(!e)return new dW(this.locale);e=e.trim();for(const t of this.providerDefinitions){const i=t.html,n=ln(t.url);for(const t of n){const n=this._getUrlMatches(e,t);if(n)return new dW(this.locale,e,n,i)}}return null}_getUrlMatches(e,t){let i=e.match(t);if(i)return i;let n=e.replace(/^https?:\/\//,"");return i=n.match(t),i||(n=n.replace(/^www\./,""),i=n.match(t),i||null)}}class dW{url;_locale;_match;_previewRenderer;constructor(e,t,i,n){this.url=this._getValidUrl(t),this._locale=e,this._match=i,this._previewRenderer=n}getViewElement(e,t){const i={};let n;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(i["data-oembed-url"]=this.url),t.renderForEditingView&&(i.class="ck-media__wrapper");const s=this._getPreviewHtml(t);n=e.createRawElement("div",i,(e,t)=>{t.setContentOf(e,s)})}else this.url&&(i.url=this.url),n=e.createEmptyElement(t.elementName,i);return e.setCustomProperty("media-content",!0,n),n}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new vp,t=this._locale.t;e.content=Lg,e.viewBox="0 0 64 42";return new Ud({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":t("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}class hW extends $n{static get pluginName(){return"MediaEmbedEditing"}static get isOfficialPlugin(){return!0}registry;constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:[/^dailymotion\.com\/video\/(\w+)/,/^dai.ly\/(\w+)/],html:e=>``},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:e=>``},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/shorts\/([\w-]+)(?:\?t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:e=>{const t=e[1],i=e[2];return``}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:e=>``},{name:"instagram",url:[/^instagram\.com\/p\/(\w+)/,/^instagram\.com\/reel\/(\w+)/]},{name:"twitter",url:[/^twitter\.com/,/^x\.com/]},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new uW(e.locale,e.config.get("mediaEmbed"))}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion,s=e.config.get("mediaEmbed.previewsInData"),o=e.config.get("mediaEmbed.elementName"),r=this.registry;e.commands.add("mediaEmbed",new cW(e)),t.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),n.for("dataDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const i=e.getAttribute("url");return rW(t,r,i,{elementName:o,renderMediaPreview:!!i&&s})}}),n.for("dataDowncast").add(iW(r,{elementName:o,renderMediaPreview:s})),n.for("editingDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const n=e.getAttribute("url");return nW(rW(t,r,n,{elementName:o,renderForEditingView:!0}),t,i("media widget"))}}),n.for("editingDowncast").add(iW(r,{elementName:o,renderForEditingView:!0})),n.for("upcast").elementToElement({view:e=>["oembed",o].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,{writer:t})=>{const i=e.getAttribute("url");return r.hasMedia(i)?t.createElement("media",{url:i}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,{writer:t})=>{const i=e.getAttribute("data-oembed-url");return r.hasMedia(i)?t.createElement("media",{url:i}):null}}).add(e=>{e.on("element:figure",(e,t,i)=>{if(!i.consumable.consume(t.viewItem,{name:!0,classes:"media"}))return;const{modelRange:n,modelCursor:s}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=n,t.modelCursor=s;fn(n.getItems())||i.consumable.revert(t.viewItem,{name:!0,classes:"media"})})})}}const mW=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class gW extends $n{static get requires(){return[xx,M_,uT]}static get pluginName(){return"AutoMediaEmbed"}static get isOfficialPlugin(){return!0}_timeoutId;_positionToInsert;constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const t=this.editor,i=t.model.document,n=t.plugins.get("ClipboardPipeline");this.listenTo(n,"inputTransformation",()=>{const e=i.selection.getFirstRange(),t=Ll.fromPosition(e.start);t.stickiness="toPrevious";const n=Ll.fromPosition(e.end);n.stickiness="toNext",i.once("change:data",()=>{this._embedMediaBetweenPositions(t,n),t.detach(),n.detach()},{priority:"high"})});t.commands.get("undo").on("execute",()=>{this._timeoutId&&(e.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedMediaBetweenPositions(t,i){const n=this.editor,s=n.plugins.get(hW).registry,o=new Fr(t,i),r=o.getWalker({ignoreElementEnd:!0});let a="";for(const e of r)e.item.is("$textProxy")&&(a+=e.item.data);if(a=a.trim(),!a.match(mW))return void o.detach();if(!s.hasMedia(a))return void o.detach();n.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=Ll.fromPosition(t),this._timeoutId=e.window.setTimeout(()=>{n.model.change(e=>{this._timeoutId=null,e.remove(o),o.detach();let t=null;"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),lW(n.model,a,t,!1),this._positionToInsert.detach(),this._positionToInsert=null}),n.plugins.get(M_).requestUndoOnBackspace()},100)):o.detach()}}class fW extends hh{focusTracker;keystrokes;urlInputView;_validators;_urlInputViewInfoDefault;_urlInputViewInfoTip;constructor(e,t){super(t),this.focusTracker=new bn,this.keystrokes=new yn,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView]})}render(){super.render(),_h({view:this}),this.focusTracker.add(this.urlInputView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.urlInputView.focus()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new Ab(this.locale,fw),i=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,i.inputMode="url",i.on("input",()=>{t.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=i.element.value.trim()}),t}}class pW extends $n{static get requires(){return[hW,Rp]}static get pluginName(){return"MediaEmbedUI"}static get isOfficialPlugin(){return!0}_formView;init(){const e=this.editor;e.ui.componentFactory.add("mediaEmbed",()=>{const e=this.editor.locale.t,t=this._createDialogButton(yp);return t.tooltip=!0,t.label=e("Insert media"),t}),e.ui.componentFactory.add("menuBar:mediaEmbed",()=>{const e=this.editor.locale.t,t=this._createDialogButton(Mp);return t.label=e("Media"),t})}_createDialogButton(e){const t=this.editor,i=new e(t.locale),n=t.commands.get("mediaEmbed"),s=this.editor.plugins.get("Dialog");return i.icon=Mg,i.bind("isEnabled").to(n,"isEnabled"),i.on("execute",()=>{"mediaEmbed"===s.id?s.hide():this._showDialog()}),i}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.commands.get("mediaEmbed"),n=e.locale.t,s=void 0!==i.value;if(!this._formView){const t=e.plugins.get(hW).registry;this._formView=new(wh(fW))(function(e,t){return[t=>{if(!t.url.length)return e("The URL must not be empty.")},i=>{if(!t.hasMedia(i.url))return e("This media URL is not supported.")}]}(e.t,t),e.locale),this._formView.on("submit",()=>this._handleSubmitForm())}t.show({id:"mediaEmbed",title:n("Media embed"),content:this._formView,isModal:!0,onShow:()=>{this._formView.url=i.value||"",this._formView.resetFormStatus(),this._formView.urlInputView.fieldView.select()},actionButtons:[{label:n("Cancel"),withText:!0,onExecute:()=>t.hide()},{label:n(s?"Save":"Insert"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSubmitForm()}]})}_handleSubmitForm(){const e=this.editor,t=e.plugins.get("Dialog");this._formView.isValid()&&(e.execute("mediaEmbed",this._formView.url),t.hide(),e.editing.view.focus())}}class bW extends $n{static get requires(){return[hW,pW,gW,qk]}static get pluginName(){return"MediaEmbed"}static get isOfficialPlugin(){return!0}}class wW extends $n{static get requires(){return[Wk]}static get pluginName(){return"MediaEmbedToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t;e.plugins.get(Wk).register("mediaEmbed",{ariaLabel:t("Media toolbar"),items:e.config.get("mediaEmbed.toolbar")||[],getRelatedElement:sW})}}const vW={"(":")","[":"]","{":"}"};class _W extends Gn{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,s=n.id,o=e.range||i.getFirstRange();if(!t.canEditAt(o))return;const r=e.text||s,a=kW({_text:r,id:s},n);if(!s.startsWith(e.marker))throw new I("mentioncommand-incorrect-id",this);t.change(e=>{const n=Cn(i.getAttributes()),s=new Map(n.entries());s.set("mention",a);const l=t.insertContent(e.createText(r,s),o),c=l.start.nodeBefore,u=l.end.nodeAfter,d=u&&u.is("$text")&&u.data.startsWith(" ");let h=!1;if(c&&u&&c.is("$text")&&u.is("$text")){const e=c.data.slice(-1),t=e in vW,i=t&&u.data.startsWith(vW[e]);h=t&&i}h||d||t.insertContent(e.createText(" ",n),o.start.getShiftedBy(r.length))})}}class yW extends $n{static get pluginName(){return"MentionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",attributes:"data-mention",classes:"mention"},model:{key:"mention",value:e=>CW(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:AW}),e.conversion.for("downcast").add(xW),i.registerPostFixer(e=>function(e,t,i){const n=t.differ.getChanges();let s=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;s=EW(n.textNode,e)||s,s=EW(t,e)||s,s=EW(n.nodeBefore,e)||s,s=EW(n.nodeAfter,e)||s}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())s=EW(i,e)||s}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;s=EW(n.nodeBefore,e)||s,s=EW(t,e)||s}}return s}(e,i,t.schema)),i.registerPostFixer(e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,s=t.range.end.nodeAfter;for(const o of[i,s])TW(o)&&o.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,o),n=!0)}return n}(e,i)),i.registerPostFixer(e=>function(e,t){const i=t.selection,n=i.focus;if(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart,i=e.nodeBefore&&e.nodeBefore.is("$text");return i||t}(n))return e.removeSelectionAttribute("mention"),!0;return!1}(e,i)),e.commands.add("mention",new _W(e))}}function kW(e,t){return Object.assign({uid:A()},e,t||{})}function CW(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(!n)return;return kW({id:i,_text:n.data},t)}function xW(e){e.on("attribute:mention",(e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const s=t.range.start;(s.textNode||s.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)},{priority:"highest"})}function AW(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function TW(e){if(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))return!1;return e.data!=e.getAttribute("mention")._text}function EW(e,t){return!!TW(e)&&(t.removeAttribute("mention",e),!0)}class SW extends zb{selected;position;constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))}),this.listenTo(this.domElement,"click",()=>{this.fire("execute")})}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class PW extends Fb{item;marker;highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const VW=[Qi.arrowup,Qi.arrowdown,Qi.esc],OW=[Qi.enter,Qi.tab];class RW extends $n{_mentionsView;_mentionsConfigurations;_balloon;_items=new gn;_lastRequested;_requestFeedDebounced;static get pluginName(){return"MentionUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Uv]}constructor(e){super(e),this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=tt(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||OW,i=VW.concat(t);this._balloon=e.plugins.get(Uv),e.editing.view.document.on("keydown",(e,n)=>{var s;s=n.keyCode,i.includes(s)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==Qi.arrowdown&&this._mentionsView.selectNext(),n.keyCode==Qi.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==Qi.esc&&this._hideUIAndRemoveMarker())},{priority:"highest"}),bh({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!NW(i))throw new I("mentionconfig-incorrect-marker",null,{marker:i});const s={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):FW(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,s)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",()=>{this._hideUIAndRemoveMarker()}),this.on("requestFeed:response",(e,t)=>this._handleFeedResponse(t)),this.on("requestFeed:error",()=>this._hideUIAndRemoveMarker())}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new SW(e);return t.items.bindTo(this._items).using(i=>{const{item:n,marker:s}=i,{dropdownLimit:o}=this._mentionsConfigurations.get(s),r=o||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new PW(e),l=this._renderItem(n,s);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=s,a.on("execute",()=>{t.fire("execute",{item:n,marker:s})}),a}),t.on("execute",(e,t)=>{const i=this.editor,n=i.model,s=t.item,o=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:s,text:s.text,marker:o,range:c}),i.editing.view.focus()}),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then(i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})}).catch(t=>{this.fire("requestFeed:error",{error:t}),P("mention-feed-callback-error",{marker:e})}):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map(e=>({...e,pattern:MW(e.marker,e.minimumCharacters||0)})),n=new D_(t.model,function(e){const t=t=>{const i=LW(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const s=t.substring(n);return i.pattern.test(s)};return t}(i));n.on("matched",(e,n)=>{const s=LW(i,n.text),o=t.model.document.selection.focus,r=t.model.createPositionAt(o.parent,s.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(o)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=MW(e.marker,0),s=t.substring(i);return s.match(n)[2]}(s,n.text),l=s.marker.length+a.length,c=o.getShiftedBy(-l),u=o.getShiftedBy(-a.length),d=t.model.createRange(c,u);if(DW(t)){const e=t.model.markers.get("mention");t.model.change(t=>{t.updateMarker(e,{range:d})})}else t.model.change(e=>{e.addMarker("mention",{range:d,usingOperation:!1,affectsData:!1})});this._requestFeedDebounced(s.marker,a)}),n.on("unmatched",()=>{this._hideUIAndRemoveMarker()});const s=t.commands.get("mention");return n.bind("isEnabled").to(s),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!DW(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0,balloonClassName:"ck-mention-balloon"}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),DW(this.editor)&&this.editor.model.change(e=>e.removeMarker("mention")),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,s=e.id;const o=this._getItemRenderer(t);if(o){const t=o(e);"string"!=typeof t?n=new IW(i.locale,t):s=t}if(!n){const e=new yp(i.locale);e.label=s,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,s=n.view.domConverter,o=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=o.toViewRange(t);return pi.getDomRangeRects(s.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:BW(t,i.locale.uiLanguageDirection)}}}function BW(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function LW(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function MW(e,t){const i=0==t?"*":`{${t},}`,s=n.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";e=e.replace(/[.*+?^${}()\-|[\]\\]/g,"\\$&");return new RegExp(`(?:^|[ ${s}])(${e})(.${i})$`,"u")}function FW(e){return t=>e.filter(e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase()))}function NW(e){return!!e}function DW(e){return e.model.markers.has("mention")}class zW extends $n{toMentionAttribute(e,t){return CW(e,t)}static get pluginName(){return"Mention"}static get isOfficialPlugin(){return!0}static get requires(){return[yW,RW]}}const HW=xi("px");class qW extends Fv{_options;constructor(e,t){super(e);const i=this.bindTemplate;this.set("top",0),this.set("height",0),this._options=t,this.extendTemplate({attributes:{tabindex:-1,"aria-hidden":"true",class:["ck-minimap__iframe"],style:{top:i.to("top",e=>HW(e)),height:i.to("height",e=>HW(e))}}})}render(){return super.render().then(()=>{this._prepareDocument()})}setHeight(e){this.height=e}setTopOffset(e){this.top=e}_prepareDocument(){const e=this.element.contentWindow.document,t=e.adoptNode(this._options.domRootClone),i=this._options.useSimplePreview?"\n\t\t\t.ck.ck-editor__editable_inline img {\n\t\t\t\tfilter: contrast( 0 );\n\t\t\t}\n\n\t\t\tp, li, a, figcaption, span {\n\t\t\t\tbackground: hsl(0, 0%, 80%) !important;\n\t\t\t\tcolor: hsl(0, 0%, 80%) !important;\n\t\t\t}\n\n\t\t\th1, h2, h3, h4 {\n\t\t\t\tbackground: hsl(0, 0%, 60%) !important;\n\t\t\t\tcolor: hsl(0, 0%, 60%) !important;\n\t\t\t}\n\t\t":"",n=this._options.pageStyles.map(e=>"string"==typeof e?``:``).join("\n"),s=`\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t${n}\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t`;e.open(),e.write(s),e.close(),e.body.appendChild(t)}}const UW=xi("px");class WW extends hh{constructor(e){super(e);const t=this.bindTemplate;this.set("height",0),this.set("top",0),this.set("scrollProgress",0),this.set("_isDragging",!1),this.setTemplate({tag:"div",attributes:{class:["ck","ck-minimap__position-tracker",t.if("_isDragging","ck-minimap__position-tracker_dragging")],style:{top:t.to("top",e=>UW(e)),height:t.to("height",e=>UW(e))},"data-progress":t.to("scrollProgress")},on:{mousedown:t.to(()=>{this._isDragging=!0})}})}render(){super.render(),this.listenTo(e.document,"mousemove",(e,t)=>{this._isDragging&&this.fire("drag",t.movementY)},{useCapture:!0}),this.listenTo(e.document,"mouseup",()=>{this._isDragging=!1},{useCapture:!0})}setHeight(e){this.height=e}setTopOffset(e){this.top=e}setScrollProgress(e){this.scrollProgress=e}}class $W extends hh{_positionTrackerView;_scaleRatio;_minimapIframeView;constructor({locale:e,scaleRatio:t,pageStyles:i,extraClasses:n,useSimplePreview:s,domRootClone:o}){super(e);const r=this.bindTemplate;this._positionTrackerView=new WW(e),this._positionTrackerView.delegate("drag").to(this),this._scaleRatio=t,this._minimapIframeView=new qW(e,{useSimplePreview:s,pageStyles:i,extraClasses:n,scaleRatio:t,domRootClone:o}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-minimap"]},children:[this._positionTrackerView],on:{click:r.to(this._handleMinimapClick.bind(this)),wheel:r.to(this._handleMinimapMouseWheel.bind(this))}})}destroy(){this._minimapIframeView.destroy(),super.destroy()}get height(){return new pi(this.element).height}get scrollHeight(){return Math.max(0,Math.min(this.height,this._minimapIframeView.height)-this._positionTrackerView.height)}render(){super.render(),this._minimapIframeView.render(),this.element.appendChild(this._minimapIframeView.element)}setContentHeight(e){this._minimapIframeView.setHeight(e*this._scaleRatio)}setScrollProgress(e){const t=this._minimapIframeView,i=this._positionTrackerView;if(t.heighto.markToSync("children",t)),n.on("change:attributes",(e,t)=>o.markToSync("attributes",t)),n.on("change:text",(e,t)=>o.markToSync("text",t)),o.render(),e.editing.view.on("render",()=>o.render()),e.on("destroy",()=>{s.unbindDomElement(r)}),r}function GW(){return Array.from(e.document.styleSheets).map(t=>t.href&&!t.href.startsWith(e.window.location.origin)?{href:t.href}:Array.from(t.cssRules).filter(e=>!(e instanceof CSSMediaRule)).map(e=>e.cssText).join(" \n"))}function KW(t){return new pi(t===e.document.body?e.window:t)}function JW(t){return t===e.document.body?e.window.innerHeight:t.clientHeight}function QW(t){return t===e.document.body?e.window:t}class YW extends $n{static get pluginName(){return"Minimap"}static get isOfficialPlugin(){return!0}_minimapView;_scrollableRootAncestor;_editingRootElement;init(){const e=this.editor;this._minimapView=null,this._scrollableRootAncestor=null,this.listenTo(e.ui,"ready",this._onUiReady.bind(this))}destroy(){super.destroy(),this._minimapView.destroy(),this._minimapView.element.remove()}_onUiReady(){const e=this.editor,t=this._editingRootElement=e.ui.getEditableElement();this._scrollableRootAncestor=ri(t),t.ownerDocument.body.contains(t)?(this._initializeMinimapView(),this.listenTo(e.editing.view,"render",()=>{"ready"===e.state&&this._syncMinimapToEditingRootScrollPosition()}),this._syncMinimapToEditingRootScrollPosition()):e.ui.once("update",this._onUiReady.bind(this))}_initializeMinimapView(){const t=this.editor,i=t.locale,n=t.config.get("minimap.useSimplePreview"),s=t.config.get("minimap.container"),o=this._scrollableRootAncestor,r=KW(this._editingRootElement).width,a=KW(s).width/r,l=this._minimapView=new $W({locale:i,scaleRatio:a,pageStyles:GW(),extraClasses:t.config.get("minimap.extraClasses"),useSimplePreview:n,domRootClone:jW(t)});l.render(),l.listenTo(e.document,"scroll",(t,i)=>{if(o===e.document.body){if(i.target!==e.document)return}else if(i.target!==o)return;this._syncMinimapToEditingRootScrollPosition()},{useCapture:!0,usePassive:!0}),l.listenTo(e.window,"resize",()=>{this._syncMinimapToEditingRootScrollPosition()}),l.on("drag",(e,t)=>{let i;i=0===l.scrollHeight?0:t/l.scrollHeight;const n=i*(o.scrollHeight-JW(o));QW(o).scrollBy(0,Math.round(n))}),l.on("click",(e,t)=>{const i=t*o.scrollHeight;QW(o).scrollBy(0,Math.round(i))}),s.appendChild(l.element)}_syncMinimapToEditingRootScrollPosition(){const e=this._editingRootElement,t=this._minimapView;t.setContentHeight(e.offsetHeight);const i=KW(e),n=KW(this._scrollableRootAncestor);let s;n.getIntersection(i)&&(n.contains(i)||i.top>n.top?s=0:(s=(i.top-n.top)/(n.height-i.height),s=Math.max(0,Math.min(s,1))),t.setPositionTrackerHeight(n.getIntersection(i).height),t.setScrollProgress(s))}}class ZW extends Gn{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=xk(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"pageBreak")}(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("pageBreak");e.insertObject(i,null,null,{setSelection:"after"})})}}class XW extends $n{static get pluginName(){return"PageBreakEditing"}static get licenseFeatureCode(){return"PB"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("pageBreak",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToStructure({model:"pageBreak",view:(e,{writer:t})=>t.createContainerElement("div",{class:"page-break",style:"page-break-after: always"},t.createContainerElement("span",{style:"display: none"}))}),n.for("editingDowncast").elementToStructure({model:"pageBreak",view:(e,{writer:t})=>{const n=i("Page break"),s=t.createContainerElement("div"),o=t.createRawElement("span",{class:"page-break__label"},function(e){e.innerText=i("Page break")});return t.addClass("page-break",s),t.insert(t.createPositionAt(s,0),o),function(e,t,i){return t.setCustomProperty("pageBreak",!0,e),bk(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:e=>{const t="always"==e.getStyle("page-break-before"),i="always"==e.getStyle("page-break-after");if(!t&&!i)return null;if(1==e.childCount){const t=e.getChild(0);if(!t.is("element","span")||"none"!=t.getStyle("display"))return null}else if(e.childCount>1)return null;return{name:!0,styles:[...t?["page-break-before"]:[],...i?["page-break-after"]:[]],...e.hasClass("page-break")&&{classes:["page-break"]}}},model:"pageBreak",converterPriority:"high"}),e.commands.add("pageBreak",new ZW(e))}}class e$ extends $n{static get pluginName(){return"PageBreakUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("pageBreak",()=>{const e=this._createButton(yp);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:pageBreak",()=>this._createButton(Mp))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("pageBreak"),s=new e(t.locale),o=i.t;return s.set({label:o("Page break"),icon:sf}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("pageBreak"),t.editing.view.focus()}),s}}class t$ extends $n{static get requires(){return[XW,e$,qk]}static get pluginName(){return"PageBreak"}static get isOfficialPlugin(){return!0}}function i$(e,t){const i=[];for(const n of t.createRangeIn(e)){const e=n.item;e.is("element","a")&&!e.hasAttribute("href")&&(e.hasAttribute("id")||e.hasAttribute("name"))&&i.push(e)}for(const e of i){const i=e.parent.getChildIndex(e)+1,n=e.getChildren();t.insertChild(i,n,e.parent)}}function n$(e){const t=parseFloat(e);return e.endsWith("pt")?o$(96*t/72):e.endsWith("pc")?o$(12*t*96/72):e.endsWith("in")?o$(96*t):e.endsWith("cm")?o$(96*t/2.54):e.endsWith("mm")?o$(t/10*96/2.54):e}function s$(e){return void 0!==e&&e.endsWith("px")}function o$(e){return Math.round(e)+"px"}function r$(e,t,i){if(!e.childCount)return;const n=new Oc(e.document),s=function(e,t){const i=t.createRangeIn(e),n=[],s=new Set;for(const e of i.getItems()){if(!e.is("element")||!e.name.match(/^(p|h\d+|li|div)$/))continue;let t=f$(e);if(void 0===t||0!=parseFloat(t)||Array.from(e.getClassNames()).find(e=>e.startsWith("MsoList"))||(t=void 0),e.hasStyle("mso-list")&&"none"!==e.getStyle("mso-list")||void 0!==t&&s.has(t)){const i=m$(e);n.push({element:e,id:i.id,order:i.order,indent:i.indent,marginLeft:t}),void 0!==t&&s.add(t)}else s.clear()}return n}(e,n);if(!s.length)return;const o={},r=[];for(const e of s)if(void 0!==e.indent){l$(e)||(r.length=0);const s=`${e.id}:${e.indent}`,a=Math.min(e.indent-1,r.length);if(ar.length-1||r[a].listElement.name!=l.type){0==a&&"ol"==l.type&&void 0!==e.id&&o[s]&&(l.startIndex=o[s]);const t=h$(l,n,i);if(s$(e.marginLeft)&&(0==a||s$(r[a-1].marginLeft))){let i=e.marginLeft;a>0&&(i=o$(parseFloat(i)-parseFloat(r[a-1].marginLeft))),n.setStyle("padding-left",i,t)}if(0==r.length){const i=e.element.parent,s=i.getChildIndex(e.element)+1;n.insertChild(s,t,i)}else{const e=r[a-1].listItemElements;n.appendChild(t,e[e.length-1])}r[a]={...e,listElement:t,listItemElements:[]},0==a&&void 0!==e.id&&(o[s]=l.startIndex||1)}}const l="li"==e.element.name?e.element:n.createElement("li");n.appendChild(l,r[a].listElement),r[a].listItemElements.push(l),0==a&&void 0!==e.id&&o[s]++,e.element!=l&&n.appendChild(e.element,l),g$(e.element,n),n.removeStyle("text-indent",e.element),n.removeStyle("margin-left",e.element)}else{const t=r.find(t=>t.marginLeft==e.marginLeft);if(t){const i=t.listItemElements;n.appendChild(e.element,i[i.length-1]),n.removeStyle("margin-left",e.element)}else r.length=0}}function a$(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}function l$(e){const t=e.element.previousSibling;if(!t){const t=e.element.parent;return c$(t)&&(!t.previousSibling||c$(t.previousSibling))}return c$(t)}function c$(e){return e.is("element","ol")||e.is("element","ul")}function u$(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,s=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=new RegExp(`@list\\s+l${e.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${e.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=o.exec(t),l=r.exec(t),c=a&&!l,u=i.exec(t);let d="decimal",h="ol",m=null;if(u&&u[1]){const t=n.exec(u[1]);if(t&&t[1]&&(d=t[1].trim(),h="bullet"!==d&&"image"!==d?"ol":"ul"),"bullet"===d){const t=function(e){if("li"==e.name&&"ul"==e.parent.name&&e.parent.hasAttribute("type"))return e.parent.getAttribute("type");const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(d=t)}else{const e=s.exec(u[1]);e&&e[1]&&(m=parseInt(e[1]))}c&&(h="ol")}return{type:h,startIndex:m,style:d$(d),isLegalStyleList:c}}function d$(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function h$(e,t,i){const n=t.createElement(e.type);return e.style&&t.setStyle("list-style-type",e.style,n),e.startIndex&&e.startIndex>1&&t.setAttribute("start",e.startIndex,n),e.isLegalStyleList&&i&&t.addClass("legal-list",n),n}function m$(e){const t=e.getStyle("mso-list");if(void 0===t)return{};const i=t.match(/(^|\s{1,100})l(\d+)/i),n=t.match(/\s{0,100}lfo(\d+)/i),s=t.match(/\s{0,100}level(\d+)/i);return i&&n&&s?{id:i[2],order:n[1],indent:parseInt(s[1])}:{indent:1}}function g$(e,t){const i=new vs({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}function f$(e){const t=e.getStyle("margin-left");return void 0===t||t.endsWith("px")?t:n$(t)}function p$(e,t){if(!e.childCount)return;const i=new Oc(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new vs({name:/v:(.+)/}),s=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,o=i&&i.is("element")?i.name:null,r=["Chart"],a=n.match(t),l=t.getAttribute("o:gfxdata"),c="v:shapetype"===o,u=l&&r.some(e=>t.getAttribute("id").includes(e));a&&l&&!c&&!u&&s.push(e.item.getAttribute("id"))}return s}(e,i);!function(e,t,i){const n=i.createRangeIn(t),s=new vs({name:"img"}),o=[];for(const t of n)if(t.item.is("element")&&s.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every(t=>e.indexOf(t)>-1)?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),s=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;o(t.item.parent.getChildren(),i)||s.push(t.item)}for(const e of s){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function o(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(o(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new vs({name:/v:(.+)/}),s=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&s.push(e.item);for(const e of s)t.remove(e)}(e,i);const s=function(e,t){const i=t.createRangeIn(e),n=new vs({name:"img"}),s=[];let o=0;for(const e of i)e.item.is("element")&&n.match(e.item)&&(e.item.getAttribute("src").startsWith("file://")&&s.push({element:e.item,imageIndex:o}),o++);return s}(e,i);s.length&&function(e,t,i){for(let n=0;nString.fromCharCode(parseInt(e,16))).join(""))}function w$(e){const t=[],i=new Oc(e.document);for(const{item:n}of i.createRangeIn(e))if(n.is("element")){for(const e of n.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,n);for(const e of n.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,n);(n.is("element","w:sdt")||n.is("element","w:sdtpr")&&n.isEmpty||n.is("element","o:p")&&n.isEmpty)&&t.push(n)}for(const e of t){const t=e.parent,n=t.getChildIndex(e);i.insertChild(n,e.getChildren(),t),i.remove(e)}}function v$(e,t,i=!1,n=!1){for(const s of t.createRangeIn(e).getItems()){if(!s.is("element","table")&&!s.is("element","td")&&!s.is("element","th"))continue;if(i&&n&&s.is("element","table")){const e=s.parent?.is("element","div")?s.parent:null,i=s.parent?.parent?.is("element","div")?s.parent.parent:null,n=e??i;n&&"center"===n.getAttribute("align")&&!s.getAttribute("align")?(t.setStyle("margin-left","auto",s),t.setStyle("margin-right","auto",s)):n&&"right"===n.getAttribute("align")&&!s.getAttribute("align")?(t.setStyle("margin-left","auto",s),t.setStyle("margin-right","0",s)):n||s.getAttribute("align")||(t.setStyle("margin-left","0",s),t.setStyle("margin-right","auto",s))}const e=["left","top","right","bottom"];if(e.every(e=>!s.hasStyle(`border-${e}-style`)))t.setStyle("border-style","none",s);else for(const i of e)s.hasStyle(`border-${i}-style`)||t.setStyle(`border-${i}-style`,"none",s);const o=["width","height",...e.map(e=>`border-${e}-width`),...e.map(e=>`padding-${e}`)];for(const e of o)s.hasStyle(e)&&t.setStyle(e,n$(s.getStyle(e)),s)}}function _$(e,t){for(const i of t.createRangeIn(e).getItems())i.is("element","table")&&("0px"===i.getStyle("width")&&t.removeStyle("width",i),"0"===i.getAttribute("width")&&t.removeAttribute("width",i))}function y$(e,t){const i=[],n=[];for(const{item:s}of e.createRangeIn(t))if(s.is("element")&&s.getStyle("mso-footnote-id")){i.unshift(s);const{nextSibling:e}=s;e?.is("$text")&&e.data.startsWith(" ")&&n.unshift(e)}for(const t of i)e.remove(t);for(const t of n){const i=t.data.substring(1);if(i.length>0){const n=t.parent,s=n.getChildIndex(t),o=e.createText(i);e.remove(t),e.insertChild(s,o,n)}else e.remove(t)}return t}function k$(e,t){const i=e.createElement("sup",{class:"footnote"}),n=e.createElement("a",{id:`ref-${t}`,href:`#${t}`});return e.appendChild(n,i),i}function C$(e,t){const i=e.createElement("li",{id:t,class:"footnote-definition"}),n=e.createElement("a",{href:`#ref-${t}`,class:"footnote-backlink"}),s=e.createElement("div",{class:"footnote-content"});return e.appendChild(e.createText("^"),n),e.appendChild(n,i),e.appendChild(s,i),{listItem:i,content:s}}const x$=//i,A$=/xmlns:o="urn:schemas-microsoft-com/i;class T${document;hasMultiLevelListPlugin;hasTablePropertiesPlugin;hasExtendedTableBlockAlignment;constructor(e,t=!1,i=!1,n=!1){this.document=e,this.hasMultiLevelListPlugin=t,this.hasTablePropertiesPlugin=i,this.hasExtendedTableBlockAlignment=n}isActive(e){return x$.test(e)||A$.test(e)}execute(e){const t=new Oc(this.document),{body:i,stylesString:n}=e._parsedData;i$(i,t),r$(i,n,this.hasMultiLevelListPlugin),p$(i,e.dataTransfer.getData("text/rtf")),v$(i,t,this.hasTablePropertiesPlugin,this.hasExtendedTableBlockAlignment),_$(i,t),function(e,t){const i=new Map,n=new Map;let s=null;for(const{item:o}of t.createRangeIn(e))if(o.is("element"))if("footnote-list"!==o.getStyle("mso-element")){if(o.hasStyle("mso-footnote-id")){const e=o.findAncestor("element",e=>"footnote"===e.getStyle("mso-element"));if(e){const t=e.getAttribute("id");n.set(t,e)}else{const e=o.getStyle("mso-footnote-id");i.set(e,o)}continue}}else s=o;if(!i.size||!s)return;const o=function(e){return e.createElement("ol",{class:"footnotes"})}(t);t.replace(s,o);for(const[e,s]of i){const i=n.get(e);if(!i)continue;t.replace(s,k$(t,e));const r=C$(t,e);y$(t,i);for(const e of i.getChildren()){let i=e;e.is("element")&&(i=t.clone(e,!0)),t.appendChild(i,r.content)}t.appendChild(r.listItem,o)}}(i,t),w$(i),e.content=i}}function E$(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}function S$(e,t){const i=new Zs(t.document.stylesProcessor),n=new Ho(i,{renderingMode:"data"}),s=n.blockElements,o=n.inlineObjectElements,r=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=I$(e,"forward",t,{blockElements:s,inlineObjectElements:o}),n=I$(e,"backward",t,{blockElements:s,inlineObjectElements:o}),a=P$(i,s);(P$(n,s)||a)&&r.push(e)}}for(const e of r)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}function I$(e,t,i,{blockElements:n,inlineObjectElements:s}){let o=i.createPositionAt(e,"forward"==t?"after":"before");return o=o.getLastMatchingPosition(({item:e})=>e.is("element")&&!n.includes(e.name)&&!s.includes(e.name),{direction:t}),"forward"==t?o.nodeAfter:o.nodeBefore}function P$(e,t){return!!e&&e.is("element")&&t.includes(e.name)}function V$(e){let t=e;for(;t;){if(t.is("element")){const e=t.getStyle?.("white-space");if("pre-wrap"===e)return!0}t=t.parent}return!1}function O$(e,t,i){const{parent:n,data:s}=e,o=s.replaceAll("\t"," ".repeat(i)),r=n.getChildIndex(e);t.remove(e),t.insertChild(r,t.createText(o),n)}const R$=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class B${document;constructor(e){this.document=e}isActive(e){return R$.test(e)}execute(e){const t=new Oc(this.document),{body:i}=e._parsedData;E$(i,t),a$(i,t),S$(i,t),function(e,t,i){const n=new Set;for(const i of t.createRangeIn(e).getItems())i.is("view:$textProxy")&&i.data.includes("\t")&&V$(i.parent)&&n.add(i.textNode);for(const e of n)O$(e,t,i)}(i,t,8),e.content=i}}function L$(e,t){for(const i of e.getChildren())i.is("element","table")&&i.hasAttribute("xmlns")&&t.removeAttribute("xmlns",i)}function M$(e,t){for(const i of e.getChildren())if(i.is("element","google-sheets-html-origin")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}function F$(e,t){for(const i of Array.from(e.getChildren()))i.is("element","style")&&t.remove(i)}const N$=/[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}function H$(e){e.querySelectorAll("span[style*=spacerun]").forEach(e=>{const t=e,i=t.innerText.length||0;t.innerText=Array(i+1).join(" ").substr(0,i)})}function q$(e){return e.replace(/(\s+)<\/span>/g,(e,t)=>1===t.length?" ":Array(t.length+1).join(" ").substr(0,t.length))}function U$(e,t){const i=new DOMParser,n=z$(function(e){const t="",i="",n=e.indexOf(t);if(n<0)return e;const s=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(s>=0?e.substring(s):"")}(e=(e=e.replace(/
abc
\n\t\t\t//\n\t\t\tif ( isAttribute && child._canMergeAttributesFrom( wrapElement ) ) {\n\t\t\t\tchild._mergeAttributesFrom( wrapElement );\n\t\t\t\twrapPositions.push( new ViewPosition( parent, i ) );\n\t\t\t}\n\t\t\t//\n\t\t\t// Wrap the child if it is not an attribute element or if it is an attribute element that should be inside\n\t\t\t// `wrapElement` (due to priority).\n\t\t\t//\n\t\t\t//
abc
-->
abc
\n\t\t\t//
abc
-->
abc
\n\t\t\telse if ( isText || !isAttribute || shouldABeOutsideB( wrapElement, child ) ) {\n\t\t\t\t// Clone attribute.\n\t\t\t\tconst newAttribute = wrapElement._clone();\n\n\t\t\t\t// Wrap current node with new attribute.\n\t\t\t\tchild._remove();\n\t\t\t\tnewAttribute._appendChild( child );\n\n\t\t\t\tparent._insertChild( i, newAttribute );\n\t\t\t\tthis._addToClonedElementsGroup( newAttribute );\n\n\t\t\t\twrapPositions.push( new ViewPosition( parent, i ) );\n\t\t\t}\n\t\t\t//\n\t\t\t// If other nested attribute is found and it wasn't wrapped (see above), continue wrapping inside it.\n\t\t\t//\n\t\t\t//
\n\t\t\t//\n\t\t\telse /* if ( isAttribute ) */ {\n\t\t\t\tthis._wrapChildren( child, 0, child.childCount, wrapElement );\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\t// Merge at each wrap.\n\t\tlet offsetChange = 0;\n\n\t\tfor ( const position of wrapPositions ) {\n\t\t\tposition.offset -= offsetChange;\n\n\t\t\t// Do not merge with elements outside selected children.\n\t\t\tif ( position.offset == startOffset ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst newPosition = this.mergeAttributes( position );\n\n\t\t\t// If nodes were merged - other merge offsets will change.\n\t\t\tif ( !newPosition.isEqual( position ) ) {\n\t\t\t\toffsetChange++;\n\t\t\t\tendOffset--;\n\t\t\t}\n\t\t}\n\n\t\treturn ViewRange._createFromParentsAndOffsets( parent, startOffset, parent, endOffset );\n\t}\n\n\t/**\n\t * Unwraps children from provided `unwrapElement`. Only children contained in `parent` element between\n\t * `startOffset` and `endOffset` will be unwrapped.\n\t */\n\tprivate _unwrapChildren( parent: ViewElement, startOffset: number, endOffset: number, unwrapElement: ViewAttributeElement ) {\n\t\tlet i = startOffset;\n\t\tconst unwrapPositions: Array = [];\n\n\t\t// Iterate over each element between provided offsets inside parent.\n\t\t// We don't use tree walker or range iterator because we will be removing and merging potentially multiple nodes,\n\t\t// so it could get messy. It is safer to it manually in this case.\n\t\twhile ( i < endOffset ) {\n\t\t\tconst child = parent.getChild( i )!;\n\n\t\t\t// Skip all text nodes. There should be no container element's here either.\n\t\t\tif ( !child.is( 'attributeElement' ) ) {\n\t\t\t\ti++;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// (In all examples, assume that `unwrapElement` is `` element.)\n\t\t\t//\n\t\t\t// If the child is similar to the given attribute element, unwrap it - it will be completely removed.\n\t\t\t//\n\t\t\t//
abcxyz
-->
abcxyz
\n\t\t\t//\n\t\t\tif ( child.isSimilar( unwrapElement ) ) {\n\t\t\t\tconst unwrapped = child.getChildren();\n\t\t\t\tconst count = child.childCount;\n\n\t\t\t\t// Replace wrapper element with its children\n\t\t\t\tchild._remove();\n\t\t\t\tparent._insertChild( i, unwrapped );\n\n\t\t\t\tthis._removeFromClonedElementsGroup( child );\n\n\t\t\t\t// Save start and end position of moved items.\n\t\t\t\tunwrapPositions.push(\n\t\t\t\t\tnew ViewPosition( parent, i ),\n\t\t\t\t\tnew ViewPosition( parent, i + count )\n\t\t\t\t);\n\n\t\t\t\t// Skip elements that were unwrapped. Assuming there won't be another element to unwrap in child elements.\n\t\t\t\ti += count;\n\t\t\t\tendOffset += count - 1;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// If the child is not similar but is an attribute element, try partial unwrapping - remove the same attributes/styles/classes.\n\t\t\t// Partial unwrapping will happen only if the elements have the same name.\n\t\t\t//\n\t\t\t//
abcxyz
-->
abcxyz
\n\t\t\t//
abcxyz
-->
abcxyz
\n\t\t\t//\n\t\t\tif ( child._canSubtractAttributesOf( unwrapElement ) ) {\n\t\t\t\tchild._subtractAttributesOf( unwrapElement );\n\t\t\t\tunwrapPositions.push(\n\t\t\t\t\tnew ViewPosition( parent, i ),\n\t\t\t\t\tnew ViewPosition( parent, i + 1 )\n\t\t\t\t);\n\n\t\t\t\ti++;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// If other nested attribute is found, look through it's children for elements to unwrap.\n\t\t\t//\n\t\t\t//
abc
-->
abc
\n\t\t\t//\n\t\t\tthis._unwrapChildren( child, 0, child.childCount, unwrapElement );\n\n\t\t\ti++;\n\t\t}\n\n\t\t// Merge at each unwrap.\n\t\tlet offsetChange = 0;\n\n\t\tfor ( const position of unwrapPositions ) {\n\t\t\tposition.offset -= offsetChange;\n\n\t\t\t// Do not merge with elements outside selected children.\n\t\t\tif ( position.offset == startOffset || position.offset == endOffset ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst newPosition = this.mergeAttributes( position );\n\n\t\t\t// If nodes were merged - other merge offsets will change.\n\t\t\tif ( !newPosition.isEqual( position ) ) {\n\t\t\t\toffsetChange++;\n\t\t\t\tendOffset--;\n\t\t\t}\n\t\t}\n\n\t\treturn ViewRange._createFromParentsAndOffsets( parent, startOffset, parent, endOffset );\n\t}\n\n\t/**\n\t * Helper function for `view.writer.wrap`. Wraps range with provided attribute element.\n\t * This method will also merge newly added attribute element with its siblings whenever possible.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n\t * an instance of {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement}.\n\t *\n\t * @returns New range after wrapping, spanning over wrapping attribute element.\n\t */\n\tprivate _wrapRange( range: ViewRange, attribute: ViewAttributeElement ): ViewRange {\n\t\t// Break attributes at range start and end.\n\t\tconst { start: breakStart, end: breakEnd } = this._breakAttributesRange( range, true );\n\t\tconst parentContainer = breakStart.parent as ViewElement;\n\n\t\t// Wrap all children with attribute.\n\t\tconst newRange = this._wrapChildren( parentContainer, breakStart.offset, breakEnd.offset, attribute );\n\n\t\t// Merge attributes at the both ends and return a new range.\n\t\tconst start = this.mergeAttributes( newRange.start );\n\n\t\t// If start position was merged - move end position back.\n\t\tif ( !start.isEqual( newRange.start ) ) {\n\t\t\tnewRange.end.offset--;\n\t\t}\n\t\tconst end = this.mergeAttributes( newRange.end );\n\n\t\treturn new ViewRange( start, end );\n\t}\n\n\t/**\n\t * Helper function for {@link #wrap}. Wraps position with provided attribute element.\n\t * This method will also merge newly added attribute element with its siblings whenever possible.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n\t * an instance of {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement}.\n\t *\n\t * @returns New position after wrapping.\n\t */\n\tprivate _wrapPosition( position: ViewPosition, attribute: ViewAttributeElement ): ViewPosition {\n\t\t// Return same position when trying to wrap with attribute similar to position parent.\n\t\tif ( attribute.isSimilar( position.parent as any ) ) {\n\t\t\treturn movePositionToTextNode( position.clone() );\n\t\t}\n\n\t\t// When position is inside text node - break it and place new position between two text nodes.\n\t\tif ( position.parent.is( '$text' ) ) {\n\t\t\tposition = breakTextNode( position );\n\t\t}\n\n\t\t// Create fake element that will represent position, and will not be merged with other attributes.\n\t\tconst fakeElement = this.createAttributeElement( '_wrapPosition-fake-element' );\n\t\t( fakeElement as any )._priority = Number.POSITIVE_INFINITY;\n\t\tfakeElement.isSimilar = () => false;\n\n\t\t// Insert fake element in position location.\n\t\t( position.parent as ViewElement )._insertChild( position.offset, fakeElement );\n\n\t\t// Range around inserted fake attribute element.\n\t\tconst wrapRange = new ViewRange( position, position.getShiftedBy( 1 ) );\n\n\t\t// Wrap fake element with attribute (it will also merge if possible).\n\t\tthis.wrap( wrapRange, attribute );\n\n\t\t// Remove fake element and place new position there.\n\t\tconst newPosition = new ViewPosition( fakeElement.parent!, fakeElement.index! );\n\t\tfakeElement._remove();\n\n\t\t// If position is placed between text nodes - merge them and return position inside.\n\t\tconst nodeBefore = newPosition.nodeBefore;\n\t\tconst nodeAfter = newPosition.nodeAfter;\n\n\t\tif ( nodeBefore && nodeBefore.is( 'view:$text' ) && nodeAfter && nodeAfter.is( 'view:$text' ) ) {\n\t\t\treturn mergeTextNodes( nodeBefore, nodeAfter );\n\t\t}\n\n\t\t// If position is next to text node - move position inside.\n\t\treturn movePositionToTextNode( newPosition );\n\t}\n\n\t/**\n\t * Helper function used by other `ViewDowncastWriter` methods. Breaks attribute elements at the boundaries of given range.\n\t *\n\t * @param range Range which `start` and `end` positions will be used to break attributes.\n\t * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.\n\t * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n\t * @returns New range with located at break positions.\n\t */\n\tprivate _breakAttributesRange( range: ViewRange, forceSplitText: boolean = false ) {\n\t\tconst rangeStart = range.start;\n\t\tconst rangeEnd = range.end;\n\n\t\tvalidateRangeContainer( range, this.document );\n\n\t\t// Break at the collapsed position. Return new collapsed range.\n\t\tif ( range.isCollapsed ) {\n\t\t\tconst position = this._breakAttributes( range.start, forceSplitText );\n\n\t\t\treturn new ViewRange( position, position );\n\t\t}\n\n\t\tconst breakEnd = this._breakAttributes( rangeEnd, forceSplitText );\n\t\tconst count = ( breakEnd.parent as ViewElement ).childCount;\n\t\tconst breakStart = this._breakAttributes( rangeStart, forceSplitText );\n\n\t\t// Calculate new break end offset.\n\t\tbreakEnd.offset += ( breakEnd.parent as ViewElement ).childCount - count;\n\n\t\treturn new ViewRange( breakStart, breakEnd );\n\t}\n\n\t/**\n\t * Helper function used by other `ViewDowncastWriter` methods. Breaks attribute elements at given position.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-empty-element` when break position\n\t * is placed inside {@link module:engine/view/emptyelement~ViewEmptyElement ViewEmptyElement}.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-ui-element` when break position\n\t * is placed inside {@link module:engine/view/uielement~ViewUIElement UIElement}.\n\t *\n\t * @param position Position where to break attributes.\n\t * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.\n\t * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n\t * @returns New position after breaking the attributes.\n\t */\n\tprivate _breakAttributes( position: ViewPosition, forceSplitText: boolean = false ): ViewPosition {\n\t\tconst positionOffset = position.offset;\n\t\tconst positionParent = position.parent;\n\n\t\t// If position is placed inside ViewEmptyElement - throw an exception as we cannot break inside.\n\t\tif ( position.parent.is( 'emptyElement' ) ) {\n\t\t\t/**\n\t\t\t * Cannot break an `EmptyElement` instance.\n\t\t\t *\n\t\t\t * This error is thrown if\n\t\t\t * {@link module:engine/view/downcastwriter~ViewDowncastWriter#breakAttributes `ViewDowncastWriter#breakAttributes()`}\n\t\t\t * was executed in an incorrect position.\n\t\t\t *\n\t\t\t * @error view-writer-cannot-break-empty-element\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-cannot-break-empty-element', this.document );\n\t\t}\n\n\t\t// If position is placed inside UIElement - throw an exception as we cannot break inside.\n\t\tif ( position.parent.is( 'uiElement' ) ) {\n\t\t\t/**\n\t\t\t * Cannot break a `UIElement` instance.\n\t\t\t *\n\t\t\t * This error is thrown if\n\t\t\t * {@link module:engine/view/downcastwriter~ViewDowncastWriter#breakAttributes `ViewDowncastWriter#breakAttributes()`}\n\t\t\t * was executed in an incorrect position.\n\t\t\t *\n\t\t\t * @error view-writer-cannot-break-ui-element\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-cannot-break-ui-element', this.document );\n\t\t}\n\n\t\t// If position is placed inside RawElement - throw an exception as we cannot break inside.\n\t\tif ( position.parent.is( 'rawElement' ) ) {\n\t\t\t/**\n\t\t\t * Cannot break a `RawElement` instance.\n\t\t\t *\n\t\t\t * This error is thrown if\n\t\t\t * {@link module:engine/view/downcastwriter~ViewDowncastWriter#breakAttributes `ViewDowncastWriter#breakAttributes()`}\n\t\t\t * was executed in an incorrect position.\n\t\t\t *\n\t\t\t * @error view-writer-cannot-break-raw-element\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-cannot-break-raw-element', this.document );\n\t\t}\n\n\t\t// There are no attributes to break and text nodes breaking is not forced.\n\t\tif ( !forceSplitText && positionParent.is( '$text' ) && isContainerOrFragment( positionParent.parent! ) ) {\n\t\t\treturn position.clone();\n\t\t}\n\n\t\t// Position's parent is container, so no attributes to break.\n\t\tif ( isContainerOrFragment( positionParent ) ) {\n\t\t\treturn position.clone();\n\t\t}\n\n\t\t// Break text and start again in new position.\n\t\tif ( positionParent.is( '$text' ) ) {\n\t\t\treturn this._breakAttributes( breakTextNode( position ), forceSplitText );\n\t\t}\n\n\t\tconst length = ( positionParent as any ).childCount;\n\n\t\t//
foobar{}
\n\t\t//
foobar[]
\n\t\t//
foobar[]
\n\t\tif ( positionOffset == length ) {\n\t\t\tconst newPosition = new ViewPosition( positionParent.parent as any, ( positionParent as any ).index + 1 );\n\n\t\t\treturn this._breakAttributes( newPosition, forceSplitText );\n\t\t} else {\n\t\t\t//
foo{}bar
\n\t\t\t//
foo[]bar
\n\t\t\t//
foo{}bar
\n\t\t\tif ( positionOffset === 0 ) {\n\t\t\t\tconst newPosition = new ViewPosition( positionParent.parent as ViewElement, ( positionParent as any ).index );\n\n\t\t\t\treturn this._breakAttributes( newPosition, forceSplitText );\n\t\t\t}\n\t\t\t//
foob{}ar
\n\t\t\t//
foob[]ar
\n\t\t\t//
foob[]ar
\n\t\t\t//
foob[]ar
\n\t\t\telse {\n\t\t\t\tconst offsetAfter = ( positionParent as any ).index + 1;\n\n\t\t\t\t// Break element.\n\t\t\t\tconst clonedNode = ( positionParent as any )._clone();\n\n\t\t\t\t// Insert cloned node to position's parent node.\n\t\t\t\t( positionParent.parent as any )._insertChild( offsetAfter, clonedNode );\n\t\t\t\tthis._addToClonedElementsGroup( clonedNode );\n\n\t\t\t\t// Get nodes to move.\n\t\t\t\tconst count = ( positionParent as any ).childCount - positionOffset;\n\t\t\t\tconst nodesToMove = ( positionParent as any )._removeChildren( positionOffset, count );\n\n\t\t\t\t// Move nodes to cloned node.\n\t\t\t\tclonedNode._appendChild( nodesToMove );\n\n\t\t\t\t// Create new position to work on.\n\t\t\t\tconst newPosition = new ViewPosition( ( positionParent as any ).parent, offsetAfter );\n\n\t\t\t\treturn this._breakAttributes( newPosition, forceSplitText );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stores the information that an {@link module:engine/view/attributeelement~ViewAttributeElement attribute element} was\n\t * added to the tree. Saves the reference to the group in the given element and updates the group, so other elements\n\t * from the group now keep a reference to the given attribute element.\n\t *\n\t * The clones group can be obtained using {@link module:engine/view/attributeelement~ViewAttributeElement#getElementsWithSameId}.\n\t *\n\t * Does nothing if added element has no {@link module:engine/view/attributeelement~ViewAttributeElement#id id}.\n\t *\n\t * @param element Attribute element to save.\n\t */\n\tprivate _addToClonedElementsGroup( element: ViewNode ): void {\n\t\t// Add only if the element is in document tree.\n\t\tif ( !element.root.is( 'rootElement' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Traverse the element's children recursively to find other attribute elements that also might got inserted.\n\t\t// The loop is at the beginning so we can make fast returns later in the code.\n\t\tif ( element.is( 'element' ) ) {\n\t\t\tfor ( const child of element.getChildren() ) {\n\t\t\t\tthis._addToClonedElementsGroup( child );\n\t\t\t}\n\t\t}\n\n\t\tconst id = ( element as any ).id;\n\n\t\tif ( !id ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet group = this._cloneGroups.get( id );\n\n\t\tif ( !group ) {\n\t\t\tgroup = new Set();\n\t\t\tthis._cloneGroups.set( id, group );\n\t\t}\n\n\t\tgroup.add( element as ViewAttributeElement );\n\t\t( element as any )._clonesGroup = group;\n\t}\n\n\t/**\n\t * Removes all the information about the given {@link module:engine/view/attributeelement~ViewAttributeElement attribute element}\n\t * from its clones group.\n\t *\n\t * Keep in mind, that the element will still keep a reference to the group (but the group will not keep a reference to it).\n\t * This allows to reference the whole group even if the element was already removed from the tree.\n\t *\n\t * Does nothing if the element has no {@link module:engine/view/attributeelement~ViewAttributeElement#id id}.\n\t *\n\t * @param element Attribute element to remove.\n\t */\n\tprivate _removeFromClonedElementsGroup( element: ViewNode ) {\n\t\t// Traverse the element's children recursively to find other attribute elements that also got removed.\n\t\t// The loop is at the beginning so we can make fast returns later in the code.\n\t\tif ( element.is( 'element' ) ) {\n\t\t\tfor ( const child of element.getChildren() ) {\n\t\t\t\tthis._removeFromClonedElementsGroup( child );\n\t\t\t}\n\t\t}\n\n\t\tconst id = ( element as any ).id;\n\n\t\tif ( !id ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst group = this._cloneGroups.get( id );\n\n\t\tif ( !group ) {\n\t\t\treturn;\n\t\t}\n\n\t\tgroup.delete( element as ViewAttributeElement );\n\t\t// Not removing group from element on purpose!\n\t\t// If other parts of code have reference to this element, they will be able to get references to other elements from the group.\n\t}\n}\n\n// Helper function for `view.writer.wrap`. Checks if given element has any children that are not ui elements.\nfunction _hasNonUiChildren( parent: ViewElement ): boolean {\n\treturn Array.from( parent.getChildren() ).some( child => !child.is( 'uiElement' ) );\n}\n\n/**\n * The `attribute` passed to {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#wrap()`}\n * must be an instance of {@link module:engine/view/attributeelement~ViewAttributeElement `AttributeElement`}.\n *\n * @error view-writer-wrap-invalid-attribute\n */\n\n/**\n * Returns first parent container of specified {@link module:engine/view/position~ViewPosition Position}.\n * Position's parent node is checked as first, then next parents are checked.\n * Note that {@link module:engine/view/documentfragment~ViewDocumentFragment DocumentFragment} is treated like a container.\n *\n * @param position Position used as a start point to locate parent container.\n * @returns Parent container element or `undefined` if container is not found.\n */\nfunction getParentContainer( position: ViewPosition ): ViewContainerElement | ViewDocumentFragment | undefined {\n\tlet parent = position.parent;\n\n\twhile ( !isContainerOrFragment( parent ) ) {\n\t\tif ( !parent ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tparent = parent.parent as any;\n\t}\n\n\treturn ( parent as ViewContainerElement | ViewDocumentFragment );\n}\n\n/**\n * Checks if first {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement} provided to the function\n * can be wrapped outside second element. It is done by comparing elements'\n * {@link module:engine/view/attributeelement~ViewAttributeElement#priority priorities}, if both have same priority\n * {@link module:engine/view/element~ViewElement#getIdentity identities} are compared.\n */\nfunction shouldABeOutsideB( a: ViewAttributeElement, b: ViewAttributeElement ): boolean {\n\tif ( a.priority < b.priority ) {\n\t\treturn true;\n\t} else if ( a.priority > b.priority ) {\n\t\treturn false;\n\t}\n\n\t// When priorities are equal and names are different - use identities.\n\treturn a.getIdentity() < b.getIdentity();\n}\n\n/**\n * Returns new position that is moved to near text node. Returns same position if there is no text node before of after\n * specified position.\n *\n * ```html\n *
foo[]
->
foo{}
\n *
[]foo
->
{}foo
\n * ```\n *\n * @returns Position located inside text node or same position if there is no text nodes\n * before or after position location.\n */\nfunction movePositionToTextNode( position: ViewPosition ): ViewPosition {\n\tconst nodeBefore = position.nodeBefore;\n\n\tif ( nodeBefore && nodeBefore.is( '$text' ) ) {\n\t\treturn new ViewPosition( nodeBefore, nodeBefore.data.length );\n\t}\n\n\tconst nodeAfter = position.nodeAfter;\n\n\tif ( nodeAfter && nodeAfter.is( '$text' ) ) {\n\t\treturn new ViewPosition( nodeAfter, 0 );\n\t}\n\n\treturn position;\n}\n\n/**\n * Breaks text node into two text nodes when possible.\n *\n * ```html\n *
foo{}bar
->
foo[]bar
\n *
{}foobar
->
[]foobar
\n *
foobar{}
->
foobar[]
\n * ```\n *\n * @param position Position that need to be placed inside text node.\n * @returns New position after breaking text node.\n */\nfunction breakTextNode( position: ViewPosition ): ViewPosition {\n\tif ( position.offset == ( position.parent as ViewText ).data.length ) {\n\t\treturn new ViewPosition( position.parent.parent as any, ( position.parent as ViewText ).index! + 1 );\n\t}\n\n\tif ( position.offset === 0 ) {\n\t\treturn new ViewPosition( position.parent.parent as any, ( position.parent as ViewText ).index! );\n\t}\n\n\t// Get part of the text that need to be moved.\n\tconst textToMove = ( position.parent as ViewText ).data.slice( position.offset );\n\n\t// Leave rest of the text in position's parent.\n\t( position.parent as ViewText )._data = ( position.parent as ViewText ).data.slice( 0, position.offset );\n\n\t// Insert new text node after position's parent text node.\n\t( position.parent.parent as any )._insertChild(\n\t\t( position.parent as ViewText ).index! + 1,\n\t\tnew ViewText( position.root.document, textToMove )\n\t);\n\n\t// Return new position between two newly created text nodes.\n\treturn new ViewPosition( position.parent.parent as any, ( position.parent as ViewText ).index! + 1 );\n}\n\n/**\n * Merges two text nodes into first node. Removes second node and returns merge position.\n *\n * @param t1 First text node to merge. Data from second text node will be moved at the end of this text node.\n * @param t2 Second text node to merge. This node will be removed after merging.\n * @returns Position after merging text nodes.\n */\nfunction mergeTextNodes( t1: ViewText, t2: ViewText ): ViewPosition {\n\t// Merge text data into first text node and remove second one.\n\tconst nodeBeforeLength = t1.data.length;\n\tt1._data += t2.data;\n\tt2._remove();\n\n\treturn new ViewPosition( t1, nodeBeforeLength );\n}\n\nconst validNodesToInsert = [ ViewText, ViewAttributeElement, ViewContainerElement, ViewEmptyElement, ViewRawElement, ViewUIElement ];\n\n/**\n * Checks if provided nodes are valid to insert.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert\n * contains instances that are not supported ones (see error description for valid ones.\n */\nfunction validateNodesToInsert( nodes: Iterable, errorContext: ViewDocument ): void {\n\tfor ( const node of nodes ) {\n\t\tif ( !validNodesToInsert.some( validNode => node instanceof validNode ) ) {\n\t\t\t/**\n\t\t\t * One of the nodes to be inserted is of an invalid type.\n\t\t\t *\n\t\t\t * Nodes to be inserted with {@link module:engine/view/downcastwriter~ViewDowncastWriter#insert `ViewDowncastWriter#insert()`}\n\t\t\t * should be of the following types:\n\t\t\t *\n\t\t\t * * {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement},\n\t\t\t * * {@link module:engine/view/containerelement~ViewContainerElement ViewContainerElement},\n\t\t\t * * {@link module:engine/view/emptyelement~ViewEmptyElement ViewEmptyElement},\n\t\t\t * * {@link module:engine/view/uielement~ViewUIElement UIElement},\n\t\t\t * * {@link module:engine/view/rawelement~ViewRawElement RawElement},\n\t\t\t * * {@link module:engine/view/text~ViewText Text}.\n\t\t\t *\n\t\t\t * @error view-writer-insert-invalid-node-type\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-insert-invalid-node-type', errorContext );\n\t\t}\n\n\t\tif ( !node.is( '$text' ) ) {\n\t\t\tvalidateNodesToInsert( ( node as ViewElement ).getChildren(), errorContext );\n\t\t}\n\t}\n}\n\n/**\n * Checks if node is ViewContainerElement or DocumentFragment, because in most cases they should be treated the same way.\n *\n * @returns Returns `true` if node is instance of ViewContainerElement or DocumentFragment.\n */\nfunction isContainerOrFragment( node: ViewNode | ViewDocumentFragment ): boolean {\n\treturn node && ( node.is( 'containerElement' ) || node.is( 'documentFragment' ) );\n}\n\n/**\n * Checks if {@link module:engine/view/range~ViewRange#start range start} and {@link module:engine/view/range~ViewRange#end range end}\n * are placed inside same {@link module:engine/view/containerelement~ViewContainerElement container element}.\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when validation fails.\n */\nfunction validateRangeContainer( range: ViewRange, errorContext: ViewDocument ) {\n\tconst startContainer = getParentContainer( range.start );\n\tconst endContainer = getParentContainer( range.end );\n\n\tif ( !startContainer || !endContainer || startContainer !== endContainer ) {\n\t\t/**\n\t\t * The container of the given range is invalid.\n\t\t *\n\t\t * This may happen if {@link module:engine/view/range~ViewRange#start range start} and\n\t\t * {@link module:engine/view/range~ViewRange#end range end} positions are not placed inside the same container element or\n\t\t * a parent container for these positions cannot be found.\n\t\t *\n\t\t * Methods like {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#remove()`},\n\t\t * {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#clean()`},\n\t\t * {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#wrap()`},\n\t\t * {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#unwrap()`} need to be called\n\t\t * on a range that has its start and end positions located in the same container element. Both positions can be\n\t\t * nested within other elements (e.g. an attribute element) but the closest container ancestor must be the same.\n\t\t *\n\t\t * @error view-writer-invalid-range-container\n\t\t */\n\t\tthrow new CKEditorError( 'view-writer-invalid-range-container', errorContext );\n\t}\n}\n\n/**\n * Checks if the provided argument is a plain object that can be used as options for container element.\n */\nfunction isContainerOptions(\n\tchildrenOrOptions: ViewNode | Iterable | { renderUnsafeAttributes?: Array }\n): childrenOrOptions is { renderUnsafeAttributes?: Array } {\n\treturn isPlainObject( childrenOrOptions );\n}\n","/**\n * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\nimport { keyCodes, isText, type KeystrokeInfo } from '@ckeditor/ckeditor5-utils';\nimport { type EditingView } from './view.js';\nimport { type ViewDocumentDomEventData } from './observer/domeventdata.js';\nimport type { ViewDocumentArrowKeyEvent } from './observer/arrowkeysobserver.js';\n\n/**\n * Set of utilities related to handling block and inline fillers.\n *\n * Browsers do not allow to put caret in elements which does not have height. Because of it, we need to fill all\n * empty elements which should be selectable with elements or characters called \"fillers\". Unfortunately there is no one\n * universal filler, this is why two types are uses:\n *\n * * Block filler is an element which fill block elements, like `
`. CKEditor uses ` ` as a block filler during the editing,\n * as browsers do natively. So instead of an empty `
` there will be `
`. The advantage of block filler is that\n * it is transparent for the selection, so when the caret is before the ` ` and user presses right arrow he will be\n * moved to the next paragraph, not after the ` `. The disadvantage is that it breaks a block, so it cannot be used\n * in the middle of a line of text. The {@link module:engine/view/filler~BR_FILLER ` ` filler} can be replaced with any other\n * character in the data output, for instance {@link module:engine/view/filler~NBSP_FILLER non-breaking space} or\n * {@link module:engine/view/filler~MARKED_NBSP_FILLER marked non-breaking space}.\n *\n * * Inline filler is a filler which does not break a line of text, so it can be used inside the text, for instance in the empty\n * `` surrendered by text: `foobar`, if we want to put the caret there. CKEditor uses a sequence of the zero-width\n * spaces as an {@link module:engine/view/filler~INLINE_FILLER inline filler} having the predetermined\n * {@link module:engine/view/filler~INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to\n * avoid treating random zero-width spaces as the inline filler. Disadvantage of the inline filler is that it is not\n * transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional\n * code is needed to handle the caret.\n *\n * Both inline and block fillers are handled by the {@link module:engine/view/renderer~ViewRenderer renderer} and are not present in the\n * view.\n *\n * @module engine/view/filler\n */\n\n/**\n * Non-breaking space filler creator. This function creates the ` ` text node.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~MARKED_NBSP_FILLER\n * @see module:engine/view/filler~BR_FILLER\n * @internal\n */\nexport const NBSP_FILLER = ( domDocument: Document ): Text => domDocument.createTextNode( '\\u00A0' );\n\n/**\n * Marked non-breaking space filler creator. This function creates the `` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @see module:engine/view/filler~BR_FILLER\n * @internal\n */\nexport const MARKED_NBSP_FILLER = ( domDocument: Document ): HTMLSpanElement => {\n\tconst span = domDocument.createElement( 'span' );\n\tspan.dataset.ckeFiller = 'true';\n\tspan.innerText = '\\u00A0';\n\n\treturn span;\n};\n\n/**\n * ` ` filler creator. This function creates the ` ` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @see module:engine/view/filler~MARKED_NBSP_FILLER\n * @internal\n */\nexport const BR_FILLER = ( domDocument: Document ): HTMLBRElement => {\n\tconst fillerBr = domDocument.createElement( 'br' );\n\tfillerBr.dataset.ckeFiller = 'true';\n\n\treturn fillerBr;\n};\n\n/**\n * Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.\n *\n * @internal\n */\nexport const INLINE_FILLER_LENGTH = 7;\n\n/**\n * Inline filler which is a sequence of the word joiners.\n *\n * @internal\n */\nexport const INLINE_FILLER = '\\u2060'.repeat( INLINE_FILLER_LENGTH );\n\n/**\n * Checks if the node is a text node which starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n * ```ts\n * startsWithFiller( document.createTextNode( INLINE_FILLER ) ); // true\n * startsWithFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // true\n * startsWithFiller( document.createTextNode( 'foo' ) ); // false\n * startsWithFiller( document.createElement( 'p' ) ); // false\n * ```\n *\n * @param domNode DOM node.\n * @returns True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n * @internal\n */\nexport function startsWithFiller( domNode: Node | string ): boolean {\n\tif ( typeof domNode == 'string' ) {\n\t\treturn domNode.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER;\n\t}\n\n\treturn isText( domNode ) && ( domNode.data.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER );\n}\n\n/**\n * Checks if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n * ```ts\n * isInlineFiller( document.createTextNode( INLINE_FILLER ) ); // true\n * isInlineFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // false\n * ```\n *\n * @param domText DOM text node.\n * @returns True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n * @internal\n */\nexport function isInlineFiller( domText: Text ): boolean {\n\treturn domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller( domText );\n}\n\n/**\n * Get string data from the text node, removing an {@link module:engine/view/filler~INLINE_FILLER inline filler} from it,\n * if text node contains it.\n *\n * ```ts\n * getDataWithoutFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ) == 'foo' // true\n * getDataWithoutFiller( document.createTextNode( 'foo' ) ) == 'foo' // true\n * ```\n *\n * @param domText DOM text node, possible with inline filler.\n * @returns Data without filler.\n * @internal\n */\nexport function getDataWithoutFiller( domText: Text | string ): string {\n\tconst data = typeof domText == 'string' ? domText : domText.data;\n\n\tif ( startsWithFiller( domText ) ) {\n\t\treturn data.slice( INLINE_FILLER_LENGTH );\n\t}\n\n\treturn data;\n}\n\n/**\n * Assign key observer which move cursor from the end of the inline filler to the beginning of it when\n * the left arrow is pressed, so the filler does not break navigation.\n *\n * @param view View controller instance we should inject quirks handling on.\n * @internal\n */\nexport function injectQuirksHandling( view: EditingView ): void {\n\tview.document.on( 'arrowKey', jumpOverInlineFiller, { priority: 'low' } );\n}\n\n/**\n * Move cursor from the end of the inline filler to the beginning of it when, so the filler does not break navigation.\n */\nfunction jumpOverInlineFiller( evt: unknown, data: ViewDocumentDomEventData & KeystrokeInfo ) {\n\tif ( data.keyCode == keyCodes.arrowleft ) {\n\t\tconst domSelection = data.domTarget.ownerDocument.defaultView!.getSelection()!;\n\n\t\tif ( domSelection.rangeCount == 1 && domSelection.getRangeAt( 0 ).collapsed ) {\n\t\t\tconst domParent = domSelection.getRangeAt( 0 ).startContainer;\n\t\t\tconst domOffset = domSelection.getRangeAt( 0 ).startOffset;\n\n\t\t\tif ( startsWithFiller( domParent ) && domOffset <= INLINE_FILLER_LENGTH ) {\n\t\t\t\tdomSelection.collapse( domParent, 0 );\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module engine/view/renderer\n */\n\nimport { ViewText } from './text.js';\nimport { ViewPosition } from './position.js';\nimport { INLINE_FILLER, INLINE_FILLER_LENGTH, startsWithFiller, isInlineFiller } from './filler.js';\n\nimport {\n\tCKEditorError,\n\tObservableMixin,\n\tdiff,\n\tenv,\n\tfastDiff,\n\tinsertAt,\n\tisComment,\n\tisNode,\n\tisText,\n\tremove,\n\tindexOf,\n\ttype DiffResult,\n\ttype ObservableChangeEvent\n} from '@ckeditor/ckeditor5-utils';\n\nimport type { ViewDocumentChangeType } from './document.js';\nimport { type ViewDocumentSelection } from './documentselection.js';\nimport { type ViewDomConverter } from './domconverter.js';\nimport { type ViewElement } from './element.js';\nimport { type ViewNode } from './node.js';\n\n// @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '../dev-utils/utils.js' );\n\nimport '../../theme/renderer.css';\n\ntype DomText = globalThis.Text;\ntype DomNode = globalThis.Node;\ntype DomDocument = globalThis.Document;\ntype DomElement = globalThis.HTMLElement;\ntype DomSelection = globalThis.Selection;\n\n/**\n * Renderer is responsible for updating the DOM structure and the DOM selection based on\n * the {@link module:engine/view/renderer~ViewRenderer#markToSync information about updated view nodes}.\n * In other words, it renders the view to the DOM.\n *\n * Its main responsibility is to make only the necessary, minimal changes to the DOM. However, unlike in many\n * virtual DOM implementations, the primary reason for doing minimal changes is not the performance but ensuring\n * that native editing features such as text composition, autocompletion, spell checking, selection's x-index are\n * affected as little as possible.\n *\n * Renderer uses {@link module:engine/view/domconverter~ViewDomConverter} to transform view nodes and positions\n * to and from the DOM.\n */\nexport class ViewRenderer extends /* #__PURE__ */ ObservableMixin() {\n\t/**\n\t * Set of DOM Documents instances.\n\t */\n\tpublic readonly domDocuments: Set = new Set();\n\n\t/**\n\t * Converter instance.\n\t */\n\tpublic readonly domConverter: ViewDomConverter;\n\n\t/**\n\t * Set of nodes which attributes changed and may need to be rendered.\n\t */\n\tpublic readonly markedAttributes: Set = new Set();\n\n\t/**\n\t * Set of elements which child lists changed and may need to be rendered.\n\t */\n\tpublic readonly markedChildren: Set = new Set();\n\n\t/**\n\t * Set of text nodes which text data changed and may need to be rendered.\n\t */\n\tpublic readonly markedTexts: Set = new Set();\n\n\t/**\n\t * View selection. Renderer updates DOM selection based on the view selection.\n\t */\n\tpublic readonly selection: ViewDocumentSelection;\n\n\t/**\n\t * Indicates if the view document is focused and selection can be rendered. Selection will not be rendered if\n\t * this is set to `false`.\n\t *\n\t * @observable\n\t */\n\tdeclare public readonly isFocused: boolean;\n\n\t/**\n\t * Indicates whether the user is making a selection in the document (e.g. holding the mouse button and moving the cursor).\n\t * When they stop selecting, the property goes back to `false`.\n\t *\n\t * Note: In some browsers, the renderer will stop rendering the selection and inline fillers while the user is making\n\t * a selection to avoid glitches in DOM selection\n\t * (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n\t *\n\t * @observable\n\t */\n\tdeclare public readonly isSelecting: boolean;\n\n\t/**\n\t * True if composition is in progress inside the document.\n\t *\n\t * This property is bound to the {@link module:engine/view/document~ViewDocument#isComposing `Document#isComposing`} property.\n\t *\n\t * @observable\n\t */\n\tdeclare public readonly isComposing: boolean;\n\n\t/**\n\t * The text node in which the inline filler was rendered.\n\t */\n\tprivate _inlineFiller: DomText | null = null;\n\n\t/**\n\t * DOM element containing fake selection.\n\t */\n\tprivate _fakeSelectionContainer: DomElement | null = null;\n\n\t/**\n\t * Creates a renderer instance.\n\t *\n\t * @param domConverter Converter instance.\n\t * @param selection View selection.\n\t */\n\tconstructor( domConverter: ViewDomConverter, selection: ViewDocumentSelection ) {\n\t\tsuper();\n\n\t\tthis.domConverter = domConverter;\n\t\tthis.selection = selection;\n\n\t\tthis.set( 'isFocused', false );\n\t\tthis.set( 'isSelecting', false );\n\t\tthis.set( 'isComposing', false );\n\n\t\t// Rendering the selection and inline filler manipulation should be postponed in (non-Android) Blink until the user finishes\n\t\t// creating the selection in DOM to avoid accidental selection collapsing\n\t\t// (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n\t\t// When the user stops selecting, all pending changes should be rendered ASAP, though.\n\t\tif ( env.isBlink && !env.isAndroid ) {\n\t\t\tthis.on( 'change:isSelecting', () => {\n\t\t\t\tif ( !this.isSelecting ) {\n\t\t\t\t\tthis.render();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Marks a view node to be updated in the DOM by {@link #render `render()`}.\n\t *\n\t * Note that only view nodes whose parents have corresponding DOM elements need to be marked to be synchronized.\n\t *\n\t * @see #markedAttributes\n\t * @see #markedChildren\n\t * @see #markedTexts\n\t *\n\t * @param type Type of the change.\n\t * @param node ViewNode to be marked.\n\t */\n\tpublic markToSync( type: ViewDocumentChangeType, node: ViewNode ): void {\n\t\tif ( type === 'text' ) {\n\t\t\tif ( this.domConverter.mapViewToDom( node.parent! ) ) {\n\t\t\t\tthis.markedTexts.add( node );\n\t\t\t}\n\t\t} else {\n\t\t\t// If the node has no DOM element it is not rendered yet,\n\t\t\t// its children/attributes do not need to be marked to be sync.\n\t\t\tif ( !this.domConverter.mapViewToDom( node as ViewElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( type === 'attributes' ) {\n\t\t\t\tthis.markedAttributes.add( node as ViewElement );\n\t\t\t} else if ( type === 'children' ) {\n\t\t\t\tthis.markedChildren.add( node as ViewElement );\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t\tconst unreachable: never = type;\n\n\t\t\t\t/**\n\t\t\t\t * Unknown type passed to Renderer.markToSync.\n\t\t\t\t *\n\t\t\t\t * @error view-renderer-unknown-type\n\t\t\t\t */\n\t\t\t\tthrow new CKEditorError( 'view-renderer-unknown-type', this );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Renders all buffered changes ({@link #markedAttributes}, {@link #markedChildren} and {@link #markedTexts}) and\n\t * the current view selection (if needed) to the DOM by applying a minimal set of changes to it.\n\t *\n\t * Renderer tries not to break the text composition (e.g. IME) and x-index of the selection,\n\t * so it does as little as it is needed to update the DOM.\n\t *\n\t * Renderer also handles {@link module:engine/view/filler fillers}. Especially, it checks if the inline filler is needed\n\t * at the selection position and adds or removes it. To prevent breaking text composition inline filler will not be\n\t * removed as long as the selection is in the text node which needed it at first.\n\t */\n\tpublic render(): void {\n\t\t// Ignore rendering while in the composition mode. Composition events are not cancellable and browser will modify the DOM tree.\n\t\t// All marked elements, attributes, etc. will wait until next render after the composition ends.\n\t\t// On Android composition events are immediately applied to the model, so we don't need to skip rendering,\n\t\t// and we should not do it because the difference between view and DOM could lead to position mapping problems.\n\t\tif ( this.isComposing && !env.isAndroid ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'%cRendering aborted while isComposing.',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'font-style: italic'\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\treturn;\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'%cRendering',\n\t\t// @if CK_DEBUG_TYPING // \t\t'font-weight: bold'\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tlet inlineFillerPosition: ViewPosition | null = null;\n\t\tconst isInlineFillerRenderingPossible = env.isBlink && !env.isAndroid ? !this.isSelecting : true;\n\n\t\t// Refresh mappings.\n\t\tfor ( const element of this.markedChildren ) {\n\t\t\tthis._updateChildrenMappings( element );\n\t\t}\n\n\t\t// Don't manipulate inline fillers while the selection is being made in (non-Android) Blink to prevent accidental\n\t\t// DOM selection collapsing\n\t\t// (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n\t\tif ( isInlineFillerRenderingPossible ) {\n\t\t\t// There was inline filler rendered in the DOM but it's not\n\t\t\t// at the selection position any more, so we can remove it\n\t\t\t// (cause even if it's needed, it must be placed in another location).\n\t\t\tif ( this._inlineFiller && !this._isSelectionInInlineFiller() ) {\n\t\t\t\tthis._removeInlineFiller();\n\t\t\t}\n\n\t\t\t// If we've got the filler, let's try to guess its position in the view.\n\t\t\tif ( this._inlineFiller ) {\n\t\t\t\tinlineFillerPosition = this._getInlineFillerPosition();\n\t\t\t}\n\t\t\t// Otherwise, if it's needed, create it at the selection position.\n\t\t\telse if ( this._needsInlineFillerAtSelection() ) {\n\t\t\t\tinlineFillerPosition = this.selection.getFirstPosition()!;\n\n\t\t\t\t// Do not use `markToSync` so it will be added even if the parent is already added.\n\t\t\t\tthis.markedChildren.add( inlineFillerPosition.parent as ViewElement );\n\t\t\t}\n\t\t}\n\t\t// Make sure the inline filler has any parent, so it can be mapped to view position by ViewDomConverter.\n\t\telse if ( this._inlineFiller && this._inlineFiller.parentNode ) {\n\t\t\t// While the user is making selection, preserve the inline filler at its original position.\n\t\t\tinlineFillerPosition = this.domConverter.domPositionToView( this._inlineFiller )!;\n\n\t\t\t// While down-casting the document selection attributes, all existing empty\n\t\t\t// attribute elements (for selection position) are removed from the view and DOM,\n\t\t\t// so make sure that we were able to map filler position.\n\t\t\t// https://github.com/ckeditor/ckeditor5/issues/12026\n\t\t\tif ( inlineFillerPosition && inlineFillerPosition.parent.is( '$text' ) ) {\n\t\t\t\t// The inline filler position is expected to be before the text node.\n\t\t\t\tinlineFillerPosition = ViewPosition._createBefore( inlineFillerPosition.parent );\n\t\t\t}\n\t\t}\n\n\t\tfor ( const element of this.markedAttributes ) {\n\t\t\tthis._updateAttrs( element );\n\t\t}\n\n\t\tfor ( const element of this.markedChildren ) {\n\t\t\tthis._updateChildren( element, { inlineFillerPosition } );\n\t\t}\n\n\t\tfor ( const node of this.markedTexts ) {\n\t\t\tif ( !this.markedChildren.has( node.parent as ViewElement ) && this.domConverter.mapViewToDom( node.parent as ViewElement ) ) {\n\t\t\t\tthis._updateText( node as ViewText, { inlineFillerPosition } );\n\t\t\t}\n\t\t}\n\n\t\t// * Check whether the inline filler is required and where it really is in the DOM.\n\t\t// At this point in most cases it will be in the DOM, but there are exceptions.\n\t\t// For example, if the inline filler was deep in the created DOM structure, it will not be created.\n\t\t// Similarly, if it was removed at the beginning of this function and then neither text nor children were updated,\n\t\t// it will not be present. Fix those and similar scenarios.\n\t\t// * Don't manipulate inline fillers while the selection is being made in (non-Android) Blink to prevent accidental\n\t\t// DOM selection collapsing\n\t\t// (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n\t\tif ( isInlineFillerRenderingPossible ) {\n\t\t\tif ( inlineFillerPosition ) {\n\t\t\t\tconst fillerDomPosition = this.domConverter.viewPositionToDom( inlineFillerPosition )!;\n\t\t\t\tconst domDocument = fillerDomPosition.parent.ownerDocument!;\n\n\t\t\t\tif ( !startsWithFiller( fillerDomPosition.parent ) ) {\n\t\t\t\t\t// Filler has not been created at filler position. Create it now.\n\t\t\t\t\tthis._inlineFiller = addInlineFiller( domDocument, fillerDomPosition.parent, fillerDomPosition.offset );\n\t\t\t\t} else {\n\t\t\t\t\t// Filler has been found, save it.\n\t\t\t\t\tthis._inlineFiller = fillerDomPosition.parent as DomText;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// There is no filler needed.\n\t\t\t\tthis._inlineFiller = null;\n\t\t\t}\n\t\t}\n\n\t\t// First focus the new editing host, then update the selection.\n\t\t// Otherwise, FF may throw an error (https://github.com/ckeditor/ckeditor5/issues/721).\n\t\tthis._updateFocus();\n\t\tthis._updateSelection();\n\n\t\tthis.domConverter._clearTemporaryCustomProperties();\n\n\t\tthis.markedTexts.clear();\n\t\tthis.markedAttributes.clear();\n\t\tthis.markedChildren.clear();\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n\t\t// @if CK_DEBUG_TYPING // }\n\t}\n\n\t/**\n\t * Updates mappings of view element's children.\n\t *\n\t * Children that were replaced in the view structure by similar elements (same tag name) are treated as 'replaced'.\n\t * This means that their mappings can be updated so the new view elements are mapped to the existing DOM elements.\n\t * Thanks to that these elements do not need to be re-rendered completely.\n\t *\n\t * @param viewElement The view element whose children mappings will be updated.\n\t */\n\tprivate _updateChildrenMappings( viewElement: ViewElement ): void {\n\t\tconst domElement = this.domConverter.mapViewToDom( viewElement );\n\n\t\tif ( !domElement ) {\n\t\t\t// If there is no `domElement` it means that it was already removed from DOM and there is no need to process it.\n\t\t\treturn;\n\t\t}\n\n\t\t// Removing nodes from the DOM as we iterate can cause `actualDomChildren`\n\t\t// (which is a live-updating `NodeList`) to get out of sync with the\n\t\t// indices that we compute as we iterate over `actions`.\n\t\t// This would produce incorrect element mappings.\n\t\t//\n\t\t// Converting live list to an array to make the list static.\n\t\tconst actualDomChildren = Array.from(\n\t\t\tdomElement.childNodes\n\t\t);\n\t\tconst expectedDomChildren = Array.from(\n\t\t\tthis.domConverter.viewChildrenToDom( viewElement, { withChildren: false } )\n\t\t);\n\t\tconst diff = this._diffNodeLists( actualDomChildren, expectedDomChildren );\n\t\tconst actions = this._findUpdateActions( diff, actualDomChildren, expectedDomChildren, areSimilarElements );\n\n\t\tif ( actions.indexOf( 'update' ) !== -1 ) {\n\t\t\tconst counter = { equal: 0, insert: 0, delete: 0 };\n\n\t\t\tfor ( const action of actions ) {\n\t\t\t\tif ( action === 'update' ) {\n\t\t\t\t\tconst insertIndex = counter.equal + counter.insert;\n\t\t\t\t\tconst deleteIndex = counter.equal + counter.delete;\n\t\t\t\t\tconst viewChild = viewElement.getChild( insertIndex );\n\n\t\t\t\t\t// UIElement and RawElement are special cases. Their children are not stored in a view (#799)\n\t\t\t\t\t// so we cannot use them with replacing flow (since they use view children during rendering\n\t\t\t\t\t// which will always result in rendering empty elements).\n\t\t\t\t\tif ( viewChild && !viewChild.is( 'uiElement' ) && !viewChild.is( 'rawElement' ) ) {\n\t\t\t\t\t\tthis._updateElementMappings( viewChild as ViewElement, actualDomChildren[ deleteIndex ] as DomElement );\n\t\t\t\t\t}\n\n\t\t\t\t\tremove( expectedDomChildren[ insertIndex ] );\n\t\t\t\t\tcounter.equal++;\n\t\t\t\t} else {\n\t\t\t\t\tcounter[ action ]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates mappings of a given view element.\n\t *\n\t * @param viewElement The view element whose mappings will be updated.\n\t * @param domElement The DOM element representing the given view element.\n\t */\n\tprivate _updateElementMappings( viewElement: ViewElement, domElement: DomElement ): void {\n\t\t// Remap 'DomConverter' bindings.\n\t\tthis.domConverter.unbindDomElement( domElement );\n\t\tthis.domConverter.bindElements( domElement, viewElement );\n\n\t\t// View element may have children which needs to be updated, but are not marked, mark them to update.\n\t\tthis.markedChildren.add( viewElement );\n\n\t\t// Because we replace new view element mapping with the existing one, the corresponding DOM element\n\t\t// will not be rerendered. The new view element may have different attributes than the previous one.\n\t\t// Since its corresponding DOM element will not be rerendered, new attributes will not be added\n\t\t// to the DOM, so we need to mark it here to make sure its attributes gets updated. See #1427 for more\n\t\t// detailed case study.\n\t\t// Also there are cases where replaced element is removed from the view structure and then has\n\t\t// its attributes changed or removed. In such cases the element will not be present in `markedAttributes`\n\t\t// and also may be the same (`element.isSimilar()`) as the reused element not having its attributes updated.\n\t\t// To prevent such situations we always mark reused element to have its attributes rerenderd (#1560).\n\t\tthis.markedAttributes.add( viewElement );\n\t}\n\n\t/**\n\t * Gets the position of the inline filler based on the current selection.\n\t * Here, we assume that we know that the filler is needed and\n\t * {@link #_isSelectionInInlineFiller is at the selection position}, and, since it is needed,\n\t * it is somewhere at the selection position.\n\t *\n\t * Note: The filler position cannot be restored based on the filler's DOM text node, because\n\t * when this method is called (before rendering), the bindings will often be broken. View-to-DOM\n\t * bindings are only dependable after rendering.\n\t */\n\tprivate _getInlineFillerPosition(): ViewPosition {\n\t\tconst firstPos = this.selection.getFirstPosition()!;\n\n\t\tif ( firstPos.parent.is( '$text' ) ) {\n\t\t\treturn ViewPosition._createBefore( firstPos.parent );\n\t\t} else {\n\t\t\treturn firstPos;\n\t\t}\n\t}\n\n\t/**\n\t * Returns `true` if the selection has not left the inline filler's text node.\n\t * If it is `true`, it means that the filler had been added for a reason and the selection did not\n\t * leave the filler's text node. For example, the user can be in the middle of a composition so it should not be touched.\n\t *\n\t * @returns `true` if the inline filler and selection are in the same place.\n\t */\n\tprivate _isSelectionInInlineFiller(): boolean {\n\t\tif ( this.selection.rangeCount != 1 || !this.selection.isCollapsed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Note, we can't check if selection's position equals position of the\n\t\t// this._inlineFiller node, because of #663. We may not be able to calculate\n\t\t// the filler's position in the view at this stage.\n\t\t// Instead, we check it the other way – whether selection is anchored in\n\t\t// that text node or next to it.\n\n\t\t// Possible options are:\n\t\t// \"FILLER{}\"\n\t\t// \"FILLERadded-text{}\"\n\t\tconst selectionPosition = this.selection.getFirstPosition()!;\n\t\tconst position = this.domConverter.viewPositionToDom( selectionPosition );\n\n\t\tif ( position && isText( position.parent ) && startsWithFiller( position.parent ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Removes the inline filler.\n\t */\n\tprivate _removeInlineFiller(): void {\n\t\tconst domFillerNode = this._inlineFiller!;\n\n\t\t// Something weird happened and the stored node doesn't contain the filler's text.\n\t\tif ( !startsWithFiller( domFillerNode ) ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.log( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'Inline filler node: ' +\n\t\t\t// @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( domFillerNode.data ) }%c (${ domFillerNode.data.length })`,\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'color: blue',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t''\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\t/**\n\t\t\t * The inline filler node was lost. Most likely, something overwrote the filler text node\n\t\t\t * in the DOM.\n\t\t\t *\n\t\t\t * @error view-renderer-filler-was-lost\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-renderer-filler-was-lost', this );\n\t\t}\n\n\t\tif ( isInlineFiller( domFillerNode ) ) {\n\t\t\tdomFillerNode.remove();\n\t\t} else {\n\t\t\tdomFillerNode.data = domFillerNode.data.substr( INLINE_FILLER_LENGTH );\n\t\t}\n\n\t\tthis._inlineFiller = null;\n\t}\n\n\t/**\n\t * Checks if the inline {@link module:engine/view/filler filler} should be added.\n\t *\n\t * @returns `true` if the inline filler should be added.\n\t */\n\tprivate _needsInlineFillerAtSelection(): boolean {\n\t\tif ( this.selection.rangeCount != 1 || !this.selection.isCollapsed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst selectionPosition = this.selection.getFirstPosition()!;\n\t\tconst selectionParent = selectionPosition.parent;\n\t\tconst selectionOffset = selectionPosition.offset;\n\n\t\t// If there is no DOM root we do not care about fillers.\n\t\tif ( !this.domConverter.mapViewToDom( selectionParent.root ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( !( selectionParent.is( 'element' ) ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Prevent adding inline filler inside elements with contenteditable=false.\n\t\t// https://github.com/ckeditor/ckeditor5-engine/issues/1170\n\t\tif ( !isEditable( selectionParent ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst nodeBefore = selectionPosition.nodeBefore;\n\t\tconst nodeAfter = selectionPosition.nodeAfter;\n\n\t\tif ( nodeBefore instanceof ViewText || nodeAfter instanceof ViewText ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// We have block filler, we do not need inline one.\n\t\tif ( selectionOffset === selectionParent.getFillerOffset!() && ( !nodeBefore || !nodeBefore.is( 'element', 'br' ) ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Do not use inline filler while typing outside inline elements on Android.\n\t\t// The deleteContentBackward would remove part of the inline filler instead of removing last letter in a link.\n\t\tif ( env.isAndroid && ( nodeBefore || nodeAfter ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Checks if text needs to be updated and possibly updates it.\n\t *\n\t * @param viewText View text to update.\n\t * @param options.inlineFillerPosition The position where the inline filler should be rendered.\n\t */\n\tprivate _updateText( viewText: ViewText, options: { inlineFillerPosition?: ViewPosition | null } ) {\n\t\tconst domText = this.domConverter.findCorrespondingDomText( viewText )!;\n\t\tconst newDomText = this.domConverter.viewToDom( viewText );\n\n\t\tlet expectedText = newDomText.data;\n\t\tconst filler = options.inlineFillerPosition;\n\n\t\tif ( filler && filler.parent == viewText.parent && filler.offset == viewText.index ) {\n\t\t\texpectedText = INLINE_FILLER + expectedText;\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'%cUpdate text',\n\t\t// @if CK_DEBUG_TYPING // \t\t'font-weight: normal'\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tthis._updateTextNode( domText, expectedText );\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n\t\t// @if CK_DEBUG_TYPING // }\n\t}\n\n\t/**\n\t * Checks if attribute list needs to be updated and possibly updates it.\n\t *\n\t * @param viewElement The view element to update.\n\t */\n\tprivate _updateAttrs( viewElement: ViewElement ): void {\n\t\tconst domElement = this.domConverter.mapViewToDom( viewElement );\n\n\t\tif ( !domElement ) {\n\t\t\t// If there is no `domElement` it means that 'viewElement' is outdated as its mapping was updated\n\t\t\t// in 'this._updateChildrenMappings()'. There is no need to process it as new view element which\n\t\t\t// replaced old 'viewElement' mapping was also added to 'this.markedAttributes'\n\t\t\t// in 'this._updateChildrenMappings()' so it will be processed separately.\n\t\t\treturn;\n\t\t}\n\n\t\t// Remove attributes from DOM elements if they do not exist in the view.\n\t\t//\n\t\t// Note: It is important to first remove DOM attributes and then set new ones, because some view attributes may be renamed\n\t\t// as they are set on DOM (due to unsafe attributes handling). If we set the view attribute first, and then remove\n\t\t// non-existing DOM attributes, then we would remove the attribute that we just set.\n\t\t//\n\t\t// Note: The domElement.attributes is a live collection, so we need to convert it to an array to avoid issues.\n\t\tfor ( const domAttr of Array.from( ( domElement as DomElement ).attributes ) ) {\n\t\t\tconst key = domAttr.name;\n\n\t\t\t// All other attributes not present in the DOM should be removed.\n\t\t\tif ( !viewElement.hasAttribute( key ) ) {\n\t\t\t\tthis.domConverter.removeDomElementAttribute( domElement as DomElement, key );\n\t\t\t}\n\t\t}\n\n\t\t// Add or overwrite attributes.\n\t\tfor ( const key of viewElement.getAttributeKeys() ) {\n\t\t\tthis.domConverter.setDomElementAttribute( domElement as DomElement, key, viewElement.getAttribute( key )!, viewElement );\n\t\t}\n\t}\n\n\t/**\n\t * Checks if elements child list needs to be updated and possibly updates it.\n\t *\n\t * Note that on Android, to reduce the risk of composition breaks, it tries to update data of an existing\n\t * child text nodes instead of replacing them completely.\n\t *\n\t * @param viewElement View element to update.\n\t * @param options.inlineFillerPosition The position where the inline filler should be rendered.\n\t */\n\tprivate _updateChildren( viewElement: ViewElement, options: { inlineFillerPosition: ViewPosition | null } ) {\n\t\tconst domElement = this.domConverter.mapViewToDom( viewElement );\n\n\t\tif ( !domElement ) {\n\t\t\t// If there is no `domElement` it means that it was already removed from DOM.\n\t\t\t// There is no need to process it. It will be processed when re-inserted.\n\t\t\treturn;\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'%cUpdate children',\n\t\t// @if CK_DEBUG_TYPING // \t\t'font-weight: normal'\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t// IME on Android inserts a new text node while typing after a link\n\t\t// instead of updating an existing text node that follows the link.\n\t\t// We must normalize those text nodes so the diff won't get confused.\n\t\t// https://github.com/ckeditor/ckeditor5/issues/12574.\n\t\tif ( env.isAndroid ) {\n\t\t\tlet previousDomNode = null;\n\n\t\t\tfor ( const domNode of Array.from( domElement.childNodes ) ) {\n\t\t\t\tif ( previousDomNode && isText( previousDomNode ) && isText( domNode ) ) {\n\t\t\t\t\tdomElement.normalize();\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tpreviousDomNode = domNode;\n\t\t\t}\n\t\t}\n\n\t\tconst inlineFillerPosition = options.inlineFillerPosition;\n\t\tconst actualDomChildren = domElement.childNodes;\n\t\tconst expectedDomChildren = Array.from(\n\t\t\tthis.domConverter.viewChildrenToDom( viewElement, { bind: true } )\n\t\t);\n\n\t\t// Inline filler element has to be created as it is present in the DOM, but not in the view. It is required\n\t\t// during diffing so text nodes could be compared correctly and also during rendering to maintain\n\t\t// proper order and indexes while updating the DOM.\n\t\tif ( inlineFillerPosition && inlineFillerPosition.parent === viewElement ) {\n\t\t\taddInlineFiller( ( domElement as DomElement ).ownerDocument, expectedDomChildren, inlineFillerPosition.offset );\n\t\t}\n\n\t\tconst diff = this._diffNodeLists( actualDomChildren, expectedDomChildren );\n\n\t\t// We need to make sure that we update the existing text node and not replace it with another one.\n\t\t// The composition and different \"language\" browser extensions are fragile to text node being completely replaced.\n\t\tconst actions = this._findUpdateActions( diff, actualDomChildren, expectedDomChildren, areTextNodes );\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping && actions.every( a => a == 'equal' ) ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'%cNothing to update.',\n\t\t// @if CK_DEBUG_TYPING // \t\t'font-style: italic'\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tlet i = 0;\n\t\tconst nodesToUnbind: Set = new Set();\n\n\t\t// Handle deletions first.\n\t\t// This is to prevent a situation where an element that already exists in `actualDomChildren` is inserted at a different\n\t\t// index in `actualDomChildren`. Since `actualDomChildren` is a `NodeList`, this works like move, not like an insert,\n\t\t// and it disrupts the whole algorithm. See https://github.com/ckeditor/ckeditor5/issues/6367.\n\t\t//\n\t\t// It doesn't matter in what order we remove or add nodes, as long as we remove and add correct nodes at correct indexes.\n\t\tfor ( const action of actions ) {\n\t\t\tif ( action === 'delete' ) {\n\t\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t\t// @if CK_DEBUG_TYPING //\tconst node = actualDomChildren[ i ];\n\t\t\t\t// @if CK_DEBUG_TYPING // \tif ( isText( node ) ) {\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\t'%cRemove text node' +\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: ` +\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\t`%c${ _escapeTextNodeData( node.data ) }%c (${ node.data.length })`,\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\t'color: blue', ''\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t) );\n\t\t\t\t// @if CK_DEBUG_TYPING // \t} else {\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\t'%cRemove element' +\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: `,\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t\tnode\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t) );\n\t\t\t\t// @if CK_DEBUG_TYPING // \t}\n\t\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\t\tnodesToUnbind.add( actualDomChildren[ i ] as DomElement );\n\t\t\t\tremove( actualDomChildren[ i ] );\n\t\t\t} else if ( action === 'equal' || action === 'update' ) {\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\n\t\ti = 0;\n\n\t\tfor ( const action of actions ) {\n\t\t\tif ( action === 'insert' ) {\n\t\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t\t// @if CK_DEBUG_TYPING //\tconst node = expectedDomChildren[ i ];\n\t\t\t\t// @if CK_DEBUG_TYPING //\tif ( isText( node ) ) {\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t'%cInsert text node' +\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: ` +\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t`%c${ _escapeTextNodeData( node.data ) }%c (${ node.data.length })`,\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t'color: blue',\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t''\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t) );\n\t\t\t\t// @if CK_DEBUG_TYPING //\t} else {\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t'%cInsert element:',\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\t'font-weight: normal',\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t\tnode\n\t\t\t\t// @if CK_DEBUG_TYPING //\t\t) );\n\t\t\t\t// @if CK_DEBUG_TYPING //\t}\n\t\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\t\tinsertAt( domElement as DomElement, i, expectedDomChildren[ i ] );\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t// Update the existing text node data.\n\t\t\telse if ( action === 'update' ) {\n\t\t\t\tthis._updateTextNode( actualDomChildren[ i ] as DomText, ( expectedDomChildren[ i ] as DomText ).data );\n\t\t\t\ti++;\n\t\t\t} else if ( action === 'equal' ) {\n\t\t\t\t// Force updating text nodes inside elements which did not change and do not need to be re-rendered (#1125).\n\t\t\t\t// Do it here (not in the loop above) because only after insertions the `i` index is correct.\n\t\t\t\tthis._markDescendantTextToSync( this.domConverter.domToView( expectedDomChildren[ i ] ) as any );\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\n\t\t// Unbind removed nodes. When node does not have a parent it means that it was removed from DOM tree during\n\t\t// comparison with the expected DOM. We don't need to check child nodes, because if child node was reinserted,\n\t\t// it was moved to DOM tree out of the removed node.\n\t\tfor ( const node of nodesToUnbind ) {\n\t\t\tif ( !node.parentNode ) {\n\t\t\t\tthis.domConverter.unbindDomElement( node as DomElement );\n\t\t\t}\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n\t\t// @if CK_DEBUG_TYPING // }\n\t}\n\n\t/**\n\t * Shorthand for diffing two arrays or node lists of DOM nodes.\n\t *\n\t * @param actualDomChildren Actual DOM children\n\t * @param expectedDomChildren Expected DOM children.\n\t * @returns The list of actions based on the {@link module:utils/diff~diff} function.\n\t */\n\tprivate _diffNodeLists( actualDomChildren: Array | NodeList, expectedDomChildren: Array | NodeList ) {\n\t\tactualDomChildren = filterOutFakeSelectionContainer( actualDomChildren, this._fakeSelectionContainer );\n\n\t\treturn diff( actualDomChildren, expectedDomChildren, sameNodes.bind( null, this.domConverter ) );\n\t}\n\n\t/**\n\t * Finds DOM nodes that were replaced with the similar nodes (same tag name) in the view. All nodes are compared\n\t * within one `insert`/`delete` action group, for example:\n\t *\n\t * ```\n\t * Actual DOM:\t\t
FooBarBazBax
\n\t * Expected DOM:\t
Bar123Baz456
\n\t * Input actions:\t[ insert, insert, delete, delete, equal, insert, delete ]\n\t * Output actions:\t[ insert, replace, delete, equal, replace ]\n\t * ```\n\t *\n\t * @param actions Actions array which is a result of the {@link module:utils/diff~diff} function.\n\t * @param actualDom Actual DOM children\n\t * @param expectedDom Expected DOM children.\n\t * @param comparator A comparator function that should return `true` if the given node should be reused\n\t * (either by the update of a text node data or an element children list for similar elements).\n\t * @returns Actions array modified with the `update` actions.\n\t */\n\tprivate _findUpdateActions(\n\t\tactions: Array,\n\t\tactualDom: Array | NodeList,\n\t\texpectedDom: Array,\n\t\tcomparator: ( a: DomNode, b: DomNode ) => boolean\n\t): Array {\n\t\t// If there is no both 'insert' and 'delete' actions, no need to check for replaced elements.\n\t\tif ( actions.indexOf( 'insert' ) === -1 || actions.indexOf( 'delete' ) === -1 ) {\n\t\t\treturn actions;\n\t\t}\n\n\t\tlet newActions: Array = [];\n\t\tlet actualSlice = [];\n\t\tlet expectedSlice = [];\n\n\t\tconst counter = { equal: 0, insert: 0, delete: 0 };\n\n\t\tfor ( const action of actions ) {\n\t\t\tif ( action === 'insert' ) {\n\t\t\t\texpectedSlice.push( expectedDom[ counter.equal + counter.insert ] );\n\t\t\t} else if ( action === 'delete' ) {\n\t\t\t\tactualSlice.push( actualDom[ counter.equal + counter.delete ] );\n\t\t\t} else { // equal\n\t\t\t\tnewActions = newActions.concat(\n\t\t\t\t\tdiff( actualSlice, expectedSlice, comparator )\n\t\t\t\t\t\t.map( action => action === 'equal' ? 'update' : action )\n\t\t\t\t);\n\n\t\t\t\tnewActions.push( 'equal' );\n\n\t\t\t\t// Reset stored elements on 'equal'.\n\t\t\t\tactualSlice = [];\n\t\t\t\texpectedSlice = [];\n\t\t\t}\n\t\t\tcounter[ action ]++;\n\t\t}\n\n\t\treturn newActions.concat(\n\t\t\tdiff( actualSlice, expectedSlice, comparator )\n\t\t\t\t.map( action => action === 'equal' ? 'update' : action )\n\t\t);\n\t}\n\n\t/**\n\t * Checks if text needs to be updated and possibly updates it by removing and inserting only parts\n\t * of the data from the existing text node to reduce impact on the IME composition.\n\t *\n\t * @param domText DOM text node to update.\n\t * @param expectedText The expected data of a text node.\n\t */\n\tprivate _updateTextNode( domText: DomText, expectedText: string ): void {\n\t\tconst actualText = domText.data;\n\n\t\tif ( actualText == expectedText ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'%cText node does not need update:%c ' +\n\t\t\t// @if CK_DEBUG_TYPING // \t\t`${ _escapeTextNodeData( actualText ) }%c (${ actualText.length })`,\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'font-style: italic',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'color: blue',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t''\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\treturn;\n\t\t}\n\n\t\t// Our approach to interleaving space character with NBSP might differ with the one implemented by the browser.\n\t\t// Avoid modifying the text node in the DOM if only NBSPs and spaces are interchanged.\n\t\t// We should avoid DOM modifications while composing to avoid breakage of composition.\n\t\t// See: https://github.com/ckeditor/ckeditor5/issues/13994.\n\t\tif ( env.isAndroid && this.isComposing && actualText.replace( /\\u00A0/g, ' ' ) == expectedText.replace( /\\u00A0/g, ' ' ) ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'%cText node ignore NBSP changes while composing: ' +\n\t\t\t// @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( actualText ) }%c (${ actualText.length }) -> ` +\n\t\t\t// @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( expectedText ) }%c (${ expectedText.length })`,\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'font-style: italic',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'color: blue',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'color: blue',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t''\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\treturn;\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'%cUpdate text node' +\n\t\t// @if CK_DEBUG_TYPING // \t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: ` +\n\t\t// @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( actualText ) }%c (${ actualText.length }) -> ` +\n\t\t// @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( expectedText ) }%c (${ expectedText.length })`,\n\t\t// @if CK_DEBUG_TYPING // \t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n\t\t// @if CK_DEBUG_TYPING // \t\t'color: blue',\n\t\t// @if CK_DEBUG_TYPING // \t\t'',\n\t\t// @if CK_DEBUG_TYPING // \t\t'color: blue',\n\t\t// @if CK_DEBUG_TYPING // \t\t''\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tthis._updateTextNodeInternal( domText, expectedText );\n\t}\n\n\t/**\n\t * Part of the `_updateTextNode` method extracted for easier testing.\n\t */\n\tprivate _updateTextNodeInternal( domText: DomText, expectedText: string ): void {\n\t\tconst actions = fastDiff( domText.data, expectedText );\n\n\t\tfor ( const action of actions ) {\n\t\t\tif ( action.type === 'insert' ) {\n\t\t\t\tdomText.insertData( action.index, action.values.join( '' ) );\n\t\t\t} else { // 'delete'\n\t\t\t\tdomText.deleteData( action.index, action.howMany );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Marks text nodes to be synchronized.\n\t *\n\t * If a text node is passed, it will be marked. If an element is passed, all descendant text nodes inside it will be marked.\n\t *\n\t * @param viewNode View node to sync.\n\t */\n\tprivate _markDescendantTextToSync( viewNode: ViewNode | undefined ): void {\n\t\tif ( !viewNode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( viewNode.is( '$text' ) ) {\n\t\t\tthis.markedTexts.add( viewNode );\n\t\t} else if ( viewNode.is( 'element' ) ) {\n\t\t\tfor ( const child of viewNode.getChildren() ) {\n\t\t\t\tthis._markDescendantTextToSync( child );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the selection needs to be updated and possibly updates it.\n\t */\n\tprivate _updateSelection(): void {\n\t\t// Block updating DOM selection in (non-Android) Blink while the user is selecting to prevent accidental selection collapsing.\n\t\t// Note: Structural changes in DOM must trigger selection rendering, though. Nodes the selection was anchored\n\t\t// to, may disappear in DOM which would break the selection (e.g. in real-time collaboration scenarios).\n\t\t// https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723\n\t\tif ( env.isBlink && !env.isAndroid && this.isSelecting && !this.markedChildren.size ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there is no selection - remove DOM and fake selections.\n\t\tif ( this.selection.rangeCount === 0 ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'Update DOM selection: remove all ranges'\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\tthis._removeDomSelection();\n\t\t\tthis._removeFakeSelection();\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst domEditable = this.domConverter.mapViewToDom( this.selection.editableElement! );\n\n\t\t// Do not update DOM selection if there is no focus, or there is no DOM element corresponding to selection's editable element.\n\t\tif ( !this.isFocused || !domEditable ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'Skip updating DOM selection:',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t`isFocused: ${ this.isFocused }, hasDomEditable: ${ !!domEditable }`\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\t// But if there was a fake selection, and it is not fake anymore - remove it as it can map to no longer existing widget.\n\t\t\t// See https://github.com/ckeditor/ckeditor5/issues/18123.\n\t\t\tif ( !this.selection.isFake && this._fakeSelectionContainer && this._fakeSelectionContainer.isConnected ) {\n\t\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t\t// @if CK_DEBUG_TYPING // \t\t'Remove fake selection (not focused editable)'\n\t\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\t\tthis._removeFakeSelection();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'Update DOM selection'\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t// Render fake selection - create the fake selection container (if needed) and move DOM selection to it.\n\t\tif ( this.selection.isFake ) {\n\t\t\tthis._updateFakeSelection( domEditable );\n\t\t}\n\t\t// There was a fake selection so remove it and update the DOM selection.\n\t\t// This is especially important on Android because otherwise IME will try to compose over the fake selection container.\n\t\telse if ( this._fakeSelectionContainer && this._fakeSelectionContainer.isConnected ) {\n\t\t\tthis._removeFakeSelection();\n\t\t\tthis._updateDomSelection( domEditable );\n\t\t}\n\t\t// Update the DOM selection in case of a plain selection change (no fake selection is involved).\n\t\t// On non-Android the whole rendering is disabled in composition mode (including DOM selection update),\n\t\t// but updating DOM selection should be also disabled on Android if in the middle of the composition\n\t\t// (to not interrupt it).\n\t\telse if ( !( this.isComposing && env.isAndroid ) ) {\n\t\t\tthis._updateDomSelection( domEditable );\n\t\t}\n\t}\n\n\t/**\n\t * Updates the fake selection.\n\t *\n\t * @param domEditable A valid DOM editable where the fake selection container should be added.\n\t */\n\tprivate _updateFakeSelection( domEditable: DomElement ): void {\n\t\tconst domDocument = domEditable.ownerDocument;\n\n\t\tif ( !this._fakeSelectionContainer ) {\n\t\t\tthis._fakeSelectionContainer = createFakeSelectionContainer( domDocument );\n\t\t}\n\n\t\tconst container = this._fakeSelectionContainer;\n\n\t\t// Bind fake selection container with the current selection *position*.\n\t\tthis.domConverter.bindFakeSelection( container, this.selection );\n\n\t\tif ( !this._fakeSelectionNeedsUpdate( domEditable ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( !container.parentElement || container.parentElement != domEditable ) {\n\t\t\tdomEditable.appendChild( container );\n\t\t}\n\n\t\tcontainer.textContent = this.selection.fakeSelectionLabel || '\\u00A0';\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'Set DOM fake selection'\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tconst domSelection = domDocument.getSelection()!;\n\t\tconst domRange = domDocument.createRange();\n\n\t\tdomSelection.removeAllRanges();\n\t\tdomRange.selectNodeContents( container );\n\t\tdomSelection.addRange( domRange );\n\t}\n\n\t/**\n\t * Updates the DOM selection.\n\t *\n\t * @param domEditable A valid DOM editable where the DOM selection should be rendered.\n\t */\n\tprivate _updateDomSelection( domEditable: DomElement ) {\n\t\tconst domSelection = domEditable.ownerDocument.defaultView!.getSelection()!;\n\n\t\t// Let's check whether DOM selection needs updating at all.\n\t\tif ( !this._domSelectionNeedsUpdate( domSelection ) ) {\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'%cDOM selection is already correct',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'font-style: italic;'\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\treturn;\n\t\t}\n\n\t\t// Multi-range selection is not available in most browsers, and, at least in Chrome, trying to\n\t\t// set such selection, that is not continuous, throws an error. Because of that, we will just use anchor\n\t\t// and focus of view selection.\n\t\t// Since we are not supporting multi-range selection, we also do not need to check if proper editable is\n\t\t// selected. If there is any editable selected, it is okay (editable is taken from selection anchor).\n\t\tconst anchor = this.domConverter.viewPositionToDom( this.selection.anchor! )!;\n\t\tconst focus = this.domConverter.viewPositionToDom( this.selection.focus! )!;\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t'Update DOM selection:',\n\t\t// @if CK_DEBUG_TYPING // \t\tanchor,\n\t\t// @if CK_DEBUG_TYPING // \t\tfocus\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tdomSelection.setBaseAndExtent( anchor.parent, anchor.offset, focus.parent, focus.offset );\n\n\t\t// Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).\n\t\tif ( env.isGecko ) {\n\t\t\tfixGeckoSelectionAfterBr( focus, domSelection );\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether a given DOM selection needs to be updated.\n\t *\n\t * @param domSelection The DOM selection to check.\n\t */\n\tprivate _domSelectionNeedsUpdate( domSelection: Selection ): boolean {\n\t\tif ( !this.domConverter.isDomSelectionCorrect( domSelection ) ) {\n\t\t\t// Current DOM selection is in incorrect position. We need to update it.\n\t\t\treturn true;\n\t\t}\n\n\t\tconst oldViewSelection = domSelection && this.domConverter.domSelectionToView( domSelection );\n\n\t\tif ( oldViewSelection && this.selection.isEqual( oldViewSelection ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// If selection is not collapsed, it does not need to be updated if it is similar.\n\t\tif ( !this.selection.isCollapsed && this.selection.isSimilar( oldViewSelection ) ) {\n\t\t\t// Selection did not changed and is correct, do not update.\n\t\t\treturn false;\n\t\t}\n\n\t\t// Selections are not similar.\n\t\treturn true;\n\t}\n\n\t/**\n\t * Checks whether the fake selection needs to be updated.\n\t *\n\t * @param domEditable A valid DOM editable where a new fake selection container should be added.\n\t */\n\tprivate _fakeSelectionNeedsUpdate( domEditable: DomElement ): boolean {\n\t\tconst container = this._fakeSelectionContainer;\n\t\tconst domSelection = domEditable.ownerDocument.getSelection()!;\n\n\t\t// Fake selection needs to be updated if there's no fake selection container, or the container currently sits\n\t\t// in a different root.\n\t\tif ( !container || container.parentElement !== domEditable ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Make sure that the selection actually is within the fake selection.\n\t\tif ( domSelection.anchorNode !== container && !container.contains( domSelection.anchorNode ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn container.textContent !== this.selection.fakeSelectionLabel;\n\t}\n\n\t/**\n\t * Removes the DOM selection.\n\t */\n\tprivate _removeDomSelection(): void {\n\t\tfor ( const doc of this.domDocuments ) {\n\t\t\tconst domSelection = doc.getSelection()!;\n\n\t\t\tif ( domSelection.rangeCount ) {\n\t\t\t\tconst activeDomElement = doc.activeElement!;\n\t\t\t\tconst viewElement = this.domConverter.mapDomToView( activeDomElement as DomElement );\n\n\t\t\t\tif ( activeDomElement && viewElement ) {\n\t\t\t\t\tdomSelection.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes the fake selection.\n\t */\n\tprivate _removeFakeSelection(): void {\n\t\tconst container = this._fakeSelectionContainer;\n\n\t\tif ( container ) {\n\t\t\tcontainer.remove();\n\t\t}\n\t}\n\n\t/**\n\t * Checks if focus needs to be updated and possibly updates it.\n\t */\n\tprivate _updateFocus(): void {\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n\t\t// @if CK_DEBUG_TYPING // \t\t`update focus: ${ this.isFocused ? 'focused' : 'not focused' }`\n\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t// @if CK_DEBUG_TYPING // }\n\n\t\tif ( this.isFocused ) {\n\t\t\tconst editable = this.selection.editableElement;\n\n\t\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t\t// @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t'focus editable:',\n\t\t\t// @if CK_DEBUG_TYPING // \t\t{ editable }\n\t\t\t// @if CK_DEBUG_TYPING // \t) );\n\t\t\t// @if CK_DEBUG_TYPING // }\n\n\t\t\tif ( editable ) {\n\t\t\t\tthis.domConverter.focus( editable );\n\t\t\t}\n\t\t}\n\n\t\t// @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n\t\t// @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n\t\t// @if CK_DEBUG_TYPING // }\n\t}\n}\n\n/**\n * Checks if provided element is editable.\n */\nfunction isEditable( element: ViewElement ): boolean {\n\tif ( element.getAttribute( 'contenteditable' ) == 'false' ) {\n\t\treturn false;\n\t}\n\n\tconst parent = element.findAncestor( element => element.hasAttribute( 'contenteditable' ) );\n\n\treturn !parent || parent.getAttribute( 'contenteditable' ) == 'true';\n}\n\n/**\n * Adds inline filler at a given position.\n *\n * The position can be given as an array of DOM nodes and an offset in that array,\n * or a DOM parent element and an offset in that element.\n *\n * @returns The DOM text node that contains an inline filler.\n */\nfunction addInlineFiller( domDocument: DomDocument, domParentOrArray: DomNode | Array, offset: number ): DomText {\n\tconst childNodes = domParentOrArray instanceof Array ? domParentOrArray : domParentOrArray.childNodes;\n\tconst nodeAfterFiller = childNodes[ offset ];\n\n\tif ( isText( nodeAfterFiller ) ) {\n\t\tnodeAfterFiller.data = INLINE_FILLER + nodeAfterFiller.data;\n\n\t\treturn nodeAfterFiller;\n\t} else {\n\t\tconst fillerNode = domDocument.createTextNode( INLINE_FILLER );\n\n\t\tif ( Array.isArray( domParentOrArray ) ) {\n\t\t\t( childNodes as Array ).splice( offset, 0, fillerNode );\n\t\t} else {\n\t\t\tinsertAt( domParentOrArray as DomElement, offset, fillerNode );\n\t\t}\n\n\t\treturn fillerNode;\n\t}\n}\n\n/**\n * Whether two DOM nodes should be considered as similar.\n * Nodes are considered similar if they have the same tag name.\n */\nfunction areSimilarElements( node1: DomNode, node2: DomNode ): boolean {\n\treturn isNode( node1 ) && isNode( node2 ) &&\n\t\t!isText( node1 ) && !isText( node2 ) &&\n\t\t!isComment( node1 ) && !isComment( node2 ) &&\n\t\t( node1 as DomElement ).tagName.toLowerCase() === ( node2 as DomElement ).tagName.toLowerCase();\n}\n\n/**\n * Whether two DOM nodes are text nodes.\n */\nfunction areTextNodes( node1: DomNode, node2: DomNode ): boolean {\n\treturn isNode( node1 ) && isNode( node2 ) &&\n\t\tisText( node1 ) && isText( node2 );\n}\n\n/**\n * Whether two dom nodes should be considered as the same.\n * Two nodes which are considered the same are:\n *\n * * Text nodes with the same text.\n * * Element nodes represented by the same object.\n * * Two block filler elements.\n *\n * @param blockFillerMode Block filler mode, see {@link module:engine/view/domconverter~ViewDomConverter#blockFillerMode}.\n */\nfunction sameNodes( domConverter: ViewDomConverter, actualDomChild: DomNode, expectedDomChild: DomNode ): boolean {\n\t// Elements.\n\tif ( actualDomChild === expectedDomChild ) {\n\t\treturn true;\n\t}\n\t// Texts.\n\telse if ( isText( actualDomChild ) && isText( expectedDomChild ) ) {\n\t\treturn actualDomChild.data === expectedDomChild.data;\n\t}\n\t// Block fillers.\n\telse if ( domConverter.isBlockFiller( actualDomChild ) &&\n\t\tdomConverter.isBlockFiller( expectedDomChild ) ) {\n\t\treturn true;\n\t}\n\n\t// Not matching types.\n\treturn false;\n}\n\n/**\n * The following is a Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).\n * When the native DOM selection is at the end of the block and preceded by e.g.\n *\n * ```html\n *
foo []
\n * ```\n *\n * which happens a lot when using the soft line break, the browser fails to (visually) move the\n * caret to the new line. A quick fix is as simple as force–refreshing the selection with the same range.\n */\nfunction fixGeckoSelectionAfterBr( focus: ReturnType, domSelection: DomSelection ) {\n\tlet parent = focus!.parent;\n\tlet offset = focus!.offset;\n\n\tif ( isText( parent ) && isInlineFiller( parent ) ) {\n\t\toffset = indexOf( parent ) + 1;\n\t\tparent = parent.parentNode!;\n\t}\n\n\t// This fix works only when the focus point is at the very end of an element.\n\t// There is no point in running it in cases unrelated to the browser bug.\n\tif ( parent.nodeType != Node.ELEMENT_NODE || offset != parent.childNodes.length - 1 ) {\n\t\treturn;\n\t}\n\n\tconst childAtOffset = parent.childNodes[ offset ];\n\n\t// To stay on the safe side, the fix being as specific as possible, it targets only the\n\t// selection which is at the very end of the element and preceded by .\n\tif ( childAtOffset && ( childAtOffset as DomElement ).tagName == 'BR' ) {\n\t\tdomSelection.addRange( domSelection.getRangeAt( 0 ) );\n\t}\n}\n\nfunction filterOutFakeSelectionContainer( domChildList: Array | NodeList, fakeSelectionContainer: DomElement | null ) {\n\tconst childList = Array.from( domChildList );\n\n\tif ( childList.length == 0 || !fakeSelectionContainer ) {\n\t\treturn childList;\n\t}\n\n\tconst last = childList[ childList.length - 1 ];\n\n\tif ( last == fakeSelectionContainer ) {\n\t\tchildList.pop();\n\t}\n\n\treturn childList;\n}\n\n/**\n * Creates a fake selection container for a given document.\n */\nfunction createFakeSelectionContainer( domDocument: DomDocument ): DomElement {\n\tconst container = domDocument.createElement( 'div' );\n\n\tcontainer.className = 'ck-fake-selection-container';\n\n\tObject.assign( container.style, {\n\t\tposition: 'fixed',\n\t\ttop: 0,\n\t\tleft: '-9999px',\n\t\t// See https://github.com/ckeditor/ckeditor5/issues/752.\n\t\twidth: '42px'\n\t} );\n\n\t// Fill it with a text node so we can update it later.\n\tcontainer.textContent = '\\u00A0';\n\n\treturn container;\n}\n\n// @if CK_DEBUG_TYPING // function _escapeTextNodeData( text ) {\n// @if CK_DEBUG_TYPING // \tconst escapedText = text\n// @if CK_DEBUG_TYPING // \t\t.replace( /&/g, '&' )\n// @if CK_DEBUG_TYPING // \t\t.replace( /\\u00A0/g, ' ' )\n// @if CK_DEBUG_TYPING // \t\t.replace( /\\u2060/g, '⁠' );\n// @if CK_DEBUG_TYPING //\n// @if CK_DEBUG_TYPING // \treturn `\"${ escapedText }\"`;\n// @if CK_DEBUG_TYPING // }\n","/**\n * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n/**\n * @module engine/view/domconverter\n */\n\nimport { ViewText } from './text.js';\nimport { ViewElement } from './element.js';\nimport { ViewUIElement } from './uielement.js';\nimport { ViewPosition } from './position.js';\nimport { ViewRange } from './range.js';\nimport { ViewSelection } from './selection.js';\nimport { ViewDocumentFragment } from './documentfragment.js';\nimport { ViewTreeWalker } from './treewalker.js';\nimport { Matcher, type MatcherPattern } from './matcher.js';\nimport {\n\tBR_FILLER, INLINE_FILLER_LENGTH, NBSP_FILLER, MARKED_NBSP_FILLER,\n\tgetDataWithoutFiller, isInlineFiller, startsWithFiller\n} from './filler.js';\n\nimport {\n\tglobal,\n\tlogWarning,\n\tindexOf,\n\tgetAncestors,\n\tisText,\n\tisComment,\n\tisValidAttributeName,\n\tfirst,\n\tenv\n} from '@ckeditor/ckeditor5-utils';\n\nimport { type ViewNode } from './node.js';\nimport { type ViewDocument } from './document.js';\nimport { type ViewDocumentSelection } from './documentselection.js';\nimport { type ViewEditableElement } from './editableelement.js';\nimport { type ViewTextProxy } from './textproxy.js';\nimport { type ViewRawElement } from './rawelement.js';\n\n// @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '../dev-utils/utils.js' );\n\ntype DomNode = globalThis.Node;\ntype DomElement = globalThis.HTMLElement;\ntype DomDocument = globalThis.Document;\ntype DomDocumentFragment = globalThis.DocumentFragment;\ntype DomComment = globalThis.Comment;\ntype DomRange = globalThis.Range;\ntype DomText = globalThis.Text;\ntype DomSelection = globalThis.Selection;\n\nconst BR_FILLER_REF = BR_FILLER( global.document ); // eslint-disable-line new-cap\nconst NBSP_FILLER_REF = NBSP_FILLER( global.document ); // eslint-disable-line new-cap\nconst MARKED_NBSP_FILLER_REF = MARKED_NBSP_FILLER( global.document ); // eslint-disable-line new-cap\nconst UNSAFE_ATTRIBUTE_NAME_PREFIX = 'data-ck-unsafe-attribute-';\nconst UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE = 'data-ck-unsafe-element';\n\n/**\n * `ViewDomConverter` is a set of tools to do transformations between DOM nodes and view nodes. It also handles\n * {@link module:engine/view/domconverter~ViewDomConverter#bindElements bindings} between these nodes.\n *\n * An instance of the DOM converter is available under\n * {@link module:engine/view/view~EditingView#domConverter `editor.editing.view.domConverter`}.\n *\n * The DOM converter does not check which nodes should be rendered (use {@link module:engine/view/renderer~ViewRenderer}), does not keep the\n * state of a tree nor keeps the synchronization between the tree view and\n * the DOM tree (use {@link module:engine/view/document~ViewDocument}).\n *\n * The DOM converter keeps DOM elements to view element bindings, so when the converter gets destroyed, the bindings are lost.\n * Two converters will keep separate binding maps, so one tree view can be bound with two DOM trees.\n */\nexport class ViewDomConverter {\n\tpublic readonly document: ViewDocument;\n\n\t/**\n\t * Whether to leave the View-to-DOM conversion result unchanged or improve editing experience by filtering out interactive data.\n\t */\n\tpublic readonly renderingMode: 'data' | 'editing';\n\n\t/**\n\t * The mode of a block filler used by the DOM converter.\n\t */\n\tpublic blockFillerMode: ViewBlockFillerMode;\n\n\t/**\n\t * Elements which are considered pre-formatted elements.\n\t */\n\tpublic readonly preElements: Array;\n\n\t/**\n\t * Elements which are considered block elements (and hence should be filled with a\n\t * {@link #isBlockFiller block filler}).\n\t *\n\t * Whether an element is considered a block element also affects handling of trailing whitespaces.\n\t *\n\t * You can extend this array if you introduce support for block elements which are not yet recognized here.\n\t */\n\tpublic readonly blockElements: Array;\n\n\t/**\n\t * A list of elements that exist inline (in text) but their inner structure cannot be edited because\n\t * of the way they are rendered by the browser. They are mostly HTML form elements but there are other\n\t * elements such as `` or `