(\s+)<\/span>/g,(t,e)=>1==e.length?" ":e).replace(//g,"")}(o.getData("text/html")):o.getData("text/plain")&&(((r=(r=o.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"").replace(/\r?\n/g,"
").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||r.includes("
"))&&(r=`
${r}
`),t=r),i=this.editor.data.htmlProcessor.toView(t)}var r;const s=new w(this,"inputTransformation");this.fire(s,{content:i,dataTransfer:o,targetRanges:e.targetRanges,method:e.method}),s.stop.called&&t.stop(),n.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(t,n)=>{if(n.content.isEmpty)return;const o=this.editor.data.toModel(n.content,"$clipboardHolder");0!=o.childCount&&(t.stop(),e.change(()=>{this.fire("contentInsertion",{content:o,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(t,n)=>{n.resultRange=e.insertContent(n.content)},{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,n=t.editing.view.document,o=(o,i)=>{const r=i.dataTransfer;i.preventDefault();const s=t.data.toView(t.model.getSelectedContent(e.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:o.name})};this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",(e,n)=>{t.isReadOnly?n.preventDefault():o(e,n)},{priority:"low"}),this.listenTo(n,"clipboardOutput",(n,o)=>{o.content.isEmpty||(o.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(o.content)),o.dataTransfer.setData("text/plain",Ak(o.content))),"cut"==o.method&&t.model.deleteContent(e.selection)},{priority:"low"})}}class vk extends(L()){constructor(){super(),this._stack=[]}add(t,e){const n=this._stack,o=n[0];this._insertDescriptor(t);const i=n[0];o===i||yk(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}remove(t,e){const n=this._stack,o=n[0];this._removeDescriptor(t);const i=n[0];o===i||yk(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}_insertDescriptor(t){const e=this._stack,n=e.findIndex(e=>e.id===t.id);if(yk(t,e[n]))return;n>-1&&e.splice(n,1);let o=0;for(;e[o]&&xk(e[o],t);)o++;e.splice(o,0,t)}_removeDescriptor(t){const e=this._stack,n=e.findIndex(e=>e.id===t);n>-1&&e.splice(n,1)}}function yk(t,e){return t&&e&&t.priority==e.priority&&Ek(t.classes)==Ek(e.classes)}function xk(t,e){return t.priority>e.priority||!(t.priorityEk(e.classes)}function Ek(t){return Array.isArray(t)?t.sort().join(","):t}const Dk='',Tk="ck-widget",Ik="ck-widget_selected";function Sk(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function Mk(t,e,n={}){if(!t.is("containerElement"))throw new x("widget-to-widget-wrong-element-type",null,{element:t});return e.setAttribute("contenteditable","false",t),e.addClass(Tk,t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=Ok,e.setCustomProperty("widgetLabel",[],t),n.label&&function(t,e){const n=t.getCustomProperty("widgetLabel");n.push(e)}(t,n.label),n.hasSelectionHandle&&function(t,e){const n=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(t){const e=this.toDomElement(t),n=new ns;return n.set("content",Dk),n.render(),e.appendChild(n.element),e}));e.insert(e.createPositionAt(t,0),n),e.addClass(["ck-widget_with-selection-handle"],t)}(t,e),Pk(t,e),t}function Nk(t,e,n){if(e.classes&&n.addClass(hr(e.classes),t),e.attributes)for(const o in e.attributes)n.setAttribute(o,e.attributes[o],t)}function Bk(t,e,n){if(e.classes&&n.removeClass(hr(e.classes),t),e.attributes)for(const o in e.attributes)n.removeAttribute(o,t)}function Pk(t,e,n=Nk,o=Bk){const i=new vk;i.on("change:top",(e,i)=>{i.oldDescriptor&&o(t,i.oldDescriptor,i.writer),i.newDescriptor&&n(t,i.newDescriptor,i.writer)}),e.setCustomProperty("addHighlight",(t,e,n)=>i.add(e,n),t),e.setCustomProperty("removeHighlight",(t,e,n)=>i.remove(e,n),t)}function zk(t,e,n={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),e.setAttribute("role","textbox",t),n.label&&e.setAttribute("aria-label",n.label,t),e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",(n,o,i)=>{e.setAttribute("contenteditable",i?"false":"true",t)}),t.on("change:isFocused",(n,o,i)=>{i?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)}),Pk(t,e),t}function Lk(t,e){const n=t.getSelectedElement();if(n){const o=Fk(t);if(o)return e.createRange(e.createPositionAt(n,o))}return Eg(t,e)}function Ok(){return null}const Rk="widget-type-around";function jk(t,e,n){return!!t&&Sk(t)&&!n.isInline(e)}function Fk(t){return t.getAttribute(Rk)}var Vk=r(5137),Hk={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(Vk.Z,Hk),Vk.Z.locals;const Uk=["before","after"],Gk=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,qk="ck-widget__type-around_disabled";class Wk extends Ss{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[yf,Yp]}constructor(t){super(t),this._currentFakeCaretModelElement=null}init(){const t=this.editor,e=t.editing.view;this.on("change:isEnabled",(n,o,i)=>{e.change(t=>{for(const n of e.document.roots)i?t.removeClass(qk,n):t.addClass(qk,n)}),i||t.model.change(t=>{t.removeSelectionAttribute(Rk)})}),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(t,e){const n=this.editor,o=n.editing.view,i=n.model.schema.getAttributesWithProperty(t,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(t,e),attributes:i}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(t,e,n,o){this.listenTo(t,e,(...t)=>{this.isEnabled&&n(...t)},o)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor.model.document.selection,e=Fk(t);if(!e)return!1;const n=t.getSelectedElement();return this._insertParagraph(n,e),!0}_enableTypeAroundUIInjection(){const t=this.editor,e=t.model.schema,n=t.locale.t,o={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",(t,i,r)=>{const s=r.mapper.toViewElement(i.item);s&&jk(s,i.item,e)&&(!function(t,e,n){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const n=this.toDomElement(t);return function(t,e){for(const n of Uk){const o=new Nr({tag:"div",attributes:{class:["ck","ck-widget__type-around__button","ck-widget__type-around__button_"+n],title:e[n],"aria-hidden":"true"},children:[t.ownerDocument.importNode(Gk,!0)]});t.appendChild(o.render())}}(n,e),function(t){const e=new Nr({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}(n),n}));t.insert(t.createPositionAt(n,"end"),o)}(r.writer,o,s),s.getCustomProperty("widgetLabel").push(()=>this.isEnabled?n("Press Enter to type after or press Shift + Enter to type before the widget"):""))},{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const t=this.editor,e=t.model,n=e.document.selection,o=e.schema,i=t.editing.view;function r(t){return"ck-widget_type-around_show-fake-caret_"+t}this._listenToIfEnabled(i.document,"arrowKey",(t,e)=>{this._handleArrowKeyPress(t,e)},{context:[Sk,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",(e,n)=>{n.directChange&&t.model.change(t=>{t.removeSelectionAttribute(Rk)})}),this._listenToIfEnabled(e.document,"change:data",()=>{const e=n.getSelectedElement();e&&jk(t.editing.mapper.toViewElement(e),e,o)||t.model.change(t=>{t.removeSelectionAttribute(Rk)})}),this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",(t,e,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);t&&(i.removeClass(Uk.map(r),t),this._currentFakeCaretModelElement=null)}const s=e.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!jk(a,s,o))return;const c=Fk(e.selection);c&&(i.addClass(r(c),a),this._currentFakeCaretModelElement=s)}),this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",(e,n,o)=>{o||t.model.change(t=>{t.removeSelectionAttribute(Rk)})})}_handleArrowKeyPress(t,e){const n=this.editor,o=n.model,i=o.document.selection,r=o.schema,s=n.editing.view,a=function(t,e){const n=dr(t,e);return"down"===n||"right"===n}(e.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;jk(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):i.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):e.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(e.preventDefault(),t.stop())}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor.model,n=Fk(e.document.selection);return e.change(e=>n?n!==(t?"after":"before")&&(e.removeSelectionAttribute(Rk),!0):(e.setSelectionAttribute(Rk,t?"after":"before"),!0))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor,n=e.model,o=n.schema,i=e.plugins.get("Widget"),r=i._getObjectElementNextToSelection(t);return!!jk(e.editing.mapper.toViewElement(r),r,o)&&(n.change(e=>{i._setSelectionOverElement(r),e.setSelectionAttribute(Rk,t?"before":"after")}),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor,n=e.model,o=n.schema,i=e.editing.mapper,r=n.document.selection,s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!jk(i.toViewElement(s),s,o)&&(n.change(e=>{e.setSelection(s,"on"),e.setSelectionAttribute(Rk,t?"after":"before")}),!0)}_enableInsertingParagraphsOnButtonClick(){const t=this.editor,e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",(n,o)=>{const i=o.domTarget.closest(".ck-widget__type-around__button");if(!i)return;const r=function(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(i),s=function(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}(i,e.domConverter),a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r),o.preventDefault(),n.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor,e=t.model.document.selection,n=t.editing.view;this._listenToIfEnabled(n.document,"enter",(n,o)=>{if("atTarget"!=n.eventPhase)return;const i=e.getSelectedElement(),r=t.editing.mapper.toViewElement(i),s=t.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:jk(r,i,s)&&(this._insertParagraph(i,o.isSoft?"before":"after"),a=!0),a&&(o.preventDefault(),n.stop())},{context:Sk})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view.document;this._listenToIfEnabled(t,"insertText",(e,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.selection=t.selection)},{priority:"high"}),h.isAndroid?this._listenToIfEnabled(t,"keydown",(t,e)=>{229==e.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(t,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"high"})}_enableDeleteIntegration(){const t=this.editor,e=t.editing.view,n=t.model,o=n.schema;this._listenToIfEnabled(e.document,"delete",(e,i)=>{if("atTarget"!=e.eventPhase)return;const r=Fk(n.document.selection);if(!r)return;const s=i.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)t.execute("delete",{selection:n.createSelection(a,"on")});else{const e=o.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e)if(e.isCollapsed){const i=n.createSelection(e.start);if(n.modifySelection(i,{direction:s}),i.focus.isEqual(e.start)){const t=function(t,e){let n=e;for(const o of e.getAncestors({parentFirst:!0})){if(o.childCount>1||t.isLimit(o))break;n=o}return n}(o,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:!0})}else n.change(n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")})}else n.change(n=>{n.setSelection(e),t.execute(c?"deleteForward":"delete")})}i.preventDefault(),e.stop()},{context:Sk})}_enableInsertContentIntegration(){const t=this.editor,e=this.editor.model,n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",(t,[o,i])=>{if(i&&!i.is("documentSelection"))return;const r=Fk(n);return r?(t.stop(),e.change(t=>{const i=n.getSelectedElement(),s=e.createPositionAt(i,r),a=t.createSelection(s),c=e.insertContent(o,a);return t.setSelection(a),c})):void 0},{priority:"high"})}_enableInsertObjectIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"insertObject",(t,n)=>{const[,o,,i={}]=n;if(o&&!o.is("documentSelection"))return;const r=Fk(e);r&&(i.findOptimalPosition=r,n[3]=i)},{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"deleteContent",(t,[n])=>{n&&!n.is("documentSelection")||Fk(e)&&t.stop()},{priority:"high"})}}function Yk(t){const e=t.model;return(n,o)=>{const i=o.keyCode==rr.arrowup,r=o.keyCode==rr.arrowdown,s=o.shiftKey,a=e.document.selection;if(!i&&!r)return;const c=r;if(s&&function(t,e){return!t.isCollapsed&&t.isBackward==e}(a,c))return;const l=function(t,e,n){const o=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition(),n=Kk(o,t,"forward");if(!n)return null;const i=o.createRange(t,n),r=$k(o.schema,i,"backward");return r?o.createRange(t,r):null}{const t=e.isCollapsed?e.focus:e.getFirstPosition(),n=Kk(o,t,"backward");if(!n)return null;const i=o.createRange(n,t),r=$k(o.schema,i,"forward");return r?o.createRange(r,t):null}}(t,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(t,e,n){const o=t.model,i=t.view.domConverter;if(n){const t=o.createSelection(e.start);o.modifySelection(t),t.focus.isAtEnd||e.start.isEqual(t.focus)||(e=o.createRange(t.focus,e.end))}const r=t.mapper.toViewRange(e),s=i.viewRangeToDom(r),a=Bi.getDomRangeRects(s);let c;for(const l of a)if(void 0!==c){if(Math.round(l.top)>=c)return!1;c=Math.max(c,Math.round(l.bottom))}else c=Math.round(l.bottom);return!0}(t,l,c))&&(e.change(t=>{const n=c?l.end:l.start;if(s){const o=e.createSelection(a.anchor);o.setFocus(n),t.setSelection(o)}else t.setSelection(n)}),n.stop(),o.preventDefault(),o.stopPropagation())}}}function Kk(t,e,n){const o=t.schema,i=t.createRangeIn(e.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:s,item:a,type:c}of i.getWalker({startPosition:e,direction:n})){if(o.isLimit(a)&&!o.isInline(a))return s;if(c==r&&o.isBlock(a))return null}return null}function $k(t,e,n){const o="backward"==n?e.end:e.start;if(t.checkChild(o,"$text"))return o;for(const{nextPosition:i}of e.getWalker({direction:n}))if(t.checkChild(i,"$text"))return i;return null}var Qk=r(6507),Zk={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(Qk.Z,Zk),Qk.Z.locals;class Jk extends Ss{static get pluginName(){return"Widget"}static get requires(){return[Wk,Yp]}init(){const t=this.editor,e=t.editing.view,n=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",(e,n,o)=>{const i=o.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=t.editing.mapper.toViewElement(s);var c;Sk(a)&&o.consumable.consume(r,"selection")&&i.setSelection(i.createRangeOn(a),{fake:!0,label:(c=a,c.getCustomProperty("widgetLabel").reduce((t,e)=>"function"==typeof e?t?t+". "+e():e():t?t+". "+e:e,""))})}),this.editor.editing.downcastDispatcher.on("selection",(t,e,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const o=n.writer,i=o.document.selection;let r=null;for(const s of i.getRanges())for(const t of s){const e=t.item;Sk(e)&&!Xk(e,r)&&(o.addClass(Ik,e),this._previouslySelected.add(e),r=e)}},{priority:"low"}),e.addObserver(zg),this.listenTo(n,"mousedown",(...t)=>this._onMousedown(...t)),this.listenTo(n,"arrowKey",(...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)},{context:[Sk,"$text"]}),this.listenTo(n,"arrowKey",(...t)=>{this._preventDefaultOnArrowKeyPress(...t)},{context:"$root"}),this.listenTo(n,"arrowKey",Yk(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",(t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())},{context:"$root"})}_onMousedown(t,e){const n=this.editor,o=n.editing.view,i=o.document;let r=e.target;if(function(t){let e=t;for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(Sk(e))return!1;e=e.parent}return!1}(r)){if((h.isSafari||h.isGecko)&&e.domEvent.detail>=3){const t=n.editing.mapper,o=r.is("attributeElement")?r.findAncestor(t=>!t.is("attributeElement")):r,i=t.toModelElement(o);e.preventDefault(),this.editor.model.change(t=>{t.setSelection(i,"in")})}return}if(!Sk(r)&&(r=r.findAncestor(Sk),!r))return;h.isAndroid&&e.preventDefault(),i.isFocused||o.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode,o=this.editor.model,i=o.schema,r=o.document.selection,s=r.getSelectedElement(),a=dr(n,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&i.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition(),s=i.getNearestSelectionRange(n,c?"forward":"backward");return void(s&&(o.change(t=>{t.setSelection(s)}),e.preventDefault(),t.stop()))}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,l=s.nodeBefore;return void((a&&i.isObject(a)||l&&i.isObject(l))&&(o.change(t=>{t.setSelection(c?s:n)}),e.preventDefault(),t.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&i.isObject(d)){if(i.isInline(d)&&l)return;this._setSelectionOverElement(d),e.preventDefault(),t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model,o=n.schema,i=n.document.selection.getSelectedElement();i&&o.isObject(i)&&(e.preventDefault(),t.stop())}_handleDelete(t){if(this.editor.isReadOnly)return;const e=this.editor.model.document.selection;if(!e.isCollapsed)return;const n=this._getObjectElementNextToSelection(t);return n?(this.editor.model.change(t=>{let o=e.anchor.parent;for(;o.isEmpty;){const e=o;o=e.parent,t.remove(e)}this._setSelectionOverElement(n)}),!0):void 0}_setSelectionOverElement(t){this.editor.model.change(e=>{e.setSelection(e.createRangeOn(t))})}_getObjectElementNextToSelection(t){const e=this.editor.model,n=e.schema,o=e.document.selection,i=e.createSelection(o);if(e.modifySelection(i,{direction:t?"forward":"backward"}),i.isEqual(o))return null;const r=t?i.focus.nodeBefore:i.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(Ik,e);this._previouslySelected.clear()}}function Xk(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}class tb extends Ss{static get requires(){return[bp]}static get pluginName(){return"WidgetToolbarRepository"}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",e=>{(function(t){const e=t.getSelectedElement();return!(!e||!Sk(e))})(t.editing.view.document.selection)&&e.stop()},{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",()=>{this._updateToolbarsVisibility()}),this.listenTo(t.ui,"update",()=>{this._updateToolbarsVisibility()}),this.listenTo(t.ui.focusTracker,"change:isFocused",()=>{this._updateToolbarsVisibility()},{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values())t.view.destroy()}register(t,{ariaLabel:e,items:n,getRelatedElement:o,balloonClassName:i="ck-toolbar-container"}){if(!n.length)return void E("widget-toolbar-no-items",{toolbarId:t});const r=this.editor,s=r.t,a=new gm(r.locale);if(a.ariaLabel=e||s("Widget toolbar"),this._toolbarDefinitions.has(t))throw new x("widget-toolbar-duplicated",this,{toolbarId:t});const c={view:a,getRelatedElement:o,balloonClassName:i,itemsConfig:n,initialized:!1};r.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const t=o(r.editing.view.document.selection);t&&this._showToolbar(c,t)},afterBlur:()=>{this._hideToolbar(c)}}),this._toolbarDefinitions.set(t,c)}_updateToolbarsVisibility(){let t=0,e=null,n=null;for(const o of this._toolbarDefinitions.values()){const i=o.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&i)if(this.editor.ui.focusTracker.isFocused){const r=i.getAncestors().length;r>t&&(t=r,e=i,n=o)}else this._isToolbarVisible(o)&&this._hideToolbar(o);else this._isToolbarInBalloon(o)&&this._hideToolbar(o)}n&&this._showToolbar(n,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?eb(this.editor,e):this._isToolbarInBalloon(t)||(t.initialized||(t.initialized=!0,t.view.fillFromConfig(t.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:t.view,position:nb(this.editor,e),balloonClassName:t.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);eb(this.editor,e)}}))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function eb(t,e){const n=t.plugins.get("ContextualBalloon"),o=nb(t,e);n.updatePosition(o)}function nb(t,e){const n=t.editing.view,o=Lm.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}Z();Z();var ob=r(2263),ib={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(ob.Z,ib),ob.Z.locals;var rb="Expected a function";const sb=function(t,e,n){var o=!0,i=!0;if("function"!=typeof t)throw new TypeError(rb);return G(n)&&(o="leading"in n?!!n.leading:o,i="trailing"in n?!!n.trailing:i),Rl(t,e,{leading:o,maxWait:e,trailing:i})};var ab=r(390),cb={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(ab.Z,cb),ab.Z.locals;class lb extends Ss{static get pluginName(){return"DragDrop"}static get requires(){return[Ck,Jk]}init(){const t=this.editor,e=t.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=sb(t=>this._updateDropMarker(t),40),this._removeDropMarkerDelayed=ub(()=>this._removeDropMarker(),40),this._clearDraggableAttributesDelayed=ub(()=>this._clearDraggableAttributes(),40),e.addObserver(wk),e.addObserver(zg),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(t,"change:isReadOnly",(t,e,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(t,e,n)=>{n||this._finalizeDragging(!1)}),h.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const t=this.editor,e=t.model,n=e.document,o=t.editing.view,i=o.document;this.listenTo(i,"dragstart",(o,r)=>{const s=n.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const a=r.target?gb(r.target):null;if(a){const n=t.editing.mapper.toModelElement(a);this._draggedRange=ch.fromRange(e.createRangeOn(n)),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!i.selection.isCollapsed){const t=i.selection.getSelectedElement();t&&Sk(t)||(this._draggedRange=ch.fromRange(s.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=A(),r.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=e.createSelection(this._draggedRange.toRange()),l=t.data.toView(e.getSelectedContent(c));i.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:l,method:"dragstart"}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(i,"dragend",(t,e)=>{this._finalizeDragging(!e.dataTransfer.isCanceled&&"move"==e.dataTransfer.dropEffect)},{priority:"low"}),this.listenTo(i,"dragenter",()=>{this.isEnabled&&o.focus()}),this.listenTo(i,"dragleave",()=>{this._removeDropMarkerDelayed()}),this.listenTo(i,"dragging",(e,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const o=db(t,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),h.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),o&&this._updateDropMarkerThrottled(o)},{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"clipboardInput",(e,n)=>{if("drop"!=n.method)return;const o=db(t,n.targetRanges,n.target);return this._removeDropMarker(),o?(this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),"move"==hb(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(o,!0)?(this._finalizeDragging(!1),void e.stop()):void(n.targetRanges=[t.editing.mapper.toViewRange(o)])):(this._finalizeDragging(!1),void e.stop())},{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(Ck);t.on("contentInsertion",(t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n=e.targetRanges.map(t=>this.editor.editing.mapper.toModelRange(t));this.editor.model.change(t=>t.setSelection(n))},{priority:"high"}),t.on("contentInsertion",(t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n="move"==hb(e.dataTransfer),o=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(o&&n)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor,e=t.editing.view,n=e.document;this.listenTo(n,"mousedown",(o,i)=>{if(h.isAndroid||!i)return;this._clearDraggableAttributesDelayed.cancel();let r=gb(i.target);if(h.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();t&&Sk(t)||(r=n.selection.editableElement)}r&&(e.change(t=>{t.setAttribute("draggable","true",r)}),this._draggableElement=t.editing.mapper.toModelElement(r))}),this.listenTo(n,"mouseup",()=>{h.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const t=this.editor.editing;t.view.change(e=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&e.removeAttribute("draggable",t.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_setupDropMarker(){const t=this.editor;t.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),t.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(e,{writer:n})=>{if(t.model.schema.checkChild(e.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);return e.append("",t.createElement("span"),""),e}))}})}_updateDropMarker(t){const e=this.editor,n=e.model.markers;e.model.change(e=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(t)||e.updateMarker("drop-target",{range:t}):e.addMarker("drop-target",{range:t,usingOperation:!1,affectsData:!1})})}_removeDropMarker(){const t=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),t.markers.has("drop-target")&&t.change(t=>{t.removeMarker("drop-target")})}_finalizeDragging(t){const e=this.editor,n=e.model;this._removeDropMarker(),this._clearDraggableAttributes(),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(t&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function db(t,e,n){const o=t.model,i=t.editing.mapper;let r=null;const s=e?e[0].start:null;if(n.is("uiElement")&&(n=n.parent),r=function(t,e){const n=t.model,o=t.editing.mapper;if(Sk(e))return n.createRangeOn(o.toModelElement(e));if(!e.is("editableElement")){const t=e.findAncestor(t=>Sk(t)||t.is("editableElement"));if(Sk(t))return n.createRangeOn(o.toModelElement(t))}return null}(t,n),r)return r;const a=function(t,e){const n=t.editing.mapper,o=t.editing.view,i=n.toModelElement(e);if(i)return i;const r=o.createPositionBefore(e),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(t,n),c=s?i.toModelPosition(s):null;return c?(r=function(t,e,n){const o=t.model;if(!o.schema.checkChild(n,"$block"))return null;const i=o.createPositionAt(n,0),r=e.path.slice(0,i.path.length),s=o.createPositionFromPath(e.root,r),a=s.nodeAfter;return a&&o.schema.isObject(a)?o.createRangeOn(a):null}(t,c,a),r||(r=o.schema.getNearestSelectionRange(c,h.isGecko?"forward":"backward"),r||function(t,e){const n=t.model;let o=e;for(;o;){if(n.schema.isObject(o))return n.createRangeOn(o);o=o.parent}return null}(t,c.parent))):function(t,e){const n=t.model,o=n.schema,i=n.createPositionAt(e,0);return o.getNearestSelectionRange(i,"forward")}(t,a)}function hb(t){return h.isGecko?t.dropEffect:["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function ub(t,e){let n;function o(...i){o.cancel(),n=setTimeout(()=>t(...i),e)}return o.cancel=()=>{clearTimeout(n)},o}function gb(t){if(t.is("editableElement"))return null;if(t.hasClass("ck-widget__selection-handle"))return t.findAncestor(Sk);if(Sk(t))return t;const e=t.findAncestor(t=>Sk(t)||t.is("editableElement"));return Sk(e)?e:null}class mb extends Ss{static get pluginName(){return"PastePlainText"}static get requires(){return[Ck]}init(){const t=this.editor,e=t.model,n=t.editing.view,o=n.document,i=e.document.selection;let r=!1;n.addObserver(wk),this.listenTo(o,"keydown",(t,e)=>{r=e.shiftKey}),t.plugins.get(Ck).on("contentInsertion",(t,n)=>{(r||function(t,e){if(t.childCount>1)return!1;const n=t.getChild(0);return!e.isObject(n)&&0==Array.from(n.getAttributeKeys()).length}(n.content,e.schema))&&e.change(t=>{const o=Array.from(i.getAttributes()).filter(([t])=>e.schema.getAttributeProperties(t).isFormatting);i.isCollapsed||e.deleteContent(i,{doNotAutoparagraph:!0}),o.push(...i.getAttributes());const r=t.createRangeIn(n.content);for(const e of r.getItems())e.is("$textProxy")&&t.setAttributes(o,e)})})}}class pb extends Ss{static get pluginName(){return"Clipboard"}static get requires(){return[Ck,lb,mb]}}class fb extends Ns{constructor(t){super(t),this.affectsData=!1}execute(){const t=this.editor.model,e=t.document.selection;let n=t.schema.getLimitElement(e);if(e.containsEntireContent(n)||!kb(t.schema,n))do{if(n=n.parent,!n)return}while(!kb(t.schema,n));t.change(t=>{t.setSelection(n,"in")})}}function kb(t,e){return t.isLimit(e)&&(t.checkChild(e,"$text")||t.checkChild(e,"paragraph"))}const bb=cr("Ctrl+A");class wb extends Ss{static get pluginName(){return"SelectAllEditing"}init(){const t=this.editor,e=t.editing.view.document;t.commands.add("selectAll",new fb(t)),this.listenTo(e,"keydown",(e,n)=>{ar(n)===bb&&(t.execute("selectAll"),n.preventDefault())})}}class _b extends Ss{static get pluginName(){return"SelectAllUI"}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",e=>{const n=t.commands.get("selectAll"),o=new rs(e),i=e.t;return o.set({label:i("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),o})}}class Ab extends Ss{static get requires(){return[wb,_b]}static get pluginName(){return"SelectAll"}}class Cb extends Ns{constructor(t){super(t),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(t.data,"set",(t,e)=>{e[1]={...e[1]};const n=e[1];n.batchType||(n.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(t.data,"set",(t,e)=>{e[1].batchType.isUndoable||this.clearStack()})}refresh(){this.isEnabled=this._stack.length>0}addBatch(t){const e=this.editor.model.document.selection,n={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(t,e,n){const o=this.editor.model,i=o.document,r=[],s=t.map(t=>t.getTransformedByOperations(n)),a=s.flat();for(const c of s){const t=c.filter(t=>t.root!=i.graveyard).filter(t=>!yb(t,a));t.length&&(vb(t),r.push(t[0]))}r.length&&o.change(t=>{t.setSelection(r,{backward:e})})}_undo(t,e){const n=this.editor.model,o=n.document;this._createdBatches.add(e);const i=t.operations.slice().filter(t=>t.isDocumentOperation);i.reverse();for(const r of i){const t=r.baseVersion+1,i=Array.from(o.history.getOperations(t)),s=Ru([r.getReversed()],i,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const a of s)e.addOperation(a),n.applyOperation(a),o.history.setOperationAsUndone(r,a)}}}function vb(t){t.sort((t,e)=>t.start.isBefore(e.start)?-1:1);for(let e=1;ee!==t&&e.containsRange(t,!0))}class xb extends Cb{execute(t=null){const e=t?this._stack.findIndex(e=>e.batch==t):this._stack.length-1,n=this._stack.splice(e,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,()=>{this._undo(n.batch,o);const t=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,t),this.fire("revert",n.batch,o)}),this.refresh()}}class Eb extends Cb{execute(){const t=this._stack.pop(),e=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(e,()=>{const n=t.batch.operations[t.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(n);this._restoreSelection(t.selection.ranges,t.selection.isBackward,o),this._undo(t.batch,e)}),this.refresh()}}class Db extends Ss{static get pluginName(){return"UndoEditing"}constructor(t){super(t),this._batchRegistry=new WeakSet}init(){const t=this.editor;this._undoCommand=new xb(t),this._redoCommand=new Eb(t),t.commands.add("undo",this._undoCommand),t.commands.add("redo",this._redoCommand),this.listenTo(t.model,"applyOperation",(t,e)=>{const n=e[0];if(!n.isDocumentOperation)return;const o=n.batch,i=this._redoCommand._createdBatches.has(o),r=this._undoCommand._createdBatches.has(o);this._batchRegistry.has(o)||(this._batchRegistry.add(o),o.isUndoable&&(i?this._undoCommand.addBatch(o):r||(this._undoCommand.addBatch(o),this._redoCommand.clearStack())))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(t,e,n)=>{this._redoCommand.addBatch(n)}),t.keystrokes.set("CTRL+Z","undo"),t.keystrokes.set("CTRL+Y","redo"),t.keystrokes.set("CTRL+SHIFT+Z","redo")}}const Tb='',Ib='';class Sb extends Ss{static get pluginName(){return"UndoUI"}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?Tb:Ib,i="ltr"==e.uiLanguageDirection?Ib:Tb;this._addButton("undo",n("Undo"),"CTRL+Z",o),this._addButton("redo",n("Redo"),"CTRL+Y",i)}_addButton(t,e,n,o){const i=this.editor;i.ui.componentFactory.add(t,r=>{const s=i.commands.get(t),a=new rs(r);return a.set({label:e,icon:o,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",()=>{i.execute(t),i.editing.view.focus()}),a})}}class Mb extends Ss{static get requires(){return[Db,Sb]}static get pluginName(){return"Undo"}}class Nb extends Ns{constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute(this.attributeKey),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=t.value;e.change(t=>{if(n.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,o):t.removeSelectionAttribute(this.attributeKey);else{const i=e.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const e of i)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}})}}class Bb extends fr{constructor(t){super(t),this.set("isEmpty",!0),this.on("change",()=>{this.set("isEmpty",0===this.length)})}add(t,e){this.find(e=>e.color===t.color)||super.add(t,e)}hasColor(t){return!!this.find(e=>e.color===t)}}k(Bb,Z);var Pb=r(2585),zb={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(Pb.Z,zb),Pb.Z.locals;class Lb extends Mr{constructor(t,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r}){super(t),this.items=this.createCollection(),this.colorDefinitions=e,this.focusTracker=new br,this.keystrokes=new wr,this.set("selectedColor"),this.removeButtonLabel=o,this.columns=n,this.documentColors=new Bb,this.documentColorsCount=r,this._focusables=new Er,this._focusCycler=new xs({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._documentColorsLabel=i,this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._createRemoveColorButton())}updateDocumentColors(t,e){const n=t.document,o=this.documentColorsCount;this.documentColors.clear();for(const i of n.getRootNames()){const r=n.getRoot(i),s=t.createRangeIn(r);for(const t of s.getItems())if(t.is("$textProxy")&&t.hasAttribute(e)&&(this._addColorToDocumentColors(t.getAttribute(e)),this.documentColors.length>=o))return}}updateSelectedColors(){const t=this.documentColorsGrid,e=this.staticColorsGrid,n=this.selectedColor;e.selectedColor=n,t&&(t.selectedColor=n)}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendGrids(){if(!this.staticColorsGrid&&(this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid),this.documentColorsCount)){const t=Nr.bind(this.documentColors,this.documentColors),e=new Zm(this.locale);e.text=this._documentColorsLabel,e.extendTemplate({attributes:{class:["ck","ck-color-grid__label",t.if("isEmpty","ck-hidden")]}}),this.items.add(e),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid),this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid)}}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_createRemoveColorButton(){const t=new rs;return t.set({withText:!0,icon:cm.eraser,label:this.removeButtonLabel}),t.class="ck-color-table__remove-color",t.on("execute",()=>{this.fire("execute",{value:null})}),t.render(),this.focusTracker.add(t.element),this._focusables.add(t),t}_createStaticColorsGrid(){const t=new gs(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return t.delegate("execute").to(this),t}_createDocumentColorsGrid(){const t=Nr.bind(this.documentColors,this.documentColors),e=new gs(this.locale,{columns:this.columns});return e.delegate("execute").to(this),e.extendTemplate({attributes:{class:t.if("isEmpty","ck-hidden")}}),e.items.bindTo(this.documentColors).using(t=>{const e=new ds;return e.set({color:t.color,hasBorder:t.options&&t.options.hasBorder}),t.label&&e.set({label:t.label,tooltip:!0}),e.on("execute",()=>{this.fire("execute",{value:t.color})}),e}),this.documentColors.on("change:isEmpty",(t,n,o)=>{o&&(e.selectedColor=null)}),e}_addColorToDocumentColors(t){const e=this.colorDefinitions.find(e=>e.color===t);e?this.documentColors.add(Object.assign({},e)):this.documentColors.add({color:t,label:t,options:{hasBorder:!1}})}}const Ob="fontSize",Rb="fontFamily",jb="fontColor",Fb="fontBackgroundColor";function Vb(t,e){const n={model:{key:t,values:[]},view:{},upcastAlso:{}};for(const o of e)n.model.values.push(o.model),n.view[o.model]=o.view,o.upcastAlso&&(n.upcastAlso[o.model]=o.upcastAlso);return n}function Hb(t){return e=>e.getStyle(t).replace(/\s/g,"")}function Ub(t){return(e,{writer:n})=>n.createAttributeElement("span",{style:`${t}:${e}`},{priority:7})}class Gb extends Nb{constructor(t){super(t,Fb)}}class qb extends Ss{static get pluginName(){return"FontBackgroundColorEditing"}constructor(t){super(t),t.config.define(Fb,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),t.data.addStyleProcessorRules(em),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:Fb,value:Hb("background-color")}}),t.conversion.for("downcast").attributeToElement({model:Fb,view:Ub("background-color")}),t.commands.add(Fb,new Gb(t)),t.model.schema.extend("$text",{allowAttributes:Fb}),t.model.schema.setAttributeProperties(Fb,{isFormatting:!0,copyOnEnter:!0})}}class Wb extends Ss{constructor(t,{commandName:e,icon:n,componentName:o,dropdownLabel:i}){super(t),this.commandName=e,this.componentName=o,this.icon=n,this.dropdownLabel=i,this.columns=t.config.get(this.componentName+".columns"),this.colorTableView=void 0}init(){const t=this.editor,e=t.locale,n=e.t,o=t.commands.get(this.commandName),i=function(t){return t.map(ls).filter(t=>!!t)}(t.config.get(this.componentName).colors),r=function(t,e){const n=t.t,o={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return e.map(t=>{const e=o[t.label];return e&&e!=t.label&&(t.label=e),t})}(e,i),s=t.config.get(this.componentName+".documentColors");t.ui.componentFactory.add(this.componentName,e=>{const i=Em(e);return this.colorTableView=function({dropdownView:t,colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r}){const s=t.locale,a=new Lb(s,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r});return t.colorTableView=a,t.panelView.children.add(a),a.delegate("execute").to(t,"execute"),a}({dropdownView:i,colors:r.map(t=>({label:t.label,color:t.model,options:{hasBorder:t.hasBorder}})),columns:this.columns,removeButtonLabel:n("Remove color"),documentColorsLabel:0!==s?n("Document colors"):void 0,documentColorsCount:void 0===s?this.columns:s}),this.colorTableView.bind("selectedColor").to(o,"value"),i.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),i.bind("isEnabled").to(o),i.on("execute",(e,n)=>{t.execute(this.commandName,n),t.editing.view.focus()}),i.on("change:isOpen",(e,n,o)=>{i.colorTableView.appendGrids(),o&&(0!==s&&this.colorTableView.updateDocumentColors(t.model,this.componentName),this.colorTableView.updateSelectedColors())}),Mm(i,()=>i.colorTableView.staticColorsGrid.items.find(t=>t.isOn)),i})}}class Yb extends Wb{constructor(t){const e=t.locale.t;super(t,{commandName:Fb,componentName:Fb,icon:'',dropdownLabel:e("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Kb extends Nb{constructor(t){super(t,jb)}}class $b extends Ss{static get pluginName(){return"FontColorEditing"}constructor(t){super(t),t.config.define(jb,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:jb,value:Hb("color")}}),t.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:jb,value:t=>t.getAttribute("color")}}),t.conversion.for("downcast").attributeToElement({model:jb,view:Ub("color")}),t.commands.add(jb,new Kb(t)),t.model.schema.extend("$text",{allowAttributes:jb}),t.model.schema.setAttributeProperties(jb,{isFormatting:!0,copyOnEnter:!0})}}class Qb extends Wb{constructor(t){const e=t.locale.t;super(t,{commandName:jb,componentName:jb,icon:'',dropdownLabel:e("Font Color")})}static get pluginName(){return"FontColorUI"}}class Zb extends Nb{constructor(t){super(t,Rb)}}function Jb(t){return t.map(Xb).filter(t=>!!t)}function Xb(t){return"object"==typeof t?t:"default"===t?{title:"Default",model:void 0}:"string"==typeof t?function(t){const e=t.replace(/"|'/g,"").split(","),n=e[0],o=e.map(tw).join(", ");return{title:n,model:o,view:{name:"span",styles:{"font-family":o},priority:7}}}(t):void 0}function tw(t){return(t=t.trim()).indexOf(" ")>0&&(t=`'${t}'`),t}class ew extends Ss{static get pluginName(){return"FontFamilyEditing"}constructor(t){super(t),t.config.define(Rb,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Rb}),t.model.schema.setAttributeProperties(Rb,{isFormatting:!0,copyOnEnter:!0});const e=Jb(t.config.get("fontFamily.options")).filter(t=>t.model),n=Vb(Rb,e);t.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):t.conversion.attributeToElement(n),t.commands.add(Rb,new Zb(t))}_prepareAnyValueConverters(){const t=this.editor;t.conversion.for("downcast").attributeToElement({model:Rb,view:(t,{writer:e})=>e.createAttributeElement("span",{style:"font-family:"+t},{priority:7})}),t.conversion.for("upcast").elementToAttribute({model:{key:Rb,value:t=>t.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:Rb,value:t=>t.getAttribute("face")}})}}class nw extends Ss{static get pluginName(){return"FontFamilyUI"}init(){const t=this.editor,e=t.t,n=this._getLocalizedOptions(),o=t.commands.get(Rb);t.ui.componentFactory.add(Rb,i=>{const r=Em(i);return Im(r,()=>function(t,e){const n=new fr;for(const o of t){const t={type:"button",model:new up({commandName:Rb,commandParam:o.model,label:o.title,withText:!0})};t.model.bind("isOn").to(e,"value",t=>t===o.model||!(!t||!o.model)&&t.split(",")[0].replace(/'/g,"").toLowerCase()===o.model.toLowerCase()),o.view&&o.view.styles&&t.model.set("labelStyle","font-family: "+o.view.styles["font-family"]),n.add(t)}return n}(n,o)),r.buttonView.set({label:e("Font Family"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(o),this.listenTo(r,"execute",e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()}),r})}_getLocalizedOptions(){const t=this.editor,e=t.t;return Jb(t.config.get(Rb).options).map(t=>("Default"===t.title&&(t.title=e("Default")),t))}}class ow extends Nb{constructor(t){super(t,Ob)}}function iw(t){return t.map(t=>function(t){if(e=t,"object"==typeof e&&e.title&&e.model&&e.view)return sw(t);var e;const n=function(t){return rw[t]||rw[t.model]}(t);return n?sw(n):"default"===t?{model:void 0,title:"Default"}:function(t){let e;if("object"==typeof t){if(!t.model)throw new x("font-size-invalid-definition",null,t);e=parseFloat(t.model)}else e=parseFloat(t);return isNaN(e)}(t)?void 0:function(t){return"number"!=typeof t&&"string"!=typeof t||(t={title:String(t),model:parseFloat(t)+"px"}),t.view={name:"span",styles:{"font-size":t.model}},sw(t)}(t)}(t)).filter(t=>!!t)}const rw={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 sw(t){return t.view.priority||(t.view.priority=7),t}const aw=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class cw extends Ss{static get pluginName(){return"FontSizeEditing"}constructor(t){super(t),t.config.define(Ob,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Ob}),t.model.schema.setAttributeProperties(Ob,{isFormatting:!0,copyOnEnter:!0});const e=t.config.get("fontSize.supportAllValues"),n=iw(this.editor.config.get("fontSize.options")).filter(t=>t.model),o=Vb(Ob,n);e?(this._prepareAnyValueConverters(o),this._prepareCompatibilityConverter()):t.conversion.attributeToElement(o),t.commands.add(Ob,new ow(t))}_prepareAnyValueConverters(t){const e=this.editor,n=t.model.values.filter(t=>{return e=String(t),!(Gg.test(e)||function(t){return qg.test(t)}(String(t)));var e});if(n.length)throw new x("font-size-invalid-use-of-named-presets",null,{presets:n});e.conversion.for("downcast").attributeToElement({model:Ob,view:(t,{writer:e})=>{if(t)return e.createAttributeElement("span",{style:"font-size:"+t},{priority:7})}}),e.conversion.for("upcast").elementToAttribute({model:{key:Ob,value:t=>t.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:Ob,value:t=>{const e=t.getAttribute("size"),n="-"===e[0]||"+"===e[0];let o=parseInt(e,10);n&&(o=3+o);const i=aw.length-1,r=Math.min(Math.max(o,0),i);return aw[r]}}})}}var lw=r(6203),dw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(lw.Z,dw),lw.Z.locals;class hw extends Ss{static get pluginName(){return"FontSizeUI"}init(){const t=this.editor,e=t.t,n=this._getLocalizedOptions(),o=t.commands.get(Ob);t.ui.componentFactory.add(Ob,i=>{const r=Em(i);return Im(r,()=>function(t,e){const n=new fr;for(const o of t){const t={type:"button",model:new up({commandName:Ob,commandParam:o.model,label:o.title,class:"ck-fontsize-option",withText:!0})};o.view&&o.view.styles&&t.model.set("labelStyle","font-size:"+o.view.styles["font-size"]),o.view&&o.view.classes&&t.model.set("class",`${t.model.class} ${o.view.classes}`),t.model.bind("isOn").to(e,"value",t=>t===o.model),n.add(t)}return n}(n,o)),r.buttonView.set({label:e("Font Size"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(o),this.listenTo(r,"execute",e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()}),r})}_getLocalizedOptions(){const t=this.editor,e=t.t,n={Default:e("Default"),Tiny:e("Tiny"),Small:e("Small"),Big:e("Big"),Huge:e("Huge")};return iw(t.config.get(Ob).options).map(t=>{const e=n[t.title];return e&&e!=t.title&&(t=Object.assign({},t,{title:e})),t})}}class uw extends Ns{refresh(){const t=this.editor.model,e=kr(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("element","paragraph"),this.isEnabled=!!e&&gw(e,t.schema)}execute(t={}){const e=this.editor.model,n=e.document;e.change(o=>{const i=(t.selection||n.selection).getSelectedBlocks();for(const t of i)!t.is("element","paragraph")&&gw(t,e.schema)&&o.rename(t,"paragraph")})}}function gw(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class mw extends Ns{execute(t){const e=this.editor.model,n=t.attributes;let o=t.position;e.change(t=>{const i=t.createElement("paragraph");if(n&&e.schema.setAllowedAttributes(i,n,t),!e.schema.checkChild(o.parent,i)){const n=e.schema.findAllowedParent(o,i);if(!n)return;o=t.split(o,n).position}e.insertContent(i,o),t.setSelection(i,"in")})}}class pw extends Ss{static get pluginName(){return"Paragraph"}init(){const t=this.editor,e=t.model;t.commands.add("paragraph",new uw(t)),t.commands.add("insertParagraph",new mw(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,{writer:e})=>pw.paragraphLikeElements.has(t.name)?t.isEmpty?null:e.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}pw.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class fw extends Ns{constructor(t,e){super(t),this.modelElements=e}refresh(){const t=kr(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some(e=>kw(t,e,this.editor.model.schema))}execute(t){const e=this.editor.model,n=e.document,o=t.value;e.change(t=>{const i=Array.from(n.selection.getSelectedBlocks()).filter(t=>kw(t,o,e.schema));for(const e of i)e.is("element",o)||t.rename(e,o)})}}function kw(t,e,n){return n.checkChild(t.parent,e)&&!n.isObject(t)}const bw="paragraph";class ww extends Ss{static get pluginName(){return"HeadingEditing"}constructor(t){super(t),t.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[pw]}init(){const t=this.editor,e=t.config.get("heading.options"),n=[];for(const o of e)"paragraph"!==o.model&&(t.model.schema.register(o.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new fw(t,n))}afterInit(){const t=this.editor,e=t.commands.get("enter"),n=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",(e,o)=>{const i=t.model.document.selection.getFirstPosition().parent;n.some(t=>i.is("element",t.model))&&!i.is("element",bw)&&0===i.childCount&&o.writer.rename(i,bw)})}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:C.get("low")+1})}}var _w=r(3230),Aw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(_w.Z,Aw),_w.Z.locals;class Cw extends Ss{static get pluginName(){return"HeadingUI"}init(){const t=this.editor,e=t.t,n=function(t){const e=t.t,n={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return t.config.get("heading.options").map(t=>{const e=n[t.title];return e&&e!=t.title&&(t.title=e),t})}(t),o=e("Choose heading"),i=e("Heading");t.ui.componentFactory.add("heading",e=>{const r={},s=new fr,a=t.commands.get("heading"),c=t.commands.get("paragraph"),l=[a];for(const t of n){const e={type:"button",model:new up({label:t.title,class:t.class,withText:!0})};"paragraph"===t.model?(e.model.bind("isOn").to(c,"value"),e.model.set("commandName","paragraph"),l.push(c)):(e.model.bind("isOn").to(a,"value",e=>e===t.model),e.model.set({commandName:"heading",commandValue:t.model})),s.add(e),r[t.model]=t.title}const d=Em(e);return Im(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:i}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",(...t)=>t.some(t=>t)),d.buttonView.bind("label").to(a,"value",c,"value",(t,e)=>{const n=t||e&&"paragraph";return"boolean"==typeof n?o:r[n]?r[n]:o}),this.listenTo(d,"execute",e=>{const{commandName:n,commandValue:o}=e.source;t.execute(n,o?{value:o}:void 0),t.editing.view.focus()}),d})}}class vw extends Ns{refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute("highlight"),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,"highlight")}execute(t={}){const e=this.editor.model,n=e.document.selection,o=t.value;e.change(t=>{if(n.isCollapsed){const e=n.getFirstPosition();if(n.hasAttribute("highlight")){const n=t=>t.item.hasAttribute("highlight")&&t.item.getAttribute("highlight")===this.value,i=e.getLastMatchingPosition(n,{direction:"backward"}),r=e.getLastMatchingPosition(n),s=t.createRange(i,r);o&&this.value!==o?(e.isEqual(r)||t.setAttribute("highlight",o,s),t.setSelectionAttribute("highlight",o)):(e.isEqual(r)||t.removeAttribute("highlight",s),t.removeSelectionAttribute("highlight"))}else o&&t.setSelectionAttribute("highlight",o)}else{const i=e.schema.getValidRanges(n.getRanges(),"highlight");for(const e of i)o?t.setAttribute("highlight",o,e):t.removeAttribute("highlight",e)}})}}class yw extends Ss{static get pluginName(){return"HighlightEditing"}constructor(t){super(t),t.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"highlight"});const e=t.config.get("highlight.options");t.conversion.attributeToElement(function(t){const e={model:{key:"highlight",values:[]},view:{}};for(const n of t)e.model.values.push(n.model),e.view[n.model]={name:"mark",classes:n.class};return e}(e)),t.commands.add("highlight",new vw(t))}}const xw='',Ew='';var Dw=r(713),Tw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(Dw.Z,Tw),Dw.Z.locals;class Iw extends Ss{get localizedOptionTitles(){const t=this.editor.t;return{"Yellow marker":t("Yellow marker"),"Green marker":t("Green marker"),"Pink marker":t("Pink marker"),"Blue marker":t("Blue marker"),"Red pen":t("Red pen"),"Green pen":t("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const t=this.editor.config.get("highlight.options");for(const e of t)this._addHighlighterButton(e);this._addRemoveHighlightButton(),this._addDropdown(t)}_addRemoveHighlightButton(){const t=this.editor.t,e=this.editor.commands.get("highlight");this._addButton("removeHighlight",t("Remove highlight"),cm.eraser,null,t=>{t.bind("isEnabled").to(e,"isEnabled")})}_addHighlighterButton(t){const e=this.editor.commands.get("highlight");this._addButton("highlight:"+t.model,t.title,Sw(t.type),t.model,(function(n){n.bind("isEnabled").to(e,"isEnabled"),n.bind("isOn").to(e,"value",e=>e===t.model),n.iconView.fillColor=t.color,n.isToggleable=!0}))}_addButton(t,e,n,o,i){const r=this.editor;r.ui.componentFactory.add(t,t=>{const s=new rs(t),a=this.localizedOptionTitles[e]?this.localizedOptionTitles[e]:e;return s.set({label:a,icon:n,tooltip:!0}),s.on("execute",()=>{r.execute("highlight",{value:o}),r.editing.view.focus()}),i(s),s})}_addDropdown(t){const e=this.editor,n=e.t,o=e.ui.componentFactory,i=t[0],r=t.reduce((t,e)=>(t[e.model]=e,t),{});o.add("highlight",s=>{const a=e.commands.get("highlight"),c=Em(s,vs),l=c.buttonView;function d(t,e){const n=t&&t!==l.lastExecuted?t:l.lastExecuted;return r[n][e]}return l.set({label:n("Highlight"),tooltip:!0,lastExecuted:i.model,commandValue:i.model,isToggleable:!0}),l.bind("icon").to(a,"value",t=>Sw(d(t,"type"))),l.bind("color").to(a,"value",t=>d(t,"color")),l.bind("commandValue").to(a,"value",t=>d(t,"model")),l.bind("isOn").to(a,"value",t=>!!t),l.delegate("execute").to(c),c.bind("isEnabled").to(a,"isEnabled"),Dm(c,()=>{const e=t.map(t=>{const e=o.create("highlight:"+t.model);return this.listenTo(e,"execute",()=>{c.buttonView.set({lastExecuted:t.model})}),e});return e.push(new Ds),e.push(o.create("removeHighlight")),e},{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:n("Text highlight toolbar")}),function(t){const e=t.buttonView.actionView;e.iconView.bind("fillColor").to(t.buttonView,"color")}(c),l.on("execute",()=>{e.execute("highlight",{value:l.commandValue})}),this.listenTo(c,"execute",()=>{e.editing.view.focus()}),c})}}function Sw(t){return"marker"===t?xw:Ew}class Mw extends Ns{refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled&&t.hasAttribute("alt")?this.value=t.getAttribute("alt"):this.value=!1}execute(t){const e=this.editor,n=e.plugins.get("ImageUtils"),o=e.model,i=n.getClosestSelectedImageElement(o.document.selection);o.change(e=>{e.setAttribute("alt",t.newValue,i)})}}function Nw(t){return t.createContainerElement("figure",{class:"image"},[t.createEmptyElement("img"),t.createSlot()])}function Bw(t,e){const n=t.plugins.get("ImageUtils"),o=t.plugins.has("ImageInlineEditing")&&t.plugins.has("ImageBlockEditing");return t=>n.isInlineImageView(t)?o&&("block"==t.getStyle("display")||t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==e?null:i(t):null;function i(t){const e={name:!0};return t.hasAttribute("src")&&(e.attributes=["src"]),e}}function Pw(t,e){const n=kr(e.getSelectedBlocks());return!n||t.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}class zw extends Ss{static get pluginName(){return"ImageUtils"}isImage(t){return this.isInlineImage(t)||this.isBlockImage(t)}isInlineImageView(t){return!!t&&t.is("element","img")}isBlockImageView(t){return!!t&&t.is("element","figure")&&t.hasClass("image")}insertImage(t={},e=null,n=null){const o=this.editor,i=o.model,r=i.document.selection;n=Lw(o,e||r,n),t={...Object.fromEntries(r.getAttributes()),...t};for(const s in t)i.schema.checkAttribute(n,s)||delete t[s];return i.change(o=>{const r=o.createElement(n,t);return i.insertObject(r,e,null,{setSelection:"on",findOptimalPosition:!e&&"imageInline"!=n}),r.parent?r:null})}getClosestSelectedImageWidget(t){const e=t.getFirstPosition();if(!e)return null;const n=t.getSelectedElement();if(n&&this.isImageWidget(n))return n;let o=e.parent;for(;o;){if(o.is("element")&&this.isImageWidget(o))return o;o=o.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const t=this.editor.model.document.selection;return function(t,e){const n=Lw(t,e);if("imageBlock"==n){const n=function(t,e){const n=Lk(t,e),o=n.start.parent;return o.isEmpty&&!o.is("element","$root")?o.parent:o}(e,t.model);if(t.model.schema.checkChild(n,"imageBlock"))return!0}else if(t.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}(this.editor,t)&&function(t){return[...t.focus.getAncestors()].every(t=>!t.is("element","imageBlock"))}(t)}toImageWidget(t,e,n){return e.setCustomProperty("image",!0,t),Mk(t,e,{label:()=>{const e=this.findViewImgElement(t).getAttribute("alt");return e?`${e} ${n}`:n}})}isImageWidget(t){return!!t.getCustomProperty("image")&&Sk(t)}isBlockImage(t){return!!t&&t.is("element","imageBlock")}isInlineImage(t){return!!t&&t.is("element","imageInline")}findViewImgElement(t){if(this.isInlineImageView(t))return t;const e=this.editor.editing.view;for(const{item:n}of e.createRangeIn(t))if(this.isInlineImageView(n))return n}}function Lw(t,e,n){const o=t.model.schema,i=t.config.get("image.insert.type");return t.plugins.has("ImageBlockEditing")?t.plugins.has("ImageInlineEditing")?n||("inline"===i?"imageInline":"block"===i?"imageBlock":e.is("selection")?Pw(o,e):o.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class Ow extends Ss{static get requires(){return[zw]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Mw(this.editor))}}var Rw=r(6831),jw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(Rw.Z,jw),Rw.Z.locals;var Fw=r(1590),Vw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(Fw.Z,Vw),Fw.Z.locals;class Hw extends Mr{constructor(t){super(t);const e=this.locale.t;this.focusTracker=new br,this.keystrokes=new wr,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(e("Save"),cm.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(e("Cancel"),cm.cancel,"ck-button-cancel","cancel"),this._focusables=new Er,this._focusCycler=new xs({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]}),i(this)}render(){super.render(),this.keystrokes.listenTo(this.element),a({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(t,e,n,o){const i=new rs(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createLabeledInputView(){const t=this.locale.t,e=new lp(this.locale,dp);return e.label=t("Text alternative"),e}}function Uw(t){const e=t.editing.view,n=Lm.defaultPositions,o=t.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(o.getClosestSelectedImageWidget(e.document.selection)),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class Gw extends Ss{static get requires(){return[bp]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const t=this.editor,e=t.t;t.ui.componentFactory.add("imageTextAlternative",n=>{const o=t.commands.get("imageTextAlternative"),i=new rs(n);return i.set({label:e("Change image text alternative"),icon:cm.lowVision,tooltip:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",t=>!!t),this.listenTo(i,"execute",()=>{this._showForm()}),i})}_createForm(){const t=this.editor,e=t.editing.view.document,o=t.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new Hw(t.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{t.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this._form.keystrokes.set("Esc",(t,e)=>{this._hideForm(!0),e()}),this.listenTo(t.ui,"update",()=>{o.getClosestSelectedImageWidget(e.selection)?this._isVisible&&function(t){const e=t.plugins.get("ContextualBalloon");if(t.plugins.get("ImageUtils").getClosestSelectedImageWidget(t.editing.view.document.selection)){const n=Uw(t);e.updatePosition(n)}}(t):this._hideForm(!0)}),n({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const t=this.editor,e=t.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Uw(t)}),n.fieldView.value=n.fieldView.element.value=e.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(t){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),t&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class qw extends Ss{static get requires(){return[Ow,Gw]}static get pluginName(){return"ImageTextAlternative"}}function Ww(t,e){return t=>{t.on("attribute:srcset:"+e,n)};function n(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);if(null===n.attributeNewValue){const t=n.attributeOldValue;t.data&&(i.removeAttribute("srcset",s),i.removeAttribute("sizes",s),t.width&&i.removeAttribute("width",s))}else{const t=n.attributeNewValue;t.data&&(i.setAttribute("srcset",t.data,s),i.setAttribute("sizes","100vw",s),t.width&&i.setAttribute("width",t.width,s))}}}function Yw(t,e,n){return t=>{t.on(`attribute:${n}:${e}`,o)};function o(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)}}class Kw extends wl{observe(t){this.listenTo(t,"load",(t,e)=>{const n=e.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(e)},{useCapture:!0})}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}}class $w extends Ns{constructor(t){super(t);const e=t.config.get("image.insert.type");t.plugins.has("ImageBlockEditing")||"block"===e&&E("image-block-plugin-required"),t.plugins.has("ImageInlineEditing")||"inline"===e&&E("image-inline-plugin-required")}refresh(){this.isEnabled=this.editor.plugins.get("ImageUtils").isImageAllowed()}execute(t){const e=hr(t.source),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach((t,e)=>{const r=n.getSelectedElement();if("string"==typeof t&&(t={src:t}),e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);o.insertImage({...t,...i},e)}else o.insertImage({...t,...i})})}}class Qw extends Ns{refresh(){const t=this.editor.plugins.get("ImageUtils"),e=this.editor.model.document.selection.getSelectedElement();this.isEnabled=t.isImage(e),this.value=this.isEnabled?e.getAttribute("src"):null}execute(t){const e=this.editor.model.document.selection.getSelectedElement();this.editor.model.change(n=>{n.setAttribute("src",t.source,e),n.removeAttribute("srcset",e),n.removeAttribute("sizes",e)})}}class Zw extends Ss{static get requires(){return[zw]}static get pluginName(){return"ImageEditing"}init(){const t=this.editor,e=t.conversion;t.editing.view.addObserver(Kw),e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:t=>{const e={data:t.getAttribute("srcset")};return t.hasAttribute("width")&&(e.width=t.getAttribute("width")),e}}});const n=new $w(t),o=new Qw(t);t.commands.add("insertImage",n),t.commands.add("replaceImageSource",o),t.commands.add("imageInsert",n)}}class Jw extends Ns{constructor(t,e){super(t),this._modelElementName=e}refresh(){const t=this.editor.plugins.get("ImageUtils"),e=t.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=t.isInlineImage(e):this.isEnabled=t.isBlockImage(e)}execute(){const t=this.editor,e=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(e.document.selection),i=Object.fromEntries(o.getAttributes());return i.src||i.uploadId?e.change(t=>{const r=Array.from(e.markers).filter(t=>t.getRange().containsItem(o)),s=n.insertImage(i,e.createSelection(o,"on"),this._modelElementName);if(!s)return null;const a=t.createRangeOn(s);for(const e of r){const n=e.getRange(),o="$graveyard"!=n.root.rootName?n.getJoined(a,!0):a;t.updateMarker(e,{range:o})}return{oldElement:o,newElement:s}}):null}}class Xw extends Ss{static get requires(){return[Zw,zw,Ck]}static get pluginName(){return"ImageBlockEditing"}init(){const t=this.editor;t.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),t.plugins.has("ImageInlineEditing")&&(t.commands.add("imageTypeBlock",new Jw(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:e})=>Nw(e)}),n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:n})=>o.toImageWidget(Nw(n),n,e("image widget"))}),n.for("downcast").add(Yw(o,"imageBlock","src")).add(Yw(o,"imageBlock","alt")).add(Ww(o,"imageBlock")),n.for("upcast").elementToElement({view:Bw(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)}).add(function(t){return t=>{t.on("element:figure",e)};function e(e,n,o){if(!o.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const i=t.findViewImgElement(n.viewItem);if(!i||!o.consumable.test(i,{name:!0}))return;o.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=kr(o.convertItem(i,n.modelCursor).modelRange.getItems());r?(o.convertChildren(n.viewItem,r),o.updateConversionResult(r,n)):o.consumable.revert(n.viewItem,{name:!0,classes:"image"})}}(o))}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",(i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isInlineImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const c=e.createSelection(a);if("imageBlock"===Pw(e.schema,c)){const t=new Lg(n.document),e=s.map(e=>t.createElement("figure",{class:"image"},e));r.content=t.createDocumentFragment(e)}})}}var t_=r(9048),e_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(t_.Z,e_),t_.Z.locals;class n_ extends Ss{static get requires(){return[Xw,Jk,qw]}static get pluginName(){return"ImageBlock"}}class o_ extends Ss{static get requires(){return[Zw,zw,Ck]}static get pluginName(){return"ImageInlineEditing"}init(){const t=this.editor,e=t.model.schema;e.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),e.addChildCheck((t,e)=>{if(t.endsWith("caption")&&"imageInline"===e.name)return!1}),this._setupConversion(),t.plugins.has("ImageBlockEditing")&&(t.commands.add("imageTypeInline",new Jw(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageInline",view:(t,{writer:e})=>e.createEmptyElement("img")}),n.for("editingDowncast").elementToStructure({model:"imageInline",view:(t,{writer:n})=>o.toImageWidget(function(t){return t.createContainerElement("span",{class:"image-inline"},t.createEmptyElement("img"))}(n),n,e("image widget"))}),n.for("downcast").add(Yw(o,"imageInline","src")).add(Yw(o,"imageInline","alt")).add(Ww(o,"imageInline")),n.for("upcast").elementToElement({view:Bw(t,"imageInline"),model:(t,{writer:e})=>e.createElement("imageInline",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)})}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",(i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isBlockImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const c=e.createSelection(a);if("imageInline"===Pw(e.schema,c)){const t=new Lg(n.document),e=s.map(e=>1===e.childCount?(Array.from(e.getAttributes()).forEach(n=>t.setAttribute(...n,o.findViewImgElement(e))),e.getChild(0)):e);r.content=t.createDocumentFragment(e)}})}}class i_ extends Ss{static get requires(){return[o_,Jk,qw]}static get pluginName(){return"ImageInline"}}class r_ extends Ns{refresh(){const t=this.editor,e=t.plugins.get("ImageCaptionUtils");if(!t.plugins.has(Xw))return this.isEnabled=!1,void(this.value=!1);const n=t.model.document.selection,o=n.getSelectedElement();if(!o){const t=e.getCaptionFromModelSelection(n);return this.isEnabled=!!t,void(this.value=!!t)}this.isEnabled=this.editor.plugins.get("ImageUtils").isImage(o),this.isEnabled?this.value=!!e.getCaptionFromImageModelElement(o):this.value=!1}execute(t={}){const{focusCaptionOnShow:e}=t;this.editor.model.change(t=>{this.value?this._hideImageCaption(t):this._showImageCaption(t,e)})}_showImageCaption(t,e){const n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing");let i=n.getSelectedElement();const r=o._getSavedCaption(i);this.editor.plugins.get("ImageUtils").isInlineImage(i)&&(this.editor.execute("imageTypeBlock"),i=n.getSelectedElement());const s=r||t.createElement("caption");t.append(s,i),e&&t.setSelection(s,"in")}_hideImageCaption(t){const e=this.editor,n=e.model.document.selection,o=e.plugins.get("ImageCaptionEditing"),i=e.plugins.get("ImageCaptionUtils");let r,s=n.getSelectedElement();s?r=i.getCaptionFromImageModelElement(s):(r=i.getCaptionFromModelSelection(n),s=r.parent),o._saveCaption(s,r),t.setSelection(s,"on"),t.remove(r)}}class s_ extends Ss{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[zw]}getCaptionFromImageModelElement(t){for(const e of t.getChildren())if(e&&e.is("element","caption"))return e;return null}getCaptionFromModelSelection(t){const e=this.editor.plugins.get("ImageUtils"),n=t.getFirstPosition().findAncestor("caption");return n&&e.isBlockImage(n.parent)?n:null}matchImageCaptionViewElement(t){const e=this.editor.plugins.get("ImageUtils");return"figcaption"==t.name&&e.isBlockImageView(t.parent)?{name:!0}:null}}class a_ extends Ss{static get requires(){return[zw,s_]}static get pluginName(){return"ImageCaptionEditing"}constructor(t){super(t),this._savedCaptionsMap=new WeakMap}init(){const t=this.editor,e=t.model.schema;e.isRegistered("caption")?e.extend("caption",{allowIn:"imageBlock"}):e.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),t.commands.add("toggleImageCaption",new r_(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageUtils"),o=t.plugins.get("ImageCaptionUtils"),i=t.t;t.conversion.for("upcast").elementToElement({view:t=>o.matchImageCaptionViewElement(t),model:"caption"}),t.conversion.for("dataDowncast").elementToElement({model:"caption",view:(t,{writer:e})=>n.isBlockImage(t.parent)?e.createContainerElement("figcaption"):null}),t.conversion.for("editingDowncast").elementToElement({model:"caption",view:(t,{writer:o})=>{if(!n.isBlockImage(t.parent))return null;const r=o.createEditableElement("figcaption");o.setCustomProperty("imageCaption",!0,r),Vs({view:e,element:r,text:i("Enter image caption"),keepOnFocus:!0});const s=t.parent.getAttribute("alt");return zk(r,o,{label:s?i("Caption for image: %0",[s]):i("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.plugins.get("ImageCaptionUtils"),o=t.commands.get("imageTypeInline"),i=t.commands.get("imageTypeBlock"),r=t=>{if(!t.return)return;const{oldElement:o,newElement:i}=t.return;if(!o)return;if(e.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(t)return void this._saveCaption(i,t)}const r=this._getSavedCaption(o);r&&this._saveCaption(i,r)};o&&this.listenTo(o,"execute",r,{priority:"low"}),i&&this.listenTo(i,"execute",r,{priority:"low"})}_getSavedCaption(t){const e=this._savedCaptionsMap.get(t);return e?Vd.fromJSON(e):null}_saveCaption(t,e){this._savedCaptionsMap.set(t,e.toJSON())}_registerCaptionReconversion(){const t=this.editor,e=t.model,n=t.plugins.get("ImageUtils"),o=t.plugins.get("ImageCaptionUtils");e.document.on("change:data",()=>{const i=e.document.differ.getChanges();for(const e of i){if("alt"!==e.attributeKey)continue;const i=e.range.start.nodeAfter;if(n.isBlockImage(i)){const e=o.getCaptionFromImageModelElement(i);if(!e)return;t.editing.reconvertItem(e)}}})}}class c_ extends Ss{static get requires(){return[s_]}static get pluginName(){return"ImageCaptionUI"}init(){const t=this.editor,e=t.editing.view,n=t.plugins.get("ImageCaptionUtils"),o=t.t;t.ui.componentFactory.add("toggleImageCaption",i=>{const r=t.commands.get("toggleImageCaption"),s=new rs(i);return s.set({icon:cm.caption,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.bind("label").to(r,"value",t=>o(t?"Toggle caption off":"Toggle caption on")),this.listenTo(s,"execute",()=>{t.execute("toggleImageCaption",{focusCaptionOnShow:!0});const o=n.getCaptionFromModelSelection(t.model.document.selection);if(o){const n=t.editing.mapper.toViewElement(o);e.scrollToTheSelection(),e.change(t=>{t.addClass("image__caption_highlighted",n)})}t.editing.view.focus()}),s})}}var l_=r(8662),d_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(l_.Z,d_),l_.Z.locals;class h_ extends Ns{constructor(t,e){super(t),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(e.map(t=>{if(t.isDefault)for(const e of t.modelElements)this._defaultStyles[e]=t.name;return[t.name,t]}))}refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled?t.hasAttribute("imageStyle")?this.value=t.getAttribute("imageStyle"):this.value=this._defaultStyles[t.name]:this.value=!1}execute(t={}){const e=this.editor,n=e.model,o=e.plugins.get("ImageUtils");n.change(e=>{const i=t.value;let r=o.getClosestSelectedImageElement(n.document.selection);i&&this.shouldConvertImageType(i,r)&&(this.editor.execute(o.isBlockImage(r)?"imageTypeInline":"imageTypeBlock"),r=o.getClosestSelectedImageElement(n.document.selection)),!i||this._styles.get(i).isDefault?e.removeAttribute("imageStyle",r):e.setAttribute("imageStyle",i,r)})}shouldConvertImageType(t,e){return!this._styles.get(t).modelElements.includes(e.name)}}const{objectFullWidth:u_,objectInline:g_,objectLeft:m_,objectRight:p_,objectCenter:f_,objectBlockLeft:k_,objectBlockRight:b_}=cm,w_={get inline(){return{name:"inline",title:"In line",icon:g_,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:m_,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:k_,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:f_,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:p_,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:b_,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:f_,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:p_,modelElements:["imageBlock"],className:"image-style-side"}}},__={full:u_,left:k_,right:b_,center:f_,inlineLeft:m_,inlineRight:p_,inline:g_},A_=[{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 C_(t){E("image-style-configuration-definition-invalid",t)}const v_={normalizeStyles:function(t){return(t.configuredStyles.options||[]).map(t=>function(t){return t="string"==typeof t?w_[t]?{...w_[t]}:{name:t}:function(t,e){const n={...e};for(const o in t)Object.prototype.hasOwnProperty.call(e,o)||(n[o]=t[o]);return n}(w_[t.name],t),"string"==typeof t.icon&&(t.icon=__[t.icon]||t.icon),t}(t)).filter(e=>function(t,{isBlockPluginLoaded:e,isInlinePluginLoaded:n}){const{modelElements:o,name:i}=t;if(!(o&&o.length&&i))return C_({style:t}),!1;{const i=[e?"imageBlock":null,n?"imageInline":null];if(!o.some(t=>i.includes(t)))return E("image-style-missing-dependency",{style:t,missingPlugins:o.map(t=>"imageBlock"===t?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}(e,t))},getDefaultStylesConfiguration:function(t,e){return t&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:t?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(t){return t.has("ImageBlockEditing")&&t.has("ImageInlineEditing")?[...A_]:[]},warnInvalidStyle:C_,DEFAULT_OPTIONS:w_,DEFAULT_ICONS:__,DEFAULT_DROPDOWN_DEFINITIONS:A_};function y_(t,e){for(const n of e)if(n.name===t)return n}class x_ extends Ss{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[zw]}init(){const{normalizeStyles:t,getDefaultStylesConfiguration:e}=v_,n=this.editor,o=n.plugins.has("ImageBlockEditing"),i=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",e(o,i)),this.normalizedStyles=t({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:i}),this._setupConversion(o,i),this._setupPostFixer(),n.commands.add("imageStyle",new h_(n,this.normalizedStyles))}_setupConversion(t,e){const n=this.editor,o=n.model.schema,i=(r=this.normalizedStyles,(t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const o=y_(e.attributeNewValue,r),i=y_(e.attributeOldValue,r),s=n.mapper.toViewElement(e.item),a=n.writer;i&&a.removeClass(i.className,s),o&&a.addClass(o.className,s)});var r;const s=function(t){const e={imageInline:t.filter(t=>!t.isDefault&&t.modelElements.includes("imageInline")),imageBlock:t.filter(t=>!t.isDefault&&t.modelElements.includes("imageBlock"))};return(t,n,o)=>{if(!n.modelRange)return;const i=n.viewItem,r=kr(n.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const s of e[r.name])o.consumable.consume(i,{classes:s.className})&&o.writer.setAttribute("imageStyle",s.name,r)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",i),n.data.downcastDispatcher.on("attribute:imageStyle",i),t&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),e&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",s,{priority:"low"}))}_setupPostFixer(){const t=this.editor,e=t.model.document,n=t.plugins.get(zw),o=new Map(this.normalizedStyles.map(t=>[t.name,t]));e.registerPostFixer(t=>{let i=!1;for(const r of e.differ.getChanges())if("insert"==r.type||"attribute"==r.type&&"imageStyle"==r.attributeKey){let e="insert"==r.type?r.position.nodeAfter:r.range.start.nodeAfter;if(e&&e.is("element","paragraph")&&e.childCount>0&&(e=e.getChild(0)),!n.isImage(e))continue;const s=e.getAttribute("imageStyle");if(!s)continue;const a=o.get(s);a&&a.modelElements.includes(e.name)||(t.removeAttribute("imageStyle",e),i=!0)}return i})}}var E_=r(4622),D_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(E_.Z,D_),E_.Z.locals;class T_ extends Ss{static get requires(){return[x_]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const t=this.editor.t;return{"Wrap text":t("Wrap text"),"Break text":t("Break text"),"In line":t("In line"),"Full size image":t("Full size image"),"Side image":t("Side image"),"Left aligned image":t("Left aligned image"),"Centered image":t("Centered image"),"Right aligned image":t("Right aligned image")}}init(){const t=this.editor.plugins,e=this.editor.config.get("image.toolbar")||[],n=I_(t.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const i of n)this._createButton(i);const o=I_([...e.filter(G),...v_.getDefaultDropdownDefinitions(t)],this.localizedDefaultStylesTitles);for(const i of o)this._createDropdown(i,n)}_createDropdown(t,e){const n=this.editor.ui.componentFactory;n.add(t.name,o=>{let i;const{defaultItem:r,items:s,title:a}=t,c=s.filter(t=>e.find(({name:e})=>S_(e)===t)).map(t=>{const e=n.create(t);return t===r&&(i=e),e});s.length!==c.length&&v_.warnInvalidStyle({dropdown:t});const l=Em(o,vs),d=l.buttonView,h=d.arrowView;return Dm(l,c,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:M_(a,i.label),class:null,tooltip:!0}),h.unbind("label"),h.set({label:a}),d.bind("icon").toMany(c,"isOn",(...t)=>{const e=t.findIndex(Oa);return e<0?i.icon:c[e].icon}),d.bind("label").toMany(c,"isOn",(...t)=>{const e=t.findIndex(Oa);return M_(a,e<0?i.label:c[e].label)}),d.bind("isOn").toMany(c,"isOn",(...t)=>t.some(Oa)),d.bind("class").toMany(c,"isOn",(...t)=>t.some(Oa)?"ck-splitbutton_flatten":null),d.on("execute",()=>{c.some(({isOn:t})=>t)?l.isOpen=!l.isOpen:i.fire("execute")}),l.bind("isEnabled").toMany(c,"isEnabled",(...t)=>t.some(Oa)),this.listenTo(l,"execute",()=>{this.editor.editing.view.focus()}),l})}_createButton(t){const e=t.name;this.editor.ui.componentFactory.add(S_(e),n=>{const o=this.editor.commands.get("imageStyle"),i=new rs(n);return i.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",t=>t===e),i.on("execute",this._executeCommand.bind(this,e)),i})}_executeCommand(t){this.editor.execute("imageStyle",{value:t}),this.editor.editing.view.focus()}}function I_(t,e){for(const n of t)e[n.title]&&(n.title=e[n.title]);return t}function S_(t){return"imageStyle:"+t}function M_(t,e){return(t?t+": ":"")+e}function N_(t){const e=t.map(t=>t.replace("+","\\+"));return new RegExp(`^image\\/(${e.join("|")})$`)}function B_(t){return new Promise((e,n)=>{const o=t.getAttribute("src");fetch(o).then(t=>t.blob()).then(t=>{const n=P_(t,o),i=n.replace("image/",""),r=new File([t],"image."+i,{type:n});e(r)}).catch(t=>t&&"TypeError"===t.name?function(t){return function(t){return new Promise((e,n)=>{const o=Di.document.createElement("img");o.addEventListener("load",()=>{const t=Di.document.createElement("canvas");t.width=o.width,t.height=o.height,t.getContext("2d").drawImage(o,0,0),t.toBlob(t=>t?e(t):n())}),o.addEventListener("error",()=>n()),o.src=t})}(t).then(e=>{const n=P_(e,t),o=n.replace("image/","");return new File([e],"image."+o,{type:n})})}(o).then(e).catch(n):n(t))})}function P_(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class z_ extends Ss{static get pluginName(){return"ImageUploadUI"}init(){const t=this.editor,e=t.t,n=n=>{const o=new nk(n),i=t.commands.get("uploadImage"),r=t.config.get("image.upload.types"),s=N_(r);return o.set({acceptedType:r.map(t=>"image/"+t).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:e("Insert image"),icon:cm.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(i),o.on("done",(e,n)=>{const o=Array.from(n).filter(t=>s.test(t.type));o.length&&(t.execute("uploadImage",{file:o}),t.editing.view.focus())}),o};t.ui.componentFactory.add("uploadImage",n),t.ui.componentFactory.add("imageUpload",n)}}var L_=r(5870),O_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(L_.Z,O_),L_.Z.locals;var R_=r(9899),j_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(R_.Z,j_),R_.Z.locals;var F_=r(9825),V_={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(F_.Z,V_),F_.Z.locals;class H_ extends Ss{static get pluginName(){return"ImageUploadProgress"}constructor(t){super(t),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const t=this.editor;t.plugins.has("ImageBlockEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",(...t)=>this.uploadStatusChange(...t)),t.plugins.has("ImageInlineEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",(...t)=>this.uploadStatusChange(...t))}uploadStatusChange(t,e,n){const o=this.editor,i=e.item,r=i.getAttribute("uploadId");if(!n.consumable.consume(e.item,t.name))return;const s=o.plugins.get("ImageUtils"),a=o.plugins.get(tk),c=r?e.attributeNewValue:null,l=this.placeholder,d=o.editing.mapper.toViewElement(i),h=n.writer;if("reading"==c)return U_(d,h),void G_(s,l,d,h);if("uploading"==c){const t=a.loaders.get(r);return U_(d,h),void(t?(q_(d,h),function(t,e,n,o){const i=function(t){const e=t.createUIElement("div",{class:"ck-progress-bar"});return t.setCustomProperty("progressBar",!0,e),e}(e);e.insert(e.createPositionAt(t,"end"),i),n.on("change:uploadedPercent",(t,e,n)=>{o.change(t=>{t.setStyle("width",n+"%",i)})})}(d,h,t,o.editing.view),function(t,e,n,o){if(o.data){const i=t.findViewImgElement(e);n.setAttribute("src",o.data,i)}}(s,d,h,t)):G_(s,l,d,h))}"complete"==c&&a.loaders.get(r)&&function(t,e,n){const o=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),o),setTimeout(()=>{n.change(t=>t.remove(t.createRangeOn(o)))},3e3)}(d,h,o.editing.view),function(t,e){Y_(t,e,"progressBar")}(d,h),q_(d,h),function(t,e){e.removeClass("ck-appear",t)}(d,h)}}function U_(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function G_(t,e,n,o){n.hasClass("ck-image-upload-placeholder")||o.addClass("ck-image-upload-placeholder",n);const i=t.findViewImgElement(n);i.getAttribute("src")!==e&&o.setAttribute("src",e,i),W_(n,"placeholder")||o.insert(o.createPositionAfter(i),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(o))}function q_(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),Y_(t,e,"placeholder")}function W_(t,e){for(const n of t.getChildren())if(n.getCustomProperty(e))return n}function Y_(t,e,n){const o=W_(t,n);o&&e.remove(e.createRangeOn(o))}class K_ extends Ns{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.model.document.selection.getSelectedElement();this.isEnabled=e.isImageAllowed()||e.isImage(n)}execute(t){const e=hr(t.file),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach((t,e)=>{const r=n.getSelectedElement();if(e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);this._uploadImage(t,i,e)}else this._uploadImage(t,i)})}_uploadImage(t,e,n){const o=this.editor,i=o.plugins.get(tk).createLoader(t),r=o.plugins.get("ImageUtils");i&&r.insertImage({...e,uploadId:i.id},n)}}class $_ extends Ss{static get requires(){return[tk,hp,Ck,zw]}static get pluginName(){return"ImageUploadEditing"}constructor(t){super(t),t.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const t=this.editor,e=t.model.document,n=t.conversion,o=t.plugins.get(tk),i=t.plugins.get("ImageUtils"),r=N_(t.config.get("image.upload.types")),s=new K_(t);t.commands.add("uploadImage",s),t.commands.add("imageUpload",s),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",(e,n)=>{if(o=n.dataTransfer,Array.from(o.types).includes("text/html")&&""!==o.getData("text/html"))return;var o;const i=Array.from(n.dataTransfer.files).filter(t=>!!t&&r.test(t.type));i.length&&(e.stop(),t.model.change(e=>{n.targetRanges&&e.setSelection(n.targetRanges.map(e=>t.editing.mapper.toModelRange(e))),t.model.enqueueChange(()=>{t.execute("uploadImage",{file:i})})}))}),this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",(e,n)=>{const r=Array.from(t.editing.view.createRangeIn(n.content)).filter(t=>function(t,e){return!(!t.isInlineImageView(e)||!e.getAttribute("src"))&&(e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||e.getAttribute("src").match(/^blob:/g))}(i,t.item)&&!t.item.getAttribute("uploadProcessed")).map(t=>({promise:B_(t.item),imageElement:t.item}));if(!r.length)return;const s=new Lg(t.editing.view.document);for(const t of r){s.setAttribute("uploadProcessed",!0,t.imageElement);const e=o.createLoader(t.promise);e&&(s.setAttribute("src","",t.imageElement),s.setAttribute("uploadId",e.id,t.imageElement))}}),t.editing.view.document.on("dragover",(t,e)=>{e.preventDefault()}),e.on("change",()=>{const n=e.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),i=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name){const n=e.position.nodeAfter,r="$graveyard"==e.position.root.rootName;for(const e of Q_(t,n)){const t=e.getAttribute("uploadId");if(!t)continue;const n=o.loaders.get(t);n&&(r?i.has(t)||n.abort():(i.add(t),this._uploadImageElements.set(t,e),"idle"==n.status&&this._readAndUpload(n)))}}}),this.on("uploadComplete",(t,{imageElement:e,data:n})=>{const o=n.urls?n.urls:n;this.editor.model.change(t=>{t.setAttribute("src",o.default,e),this._parseAndSetSrcsetAttributeOnImage(o,e,t)})},{priority:"low"})}afterInit(){const t=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&t.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(t){const e=this.editor,n=e.model,o=e.locale.t,i=e.plugins.get(tk),r=e.plugins.get(hp),s=e.plugins.get("ImageUtils"),a=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},e=>{e.setAttribute("uploadStatus","reading",a.get(t.id))}),t.read().then(()=>{const o=t.upload(),i=a.get(t.id);if(h.isSafari){const t=e.editing.mapper.toViewElement(i),n=s.findViewImgElement(t);e.editing.view.once("render",()=>{if(!n.parent)return;const t=e.editing.view.domConverter.mapViewToDom(n.parent);if(!t)return;const o=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=o})}return n.enqueueChange({isUndoable:!1},t=>{t.setAttribute("uploadStatus","uploading",i)}),o}).then(e=>{n.enqueueChange({isUndoable:!1},n=>{const o=a.get(t.id);n.setAttribute("uploadStatus","complete",o),this.fire("uploadComplete",{data:e,imageElement:o})}),c()}).catch(e=>{if("error"!==t.status&&"aborted"!==t.status)throw e;"error"==t.status&&e&&r.showWarning(e,{title:o("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},e=>{e.remove(a.get(t.id))}),c()});function c(){n.enqueueChange({isUndoable:!1},e=>{const n=a.get(t.id);e.removeAttribute("uploadId",n),e.removeAttribute("uploadStatus",n),a.delete(t.id)}),i.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,n){let o=0;const i=Object.keys(t).filter(t=>{const e=parseInt(t,10);if(!isNaN(e))return o=Math.max(o,e),!0}).map(e=>`${t[e]} ${e}w`).join(", ");""!=i&&n.setAttribute("srcset",{data:i,width:o},e)}}function Q_(t,e){const n=t.plugins.get("ImageUtils");return Array.from(t.model.createRangeOn(e)).filter(t=>n.isImage(t.item)).map(t=>t.item)}class Z_ extends Ss{static get pluginName(){return"IndentEditing"}init(){const t=this.editor;t.commands.add("indent",new Ps(t)),t.commands.add("outdent",new Ps(t))}}const J_='',X_='';class tA extends Ss{static get pluginName(){return"IndentUI"}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?J_:X_,i="ltr"==e.uiLanguageDirection?X_:J_;this._defineButton("indent",n("Increase indent"),o),this._defineButton("outdent",n("Decrease indent"),i)}_defineButton(t,e,n){const o=this.editor;o.ui.componentFactory.add(t,i=>{const r=o.commands.get(t),s=new rs(i);return s.set({label:e,icon:n,tooltip:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(s,"execute",()=>{o.execute(t),o.editing.view.focus()}),s})}}const eA="italic";class nA extends Ss{static get pluginName(){return"ItalicEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:eA}),t.model.schema.setAttributeProperties(eA,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:eA,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(eA,new Of(t,eA)),t.keystrokes.set("CTRL+I",eA)}}const oA="italic";class iA extends Ss{static get pluginName(){return"ItalicUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(oA,n=>{const o=t.commands.get(oA),i=new rs(n);return i.set({label:e("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",()=>{t.execute(oA),t.editing.view.focus()}),i})}}class rA{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(t){Array.isArray(t)?t.forEach(t=>this._definitions.add(t)):this._definitions.add(t)}getDispatcher(){return t=>{t.on("attribute:linkHref",(t,e,n)=>{if(!n.consumable.test(e.item,"attribute:linkHref"))return;if(!e.item.is("selection")&&!n.schema.isInline(e.item))return;const o=n.writer,i=o.document.selection;for(const r of this._definitions){const t=o.createAttributeElement("a",r.attributes,{priority:5});r.classes&&o.addClass(r.classes,t);for(const e in r.styles)o.setStyle(e,r.styles[e],t);o.setCustomProperty("link",!0,t),r.callback(e.attributeNewValue)?e.item.is("selection")?o.wrap(i.getFirstRange(),t):o.wrap(n.mapper.toViewRange(e.range),t):o.unwrap(n.mapper.toViewRange(e.range),t)}},{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",(t,e,{writer:n,mapper:o})=>{const i=o.toViewElement(e.item),r=Array.from(i.getChildren()).find(t=>"a"===t.name);for(const s of this._definitions){const t=_r(s.attributes);if(s.callback(e.attributeNewValue)){for(const[e,o]of t)"class"===e?n.addClass(o,r):n.setAttribute(e,o,r);s.classes&&n.addClass(s.classes,r);for(const t in s.styles)n.setStyle(t,s.styles[t],r)}else{for(const[e,o]of t)"class"===e?n.removeClass(o,r):n.removeAttribute(e,r);s.classes&&n.removeClass(s.classes,r);for(const t in s.styles)n.removeStyle(t,r)}}})}}}const sA=function(t,e,n){var o=t.length;return n=void 0===n?o:n,!e&&n>=o?t:xa(t,e,n)};var aA=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const cA=function(t){return aA.test(t)},lA=function(t){return t.split("")};var dA="\\ud800-\\udfff",hA="["+dA+"]",uA="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",gA="\\ud83c[\\udffb-\\udfff]",mA="[^"+dA+"]",pA="(?:\\ud83c[\\udde6-\\uddff]){2}",fA="[\\ud800-\\udbff][\\udc00-\\udfff]",kA="(?:"+uA+"|"+gA+")?",bA="[\\ufe0e\\ufe0f]?",wA=bA+kA+"(?:\\u200d(?:"+[mA,pA,fA].join("|")+")"+bA+kA+")*",_A="(?:"+[mA+uA+"?",uA,pA,fA,hA].join("|")+")",AA=RegExp(gA+"(?="+gA+")|"+_A+wA,"g");const CA=function(t){return t.match(AA)||[]},vA=function(t){return cA(t)?CA(t):lA(t)},yA=function(t){return function(e){e=wa(e);var n=cA(e)?vA(e):void 0,o=n?n[0]:e.charAt(0),i=n?sA(n,1).join(""):e.slice(1);return o[t]()+i}}("toUpperCase"),xA=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,EA=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,DA=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,TA=/^((\w+:(\/{2,})?)|(\W))/i,IA="Ctrl+K";function SA(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,n),n}function MA(t){return function(t){const e=t.replace(xA,"");return e.match(EA)}(t=String(t))?t:"#"}function NA(t,e){return!!t&&e.checkAttribute(t.name,"linkHref")}function BA(t,e){const n=(o=t,DA.test(o)?"mailto:":e);var o;const i=!!n&&!PA(t);return t&&i?n+t:t}function PA(t){return TA.test(t)}function zA(t){window.open(t,"_blank","noopener")}class LA extends Ns{constructor(t){super(t),this.manualDecorators=new fr,this.automaticDecorators=new rA}restoreManualDecoratorStates(){for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement()||kr(e.getSelectedBlocks());NA(n,t.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttribute(n,"linkHref")):(this.value=e.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref"));for(const o of this.manualDecorators)o.value=this._getDecoratorStateFromModel(o.id)}execute(t,e={}){const n=this.editor.model,o=n.document.selection,i=[],r=[];for(const s in e)e[s]?i.push(s):r.push(s);n.change(e=>{if(o.isCollapsed){const s=o.getFirstPosition();if(o.hasAttribute("linkHref")){const a=gf(s,"linkHref",o.getAttribute("linkHref"),n);e.setAttribute("linkHref",t,a),i.forEach(t=>{e.setAttribute(t,!0,a)}),r.forEach(t=>{e.removeAttribute(t,a)}),e.setSelection(e.createPositionAfter(a.end.nodeBefore))}else if(""!==t){const r=_r(o.getAttributes());r.set("linkHref",t),i.forEach(t=>{r.set(t,!0)});const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...i,...r].forEach(t=>{e.removeSelectionAttribute(t)})}else{const s=n.schema.getValidRanges(o.getRanges(),"linkHref"),a=[];for(const t of o.getSelectedBlocks())n.schema.checkAttribute(t,"linkHref")&&a.push(e.createRangeOn(t));const c=a.slice();for(const t of s)this._isRangeToUpdate(t,a)&&c.push(t);for(const n of c)e.setAttribute("linkHref",t,n),i.forEach(t=>{e.setAttribute(t,!0,n)}),r.forEach(t=>{e.removeAttribute(t,n)})}})}_getDecoratorStateFromModel(t){const e=this.editor.model,n=e.document.selection,o=n.getSelectedElement();return NA(o,e.schema)?o.getAttribute(t):n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e)if(n.containsRange(t))return!1;return!0}}class OA extends Ns{refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement();NA(n,t.schema)?this.isEnabled=t.schema.checkAttribute(n,"linkHref"):this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}execute(){const t=this.editor,e=this.editor.model,n=e.document.selection,o=t.commands.get("link");e.change(t=>{const i=n.isCollapsed?[gf(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of i)if(t.removeAttribute("linkHref",e),o)for(const n of o.manualDecorators)t.removeAttribute(n.id,e)})}}class RA{constructor({id:t,label:e,attributes:n,classes:o,styles:i,defaultValue:r}){this.id=t,this.set("value"),this.defaultValue=r,this.label=e,this.attributes=n,this.classes=o,this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}k(RA,Z);var jA=r(399),FA={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(jA.Z,FA),jA.Z.locals;const VA="automatic",HA=/^(https?:)?\/\//;class UA extends Ss{static get pluginName(){return"LinkEditing"}static get requires(){return[Zp,Rp,Ck]}constructor(t){super(t),t.config.define("link",{addTargetToExternalLinks:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:SA}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,e)=>SA(MA(t),e)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new LA(t)),t.commands.add("unlink",new OA(t));const e=function(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach(t=>(t.label&&n[t.label]&&(t.label=n[t.label]),t)),e}(t.t,function(t){const e=[];if(t)for(const[n,o]of Object.entries(t)){const t=Object.assign({},o,{id:"link"+yA(n)});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(e.filter(t=>t.mode===VA)),this._enableManualDecorators(e.filter(t=>"manual"===t.mode)),t.plugins.get(Zp).registerAttribute("linkHref"),function(t,e,n,o){const i=t.editing.view,r=new Set;i.document.registerPostFixer(i=>{const s=t.model.document.selection;let a=!1;if(s.hasAttribute(e)){const c=gf(s.getFirstPosition(),e,s.getAttribute(e),t.model),l=t.editing.mapper.toViewRange(c);for(const t of l.getItems())t.is("element",n)&&!t.hasClass(o)&&(i.addClass(o,t),r.add(t),a=!0)}return a}),t.conversion.for("editingDowncast").add(t=>{function e(){i.change(t=>{for(const e of r.values())t.removeClass(o,e),r.delete(e)})}t.on("insert",e,{priority:"highest"}),t.on("remove",e,{priority:"highest"}),t.on("attribute",e,{priority:"highest"}),t.on("selection",e,{priority:"highest"})})}(t,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink(),this._enableClipboardIntegration()}_enableAutomaticDecorators(t){const e=this.editor,n=e.commands.get("link").automaticDecorators;e.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:VA,callback:t=>HA.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(t),n.length&&e.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(t){if(!t.length)return;const e=this.editor,n=e.commands.get("link").manualDecorators;t.forEach(t=>{e.model.schema.extend("$text",{allowAttributes:t.id}),t=new RA(t),n.add(t),e.conversion.for("downcast").attributeToElement({model:t.id,view:(e,{writer:n,schema:o},{item:i})=>{if((i.is("selection")||o.isInline(i))&&e){const e=n.createAttributeElement("a",t.attributes,{priority:5});t.classes&&n.addClass(t.classes,e);for(const o in t.styles)n.setStyle(o,t.styles[o],e);return n.setCustomProperty("link",!0,e),e}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",...t._createPattern()},model:{key:t.id}})})}_enableLinkOpen(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"click",(t,e)=>{if(!(h.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey))return;let n=e.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const o=n.getAttribute("href");o&&(t.stop(),e.preventDefault(),zA(o))},{context:"$capture"}),this.listenTo(e,"keydown",(e,n)=>{const o=t.commands.get("link").value;o&&n.keyCode===rr.enter&&n.altKey&&(e.stop(),zA(o))})}_enableInsertContentSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection;this.listenTo(t,"insertContent",()=>{const n=e.anchor.nodeBefore,o=e.anchor.nodeAfter;e.hasAttribute("linkHref")&&n&&n.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change(e=>{GA(e,WA(t.schema))}))},{priority:"low"})}_enableClickingAfterLink(){const t=this.editor,e=t.model;t.editing.view.addObserver(zg);let n=!1;this.listenTo(t.editing.view.document,"mousedown",()=>{n=!0}),this.listenTo(t.editing.view.document,"selectionChange",()=>{if(!n)return;n=!1;const t=e.document.selection;if(!t.isCollapsed)return;if(!t.hasAttribute("linkHref"))return;const o=t.getFirstPosition(),i=gf(o,"linkHref",t.getAttribute("linkHref"),e);(o.isTouching(i.start)||o.isTouching(i.end))&&e.change(t=>{GA(t,WA(e.schema))})})}_enableTypingOverLink(){const t=this.editor,e=t.editing.view;let n,o;this.listenTo(e.document,"delete",()=>{o=!0},{priority:"high"}),this.listenTo(t.model,"deleteContent",()=>{const e=t.model.document.selection;e.isCollapsed||(o?o=!1:qA(t)&&function(t){const e=t.document.selection,n=e.getFirstPosition(),o=e.getLastPosition(),i=n.nodeAfter;if(!i)return!1;if(!i.is("$text"))return!1;if(!i.hasAttribute("linkHref"))return!1;const r=o.textNode||o.nodeBefore;return i===r||gf(n,"linkHref",i.getAttribute("linkHref"),t).containsRange(t.createRange(n,o),!0)}(t.model)&&(n=e.getAttributes()))},{priority:"high"}),this.listenTo(t.model,"insertContent",(e,[i])=>{o=!1,qA(t)&&n&&(t.model.change(t=>{for(const[e,o]of n)t.setAttribute(e,o,i)}),n=null)},{priority:"high"})}_handleDeleteContentAfterLink(){const t=this.editor,e=t.model,n=e.document.selection,o=t.editing.view;let i=!1,r=!1;this.listenTo(o.document,"delete",(t,e)=>{r="backward"===e.direction},{priority:"high"}),this.listenTo(e,"deleteContent",()=>{i=!1;const t=n.getFirstPosition(),o=n.getAttribute("linkHref");if(!o)return;const r=gf(t,"linkHref",o,e);i=r.containsPosition(t)||r.end.isEqual(t)},{priority:"high"}),this.listenTo(e,"deleteContent",()=>{r&&(r=!1,i||t.model.enqueueChange(t=>{GA(t,WA(e.schema))}))},{priority:"low"})}_enableClipboardIntegration(){const t=this.editor,e=t.model,n=this.editor.config.get("link.defaultProtocol");n&&this.listenTo(t.plugins.get("ClipboardPipeline"),"contentInsertion",(t,o)=>{e.change(t=>{const e=t.createRangeIn(o.content);for(const o of e.getItems())if(o.hasAttribute("linkHref")){const e=BA(o.getAttribute("linkHref"),n);t.setAttribute("linkHref",e,o)}})})}}function GA(t,e){t.removeSelectionAttribute("linkHref");for(const n of e)t.removeSelectionAttribute(n)}function qA(t){return t.model.change(t=>t.batch).isTyping}function WA(t){return t.getDefinition("$text").allowAttributes.filter(t=>t.startsWith("link"))}var YA=r(4827),KA={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(YA.Z,KA),YA.Z.locals;class $A extends Mr{constructor(t,e){super(t);const n=t.t;this.focusTracker=new br,this.keystrokes=new wr,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),cm.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),cm.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusables=new Er,this._focusCycler=new xs({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];e.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children}),i(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((t,e)=>(t[e.name]=e.isOn,t),{})}render(){super.render(),a({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const t=this.locale.t,e=new lp(this.locale,dp);return e.label=t("Link URL"),e}_createButton(t,e,n,o){const i=new rs(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const o=new cs(this.locale);o.set({name:n.id,label:n.label,withText:!0}),o.bind("isOn").toMany([n,t],"value",(t,e)=>void 0===e&&void 0===t?n.defaultValue:t),o.on("execute",()=>{n.set("value",!o.isOn)}),e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new Mr;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map(t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}})),attributes:{class:["ck","ck-reset","ck-list"]}}),e.add(t)}return e.add(this.saveButtonView),e.add(this.cancelButtonView),e}}var QA=r(9465),ZA={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(QA.Z,ZA),QA.Z.locals;class JA extends Mr{constructor(t){super(t);const e=t.t;this.focusTracker=new br,this.keystrokes=new wr,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(e("Unlink"),'',"unlink"),this.editButtonView=this._createButton(e("Edit link"),cm.pencil,"edit"),this.set("href"),this._focusables=new Er,this._focusCycler=new xs({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(t,e,n){const o=new rs(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.delegate("execute").to(this,n),o}_createPreviewButton(){const t=new rs(this.locale),e=this.bindTemplate,n=this.t;return t.set({withText:!0,tooltip:n("Open link in new tab")}),t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",t=>t&&MA(t)),target:"_blank",rel:"noopener noreferrer"}}),t.bind("label").to(this,"href",t=>t||n("This link has no URL")),t.bind("isEnabled").to(this,"href",t=>!!t),t.template.tag="a",t.template.eventListeners={},t}}const XA="link-ui";class tC extends Ss{static get requires(){return[bp]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(Pg),this.actionsView=null,this.formView=null,this._balloon=t.plugins.get(bp),this._createToolbarLinkButton(),this._enableBalloonActivators(),t.conversion.for("editingDowncast").markerToHighlight({model:XA,view:{classes:["ck-fake-link-selection"]}}),t.conversion.for("editingDowncast").markerToElement({model:XA,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const t=this.editor,e=new JA(t.locale),n=t.commands.get("link"),o=t.commands.get("unlink");return e.bind("href").to(n,"value"),e.editButtonView.bind("isEnabled").to(n),e.unlinkButtonView.bind("isEnabled").to(o),this.listenTo(e,"edit",()=>{this._addFormView()}),this.listenTo(e,"unlink",()=>{t.execute("unlink"),this._hideUI()}),e.keystrokes.set("Esc",(t,e)=>{this._hideUI(),e()}),e.keystrokes.set(IA,(t,e)=>{this._addFormView(),e()}),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),n=t.config.get("link.defaultProtocol"),o=new $A(t.locale,e);return o.urlInputView.fieldView.bind("value").to(e,"value"),o.urlInputView.bind("isReadOnly").to(e,"isEnabled",t=>!t),o.saveButtonView.bind("isEnabled").to(e),this.listenTo(o,"submit",()=>{const{value:e}=o.urlInputView.fieldView.element,i=BA(e,n);t.execute("link",i,o.getDecoratorSwitchesState()),this._closeFormView()}),this.listenTo(o,"cancel",()=>{this._closeFormView()}),o.keystrokes.set("Esc",(t,e)=>{this._closeFormView(),e()}),o}_createToolbarLinkButton(){const t=this.editor,e=t.commands.get("link"),n=t.t;t.ui.componentFactory.add("link",t=>{const o=new rs(t);return o.isEnabled=!0,o.label=n("Link"),o.icon='',o.keystroke=IA,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(e,"isEnabled"),o.bind("isOn").to(e,"value",t=>!!t),this.listenTo(o,"execute",()=>this._showUI(!0)),o})}_enableBalloonActivators(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),t.keystrokes.set(IA,(e,n)=>{n(),t.commands.get("link").isEnabled&&this._showUI(!0)})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(t,e)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),e())},{priority:"high"}),this.editor.keystrokes.set("Esc",(t,e)=>{this._isUIVisible&&(this._hideUI(),e())}),n({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const t=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=t.value||""}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates(),void 0!==t.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(t=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),t&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),t&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),t.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const t=this.editor,e=t.editing.view.document;let n=this._getSelectedLinkElement(),o=r();const i=()=>{const t=this._getSelectedLinkElement(),e=r();n&&!t||!n&&e!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=t,o=e};function r(){return e.selection.focus.getAncestors().reverse().find(t=>t.is("element"))}this.listenTo(t.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const t=this.editor.editing.view,e=this.editor.model,n=t.document;let o=null;if(e.markers.has(XA)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(XA)),n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));o=t.domConverter.viewRangeToDom(n)}else o=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:o}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection,n=e.getSelectedElement();if(e.isCollapsed||n&&Sk(n))return eC(e.getFirstPosition());{const n=e.getFirstRange().getTrimmed(),o=eC(n.start),i=eC(n.end);return o&&o==i&&t.createRangeIn(o).getTrimmed().isEqual(n)?o:null}}_showFakeVisualSelection(){const t=this.editor.model;t.change(e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(XA))e.updateMarker(XA,{range:n});else if(n.start.isAtEnd){const o=n.start.getLastMatchingPosition(({item:e})=>!t.schema.isContent(e),{boundaries:n});e.addMarker(XA,{usingOperation:!1,affectsData:!1,range:e.createRange(o,n.end)})}else e.addMarker(XA,{usingOperation:!1,affectsData:!1,range:n})})}_hideFakeVisualSelection(){const t=this.editor.model;t.markers.has(XA)&&t.change(t=>{t.removeMarker(XA)})}}function eC(t){return t.getAncestors().find(t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e})}const nC=4,oC=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i"),iC=2;class rC extends Ss{static get requires(){return[Yp]}static get pluginName(){return"AutoLink"}init(){const t=this.editor.model.document.selection;t.on("change:range",()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const t=this.editor,e=new Qp(t.model,t=>{if(!function(t){return t.length>nC&&" "===t[t.length-1]&&" "!==t[t.length-2]}(t))return;const e=sC(t.substr(0,t.length-1));return e?{url:e}:void 0});e.on("matched:data",(e,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),c=t.model.createRange(a,s);this._applyAutoLink(r,c)}),e.bind("isEnabled").to(this)}_enableEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("enter");n&&n.on("execute",()=>{const t=e.document.selection.getFirstPosition();if(!t.parent.previousSibling)return;const n=e.createRangeIn(t.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)})}_enableShiftEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("shiftEnter");n&&n.on("execute",()=>{const t=e.document.selection.getFirstPosition(),n=e.createRange(e.createPositionAt(t.parent,0),t.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)})}_checkAndApplyAutoLinkOnRange(t){const e=this.editor.model,{text:n,range:o}=$p(t,e),i=sC(n);if(i){const t=e.createRange(o.end.getShiftedBy(-i.length),o.end);this._applyAutoLink(i,t)}}_applyAutoLink(t,e){const n=this.editor.model,o=BA(t,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}(e,n)&&PA(o)&&!function(t){const e=t.start.nodeAfter;return e&&e.hasAttribute("linkHref")}(e)&&this._persistAutoLink(o,e)}_persistAutoLink(t,e){const n=this.editor.model,o=this.editor.plugins.get("Delete");n.enqueueChange(i=>{i.setAttribute("linkHref",t,e),n.enqueueChange(()=>{o.requestUndoOnBackspace()})})}}function sC(t){const e=oC.exec(t);return e?e[iC]:null}class aC extends Ns{constructor(t,e){super(t),this.type=e}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document,o=Array.from(n.selection.getSelectedBlocks()).filter(t=>lC(t,e.schema)),i=void 0!==t.forceValue?!t.forceValue:this.value;e.change(t=>{if(i){let e=o[o.length-1].nextSibling,n=Number.POSITIVE_INFINITY,i=[];for(;e&&"listItem"==e.name&&0!==e.getAttribute("listIndent");){const t=e.getAttribute("listIndent");t=n;)r>i.getAttribute("listIndent")&&(r=i.getAttribute("listIndent")),i.getAttribute("listIndent")==r&&t[e?"unshift":"push"](i),i=i[e?"previousSibling":"nextSibling"]}}function lC(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}class dC extends Ns{constructor(t,e){super(t),this._indentBy="forward"==e?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=t.document;let n=Array.from(e.selection.getSelectedBlocks());t.change(t=>{const e=n[n.length-1];let o=e.nextSibling;for(;o&&"listItem"==o.name&&o.getAttribute("listIndent")>e.getAttribute("listIndent");)n.push(o),o=o.nextSibling;this._indentBy<0&&(n=n.reverse());for(const i of n){const e=i.getAttribute("listIndent")+this._indentBy;e<0?t.rename(i,"paragraph"):t.setAttribute("listIndent",e,i)}this.fire("_executeCleanup",n)})}_checkEnabled(){const t=kr(this.editor.model.document.selection.getSelectedBlocks());if(!t||!t.is("element","listItem"))return!1;if(this._indentBy>0){const e=t.getAttribute("listIndent"),n=t.getAttribute("listType");let o=t.previousSibling;for(;o&&o.is("element","listItem")&&o.getAttribute("listIndent")>=e;){if(o.getAttribute("listIndent")==e)return o.getAttribute("listType")==n;o=o.previousSibling}return!1}return!0}}function hC(t,e){const n=e.mapper,o=e.writer,i="numbered"==t.getAttribute("listType")?"ol":"ul",r=function(t){const e=t.createContainerElement("li");return e.getFillerOffset=_C,e}(o),s=o.createContainerElement(i,null);return o.insert(o.createPositionAt(s,0),r),n.bindElements(t,r),r}function uC(t,e,n,o){const i=e.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(o.createPositionBefore(t));const c=pC(t.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:t.getAttribute("listIndent")}),l=t.previousSibling;if(c&&c.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(t))}else if(l&&"listItem"==l.name){a=r.toViewPosition(o.createPositionAt(l,"end"));const t=r.findMappedViewAncestor(a),e=function(t){for(const e of t.getChildren())if("ul"==e.name||"ol"==e.name)return e;return null}(t);a=e?s.createPositionBefore(e):s.createPositionAt(t,"end")}else a=r.toViewPosition(o.createPositionBefore(t));if(a=mC(a),s.insert(a,i),l&&"listItem"==l.name){const t=r.toViewElement(l),n=s.createRange(s.createPositionAt(t,0),a).getWalker({ignoreElementEnd:!0});for(const o of n)if(o.item.is("element","li")){const t=s.breakContainer(s.createPositionBefore(o.item)),i=o.item.parent,r=s.createPositionAt(e,"end");gC(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(i),r),n.position=t}}else{const n=i.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let o=null;for(const e of n.getChildren()){const n=r.toModelElement(e);if(!(n&&n.getAttribute("listIndent")>t.getAttribute("listIndent")))break;o=e}o&&(s.breakContainer(s.createPositionAfter(o)),s.move(s.createRangeOn(o.parent),s.createPositionAt(e,"end")))}}gC(s,i,i.nextSibling),gC(s,i.previousSibling,i)}function gC(t,e,n){return!e||!n||"ul"!=e.name&&"ol"!=e.name||e.name!=n.name||e.getAttribute("class")!==n.getAttribute("class")?null:t.mergeContainers(t.createPositionAfter(e))}function mC(t){return t.getLastMatchingPosition(t=>t.item.is("uiElement"))}function pC(t,e){const n=!!e.sameIndent,o=!!e.smallerIndent,i=e.listIndent;let r=t;for(;r&&"listItem"==r.name;){const t=r.getAttribute("listIndent");if(n&&i==t||o&&i>t)return r;r="forward"===e.direction?r.nextSibling:r.previousSibling}return null}function fC(t,e,n,o){t.ui.componentFactory.add(e,i=>{const r=t.commands.get(e),s=new rs(i);return s.set({label:n,icon:o,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",()=>{t.execute(e),t.editing.view.focus()}),s})}function kC(t,e){const n=[],o=t.parent,i={ignoreElementEnd:!1,startPosition:t,shallow:!0,direction:e},r=o.getAttribute("listIndent"),s=[...new Hd(i)].filter(t=>t.item.is("element")).map(t=>t.item);for(const a of s){if(!a.is("element","listItem"))break;if(a.getAttribute("listIndent")r)){if(a.getAttribute("listType")!==o.getAttribute("listType"))break;if(a.getAttribute("listStyle")!==o.getAttribute("listStyle"))break;if(a.getAttribute("listReversed")!==o.getAttribute("listReversed"))break;if(a.getAttribute("listStart")!==o.getAttribute("listStart"))break;"backward"===e?n.unshift(a):n.push(a)}}return n}const bC=["disc","circle","square"],wC=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function _C(){const t=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||t?0:ac.call(this)}class AC extends Ss{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(t){return function(t){return bC.includes(t)?"bulleted":wC.includes(t)?"numbered":null}(t)}getSelectedListItems(t){return function(t){let e=[...t.document.selection.getSelectedBlocks()].filter(t=>t.is("element","listItem")).map(e=>{const n=t.change(t=>t.createPositionAt(e,0));return[...kC(n,"backward"),...kC(n,"forward")]}).flat();return e=[...new Set(e)],e}(t)}getSiblingNodes(t,e){return kC(t,e)}}function CC(t){return(e,n,o)=>{const i=o.consumable;if(!i.test(n.item,"insert")||!i.test(n.item,"attribute:listType")||!i.test(n.item,"attribute:listIndent"))return;i.consume(n.item,"insert"),i.consume(n.item,"attribute:listType"),i.consume(n.item,"attribute:listIndent");const r=n.item;uC(r,hC(r,o),o,t)}}const vC=(t,e,n)=>{if(!n.consumable.test(e.item,t.name))return;const o=n.mapper.toViewElement(e.item),i=n.writer;i.breakContainer(i.createPositionBefore(o)),i.breakContainer(i.createPositionAfter(o));const r=o.parent,s="numbered"==e.attributeNewValue?"ol":"ul";i.rename(s,r)},yC=(t,e,n)=>{n.consumable.consume(e.item,t.name);const o=n.mapper.toViewElement(e.item).parent,i=n.writer;gC(i,o,o.nextSibling),gC(i,o.previousSibling,o)},xC=(t,e,n)=>{if(n.consumable.test(e.item,t.name)&&"listItem"!=e.item.name){let t=n.mapper.toViewPosition(e.range.start);const o=n.writer,i=[];for(;("ul"==t.parent.name||"ol"==t.parent.name)&&(t=o.breakContainer(t),"li"==t.parent.name);){const e=t,n=o.createPositionAt(t.parent,"end");if(!e.isEqual(n)){const t=o.remove(o.createRange(e,n));i.push(t)}t=o.createPositionAfter(t.parent)}if(i.length>0){for(let e=0;e0){const e=gC(o,n,n.nextSibling);e&&e.parent==n&&t.offset--}}gC(o,t.nodeBefore,t.nodeAfter)}}},EC=(t,e,n)=>{const o=n.mapper.toViewPosition(e.position),i=o.nodeBefore,r=o.nodeAfter;gC(n.writer,i,r)},DC=(t,e,n)=>{if(n.consumable.consume(e.viewItem,{name:!0})){const t=n.writer,o=t.createElement("listItem"),i=function(t){let e=0,n=t.parent;for(;n;){if(n.is("element","li"))e++;else{const t=n.previousSibling;t&&t.is("element","li")&&e++}n=n.parent}return e}(e.viewItem);t.setAttribute("listIndent",i,o);const r=e.viewItem.parent&&"ol"==e.viewItem.parent.name?"numbered":"bulleted";if(t.setAttribute("listType",r,o),!n.safeInsert(o,e.modelCursor))return;const s=function(t,e,n){const{writer:o,schema:i}=n;let r=o.createPositionAfter(t);for(const s of e)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const e=n.convertItem(s,o.createPositionAt(t,"end")),a=e.modelRange.start.nodeAfter;a&&a.is("element")&&!i.checkChild(t,a.name)&&(t=e.modelCursor.parent.is("element","listItem")?e.modelCursor.parent:NC(e.modelCursor),r=o.createPositionAfter(t))}return r}(o,e.viewItem.getChildren(),n);e.modelRange=t.createRange(e.modelCursor,s),n.updateConversionResult(o,e)}},TC=(t,e,n)=>{if(n.consumable.test(e.viewItem,{name:!0})){const t=Array.from(e.viewItem.getChildren());for(const e of t)!e.is("element","li")&&!PC(e)&&e._remove()}},IC=(t,e,n)=>{if(n.consumable.test(e.viewItem,{name:!0})){if(0===e.viewItem.childCount)return;const t=[...e.viewItem.getChildren()];let n=!1;for(const e of t)n&&!PC(e)&&e._remove(),PC(e)&&(n=!0)}};function SC(t){return(e,n)=>{if(n.isPhantom)return;const o=n.modelPosition.nodeBefore;if(o&&o.is("element","listItem")){const e=n.mapper.toViewElement(o),i=e.getAncestors().find(PC),r=t.createPositionAt(e,0).getWalker();for(const t of r){if("elementStart"==t.type&&t.item.is("element","li")){n.viewPosition=t.previousPosition;break}if("elementEnd"==t.type&&t.item==i){n.viewPosition=t.nextPosition;break}}}}}const MC=function(t,[e,n,o]){const i=this;let r,s=e.is("documentFragment")?e.getChild(0):e;if(r=n?i.createSelection(n,o):i.document.selection,s&&s.is("element","listItem")){const t=r.getFirstPosition();let e=null;if(t.parent.is("element","listItem")?e=t.parent:t.nodeBefore&&t.nodeBefore.is("element","listItem")&&(e=t.nodeBefore),e){const t=e.getAttribute("listIndent");if(t>0)for(;s&&s.is("element","listItem");)s._setAttribute("listIndent",s.getAttribute("listIndent")+t),s=s.nextSibling}}};function NC(t){const e=new Hd({startPosition:t});let n;do{n=e.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function BC(t,e,n,o,i,r){const s=pC(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:t}),a=i.mapper,c=i.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==t){const t=a.toViewElement(s).parent;d=c.createPositionAfter(t)}else{const t=r.createPositionAt(s,"end");d=a.toViewPosition(t)}else d=n;d=mC(d);for(const h of[...o.getChildren()])PC(h)&&(d=c.move(c.createRangeOn(h),d).end,gC(c,h,h.nextSibling),gC(c,h.previousSibling,h))}function PC(t){return t.is("element","ol")||t.is("element","ul")}var zC=r(9989),LC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(zC.Z,LC),zC.Z.locals;class OC extends Ss{static get pluginName(){return"ListEditing"}static get requires(){return[yf,Yp,AC]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data,n=t.editing;var o;t.model.document.registerPostFixer(e=>function(t,e){const n=t.document.differ.getChanges(),o=new Map;let i=!1;for(const c of n)if("insert"==c.type&&"listItem"==c.name)r(c.position);else if("insert"==c.type&&"listItem"!=c.name){if("$text"!=c.name){const n=c.position.nodeAfter;n.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",n),i=!0),n.hasAttribute("listType")&&(e.removeAttribute("listType",n),i=!0),n.hasAttribute("listStyle")&&(e.removeAttribute("listStyle",n),i=!0),n.hasAttribute("listReversed")&&(e.removeAttribute("listReversed",n),i=!0),n.hasAttribute("listStart")&&(e.removeAttribute("listStart",n),i=!0);for(const e of Array.from(t.createRangeIn(n)).filter(t=>t.item.is("element","listItem")))r(e.previousPosition)}r(c.position.getShiftedBy(c.length))}else"remove"==c.type&&"listItem"==c.name?r(c.position):("attribute"==c.type&&"listIndent"==c.attributeKey||"attribute"==c.type&&"listType"==c.attributeKey)&&r(c.range.start);for(const c of o.values())s(c),a(c);return i;function r(t){const e=t.nodeBefore;if(e&&e.is("element","listItem")){let t=e;if(o.has(t))return;for(let e=t.previousSibling;e&&e.is("element","listItem");e=t.previousSibling)if(t=e,o.has(t))return;o.set(e,t)}else{const e=t.nodeAfter;e&&e.is("element","listItem")&&o.set(e,e)}}function s(t){let n=0,o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(r>n){let s;null===o?(o=r-n,s=n):(o>r&&(o=r),s=r-o),e.setAttribute("listIndent",s,t),i=!0}else o=null,n=t.getAttribute("listIndent")+1;t=t.nextSibling}}function a(t){let n=[],o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(o&&o.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const o=n[r];t.getAttribute("listType")!=o&&(e.setAttribute("listType",o,t),i=!0)}else n[r]=t.getAttribute("listType");o=t,t=t.nextSibling}}}(t.model,e)),n.mapper.registerViewToModelLength("li",RC),e.mapper.registerViewToModelLength("li",RC),n.mapper.on("modelToViewPosition",SC(n.view)),n.mapper.on("viewToModelPosition",(o=t.model,(t,e)=>{const n=e.viewPosition,i=n.parent,r=e.mapper;if("ul"==i.name||"ol"==i.name){if(n.isAtEnd){const t=r.toModelElement(n.nodeBefore),i=r.getModelLength(n.nodeBefore);e.modelPosition=o.createPositionBefore(t).getShiftedBy(i)}else{const t=r.toModelElement(n.nodeAfter);e.modelPosition=o.createPositionBefore(t)}t.stop()}else if("li"==i.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(i);let a=1,c=n.nodeBefore;for(;c&&PC(c);)a+=r.getModelLength(c),c=c.previousSibling;e.modelPosition=o.createPositionBefore(s).getShiftedBy(a),t.stop()}})),e.mapper.on("modelToViewPosition",SC(n.view)),t.conversion.for("editingDowncast").add(e=>{e.on("insert",xC,{priority:"high"}),e.on("insert:listItem",CC(t.model)),e.on("attribute:listType:listItem",vC,{priority:"high"}),e.on("attribute:listType:listItem",yC,{priority:"low"}),e.on("attribute:listIndent:listItem",function(t){return(e,n,o)=>{if(!o.consumable.consume(n.item,"attribute:listIndent"))return;const i=o.mapper.toViewElement(n.item),r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&gC(r,a,a.nextSibling),BC(n.attributeOldValue+1,n.range.start,c.start,i,o,t),uC(n.item,i,o,t);for(const t of n.item.getChildren())o.consumable.consume(t,"insert")}}(t.model)),e.on("remove:listItem",function(t){return(e,n,o)=>{const i=o.mapper.toViewPosition(n.position).getLastMatchingPosition(t=>!t.item.is("element","li")).nodeAfter,r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&gC(r,a,a.nextSibling),BC(o.mapper.toModelElement(i).getAttribute("listIndent")+1,n.position,c.start,i,o,t);for(const t of r.createRangeIn(l).getItems())o.mapper.unbindViewElement(t);e.stop()}}(t.model)),e.on("remove",EC,{priority:"low"})}),t.conversion.for("dataDowncast").add(e=>{e.on("insert",xC,{priority:"high"}),e.on("insert:listItem",CC(t.model))}),t.conversion.for("upcast").add(t=>{t.on("element:ul",TC,{priority:"high"}),t.on("element:ol",TC,{priority:"high"}),t.on("element:li",IC,{priority:"high"}),t.on("element:li",DC)}),t.model.on("insertContent",MC,{priority:"high"}),t.commands.add("numberedList",new aC(t,"numbered")),t.commands.add("bulletedList",new aC(t,"bulleted")),t.commands.add("indentList",new dC(t,"forward")),t.commands.add("outdentList",new dC(t,"backward"));const i=n.view.document;this.listenTo(i,"enter",(t,e)=>{const n=this.editor.model.document,o=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==o.name&&o.isEmpty&&(this.editor.execute("outdentList"),e.preventDefault(),t.stop())},{context:"li"}),this.listenTo(i,"delete",(t,e)=>{if("backward"!==e.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const o=n.getFirstPosition();if(!o.isAtStart)return;const i=o.parent;"listItem"===i.name&&(i.previousSibling&&"listItem"===i.previousSibling.name||(this.editor.execute("outdentList"),e.preventDefault(),t.stop()))},{context:"li"}),this.listenTo(t.editing.view.document,"tab",(e,n)=>{const o=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(o).isEnabled&&(t.execute(o),n.stopPropagation(),n.preventDefault(),e.stop())},{context:"li"})}afterInit(){const t=this.editor.commands,e=t.get("indent"),n=t.get("outdent");e&&e.registerChildCommand(t.get("indentList")),n&&n.registerChildCommand(t.get("outdentList"))}}function RC(t){let e=1;for(const n of t.getChildren())if("ul"==n.name||"ol"==n.name)for(const t of n.getChildren())e+=RC(t);return e}class jC extends Ss{static get pluginName(){return"ListUI"}init(){const t=this.editor.t;fC(this.editor,"numberedList",t("Numbered List"),''),fC(this.editor,"bulletedList",t("Bulleted List"),'')}}function FC(t,e){return t=>{t.on("attribute:url:media",n)};function n(n,o,i){if(!i.consumable.consume(o.item,n.name))return;const r=o.attributeNewValue,s=i.writer,a=i.mapper.toViewElement(o.item),c=[...a.getChildren()].find(t=>t.getCustomProperty("media-content"));s.remove(c);const l=t.getMediaViewElement(s,r,e);s.insert(s.createPositionAt(a,0),l)}}function VC(t,e,n,o){return t.createContainerElement("figure",{class:"media"},[e.getMediaViewElement(t,n,o),t.createSlot()])}function HC(t){const e=t.getSelectedElement();return e&&e.is("element","media")?e:null}function UC(t,e,n,o){t.change(i=>{const r=i.createElement("media",{url:e});t.insertObject(r,n,null,{setSelection:"on",findOptimalPosition:o})})}class GC extends Ns{refresh(){const t=this.editor.model,e=t.document.selection,n=HC(e);this.value=n?n.getAttribute("url"):null,this.isEnabled=function(t){const e=t.getSelectedElement();return!!e&&"media"===e.name}(e)||function(t,e){const n=Lk(t,e);let o=n.start.parent;return o.isEmpty&&!e.schema.isLimit(o)&&(o=o.parent),e.schema.checkChild(o,"media")}(e,t)}execute(t){const e=this.editor.model,n=e.document.selection,o=HC(n);o?e.change(e=>{e.setAttribute("url",t,o)}):UC(e,t,n,!0)}}class qC{constructor(t,e){const n=e.providers,o=e.extraProviders||[],i=new Set(e.removeProviders),r=n.concat(o).filter(t=>{const e=t.name;return e?!i.has(e):(E("media-embed-no-provider-name",{provider:t}),!1)});this.locale=t,this.providerDefinitions=r}hasMedia(t){return!!this._getMedia(t)}getMediaViewElement(t,e,n){return this._getMedia(e).getViewElement(t,n)}_getMedia(t){if(!t)return new WC(this.locale);t=t.trim();for(const e of this.providerDefinitions){const n=e.html,o=hr(e.url);for(const e of o){const o=this._getUrlMatches(t,e);if(o)return new WC(this.locale,t,o,n)}}return null}_getUrlMatches(t,e){let n=t.match(e);if(n)return n;let o=t.replace(/^https?:\/\//,"");return n=o.match(e),n||(o=o.replace(/^www\./,""),n=o.match(e),n||null)}}class WC{constructor(t,e,n,o){this.url=this._getValidUrl(e),this._locale=t,this._match=n,this._previewRenderer=o}getViewElement(t,e){const n={};let o;if(e.renderForEditingView||e.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(n["data-oembed-url"]=this.url),e.renderForEditingView&&(n.class="ck-media__wrapper");const i=this._getPreviewHtml(e);o=t.createRawElement("div",n,(t,e)=>{e.setContentOf(t,i)})}else this.url&&(n.url=this.url),o=t.createEmptyElement(e.elementName,n);return t.setCustomProperty("media-content",!0,o),o}_getPreviewHtml(t){return this._previewRenderer?this._previewRenderer(this._match):this.url&&t.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const t=new ns,e=this._locale.t;return t.content='',t.viewBox="0 0 64 42",new Nr({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[t]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":e("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(t){return t?t.match(/^https?/)?t:"https://"+t:null}}var YC=r(952),KC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(YC.Z,KC),YC.Z.locals;class $C extends Ss{static get pluginName(){return"MediaEmbedEditing"}constructor(t){super(t),t.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:t=>``},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:t=>``},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:t=>{const e=t[1],n=t[2];return``}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:t=>``},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.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 qC(t.locale,t.config.get("mediaEmbed"))}init(){const t=this.editor,e=t.model.schema,n=t.t,o=t.conversion,i=t.config.get("mediaEmbed.previewsInData"),r=t.config.get("mediaEmbed.elementName"),s=this.registry;t.commands.add("mediaEmbed",new GC(t)),e.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),o.for("dataDowncast").elementToStructure({model:"media",view:(t,{writer:e})=>{const n=t.getAttribute("url");return VC(e,s,n,{elementName:r,renderMediaPreview:n&&i})}}),o.for("dataDowncast").add(FC(s,{elementName:r,renderMediaPreview:i})),o.for("editingDowncast").elementToStructure({model:"media",view:(t,{writer:e})=>{const o=t.getAttribute("url");return function(t,e,n){return e.setCustomProperty("media",!0,t),Mk(t,e,{label:n})}(VC(e,s,o,{elementName:r,renderForEditingView:!0}),e,n("media widget"))}}),o.for("editingDowncast").add(FC(s,{elementName:r,renderForEditingView:!0})),o.for("upcast").elementToElement({view:t=>["oembed",r].includes(t.name)&&t.getAttribute("url")?{name:!0}:null,model:(t,{writer:e})=>{const n=t.getAttribute("url");if(s.hasMedia(n))return e.createElement("media",{url:n})}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(t,{writer:e})=>{const n=t.getAttribute("data-oembed-url");if(s.hasMedia(n))return e.createElement("media",{url:n})}}).add(t=>{t.on("element:figure",(function(t,e,n){if(!n.consumable.consume(e.viewItem,{name:!0,classes:"media"}))return;const{modelRange:o,modelCursor:i}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=o,e.modelCursor=i,kr(o.getItems())||n.consumable.revert(e.viewItem,{name:!0,classes:"media"})}))})}}const QC=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class ZC extends Ss{static get requires(){return[pb,Yp,Mb]}static get pluginName(){return"AutoMediaEmbed"}constructor(t){super(t),this._timeoutId=null,this._positionToInsert=null}init(){const t=this.editor,e=t.model.document;this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",()=>{const t=e.selection.getFirstRange(),n=qu.fromPosition(t.start);n.stickiness="toPrevious";const o=qu.fromPosition(t.end);o.stickiness="toNext",e.once("change:data",()=>{this._embedMediaBetweenPositions(n,o),n.detach(),o.detach()},{priority:"high"})}),t.commands.get("undo").on("execute",()=>{this._timeoutId&&(Di.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedMediaBetweenPositions(t,e){const n=this.editor,o=n.plugins.get($C).registry,i=new ch(t,e),r=i.getWalker({ignoreElementEnd:!0});let s="";for(const a of r)a.item.is("$textProxy")&&(s+=a.item.data);s=s.trim(),s.match(QC)&&o.hasMedia(s)&&n.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=qu.fromPosition(t),this._timeoutId=Di.window.setTimeout(()=>{n.model.change(t=>{let e;this._timeoutId=null,t.remove(i),i.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(e=this._positionToInsert),UC(n.model,s,e,!1),this._positionToInsert.detach(),this._positionToInsert=null}),n.plugins.get("Delete").requestUndoOnBackspace()},100)):i.detach()}}var JC=r(3525),XC={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};Tr()(JC.Z,XC),JC.Z.locals;class tv extends Mr{constructor(t,e){super(e);const n=e.t;this.focusTracker=new br,this.keystrokes=new wr,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),cm.check,"ck-button-save"),this.saveButtonView.type="submit",this.saveButtonView.bind("isEnabled").to(this,"mediaURLInputValue",t=>!!t),this.cancelButtonView=this._createButton(n("Cancel"),cm.cancel,"ck-button-cancel","cancel"),this._focusables=new Er,this._focusCycler=new xs({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=t,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]}),i(this)}render(){super.render(),a({view:this}),[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element);const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t),this.listenTo(this.urlInputView.element,"selectstart",(t,e)=>{e.stopPropagation()},{priority:"high"})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(t){this.urlInputView.fieldView.element.value=t.trim()}isValid(){this.resetFormStatus();for(const t of this._validators){const e=t(this);if(e)return this.urlInputView.errorText=e,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const t=this.locale.t,e=new lp(this.locale,dp),n=e.fieldView;return this._urlInputViewInfoDefault=t("Paste the media URL in the input."),this._urlInputViewInfoTip=t("Tip: Paste the URL into the content to embed faster."),e.label=t("Media URL"),e.infoText=this._urlInputViewInfoDefault,n.on("input",()=>{e.infoText=n.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=n.element.value.trim()}),e}_createButton(t,e,n,o){const i=new rs(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}}class ev extends Ss{static get requires(){return[$C]}static get pluginName(){return"MediaEmbedUI"}init(){const t=this.editor,e=t.commands.get("mediaEmbed");t.ui.componentFactory.add("mediaEmbed",t=>{const n=Em(t);return this._setUpDropdown(n,e),n})}_setUpDropdown(t,e){const n=this.editor,o=n.t,i=t.buttonView,r=n.plugins.get($C).registry;t.once("change:isOpen",()=>{const o=new tv(function(t,e){return[e=>{if(!e.url.length)return t("The URL must not be empty.")},n=>{if(!e.hasMedia(n.url))return t("This media URL is not supported.")}]}(n.t,r),n.locale);t.panelView.children.add(o),i.on("open",()=>{o.disableCssTransitions(),o.url=e.value||"",o.urlInputView.fieldView.select(),o.enableCssTransitions()},{priority:"low"}),t.on("submit",()=>{o.isValid()&&(n.execute("mediaEmbed",o.url),n.editing.view.focus())}),t.on("change:isOpen",()=>o.resetFormStatus()),t.on("cancel",()=>{n.editing.view.focus()}),o.delegate("submit","cancel").to(t),o.urlInputView.bind("value").to(e,"value"),o.urlInputView.bind("isReadOnly").to(e,"isEnabled",t=>!t)}),t.bind("isEnabled").to(e),i.set({label:o("Insert media"),icon:'',tooltip:!0})}}var nv=r(5777),ov={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};function iv(t,e,n,{blockElements:o,inlineObjectElements:i}){let r=n.createPositionAt(t,"forward"==e?"after":"before");return r=r.getLastMatchingPosition(({item:t})=>t.is("element")&&!o.includes(t.name)&&!i.includes(t.name),{direction:e}),"forward"==e?r.nodeAfter:r.nodeBefore}function rv(t,e){return!!t&&t.is("element")&&e.includes(t.name)}function sv(t,e){if(!t.childCount)return;const n=new Lg(t.document),o=function(t,e){const n=e.createRangeIn(t),o=new Js({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),i=[];for(const r of n)if("elementStart"===r.type&&o.match(r.item)){const t=lv(r.item);i.push({element:r.item,id:t.id,order:t.order,indent:t.indent})}return i}(t,n);if(!o.length)return;let i=null,r=1;o.forEach((t,s)=>{const a=function(t,e){if(!t)return!0;if(t.id!==e.id)return e.indent-t.indent!=1;const n=e.element.previousSibling;return!n||(o=n,!(o.is("element","ol")||o.is("element","ul")));var o}(o[s-1],t),c=a?null:o[s-1],l=(h=t,(d=c)?h.indent-d.indent:h.indent-1);var d,h;if(a&&(i=null,r=1),!i||0!==l){const o=function(t,e){const n=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),o=/mso-level-number-format:([^;]{0,100});/gi,i=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(e);let s="decimal",a="ol",c=null;if(r&&r[1]){const e=o.exec(r[1]);if(e&&e[1]&&(s=e[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const e=function(t){const e=function(t){if(t.getChild(0).is("$text"))return null;for(const e of t.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);return t.is("$text")?t:t.getChild(0)}return null}(t);if(!e)return null;const n=e._data;return"o"===n?"circle":"·"===n?"disc":"§"===n?"square":null}(t.element);e&&(s=e)}else{const t=i.exec(r[1]);t&&t[1]&&(c=parseInt(t[1]))}}return{type:a,startIndex:c,style:av(s)}}(t,e);if(i){if(t.indent>r){const t=i.getChild(i.childCount-1),e=t.getChild(t.childCount-1);i=cv(o,e,n),r+=1}else if(t.indent1&&n.setAttribute("start",t.startIndex,i),i}function lv(t){const e={},n=t.getStyle("mso-list");if(n){const t=n.match(/(^|\s{1,100})l(\d+)/i),o=n.match(/\s{0,100}lfo(\d+)/i),i=n.match(/\s{0,100}level(\d+)/i);t&&o&&i&&(e.id=t[2],e.order=o[1],e.indent=parseInt(i[1]))}return e}Tr()(nv.Z,ov),nv.Z.locals;const dv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class hv{constructor(t){this.document=t}isActive(t){return dv.test(t)}execute(t){const e=new Lg(this.document),{body:n}=t._parsedData;!function(t,e){for(const n of t.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const o=t.getChildIndex(n);e.remove(n),e.insertChild(o,n.getChildren(),t)}}(n,e),function(t,e){for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","li")){const n=t.getChild(0);n&&n.is("element","p")&&e.unwrapElement(n)}}}(n,e),function(t,e){const n=new yc(e.document.stylesProcessor),o=new pl(n,{renderingMode:"data"}),i=o.blockElements,r=o.inlineObjectElements,s=[];for(const a of e.createRangeIn(t)){const t=a.item;if(t.is("element","br")){const n=iv(t,"forward",e,{blockElements:i,inlineObjectElements:r}),o=iv(t,"backward",e,{blockElements:i,inlineObjectElements:r}),a=rv(n,i);(rv(o,i)||a)&&s.push(t)}}for(const a of s)a.hasClass("Apple-interchange-newline")?e.remove(a):e.replace(a,e.createElement("p"))}(n,e),t.content=n}}function uv(t,e){if(!t.childCount)return;const n=new Lg(t.document),o=function(t,e){const n=e.createRangeIn(t),o=new Js({name:/v:(.+)/}),i=[];for(const r of n){if("elementStart"!=r.type)continue;const t=r.item,e=t.previousSibling,n=e&&e.is("element")?e.name:null;o.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==n&&i.push(r.item.getAttribute("id"))}return i}(t,n);!function(t,e,n){const o=n.createRangeIn(e),i=new Js({name:"img"}),r=[];for(const s of o)if(s.item.is("element")&&i.match(s.item)){const e=s.item,n=e.getAttribute("v:shapes")?e.getAttribute("v:shapes").split(" "):[];n.length&&n.every(e=>t.indexOf(e)>-1)?r.push(e):e.getAttribute("src")||r.push(e)}for(const s of r)n.remove(s)}(o,t,n),function(t,e,n){const o=n.createRangeIn(e),i=[];for(const a of o)if("elementStart"==a.type&&a.item.is("element","v:shape")){const e=a.item.getAttribute("id");if(t.includes(e))continue;r(a.item.parent.getChildren(),e)||i.push(a.item)}for(const a of i){const t={src:s(a)};a.hasAttribute("alt")&&(t.alt=a.getAttribute("alt"));const e=n.createElement("img",t);n.insertChild(a.index+1,e,a.parent)}function r(t,e){for(const n of t)if(n.is("element")){if("img"==n.name&&n.getAttribute("v:shapes")==e)return!0;if(r(n.getChildren(),e))return!0}return!1}function s(t){for(const e of t.getChildren())if(e.is("element")&&e.getAttribute("src"))return e.getAttribute("src")}}(o,t,n),function(t,e){const n=e.createRangeIn(t),o=new Js({name:/v:(.+)/}),i=[];for(const r of n)"elementStart"==r.type&&o.match(r.item)&&i.push(r.item);for(const r of i)e.remove(r)}(t,n);const i=function(t,e){const n=e.createRangeIn(t),o=new Js({name:"img"}),i=[];for(const r of n)r.item.is("element")&&o.match(r.item)&&r.item.getAttribute("src").startsWith("file://")&&i.push(r.item);return i}(t,n);i.length&&function(t,e,n){if(t.length===e.length)for(let o=0;oString.fromCharCode(parseInt(t,16))).join(""))}const mv=//i,pv=/xmlns:o="urn:schemas-microsoft-com/i;class fv{constructor(t){this.document=t}isActive(t){return mv.test(t)||pv.test(t)}execute(t){const{body:e,stylesString:n}=t._parsedData;sv(e,n),uv(e,t.dataTransfer.getData("text/rtf")),t.content=e}}function kv(t){return t.replace(/(\s+)<\/span>/g,(t,e)=>1===e.length?" ":Array(e.length+1).join(" ").substr(0,e.length))}function bv(t,e){const n=new DOMParser,o=function(t){return kv(kv(t)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(t){const e="",n="